@dosu/cli 0.8.0 → 0.9.1
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/dosu.js +166 -62
- package/package.json +1 -1
package/bin/dosu.js
CHANGED
|
@@ -2192,7 +2192,7 @@ var require_picocolors = __commonJS((exports, module) => {
|
|
|
2192
2192
|
function getVersionString() {
|
|
2193
2193
|
return `v${VERSION}`;
|
|
2194
2194
|
}
|
|
2195
|
-
var VERSION = "0.
|
|
2195
|
+
var VERSION = "0.9.1";
|
|
2196
2196
|
|
|
2197
2197
|
// src/debug/logger.ts
|
|
2198
2198
|
import {
|
|
@@ -3485,17 +3485,17 @@ import y2 from "node:process";
|
|
|
3485
3485
|
function ce() {
|
|
3486
3486
|
return y2.platform !== "win32" ? y2.env.TERM !== "linux" : !!y2.env.CI || !!y2.env.WT_SESSION || !!y2.env.TERMINUS_SUBLIME || y2.env.ConEmuTask === "{cmd::Cmder}" || y2.env.TERM_PROGRAM === "Terminus-Sublime" || y2.env.TERM_PROGRAM === "vscode" || y2.env.TERM === "xterm-256color" || y2.env.TERM === "alacritty" || y2.env.TERMINAL_EMULATOR === "JetBrains-JediTerm";
|
|
3487
3487
|
}
|
|
3488
|
-
var
|
|
3488
|
+
var import_picocolors3, import_sisteransi2, V2, u = (t, n) => V2 ? t : n, le, L2, W2, C2, ue, o, d2, k2, P2, A2, T, F, $e, _2, me, de, pe, q, D, U, K2, b2 = (t) => {
|
|
3489
3489
|
switch (t) {
|
|
3490
3490
|
case "initial":
|
|
3491
3491
|
case "active":
|
|
3492
|
-
return
|
|
3492
|
+
return import_picocolors3.default.cyan(le);
|
|
3493
3493
|
case "cancel":
|
|
3494
|
-
return
|
|
3494
|
+
return import_picocolors3.default.red(L2);
|
|
3495
3495
|
case "error":
|
|
3496
|
-
return
|
|
3496
|
+
return import_picocolors3.default.yellow(W2);
|
|
3497
3497
|
case "submit":
|
|
3498
|
-
return
|
|
3498
|
+
return import_picocolors3.default.green(C2);
|
|
3499
3499
|
}
|
|
3500
3500
|
}, G2 = (t) => {
|
|
3501
3501
|
const { cursor: n, options: r, style: i } = t, s = t.maxItems ?? Number.POSITIVE_INFINITY, c = Math.max(process.stdout.rows - 4, 0), a = Math.min(c, Math.max(s, 5));
|
|
@@ -3504,23 +3504,23 @@ var import_picocolors2, import_sisteransi2, V2, u = (t, n) => V2 ? t : n, le, L2
|
|
|
3504
3504
|
const $2 = a < r.length && l2 > 0, g2 = a < r.length && l2 + a < r.length;
|
|
3505
3505
|
return r.slice(l2, l2 + a).map((p2, v, f) => {
|
|
3506
3506
|
const j2 = v === 0 && $2, E = v === f.length - 1 && g2;
|
|
3507
|
-
return j2 || E ?
|
|
3507
|
+
return j2 || E ? import_picocolors3.default.dim("...") : i(p2, v + l2 === n);
|
|
3508
3508
|
});
|
|
3509
3509
|
}, ye = (t) => {
|
|
3510
3510
|
const n = t.active ?? "Yes", r = t.inactive ?? "No";
|
|
3511
3511
|
return new dD({ active: n, inactive: r, initialValue: t.initialValue ?? true, render() {
|
|
3512
|
-
const i = `${
|
|
3512
|
+
const i = `${import_picocolors3.default.gray(o)}
|
|
3513
3513
|
${b2(this.state)} ${t.message}
|
|
3514
3514
|
`, s = this.value ? n : r;
|
|
3515
3515
|
switch (this.state) {
|
|
3516
3516
|
case "submit":
|
|
3517
|
-
return `${i}${
|
|
3517
|
+
return `${i}${import_picocolors3.default.gray(o)} ${import_picocolors3.default.dim(s)}`;
|
|
3518
3518
|
case "cancel":
|
|
3519
|
-
return `${i}${
|
|
3520
|
-
${
|
|
3519
|
+
return `${i}${import_picocolors3.default.gray(o)} ${import_picocolors3.default.strikethrough(import_picocolors3.default.dim(s))}
|
|
3520
|
+
${import_picocolors3.default.gray(o)}`;
|
|
3521
3521
|
default:
|
|
3522
|
-
return `${i}${
|
|
3523
|
-
${
|
|
3522
|
+
return `${i}${import_picocolors3.default.cyan(o)} ${this.value ? `${import_picocolors3.default.green(k2)} ${n}` : `${import_picocolors3.default.dim(P2)} ${import_picocolors3.default.dim(n)}`} ${import_picocolors3.default.dim("/")} ${this.value ? `${import_picocolors3.default.dim(P2)} ${import_picocolors3.default.dim(r)}` : `${import_picocolors3.default.green(k2)} ${r}`}
|
|
3523
|
+
${import_picocolors3.default.cyan(d2)}
|
|
3524
3524
|
`;
|
|
3525
3525
|
}
|
|
3526
3526
|
} }).prompt();
|
|
@@ -3529,43 +3529,43 @@ ${import_picocolors2.default.cyan(d2)}
|
|
|
3529
3529
|
const s = r.label ?? String(r.value);
|
|
3530
3530
|
switch (i) {
|
|
3531
3531
|
case "selected":
|
|
3532
|
-
return `${
|
|
3532
|
+
return `${import_picocolors3.default.dim(s)}`;
|
|
3533
3533
|
case "active":
|
|
3534
|
-
return `${
|
|
3534
|
+
return `${import_picocolors3.default.green(k2)} ${s} ${r.hint ? import_picocolors3.default.dim(`(${r.hint})`) : ""}`;
|
|
3535
3535
|
case "cancelled":
|
|
3536
|
-
return `${
|
|
3536
|
+
return `${import_picocolors3.default.strikethrough(import_picocolors3.default.dim(s))}`;
|
|
3537
3537
|
default:
|
|
3538
|
-
return `${
|
|
3538
|
+
return `${import_picocolors3.default.dim(P2)} ${import_picocolors3.default.dim(s)}`;
|
|
3539
3539
|
}
|
|
3540
3540
|
};
|
|
3541
3541
|
return new LD({ options: t.options, initialValue: t.initialValue, render() {
|
|
3542
|
-
const r = `${
|
|
3542
|
+
const r = `${import_picocolors3.default.gray(o)}
|
|
3543
3543
|
${b2(this.state)} ${t.message}
|
|
3544
3544
|
`;
|
|
3545
3545
|
switch (this.state) {
|
|
3546
3546
|
case "submit":
|
|
3547
|
-
return `${r}${
|
|
3547
|
+
return `${r}${import_picocolors3.default.gray(o)} ${n(this.options[this.cursor], "selected")}`;
|
|
3548
3548
|
case "cancel":
|
|
3549
|
-
return `${r}${
|
|
3550
|
-
${
|
|
3549
|
+
return `${r}${import_picocolors3.default.gray(o)} ${n(this.options[this.cursor], "cancelled")}
|
|
3550
|
+
${import_picocolors3.default.gray(o)}`;
|
|
3551
3551
|
default:
|
|
3552
|
-
return `${r}${
|
|
3553
|
-
${
|
|
3554
|
-
${
|
|
3552
|
+
return `${r}${import_picocolors3.default.cyan(o)} ${G2({ cursor: this.cursor, options: this.options, maxItems: t.maxItems, style: (i, s) => n(i, s ? "active" : "inactive") }).join(`
|
|
3553
|
+
${import_picocolors3.default.cyan(o)} `)}
|
|
3554
|
+
${import_picocolors3.default.cyan(d2)}
|
|
3555
3555
|
`;
|
|
3556
3556
|
}
|
|
3557
3557
|
} }).prompt();
|
|
3558
3558
|
}, fe = (t) => {
|
|
3559
3559
|
const n = (r, i) => {
|
|
3560
3560
|
const s = r.label ?? String(r.value);
|
|
3561
|
-
return i === "active" ? `${
|
|
3561
|
+
return i === "active" ? `${import_picocolors3.default.cyan(A2)} ${s} ${r.hint ? import_picocolors3.default.dim(`(${r.hint})`) : ""}` : i === "selected" ? `${import_picocolors3.default.green(T)} ${import_picocolors3.default.dim(s)} ${r.hint ? import_picocolors3.default.dim(`(${r.hint})`) : ""}` : i === "cancelled" ? `${import_picocolors3.default.strikethrough(import_picocolors3.default.dim(s))}` : i === "active-selected" ? `${import_picocolors3.default.green(T)} ${s} ${r.hint ? import_picocolors3.default.dim(`(${r.hint})`) : ""}` : i === "submitted" ? `${import_picocolors3.default.dim(s)}` : `${import_picocolors3.default.dim(F)} ${import_picocolors3.default.dim(s)}`;
|
|
3562
3562
|
};
|
|
3563
3563
|
return new SD({ options: t.options, initialValues: t.initialValues, required: t.required ?? true, cursorAt: t.cursorAt, validate(r) {
|
|
3564
3564
|
if (this.required && r.length === 0)
|
|
3565
3565
|
return `Please select at least one option.
|
|
3566
|
-
${
|
|
3566
|
+
${import_picocolors3.default.reset(import_picocolors3.default.dim(`Press ${import_picocolors3.default.gray(import_picocolors3.default.bgWhite(import_picocolors3.default.inverse(" space ")))} to select, ${import_picocolors3.default.gray(import_picocolors3.default.bgWhite(import_picocolors3.default.inverse(" enter ")))} to submit`))}`;
|
|
3567
3567
|
}, render() {
|
|
3568
|
-
const r = `${
|
|
3568
|
+
const r = `${import_picocolors3.default.gray(o)}
|
|
3569
3569
|
${b2(this.state)} ${t.message}
|
|
3570
3570
|
`, i = (s, c) => {
|
|
3571
3571
|
const a = this.value.includes(s.value);
|
|
@@ -3573,34 +3573,34 @@ ${b2(this.state)} ${t.message}
|
|
|
3573
3573
|
};
|
|
3574
3574
|
switch (this.state) {
|
|
3575
3575
|
case "submit":
|
|
3576
|
-
return `${r}${
|
|
3576
|
+
return `${r}${import_picocolors3.default.gray(o)} ${this.options.filter(({ value: s }) => this.value.includes(s)).map((s) => n(s, "submitted")).join(import_picocolors3.default.dim(", ")) || import_picocolors3.default.dim("none")}`;
|
|
3577
3577
|
case "cancel": {
|
|
3578
|
-
const s = this.options.filter(({ value: c }) => this.value.includes(c)).map((c) => n(c, "cancelled")).join(
|
|
3579
|
-
return `${r}${
|
|
3580
|
-
${
|
|
3578
|
+
const s = this.options.filter(({ value: c }) => this.value.includes(c)).map((c) => n(c, "cancelled")).join(import_picocolors3.default.dim(", "));
|
|
3579
|
+
return `${r}${import_picocolors3.default.gray(o)} ${s.trim() ? `${s}
|
|
3580
|
+
${import_picocolors3.default.gray(o)}` : ""}`;
|
|
3581
3581
|
}
|
|
3582
3582
|
case "error": {
|
|
3583
3583
|
const s = this.error.split(`
|
|
3584
|
-
`).map((c, a) => a === 0 ? `${
|
|
3584
|
+
`).map((c, a) => a === 0 ? `${import_picocolors3.default.yellow(d2)} ${import_picocolors3.default.yellow(c)}` : ` ${c}`).join(`
|
|
3585
3585
|
`);
|
|
3586
|
-
return `${r +
|
|
3587
|
-
${
|
|
3586
|
+
return `${r + import_picocolors3.default.yellow(o)} ${G2({ options: this.options, cursor: this.cursor, maxItems: t.maxItems, style: i }).join(`
|
|
3587
|
+
${import_picocolors3.default.yellow(o)} `)}
|
|
3588
3588
|
${s}
|
|
3589
3589
|
`;
|
|
3590
3590
|
}
|
|
3591
3591
|
default:
|
|
3592
|
-
return `${r}${
|
|
3593
|
-
${
|
|
3594
|
-
${
|
|
3592
|
+
return `${r}${import_picocolors3.default.cyan(o)} ${G2({ options: this.options, cursor: this.cursor, maxItems: t.maxItems, style: i }).join(`
|
|
3593
|
+
${import_picocolors3.default.cyan(o)} `)}
|
|
3594
|
+
${import_picocolors3.default.cyan(d2)}
|
|
3595
3595
|
`;
|
|
3596
3596
|
}
|
|
3597
3597
|
} }).prompt();
|
|
3598
3598
|
}, Ie = (t = "") => {
|
|
3599
|
-
process.stdout.write(`${
|
|
3599
|
+
process.stdout.write(`${import_picocolors3.default.gray(ue)} ${t}
|
|
3600
3600
|
`);
|
|
3601
3601
|
}, Se = (t = "") => {
|
|
3602
|
-
process.stdout.write(`${
|
|
3603
|
-
${
|
|
3602
|
+
process.stdout.write(`${import_picocolors3.default.gray(o)}
|
|
3603
|
+
${import_picocolors3.default.gray(d2)} ${t}
|
|
3604
3604
|
|
|
3605
3605
|
`);
|
|
3606
3606
|
}, M2, J2, Y2 = ({ indicator: t = "dots" } = {}) => {
|
|
@@ -3625,14 +3625,14 @@ ${import_picocolors2.default.gray(d2)} ${t}
|
|
|
3625
3625
|
const h2 = (performance.now() - m2) / 1000, w2 = Math.floor(h2 / 60), I2 = Math.floor(h2 % 60);
|
|
3626
3626
|
return w2 > 0 ? `[${w2}m ${I2}s]` : `[${I2}s]`;
|
|
3627
3627
|
}, H2 = (m2 = "") => {
|
|
3628
|
-
a = true, s = fD(), l2 = R2(m2), g2 = performance.now(), process.stdout.write(`${
|
|
3628
|
+
a = true, s = fD(), l2 = R2(m2), g2 = performance.now(), process.stdout.write(`${import_picocolors3.default.gray(o)}
|
|
3629
3629
|
`);
|
|
3630
3630
|
let h2 = 0, w2 = 0;
|
|
3631
3631
|
j2(), c = setInterval(() => {
|
|
3632
3632
|
if (i && l2 === $2)
|
|
3633
3633
|
return;
|
|
3634
3634
|
B2(), $2 = l2;
|
|
3635
|
-
const I2 =
|
|
3635
|
+
const I2 = import_picocolors3.default.magenta(n[h2]);
|
|
3636
3636
|
if (i)
|
|
3637
3637
|
process.stdout.write(`${I2} ${l2}...`);
|
|
3638
3638
|
else if (t === "timer")
|
|
@@ -3645,7 +3645,7 @@ ${import_picocolors2.default.gray(d2)} ${t}
|
|
|
3645
3645
|
}, r);
|
|
3646
3646
|
}, N2 = (m2 = "", h2 = 0) => {
|
|
3647
3647
|
a = false, clearInterval(c), B2();
|
|
3648
|
-
const w2 = h2 === 0 ?
|
|
3648
|
+
const w2 = h2 === 0 ? import_picocolors3.default.green(C2) : h2 === 1 ? import_picocolors3.default.red(L2) : import_picocolors3.default.red(W2);
|
|
3649
3649
|
l2 = R2(m2 ?? l2), t === "timer" ? process.stdout.write(`${w2} ${l2} ${O2(g2)}
|
|
3650
3650
|
`) : process.stdout.write(`${w2} ${l2}
|
|
3651
3651
|
`), E(), s();
|
|
@@ -3657,7 +3657,7 @@ ${import_picocolors2.default.gray(d2)} ${t}
|
|
|
3657
3657
|
var init_dist2 = __esm(() => {
|
|
3658
3658
|
init_dist();
|
|
3659
3659
|
init_dist();
|
|
3660
|
-
|
|
3660
|
+
import_picocolors3 = __toESM(require_picocolors(), 1);
|
|
3661
3661
|
import_sisteransi2 = __toESM(require_src(), 1);
|
|
3662
3662
|
V2 = ce();
|
|
3663
3663
|
le = u("◆", "*");
|
|
@@ -3681,30 +3681,30 @@ var init_dist2 = __esm(() => {
|
|
|
3681
3681
|
D = u("◆", "*");
|
|
3682
3682
|
U = u("▲", "!");
|
|
3683
3683
|
K2 = u("■", "x");
|
|
3684
|
-
M2 = { message: (t = "", { symbol: n =
|
|
3685
|
-
const r = [`${
|
|
3684
|
+
M2 = { message: (t = "", { symbol: n = import_picocolors3.default.gray(o) } = {}) => {
|
|
3685
|
+
const r = [`${import_picocolors3.default.gray(o)}`];
|
|
3686
3686
|
if (t) {
|
|
3687
3687
|
const [i, ...s] = t.split(`
|
|
3688
3688
|
`);
|
|
3689
|
-
r.push(`${n} ${i}`, ...s.map((c) => `${
|
|
3689
|
+
r.push(`${n} ${i}`, ...s.map((c) => `${import_picocolors3.default.gray(o)} ${c}`));
|
|
3690
3690
|
}
|
|
3691
3691
|
process.stdout.write(`${r.join(`
|
|
3692
3692
|
`)}
|
|
3693
3693
|
`);
|
|
3694
3694
|
}, info: (t) => {
|
|
3695
|
-
M2.message(t, { symbol:
|
|
3695
|
+
M2.message(t, { symbol: import_picocolors3.default.blue(q) });
|
|
3696
3696
|
}, success: (t) => {
|
|
3697
|
-
M2.message(t, { symbol:
|
|
3697
|
+
M2.message(t, { symbol: import_picocolors3.default.green(D) });
|
|
3698
3698
|
}, step: (t) => {
|
|
3699
|
-
M2.message(t, { symbol:
|
|
3699
|
+
M2.message(t, { symbol: import_picocolors3.default.green(C2) });
|
|
3700
3700
|
}, warn: (t) => {
|
|
3701
|
-
M2.message(t, { symbol:
|
|
3701
|
+
M2.message(t, { symbol: import_picocolors3.default.yellow(U) });
|
|
3702
3702
|
}, warning: (t) => {
|
|
3703
3703
|
M2.warn(t);
|
|
3704
3704
|
}, error: (t) => {
|
|
3705
|
-
M2.message(t, { symbol:
|
|
3705
|
+
M2.message(t, { symbol: import_picocolors3.default.red(K2) });
|
|
3706
3706
|
} };
|
|
3707
|
-
J2 = `${
|
|
3707
|
+
J2 = `${import_picocolors3.default.gray(o)} `;
|
|
3708
3708
|
});
|
|
3709
3709
|
|
|
3710
3710
|
// src/client/client.ts
|
|
@@ -3859,14 +3859,14 @@ var init_client = __esm(() => {
|
|
|
3859
3859
|
|
|
3860
3860
|
// src/setup/styles.ts
|
|
3861
3861
|
function dim(msg) {
|
|
3862
|
-
return
|
|
3862
|
+
return import_picocolors4.default.dim(msg);
|
|
3863
3863
|
}
|
|
3864
3864
|
function info(msg) {
|
|
3865
|
-
return
|
|
3865
|
+
return import_picocolors4.default.cyan(msg);
|
|
3866
3866
|
}
|
|
3867
|
-
var
|
|
3867
|
+
var import_picocolors4;
|
|
3868
3868
|
var init_styles = __esm(() => {
|
|
3869
|
-
|
|
3869
|
+
import_picocolors4 = __toESM(require_picocolors(), 1);
|
|
3870
3870
|
});
|
|
3871
3871
|
|
|
3872
3872
|
// src/auth/server.ts
|
|
@@ -5028,7 +5028,7 @@ __export(exports_tui, {
|
|
|
5028
5028
|
handleLogout: () => handleLogout
|
|
5029
5029
|
});
|
|
5030
5030
|
async function runTUI() {
|
|
5031
|
-
console.log(
|
|
5031
|
+
console.log(import_picocolors5.default.magenta(LOGO));
|
|
5032
5032
|
const cfg = loadConfig();
|
|
5033
5033
|
if (!isAuthenticated(cfg)) {
|
|
5034
5034
|
await handleAuthenticate(cfg);
|
|
@@ -5125,7 +5125,7 @@ function handleLogout(cfg) {
|
|
|
5125
5125
|
saveConfig(cfg);
|
|
5126
5126
|
M2.success("Credentials cleared.");
|
|
5127
5127
|
}
|
|
5128
|
-
var
|
|
5128
|
+
var import_picocolors5, LOGO = `
|
|
5129
5129
|
/$$$$$$$
|
|
5130
5130
|
| $$__ $$
|
|
5131
5131
|
| $$ \\ $$ /$$$$$$ /$$$$$$$ /$$ /$$
|
|
@@ -5140,11 +5140,11 @@ var init_tui = __esm(() => {
|
|
|
5140
5140
|
init_client();
|
|
5141
5141
|
init_config();
|
|
5142
5142
|
init_flow2();
|
|
5143
|
-
|
|
5143
|
+
import_picocolors5 = __toESM(require_picocolors(), 1);
|
|
5144
5144
|
});
|
|
5145
5145
|
|
|
5146
5146
|
// src/cli/cli.ts
|
|
5147
|
-
import { readFileSync as
|
|
5147
|
+
import { readFileSync as readFileSync6, unlinkSync } from "node:fs";
|
|
5148
5148
|
|
|
5149
5149
|
// node_modules/commander/esm.mjs
|
|
5150
5150
|
var import__ = __toESM(require_commander(), 1);
|
|
@@ -5166,11 +5166,115 @@ var {
|
|
|
5166
5166
|
init_config();
|
|
5167
5167
|
init_logger();
|
|
5168
5168
|
init_providers();
|
|
5169
|
+
|
|
5170
|
+
// src/version/update-check.ts
|
|
5171
|
+
init_config();
|
|
5172
|
+
init_logger();
|
|
5173
|
+
var import_picocolors2 = __toESM(require_picocolors(), 1);
|
|
5174
|
+
import { existsSync as existsSync7, mkdirSync as mkdirSync5, readFileSync as readFileSync5, writeFileSync as writeFileSync5 } from "node:fs";
|
|
5175
|
+
import { join as join17 } from "node:path";
|
|
5176
|
+
var CACHE_FILENAME = "update-check.json";
|
|
5177
|
+
var CHECK_INTERVAL_MS = 24 * 60 * 60 * 1000;
|
|
5178
|
+
var FETCH_TIMEOUT_MS = 5000;
|
|
5179
|
+
var REGISTRY_URL = "https://registry.npmjs.org/-/package/@dosu/cli/dist-tags";
|
|
5180
|
+
function stripPrerelease(version) {
|
|
5181
|
+
return version.replace(/[-+].*$/, "");
|
|
5182
|
+
}
|
|
5183
|
+
function isNewerVersion(latest, current) {
|
|
5184
|
+
const a = stripPrerelease(latest).split(".").map(Number);
|
|
5185
|
+
const b = stripPrerelease(current).split(".").map(Number);
|
|
5186
|
+
const len = Math.max(a.length, b.length);
|
|
5187
|
+
for (let i = 0;i < len; i++) {
|
|
5188
|
+
const av = a[i] ?? 0;
|
|
5189
|
+
const bv = b[i] ?? 0;
|
|
5190
|
+
if (av > bv)
|
|
5191
|
+
return true;
|
|
5192
|
+
if (av < bv)
|
|
5193
|
+
return false;
|
|
5194
|
+
}
|
|
5195
|
+
return false;
|
|
5196
|
+
}
|
|
5197
|
+
function getCachePath() {
|
|
5198
|
+
return join17(getConfigDir(), CACHE_FILENAME);
|
|
5199
|
+
}
|
|
5200
|
+
function readCache() {
|
|
5201
|
+
try {
|
|
5202
|
+
const path = getCachePath();
|
|
5203
|
+
if (!existsSync7(path))
|
|
5204
|
+
return null;
|
|
5205
|
+
const data = JSON.parse(readFileSync5(path, "utf-8"));
|
|
5206
|
+
if (typeof data.lastCheck === "number" && typeof data.latestVersion === "string") {
|
|
5207
|
+
return data;
|
|
5208
|
+
}
|
|
5209
|
+
return null;
|
|
5210
|
+
} catch {
|
|
5211
|
+
return null;
|
|
5212
|
+
}
|
|
5213
|
+
}
|
|
5214
|
+
function writeCache(cache) {
|
|
5215
|
+
try {
|
|
5216
|
+
const dir = getConfigDir();
|
|
5217
|
+
if (!existsSync7(dir)) {
|
|
5218
|
+
mkdirSync5(dir, { recursive: true, mode: 448 });
|
|
5219
|
+
}
|
|
5220
|
+
writeFileSync5(getCachePath(), JSON.stringify(cache), { mode: 384 });
|
|
5221
|
+
} catch {}
|
|
5222
|
+
}
|
|
5223
|
+
async function fetchLatestVersion() {
|
|
5224
|
+
const controller = new AbortController;
|
|
5225
|
+
const timeout = setTimeout(() => controller.abort(), FETCH_TIMEOUT_MS);
|
|
5226
|
+
try {
|
|
5227
|
+
const resp = await fetch(REGISTRY_URL, { signal: controller.signal });
|
|
5228
|
+
if (!resp.ok)
|
|
5229
|
+
return null;
|
|
5230
|
+
const data = await resp.json();
|
|
5231
|
+
const latest = data.latest;
|
|
5232
|
+
return typeof latest === "string" ? latest : null;
|
|
5233
|
+
} catch {
|
|
5234
|
+
return null;
|
|
5235
|
+
} finally {
|
|
5236
|
+
clearTimeout(timeout);
|
|
5237
|
+
}
|
|
5238
|
+
}
|
|
5239
|
+
function displayNotice(current, latest) {
|
|
5240
|
+
const msg = `
|
|
5241
|
+
${import_picocolors2.default.yellow(` Update available: ${current} → ${latest}`)}
|
|
5242
|
+
` + `${import_picocolors2.default.dim(' Run "npm update -g @dosu/cli" or visit https://github.com/dosu-ai/dosu-cli/releases')}
|
|
5243
|
+
`;
|
|
5244
|
+
console.error(msg);
|
|
5245
|
+
}
|
|
5246
|
+
function checkForUpdates() {
|
|
5247
|
+
try {
|
|
5248
|
+
const cache = readCache();
|
|
5249
|
+
if (cache && isNewerVersion(cache.latestVersion, VERSION)) {
|
|
5250
|
+
displayNotice(VERSION, cache.latestVersion);
|
|
5251
|
+
}
|
|
5252
|
+
const isStale = !cache || Date.now() - cache.lastCheck > CHECK_INTERVAL_MS;
|
|
5253
|
+
if (isStale) {
|
|
5254
|
+
fetchLatestVersion().then((latest) => {
|
|
5255
|
+
writeCache({
|
|
5256
|
+
lastCheck: Date.now(),
|
|
5257
|
+
latestVersion: latest ?? cache?.latestVersion ?? VERSION
|
|
5258
|
+
});
|
|
5259
|
+
if (latest) {
|
|
5260
|
+
logger.debug("update-check", `Cached latest version: ${latest}`);
|
|
5261
|
+
}
|
|
5262
|
+
}).catch((err) => {
|
|
5263
|
+
logger.error("update-check", `Background fetch failed: ${err}`);
|
|
5264
|
+
});
|
|
5265
|
+
}
|
|
5266
|
+
} catch (err) {
|
|
5267
|
+
logger.error("update-check", `Update check failed: ${err}`);
|
|
5268
|
+
}
|
|
5269
|
+
}
|
|
5270
|
+
|
|
5271
|
+
// src/cli/cli.ts
|
|
5169
5272
|
function createProgram() {
|
|
5170
5273
|
const program2 = new Command;
|
|
5171
5274
|
program2.name("dosu").description("Dosu CLI - Manage MCP servers for AI tools").version(getVersionString(), "-v, --version").option("--debug", "Enable debug logging to stderr", false).hook("preAction", (thisCommand) => {
|
|
5172
5275
|
const opts = thisCommand.optsWithGlobals();
|
|
5173
5276
|
logger.init({ debug: opts.debug });
|
|
5277
|
+
checkForUpdates();
|
|
5174
5278
|
}).action(async () => {
|
|
5175
5279
|
const { runTUI: runTUI2 } = await Promise.resolve().then(() => (init_tui(), exports_tui));
|
|
5176
5280
|
await runTUI2();
|
|
@@ -5304,7 +5408,7 @@ Use 'dosu mcp add <tool>' to add Dosu MCP to a tool.`);
|
|
|
5304
5408
|
if (opts.tail !== undefined) {
|
|
5305
5409
|
const n = typeof opts.tail === "string" ? parseInt(opts.tail, 10) || 50 : 50;
|
|
5306
5410
|
try {
|
|
5307
|
-
const content =
|
|
5411
|
+
const content = readFileSync6(logPath, "utf-8");
|
|
5308
5412
|
const lines = content.split(`
|
|
5309
5413
|
`);
|
|
5310
5414
|
console.log(lines.slice(-n).join(`
|