@cnc-tools/storm 0.9.0 → 0.9.1
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/bin/storm.js +3 -14
- package/dist/application.d.ts +18 -10
- package/dist/application.js +10 -11
- package/dist/bin/storm.js +97 -41
- package/dist/build-info.js +1 -1
- package/dist/chunks/chunk-5CQCRX2L.js +5768 -0
- package/dist/chunks/chunk-5U5Q6VZR.js +556 -0
- package/dist/chunks/chunk-7O6UN63H.js +63 -0
- package/dist/chunks/chunk-I5GZLOLQ.js +38 -0
- package/dist/chunks/chunk-NX55IJ5S.js +1842 -0
- package/dist/chunks/chunk-OCZJE5XV.js +910 -0
- package/dist/chunks/chunk-RRQ2ZGSE.js +1512 -0
- package/dist/chunks/chunk-S5NAIZYS.js +13 -0
- package/dist/chunks/chunk-UHO5OCEX.js +360 -0
- package/dist/chunks/chunk-WBIHJM7D.js +188 -0
- package/dist/chunks/chunk-WV6WQFC6.js +436 -0
- package/dist/chunks/live-app-X3PW2W42.js +89 -0
- package/dist/chunks/version-X7RMSKZI.js +12 -0
- package/dist/commands/exec/command.js +35 -21
- package/dist/commands/exec/metadata.js +66 -58
- package/dist/commands/exec/redaction.js +1 -1
- package/dist/commands/exec/run-collector.d.ts +1 -1
- package/dist/commands/exec/run-collector.js +1 -1
- package/dist/commands/exec/run-record.d.ts +1 -1
- package/dist/commands/exec/tests-summary.d.ts +1 -1
- package/dist/commands/exec/worker-chart.d.ts +1 -1
- package/dist/commands/runs/list/command.js +136 -33
- package/dist/commands/runs/list/metadata.js +22 -18
- package/dist/commands/runs/logs/command.js +131 -48
- package/dist/commands/runs/logs/metadata.js +24 -20
- package/dist/commands/runs/metadata.js +6 -2
- package/dist/commands/runs/past-run.d.ts +1 -1
- package/dist/commands/runs/past-run.js +1 -1
- package/dist/commands/runs/show/command.js +396 -74
- package/dist/commands/runs/show/metadata.js +24 -20
- package/dist/commands/vitest/command.js +195 -128
- package/dist/commands/vitest/metadata.js +45 -37
- package/dist/context.d.ts +1 -1
- package/dist/core/events.d.ts +1 -1
- package/dist/core/payload.d.ts +1 -1
- package/dist/core/payload.js +1 -1
- package/dist/core/provider.d.ts +12 -2
- package/dist/core/run.js +1 -1
- package/dist/live-app.d.ts +9 -0
- package/dist/live-app.js +21 -0
- package/dist/resource-commands.d.ts +13 -0
- package/dist/resource-commands.js +22 -0
- package/dist/resources/github/provider.d.ts +1 -1
- package/dist/resources/testserver/command-tree.d.ts +4 -0
- package/dist/resources/testserver/command-tree.js +12 -0
- package/dist/resources/testserver/commands/create/command.js +373 -194
- package/dist/resources/testserver/commands/create/metadata.js +52 -48
- package/dist/resources/testserver/commands/list/command.js +195 -50
- package/dist/resources/testserver/commands/list/metadata.js +12 -8
- package/dist/resources/testserver/provider.d.ts +1 -1
- package/dist/resources/testserver/resource-provider.js +2 -8
- package/dist/resources.d.ts +0 -3
- package/dist/resources.js +5 -10
- package/dist/runner/recipe.js +1 -1
- package/dist/runner/remote-command.js +1 -1
- package/dist/sdk/host.d.ts +2 -0
- package/dist/sdk/host.js +7 -0
- package/dist/version.d.ts +2 -2
- package/dist/version.js +10 -11
- package/dist/vitest/config.d.ts +4 -8
- package/dist/vitest/config.js +5 -9
- package/dist/vitest/container-scope.d.ts +12 -5
- package/dist/vitest/container-scope.js +27 -4
- package/dist/vitest/diagnostics.d.ts +8 -2
- package/dist/vitest/diagnostics.js +7 -4
- package/dist/vitest/fixtures.d.ts +4 -1
- package/dist/vitest/fixtures.js +17 -6
- package/dist/vitest/plan.d.ts +1 -1
- package/dist/vitest/plan.js +2 -2
- package/dist/vitest/sandbox.d.ts +6 -0
- package/dist/vitest/sandbox.js +6 -0
- package/package.json +4 -3
- package/bin/node-version.js +0 -24
- package/dist/closed-terminal.d.ts +0 -7
- package/dist/closed-terminal.js +0 -18
|
@@ -1,59 +1,67 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
1
|
+
import {
|
|
2
|
+
RUN_FIELDS,
|
|
3
|
+
RUN_USAGE_FLAGS
|
|
4
|
+
} from "../../chunks/chunk-7O6UN63H.js";
|
|
5
|
+
|
|
6
|
+
// src/commands/exec/metadata.ts
|
|
7
|
+
var metadata = {
|
|
8
|
+
description: "Run any command, the argument list after --, as it is, with the run payload in STORM_RUN. For vitest, use storm vitest, which counts the tests and sizes the run first; exec counts nothing and sizes nothing. In a local run (--local), the command runs on this machine in the working directory, with this machine's environment less the host variables a resource names (TESTSERVER_BASES and TESTSERVER_BASE), plus STORM_RUN, and FORCE_COLOR or NO_COLOR when neither is set. In a runner run, the default, it runs in a runner sandbox, a Vercel Sandbox readied from the runner recipe in storm.config.ts, in the recipe's cwd, with the runner sandbox's own environment, a PATH that starts with node_modules/.bin of that cwd and of the repository's root, the recipe's env and STORM_RUN, and nothing from this machine's environment; each recipe step that names a runner secret, never the command, also gets that host variable, one its secrets key declares, shown as <token> in what storm prints and writes, and a runner run refuses before it starts when one of them is unset, holds a line break or is shorter than 8 characters; each path under the repository's root in its arguments points at the runner sandbox's copy, and each in its output back at this checkout. With a Testserver side (resources.testserverPool in storm.config.ts, or any --testserver-* flag), first lease usable Testserver sandboxes from the pool and create the rest, while a runner run readies its runner sandbox, and release the leases once the command ends; without one, the run payload names no Testserver sandbox. Shows on stderr what runs when and what runs at once, live on a terminal and one line at a time elsewhere, then a waterfall of the run's lanes naming its critical path, and exits with the command's code. Each run writes what it was and how it ended, its events, its steps' output, its command's output, its test events and its timeline to a run directory under ${XDG_STATE_HOME:-~/.local/state}/storm/runs/, named for its run id, keeping the newest 1000 completed ones and every one whose run is still going; the summary names the run id, storm runs show reads the run back, and storm runs logs prints its command's output and its steps' logs. A flag overrides storm.config.ts, found in the working directory or a parent up to the git worktree's root and checked whole, which overrides the built-in default. With resources.githubFixtureRepo, in storm.config.ts or by a --set of its options, the run reads a token for that GitHub repository from the host variable its tokenEnv names (refusing without it, unless optional), checks the token can read the repository, hands the command the repository, the token and a run prefix (run/<UTC timestamp>-<suffix>) in the run payload, shows the token as <token> in what it prints and writes, and deletes every branch under the run prefix once the command has stopped.",
|
|
9
|
+
summary: "Run any command, in a runner sandbox or locally.",
|
|
10
|
+
usages: [`${RUN_USAGE_FLAGS} -- <command...>`],
|
|
11
|
+
fields: {
|
|
12
|
+
...RUN_FIELDS,
|
|
13
|
+
command: {
|
|
14
|
+
valueLabel: "command",
|
|
15
|
+
description: "The command to run, after --, as an argument list with no shell. Locally it gets this machine's working directory and environment, less TESTSERVER_BASES and TESTSERVER_BASE, plus STORM_RUN and FORCE_COLOR or NO_COLOR; in a runner run, the runner recipe's cwd, its env, the runner's PATH and STORM_RUN, with paths under the repository's root rewritten."
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
examples: [
|
|
19
|
+
{
|
|
20
|
+
argv: "-- pnpm test",
|
|
21
|
+
description: "Run the package's test script in a runner sandbox, with the runner recipe, team and project from storm.config.ts, and its Testserver side, if it has one."
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
argv: "--testserver-sandboxes 4 -- pnpm test:testserver",
|
|
25
|
+
description: "Run a script in a runner sandbox against 4 Testserver sandboxes."
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
argv: "--local --testserver-sandboxes 4 --scope vercel --project vercel -- pnpm test",
|
|
29
|
+
description: "Run the tests on this machine against 4 Testserver sandboxes on the stable build channel."
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
argv: "--keep-sandbox 2h -- pnpm test",
|
|
33
|
+
description: "Run the tests in a runner sandbox and keep it running 2 hours after the run, to debug in it."
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
argv: "--local -- node scripts/smoke.mjs",
|
|
37
|
+
description: "Run a Node.js script on this machine, with no Testserver sandbox when storm.config.ts has no resources.testserverPool."
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
argv: "--local --testserver-ttl 30m --testserver-min-time-left 25m -- pnpm test",
|
|
41
|
+
description: "Create Testserver sandboxes that live 30 minutes, with team and project from storm.config.ts."
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
argv: "--local --testserver-build pr:104196 -- pnpm test",
|
|
45
|
+
description: "Run the tests on this machine against the Testserver build of vercel/api pull request 104196's head commit."
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
argv: "--local --testserver-no-create --testserver-sandboxes 4 -- pnpm test",
|
|
49
|
+
description: "Run only on Testserver sandboxes already in the pool, never minting."
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
argv: "--local --verbose --testserver-sandboxes 2 -- pnpm test",
|
|
53
|
+
description: "Run the tests, printing each create's progress and, through the Vitest adapter, each test as it ends."
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
argv: "--local --credential github-actions --testserver-ttl 30m --testserver-min-time-left 25m -- pnpm test",
|
|
57
|
+
description: "In a GitHub Actions job, create Testserver sandboxes with a GitHub Actions OIDC token."
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
argv: "--local --testserver-build latest_main --testserver-min-time-left 75m --scope vercel --project vercel -- pnpm test",
|
|
61
|
+
description: "Run them on the newest main build, with Testserver sandboxes that live at least 75 more minutes."
|
|
62
|
+
}
|
|
63
|
+
]
|
|
64
|
+
};
|
|
65
|
+
export {
|
|
66
|
+
metadata
|
|
59
67
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// Hiding a run's secrets, such as the GitHub fixture repository's token, in what the run prints and writes: its
|
|
2
2
|
// events (which feed progress, the run directory's `events.jsonl`, the timeline, the job summary and the outcome), the
|
|
3
3
|
// remote command's output (the terminal and `command.log`), and the test events a local command appended.
|
|
4
|
-
import { redactSecrets } from "../../sdk/
|
|
4
|
+
import { redactSecrets } from "../../sdk/host.js";
|
|
5
5
|
/** A redaction of `secrets`, each replaced by `<token>` wherever it appears. */
|
|
6
6
|
export function redactor(secrets) {
|
|
7
7
|
const kept = secrets.filter((secret) => secret !== "");
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type RunDirectory } from "../../core/index.ts";
|
|
2
2
|
import { type StormRunObserver, type StormRunState } from "../../resources.ts";
|
|
3
|
-
import { type TestEvent } from "../../sdk/
|
|
3
|
+
import { type TestEvent } from "../../sdk/host.ts";
|
|
4
4
|
import { type Redact } from "./redaction.ts";
|
|
5
5
|
/** The test events the summary reads, how many lines held none, and why they may be incomplete, when they may. */
|
|
6
6
|
export interface RunTestEvents {
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
// run keeps no test output or test errors in memory after it has handed them on.
|
|
4
4
|
import { EMPTY_RUN_STATE } from "../../core/index.js";
|
|
5
5
|
import { applyStormRunEvent } from "../../resources.js";
|
|
6
|
-
import { parseTestEvent, testEventLine } from "../../sdk/
|
|
6
|
+
import { parseTestEvent, testEventLine } from "../../sdk/host.js";
|
|
7
7
|
import { redactStrings } from "./redaction.js";
|
|
8
8
|
/**
|
|
9
9
|
* A collector that folds every event but a runner step's output into the run's state. Each test event it hears or
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import { type StormResourceRanFacts } from "../../resources.ts";
|
|
3
|
-
import type { TestEvent } from "../../sdk/
|
|
3
|
+
import type { TestEvent } from "../../sdk/host.ts";
|
|
4
4
|
declare const testTotalsSchema: z.ZodObject<{
|
|
5
5
|
passed: z.ZodNumber;
|
|
6
6
|
failed: z.ZodNumber;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { TestEvent } from "../../sdk/
|
|
1
|
+
import type { TestEvent } from "../../sdk/host.ts";
|
|
2
2
|
/**
|
|
3
3
|
* What the summary says about the tests, a line apiece: `tests`, the totals and how busy the workers were;
|
|
4
4
|
* `containers`, how long container starts took and how much of the attempts' time they were; `slowest`, the slowest
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { TimelineSpan } from "../../core/index.ts";
|
|
2
|
-
import type { TestEvent } from "../../sdk/
|
|
2
|
+
import type { TestEvent } from "../../sdk/host.ts";
|
|
3
3
|
import { type Paint } from "./text.ts";
|
|
4
4
|
/** The most workers the chart draws; the rest, those that finished first, are counted on one line. */
|
|
5
5
|
export declare const MAX_WORKER_ROWS = 16;
|
|
@@ -1,36 +1,139 @@
|
|
|
1
|
+
import {
|
|
2
|
+
branchText,
|
|
3
|
+
commandText,
|
|
4
|
+
exitText,
|
|
5
|
+
exitTone,
|
|
6
|
+
onBranch,
|
|
7
|
+
runFacts,
|
|
8
|
+
runFactsSchema,
|
|
9
|
+
runScope,
|
|
10
|
+
runnerCell,
|
|
11
|
+
runsInScope,
|
|
12
|
+
runsUnreadable,
|
|
13
|
+
scopeFacts,
|
|
14
|
+
scopeSchema,
|
|
15
|
+
scopeText,
|
|
16
|
+
startedText,
|
|
17
|
+
tookText,
|
|
18
|
+
totalsText,
|
|
19
|
+
totalsTone
|
|
20
|
+
} from "../../../chunks/chunk-UHO5OCEX.js";
|
|
21
|
+
import "../../../chunks/chunk-5U5Q6VZR.js";
|
|
22
|
+
import "../../../chunks/chunk-NX55IJ5S.js";
|
|
23
|
+
import {
|
|
24
|
+
findConfigFile
|
|
25
|
+
} from "../../../chunks/chunk-OCZJE5XV.js";
|
|
26
|
+
import "../../../chunks/chunk-5CQCRX2L.js";
|
|
27
|
+
import "../../../chunks/chunk-S5NAIZYS.js";
|
|
28
|
+
|
|
29
|
+
// src/commands/runs/list/command.ts
|
|
30
|
+
import { z as z2 } from "zod";
|
|
31
|
+
|
|
32
|
+
// src/commands/runs/list/outcomes.ts
|
|
33
|
+
import { muted, path, renderOutcome, status } from "@vercel/clinkr/vcli-kit";
|
|
34
|
+
import { defineOutcomes } from "@vercel/clinkr";
|
|
1
35
|
import { z } from "zod";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
return
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
36
|
+
var listedSchema = z.object({
|
|
37
|
+
/** Which runs it listed: one config file's, or every run. */
|
|
38
|
+
scope: scopeSchema,
|
|
39
|
+
/** The branch --branch named, which every listed run started on; null without --branch. */
|
|
40
|
+
branch: z.string().nullable(),
|
|
41
|
+
/** How many runs are in the scope, and on the branch, listed or not. */
|
|
42
|
+
total: z.number(),
|
|
43
|
+
/** The newest runs in the scope, newest first, at most --limit. */
|
|
44
|
+
runs: z.array(runFactsSchema)
|
|
45
|
+
});
|
|
46
|
+
function emptyText({ scope, branch }) {
|
|
47
|
+
if (branch === null)
|
|
48
|
+
return scope.kind === "config" ? "No runs of this config file. Pass --all to see every run." : "No runs.";
|
|
49
|
+
return scope.kind === "config" ? "No runs of this config file match this filter. Remove --branch to see all of them, or pass --all to look through every run." : "No runs match this filter. Remove --branch to see all runs.";
|
|
50
|
+
}
|
|
51
|
+
function cell(text, tone) {
|
|
52
|
+
if (text === "-") return muted(text);
|
|
53
|
+
return tone === void 0 ? text : status(text, tone);
|
|
54
|
+
}
|
|
55
|
+
function branchCell(run) {
|
|
56
|
+
const text = branchText(run);
|
|
57
|
+
return run.git === null || run.git.branch === null ? muted(text) : text;
|
|
58
|
+
}
|
|
59
|
+
var outcomes = defineOutcomes({
|
|
60
|
+
results: {
|
|
61
|
+
listed: {
|
|
62
|
+
schema: listedSchema,
|
|
63
|
+
description: "The newest runs in the scope; none is an empty list.",
|
|
64
|
+
render: (listed) => renderOutcome({
|
|
65
|
+
rows: [
|
|
66
|
+
["Runs of", listed.scope.kind === "config" ? path(listed.scope.configFile) : scopeText(listed.scope)],
|
|
67
|
+
...listed.branch === null ? [] : [["Branch", listed.branch]]
|
|
68
|
+
],
|
|
69
|
+
...listed.runs.length === 0 ? { message: emptyText(listed) } : {
|
|
70
|
+
table: {
|
|
71
|
+
columns: ["RUN", "STARTED", "TOOK", "EXIT", "RUNNER", "BRANCH", "TESTS", "COMMAND"],
|
|
72
|
+
// The exit and the tests in the color of how they went, the runner sandbox in a link's color, and
|
|
73
|
+
// what is unknown or not a place muted.
|
|
74
|
+
rows: listed.runs.map((run) => [
|
|
75
|
+
run.id,
|
|
76
|
+
cell(startedText(run)),
|
|
77
|
+
cell(tookText(run)),
|
|
78
|
+
cell(exitText(run), exitTone(run)),
|
|
79
|
+
runnerCell(run),
|
|
80
|
+
branchCell(run),
|
|
81
|
+
cell(totalsText(run), totalsTone(run)),
|
|
82
|
+
cell(commandText(run))
|
|
83
|
+
])
|
|
84
|
+
}
|
|
34
85
|
},
|
|
35
|
-
|
|
86
|
+
...listed.total > listed.runs.length ? {
|
|
87
|
+
next: [
|
|
88
|
+
{
|
|
89
|
+
type: "command",
|
|
90
|
+
argv: [
|
|
91
|
+
"storm",
|
|
92
|
+
"runs",
|
|
93
|
+
"list",
|
|
94
|
+
...listed.scope.kind === "all" && listed.scope.why === "flag" ? ["--all"] : [],
|
|
95
|
+
...listed.branch === null ? [] : ["--branch", listed.branch],
|
|
96
|
+
"--limit",
|
|
97
|
+
String(listed.total)
|
|
98
|
+
],
|
|
99
|
+
label: `List all ${listed.total} runs`
|
|
100
|
+
}
|
|
101
|
+
]
|
|
102
|
+
} : {}
|
|
103
|
+
})
|
|
104
|
+
}
|
|
105
|
+
},
|
|
106
|
+
errors: {
|
|
107
|
+
runsUnreadable
|
|
108
|
+
}
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
// src/commands/runs/list/command.ts
|
|
112
|
+
var DEFAULT_LIMIT = 20;
|
|
113
|
+
function command(cmd) {
|
|
114
|
+
return cmd.define({
|
|
115
|
+
requestSchema: z2.object({
|
|
116
|
+
all: z2.boolean().default(false),
|
|
117
|
+
limit: z2.number().int().min(1).default(DEFAULT_LIMIT),
|
|
118
|
+
branch: z2.string().min(1).optional()
|
|
119
|
+
}),
|
|
120
|
+
response: outcomes,
|
|
121
|
+
handler: async ({ app }, request) => {
|
|
122
|
+
const now = app.context.clock.now();
|
|
123
|
+
const listed = await app.context.runDirectories.list({ now });
|
|
124
|
+
if (!listed.ok) return outcomes.runsUnreadable({ ...listed.failure });
|
|
125
|
+
const scope = runScope(request.all, await findConfigFile(app.context.config, app.cwd));
|
|
126
|
+
const runs = onBranch(runsInScope(listed.runs, scope), request.branch);
|
|
127
|
+
return outcomes.listed({
|
|
128
|
+
scope: scopeFacts(scope),
|
|
129
|
+
branch: request.branch ?? null,
|
|
130
|
+
total: runs.length,
|
|
131
|
+
runs: runs.slice(0, request.limit).map((run) => runFacts(run, now))
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
});
|
|
36
135
|
}
|
|
136
|
+
export {
|
|
137
|
+
DEFAULT_LIMIT,
|
|
138
|
+
command
|
|
139
|
+
};
|
|
@@ -1,19 +1,23 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
1
|
+
// src/commands/runs/list/metadata.ts
|
|
2
|
+
var metadata = {
|
|
3
|
+
description: "List past runs, newest first, from their run directories under ${XDG_STATE_HOME:-~/.local/state}/storm/runs/ on this machine: each run's id, when it started, how long its command took, how it ended, the runner its command ran on (local for this machine, with --local, or the runner sandbox's name, linked to its page in the Vercel dashboard on a terminal that takes color, with how long it has left while the run keeps it running), the branch it started from, its tests' totals and its command, the exit and the totals in the color of how the run went on a terminal that takes color. By default only the runs of the storm.config.ts found from the working directory, so each worktree sees its own; every run when none is found. --branch keeps only the runs started on one branch, whichever worktree ran them when given with --all. Changes nothing.",
|
|
4
|
+
summary: "List past runs.",
|
|
5
|
+
aliases: ["ls"],
|
|
6
|
+
fields: {
|
|
7
|
+
all: { description: "List every run, whatever config file it ran with, including runs from an older storm." },
|
|
8
|
+
limit: { valueLabel: "N", description: "List at most N runs, the newest; default 20." },
|
|
9
|
+
branch: {
|
|
10
|
+
valueLabel: "BRANCH",
|
|
11
|
+
description: "List only the runs started with BRANCH checked out. With --all, from every worktree."
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
examples: [
|
|
15
|
+
{ argv: "", description: "List this config file's newest 20 runs." },
|
|
16
|
+
{ argv: "--all --limit 100", description: "List the newest 100 runs on this machine." },
|
|
17
|
+
{ argv: "--all --branch my-feature", description: "List the runs of branch my-feature, from any worktree." },
|
|
18
|
+
{ argv: "--json", description: "List the runs as JSON, each with its run.json facts." }
|
|
19
|
+
]
|
|
20
|
+
};
|
|
21
|
+
export {
|
|
22
|
+
metadata
|
|
19
23
|
};
|
|
@@ -1,51 +1,134 @@
|
|
|
1
|
+
import {
|
|
2
|
+
LOG_STEPS,
|
|
3
|
+
newest,
|
|
4
|
+
runNotFound,
|
|
5
|
+
runScope,
|
|
6
|
+
runsInScope,
|
|
7
|
+
runsUnreadable,
|
|
8
|
+
scopeFacts,
|
|
9
|
+
scopeSchema
|
|
10
|
+
} from "../../../chunks/chunk-UHO5OCEX.js";
|
|
11
|
+
import "../../../chunks/chunk-5U5Q6VZR.js";
|
|
12
|
+
import "../../../chunks/chunk-NX55IJ5S.js";
|
|
13
|
+
import {
|
|
14
|
+
findConfigFile
|
|
15
|
+
} from "../../../chunks/chunk-OCZJE5XV.js";
|
|
16
|
+
import "../../../chunks/chunk-5CQCRX2L.js";
|
|
17
|
+
import "../../../chunks/chunk-S5NAIZYS.js";
|
|
18
|
+
|
|
19
|
+
// src/commands/runs/logs/command.ts
|
|
20
|
+
import { z as z2 } from "zod";
|
|
21
|
+
|
|
22
|
+
// src/commands/runs/logs/outcomes.ts
|
|
23
|
+
import { renderOutcome } from "@vercel/clinkr/vcli-kit";
|
|
24
|
+
import { defineOutcomes } from "@vercel/clinkr";
|
|
1
25
|
import { z } from "zod";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
26
|
+
var stepSchema = z.enum(LOG_STEPS);
|
|
27
|
+
var printedSchema = z.object({
|
|
28
|
+
/** The run id. */
|
|
29
|
+
runId: z.string(),
|
|
30
|
+
/** The run log: `command` for the command's output, or a step's log. */
|
|
31
|
+
step: stepSchema,
|
|
32
|
+
/** The run log's file. */
|
|
33
|
+
path: z.string(),
|
|
34
|
+
/** The run log's text, as it is now. A step's log starts each line with its time. */
|
|
35
|
+
text: z.string()
|
|
36
|
+
});
|
|
37
|
+
var outcomes = defineOutcomes({
|
|
38
|
+
results: {
|
|
39
|
+
printed: {
|
|
40
|
+
schema: printedSchema,
|
|
41
|
+
description: "The run log's text, as it is.",
|
|
42
|
+
render: ({ text }) => renderOutcome({ text })
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
errors: {
|
|
46
|
+
runsUnreadable,
|
|
47
|
+
runNotFound,
|
|
48
|
+
noRuns: {
|
|
49
|
+
exitCode: 1,
|
|
50
|
+
description: "Without an id, the scope has no run.",
|
|
51
|
+
schema: z.object({
|
|
52
|
+
/** Which runs it looked through. */
|
|
53
|
+
scope: scopeSchema
|
|
54
|
+
}),
|
|
55
|
+
render: ({ scope }) => scope.kind === "config" ? {
|
|
56
|
+
message: `Couldn't find a run of ${scope.configFile}.`,
|
|
57
|
+
next: [
|
|
58
|
+
{
|
|
59
|
+
type: "command",
|
|
60
|
+
argv: ["storm", "runs", "logs", "--all"],
|
|
61
|
+
label: "Print the newest run's command log, of any config file"
|
|
62
|
+
}
|
|
63
|
+
]
|
|
64
|
+
} : {
|
|
65
|
+
message: "Couldn't find a run.",
|
|
66
|
+
next: [{ type: "text", text: "Start one with storm vitest or storm exec." }]
|
|
67
|
+
}
|
|
68
|
+
},
|
|
69
|
+
logNotFound: {
|
|
70
|
+
exitCode: 1,
|
|
71
|
+
description: "The run has no log for the step given: the step didn't run, or hasn't written output yet.",
|
|
72
|
+
schema: z.object({
|
|
73
|
+
/** The run id. */
|
|
74
|
+
id: z.string(),
|
|
75
|
+
/** The step given. */
|
|
76
|
+
step: stepSchema,
|
|
77
|
+
/** The run logs the run has. */
|
|
78
|
+
logs: z.array(stepSchema)
|
|
79
|
+
}),
|
|
80
|
+
render: ({ id, step, logs }) => {
|
|
81
|
+
const first = logs[0];
|
|
82
|
+
return {
|
|
83
|
+
message: `Run ${id} has no ${step} log.`,
|
|
84
|
+
rows: [["Logs", logs.length === 0 ? "none" : logs.join(", ")]],
|
|
85
|
+
next: first === void 0 ? [{ type: "command", argv: ["storm", "runs", "show", id], label: "Show the run" }] : [
|
|
86
|
+
{
|
|
87
|
+
type: "command",
|
|
88
|
+
argv: ["storm", "runs", "logs", id, "--step", first],
|
|
89
|
+
label: `Print its ${first} log`
|
|
33
90
|
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
91
|
+
]
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
// src/commands/runs/logs/command.ts
|
|
99
|
+
function command(cmd) {
|
|
100
|
+
return cmd.define({
|
|
101
|
+
requestSchema: z2.object({
|
|
102
|
+
id: z2.string().min(1).optional(),
|
|
103
|
+
step: z2.enum(LOG_STEPS).default("command"),
|
|
104
|
+
all: z2.boolean().default(false)
|
|
105
|
+
}),
|
|
106
|
+
cli: { positionals: ["id"] },
|
|
107
|
+
response: outcomes,
|
|
108
|
+
handler: async ({ app }, request) => {
|
|
109
|
+
const now = app.context.clock.now();
|
|
110
|
+
let id = request.id;
|
|
111
|
+
if (id === void 0) {
|
|
112
|
+
const listed = await app.context.runDirectories.list({ now });
|
|
113
|
+
if (!listed.ok) return outcomes.runsUnreadable({ ...listed.failure });
|
|
114
|
+
const scope = runScope(request.all, await findConfigFile(app.context.config, app.cwd));
|
|
115
|
+
const run = newest(runsInScope(listed.runs, scope));
|
|
116
|
+
if (run === void 0) return outcomes.noRuns({ scope: scopeFacts(scope) });
|
|
117
|
+
id = run.id;
|
|
118
|
+
}
|
|
119
|
+
const read = await app.context.runDirectories.read({ id, now });
|
|
120
|
+
if (read.kind === "failed") return outcomes.runsUnreadable({ ...read.failure });
|
|
121
|
+
if (read.kind === "not-found") return outcomes.runNotFound({ id });
|
|
122
|
+
const logs = LOG_STEPS.filter((log2) => read.directory.logs.includes(log2));
|
|
123
|
+
const notFound = () => outcomes.logNotFound({ id, step: request.step, logs: [...logs] });
|
|
124
|
+
if (!logs.includes(request.step)) return notFound();
|
|
125
|
+
const log = await app.context.runDirectories.readLog({ id, log: request.step });
|
|
126
|
+
if (log.kind === "failed") return outcomes.runsUnreadable({ ...log.failure });
|
|
127
|
+
if (log.kind === "not-found") return notFound();
|
|
128
|
+
return outcomes.printed({ runId: id, step: request.step, path: log.path, text: log.text });
|
|
129
|
+
}
|
|
130
|
+
});
|
|
51
131
|
}
|
|
132
|
+
export {
|
|
133
|
+
command
|
|
134
|
+
};
|