@tacuchi/updater 2.0.3 → 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 +57 -42
  2. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -873,31 +873,32 @@ var softwareupdate = {
873
873
  };
874
874
 
875
875
  // src/managers/descriptors/winget.ts
876
+ var ACCEPT = ["--accept-source-agreements", "--accept-package-agreements"];
876
877
  function parseWingetOutdated(stdout) {
877
- const packages = [];
878
- const lines = stdout.split("\n");
879
- let inTable = false;
880
- for (const line of lines) {
881
- if (line.includes("------")) {
882
- inTable = true;
883
- continue;
884
- }
885
- if (!inTable) continue;
886
- const cols = line.trim().split(/\s{2,}/);
887
- if (cols.length >= 4) {
888
- packages.push({
889
- name: cols[1] ?? cols[0] ?? "Unknown",
890
- currentVersion: cols[2] ?? "?",
891
- newVersion: cols[3] ?? "?"
892
- });
893
- }
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 || "?" });
894
895
  }
895
- 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);
896
901
  }
897
- var ACCEPT_AGREEMENTS = [
898
- "--accept-source-agreements",
899
- "--accept-package-agreements"
900
- ];
901
902
  var winget = {
902
903
  id: "winget",
903
904
  group: "apps",
@@ -906,19 +907,33 @@ var winget = {
906
907
  kind: "direct",
907
908
  detectCmd: { cmd: "winget", args: ["--version"], timeout: 3e3 },
908
909
  parseVersion: (stdout) => stdout.trim() || void 0,
909
- listOutdatedCmd: () => ({
910
- cmd: "winget",
911
- args: ["list", "--upgrade-available", "--accept-source-agreements"]
912
- }),
910
+ listOutdatedCmd: () => ({ cmd: "winget", args: ["list", "--upgrade-available", "--accept-source-agreements"] }),
913
911
  parseOutdated: (stdout) => parseWingetOutdated(stdout),
914
- // Single bulk command: `winget upgrade --all` when nothing is selected,
915
- // otherwise one invocation carrying every selected id (`--id <id>` per pkg).
916
- upgradeCmd: (pkgs) => {
917
- if (pkgs && pkgs.length) {
918
- const idArgs = pkgs.flatMap((id) => ["--id", id]);
919
- 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);
920
936
  }
921
- return { cmd: "winget", args: ["upgrade", "--all", ...ACCEPT_AGREEMENTS] };
922
937
  }
923
938
  };
924
939
 
@@ -2309,6 +2324,7 @@ var es = {
2309
2324
  selectHint: "Espacio marcar \xB7 A todos \xB7 N ninguno \xB7 Enter continuar \xB7 S ajustes \xB7 Q salir",
2310
2325
  confirmHint: "Enter actualizar \xB7 Esc volver \xB7 Q salir",
2311
2326
  updatingHint: "Esc cancelar",
2327
+ passwordNote: 'Si aparece "Password:" abajo, es un gestor (p.ej. un cask de brew): escr\xEDbela y Enter.',
2312
2328
  summaryHint: "R re-escanear \xB7 Q salir",
2313
2329
  elapsed: "transcurrido",
2314
2330
  cancel: "Cancelando..."
@@ -2507,6 +2523,7 @@ var en = {
2507
2523
  selectHint: "Space toggle \xB7 A all \xB7 N none \xB7 Enter continue \xB7 S settings \xB7 Q quit",
2508
2524
  confirmHint: "Enter update \xB7 Esc back \xB7 Q quit",
2509
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.',
2510
2527
  summaryHint: "R rescan \xB7 Q quit",
2511
2528
  elapsed: "elapsed",
2512
2529
  cancel: "Cancelling..."
@@ -2643,13 +2660,8 @@ function useAppMachine(sudoMode2) {
2643
2660
  if (e.phase === "queued") {
2644
2661
  enqueue({ type: "MGR_QUEUED", id });
2645
2662
  } else if (e.phase === "upgrading") {
2646
- if (e.event && (e.event.percent !== void 0 || e.event.package || e.event.message)) {
2647
- enqueue({
2648
- type: "MGR_PROGRESS",
2649
- id,
2650
- percent: e.event.percent,
2651
- currentPackage: e.event.package ?? e.event.message
2652
- });
2663
+ if (e.event?.percent !== void 0) {
2664
+ enqueue({ type: "MGR_PROGRESS", id, percent: e.event.percent });
2653
2665
  } else if (!e.event) {
2654
2666
  enqueue({ type: "MGR_RUNNING", id });
2655
2667
  }
@@ -3013,7 +3025,7 @@ function clip2(s, n) {
3013
3025
  }
3014
3026
  function Row({ e, width }) {
3015
3027
  let detail = "";
3016
- if (e.status === "running") detail = `${e.percent > 0 ? `${e.percent}% ` : ""}${e.currentPackage ?? ""}`;
3028
+ if (e.status === "running") detail = e.percent > 0 ? `${e.percent}%` : "";
3017
3029
  else if (e.status === "skipped") detail = e.manualCommand ?? "manual";
3018
3030
  else if (e.status === "failed") detail = e.result?.failures[0]?.message ?? "";
3019
3031
  return /* @__PURE__ */ jsxs5(Box5, { children: [
@@ -3059,7 +3071,10 @@ function UpdateScreen() {
3059
3071
  const e = state.managers[id];
3060
3072
  return e ? /* @__PURE__ */ jsx7(Row, { e, width }, id) : null;
3061
3073
  }),
3062
- /* @__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
+ ] })
3063
3078
  ] });
3064
3079
  }
3065
3080
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tacuchi/updater",
3
- "version": "2.0.3",
3
+ "version": "2.0.4",
4
4
  "description": "CLI multiplataforma para actualizar gestores de paquetes del sistema",
5
5
  "type": "module",
6
6
  "bin": {