@d5render/cli 0.1.55 → 0.1.56
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/d5cli +59 -4
- package/package.json +1 -1
package/bin/d5cli
CHANGED
|
@@ -108,7 +108,7 @@ function installCopilot() {
|
|
|
108
108
|
//#endregion
|
|
109
109
|
//#region package.json
|
|
110
110
|
var name = "@d5render/cli";
|
|
111
|
-
var version = "0.1.
|
|
111
|
+
var version = "0.1.56";
|
|
112
112
|
|
|
113
113
|
//#endregion
|
|
114
114
|
//#region packages/gitlab/url.ts
|
|
@@ -305,12 +305,16 @@ Otherwise, use chinese as default language to call the mcp tool '${name$1}-${rep
|
|
|
305
305
|
async function logProxyStatus(httpProxy, httpsProxy) {
|
|
306
306
|
const tag = "[proxy]";
|
|
307
307
|
console.log(`${tag} -------- 代理排查 --------`);
|
|
308
|
+
const proxyKeys = Object.keys(process.env).filter((k) => /proxy/i.test(k));
|
|
309
|
+
if (proxyKeys.length > 0) console.log(`${tag} 当前进程里含 proxy 的环境变量名: ${proxyKeys.join(", ")}`);
|
|
310
|
+
else console.log(`${tag} 当前进程里没有任何含 proxy 的环境变量(GitLab 未传入或未生效)`);
|
|
308
311
|
console.log(`${tag} 当前进程 env: HTTP_PROXY = ${process.env.HTTP_PROXY ?? "(未设置)"}, http_proxy = ${process.env.http_proxy ?? "(未设置)"}`);
|
|
309
312
|
console.log(`${tag} 当前进程 env: HTTPS_PROXY = ${process.env.HTTPS_PROXY ?? "(未设置)"}, https_proxy = ${process.env.https_proxy ?? "(未设置)"}`);
|
|
310
313
|
console.log(`${tag} 传给子进程: HTTP_PROXY = ${httpProxy || "(空)"}, HTTPS_PROXY = ${httpsProxy || "(空)"}`);
|
|
311
314
|
const proxyUrl = httpsProxy || httpProxy;
|
|
312
315
|
if (!proxyUrl) {
|
|
313
316
|
console.log(`${tag} 结论: 未设置代理,子进程将直连外网,不会经代理`);
|
|
317
|
+
await logGitHubReachable(tag, false);
|
|
314
318
|
console.log(`${tag} ------------------------`);
|
|
315
319
|
return;
|
|
316
320
|
}
|
|
@@ -325,13 +329,17 @@ async function logProxyStatus(httpProxy, httpsProxy) {
|
|
|
325
329
|
console.log(`${tag} ------------------------`);
|
|
326
330
|
return;
|
|
327
331
|
}
|
|
328
|
-
|
|
332
|
+
const reachable = await checkPortReachable(host, port);
|
|
333
|
+
if (reachable) {
|
|
329
334
|
console.log(`${tag} 代理检测: ${host}:${port} 可连接,代理服务应在运行`);
|
|
330
|
-
|
|
335
|
+
logPortListener(port, tag);
|
|
331
336
|
} else {
|
|
332
337
|
console.log(`${tag} 代理检测: ${host}:${port} 无法连接,可能代理未启动或地址/端口错误`);
|
|
333
|
-
|
|
338
|
+
logPortListener(port, tag);
|
|
334
339
|
}
|
|
340
|
+
await logGitHubReachable(tag, !!proxyUrl);
|
|
341
|
+
if (reachable) console.log(`${tag} 结论: 子进程已继承代理环境变量,请求应能通过代理发出`);
|
|
342
|
+
else console.log(`${tag} 结论: 子进程虽有代理变量,但代理不可达,请求可能失败或直连`);
|
|
335
343
|
console.log(`${tag} ------------------------`);
|
|
336
344
|
}
|
|
337
345
|
function checkPortReachable(host, port, timeoutMs = 3e3) {
|
|
@@ -348,6 +356,53 @@ function checkPortReachable(host, port, timeoutMs = 3e3) {
|
|
|
348
356
|
socket.on("error", () => resolve(false));
|
|
349
357
|
});
|
|
350
358
|
}
|
|
359
|
+
/** 打印指定端口上的监听进程(如 7890 上是 mihomo) */
|
|
360
|
+
function logPortListener(port, tag) {
|
|
361
|
+
try {
|
|
362
|
+
if (platform === "win32") {
|
|
363
|
+
const out = execSync(`netstat -ano | findstr :${port}`, {
|
|
364
|
+
encoding: "utf8",
|
|
365
|
+
maxBuffer: 65536
|
|
366
|
+
});
|
|
367
|
+
console.log(`${tag} 端口 ${port} 监听情况 (netstat):\n${out.trim().split("\n").slice(0, 10).join("\n")}`);
|
|
368
|
+
return;
|
|
369
|
+
}
|
|
370
|
+
const lsof = execSync(`lsof -i :${port} 2>/dev/null`, {
|
|
371
|
+
encoding: "utf8",
|
|
372
|
+
maxBuffer: 65536
|
|
373
|
+
}).trim();
|
|
374
|
+
if (lsof) {
|
|
375
|
+
console.log(`${tag} 端口 ${port} 监听进程 (lsof):\n${lsof}`);
|
|
376
|
+
return;
|
|
377
|
+
}
|
|
378
|
+
} catch {}
|
|
379
|
+
try {
|
|
380
|
+
const ss = execSync(`ss -tlnp 2>/dev/null | grep :${port}`, {
|
|
381
|
+
encoding: "utf8",
|
|
382
|
+
maxBuffer: 65536
|
|
383
|
+
}).trim();
|
|
384
|
+
if (ss) console.log(`${tag} 端口 ${port} 监听进程 (ss):\n${ss}`);
|
|
385
|
+
else console.log(`${tag} 端口 ${port}: 无法获取监听进程 (无 lsof/ss 或无权限)`);
|
|
386
|
+
} catch {
|
|
387
|
+
console.log(`${tag} 端口 ${port}: 无法获取监听进程 (无 lsof/ss 或无权限)`);
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
/** 检测 GitHub 是否可访问(Node 内置 fetch 不走代理,此处为直连可达性) */
|
|
391
|
+
async function logGitHubReachable(tag, proxySet) {
|
|
392
|
+
const url = "https://api.github.com";
|
|
393
|
+
const note = proxySet ? " (当前进程已设代理,但 Node fetch 不经过代理,此处为直连)" : " (直连)";
|
|
394
|
+
try {
|
|
395
|
+
const ac = new AbortController();
|
|
396
|
+
const t = setTimeout(() => ac.abort(), 1e4);
|
|
397
|
+
const res = await fetch(url, { signal: ac.signal });
|
|
398
|
+
clearTimeout(t);
|
|
399
|
+
const ok = res.ok || res.status === 403;
|
|
400
|
+
console.log(`${tag} GitHub 连通性${note}: ${ok ? "可调通" : "异常"} status=${res.status}`);
|
|
401
|
+
} catch (e) {
|
|
402
|
+
const msg = e instanceof Error ? e.message : String(e);
|
|
403
|
+
console.log(`${tag} GitHub 连通性${note}: 调不通 - ${msg}`);
|
|
404
|
+
}
|
|
405
|
+
}
|
|
351
406
|
function findCopilopt() {
|
|
352
407
|
let copilot = "";
|
|
353
408
|
try {
|