@d5render/cli 0.1.55 → 0.1.57
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 +1 -50
- package/package.json +1 -1
package/bin/d5cli
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { execSync, spawn } from "node:child_process";
|
|
3
|
-
import { createConnection } from "node:net";
|
|
4
3
|
import { copyFileSync, existsSync, mkdirSync, readFileSync, readdirSync, rmSync, writeFileSync } from "node:fs";
|
|
5
4
|
import { dirname, join } from "node:path";
|
|
6
5
|
import { argv, env, platform } from "node:process";
|
|
@@ -108,7 +107,7 @@ function installCopilot() {
|
|
|
108
107
|
//#endregion
|
|
109
108
|
//#region package.json
|
|
110
109
|
var name = "@d5render/cli";
|
|
111
|
-
var version = "0.1.
|
|
110
|
+
var version = "0.1.57";
|
|
112
111
|
|
|
113
112
|
//#endregion
|
|
114
113
|
//#region packages/gitlab/url.ts
|
|
@@ -273,7 +272,6 @@ async function codereview() {
|
|
|
273
272
|
Otherwise, use chinese as default language to call the mcp tool '${name$1}-${report}'`;
|
|
274
273
|
const httpProxy = process.env.HTTP_PROXY || process.env.http_proxy || "";
|
|
275
274
|
const httpsProxy = process.env.HTTPS_PROXY || process.env.https_proxy || "";
|
|
276
|
-
await logProxyStatus(httpProxy, httpsProxy);
|
|
277
275
|
const copilot = spawn("node", [
|
|
278
276
|
findCopilopt(),
|
|
279
277
|
...tools,
|
|
@@ -301,53 +299,6 @@ Otherwise, use chinese as default language to call the mcp tool '${name$1}-${rep
|
|
|
301
299
|
copilot.on("close", (code) => res());
|
|
302
300
|
});
|
|
303
301
|
}
|
|
304
|
-
/** 代理排查:环境变量 + 检测代理是否在运行、子进程是否会走代理 */
|
|
305
|
-
async function logProxyStatus(httpProxy, httpsProxy) {
|
|
306
|
-
const tag = "[proxy]";
|
|
307
|
-
console.log(`${tag} -------- 代理排查 --------`);
|
|
308
|
-
console.log(`${tag} 当前进程 env: HTTP_PROXY = ${process.env.HTTP_PROXY ?? "(未设置)"}, http_proxy = ${process.env.http_proxy ?? "(未设置)"}`);
|
|
309
|
-
console.log(`${tag} 当前进程 env: HTTPS_PROXY = ${process.env.HTTPS_PROXY ?? "(未设置)"}, https_proxy = ${process.env.https_proxy ?? "(未设置)"}`);
|
|
310
|
-
console.log(`${tag} 传给子进程: HTTP_PROXY = ${httpProxy || "(空)"}, HTTPS_PROXY = ${httpsProxy || "(空)"}`);
|
|
311
|
-
const proxyUrl = httpsProxy || httpProxy;
|
|
312
|
-
if (!proxyUrl) {
|
|
313
|
-
console.log(`${tag} 结论: 未设置代理,子进程将直连外网,不会经代理`);
|
|
314
|
-
console.log(`${tag} ------------------------`);
|
|
315
|
-
return;
|
|
316
|
-
}
|
|
317
|
-
let host;
|
|
318
|
-
let port;
|
|
319
|
-
try {
|
|
320
|
-
const u = new URL(proxyUrl);
|
|
321
|
-
host = u.hostname || "127.0.0.1";
|
|
322
|
-
port = u.port ? parseInt(u.port, 10) : 7890;
|
|
323
|
-
} catch {
|
|
324
|
-
console.log(`${tag} 结论: 代理 URL 解析失败,子进程可能无法正确使用代理: ${proxyUrl}`);
|
|
325
|
-
console.log(`${tag} ------------------------`);
|
|
326
|
-
return;
|
|
327
|
-
}
|
|
328
|
-
if (await checkPortReachable(host, port)) {
|
|
329
|
-
console.log(`${tag} 代理检测: ${host}:${port} 可连接,代理服务应在运行`);
|
|
330
|
-
console.log(`${tag} 结论: 子进程已继承代理环境变量,请求应能通过代理发出`);
|
|
331
|
-
} else {
|
|
332
|
-
console.log(`${tag} 代理检测: ${host}:${port} 无法连接,可能代理未启动或地址/端口错误`);
|
|
333
|
-
console.log(`${tag} 结论: 子进程虽有代理变量,但代理不可达,请求可能失败或直连`);
|
|
334
|
-
}
|
|
335
|
-
console.log(`${tag} ------------------------`);
|
|
336
|
-
}
|
|
337
|
-
function checkPortReachable(host, port, timeoutMs = 3e3) {
|
|
338
|
-
return new Promise((resolve) => {
|
|
339
|
-
const socket = createConnection(port, host, () => {
|
|
340
|
-
socket.destroy();
|
|
341
|
-
resolve(true);
|
|
342
|
-
});
|
|
343
|
-
socket.setTimeout(timeoutMs);
|
|
344
|
-
socket.on("timeout", () => {
|
|
345
|
-
socket.destroy();
|
|
346
|
-
resolve(false);
|
|
347
|
-
});
|
|
348
|
-
socket.on("error", () => resolve(false));
|
|
349
|
-
});
|
|
350
|
-
}
|
|
351
302
|
function findCopilopt() {
|
|
352
303
|
let copilot = "";
|
|
353
304
|
try {
|