@theholocron/cli 5.0.0-alpha.491 → 5.0.0-alpha.493

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/README.md CHANGED
@@ -557,6 +557,14 @@ non-zero and the output includes the provider's own reason
557
557
  exited with 1`). Providers build asynchronously, so accepting a deployment
558
558
  isn't the same as it going live (holocron#911).
559
559
 
560
+ With `--files`, a deployment that ends `error` because its package install
561
+ failed (`Command "npm install" exited with 1`) is deployed again, twice more,
562
+ after 60 s and then 120 s: right after a release the registry can lag a
563
+ version published seconds earlier (holocron#2406). Each retry is reported, and
564
+ when every try fails the command exits non-zero with the deployment URL, the
565
+ install error and the manual redeploy command. Any other failure (a build
566
+ error, a cancellation, a timeout) is never retried.
567
+
560
568
  Provider plugins support this through the `Deployment` capability's
561
569
  existing `getDeployment(id)`. They should set `errorMessage` on the
562
570
  returned `DeploymentRecord` whenever the provider exposes one.
package/dist/cli.mjs CHANGED
@@ -6135,6 +6135,9 @@ const deployOnReleaseCommand = {
6135
6135
  */
6136
6136
  const DEFAULT_WAIT_TIMEOUT_MS = 6e5;
6137
6137
  const DEFAULT_WAIT_INTERVAL_MS = 5e3;
6138
+ /** Tries for a files deployment whose install fails (the first plus two retries), and the waits between them (3 minutes in all). */
6139
+ const DEFAULT_INSTALL_RETRY_ATTEMPTS = 3;
6140
+ const DEFAULT_INSTALL_RETRY_DELAYS_MS = [6e4, 12e4];
6138
6141
  const TERMINAL_STATUSES = /* @__PURE__ */ new Set([
6139
6142
  "ready",
6140
6143
  "error",
@@ -6158,6 +6161,10 @@ async function waitForDeployment(deploy, deploymentId, options = {}) {
6158
6161
  await sleep(intervalMs);
6159
6162
  }
6160
6163
  }
6164
+ /** True for a deployment the provider ended in `error` because its package install failed. */
6165
+ function isInstallFailure(record) {
6166
+ return record.status === "error" && /\b(?:npm|pnpm|yarn) install\b/i.test(record.errorMessage ?? "");
6167
+ }
6161
6168
  /** One terminal, non-ready record as a single human-readable failure line. */
6162
6169
  function terminalFailure(record) {
6163
6170
  return `deployment ${record.id} ended ${record.status}${record.errorMessage ? `: ${record.errorMessage}` : ""}`;
@@ -6290,19 +6297,38 @@ async function runDeployFromFiles(input) {
6290
6297
  };
6291
6298
  }
6292
6299
  try {
6293
- const result = await withSpinner(`Deploying ${fileCount} file${fileCount === 1 ? "" : "s"} from ${input.dir}…`, () => deploy.deployFunction(input.projectId, {
6294
- files,
6295
- ...input.target ? { target: input.target } : {},
6296
- ...input.previewKey && !input.target ? { meta: { holocronPreview: input.previewKey } } : {}
6297
- }));
6298
- logger.info({
6299
- url: result.url,
6300
- id: result.deploymentId
6301
- }, "deploy: triggered (files)");
6302
- const record = await withSpinner(`Waiting for ${withScheme(result.url)} to finish…`, () => waitForDeployment(deploy, result.deploymentId, input.wait));
6303
- if (record.status !== "ready") {
6304
- const message = terminalFailure(record);
6305
- print(` ${style.fail(`${message} — ${withScheme(result.url)}`)}`);
6300
+ const retry = input.retry ?? {};
6301
+ const attempts = Math.max(1, retry.attempts ?? DEFAULT_INSTALL_RETRY_ATTEMPTS);
6302
+ const delays = retry.delaysMs ?? DEFAULT_INSTALL_RETRY_DELAYS_MS;
6303
+ const sleep = retry.sleep ?? ((ms) => new Promise((resolve) => setTimeout(resolve, ms)));
6304
+ let result;
6305
+ for (let attempt = 1;; attempt++) {
6306
+ result = await withSpinner(`Deploying ${fileCount} file${fileCount === 1 ? "" : "s"} from ${input.dir}…`, () => deploy.deployFunction(input.projectId, {
6307
+ files,
6308
+ ...input.target ? { target: input.target } : {},
6309
+ ...input.previewKey && !input.target ? { meta: { holocronPreview: input.previewKey } } : {}
6310
+ }));
6311
+ logger.info({
6312
+ url: result.url,
6313
+ id: result.deploymentId,
6314
+ attempt
6315
+ }, "deploy: triggered (files)");
6316
+ const record = await withSpinner(`Waiting for ${withScheme(result.url)} to finish…`, () => waitForDeployment(deploy, result.deploymentId, input.wait));
6317
+ if (record.status === "ready") break;
6318
+ if (isInstallFailure(record) && attempt < attempts) {
6319
+ const delayMs = delays[Math.min(attempt - 1, delays.length - 1)] ?? 0;
6320
+ print(` ${style.warn(`${terminalFailure(record)} — ${withScheme(result.url)}; retrying in ${Math.round(delayMs / 1e3)}s (attempt ${attempt + 1} of ${attempts})`)}`);
6321
+ logger.warn({
6322
+ id: record.id,
6323
+ reason: record.errorMessage,
6324
+ attempt
6325
+ }, "deploy: install failed, retrying");
6326
+ await sleep(delayMs);
6327
+ continue;
6328
+ }
6329
+ const base = terminalFailure(record);
6330
+ const message = isInstallFailure(record) ? `${base} — ${withScheme(result.url)} (after ${attempt} attempt${attempt === 1 ? "" : "s"}). Redeploy by hand with \`pnpm --filter @theholocron/sentinel run deploy\` once npm serves the staged versions.` : base;
6331
+ print(` ${style.fail(`${message}${isInstallFailure(record) ? "" : ` — ${withScheme(result.url)}`}`)}`);
6306
6332
  logger.warn({
6307
6333
  id: record.id,
6308
6334
  status: record.status,
@@ -24409,7 +24435,11 @@ function groupOf(dir) {
24409
24435
  return dir.split("/")[0] || "root";
24410
24436
  }
24411
24437
  // src/commands/probe/deps/collect-edges.ts
24412
- /** Every dependency edge in the workspace: one per manifest entry that is not a `workspace:` link. */
24438
+ /**
24439
+ * Every dependency edge in the workspace: one per manifest entry that is not a `workspace:` link. The root manifest's
24440
+ * `link:` entries for workspace packages are left out too: turbo gives the root an edge to every package that has no
24441
+ * internal dependency, so a `workspace:` entry there makes every package affected by a change to any of them (#2407).
24442
+ */
24413
24443
  function collectEdges(root, dirs) {
24414
24444
  const edges = [];
24415
24445
  const inRepo = /* @__PURE__ */ new Set();
@@ -24428,6 +24458,7 @@ function collectEdges(root, dirs) {
24428
24458
  for (const [name, spec] of Object.entries(entries)) {
24429
24459
  const range = String(spec);
24430
24460
  if (range.startsWith("workspace:")) continue;
24461
+ if (dir === "" && range.startsWith("link:") && inRepo.has(name)) continue;
24431
24462
  edges.push({
24432
24463
  name,
24433
24464
  spec: range,
@@ -28103,6 +28134,7 @@ async function runProjectReconcile(input) {
28103
28134
  }
28104
28135
  let board;
28105
28136
  let plan;
28137
+ const problems = [];
28106
28138
  try {
28107
28139
  board = await projects.find(owner, declared.name);
28108
28140
  if (!board) {
@@ -28111,6 +28143,10 @@ async function runProjectReconcile(input) {
28111
28143
  }
28112
28144
  const items = await projects.items(owner, board, template);
28113
28145
  plan = planReconcile(items, template);
28146
+ for (const item of items) {
28147
+ if (item.pullRequestsProblem === void 0) continue;
28148
+ problems.push(`${item.key} pull requests could not be read (${item.pullRequestsProblem}): their rules were not applied`);
28149
+ }
28114
28150
  const settled = /* @__PURE__ */ new Set([...plan.changes.map((c) => c.key), ...plan.unset.map((i) => i.key)]);
28115
28151
  for (const item of items) {
28116
28152
  if (settled.has(item.key)) continue;
@@ -28158,6 +28194,14 @@ async function runProjectReconcile(input) {
28158
28194
  }, "reconcile project");
28159
28195
  }
28160
28196
  }
28197
+ for (const problem of problems) {
28198
+ print(` ${style.warn(problem)}`);
28199
+ logger.warn({
28200
+ board: declared.name,
28201
+ reason: problem
28202
+ }, "reconcile project");
28203
+ skipped++;
28204
+ }
28161
28205
  for (const item of plan.unset) {
28162
28206
  print(` ${style.warn(`${item.key} has no status: needs a decision, left as it is`)}`);
28163
28207
  skipped++;