wyt-cli 1.0.16 → 1.0.17

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -30,7 +30,7 @@ export default function () {
30
30
  type: 'rawlist',
31
31
  name: 'runstyle',
32
32
  message: `请选择项目运行方式:` + getInquirerOperationText('list'),
33
- default: 1,
33
+ default: 0,
34
34
  choices: [
35
35
  { name: '方式1:运行所有项目', value: 0 },
36
36
  { name: '方式2:运行指定项目', value: 1 },
@@ -62,18 +62,55 @@ export default function () {
62
62
  }
63
63
 
64
64
  // 运行项目
65
- function runProject(projects = [], appsDir) {
66
- projects.forEach((project) => {
65
+ async function runProject(projects = [], appsDir) {
66
+ // 更新 packages 最新版本
67
+ log_info(`🔄 检查并更新 packages 最新版本...`);
68
+ await execa('pnpm', ['install'], {
69
+ cwd: process.cwd(),
70
+ stdio: 'inherit',
71
+ });
72
+
73
+ // 运行命令
74
+ const command = 'npm run dev';
75
+ // 运行项目文档
76
+ log_info(`🚀 启动项目文档...`);
77
+ const docsPath = path.join(process.cwd(), 'docs');
78
+ const docsProcess = execa(command, {
79
+ cwd: docsPath,
80
+ stdio: 'inherit',
81
+ });
82
+ docsProcess.on('exit', (code) => {
83
+ if (code !== 0) log_error(`项目文档异常退出 (CODE: ${code})`);
84
+ });
85
+
86
+ // 运行项目
87
+ const configPath = path.join(process.cwd(), 'project.json');
88
+ let config = JSON.parse(fs.readFileSync(configPath, 'utf8'));
89
+ if (config.apps) {
90
+ // 初始化
91
+ config.apps.forEach((app, index) => {
92
+ config.apps[index] = {
93
+ ...app,
94
+ lastRun: false,
95
+ };
96
+ });
97
+ }
98
+ projects.forEach(async (project) => {
67
99
  const projectName = project.name;
68
100
  if (projectName) {
69
101
  const projectPath = path.join(appsDir, projectName);
70
102
  if (!fs.existsSync(projectPath)) {
71
103
  throw new Error(`项目 ${projectName} 不存在`);
72
104
  }
73
- // 准备运行命令
74
- const command = 'npm run dev';
105
+
75
106
  // 执行命令
76
107
  log_info(`🚀 启动项目 ${projectName}...`);
108
+ // 更新项目启动状态
109
+ const targetIndex = config.apps.findIndex((app) => app.name === projectName);
110
+ if (targetIndex !== -1) {
111
+ config.apps[targetIndex].lastRun = true;
112
+ }
113
+
77
114
  const subprocess = execa(command, {
78
115
  cwd: projectPath,
79
116
  stdio: 'inherit',
@@ -86,4 +123,6 @@ function runProject(projects = [], appsDir) {
86
123
  });
87
124
  }
88
125
  });
126
+
127
+ fs.writeFileSync(configPath, JSON.stringify(config, null, 2));
89
128
  }
package/bin/main.js CHANGED
@@ -1,4 +1,4 @@
1
- #!/usr/bin/env node
1
+ #!/usr/bin/env node
2
2
  import { require } from './lib/utils.js';
3
3
  import { LOWEST_NODE_VERSION } from './lib/const.js';
4
4
  import { log_error, log_warning } from './lib/logger.js';
@@ -3,7 +3,7 @@
3
3
  "private": true,
4
4
  "version": "1.0.0",
5
5
  "type": "module",
6
- "description": "个人工作台",
6
+ "description": "",
7
7
  "devServer": {
8
8
  "port": "<%= devServerPort %>"
9
9
  },
@@ -6,7 +6,7 @@ const projectConfig = JSON.parse(fs.readFileSync(path.resolve(process.cwd(), '..
6
6
  const ProxyURL = projectConfig.apiUrl || 'https://hrp3.wytdev.com';
7
7
 
8
8
  export default defineConfig({
9
- base: './',
9
+ base: process.env.NODE_ENV == 'development' ? './' : '/<%= projectName %>',
10
10
  build: {
11
11
  outDir: '<%= buildOutDir %>',
12
12
  emptyOutDir: true, // 清空输出目录
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wyt-cli",
3
- "version": "1.0.16",
3
+ "version": "1.0.17",
4
4
  "description": "HRP3.0 项目命令行工具",
5
5
  "main": "index.js",
6
6
  "bin": {