@haakco/hostingctl 1.0.394 → 1.0.403

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
@@ -909,13 +909,44 @@ function createTransport(target) {
909
909
  };
910
910
  };
911
911
  }
912
+ /** The target the current command was configured with, so a call that legitimately takes minutes can borrow a budget. */
913
+ var activeTarget = null;
912
914
  /** Point the generated client at one target. Called once, before any command runs. */
913
915
  function configureApi(target) {
916
+ activeTarget = target;
914
917
  client.setConfig({
915
918
  baseURL: target.baseURL,
916
919
  transport: createTransport(target)
917
920
  });
918
921
  }
922
+ /**
923
+ * Run one call with a longer request budget than the default.
924
+ *
925
+ * The default bounds a conversational round trip at a minute. An import upload is not one: it streams a site's files
926
+ * and the API stages the entire archive — expanding every entry and normalizing the database — before it answers, so
927
+ * its duration follows the archive rather than the connection. The first real customer backup is 1.6 GiB across 74,150
928
+ * entries, and the default reported that request as unanswered while the server was still working on it. The ordinary
929
+ * budget is restored afterwards, so every later call in the process keeps the tighter limit.
930
+ */
931
+ async function withRequestBudget(timeoutMs, run) {
932
+ if (activeTarget === null) return await run();
933
+ const previous = activeTarget;
934
+ client.setConfig({
935
+ baseURL: previous.baseURL,
936
+ transport: createTransport({
937
+ ...previous,
938
+ timeoutMs
939
+ })
940
+ });
941
+ try {
942
+ return await run();
943
+ } finally {
944
+ client.setConfig({
945
+ baseURL: previous.baseURL,
946
+ transport: createTransport(previous)
947
+ });
948
+ }
949
+ }
919
950
  //#endregion
920
951
  //#region src/platform.ts
921
952
  /** Whether this platform is Windows. */
@@ -10832,6 +10863,8 @@ var USAGE$40 = [
10832
10863
  "what would be uploaded without reading it."
10833
10864
  ].join("\n");
10834
10865
  /** `application import-upload`, which stages a client site for review. */
10866
+ /** How long one import upload may take before the CLI calls it unanswered. */
10867
+ var UPLOAD_REQUEST_BUDGET_MS = 9e5;
10835
10868
  async function applicationUpload(context, path, rest) {
10836
10869
  if (rest.length > 0) throw new UsageError(USAGE$40);
10837
10870
  const database = context.flags.get("--database")?.trim() ?? "";
@@ -10850,15 +10883,16 @@ async function applicationUpload(context, path, rest) {
10850
10883
  directory === "" ? "" : `, ${String(files.length)} file(s) totalling ${describe(fileBytes)}`,
10851
10884
  ". The import is staged for review; nothing is applied yet."
10852
10885
  ].join(""), async () => {
10853
- return (await hostingWordpressImportStore({
10886
+ const body = {
10887
+ database: database === "" ? null : await partOf(database),
10888
+ archive: archive === "" ? null : await partOf(archive),
10889
+ directory: files.length === 0 ? null : await Promise.all(files.map(async (one) => await partOf(one.absolute))),
10890
+ directoryPaths: files.length === 0 ? null : JSON.stringify(files.map((one) => one.relative))
10891
+ };
10892
+ return await withRequestBudget(UPLOAD_REQUEST_BUDGET_MS, async () => (await hostingWordpressImportStore({
10854
10893
  path,
10855
- body: {
10856
- database: database === "" ? null : await partOf(database),
10857
- archive: archive === "" ? null : await partOf(archive),
10858
- directory: files.length === 0 ? null : await Promise.all(files.map(async (one) => await partOf(one.absolute))),
10859
- directoryPaths: files.length === 0 ? null : JSON.stringify(files.map((one) => one.relative))
10860
- }
10861
- })).data;
10894
+ body
10895
+ })).data);
10862
10896
  })
10863
10897
  };
10864
10898
  }
@@ -36987,7 +37021,7 @@ function writeUpdateState(state, env = process.env) {
36987
37021
  }
36988
37022
  //#endregion
36989
37023
  //#region src/version.ts
36990
- var VERSION = "1.0.394";
37024
+ var VERSION = "1.0.403";
36991
37025
  //#endregion
36992
37026
  //#region src/commands/update.ts
36993
37027
  /**
@@ -37062,7 +37096,7 @@ var update = {
37062
37096
  }, process.env);
37063
37097
  return {
37064
37098
  ...known,
37065
- current: after ?? "1.0.394",
37099
+ current: after ?? "1.0.403",
37066
37100
  latest: after ?? latest,
37067
37101
  upToDate: after !== null && (latest === null || !isNewerVersion(latest, after)),
37068
37102
  action: "run",
@@ -37337,7 +37371,7 @@ async function printUpdateNotice(options) {
37337
37371
  }, env, { waitMs: NOTICE_LOCK_WAIT_MS });
37338
37372
  } catch {}
37339
37373
  if (latest === null) return;
37340
- if (!isNewerVersion(latest, "1.0.394")) return;
37374
+ if (!isNewerVersion(latest, "1.0.403")) return;
37341
37375
  process.stderr.write(`A newer hostingctl is published: ${latest} (this copy is ${VERSION}). Run \`hostingctl update\` to update.\n`);
37342
37376
  }
37343
37377
  /** Whether an environment variable is set to something, which is how CI and the opt-out are read. */