chore: npm run setup 和 npm run start 命令适配 win 系统 (#574)

* chore: npm run setup & npm run start 命令适配 win 系统

* chore: 补上漏掉的 await

* chore: 参考 antfu 大神的轮子 ni 源码,改用更为知名的命令行库

* chore: npm run start 命令适配 win 系统

* chore: 调整样式
This commit is contained in:
blueju 2022-06-01 13:55:22 +08:00 committed by GitHub
parent b8f35c504e
commit ac881145cf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 41 additions and 2 deletions

View File

@ -22,10 +22,10 @@
"pub:premajor": "npm run watchdog:build && lerna publish premajor --force-publish --exact --dist-tag beta --preid beta --no-changelog",
"pub:prepatch": "npm run watchdog:build && lerna publish prepatch --force-publish --exact --dist-tag beta --preid beta --no-changelog",
"pub:prerelease": "npm run watchdog:build && lerna publish prerelease --force-publish --exact --dist-tag beta --preid beta --no-changelog",
"setup": "./scripts/setup.sh",
"setup": "node ./scripts/setup.js",
"setup:test": "./scripts/setup-for-test.sh",
"setup:skip-build": "./scripts/setup-skip-build.sh",
"start": "./scripts/start.sh",
"start": "node ./scripts/start.js",
"test": "lerna run test --stream",
"test:snapshot": "lerna run test:snapshot",
"watchdog:build": "node ./scripts/watchdog.js",
@ -38,7 +38,10 @@
}
},
"devDependencies": {
"del": "^6.1.1",
"execa": "^5.1.1",
"f2elint": "^2.0.1",
"gulp": "^4.0.2",
"husky": "^7.0.4",
"lerna": "^4.0.0",
"typescript": "^4.5.5",

26
scripts/setup.js Normal file
View File

@ -0,0 +1,26 @@
#!/usr/bin/env node
const os = require('os');
const del = require('del');
const gulp = require('gulp');
const execa = require('execa');
async function deleteRootDirLockFile() {
await del('package-lock.json');
await del('yarn.lock');
}
async function clean() {
await execa.command('lerna clean -y', { stdio: 'inherit', encoding: 'utf-8' });
}
async function deletePackagesDirLockFile() {
await del('packages/**/package-lock.json');
}
async function bootstrap() {
await execa.command('lerna bootstrap --force-local', { stdio: 'inherit', encoding: 'utf-8' });
}
const setup = gulp.series(deleteRootDirLockFile, clean, deletePackagesDirLockFile, bootstrap);
os.type() === 'Windows_NT' ? setup() : execa.command('scripts/setup.sh', { stdio: 'inherit', encoding: 'utf-8' });

10
scripts/start.js Normal file
View File

@ -0,0 +1,10 @@
#!/usr/bin/env node
const os = require('os');
const execa = require('execa');
async function start() {
const [, , pkgName = '@alilc/lowcode-ignitor'] = process.argv;
await execa.command(`lerna exec --scope ${pkgName} -- npm start`, { stdio: 'inherit', encoding: 'utf-8' });
}
os.type() === 'Windows_NT' ? start() : execa.command('scripts/start.sh', { stdio: 'inherit', encoding: 'utf-8' });