sedum-cli 0.1.0-alpha.0 → 0.1.0-alpha.11

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.
@@ -2,11 +2,11 @@ import {
2
2
  browserAvailable,
3
3
  keyPresent,
4
4
  supportedNode
5
- } from "./chunk-OB6ZUJ6X.js";
5
+ } from "./chunk-HXQDSNLL.js";
6
6
  import {
7
7
  ProjectConfigError,
8
8
  loadProjectConfig
9
- } from "./chunk-TZGSCV23.js";
9
+ } from "./chunk-FAGJCNV7.js";
10
10
 
11
11
  // src/init-command.ts
12
12
  import { constants } from "fs";
@@ -19,23 +19,36 @@ browser: chromium
19
19
  outputDir: .sedum/runs
20
20
  reporterDir: .sedum/reports
21
21
  `;
22
- var EXAMPLE = `description: Sign in to the SauceDemo sample store
23
- url: https://www.saucedemo.com/
24
- data:
25
- user: standard_user
26
- password: $SAUCE_PASSWORD
27
- steps:
28
- - type {{user}} in the username field
29
- - type {{password}} in the password field
30
- - click the login button
31
- - verify a list of products with prices is shown
22
+ var EXAMPLE = `import { test, secret } from "sedum-cli";
23
+
24
+ test(
25
+ "a customer signs in to the SauceDemo sample store",
26
+ { url: "https://www.saucedemo.com/" },
27
+ async ({ ai, env }) => {
28
+ await ai("type {{user}} in the username field", { user: "standard_user" });
29
+ await ai("type {{password}} in the password field", {
30
+ password: secret(env.SAUCE_PASSWORD ?? ""),
31
+ });
32
+ await ai("click the login button");
33
+ await ai("verify a list of products with prices is shown");
34
+ },
35
+ );
32
36
  `;
33
37
  var ENV_EXAMPLE = `# Get a TypeSafe key and put it in .env, or set it in your shell.
38
+ # For a compatible provider, also set TYPESAFE_BASE_URL and optionally TYPESAFE_DEFAULT_MODEL.
34
39
  TYPESAFE_API_KEY=
40
+ # If provider.name is clef, use these instead (never commit .env).
41
+ # CLOUDFLARE_ACCOUNT_ID=
42
+ # CLOUDFLARE_AUTH_TOKEN=
35
43
  # Public SauceDemo sample account; no Sauce Labs account is required.
36
44
  SAUCE_PASSWORD=secret_sauce
37
45
  `;
38
- var IGNORE = [".env", ".sedum/runs/", ".sedum/reports/"];
46
+ var IGNORE = [
47
+ "node_modules/",
48
+ ".env",
49
+ ".sedum/runs/",
50
+ ".sedum/reports/"
51
+ ];
39
52
  var WORDMARK = [
40
53
  " \u2588\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588 \u2588\u2588\u2588\u2588 \u2588 \u2588 \u2588 \u2588 \u2588\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588 \u2588 \u2588",
41
54
  "\u2588 \u2591\u2591\u2591\u2591\u2588\u2591\u2591\u2591\u2591\u2591\u2588\u2591\u2591\u2591\u2588 \u2588\u2591 \u2588\u2591\u2588\u2588 \u2588\u2588\u2591 \u2588\u2591\u2591\u2591\u2588 \u2588\u2591\u2591\u2591\u2591\u2591\u2588\u2591 \u2588\u2591",
@@ -152,12 +165,12 @@ async function executeInitCommand(options) {
152
165
  await regularDirectory(path.join(root, "tests"));
153
166
  for (const [name, contents] of [
154
167
  ["sedum.config.yaml", CONFIG],
155
- ["tests/example.test.yaml", EXAMPLE],
168
+ ["tests/example.test.ts", EXAMPLE],
156
169
  [".env.example", ENV_EXAMPLE]
157
170
  ]) {
158
171
  const result = await createOrKeep(path.join(root, name), contents);
159
172
  if (name === ".env.example" && result === "kept") keptEnvExample = true;
160
- if (name === "tests/example.test.yaml" && result === "created")
173
+ if (name === "tests/example.test.ts" && result === "created")
161
174
  createdExample = true;
162
175
  say(`${result} ${name}
163
176
  `);
@@ -165,7 +178,7 @@ async function executeInitCommand(options) {
165
178
  say(await updateIgnore(root, options));
166
179
  say("\nSedum runs plain-language tests in a browser.\n");
167
180
  if (createdExample) {
168
- const title = "\u2500\u2500 tests/example.test.yaml ";
181
+ const title = "\u2500\u2500 tests/example.test.ts ";
169
182
  const divider = "\u2500".repeat(54);
170
183
  say(`
171
184
  ${title}${divider.slice(title.length)}
@@ -189,10 +202,15 @@ ${++step}. ${title}
189
202
  const hasBrowser = (options.browser ?? browserAvailable)(config.browser);
190
203
  const hasEnv = await pathExists(path.join(root, ".env"));
191
204
  if (!keyPresent(config))
192
- next("Add your TypeSafe API key", [
193
- "Get a key at https://typesafe.ai/.",
205
+ next("Add a provider API key", [
206
+ ...config.providerName === "clef" ? ["Create a scoped Workers AI token in the Cloudflare dashboard."] : ["Get a key at https://typesafe.ai/."],
194
207
  ...hasEnv ? [] : ["cp .env.example .env"],
195
- "Open .env and set TYPESAFE_API_KEY to your key (or set it in your shell)."
208
+ ...config.providerName === "clef" ? [
209
+ "Open .env and set CLOUDFLARE_ACCOUNT_ID and CLOUDFLARE_AUTH_TOKEN (or set them in your shell)."
210
+ ] : [
211
+ "Open .env and set TYPESAFE_API_KEY to your key (or set it in your shell).",
212
+ "For a compatible provider, also set TYPESAFE_BASE_URL and use that provider's key as TYPESAFE_API_KEY."
213
+ ]
196
214
  ]);
197
215
  if (!hasBrowser)
198
216
  next(
@@ -217,7 +235,7 @@ ${++step}. ${title}
217
235
  ]);
218
236
  }
219
237
  next("Run the example", [
220
- "sedum run tests/example.test.yaml --headed",
238
+ "sedum run tests/example.test.ts --headed",
221
239
  "This calls the TypeSafe API and may incur a charge."
222
240
  ]);
223
241
  return { stdout: output.join(""), stderr: "", exitCode: 0 };