Skip to content

Commit 7484675

Browse files
committed
fix: 修复必要环境缺失时不引导安装直接退出的问题
合并必要/可选工具的安装引导为统一流程: - 所有缺失工具统一弹出安装对话框 - 选择列表中显示(必需)/(可选)标签 - 安装完成后重新检测必要工具是否就绪
1 parent 330c48a commit 7484675

1 file changed

Lines changed: 17 additions & 13 deletions

File tree

src/commands/create.ts

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -215,18 +215,7 @@ async function _createFlow() {
215215
clack.log.info(status);
216216
}
217217

218-
// 检查必须工具是否缺失
219-
const missingRequired = getMissingRequiredTools(envSummary);
220-
if (missingRequired.length > 0) {
221-
clack.log.error(
222-
chalk.red(
223-
`${missingRequired.map((m) => m.name).join(", ")} ${t("envRequired")}`,
224-
),
225-
);
226-
process.exit(1);
227-
}
228-
229-
// 处理缺失的可选工具
218+
// 处理所有缺失的工具(必要 + 可选)
230219
const missing = getMissingTools(envSummary);
231220
if (missing.length > 0) {
232221
const shouldInstall = await clack.confirm({ message: t("envMissing") });
@@ -235,7 +224,10 @@ async function _createFlow() {
235224
if (shouldInstall) {
236225
const toInstall = await clack.multiselect({
237226
message: `${t("envSelectInstall")} ${chalk.dim(t("multiselectHint"))}`,
238-
options: missing.map((m) => ({ value: m.command, label: m.name })),
227+
options: missing.map((m) => ({
228+
value: m.command,
229+
label: `${m.name} ${m.required ? chalk.yellow(`(${t("envRequired")})`) : chalk.dim(`(${t("envOptional")})`)}`,
230+
})),
239231
initialValues: missing.map((m) => m.command),
240232
});
241233
if (clack.isCancel(toInstall)) onCancel();
@@ -252,6 +244,18 @@ async function _createFlow() {
252244
}
253245
}
254246
}
247+
248+
// 安装后重新检测必要工具是否就绪
249+
const recheck = await checkEnvironment();
250+
const stillMissing = getMissingRequiredTools(recheck);
251+
if (stillMissing.length > 0) {
252+
clack.log.error(
253+
chalk.red(
254+
`${stillMissing.map((m) => m.name).join(", ")} ${t("envRequired")}`,
255+
),
256+
);
257+
process.exit(1);
258+
}
255259
}
256260

257261
// ─── 项目配置 ───

0 commit comments

Comments
 (0)