@cnc-tools/storm 0.6.0 → 0.8.0

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 (174) hide show
  1. package/dist/build-info.js +1 -1
  2. package/dist/commands/exec/cleanup.d.ts +3 -3
  3. package/dist/commands/exec/cleanup.js +1 -1
  4. package/dist/commands/exec/command.d.ts +797 -1
  5. package/dist/commands/exec/command.js +1 -1
  6. package/dist/commands/exec/live-view.js +32 -15
  7. package/dist/commands/exec/metadata.d.ts +5 -2
  8. package/dist/commands/exec/metadata.js +4 -0
  9. package/dist/commands/exec/mint-failed.d.ts +28 -0
  10. package/dist/commands/exec/outcomes.d.ts +526 -0
  11. package/dist/commands/exec/outcomes.js +9 -0
  12. package/dist/commands/exec/progress.d.ts +14 -2
  13. package/dist/commands/exec/progress.js +57 -14
  14. package/dist/commands/exec/run-command.d.ts +10 -4
  15. package/dist/commands/exec/run-command.js +41 -8
  16. package/dist/commands/exec/run-metadata.d.ts +6 -3
  17. package/dist/commands/exec/run-metadata.js +6 -3
  18. package/dist/commands/exec/run-record.d.ts +83 -4
  19. package/dist/commands/exec/run-record.js +49 -1
  20. package/dist/commands/exec/tests-summary.d.ts +1 -1
  21. package/dist/commands/exec/tests-summary.js +1 -1
  22. package/dist/commands/exec/view.js +36 -4
  23. package/dist/commands/runs/facts.d.ts +25 -0
  24. package/dist/commands/runs/facts.js +36 -3
  25. package/dist/commands/runs/list/command.d.ts +154 -1
  26. package/dist/commands/runs/list/command.js +1 -1
  27. package/dist/commands/runs/list/outcomes.d.ts +41 -0
  28. package/dist/commands/runs/logs/command.d.ts +263 -1
  29. package/dist/commands/runs/logs/command.js +1 -1
  30. package/dist/commands/runs/logs/outcomes.d.ts +105 -0
  31. package/dist/commands/runs/show/command.d.ts +354 -1
  32. package/dist/commands/runs/show/command.js +1 -1
  33. package/dist/commands/runs/show/metadata.js +1 -1
  34. package/dist/commands/runs/show/outcomes.d.ts +96 -0
  35. package/dist/commands/runs/show/outcomes.js +30 -1
  36. package/dist/commands/vitest/command.d.ts +912 -1
  37. package/dist/commands/vitest/command.js +1 -1
  38. package/dist/commands/vitest/metadata.d.ts +5 -2
  39. package/dist/commands/vitest/metadata.js +4 -0
  40. package/dist/commands/vitest/outcomes.d.ts +320 -0
  41. package/dist/config/errors.d.ts +73 -0
  42. package/dist/config/schema.d.ts +1 -1
  43. package/dist/config-file/define.d.ts +4 -3
  44. package/dist/config-file/define.js +1 -1
  45. package/dist/config-file/toolchain.js +1 -1
  46. package/dist/core/command-slots.d.ts +8 -2
  47. package/dist/core/command-slots.js +6 -2
  48. package/dist/core/events.d.ts +9 -7
  49. package/dist/core/index.d.ts +1 -1
  50. package/dist/core/run-state.d.ts +30 -6
  51. package/dist/core/run-state.js +19 -4
  52. package/dist/core/run.d.ts +17 -4
  53. package/dist/core/run.js +61 -25
  54. package/dist/credential/index.d.ts +1 -0
  55. package/dist/credential/index.js +1 -0
  56. package/dist/credential/settle.d.ts +20 -0
  57. package/dist/credential/target.d.ts +6 -0
  58. package/dist/credential/target.js +7 -0
  59. package/dist/resources/github/command.d.ts +54 -2
  60. package/dist/resources/github/config.js +1 -1
  61. package/dist/resources/github/index.js +1 -1
  62. package/dist/resources/github/resource.js +2 -2
  63. package/dist/resources/testserver/command.d.ts +208 -10
  64. package/dist/resources/testserver/command.js +7 -0
  65. package/dist/resources/testserver/commands/create/command.d.ts +808 -1
  66. package/dist/resources/testserver/commands/create/command.js +64 -23
  67. package/dist/resources/testserver/commands/create/metadata.js +6 -2
  68. package/dist/resources/testserver/commands/create/outcomes.d.ts +347 -0
  69. package/dist/resources/testserver/commands/create/outcomes.js +14 -1
  70. package/dist/resources/testserver/commands/list/command.d.ts +84 -1
  71. package/dist/resources/testserver/commands/list/command.js +1 -1
  72. package/dist/resources/testserver/commands/list/outcomes.d.ts +16 -0
  73. package/dist/resources/testserver/config.js +14 -4
  74. package/dist/resources/testserver/events.d.ts +9 -0
  75. package/dist/resources/testserver/index.js +8 -7
  76. package/dist/resources/testserver/lane.js +1 -0
  77. package/dist/resources/testserver/live/gateways.d.ts +2 -0
  78. package/dist/resources/testserver/live/gateways.js +16 -3
  79. package/dist/resources/testserver/pool/channels.d.ts +5 -2
  80. package/dist/resources/testserver/pool/channels.js +1 -1
  81. package/dist/resources/testserver/pool/create.d.ts +6 -2
  82. package/dist/resources/testserver/pool/create.js +6 -5
  83. package/dist/resources/testserver/pool/index.d.ts +1 -0
  84. package/dist/resources/testserver/pool/index.js +1 -0
  85. package/dist/resources/testserver/pool/pull-request.d.ts +89 -0
  86. package/dist/resources/testserver/pool/pull-request.js +85 -0
  87. package/dist/resources/testserver/pr-build-facts.d.ts +130 -0
  88. package/dist/resources/testserver/pr-build-facts.js +261 -0
  89. package/dist/resources/testserver/presentation.d.ts +2 -2
  90. package/dist/resources/testserver/presentation.js +12 -3
  91. package/dist/resources/testserver/provider.d.ts +16 -6
  92. package/dist/resources/testserver/provider.js +46 -15
  93. package/dist/resources/testserver/pull-request/gateways.d.ts +117 -0
  94. package/dist/resources/testserver/pull-request/gateways.js +5 -0
  95. package/dist/resources/testserver/pull-request/index.d.ts +5 -0
  96. package/dist/resources/testserver/pull-request/index.js +6 -0
  97. package/dist/resources/testserver/pull-request/live/github-rest.d.ts +28 -0
  98. package/dist/resources/testserver/pull-request/live/github-rest.js +114 -0
  99. package/dist/resources/testserver/pull-request/live/github-token-gateway.d.ts +12 -0
  100. package/dist/resources/testserver/pull-request/live/github-token-gateway.js +39 -0
  101. package/dist/resources/testserver/pull-request/live/pull-request-gateway.d.ts +10 -0
  102. package/dist/resources/testserver/pull-request/live/pull-request-gateway.js +27 -0
  103. package/dist/resources/testserver/pull-request/live/testserver-workflow-gateway.d.ts +21 -0
  104. package/dist/resources/testserver/pull-request/live/testserver-workflow-gateway.js +64 -0
  105. package/dist/resources/testserver/ran.d.ts +5 -0
  106. package/dist/resources/testserver/ran.js +19 -3
  107. package/dist/resources/testserver/resource.d.ts +5 -1
  108. package/dist/resources/testserver/resource.js +2 -2
  109. package/dist/resources/testserver/sandbox/build-reference.d.ts +38 -0
  110. package/dist/resources/testserver/sandbox/build-reference.js +79 -0
  111. package/dist/resources/testserver/sandbox/index.d.ts +1 -0
  112. package/dist/resources/testserver/sandbox/index.js +1 -0
  113. package/dist/resources.d.ts +265 -15
  114. package/dist/runner/events.d.ts +64 -1
  115. package/dist/runner/gateways.d.ts +17 -6
  116. package/dist/runner/index.d.ts +5 -4
  117. package/dist/runner/index.js +4 -3
  118. package/dist/runner/live/snapshot-records.js +18 -4
  119. package/dist/runner/prepare.d.ts +23 -4
  120. package/dist/runner/prepare.js +13 -3
  121. package/dist/runner/ready.d.ts +7 -3
  122. package/dist/runner/ready.js +11 -5
  123. package/dist/runner/scope.d.ts +17 -1
  124. package/dist/runner/scope.js +4 -0
  125. package/dist/runner/snapshot-build.d.ts +3 -1
  126. package/dist/runner/snapshot-build.js +12 -2
  127. package/dist/runner/snapshot-cache.d.ts +46 -8
  128. package/dist/runner/snapshot-cache.js +60 -11
  129. package/dist/runner/snapshot-key.d.ts +12 -1
  130. package/dist/runner/snapshot-key.js +17 -1
  131. package/dist/runner/snapshot-save.d.ts +53 -0
  132. package/dist/runner/snapshot-save.js +148 -0
  133. package/dist/sdk/index.js +2 -2
  134. package/dist/story/align.d.ts +1 -1
  135. package/dist/story/align.js +1 -1
  136. package/dist/story/command-line.d.ts +34 -0
  137. package/dist/story/command-line.js +100 -0
  138. package/dist/story/definition.d.ts +22 -15
  139. package/dist/story/definition.js +2 -2
  140. package/dist/story/errors.js +1 -1
  141. package/dist/story/gateways.d.ts +45 -25
  142. package/dist/story/gateways.js +2 -2
  143. package/dist/story/host.d.ts +11 -8
  144. package/dist/story/host.js +37 -37
  145. package/dist/story/index.d.ts +2 -1
  146. package/dist/story/index.js +6 -5
  147. package/dist/story/json.d.ts +1 -1
  148. package/dist/story/json.js +2 -2
  149. package/dist/story/live/recording-gateway.d.ts +2 -0
  150. package/dist/story/live/{artifact-gateway.js → recording-gateway.js} +33 -12
  151. package/dist/story/mode.d.ts +2 -2
  152. package/dist/story/mode.js +1 -1
  153. package/dist/story/orphans.d.ts +23 -5
  154. package/dist/story/orphans.js +44 -8
  155. package/dist/story/recording.d.ts +62 -0
  156. package/dist/story/{artifact.js → recording.js} +31 -27
  157. package/dist/story/report.d.ts +21 -9
  158. package/dist/story/report.js +37 -25
  159. package/dist/story/settle.d.ts +23 -21
  160. package/dist/story/settle.js +17 -16
  161. package/dist/story/{run.d.ts → start.d.ts} +18 -17
  162. package/dist/story/{run.js → start.js} +66 -43
  163. package/dist/vercel-cli/context.js +1 -1
  164. package/dist/vercel-cli/index.js +1 -1
  165. package/dist/vitest/config.js +2 -2
  166. package/dist/vitest/fixtures.d.ts +1 -1
  167. package/dist/vitest/fixtures.js +1 -1
  168. package/dist/vitest/index.js +3 -3
  169. package/dist/vitest/plan.js +1 -1
  170. package/package.json +3 -3
  171. package/skills/overview.md +2 -0
  172. package/skills/testserver-builds.md +80 -0
  173. package/dist/story/artifact.d.ts +0 -60
  174. package/dist/story/live/artifact-gateway.d.ts +0 -2
