From ccbdfcdbdf3f86123b9c66eb265a1de2b4d957ee Mon Sep 17 00:00:00 2001 From: jianglong Date: Wed, 21 Jun 2023 13:45:36 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=F0=9F=8C=88=20style:=20=E6=A0=B7=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/App.vue | 4 +++- src/main.ts | 2 -- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/App.vue b/src/App.vue index d255d64..470fa54 100644 --- a/src/App.vue +++ b/src/App.vue @@ -41,4 +41,6 @@ - + diff --git a/src/main.ts b/src/main.ts index 9e264b3..267ddb1 100644 --- a/src/main.ts +++ b/src/main.ts @@ -1,5 +1,3 @@ -import './assets/css/main.scss' - import { createApp } from 'vue' import App from './App.vue' import { createPinia } from 'pinia' -- Gitee From 8ec634e6c50064aa10379e2a3db2f5bea985386d Mon Sep 17 00:00:00 2001 From: jianglong Date: Wed, 21 Jun 2023 13:47:58 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=F0=9F=8E=88=20perf:=20=E8=B7=AF=E5=BE=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- viteConfig/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/viteConfig/index.ts b/viteConfig/index.ts index 54bc8d5..2a93fe4 100644 --- a/viteConfig/index.ts +++ b/viteConfig/index.ts @@ -40,7 +40,7 @@ export default defineConfig((conf: ConfigEnv) => { ], resolve: { alias: { - '@': path.resolve('/src') + '@': path.resolve('./src') } }, /** 打包配置 */ -- Gitee From e351608b04f991de531410ed5a8f7e99366a185d Mon Sep 17 00:00:00 2001 From: jianglong Date: Tue, 27 Jun 2023 11:18:13 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=F0=9F=8E=88=20perf:=20=E6=9B=B4=E6=94=B9?= =?UTF-8?q?=E8=B0=83=E8=AF=95=E8=BF=90=E8=A1=8C=E5=92=8C=E6=89=93=E5=8C=85?= =?UTF-8?q?=E7=9A=84=E8=84=9A=E6=9C=AC=E4=BE=9D=E8=B5=96=E5=8C=85cross-spa?= =?UTF-8?q?wn?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 2 +- pnpm-lock.yaml | 34 +++------------------------------- start/index.js | 16 ++++++++++++---- start/utils.js | 25 ++++++++++++------------- 4 files changed, 28 insertions(+), 49 deletions(-) diff --git a/package.json b/package.json index c8ce820..420f740 100644 --- a/package.json +++ b/package.json @@ -35,6 +35,7 @@ "@vue/test-utils": "^2.3.2", "@vue/tsconfig": "^0.4.0", "autoprefixer": "^10.4.14", + "cross-spawn": "^7.0.3", "envfile": "^6.18.0", "eslint": "^8.39.0", "eslint-plugin-vue": "^9.11.0", @@ -45,7 +46,6 @@ "rollup-plugin-external-globals": "^0.8.0", "rollup-plugin-visualizer": "^5.9.0", "sass": "^1.63.5", - "shelljs": "^0.8.5", "typescript": "~5.0.4", "vite": "^4.3.9", "vite-plugin-compression": "^0.5.1", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index a1e3b68..3bcb785 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -61,6 +61,9 @@ devDependencies: autoprefixer: specifier: ^10.4.14 version: registry.npmmirror.com/autoprefixer@10.4.14(postcss@8.4.23) + cross-spawn: + specifier: ^7.0.3 + version: registry.npmmirror.com/cross-spawn@7.0.3 envfile: specifier: ^6.18.0 version: registry.npmmirror.com/envfile@6.18.0 @@ -91,9 +94,6 @@ devDependencies: sass: specifier: ^1.63.5 version: registry.npmmirror.com/sass@1.63.5 - shelljs: - specifier: ^0.8.5 - version: registry.npmmirror.com/shelljs@0.8.5 typescript: specifier: ~5.0.4 version: registry.npmmirror.com/typescript@5.0.4 @@ -3577,13 +3577,6 @@ packages: side-channel: registry.npmmirror.com/side-channel@1.0.4 dev: true - registry.npmmirror.com/interpret@1.4.0: - resolution: {integrity: sha512-agE4QfB2Lkp9uICn7BAqoscw4SZP9kTE2hxiFI3jBPmXJfdqiahTbUuKGsMoN2GtqL9AxhYioAcVvgsb1HvRbA==, registry: https://registry.npm.taobao.org/, tarball: https://registry.npmmirror.com/interpret/-/interpret-1.4.0.tgz} - name: interpret - version: 1.4.0 - engines: {node: '>= 0.10'} - dev: true - registry.npmmirror.com/is-array-buffer@3.0.2: resolution: {integrity: sha512-y+FyyR/w8vfIRq4eQcM1EYgSTnmHXPqaF+IgzgraytCFq5Xh8lllDVmAZolPJiZttZLeFSINPYMaEJ7/vWUa1w==, registry: https://registry.npm.taobao.org/, tarball: https://registry.npmmirror.com/is-array-buffer/-/is-array-buffer-3.0.2.tgz} name: is-array-buffer @@ -4755,15 +4748,6 @@ packages: picomatch: registry.npmmirror.com/picomatch@2.3.1 dev: true - registry.npmmirror.com/rechoir@0.6.2: - resolution: {integrity: sha512-HFM8rkZ+i3zrV+4LQjwQ0W+ez98pApMGM3HUrN04j3CqzPOzl9nmP15Y8YXNm8QHGv/eacOVEjqhmWpkRV0NAw==, registry: https://registry.npm.taobao.org/, tarball: https://registry.npmmirror.com/rechoir/-/rechoir-0.6.2.tgz} - name: rechoir - version: 0.6.2 - engines: {node: '>= 0.10'} - dependencies: - resolve: registry.npmmirror.com/resolve@1.22.2 - dev: true - registry.npmmirror.com/regenerator-runtime@0.13.11: resolution: {integrity: sha512-kY1AZVr2Ra+t+piVaJ4gxaFaReZVH40AKNo7UCX6W+dEwBo/2oZJzqfuN1qLq1oL45o56cPaTXELwrTh8Fpggg==, registry: https://registry.npm.taobao.org/, tarball: https://registry.npmmirror.com/regenerator-runtime/-/regenerator-runtime-0.13.11.tgz} name: regenerator-runtime @@ -5030,18 +5014,6 @@ packages: version: 1.8.1 dev: true - registry.npmmirror.com/shelljs@0.8.5: - resolution: {integrity: sha512-TiwcRcrkhHvbrZbnRcFYMLl30Dfov3HKqzp5tO5b4pt6G/SezKcYhmDg15zXVBswHmctSAQKznqNW2LO5tTDow==, registry: https://registry.npm.taobao.org/, tarball: https://registry.npmmirror.com/shelljs/-/shelljs-0.8.5.tgz} - name: shelljs - version: 0.8.5 - engines: {node: '>=4'} - hasBin: true - dependencies: - glob: registry.npmmirror.com/glob@7.2.3 - interpret: registry.npmmirror.com/interpret@1.4.0 - rechoir: registry.npmmirror.com/rechoir@0.6.2 - dev: true - registry.npmmirror.com/side-channel@1.0.4: resolution: {integrity: sha512-q5XPytqFEIKHkGdiMIrY10mvLRvnQh42/+GoBlFW3b2LXLE2xxJpZFdm94we0BaoV3RwJyGqg5wS7epxTv0Zvw==, registry: https://registry.npm.taobao.org/, tarball: https://registry.npmmirror.com/side-channel/-/side-channel-1.0.4.tgz} name: side-channel diff --git a/start/index.js b/start/index.js index 27d8efc..ad5a5b4 100644 --- a/start/index.js +++ b/start/index.js @@ -1,7 +1,9 @@ /* * @Description: 该文件用于调试运行和打包的脚本 */ -const { getEnvShell } = require('./utils') + +const { spawn } = require('cross-spawn') +const { getEnvShell } = require('./utils.js') const shell = require('shelljs') const inquirer = require('inquirer') @@ -37,8 +39,14 @@ async function checkList() { return commands[prompt.mode][prompt.environment] } -/** 运行脚本 */ +/** 运行脚本: https://www.npmjs.com/package/cross-spawn */ checkList().then((command) => { - console.log('command: ', command) - shell.exec(command) + const commands = command.split('&&').map((item) => item.trim()) + const children = commands.map((item) => item.split(' ')) + // 这里运行的pnpm是根据你的项目中的package.json中的scripts来决定的 + children.forEach((child) => { + spawn.sync('pnpm', child, { + stdio: 'inherit' + }) + }) }) diff --git a/start/utils.js b/start/utils.js index 023ca35..1878b9e 100644 --- a/start/utils.js +++ b/start/utils.js @@ -2,7 +2,7 @@ * @Description: 工具库 */ const path = require('path') -const fs = require('fs'); +const fs = require('fs') const { parse } = require('envfile') /** @@ -18,9 +18,9 @@ function getPathEnvs() { fs.readdir(directory, function (err, files) { if (err) { resolve(envs) - return; + return } - files.forEach(fileName => { + files.forEach((fileName) => { // 如果fileName是以.env.开头的字符串 if (`${fileName}`.indexOf(firstName) === 0) { envs.push({ @@ -41,26 +41,25 @@ function getPathEnvs() { /** 获取所有配置的脚本 */ async function getEnvShell() { /** 类型检查命令 */ - const type_check = 'vue-tsc --noEmit -p tsconfig.vitest.json --composite false' + const type_check = `vue-tsc --noEmit -p tsconfig.vitest.json --composite false` const envs = await getPathEnvs() const shellSet = { commands: { - debug: { }, - build: { } + debug: {}, + build: {} }, environment: [] } - envs.forEach((item => { - const parsedFile = parse(fs.readFileSync(item.path, 'utf-8')); + envs.forEach((item) => { + const parsedFile = parse(fs.readFileSync(item.path, 'utf-8')) shellSet.environment.push({ - name: parsedFile.VITE_APP_ENVNAME, - value: item.mode + name: parsedFile.VITE_APP_ENVNAME, + value: item.mode }) shellSet.commands.debug[item.mode] = `vite --mode ${item.mode}` shellSet.commands.build[item.mode] = `${type_check} && vite build --mode ${item.mode}` - })) - - return shellSet; + }) + return shellSet } module.exports = { -- Gitee From 5e945db112e3a94d378c1354a499f844b956071c Mon Sep 17 00:00:00 2001 From: jianglong Date: Tue, 27 Jun 2023 11:18:38 +0800 Subject: [PATCH 4/4] =?UTF-8?q?=F0=9F=8E=88=20perf:=20=E5=8E=BB=E6=8E=89sh?= =?UTF-8?q?elljs=E4=BE=9D=E8=B5=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- start/index.js | 1 - 1 file changed, 1 deletion(-) diff --git a/start/index.js b/start/index.js index ad5a5b4..8f8c8a4 100644 --- a/start/index.js +++ b/start/index.js @@ -4,7 +4,6 @@ const { spawn } = require('cross-spawn') const { getEnvShell } = require('./utils.js') -const shell = require('shelljs') const inquirer = require('inquirer') /** 打包之后预览命令 */ -- Gitee