Commit ac85698e authored by Moises Sacal's avatar Moises Sacal
Browse files

Update uuidv4 and package.json

parent aabab228
......@@ -153,15 +153,15 @@ async function generateHTML(metadataPath) {
if (!root.isPartOf && parentRoot.identifier) {
root.isPartOf = parentRoot.identifier;
}
}
const preview = await new Preview(crate);
const f = new HtmlFile(preview);
const f = new HtmlFile(preview);
fs.writeFileSync(path.join(dir, htmlFileName),
await f.render(program.cratescript));
if (program.bag) {
var bagger = new Bag();
......@@ -178,7 +178,7 @@ async function generateHTML(metadataPath) {
metadata_path = path.join(dir, metadata_file_name);
const index = await fs.copyFile(path.join(__dirname, "defaults", "index.html"), path.join(dest, "index.html"));
//bagger.update();
if (program.zip){
var zipname = path.resolve(path.join(program.bag, path.basename(path.dirname(metadataPath)).replace(" ","_") + ".zip"));
console.log('Zipping to', zipname)
......@@ -187,6 +187,6 @@ async function generateHTML(metadataPath) {
shell.exec(`zip -r "${zipname}" *`);
}
}
}
\ No newline at end of file
}
......@@ -27,7 +27,7 @@ var RoCrate = rocrate.ROCrate;
const Property = require("./property.js");
const Item = require("./item.js");
const uuidv4 = require("uuid/v4");
const { v4: uuidV4 } = require('uuid');
const shell = require("shelljs");
var fs = require('fs');
......@@ -92,7 +92,7 @@ module.exports = function() {
json["@context"] = defaults.context;
fs.writeFileSync("test.jsonld", JSON.stringify(json, null, 2));
defaults.context.push(collection.extraContext)
var promise = promises.flatten(json, defaults.context);
var promise = promises.flatten(json, defaults.context);
return promise;
}
......@@ -117,11 +117,11 @@ module.exports = function() {
id = String(id);
if (id.match(/^https?:\/\//i)){
return id;
}
}
else {
return id;
}
},
},
add_id: function(item) {
var id = this.make_id(item.id);
this.id_lookup[id] = item;
......@@ -187,7 +187,7 @@ module.exports = function() {
this.collection_metadata = new Item();
}
var collection_json = this.collection_metadata.to_json_ld_fragment();
graph.push(collection_json);
//console.log("COLLECTION METADATA", json);
......@@ -231,7 +231,7 @@ module.exports = function() {
});
}
},
to_json_ld: function to_json_ld() {
// Turn the entire collection into a JSON-LD document
this.crate = new RoCrate();
......@@ -367,8 +367,8 @@ module.exports = function() {
process.exit(1);
}
//console.log("FILES", JSON.stringify(this.file_info.files, null, 2));
this.file_info_by_filename = {};
for (var i = 0; i < this.file_info.files.length; i++) {
......@@ -386,7 +386,7 @@ module.exports = function() {
sheet_names = this.workbook.SheetNames;
for (var i = 0; i < sheet_names.length; i++) {
sheet_name = sheet_names[i];
var sheet = this.workbook.Sheets[sheet_name];
//console.log(sheet_name);
......@@ -437,7 +437,7 @@ module.exports = function() {
//console.log(XLSX.utils.sheet_to_json(this.workbook.Sheets['Files']));
get_metadata(this.workbook, this, "Files");
//console.log("got metadata");
} else if (sheet_name == "@context") {
extra_context = XLSX.utils.sheet_to_json(
this.workbook.Sheets["@context"]
......
......@@ -21,7 +21,7 @@ var XLSX = require("xlsx");
var path = require("path");
const context = require("../defaults/context.json");
const metadata_property_name = require("./property.js");
const uuidv4 = require("uuid/v4");
const { v4: uuidV4 } = require('uuid');
const ejs = require("ejs");
const jsonld = require("../lib/jsonldhelper.js");
......@@ -79,7 +79,7 @@ module.exports = function() {
if (f.is_type) {
types = f.data; //Don't output now
} else if (f.name != "ID") {
frag[f.name] = [];
if (!Array.isArray(f.data)) {
f.data = [f.data];
......@@ -89,7 +89,7 @@ module.exports = function() {
? f.links_to
: links_to_id(f.data[k], this.collection);
if (f.is_file) {
this.is_file = true;
//types.push("schema:MediaObject");
......@@ -149,11 +149,11 @@ module.exports = function() {
} else if (property.is_type) {
this.types = this.types.concat(property.data);
}
// Add to lookup table
if (!this.id) {
this.id = "#" + uuidv4();
}
}
//console.log(this.name)
if (this.name) {
//console.log("Adding name", this.name)
......@@ -168,7 +168,7 @@ module.exports = function() {
var nest_this_item = new module.exports();
nest_this_item.load_json(nested_json, this.collection);
this.nested_items[property.name] = nest_this_item;
}
} else {
this.properties[property.name] = property;
......@@ -203,7 +203,7 @@ module.exports = function() {
"http://www.nationalarchives.gov.uk/PRONOM/" + id
);
this.properties[pronom.name] = pronom;
}
}
var name_prop = new metadata_property_name();
name_prop.parse("encodingFormat", file_info.matches[0].format);
......
......@@ -26,19 +26,19 @@ var defaults = require("./defaults.js");
class jsonldHelper {
constructor () {
}
flatten(){
var promises = jsonld.promises;
var promise = promises.flatten(json, defaults.context); //require("../defaults/context.json")); //,
return promise.then(
(flattened) => {
(flattened) => {
this.init(flattened);
this.trim_context();
});
});
}
reference_to_item(node) {
// Check if node is a reference to something else
// If it is, return the something else
......@@ -81,7 +81,7 @@ class jsonldHelper {
this.items_by_new_id = {}
this.graph = this.json_ld["@graph"];
/*
USed to do this -
USed to do this -
if (!this.json_ld["@context"]) {
this.json_ld["@context"] = defaults.default_context;
}
......@@ -120,15 +120,15 @@ class jsonldHelper {
val["@id"] = this.item_by_id[val["@id"]]["@id"];
}
}
}
}
}
}
}
get_name(node){
if (!node || !node["name"]) {
return;
}
var name = "";
}
var name = "";
for (var n of this.value_as_array(node["name"])){
if (n["@value"]) {
name += n["@value"];
......@@ -137,7 +137,7 @@ class jsonldHelper {
} else {
name += n;
}
return name;
}
}
......@@ -145,7 +145,7 @@ class jsonldHelper {
for (let key of Object.keys(item)) {
if (key != "@id" && key != "@reverse") {
for (let part of this.value_as_array(item[key])) {
var target = this.reference_to_item(part);
var back_link = defaults.back_links[key];
// Dealing with one of the known stuctural properties
......@@ -184,7 +184,7 @@ class jsonldHelper {
}
add_back_links() {
// Add @reverse properties if not there
for (let item of this.json_ld["@graph"]){
this.make_back_links(item);
......
......@@ -122,9 +122,9 @@ module.exports = function() {
console.log(name, this.is_repeating, this.is_relational)
this.property_URI = get_RDF_for_column(this.name);
if (this.property_URI == "http://schema.org/name") {
this.is_name = true;
......@@ -141,7 +141,7 @@ module.exports = function() {
} else if (!Array.isArray(this.data)) {
this.data = [this.data];
}
}
}
};
......
......@@ -2,7 +2,7 @@
"name": "calcyte",
"version": "1.0.10",
"description": "Calcyte is a command-line tool and set of libraries for creating and managing DataCrate data packages",
"main": "calcyfy",
"main": "lib/defauts.js",
"bin": {
"calcyfy": "./calcyfy"
},
......@@ -38,7 +38,7 @@
"shelljs": "^0.8.3",
"tmp": "0.0.33",
"uri-js": "^4.2.2",
"uuid": "latest",
"uuid": "^8.3.2",
"xlsx": "^0.11.19",
"xmlbuilder": "^9.0.7",
"xmlhttprequest": "^1.8.0"
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment