@d5render/cli 0.1.84 → 0.1.85
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 +36 -2
- package/package.json +1 -1
package/bin/d5cli
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { argv, env, platform } from "node:process";
|
|
3
|
-
import { execSync, spawn } from "node:child_process";
|
|
3
|
+
import { execSync, spawn, spawnSync } from "node:child_process";
|
|
4
4
|
import { createHash } from "node:crypto";
|
|
5
5
|
import { copyFileSync, existsSync, mkdirSync, readFileSync, readdirSync, writeFileSync } from "node:fs";
|
|
6
6
|
import { dirname, join } from "node:path";
|
|
@@ -8,7 +8,7 @@ import { fileURLToPath } from "node:url";
|
|
|
8
8
|
|
|
9
9
|
//#region package.json
|
|
10
10
|
var name$1 = "@d5render/cli";
|
|
11
|
-
var version = "0.1.
|
|
11
|
+
var version = "0.1.85";
|
|
12
12
|
|
|
13
13
|
//#endregion
|
|
14
14
|
//#region packages/env.ts
|
|
@@ -311,10 +311,40 @@ async function deploy() {
|
|
|
311
311
|
//#endregion
|
|
312
312
|
//#region review/copilot/index.ts
|
|
313
313
|
const bind = "copilot";
|
|
314
|
+
const verifyPrompt = "Reply with OK only, no other text.";
|
|
314
315
|
/** 单引号包裹并转义,用于 shell 内联,避免子进程 env 被改写 */
|
|
315
316
|
function shellEscape(val) {
|
|
316
317
|
return `'${val.replace(/'/g, "'\\''")}'`;
|
|
317
318
|
}
|
|
319
|
+
/** 最简 copilot 调用(仅 -p),用于验证登录/env 是否可用 */
|
|
320
|
+
function runVerifySync() {
|
|
321
|
+
const verifyArgs = ["-p", verifyPrompt];
|
|
322
|
+
const opts = {
|
|
323
|
+
cwd: env.CI_PROJECT_DIR,
|
|
324
|
+
encoding: "utf8"
|
|
325
|
+
};
|
|
326
|
+
if (platform === "win32") {
|
|
327
|
+
const r = spawnSync(bind, verifyArgs, {
|
|
328
|
+
...opts,
|
|
329
|
+
shell: true
|
|
330
|
+
});
|
|
331
|
+
return {
|
|
332
|
+
code: r.status ?? -1,
|
|
333
|
+
out: r.stdout?.toString() ?? "",
|
|
334
|
+
err: r.stderr?.toString() ?? ""
|
|
335
|
+
};
|
|
336
|
+
}
|
|
337
|
+
const token = env.COPILOT_GITHUB_TOKEN || env.GH_TOKEN || env.GITHUB_TOKEN || env.GITHUB_COPILOT_TOKEN;
|
|
338
|
+
const r = spawnSync("sh", ["-c", `${token !== void 0 && token !== "" ? `export COPILOT_GITHUB_TOKEN=${shellEscape(token)} GH_TOKEN=${shellEscape(token)} GITHUB_TOKEN=${shellEscape(token)}; ` : ""}exec ${bind} ${verifyArgs.map((a) => shellEscape(a)).join(" ")}`], {
|
|
339
|
+
...opts,
|
|
340
|
+
env
|
|
341
|
+
});
|
|
342
|
+
return {
|
|
343
|
+
code: r.status ?? -1,
|
|
344
|
+
out: r.stdout?.toString() ?? "",
|
|
345
|
+
err: r.stderr?.toString() ?? ""
|
|
346
|
+
};
|
|
347
|
+
}
|
|
318
348
|
async function cli() {
|
|
319
349
|
await deploy();
|
|
320
350
|
const httpProxy = env.HTTP_PROXY || env.http_proxy || "";
|
|
@@ -322,6 +352,10 @@ async function cli() {
|
|
|
322
352
|
if (httpProxy) env.HTTP_PROXY = httpProxy;
|
|
323
353
|
if (httpsProxy) env.HTTPS_PROXY = httpsProxy;
|
|
324
354
|
console.log("@d5render/cli version:", VERSION);
|
|
355
|
+
const verify = runVerifySync();
|
|
356
|
+
console.log("copilot verify:", verify.code === 0 ? "OK" : `failed (code ${verify.code})`);
|
|
357
|
+
if (verify.out) console.log(verify.out.trim());
|
|
358
|
+
if (verify.err) console.error(verify.err.trim());
|
|
325
359
|
const args = [
|
|
326
360
|
...tools,
|
|
327
361
|
"-p",
|