@usepowerplant/cli 0.4.44 → 0.4.45

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/main.js CHANGED
@@ -1,5 +1,5 @@
1
1
 
2
- !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="e21c9e8f-a5a6-561f-b7c6-99dd92ba2436")}catch(e){}}();
2
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="fc35294e-883a-5146-8d1c-99832269672d")}catch(e){}}();
3
3
  import { createRequire as __cliCreateRequire } from 'node:module';
4
4
  const require = __cliCreateRequire(import.meta.url);
5
5
  var __create = Object.create;
@@ -88471,7 +88471,7 @@ function _init2(options = {}, getDefaultIntegrationsImpl) {
88471
88471
  import tls2 from "node:tls";
88472
88472
  var import_undici = __toESM(require_undici(), 1);
88473
88473
  var CLI_VERSION_HEADER = "x-powerplant-cli-version";
88474
- var cliVersion = true ? "0.4.44" : "0.0.0-checkout";
88474
+ var cliVersion = true ? "0.4.45" : "0.0.0-checkout";
88475
88475
  function cliVersionHeaders() {
88476
88476
  return { [CLI_VERSION_HEADER]: cliVersion, "user-agent": `powerplant-cli/${cliVersion}` };
88477
88477
  }
@@ -94708,6 +94708,7 @@ var POWERPLANT_PUBLISHER = { O: "Forestwalk Labs, Inc.", C: "CA" };
94708
94708
  var POWERPLANT_WINDOWS_PUBLISHER = false ? null : POWERPLANT_PUBLISHER;
94709
94709
  var POWERPLANT_SIGNER = { vendor: "Powerplant", windowsSubject: POWERPLANT_WINDOWS_PUBLISHER };
94710
94710
  var REGISTRY_HOST = "registry.npmjs.org";
94711
+ var DOWNLOAD_TIMEOUT_MS = 10 * 6e4;
94711
94712
  var MAX_TARBALL_BYTES = 512 * 1024 * 1024;
94712
94713
  var releaseAnswerSchema = external_exports.object({
94713
94714
  data: external_exports.object({
@@ -94739,8 +94740,9 @@ async function downloadRelease(release2, file2, fetchImpl = fetch) {
94739
94740
  }
94740
94741
  let response;
94741
94742
  try {
94742
- response = await fetchImpl(url2, { signal: AbortSignal.timeout(10 * 6e4), redirect: "error" });
94743
+ response = await fetchImpl(url2, { signal: AbortSignal.timeout(DOWNLOAD_TIMEOUT_MS), redirect: "error" });
94743
94744
  } catch (error63) {
94745
+ if (isTimeout(error63)) throw downloadTimedOut(release2, error63);
94744
94746
  throw new ExpectedCliError(`Could not download Powerplant ${release2.version} (${error63 instanceof Error ? error63.message : String(error63)}).`);
94745
94747
  }
94746
94748
  if (!response.ok || response.body === null) {
@@ -94767,9 +94769,19 @@ async function downloadRelease(release2, file2, fetchImpl = fetch) {
94767
94769
  }
94768
94770
  } catch (error63) {
94769
94771
  rmSync8(file2, { force: true });
94772
+ if (isTimeout(error63)) throw downloadTimedOut(release2, error63);
94770
94773
  throw error63;
94771
94774
  }
94772
94775
  }
94776
+ function isTimeout(error63) {
94777
+ return error63 instanceof DOMException && error63.name === "TimeoutError";
94778
+ }
94779
+ function downloadTimedOut(release2, cause) {
94780
+ return new ExpectedCliError(
94781
+ `The download of Powerplant ${release2.version} did not finish within ${DOWNLOAD_TIMEOUT_MS / 6e4} minutes. Check this computer's internet connection, then try again.`,
94782
+ { cause }
94783
+ );
94784
+ }
94773
94785
  function unpackWindowsTarball(file2, folder, tar) {
94774
94786
  mkdirSync11(folder, { recursive: true });
94775
94787
  const result = spawnSync5(tar, ["-xzf", file2, "-C", folder, "--strip-components=1"], {
@@ -95017,15 +95029,23 @@ var updateProgressSchema = external_exports.object({
95017
95029
  finishedAt: external_exports.string().optional(),
95018
95030
  /** One line of why, for a failure. */
95019
95031
  detail: external_exports.string().optional(),
95020
- /** Why it failed, when the cause is one the daemon may retry by itself:
95021
- * the registry did not serve the release yet (releaseNotServed). Absent
95022
- * for every other failure, which is left for a person. */
95023
- cause: external_exports.enum(["release-not-served"]).optional(),
95024
- /** Failed installs of this target so far: on a failed record including
95025
- * this one, on a reservation the count the retry continues from. */
95032
+ /** Failed installs of this target in a row: on a failed record including
95033
+ * this one, on an installing record the count this run continues from.
95034
+ * The hourly update reads it to space out its retries. */
95026
95035
  attempts: external_exports.number().int().nonnegative().optional()
95027
95036
  });
95028
95037
  var UPDATE_PROGRESS_STALE_MS = 15 * 6e4;
95038
+ function failedAttemptsAt(progress, target, now) {
95039
+ if (progress === null || progress.target !== target) return 0;
95040
+ switch (progress.state) {
95041
+ case "up-to-date":
95042
+ return 0;
95043
+ case "failed":
95044
+ return progress.attempts ?? 1;
95045
+ case "installing":
95046
+ return (progress.attempts ?? 0) + (now - Date.parse(progress.startedAt) > UPDATE_PROGRESS_STALE_MS ? 1 : 0);
95047
+ }
95048
+ }
95029
95049
  function updateProgressPath(homeDir) {
95030
95050
  return path30.join(collectorStateDir(homeDir), "cli-update.json");
95031
95051
  }
@@ -95242,7 +95262,11 @@ function startNewCopy(output2) {
95242
95262
  }
95243
95263
  async function runInstalledUpdate(run2) {
95244
95264
  const startedAt = new Date(run2.now()).toISOString();
95245
- const write2 = (state, target2, extra = {}) => run2.progress.write({ state, target: target2, startedAt, pid: run2.pid, ...extra });
95265
+ const previous = run2.progress.read();
95266
+ const write2 = (state, target2, extra = {}) => {
95267
+ const attempts = failedAttemptsAt(previous, target2, Date.parse(startedAt)) + (state === "failed" ? 1 : 0);
95268
+ run2.progress.write({ state, target: target2, startedAt, pid: run2.pid, ...attempts > 0 && state !== "up-to-date" && { attempts }, ...extra });
95269
+ };
95246
95270
  let target = run2.target;
95247
95271
  write2("installing", target);
95248
95272
  mkdirSync15(run2.workFolder, { recursive: true });
@@ -105510,6 +105534,9 @@ function ago(ms) {
105510
105534
  return ms < 6e4 ? "just now" : `${duration3(ms)} ago`;
105511
105535
  }
105512
105536
 
105537
+ // src/update.ts
105538
+ import path61 from "node:path";
105539
+
105513
105540
  // src/installOwner.ts
105514
105541
  import { accessSync as accessSync3, constants as constants6, readFileSync as readFileSync27 } from "node:fs";
105515
105542
  import path60 from "node:path";
@@ -105630,8 +105657,9 @@ function realInspectEnvironment() {
105630
105657
  }
105631
105658
 
105632
105659
  // src/update.ts
105633
- import path61 from "node:path";
105634
- var RELEASE_NOT_SERVED_RETRY_LIMIT = 3;
105660
+ var HOURLY_RETRY_ATTEMPTS = 3;
105661
+ var HOURLY_RETRY_WAIT_MS = 50 * 6e4;
105662
+ var DAILY_RETRY_MS = 24 * 60 * 6e4;
105635
105663
  function releaseNotServed(managerOutput) {
105636
105664
  return /\bETARGET\b|\bnotarget\b|ERR_PNPM_NO_MATCHING_VERSION/.test(managerOutput);
105637
105665
  }
@@ -105645,12 +105673,14 @@ function updateProgressView(progress, cliVersion2, now) {
105645
105673
  if (progress === null || progress.state === "up-to-date") return { kind: "none" };
105646
105674
  const reached = progress.target === null ? null : compareReleaseVersions(cliVersion2, progress.target);
105647
105675
  if (reached === 0 || reached === 1) return { kind: "none" };
105676
+ const startedAt = Date.parse(progress.startedAt);
105677
+ const attempts = failedAttemptsAt(progress, progress.target, now);
105678
+ const retryAt = startedAt + (attempts < HOURLY_RETRY_ATTEMPTS ? HOURLY_RETRY_WAIT_MS : DAILY_RETRY_MS);
105648
105679
  if (progress.state === "failed") {
105649
- const retryable = progress.cause === "release-not-served" && (progress.attempts ?? 0) < RELEASE_NOT_SERVED_RETRY_LIMIT;
105650
- return { kind: "failed", target: progress.target, detail: progress.detail ?? "It didn't finish.", retryable };
105680
+ return { kind: "failed", target: progress.target, detail: progress.detail ?? "It didn't finish.", retryAt };
105651
105681
  }
105652
- if (now - Date.parse(progress.startedAt) > UPDATE_PROGRESS_STALE_MS) {
105653
- return { kind: "failed", target: progress.target, detail: "It didn't finish within 15 minutes.", retryable: false };
105682
+ if (now - startedAt > UPDATE_PROGRESS_STALE_MS) {
105683
+ return { kind: "failed", target: progress.target, detail: "It didn't finish within 15 minutes.", retryAt };
105654
105684
  }
105655
105685
  return { kind: "installing", target: progress.target };
105656
105686
  }
@@ -105674,7 +105704,8 @@ async function runUpdate(deps) {
105674
105704
  }
105675
105705
  const startedAt = new Date(deps.now()).toISOString();
105676
105706
  const reserved = running?.state === "installing" ? running.target : null;
105677
- const attempts = (release2) => running?.target === release2 && running.attempts !== void 0 ? { attempts: running.attempts } : {};
105707
+ const priorFailures = (release2) => failedAttemptsAt(running, release2, Date.parse(startedAt));
105708
+ const attempts = (release2) => priorFailures(release2) > 0 ? { attempts: priorFailures(release2) } : {};
105678
105709
  deps.writeProgress({ state: "installing", target: reserved, startedAt, pid: deps.pid, ...attempts(reserved) });
105679
105710
  const resolved = await deps.resolveTarget();
105680
105711
  if (resolved !== null) deps.recordAvailableVersion(resolved);
@@ -105714,8 +105745,7 @@ async function runUpdate(deps) {
105714
105745
  pid: deps.pid,
105715
105746
  finishedAt: new Date(deps.now()).toISOString(),
105716
105747
  detail,
105717
- cause: "release-not-served",
105718
- attempts: (attempts(target).attempts ?? 0) + 1
105748
+ attempts: priorFailures(target) + 1
105719
105749
  });
105720
105750
  throw new ExpectedCliError(`${detail} A release can take a few minutes to appear; try again shortly, or update by hand: ${byHand}`);
105721
105751
  }
@@ -105727,7 +105757,8 @@ async function runUpdate(deps) {
105727
105757
  startedAt,
105728
105758
  pid: deps.pid,
105729
105759
  finishedAt: new Date(deps.now()).toISOString(),
105730
- detail
105760
+ detail,
105761
+ attempts: priorFailures(target) + 1
105731
105762
  });
105732
105763
  throw new ExpectedCliError(`${detail}. Update by hand: ${byHand}`);
105733
105764
  }
@@ -105740,7 +105771,8 @@ async function runUpdate(deps) {
105740
105771
  startedAt,
105741
105772
  pid: deps.pid,
105742
105773
  finishedAt: new Date(deps.now()).toISOString(),
105743
- detail
105774
+ detail,
105775
+ attempts: priorFailures(target) + 1
105744
105776
  });
105745
105777
  throw new ExpectedCliError(`${detail}. Update by hand: ${byHand}`);
105746
105778
  }
@@ -105764,8 +105796,8 @@ function launchBackgroundUpdate(deps) {
105764
105796
  return "already-running";
105765
105797
  }
105766
105798
  const startedAt = new Date(deps.now()).toISOString();
105767
- const attempts = running?.state === "failed" && running.cause === "release-not-served" && running.target === deps.target ? running.attempts : void 0;
105768
- deps.writeProgress({ state: "installing", target: deps.target, startedAt, pid: null, ...attempts !== void 0 && { attempts } });
105799
+ const attempts = failedAttemptsAt(running, deps.target, deps.now());
105800
+ deps.writeProgress({ state: "installing", target: deps.target, startedAt, pid: null, ...attempts > 0 && { attempts } });
105769
105801
  if (deps.spawnChild() === void 0) {
105770
105802
  deps.writeProgress({
105771
105803
  state: "failed",
@@ -105773,7 +105805,8 @@ function launchBackgroundUpdate(deps) {
105773
105805
  startedAt,
105774
105806
  pid: null,
105775
105807
  finishedAt: new Date(deps.now()).toISOString(),
105776
- detail: "The background update could not start."
105808
+ detail: "The background update could not start.",
105809
+ attempts: attempts + 1
105777
105810
  });
105778
105811
  throw new ExpectedCliError("Could not start the background update.");
105779
105812
  }
@@ -105835,6 +105868,9 @@ function parseAutomaticFlag(value) {
105835
105868
  function setAutomaticUpdates(appEnv, enabled) {
105836
105869
  updateCollectorControl(appEnv, (control) => ({ ...control, autoUpdate: enabled }));
105837
105870
  }
105871
+ function failureHoldsRelease(failed2, latestVersion) {
105872
+ return failed2.target === null || failed2.target === latestVersion;
105873
+ }
105838
105874
  function autoUpdateDecision(i) {
105839
105875
  if (!automaticUpdatesOn(i.control)) return { kind: "skip", reason: "off" };
105840
105876
  if (!i.inspection.inPlace.ok) {
@@ -105844,10 +105880,8 @@ function autoUpdateDecision(i) {
105844
105880
  if (!isUpdateAvailable(i.cliVersion, i.latestVersion)) return { kind: "skip", reason: "up-to-date" };
105845
105881
  const progress = updateProgressView(i.progress, i.cliVersion, i.now);
105846
105882
  if (progress.kind === "installing") return { kind: "skip", reason: "already-running" };
105847
- const releaseUnknown = progress.kind === "failed" && progress.target === null && !isPerUserInstall(i.inspection);
105848
- if (progress.kind === "failed" && (releaseUnknown || progress.target === i.latestVersion)) {
105849
- if (progress.retryable) return { kind: "update", target: i.latestVersion };
105850
- return { kind: "skip", reason: "failed-before", detail: progress.detail };
105883
+ if (progress.kind === "failed" && failureHoldsRelease(progress, i.latestVersion) && i.now < progress.retryAt) {
105884
+ return { kind: "skip", reason: "retry-later", detail: progress.detail };
105851
105885
  }
105852
105886
  return { kind: "update", target: i.latestVersion };
105853
105887
  }
@@ -106032,10 +106066,10 @@ function updateItems(i, progress, envArgs2, problem) {
106032
106066
  }
106033
106067
  }
106034
106068
  function failedUpdateDetail(i, progress) {
106035
- if (progress.retryable && automaticUpdatesOn(i.control) && i.service === "loaded") {
106036
- return `${progress.detail} Background sync retries within the hour.`;
106037
- }
106038
- return progress.detail;
106069
+ if (!automaticUpdatesOn(i.control) || i.service !== "loaded" || !i.update.inPlace) return progress.detail;
106070
+ const sentence = /[.!?]$/.test(progress.detail) ? progress.detail : `${progress.detail}.`;
106071
+ const waitsADay = failureHoldsRelease(progress, i.latestVersion) && progress.retryAt - i.now > 60 * 6e4;
106072
+ return `${sentence} Background sync retries ${waitsADay ? "in about a day" : "within the hour"}.`;
106039
106073
  }
106040
106074
  function collectorBlock(i, envArgs2, problem, warning2, more) {
106041
106075
  const restart = {
@@ -107443,7 +107477,7 @@ async function confirmResume(deps, output2) {
107443
107477
  var MACOS_BLOCKED_FOLDER_REMEDY = "To allow it, open System Settings > Privacy & Security > Files and Folders, enable the folder for node, then run `powerplant init`.";
107444
107478
 
107445
107479
  // src/version.ts
107446
- var CLI_VERSION = true ? "0.4.44" : "0.0.0-checkout";
107480
+ var CLI_VERSION = true ? "0.4.45" : "0.0.0-checkout";
107447
107481
  var CLI_RELEASE_BUILD = true ? true : false;
107448
107482
  var CLI_DEVELOPMENT_COPY = false;
107449
107483
  function updateRefusal(tarball, developmentCopy = CLI_DEVELOPMENT_COPY) {
@@ -109855,4 +109889,4 @@ undici/lib/web/websocket/frame.js:
109855
109889
  (*! ws. MIT License. Einar Otto Stangvik <einaros@gmail.com> *)
109856
109890
  */
109857
109891
 
109858
- //# debugId=e21c9e8f-a5a6-561f-b7c6-99dd92ba2436
109892
+ //# debugId=fc35294e-883a-5146-8d1c-99832269672d
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@usepowerplant/cli",
3
- "version": "0.4.44",
3
+ "version": "0.4.45",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },