sedum-cli 0.1.0-alpha.17 → 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-KRK5HRF4.js → affected-selection-NTBVWIK5.js} +8 -50
- package/dist/auth-command-TSTYIWGX.js +634 -0
- package/dist/{chunk-GJ5QI7JQ.js → chunk-CGDXQY2Y.js} +1 -1
- package/dist/{chunk-F4RD4S4P.js → chunk-DXNJ3PGB.js} +41 -17
- package/dist/{chunk-ACDJLEMS.js → chunk-FOGLJA3Z.js} +56 -24
- package/dist/{chunk-OKZ6VJKA.js → chunk-J7CLCLHW.js} +266 -151
- package/dist/chunk-JYWNBHN7.js +109 -0
- package/dist/{chunk-A7HBQLEM.js → chunk-KMWECJ4D.js} +158 -64
- package/dist/chunk-NIUOM3FA.js +50 -0
- package/dist/{chunk-ZAACPFCW.js → chunk-QVCT63FH.js} +1 -1
- package/dist/cli.js +10 -4
- package/dist/cloud-command-YYQ47FTU.js +329 -0
- package/dist/cloud-upload-IGNNU5WX.js +243 -0
- package/dist/{doctor-command-KIGPIDQA.js → doctor-command-OFMURNPN.js} +5 -3
- package/dist/{explore-command-NRRJADY4.js → explore-command-KMS6UAPM.js} +3 -2
- package/dist/index.d.ts +16 -0
- package/dist/index.js +5 -4
- package/dist/{init-command-DEEVMROG.js → init-command-IXR3YUQW.js} +3 -3
- package/dist/{run-command-EVUWZI4F.js → run-command-WYSLSLYM.js} +10 -7
- package/package.json +6 -5
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
providerDiagnostic
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-CGDXQY2Y.js";
|
|
4
4
|
import {
|
|
5
5
|
DEFAULT_PROVIDER_BASE_URL,
|
|
6
6
|
DEFAULT_PROVIDER_MODEL,
|
|
7
|
+
ProjectConfigError,
|
|
7
8
|
loadProjectConfig
|
|
8
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-J7CLCLHW.js";
|
|
9
10
|
|
|
10
11
|
// src/doctor-command.ts
|
|
11
12
|
import { lstat, mkdir, mkdtemp, rm, rmdir, writeFile } from "fs/promises";
|
|
@@ -15,6 +16,12 @@ import {
|
|
|
15
16
|
probeTypeSafeApiKey
|
|
16
17
|
} from "@sedum-dev/provider-typesafe";
|
|
17
18
|
var CLOUDFLARE_API = "https://api.cloudflare.com";
|
|
19
|
+
function doctorOptions(options) {
|
|
20
|
+
return {
|
|
21
|
+
...options.env ? { environment: options.env } : {},
|
|
22
|
+
...options.browser ? { browser: options.browser } : {}
|
|
23
|
+
};
|
|
24
|
+
}
|
|
18
25
|
var pass = (id, message) => ({
|
|
19
26
|
id,
|
|
20
27
|
status: "pass",
|
|
@@ -96,6 +103,29 @@ var VISION_CHECKS = {
|
|
|
96
103
|
"Use the TypeSafe API with screenshots on (the default there), or set vision.enabled: false."
|
|
97
104
|
)
|
|
98
105
|
};
|
|
106
|
+
function browserOrigin(config) {
|
|
107
|
+
return config.browserSource === "default" ? "the default" : `from ${config.browserSource}`;
|
|
108
|
+
}
|
|
109
|
+
function configOverrides(options) {
|
|
110
|
+
return {
|
|
111
|
+
...options.environment ? { environment: options.environment } : {},
|
|
112
|
+
...options.browser ? { browser: options.browser } : {}
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
function configFailure(error) {
|
|
116
|
+
const detail = error instanceof ProjectConfigError ? error.diagnostics[0] : void 0;
|
|
117
|
+
if (!detail)
|
|
118
|
+
return fail(
|
|
119
|
+
"config",
|
|
120
|
+
"Project configuration could not be loaded.",
|
|
121
|
+
"Correct sedum.config.yaml or the project-root .env and check file permissions."
|
|
122
|
+
);
|
|
123
|
+
return fail(
|
|
124
|
+
"config",
|
|
125
|
+
`Project configuration could not be loaded: ${detail.message}`,
|
|
126
|
+
detail.fix
|
|
127
|
+
);
|
|
128
|
+
}
|
|
99
129
|
async function executeDoctorCommand(cwd, probes = {}, options = {}) {
|
|
100
130
|
const checks = [];
|
|
101
131
|
const version = probes.nodeVersion ?? process.versions.node;
|
|
@@ -108,28 +138,21 @@ async function executeDoctorCommand(cwd, probes = {}, options = {}) {
|
|
|
108
138
|
);
|
|
109
139
|
let config = null;
|
|
110
140
|
try {
|
|
111
|
-
config = probes.loadConfig ? await probes.loadConfig(cwd) : await loadProjectConfig(
|
|
112
|
-
cwd,
|
|
113
|
-
process.env,
|
|
114
|
-
options.environment ? { environment: options.environment } : {}
|
|
115
|
-
);
|
|
141
|
+
config = probes.loadConfig ? await probes.loadConfig(cwd) : await loadProjectConfig(cwd, process.env, configOverrides(options));
|
|
116
142
|
checks.push(pass("config", "Project configuration is valid."));
|
|
117
|
-
} catch {
|
|
118
|
-
checks.push(
|
|
119
|
-
fail(
|
|
120
|
-
"config",
|
|
121
|
-
"Project configuration could not be loaded.",
|
|
122
|
-
"Correct sedum.config.yaml or the project-root .env and check file permissions."
|
|
123
|
-
)
|
|
124
|
-
);
|
|
143
|
+
} catch (error) {
|
|
144
|
+
checks.push(configFailure(error));
|
|
125
145
|
}
|
|
126
146
|
if (config) {
|
|
127
147
|
try {
|
|
128
148
|
const available = (probes.browser ?? browserAvailable)(config.browser);
|
|
129
149
|
checks.push(
|
|
130
|
-
available ? pass(
|
|
150
|
+
available ? pass(
|
|
151
|
+
"browser",
|
|
152
|
+
`${config.browser} is available (${browserOrigin(config)}).`
|
|
153
|
+
) : fail(
|
|
131
154
|
"browser",
|
|
132
|
-
`${config.browser} was not found.`,
|
|
155
|
+
`${config.browser} was not found (${browserOrigin(config)}).`,
|
|
133
156
|
"Install Chrome or run `sedum browsers install chromium`; check the configured browser."
|
|
134
157
|
)
|
|
135
158
|
);
|
|
@@ -275,6 +298,7 @@ function renderDoctorText(result) {
|
|
|
275
298
|
}
|
|
276
299
|
|
|
277
300
|
export {
|
|
301
|
+
doctorOptions,
|
|
278
302
|
supportedNode,
|
|
279
303
|
browserAvailable,
|
|
280
304
|
keyPresent,
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
|
+
configDiagnostic
|
|
3
|
+
} from "./chunk-CGDXQY2Y.js";
|
|
4
|
+
import {
|
|
5
|
+
ProjectConfigError,
|
|
6
|
+
loadProjectConfig,
|
|
2
7
|
readProjectEnvironment
|
|
3
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-J7CLCLHW.js";
|
|
4
9
|
|
|
5
10
|
// src/explore-command.ts
|
|
6
11
|
import { randomInt } from "crypto";
|
|
@@ -186,15 +191,20 @@ async function advisor(mode, needed, provider = {}) {
|
|
|
186
191
|
return new TypeSafeAdapter(provider);
|
|
187
192
|
}
|
|
188
193
|
async function exploreProvider(cwd, environment = process.env) {
|
|
189
|
-
const
|
|
194
|
+
const config = await loadProjectConfig(cwd, environment);
|
|
195
|
+
const file = await readProjectEnvironment(config.projectRoot);
|
|
190
196
|
const value = (name) => environment[name]?.trim() || file[name]?.trim() || void 0;
|
|
191
|
-
const
|
|
197
|
+
const keyName = config.providerName === "typesafe" ? config.apiKeyEnv ?? "TYPESAFE_API_KEY" : "TYPESAFE_API_KEY";
|
|
198
|
+
const apiKey = value(keyName) ?? "";
|
|
192
199
|
const baseURL = value("TYPESAFE_BASE_URL");
|
|
193
200
|
const model = value("TYPESAFE_DEFAULT_MODEL");
|
|
194
201
|
return {
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
202
|
+
provider: {
|
|
203
|
+
apiKey,
|
|
204
|
+
...baseURL ? { baseURL } : {},
|
|
205
|
+
...model ? { model } : {}
|
|
206
|
+
},
|
|
207
|
+
keyName
|
|
198
208
|
};
|
|
199
209
|
}
|
|
200
210
|
function traceEnd(result, step) {
|
|
@@ -331,9 +341,9 @@ async function openRun(options) {
|
|
|
331
341
|
return { seed, id, directory, trace, startedAt: (/* @__PURE__ */ new Date()).toISOString() };
|
|
332
342
|
}
|
|
333
343
|
async function walk(page, place, frames, options) {
|
|
334
|
-
const { explore } = await import("@sedum-dev/core");
|
|
344
|
+
const { explore: explore2 } = await import("@sedum-dev/core");
|
|
335
345
|
const guide = await advisor(options.mode, false, options.provider);
|
|
336
|
-
return
|
|
346
|
+
return explore2(page, {
|
|
337
347
|
startUrl: options.url,
|
|
338
348
|
steps: options.steps,
|
|
339
349
|
seed: place.seed,
|
|
@@ -439,7 +449,7 @@ function safetyOf(safe) {
|
|
|
439
449
|
if (safe === void 0) return "off";
|
|
440
450
|
return safe === true ? "on" : safe;
|
|
441
451
|
}
|
|
442
|
-
async function run(url, flags, io) {
|
|
452
|
+
async function run(url, flags, io, provider) {
|
|
443
453
|
return executeExploreCommand({
|
|
444
454
|
url,
|
|
445
455
|
steps: flags.steps,
|
|
@@ -457,7 +467,7 @@ async function run(url, flags, io) {
|
|
|
457
467
|
detect: flags.detect,
|
|
458
468
|
detectAllow: flags.detectAllow,
|
|
459
469
|
...flags.cookies ? { cookies: path3.resolve(io.cwd, flags.cookies) } : {},
|
|
460
|
-
provider
|
|
470
|
+
provider,
|
|
461
471
|
...io.signal ? { signal: io.signal } : {},
|
|
462
472
|
write: io.write
|
|
463
473
|
});
|
|
@@ -471,28 +481,50 @@ function usageProblem({
|
|
|
471
481
|
return url ? null : "Missing start URL.\nFix: use `sedum explore <url>`.\n";
|
|
472
482
|
}
|
|
473
483
|
async function exploreAction(url, flags, io) {
|
|
484
|
+
if (flags.rerun)
|
|
485
|
+
return executeRerunCommand({
|
|
486
|
+
trace: path3.resolve(io.cwd, flags.rerun),
|
|
487
|
+
headed: flags.headed,
|
|
488
|
+
write: io.write
|
|
489
|
+
});
|
|
490
|
+
const problem = usageProblem({ url, flags });
|
|
491
|
+
if (problem) {
|
|
492
|
+
io.writeErr(problem);
|
|
493
|
+
return 3;
|
|
494
|
+
}
|
|
495
|
+
return explore(url, flags, io);
|
|
496
|
+
}
|
|
497
|
+
async function explore(url, flags, io) {
|
|
498
|
+
const credentials = await projectCredentials(io);
|
|
499
|
+
if (!credentials) return 3;
|
|
474
500
|
const { ProviderError } = await import("@sedum-dev/core");
|
|
475
501
|
try {
|
|
476
|
-
|
|
477
|
-
return await executeRerunCommand({
|
|
478
|
-
trace: path3.resolve(io.cwd, flags.rerun),
|
|
479
|
-
headed: flags.headed,
|
|
480
|
-
write: io.write
|
|
481
|
-
});
|
|
482
|
-
const problem = usageProblem({ url, flags });
|
|
483
|
-
if (!problem) return await run(url, flags, io);
|
|
484
|
-
io.writeErr(problem);
|
|
502
|
+
return await run(url, flags, io, credentials.provider);
|
|
485
503
|
} catch (error) {
|
|
486
504
|
if (!(error instanceof ProviderError && error.code === "configuration"))
|
|
487
505
|
throw error;
|
|
488
|
-
io.writeErr(
|
|
489
|
-
`${error.message}
|
|
490
|
-
Fix: set TYPESAFE_API_KEY in the project-root .env or your shell, or use --mode random or --mode heuristic without --shrink.
|
|
491
|
-
`
|
|
492
|
-
);
|
|
506
|
+
io.writeErr(missingKeyMessage(credentials, error.message));
|
|
493
507
|
}
|
|
494
508
|
return 3;
|
|
495
509
|
}
|
|
510
|
+
async function projectCredentials(io) {
|
|
511
|
+
try {
|
|
512
|
+
return await exploreProvider(io.cwd);
|
|
513
|
+
} catch (error) {
|
|
514
|
+
if (!(error instanceof ProjectConfigError)) throw error;
|
|
515
|
+
const diagnostic = configDiagnostic(error);
|
|
516
|
+
io.writeErr(`${diagnostic.message}
|
|
517
|
+
Fix: ${diagnostic.fix}
|
|
518
|
+
`);
|
|
519
|
+
return null;
|
|
520
|
+
}
|
|
521
|
+
}
|
|
522
|
+
function missingKeyMessage({ provider, keyName }, adapterMessage) {
|
|
523
|
+
const message = provider.apiKey ? adapterMessage : `Set ${keyName} to use the TypeSafe provider.`;
|
|
524
|
+
return `${message}
|
|
525
|
+
Fix: set ${keyName} in the project-root .env or your shell, or use --mode random or --mode heuristic without --shrink.
|
|
526
|
+
`;
|
|
527
|
+
}
|
|
496
528
|
|
|
497
529
|
export {
|
|
498
530
|
EXPLORE_MODES,
|