@cnc-tools/storm 0.5.0 → 0.6.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 (113) hide show
  1. package/dist/build-info.js +1 -1
  2. package/dist/combine-errors.js +2 -2
  3. package/dist/commands/dashboard.js +1 -1
  4. package/dist/commands/{run → exec}/cleanup.d.ts +1 -1
  5. package/dist/commands/{run → exec}/cleanup.js +1 -1
  6. package/dist/commands/{run/outcomes.d.ts → exec/command.d.ts} +77 -112
  7. package/dist/commands/exec/command.js +23 -0
  8. package/dist/commands/{run → exec}/job-summary.d.ts +5 -1
  9. package/dist/commands/{run → exec}/job-summary.js +5 -2
  10. package/dist/commands/exec/metadata.d.ts +66 -0
  11. package/dist/commands/exec/metadata.js +55 -0
  12. package/dist/commands/{run → exec}/mint-failed.js +4 -4
  13. package/dist/commands/exec/outcomes.d.ts +614 -0
  14. package/dist/commands/exec/outcomes.js +338 -0
  15. package/dist/commands/exec/run-command.d.ts +221 -0
  16. package/dist/commands/exec/run-command.js +663 -0
  17. package/dist/commands/exec/run-metadata.d.ts +56 -0
  18. package/dist/commands/exec/run-metadata.js +58 -0
  19. package/dist/commands/{run → exec}/run-record.d.ts +27 -1
  20. package/dist/commands/{run → exec}/run-record.js +8 -0
  21. package/dist/commands/exec/testserver-flags.d.ts +48 -0
  22. package/dist/commands/exec/testserver-flags.js +80 -0
  23. package/dist/commands/runs/facts.js +2 -2
  24. package/dist/commands/runs/logs/metadata.js +1 -1
  25. package/dist/commands/runs/logs/outcomes.js +4 -1
  26. package/dist/commands/runs/past-run.d.ts +2 -2
  27. package/dist/commands/runs/past-run.js +2 -2
  28. package/dist/commands/runs/show/metadata.js +2 -2
  29. package/dist/commands/runs/show/outcomes.js +7 -4
  30. package/dist/commands/vitest/command.d.ts +299 -0
  31. package/dist/commands/vitest/command.js +138 -0
  32. package/dist/commands/vitest/metadata.d.ts +66 -0
  33. package/dist/commands/vitest/metadata.js +35 -0
  34. package/dist/commands/vitest/outcomes.d.ts +273 -0
  35. package/dist/commands/vitest/outcomes.js +77 -0
  36. package/dist/config/index.d.ts +2 -1
  37. package/dist/config/index.js +1 -0
  38. package/dist/config/resolve.d.ts +3 -3
  39. package/dist/config/resolve.js +3 -3
  40. package/dist/config/resource-config.d.ts +2 -2
  41. package/dist/config/schema.d.ts +1 -1
  42. package/dist/config/set.d.ts +15 -4
  43. package/dist/config/set.js +28 -12
  44. package/dist/config-file/define.d.ts +8 -6
  45. package/dist/context.d.ts +6 -3
  46. package/dist/context.js +4 -2
  47. package/dist/core/command-provider.d.ts +1 -1
  48. package/dist/core/presentation.js +1 -1
  49. package/dist/core/presentations.js +1 -1
  50. package/dist/resources/testserver/command.d.ts +1 -1
  51. package/dist/resources/testserver/command.js +1 -1
  52. package/dist/resources/testserver/config.d.ts +1 -1
  53. package/dist/resources/testserver/config.js +3 -2
  54. package/dist/resources/testserver/credential-facts.js +1 -1
  55. package/dist/resources/testserver/resource.d.ts +2 -2
  56. package/dist/resources/testserver/sandbox/create.d.ts +2 -2
  57. package/dist/resources/testserver/sandbox/create.js +2 -2
  58. package/dist/resources.d.ts +9 -6
  59. package/dist/resources.js +3 -3
  60. package/dist/sdk/index.js +1 -1
  61. package/dist/sdk/payload/payload.d.ts +2 -2
  62. package/dist/sdk/payload/payload.js +2 -2
  63. package/dist/vercel-cli/driver.d.ts +1 -1
  64. package/dist/vercel-cli/entry.d.ts +1 -1
  65. package/dist/vercel-cli/entry.js +1 -1
  66. package/dist/vercel-cli/verbose.d.ts +2 -2
  67. package/dist/vercel-cli/verbose.js +2 -2
  68. package/dist/vitest/config.d.ts +5 -5
  69. package/dist/vitest/config.js +5 -5
  70. package/dist/vitest/find-vitest.d.ts +7 -0
  71. package/dist/vitest/find-vitest.js +28 -0
  72. package/dist/vitest/fixtures.d.ts +2 -2
  73. package/dist/vitest/fixtures.js +3 -3
  74. package/dist/vitest/gateways.d.ts +37 -6
  75. package/dist/vitest/gateways.js +3 -2
  76. package/dist/vitest/live/list-gateway.d.ts +7 -3
  77. package/dist/vitest/live/list-gateway.js +55 -8
  78. package/dist/vitest/plan.d.ts +41 -8
  79. package/dist/vitest/plan.js +47 -16
  80. package/dist/vitest/sandbox.d.ts +1 -1
  81. package/dist/vitest/sandbox.js +1 -1
  82. package/dist/vitest/test-events.d.ts +2 -2
  83. package/dist/vitest/test-events.js +3 -3
  84. package/dist/vitest/test-results.d.ts +1 -1
  85. package/dist/vitest/test-results.js +1 -1
  86. package/dist/vitest/types.d.ts +1 -1
  87. package/package.json +2 -2
  88. package/skills/overview.md +5 -4
  89. package/skills/read-run-output.md +1 -1
  90. package/dist/commands/run/command.d.ts +0 -327
  91. package/dist/commands/run/command.js +0 -620
  92. package/dist/commands/run/metadata.d.ts +0 -47
  93. package/dist/commands/run/metadata.js +0 -83
  94. package/dist/commands/run/outcomes.js +0 -332
  95. /package/dist/commands/{run → exec}/live-view.d.ts +0 -0
  96. /package/dist/commands/{run → exec}/live-view.js +0 -0
  97. /package/dist/commands/{run → exec}/mint-failed.d.ts +0 -0
  98. /package/dist/commands/{run → exec}/progress.d.ts +0 -0
  99. /package/dist/commands/{run → exec}/progress.js +0 -0
  100. /package/dist/commands/{run → exec}/redaction.d.ts +0 -0
  101. /package/dist/commands/{run → exec}/redaction.js +0 -0
  102. /package/dist/commands/{run → exec}/run-collector.d.ts +0 -0
  103. /package/dist/commands/{run → exec}/run-collector.js +0 -0
  104. /package/dist/commands/{run → exec}/tests-summary.d.ts +0 -0
  105. /package/dist/commands/{run → exec}/tests-summary.js +0 -0
  106. /package/dist/commands/{run → exec}/text.d.ts +0 -0
  107. /package/dist/commands/{run → exec}/text.js +0 -0
  108. /package/dist/commands/{run → exec}/view.d.ts +0 -0
  109. /package/dist/commands/{run → exec}/view.js +0 -0
  110. /package/dist/commands/{run → exec}/waterfall.d.ts +0 -0
  111. /package/dist/commands/{run → exec}/waterfall.js +0 -0
  112. /package/dist/commands/{run → exec}/worker-chart.d.ts +0 -0
  113. /package/dist/commands/{run → exec}/worker-chart.js +0 -0
