From 3e68e3d7a4062993bb348c90119926465b542da9 Mon Sep 17 00:00:00 2001 From: Simon Van Braeckel Date: Thu, 19 Sep 2024 16:02:14 +0200 Subject: [PATCH 01/14] Make yarn-run-dev not move queries.json to build folder --- bin/generate.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/bin/generate.js b/bin/generate.js index 3fd372b..c49114c 100755 --- a/bin/generate.js +++ b/bin/generate.js @@ -82,4 +82,7 @@ if (args.h || args.help || args._.length > 1) { fs.unlinkSync('.tmp-comunica-engine.js'); }); + if (fs.existsSync(path.join(process.cwd(), 'queries.json'))) { + fs.renameSync(path.join(process.cwd(), 'queries.json'), path.join(process.cwd(), `${destinationPath}/queries.json`)); + }; })(); From 3d2aefd6bf95e7ecfe116bc45ef19282b1c15141 Mon Sep 17 00:00:00 2001 From: Simon Van Braeckel Date: Thu, 19 Sep 2024 20:02:19 +0200 Subject: [PATCH 02/14] Delete queries.json config linefor build configuration --- bin/generate.js | 16 ++++++++++++---- package.json | 2 +- webpack.config.js | 2 +- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/bin/generate.js b/bin/generate.js index c49114c..3b184ff 100755 --- a/bin/generate.js +++ b/bin/generate.js @@ -50,22 +50,29 @@ if (args.h || args.help || args._.length > 1) { const settingsFile = args.s || path.join(__dirname, '..', 'settings.json'); const outputFile = 'queries.json'; compileSettings(queryDir, settingsFile, outputFile); - + // Compile Web version const destinationPath = args.d || 'build'; const mode = args.m || 'production'; const baseURL = args.b || 'https://query.linkeddatafragments.org/'; const webpackConfig = require(args.w ? path.resolve(process.cwd(), args.w) : '../webpack.config.js'); + // Remove the location of queries.json which shouldn't be present in the build configuration. + webpackConfig[0].entry=webpackConfig[0].entry.filter(x => !x.endsWith('queries.json')); + // Override the baseURL in the webpack config webpackConfig.baseURL.replace = baseURL; - + + // Override the buildContext in the webpack config + webpackConfig.buildContext.dir = destinationPath; + for (const entry of webpackConfig) { entry.mode = mode; if (entry.output) { entry.output.path = path.resolve(process.cwd(), destinationPath); } } + webpack(webpackConfig, (err, stats) => { if (err) { console.error(err.stack || err); @@ -74,14 +81,15 @@ if (args.h || args.help || args._.length > 1) { } process.exit(1); } - + console.error(stats.toString({ colors: true })); if (stats.hasErrors()) { process.exit(1); } - + fs.unlinkSync('.tmp-comunica-engine.js'); }); + if (fs.existsSync(path.join(process.cwd(), 'queries.json'))) { fs.renameSync(path.join(process.cwd(), 'queries.json'), path.join(process.cwd(), `${destinationPath}/queries.json`)); }; diff --git a/package.json b/package.json index f5e2cac..6c3d580 100644 --- a/package.json +++ b/package.json @@ -54,7 +54,7 @@ "lint": "eslint src/*.js", "dev-prod-ci": "comunica-compile-config config/config-default.json > .tmp-comunica-engine.js && ./bin/queries-to-json.js && webpack --config webpack.config.js --mode production", "dev-ci": "comunica-compile-config config/config-default.json > .tmp-comunica-engine.js && ./bin/queries-to-json.js && webpack --config webpack.config.js --mode development", - "dev-prod": "comunica-compile-config config/config-default.json > .tmp-comunica-engine.js && ./bin/queries-to-json.js && webpack serve --config webpack.config.js --mode production", + "dev-prod": "comunica-compile-config config/config-default.json > .tmp-comunica-engine.js && ./bin/queries-to-json.js && webpack serve --config webpack.config.dev.js --mode production", "dev": "comunica-compile-config config/config-default.json > .tmp-comunica-engine.js && ./bin/queries-to-json.js && webpack serve --config webpack.config.js --mode development", "build": "node ./bin/generate.js", "version": "manual-git-changelog onversion" diff --git a/webpack.config.js b/webpack.config.js index 15aa2d0..be85e24 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -41,7 +41,7 @@ module.exports = [ path.join(__dirname, './images/sparql.png'), path.join(__dirname, './favicon.ico'), path.join(__dirname, './solid-client-id.jsonld'), - path.join(process.cwd(), './queries.json'), + path.join(__dirname, './queries.json'), ], output: { filename: 'scripts/ldf-client-ui.min.js', From 039b728c270eab9550ca2af315168cb18cb87b1e Mon Sep 17 00:00:00 2001 From: Simon Van Braeckel Date: Thu, 19 Sep 2024 20:04:12 +0200 Subject: [PATCH 03/14] Cleanup --- bin/generate.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/bin/generate.js b/bin/generate.js index 3b184ff..08ede67 100755 --- a/bin/generate.js +++ b/bin/generate.js @@ -50,7 +50,7 @@ if (args.h || args.help || args._.length > 1) { const settingsFile = args.s || path.join(__dirname, '..', 'settings.json'); const outputFile = 'queries.json'; compileSettings(queryDir, settingsFile, outputFile); - + // Compile Web version const destinationPath = args.d || 'build'; const mode = args.m || 'production'; @@ -62,10 +62,10 @@ if (args.h || args.help || args._.length > 1) { // Override the baseURL in the webpack config webpackConfig.baseURL.replace = baseURL; - + // Override the buildContext in the webpack config webpackConfig.buildContext.dir = destinationPath; - + for (const entry of webpackConfig) { entry.mode = mode; if (entry.output) { @@ -81,12 +81,12 @@ if (args.h || args.help || args._.length > 1) { } process.exit(1); } - + console.error(stats.toString({ colors: true })); if (stats.hasErrors()) { process.exit(1); } - + fs.unlinkSync('.tmp-comunica-engine.js'); }); From e612c2685eab63cc66ff35e017e3116bc4762f15 Mon Sep 17 00:00:00 2001 From: Simon Van Braeckel Date: Sat, 28 Sep 2024 00:17:14 +0200 Subject: [PATCH 04/14] Use correct config for yarn dev-prod script --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 6c3d580..f5e2cac 100644 --- a/package.json +++ b/package.json @@ -54,7 +54,7 @@ "lint": "eslint src/*.js", "dev-prod-ci": "comunica-compile-config config/config-default.json > .tmp-comunica-engine.js && ./bin/queries-to-json.js && webpack --config webpack.config.js --mode production", "dev-ci": "comunica-compile-config config/config-default.json > .tmp-comunica-engine.js && ./bin/queries-to-json.js && webpack --config webpack.config.js --mode development", - "dev-prod": "comunica-compile-config config/config-default.json > .tmp-comunica-engine.js && ./bin/queries-to-json.js && webpack serve --config webpack.config.dev.js --mode production", + "dev-prod": "comunica-compile-config config/config-default.json > .tmp-comunica-engine.js && ./bin/queries-to-json.js && webpack serve --config webpack.config.js --mode production", "dev": "comunica-compile-config config/config-default.json > .tmp-comunica-engine.js && ./bin/queries-to-json.js && webpack serve --config webpack.config.js --mode development", "build": "node ./bin/generate.js", "version": "manual-git-changelog onversion" From fcfb7d8b7f09c2b6a76e035eeb5db33272d34cea Mon Sep 17 00:00:00 2001 From: Simon Van Braeckel Date: Fri, 11 Oct 2024 15:35:57 +0200 Subject: [PATCH 05/14] Test for CI --- bin/generate.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/generate.js b/bin/generate.js index 08ede67..9e50d3c 100755 --- a/bin/generate.js +++ b/bin/generate.js @@ -90,7 +90,7 @@ if (args.h || args.help || args._.length > 1) { fs.unlinkSync('.tmp-comunica-engine.js'); }); - if (fs.existsSync(path.join(process.cwd(), 'queries.json'))) { + if (fs.existsSync(path.join(process.cwd(), 'queries.json')) && fs.access(path.join(process.cwd(), 'build'))) { fs.renameSync(path.join(process.cwd(), 'queries.json'), path.join(process.cwd(), `${destinationPath}/queries.json`)); }; })(); From 5b44f4da1213f7d2690ddbfb42f27437cbf5e06e Mon Sep 17 00:00:00 2001 From: Simon Van Braeckel Date: Fri, 11 Oct 2024 15:41:39 +0200 Subject: [PATCH 06/14] Undo change, can't force CI to run on github --- bin/generate.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/generate.js b/bin/generate.js index 9e50d3c..08ede67 100755 --- a/bin/generate.js +++ b/bin/generate.js @@ -90,7 +90,7 @@ if (args.h || args.help || args._.length > 1) { fs.unlinkSync('.tmp-comunica-engine.js'); }); - if (fs.existsSync(path.join(process.cwd(), 'queries.json')) && fs.access(path.join(process.cwd(), 'build'))) { + if (fs.existsSync(path.join(process.cwd(), 'queries.json'))) { fs.renameSync(path.join(process.cwd(), 'queries.json'), path.join(process.cwd(), `${destinationPath}/queries.json`)); }; })(); From e97a6e851c0bad7d977f3d1f989532172036af16 Mon Sep 17 00:00:00 2001 From: Simon Van Braeckel Date: Wed, 6 Nov 2024 21:45:50 +0100 Subject: [PATCH 07/14] Add some debug output --- src/ldf-client-worker.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/ldf-client-worker.js b/src/ldf-client-worker.js index 86391b9..8e20cb7 100644 --- a/src/ldf-client-worker.js +++ b/src/ldf-client-worker.js @@ -20,6 +20,10 @@ const workerToWindowHandler = new WorkerToWindowHandler(self); function initEngine(config) { // Create an engine lazily + console.log("engine"); + console.log(engine); + console.log("require('my-comunica-engine')"); + console.log(require('my-comunica-engine')); if (!engine) engine = new QueryEngineBase(require('my-comunica-engine')()); @@ -44,8 +48,13 @@ var handlers = { // Create a client to fetch the fragments through HTTP config.context.log = logger; + console.log("config.query"); + console.log(config.query); + console.log("config.context"); + console.log(config.context); engine.query(config.query, config.context) .then(async function (result) { + console.log("then engine.query"); // Post query metadata postMessage({ type: 'queryInfo', queryType: result.resultType }); @@ -98,6 +107,7 @@ var handlers = { } } }).catch(postError); + console.log("2 post engine.query"); }, // Stop the execution of the current query From 8a7e47d3517cb329127314e2adb2b64ddb62a074 Mon Sep 17 00:00:00 2001 From: Simon Van Braeckel Date: Wed, 13 Nov 2024 21:58:25 +0100 Subject: [PATCH 08/14] remove obsolete addition to buildcontext --- bin/generate.js | 3 --- 1 file changed, 3 deletions(-) diff --git a/bin/generate.js b/bin/generate.js index 08ede67..06be033 100755 --- a/bin/generate.js +++ b/bin/generate.js @@ -63,9 +63,6 @@ if (args.h || args.help || args._.length > 1) { // Override the baseURL in the webpack config webpackConfig.baseURL.replace = baseURL; - // Override the buildContext in the webpack config - webpackConfig.buildContext.dir = destinationPath; - for (const entry of webpackConfig) { entry.mode = mode; if (entry.output) { From 19394a58f6373627d40aee36a622019c869609d6 Mon Sep 17 00:00:00 2001 From: Simon Van Braeckel Date: Wed, 13 Nov 2024 21:58:37 +0100 Subject: [PATCH 09/14] remove debug prints --- src/ldf-client-worker.js | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/src/ldf-client-worker.js b/src/ldf-client-worker.js index 8e20cb7..86391b9 100644 --- a/src/ldf-client-worker.js +++ b/src/ldf-client-worker.js @@ -20,10 +20,6 @@ const workerToWindowHandler = new WorkerToWindowHandler(self); function initEngine(config) { // Create an engine lazily - console.log("engine"); - console.log(engine); - console.log("require('my-comunica-engine')"); - console.log(require('my-comunica-engine')); if (!engine) engine = new QueryEngineBase(require('my-comunica-engine')()); @@ -48,13 +44,8 @@ var handlers = { // Create a client to fetch the fragments through HTTP config.context.log = logger; - console.log("config.query"); - console.log(config.query); - console.log("config.context"); - console.log(config.context); engine.query(config.query, config.context) .then(async function (result) { - console.log("then engine.query"); // Post query metadata postMessage({ type: 'queryInfo', queryType: result.resultType }); @@ -107,7 +98,6 @@ var handlers = { } } }).catch(postError); - console.log("2 post engine.query"); }, // Stop the execution of the current query From f3e2b3aa55e6320f7bff3a43e7701f023dd7d1f1 Mon Sep 17 00:00:00 2001 From: Simon Van Braeckel Date: Fri, 22 Nov 2024 19:15:30 +0100 Subject: [PATCH 10/14] copy queries.json from CWD to fix CI --- webpack.config.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/webpack.config.js b/webpack.config.js index be85e24..15aa2d0 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -41,7 +41,7 @@ module.exports = [ path.join(__dirname, './images/sparql.png'), path.join(__dirname, './favicon.ico'), path.join(__dirname, './solid-client-id.jsonld'), - path.join(__dirname, './queries.json'), + path.join(process.cwd(), './queries.json'), ], output: { filename: 'scripts/ldf-client-ui.min.js', From 04d66b24e84b8db5a6f2c1c1cafbc38fd7f630a1 Mon Sep 17 00:00:00 2001 From: Simon Van Braeckel Date: Fri, 29 Nov 2024 14:26:00 +0100 Subject: [PATCH 11/14] Debug path.resolve vs path.join & presence of build folder for CI --- bin/generate.js | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/bin/generate.js b/bin/generate.js index 06be033..3b92db6 100755 --- a/bin/generate.js +++ b/bin/generate.js @@ -88,6 +88,27 @@ if (args.h || args.help || args._.length > 1) { }); if (fs.existsSync(path.join(process.cwd(), 'queries.json'))) { - fs.renameSync(path.join(process.cwd(), 'queries.json'), path.join(process.cwd(), `${destinationPath}/queries.json`)); + // Debug the difference between path.resolve and path.join on different systems in the CI + // Most likely build/ doesn't exist + console.log("path.resolve(process.cwd(), `${destinationPath}/queries.json`)"); + console.log(path.resolve(process.cwd(), `${destinationPath}/queries.json`)); + console.log("path.join(process.cwd(), `${destinationPath}/queries.json`)"); + console.log(path.join(process.cwd(), `${destinationPath}/queries.json`)); + if (! fs.existsSync(path.resolve(process.cwd(), destinationPath))) { + console.log("resolve destinationPath doesn't exist"); + console.log("CREATE"); + fs.mkdirSync(path.resolve(process.cwd(), destinationPath)); + } else { + console.log("resolve destinationPath exists"); + } + if (! fs.existsSync(path.join(process.cwd(), destinationPath))) { + console.log("join destinationPath doesn't exist"); + console.log("CREATE"); + fs.mkdirSync(path.join(process.cwd(), destinationPath)); + } else { + console.log("join destinationPath exists"); + } + + fs.renameSync(path.join(process.cwd(), 'queries.json'), path.resolve(process.cwd(), `${destinationPath}/queries.json`)); }; })(); From f0d32c6438b0427818f9e653672f927b00cbc2ea Mon Sep 17 00:00:00 2001 From: Simon Van Braeckel Date: Fri, 29 Nov 2024 14:27:45 +0100 Subject: [PATCH 12/14] Change back line that didn't need changing --- webpack.config.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/webpack.config.js b/webpack.config.js index 15aa2d0..be85e24 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -41,7 +41,7 @@ module.exports = [ path.join(__dirname, './images/sparql.png'), path.join(__dirname, './favicon.ico'), path.join(__dirname, './solid-client-id.jsonld'), - path.join(process.cwd(), './queries.json'), + path.join(__dirname, './queries.json'), ], output: { filename: 'scripts/ldf-client-ui.min.js', From 167cc95b3c1b6fef9a79ff0b041168707701c644 Mon Sep 17 00:00:00 2001 From: Simon Van Braeckel Date: Fri, 29 Nov 2024 19:38:10 +0100 Subject: [PATCH 13/14] Create build folder to fix CI --- bin/generate.js | 19 +------------------ 1 file changed, 1 insertion(+), 18 deletions(-) diff --git a/bin/generate.js b/bin/generate.js index 3b92db6..d3f6501 100755 --- a/bin/generate.js +++ b/bin/generate.js @@ -88,27 +88,10 @@ if (args.h || args.help || args._.length > 1) { }); if (fs.existsSync(path.join(process.cwd(), 'queries.json'))) { - // Debug the difference between path.resolve and path.join on different systems in the CI - // Most likely build/ doesn't exist - console.log("path.resolve(process.cwd(), `${destinationPath}/queries.json`)"); - console.log(path.resolve(process.cwd(), `${destinationPath}/queries.json`)); - console.log("path.join(process.cwd(), `${destinationPath}/queries.json`)"); - console.log(path.join(process.cwd(), `${destinationPath}/queries.json`)); + // Create the build output folder if it doesn't exist if (! fs.existsSync(path.resolve(process.cwd(), destinationPath))) { - console.log("resolve destinationPath doesn't exist"); - console.log("CREATE"); fs.mkdirSync(path.resolve(process.cwd(), destinationPath)); - } else { - console.log("resolve destinationPath exists"); } - if (! fs.existsSync(path.join(process.cwd(), destinationPath))) { - console.log("join destinationPath doesn't exist"); - console.log("CREATE"); - fs.mkdirSync(path.join(process.cwd(), destinationPath)); - } else { - console.log("join destinationPath exists"); - } - fs.renameSync(path.join(process.cwd(), 'queries.json'), path.resolve(process.cwd(), `${destinationPath}/queries.json`)); }; })(); From dfbd305a253b7015ffaedef669d3303acbe82346 Mon Sep 17 00:00:00 2001 From: Simon Van Braeckel Date: Fri, 13 Dec 2024 12:39:57 +0100 Subject: [PATCH 14/14] Copy queries.json from process.cwd() --- webpack.config.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/webpack.config.js b/webpack.config.js index be85e24..15aa2d0 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -41,7 +41,7 @@ module.exports = [ path.join(__dirname, './images/sparql.png'), path.join(__dirname, './favicon.ico'), path.join(__dirname, './solid-client-id.jsonld'), - path.join(__dirname, './queries.json'), + path.join(process.cwd(), './queries.json'), ], output: { filename: 'scripts/ldf-client-ui.min.js',