From f320529055ce7728a04fcb0fc07ca2c55fc0a304 Mon Sep 17 00:00:00 2001 From: caele Date: Mon, 8 Jan 2024 10:39:43 +0100 Subject: [PATCH] chore: add postinstall theme copy --- .eslintignore | 3 ++- package.json | 5 +++-- tools/install-themes.js | 29 +++++++++++++++++++++++++++++ 3 files changed, 34 insertions(+), 3 deletions(-) create mode 100644 tools/install-themes.js diff --git a/.eslintignore b/.eslintignore index 165003365..b937aaad4 100644 --- a/.eslintignore +++ b/.eslintignore @@ -2,4 +2,5 @@ dist/ coverage/ node_modules/ apis/snapshooter/client.js -apis/*/core/**/*.js \ No newline at end of file +apis/*/core/**/*.js +tools/ \ No newline at end of file diff --git a/package.json b/package.json index e91ad4a3f..5c32d7d40 100644 --- a/package.json +++ b/package.json @@ -23,7 +23,8 @@ "test:rendering": "playwright test --config=./test/rendering/playwright.config.rendering.js --quiet", "test:integration": "aw puppet -c aw.config.js --testExt '*.int.js' --glob 'test/integration/**/*.int.js'", "test:component": "aw puppet -c aw.config.js --testExt '*.comp.js' --glob 'test/component/**/*.comp.js'", - "prepare": "husky install" + "prepare": "husky install", + "postinstall": "node tools/install-themes.js" }, "repository": { "type": "git", @@ -107,4 +108,4 @@ "apis/*", "test/component/*" ] -} +} \ No newline at end of file diff --git a/tools/install-themes.js b/tools/install-themes.js new file mode 100644 index 000000000..95d8ab3c2 --- /dev/null +++ b/tools/install-themes.js @@ -0,0 +1,29 @@ +var child_process = require('child_process'); + +function install(modules, callback) { + if (modules.length == 0) { + if (callback) callback(null); + return; + } + var module = modules.shift(); + child_process.exec('npm install ' + module + ' --no-save --silent', {}, function (error, stdout, stderr) { + process.stdout.write(stdout + '\n'); + process.stderr.write(stderr + '\n'); + if (error !== null) { + if (callback) callback(error); + } else { + install(modules, callback); + } + }); +} + +function copyFiles(error) { + if (!error) { + child_process.exec('cp -a node_modules/@qlik-trial/sense-themes-default/dist/. apis/theme/src/themes/'); + } + child_process.exec('git restore yarn.lock'); +} + +/* Example */ + +install(['@qlik-trial/sense-themes-default'], copyFiles);