@tacuchi/updater 2.0.2 → 2.0.4

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.
Files changed (2) hide show
  1. package/dist/cli.js +98 -76
  2. 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 = 3e5;
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, _ctx) {
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
  }
@@ -870,31 +873,32 @@ var softwareupdate = {
870
873
  };
871
874
 
872
875
  // src/managers/descriptors/winget.ts
876
+ var ACCEPT = ["--accept-source-agreements", "--accept-package-agreements"];
873
877
  function parseWingetOutdated(stdout) {
874
- const packages = [];
875
- const lines = stdout.split("\n");
876
- let inTable = false;
877
- for (const line of lines) {
878
- if (line.includes("------")) {
879
- inTable = true;
880
- continue;
881
- }
882
- if (!inTable) continue;
883
- const cols = line.trim().split(/\s{2,}/);
884
- if (cols.length >= 4) {
885
- packages.push({
886
- name: cols[1] ?? cols[0] ?? "Unknown",
887
- currentVersion: cols[2] ?? "?",
888
- newVersion: cols[3] ?? "?"
889
- });
890
- }
878
+ const lines = stdout.split("\n").map((l) => (l.split("\r").pop() ?? l).replace(/[⠀-⣿]/g, "").replace(/\s+$/, ""));
879
+ const dashIdx = lines.findIndex((l) => l.trim().length >= 3 && /^-+$/.test(l.trim()));
880
+ if (dashIdx < 1) return [];
881
+ const header = lines[dashIdx - 1] ?? "";
882
+ const starts = [];
883
+ for (const m of header.matchAll(/\S+/g)) starts.push(m.index ?? 0);
884
+ if (starts.length < 4) return [];
885
+ const cell = (line, i) => (i < starts.length - 1 ? line.slice(starts[i], starts[i + 1]) : line.slice(starts[i])).trim();
886
+ const out = [];
887
+ for (let i = dashIdx + 1; i < lines.length; i++) {
888
+ const line = lines[i];
889
+ if (line.trim().length === 0) continue;
890
+ const id = cell(line, 1);
891
+ const current = cell(line, 2);
892
+ const available = cell(line, 3);
893
+ if (!id || !available) continue;
894
+ out.push({ name: id, currentVersion: current || "?", newVersion: available || "?" });
891
895
  }
892
- return packages;
896
+ return out;
897
+ }
898
+ async function listWinget() {
899
+ const res = await execCommand("winget", ["list", "--upgrade-available", "--accept-source-agreements"], 6e4);
900
+ return parseWingetOutdated(res.stdout);
893
901
  }
894
- var ACCEPT_AGREEMENTS = [
895
- "--accept-source-agreements",
896
- "--accept-package-agreements"
897
- ];
898
902
  var winget = {
899
903
  id: "winget",
900
904
  group: "apps",
@@ -903,19 +907,33 @@ var winget = {
903
907
  kind: "direct",
904
908
  detectCmd: { cmd: "winget", args: ["--version"], timeout: 3e3 },
905
909
  parseVersion: (stdout) => stdout.trim() || void 0,
906
- listOutdatedCmd: () => ({
907
- cmd: "winget",
908
- args: ["list", "--upgrade-available", "--accept-source-agreements"]
909
- }),
910
+ listOutdatedCmd: () => ({ cmd: "winget", args: ["list", "--upgrade-available", "--accept-source-agreements"] }),
910
911
  parseOutdated: (stdout) => parseWingetOutdated(stdout),
911
- // Single bulk command: `winget upgrade --all` when nothing is selected,
912
- // otherwise one invocation carrying every selected id (`--id <id>` per pkg).
913
- upgradeCmd: (pkgs) => {
914
- if (pkgs && pkgs.length) {
915
- const idArgs = pkgs.flatMap((id) => ["--id", id]);
916
- return { cmd: "winget", args: ["upgrade", ...ACCEPT_AGREEMENTS, ...idArgs] };
912
+ // Escape hatch: winget upgrades ONE package per invocation (no multi-target),
913
+ // so a single bulk `--id A --id B` silently fails. Loop one `winget upgrade
914
+ // --exact --id <id>` per selected package, then verify by re-listing.
915
+ escapeHatch: {
916
+ listOutdated: listWinget,
917
+ async *upgrade(packages, ctx) {
918
+ yield { type: "phase", phase: "upgrading", message: "Actualizando winget..." };
919
+ const before = await listWinget();
920
+ const targets = packages && packages.length ? packages : before.map((p) => p.name);
921
+ const commands = [];
922
+ const run = async function* (args2) {
923
+ yield { type: "log", message: `winget ${args2.join(" ")}` };
924
+ const rec = yield* runStream("winget", args2, { timeoutMs: 6e5, sudo: false, signal: ctx.signal });
925
+ commands.push(rec);
926
+ logCommand(rec);
927
+ };
928
+ if (!targets.length) {
929
+ yield* run(["upgrade", "--all", ...ACCEPT]);
930
+ } else {
931
+ for (const id of targets) yield* run(["upgrade", "--exact", "--id", id, ...ACCEPT]);
932
+ }
933
+ yield { type: "phase", phase: "verifying", message: "Verificando resultado..." };
934
+ const after = await listWinget();
935
+ return reconcile(packages, before, { stillOutdated: after.map((p) => ({ name: p.name })) }, commands);
917
936
  }
918
- return { cmd: "winget", args: ["upgrade", "--all", ...ACCEPT_AGREEMENTS] };
919
937
  }
920
938
  };
921
939
 
@@ -1142,7 +1160,7 @@ var flutter = {
1142
1160
  if (before.length) {
1143
1161
  const args2 = ["upgrade", "--force"];
1144
1162
  yield { type: "log", message: `flutter ${args2.join(" ")}` };
1145
- const rec = yield* runStream("flutter", args2, { timeoutMs: 6e5, sudo: false });
1163
+ const rec = yield* runStream("flutter", args2, { timeoutMs: 6e5, sudo: false, signal: ctx.signal });
1146
1164
  commands.push(rec);
1147
1165
  logCommand(rec);
1148
1166
  }
@@ -1198,7 +1216,7 @@ var angular = {
1198
1216
  // Upgrade is a single bulk `npm install -g @angular/cli@latest`.
1199
1217
  escapeHatch: {
1200
1218
  listOutdated: listOutdated4,
1201
- async *upgrade(packages, _ctx) {
1219
+ async *upgrade(packages, ctx) {
1202
1220
  yield { type: "phase", phase: "upgrading", message: "Actualizando Angular CLI..." };
1203
1221
  const before = await listOutdated4();
1204
1222
  const target = packages && packages.length ? packages : before.map((p) => p.name);
@@ -1206,7 +1224,7 @@ var angular = {
1206
1224
  if (target.length) {
1207
1225
  const args2 = ["install", "-g", `${PACKAGE}@latest`];
1208
1226
  yield { type: "log", message: `npm ${args2.join(" ")}` };
1209
- const rec = yield* runStream("npm", args2, { timeoutMs: 3e5, sudo: false });
1227
+ const rec = yield* runStream("npm", args2, { timeoutMs: 3e5, sudo: false, signal: ctx.signal });
1210
1228
  commands.push(rec);
1211
1229
  logCommand(rec);
1212
1230
  }
@@ -1335,7 +1353,7 @@ var goLang = {
1335
1353
  const commands = [];
1336
1354
  const args2 = ["upgrade", "go"];
1337
1355
  yield { type: "log", message: `brew ${args2.join(" ")}` };
1338
- const rec = yield* runStream("brew", args2, { timeoutMs: 3e5, sudo: false });
1356
+ const rec = yield* runStream("brew", args2, { timeoutMs: 3e5, sudo: false, signal: ctx.signal });
1339
1357
  commands.push(rec);
1340
1358
  logCommand(rec);
1341
1359
  yield { type: "phase", phase: "verifying", message: "Verificando resultado..." };
@@ -1479,7 +1497,7 @@ var pnpm = {
1479
1497
  // `pnpm update -g` (or `pnpm update -g <names>` for a subset).
1480
1498
  escapeHatch: {
1481
1499
  listOutdated: listOutdated6,
1482
- async *upgrade(packages, _ctx) {
1500
+ async *upgrade(packages, ctx) {
1483
1501
  yield { type: "phase", phase: "upgrading", message: "Actualizando pnpm..." };
1484
1502
  const before = await listOutdated6();
1485
1503
  const target = packages && packages.length ? packages : before.map((p) => p.name);
@@ -1487,7 +1505,7 @@ var pnpm = {
1487
1505
  if (target.length) {
1488
1506
  const args2 = packages && packages.length ? ["update", "-g", ...packages] : ["update", "-g"];
1489
1507
  yield { type: "log", message: `pnpm ${args2.join(" ")}` };
1490
- const rec = yield* runStream("pnpm", args2, { timeoutMs: 3e5, sudo: false });
1508
+ const rec = yield* runStream("pnpm", args2, { timeoutMs: 3e5, sudo: false, signal: ctx.signal });
1491
1509
  commands.push(rec);
1492
1510
  logCommand(rec);
1493
1511
  }
@@ -1563,7 +1581,7 @@ var yarn = {
1563
1581
  // success: berry returns [] for listing and a noop + manualCommand on upgrade.
1564
1582
  escapeHatch: {
1565
1583
  listOutdated: listOutdated7,
1566
- async *upgrade(packages, _ctx) {
1584
+ async *upgrade(packages, ctx) {
1567
1585
  const line = await yarnLine();
1568
1586
  if (line === "berry") {
1569
1587
  yield {
@@ -1590,7 +1608,7 @@ var yarn = {
1590
1608
  if (target.length) {
1591
1609
  const args2 = packages && packages.length ? ["global", "upgrade", ...packages] : ["global", "upgrade"];
1592
1610
  yield { type: "log", message: `yarn ${args2.join(" ")}` };
1593
- const rec = yield* runStream("yarn", args2, { timeoutMs: 3e5, sudo: false });
1611
+ const rec = yield* runStream("yarn", args2, { timeoutMs: 3e5, sudo: false, signal: ctx.signal });
1594
1612
  commands.push(rec);
1595
1613
  logCommand(rec);
1596
1614
  }
@@ -1641,13 +1659,13 @@ var bun = {
1641
1659
  async listOutdated() {
1642
1660
  return [];
1643
1661
  },
1644
- async *upgrade(packages, _ctx) {
1662
+ async *upgrade(packages, ctx) {
1645
1663
  yield { type: "phase", phase: "upgrading", message: "Actualizando bun..." };
1646
1664
  const beforeMap = await installed();
1647
1665
  const commands = [];
1648
1666
  const args2 = packages && packages.length ? ["update", "-g", ...packages] : ["update", "-g"];
1649
1667
  yield { type: "log", message: `bun ${args2.join(" ")}` };
1650
- const rec = yield* runStream("bun", args2, { timeoutMs: 3e5, sudo: false });
1668
+ const rec = yield* runStream("bun", args2, { timeoutMs: 3e5, sudo: false, signal: ctx.signal });
1651
1669
  commands.push(rec);
1652
1670
  logCommand(rec);
1653
1671
  yield { type: "phase", phase: "verifying", message: "Verificando resultado..." };
@@ -1951,7 +1969,7 @@ var pipx = {
1951
1969
  // version means that package was upgraded (reconcile derives the verdict).
1952
1970
  escapeHatch: {
1953
1971
  listOutdated: listOutdated9,
1954
- async *upgrade(packages, _ctx) {
1972
+ async *upgrade(packages, ctx) {
1955
1973
  yield { type: "phase", phase: "upgrading", message: "Actualizando pipx..." };
1956
1974
  const beforeSnap = await snapshot();
1957
1975
  const before = Object.entries(beforeSnap).map(([name, version]) => ({
@@ -1963,7 +1981,7 @@ var pipx = {
1963
1981
  if (before.length) {
1964
1982
  const args2 = ["upgrade-all"];
1965
1983
  yield { type: "log", message: `pipx ${args2.join(" ")}` };
1966
- const rec = yield* runStream("pipx", args2, { timeoutMs: 3e5, sudo: false });
1984
+ const rec = yield* runStream("pipx", args2, { timeoutMs: 3e5, sudo: false, signal: ctx.signal });
1967
1985
  commands.push(rec);
1968
1986
  logCommand(rec);
1969
1987
  }
@@ -2060,7 +2078,7 @@ async function runTask(task, opts) {
2060
2078
  }
2061
2079
  opts.onEvent({ managerId, phase: "upgrading" });
2062
2080
  try {
2063
- const gen = task.op === "uninstall" && task.manager.uninstall ? task.manager.uninstall(task.packages ?? [], opts.sudoMode) : task.manager.upgrade(task.packages, opts.sudoMode);
2081
+ 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
2082
  let next = await gen.next();
2065
2083
  while (!next.done) {
2066
2084
  opts.onEvent({ managerId, phase: "upgrading", event: next.value });
@@ -2306,6 +2324,7 @@ var es = {
2306
2324
  selectHint: "Espacio marcar \xB7 A todos \xB7 N ninguno \xB7 Enter continuar \xB7 S ajustes \xB7 Q salir",
2307
2325
  confirmHint: "Enter actualizar \xB7 Esc volver \xB7 Q salir",
2308
2326
  updatingHint: "Esc cancelar",
2327
+ passwordNote: 'Si aparece "Password:" abajo, es un gestor (p.ej. un cask de brew): escr\xEDbela y Enter.',
2309
2328
  summaryHint: "R re-escanear \xB7 Q salir",
2310
2329
  elapsed: "transcurrido",
2311
2330
  cancel: "Cancelando..."
@@ -2504,6 +2523,7 @@ var en = {
2504
2523
  selectHint: "Space toggle \xB7 A all \xB7 N none \xB7 Enter continue \xB7 S settings \xB7 Q quit",
2505
2524
  confirmHint: "Enter update \xB7 Esc back \xB7 Q quit",
2506
2525
  updatingHint: "Esc cancel",
2526
+ passwordNote: 'If a "Password:" prompt appears below, it is a manager (e.g. a brew cask): type it and Enter.',
2507
2527
  summaryHint: "R rescan \xB7 Q quit",
2508
2528
  elapsed: "elapsed",
2509
2529
  cancel: "Cancelling..."
@@ -2640,13 +2660,8 @@ function useAppMachine(sudoMode2) {
2640
2660
  if (e.phase === "queued") {
2641
2661
  enqueue({ type: "MGR_QUEUED", id });
2642
2662
  } else if (e.phase === "upgrading") {
2643
- if (e.event && (e.event.percent !== void 0 || e.event.package || e.event.message)) {
2644
- enqueue({
2645
- type: "MGR_PROGRESS",
2646
- id,
2647
- percent: e.event.percent,
2648
- currentPackage: e.event.package ?? e.event.message
2649
- });
2663
+ if (e.event?.percent !== void 0) {
2664
+ enqueue({ type: "MGR_PROGRESS", id, percent: e.event.percent });
2650
2665
  } else if (!e.event) {
2651
2666
  enqueue({ type: "MGR_RUNNING", id });
2652
2667
  }
@@ -3010,7 +3025,7 @@ function clip2(s, n) {
3010
3025
  }
3011
3026
  function Row({ e, width }) {
3012
3027
  let detail = "";
3013
- if (e.status === "running") detail = `${e.percent > 0 ? `${e.percent}% ` : ""}${e.currentPackage ?? ""}`;
3028
+ if (e.status === "running") detail = e.percent > 0 ? `${e.percent}%` : "";
3014
3029
  else if (e.status === "skipped") detail = e.manualCommand ?? "manual";
3015
3030
  else if (e.status === "failed") detail = e.result?.failures[0]?.message ?? "";
3016
3031
  return /* @__PURE__ */ jsxs5(Box5, { children: [
@@ -3056,7 +3071,10 @@ function UpdateScreen() {
3056
3071
  const e = state.managers[id];
3057
3072
  return e ? /* @__PURE__ */ jsx7(Row, { e, width }, id) : null;
3058
3073
  }),
3059
- /* @__PURE__ */ jsx7(Box5, { marginTop: 1, children: /* @__PURE__ */ jsx7(Text6, { color: semantic.muted, children: t("ui", "updatingHint") }) })
3074
+ /* @__PURE__ */ jsxs5(Box5, { marginTop: 1, flexDirection: "column", children: [
3075
+ /* @__PURE__ */ jsx7(Text6, { color: semantic.muted, children: t("ui", "updatingHint") }),
3076
+ /* @__PURE__ */ jsx7(Text6, { color: semantic.muted, children: t("ui", "passwordNote") })
3077
+ ] })
3060
3078
  ] });
3061
3079
  }
3062
3080
 
@@ -3085,7 +3103,7 @@ function SummaryScreen() {
3085
3103
  if (r) {
3086
3104
  upgraded += r.upgraded;
3087
3105
  failed += r.failed;
3088
- for (const f of r.failures) failures.push({ manager: id, message: f.message, kind: f.kind });
3106
+ for (const f of r.failures) failures.push({ manager: id, package: f.package, message: f.message, kind: f.kind });
3089
3107
  }
3090
3108
  }
3091
3109
  const hasErrors = failed > 0;
@@ -3111,17 +3129,21 @@ function SummaryScreen() {
3111
3129
  t("ui", "skipped")
3112
3130
  ] })
3113
3131
  ] }),
3114
- failures.length > 0 && /* @__PURE__ */ jsx8(Box6, { flexDirection: "column", marginBottom: 1, children: failures.slice(0, 8).map((f, i) => /* @__PURE__ */ jsxs6(Text7, { color: semantic.error, wrap: "truncate-end", children: [
3115
- "\u2717 ",
3116
- managerName(f.manager),
3117
- ": ",
3118
- f.message,
3119
- f.kind ? /* @__PURE__ */ jsxs6(Text7, { color: semantic.muted, children: [
3120
- " [",
3121
- f.kind,
3122
- "]"
3123
- ] }) : null
3124
- ] }, i)) }),
3132
+ failures.length > 0 && /* @__PURE__ */ jsxs6(Box6, { flexDirection: "column", marginBottom: 1, children: [
3133
+ failures.slice(0, 8).map((f, i) => /* @__PURE__ */ jsxs6(Text7, { color: semantic.error, wrap: "truncate-end", children: [
3134
+ "\u2717 ",
3135
+ managerName(f.manager),
3136
+ f.package ? /* @__PURE__ */ jsxs6(Text7, { color: semantic.text, children: [
3137
+ " ",
3138
+ f.package
3139
+ ] }) : null,
3140
+ f.kind ? /* @__PURE__ */ jsxs6(Text7, { color: semantic.muted, children: [
3141
+ " \xB7 ",
3142
+ f.kind
3143
+ ] }) : null
3144
+ ] }, i)),
3145
+ 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." })
3146
+ ] }),
3125
3147
  manuals.length > 0 && /* @__PURE__ */ jsxs6(Box6, { flexDirection: "column", marginBottom: 1, children: [
3126
3148
  /* @__PURE__ */ jsx8(Text7, { color: semantic.warning, children: t("ui", "manualNeeded") }),
3127
3149
  manuals.map((m, i) => /* @__PURE__ */ jsxs6(Text7, { color: semantic.muted, children: [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tacuchi/updater",
3
- "version": "2.0.2",
3
+ "version": "2.0.4",
4
4
  "description": "CLI multiplataforma para actualizar gestores de paquetes del sistema",
5
5
  "type": "module",
6
6
  "bin": {