@tacuchi/updater 2.2.0 → 2.2.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.
Files changed (2) hide show
  1. package/dist/cli.js +19 -10
  2. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -576,6 +576,10 @@ function addToMemory(level, message) {
576
576
  inMemoryLog.push({ id, timestamp, level, message });
577
577
  if (inMemoryLog.length > 200) inMemoryLog.shift();
578
578
  }
579
+ function warn(message) {
580
+ writeRaw("WARN", message);
581
+ addToMemory("warn", message);
582
+ }
579
583
  function error(message) {
580
584
  writeRaw("ERROR", message);
581
585
  addToMemory("error", message);
@@ -836,6 +840,9 @@ async function pythonModuleCmd() {
836
840
  return null;
837
841
  });
838
842
  }
843
+ async function resolvedInvocation() {
844
+ return once("pip:invocation", async () => pipInvocation(await pythonModuleCmd()));
845
+ }
839
846
  function parsePipOutdated(stdout) {
840
847
  try {
841
848
  const data = JSON.parse(stdout);
@@ -846,14 +853,15 @@ function parsePipOutdated(stdout) {
846
853
  }
847
854
  async function pep668Flags() {
848
855
  return once("pip:pep668", async () => {
849
- const cmd = pipCmd();
850
- const probe = await execCommand(cmd, ["install", "--user", "--dry-run", "pip"], 5e3);
856
+ const { cmd, baseArgs } = await resolvedInvocation();
857
+ const probe = await execCommand(cmd, [...baseArgs, "install", "--user", "--dry-run", "pip"], 5e3);
851
858
  const managed = (probe.stdout + probe.stderr).includes("externally-managed");
852
859
  return managed ? ["--break-system-packages"] : [];
853
860
  });
854
861
  }
855
862
  async function listOutdated() {
856
- const res = await execCommand(pipCmd(), ["list", "--outdated", "--format=json"], 3e4);
863
+ const { cmd, baseArgs } = await resolvedInvocation();
864
+ const res = await execCommand(cmd, [...baseArgs, "list", "--outdated", "--format=json"], 3e4);
857
865
  if (res.exitCode !== 0) return [];
858
866
  return parsePipOutdated(res.stdout);
859
867
  }
@@ -865,17 +873,17 @@ var pip = {
865
873
  kind: "direct",
866
874
  detectCmd: { cmd: pipCmd(), args: ["--version"], timeout: 3e3 },
867
875
  parseVersion: (stdout) => stdout.match(/pip (\S+)/)?.[1],
868
- listOutdatedCmd: () => ({ cmd: pipCmd(), args: ["list", "--outdated", "--format=json"] }),
869
- parseOutdated: (stdout) => parsePipOutdated(stdout),
870
876
  // Escape hatch: pip needs a cached PEP 668 probe and a single bulk install
871
877
  // (the old code looped one `pip install` per package — the main slowness).
878
+ // No declarative listOutdatedCmd: the engine prefers escapeHatch.listOutdated,
879
+ // and listing MUST share the upgrade's interpreter (resolvedInvocation).
872
880
  escapeHatch: {
873
881
  listOutdated,
874
882
  async *upgrade(packages, ctx) {
875
883
  yield { type: "phase", phase: "upgrading", message: "Actualizando pip..." };
876
884
  const flags = await pep668Flags();
877
885
  if (flags.length) yield { type: "log", message: "Entorno PEP 668: usando --break-system-packages" };
878
- const { cmd, baseArgs } = pipInvocation(await pythonModuleCmd());
886
+ const { cmd, baseArgs } = await resolvedInvocation();
879
887
  const before = await listOutdated();
880
888
  const target = packages && packages.length ? packages : before.map((p) => p.name);
881
889
  const commands = [];
@@ -3830,13 +3838,14 @@ if (process.platform === "win32" && sudoRequested && !elevated) {
3830
3838
  var sudoMode = process.platform === "win32" ? elevated : isRoot || sudoRequested;
3831
3839
  var nonInteractive = !process.stdin.isTTY || args.includes("--yes") || args.includes("-y") || args.includes("--all");
3832
3840
  var { unmount } = render(/* @__PURE__ */ jsx11(App, { sudoMode, nonInteractive }));
3833
- var onSignal = (code) => () => {
3841
+ var onSignal = (code, name) => () => {
3842
+ warn(`Interrumpido por se\xF1al (${name}) \u2014 run incompleto, sin resumen`);
3834
3843
  fireProcessCancel();
3835
3844
  setTimeout(() => {
3836
3845
  unmount();
3837
3846
  process.exit(code);
3838
3847
  }, 200);
3839
3848
  };
3840
- process.on("SIGINT", onSignal(130));
3841
- process.on("SIGTERM", onSignal(143));
3842
- process.on("SIGBREAK", onSignal(130));
3849
+ process.on("SIGINT", onSignal(130, "SIGINT"));
3850
+ process.on("SIGTERM", onSignal(143, "SIGTERM"));
3851
+ process.on("SIGBREAK", onSignal(130, "SIGBREAK"));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tacuchi/updater",
3
- "version": "2.2.0",
3
+ "version": "2.2.1",
4
4
  "description": "CLI multiplataforma para actualizar gestores de paquetes del sistema",
5
5
  "type": "module",
6
6
  "bin": {