@@ -12,7 +12,7 @@ export function command(cmd) {
12
12
  command: z.array(z.string()).min(1, { message: "Give the command to run after --" }),
13
13
  }),
14
14
  cli: { options: RUN_CLI_OPTIONS, positionals: ["command"] },
15
- outcomes,
15
+ response: outcomes,
16
16
  validate: runProblems,
17
17
  handler: async (context, request) => await runCommand(context, request, {
18
18
  name: "exec",
@@ -5,6 +5,7 @@
5
5
  // starts, it is printed above for good in its final form. Each resource lane's rows are its presentation's text
6
6
  // (`RESOURCE_PRESENTATIONS`), laid out here.
7
7
  import { cleanupProblems, megabytesText, } from "../../core/index.js";
8
+ import { mintTargetText } from "../../credential/index.js";
8
9
  import { RESOURCE_PRESENTATIONS } from "../../resources.js";
9
10
  import { versionText } from "../../version.js";
10
11
  import { commandEnd, LANE_WIDTH } from "./progress.js";
@@ -72,7 +73,7 @@ export function phaseFrame(state, phase, now, width, paint) {
72
73
  case "tests":
73
74
  return testsFrame(state, view);
74
75
  case "cleanup":
75
- return state.cleanup === undefined ? [] : [cleanupLine(state.cleanup, state.runner?.kept, view, false)];
76
+ return state.cleanup === undefined ? [] : [cleanupLine(state.cleanup, state.runner, view, false)];
76
77
  }
77
78
  }
78
79
  /**
@@ -102,7 +103,7 @@ export function phaseRecord(state, phase, width, paint) {
102
103
  case "tests":
103
104
  return state.command === undefined ? [] : [testsLine(state, state.command, view, false)];
104
105
  case "cleanup":
105
- return state.cleanup === undefined ? [] : [cleanupLine(state.cleanup, state.runner?.kept, view, true)];
106
+ return state.cleanup === undefined ? [] : [cleanupLine(state.cleanup, state.runner, view, true)];
106
107
  }
107
108
  }
108
109
  /** What a resource lane's presentation draws with: `view`, with its span's time and durations. */
@@ -121,7 +122,7 @@ function elapsed(view, from, to) {
121
122
  return from === undefined || end === undefined ? "" : seconds(end - from);
122
123
  }
123
124
  function credentialLine(mint, view) {
124
- return view.row(` ${view.glyph(mint.status)} credential ${mint.target.team}/${mint.target.project}`, elapsed(view, mint.startedAt, mint.endedAt));
125
+ return view.row(` ${view.glyph(mint.status)} credential ${mintTargetText(mint.target)}`, elapsed(view, mint.startedAt, mint.endedAt));
125
126
  }
126
127
  /**
127
128
  * The lanes block: a row for each resource lane the run holds, a runner row with its current step and the steps it
@@ -272,7 +273,7 @@ function localResourcesFrame(state, view) {
272
273
  const { mint } = state;
273
274
  const draw = laneDraw(view);
274
275
  const mintRow = mint !== undefined && mint.status === "running"
275
- ? view.row(` ${view.glyph("running")} minting a credential for ${mint.target.team}/${mint.target.project}`, elapsed(view, mint.startedAt, mint.endedAt))
276
+ ? view.row(` ${view.glyph("running")} minting a credential for ${mintTargetText(mint.target)}`, elapsed(view, mint.startedAt, mint.endedAt))
276
277
  : undefined;
277
278
  const rows = RESOURCE_PRESENTATIONS.lanes.flatMap((lane) => {
278
279
  const row = lane.localRow(state.resources, draw);
@@ -354,27 +355,43 @@ function testsProgress(tests, view, room) {
354
355
  return visibleLength(full) <= room ? full : text(false);
355
356
  }
356
357
  /**
357
- * The cleanup row: what it does while it runs, what it did in its final form, with the runner sandbox it `kept`
358
- * running, if it kept one.
358
+ * The cleanup row: what it does while it runs, what it did in its final form, with the runner sandbox it kept
359
+ * running, if it kept one, or the branch snapshot it saved it as.
359
360
  */
360
- function cleanupLine(cleanup, kept, view, record) {
361
+ function cleanupLine(cleanup, runner, view, record) {
361
362
  const done = record || cleanup.status !== "running";
362
363
  const releases = RESOURCE_PRESENTATIONS.releaseTexts(cleanup.holdings, done ? "done" : "doing");
363
364
  const release = releases.length === 0 ? undefined : releases.join(", ");
364
- const sandbox = kept !== undefined
365
- ? `kept the runner sandbox until ${isoSecondsText(kept.stopsAt)}`
366
- : !done && cleanup.keepSandboxMs > 0
367
- ? `keeping the runner sandbox running ${keepTimeText(cleanup.keepSandboxMs)}`
368
- : `${done ? "stopped and deleted" : "stopping and deleting"} the runner sandbox`;
365
+ const { runnerSandbox } = cleanup;
369
366
  const text = !done && cleanup.waiting
370
367
  ? `${WAITING_FOR_SNAPSHOT}…`
371
- : cleanup.runner
372
- ? `${sandbox}${release === undefined ? "" : `, ${release}`}`
373
- : (release ?? "nothing to release");
368
+ : runnerSandbox === null
369
+ ? (release ?? "nothing to release")
370
+ : `${runnerSandboxText(runnerSandbox, runner, done)}${release === undefined ? "" : `, ${release}`}`;
374
371
  const leftBehind = cleanupProblems(cleanup);
375
372
  const ending = done ? (leftBehind === 0 ? "" : `: ${leftBehind} left behind`) : "…";
376
373
  return view.row(` ${view.glyph(cleanup.status)} cleanup ${text}${!done && cleanup.waiting ? "" : ending}`, elapsed(view, cleanup.startedAt, cleanup.endedAt));
377
374
  }
375
+ /**
376
+ * What cleanup does with the runner sandbox, as the cleanup row says: kept it running, keeps it running while cleanup
377
+ * runs (`keep`), saves it or saved it as a branch snapshot (`save`), or else stops and deletes it.
378
+ */
379
+ function runnerSandboxText(sandbox, runner, done) {
380
+ const kept = runner?.kept;
381
+ if (kept !== undefined)
382
+ return `kept the runner sandbox until ${isoSecondsText(kept.stopsAt)}`;
383
+ const removed = `${done ? "stopped and deleted" : "stopping and deleting"} the runner sandbox`;
384
+ switch (sandbox.kind) {
385
+ case "keep":
386
+ return !done && sandbox.ms > 0 ? `keeping the runner sandbox running ${keepTimeText(sandbox.ms)}` : removed;
387
+ case "save": {
388
+ const save = runner?.save;
389
+ if (save?.kind === "saved")
390
+ return `saved branch snapshot ${save.id} of ${save.branch}`;
391
+ return !done && save?.kind !== "not-saved" ? `saving a branch snapshot of ${sandbox.branch}` : removed;
392
+ }
393
+ }
394
+ }
378
395
  function statusGlyph(status, now, paint) {
379
396
  switch (status) {
380
397
  case "pending":
@@ -9,7 +9,7 @@ export declare const metadata: {
9
9
  };
10
10
  testserverBuild: {
11
11
  readonly valueLabel: "BUILD";
12
- readonly description: "The build the Testserver sandboxes run: a build name or the build channel stable or latest_main, overriding resources.testserverPool.build in storm.config.ts; default stable. Gives the run a Testserver side.";
12
+ readonly description: "The build the Testserver sandboxes run: a build name, the build channel stable or latest_main, or a vercel/api pull request as pr:<N> or its URL, overriding resources.testserverPool.build in storm.config.ts; default stable. A pull request runs on the newest build made from its head commit, which storm reads from GitHub with GITHUB_TOKEN, GH_TOKEN or gh auth token, or refuses. Gives the run a Testserver side.";
13
13
  };
14
14
  testserverMinTimeLeft: {
15
15
  readonly valueLabel: "DURATION";
@@ -34,7 +34,10 @@ export declare const metadata: {
34
34
  readonly description: "Run the command on this machine instead of in a runner sandbox. Without it, the command runs in a Vercel Sandbox started from a runner snapshot of the base, with this checkout's changes applied, installed and built, from the runner key of storm.config.ts, and its output streams back with paths rewritten to this checkout's. No config key.";
35
35
  };
36
36
  rebuildSnapshot: {
37
- readonly description: "Build a runner snapshot of the base whatever the runner snapshot cache holds, replacing an entry for the same base. Not with --local. No config key.";
37
+ readonly description: "Build a runner snapshot of the base whatever the runner snapshot cache holds, replacing an entry for the same base, and drop this branch's saved branch snapshots from the cache. Not with --local. No config key.";
38
+ };
39
+ saveSnapshot: {
40
+ readonly description: "Once the command ends on its own after a successful install and build, save the runner sandbox as this branch's runner snapshot, so the next run on the branch starts from this run's install and build outputs. The run resets the working tree to the snapshot's base, keeps .git and ignored files such as node_modules and build outputs, and empties /tmp; the snapshot keeps whatever the command wrote there and to $HOME, a resource's token included. A run with it on a branch keeps no runner sandbox, even when it fails or stops before the save. With a detached HEAD it says so as it starts and keeps the runner sandbox as without the flag. Not with --local, or with --keep-sandbox above 0. No config key.";
38
41
  };
39
42
  keepSandbox: {
40
43
  readonly valueLabel: "DURATION";
@@ -35,6 +35,10 @@ export const metadata = {
35
35
  argv: "--local --testserver-ttl 30m --testserver-min-time-left 25m -- pnpm test",
36
36
  description: "Create Testserver sandboxes that live 30 minutes, with team and project from storm.config.ts.",
37
37
  },
38
+ {
39
+ argv: "--local --testserver-build pr:104196 -- pnpm test",
40
+ description: "Run the tests on this machine against the Testserver build of vercel/api pull request 104196's head commit.",
41
+ },
38
42
  {
39
43
  argv: "--local --testserver-no-create --testserver-sandboxes 4 -- pnpm test",
40
44
  description: "Run only on Testserver sandboxes already in the pool, never minting.",
@@ -8,4 +8,32 @@ export declare const mintFailedErrors: import("@vercel/clinkr").SharedErrors<{
8
8
  runner: z.ZodBoolean;
9
9
  cleanup: z.ZodType<import("./cleanup.ts").StormCleanupFacts, import("./cleanup.ts").StormCleanupFacts, z.core.$ZodTypeInternals<import("./cleanup.ts").StormCleanupFacts, import("./cleanup.ts").StormCleanupFacts>>;
10
10
  }, z.core.$strip>;
11
+ }, {
12
+ readonly mintFailed: {
13
+ readonly exitCode: 1;
14
+ readonly description: "The vercel CLI couldn't mint a credential, so the command didn't run. In a runner run, the credential was for the runner sandbox, which always needs one; in a local run, for a resource that couldn't go on without it.";
15
+ readonly schema: z.ZodObject<{
16
+ team: z.ZodString;
17
+ project: z.ZodString;
18
+ cause: z.ZodString;
19
+ fix: z.ZodString;
20
+ runner: z.ZodBoolean;
21
+ cleanup: z.ZodType<import("./cleanup.ts").StormCleanupFacts, import("./cleanup.ts").StormCleanupFacts, z.core.$ZodTypeInternals<import("./cleanup.ts").StormCleanupFacts, import("./cleanup.ts").StormCleanupFacts>>;
22
+ }, z.core.$strip>;
23
+ readonly render: ({ cause, fix, runner, cleanup }: {
24
+ team: string;
25
+ project: string;
26
+ cause: string;
27
+ fix: string;
28
+ runner: boolean;
29
+ cleanup: import("./cleanup.ts").StormCleanupFacts;
30
+ }) => {
31
+ message: string;
32
+ rows?: readonly import("@vercel/clinkr").Row[];
33
+ next: {
34
+ type: "text";
35
+ text: string;
36
+ }[];
37
+ };
38
+ };
11
39
  }>;