sedum-cli 0.1.0-alpha.18 → 0.1.0-alpha.21
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/README.md +65 -0
- package/dist/{affected-selection-DAQPGKOZ.js → affected-selection-NTBVWIK5.js} +10 -50
- package/dist/auth-command-TSTYIWGX.js +634 -0
- package/dist/chunk-CGDXQY2Y.js +208 -0
- package/dist/{chunk-SI2F6MBN.js → chunk-DXNJ3PGB.js} +44 -18
- package/dist/{chunk-FG46OUHT.js → chunk-FOGLJA3Z.js} +4 -2
- package/dist/{chunk-KZF4NZ6M.js → chunk-J7CLCLHW.js} +267 -354
- package/dist/chunk-JYWNBHN7.js +109 -0
- package/dist/chunk-NIUOM3FA.js +50 -0
- package/dist/{chunk-EPXLY5Q4.js → chunk-PX6PJ7U2.js} +291 -174
- package/dist/{chunk-6ILFLNDI.js → chunk-QVCT63FH.js} +1 -1
- package/dist/cli.js +10 -3
- package/dist/cloud-command-YYQ47FTU.js +329 -0
- package/dist/cloud-upload-IGNNU5WX.js +243 -0
- package/dist/{doctor-command-7IBKI5YO.js → doctor-command-OFMURNPN.js} +5 -2
- package/dist/{explore-command-QZCKFDYM.js → explore-command-KMS6UAPM.js} +3 -2
- package/dist/index.d.ts +21 -0
- package/dist/index.js +5 -3
- package/dist/{init-command-MBTLGU5J.js → init-command-IXR3YUQW.js} +3 -2
- package/dist/{run-command-P55TKTX3.js → run-command-6UTIJAHU.js} +39 -22
- package/package.json +6 -5
|
@@ -1,10 +1,13 @@
|
|
|
1
|
+
import {
|
|
2
|
+
AuthError
|
|
3
|
+
} from "./chunk-JYWNBHN7.js";
|
|
1
4
|
import {
|
|
2
5
|
collectText,
|
|
3
6
|
exploreMode,
|
|
4
7
|
seedValue,
|
|
5
8
|
startUrl,
|
|
6
9
|
watchOrigin
|
|
7
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-FOGLJA3Z.js";
|
|
8
11
|
import {
|
|
9
12
|
MAX_PARALLEL,
|
|
10
13
|
clearLocatorCache,
|
|
@@ -14,13 +17,15 @@ import {
|
|
|
14
17
|
createCliProvider
|
|
15
18
|
} from "./chunk-N5CTUO2A.js";
|
|
16
19
|
import {
|
|
17
|
-
ProjectConfigError,
|
|
18
20
|
configDiagnostic,
|
|
21
|
+
renderDiagnostic
|
|
22
|
+
} from "./chunk-CGDXQY2Y.js";
|
|
23
|
+
import {
|
|
24
|
+
ProjectConfigError,
|
|
19
25
|
discoverConfiguredTests,
|
|
20
26
|
loadProjectConfig,
|
|
21
|
-
renderDiagnostic,
|
|
22
27
|
validAffectedGlob
|
|
23
|
-
} from "./chunk-
|
|
28
|
+
} from "./chunk-J7CLCLHW.js";
|
|
24
29
|
|
|
25
30
|
// src/invocation.ts
|
|
26
31
|
function sedumCommand(env = process.env, script = process.argv[1] ?? "") {
|
|
@@ -28,7 +33,7 @@ function sedumCommand(env = process.env, script = process.argv[1] ?? "") {
|
|
|
28
33
|
return "npx sedum";
|
|
29
34
|
return /[\\/]node_modules[\\/]/.test(script) ? "npx sedum" : "sedum";
|
|
30
35
|
}
|
|
31
|
-
var SUBCOMMAND = /(?<![\w./-]|npx )sedum (?=(?:run|browsers|doctor|validate|init|list)\b|--help\b|--version\b)/g;
|
|
36
|
+
var SUBCOMMAND = /(?<![\w./-]|npx )sedum (?=(?:run|runs|tests|browsers|doctor|validate|init|list|auth)\b|--help\b|--version\b)/g;
|
|
32
37
|
function withCommand(text, command) {
|
|
33
38
|
return command === "sedum" ? text : text.replace(SUBCOMMAND, `${command} `);
|
|
34
39
|
}
|
|
@@ -55,7 +60,7 @@ function listExitCode(listing, failedBeforeListing) {
|
|
|
55
60
|
}
|
|
56
61
|
|
|
57
62
|
// src/output.ts
|
|
58
|
-
import { validateRunResult as validateRunResult2 } from "@sedum-dev/core";
|
|
63
|
+
import { isBlocking, validateRunResult as validateRunResult2 } from "@sedum-dev/core";
|
|
59
64
|
import { testLabel, usageLines, visionSummary } from "@sedum-dev/reporters";
|
|
60
65
|
var ansi = {
|
|
61
66
|
green: "\x1B[32m",
|
|
@@ -202,9 +207,13 @@ function discoveryLine(problem) {
|
|
|
202
207
|
return `discovery ${problem.file}${location}: ${problem.message} Fix: ${problem.fix}`;
|
|
203
208
|
}
|
|
204
209
|
function testCountLine(value) {
|
|
205
|
-
const errored = value.tests.filter(
|
|
210
|
+
const errored = value.tests.filter(
|
|
211
|
+
(test) => isBlocking(test) && test.state === "error"
|
|
212
|
+
).length;
|
|
206
213
|
const errorCount = errored ? `, ${errored} could not run` : "";
|
|
207
|
-
|
|
214
|
+
const nonBlocking = value.totals.nonBlockingFailedTests;
|
|
215
|
+
const nonBlockingCount = nonBlocking === void 0 ? "" : `, ${nonBlocking} non-blocking failed`;
|
|
216
|
+
return `tests ${value.totals.selectedTests} selected, ${value.totals.executedTests} executed, ${value.totals.passedTests} passed, ${value.totals.failedTests} failed${errorCount}${nonBlockingCount}`;
|
|
208
217
|
}
|
|
209
218
|
function flagCountLine(value, counts) {
|
|
210
219
|
const flaky = value.tests.filter(
|
|
@@ -363,7 +372,7 @@ async function loadProjectContext(paths, cwd) {
|
|
|
363
372
|
}
|
|
364
373
|
function renderConfigErrors(errors, cwd) {
|
|
365
374
|
return errors.map((item) => {
|
|
366
|
-
const file = path.relative(cwd, item.file).split(path.sep).join("/");
|
|
375
|
+
const file = path.isAbsolute(item.file) ? path.relative(cwd, item.file).split(path.sep).join("/") : item.file;
|
|
367
376
|
return `${file}:${item.line}:${item.col}: error ${item.code}: ${item.message}
|
|
368
377
|
Fix: ${item.fix}
|
|
369
378
|
`;
|
|
@@ -856,25 +865,21 @@ async function runCli(args, version, runtime = {}) {
|
|
|
856
865
|
const writeOut = (value) => rawOut(withCommand(value, command));
|
|
857
866
|
const writeErr = (value) => rawErr(withCommand(value, command));
|
|
858
867
|
const capabilities = runtime.capabilities ?? plainOutput;
|
|
859
|
-
const executeRun = runtime.executeRun ?? (async (options) => (await import("./run-command-
|
|
868
|
+
const executeRun = runtime.executeRun ?? (async (options) => (await import("./run-command-6UTIJAHU.js")).executeRunCommand(options));
|
|
860
869
|
const cwd = runtime.cwd ?? process.cwd();
|
|
861
870
|
let exitCode = 3;
|
|
862
|
-
const program =
|
|
863
|
-
|
|
864
|
-
|
|
871
|
+
const program = createProgram(version, writeOut, writeErr);
|
|
872
|
+
await registerAccountCommands(program, runtime, {
|
|
873
|
+
rawOut,
|
|
865
874
|
writeOut,
|
|
866
875
|
writeErr,
|
|
867
|
-
|
|
868
|
-
})
|
|
869
|
-
"after",
|
|
870
|
-
"\nExamples:\n sedum init\n sedum run tests/login.test.yaml\n sedum validate\n sedum list --json\n sedum doctor --json\n sedum browsers install chromium\n\nExit codes:\n 0 passed\n 1 failed test (validate and list: invalid test files)\n 2 flagged pass with --strict\n 3 command or operational error\n"
|
|
871
|
-
);
|
|
872
|
-
program.action(() => commandHelp(program, writeErr));
|
|
876
|
+
setExitCode: (value) => exitCode = value
|
|
877
|
+
});
|
|
873
878
|
program.command("init").description("scaffold a runnable Sedum project in the current directory").addHelpText(
|
|
874
879
|
"after",
|
|
875
880
|
"\nCreates a config, a SauceDemo example, .env.example, and ignore rules.\nExisting files are never replaced.\n"
|
|
876
881
|
).action(async () => {
|
|
877
|
-
const { executeInitCommand } = await import("./init-command-
|
|
882
|
+
const { executeInitCommand } = await import("./init-command-IXR3YUQW.js");
|
|
878
883
|
const interactive = capabilities.stdoutIsTTY && (process.stdin.isTTY === true || runtime.confirmInit !== void 0);
|
|
879
884
|
const confirm = runtime.confirmInit ?? (interactive ? async (question) => {
|
|
880
885
|
const { createInterface } = await import("readline/promises");
|
|
@@ -900,113 +905,9 @@ async function runCli(args, version, runtime = {}) {
|
|
|
900
905
|
writeErr(result.stderr);
|
|
901
906
|
exitCode = result.exitCode;
|
|
902
907
|
});
|
|
903
|
-
|
|
904
|
-
"
|
|
905
|
-
|
|
906
|
-
).option(
|
|
907
|
-
"--affected",
|
|
908
|
-
"experimental: send Git diff and test sources to the text provider; run relevant tests",
|
|
909
|
-
false
|
|
910
|
-
).option("--base <ref>", "base ref for --affected (default main or master)").option(
|
|
911
|
-
"--affected-ignore <glob>",
|
|
912
|
-
"exclude matching repository-relative diff paths (repeatable)",
|
|
913
|
-
collectAffectedGlob,
|
|
914
|
-
[]
|
|
915
|
-
).option(
|
|
916
|
-
"--threshold <probability>",
|
|
917
|
-
"minimum relevance probability for --affected (default 0.3)",
|
|
918
|
-
relevanceThreshold
|
|
919
|
-
).option(
|
|
920
|
-
"--selection-only",
|
|
921
|
-
"with --affected, print selection JSON without running tests (calls the text provider)",
|
|
922
|
-
false
|
|
923
|
-
).option(
|
|
924
|
-
"--include <glob>",
|
|
925
|
-
"include matching project-relative paths (repeatable)",
|
|
926
|
-
collectGlob,
|
|
927
|
-
[]
|
|
928
|
-
).option(
|
|
929
|
-
"--exclude <glob>",
|
|
930
|
-
"exclude matching project-relative paths (repeatable)",
|
|
931
|
-
collectGlob,
|
|
932
|
-
[]
|
|
933
|
-
).option(
|
|
934
|
-
"--labels <tags>",
|
|
935
|
-
"require all comma-separated test tags (repeatable)",
|
|
936
|
-
collectLabels,
|
|
937
|
-
[]
|
|
938
|
-
).option(
|
|
939
|
-
"--name <text>",
|
|
940
|
-
"match id or description substring (repeatable)",
|
|
941
|
-
collectValue,
|
|
942
|
-
[]
|
|
943
|
-
).option(
|
|
944
|
-
"--id <id>",
|
|
945
|
-
"select a test by its exact id (repeatable)",
|
|
946
|
-
collectValue,
|
|
947
|
-
[]
|
|
948
|
-
).option("--env <name>", "select a named environment").option("--browser <kind>", "chrome or chromium").option("--vision", "enable vision fallback for ambiguous clicks").option("--no-vision", "disable vision fallback").option(
|
|
949
|
-
"--screenshots",
|
|
950
|
-
"send screenshots to TypeSafe to check targets and judge claims (default for the TypeSafe API)"
|
|
951
|
-
).option("--no-screenshots", "send page text only, never screenshots").option(
|
|
952
|
-
"--url-override <url>",
|
|
953
|
-
"replace entry URL origin for preview deployments"
|
|
954
|
-
).option("--output-dir <path>", "run output directory").option("--reporter-dir <path>", "reporter artifact directory").option("--headed", "show the browser", false).option(
|
|
955
|
-
"--slow <ms>",
|
|
956
|
-
"slow browser actions by milliseconds",
|
|
957
|
-
nonnegativeSlow
|
|
958
|
-
).option(
|
|
959
|
-
"--retries <count>",
|
|
960
|
-
"additional whole-test attempts",
|
|
961
|
-
nonnegativeInteger,
|
|
962
|
-
0
|
|
963
|
-
).option(
|
|
964
|
-
"--timeout-minutes <minutes>",
|
|
965
|
-
"whole-run deadline",
|
|
966
|
-
positiveMinutes
|
|
967
|
-
).option(
|
|
968
|
-
"--parallel <n|auto>",
|
|
969
|
-
"run tests in parallel lanes; auto uses half the CPU cores (default 1)",
|
|
970
|
-
parallelValue
|
|
971
|
-
).option(
|
|
972
|
-
"--shard-index <index>",
|
|
973
|
-
"run only this 1-based shard of the selection (with --shard-count)",
|
|
974
|
-
positiveCount(1e4)
|
|
975
|
-
).option(
|
|
976
|
-
"--shard-count <count>",
|
|
977
|
-
"split the selection into this many deterministic shards",
|
|
978
|
-
positiveCount(1e4)
|
|
979
|
-
).option(
|
|
980
|
-
"--provider-concurrency <n>",
|
|
981
|
-
"cap concurrent model-provider requests (default min(4, 2 x lanes))",
|
|
982
|
-
positiveCount(32)
|
|
983
|
-
).option("--replay", "capture replay frames for executed steps", false).option("--no-evidence", "disable non-passing evidence frames").option("--no-locator-cache", "disable the local locator cache").option("--locator-cache-ci", "enable the local locator cache in CI", false).option(
|
|
984
|
-
"--sensitive-origin <url>",
|
|
985
|
-
"omit sensitive page details and frames (repeatable)",
|
|
986
|
-
collectOrigin,
|
|
987
|
-
[]
|
|
988
|
-
).option(
|
|
989
|
-
"--detect <mode>",
|
|
990
|
-
"flag steps whose page reported console errors, uncaught exceptions, unhandled rejections, or HTTP errors: off, browser, or semantic (also asks Jev whether each new page looks broken)",
|
|
991
|
-
detectMode
|
|
992
|
-
).option(
|
|
993
|
-
"--detect-allow <rule>",
|
|
994
|
-
"ignore a known detector finding: [check:]substring or [check:]re:regex (repeatable)",
|
|
995
|
-
collectAllowRule,
|
|
996
|
-
[]
|
|
997
|
-
).option("--strict", "exit 2 when a passed run has uncertainty flags", false).option(
|
|
998
|
-
"--reporter <name>",
|
|
999
|
-
"reporter: list, steps, terminal, json, markdown, or junit (repeatable or comma-separated; default list)",
|
|
1000
|
-
collectReporter,
|
|
1001
|
-
[]
|
|
1002
|
-
).option(
|
|
1003
|
-
"--costs",
|
|
1004
|
-
"show model tokens and cost even when stdout is redirected",
|
|
1005
|
-
false
|
|
1006
|
-
).addHelpText(
|
|
1007
|
-
"after",
|
|
1008
|
-
"\nPrerequisites:\n Install Chromium with `sedum browsers install chromium` and configure the selected provider's credentials. TypeSafe uses TYPESAFE_API_KEY (and TYPESAFE_BASE_URL for a compatible gateway); OpenRouter uses OPENROUTER_API_KEY; Clef uses CLOUDFLARE_ACCOUNT_ID and CLOUDFLARE_AUTH_TOKEN.\n\nExamples:\n sedum run tests/login.test.ts\n sedum run tests/login.test.ts --id 'tests/login.test.ts#signs in'\n sedum run tests/login.test.yaml --strict --costs\n"
|
|
1009
|
-
).action(
|
|
908
|
+
addRunReportOptions(
|
|
909
|
+
addRunExecutionOptions(addRunSelectionOptions(program.command("run")))
|
|
910
|
+
).description("run configured tests, files, or directories").action(
|
|
1010
911
|
async (paths, options) => {
|
|
1011
912
|
if (options.shardIndex === void 0 !== (options.shardCount === void 0) || options.shardIndex !== void 0 && options.shardIndex > options.shardCount) {
|
|
1012
913
|
writeErr(
|
|
@@ -1038,7 +939,7 @@ async function runCli(args, version, runtime = {}) {
|
|
|
1038
939
|
return;
|
|
1039
940
|
}
|
|
1040
941
|
if (options.affected) {
|
|
1041
|
-
const { selectAffectedTests, AffectedSelectionError } = await import("./affected-selection-
|
|
942
|
+
const { selectAffectedTests, AffectedSelectionError } = await import("./affected-selection-NTBVWIK5.js");
|
|
1042
943
|
const { ProviderError: ProviderError2 } = await import("@sedum-dev/core");
|
|
1043
944
|
writeErr(
|
|
1044
945
|
"Experimental selection sends the committed Git diff and complete test/module sources to the configured provider. Tracked local edits are refused. Full CI is still recommended.\n"
|
|
@@ -1127,6 +1028,7 @@ No tests were run. Fix the selection error or run without --affected.
|
|
|
1127
1028
|
if (output) writeOut(output);
|
|
1128
1029
|
}
|
|
1129
1030
|
};
|
|
1031
|
+
const upload = options.cloud ? await (await import("./cloud-upload-IGNNU5WX.js")).prepareCloudUpload(process.cwd()) : void 0;
|
|
1130
1032
|
const execution = await executeRun({
|
|
1131
1033
|
command,
|
|
1132
1034
|
...runtime.onStrayRejection ? { onStrayRejection: runtime.onStrayRejection } : {},
|
|
@@ -1138,6 +1040,7 @@ No tests were run. Fix the selection error or run without --affected.
|
|
|
1138
1040
|
names: options.name,
|
|
1139
1041
|
ids: options.id
|
|
1140
1042
|
},
|
|
1043
|
+
nonBlockingLabels: options.nonBlockingLabels,
|
|
1141
1044
|
...options.env ? { environment: options.env } : {},
|
|
1142
1045
|
...options.browser ? { browser: options.browser } : {},
|
|
1143
1046
|
...options.vision !== void 0 ? { vision: options.vision } : {},
|
|
@@ -1171,38 +1074,29 @@ No tests were run. Fix the selection error or run without --affected.
|
|
|
1171
1074
|
...runtime.onRunDeadline ? { onDeadline: runtime.onRunDeadline } : {},
|
|
1172
1075
|
onSnapshot: emit
|
|
1173
1076
|
});
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
code: "reporter_output_error",
|
|
1198
|
-
message: "The selected reporter could not write output.",
|
|
1199
|
-
fix: "Check terminal output access and rerun the command."
|
|
1200
|
-
}
|
|
1201
|
-
)
|
|
1202
|
-
);
|
|
1203
|
-
exitCode = 3;
|
|
1204
|
-
return;
|
|
1205
|
-
}
|
|
1077
|
+
try {
|
|
1078
|
+
writeFinalRunReport(execution, {
|
|
1079
|
+
reporters,
|
|
1080
|
+
emit,
|
|
1081
|
+
context,
|
|
1082
|
+
writeOut,
|
|
1083
|
+
capabilities,
|
|
1084
|
+
showCosts: options.costs
|
|
1085
|
+
});
|
|
1086
|
+
} catch {
|
|
1087
|
+
const failure = await execution.onReporterFailure?.();
|
|
1088
|
+
if (upload && failure) writeErr(await upload(failure));
|
|
1089
|
+
writeErr(
|
|
1090
|
+
renderDiagnostic(
|
|
1091
|
+
failure?.diagnostic ?? {
|
|
1092
|
+
code: "reporter_output_error",
|
|
1093
|
+
message: "The selected reporter could not write output.",
|
|
1094
|
+
fix: "Check terminal output access and rerun the command."
|
|
1095
|
+
}
|
|
1096
|
+
)
|
|
1097
|
+
);
|
|
1098
|
+
exitCode = 3;
|
|
1099
|
+
return;
|
|
1206
1100
|
}
|
|
1207
1101
|
if (!reporters.length && execution.artifacts.authoritative && execution.artifacts.markdownPath) {
|
|
1208
1102
|
writeOut(`markdown ${execution.artifacts.markdownPath}
|
|
@@ -1213,6 +1107,7 @@ No tests were run. Fix the selection error or run without --affected.
|
|
|
1213
1107
|
}
|
|
1214
1108
|
if (execution.diagnostic)
|
|
1215
1109
|
writeErr(renderDiagnostic(execution.diagnostic));
|
|
1110
|
+
if (upload) writeErr(await upload(execution));
|
|
1216
1111
|
exitCode = runExitCode(execution.result, options.strict);
|
|
1217
1112
|
}
|
|
1218
1113
|
);
|
|
@@ -1286,7 +1181,7 @@ No tests were run. Fix the selection error or run without --affected.
|
|
|
1286
1181
|
"after",
|
|
1287
1182
|
"\nGuided mode and --shrink make billable TypeSafe calls (TYPESAFE_API_KEY).\nSafety is off by default, for disposable staging: exploration clicks real buttons\nand completes forms. Use --safe on shared or production-like data.\n\nWrites trace.jsonl, result.json, report.md and report.html into --out/<run-id>/.\n\nExamples:\n sedum explore https://staging.example.com --steps 200 --seed 7 --replay\n sedum explore https://staging.example.com --safe --shrink\n sedum explore --rerun .sedum/explore/<run>/trace.jsonl\n\nExit codes:\n 0 no failures observed\n 1 console errors, page exceptions or HTTP 5xx observed\n 3 command or operational error\n"
|
|
1288
1183
|
).action(async (url, options) => {
|
|
1289
|
-
const { exploreAction } = await import("./explore-command-
|
|
1184
|
+
const { exploreAction } = await import("./explore-command-KMS6UAPM.js");
|
|
1290
1185
|
exitCode = await exploreAction(url, options, {
|
|
1291
1186
|
cwd,
|
|
1292
1187
|
write: writeOut,
|
|
@@ -1303,22 +1198,24 @@ No tests were run. Fix the selection error or run without --affected.
|
|
|
1303
1198
|
);
|
|
1304
1199
|
exitCode = 0;
|
|
1305
1200
|
});
|
|
1306
|
-
program.command("doctor").description("check whether this environment can run Sedum").option("--env <name>", "select a named environment").option("--json", "print versioned JSON checks on stdout", false).addHelpText(
|
|
1201
|
+
program.command("doctor").description("check whether this environment can run Sedum").option("--env <name>", "select a named environment").option("--browser <kind>", "chrome or chromium").option("--json", "print versioned JSON checks on stdout", false).addHelpText(
|
|
1307
1202
|
"after",
|
|
1308
1203
|
"\nThe authenticated API check makes one small, potentially billable request.\n\nExit codes:\n 0 all checks passed\n 3 one or more prerequisites failed\n"
|
|
1309
|
-
).action(
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1204
|
+
).action(
|
|
1205
|
+
async (options) => {
|
|
1206
|
+
const { doctorOptions, executeDoctorCommand, renderDoctorText } = await import("./doctor-command-OFMURNPN.js");
|
|
1207
|
+
const result = await executeDoctorCommand(
|
|
1208
|
+
cwd,
|
|
1209
|
+
runtime.doctorProbes,
|
|
1210
|
+
doctorOptions(options)
|
|
1211
|
+
);
|
|
1212
|
+
writeOut(
|
|
1213
|
+
options.json ? `${JSON.stringify(result)}
|
|
1318
1214
|
` : renderDoctorText(result)
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1215
|
+
);
|
|
1216
|
+
exitCode = result.checks.every((check) => check.status === "pass") ? 0 : 3;
|
|
1217
|
+
}
|
|
1218
|
+
);
|
|
1322
1219
|
program.command("validate").description(
|
|
1323
1220
|
"check tests and modules without a browser or model key (offline by default)"
|
|
1324
1221
|
).argument(
|
|
@@ -1431,6 +1328,226 @@ Fix: rerun the command; if it happens again, report it with the run's result.jso
|
|
|
1431
1328
|
}
|
|
1432
1329
|
return { stdout: stdout.join(""), stderr: stderr.join(""), exitCode };
|
|
1433
1330
|
}
|
|
1331
|
+
function addRunSelectionOptions(command) {
|
|
1332
|
+
return command.argument(
|
|
1333
|
+
"[paths...]",
|
|
1334
|
+
"test files or directories relative to the project root"
|
|
1335
|
+
).option(
|
|
1336
|
+
"--affected",
|
|
1337
|
+
"experimental: send Git diff and test sources to the text provider; run relevant tests",
|
|
1338
|
+
false
|
|
1339
|
+
).option("--base <ref>", "base ref for --affected (default main or master)").option(
|
|
1340
|
+
"--affected-ignore <glob>",
|
|
1341
|
+
"exclude matching repository-relative diff paths (repeatable)",
|
|
1342
|
+
collectAffectedGlob,
|
|
1343
|
+
[]
|
|
1344
|
+
).option(
|
|
1345
|
+
"--threshold <probability>",
|
|
1346
|
+
"minimum relevance probability for --affected (default 0.3)",
|
|
1347
|
+
relevanceThreshold
|
|
1348
|
+
).option(
|
|
1349
|
+
"--selection-only",
|
|
1350
|
+
"with --affected, print selection JSON without running tests (calls the text provider)",
|
|
1351
|
+
false
|
|
1352
|
+
).option(
|
|
1353
|
+
"--include <glob>",
|
|
1354
|
+
"include matching project-relative paths (repeatable)",
|
|
1355
|
+
collectGlob,
|
|
1356
|
+
[]
|
|
1357
|
+
).option(
|
|
1358
|
+
"--exclude <glob>",
|
|
1359
|
+
"exclude matching project-relative paths (repeatable)",
|
|
1360
|
+
collectGlob,
|
|
1361
|
+
[]
|
|
1362
|
+
).option(
|
|
1363
|
+
"--labels <tags>",
|
|
1364
|
+
"require all comma-separated test tags (repeatable)",
|
|
1365
|
+
collectLabels,
|
|
1366
|
+
[]
|
|
1367
|
+
).option(
|
|
1368
|
+
"--non-blocking-labels <tags>",
|
|
1369
|
+
"run tests with any of these comma-separated tags, but do not let their failures fail the run (repeatable)",
|
|
1370
|
+
collectLabels,
|
|
1371
|
+
[]
|
|
1372
|
+
).option(
|
|
1373
|
+
"--name <text>",
|
|
1374
|
+
"match id or description substring (repeatable)",
|
|
1375
|
+
collectValue,
|
|
1376
|
+
[]
|
|
1377
|
+
).option(
|
|
1378
|
+
"--id <id>",
|
|
1379
|
+
"select a test by its exact id (repeatable)",
|
|
1380
|
+
collectValue,
|
|
1381
|
+
[]
|
|
1382
|
+
);
|
|
1383
|
+
}
|
|
1384
|
+
function addRunExecutionOptions(command) {
|
|
1385
|
+
return command.option("--env <name>", "select a named environment").option("--browser <kind>", "chrome or chromium").option("--vision", "enable vision fallback for ambiguous clicks").option("--no-vision", "disable vision fallback").option(
|
|
1386
|
+
"--screenshots",
|
|
1387
|
+
"send screenshots to TypeSafe to check targets and judge claims (default for the TypeSafe API)"
|
|
1388
|
+
).option("--no-screenshots", "send page text only, never screenshots").option(
|
|
1389
|
+
"--url-override <url>",
|
|
1390
|
+
"replace entry URL origin for preview deployments"
|
|
1391
|
+
).option("--output-dir <path>", "run output directory").option("--reporter-dir <path>", "reporter artifact directory").option("--headed", "show the browser", false).option(
|
|
1392
|
+
"--slow <ms>",
|
|
1393
|
+
"slow browser actions by milliseconds",
|
|
1394
|
+
nonnegativeSlow
|
|
1395
|
+
).option(
|
|
1396
|
+
"--retries <count>",
|
|
1397
|
+
"additional whole-test attempts",
|
|
1398
|
+
nonnegativeInteger,
|
|
1399
|
+
0
|
|
1400
|
+
).option(
|
|
1401
|
+
"--timeout-minutes <minutes>",
|
|
1402
|
+
"whole-run deadline",
|
|
1403
|
+
positiveMinutes
|
|
1404
|
+
).option(
|
|
1405
|
+
"--parallel <n|auto>",
|
|
1406
|
+
"run tests in parallel lanes; auto uses half the CPU cores (default 1)",
|
|
1407
|
+
parallelValue
|
|
1408
|
+
).option(
|
|
1409
|
+
"--shard-index <index>",
|
|
1410
|
+
"run only this 1-based shard of the selection (with --shard-count)",
|
|
1411
|
+
positiveCount(1e4)
|
|
1412
|
+
).option(
|
|
1413
|
+
"--shard-count <count>",
|
|
1414
|
+
"split the selection into this many deterministic shards",
|
|
1415
|
+
positiveCount(1e4)
|
|
1416
|
+
).option(
|
|
1417
|
+
"--provider-concurrency <n>",
|
|
1418
|
+
"cap concurrent model-provider requests (default min(4, 2 x lanes))",
|
|
1419
|
+
positiveCount(32)
|
|
1420
|
+
);
|
|
1421
|
+
}
|
|
1422
|
+
function addRunReportOptions(command) {
|
|
1423
|
+
return command.option("--replay", "capture replay frames for executed steps", false).option("--no-evidence", "disable non-passing evidence frames").option("--no-cloud", "disable automatic upload to Sedum Cloud").option("--no-locator-cache", "disable the local locator cache").option("--locator-cache-ci", "enable the local locator cache in CI", false).option(
|
|
1424
|
+
"--sensitive-origin <url>",
|
|
1425
|
+
"omit sensitive page details and frames (repeatable)",
|
|
1426
|
+
collectOrigin,
|
|
1427
|
+
[]
|
|
1428
|
+
).option(
|
|
1429
|
+
"--detect <mode>",
|
|
1430
|
+
"flag steps whose page reported console errors, uncaught exceptions, unhandled rejections, or HTTP errors: off, browser, or semantic (also asks Jev whether each new page looks broken)",
|
|
1431
|
+
detectMode
|
|
1432
|
+
).option(
|
|
1433
|
+
"--detect-allow <rule>",
|
|
1434
|
+
"ignore a known detector finding: [check:]substring or [check:]re:regex (repeatable)",
|
|
1435
|
+
collectAllowRule,
|
|
1436
|
+
[]
|
|
1437
|
+
).option("--strict", "exit 2 when a passed run has uncertainty flags", false).option(
|
|
1438
|
+
"--reporter <name>",
|
|
1439
|
+
"reporter: list, steps, terminal, json, markdown, or junit (repeatable or comma-separated; default list)",
|
|
1440
|
+
collectReporter,
|
|
1441
|
+
[]
|
|
1442
|
+
).option(
|
|
1443
|
+
"--costs",
|
|
1444
|
+
"show model tokens and cost even when stdout is redirected",
|
|
1445
|
+
false
|
|
1446
|
+
).addHelpText(
|
|
1447
|
+
"after",
|
|
1448
|
+
"\nPrerequisites:\n Install Chromium with `sedum browsers install chromium` and configure the selected provider's credentials. TypeSafe uses TYPESAFE_API_KEY (and TYPESAFE_BASE_URL for a compatible gateway); OpenRouter uses OPENROUTER_API_KEY; Clef uses CLOUDFLARE_ACCOUNT_ID and CLOUDFLARE_AUTH_TOKEN.\n\nExamples:\n sedum run tests/login.test.ts\n sedum run tests/login.test.ts --id 'tests/login.test.ts#signs in'\n sedum run tests/login.test.yaml --strict --costs\n sedum run --non-blocking-labels quarantine\n"
|
|
1449
|
+
);
|
|
1450
|
+
}
|
|
1451
|
+
function createProgram(version, writeOut, writeErr) {
|
|
1452
|
+
const program = new Command2().name("sedum").description(
|
|
1453
|
+
"Run plain-English browser tests with deterministic automation."
|
|
1454
|
+
).version(version, "-v, --version", "print the installed Sedum version").helpOption("-h, --help", "show command help").showSuggestionAfterError().showHelpAfterError("Run `sedum --help` to see available commands.").exitOverride().configureOutput({
|
|
1455
|
+
writeOut,
|
|
1456
|
+
writeErr,
|
|
1457
|
+
outputError: (value, write) => write(value)
|
|
1458
|
+
}).addHelpText(
|
|
1459
|
+
"after",
|
|
1460
|
+
"\nExamples:\n sedum init\n sedum run tests/login.test.yaml\n sedum validate\n sedum list --json\n sedum doctor --json\n sedum browsers install chromium\n sedum auth login --url <Cloud origin>\n\nExit codes:\n 0 passed\n 1 failed test (validate and list: invalid test files)\n 2 flagged pass with --strict\n 3 command or operational error\n"
|
|
1461
|
+
);
|
|
1462
|
+
program.action(() => commandHelp(program, writeErr));
|
|
1463
|
+
return program;
|
|
1464
|
+
}
|
|
1465
|
+
async function registerAccountCommands(program, runtime, output) {
|
|
1466
|
+
const { writeOut, writeErr } = output;
|
|
1467
|
+
const auth = program.command("auth").description(
|
|
1468
|
+
"manage Cloud account sessions (separate from CI upload tokens)"
|
|
1469
|
+
);
|
|
1470
|
+
auth.action(() => commandHelp(auth, writeErr));
|
|
1471
|
+
for (const name of ["login", "status", "logout"]) {
|
|
1472
|
+
auth.command(name).description(`${name} a Cloud account session`).option("--url <origin>", "self-hosted Cloud origin (or SEDUM_CLOUD_URL)").option("--organization <id-or-name>", "select current organization").option("--project <id-or-name>", "select current project").option(
|
|
1473
|
+
"--no-browser",
|
|
1474
|
+
"print activation instructions without opening a browser"
|
|
1475
|
+
).action(async (options) => {
|
|
1476
|
+
const { executeAuthCommand } = await import("./auth-command-TSTYIWGX.js");
|
|
1477
|
+
const interactive = (runtime.capabilities ?? plainOutput).stdoutIsTTY && process.stdin.isTTY === true;
|
|
1478
|
+
const choose = runtime.auth?.choose ?? (interactive ? promptAuthChoice(writeOut) : void 0);
|
|
1479
|
+
output.setExitCode(
|
|
1480
|
+
await executeAuthCommand(
|
|
1481
|
+
name,
|
|
1482
|
+
{
|
|
1483
|
+
options,
|
|
1484
|
+
runtime: { ...runtime.auth, ...choose ? { choose } : {} },
|
|
1485
|
+
write: writeOut,
|
|
1486
|
+
writeErr
|
|
1487
|
+
},
|
|
1488
|
+
runtime.signal
|
|
1489
|
+
)
|
|
1490
|
+
);
|
|
1491
|
+
});
|
|
1492
|
+
}
|
|
1493
|
+
const { registerCloudCommands } = await import("./cloud-command-YYQ47FTU.js");
|
|
1494
|
+
registerCloudCommands(program, runtime, output);
|
|
1495
|
+
}
|
|
1496
|
+
function promptAuthChoice(writeOut) {
|
|
1497
|
+
return async (kind, choices, signal) => {
|
|
1498
|
+
const { createInterface } = await import("readline/promises");
|
|
1499
|
+
const prompt = createInterface({
|
|
1500
|
+
input: process.stdin,
|
|
1501
|
+
output: process.stdout
|
|
1502
|
+
});
|
|
1503
|
+
const controller = new AbortController();
|
|
1504
|
+
const cancel = () => controller.abort();
|
|
1505
|
+
prompt.on("close", cancel);
|
|
1506
|
+
prompt.on("SIGINT", cancel);
|
|
1507
|
+
try {
|
|
1508
|
+
choices.forEach(
|
|
1509
|
+
(item, index) => writeOut(
|
|
1510
|
+
`${index + 1}. ${JSON.stringify(item.name)} (${JSON.stringify(item.id)})
|
|
1511
|
+
`
|
|
1512
|
+
)
|
|
1513
|
+
);
|
|
1514
|
+
const answer = await prompt.question(`Select ${kind} number: `, {
|
|
1515
|
+
signal: AbortSignal.any([signal, controller.signal])
|
|
1516
|
+
});
|
|
1517
|
+
return choices[Number(answer) - 1]?.id ?? "";
|
|
1518
|
+
} catch (error) {
|
|
1519
|
+
throw choiceFailure(error, [signal, controller.signal]);
|
|
1520
|
+
} finally {
|
|
1521
|
+
prompt.close();
|
|
1522
|
+
}
|
|
1523
|
+
};
|
|
1524
|
+
}
|
|
1525
|
+
function choiceFailure(error, signals) {
|
|
1526
|
+
if (signals.some((signal) => signal.aborted))
|
|
1527
|
+
return new AuthError("Authentication cancelled.");
|
|
1528
|
+
if (error instanceof Error && error.name === "AbortError")
|
|
1529
|
+
return new AuthError("Authentication cancelled.");
|
|
1530
|
+
return error;
|
|
1531
|
+
}
|
|
1532
|
+
function writeFinalRunReport(execution, output) {
|
|
1533
|
+
if (execution.reporterFailed || !output.reporters.length) return;
|
|
1534
|
+
output.emit(execution.result, execution.artifacts);
|
|
1535
|
+
output.writeOut(
|
|
1536
|
+
renderRunSummary(
|
|
1537
|
+
execution.result,
|
|
1538
|
+
output.capabilities,
|
|
1539
|
+
execution.artifacts,
|
|
1540
|
+
output.showCosts
|
|
1541
|
+
)
|
|
1542
|
+
);
|
|
1543
|
+
for (const [index, reporter] of output.reporters.entries()) {
|
|
1544
|
+
const text = reporter.onResult(execution.result, {
|
|
1545
|
+
...output.context(execution.artifacts),
|
|
1546
|
+
includeSharedSummary: index === 0
|
|
1547
|
+
});
|
|
1548
|
+
if (text) output.writeOut(text);
|
|
1549
|
+
}
|
|
1550
|
+
}
|
|
1434
1551
|
|
|
1435
1552
|
export {
|
|
1436
1553
|
sedumCommand,
|
package/dist/cli.js
CHANGED
|
@@ -2,11 +2,13 @@
|
|
|
2
2
|
import {
|
|
3
3
|
runCli,
|
|
4
4
|
sedumCommand
|
|
5
|
-
} from "./chunk-
|
|
6
|
-
import "./chunk-
|
|
5
|
+
} from "./chunk-PX6PJ7U2.js";
|
|
6
|
+
import "./chunk-JYWNBHN7.js";
|
|
7
|
+
import "./chunk-FOGLJA3Z.js";
|
|
7
8
|
import "./chunk-EFRMSNBD.js";
|
|
8
9
|
import "./chunk-N5CTUO2A.js";
|
|
9
|
-
import "./chunk-
|
|
10
|
+
import "./chunk-CGDXQY2Y.js";
|
|
11
|
+
import "./chunk-J7CLCLHW.js";
|
|
10
12
|
|
|
11
13
|
// src/cli.ts
|
|
12
14
|
import { createRequire } from "module";
|
|
@@ -59,6 +61,11 @@ process.on("unhandledRejection", (reason) => {
|
|
|
59
61
|
`A promise nobody awaited rejected outside any running test: ${describeRejection(reason)}`
|
|
60
62
|
);
|
|
61
63
|
});
|
|
64
|
+
var ignoreClosedPipe = (error) => {
|
|
65
|
+
if (error.code !== "EPIPE") throw error;
|
|
66
|
+
};
|
|
67
|
+
process.stdout.on("error", ignoreClosedPipe);
|
|
68
|
+
process.stderr.on("error", ignoreClosedPipe);
|
|
62
69
|
var onSigint = () => interrupts.request("SIGINT");
|
|
63
70
|
var onSigterm = () => interrupts.request("SIGTERM");
|
|
64
71
|
process.on("SIGINT", onSigint);
|