tachybase_todo/publish.js
ChengLei Shao 45d4a9f242
Fix create nocobase app (#307)
* 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 <chenlinxh@gmail.com>
2022-04-21 10:56:29 +08:00

30 lines
870 B
JavaScript

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}`);
});
}),
);