@simonyea/holysheep-cli 1.1.4 → 1.1.5
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/package.json +1 -1
- package/src/commands/setup.js +11 -15
package/package.json
CHANGED
package/src/commands/setup.js
CHANGED
|
@@ -45,19 +45,13 @@ async function tryAutoInstall(tool) {
|
|
|
45
45
|
spinner.fail(`安装失败,请手动运行: ${chalk.cyan(info.cmd)}`)
|
|
46
46
|
return false
|
|
47
47
|
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
// 安装后重新检测
|
|
54
|
-
if (tool.checkInstalled()) {
|
|
55
|
-
spinner.succeed(`${tool.name} 安装成功`)
|
|
56
|
-
return true
|
|
57
|
-
} else {
|
|
58
|
-
spinner.fail(`${tool.name} 安装后仍未检测到,请手动安装: ${chalk.cyan(info.cmd)}`)
|
|
59
|
-
return false
|
|
48
|
+
spinner.succeed(`${tool.name} 安装成功`)
|
|
49
|
+
// Windows PATH 在当前进程内不会刷新,但安装已成功,直接继续配置
|
|
50
|
+
// 非 Windows 再额外做一次检测
|
|
51
|
+
if (process.platform !== 'win32' && !tool.checkInstalled()) {
|
|
52
|
+
console.log(chalk.yellow(` ⚠ 安装后未检测到命令,尝试直接配置...`))
|
|
60
53
|
}
|
|
54
|
+
return true // 安装成功就视为可配置
|
|
61
55
|
} catch (e) {
|
|
62
56
|
spinner.fail(`安装失败: ${e.message}`)
|
|
63
57
|
return false
|
|
@@ -138,6 +132,7 @@ async function setup(options) {
|
|
|
138
132
|
const selectedTools = TOOLS.filter(t => toolIds.includes(t.id))
|
|
139
133
|
const needInstall = selectedTools.filter(t => !t.checkInstalled() && canAutoInstall(t.id))
|
|
140
134
|
const cantInstall = selectedTools.filter(t => !t.checkInstalled() && !canAutoInstall(t.id))
|
|
135
|
+
const justInstalled = new Set() // 记录本次刚安装成功的工具 id
|
|
141
136
|
|
|
142
137
|
// 提示不能自动安装的工具
|
|
143
138
|
if (cantInstall.length) {
|
|
@@ -157,16 +152,17 @@ async function setup(options) {
|
|
|
157
152
|
|
|
158
153
|
if (doInstall) {
|
|
159
154
|
for (const tool of needInstall) {
|
|
160
|
-
await tryAutoInstall(tool)
|
|
155
|
+
const ok = await tryAutoInstall(tool)
|
|
156
|
+
if (ok) justInstalled.add(tool.id)
|
|
161
157
|
}
|
|
162
158
|
console.log()
|
|
163
159
|
}
|
|
164
160
|
}
|
|
165
161
|
|
|
166
|
-
// Step 4:
|
|
162
|
+
// Step 4: 配置每个已安装的工具(包含刚刚安装成功的)
|
|
167
163
|
const envVarsToWrite = {}
|
|
168
164
|
const results = []
|
|
169
|
-
const toConfigureTools = selectedTools.filter(t => t.checkInstalled())
|
|
165
|
+
const toConfigureTools = selectedTools.filter(t => t.checkInstalled() || justInstalled.has(t.id))
|
|
170
166
|
|
|
171
167
|
if (toConfigureTools.length === 0) {
|
|
172
168
|
console.log(chalk.yellow('没有可配置的工具(请先安装),退出。'))
|