From 45d4a9f24261d358dd81b407a29e0cc610a39986 Mon Sep 17 00:00:00 2001 From: ChengLei Shao Date: Thu, 21 Apr 2022 10:56:29 +0800 Subject: [PATCH] Fix create nocobase app (#307) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * chore: create-nocobase-app * chore: change create-nocobase-app lib to src * chore(versions): 😊 publish v0.6.2-alpha.9 * fix: publish * chore(versions): 😊 publish v0.6.2-alpha.10 * fix: read-config * chore(versions): 😊 publish v0.6.2-alpha.11 * fix: create-nocobase-app publish * chore: create-nocobase-app package.json * chore(versions): 😊 publish v0.6.2-alpha.12 * feat: publish script Co-authored-by: chenos --- .../create-nocobase-app/src/create-app.js | 2 +- publish.js | 29 +++++++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 publish.js diff --git a/packages/core/create-nocobase-app/src/create-app.js b/packages/core/create-nocobase-app/src/create-app.js index c6e10c780..06160d9a5 100644 --- a/packages/core/create-nocobase-app/src/create-app.js +++ b/packages/core/create-nocobase-app/src/create-app.js @@ -62,7 +62,7 @@ const getDatabaseOptionsFromCommandOptions = (commandOptions) => { host: envs['DB_HOST'], port: envs['DB_PORT'], database: envs['DB_DATABASE'], - username: envs['DB_USERNAME'], + user: envs['DB_USER'], password: envs['DB_PASSWORD'], }; diff --git a/publish.js b/publish.js new file mode 100644 index 000000000..4177bb45c --- /dev/null +++ b/publish.js @@ -0,0 +1,29 @@ +const { readdir } = require('fs/promises'); +const path = require('path'); +const { exec } = require('child_process'); + +const getDirectories = async (source) => + (await readdir(source, { withFileTypes: true })) + .filter((dirent) => dirent.isDirectory()) + .map((d) => d.name) + .map((d) => path.resolve(source, d)); + +const packageDirs = ['packages/core', 'packages/plugins', 'packages/app']; + +Promise.all(packageDirs.map((d) => getDirectories(d))) + .then((res) => res.flat()) + .then((res) => + res.forEach((d) => { + exec(`cd ${d} && npm unpublish -f && npm publish`, (error, stdout, stderr) => { + if (error) { + console.log(`error: ${error.message}`); + return; + } + if (stderr) { + console.log(`stderr: ${stderr}`); + return; + } + console.log(`stdout: ${stdout}`); + }); + }), + );