@cnc-tools/storm 0.15.0 → 0.16.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 +1 -1
- package/dist/build-info.js +1 -1
- package/dist/chunks/{chunk-QUHY6FGN.js → chunk-2MAD5NKK.js} +1 -1
- package/dist/chunks/{chunk-XEVHP5ZW.js → chunk-3L52KNQA.js} +1 -1
- package/dist/chunks/{chunk-E4PJNZVG.js → chunk-7EENF73W.js} +12 -13
- package/dist/chunks/{chunk-4U4DZ7VG.js → chunk-CK2GZEPK.js} +1 -1
- package/dist/chunks/{chunk-L36GBUBB.js → chunk-DC2CDHNK.js} +398 -158
- package/dist/chunks/{chunk-PN5ULTTH.js → chunk-DWEAHX4T.js} +1 -1
- package/dist/chunks/{chunk-5GBMR4HM.js → chunk-FCQUJDA4.js} +4 -7
- package/dist/chunks/{chunk-YV7GE6EV.js → chunk-FOZWA52V.js} +1 -1
- package/dist/chunks/{chunk-OX7X4B2L.js → chunk-G3PHMXH5.js} +1 -1
- package/dist/chunks/{chunk-CXAT7ZKP.js → chunk-HVNK3I45.js} +1 -1
- package/dist/chunks/{chunk-QVS7HRU7.js → chunk-OIY3DMF2.js} +2 -2
- package/dist/chunks/{chunk-SZEURWRS.js → chunk-P357TZAY.js} +2 -2
- package/dist/chunks/{chunk-KC4KDJ5K.js → chunk-V4IKA3WI.js} +153 -139
- package/dist/chunks/{chunk-RAQEXKL6.js → chunk-Z5PBVG3Y.js} +26 -18
- package/dist/chunks/{live-app-PI3BAN6Y.js → live-app-WECQOQ4C.js} +4 -4
- package/dist/commands/exec/across-sandboxes-outcomes.js +2 -1
- package/dist/commands/exec/command.d.ts +8 -2
- package/dist/commands/exec/command.js +11 -11
- package/dist/commands/exec/metadata.js +1 -1
- package/dist/commands/exec/outcomes.d.ts +4 -1
- package/dist/commands/exec/outcomes.js +2 -2
- package/dist/commands/exec/plan-only.js +1 -2
- package/dist/commands/exec/planned-outcome.js +8 -1
- package/dist/commands/exec/run-command.d.ts +6 -7
- package/dist/commands/exec/run-command.js +8 -9
- package/dist/commands/exec/run-metadata.js +1 -1
- package/dist/commands/runs/facts.d.ts +2 -1
- package/dist/commands/runs/facts.js +11 -3
- package/dist/commands/runs/list/command.d.ts +2 -0
- package/dist/commands/runs/list/command.js +6 -6
- package/dist/commands/runs/list/outcomes.d.ts +1 -0
- package/dist/commands/runs/logs/command.d.ts +6 -2
- package/dist/commands/runs/logs/command.js +6 -6
- package/dist/commands/runs/logs/outcomes.d.ts +3 -1
- package/dist/commands/runs/past-run.d.ts +14 -5
- package/dist/commands/runs/past-run.js +16 -5
- package/dist/commands/runs/show/command.d.ts +6 -2
- package/dist/commands/runs/show/command.js +9 -9
- package/dist/commands/runs/show/outcomes.d.ts +3 -1
- package/dist/commands/snapshots/build/command.js +11 -11
- package/dist/commands/snapshots/list/command.d.ts +3 -3
- package/dist/commands/snapshots/list/command.js +6 -6
- package/dist/commands/snapshots/list/metadata.js +1 -1
- package/dist/commands/suites/list/command.js +7 -6
- package/dist/commands/suites/list/outcomes.js +2 -2
- package/dist/commands/test/command.d.ts +8 -2
- package/dist/commands/test/command.js +38 -40
- package/dist/commands/test/metadata.js +1 -1
- package/dist/commands/test/outcomes.d.ts +4 -1
- package/dist/commands/test/outcomes.js +2 -2
- package/dist/commands/test/plan.d.ts +2 -2
- package/dist/commands/test/plan.js +2 -5
- package/dist/config/check-runner.d.ts +4 -2
- package/dist/config/check-runner.js +27 -2
- package/dist/config/check-suites.js +1 -0
- package/dist/config/gateways.d.ts +7 -3
- package/dist/config/index.d.ts +2 -3
- package/dist/config/index.js +2 -3
- package/dist/config/live/config-gateway.js +5 -2
- package/dist/config/load.d.ts +21 -4
- package/dist/config/load.js +129 -15
- package/dist/config/runner.d.ts +5 -6
- package/dist/config/runner.js +1 -1
- package/dist/config/schema.d.ts +15 -3
- package/dist/config/schema.js +10 -2
- package/dist/config/typed-options.d.ts +1 -6
- package/dist/config/typed-options.js +2 -10
- package/dist/config-file/define.d.ts +1 -11
- package/dist/config-file/define.js +3 -3
- package/dist/config-file/runner.d.ts +2 -3
- package/dist/config-file/toolchain.d.ts +13 -7
- package/dist/config-file/toolchain.js +51 -35
- package/dist/extensions/github/resource.d.ts +1 -1
- package/dist/extensions/github/resource.js +1 -1
- package/dist/extensions/testserver/commands/pool/create/command.js +1 -1
- package/dist/extensions/testserver/resource.d.ts +2 -2
- package/dist/extensions/testserver/resource.js +2 -2
- package/dist/planning/plan-only.d.ts +4 -1
- package/dist/planning/plan-only.js +5 -2
- package/dist/planning/run-plan.d.ts +1 -2
- package/dist/planning/test-plan.js +1 -2
- package/dist/runner/base.d.ts +0 -6
- package/dist/runner/base.js +0 -15
- package/dist/runner/build-snapshots.js +7 -8
- package/dist/runner/gateways.d.ts +5 -0
- package/dist/runner/index.d.ts +1 -1
- package/dist/runner/live/sandbox-gateway.js +12 -0
- package/dist/runner/prepare.d.ts +16 -15
- package/dist/runner/prepare.js +11 -12
- package/dist/runner/recipe.d.ts +66 -67
- package/dist/runner/recipe.js +204 -120
- package/dist/runner/snapshot-build.d.ts +1 -1
- package/dist/runner/snapshot-build.js +10 -3
- package/dist/runner/snapshot-inspect.d.ts +4 -4
- package/dist/runner/snapshot-inspect.js +7 -7
- package/dist/runner/snapshot-key.d.ts +23 -15
- package/dist/runner/snapshot-key.js +46 -27
- package/dist/sdk/extension/resource-definition.d.ts +3 -2
- package/dist/sdk/extension/resource-definition.js +3 -2
- package/dist/sdk/extension/resource-factory.js +3 -4
- package/dist/sdk/run/present.d.ts +3 -3
- package/dist/sdk/run/present.js +1 -3
- package/package.json +1 -1
- package/skills/overview.md +2 -0
- package/skills/plan-runs.md +1 -1
- package/dist/config/recipe-run.d.ts +0 -33
- package/dist/config/recipe-run.js +0 -28
package/dist/config/index.d.ts
CHANGED
|
@@ -4,11 +4,10 @@ export { configErrors, configProblemLine, optionProblemLine } from "./errors.ts"
|
|
|
4
4
|
export type { ConfigGateway, ConfigImport, ConfigLocation, FileListsFileGateway, FileListsFileRead, } from "./gateways.ts";
|
|
5
5
|
export { liveConfigGateway } from "./live/config-gateway.ts";
|
|
6
6
|
export { liveFileListsFileGateway } from "./live/file-lists-file-gateway.ts";
|
|
7
|
-
export { type ConfigProblem, type ConfigValues, findConfigFile, type LoadedConfig, loadConfig } from "./load.ts";
|
|
8
|
-
export { type RecipeResource, type RecipeRun, recipeRun } from "./recipe-run.ts";
|
|
7
|
+
export { type ConfigFileLookup, type ConfigProblem, type ConfigValues, findConfigFile, type LoadedConfig, loadConfig, } from "./load.ts";
|
|
9
8
|
export { type MergedResourceOptions, type MergedRunResources, mergeRunResources, mergeResourceOptions, type PlannedOption, type ResolvedResourceOptions, type ResolvedResourceRecord, type ResolvedSettings, resolveSettings, type ResourceFlagOptions, type ResourceOptionProblem, type ResourceRecord, type SettingFlags, } from "./resolve.ts";
|
|
10
9
|
export type { CheckedRunner, LaunchMachineRunner, RunnerConfig, RunnerKind, SuiteRunnerConfig, VercelSandboxRunner, } from "./runner.ts";
|
|
11
|
-
export { type CheckedSettings, checkWith, CONFIG_FILE_NAME, CONFIG_SETTING_KEYS, type ConfigKey, type ConfigSettingKey, type ConfigSettings, type SettingValue, } from "./schema.ts";
|
|
10
|
+
export { type CheckedSettings, checkWith, CONFIG_FILE_NAME, CONFIG_FILE_NAMES, CONFIG_FILE_NAMES_TEXT, CONFIG_SETTING_KEYS, type ConfigFileName, type ConfigKey, type ConfigSettingKey, type ConfigSettings, type SettingValue, } from "./schema.ts";
|
|
12
11
|
export { type ConfigLoadError, type ConfigResolver, configResolver, type LoadedResourceSettings, type StormConfigResolver, type TargetSettings, } from "./resolver.ts";
|
|
13
12
|
export { effectiveConfig, fileOptions, fileSettings, invalidConfig, invalidResourceOptions, loadSettingsFile, type SettingsFile, settleRunResources, } from "./settings-file.ts";
|
|
14
13
|
export { type CheckedSuite, type CheckedSuiteMap, SUITE_NAME_PATTERN, type SuiteConfig, type SuiteConfigMap, } from "./suite.ts";
|
package/dist/config/index.js
CHANGED
|
@@ -10,10 +10,9 @@ export { credentialErrors, requireTarget, settleCredential } from "./credential-
|
|
|
10
10
|
export { configErrors, configProblemLine, optionProblemLine } from "./errors.js";
|
|
11
11
|
export { liveConfigGateway } from "./live/config-gateway.js";
|
|
12
12
|
export { liveFileListsFileGateway } from "./live/file-lists-file-gateway.js";
|
|
13
|
-
export { findConfigFile, loadConfig } from "./load.js";
|
|
14
|
-
export { recipeRun } from "./recipe-run.js";
|
|
13
|
+
export { findConfigFile, loadConfig, } from "./load.js";
|
|
15
14
|
export { mergeRunResources, mergeResourceOptions, resolveSettings, } from "./resolve.js";
|
|
16
|
-
export { checkWith, CONFIG_FILE_NAME, CONFIG_SETTING_KEYS, } from "./schema.js";
|
|
15
|
+
export { checkWith, CONFIG_FILE_NAME, CONFIG_FILE_NAMES, CONFIG_FILE_NAMES_TEXT, CONFIG_SETTING_KEYS, } from "./schema.js";
|
|
17
16
|
export { configResolver, } from "./resolver.js";
|
|
18
17
|
export { effectiveConfig, fileOptions, fileSettings, invalidConfig, invalidResourceOptions, loadSettingsFile, settleRunResources, } from "./settings-file.js";
|
|
19
18
|
export { SUITE_NAME_PATTERN, } from "./suite.js";
|
|
@@ -9,14 +9,17 @@ var __rewriteRelativeImportExtension = (this && this.__rewriteRelativeImportExte
|
|
|
9
9
|
import { stat } from "node:fs/promises";
|
|
10
10
|
import { basename, join } from "node:path";
|
|
11
11
|
import { pathToFileURL } from "node:url";
|
|
12
|
-
import {
|
|
12
|
+
import { CONFIG_FILE_NAMES } from "../schema.js";
|
|
13
13
|
/**
|
|
14
14
|
* The live config gateway: `stat` for the config file and `.git`, and a plain `import()`, so Node's own type
|
|
15
15
|
* stripping loads the file. Node caches a module by its URL, so a process imports each config file once.
|
|
16
16
|
*/
|
|
17
17
|
export function liveConfigGateway() {
|
|
18
18
|
return {
|
|
19
|
-
|
|
19
|
+
configFileNames: async (directory) => {
|
|
20
|
+
const kinds = await Promise.all(CONFIG_FILE_NAMES.map((name) => kind(join(directory, name))));
|
|
21
|
+
return CONFIG_FILE_NAMES.filter((_, index) => kinds[index] === "file");
|
|
22
|
+
},
|
|
20
23
|
isWorktreeRoot: async (directory) => (await kind(join(directory, ".git"))) !== undefined,
|
|
21
24
|
importConfig: async (path) => {
|
|
22
25
|
try {
|
package/dist/config/load.d.ts
CHANGED
|
@@ -42,11 +42,28 @@ export type LoadedConfig = {
|
|
|
42
42
|
readonly problems: readonly ConfigProblem[];
|
|
43
43
|
};
|
|
44
44
|
/**
|
|
45
|
-
*
|
|
46
|
-
*
|
|
47
|
-
*
|
|
45
|
+
* What `findConfigFile` found:
|
|
46
|
+
*
|
|
47
|
+
* - `none`: no directory it looked in holds a config file.
|
|
48
|
+
* - `found`: the config file at `path`.
|
|
49
|
+
* - `conflict`: the nearest directory holding a config file holds more than one, at `paths`, in `CONFIG_FILE_NAMES`
|
|
50
|
+
* order. storm picks none of them.
|
|
51
|
+
*/
|
|
52
|
+
export type ConfigFileLookup = {
|
|
53
|
+
readonly kind: "none";
|
|
54
|
+
} | {
|
|
55
|
+
readonly kind: "found";
|
|
56
|
+
readonly path: string;
|
|
57
|
+
} | {
|
|
58
|
+
readonly kind: "conflict";
|
|
59
|
+
readonly paths: readonly [string, string, ...string[]];
|
|
60
|
+
};
|
|
61
|
+
/**
|
|
62
|
+
* Finds the config file for `startDirectory` (absolute): `storm.config.ts` or `storm.config.mts` in it, then in each
|
|
63
|
+
* parent up to the git worktree's root, the first directory holding `.git`; outside a git worktree, only in
|
|
64
|
+
* `startDirectory`. The nearest directory holding one wins, and it must hold only one.
|
|
48
65
|
*/
|
|
49
|
-
export declare function findConfigFile(gateway: ConfigGateway, startDirectory: string): Promise<
|
|
66
|
+
export declare function findConfigFile(gateway: ConfigGateway, startDirectory: string): Promise<ConfigFileLookup>;
|
|
50
67
|
/**
|
|
51
68
|
* Finds and imports the config file for `startDirectory` (see `findConfigFile`), and checks all of it, whatever
|
|
52
69
|
* command reads it. The file must default-export an object holding only known keys, each top-level setting by its
|
package/dist/config/load.js
CHANGED
|
@@ -1,26 +1,37 @@
|
|
|
1
|
-
import { dirname, join } from "node:path";
|
|
1
|
+
import { basename, dirname, join } from "node:path";
|
|
2
2
|
import { describeValue } from "../sdk/extension/index.js";
|
|
3
3
|
import { checkResources } from "./check-resources.js";
|
|
4
4
|
import { rawVercelSandboxOptions } from "./check-runner.js";
|
|
5
5
|
import { checkSuites } from "./check-suites.js";
|
|
6
|
-
import {
|
|
6
|
+
import { checkSettingValue, isConfigSettingKey, } from "./schema.js";
|
|
7
7
|
/**
|
|
8
|
-
* Finds the config file for `startDirectory` (absolute): `storm.config.ts` in it, then in each
|
|
9
|
-
* git worktree's root, the first directory holding `.git`; outside a git worktree, only in
|
|
10
|
-
*
|
|
8
|
+
* Finds the config file for `startDirectory` (absolute): `storm.config.ts` or `storm.config.mts` in it, then in each
|
|
9
|
+
* parent up to the git worktree's root, the first directory holding `.git`; outside a git worktree, only in
|
|
10
|
+
* `startDirectory`. The nearest directory holding one wins, and it must hold only one.
|
|
11
11
|
*/
|
|
12
12
|
export async function findConfigFile(gateway, startDirectory) {
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
const here = await lookIn(gateway, startDirectory);
|
|
14
|
+
if (here !== undefined)
|
|
15
|
+
return here;
|
|
15
16
|
const root = await worktreeRoot(gateway, startDirectory);
|
|
16
17
|
if (root === undefined)
|
|
17
|
-
return
|
|
18
|
+
return { kind: "none" };
|
|
18
19
|
for (let directory = startDirectory; directory !== root;) {
|
|
19
20
|
directory = dirname(directory);
|
|
20
|
-
|
|
21
|
-
|
|
21
|
+
const found = await lookIn(gateway, directory);
|
|
22
|
+
if (found !== undefined)
|
|
23
|
+
return found;
|
|
22
24
|
}
|
|
23
|
-
return
|
|
25
|
+
return { kind: "none" };
|
|
26
|
+
}
|
|
27
|
+
/** What `directory` holds: one config file, a conflict, or nothing (undefined). */
|
|
28
|
+
async function lookIn(gateway, directory) {
|
|
29
|
+
const [first, second, ...rest] = (await gateway.configFileNames(directory)).map((name) => join(directory, name));
|
|
30
|
+
if (first === undefined)
|
|
31
|
+
return undefined;
|
|
32
|
+
if (second === undefined)
|
|
33
|
+
return { kind: "found", path: first };
|
|
34
|
+
return { kind: "conflict", paths: [first, second, ...rest] };
|
|
24
35
|
}
|
|
25
36
|
/** The nearest directory at or above `directory` holding `.git`, if any. */
|
|
26
37
|
async function worktreeRoot(gateway, directory) {
|
|
@@ -40,9 +51,21 @@ async function worktreeRoot(gateway, directory) {
|
|
|
40
51
|
* merge with the flags (`mergeRunResources`) and its plan.
|
|
41
52
|
*/
|
|
42
53
|
export async function loadConfig(gateway, startDirectory, definitions, drivers) {
|
|
43
|
-
const
|
|
44
|
-
if (
|
|
54
|
+
const found = await findConfigFile(gateway, startDirectory);
|
|
55
|
+
if (found.kind === "none")
|
|
45
56
|
return { kind: "none" };
|
|
57
|
+
if (found.kind === "conflict") {
|
|
58
|
+
const [path, ...others] = found.paths;
|
|
59
|
+
const names = others.map((other) => basename(other)).join(" and ");
|
|
60
|
+
return {
|
|
61
|
+
kind: "invalid",
|
|
62
|
+
path,
|
|
63
|
+
problems: [
|
|
64
|
+
fileProblem(`is in the same directory as ${names}, so storm can't tell which config file applies; keep one of them`),
|
|
65
|
+
],
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
const { path } = found;
|
|
46
69
|
const imported = await gateway.importConfig(path);
|
|
47
70
|
switch (imported.kind) {
|
|
48
71
|
case "import-failed":
|
|
@@ -73,7 +96,7 @@ function checkFile(path, value, definitions, drivers) {
|
|
|
73
96
|
let resources = {};
|
|
74
97
|
let rawSuites;
|
|
75
98
|
let hasSuitesKey = false;
|
|
76
|
-
const settingContext = { drivers };
|
|
99
|
+
const settingContext = { definitions, drivers };
|
|
77
100
|
const hasTopLevelDriver = value["driver"] !== undefined;
|
|
78
101
|
for (const [key, keyValue] of Object.entries(value)) {
|
|
79
102
|
if (key === "resources")
|
|
@@ -87,7 +110,7 @@ function checkFile(path, value, definitions, drivers) {
|
|
|
87
110
|
checkSetting(key, keyValue, settings, settingContext, problems);
|
|
88
111
|
}
|
|
89
112
|
else
|
|
90
|
-
problems.push({ key, location: null, problem: `is not a ${
|
|
113
|
+
problems.push({ key, location: null, problem: `is not a ${basename(path)} key` });
|
|
91
114
|
}
|
|
92
115
|
if (settings.args !== undefined && !hasTopLevelDriver) {
|
|
93
116
|
problems.push({ key: "args", location: null, problem: "requires a top-level driver" });
|
|
@@ -100,10 +123,101 @@ function checkFile(path, value, definitions, drivers) {
|
|
|
100
123
|
topLevelRunnerOptions: rawVercelSandboxOptions(value["runner"]),
|
|
101
124
|
}, problems)
|
|
102
125
|
: {};
|
|
126
|
+
checkPlainData(value, problems);
|
|
103
127
|
if (problems.length > 0)
|
|
104
128
|
return { kind: "invalid", path, problems };
|
|
105
129
|
return { kind: "loaded", path, values: { settings, resources, suites } };
|
|
106
130
|
}
|
|
131
|
+
/**
|
|
132
|
+
* Refuses any value JSON cannot hold anywhere in the loaded config object: functions, symbols, bigints, non-finite
|
|
133
|
+
* numbers (`NaN`, `Infinity`), `undefined` array elements, non-plain objects (such as `Date`, `RegExp`, `Map`, `Set`,
|
|
134
|
+
* or class instances), and circular references. Paths already reported by schema checks (such as a function at
|
|
135
|
+
* `runner.vcpus`, whose schema check names the declared form) are not duplicated.
|
|
136
|
+
*/
|
|
137
|
+
function checkPlainData(root, problems) {
|
|
138
|
+
const reported = new Set(problems.map(({ key }) => key).filter((key) => key !== null));
|
|
139
|
+
const visiting = new Set();
|
|
140
|
+
const addProblem = (path, problem) => {
|
|
141
|
+
const key = path.join(".");
|
|
142
|
+
if (reported.has(key))
|
|
143
|
+
return;
|
|
144
|
+
reported.add(key);
|
|
145
|
+
problems.push({ key: key.length === 0 ? null : key, location: null, problem });
|
|
146
|
+
};
|
|
147
|
+
const visit = (current, path) => {
|
|
148
|
+
if (current === null || typeof current === "string" || typeof current === "boolean")
|
|
149
|
+
return;
|
|
150
|
+
if (current === undefined) {
|
|
151
|
+
addProblem(path, "must be plain data (JSON cannot hold undefined in an array)");
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
154
|
+
if (typeof current === "number") {
|
|
155
|
+
if (!Number.isFinite(current))
|
|
156
|
+
addProblem(path, `must be plain data (JSON cannot hold ${String(current)})`);
|
|
157
|
+
return;
|
|
158
|
+
}
|
|
159
|
+
if (typeof current === "function") {
|
|
160
|
+
addProblem(path, "must be plain data (JSON cannot hold a function)");
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
163
|
+
if (typeof current === "symbol") {
|
|
164
|
+
addProblem(path, "must be plain data (JSON cannot hold a symbol)");
|
|
165
|
+
return;
|
|
166
|
+
}
|
|
167
|
+
if (typeof current === "bigint") {
|
|
168
|
+
addProblem(path, "must be plain data (JSON cannot hold a bigint)");
|
|
169
|
+
return;
|
|
170
|
+
}
|
|
171
|
+
if (typeof current !== "object")
|
|
172
|
+
return;
|
|
173
|
+
if (visiting.has(current)) {
|
|
174
|
+
addProblem(path, "must be plain data (circular reference)");
|
|
175
|
+
return;
|
|
176
|
+
}
|
|
177
|
+
if (Array.isArray(current)) {
|
|
178
|
+
visiting.add(current);
|
|
179
|
+
for (let index = 0; index < current.length; index += 1)
|
|
180
|
+
visit(current[index], [...path, String(index)]);
|
|
181
|
+
visiting.delete(current);
|
|
182
|
+
return;
|
|
183
|
+
}
|
|
184
|
+
const proto = Object.getPrototypeOf(current);
|
|
185
|
+
if (proto !== Object.prototype && proto !== null) {
|
|
186
|
+
addProblem(path, `must be plain data (expected a plain object, not ${describeNonPlainObject(proto)})`);
|
|
187
|
+
return;
|
|
188
|
+
}
|
|
189
|
+
visiting.add(current);
|
|
190
|
+
const isRunnerWrapper = (path.length === 1 && path[0] === "runner") ||
|
|
191
|
+
(path.length === 3 && path[0] === "suites" && path[2] === "runner");
|
|
192
|
+
const unwrapRunnerOptions = isRunnerWrapper && current["kind"] === "vercel-sandbox";
|
|
193
|
+
const isResourceWrapper = (path.length === 2 && path[0] === "resources") ||
|
|
194
|
+
(path.length === 4 && path[0] === "suites" && path[2] === "resources");
|
|
195
|
+
const unwrapResourceOptions = isResourceWrapper && typeof current["name"] === "string";
|
|
196
|
+
for (const [key, entry] of Object.entries(current)) {
|
|
197
|
+
if (entry === undefined)
|
|
198
|
+
continue;
|
|
199
|
+
if ((unwrapRunnerOptions || unwrapResourceOptions) && key === "options" && isPlainObject(entry)) {
|
|
200
|
+
visit(entry, path);
|
|
201
|
+
continue;
|
|
202
|
+
}
|
|
203
|
+
visit(entry, [...path, key]);
|
|
204
|
+
}
|
|
205
|
+
visiting.delete(current);
|
|
206
|
+
};
|
|
207
|
+
visit(root, []);
|
|
208
|
+
}
|
|
209
|
+
function isPlainObject(value) {
|
|
210
|
+
if (typeof value !== "object" || value === null || Array.isArray(value))
|
|
211
|
+
return false;
|
|
212
|
+
const proto = Object.getPrototypeOf(value);
|
|
213
|
+
return proto === Object.prototype || proto === null;
|
|
214
|
+
}
|
|
215
|
+
function describeNonPlainObject(proto) {
|
|
216
|
+
const ctor = typeof proto === "object" && proto !== null ? proto.constructor : undefined;
|
|
217
|
+
if (typeof ctor === "function" && ctor.name.length > 0 && ctor.name !== "Object")
|
|
218
|
+
return ctor.name;
|
|
219
|
+
return "a non-plain object";
|
|
220
|
+
}
|
|
107
221
|
/** Checks one top-level setting, putting its value in `settings` or each thing wrong with it onto `problems`. */
|
|
108
222
|
function checkSetting(key, value, settings, context, problems) {
|
|
109
223
|
const checked = checkSettingValue(key, value, context);
|
package/dist/config/runner.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type { CheckedRecipe, RunnerRecipe } from "../runner/recipe.ts";
|
|
2
|
-
import type { RecipeRun } from "./recipe-run.ts";
|
|
3
2
|
/** One runner kind storm supports. */
|
|
4
3
|
export type RunnerKind = "launch-machine" | "vercel-sandbox";
|
|
5
4
|
/** The launch machine runner value, made by `launchMachine()`. */
|
|
@@ -7,18 +6,18 @@ export interface LaunchMachineRunner {
|
|
|
7
6
|
readonly kind: "launch-machine";
|
|
8
7
|
}
|
|
9
8
|
/** The Vercel Sandbox runner value, made by `vercelSandbox(options)`. */
|
|
10
|
-
export interface VercelSandboxRunner<TOptions = RunnerRecipe
|
|
9
|
+
export interface VercelSandboxRunner<TOptions = RunnerRecipe> {
|
|
11
10
|
readonly kind: "vercel-sandbox";
|
|
12
11
|
readonly options: TOptions;
|
|
13
12
|
}
|
|
14
13
|
/** A top-level `runner` value in `storm.config.ts`: complete Vercel Sandbox options, or the launch machine. */
|
|
15
|
-
export type RunnerConfig
|
|
14
|
+
export type RunnerConfig = LaunchMachineRunner | VercelSandboxRunner;
|
|
16
15
|
/** A suite's `runner` value in `storm.config.ts`: complete or partial Vercel Sandbox options, or the launch machine. */
|
|
17
|
-
export type SuiteRunnerConfig
|
|
16
|
+
export type SuiteRunnerConfig = LaunchMachineRunner | VercelSandboxRunner<Partial<RunnerRecipe>>;
|
|
18
17
|
/** A checked `runner` value after loading `storm.config.ts`, with defaults filled in on a Vercel Sandbox recipe. */
|
|
19
|
-
export type CheckedRunner
|
|
18
|
+
export type CheckedRunner = {
|
|
20
19
|
readonly kind: "launch-machine";
|
|
21
20
|
} | {
|
|
22
21
|
readonly kind: "vercel-sandbox";
|
|
23
|
-
readonly recipe: CheckedRecipe
|
|
22
|
+
readonly recipe: CheckedRecipe;
|
|
24
23
|
};
|
package/dist/config/runner.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
// The declared `runner` value in `storm.config.ts` and its checked form: two peer runner kinds, the launch machine
|
|
2
2
|
// (`launchMachine()`) and Vercel Sandbox (`vercelSandbox(options)`). Type-only so `@vercel/storm/config`'s
|
|
3
|
-
// declarations reach only `runner/recipe.ts
|
|
3
|
+
// declarations reach only `runner/recipe.ts`, never Clinkr or zod.
|
|
4
4
|
export {};
|
package/dist/config/schema.d.ts
CHANGED
|
@@ -1,7 +1,18 @@
|
|
|
1
1
|
import type { z } from "zod";
|
|
2
2
|
import type { CheckedRunner, RunnerConfig } from "./runner.ts";
|
|
3
|
-
|
|
3
|
+
import { type ResourceDefinition } from "../sdk/extension/index.ts";
|
|
4
|
+
/** The config file's usual name, which storm's text names it by. */
|
|
4
5
|
export declare const CONFIG_FILE_NAME = "storm.config.ts";
|
|
6
|
+
/**
|
|
7
|
+
* Each name a config file may have, in the working directory or a parent. `storm.config.mts` is always an ES module,
|
|
8
|
+
* so Node loads it without the `MODULE_TYPELESS_PACKAGE_JSON` warning in a package with no `"type": "module"`, where
|
|
9
|
+
* `storm.config.ts` is first parsed as CommonJS. One directory may hold only one of them.
|
|
10
|
+
*/
|
|
11
|
+
export declare const CONFIG_FILE_NAMES: readonly ["storm.config.ts", "storm.config.mts"];
|
|
12
|
+
/** One of `CONFIG_FILE_NAMES`. */
|
|
13
|
+
export type ConfigFileName = (typeof CONFIG_FILE_NAMES)[number];
|
|
14
|
+
/** The config file names as text says them: `storm.config.ts or storm.config.mts`. */
|
|
15
|
+
export declare const CONFIG_FILE_NAMES_TEXT: string;
|
|
5
16
|
/**
|
|
6
17
|
* The settings a `storm.config.ts` can give at its top level, as the file gives them. A flag (`--scope` or
|
|
7
18
|
* `--project`) overrides the file; none has a built-in default here. `@vercel/storm/config`'s `StormConfig` adds
|
|
@@ -18,7 +29,7 @@ export interface ConfigSettings {
|
|
|
18
29
|
readonly args?: readonly string[];
|
|
19
30
|
/**
|
|
20
31
|
* Where the command runs, made by `launchMachine()` or `vercelSandbox({ … })`. For `vercelSandbox`, its `vcpus` may
|
|
21
|
-
* be a
|
|
32
|
+
* be a positive whole number or a declared resource-scaling rule (`RunnerVcpuRule`).
|
|
22
33
|
*/
|
|
23
34
|
readonly runner?: RunnerConfig;
|
|
24
35
|
/**
|
|
@@ -61,8 +72,9 @@ export type Checked<T> = {
|
|
|
61
72
|
};
|
|
62
73
|
/** `value` checked by `schema`: its output, or each issue as a problem at the issue's path inside the value. */
|
|
63
74
|
export declare function checkWith<T>(schema: z.ZodType<T>, value: unknown): Checked<T>;
|
|
64
|
-
/** What setting rules need beside the value itself: the registered driver names and any top-level `vercelSandbox` options. */
|
|
75
|
+
/** What setting rules need beside the value itself: the resource definitions, registered driver names, and any top-level `vercelSandbox` options. */
|
|
65
76
|
export interface SettingCheckContext {
|
|
77
|
+
readonly definitions: readonly ResourceDefinition[];
|
|
66
78
|
readonly drivers: readonly string[];
|
|
67
79
|
/** Raw options from a top-level `vercelSandbox(...)`, for a suite's `vercelSandbox(...)` to merge over. */
|
|
68
80
|
readonly topLevelRunnerOptions?: Readonly<Record<string, unknown>> | undefined;
|
package/dist/config/schema.js
CHANGED
|
@@ -4,8 +4,16 @@
|
|
|
4
4
|
// vocabulary every rule shares: `Checked`, `ValueProblem`, `checkWith`, and how a problem names a value.
|
|
5
5
|
import { checkRunner } from "./check-runner.js";
|
|
6
6
|
import { booleanOption, describeValue, nonEmptyString } from "../sdk/extension/index.js";
|
|
7
|
-
/** The config file's name
|
|
7
|
+
/** The config file's usual name, which storm's text names it by. */
|
|
8
8
|
export const CONFIG_FILE_NAME = "storm.config.ts";
|
|
9
|
+
/**
|
|
10
|
+
* Each name a config file may have, in the working directory or a parent. `storm.config.mts` is always an ES module,
|
|
11
|
+
* so Node loads it without the `MODULE_TYPELESS_PACKAGE_JSON` warning in a package with no `"type": "module"`, where
|
|
12
|
+
* `storm.config.ts` is first parsed as CommonJS. One directory may hold only one of them.
|
|
13
|
+
*/
|
|
14
|
+
export const CONFIG_FILE_NAMES = [CONFIG_FILE_NAME, "storm.config.mts"];
|
|
15
|
+
/** The config file names as text says them: `storm.config.ts or storm.config.mts`. */
|
|
16
|
+
export const CONFIG_FILE_NAMES_TEXT = CONFIG_FILE_NAMES.join(" or ");
|
|
9
17
|
/** `value` checked by `schema`: its output, or each issue as a problem at the issue's path inside the value. */
|
|
10
18
|
export function checkWith(schema, value) {
|
|
11
19
|
const parsed = schema.safeParse(value);
|
|
@@ -47,7 +55,7 @@ const SETTING_CHECKS = {
|
|
|
47
55
|
project: (value) => checkWith(nonEmptyString, value),
|
|
48
56
|
driver: (value, { drivers }) => checkDriver(value, drivers),
|
|
49
57
|
args: checkStringList,
|
|
50
|
-
runner: (value, { topLevelRunnerOptions }) => checkRunner(value, topLevelRunnerOptions),
|
|
58
|
+
runner: (value, { topLevelRunnerOptions, definitions }) => checkRunner(value, topLevelRunnerOptions, definitions),
|
|
51
59
|
testPlan: (value) => checkWith(booleanOption, value),
|
|
52
60
|
};
|
|
53
61
|
/** Every top-level setting, in the order a config file's problems list them. */
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ResourceDefinition, GivenOptions,
|
|
1
|
+
import type { ResourceDefinition, GivenOptions, Setting, SettingsOf } from "../sdk/extension/index.ts";
|
|
2
2
|
/**
|
|
3
3
|
* One resource's given options as `GivenOptions<D>`. Sound because every key is one of `definition.options` and every value
|
|
4
4
|
* passed that option's schema.
|
|
@@ -14,8 +14,3 @@ export declare function givenOptionsOf<D extends ResourceDefinition>(_definition
|
|
|
14
14
|
export declare function settingsOf<D extends ResourceDefinition>(_definition: D, settings: {
|
|
15
15
|
readonly [option: string]: Setting<unknown>;
|
|
16
16
|
}): SettingsOf<D>;
|
|
17
|
-
/**
|
|
18
|
-
* One resource's options, of definition `D`, as `OptionsOf<D>`. Sound because the caller checked that
|
|
19
|
-
* the resource's record names `D`, and the run has each resource's options merged and checked by its definition.
|
|
20
|
-
*/
|
|
21
|
-
export declare function resourceOptionsOf<D extends ResourceDefinition>(_definition: D, value: object): OptionsOf<D>;
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
// The casts in the config module that type one resource's options as its definition's. The config module builds a
|
|
2
2
|
// resource's options as a record by option name, from a loop over its definition's options or over what the file or
|
|
3
3
|
// the flags give. TypeScript widens such a record to `Record<string, …>` and can't relate it to the mapped type over
|
|
4
|
-
// one definition's options (`GivenOptions`, `SettingsOf
|
|
5
|
-
//
|
|
6
|
-
// call site.
|
|
4
|
+
// one definition's options (`GivenOptions`, `SettingsOf`), which the config resolver's `load<D>` takes. Each function
|
|
5
|
+
// below states that fact once, for every call site.
|
|
7
6
|
/**
|
|
8
7
|
* One resource's given options as `GivenOptions<D>`. Sound because every key is one of `definition.options` and every value
|
|
9
8
|
* passed that option's schema.
|
|
@@ -19,10 +18,3 @@ export function givenOptionsOf(_definition, values) {
|
|
|
19
18
|
export function settingsOf(_definition, settings) {
|
|
20
19
|
return settings;
|
|
21
20
|
}
|
|
22
|
-
/**
|
|
23
|
-
* One resource's options, of definition `D`, as `OptionsOf<D>`. Sound because the caller checked that
|
|
24
|
-
* the resource's record names `D`, and the run has each resource's options merged and checked by its definition.
|
|
25
|
-
*/
|
|
26
|
-
export function resourceOptionsOf(_definition, value) {
|
|
27
|
-
return value;
|
|
28
|
-
}
|
|
@@ -1,24 +1,14 @@
|
|
|
1
|
-
import type { RecipeRun } from "../config/recipe-run.ts";
|
|
2
1
|
import type { SuiteRunnerConfig } from "../config/runner.ts";
|
|
3
2
|
import type { ConfigSettings } from "../config/schema.ts";
|
|
4
3
|
import type { SuiteConfig, SuiteConfigMap } from "../config/suite.ts";
|
|
5
|
-
import type { RunnerRecipe as RunnerRecipeOf } from "../runner/recipe.ts";
|
|
6
4
|
import type { Resource } from "../sdk/extension/resource-definition.ts";
|
|
7
5
|
export { launchMachine, vercelSandbox } from "./runner.ts";
|
|
8
6
|
export { pnpmToolchains } from "./toolchain.ts";
|
|
9
|
-
export type { RecipeRun } from "../config/recipe-run.ts";
|
|
10
7
|
export type { LaunchMachineRunner, RunnerConfig, RunnerKind, SuiteRunnerConfig, VercelSandboxRunner, } from "../config/runner.ts";
|
|
11
8
|
export type { SuiteConfig, SuiteConfigMap } from "../config/suite.ts";
|
|
12
|
-
export type { CredentialDeclaration,
|
|
13
|
-
export type { RunTestPlan } from "../sdk/extension/resource-definition.ts";
|
|
9
|
+
export type { CredentialDeclaration, RunnerRecipe, RunnerSandboxCount, RunnerStep, RunnerVcpuCount, RunnerVcpuRule, SandboxCountDefault, SandboxCountDefaultRule, ToolchainStep, UnsafeSecretEnvVar, } from "../runner/recipe.ts";
|
|
14
10
|
export type { Resource } from "../sdk/extension/resource-definition.ts";
|
|
15
11
|
export type { SecretSource } from "../sdk/extension/secret-source.ts";
|
|
16
|
-
export type { Present } from "../sdk/run/launcher.ts";
|
|
17
|
-
/**
|
|
18
|
-
* The runner recipe passed to `vercelSandbox(options)`: its `vcpus` may be a function of the run (`RecipeRun`), which
|
|
19
|
-
* reads a resource by its resource factory, `run.get(<name>)`, as a `Present` of its options.
|
|
20
|
-
*/
|
|
21
|
-
export type RunnerRecipe = RunnerRecipeOf<RecipeRun>;
|
|
22
12
|
/**
|
|
23
13
|
* What a `storm.config.ts` can give: the top-level settings (the project's tests), a run's resources, and named
|
|
24
14
|
* variations under `suites`. A flag (`--scope`, `--project`, or a resource's own flag) overrides the file, and the
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
// The config file's published surface, `@vercel/storm/config`. A user's `storm.config.ts` imports it, so it
|
|
2
2
|
// imports nothing at run time outside `src/config-file/` (`runner.ts` and `toolchain.ts`, which import nothing
|
|
3
3
|
// either): loading it pulls in no Clinkr, zod, or CLI code. Everything it takes from the modules, the top-level
|
|
4
|
-
// settings, the runner value types, the suite types, the runner recipe's types, the
|
|
5
|
-
//
|
|
6
|
-
//
|
|
4
|
+
// settings, the runner value types, the suite types, the runner recipe's types, and the resource's type, is a
|
|
5
|
+
// type-only import, erased at run time. A resource comes from its resource factory, which the config file imports from
|
|
6
|
+
// the resource's own export, `@vercel/storm/<resource>`.
|
|
7
7
|
//
|
|
8
8
|
// Its declarations ship too, and storm bundles Clinkr, so a consumer has no Clinkr to resolve them against. Each type
|
|
9
9
|
// comes from the file that declares it, not its module's `index.ts`, whose declarations reach Clinkr:
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { RecipeRun } from "../config/recipe-run.ts";
|
|
2
1
|
import type { LaunchMachineRunner, VercelSandboxRunner } from "../config/runner.ts";
|
|
3
2
|
import type { RunnerRecipe } from "../runner/recipe.ts";
|
|
4
3
|
/** Declares the launch machine runner: runs the command on the launch machine as it is, with no isolation. */
|
|
@@ -8,5 +7,5 @@ export declare function launchMachine(): LaunchMachineRunner;
|
|
|
8
7
|
* complete runner recipe; in a suite under `suites`, `options` may override only the top-level recipe keys that
|
|
9
8
|
* differ.
|
|
10
9
|
*/
|
|
11
|
-
export declare function vercelSandbox(options: RunnerRecipe
|
|
12
|
-
export declare function vercelSandbox(options: Partial<RunnerRecipe
|
|
10
|
+
export declare function vercelSandbox(options: RunnerRecipe): VercelSandboxRunner;
|
|
11
|
+
export declare function vercelSandbox(options: Partial<RunnerRecipe>): VercelSandboxRunner<Partial<RunnerRecipe>>;
|
|
@@ -1,9 +1,15 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ToolchainStep } from "../runner/recipe.ts";
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* `snapshot.toolchains`. It rejects when `packageManager` isn't `pnpm@<x.y.z>` or `engines.node` isn't `>=<x.y.z>`,
|
|
7
|
-
* which keeps a cached runner snapshot at that base from being used.
|
|
3
|
+
* Node program run inside `pnpmToolchains` to read `packageManager` and `engines.node` from the staged `package.json`
|
|
4
|
+
* and print `<nodeMin> <pnpmVersion>`. Exported from this file (not `@vercel/storm/config`) so tests can run it
|
|
5
|
+
* directly without slicing the shell script.
|
|
8
6
|
*/
|
|
9
|
-
export declare
|
|
7
|
+
export declare const PNPM_TOOLCHAINS_MANIFEST_SCRIPT: string;
|
|
8
|
+
/**
|
|
9
|
+
* Plain-data toolchain step for a pnpm workspace whose root `package.json` declares `packageManager` (`pnpm@<x.y.z>`)
|
|
10
|
+
* and `engines.node` (`>=<x.y.z>`). storm stages `package.json` into `/vercel/sandbox/package.json` before toolchain
|
|
11
|
+
* steps run, and the script puts `git` on `PATH`, downloads Node into `~/.local/bin` when the runtime's Node is older
|
|
12
|
+
* than `engines.node`, and installs the `packageManager` pnpm through corepack. Give it as `snapshot.toolchains`, or
|
|
13
|
+
* spread it alongside other toolchain steps (`[...pnpmToolchains, ...]`).
|
|
14
|
+
*/
|
|
15
|
+
export declare const pnpmToolchains: readonly ToolchainStep[];
|
|
@@ -1,41 +1,57 @@
|
|
|
1
1
|
// The toolchain steps a pnpm workspace's runner recipe can use, exported from `@vercel/storm/config`. Like
|
|
2
2
|
// `define.ts`, it imports nothing at run time, so a config file that uses it loads no Clinkr, zod or CLI code.
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
* `snapshot.toolchains`. It rejects when `packageManager` isn't `pnpm@<x.y.z>` or `engines.node` isn't `>=<x.y.z>`,
|
|
8
|
-
* which keeps a cached runner snapshot at that base from being used.
|
|
4
|
+
* Node program run inside `pnpmToolchains` to read `packageManager` and `engines.node` from the staged `package.json`
|
|
5
|
+
* and print `<nodeMin> <pnpmVersion>`. Exported from this file (not `@vercel/storm/config`) so tests can run it
|
|
6
|
+
* directly without slicing the shell script.
|
|
9
7
|
*/
|
|
10
|
-
export
|
|
11
|
-
|
|
12
|
-
|
|
8
|
+
export const PNPM_TOOLCHAINS_MANIFEST_SCRIPT = String.raw `
|
|
9
|
+
const fs = require("node:fs");
|
|
10
|
+
const manifest = JSON.parse(fs.readFileSync("package.json", "utf8"));
|
|
11
|
+
const fields = typeof manifest === "object" && manifest !== null ? manifest : {};
|
|
12
|
+
const packageManager = fields.packageManager;
|
|
13
|
+
const pnpm = typeof packageManager === "string" ? /^pnpm@(\d+\.\d+\.\d+)/.exec(packageManager)?.[1] : undefined;
|
|
14
|
+
if (pnpm === undefined) {
|
|
15
|
+
console.error("package.json's packageManager isn't a pnpm version: " + String(packageManager));
|
|
16
|
+
process.exit(1);
|
|
13
17
|
}
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
throw new Error(`package.json's packageManager isn't a pnpm version: ${String(packageManager)}`);
|
|
20
|
-
const engine = typeof engines === "object" && engines !== null ? engines["node"] : undefined;
|
|
21
|
-
const node = typeof engine === "string" ? /^>=\s*(\d+\.\d+\.\d+)$/.exec(engine)?.[1] : undefined;
|
|
22
|
-
if (node === undefined)
|
|
23
|
-
throw new Error("package.json's engines.node isn't a >= minimum");
|
|
24
|
-
return [
|
|
25
|
-
"set -euo pipefail",
|
|
26
|
-
'mkdir -p "$HOME/.local/bin"',
|
|
27
|
-
"command -v git >/dev/null || sudo dnf install -y -q git",
|
|
28
|
-
"git --version",
|
|
29
|
-
`if ! node -e 'const [a, b, c] = process.versions.node.split(".").map(Number); const [x, y, z] = "${node}".split(".").map(Number); process.exit(a !== x ? (a > x ? 0 : 1) : b !== y ? (b > y ? 0 : 1) : c >= z ? 0 : 1)'; then`,
|
|
30
|
-
' case "$(uname -m)" in aarch64) arch=arm64 ;; *) arch=x64 ;; esac',
|
|
31
|
-
` curl -fsSL "https://nodejs.org/dist/v${node}/node-v${node}-linux-$arch.tar.gz" | tar -xz -C "$HOME/.local"`,
|
|
32
|
-
` ln -sf "$HOME/.local/node-v${node}-linux-$arch/bin/"* "$HOME/.local/bin/"`,
|
|
33
|
-
"fi",
|
|
34
|
-
"hash -r",
|
|
35
|
-
"node --version",
|
|
36
|
-
'corepack enable --install-directory "$HOME/.local/bin" pnpm',
|
|
37
|
-
`corepack install -g pnpm@${pnpm}`,
|
|
38
|
-
"hash -r",
|
|
39
|
-
"pnpm --version",
|
|
40
|
-
].join("\n");
|
|
18
|
+
const engine = typeof fields.engines === "object" && fields.engines !== null ? fields.engines.node : undefined;
|
|
19
|
+
const node = typeof engine === "string" ? /^>=\s*(\d+\.\d+\.\d+)$/.exec(engine)?.[1] : undefined;
|
|
20
|
+
if (node === undefined) {
|
|
21
|
+
console.error("package.json's engines.node isn't a >= minimum");
|
|
22
|
+
process.exit(1);
|
|
41
23
|
}
|
|
24
|
+
process.stdout.write(node + " " + pnpm + "\n");
|
|
25
|
+
`.trim();
|
|
26
|
+
/**
|
|
27
|
+
* Plain-data toolchain step for a pnpm workspace whose root `package.json` declares `packageManager` (`pnpm@<x.y.z>`)
|
|
28
|
+
* and `engines.node` (`>=<x.y.z>`). storm stages `package.json` into `/vercel/sandbox/package.json` before toolchain
|
|
29
|
+
* steps run, and the script puts `git` on `PATH`, downloads Node into `~/.local/bin` when the runtime's Node is older
|
|
30
|
+
* than `engines.node`, and installs the `packageManager` pnpm through corepack. Give it as `snapshot.toolchains`, or
|
|
31
|
+
* spread it alongside other toolchain steps (`[...pnpmToolchains, ...]`).
|
|
32
|
+
*/
|
|
33
|
+
export const pnpmToolchains = [
|
|
34
|
+
{
|
|
35
|
+
label: "Installing the toolchains",
|
|
36
|
+
baseFiles: ["package.json"],
|
|
37
|
+
script: [
|
|
38
|
+
"set -euo pipefail",
|
|
39
|
+
'mkdir -p "$HOME/.local/bin"',
|
|
40
|
+
"command -v git >/dev/null || sudo dnf install -y -q git",
|
|
41
|
+
"git --version",
|
|
42
|
+
`STORM_TOOLCHAINS="$(node - <<'STORM_MANIFEST_EOF'\n${PNPM_TOOLCHAINS_MANIFEST_SCRIPT}\nSTORM_MANIFEST_EOF\n)"`,
|
|
43
|
+
'read -r STORM_NODE_MIN STORM_PNPM_VERSION <<< "$STORM_TOOLCHAINS"',
|
|
44
|
+
`if ! node -e 'const [a, b, c] = process.versions.node.split(".").map(Number); const [x, y, z] = process.argv[1].split(".").map(Number); process.exit(a !== x ? (a > x ? 0 : 1) : b !== y ? (b > y ? 0 : 1) : c >= z ? 0 : 1)' "$STORM_NODE_MIN"; then`,
|
|
45
|
+
' case "$(uname -m)" in aarch64) arch=arm64 ;; *) arch=x64 ;; esac',
|
|
46
|
+
' curl -fsSL "https://nodejs.org/dist/v${STORM_NODE_MIN}/node-v${STORM_NODE_MIN}-linux-$arch.tar.gz" | tar -xz -C "$HOME/.local"',
|
|
47
|
+
' ln -sf "$HOME/.local/node-v${STORM_NODE_MIN}-linux-$arch/bin/"* "$HOME/.local/bin/"',
|
|
48
|
+
"fi",
|
|
49
|
+
"hash -r",
|
|
50
|
+
"node --version",
|
|
51
|
+
'corepack enable --install-directory "$HOME/.local/bin" pnpm',
|
|
52
|
+
'corepack install -g "pnpm@${STORM_PNPM_VERSION}"',
|
|
53
|
+
"hash -r",
|
|
54
|
+
"pnpm --version",
|
|
55
|
+
].join("\n"),
|
|
56
|
+
},
|
|
57
|
+
];
|
|
@@ -22,7 +22,7 @@ export type { SecretSource } from "../../sdk/extension/index.ts";
|
|
|
22
22
|
* uses it. Once the command has stopped, the run deletes every branch under the run prefix. With `optional: true`, or
|
|
23
23
|
* `storm exec`'s and `storm test`'s `--github-optional`, a run without the token goes on without the repository. A
|
|
24
24
|
* command reads the repository with `readRunPayload().get(githubFixtureRepoPayload)`, from
|
|
25
|
-
* `@vercel/storm/github/payload
|
|
25
|
+
* `@vercel/storm/github/payload`.
|
|
26
26
|
*/
|
|
27
27
|
export declare const githubFixtureRepo: import("../../sdk/extension/resource-factory.ts").ResourceFactory<import("../../sdk/extension/resource-definition.ts").ResourceDefinition<"githubFixtureRepo", {
|
|
28
28
|
readonly repo: {
|
|
@@ -24,6 +24,6 @@ import { githubFixtureRepoDefinition } from "./definition.js";
|
|
|
24
24
|
* uses it. Once the command has stopped, the run deletes every branch under the run prefix. With `optional: true`, or
|
|
25
25
|
* `storm exec`'s and `storm test`'s `--github-optional`, a run without the token goes on without the repository. A
|
|
26
26
|
* command reads the repository with `readRunPayload().get(githubFixtureRepoPayload)`, from
|
|
27
|
-
* `@vercel/storm/github/payload
|
|
27
|
+
* `@vercel/storm/github/payload`.
|
|
28
28
|
*/
|
|
29
29
|
export const githubFixtureRepo = resourceFactory(githubFixtureRepoDefinition);
|