@cnc-tools/storm 0.10.0 → 0.11.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.
- package/dist/bin/storm.js +17 -9
- package/dist/build-info.js +1 -1
- package/dist/chunks/{chunk-YF3ICDBY.js → chunk-3ZZVZPMG.js} +1 -1
- package/dist/chunks/{chunk-JQ2HK4RN.js → chunk-4EU4AH7E.js} +141 -6
- package/dist/chunks/{chunk-ZJ2USLAT.js → chunk-4PRAB24Y.js} +2 -22
- package/dist/chunks/chunk-AMTYHUYB.js +257 -0
- package/dist/chunks/{chunk-WF4KJ7YG.js → chunk-ETCZ6WP7.js} +1 -1
- package/dist/chunks/chunk-FVMQKYTT.js +10 -0
- package/dist/chunks/{chunk-XHJGHJBW.js → chunk-GRMD7G4J.js} +33 -275
- package/dist/chunks/chunk-ICB4BZJX.js +22 -0
- package/dist/chunks/{chunk-AGWW3HDT.js → chunk-KR7WIYLG.js} +1826 -2201
- package/dist/chunks/{chunk-OVXD7GES.js → chunk-L4ZPMSKQ.js} +4 -37
- package/dist/chunks/chunk-NPPJ57W7.js +569 -0
- package/dist/chunks/{chunk-VJQLMGOH.js → chunk-O4BUT7BE.js} +361 -1716
- package/dist/chunks/chunk-OJOKQRM6.js +1457 -0
- package/dist/chunks/chunk-SLNKW4ZM.js +40 -0
- package/dist/chunks/{chunk-AKKNF3WZ.js → chunk-TRFEAYNC.js} +277 -348
- package/dist/chunks/chunk-VZZTHCBW.js +93 -0
- package/dist/chunks/chunk-WNIQA5J6.js +19 -0
- package/dist/chunks/chunk-WSIF7SR6.js +10 -0
- package/dist/chunks/{live-app-RIJM3QFD.js → live-app-LOGYUBKB.js} +52 -7
- package/dist/commands/exec/cleanup.d.ts +3 -3
- package/dist/commands/exec/cleanup.js +6 -2
- package/dist/commands/exec/command.d.ts +3 -3
- package/dist/commands/exec/command.js +17 -10
- package/dist/commands/exec/job-summary.d.ts +1 -1
- package/dist/commands/exec/job-summary.js +1 -1
- package/dist/commands/exec/live-view.js +5 -5
- package/dist/commands/exec/mint-failed.js +1 -1
- package/dist/commands/exec/outcomes.d.ts +2 -2
- package/dist/commands/exec/outcomes.js +7 -8
- package/dist/commands/exec/plan-run.d.ts +3 -5
- package/dist/commands/exec/progress.d.ts +3 -3
- package/dist/commands/exec/progress.js +6 -6
- package/dist/commands/exec/resource-refusals.d.ts +1 -1
- package/dist/commands/exec/resource-refusals.js +1 -1
- package/dist/commands/exec/run-command.d.ts +14 -9
- package/dist/commands/exec/run-command.js +91 -202
- package/dist/commands/exec/run-metadata.d.ts +2 -2
- package/dist/commands/exec/run-metadata.js +3 -3
- package/dist/commands/exec/test-plan.d.ts +1 -35
- package/dist/commands/exec/test-plan.js +4 -24
- package/dist/commands/exec/view.js +3 -3
- package/dist/commands/exec/waterfall.d.ts +3 -1
- package/dist/commands/exec/waterfall.js +18 -1
- package/dist/commands/runs/facts.d.ts +2 -1
- package/dist/commands/runs/facts.js +1 -1
- package/dist/commands/runs/list/command.js +10 -9
- package/dist/commands/runs/logs/command.js +14 -12
- package/dist/commands/runs/past-run.d.ts +3 -27
- package/dist/commands/runs/past-run.js +3 -37
- package/dist/commands/runs/show/command.js +24 -21
- package/dist/commands/runs/show/outcomes.js +2 -2
- package/dist/commands/vitest/command.d.ts +3 -3
- package/dist/commands/vitest/command.js +24 -17
- package/dist/commands/vitest/outcomes.d.ts +1 -1
- package/dist/commands/vitest/outcomes.js +1 -1
- package/dist/config/credential-resolver.d.ts +6 -3
- package/dist/config/credential-resolver.js +6 -5
- package/dist/context.d.ts +27 -9
- package/dist/context.js +19 -8
- package/dist/core/before-run.d.ts +5 -4
- package/dist/core/before-run.js +6 -6
- package/dist/core/definition-lookup.d.ts +22 -0
- package/dist/core/definition-lookup.js +34 -0
- package/dist/core/events.d.ts +5 -19
- package/dist/core/gateways.d.ts +22 -162
- package/dist/core/index.d.ts +10 -11
- package/dist/core/index.js +9 -11
- package/dist/core/launcher-supplies.js +2 -2
- package/dist/core/live/terminal-command-gateway.d.ts +8 -0
- package/dist/core/live/terminal-command-gateway.js +49 -0
- package/dist/core/presentations.d.ts +4 -3
- package/dist/core/presentations.js +4 -5
- package/dist/core/resource-registry.d.ts +35 -51
- package/dist/core/resource-registry.js +27 -54
- package/dist/core/resource-reports.d.ts +37 -4
- package/dist/core/resource-reports.js +34 -5
- package/dist/core/resources.d.ts +4 -3
- package/dist/core/resources.js +2 -4
- package/dist/core/run-state.d.ts +1 -1
- package/dist/core/run-state.js +1 -1
- package/dist/core/run.d.ts +19 -37
- package/dist/core/run.js +59 -114
- package/dist/core/timeline.js +2 -1
- package/dist/credential/events.d.ts +20 -0
- package/dist/credential/events.js +4 -0
- package/dist/credential/index.d.ts +2 -1
- package/dist/credential/index.js +6 -5
- package/dist/credential/source.d.ts +38 -26
- package/dist/credential/source.js +25 -34
- package/dist/extension-commands.d.ts +12 -6
- package/dist/extension-commands.js +18 -11
- package/dist/extensions/story/command-tree.d.ts +6 -0
- package/dist/extensions/story/command-tree.js +21 -0
- package/dist/extensions/story/commands/app.d.ts +23 -0
- package/dist/extensions/story/commands/app.js +5 -0
- package/dist/extensions/story/commands/run/command.d.ts +211 -0
- package/dist/extensions/story/commands/run/command.js +259 -0
- package/dist/extensions/story/commands/run/metadata.d.ts +4 -0
- package/dist/extensions/story/commands/run/metadata.js +8 -0
- package/dist/extensions/story/commands/run/outcomes.d.ts +101 -0
- package/dist/extensions/story/commands/run/outcomes.js +73 -0
- package/dist/extensions/story/commands/tree.d.ts +2 -0
- package/dist/extensions/story/commands/tree.js +6 -0
- package/dist/extensions/story/extension.d.ts +2 -0
- package/dist/extensions/story/extension.js +8 -0
- package/dist/extensions/testserver/command-tree.d.ts +1 -1
- package/dist/extensions/testserver/command-tree.js +0 -1
- package/dist/extensions/testserver/commands/pool/create/command.js +14 -8
- package/dist/extensions/testserver/commands/pool/list/command.js +8 -4
- package/dist/extensions/testserver/vitest/config.d.ts +7 -5
- package/dist/extensions/testserver/vitest/config.js +7 -5
- package/dist/extensions/testserver/vitest/fixtures.d.ts +2 -0
- package/dist/extensions/testserver/vitest/fixtures.js +36 -5
- package/dist/extensions.d.ts +12 -21
- package/dist/extensions.js +22 -34
- package/dist/forward-sigterm.d.ts +8 -0
- package/dist/forward-sigterm.js +18 -0
- package/dist/launcher-resolvers/index.d.ts +1 -0
- package/dist/launcher-resolvers/index.js +2 -1
- package/dist/launcher-resolvers/local-services.d.ts +57 -0
- package/dist/launcher-resolvers/local-services.js +7 -0
- package/dist/live-app.js +2 -1
- package/dist/local-services.d.ts +19 -0
- package/dist/local-services.js +37 -0
- package/dist/run-directory/gateways.d.ts +167 -0
- package/dist/run-directory/gateways.js +2 -0
- package/dist/run-directory/index.d.ts +8 -0
- package/dist/run-directory/index.js +13 -0
- package/dist/run-directory/plan.d.ts +35 -0
- package/dist/run-directory/plan.js +24 -0
- package/dist/run-directory/reader.d.ts +70 -0
- package/dist/run-directory/reader.js +51 -0
- package/dist/run-directory/recording.d.ts +92 -0
- package/dist/run-directory/recording.js +85 -0
- package/dist/{commands/exec → run-directory}/run-collector.d.ts +9 -8
- package/dist/{commands/exec → run-directory}/run-collector.js +8 -10
- package/dist/{core → run-directory}/run-directory.d.ts +3 -3
- package/dist/{core → run-directory}/run-directory.js +2 -2
- package/dist/{commands/exec → run-directory}/run-record.d.ts +29 -7
- package/dist/{commands/exec → run-directory}/run-record.js +79 -5
- package/dist/{commands/exec → run-directory}/timeline-facts.d.ts +4 -8
- package/dist/{commands/exec → run-directory}/timeline-facts.js +8 -24
- package/dist/runner/events.d.ts +6 -5
- package/dist/runner/index.d.ts +13 -17
- package/dist/runner/index.js +10 -14
- package/dist/runner/prepare.d.ts +28 -6
- package/dist/runner/prepare.js +15 -9
- package/dist/runner/recipe.d.ts +14 -0
- package/dist/runner/recipe.js +12 -0
- package/dist/runner/scope.d.ts +18 -11
- package/dist/runner/scope.js +12 -10
- package/dist/runner/session.d.ts +100 -0
- package/dist/runner/session.js +109 -0
- package/dist/runner/snapshot-save.d.ts +3 -2
- package/dist/runner/snapshot-save.js +6 -5
- package/dist/sdk/extension/ci.d.ts +2 -0
- package/dist/sdk/extension/ci.js +6 -0
- package/dist/sdk/extension/commands.d.ts +11 -13
- package/dist/sdk/extension/commands.js +5 -5
- package/dist/sdk/extension/index.d.ts +1 -0
- package/dist/sdk/extension/index.js +1 -0
- package/dist/sdk/extension/lifecycle.d.ts +4 -3
- package/dist/sdk/extension/progress.js +2 -2
- package/dist/sdk/extension/resource.js +1 -1
- package/dist/story/align.d.ts +1 -1
- package/dist/story/align.js +1 -1
- package/dist/story/command-line.d.ts +6 -16
- package/dist/story/command-line.js +11 -23
- package/dist/story/errors.d.ts +1 -1
- package/dist/story/errors.js +1 -1
- package/dist/story/host.d.ts +1 -1
- package/dist/story/host.js +2 -2
- package/dist/story/index.d.ts +2 -2
- package/dist/story/index.js +4 -3
- package/dist/story/launch.d.ts +70 -0
- package/dist/story/launch.js +77 -0
- package/dist/story/report.d.ts +2 -2
- package/dist/story/report.js +3 -4
- package/dist/story/settle.d.ts +7 -7
- package/dist/story/settle.js +5 -5
- package/dist/story/start.d.ts +2 -2
- package/dist/vendor/testserver-sdk/container/container.d.ts +11 -6
- package/dist/vendor/testserver-sdk/container/container.js +38 -16
- package/dist/vendor/testserver-sdk/testserver/failure.d.ts +4 -3
- package/dist/vendor/testserver-sdk/testserver/failure.js +4 -3
- package/package.json +1 -1
- package/skills/overview.md +3 -0
- package/skills/read-run-output.md +2 -2
- package/dist/chunks/chunk-H2VCSNVU.js +0 -351
- package/dist/chunks/chunk-J6ZNYUDV.js +0 -21
- package/dist/core/mint.d.ts +0 -10
- package/dist/core/mint.js +0 -14
- package/dist/story/mode.d.ts +0 -17
- package/dist/story/mode.js +0 -21
- /package/dist/{core → run-directory}/live/run-directory-gateway.d.ts +0 -0
- /package/dist/{core → run-directory}/live/run-directory-gateway.js +0 -0
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { defineOutcomes, renderOutcome } from "../../../../sdk/extension/commands.js";
|
|
3
|
+
import { storyAnswersLevelSchema, storyExecutableSchema } from "../../../../story/launch.js";
|
|
4
|
+
/** What `story run` handed the stories, which every outcome after it found vitest reports. */
|
|
5
|
+
const launchedShape = {
|
|
6
|
+
/** The Vitest projects it ran, each from a `--project`, in order. */
|
|
7
|
+
projects: z.array(z.string()),
|
|
8
|
+
/** The answers level the stories got: `--answers`, or its default, `check` when `CI` is set and `add` elsewhere. */
|
|
9
|
+
answers: storyAnswersLevelSchema,
|
|
10
|
+
/**
|
|
11
|
+
* The executable `--bin` named for the stories to invoke, resolved: its program, a relative one against the working
|
|
12
|
+
* directory, and the words it gets before a story's own; null without `--bin`.
|
|
13
|
+
*/
|
|
14
|
+
bin: storyExecutableSchema.nullable(),
|
|
15
|
+
/** The `vitest` it ran: the nearest `node_modules/.bin/vitest` from the working directory. */
|
|
16
|
+
vitest: z.string(),
|
|
17
|
+
/** What `vitest` got, after the executable: `run`, a `--project` for each project, then the rest, in order. */
|
|
18
|
+
args: z.array(z.string()),
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* How `story run` ends. Vitest owns the terminal while it runs, so a run that started vitest prints nothing of its own:
|
|
22
|
+
* vitest's output is the report. Only a refusal before vitest starts prints an error.
|
|
23
|
+
*/
|
|
24
|
+
export const outcomes = defineOutcomes({
|
|
25
|
+
results: {
|
|
26
|
+
ran: {
|
|
27
|
+
schema: z.object({
|
|
28
|
+
...launchedShape,
|
|
29
|
+
/** Vitest's exit code; null when a signal ended it. */
|
|
30
|
+
exitCode: z.number().nullable(),
|
|
31
|
+
/** The signal that ended vitest, such as `SIGINT`; null when it exited. */
|
|
32
|
+
signal: z.string().nullable(),
|
|
33
|
+
}),
|
|
34
|
+
description: "Vitest ran and ended. storm exits with its code, or 128 + n when signal n ended it, whatever this result's exit code.",
|
|
35
|
+
render: () => renderOutcome({}),
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
errors: {
|
|
39
|
+
vitestNotFound: {
|
|
40
|
+
exitCode: 1,
|
|
41
|
+
description: "No directory from the working directory up to the repository's root, or the filesystem's root outside a repository, has node_modules/.bin/vitest, so no story ran.",
|
|
42
|
+
schema: z.object({
|
|
43
|
+
/** The working directory, where vitest would run. */
|
|
44
|
+
cwd: z.string(),
|
|
45
|
+
/** Every directory searched for `node_modules/.bin/vitest`, nearest first. */
|
|
46
|
+
searched: z.array(z.string()),
|
|
47
|
+
}),
|
|
48
|
+
render: ({ cwd, searched }) => ({
|
|
49
|
+
message: `Couldn't find vitest for ${cwd} in node_modules/.bin of ${searched.join(", ")}.`,
|
|
50
|
+
next: [
|
|
51
|
+
{
|
|
52
|
+
type: "text",
|
|
53
|
+
text: "Run it from the package that holds the stories, once vitest is installed in its node_modules/.bin or one above it.",
|
|
54
|
+
},
|
|
55
|
+
],
|
|
56
|
+
}),
|
|
57
|
+
},
|
|
58
|
+
spawnFailed: {
|
|
59
|
+
exitCode: 1,
|
|
60
|
+
description: "vitest couldn't start, so no story ran.",
|
|
61
|
+
schema: z.object({
|
|
62
|
+
...launchedShape,
|
|
63
|
+
/** What the OS said. */
|
|
64
|
+
message: z.string(),
|
|
65
|
+
}),
|
|
66
|
+
render: ({ vitest, message }) => ({
|
|
67
|
+
message: `Failed to start vitest. ${/[.!?]$/u.test(message) ? message : `${message}.`}`,
|
|
68
|
+
rows: [["Vitest", vitest]],
|
|
69
|
+
next: [{ type: "text", text: "Fix what the OS said about that vitest, then run it again." }],
|
|
70
|
+
}),
|
|
71
|
+
},
|
|
72
|
+
},
|
|
73
|
+
});
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
// The story extension's own command tree: `run`, mounted as `storm story`. Each command does
|
|
2
|
+
// `export default storyCommands.define({ … })`, so its handler takes `StoryCommandApp` from this import. The tree
|
|
3
|
+
// reads no path: its mount (`../command-tree.ts`) gives the directory, so a bundled build may move this module's code
|
|
4
|
+
// to another file.
|
|
5
|
+
import { commandTree } from "../../../sdk/extension/commands.js";
|
|
6
|
+
export const storyCommands = commandTree({ id: "story" });
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
// The story extension: `storm story run`, which runs a package's stories on this machine. It brings no resource, only
|
|
2
|
+
// its command, which the registry mounts at the top level, as `storm story` (`src/extension-commands.ts`). The one
|
|
3
|
+
// value the folder hands the registry (`src/extensions.ts`). Story core itself is a test-side library
|
|
4
|
+
// (`src/story/`, `@vercel/storm/story`) that knows nothing of this extension.
|
|
5
|
+
import { defineExtension } from "../../sdk/extension/commands.js";
|
|
6
|
+
import { storyExtensionCommands } from "./command-tree.js";
|
|
7
|
+
/** The story extension. It has no resources; its commands (`command-tree.ts`) take `StoryCommandApp`. */
|
|
8
|
+
export const storyExtension = defineExtension({ name: "story", resources: [], commands: storyExtensionCommands });
|
|
@@ -3,4 +3,4 @@ import type { TestserverLauncherApp } from "./commands/app.ts";
|
|
|
3
3
|
* The Testserver extension's commands, which take `TestserverCommandApp` (`commands/app.ts`), projected from the
|
|
4
4
|
* launcher's app: the Testserver pool's world and the launcher resolvers.
|
|
5
5
|
*/
|
|
6
|
-
export declare const testserverExtensionCommands: import("../../sdk/extension/commands.ts").ExtensionCommands<
|
|
6
|
+
export declare const testserverExtensionCommands: import("../../sdk/extension/commands.ts").ExtensionCommands<TestserverLauncherApp>;
|
|
@@ -9,7 +9,6 @@ import { testserverCommands } from "./commands/tree.js";
|
|
|
9
9
|
* launcher's app: the Testserver pool's world and the launcher resolvers.
|
|
10
10
|
*/
|
|
11
11
|
export const testserverExtensionCommands = defineExtensionCommands({
|
|
12
|
-
extension: "testserver",
|
|
13
12
|
description: "Work with Vercel Testserver: the pool of Testserver sandboxes that runs lease.",
|
|
14
13
|
tree: testserverCommands,
|
|
15
14
|
directory: "extensions/testserver/commands",
|
|
@@ -1,15 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
|
-
configErrors,
|
|
3
|
-
credentialErrors,
|
|
4
2
|
credentialOriginRows,
|
|
5
|
-
credentialSourceErrors,
|
|
6
3
|
prBuildRefusalErrors,
|
|
7
4
|
prBuildRefusalFacts,
|
|
8
5
|
rejectedCredentialFacts,
|
|
9
6
|
rejectedCredentialShape,
|
|
10
7
|
rejectedCredentialText,
|
|
11
8
|
testserverPoolDefinition
|
|
12
|
-
} from "../../../../../chunks/chunk-
|
|
9
|
+
} from "../../../../../chunks/chunk-OJOKQRM6.js";
|
|
13
10
|
import {
|
|
14
11
|
CREATE_ATTEMPTS,
|
|
15
12
|
DEFAULT_TTL_MINUTES,
|
|
@@ -22,12 +19,21 @@ import {
|
|
|
22
19
|
parseTtl,
|
|
23
20
|
resolvePrBuild,
|
|
24
21
|
shortSha
|
|
25
|
-
} from "../../../../../chunks/chunk-
|
|
22
|
+
} from "../../../../../chunks/chunk-GRMD7G4J.js";
|
|
26
23
|
import {
|
|
27
|
-
defineOutcomes,
|
|
28
|
-
renderOutcome,
|
|
29
24
|
testserverCommands
|
|
30
|
-
} from "../../../../../chunks/chunk-
|
|
25
|
+
} from "../../../../../chunks/chunk-FVMQKYTT.js";
|
|
26
|
+
import "../../../../../chunks/chunk-ICB4BZJX.js";
|
|
27
|
+
import {
|
|
28
|
+
configErrors,
|
|
29
|
+
credentialErrors,
|
|
30
|
+
credentialSourceErrors
|
|
31
|
+
} from "../../../../../chunks/chunk-O4BUT7BE.js";
|
|
32
|
+
import "../../../../../chunks/chunk-AMTYHUYB.js";
|
|
33
|
+
import {
|
|
34
|
+
defineOutcomes,
|
|
35
|
+
renderOutcome
|
|
36
|
+
} from "../../../../../chunks/chunk-4PRAB24Y.js";
|
|
31
37
|
|
|
32
38
|
// src/extensions/testserver/commands/pool/create/command.ts
|
|
33
39
|
import { z as z2 } from "zod";
|
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
import {
|
|
2
2
|
inspectPool
|
|
3
|
-
} from "../../../../../chunks/chunk-
|
|
3
|
+
} from "../../../../../chunks/chunk-GRMD7G4J.js";
|
|
4
4
|
import {
|
|
5
|
-
defineOutcomes,
|
|
6
|
-
renderOutcome,
|
|
7
5
|
testserverCommands
|
|
8
|
-
} from "../../../../../chunks/chunk-
|
|
6
|
+
} from "../../../../../chunks/chunk-FVMQKYTT.js";
|
|
7
|
+
import "../../../../../chunks/chunk-ICB4BZJX.js";
|
|
8
|
+
import "../../../../../chunks/chunk-AMTYHUYB.js";
|
|
9
|
+
import {
|
|
10
|
+
defineOutcomes,
|
|
11
|
+
renderOutcome
|
|
12
|
+
} from "../../../../../chunks/chunk-4PRAB24Y.js";
|
|
9
13
|
|
|
10
14
|
// src/extensions/testserver/commands/pool/list/command.ts
|
|
11
15
|
import { z as z2 } from "zod";
|
|
@@ -3,11 +3,13 @@ export { WORKERS_PER_SANDBOX } from "./sandbox.ts";
|
|
|
3
3
|
* A vitest `retry` for a testserver project: one more attempt for a test that failed because Testserver couldn't
|
|
4
4
|
* serve a call for a reason outside the test (`TESTSERVER_TRANSIENT_FAILURE`): its connection failed, such as a
|
|
5
5
|
* `read ECONNRESET` between the runner and the Testserver URL, or Testserver had stopped the container, as its idle
|
|
6
|
-
* eviction does to a container no request has reached for a while, whether the test made the call
|
|
7
|
-
* forwarded it. None for any other failure. The adapter ends a file's
|
|
8
|
-
* request or proxied request failed so, so the retry runs on a new
|
|
9
|
-
* on the old one can't collide with it. vitest's own output marks
|
|
10
|
-
* the count: `retry: { ...testserverTransientRetry, count: 2 }
|
|
6
|
+
* eviction does to a container no request has reached for a while, whether the test made the call, its proxy
|
|
7
|
+
* forwarded it, or the call was the start of its container. None for any other failure. The adapter ends a file's
|
|
8
|
+
* container after a test whose factory call, API request or proxied request failed so, so the retry runs on a new
|
|
9
|
+
* container, where a factory call that half-happened on the old one can't collide with it. vitest's own output marks
|
|
10
|
+
* a test it rescued `(retry x1)`. Spread it to change the count: `retry: { ...testserverTransientRetry, count: 2 }`;
|
|
11
|
+
* under Vitest before 5.0.4, only the first retry can start a container again after a failed start (the adapter's
|
|
12
|
+
* `README.md`, `stormContainer`).
|
|
11
13
|
*/
|
|
12
14
|
export declare const testserverTransientRetry: {
|
|
13
15
|
readonly count: number;
|
|
@@ -11,11 +11,13 @@ export { WORKERS_PER_SANDBOX } from "./sandbox.js";
|
|
|
11
11
|
* A vitest `retry` for a testserver project: one more attempt for a test that failed because Testserver couldn't
|
|
12
12
|
* serve a call for a reason outside the test (`TESTSERVER_TRANSIENT_FAILURE`): its connection failed, such as a
|
|
13
13
|
* `read ECONNRESET` between the runner and the Testserver URL, or Testserver had stopped the container, as its idle
|
|
14
|
-
* eviction does to a container no request has reached for a while, whether the test made the call
|
|
15
|
-
* forwarded it. None for any other failure. The adapter ends a file's
|
|
16
|
-
* request or proxied request failed so, so the retry runs on a new
|
|
17
|
-
* on the old one can't collide with it. vitest's own output marks
|
|
18
|
-
* the count: `retry: { ...testserverTransientRetry, count: 2 }
|
|
14
|
+
* eviction does to a container no request has reached for a while, whether the test made the call, its proxy
|
|
15
|
+
* forwarded it, or the call was the start of its container. None for any other failure. The adapter ends a file's
|
|
16
|
+
* container after a test whose factory call, API request or proxied request failed so, so the retry runs on a new
|
|
17
|
+
* container, where a factory call that half-happened on the old one can't collide with it. vitest's own output marks
|
|
18
|
+
* a test it rescued `(retry x1)`. Spread it to change the count: `retry: { ...testserverTransientRetry, count: 2 }`;
|
|
19
|
+
* under Vitest before 5.0.4, only the first retry can start a container again after a failed start (the adapter's
|
|
20
|
+
* `README.md`, `stormContainer`).
|
|
19
21
|
*/
|
|
20
22
|
export const testserverTransientRetry = {
|
|
21
23
|
count: 1,
|
|
@@ -49,6 +49,8 @@ declare module "vitest" {
|
|
|
49
49
|
* A concurrent test fails instead. In `'test'` scope, a container started for the test, labeled with the test's
|
|
50
50
|
* name, and ended after it. The test's `task.meta.storm` records the Testserver URL and, once the test has the
|
|
51
51
|
* container, its test id.
|
|
52
|
+
* A retry of a test whose container failed to start starts one again, once: Vitest before 5.0.4 sets no fixture up
|
|
53
|
+
* again after its setup throws, so in a later attempt `seed` and `proxy` fail, saying the attempt has no container.
|
|
52
54
|
* - `seed`: a `Seeder` over `container`, per test.
|
|
53
55
|
* - `proxy`: a proxy adding `container`'s test id, per test, closed after it. Once closed, its cleanup fails the
|
|
54
56
|
* test when a fault rule forwarded a request and Testserver failed (`fault.upstream.error`), or Testserver refused a
|
|
@@ -18,6 +18,20 @@ function workerTestserverUrl() {
|
|
|
18
18
|
const NO_SERVICES = [];
|
|
19
19
|
/** The default `featureFlags`: none. */
|
|
20
20
|
const NO_FEATURE_FLAGS = {};
|
|
21
|
+
/**
|
|
22
|
+
* `container`, the `container` fixture's value as another fixture reads it, or an error when there is none. Vitest
|
|
23
|
+
* before 5.0.4 never sets up again a test's fixture whose setup threw, and hands its dependents `undefined` in every
|
|
24
|
+
* later attempt (vitest-dev/vitest#11237). The adapter sets a container up again for one retry (`stormContainer`);
|
|
25
|
+
* when that fails too, a later attempt has none, and this says so in place of a `TypeError` from the first read of it.
|
|
26
|
+
*/
|
|
27
|
+
function startedContainer(container) {
|
|
28
|
+
if (container === undefined) {
|
|
29
|
+
throw new Error("storm: this attempt at the test has no container. Setting it up failed in each earlier attempt, whose errors " +
|
|
30
|
+
"say why. Vitest before 5.0.4 doesn't set a fixture up again after its setup throws " +
|
|
31
|
+
"(vitest-dev/vitest#11237), so the adapter can set a container up again for one retry only.");
|
|
32
|
+
}
|
|
33
|
+
return container;
|
|
34
|
+
}
|
|
21
35
|
// The fixture chain, as vitest types it; published as `test` below, under its named type.
|
|
22
36
|
const fixtures = vitestTest
|
|
23
37
|
.extend("testserverUrl", { scope: "worker" }, () => workerTestserverUrl())
|
|
@@ -65,7 +79,9 @@ const fixtures = vitestTest
|
|
|
65
79
|
.extend("containerScope", CONTAINER_SCOPE)
|
|
66
80
|
.extend("warmServices", NO_SERVICES)
|
|
67
81
|
.extend("featureFlags", NO_FEATURE_FLAGS)
|
|
68
|
-
|
|
82
|
+
// How the test's container is set up, for the fixture that hands it `onCleanup` (`stormContainer`, or `container`
|
|
83
|
+
// in its place). Setting this up starts nothing and never throws.
|
|
84
|
+
.extend("stormContainerSetup", ({ containerScope, warmServices, featureFlags, stormFile, stormTestserverFailure, stormEvents, testserverUrl, verbose, task, signal, onTestFailed, }) => async (onCleanup) => {
|
|
69
85
|
// Starts a container labeled `name` with `featureFlags`, then warms `warmServices`, both the start's test's, in
|
|
70
86
|
// it, reporting both as one container start. Under a verbose run, each container start prints as it ends, for
|
|
71
87
|
// passing tests too, saying when it replaced the file's container and why.
|
|
@@ -103,8 +119,21 @@ const fixtures = vitestTest
|
|
|
103
119
|
task.meta.storm = { testserverUrl, testId: container.testId };
|
|
104
120
|
return container;
|
|
105
121
|
})
|
|
106
|
-
|
|
122
|
+
// The test's container, which `container` hands on. The two are apart for Vitest before 5.0.4, which never sets up
|
|
123
|
+
// again a test's fixture whose setup threw, and hands its dependents `undefined` in every later attempt
|
|
124
|
+
// (vitest-dev/vitest#11237). So a retry after this one threw finds it `undefined`, and `container`, whose setup
|
|
125
|
+
// Vitest has not run yet, sets the container up itself. That covers one retry: when `container` throws too, a
|
|
126
|
+
// later attempt has no container (`startedContainer`). Later Vitest sets this one up again for every attempt.
|
|
127
|
+
// Remove the split once storm's Vitest peer range (`package.json`) requires 5.0.4 or later: `container` becomes the
|
|
128
|
+
// one fixture again, and `stormContainerSetup`, `stormContainer` and `startedContainer` go.
|
|
129
|
+
.extend("stormContainer", ({ stormContainerSetup }, { onCleanup }) => stormContainerSetup(onCleanup))
|
|
130
|
+
.extend("container", ({ stormContainer, stormContainerSetup }, { onCleanup }) => {
|
|
131
|
+
const provided = stormContainer;
|
|
132
|
+
return provided ?? stormContainerSetup(onCleanup);
|
|
133
|
+
})
|
|
134
|
+
.extend("seed", ({ container }) => seeder(startedContainer(container)))
|
|
107
135
|
.extend("proxy", async ({ container, stormFile, stormTestserverFailure, verbose, signal, onTestFailed, onTestFinished }, { onCleanup }) => {
|
|
136
|
+
startedContainer(container);
|
|
108
137
|
// Under a verbose run, each request prints as the proxy records it, for passing tests too.
|
|
109
138
|
const onRequest = verbose
|
|
110
139
|
? (record) => console.error(proxyRequestReport(container.testId, record, (text) => container.redact(text)))
|
|
@@ -174,6 +203,8 @@ const fixtures = vitestTest
|
|
|
174
203
|
* A concurrent test fails instead. In `'test'` scope, a container started for the test, labeled with the test's
|
|
175
204
|
* name, and ended after it. The test's `task.meta.storm` records the Testserver URL and, once the test has the
|
|
176
205
|
* container, its test id.
|
|
206
|
+
* A retry of a test whose container failed to start starts one again, once: Vitest before 5.0.4 sets no fixture up
|
|
207
|
+
* again after its setup throws, so in a later attempt `seed` and `proxy` fail, saying the attempt has no container.
|
|
177
208
|
* - `seed`: a `Seeder` over `container`, per test.
|
|
178
209
|
* - `proxy`: a proxy adding `container`'s test id, per test, closed after it. Once closed, its cleanup fails the
|
|
179
210
|
* test when a fault rule forwarded a request and Testserver failed (`fault.upstream.error`), or Testserver refused a
|
|
@@ -189,7 +220,7 @@ const fixtures = vitestTest
|
|
|
189
220
|
* prints the requests it received, each a fault rule matched tagged with the fault, then each fault rule with hits
|
|
190
221
|
* left. Tokens are redacted throughout.
|
|
191
222
|
*/
|
|
192
|
-
// The chain also holds the adapter's own fixtures (`stormEvents`, `stormFileEvents`, `stormTestEvents`,
|
|
193
|
-
// `
|
|
194
|
-
// `StormTest`; the cast drops them from the type.
|
|
223
|
+
// The chain also holds the adapter's own fixtures (`stormEvents`, `stormFileEvents`, `stormTestEvents`, `stormFile`,
|
|
224
|
+
// `stormTestserverFailure`, `stormContainerSetup`, `stormContainer`), which exist at run time but aren't published,
|
|
225
|
+
// so vitest's types can't see the chain as a `StormTest`; the cast drops them from the type.
|
|
195
226
|
export const test = fixtures;
|
package/dist/extensions.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { type ResourceLifecycles, type RunState, type TimedRunEvent, type Timeline } from "./core/index.ts";
|
|
2
1
|
/**
|
|
3
|
-
* Every extension, in order. Adding an extension adds it here; its resources join `RESOURCES` in this order.
|
|
2
|
+
* Every extension, in order. Adding an extension adds it here; its resources join `RESOURCES` in this order. An
|
|
3
|
+
* extension may bring no resource, as the story extension brings only `storm story run`.
|
|
4
4
|
*/
|
|
5
5
|
export declare const EXTENSIONS: readonly [import("./sdk/extension/commands.ts").Extension<"github", readonly [import("./sdk/extension/resource-definition.ts").ResourceDefinition<"githubFixtureRepo", {
|
|
6
6
|
readonly repo: {
|
|
@@ -58,14 +58,14 @@ export declare const EXTENSIONS: readonly [import("./sdk/extension/commands.ts")
|
|
|
58
58
|
readonly description: "Whether the run may create Testserver sandboxes, overriding resources.testserverPool.create in storm.config.ts; default true. --testserver-create=false runs only on Testserver sandboxes already in the pool, never minting for Testserver or creating: it needs no --scope or --project with --unsandboxed, and takes no --testserver-ttl. --testserver-create turns creating on over the file's create: false. Gives the run the Testserver pool.";
|
|
59
59
|
};
|
|
60
60
|
};
|
|
61
|
-
}, import("./extensions/testserver/run/connection.ts").TestserverConnection, import("./extensions/testserver/world.ts").TestserverWorld>], import("./extensions/testserver/commands/app.ts").TestserverLauncherApp>];
|
|
61
|
+
}, import("./extensions/testserver/run/connection.ts").TestserverConnection, import("./extensions/testserver/world.ts").TestserverWorld>], import("./extensions/testserver/commands/app.ts").TestserverLauncherApp>, import("./sdk/extension/commands.ts").Extension<"story", readonly [], import("./extensions/story/commands/app.ts").StoryCommandApp>];
|
|
62
62
|
/**
|
|
63
63
|
* Every extension's resources, each extension's in turn, in the one order everything about the resources follows:
|
|
64
64
|
* the order a run calls their `beforeRun` and their `acquireForRun`, their refusals rank in, the run payload's
|
|
65
65
|
* `resources`, the waterfall's resource rows, the order a config file's problems name the resources in, and the cleanup
|
|
66
|
-
* warnings. A run calls their `releaseAfterRun` in reverse. What a run
|
|
67
|
-
*
|
|
68
|
-
*
|
|
66
|
+
* warnings. A run calls their `releaseAfterRun` in reverse. What a config file's `resources` and the run flags are
|
|
67
|
+
* checked by, each resource with its own types. Adding a resource definition adds its `defineResource` to its
|
|
68
|
+
* extension's `resources`.
|
|
69
69
|
*/
|
|
70
70
|
export declare const RESOURCES: readonly [import("./sdk/extension/resource-definition.ts").ResourceDefinition<"githubFixtureRepo", {
|
|
71
71
|
readonly repo: {
|
|
@@ -124,14 +124,12 @@ export declare const RESOURCES: readonly [import("./sdk/extension/resource-defin
|
|
|
124
124
|
};
|
|
125
125
|
};
|
|
126
126
|
}, import("./extensions/testserver/run/connection.ts").TestserverConnection, import("./extensions/testserver/world.ts").TestserverWorld>];
|
|
127
|
-
/**
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
export declare const
|
|
133
|
-
/** Every resource's lifecycle, over its world from `worlds`, by its name: what a run calls before it starts. */
|
|
134
|
-
export declare function resourceLifecycles(worlds: StormWorlds): ResourceLifecycles;
|
|
127
|
+
/**
|
|
128
|
+
* The registry of `RESOURCES`, in their order: what a run, its views and its reports take. It holds every resource's
|
|
129
|
+
* reports and presentations, the run's state and waterfall through the resources' progress, their lifecycles over
|
|
130
|
+
* given worlds, and their worlds built from a launcher environment.
|
|
131
|
+
*/
|
|
132
|
+
export declare const REGISTRY: import("./core/resource-registry.ts").ResourceRegistry;
|
|
135
133
|
/**
|
|
136
134
|
* Each definition's world, by its name: what the launcher hands each lifecycle, for every resource instance of the
|
|
137
135
|
* definition, and what an extension's mount reads its own. Each resource keeps its world's type.
|
|
@@ -144,10 +142,3 @@ export type StormWorlds = {
|
|
|
144
142
|
* state directory.
|
|
145
143
|
*/
|
|
146
144
|
export declare function liveWorlds(env: Readonly<Record<string, string | undefined>>): StormWorlds;
|
|
147
|
-
/**
|
|
148
|
-
* The run's state after `timed`, through the registry's resources' progress. A run's final state is
|
|
149
|
-
* `events.reduce(applyStormEvent, EMPTY_RUN_STATE)`.
|
|
150
|
-
*/
|
|
151
|
-
export declare function applyStormEvent(state: RunState, timed: TimedRunEvent): RunState;
|
|
152
|
-
/** A run's waterfall, from its final state, with each resource lane's row. */
|
|
153
|
-
export declare function stormTimeline(state: RunState): Timeline;
|
package/dist/extensions.js
CHANGED
|
@@ -1,53 +1,41 @@
|
|
|
1
1
|
// The registry, in the composition layer: the one file that takes every extension value. It lists the extensions in
|
|
2
|
-
// order (`EXTENSIONS`), takes their resources in that order (`RESOURCES`), each as its `defineResource` returned it,
|
|
3
|
-
// builds
|
|
4
|
-
// the
|
|
5
|
-
//
|
|
2
|
+
// order (`EXTENSIONS`), takes their resources in that order (`RESOURCES`), each as its `defineResource` returned it,
|
|
3
|
+
// and builds from that list the one registry value (`REGISTRY`, the core's `resourceRegistry`): the resource reports
|
|
4
|
+
// and presentations, the run's state and waterfall, the lifecycles and the worlds. It types each definition's world
|
|
5
|
+
// (`StormWorlds`) and builds the live worlds (`liveWorlds`). It imports no command: the commands import it. The
|
|
6
|
+
// extensions' command trees, which help needs without the rest, are in `src/extension-commands.ts`. An extension
|
|
7
|
+
// folder, the story extension's among them, which brings only commands, is reached only through its extension value,
|
|
6
8
|
// and only this file takes one (`src/extension-commands.ts` takes only each extension's `command-tree.ts`);
|
|
7
9
|
// `.oxlintrc.json` enforces it.
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
+
import { resourceRegistry, resourcesOf } from "./core/index.js";
|
|
11
|
+
import { storyExtension } from "./extensions/story/extension.js";
|
|
10
12
|
import { githubExtension } from "./extensions/github/index.js";
|
|
11
13
|
import { testserverExtension } from "./extensions/testserver/index.js";
|
|
12
14
|
/**
|
|
13
|
-
* Every extension, in order. Adding an extension adds it here; its resources join `RESOURCES` in this order.
|
|
15
|
+
* Every extension, in order. Adding an extension adds it here; its resources join `RESOURCES` in this order. An
|
|
16
|
+
* extension may bring no resource, as the story extension brings only `storm story run`.
|
|
14
17
|
*/
|
|
15
|
-
export const EXTENSIONS = [githubExtension, testserverExtension];
|
|
18
|
+
export const EXTENSIONS = [githubExtension, testserverExtension, storyExtension];
|
|
16
19
|
/**
|
|
17
20
|
* Every extension's resources, each extension's in turn, in the one order everything about the resources follows:
|
|
18
21
|
* the order a run calls their `beforeRun` and their `acquireForRun`, their refusals rank in, the run payload's
|
|
19
22
|
* `resources`, the waterfall's resource rows, the order a config file's problems name the resources in, and the cleanup
|
|
20
|
-
* warnings. A run calls their `releaseAfterRun` in reverse. What a run
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
+
* warnings. A run calls their `releaseAfterRun` in reverse. What a config file's `resources` and the run flags are
|
|
24
|
+
* checked by, each resource with its own types. Adding a resource definition adds its `defineResource` to its
|
|
25
|
+
* extension's `resources`.
|
|
23
26
|
*/
|
|
24
27
|
export const RESOURCES = resourcesOf(EXTENSIONS);
|
|
25
|
-
/**
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
export const
|
|
31
|
-
/** Every resource's lifecycle, over its world from `worlds`, by its name: what a run calls before it starts. */
|
|
32
|
-
export function resourceLifecycles(worlds) {
|
|
33
|
-
return bindLifecycles(RESOURCES, worlds);
|
|
34
|
-
}
|
|
28
|
+
/**
|
|
29
|
+
* The registry of `RESOURCES`, in their order: what a run, its views and its reports take. It holds every resource's
|
|
30
|
+
* reports and presentations, the run's state and waterfall through the resources' progress, their lifecycles over
|
|
31
|
+
* given worlds, and their worlds built from a launcher environment.
|
|
32
|
+
*/
|
|
33
|
+
export const REGISTRY = resourceRegistry(RESOURCES);
|
|
35
34
|
/**
|
|
36
35
|
* Every definition's live world, by its name, each built from what the launcher supplies it over `env`, with its own
|
|
37
36
|
* state directory.
|
|
38
37
|
*/
|
|
39
38
|
export function liveWorlds(env) {
|
|
40
|
-
//
|
|
41
|
-
return
|
|
42
|
-
}
|
|
43
|
-
/**
|
|
44
|
-
* The run's state after `timed`, through the registry's resources' progress. A run's final state is
|
|
45
|
-
* `events.reduce(applyStormEvent, EMPTY_RUN_STATE)`.
|
|
46
|
-
*/
|
|
47
|
-
export function applyStormEvent(state, timed) {
|
|
48
|
-
return applyRunEvent(RESOURCES, state, timed);
|
|
49
|
-
}
|
|
50
|
-
/** A run's waterfall, from its final state, with each resource lane's row. */
|
|
51
|
-
export function stormTimeline(state) {
|
|
52
|
-
return timeline(RESOURCES, state);
|
|
39
|
+
// The registry builds one world per resource of `RESOURCES`, under its definition's name, from its own `world`.
|
|
40
|
+
return REGISTRY.worlds(env);
|
|
53
41
|
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/** The command's `terminate` signal, and how to stop following the command's own signal once the command ended. */
|
|
2
|
+
export interface ForwardedSigterm {
|
|
3
|
+
/** Aborts once `signal` has aborted with a SIGTERM: what a command gateway sends the command SIGTERM on. */
|
|
4
|
+
readonly terminate: AbortSignal;
|
|
5
|
+
readonly release: () => void;
|
|
6
|
+
}
|
|
7
|
+
/** Follows `signal`, Clinkr's command signal, and aborts `terminate` only for a SIGTERM, even one before the call. */
|
|
8
|
+
export declare function forwardSigterm(signal: AbortSignal): ForwardedSigterm;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
// Which of the signals that stop a command storm passes on to a command it runs on this machine: only SIGTERM. Ctrl+C
|
|
2
|
+
// and a closed terminal reach the command directly, through its process group, so passing them on would signal it
|
|
3
|
+
// twice. `exec`'s and `vitest`'s run and the terminal local service share it.
|
|
4
|
+
import { NodeSignalCancellation } from "@vercel/clinkr/node";
|
|
5
|
+
/** Follows `signal`, Clinkr's command signal, and aborts `terminate` only for a SIGTERM, even one before the call. */
|
|
6
|
+
export function forwardSigterm(signal) {
|
|
7
|
+
const terminate = new AbortController();
|
|
8
|
+
const forward = () => {
|
|
9
|
+
const reason = signal.reason;
|
|
10
|
+
if (reason instanceof NodeSignalCancellation && reason.signal === "SIGTERM")
|
|
11
|
+
terminate.abort(reason);
|
|
12
|
+
};
|
|
13
|
+
if (signal.aborted)
|
|
14
|
+
forward();
|
|
15
|
+
else
|
|
16
|
+
signal.addEventListener("abort", forward, { once: true });
|
|
17
|
+
return { terminate: terminate.signal, release: () => signal.removeEventListener("abort", forward) };
|
|
18
|
+
}
|
|
@@ -1 +1,2 @@
|
|
|
1
1
|
export { type CommandCredentialSource, configErrors, type ConfigLoadError, type ConfigResolver, credentialErrors, type CredentialReport, type CredentialResolver, type CredentialSourceError, credentialSourceErrors, type CredentialTarget, type LoadedResourceSettings, type TargetSettings, } from "../config/index.ts";
|
|
2
|
+
export type { TerminalRunOutcome, TerminalRunRequest, TerminalService, VitestSearch, VitestService, } from "./local-services.ts";
|
|
@@ -3,5 +3,6 @@
|
|
|
3
3
|
// (`CredentialResolver`, `credentialErrors` and `credentialSourceErrors`), re-exported from `config`. It is the
|
|
4
4
|
// launcher's, not the SDK's: it loads `config`, and through it the runner and Clinkr, which a resource's code, through
|
|
5
5
|
// the extension API's run-time entry, never loads. Only an extension's command files import it (`.oxlintrc.json`). A
|
|
6
|
-
// command that uses a resolver spreads its error maps into its outcomes and returns a resolver's refusal as it is.
|
|
6
|
+
// command that uses a resolver spreads its error maps into its outcomes and returns a resolver's refusal as it is. It
|
|
7
|
+
// also declares the local services' types (`local-services.ts`), which reach this machine and refuse nothing.
|
|
7
8
|
export { configErrors, credentialErrors, credentialSourceErrors, } from "../config/index.js";
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Where the vitest service found `vitest`: the absolute path of the nearest `node_modules/.bin/vitest`; or, when no
|
|
3
|
+
* directory has one, every directory it looked in, nearest first.
|
|
4
|
+
*/
|
|
5
|
+
export type VitestSearch = {
|
|
6
|
+
readonly ok: true;
|
|
7
|
+
readonly path: string;
|
|
8
|
+
} | {
|
|
9
|
+
readonly ok: false;
|
|
10
|
+
readonly searched: readonly string[];
|
|
11
|
+
};
|
|
12
|
+
/** Finds the `vitest` a package's scripts would run, as `storm vitest` finds it for a run on this machine. */
|
|
13
|
+
export interface VitestService {
|
|
14
|
+
/**
|
|
15
|
+
* The nearest `node_modules/.bin/vitest` from `from`, an absolute directory, and each directory above it, up to the
|
|
16
|
+
* root of the Git repository `from` is in, or the filesystem's root outside one.
|
|
17
|
+
*/
|
|
18
|
+
find(from: string): Promise<VitestSearch>;
|
|
19
|
+
}
|
|
20
|
+
/** A command to run in the launcher's terminal. */
|
|
21
|
+
export interface TerminalRunRequest {
|
|
22
|
+
/** The command, run as given, with no shell. `argv[0]` is the executable. */
|
|
23
|
+
readonly argv: readonly string[];
|
|
24
|
+
/** The command's whole environment; nothing else is inherited. */
|
|
25
|
+
readonly env: Readonly<Record<string, string>>;
|
|
26
|
+
/** The directory it runs in, an absolute path. */
|
|
27
|
+
readonly cwd: string;
|
|
28
|
+
/** The command's own signal (Clinkr's `signal`), which aborts on the first SIGINT, SIGTERM or SIGHUP. */
|
|
29
|
+
readonly signal: AbortSignal;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* How a command in the launcher's terminal ended: it exited with `code`, a signal ended it (`signal`, such as
|
|
33
|
+
* `SIGINT`), or it never started (`spawn-failed`, with what the OS said). A command that ran carries the `status` storm
|
|
34
|
+
* exits with when it passes the command's end on, as `exec` does: its code, or `128 + n` when signal `n` ended it (1
|
|
35
|
+
* for a signal Node can't number).
|
|
36
|
+
*/
|
|
37
|
+
export type TerminalRunOutcome = {
|
|
38
|
+
readonly kind: "exited";
|
|
39
|
+
readonly code: number;
|
|
40
|
+
readonly status: number;
|
|
41
|
+
} | {
|
|
42
|
+
readonly kind: "signaled";
|
|
43
|
+
readonly signal: string;
|
|
44
|
+
readonly status: number;
|
|
45
|
+
} | {
|
|
46
|
+
readonly kind: "spawn-failed";
|
|
47
|
+
readonly message: string;
|
|
48
|
+
};
|
|
49
|
+
/** Runs a command on this machine in the launcher's terminal. */
|
|
50
|
+
export interface TerminalService {
|
|
51
|
+
/**
|
|
52
|
+
* Runs `argv` in `cwd` with `env`, sharing storm's stdin, stdout and stderr, and waits for it to exit. Ctrl+C and a
|
|
53
|
+
* closed terminal reach the command directly through its process group, so of the signals that abort `signal` only
|
|
54
|
+
* SIGTERM is passed on. A second signal makes Clinkr's host exit at once. It never rejects.
|
|
55
|
+
*/
|
|
56
|
+
run(request: TerminalRunRequest): Promise<TerminalRunOutcome>;
|
|
57
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
// The local services' types (`GLOSSARY.md`, **Local service**): what the launcher gives every command to reach this
|
|
2
|
+
// machine, the vitest service (`VitestService`), which finds `vitest`, and the terminal service (`TerminalService`),
|
|
3
|
+
// which runs a command in the launcher's terminal. The composition layer builds them (`src/local-services.ts`). They
|
|
4
|
+
// refuse nothing: each answers what happened, and the command words it. This file imports nothing, so the module
|
|
5
|
+
// stays left of `core`: `TerminalRunOutcome` declares the shape of the core's `CommandOutcome` itself, with the exit
|
|
6
|
+
// status, and `VitestSearch` that of storm's Vitest integration's `FindVitestResult`.
|
|
7
|
+
export {};
|
package/dist/live-app.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// from Clinkr's Node host. Only `bin/storm.ts` loads this module, inside its `app` factory, which Clinkr calls only
|
|
3
3
|
// when a command runs; so help, listings, `--version`, and invocation errors never load the resource registry, the
|
|
4
4
|
// runner, or the SDK.
|
|
5
|
-
import { launcherResolvers, liveContext } from "./context.js";
|
|
5
|
+
import { launcherResolvers, liveContext, localServices } from "./context.js";
|
|
6
6
|
import { resolvePresentation } from "./presentation.js";
|
|
7
7
|
import { liveWorlds, RESOURCES } from "./extensions.js";
|
|
8
8
|
import { localUserName } from "./runner/index.js";
|
|
@@ -14,6 +14,7 @@ export function liveStormApp(host, build, exit) {
|
|
|
14
14
|
worlds: liveWorlds(host.env),
|
|
15
15
|
resourceDefinitions: RESOURCES,
|
|
16
16
|
...launcherResolvers({ context, cwd: host.cwd, resourceDefinitions: RESOURCES }),
|
|
17
|
+
...localServices({ context }),
|
|
17
18
|
env: host.env,
|
|
18
19
|
cwd: host.cwd,
|
|
19
20
|
version: build.version,
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { CheckoutGateway } from "./runner/index.ts";
|
|
2
|
+
import { type TerminalCommandGateway } from "./core/index.ts";
|
|
3
|
+
import type { TerminalService, VitestService } from "./launcher-resolvers/index.ts";
|
|
4
|
+
import type { VitestListGateway } from "./vitest/plan.ts";
|
|
5
|
+
/**
|
|
6
|
+
* The vitest service over `checkout`, which says the repository's root, and `vitestList`, which looks for `vitest`
|
|
7
|
+
* in each directory from `from` up to that root, or up to the filesystem's root outside a repository.
|
|
8
|
+
*/
|
|
9
|
+
export declare function vitestService(context: {
|
|
10
|
+
readonly checkout: CheckoutGateway;
|
|
11
|
+
readonly vitestList: VitestListGateway;
|
|
12
|
+
}): VitestService;
|
|
13
|
+
/**
|
|
14
|
+
* The terminal service over `terminalCommands`. It passes on only a SIGTERM that aborts the command's signal
|
|
15
|
+
* (`forwardSigterm`), and waits for the command either way.
|
|
16
|
+
*/
|
|
17
|
+
export declare function terminalService(context: {
|
|
18
|
+
readonly terminalCommands: TerminalCommandGateway;
|
|
19
|
+
}): TerminalService;
|