From ac881145cfc8b194173565e4f0ad11197bcd5340 Mon Sep 17 00:00:00 2001 From: blueju <49681036+blueju@users.noreply.github.com> Date: Wed, 1 Jun 2022 13:55:22 +0800 Subject: [PATCH] =?UTF-8?q?chore:=20npm=20run=20setup=20=E5=92=8C=20npm=20?= =?UTF-8?q?run=20start=20=E5=91=BD=E4=BB=A4=E9=80=82=E9=85=8D=20win=20?= =?UTF-8?q?=E7=B3=BB=E7=BB=9F=20(#574)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * chore: npm run setup & npm run start 命令适配 win 系统 * chore: 补上漏掉的 await * chore: 参考 antfu 大神的轮子 ni 源码,改用更为知名的命令行库 * chore: npm run start 命令适配 win 系统 * chore: 调整样式 --- package.json | 7 +++++-- scripts/setup.js | 26 ++++++++++++++++++++++++++ scripts/start.js | 10 ++++++++++ 3 files changed, 41 insertions(+), 2 deletions(-) create mode 100644 scripts/setup.js create mode 100644 scripts/start.js diff --git a/package.json b/package.json index 72ddd3ca6..90c099d15 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/scripts/setup.js b/scripts/setup.js new file mode 100644 index 000000000..77da2291f --- /dev/null +++ b/scripts/setup.js @@ -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' }); \ No newline at end of file diff --git a/scripts/start.js b/scripts/start.js new file mode 100644 index 000000000..e1a83ea73 --- /dev/null +++ b/scripts/start.js @@ -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' });