terminal-bridge-setup 3.3.2 → 3.3.4

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 CHANGED
@@ -126,23 +126,38 @@ function installProxyDeps() {
126
126
  // 支持 --registry 透传(国内网络/公司内网常用)
127
127
  // 用法:npx terminal-bridge-setup --registry=https://registry.npmmirror.com
128
128
  const registryArg = process.argv.find(a => a.startsWith("--registry="));
129
- const npmArgs = ["install", "--no-audit", "--no-fund"];
129
+ const baseArgs = ["install", "--no-audit", "--no-fund"];
130
+ const runNpm = (args) => {
131
+ // Windows 的 npm 是 npm.cmd 批处理,spawn 不带 shell 无法启动
132
+ // (表现为"运行 npm install ..."后无任何输出直接失败,实测踩过)。
133
+ // shell:true 下走 cmd 解析;registry 参数先过白名单校验防 shell 注入。
134
+ const safeArgs = args.filter(a =>
135
+ !a.startsWith("--registry=") || /^--registry=https?:\/\/[\w.\-/:]+$/.test(a));
136
+ console.log(c.dim(` 运行 npm ${safeArgs.join(" ")} ...`));
137
+ return spawnSync("npm", safeArgs, { cwd: proxyDir, stdio: "inherit", shell: true });
138
+ };
139
+
140
+ let result;
130
141
  if (registryArg) {
131
- npmArgs.push(registryArg);
132
142
  console.log(c.dim(` 使用 registry: ${registryArg.split("=")[1]}`));
143
+ result = runNpm([...baseArgs, registryArg]);
133
144
  } else {
134
- npmArgs.push("--silent");
145
+ // 不加 --silent:私有源缺包/认证失败等真实错误必须可见,不能吞掉
146
+ result = runNpm(baseArgs);
147
+ if (result.status !== 0) {
148
+ // 内网镜像未同步/缺包是高频原因(verdaccio 同步延迟实测踩过),
149
+ // 自动用官方源兜底重试一次再判失败
150
+ console.log(c.yellow(" 默认 registry 安装失败,用官方源 npmjs.org 重试..."));
151
+ result = runNpm([...baseArgs, "--registry=https://registry.npmjs.org"]);
152
+ }
135
153
  }
136
154
 
137
- console.log(c.dim(" 运行 npm install ..."));
138
- const result = spawnSync("npm", npmArgs, {
139
- cwd: proxyDir,
140
- stdio: "inherit",
141
- });
142
-
143
- if (result.status !== 0) {
144
- // 失败时给出明确的排查建议
145
- console.error("");
155
+ if (result.status !== 0 || result.error) {
156
+ if (result.error) {
157
+ console.error(c.red(" ✗ 无法启动 npm:" + result.error.message));
158
+ console.error(c.yellow(` 手动修复:cd "${join(INSTALL_DIR, "proxy")}" && npm install`));
159
+ fail("npm 无法启动");
160
+ }
146
161
  console.error(c.red(" ✗ npm install 失败"));
147
162
  console.error(c.yellow(" 常见原因和解决方法:"));
148
163
  console.error("");
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "manifest_version": 3,
3
3
  "name": "JumpServer 终端桥接",
4
- "version": "3.3.2",
4
+ "version": "3.3.4",
5
5
  "description": "终端桥接:JumpServer / Arthas / Yearning,让 Agent 能通过浏览器执行命令、收结果与查数据",
6
6
  "key": "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAtsnqR6PcFUueZwYria79tVbstvjk+tM7PpvIXILm5xbd6bAdjDIhzg3lsnKioVfvxjfvT+s6vJsiOYa9ojVZyJMFc5m/05TYqr770ovYwQmz0e88fmiy6dUoSulbtKvBCSLbN6OOL7u+ul8ixLZ/HautxSmou/eNgAFPmhE+4UueE7wfCqcgMYvjLvEzlqTVumMW+5LKw9YsRk6WhHPghY1a3MVUn3eQOWXBtQTEUy3wBM3v4wHxLwDeinVOR4f/P87IlUNo84C5DeimoFit0qCj3K04hS8MIYCLCYZc3v9ftRJDJBkAoah6Eaqj7JajbS3KvLR1ctOYfDhubgmURQIDAQAB",
7
7
  "permissions": ["debugger", "tabs", "alarms", "webNavigation", "nativeMessaging", "scripting", "downloads", "storage"],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "terminal-bridge-setup",
3
- "version": "3.3.2",
3
+ "version": "3.3.4",
4
4
  "description": "一次性安装器:释放终端桥接(JumpServer / Arthas / Yearning)的本地代理 + Chrome 插件,并注册 native messaging host。让 Agent 能通过浏览器 xterm 终端执行命令并拿回输出。",
5
5
  "license": "MIT",
6
6
  "author": "encorearon",