terminal-bridge-setup 2.5.0 → 2.6.0
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/setup.mjs +29 -2
- package/package.json +1 -1
package/bin/setup.mjs
CHANGED
|
@@ -88,14 +88,41 @@ function installProxyDeps() {
|
|
|
88
88
|
}
|
|
89
89
|
|
|
90
90
|
const proxyDir = join(INSTALL_DIR, "proxy");
|
|
91
|
+
|
|
92
|
+
// 支持 --registry 透传(国内网络/公司内网常用)
|
|
93
|
+
// 用法:npx terminal-bridge-setup --registry=https://registry.npmmirror.com
|
|
94
|
+
const registryArg = process.argv.find(a => a.startsWith("--registry="));
|
|
95
|
+
const npmArgs = ["install", "--no-audit", "--no-fund"];
|
|
96
|
+
if (registryArg) {
|
|
97
|
+
npmArgs.push(registryArg);
|
|
98
|
+
console.log(c.dim(` 使用 registry: ${registryArg.split("=")[1]}`));
|
|
99
|
+
} else {
|
|
100
|
+
npmArgs.push("--silent");
|
|
101
|
+
}
|
|
102
|
+
|
|
91
103
|
console.log(c.dim(" 运行 npm install ..."));
|
|
92
|
-
const result = spawnSync("npm",
|
|
104
|
+
const result = spawnSync("npm", npmArgs, {
|
|
93
105
|
cwd: proxyDir,
|
|
94
106
|
stdio: "inherit",
|
|
95
107
|
});
|
|
96
108
|
|
|
97
109
|
if (result.status !== 0) {
|
|
98
|
-
|
|
110
|
+
// 失败时给出明确的排查建议
|
|
111
|
+
console.error("");
|
|
112
|
+
console.error(c.red(" ✗ npm install 失败"));
|
|
113
|
+
console.error(c.yellow(" 常见原因和解决方法:"));
|
|
114
|
+
console.error("");
|
|
115
|
+
console.error(" 1. 网络不通/防火墙拦截:");
|
|
116
|
+
console.error(" 检查:curl -I https://registry.npmjs.org/ws");
|
|
117
|
+
console.error("");
|
|
118
|
+
console.error(" 2. 公司内网/国内网络慢:换国内镜像重试");
|
|
119
|
+
console.error(" 命令:npx terminal-bridge-setup --registry=https://registry.npmmirror.com");
|
|
120
|
+
console.error("");
|
|
121
|
+
console.error(" 3. 需要代理:");
|
|
122
|
+
console.error(" 命令:npm config set proxy http://your-proxy:port");
|
|
123
|
+
console.error(" 然后重跑 npx terminal-bridge-setup");
|
|
124
|
+
console.error("");
|
|
125
|
+
fail("npm install 失败(见上方排查建议)");
|
|
99
126
|
}
|
|
100
127
|
ok("依赖安装完成");
|
|
101
128
|
}
|
package/package.json
CHANGED