@bgicli/bgicli 2.2.9 → 2.2.10
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/dist/bgi.js +65 -1
- package/package.json +1 -1
package/dist/bgi.js
CHANGED
|
@@ -6935,6 +6935,8 @@ var source_default = chalk;
|
|
|
6935
6935
|
var import_fs5 = require("fs");
|
|
6936
6936
|
var import_path5 = require("path");
|
|
6937
6937
|
var import_os3 = require("os");
|
|
6938
|
+
var import_https2 = require("https");
|
|
6939
|
+
var import_child_process2 = require("child_process");
|
|
6938
6940
|
|
|
6939
6941
|
// node_modules/openai/internal/qs/formats.mjs
|
|
6940
6942
|
var default_format = "RFC3986";
|
|
@@ -15408,7 +15410,68 @@ function clearCheckpoints(sessionId) {
|
|
|
15408
15410
|
|
|
15409
15411
|
// src/index.ts
|
|
15410
15412
|
var import_fs6 = require("fs");
|
|
15411
|
-
var VERSION2 = "2.2.
|
|
15413
|
+
var VERSION2 = "2.2.10";
|
|
15414
|
+
function isNewer(latest, current) {
|
|
15415
|
+
const [lM, lm, lp] = latest.split(".").map(Number);
|
|
15416
|
+
const [cM, cm, cp] = current.split(".").map(Number);
|
|
15417
|
+
if (lM !== cM) return lM > cM;
|
|
15418
|
+
if (lm !== cm) return lm > cm;
|
|
15419
|
+
return lp > cp;
|
|
15420
|
+
}
|
|
15421
|
+
async function checkAndAutoUpdate() {
|
|
15422
|
+
let latest;
|
|
15423
|
+
try {
|
|
15424
|
+
latest = await new Promise((resolve3, reject) => {
|
|
15425
|
+
const req = (0, import_https2.get)(
|
|
15426
|
+
"https://registry.npmjs.org/@bgicli/bgicli/latest",
|
|
15427
|
+
{ headers: { "User-Agent": `bgicli/${VERSION2}` } },
|
|
15428
|
+
(res) => {
|
|
15429
|
+
const chunks = [];
|
|
15430
|
+
res.on("data", (c2) => chunks.push(c2));
|
|
15431
|
+
res.on("end", () => {
|
|
15432
|
+
try {
|
|
15433
|
+
resolve3(JSON.parse(Buffer.concat(chunks).toString()).version);
|
|
15434
|
+
} catch {
|
|
15435
|
+
reject(new Error("parse"));
|
|
15436
|
+
}
|
|
15437
|
+
});
|
|
15438
|
+
}
|
|
15439
|
+
);
|
|
15440
|
+
req.setTimeout(5e3, () => {
|
|
15441
|
+
req.destroy();
|
|
15442
|
+
reject(new Error("timeout"));
|
|
15443
|
+
});
|
|
15444
|
+
req.on("error", reject);
|
|
15445
|
+
});
|
|
15446
|
+
} catch {
|
|
15447
|
+
return;
|
|
15448
|
+
}
|
|
15449
|
+
if (!isNewer(latest, VERSION2)) return;
|
|
15450
|
+
process.stdout.write(
|
|
15451
|
+
source_default.cyan(`
|
|
15452
|
+
\u{1F504} \u53D1\u73B0\u65B0\u7248\u672C v${latest}\uFF08\u5F53\u524D v${VERSION2}\uFF09\uFF0C\u6B63\u5728\u81EA\u52A8\u66F4\u65B0...
|
|
15453
|
+
`)
|
|
15454
|
+
);
|
|
15455
|
+
const ok = await new Promise((resolve3) => {
|
|
15456
|
+
const isWin = process.platform === "win32";
|
|
15457
|
+
const child = (0, import_child_process2.spawn)(
|
|
15458
|
+
isWin ? "npm.cmd" : "npm",
|
|
15459
|
+
["install", "-g", `@bgicli/bgicli@${latest}`, "--registry", "https://registry.npmjs.org"],
|
|
15460
|
+
{ stdio: "inherit", shell: false }
|
|
15461
|
+
);
|
|
15462
|
+
child.on("close", (code) => resolve3(code === 0));
|
|
15463
|
+
child.on("error", () => resolve3(false));
|
|
15464
|
+
});
|
|
15465
|
+
if (ok) {
|
|
15466
|
+
process.stdout.write(source_default.green(` \u2713 \u5DF2\u66F4\u65B0\u81F3 v${latest}\uFF0C\u91CD\u542F bgi \u540E\u751F\u6548
|
|
15467
|
+
|
|
15468
|
+
`));
|
|
15469
|
+
} else {
|
|
15470
|
+
process.stdout.write(source_default.yellow(` \u26A0 \u81EA\u52A8\u66F4\u65B0\u5931\u8D25\uFF0C\u8BF7\u624B\u52A8\u8FD0\u884C: npm install -g @bgicli/bgicli
|
|
15471
|
+
|
|
15472
|
+
`));
|
|
15473
|
+
}
|
|
15474
|
+
}
|
|
15412
15475
|
var SESSION_CTX = {
|
|
15413
15476
|
id: "",
|
|
15414
15477
|
createdAt: "",
|
|
@@ -16629,6 +16692,7 @@ ${summary}` },
|
|
|
16629
16692
|
async function main() {
|
|
16630
16693
|
installBundledData();
|
|
16631
16694
|
printBanner();
|
|
16695
|
+
await checkAndAutoUpdate();
|
|
16632
16696
|
const rl = (0, import_readline.createInterface)({
|
|
16633
16697
|
input: process.stdin,
|
|
16634
16698
|
output: process.stdout,
|