@@ -0,0 +1,56 @@
1
+ /** The flags every run takes, as a usage line names them, before the command's own arguments. */
2
+ export declare const RUN_USAGE_FLAGS = "[--testserver-sandboxes <N>] [--testserver-build <BUILD>] [--testserver-min-time-left <DURATION>] [--testserver-ttl <DURATION> | --testserver-no-create] [--set <KEY=VALUE>]... [--credential <SOURCE>] [--scope <TEAM> --project <PROJECT>] [--local | [--rebuild-snapshot] [--show-output] [--keep-sandbox <DURATION>]] [--verbose]";
3
+ /** The field descriptions of the flags every run takes. */
4
+ export declare const RUN_FIELDS: {
5
+ readonly testserverSandboxes: {
6
+ readonly valueLabel: "N";
7
+ readonly description: "How many Testserver sandboxes the command gets, 1 to 32, overriding resources.testserverPool.sandboxes in storm.config.ts; default 1. Gives the run a Testserver side.";
8
+ };
9
+ readonly testserverBuild: {
10
+ readonly valueLabel: "BUILD";
11
+ 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
+ };
13
+ readonly testserverMinTimeLeft: {
14
+ readonly valueLabel: "DURATION";
15
+ readonly description: "The least time left a Testserver sandbox from the pool needs, in whole minutes or hours (30m, 2h), overriding resources.testserverPool.minTimeLeft in storm.config.ts; default 30m. Gives the run a Testserver side.";
16
+ };
17
+ readonly testserverTtl: {
18
+ readonly valueLabel: "DURATION";
19
+ readonly description: "How long each Testserver sandbox the run creates lives, 10m to 5h and longer than minTimeLeft, overriding resources.testserverPool.ttl in storm.config.ts; default 5h. Not with noCreate. Gives the run a Testserver side.";
20
+ };
21
+ readonly testserverNoCreate: {
22
+ readonly description: "Run only on Testserver sandboxes already in the pool, never minting for Testserver or creating: needs no --scope or --project with --local, and takes no --testserver-ttl. Turns on resources.testserverPool.noCreate whatever storm.config.ts says; without it, the file's noCreate, default false, applies. Gives the run a Testserver side.";
23
+ };
24
+ readonly set: {
25
+ readonly valueLabel: "KEY=VALUE";
26
+ readonly description: "Set a resource's option for this run by its key path in storm.config.ts, resources.<name>.<option>, overriding the file and the default; repeat it for each option. The key paths: resources.githubFixtureRepo.repo, the GitHub repository as owner/name, required; resources.githubFixtureRepo.tokenEnv, the host environment variable holding its token, required; resources.githubFixtureRepo.optional, true or false, default false: false refuses the run without the token, true goes on without the repository. The Testserver pool resource's options have their own flags, --testserver-<option>, which --set doesn't take. Any --set of a resource's option gives the run that resource, as storm.config.ts does. An unknown key path, one given twice, one with its own flag, or a value its option refuses is a usage error. Options that don't fit together once merged, or a required one nothing gives, are invalid_resource_options, naming where each value came from.";
27
+ };
28
+ readonly credential: {
29
+ readonly valueLabel: "SOURCE";
30
+ readonly description: "The credential source: mint, the default, mints one with the vercel CLI for --scope and --project; github-actions requests a GitHub Actions OIDC token, in a GitHub Actions job with permissions id-token: write, anew once it is 4 minutes old, and needs no --scope or --project. Only --local takes it: a runner run needs the mint. Only a run holding a resource that takes a credential takes it, the Testserver pool resource without noCreate (resources.testserverPool in storm.config.ts, or any --testserver-* flag but --testserver-no-create); otherwise it is credential_unused. No config key.";
31
+ };
32
+ readonly local: {
33
+ 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.";
34
+ };
35
+ readonly rebuildSnapshot: {
36
+ 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
+ };
38
+ readonly keepSandbox: {
39
+ readonly valueLabel: "DURATION";
40
+ readonly description: "How long the runner sandbox keeps running once the run ends, however it ends, so you can connect to it from its page in the Vercel dashboard: 0, which stops and deletes it with the run's other sandboxes, or a whole number of minutes or hours up to 5h (30m, 2h). The run asks Vercel Sandbox to extend the runner sandbox's timeout when it would stop sooner; it never shortens it, so the sandbox may run past the keep time until its own timeout. The run says until when it runs, and storm runs show and runs list say so too. Default: keepSandbox in the runner recipe, else 30m, or 0 when CI is set. Not with --local.";
41
+ };
42
+ readonly showOutput: {
43
+ readonly description: "In a runner run on a terminal, print the runner's step output (a snapshot build, the install, the build) above the live view instead of keeping only each step's last line there. Plain output always prints it. Either way, the run directory keeps it whole. Not with --local. No config key.";
44
+ };
45
+ readonly verbose: {
46
+ readonly description: "Print more as it happens: each Testserver sandbox create's progress messages, the runner's step output as with --show-output, and verbose in the run payload, which has the Vitest adapter's reporters print each test as it finishes and its fixtures print each container start, proxied request and vercel invocation, for passing tests too. No config key.";
47
+ };
48
+ readonly scope: {
49
+ readonly valueLabel: "TEAM";
50
+ readonly description: "The control plane team: the Vercel team whose project's development OIDC tokens the Testserver control plane trusts. Required, from this flag or scope in storm.config.ts, unless --local without a Testserver side, with noCreate or with --credential github-actions.";
51
+ };
52
+ readonly project: {
53
+ readonly valueLabel: "PROJECT";
54
+ readonly description: "The control plane project: the Vercel project, within the team, to mint the credential for. Required, from this flag or project in storm.config.ts, unless --local without a Testserver side, with noCreate or with --credential github-actions.";
55
+ };
56
+ };
@@ -0,0 +1,58 @@
1
+ // The help every run's command shares, `exec`'s and `vitest`'s: the usage of the flags every run takes, and their field
2
+ // descriptions. Clinkr loads each command's metadata eagerly for navigation, so this module imports nothing.
3
+ /** The flags every run takes, as a usage line names them, before the command's own arguments. */
4
+ export const RUN_USAGE_FLAGS = "[--testserver-sandboxes <N>] [--testserver-build <BUILD>] [--testserver-min-time-left <DURATION>] [--testserver-ttl <DURATION> | --testserver-no-create] [--set <KEY=VALUE>]... [--credential <SOURCE>] [--scope <TEAM> --project <PROJECT>] [--local | [--rebuild-snapshot] [--show-output] [--keep-sandbox <DURATION>]] [--verbose]";
5
+ /** The field descriptions of the flags every run takes. */
6
+ export const RUN_FIELDS = {
7
+ testserverSandboxes: {
8
+ valueLabel: "N",
9
+ description: "How many Testserver sandboxes the command gets, 1 to 32, overriding resources.testserverPool.sandboxes in storm.config.ts; default 1. Gives the run a Testserver side.",
10
+ },
11
+ testserverBuild: {
12
+ valueLabel: "BUILD",
13
+ 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.",
14
+ },
15
+ testserverMinTimeLeft: {
16
+ valueLabel: "DURATION",
17
+ description: "The least time left a Testserver sandbox from the pool needs, in whole minutes or hours (30m, 2h), overriding resources.testserverPool.minTimeLeft in storm.config.ts; default 30m. Gives the run a Testserver side.",
18
+ },
19
+ testserverTtl: {
20
+ valueLabel: "DURATION",
21
+ description: "How long each Testserver sandbox the run creates lives, 10m to 5h and longer than minTimeLeft, overriding resources.testserverPool.ttl in storm.config.ts; default 5h. Not with noCreate. Gives the run a Testserver side.",
22
+ },
23
+ testserverNoCreate: {
24
+ description: "Run only on Testserver sandboxes already in the pool, never minting for Testserver or creating: needs no --scope or --project with --local, and takes no --testserver-ttl. Turns on resources.testserverPool.noCreate whatever storm.config.ts says; without it, the file's noCreate, default false, applies. Gives the run a Testserver side.",
25
+ },
26
+ set: {
27
+ valueLabel: "KEY=VALUE",
28
+ description: "Set a resource's option for this run by its key path in storm.config.ts, resources.<name>.<option>, overriding the file and the default; repeat it for each option. The key paths: resources.githubFixtureRepo.repo, the GitHub repository as owner/name, required; resources.githubFixtureRepo.tokenEnv, the host environment variable holding its token, required; resources.githubFixtureRepo.optional, true or false, default false: false refuses the run without the token, true goes on without the repository. The Testserver pool resource's options have their own flags, --testserver-<option>, which --set doesn't take. Any --set of a resource's option gives the run that resource, as storm.config.ts does. An unknown key path, one given twice, one with its own flag, or a value its option refuses is a usage error. Options that don't fit together once merged, or a required one nothing gives, are invalid_resource_options, naming where each value came from.",
29
+ },
30
+ credential: {
31
+ valueLabel: "SOURCE",
32
+ description: "The credential source: mint, the default, mints one with the vercel CLI for --scope and --project; github-actions requests a GitHub Actions OIDC token, in a GitHub Actions job with permissions id-token: write, anew once it is 4 minutes old, and needs no --scope or --project. Only --local takes it: a runner run needs the mint. Only a run holding a resource that takes a credential takes it, the Testserver pool resource without noCreate (resources.testserverPool in storm.config.ts, or any --testserver-* flag but --testserver-no-create); otherwise it is credential_unused. No config key.",
33
+ },
34
+ local: {
35
+ 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.",
36
+ },
37
+ rebuildSnapshot: {
38
+ 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.",
39
+ },
40
+ keepSandbox: {
41
+ valueLabel: "DURATION",
42
+ description: "How long the runner sandbox keeps running once the run ends, however it ends, so you can connect to it from its page in the Vercel dashboard: 0, which stops and deletes it with the run's other sandboxes, or a whole number of minutes or hours up to 5h (30m, 2h). The run asks Vercel Sandbox to extend the runner sandbox's timeout when it would stop sooner; it never shortens it, so the sandbox may run past the keep time until its own timeout. The run says until when it runs, and storm runs show and runs list say so too. Default: keepSandbox in the runner recipe, else 30m, or 0 when CI is set. Not with --local.",
43
+ },
44
+ showOutput: {
45
+ description: "In a runner run on a terminal, print the runner's step output (a snapshot build, the install, the build) above the live view instead of keeping only each step's last line there. Plain output always prints it. Either way, the run directory keeps it whole. Not with --local. No config key.",
46
+ },
47
+ verbose: {
48
+ description: "Print more as it happens: each Testserver sandbox create's progress messages, the runner's step output as with --show-output, and verbose in the run payload, which has the Vitest adapter's reporters print each test as it finishes and its fixtures print each container start, proxied request and vercel invocation, for passing tests too. No config key.",
49
+ },
50
+ scope: {
51
+ valueLabel: "TEAM",
52
+ description: "The control plane team: the Vercel team whose project's development OIDC tokens the Testserver control plane trusts. Required, from this flag or scope in storm.config.ts, unless --local without a Testserver side, with noCreate or with --credential github-actions.",
53
+ },
54
+ project: {
55
+ valueLabel: "PROJECT",
56
+ description: "The control plane project: the Vercel project, within the team, to mint the credential for. Required, from this flag or project in storm.config.ts, unless --local without a Testserver side, with noCreate or with --credential github-actions.",
57
+ },
58
+ };
@@ -80,12 +80,38 @@ declare const gitSchema: z.ZodObject<{
80
80
  * tree had uncommitted changes or untracked files.
81
81
  */
82
82
  export type RunRecordGit = Readonly<z.output<typeof gitSchema>>;
83
+ declare const planSchema: z.ZodObject<{
84
+ tests: z.ZodNumber;
85
+ files: z.ZodNumber;
86
+ sandboxes: z.ZodNullable<z.ZodNumber>;
87
+ sandboxesFrom: z.ZodNullable<z.ZodEnum<{
88
+ auto: "auto";
89
+ file: "file";
90
+ flag: "flag";
91
+ }>>;
92
+ }, z.core.$strip>;
93
+ /**
94
+ * A `storm vitest` run's test plan: how many tests `vitest list` counted, in how many files, and, with a Testserver
95
+ * side, how many Testserver sandboxes the run asked for and where that count came from (`--testserver-sandboxes`, the
96
+ * config file's `resources.testserverPool.sandboxes`, or sized automatically from the files); both null without one.
97
+ */
98
+ export type RunRecordPlan = Readonly<z.output<typeof planSchema>>;
83
99
  declare const runRecordSchema: z.ZodObject<{
84
100
  version: z.ZodLiteral<1>;
85
101
  startedAt: z.ZodString;
86
102
  cwd: z.ZodString;
87
103
  configFile: z.ZodNullable<z.ZodString>;
88
104
  argv: z.ZodReadonly<z.ZodArray<z.ZodString>>;
105
+ plan: z.ZodExactOptional<z.ZodObject<{
106
+ tests: z.ZodNumber;
107
+ files: z.ZodNumber;
108
+ sandboxes: z.ZodNullable<z.ZodNumber>;
109
+ sandboxesFrom: z.ZodNullable<z.ZodEnum<{
110
+ auto: "auto";
111
+ file: "file";
112
+ flag: "flag";
113
+ }>>;
114
+ }, z.core.$strip>>;
89
115
  where: z.ZodDiscriminatedUnion<[z.ZodObject<{
90
116
  kind: z.ZodLiteral<"local">;
91
117
  }, z.core.$strip>, z.ZodObject<{
@@ -126,7 +152,7 @@ declare const runRecordSchema: z.ZodObject<{
126
152
  }, z.core.$strip>;
127
153
  /**
128
154
  * A run as `run.json` records it: when it started, the working directory and config file it ran with (null when
129
- * none applied), the command after `--`, where its command ran, the Git checkout it started from (null outside one,
155
+ * none applied), its command's argv, a `storm vitest` run's test plan, where its command ran, the Git checkout it started from (null outside one,
130
156
  * or when git couldn't say), and, once it is over, how it ended.
131
157
  */
132
158
  export type RunRecord = Readonly<Omit<z.output<typeof runRecordSchema>, "ended"> & {
@@ -38,12 +38,20 @@ const whereSchema = z.discriminatedUnion("kind", [
38
38
  }),
39
39
  ]);
40
40
  const gitSchema = z.object({ branch: z.string().nullable(), commit: z.string(), dirty: z.boolean() });
41
+ const planSchema = z.object({
42
+ tests: z.number().int().nonnegative(),
43
+ files: z.number().int().nonnegative(),
44
+ sandboxes: z.number().int().positive().nullable(),
45
+ sandboxesFrom: z.enum(["flag", "file", "auto"]).nullable(),
46
+ });
41
47
  const runRecordSchema = z.object({
42
48
  version: z.literal(1),
43
49
  startedAt: z.string(),
44
50
  cwd: z.string(),
45
51
  configFile: z.string().nullable(),
46
52
  argv: z.array(z.string()).readonly(),
53
+ // Only a `storm vitest` run has one.
54
+ plan: planSchema.exactOptional(),
47
55
  where: whereSchema,
48
56
  git: gitSchema.nullable(),
49
57
  ended: endedSchema.exactOptional(),
@@ -0,0 +1,48 @@
1
+ import { type AnyResourceConfig, type OwnFlags, type SettingsFile } from "../../config/index.ts";
2
+ import { type StormSetValues } from "../../resources.ts";
3
+ /** The Testserver pool resource's options as the command line gives them, each checked; one not given is absent. */
4
+ export type TestserverPoolFlagValues = NonNullable<StormSetValues["testserverPool"]>;
5
+ /** One of the Testserver pool resource's options. */
6
+ type TestserverPoolOption = keyof TestserverPoolFlagValues;
7
+ /** The request field of an option's flag: `testserver` and the option's name, such as `testserverMinTimeLeft`. */
8
+ type TestserverField<O extends string> = `testserver${Capitalize<O>}`;
9
+ /** An option's flag: its request field and its spelling, which Clinkr derives from the field. */
10
+ interface TestserverFlag<O extends string> {
11
+ readonly field: TestserverField<O>;
12
+ readonly flag: string;
13
+ }
14
+ /**
15
+ * Each Testserver pool option's flag, by option. An option the resource gains or loses fails to compile here until its
16
+ * flag follows; the run's request fields (`RUN_REQUEST_FIELDS`) declare each by hand, and the run's help names each
17
+ * flag.
18
+ */
19
+ export declare const TESTSERVER_FLAGS: {
20
+ readonly [O in TestserverPoolOption]-?: TestserverFlag<O>;
21
+ };
22
+ /** What a run's request holds of the flags: each field, `undefined` when its flag wasn't given. */
23
+ export type TestserverFlagRequest = {
24
+ readonly [O in TestserverPoolOption as TestserverField<O>]?: unknown;
25
+ };
26
+ /** The key path of each option with a flag, with that flag, for `parseSetFlags`, which refuses them by the flag. */
27
+ export declare const TESTSERVER_OWN_FLAGS: OwnFlags;
28
+ /** A flag value its option's rule refuses, as `validate` reports it. */
29
+ export interface TestserverFlagProblem {
30
+ readonly field: string;
31
+ readonly message: string;
32
+ }
33
+ /** Each flag value in `request` its option's rule refuses, such as `--testserver-sandboxes` of 40. */
34
+ export declare function testserverFlagProblems(request: TestserverFlagRequest): readonly TestserverFlagProblem[];
35
+ /**
36
+ * The values `--set` gave, `sets`, with the Testserver pool options the flags in `request` gave. `--set` takes none of
37
+ * them, so nothing is overridden. Any flag gives the run the Testserver pool resource, as the file's section does.
38
+ */
39
+ export declare function withTestserverFlags(sets: StormSetValues, request: TestserverFlagRequest): StormSetValues;
40
+ /** Where a held Testserver pool resource's `sandboxes` came from: its flag, the file's section, or its default. */
41
+ export type TestserverSandboxesSource = "flag" | "file" | "default";
42
+ /**
43
+ * Where the Testserver sandbox count of a run holding the Testserver pool resource came from: `--testserver-sandboxes`
44
+ * in `request`, else `resources.testserverPool.sandboxes` in `file`, else the option's default. `--set` takes no
45
+ * Testserver pool option, so these are the only sources.
46
+ */
47
+ export declare function testserverSandboxesSource(request: TestserverFlagRequest, file: SettingsFile<readonly AnyResourceConfig[]>): TestserverSandboxesSource;
48
+ export {};
@@ -0,0 +1,80 @@
1
+ // A run's own flags for the Testserver pool resource's options, `exec`'s and `vitest`'s, `--testserver-<option>`, the
2
+ // one way to give one on the command line: `--set` refuses their key paths and names the flag (`TESTSERVER_OWN_FLAGS`).
3
+ // Each flag's value passes its option's rule, as a value from the file does, and counts as a flag's when the options
4
+ // are merged, so the precedence (flag, then file, then default) and the checks across options stay the resource
5
+ // config's.
6
+ import { fileOptions, givenOptionsOf, optionKeyPath, } from "../../config/index.js";
7
+ import { RESOURCE_CONFIGS } from "../../resources.js";
8
+ /**
9
+ * Each Testserver pool option's flag, by option. An option the resource gains or loses fails to compile here until its
10
+ * flag follows; the run's request fields (`RUN_REQUEST_FIELDS`) declare each by hand, and the run's help names each
11
+ * flag.
12
+ */
13
+ export const TESTSERVER_FLAGS = {
14
+ sandboxes: { field: "testserverSandboxes", flag: "--testserver-sandboxes" },
15
+ build: { field: "testserverBuild", flag: "--testserver-build" },
16
+ minTimeLeft: { field: "testserverMinTimeLeft", flag: "--testserver-min-time-left" },
17
+ ttl: { field: "testserverTtl", flag: "--testserver-ttl" },
18
+ noCreate: { field: "testserverNoCreate", flag: "--testserver-no-create" },
19
+ };
20
+ function isTestserverPoolConfig(config) {
21
+ return config.name === "testserverPool";
22
+ }
23
+ function testserverPoolConfig() {
24
+ const config = RESOURCE_CONFIGS.find(isTestserverPoolConfig);
25
+ if (config === undefined)
26
+ throw new Error("The registry has no testserverPool resource config");
27
+ return config;
28
+ }
29
+ const CONFIG = testserverPoolConfig();
30
+ /** Each option's rule, by name, as the generic machinery reads them. */
31
+ const RULES = CONFIG.options;
32
+ /** The key path of each option with a flag, with that flag, for `parseSetFlags`, which refuses them by the flag. */
33
+ export const TESTSERVER_OWN_FLAGS = Object.fromEntries(Object.entries(TESTSERVER_FLAGS).map(([option, { flag }]) => [optionKeyPath(CONFIG.name, option), flag]));
34
+ /** Checks each flag given in `request` by its option's rule. */
35
+ function readTestserverFlags(request) {
36
+ const values = {};
37
+ const problems = [];
38
+ for (const [option, { field, flag }] of Object.entries(TESTSERVER_FLAGS)) {
39
+ const value = request[field];
40
+ if (value === undefined)
41
+ continue;
42
+ const rule = RULES[option];
43
+ if (rule === undefined)
44
+ throw new Error(`testserverPool has no option ${option}`);
45
+ const checked = rule.check(value);
46
+ if (checked.ok)
47
+ values[option] = checked.value;
48
+ else
49
+ problems.push(...checked.problems.map(({ problem }) => ({ field, message: `${flag} ${problem}.` })));
50
+ }
51
+ if (problems.length > 0)
52
+ return { ok: false, problems };
53
+ return { ok: true, values: Object.keys(values).length === 0 ? undefined : givenOptionsOf(CONFIG, values) };
54
+ }
55
+ /** Each flag value in `request` its option's rule refuses, such as `--testserver-sandboxes` of 40. */
56
+ export function testserverFlagProblems(request) {
57
+ const read = readTestserverFlags(request);
58
+ return read.ok ? [] : read.problems;
59
+ }
60
+ /**
61
+ * The values `--set` gave, `sets`, with the Testserver pool options the flags in `request` gave. `--set` takes none of
62
+ * them, so nothing is overridden. Any flag gives the run the Testserver pool resource, as the file's section does.
63
+ */
64
+ export function withTestserverFlags(sets, request) {
65
+ const read = readTestserverFlags(request);
66
+ // `validate` refused every flag value its option's rule refuses.
67
+ if (!read.ok)
68
+ throw new Error(`The flags should have been refused: ${read.problems.map((p) => p.message).join(" ")}`);
69
+ return read.values === undefined ? sets : { ...sets, testserverPool: read.values };
70
+ }
71
+ /**
72
+ * Where the Testserver sandbox count of a run holding the Testserver pool resource came from: `--testserver-sandboxes`
73
+ * in `request`, else `resources.testserverPool.sandboxes` in `file`, else the option's default. `--set` takes no
74
+ * Testserver pool option, so these are the only sources.
75
+ */
76
+ export function testserverSandboxesSource(request, file) {
77
+ if (request[TESTSERVER_FLAGS.sandboxes.field] !== undefined)
78
+ return "flag";
79
+ return fileOptions(file, CONFIG)?.sandboxes === undefined ? "default" : "file";
80
+ }
@@ -4,7 +4,7 @@ import { muted } from "@cnc-tools/cli-kit/clinkr";
4
4
  import { z } from "zod";
5
5
  import { RESOURCE_REPORTS } from "../../resources.js";
6
6
  import { sandboxPage, snapshotPage } from "../dashboard.js";
7
- import { isoSecondsText, seconds, short } from "../run/text.js";
7
+ import { isoSecondsText, seconds, short } from "../exec/text.js";
8
8
  /**
9
9
  * The run logs `runs logs` prints and `runs show` names: the command log (`command`), then each step's, in the order a
10
10
  * person looks for them.
@@ -91,7 +91,7 @@ export const runFactsSchema = z.object({
91
91
  tests: z.object({ passed: z.number(), failed: z.number(), skipped: z.number() }).nullable(),
92
92
  /** Why its test results may be incomplete: a runner run's read of its test events file, once the command ended, failed with this message; null otherwise. */
93
93
  testsIncomplete: z.string().nullable(),
94
- /** What each resource it acquired reported, as a `storm run` result's `resources`, such as the Testserver sandboxes and their log viewer URLs; null unless its command ran, or when unknown. */
94
+ /** What each resource it acquired reported, as a run's `ran` result's `resources`, such as the Testserver sandboxes and their log viewer URLs; null unless its command ran, or when unknown. */
95
95
  resources: RESOURCE_REPORTS.ranSchema.nullable(),
96
96
  })
97
97
  .nullable(),
@@ -5,7 +5,7 @@ export const metadata = {
5
5
  fields: {
6
6
  id: {
7
7
  valueLabel: "id",
8
- description: "The run id, such as 20261103T192655-8277, which `storm run` and `storm runs list` print.",
8
+ description: "The run id, such as 20261103T192655-8277, which `storm vitest`, `storm exec` and `storm runs list` print.",
9
9
  },
10
10
  step: {
11
11
  valueLabel: "STEP",
@@ -43,7 +43,10 @@ export const outcomes = defineOutcomes({
43
43
  },
44
44
  ],
45
45
  }
46
- : { message: "Couldn't find a run.", next: [{ type: "text", text: "Run storm run first." }] },
46
+ : {
47
+ message: "Couldn't find a run.",
48
+ next: [{ type: "text", text: "Start one with storm vitest or storm exec." }],
49
+ },
47
50
  },
48
51
  logNotFound: {
49
52
  exitCode: 1,
@@ -2,8 +2,8 @@ import type { z } from "zod";
2
2
  import type { ListedRunDirectory, PastRunDirectory } from "../../core/index.ts";
3
3
  import type { StormTimeline } from "../../resources.ts";
4
4
  import { type TestEvent, type TestResultEvent } from "../../sdk/index.ts";
5
- import { timelineSchema } from "../run/outcomes.ts";
6
- import { type RunRecord } from "../run/run-record.ts";
5
+ import { timelineSchema } from "../exec/outcomes.ts";
6
+ import { type RunRecord } from "../exec/run-record.ts";
7
7
  /**
8
8
  * Which runs a command sees: those of the config file `storm.config.ts` the working directory finds, or every run,
9
9
  * by `--all` or because no config file was found.
@@ -3,8 +3,8 @@
3
3
  // what the run directory gateway read. Files it can't read, or from an older storm, leave facts unknown, never
4
4
  // an error.
5
5
  import { parseTestEvent } from "../../sdk/index.js";
6
- import { timelineSchema } from "../run/outcomes.js";
7
- import { parseRunRecord } from "../run/run-record.js";
6
+ import { timelineSchema } from "../exec/outcomes.js";
7
+ import { parseRunRecord } from "../exec/run-record.js";
8
8
  /** The scope for `--all` and the config file found from the working directory, if any. */
9
9
  export function runScope(all, configFile) {
10
10
  if (all)
@@ -1,11 +1,11 @@
1
1
  export const metadata = {
2
- description: "Show a past run from its run directory: its command, config file, working directory, the branch and commit it started from, start, how long it took and how it ended; where its command ran, on this machine or in a runner sandbox, with the sandbox's name, region, vCPUs, runtime and page in the Vercel dashboard, until when the run kept it running, with its Connect page while it runs, its control plane team and project, the run's base and the runner snapshot it started from, with its page; each Testserver sandbox it used, with its log viewer URL; the run logs it has, each with the storm runs logs command that prints it; its waterfall; and each test's final result, in color on a terminal that takes it. With --failed or --test, only the selected tests, how many of all they are, and each one's errors and test output, the last 8 MiB of what it printed, failure reports included. Without an id, the newest finished run of the storm.config.ts found from the working directory, or of every config with --all; pass the id `storm run` printed when another run may have finished since. A run's test results are saved once it finishes. Changes nothing.",
2
+ description: "Show a past run from its run directory: its command, config file, working directory, the branch and commit it started from, start, how long it took and how it ended; where its command ran, on this machine or in a runner sandbox, with the sandbox's name, region, vCPUs, runtime and page in the Vercel dashboard, until when the run kept it running, with its Connect page while it runs, its control plane team and project, the run's base and the runner snapshot it started from, with its page; each Testserver sandbox it used, with its log viewer URL; the run logs it has, each with the storm runs logs command that prints it; its waterfall; and each test's final result, in color on a terminal that takes it. With --failed or --test, only the selected tests, how many of all they are, and each one's errors and test output, the last 8 MiB of what it printed, failure reports included. Without an id, the newest finished run of the storm.config.ts found from the working directory, or of every config with --all; pass the id `storm vitest` or `storm exec` printed when another run may have finished since. A run's test results are saved once it finishes. Changes nothing.",
3
3
  summary: "Show a past run and its tests.",
4
4
  usages: ["[<id>] [--failed] [--test <TEXT>] [--all]"],
5
5
  fields: {
6
6
  id: {
7
7
  valueLabel: "id",
8
- description: "The run id, such as 20261103T192655-8277, which `storm run` and `storm runs list` print.",
8
+ description: "The run id, such as 20261103T192655-8277, which `storm vitest`, `storm exec` and `storm runs list` print.",
9
9
  },
10
10
  failed: { description: "Show each failed test's errors and test output." },
11
11
  test: {
@@ -3,9 +3,9 @@ import { bold, paint } from "@cnc-tools/cli-kit/theme";
3
3
  import { defineOutcomes } from "@vercel/clinkr";
4
4
  import { z } from "zod";
5
5
  import { RESOURCE_REPORTS } from "../../../resources.js";
6
- import { timelineSchema } from "../../run/outcomes.js";
7
- import { short } from "../../run/text.js";
8
- import { waterfallLines } from "../../run/waterfall.js";
6
+ import { timelineSchema } from "../../exec/outcomes.js";
7
+ import { short } from "../../exec/text.js";
8
+ import { waterfallLines } from "../../exec/waterfall.js";
9
9
  import { commandText, exitText, exitTone, gitText, keptText, LOG_STEPS, runFactsSchema, runNotFound, runsUnreadable, scopeSchema, startedText, tookText, totalsText, totalsTone, } from "../facts.js";
10
10
  import { timelineFromFacts } from "../past-run.js";
11
11
  const testSchema = z.object({
@@ -75,7 +75,10 @@ export const outcomes = defineOutcomes({
75
75
  },
76
76
  ],
77
77
  }
78
- : { message: "Couldn't find a finished run.", next: [{ type: "text", text: "Run storm run first." }] },
78
+ : {
79
+ message: "Couldn't find a finished run.",
80
+ next: [{ type: "text", text: "Start one with storm vitest or storm exec." }],
81
+ },
79
82
  },
80
83
  },
81
84
  });