sedum-cli 0.1.0-alpha.18 → 0.1.0-alpha.20
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-EPXLY5Q4.js → chunk-KMWECJ4D.js} +161 -65
- package/dist/chunk-NIUOM3FA.js +50 -0
- 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 +16 -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-WYSLSLYM.js} +13 -8
- package/package.json +6 -5
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
// src/auth-api.ts
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
var AuthError = class extends Error {
|
|
4
|
+
};
|
|
5
|
+
function cloudOrigin(value) {
|
|
6
|
+
try {
|
|
7
|
+
const url = new URL(value);
|
|
8
|
+
if ([url.username, url.password, url.search, url.hash].some(Boolean))
|
|
9
|
+
throw new Error();
|
|
10
|
+
if (!["/", ""].includes(url.pathname)) throw new Error();
|
|
11
|
+
if (!secureProtocol(url)) throw new Error();
|
|
12
|
+
return url.origin;
|
|
13
|
+
} catch {
|
|
14
|
+
throw new AuthError(
|
|
15
|
+
"Cloud URL must be an HTTPS origin (HTTP is allowed only on loopback), without credentials, path, query or fragment."
|
|
16
|
+
);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
function secureProtocol(url) {
|
|
20
|
+
if (url.protocol === "https:") return true;
|
|
21
|
+
return url.protocol === "http:" && ["localhost", "127.0.0.1", "[::1]"].includes(url.hostname);
|
|
22
|
+
}
|
|
23
|
+
var tokensSchema = z.object({
|
|
24
|
+
token_type: z.literal("Bearer"),
|
|
25
|
+
access_token: z.string().min(1),
|
|
26
|
+
refresh_token: z.string().min(1),
|
|
27
|
+
expires_in: z.number().positive().finite()
|
|
28
|
+
});
|
|
29
|
+
var membershipSchema = z.object({
|
|
30
|
+
user: z.object({
|
|
31
|
+
id: z.string(),
|
|
32
|
+
name: z.string().nullable(),
|
|
33
|
+
email: z.string().nullable()
|
|
34
|
+
}),
|
|
35
|
+
organizations: z.array(
|
|
36
|
+
z.object({
|
|
37
|
+
id: z.string(),
|
|
38
|
+
name: z.string(),
|
|
39
|
+
role: z.string(),
|
|
40
|
+
projects: z.array(z.object({ id: z.string(), name: z.string() }))
|
|
41
|
+
})
|
|
42
|
+
)
|
|
43
|
+
});
|
|
44
|
+
async function request(origin, endpoint, signal, options = {}) {
|
|
45
|
+
try {
|
|
46
|
+
const response = await fetch(`${origin}${endpoint}`, {
|
|
47
|
+
redirect: "error",
|
|
48
|
+
signal: AbortSignal.any([signal, AbortSignal.timeout(15e3)]),
|
|
49
|
+
...requestOptions(options)
|
|
50
|
+
});
|
|
51
|
+
const body = await responseBody(response, endpoint);
|
|
52
|
+
return {
|
|
53
|
+
ok: response.ok,
|
|
54
|
+
status: response.status,
|
|
55
|
+
body,
|
|
56
|
+
retryMs: retryDelay(response.headers.get("retry-after"))
|
|
57
|
+
};
|
|
58
|
+
} catch {
|
|
59
|
+
throw new AuthError(
|
|
60
|
+
signal.aborted ? "Authentication cancelled." : "Cloud request failed or timed out. Check the instance URL and connection; redirects are not allowed."
|
|
61
|
+
);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
async function responseBody(response, endpoint) {
|
|
65
|
+
const readBody = response.ok && endpoint !== "/api/oauth/revoke" || response.status === 400 && endpoint === "/api/oauth/token";
|
|
66
|
+
if (readBody) return response.json();
|
|
67
|
+
await response.body?.cancel().catch(() => {
|
|
68
|
+
});
|
|
69
|
+
return {};
|
|
70
|
+
}
|
|
71
|
+
function requestOptions({
|
|
72
|
+
form,
|
|
73
|
+
access
|
|
74
|
+
}) {
|
|
75
|
+
const headers = {};
|
|
76
|
+
if (access) headers.authorization = `Bearer ${access}`;
|
|
77
|
+
if (!form) return { method: "GET", headers };
|
|
78
|
+
headers["content-type"] = "application/x-www-form-urlencoded";
|
|
79
|
+
return {
|
|
80
|
+
method: "POST",
|
|
81
|
+
headers,
|
|
82
|
+
body: new URLSearchParams({ client_id: "sedum-cli", ...form })
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
function retryDelay(retry) {
|
|
86
|
+
if (!retry) return 0;
|
|
87
|
+
const delay = /^\d+$/.test(retry) ? Number(retry) * 1e3 : Math.max(0, Date.parse(retry) - Date.now());
|
|
88
|
+
return Number.isFinite(delay) ? delay : 0;
|
|
89
|
+
}
|
|
90
|
+
function parse(schema, value) {
|
|
91
|
+
const result = schema.safeParse(value);
|
|
92
|
+
if (!result.success)
|
|
93
|
+
throw new AuthError("Cloud returned an invalid authentication response.");
|
|
94
|
+
return result.data;
|
|
95
|
+
}
|
|
96
|
+
function tokenResult(body) {
|
|
97
|
+
const tokens = parse(tokensSchema, body);
|
|
98
|
+
return { ...tokens, expiresAt: Date.now() + tokens.expires_in * 1e3 };
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
export {
|
|
102
|
+
AuthError,
|
|
103
|
+
cloudOrigin,
|
|
104
|
+
tokensSchema,
|
|
105
|
+
membershipSchema,
|
|
106
|
+
request,
|
|
107
|
+
parse,
|
|
108
|
+
tokenResult
|
|
109
|
+
};
|
|
@@ -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
|
}
|
|
@@ -363,7 +368,7 @@ async function loadProjectContext(paths, cwd) {
|
|
|
363
368
|
}
|
|
364
369
|
function renderConfigErrors(errors, cwd) {
|
|
365
370
|
return errors.map((item) => {
|
|
366
|
-
const file = path.relative(cwd, item.file).split(path.sep).join("/");
|
|
371
|
+
const file = path.isAbsolute(item.file) ? path.relative(cwd, item.file).split(path.sep).join("/") : item.file;
|
|
367
372
|
return `${file}:${item.line}:${item.col}: error ${item.code}: ${item.message}
|
|
368
373
|
Fix: ${item.fix}
|
|
369
374
|
`;
|
|
@@ -856,25 +861,21 @@ async function runCli(args, version, runtime = {}) {
|
|
|
856
861
|
const writeOut = (value) => rawOut(withCommand(value, command));
|
|
857
862
|
const writeErr = (value) => rawErr(withCommand(value, command));
|
|
858
863
|
const capabilities = runtime.capabilities ?? plainOutput;
|
|
859
|
-
const executeRun = runtime.executeRun ?? (async (options) => (await import("./run-command-
|
|
864
|
+
const executeRun = runtime.executeRun ?? (async (options) => (await import("./run-command-WYSLSLYM.js")).executeRunCommand(options));
|
|
860
865
|
const cwd = runtime.cwd ?? process.cwd();
|
|
861
866
|
let exitCode = 3;
|
|
862
|
-
const program =
|
|
863
|
-
|
|
864
|
-
|
|
867
|
+
const program = createProgram(version, writeOut, writeErr);
|
|
868
|
+
await registerAccountCommands(program, runtime, {
|
|
869
|
+
rawOut,
|
|
865
870
|
writeOut,
|
|
866
871
|
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));
|
|
872
|
+
setExitCode: (value) => exitCode = value
|
|
873
|
+
});
|
|
873
874
|
program.command("init").description("scaffold a runnable Sedum project in the current directory").addHelpText(
|
|
874
875
|
"after",
|
|
875
876
|
"\nCreates a config, a SauceDemo example, .env.example, and ignore rules.\nExisting files are never replaced.\n"
|
|
876
877
|
).action(async () => {
|
|
877
|
-
const { executeInitCommand } = await import("./init-command-
|
|
878
|
+
const { executeInitCommand } = await import("./init-command-IXR3YUQW.js");
|
|
878
879
|
const interactive = capabilities.stdoutIsTTY && (process.stdin.isTTY === true || runtime.confirmInit !== void 0);
|
|
879
880
|
const confirm = runtime.confirmInit ?? (interactive ? async (question) => {
|
|
880
881
|
const { createInterface } = await import("readline/promises");
|
|
@@ -980,7 +981,7 @@ async function runCli(args, version, runtime = {}) {
|
|
|
980
981
|
"--provider-concurrency <n>",
|
|
981
982
|
"cap concurrent model-provider requests (default min(4, 2 x lanes))",
|
|
982
983
|
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
|
+
).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(
|
|
984
985
|
"--sensitive-origin <url>",
|
|
985
986
|
"omit sensitive page details and frames (repeatable)",
|
|
986
987
|
collectOrigin,
|
|
@@ -1038,7 +1039,7 @@ async function runCli(args, version, runtime = {}) {
|
|
|
1038
1039
|
return;
|
|
1039
1040
|
}
|
|
1040
1041
|
if (options.affected) {
|
|
1041
|
-
const { selectAffectedTests, AffectedSelectionError } = await import("./affected-selection-
|
|
1042
|
+
const { selectAffectedTests, AffectedSelectionError } = await import("./affected-selection-NTBVWIK5.js");
|
|
1042
1043
|
const { ProviderError: ProviderError2 } = await import("@sedum-dev/core");
|
|
1043
1044
|
writeErr(
|
|
1044
1045
|
"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 +1128,7 @@ No tests were run. Fix the selection error or run without --affected.
|
|
|
1127
1128
|
if (output) writeOut(output);
|
|
1128
1129
|
}
|
|
1129
1130
|
};
|
|
1131
|
+
const upload = options.cloud ? await (await import("./cloud-upload-IGNNU5WX.js")).prepareCloudUpload(process.cwd()) : void 0;
|
|
1130
1132
|
const execution = await executeRun({
|
|
1131
1133
|
command,
|
|
1132
1134
|
...runtime.onStrayRejection ? { onStrayRejection: runtime.onStrayRejection } : {},
|
|
@@ -1171,38 +1173,29 @@ No tests were run. Fix the selection error or run without --affected.
|
|
|
1171
1173
|
...runtime.onRunDeadline ? { onDeadline: runtime.onRunDeadline } : {},
|
|
1172
1174
|
onSnapshot: emit
|
|
1173
1175
|
});
|
|
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
|
-
}
|
|
1176
|
+
try {
|
|
1177
|
+
writeFinalRunReport(execution, {
|
|
1178
|
+
reporters,
|
|
1179
|
+
emit,
|
|
1180
|
+
context,
|
|
1181
|
+
writeOut,
|
|
1182
|
+
capabilities,
|
|
1183
|
+
showCosts: options.costs
|
|
1184
|
+
});
|
|
1185
|
+
} catch {
|
|
1186
|
+
const failure = await execution.onReporterFailure?.();
|
|
1187
|
+
if (upload && failure) writeErr(await upload(failure));
|
|
1188
|
+
writeErr(
|
|
1189
|
+
renderDiagnostic(
|
|
1190
|
+
failure?.diagnostic ?? {
|
|
1191
|
+
code: "reporter_output_error",
|
|
1192
|
+
message: "The selected reporter could not write output.",
|
|
1193
|
+
fix: "Check terminal output access and rerun the command."
|
|
1194
|
+
}
|
|
1195
|
+
)
|
|
1196
|
+
);
|
|
1197
|
+
exitCode = 3;
|
|
1198
|
+
return;
|
|
1206
1199
|
}
|
|
1207
1200
|
if (!reporters.length && execution.artifacts.authoritative && execution.artifacts.markdownPath) {
|
|
1208
1201
|
writeOut(`markdown ${execution.artifacts.markdownPath}
|
|
@@ -1213,6 +1206,7 @@ No tests were run. Fix the selection error or run without --affected.
|
|
|
1213
1206
|
}
|
|
1214
1207
|
if (execution.diagnostic)
|
|
1215
1208
|
writeErr(renderDiagnostic(execution.diagnostic));
|
|
1209
|
+
if (upload) writeErr(await upload(execution));
|
|
1216
1210
|
exitCode = runExitCode(execution.result, options.strict);
|
|
1217
1211
|
}
|
|
1218
1212
|
);
|
|
@@ -1286,7 +1280,7 @@ No tests were run. Fix the selection error or run without --affected.
|
|
|
1286
1280
|
"after",
|
|
1287
1281
|
"\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
1282
|
).action(async (url, options) => {
|
|
1289
|
-
const { exploreAction } = await import("./explore-command-
|
|
1283
|
+
const { exploreAction } = await import("./explore-command-KMS6UAPM.js");
|
|
1290
1284
|
exitCode = await exploreAction(url, options, {
|
|
1291
1285
|
cwd,
|
|
1292
1286
|
write: writeOut,
|
|
@@ -1303,22 +1297,24 @@ No tests were run. Fix the selection error or run without --affected.
|
|
|
1303
1297
|
);
|
|
1304
1298
|
exitCode = 0;
|
|
1305
1299
|
});
|
|
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(
|
|
1300
|
+
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
1301
|
"after",
|
|
1308
1302
|
"\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
|
-
|
|
1303
|
+
).action(
|
|
1304
|
+
async (options) => {
|
|
1305
|
+
const { doctorOptions, executeDoctorCommand, renderDoctorText } = await import("./doctor-command-OFMURNPN.js");
|
|
1306
|
+
const result = await executeDoctorCommand(
|
|
1307
|
+
cwd,
|
|
1308
|
+
runtime.doctorProbes,
|
|
1309
|
+
doctorOptions(options)
|
|
1310
|
+
);
|
|
1311
|
+
writeOut(
|
|
1312
|
+
options.json ? `${JSON.stringify(result)}
|
|
1318
1313
|
` : renderDoctorText(result)
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1314
|
+
);
|
|
1315
|
+
exitCode = result.checks.every((check) => check.status === "pass") ? 0 : 3;
|
|
1316
|
+
}
|
|
1317
|
+
);
|
|
1322
1318
|
program.command("validate").description(
|
|
1323
1319
|
"check tests and modules without a browser or model key (offline by default)"
|
|
1324
1320
|
).argument(
|
|
@@ -1431,6 +1427,106 @@ Fix: rerun the command; if it happens again, report it with the run's result.jso
|
|
|
1431
1427
|
}
|
|
1432
1428
|
return { stdout: stdout.join(""), stderr: stderr.join(""), exitCode };
|
|
1433
1429
|
}
|
|
1430
|
+
function createProgram(version, writeOut, writeErr) {
|
|
1431
|
+
const program = new Command2().name("sedum").description(
|
|
1432
|
+
"Run plain-English browser tests with deterministic automation."
|
|
1433
|
+
).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({
|
|
1434
|
+
writeOut,
|
|
1435
|
+
writeErr,
|
|
1436
|
+
outputError: (value, write) => write(value)
|
|
1437
|
+
}).addHelpText(
|
|
1438
|
+
"after",
|
|
1439
|
+
"\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"
|
|
1440
|
+
);
|
|
1441
|
+
program.action(() => commandHelp(program, writeErr));
|
|
1442
|
+
return program;
|
|
1443
|
+
}
|
|
1444
|
+
async function registerAccountCommands(program, runtime, output) {
|
|
1445
|
+
const { writeOut, writeErr } = output;
|
|
1446
|
+
const auth = program.command("auth").description(
|
|
1447
|
+
"manage Cloud account sessions (separate from CI upload tokens)"
|
|
1448
|
+
);
|
|
1449
|
+
auth.action(() => commandHelp(auth, writeErr));
|
|
1450
|
+
for (const name of ["login", "status", "logout"]) {
|
|
1451
|
+
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(
|
|
1452
|
+
"--no-browser",
|
|
1453
|
+
"print activation instructions without opening a browser"
|
|
1454
|
+
).action(async (options) => {
|
|
1455
|
+
const { executeAuthCommand } = await import("./auth-command-TSTYIWGX.js");
|
|
1456
|
+
const interactive = (runtime.capabilities ?? plainOutput).stdoutIsTTY && process.stdin.isTTY === true;
|
|
1457
|
+
const choose = runtime.auth?.choose ?? (interactive ? promptAuthChoice(writeOut) : void 0);
|
|
1458
|
+
output.setExitCode(
|
|
1459
|
+
await executeAuthCommand(
|
|
1460
|
+
name,
|
|
1461
|
+
{
|
|
1462
|
+
options,
|
|
1463
|
+
runtime: { ...runtime.auth, ...choose ? { choose } : {} },
|
|
1464
|
+
write: writeOut,
|
|
1465
|
+
writeErr
|
|
1466
|
+
},
|
|
1467
|
+
runtime.signal
|
|
1468
|
+
)
|
|
1469
|
+
);
|
|
1470
|
+
});
|
|
1471
|
+
}
|
|
1472
|
+
const { registerCloudCommands } = await import("./cloud-command-YYQ47FTU.js");
|
|
1473
|
+
registerCloudCommands(program, runtime, output);
|
|
1474
|
+
}
|
|
1475
|
+
function promptAuthChoice(writeOut) {
|
|
1476
|
+
return async (kind, choices, signal) => {
|
|
1477
|
+
const { createInterface } = await import("readline/promises");
|
|
1478
|
+
const prompt = createInterface({
|
|
1479
|
+
input: process.stdin,
|
|
1480
|
+
output: process.stdout
|
|
1481
|
+
});
|
|
1482
|
+
const controller = new AbortController();
|
|
1483
|
+
const cancel = () => controller.abort();
|
|
1484
|
+
prompt.on("close", cancel);
|
|
1485
|
+
prompt.on("SIGINT", cancel);
|
|
1486
|
+
try {
|
|
1487
|
+
choices.forEach(
|
|
1488
|
+
(item, index) => writeOut(
|
|
1489
|
+
`${index + 1}. ${JSON.stringify(item.name)} (${JSON.stringify(item.id)})
|
|
1490
|
+
`
|
|
1491
|
+
)
|
|
1492
|
+
);
|
|
1493
|
+
const answer = await prompt.question(`Select ${kind} number: `, {
|
|
1494
|
+
signal: AbortSignal.any([signal, controller.signal])
|
|
1495
|
+
});
|
|
1496
|
+
return choices[Number(answer) - 1]?.id ?? "";
|
|
1497
|
+
} catch (error) {
|
|
1498
|
+
throw choiceFailure(error, [signal, controller.signal]);
|
|
1499
|
+
} finally {
|
|
1500
|
+
prompt.close();
|
|
1501
|
+
}
|
|
1502
|
+
};
|
|
1503
|
+
}
|
|
1504
|
+
function choiceFailure(error, signals) {
|
|
1505
|
+
if (signals.some((signal) => signal.aborted))
|
|
1506
|
+
return new AuthError("Authentication cancelled.");
|
|
1507
|
+
if (error instanceof Error && error.name === "AbortError")
|
|
1508
|
+
return new AuthError("Authentication cancelled.");
|
|
1509
|
+
return error;
|
|
1510
|
+
}
|
|
1511
|
+
function writeFinalRunReport(execution, output) {
|
|
1512
|
+
if (execution.reporterFailed || !output.reporters.length) return;
|
|
1513
|
+
output.emit(execution.result, execution.artifacts);
|
|
1514
|
+
output.writeOut(
|
|
1515
|
+
renderRunSummary(
|
|
1516
|
+
execution.result,
|
|
1517
|
+
output.capabilities,
|
|
1518
|
+
execution.artifacts,
|
|
1519
|
+
output.showCosts
|
|
1520
|
+
)
|
|
1521
|
+
);
|
|
1522
|
+
for (const [index, reporter] of output.reporters.entries()) {
|
|
1523
|
+
const text = reporter.onResult(execution.result, {
|
|
1524
|
+
...output.context(execution.artifacts),
|
|
1525
|
+
includeSharedSummary: index === 0
|
|
1526
|
+
});
|
|
1527
|
+
if (text) output.writeOut(text);
|
|
1528
|
+
}
|
|
1529
|
+
}
|
|
1434
1530
|
|
|
1435
1531
|
export {
|
|
1436
1532
|
sedumCommand,
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
// src/affected-git-read.ts
|
|
2
|
+
import { spawn } from "child_process";
|
|
3
|
+
import { isUtf8 } from "buffer";
|
|
4
|
+
var MAX_DIFF_BYTES = 16 * 1024 * 1024;
|
|
5
|
+
var AffectedSelectionError = class extends Error {
|
|
6
|
+
};
|
|
7
|
+
function gitRead(cwd, args, signal, limit = MAX_DIFF_BYTES) {
|
|
8
|
+
return new Promise((resolve, reject) => {
|
|
9
|
+
const child = spawn("git", args, {
|
|
10
|
+
cwd,
|
|
11
|
+
stdio: ["ignore", "pipe", "ignore"],
|
|
12
|
+
env: { ...process.env, GIT_OPTIONAL_LOCKS: "0" },
|
|
13
|
+
...signal ? { signal } : {}
|
|
14
|
+
});
|
|
15
|
+
const buffers = [];
|
|
16
|
+
let bytes = 0;
|
|
17
|
+
let exceeded = false;
|
|
18
|
+
child.stdout.on("data", (buffer) => {
|
|
19
|
+
bytes += buffer.length;
|
|
20
|
+
if (bytes > limit) {
|
|
21
|
+
exceeded = true;
|
|
22
|
+
child.kill();
|
|
23
|
+
} else buffers.push(buffer);
|
|
24
|
+
});
|
|
25
|
+
child.on("error", reject);
|
|
26
|
+
child.on("close", (code) => {
|
|
27
|
+
if (exceeded)
|
|
28
|
+
reject(
|
|
29
|
+
new AffectedSelectionError(
|
|
30
|
+
"Retained Git input exceeds the 16 MiB guard. Run the full suite; input was not truncated."
|
|
31
|
+
)
|
|
32
|
+
);
|
|
33
|
+
else if (code !== 0) reject(new Error("Git read failed"));
|
|
34
|
+
else resolve(Buffer.concat(buffers));
|
|
35
|
+
});
|
|
36
|
+
}).then(decodeGitOutput);
|
|
37
|
+
}
|
|
38
|
+
function decodeGitOutput(output) {
|
|
39
|
+
if (!isUtf8(output))
|
|
40
|
+
throw new AffectedSelectionError(
|
|
41
|
+
"Git input is not valid UTF-8. Run the full suite."
|
|
42
|
+
);
|
|
43
|
+
return output.toString("utf8");
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export {
|
|
47
|
+
MAX_DIFF_BYTES,
|
|
48
|
+
AffectedSelectionError,
|
|
49
|
+
gitRead
|
|
50
|
+
};
|
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-KMWECJ4D.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);
|