@tacuchi/updater 2.0.2 → 2.0.3
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/cli.js +41 -34
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -471,7 +471,7 @@ function getLogFilePath() {
|
|
|
471
471
|
var defaultDeps = { execCommand, runStream };
|
|
472
472
|
var DETECT_TIMEOUT = 5e3;
|
|
473
473
|
var LIST_TIMEOUT = 3e4;
|
|
474
|
-
var UPGRADE_TIMEOUT =
|
|
474
|
+
var UPGRADE_TIMEOUT = 6e5;
|
|
475
475
|
function skippedResult(managerId, manualCommand) {
|
|
476
476
|
return {
|
|
477
477
|
success: false,
|
|
@@ -485,10 +485,11 @@ function skippedResult(managerId, manualCommand) {
|
|
|
485
485
|
};
|
|
486
486
|
}
|
|
487
487
|
function fromDescriptor(d, cfg, deps = defaultDeps) {
|
|
488
|
-
const ctx = (sudoMode2) => ({
|
|
488
|
+
const ctx = (sudoMode2, signal) => ({
|
|
489
489
|
platform: process.platform,
|
|
490
490
|
sudoMode: sudoMode2,
|
|
491
|
-
meta: {}
|
|
491
|
+
meta: {},
|
|
492
|
+
signal
|
|
492
493
|
});
|
|
493
494
|
const upgradeTimeout = cfg.timeoutsMs[d.id] ?? d.defaultTimeoutMs ?? UPGRADE_TIMEOUT;
|
|
494
495
|
function sudoFor(spec, c) {
|
|
@@ -521,8 +522,8 @@ function fromDescriptor(d, cfg, deps = defaultDeps) {
|
|
|
521
522
|
if (!ok) return [];
|
|
522
523
|
return d.parseOutdated(res.stdout, res.stderr, c);
|
|
523
524
|
},
|
|
524
|
-
async *upgrade(packages, sudoMode2) {
|
|
525
|
-
const c = ctx(sudoMode2 ?? false);
|
|
525
|
+
async *upgrade(packages, sudoMode2, signal) {
|
|
526
|
+
const c = ctx(sudoMode2 ?? false, signal);
|
|
526
527
|
const startedAt = Date.now();
|
|
527
528
|
if (d.escapeHatch?.upgrade) {
|
|
528
529
|
const r = yield* d.escapeHatch.upgrade(packages, c);
|
|
@@ -547,7 +548,7 @@ function fromDescriptor(d, cfg, deps = defaultDeps) {
|
|
|
547
548
|
const rec = yield* deps.runStream(
|
|
548
549
|
spec.cmd,
|
|
549
550
|
spec.args,
|
|
550
|
-
{ timeoutMs: spec.timeout ?? upgradeTimeout, sudo: sudoFor(spec, c) },
|
|
551
|
+
{ timeoutMs: spec.timeout ?? upgradeTimeout, sudo: sudoFor(spec, c), signal: c.signal },
|
|
551
552
|
pp
|
|
552
553
|
);
|
|
553
554
|
commands.push(rec);
|
|
@@ -618,6 +619,8 @@ var brew = {
|
|
|
618
619
|
platforms: ["darwin"],
|
|
619
620
|
requiresAdmin: false,
|
|
620
621
|
kind: "direct",
|
|
622
|
+
// Casks (e.g. docker-desktop) download + replace whole apps; 20 min headroom.
|
|
623
|
+
defaultTimeoutMs: 12e5,
|
|
621
624
|
detectCmd: { cmd: "brew", args: ["--version"], timeout: 3e3 },
|
|
622
625
|
parseVersion: (stdout) => stdout.split("\n")[0]?.replace("Homebrew ", "").trim(),
|
|
623
626
|
listOutdatedCmd: () => ({ cmd: "brew", args: ["outdated", "--json=v2"] }),
|
|
@@ -676,7 +679,7 @@ var pip = {
|
|
|
676
679
|
// (the old code looped one `pip install` per package — the main slowness).
|
|
677
680
|
escapeHatch: {
|
|
678
681
|
listOutdated,
|
|
679
|
-
async *upgrade(packages,
|
|
682
|
+
async *upgrade(packages, ctx) {
|
|
680
683
|
const cmd = pipCmd();
|
|
681
684
|
yield { type: "phase", phase: "upgrading", message: "Actualizando pip..." };
|
|
682
685
|
const flags = await pep668Flags();
|
|
@@ -687,7 +690,7 @@ var pip = {
|
|
|
687
690
|
if (target.length) {
|
|
688
691
|
const args2 = ["install", "--user", "--upgrade", ...flags, ...target];
|
|
689
692
|
yield { type: "log", message: `${cmd} ${args2.join(" ")}` };
|
|
690
|
-
const rec = yield* runStream(cmd, args2, { timeoutMs: 3e5, sudo: false });
|
|
693
|
+
const rec = yield* runStream(cmd, args2, { timeoutMs: 3e5, sudo: false, signal: ctx.signal });
|
|
691
694
|
commands.push(rec);
|
|
692
695
|
logCommand(rec);
|
|
693
696
|
}
|
|
@@ -827,7 +830,7 @@ var gem = {
|
|
|
827
830
|
if (target.length) {
|
|
828
831
|
const args2 = updateArgs(target, useSudo);
|
|
829
832
|
yield { type: "log", message: `${useSudo ? "sudo " : ""}gem ${args2.join(" ")}` };
|
|
830
|
-
const rec = yield* runStream("gem", args2, { timeoutMs: 3e5, sudo: useSudo });
|
|
833
|
+
const rec = yield* runStream("gem", args2, { timeoutMs: 3e5, sudo: useSudo, signal: ctx.signal });
|
|
831
834
|
commands.push(rec);
|
|
832
835
|
logCommand(rec);
|
|
833
836
|
}
|
|
@@ -1142,7 +1145,7 @@ var flutter = {
|
|
|
1142
1145
|
if (before.length) {
|
|
1143
1146
|
const args2 = ["upgrade", "--force"];
|
|
1144
1147
|
yield { type: "log", message: `flutter ${args2.join(" ")}` };
|
|
1145
|
-
const rec = yield* runStream("flutter", args2, { timeoutMs: 6e5, sudo: false });
|
|
1148
|
+
const rec = yield* runStream("flutter", args2, { timeoutMs: 6e5, sudo: false, signal: ctx.signal });
|
|
1146
1149
|
commands.push(rec);
|
|
1147
1150
|
logCommand(rec);
|
|
1148
1151
|
}
|
|
@@ -1198,7 +1201,7 @@ var angular = {
|
|
|
1198
1201
|
// Upgrade is a single bulk `npm install -g @angular/cli@latest`.
|
|
1199
1202
|
escapeHatch: {
|
|
1200
1203
|
listOutdated: listOutdated4,
|
|
1201
|
-
async *upgrade(packages,
|
|
1204
|
+
async *upgrade(packages, ctx) {
|
|
1202
1205
|
yield { type: "phase", phase: "upgrading", message: "Actualizando Angular CLI..." };
|
|
1203
1206
|
const before = await listOutdated4();
|
|
1204
1207
|
const target = packages && packages.length ? packages : before.map((p) => p.name);
|
|
@@ -1206,7 +1209,7 @@ var angular = {
|
|
|
1206
1209
|
if (target.length) {
|
|
1207
1210
|
const args2 = ["install", "-g", `${PACKAGE}@latest`];
|
|
1208
1211
|
yield { type: "log", message: `npm ${args2.join(" ")}` };
|
|
1209
|
-
const rec = yield* runStream("npm", args2, { timeoutMs: 3e5, sudo: false });
|
|
1212
|
+
const rec = yield* runStream("npm", args2, { timeoutMs: 3e5, sudo: false, signal: ctx.signal });
|
|
1210
1213
|
commands.push(rec);
|
|
1211
1214
|
logCommand(rec);
|
|
1212
1215
|
}
|
|
@@ -1335,7 +1338,7 @@ var goLang = {
|
|
|
1335
1338
|
const commands = [];
|
|
1336
1339
|
const args2 = ["upgrade", "go"];
|
|
1337
1340
|
yield { type: "log", message: `brew ${args2.join(" ")}` };
|
|
1338
|
-
const rec = yield* runStream("brew", args2, { timeoutMs: 3e5, sudo: false });
|
|
1341
|
+
const rec = yield* runStream("brew", args2, { timeoutMs: 3e5, sudo: false, signal: ctx.signal });
|
|
1339
1342
|
commands.push(rec);
|
|
1340
1343
|
logCommand(rec);
|
|
1341
1344
|
yield { type: "phase", phase: "verifying", message: "Verificando resultado..." };
|
|
@@ -1479,7 +1482,7 @@ var pnpm = {
|
|
|
1479
1482
|
// `pnpm update -g` (or `pnpm update -g <names>` for a subset).
|
|
1480
1483
|
escapeHatch: {
|
|
1481
1484
|
listOutdated: listOutdated6,
|
|
1482
|
-
async *upgrade(packages,
|
|
1485
|
+
async *upgrade(packages, ctx) {
|
|
1483
1486
|
yield { type: "phase", phase: "upgrading", message: "Actualizando pnpm..." };
|
|
1484
1487
|
const before = await listOutdated6();
|
|
1485
1488
|
const target = packages && packages.length ? packages : before.map((p) => p.name);
|
|
@@ -1487,7 +1490,7 @@ var pnpm = {
|
|
|
1487
1490
|
if (target.length) {
|
|
1488
1491
|
const args2 = packages && packages.length ? ["update", "-g", ...packages] : ["update", "-g"];
|
|
1489
1492
|
yield { type: "log", message: `pnpm ${args2.join(" ")}` };
|
|
1490
|
-
const rec = yield* runStream("pnpm", args2, { timeoutMs: 3e5, sudo: false });
|
|
1493
|
+
const rec = yield* runStream("pnpm", args2, { timeoutMs: 3e5, sudo: false, signal: ctx.signal });
|
|
1491
1494
|
commands.push(rec);
|
|
1492
1495
|
logCommand(rec);
|
|
1493
1496
|
}
|
|
@@ -1563,7 +1566,7 @@ var yarn = {
|
|
|
1563
1566
|
// success: berry returns [] for listing and a noop + manualCommand on upgrade.
|
|
1564
1567
|
escapeHatch: {
|
|
1565
1568
|
listOutdated: listOutdated7,
|
|
1566
|
-
async *upgrade(packages,
|
|
1569
|
+
async *upgrade(packages, ctx) {
|
|
1567
1570
|
const line = await yarnLine();
|
|
1568
1571
|
if (line === "berry") {
|
|
1569
1572
|
yield {
|
|
@@ -1590,7 +1593,7 @@ var yarn = {
|
|
|
1590
1593
|
if (target.length) {
|
|
1591
1594
|
const args2 = packages && packages.length ? ["global", "upgrade", ...packages] : ["global", "upgrade"];
|
|
1592
1595
|
yield { type: "log", message: `yarn ${args2.join(" ")}` };
|
|
1593
|
-
const rec = yield* runStream("yarn", args2, { timeoutMs: 3e5, sudo: false });
|
|
1596
|
+
const rec = yield* runStream("yarn", args2, { timeoutMs: 3e5, sudo: false, signal: ctx.signal });
|
|
1594
1597
|
commands.push(rec);
|
|
1595
1598
|
logCommand(rec);
|
|
1596
1599
|
}
|
|
@@ -1641,13 +1644,13 @@ var bun = {
|
|
|
1641
1644
|
async listOutdated() {
|
|
1642
1645
|
return [];
|
|
1643
1646
|
},
|
|
1644
|
-
async *upgrade(packages,
|
|
1647
|
+
async *upgrade(packages, ctx) {
|
|
1645
1648
|
yield { type: "phase", phase: "upgrading", message: "Actualizando bun..." };
|
|
1646
1649
|
const beforeMap = await installed();
|
|
1647
1650
|
const commands = [];
|
|
1648
1651
|
const args2 = packages && packages.length ? ["update", "-g", ...packages] : ["update", "-g"];
|
|
1649
1652
|
yield { type: "log", message: `bun ${args2.join(" ")}` };
|
|
1650
|
-
const rec = yield* runStream("bun", args2, { timeoutMs: 3e5, sudo: false });
|
|
1653
|
+
const rec = yield* runStream("bun", args2, { timeoutMs: 3e5, sudo: false, signal: ctx.signal });
|
|
1651
1654
|
commands.push(rec);
|
|
1652
1655
|
logCommand(rec);
|
|
1653
1656
|
yield { type: "phase", phase: "verifying", message: "Verificando resultado..." };
|
|
@@ -1951,7 +1954,7 @@ var pipx = {
|
|
|
1951
1954
|
// version means that package was upgraded (reconcile derives the verdict).
|
|
1952
1955
|
escapeHatch: {
|
|
1953
1956
|
listOutdated: listOutdated9,
|
|
1954
|
-
async *upgrade(packages,
|
|
1957
|
+
async *upgrade(packages, ctx) {
|
|
1955
1958
|
yield { type: "phase", phase: "upgrading", message: "Actualizando pipx..." };
|
|
1956
1959
|
const beforeSnap = await snapshot();
|
|
1957
1960
|
const before = Object.entries(beforeSnap).map(([name, version]) => ({
|
|
@@ -1963,7 +1966,7 @@ var pipx = {
|
|
|
1963
1966
|
if (before.length) {
|
|
1964
1967
|
const args2 = ["upgrade-all"];
|
|
1965
1968
|
yield { type: "log", message: `pipx ${args2.join(" ")}` };
|
|
1966
|
-
const rec = yield* runStream("pipx", args2, { timeoutMs: 3e5, sudo: false });
|
|
1969
|
+
const rec = yield* runStream("pipx", args2, { timeoutMs: 3e5, sudo: false, signal: ctx.signal });
|
|
1967
1970
|
commands.push(rec);
|
|
1968
1971
|
logCommand(rec);
|
|
1969
1972
|
}
|
|
@@ -2060,7 +2063,7 @@ async function runTask(task, opts) {
|
|
|
2060
2063
|
}
|
|
2061
2064
|
opts.onEvent({ managerId, phase: "upgrading" });
|
|
2062
2065
|
try {
|
|
2063
|
-
const gen = task.op === "uninstall" && task.manager.uninstall ? task.manager.uninstall(task.packages ?? [], opts.sudoMode) : task.manager.upgrade(task.packages, opts.sudoMode);
|
|
2066
|
+
const gen = task.op === "uninstall" && task.manager.uninstall ? task.manager.uninstall(task.packages ?? [], opts.sudoMode) : task.manager.upgrade(task.packages, opts.sudoMode, opts.signal);
|
|
2064
2067
|
let next = await gen.next();
|
|
2065
2068
|
while (!next.done) {
|
|
2066
2069
|
opts.onEvent({ managerId, phase: "upgrading", event: next.value });
|
|
@@ -3085,7 +3088,7 @@ function SummaryScreen() {
|
|
|
3085
3088
|
if (r) {
|
|
3086
3089
|
upgraded += r.upgraded;
|
|
3087
3090
|
failed += r.failed;
|
|
3088
|
-
for (const f of r.failures) failures.push({ manager: id, message: f.message, kind: f.kind });
|
|
3091
|
+
for (const f of r.failures) failures.push({ manager: id, package: f.package, message: f.message, kind: f.kind });
|
|
3089
3092
|
}
|
|
3090
3093
|
}
|
|
3091
3094
|
const hasErrors = failed > 0;
|
|
@@ -3111,17 +3114,21 @@ function SummaryScreen() {
|
|
|
3111
3114
|
t("ui", "skipped")
|
|
3112
3115
|
] })
|
|
3113
3116
|
] }),
|
|
3114
|
-
failures.length > 0 && /* @__PURE__ */
|
|
3115
|
-
|
|
3116
|
-
|
|
3117
|
-
|
|
3118
|
-
|
|
3119
|
-
|
|
3120
|
-
|
|
3121
|
-
|
|
3122
|
-
|
|
3123
|
-
|
|
3124
|
-
|
|
3117
|
+
failures.length > 0 && /* @__PURE__ */ jsxs6(Box6, { flexDirection: "column", marginBottom: 1, children: [
|
|
3118
|
+
failures.slice(0, 8).map((f, i) => /* @__PURE__ */ jsxs6(Text7, { color: semantic.error, wrap: "truncate-end", children: [
|
|
3119
|
+
"\u2717 ",
|
|
3120
|
+
managerName(f.manager),
|
|
3121
|
+
f.package ? /* @__PURE__ */ jsxs6(Text7, { color: semantic.text, children: [
|
|
3122
|
+
" ",
|
|
3123
|
+
f.package
|
|
3124
|
+
] }) : null,
|
|
3125
|
+
f.kind ? /* @__PURE__ */ jsxs6(Text7, { color: semantic.muted, children: [
|
|
3126
|
+
" \xB7 ",
|
|
3127
|
+
f.kind
|
|
3128
|
+
] }) : null
|
|
3129
|
+
] }, i)),
|
|
3130
|
+
failures.some((f) => f.kind === "TIMEOUT") && /* @__PURE__ */ jsx8(Text7, { color: semantic.warning, children: "\u24D8 Un TIMEOUT suele indicar un paquete que pide interacci\xF3n (ej. un cask que requiere cerrar la app o sudo). Actual\xEDzalo manualmente en una terminal." })
|
|
3131
|
+
] }),
|
|
3125
3132
|
manuals.length > 0 && /* @__PURE__ */ jsxs6(Box6, { flexDirection: "column", marginBottom: 1, children: [
|
|
3126
3133
|
/* @__PURE__ */ jsx8(Text7, { color: semantic.warning, children: t("ui", "manualNeeded") }),
|
|
3127
3134
|
manuals.map((m, i) => /* @__PURE__ */ jsxs6(Text7, { color: semantic.muted, children: [
|