From e04c0eb7595c94f9eb5a254df9b58d6726010fb0 Mon Sep 17 00:00:00 2001 From: Wing-Kam Wong Date: Thu, 8 Jun 2023 17:08:32 +0800 Subject: [PATCH] feat: add install:local-sdk --- package.json | 3 ++- scripts/installLocalSdk.js | 42 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+), 1 deletion(-) create mode 100644 scripts/installLocalSdk.js diff --git a/package.json b/package.json index 81c678344f..e035640227 100644 --- a/package.json +++ b/package.json @@ -46,7 +46,8 @@ "start:mysql": "docker-compose -f ./tests/playwright/scripts/docker-compose-mysql-playwright.yml up -d", "stop:mysql": "docker-compose -f ./tests/playwright/scripts/docker-compose-mysql-playwright.yml down", "start:pg": "docker-compose -f ./tests/playwright/scripts/docker-compose-pg.yml up -d", - "stop:pg": "docker-compose -f ./tests/playwright/scripts/docker-compose-pg.yml down" + "stop:pg": "docker-compose -f ./tests/playwright/scripts/docker-compose-pg.yml down", + "install:local-sdk": "node scripts/installLocalSdk.js" }, "dependencies": { "express": "^4.18.1", diff --git a/scripts/installLocalSdk.js b/scripts/installLocalSdk.js new file mode 100644 index 0000000000..df95644d79 --- /dev/null +++ b/scripts/installLocalSdk.js @@ -0,0 +1,42 @@ +const { exec } = require('child_process'); +const path = require('path'); +const sdkPath = path.join(__dirname, '..', 'packages', 'nocodb-sdk'); +const guiPath = path.join(__dirname, '..', 'packages', 'nc-gui'); +const nocodbPath = path.join(__dirname, '..', 'packages', 'nocodb'); + +exec(`cd ${sdkPath} && npm i && npm run build`, (err, stdout, stderr) => { + if (err) { + console.error(`Error installing dependencies and building nocodb-sdk: ${err}`); + return; + } + + console.log(`Dependencies installed and nocodb-sdk built: ${stdout}`); + + const guiPromise = new Promise((resolve, reject) => { + exec(`cd ${guiPath} && npm i ${sdkPath}`, (err, stdout, stderr) => { + if (err) { + reject(`Error installing dependencies for nc-gui: ${err}`); + } else { + resolve(`Dependencies installed for nc-gui: ${stdout}`); + } + }); + }); + + const nocodbPromise = new Promise((resolve, reject) => { + exec(`cd ${nocodbPath} && npm i ${sdkPath}`, (err, stdout, stderr) => { + if (err) { + reject(`Error installing dependencies for nocodb: ${err}`); + } else { + resolve(`Dependencies installed for nocodb: ${stdout}`); + } + }); + }); + + Promise.all([guiPromise, nocodbPromise]) + .then((results) => { + console.log(results.join('\n')); + }) + .catch((err) => { + console.error(err); + }); + }); \ No newline at end of file