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.
package/bin/commands/run.js
CHANGED
|
@@ -30,7 +30,7 @@ export default function () {
|
|
|
30
30
|
type: 'rawlist',
|
|
31
31
|
name: 'runstyle',
|
|
32
32
|
message: `请选择项目运行方式:` + getInquirerOperationText('list'),
|
|
33
|
-
default:
|
|
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
|
-
|
|
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
|
@@ -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, // 清空输出目录
|