Skip to content

change build system to esbuild and add rdflib.js #209

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 8 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
100 changes: 100 additions & 0 deletions esbuild.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
#!/usr/bin/env node
const path = require('path');
const fs = require('fs');
const esbuild = require('esbuild');
const pkg = require('./package.json');

const outdir = path.join(__dirname, 'deploy/');
const static_files = {'./src/index.html' : '',
'./src/favicon.ico' : '',
'./src/app/data/benchmark.json' : 'data',
'./src/app/data/foaf.json' : 'data',
'./src/app/data/goodrelations.json' : 'data',
'./src/app/data/muto.json' : 'data',
'./src/app/data/new_ontology.json' : 'data',
'./src/app/data/ontovibe.json' : 'data',
'./src/app/data/personasonto.json' : 'data',
'./src/app/data/sioc.json' : 'data',
'./src/app/data/template.json' : 'data'
};

const options = {
bundle: true,
outdir: outdir,
external: ['d3'],
minify: false,
sourcemap: true,
// target: 'es2015',
format:'iife',
platform: 'browser',
entryNames: '[ext]/[name]',
plugins: [{
name: 'watch',
setup({ onEnd }) {
onEnd((ret) => {
})
}
}]
};

function copy_static_file(file) {
const p = path.join(__dirname, file);
var data = fs.readFileSync(p)
if(file.endsWith('index.html'))
data = data.toString('utf8').replaceAll('<%= version %>', pkg.version);
const foutDir = path.join(outdir, static_files[file]);
try { fs.mkdirSync(foutDir, 0775); } catch(e) {}
fs.writeFileSync(path.join(foutDir, path.basename(p)), data);
}

function copy_static() {
for(var file in static_files) copy_static_file(file);
}

function watch_static() {
try { fs.mkdirSync(outdir, 0775); } catch(e) {}
for(var file in static_files) {
(function (f) {
fs.watchFile(path.join(__dirname, f), {
bigint: false,
persistent: true,
interval: 1000,
}, () => {
copy_static_file(f);
});
})(file);
}
console.log('watching...');
}

function build(opt) {
esbuild.context(Object.assign(opt, options))
.then((r) => {
r.watch();
console.log('watching...');
}).catch(() => process.exit(1));
}

copy_static();
watch_static();

build({
entryPoints: {
'js/webvowl': './src/webvowl/js/entry.js'
},
globalName: 'webvowl'
});

build({
entryPoints: {
'js/webvowl.app': './src/app/js/entry.js'
},
globalName: 'webvowl.app'
});

build({
entryPoints: {
'js/d3.min' : './node_modules/d3/d3.min.js'
},
globalName: 'd3'
});
46 changes: 5 additions & 41 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,49 +3,13 @@
"version": "1.1.7",
"dependencies": {
"d3": "^3.5.6",
"grunt-cli": "^1.3.2",
"lodash": "^4.1.0"
},
"devDependencies": {
"connect-livereload": "^0.6.0",
"copy-webpack-plugin": "^4.0.1",
"css-loader": "^0.26.0",
"extract-text-webpack-plugin": "^1.0.1",
"grunt": "^1.0.1",
"grunt-bump": "^0.8.0",
"grunt-contrib-clean": "^1.0.0",
"grunt-contrib-compress": "^1.2.0",
"grunt-contrib-connect": "^1.0.1",
"grunt-contrib-copy": "^1.0.0",
"grunt-contrib-jshint": "^1.0.0",
"grunt-contrib-watch": "^1.0.0",
"grunt-gitinfo": "^0.1.8",
"grunt-html-build": "^0.6.0",
"grunt-karma": "^2.0.0",
"grunt-replace": "^1.0.1",
"grunt-webpack": "^1.0.11",
"jasmine-core": "^2.2.0",
"karma": "^1.3.0",
"karma-commonjs": "^1.0.0",
"karma-jasmine": "^1.0.2",
"karma-phantomjs-launcher": "^1.0.0",
"karma-spec-reporter": "0.0.26",
"karma-webpack": "^1.7.0",
"load-grunt-tasks": "^3.2.0",
"phantomjs-prebuilt": "^2.1.4",
"serve-favicon": "^2.3.0",
"serve-static": "^1.10.0",
"style-loader": "^0.13.0",
"webpack": "^1.12.0",
"webpack-dev-server": "^1.12.0"
"lodash": "^4.1.0",
"rdflib": "^2.2.37"
},
"scripts": {
"postinstall": "grunt release",
"package": "grunt package",
"release": "grunt release",
"test": "grunt test-ci",
"webserver": "grunt webserver"
},
"release": "./esbuild.js release",
"debug": "./esbuild.js debug"
},
"license": "MIT",
"private": true
}
20 changes: 20 additions & 0 deletions parser_test/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Node.js dependencies
node_modules

# IntelliJ files
*.iml
.idea/

# Eclipse files
.project
.classpath

# Build files
deploy/**
!deploy/.htaccess
webvowl*.zip

# NetBeans files
**/nbproject/**

package-lock.json
52 changes: 52 additions & 0 deletions parser_test/browser_runner.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<script src="node_modules/diff/dist/diff.min.js"></script>
<script src="node_modules/rdflib/dist/rdflib.min.js"></script>
<script>
window.onload = () => {
(async () => {
let web = await import("./web_parser.js");
web.init();

let test = {
"file":"data/sioc.rdf",
"compare":"sorted_data/sioc_sorted.json",
"baseIri": "http://rdfs.org/sioc/ns#",
"iriMap": {
}
};

async function getData(file) {
const response = await fetch(file);
if (!response.ok)
throw new Error("cannot fetch file: " + file);
return await response.text();
}

try {
const ext = test.file.substr(test.file.lastIndexOf(".") + 1);
const data = await getData(test.file);
const compare = await getData(test.compare);
var result = await parser.transform(data, test.baseIri, parser.MimeExtMap[test], test.iriMap);
result._comment = "Created with OWL2VOWL (version 0.3.7), http://vowl.visualdataweb.org";
const diff = Diff.structuredPatch("parsed", "orig", JSON.stringify(sorter.sort(result), null, 2).trim(), compare.trim());
if(diff.hunks.length)
throw new Error(Diff.formatPatch(diff));
console.log(test.file + ": ok");
} catch(err){
console.log("test for " + test.file + " failed with:");
console.log(err.message);
}
})();




}

</script>
</head>
<body></body>
</html>
Loading