@cnc-tools/storm 0.16.0 → 0.18.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 +54 -40
- package/dist/build-info.js +1 -1
- package/dist/chunks/{chunk-VL7WFTVQ.js → chunk-24UYAK4R.js} +465 -365
- package/dist/chunks/{chunk-DC2CDHNK.js → chunk-2JMWUKH3.js} +2074 -473
- package/dist/chunks/{chunk-FOZWA52V.js → chunk-3VXZONGE.js} +481 -376
- package/dist/chunks/{chunk-ZG3WQ4UF.js → chunk-55O4FCN4.js} +1 -1
- package/dist/chunks/{chunk-CN4EFA5J.js → chunk-72ZFEMAW.js} +1 -1
- package/dist/chunks/chunk-AS37D43E.js +2173 -0
- package/dist/chunks/chunk-CQAY6GLP.js +1260 -0
- package/dist/chunks/chunk-DZLU7BYK.js +340 -0
- package/dist/chunks/{chunk-R7XVBZOY.js → chunk-EEENLQHE.js} +59 -11
- package/dist/chunks/{chunk-TJNFVNKR.js → chunk-EI3XDCEI.js} +1 -1
- package/dist/chunks/{chunk-HVNK3I45.js → chunk-FDUY3BNF.js} +1 -1
- package/dist/chunks/{chunk-FCQUJDA4.js → chunk-GUCCYCIO.js} +4 -189
- package/dist/chunks/{chunk-OIY3DMF2.js → chunk-HBI4LEMH.js} +3 -3
- package/dist/chunks/{chunk-2MAD5NKK.js → chunk-K4MDQPLW.js} +1 -18
- package/dist/chunks/chunk-KK7PAWIZ.js +198 -0
- package/dist/chunks/{chunk-G3PHMXH5.js → chunk-KQ5FXRUD.js} +18 -1
- package/dist/chunks/{chunk-5VXBKPW6.js → chunk-LKXHGGGX.js} +1 -1
- package/dist/chunks/{chunk-P357TZAY.js → chunk-LOGHIUUB.js} +21 -18
- package/dist/chunks/{chunk-CK2GZEPK.js → chunk-OEPFINFT.js} +2 -2
- package/dist/chunks/{chunk-DWEAHX4T.js → chunk-OI4AP6Z7.js} +5 -5
- package/dist/chunks/{chunk-V4IKA3WI.js → chunk-PMBQWVTW.js} +26 -19
- package/dist/chunks/chunk-SZMYIIG2.js +88 -0
- package/dist/chunks/{chunk-5CCP36QQ.js → chunk-TXCOFC7N.js} +1 -1
- package/dist/chunks/{chunk-VUPZH7J2.js → chunk-UXD3TVWM.js} +1 -1
- package/dist/chunks/{chunk-3L52KNQA.js → chunk-WNW2QXQK.js} +8 -8
- package/dist/chunks/{chunk-AWBSONHB.js → chunk-XBDRVFEV.js} +55 -16
- package/dist/chunks/{live-app-WECQOQ4C.js → live-app-UY7BEDUN.js} +17 -13
- package/dist/cli.d.ts +28 -0
- package/dist/cli.js +64 -0
- package/dist/commands/exec/across-sandboxes-outcomes.d.ts +2 -2
- package/dist/commands/exec/across-sandboxes-outcomes.js +3 -3
- package/dist/commands/exec/before-run.d.ts +123 -0
- package/dist/commands/exec/before-run.js +105 -0
- package/dist/commands/exec/command.d.ts +67 -14
- package/dist/commands/exec/command.js +31 -95
- package/dist/commands/exec/driver-plan.d.ts +9 -4
- package/dist/commands/exec/driver-plan.js +8 -8
- package/dist/commands/exec/exec-words.js +1 -1
- package/dist/commands/exec/execute-run.d.ts +39 -0
- package/dist/commands/exec/execute-run.js +325 -0
- package/dist/commands/exec/live-view.d.ts +3 -3
- package/dist/commands/exec/live-view.js +16 -15
- package/dist/commands/exec/metadata.js +1 -1
- package/dist/commands/exec/mint-failed.d.ts +38 -0
- package/dist/commands/exec/mint-failed.js +27 -4
- package/dist/commands/exec/outcomes.d.ts +104 -22
- package/dist/commands/exec/outcomes.js +73 -26
- package/dist/commands/exec/plan-run.d.ts +58 -150
- package/dist/commands/exec/plan-run.js +239 -90
- package/dist/commands/exec/progress.d.ts +10 -6
- package/dist/commands/exec/progress.js +38 -25
- package/dist/commands/exec/run-bin.d.ts +11 -11
- package/dist/commands/exec/run-bin.js +9 -9
- package/dist/commands/exec/run-flags.d.ts +69 -0
- package/dist/commands/exec/run-flags.js +58 -0
- package/dist/commands/exec/run-metadata.js +4 -4
- package/dist/commands/exec/run-summary.d.ts +58 -0
- package/dist/commands/exec/run-summary.js +205 -0
- package/dist/commands/exec/runner-refusals.d.ts +82 -0
- package/dist/commands/exec/runner-refusals.js +71 -0
- package/dist/commands/exec/sandbox-progress.js +3 -0
- package/dist/commands/exec/stopped-outcome.d.ts +12 -0
- package/dist/commands/exec/stopped-outcome.js +77 -0
- package/dist/commands/exec/view.d.ts +20 -11
- package/dist/commands/exec/view.js +103 -47
- package/dist/commands/runs/facts.d.ts +8 -4
- package/dist/commands/runs/facts.js +19 -10
- package/dist/commands/runs/list/command.d.ts +16 -8
- package/dist/commands/runs/list/command.js +10 -10
- package/dist/commands/runs/list/outcomes.d.ts +8 -4
- package/dist/commands/runs/logs/command.js +10 -10
- package/dist/commands/runs/show/command.d.ts +16 -8
- package/dist/commands/runs/show/command.js +31 -29
- package/dist/commands/runs/show/metadata.js +1 -1
- package/dist/commands/runs/show/outcomes.d.ts +8 -4
- package/dist/commands/runs/show/outcomes.js +8 -6
- package/dist/commands/snapshots/access.d.ts +111 -0
- package/dist/commands/snapshots/access.js +96 -0
- package/dist/commands/snapshots/build/command.d.ts +376 -101
- package/dist/commands/snapshots/build/command.js +447 -149
- package/dist/commands/snapshots/build/metadata.d.ts +10 -0
- package/dist/commands/snapshots/build/metadata.js +31 -11
- package/dist/commands/snapshots/build/outcomes.d.ts +242 -47
- package/dist/commands/snapshots/build/outcomes.js +200 -36
- package/dist/commands/snapshots/list/command.d.ts +368 -27
- package/dist/commands/snapshots/list/command.js +298 -68
- package/dist/commands/snapshots/list/metadata.d.ts +16 -0
- package/dist/commands/snapshots/list/metadata.js +29 -6
- package/dist/commands/snapshots/list/outcomes.d.ts +247 -15
- package/dist/commands/snapshots/list/outcomes.js +223 -52
- package/dist/commands/snapshots/metadata.js +1 -1
- package/dist/commands/snapshots/prune/command.d.ts +430 -0
- package/dist/commands/snapshots/prune/command.js +161 -0
- package/dist/commands/snapshots/prune/metadata.d.ts +28 -0
- package/dist/commands/snapshots/prune/metadata.js +39 -0
- package/dist/commands/snapshots/prune/outcomes.d.ts +208 -0
- package/dist/commands/snapshots/prune/outcomes.js +78 -0
- package/dist/commands/suites/list/command.js +17 -17
- package/dist/commands/suites/list/outcomes.js +2 -2
- package/dist/commands/test/command.d.ts +67 -14
- package/dist/commands/test/command.js +49 -252
- package/dist/commands/test/outcomes.d.ts +33 -7
- package/dist/config/check-runner.d.ts +3 -3
- package/dist/config/check-runner.js +8 -7
- package/dist/config/credential-resolver.d.ts +50 -5
- package/dist/config/credential-resolver.js +51 -19
- package/dist/config/credential-settle.d.ts +6 -2
- package/dist/config/credential-settle.js +11 -5
- package/dist/config/index.d.ts +2 -2
- package/dist/config/index.js +1 -1
- package/dist/config/runner.d.ts +5 -5
- package/dist/config/runner.js +1 -1
- package/dist/config/schema.d.ts +2 -2
- package/dist/config/schema.js +1 -1
- package/dist/config-file/define.d.ts +1 -1
- package/dist/config-file/define.js +1 -1
- package/dist/config-file/runner.d.ts +5 -5
- package/dist/config-file/toolchain.d.ts +14 -4
- package/dist/config-file/toolchain.js +43 -7
- package/dist/context.d.ts +10 -6
- package/dist/context.js +8 -6
- package/dist/core/across-sandboxes.d.ts +7 -6
- package/dist/core/across-sandboxes.js +123 -152
- package/dist/core/coordinator.d.ts +166 -0
- package/dist/core/coordinator.js +233 -0
- package/dist/core/events.d.ts +2 -2
- package/dist/core/index.d.ts +4 -2
- package/dist/core/index.js +1 -1
- package/dist/core/outcomes.d.ts +148 -0
- package/dist/core/{sandbox-end.js → outcomes.js} +28 -4
- package/dist/core/resources.d.ts +31 -53
- package/dist/core/resources.js +32 -70
- package/dist/core/run-state.d.ts +7 -1
- package/dist/core/run-state.js +2 -0
- package/dist/core/run.d.ts +32 -236
- package/dist/core/run.js +107 -267
- package/dist/core/state-directory.d.ts +1 -1
- package/dist/core/state-directory.js +2 -2
- package/dist/credential/gateways.d.ts +15 -1
- package/dist/credential/index.d.ts +4 -3
- package/dist/credential/index.js +3 -2
- package/dist/credential/live/vercel-cli-gateway.d.ts +1 -1
- package/dist/credential/live/vercel-cli-gateway.js +1 -1
- package/dist/credential/live/vercel-oidc-token-gateway.d.ts +11 -0
- package/dist/credential/live/vercel-oidc-token-gateway.js +16 -0
- package/dist/credential/source.d.ts +73 -6
- package/dist/credential/source.js +55 -2
- package/dist/extension-commands.d.ts +1 -1
- package/dist/extension-commands.js +2 -2
- package/dist/extensions/testserver/commands/pool/create/command.d.ts +35 -2
- package/dist/extensions/testserver/commands/pool/create/command.js +7 -7
- package/dist/extensions/testserver/commands/pool/create/metadata.js +5 -5
- package/dist/extensions/testserver/commands/pool/create/outcomes.d.ts +17 -1
- package/dist/extensions/testserver/commands/pool/list/command.js +4 -4
- package/dist/extensions/testserver/credential-facts.d.ts +6 -2
- package/dist/extensions/testserver/credential-facts.js +29 -11
- package/dist/extensions/testserver/lifecycle.js +7 -1
- package/dist/extensions/testserver/limit.d.ts +3 -0
- package/dist/extensions/testserver/limit.js +3 -0
- package/dist/extensions/testserver/provision.d.ts +8 -1
- package/dist/extensions/testserver/provision.js +8 -3
- package/dist/extensions/testserver/refusals.d.ts +6 -1
- package/dist/extensions/testserver/refusals.js +16 -1
- package/dist/extensions/testserver/resource.d.ts +1 -1
- package/dist/extensions/testserver/resource.js +1 -1
- package/dist/extensions/testserver/result.d.ts +1 -1
- package/dist/extensions/testserver/result.js +9 -4
- package/dist/planning/driver-file-lists.d.ts +0 -15
- package/dist/planning/driver-file-lists.js +2 -21
- package/dist/planning/plan-only.d.ts +3 -14
- package/dist/planning/plan-only.js +11 -20
- package/dist/planning/run-kind-flags.js +2 -2
- package/dist/planning/run-plan.d.ts +45 -12
- package/dist/planning/run-plan.js +4 -3
- package/dist/planning/suites.d.ts +1 -1
- package/dist/planning/suites.js +2 -2
- package/dist/planning/test-plan.d.ts +9 -0
- package/dist/planning/test-plan.js +9 -0
- package/dist/run-directory/recording.js +3 -3
- package/dist/run-directory/run-record.d.ts +26 -11
- package/dist/run-directory/run-record.js +16 -13
- package/dist/runner/base.js +1 -1
- package/dist/runner/build-snapshots.d.ts +60 -29
- package/dist/runner/build-snapshots.js +136 -29
- package/dist/runner/context.d.ts +15 -7
- package/dist/runner/context.js +19 -6
- package/dist/runner/events.d.ts +16 -10
- package/dist/runner/gateways.d.ts +122 -23
- package/dist/runner/gateways.js +1 -1
- package/dist/runner/gh.d.ts +42 -0
- package/dist/runner/gh.js +58 -0
- package/dist/runner/index.d.ts +13 -8
- package/dist/runner/index.js +12 -6
- package/dist/runner/live/checkout-gateway.js +7 -0
- package/dist/runner/live/gh-output.d.ts +17 -0
- package/dist/runner/live/gh-output.js +37 -0
- package/dist/runner/live/gh-token-gateway.d.ts +13 -0
- package/dist/runner/live/gh-token-gateway.js +51 -0
- package/dist/runner/live/sandbox-errors.d.ts +2 -0
- package/dist/runner/live/sandbox-errors.js +4 -0
- package/dist/runner/live/sandbox-gateway.js +140 -4
- package/dist/runner/live/snapshot-index-gateway.d.ts +12 -0
- package/dist/runner/live/{snapshot-cache-gateway.js → snapshot-index-gateway.js} +11 -11
- package/dist/runner/live/snapshot-records.js +12 -12
- package/dist/runner/local-snapshot-index.d.ts +205 -0
- package/dist/runner/local-snapshot-index.js +210 -0
- package/dist/runner/network-policy.d.ts +6 -6
- package/dist/runner/network-policy.js +7 -7
- package/dist/runner/policy-writes.d.ts +1 -1
- package/dist/runner/policy-writes.js +1 -1
- package/dist/runner/prepare.d.ts +14 -14
- package/dist/runner/prepare.js +20 -11
- package/dist/runner/ready.d.ts +19 -11
- package/dist/runner/ready.js +104 -33
- package/dist/runner/sandboxed-command.d.ts +3 -3
- package/dist/runner/sandboxed-command.js +3 -3
- package/dist/runner/scope.d.ts +15 -8
- package/dist/runner/scope.js +16 -5
- package/dist/runner/secrets.d.ts +41 -18
- package/dist/runner/secrets.js +226 -30
- package/dist/runner/session.d.ts +8 -8
- package/dist/runner/session.js +6 -3
- package/dist/runner/shared-snapshot-entry.d.ts +92 -0
- package/dist/runner/shared-snapshot-entry.js +168 -0
- package/dist/runner/shared-snapshot-list.d.ts +81 -0
- package/dist/runner/shared-snapshot-list.js +155 -0
- package/dist/runner/shared-snapshot-lookup.d.ts +51 -0
- package/dist/runner/shared-snapshot-lookup.js +118 -0
- package/dist/runner/shared-snapshot-prune.d.ts +58 -0
- package/dist/runner/shared-snapshot-prune.js +133 -0
- package/dist/runner/snapshot-build.d.ts +42 -14
- package/dist/runner/snapshot-build.js +79 -47
- package/dist/runner/snapshot-choice.js +2 -1
- package/dist/runner/snapshot-inspect.d.ts +39 -40
- package/dist/runner/snapshot-inspect.js +52 -35
- package/dist/runner/snapshot-key.d.ts +32 -17
- package/dist/runner/snapshot-key.js +43 -18
- package/dist/runner/snapshot-source.d.ts +31 -0
- package/dist/runner/snapshot-source.js +122 -0
- package/dist/runner/steps.d.ts +1 -1
- package/dist/runner/steps.js +1 -1
- package/dist/runner/{recipe-check.d.ts → vercel-sandbox-check.d.ts} +4 -2
- package/dist/runner/{recipe-check.js → vercel-sandbox-check.js} +7 -2
- package/dist/runner/{recipe.d.ts → vercel-sandbox-options.d.ts} +59 -28
- package/dist/runner/{recipe.js → vercel-sandbox-options.js} +128 -84
- package/dist/runner/vercel-sandbox-secrets.d.ts +116 -0
- package/dist/runner/{recipe-secrets.js → vercel-sandbox-secrets.js} +159 -26
- package/dist/sdk/extension/credential-diagnosis.d.ts +3 -1
- package/dist/sdk/extension/credential-diagnosis.js +25 -5
- package/dist/sdk/extension/credential-source.d.ts +20 -3
- package/dist/sdk/extension/credential-source.js +4 -4
- package/dist/sdk/extension/index.d.ts +3 -2
- package/dist/sdk/extension/index.js +2 -1
- package/dist/sdk/extension/resource-definition.d.ts +1 -1
- package/dist/sdk/extension/secret-source.d.ts +1 -1
- package/dist/sdk/extension/secret-source.js +1 -1
- package/dist/sdk/extension/vercel-oidc-facts.d.ts +20 -0
- package/dist/sdk/extension/vercel-oidc-facts.js +20 -0
- package/dist/shared/cleanup.d.ts +3 -3
- package/dist/shared/cleanup.js +15 -5
- package/dist/shared/snapshot-text.d.ts +4 -4
- package/dist/shared/snapshot-text.js +11 -11
- package/dist/time/duration.js +1 -1
- package/package.json +5 -3
- package/skills/overview.md +4 -4
- package/skills/plan-runs.md +1 -1
- package/skills/read-run-output.md +6 -6
- package/dist/application.d.ts +0 -21
- package/dist/application.js +0 -30
- package/dist/chunks/chunk-7EENF73W.js +0 -782
- package/dist/chunks/chunk-Z5PBVG3Y.js +0 -2599
- package/dist/commands/exec/across-sandboxes-run.d.ts +0 -180
- package/dist/commands/exec/across-sandboxes-run.js +0 -339
- package/dist/commands/exec/plan-only.d.ts +0 -10
- package/dist/commands/exec/plan-only.js +0 -45
- package/dist/commands/exec/run-command.d.ts +0 -475
- package/dist/commands/exec/run-command.js +0 -603
- package/dist/commands/exec/run-planned.d.ts +0 -20
- package/dist/commands/exec/run-planned.js +0 -22
- package/dist/commands/exec/sandbox-view.d.ts +0 -19
- package/dist/commands/exec/sandbox-view.js +0 -72
- package/dist/commands/test/plan.d.ts +0 -92
- package/dist/commands/test/plan.js +0 -125
- package/dist/core/sandbox-end.d.ts +0 -64
- package/dist/runner/live/snapshot-cache-gateway.d.ts +0 -12
- package/dist/runner/recipe-secrets.d.ts +0 -67
- package/dist/runner/snapshot-cache.d.ts +0 -148
- package/dist/runner/snapshot-cache.js +0 -126
|
@@ -1,67 +1,60 @@
|
|
|
1
|
-
import { type CommandError } from "@vercel/clinkr";
|
|
2
1
|
import type { StormApp } from "../../context.ts";
|
|
3
|
-
import
|
|
4
|
-
import { type ResourceFlagOptions, type SettingsFile } from "../../config/index.ts";
|
|
5
|
-
import type { RunTestPlan } from "../../sdk/extension/index.ts";
|
|
2
|
+
import { settleCredential, settleRunResources } from "../../config/index.ts";
|
|
6
3
|
import type { ResourceLifecycles } from "../../core/index.ts";
|
|
7
|
-
import type {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
readonly
|
|
17
|
-
readonly
|
|
4
|
+
import type { DriverRefusals } from "../../planning/driver-refusals.ts";
|
|
5
|
+
import type { RunPlan } from "../../planning/run-plan.ts";
|
|
6
|
+
import { type Driver } from "../../sdk/extension/index.ts";
|
|
7
|
+
import { fileListErrors, sandboxesDefaultErrors, sandboxesErrors } from "./across-sandboxes-outcomes.ts";
|
|
8
|
+
import { type DriverPlanRefusal } from "./driver-plan.ts";
|
|
9
|
+
import { canceledBeforeStart, runErrors } from "./outcomes.ts";
|
|
10
|
+
import { type RunPlanRequest } from "./run-flags.ts";
|
|
11
|
+
/** Planning target for `storm exec`: a direct command argument list with no driver. */
|
|
12
|
+
export interface ExecPlanTarget {
|
|
13
|
+
readonly kind: "exec";
|
|
14
|
+
readonly command: readonly string[];
|
|
18
15
|
}
|
|
19
|
-
/**
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
readonly
|
|
24
|
-
readonly
|
|
16
|
+
/** Planning target for `storm test`: a driver, its combined arguments, test counting, and driver refusal builders. */
|
|
17
|
+
export interface DriverPlanTarget {
|
|
18
|
+
readonly kind: "driver";
|
|
19
|
+
readonly driver: Driver;
|
|
20
|
+
readonly args: readonly string[];
|
|
21
|
+
readonly countTests: boolean;
|
|
22
|
+
readonly errors: DriverRefusals;
|
|
25
23
|
}
|
|
26
|
-
/**
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
24
|
+
/** What `planRun` plans: either a direct command (`exec`) or a driver run (`driver`). */
|
|
25
|
+
export type PlanTarget = ExecPlanTarget | DriverPlanTarget;
|
|
26
|
+
type SandboxesMaxRefusal = ReturnType<typeof sandboxesErrors.missingSandboxesMax> | ReturnType<typeof sandboxesErrors.sandboxesOverMax>;
|
|
27
|
+
type FileListRefusal = ReturnType<typeof fileListErrors.fileListsUnreadable> | ReturnType<typeof fileListErrors.invalidFileLists> | ReturnType<typeof fileListErrors.fileListsUnlisted>;
|
|
28
|
+
type SandboxesDefaultRefusal = ReturnType<typeof sandboxesDefaultErrors.sandboxesDefaultRefused>;
|
|
29
|
+
type BasePlanRefusal = ReturnType<typeof runErrors.missingRunner> | ReturnType<typeof runErrors.conflictingOptions> | ReturnType<typeof runErrors.credentialsInvalid> | ReturnType<typeof runErrors.keepSandboxUnsafeSecretEnvVars> | ReturnType<typeof runErrors.keepSandboxManagedCredentials> | ReturnType<typeof runErrors.unsafeSecretEnvVarsInvalid> | Extract<ReturnType<typeof settleCredential>, {
|
|
30
|
+
readonly ok: false;
|
|
31
|
+
}>["refusal"] | Extract<ReturnType<typeof settleRunResources>, {
|
|
32
|
+
readonly ok: false;
|
|
33
|
+
}>["refusal"] | ReturnType<typeof canceledBeforeStart> | SandboxesMaxRefusal;
|
|
34
|
+
type ExecPlanRefusal = BasePlanRefusal;
|
|
35
|
+
type DriverPlanTargetRefusal = BasePlanRefusal | DriverPlanRefusal | FileListRefusal | SandboxesDefaultRefusal;
|
|
36
|
+
type PlanRefusal = ExecPlanRefusal | DriverPlanTargetRefusal;
|
|
37
|
+
type PlanOutcome<TRefusal> = {
|
|
38
|
+
readonly ok: true;
|
|
39
|
+
readonly planned: RunPlan;
|
|
40
|
+
readonly lifecycles: ResourceLifecycles;
|
|
41
|
+
} | {
|
|
33
42
|
readonly ok: false;
|
|
34
43
|
readonly refusal: TRefusal;
|
|
35
|
-
}
|
|
44
|
+
};
|
|
36
45
|
/**
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
*
|
|
46
|
+
* What is wrong with `--sandboxes` or `--file-lists` for `driver` and the run's arguments `args` (the command line's,
|
|
47
|
+
* then the config file's): a driver without file list support (`Driver.fileLists`) takes neither, and a driver with it
|
|
48
|
+
* checks the arguments (`fileLists.validate`). Undefined without either flag, or when the driver takes them.
|
|
40
49
|
*/
|
|
41
|
-
export
|
|
42
|
-
readonly kind: "unsandboxed";
|
|
43
|
-
readonly credential: CredentialSourceChoice | undefined;
|
|
44
|
-
} | Extract<PlannedWhere, {
|
|
45
|
-
readonly kind: "runner";
|
|
46
|
-
}>;
|
|
47
|
-
/** What `planRun` and `resourcesBeforeRun` read of a run's request. */
|
|
48
|
-
export interface PlanRequest {
|
|
49
|
-
readonly given: ResourceFlagOptions;
|
|
50
|
-
readonly scope?: string | undefined;
|
|
51
|
-
readonly project?: string | undefined;
|
|
52
|
-
readonly runner?: "launch-machine" | undefined;
|
|
53
|
-
readonly showOutput: boolean;
|
|
54
|
-
readonly keepSandbox?: string | undefined;
|
|
55
|
-
readonly credential?: CredentialSourceChoice["source"] | undefined;
|
|
56
|
-
/** `--sandboxes`, on `storm exec` and `storm test`. */
|
|
50
|
+
export declare function driverSandboxesProblem(driver: Driver, args: readonly string[], asks: {
|
|
57
51
|
readonly sandboxes?: number | undefined;
|
|
58
|
-
/** `--file-lists`, on `storm test`. */
|
|
59
52
|
readonly fileLists?: string | undefined;
|
|
60
|
-
|
|
61
|
-
readonly
|
|
62
|
-
|
|
63
|
-
readonly
|
|
64
|
-
}
|
|
53
|
+
}): {
|
|
54
|
+
readonly kind: "unsupported" | "args";
|
|
55
|
+
readonly flag: "--sandboxes" | "--file-lists";
|
|
56
|
+
readonly problem: string;
|
|
57
|
+
} | undefined;
|
|
65
58
|
/**
|
|
66
59
|
* Plans a run before anything is minted, acquired, or started, refusing in this order:
|
|
67
60
|
*
|
|
@@ -75,101 +68,16 @@ export interface PlanRequest {
|
|
|
75
68
|
* 4. Merges each resource's options once (`settleRunResources`): a required option nothing gives is
|
|
76
69
|
* `invalid_resource_options`. The merged options, each function default given `NOT_COUNTED`, name each resource's
|
|
77
70
|
* secrets.
|
|
78
|
-
* 5.
|
|
79
|
-
*
|
|
80
|
-
*
|
|
71
|
+
* 5. Plans the target (`exec` or `driver`), reading `--file-lists` (`file_lists_unreadable`, `invalid_file_lists`)
|
|
72
|
+
* before checking `runner.sandboxes.max` (`missing_sandboxes_max`, `sandboxes_over_max`), running the driver's plan
|
|
73
|
+
* step when needed, and dealing file lists or applying `runner.sandboxes.default`. Any refusal from target planning
|
|
74
|
+
* hides runner secrets and each resource's pure `secrets` over the merged options. A signal by then cancels the run
|
|
75
|
+
* (`canceledBeforeStart`).
|
|
81
76
|
* 6. Plans the merged options for the planned run (`plan`), each function default given the planned run once, and runs
|
|
82
|
-
* the checks across them
|
|
83
|
-
|
|
84
|
-
export declare function planRun<TTestPlan extends RunTestPlan, TRefusal extends CommandError>(app: StormApp, lifecycles: ResourceLifecycles, request: PlanRequest, planCommand: PlanCommand<TTestPlan, TRefusal>, signal: AbortSignal): Promise<{
|
|
85
|
-
readonly ok: false;
|
|
86
|
-
readonly refusal: CommandError<"invalid_resource_options">;
|
|
87
|
-
} | {
|
|
88
|
-
readonly ok: false;
|
|
89
|
-
readonly refusal: CommandError<"missing_target">;
|
|
90
|
-
} | {
|
|
91
|
-
readonly ok: false;
|
|
92
|
-
readonly refusal: TRefusal;
|
|
93
|
-
} | {
|
|
94
|
-
readonly ok: false;
|
|
95
|
-
readonly refusal: import("@vercel/clinkr").ClinkrError<"canceled">;
|
|
96
|
-
} | {
|
|
97
|
-
readonly ok: false;
|
|
98
|
-
readonly refusal: CommandError<"conflicting_options">;
|
|
99
|
-
} | {
|
|
100
|
-
readonly ok: false;
|
|
101
|
-
readonly refusal: CommandError<"credentials_invalid">;
|
|
102
|
-
} | {
|
|
103
|
-
readonly ok: false;
|
|
104
|
-
readonly refusal: CommandError<"keep_sandbox_unsafe_secret_env_vars">;
|
|
105
|
-
} | {
|
|
106
|
-
readonly ok: false;
|
|
107
|
-
readonly refusal: CommandError<"missing_runner">;
|
|
108
|
-
} | {
|
|
109
|
-
readonly ok: false;
|
|
110
|
-
readonly refusal: CommandError<"unsafe_secret_env_vars_invalid">;
|
|
111
|
-
} | {
|
|
112
|
-
readonly ok: true;
|
|
113
|
-
readonly configFile: string | null;
|
|
114
|
-
readonly settings: import("../../config/resolve.ts").ResolvedSettings;
|
|
115
|
-
readonly where: PlannedWhere;
|
|
116
|
-
readonly argv: readonly string[];
|
|
117
|
-
readonly testPlan: TTestPlan;
|
|
118
|
-
readonly testFiles: readonly string[] | undefined;
|
|
119
|
-
readonly sandboxes: PlannedSandboxesRun | undefined;
|
|
120
|
-
readonly resources: {
|
|
121
|
-
readonly [key: string]: import("../../config/resolve.ts").ResolvedResourceRecord;
|
|
122
|
-
};
|
|
123
|
-
readonly planOptions: Readonly<{
|
|
124
|
-
path: string;
|
|
125
|
-
value: string | number | boolean;
|
|
126
|
-
from: "default" | "file" | "flag";
|
|
127
|
-
}>[];
|
|
128
|
-
}>;
|
|
129
|
-
/** A planned run, as `planRun` answers it. */
|
|
130
|
-
export type RunPlan = Extract<Awaited<ReturnType<typeof planRun>>, {
|
|
131
|
-
readonly ok: true;
|
|
132
|
-
}>;
|
|
133
|
-
/**
|
|
134
|
-
* Calls each resource's `beforeRun` in registry order, with its options and their sources, then chooses the credential
|
|
135
|
-
* source, refusing in this order: a resource's `beforeRun` refusal (`resource_refused_before_run`), with the config
|
|
136
|
-
* file beside it, which stops the resources after it from being asked; a `--credential` no used resource needs
|
|
137
|
-
* (`credential_unused`); in an unsandboxed run, a used resource that needs a runner sandbox
|
|
138
|
-
* (`resource_needs_runner_sandbox`, naming every such resource by its key; a skipped resource never refuses); in an
|
|
139
|
-
* unsandboxed run where a used resource needs the Vercel credential, the credential source (`missing_target` for the
|
|
140
|
-
* mint). Each refusal ends the command before the run starts, so it leaves no run directory.
|
|
141
|
-
*/
|
|
142
|
-
export declare function resourcesBeforeRun(lifecycles: ResourceLifecycles, plan: RunPlan, request: Pick<PlanRequest, "credential">): Promise<{
|
|
143
|
-
readonly ok: false;
|
|
144
|
-
readonly refusal: CommandError<"missing_target">;
|
|
145
|
-
} | {
|
|
146
|
-
readonly ok: false;
|
|
147
|
-
readonly refusal: CommandError<"credential_unused">;
|
|
148
|
-
} | {
|
|
149
|
-
readonly ok: false;
|
|
150
|
-
readonly refusal: CommandError<"resource_needs_runner_sandbox">;
|
|
151
|
-
} | {
|
|
152
|
-
readonly ok: false;
|
|
153
|
-
readonly refusal: CommandError<"resource_refused_before_run">;
|
|
154
|
-
} | {
|
|
155
|
-
readonly ok: true;
|
|
156
|
-
readonly where: RunWhere;
|
|
157
|
-
readonly used: {
|
|
158
|
-
readonly ok: true;
|
|
159
|
-
readonly requests: import("../../core/resource.ts").ResourceRequests;
|
|
160
|
-
readonly skipped: readonly import("../../core/resource.ts").ResourceSkip[];
|
|
161
|
-
readonly secrets: readonly string[];
|
|
162
|
-
readonly needsVercelCredential: boolean;
|
|
163
|
-
readonly needRunnerSandbox: readonly string[];
|
|
164
|
-
readonly hiddenVariables: readonly string[];
|
|
165
|
-
};
|
|
166
|
-
}>;
|
|
167
|
-
/** What the resources' `beforeRun` answered, once they let the run go on. */
|
|
168
|
-
export type BeforeRun = Extract<Awaited<ReturnType<typeof resourcesBeforeRun>>, {
|
|
169
|
-
readonly ok: true;
|
|
170
|
-
}>;
|
|
171
|
-
/**
|
|
172
|
-
* A run canceled before it started, while storm planned it or called its resources' `beforeRun`: nothing was minted,
|
|
173
|
-
* acquired or started, and the command didn't run.
|
|
77
|
+
* the checks across them (`invalid_resource_options`), then refuses `--show-output` when `runner.sandboxes.default`
|
|
78
|
+
* made the run across runner sandboxes (`sandboxes_default_refused`).
|
|
174
79
|
*/
|
|
175
|
-
export declare function
|
|
80
|
+
export declare function planRun(app: StormApp, request: RunPlanRequest, target: ExecPlanTarget, signal: AbortSignal): Promise<PlanOutcome<ExecPlanRefusal>>;
|
|
81
|
+
export declare function planRun(app: StormApp, request: RunPlanRequest, target: DriverPlanTarget, signal: AbortSignal): Promise<PlanOutcome<DriverPlanTargetRefusal>>;
|
|
82
|
+
export declare function planRun(app: StormApp, request: RunPlanRequest, target: PlanTarget, signal: AbortSignal): Promise<PlanOutcome<PlanRefusal>>;
|
|
83
|
+
export {};
|
|
@@ -1,35 +1,74 @@
|
|
|
1
|
-
// Planning a run, which `storm test` and `storm exec` share:
|
|
2
|
-
//
|
|
3
|
-
//
|
|
1
|
+
// Planning a run, which `storm test` and `storm exec` share: binding the resources' lifecycles once, settling the
|
|
2
|
+
// runner from the effective config, checking unfit flags and runner requirements, merging each resource's required
|
|
3
|
+
// options, planning the exec or driver target (including `--sandboxes`, `--file-lists`, and `runner.sandboxes.default`),
|
|
4
|
+
// and resolving function defaults and cross-option checks. Nothing is minted, acquired, or started yet, and a refusal
|
|
4
5
|
// leaves no run directory.
|
|
5
6
|
import { refused } from "@vercel/clinkr";
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
7
|
+
import { fileSettings, givenTarget, settleCredential, settleRunResources, } from "../../config/index.js";
|
|
8
|
+
import { DEFINITION_SET } from "../../extensions.js";
|
|
9
|
+
import { driverCallerFileListsRun, driverSandboxesRun } from "../../planning/driver-file-lists.js";
|
|
10
|
+
import { readFileListsFile } from "../../planning/file-lists-file.js";
|
|
10
11
|
import { redactor, redactStrings } from "../../planning/redaction.js";
|
|
12
|
+
import { resourceFlagValues } from "../../planning/resource-flags.js";
|
|
11
13
|
import { runKindFlagMessage, runKindFlagName, unfitRunFlags } from "../../planning/run-kind-flags.js";
|
|
12
|
-
import {
|
|
14
|
+
import { commandsForSandboxes } from "../../planning/sandbox-placeholders.js";
|
|
15
|
+
import { readCredentials, readUnsafeSecretEnvVars, resolveSandboxCountDefault, SECRET_MIN_LENGTH, } from "../../runner/index.js";
|
|
16
|
+
import { NOT_COUNTED, } from "../../sdk/extension/index.js";
|
|
17
|
+
import { parseKeepTime } from "../../time/index.js";
|
|
18
|
+
import { fileListErrors, sandboxesDefaultErrors, sandboxesErrors } from "./across-sandboxes-outcomes.js";
|
|
19
|
+
import { driverCount, planDriverCommand } from "./driver-plan.js";
|
|
20
|
+
import { canceledBeforeStart, runErrors } from "./outcomes.js";
|
|
21
|
+
import { SHOW_OUTPUT_ACROSS_SANDBOXES_DETAIL } from "./run-flags.js";
|
|
22
|
+
const SANDBOXES_MAX_KEY = "runner.sandboxes.max";
|
|
23
|
+
const SANDBOXES_DEFAULT_KEY = "runner.sandboxes.default";
|
|
13
24
|
/**
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
* 1. Settles the effective runner in one place: `--runner launch-machine` (on `storm exec`), else the effective
|
|
17
|
-
* config's `runner`, else `missing_runner`.
|
|
18
|
-
* 2. Refuses any flag that doesn't fit the effective runner (`conflicting_options`).
|
|
19
|
-
* 3. For the Vercel Sandbox runner, checks the team and project its mint needs (`missing_target`), the credentials'
|
|
20
|
-
* values from the launcher environment (`credentials_invalid`), no `--keep-sandbox` above 0 with
|
|
21
|
-
* `unsafeSecretEnvVars` (`keep_sandbox_unsafe_secret_env_vars`), and the unsafe secret environment variables' values
|
|
22
|
-
* (`unsafe_secret_env_vars_invalid`).
|
|
23
|
-
* 4. Merges each resource's options once (`settleRunResources`): a required option nothing gives is
|
|
24
|
-
* `invalid_resource_options`. The merged options, each function default given `NOT_COUNTED`, name each resource's
|
|
25
|
-
* secrets.
|
|
26
|
-
* 5. Asks the command for its part (`planCommand`), with the file's `testPlan`: its argv, and what it counted, or its
|
|
27
|
-
* refusal, with the credentials' values and the resources' secrets hidden, from each resource's pure `secrets` over
|
|
28
|
-
* the merged options. A signal by then cancels the run (`canceledBeforeStart`).
|
|
29
|
-
* 6. Plans the merged options for the planned run (`plan`), each function default given the planned run once, and runs
|
|
30
|
-
* the checks across them: `invalid_resource_options`.
|
|
25
|
+
* Checks whether `driver` supports file lists and accepts `args` for a run across runner sandboxes.
|
|
31
26
|
*/
|
|
32
|
-
|
|
27
|
+
function checkDriverFileLists(driver, args) {
|
|
28
|
+
if (driver.fileLists === undefined) {
|
|
29
|
+
return {
|
|
30
|
+
ok: false,
|
|
31
|
+
kind: "unsupported",
|
|
32
|
+
problem: `The ${driver.name} driver has no file list support, so storm test can't run it across runner sandboxes.`,
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
const checked = driver.fileLists.validate(args);
|
|
36
|
+
return checked.ok ? { ok: true } : { ok: false, kind: "args", problem: checked.problem };
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* What is wrong with `--sandboxes` or `--file-lists` for `driver` and the run's arguments `args` (the command line's,
|
|
40
|
+
* then the config file's): a driver without file list support (`Driver.fileLists`) takes neither, and a driver with it
|
|
41
|
+
* checks the arguments (`fileLists.validate`). Undefined without either flag, or when the driver takes them.
|
|
42
|
+
*/
|
|
43
|
+
export function driverSandboxesProblem(driver, args, asks) {
|
|
44
|
+
const flag = asks.fileLists !== undefined ? "--file-lists" : asks.sandboxes !== undefined ? "--sandboxes" : undefined;
|
|
45
|
+
if (flag === undefined)
|
|
46
|
+
return undefined;
|
|
47
|
+
const checked = checkDriverFileLists(driver, args);
|
|
48
|
+
return checked.ok ? undefined : { kind: checked.kind, flag, problem: checked.problem };
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Checks `runner.sandboxes.max` for a run that explicitly asked for runner sandboxes (`--sandboxes` or `--file-lists`).
|
|
52
|
+
*/
|
|
53
|
+
function checkSandboxesMax(runner, asked, configFile) {
|
|
54
|
+
if (runner.kind !== "vercel-sandbox")
|
|
55
|
+
throw new Error("a run across runner sandboxes uses the Vercel Sandbox runner");
|
|
56
|
+
const policy = runner.options.sandboxes;
|
|
57
|
+
if (policy === undefined)
|
|
58
|
+
return refused(sandboxesErrors.missingSandboxesMax({ flag: asked.flag, key: SANDBOXES_MAX_KEY, configFile }));
|
|
59
|
+
if (asked.count > policy.max)
|
|
60
|
+
return refused(sandboxesErrors.sandboxesOverMax({
|
|
61
|
+
flag: asked.flag,
|
|
62
|
+
sandboxes: asked.count,
|
|
63
|
+
key: SANDBOXES_MAX_KEY,
|
|
64
|
+
max: policy.max,
|
|
65
|
+
configFile,
|
|
66
|
+
}));
|
|
67
|
+
return { ok: true, runner, max: policy.max };
|
|
68
|
+
}
|
|
69
|
+
export async function planRun(app, request, target, signal) {
|
|
70
|
+
const lifecycles = DEFINITION_SET.lifecycles(app.resourceContexts);
|
|
71
|
+
const given = resourceFlagValues(request);
|
|
33
72
|
const file = request.settingsFile;
|
|
34
73
|
const configFile = file.path;
|
|
35
74
|
const settings = fileSettings(file, request);
|
|
@@ -45,60 +84,73 @@ export async function planRun(app, lifecycles, request, planCommand, signal) {
|
|
|
45
84
|
configFile,
|
|
46
85
|
}));
|
|
47
86
|
}
|
|
48
|
-
let
|
|
87
|
+
let plannedRunner;
|
|
49
88
|
if (runner.kind === "launch-machine")
|
|
50
|
-
|
|
89
|
+
plannedRunner = { kind: "launch-machine" };
|
|
51
90
|
else {
|
|
52
91
|
// Only a config file declares `vercelSandbox({ … })`, so a run with this runner has one.
|
|
53
92
|
if (configFile === null)
|
|
54
93
|
throw new Error("planRun: the Vercel Sandbox runner comes from a config file");
|
|
55
|
-
const
|
|
56
|
-
if (!
|
|
57
|
-
return
|
|
58
|
-
|
|
59
|
-
|
|
94
|
+
const chosen = settleCredential(request.credential ?? "mint", settings.scope, settings.project);
|
|
95
|
+
if (!chosen.ok)
|
|
96
|
+
return chosen;
|
|
97
|
+
if (chosen.credential.source === "github-actions")
|
|
98
|
+
throw new Error("planRun: --credential github-actions should have been refused for vercel-sandbox");
|
|
99
|
+
const targetConfig = givenTarget(settings.scope, settings.project);
|
|
100
|
+
const { options } = runner;
|
|
101
|
+
const credentials = await readCredentials(options, app.env, app.context);
|
|
60
102
|
if (!credentials.ok)
|
|
61
103
|
return refused(runErrors.credentialsInvalid({
|
|
62
|
-
|
|
104
|
+
problems: credentials.problems.map(({ name, problem, detail, hint }) => ({ name, problem, detail, hint })),
|
|
63
105
|
minLength: SECRET_MIN_LENGTH,
|
|
64
106
|
configFile,
|
|
65
107
|
}));
|
|
66
108
|
const keepFlagMinutes = request.keepSandbox === undefined ? 0 : (parseKeepTime(request.keepSandbox) ?? 0);
|
|
67
|
-
if (
|
|
109
|
+
if (options.unsafeSecretEnvVars.length > 0 && keepFlagMinutes > 0)
|
|
68
110
|
return refused(runErrors.keepSandboxUnsafeSecretEnvVars({
|
|
69
|
-
variables:
|
|
111
|
+
variables: options.unsafeSecretEnvVars.map(({ name }) => name),
|
|
70
112
|
configFile,
|
|
71
113
|
}));
|
|
72
|
-
|
|
114
|
+
if (options.managedCredentials.length > 0 && keepFlagMinutes > 0)
|
|
115
|
+
return refused(runErrors.keepSandboxManagedCredentials({
|
|
116
|
+
providers: [...options.managedCredentials],
|
|
117
|
+
configFile,
|
|
118
|
+
}));
|
|
119
|
+
const unsafeSecretEnvVars = readUnsafeSecretEnvVars(options, app.env);
|
|
73
120
|
if (!unsafeSecretEnvVars.ok)
|
|
74
121
|
return refused(runErrors.unsafeSecretEnvVarsInvalid({
|
|
75
122
|
variables: unsafeSecretEnvVars.variables.map(({ name, problem }) => ({ name, problem })),
|
|
76
123
|
minLength: SECRET_MIN_LENGTH,
|
|
77
124
|
configFile,
|
|
78
125
|
}));
|
|
79
|
-
|
|
80
|
-
kind: "
|
|
126
|
+
plannedRunner = {
|
|
127
|
+
kind: "vercel-sandbox",
|
|
81
128
|
configFile,
|
|
82
|
-
|
|
83
|
-
|
|
129
|
+
options,
|
|
130
|
+
credential: chosen.credential,
|
|
131
|
+
target: targetConfig,
|
|
84
132
|
credentials: credentials.credentials,
|
|
85
133
|
unsafeSecretEnvVars: unsafeSecretEnvVars.values,
|
|
86
|
-
secrets: [...credentials.
|
|
134
|
+
secrets: [...credentials.secrets, ...Object.values(unsafeSecretEnvVars.values)],
|
|
87
135
|
};
|
|
88
136
|
}
|
|
89
137
|
// A required option nothing gives is missing whatever the count says, so it refuses before the count. The merged
|
|
90
|
-
// options name each resource's secrets, which a refusal from
|
|
138
|
+
// options name each resource's secrets, which a refusal from target planning hides, even when the checks across a
|
|
91
139
|
// resource's options would refuse it later.
|
|
92
|
-
const merged = settleRunResources(file,
|
|
140
|
+
const merged = settleRunResources(file, given);
|
|
93
141
|
if (!merged.ok)
|
|
94
142
|
return merged;
|
|
95
|
-
const command = await
|
|
143
|
+
const command = await planTarget(app, request, target, plannedRunner, settings.testPlan?.value === true, configFile, signal);
|
|
96
144
|
if (signal.aborted)
|
|
97
145
|
return refused(canceledBeforeStart());
|
|
98
146
|
if (!command.ok) {
|
|
99
|
-
// A refusal can quote what planning ran with this machine's environment, such as the last line of
|
|
100
|
-
// stderr, which a resource's token can reach. `secrets` is pure, so this calls no `beforeRun`, which may
|
|
101
|
-
|
|
147
|
+
// A refusal can quote what planning ran with this machine's environment, such as the last line of a driver's
|
|
148
|
+
// listing stderr, which a resource's token can reach. `secrets` is pure, so this calls no `beforeRun`, which may
|
|
149
|
+
// do I/O.
|
|
150
|
+
const secrets = [
|
|
151
|
+
...(plannedRunner.kind === "vercel-sandbox" ? plannedRunner.secrets : []),
|
|
152
|
+
...lifecycles.secrets(merged.options),
|
|
153
|
+
];
|
|
102
154
|
return refused(secrets.length === 0 ? command.refusal : redactStrings(command.refusal, redactor(secrets)));
|
|
103
155
|
}
|
|
104
156
|
const run = Object.freeze({
|
|
@@ -108,58 +160,155 @@ export async function planRun(app, lifecycles, request, planCommand, signal) {
|
|
|
108
160
|
const resolved = merged.plan(run);
|
|
109
161
|
if (!resolved.ok)
|
|
110
162
|
return resolved;
|
|
111
|
-
|
|
112
|
-
|
|
163
|
+
if (command.sandboxes?.count.from === "default" && request.showOutput) {
|
|
164
|
+
return refused(sandboxesDefaultErrors.sandboxesDefaultRefused({
|
|
165
|
+
key: SANDBOXES_DEFAULT_KEY,
|
|
166
|
+
sandboxes: command.sandboxes.sandboxes.length,
|
|
167
|
+
field: "showOutput",
|
|
168
|
+
problem: `a run across runner sandboxes ${SHOW_OUTPUT_ACROSS_SANDBOXES_DETAIL}`,
|
|
169
|
+
configFile,
|
|
170
|
+
}));
|
|
171
|
+
}
|
|
172
|
+
const basePlan = {
|
|
113
173
|
configFile,
|
|
114
174
|
settings,
|
|
115
|
-
where,
|
|
116
175
|
argv: command.argv,
|
|
117
176
|
testPlan: command.testPlan,
|
|
118
177
|
testFiles: command.testFiles,
|
|
119
|
-
sandboxes: command.sandboxes,
|
|
120
178
|
resources: resolved.resources,
|
|
121
179
|
planOptions: resolved.planned.map(planOption),
|
|
122
180
|
};
|
|
181
|
+
const planned = command.sandboxes === undefined
|
|
182
|
+
? { ...basePlan, runner: plannedRunner, sandboxes: undefined }
|
|
183
|
+
: { ...basePlan, runner: command.runner, sandboxes: command.sandboxes };
|
|
184
|
+
return { ok: true, planned, lifecycles };
|
|
123
185
|
}
|
|
124
|
-
/**
|
|
125
|
-
function
|
|
126
|
-
|
|
186
|
+
/** Counts a driver target with file list support and guarantees `testFiles` is present. */
|
|
187
|
+
async function planDriverFiles(app, target, runner, signal) {
|
|
188
|
+
const { driver, args, countTests, errors } = target;
|
|
189
|
+
const planned = await planDriverCommand(app, driver, errors, args, { countTests: driver.countsFilesOnly !== true || countTests }, runner, signal);
|
|
190
|
+
if (!planned.ok)
|
|
191
|
+
return planned;
|
|
192
|
+
const { argv, testPlan, testFiles } = planned;
|
|
193
|
+
if (testFiles === undefined) {
|
|
194
|
+
throw new Error(`planRun: driver ${driver.name} has file list support, and its plan step answered no test files`);
|
|
195
|
+
}
|
|
196
|
+
return { ok: true, argv, testPlan, testFiles };
|
|
127
197
|
}
|
|
128
|
-
/**
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
where = plan.where;
|
|
149
|
-
else if (used.needsVercelCredential) {
|
|
150
|
-
const chosen = settleCredential(request.credential ?? "mint", settings.scope, settings.project);
|
|
151
|
-
if (!chosen.ok)
|
|
152
|
-
return chosen;
|
|
153
|
-
where = { kind: "unsandboxed", credential: chosen.credential };
|
|
198
|
+
/** Plans the command or driver target, including `--sandboxes`, `--file-lists`, and `runner.sandboxes.default`. */
|
|
199
|
+
async function planTarget(app, request, target, runner, testPlanSetting, configFile, signal) {
|
|
200
|
+
if (target.kind === "exec") {
|
|
201
|
+
const { command } = target;
|
|
202
|
+
if (request.sandboxes === undefined) {
|
|
203
|
+
return { ok: true, argv: command, testPlan: NOT_COUNTED.testPlan, runner };
|
|
204
|
+
}
|
|
205
|
+
const checked = checkSandboxesMax(runner, { count: request.sandboxes, flag: "--sandboxes" }, configFile);
|
|
206
|
+
if (!checked.ok)
|
|
207
|
+
return checked;
|
|
208
|
+
return {
|
|
209
|
+
ok: true,
|
|
210
|
+
argv: command,
|
|
211
|
+
testPlan: NOT_COUNTED.testPlan,
|
|
212
|
+
runner: checked.runner,
|
|
213
|
+
sandboxes: {
|
|
214
|
+
count: { count: request.sandboxes, from: "flag", max: checked.max },
|
|
215
|
+
sandboxes: commandsForSandboxes(command, request.sandboxes).map((argv) => ({ argv, files: null })),
|
|
216
|
+
},
|
|
217
|
+
};
|
|
154
218
|
}
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
219
|
+
const { driver, args, countTests, errors } = target;
|
|
220
|
+
let lists;
|
|
221
|
+
if (request.fileLists !== undefined) {
|
|
222
|
+
const read = await readFileListsFile(app.context.fileListsFiles, {
|
|
223
|
+
path: request.fileLists,
|
|
224
|
+
cwd: app.cwd,
|
|
225
|
+
sandboxes: request.sandboxes,
|
|
226
|
+
});
|
|
227
|
+
if (!read.ok) {
|
|
228
|
+
return refused(read.kind === "unreadable"
|
|
229
|
+
? fileListErrors.fileListsUnreadable({ path: read.path, problem: read.problem, message: read.message })
|
|
230
|
+
: fileListErrors.invalidFileLists({
|
|
231
|
+
path: read.path,
|
|
232
|
+
problems: read.problems.map((problem) => problem.kind === "in-two-lists" ? { ...problem, sandboxes: [...problem.sandboxes] } : { ...problem }),
|
|
233
|
+
}));
|
|
234
|
+
}
|
|
235
|
+
lists = read.lists;
|
|
236
|
+
}
|
|
237
|
+
const asked = lists !== undefined
|
|
238
|
+
? { count: lists.lists.length, flag: "--file-lists" }
|
|
239
|
+
: request.sandboxes === undefined
|
|
240
|
+
? undefined
|
|
241
|
+
: { count: request.sandboxes, flag: "--sandboxes" };
|
|
242
|
+
if (asked !== undefined) {
|
|
243
|
+
const checked = checkSandboxesMax(runner, asked, configFile);
|
|
244
|
+
if (!checked.ok)
|
|
245
|
+
return checked;
|
|
246
|
+
const planned = await planDriverFiles(app, target, checked.runner, signal);
|
|
247
|
+
if (!planned.ok)
|
|
248
|
+
return planned;
|
|
249
|
+
const { argv, testPlan, testFiles } = planned;
|
|
250
|
+
if (lists === undefined) {
|
|
251
|
+
return {
|
|
252
|
+
ok: true,
|
|
253
|
+
argv,
|
|
254
|
+
testPlan,
|
|
255
|
+
testFiles,
|
|
256
|
+
runner: checked.runner,
|
|
257
|
+
sandboxes: driverSandboxesRun({
|
|
258
|
+
argv,
|
|
259
|
+
testFiles,
|
|
260
|
+
asked: { from: "flag", count: asked.count },
|
|
261
|
+
max: checked.max,
|
|
262
|
+
}),
|
|
263
|
+
};
|
|
264
|
+
}
|
|
265
|
+
const resolved = driverCallerFileListsRun({ argv, testFiles, lists, max: checked.max });
|
|
266
|
+
if (!resolved.ok) {
|
|
267
|
+
return refused(fileListErrors.fileListsUnlisted({
|
|
268
|
+
path: lists.path,
|
|
269
|
+
files: [...resolved.unlisted],
|
|
270
|
+
listed: resolved.listed,
|
|
271
|
+
}));
|
|
272
|
+
}
|
|
273
|
+
return { ok: true, argv, testPlan, testFiles, runner: checked.runner, sandboxes: resolved.sandboxes };
|
|
274
|
+
}
|
|
275
|
+
const policy = runner.kind === "vercel-sandbox" ? runner.options.sandboxes : undefined;
|
|
276
|
+
if (driver.fileLists !== undefined && runner.kind === "vercel-sandbox" && policy?.default !== undefined) {
|
|
277
|
+
const planned = await planDriverFiles(app, target, runner, signal);
|
|
278
|
+
if (!planned.ok)
|
|
279
|
+
return planned;
|
|
280
|
+
const { argv, testPlan, testFiles } = planned;
|
|
281
|
+
const resolved = resolveSandboxCountDefault(policy.default, testPlan);
|
|
282
|
+
const checked = checkDriverFileLists(driver, args);
|
|
283
|
+
if (!checked.ok) {
|
|
284
|
+
return refused(sandboxesDefaultErrors.sandboxesDefaultRefused({
|
|
285
|
+
key: SANDBOXES_DEFAULT_KEY,
|
|
286
|
+
sandboxes: Math.min(resolved, policy.max, testFiles.length),
|
|
287
|
+
field: "args",
|
|
288
|
+
problem: checked.problem,
|
|
289
|
+
configFile,
|
|
290
|
+
}));
|
|
291
|
+
}
|
|
292
|
+
return {
|
|
293
|
+
ok: true,
|
|
294
|
+
argv,
|
|
295
|
+
testPlan,
|
|
296
|
+
testFiles,
|
|
297
|
+
runner,
|
|
298
|
+
sandboxes: driverSandboxesRun({
|
|
299
|
+
argv,
|
|
300
|
+
testFiles,
|
|
301
|
+
asked: { from: "default", default: resolved },
|
|
302
|
+
max: policy.max,
|
|
303
|
+
}),
|
|
304
|
+
};
|
|
305
|
+
}
|
|
306
|
+
const single = await planDriverCommand(app, driver, errors, args, driverCount(driver, testPlanSetting, countTests), runner, signal);
|
|
307
|
+
if (!single.ok)
|
|
308
|
+
return single;
|
|
309
|
+
return { ...single, runner };
|
|
158
310
|
}
|
|
159
|
-
/**
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
*/
|
|
163
|
-
export function canceledBeforeStart() {
|
|
164
|
-
return outcomes.canceled({ changed: "The command didn't run.\nNothing was minted, acquired or started." });
|
|
311
|
+
/** A planned option as the run's plan names it. */
|
|
312
|
+
function planOption({ path, value, source }) {
|
|
313
|
+
return { path, value, from: source };
|
|
165
314
|
}
|