From aaa83ba1621c8b31b37e173700dbd226b0198cec Mon Sep 17 00:00:00 2001 From: chilingling <26962197+chilingling@users.noreply.github.com> Date: Tue, 14 Nov 2023 03:35:30 -0800 Subject: [PATCH] feat(chore): add setup script setup environment before serving (#80) --- package.json | 5 +++-- scripts/setup.js | 9 +++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) create mode 100644 scripts/setup.js diff --git a/package.json b/package.json index 7829e7b..365ca8e 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,7 @@ "private": true, "scripts": { "preinstall": "npx only-allow pnpm", - "dev": "concurrently 'pnpm:serve:backend' 'pnpm:serve:frontend'", + "dev": "pnpm run setup && concurrently 'pnpm:serve:backend' 'pnpm:serve:frontend'", "dev:mock": "pnpm --filter @opentiny/tiny-engine dev", "serve:frontend": "pnpm --filter @opentiny/tiny-engine serve", "serve:backend": "pnpm --filter @opentiny/tiny-engine-mock dev", @@ -18,7 +18,8 @@ "pub:premajor": "pnpm run build:plugin && pnpm run build:alpha && pnpm lerna version premajor --preid beta --no-push --yes && lerna publish from-package --pre-dist-tag beta --yes", "pub:preminor": "pnpm run build:plugin && pnpm run build:alpha && pnpm lerna version preminor --preid beta --no-push --yes && lerna publish from-package --pre-dist-tag beta --yes", "pub:prepatch": "pnpm run build:plugin && pnpm run build:alpha && pnpm lerna version prepatch --preid beta --no-push --yes && lerna publish from-package --pre-dist-tag beta --yes", - "pub:prerelease": "pnpm run build:plugin && pnpm run build:alpha && pnpm lerna version prerelease --preid beta --no-push --yes && lerna publish from-package --pre-dist-tag beta --yes" + "pub:prerelease": "pnpm run build:plugin && pnpm run build:alpha && pnpm lerna version prerelease --preid beta --no-push --yes && lerna publish from-package --pre-dist-tag beta --yes", + "setup": "node ./scripts/setup.js" }, "devDependencies": { "@babel/eslint-parser": "^7.21.3", diff --git a/scripts/setup.js b/scripts/setup.js new file mode 100644 index 0000000..64a7d1f --- /dev/null +++ b/scripts/setup.js @@ -0,0 +1,9 @@ +const { exec } = require('child_process') +const fs = require('fs') +const path = require('path') + +fs.access(path.resolve(__dirname, 'packages/vue-generator/dist'), (err) => { + if (err) { + exec('pnpm -F @opentiny/tiny-engine-dsl-vue build') + } +})