Skip to content

Commit ac88114

Browse files
authored
chore: npm run setup 和 npm run start 命令适配 win 系统 (alibaba#574)
* chore: npm run setup & npm run start 命令适配 win 系统 * chore: 补上漏掉的 await * chore: 参考 antfu 大神的轮子 ni 源码,改用更为知名的命令行库 * chore: npm run start 命令适配 win 系统 * chore: 调整样式
1 parent b8f35c5 commit ac88114

File tree

3 files changed

+41
-2
lines changed

3 files changed

+41
-2
lines changed

package.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@
2222
"pub:premajor": "npm run watchdog:build && lerna publish premajor --force-publish --exact --dist-tag beta --preid beta --no-changelog",
2323
"pub:prepatch": "npm run watchdog:build && lerna publish prepatch --force-publish --exact --dist-tag beta --preid beta --no-changelog",
2424
"pub:prerelease": "npm run watchdog:build && lerna publish prerelease --force-publish --exact --dist-tag beta --preid beta --no-changelog",
25-
"setup": "./scripts/setup.sh",
25+
"setup": "node ./scripts/setup.js",
2626
"setup:test": "./scripts/setup-for-test.sh",
2727
"setup:skip-build": "./scripts/setup-skip-build.sh",
28-
"start": "./scripts/start.sh",
28+
"start": "node ./scripts/start.js",
2929
"test": "lerna run test --stream",
3030
"test:snapshot": "lerna run test:snapshot",
3131
"watchdog:build": "node ./scripts/watchdog.js",
@@ -38,7 +38,10 @@
3838
}
3939
},
4040
"devDependencies": {
41+
"del": "^6.1.1",
42+
"execa": "^5.1.1",
4143
"f2elint": "^2.0.1",
44+
"gulp": "^4.0.2",
4245
"husky": "^7.0.4",
4346
"lerna": "^4.0.0",
4447
"typescript": "^4.5.5",

scripts/setup.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#!/usr/bin/env node
2+
const os = require('os');
3+
const del = require('del');
4+
const gulp = require('gulp');
5+
const execa = require('execa');
6+
7+
async function deleteRootDirLockFile() {
8+
await del('package-lock.json');
9+
await del('yarn.lock');
10+
}
11+
12+
async function clean() {
13+
await execa.command('lerna clean -y', { stdio: 'inherit', encoding: 'utf-8' });
14+
}
15+
16+
async function deletePackagesDirLockFile() {
17+
await del('packages/**/package-lock.json');
18+
}
19+
20+
async function bootstrap() {
21+
await execa.command('lerna bootstrap --force-local', { stdio: 'inherit', encoding: 'utf-8' });
22+
}
23+
24+
const setup = gulp.series(deleteRootDirLockFile, clean, deletePackagesDirLockFile, bootstrap);
25+
26+
os.type() === 'Windows_NT' ? setup() : execa.command('scripts/setup.sh', { stdio: 'inherit', encoding: 'utf-8' });

scripts/start.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/usr/bin/env node
2+
const os = require('os');
3+
const execa = require('execa');
4+
5+
async function start() {
6+
const [, , pkgName = '@alilc/lowcode-ignitor'] = process.argv;
7+
await execa.command(`lerna exec --scope ${pkgName} -- npm start`, { stdio: 'inherit', encoding: 'utf-8' });
8+
}
9+
10+
os.type() === 'Windows_NT' ? start() : execa.command('scripts/start.sh', { stdio: 'inherit', encoding: 'utf-8' });

0 commit comments

Comments
 (0)