@specdest/devkit 0.1.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/catalog/README.md +11 -0
- package/catalog/modules/backend-convex/manifest.json +14 -0
- package/catalog/modules/backend-convex-expo/manifest.json +11 -0
- package/catalog/modules/backend-supabase/manifest.json +15 -0
- package/catalog/modules/backend-supabase-expo/manifest.json +11 -0
- package/catalog/modules/checker-runtime/config.ts +24 -0
- package/catalog/modules/checker-runtime/fs.ts +47 -0
- package/catalog/modules/checker-runtime/manifest.json +23 -0
- package/catalog/modules/devflow/.agents/skills/devflow/SKILL.md +33 -0
- package/catalog/modules/devflow/.devflow.json +10 -0
- package/catalog/modules/devflow/manifest.json +35 -0
- package/catalog/modules/e2e-playwright/.agents/skills/e2e-playwright/SKILL.md +85 -0
- package/catalog/modules/e2e-playwright/.agents/skills/e2e-playwright/scripts/activeScenario.mjs +130 -0
- package/catalog/modules/e2e-playwright/.agents/skills/e2e-playwright/scripts/checkLocalEnvironment.mjs +7 -0
- package/catalog/modules/e2e-playwright/.agents/skills/e2e-playwright/scripts/completeActiveScenario.mjs +36 -0
- package/catalog/modules/e2e-playwright/.agents/skills/e2e-playwright/scripts/createActiveScenario.mjs +143 -0
- package/catalog/modules/e2e-playwright/.agents/skills/e2e-playwright/scripts/localEnvironment.mjs +43 -0
- package/catalog/modules/e2e-playwright/.agents/skills/e2e-playwright/scripts/prompt.mjs +25 -0
- package/catalog/modules/e2e-playwright/.agents/skills/e2e-playwright/scripts/runActiveScenario.mjs +66 -0
- package/catalog/modules/e2e-playwright/.agents/skills/e2e-playwright/scripts/runAuthoringScenario.mjs +146 -0
- package/catalog/modules/e2e-playwright/.agents/skills/e2e-playwright/scripts/seed.mjs +56 -0
- package/catalog/modules/e2e-playwright/.agents/skills/e2e-playwright/scripts/seedActiveScenario.mjs +6 -0
- package/catalog/modules/e2e-playwright/docs/e2e-playwright/README.md +103 -0
- package/catalog/modules/e2e-playwright/manifest.json +206 -0
- package/catalog/modules/e2e-playwright/playwright.e2e.config.ts +39 -0
- package/catalog/modules/e2e-playwright/tests/e2e/support/e2ePlaywrightFlow.ts +107 -0
- package/catalog/modules/e2e-playwright/tests/e2e/support/fixtures.ts +27 -0
- package/catalog/modules/local-log/AGENTS.local-log.md +13 -0
- package/catalog/modules/local-log/docs/features/local-logging/README.md +70 -0
- package/catalog/modules/local-log/manifest.json +39 -0
- package/catalog/modules/local-log/tmp/logs/.gitignore +2 -0
- package/catalog/modules/local-log/tools/local-log/README.md +47 -0
- package/catalog/modules/local-log/tools/local-log/local-log.mjs +241 -0
- package/catalog/modules/stack-common-vite/manifest.json +16 -0
- package/catalog/modules/stack-expo-convex/manifest.json +31 -0
- package/catalog/modules/stack-expo-supabase/manifest.json +44 -0
- package/catalog/modules/stack-vite-convex/manifest.json +32 -0
- package/catalog/modules/stack-vite-supabase/manifest.json +45 -0
- package/catalog/rules/abac-permissions-convex/SKILL.md +17 -0
- package/catalog/rules/abac-permissions-convex/check.ts +86 -0
- package/catalog/rules/abac-permissions-convex/manifest.json +35 -0
- package/catalog/rules/abac-permissions-supabase/SKILL.md +17 -0
- package/catalog/rules/abac-permissions-supabase/check.ts +86 -0
- package/catalog/rules/abac-permissions-supabase/manifest.json +35 -0
- package/catalog/rules/convex-multi-presentation/SKILL.md +48 -0
- package/catalog/rules/convex-multi-presentation/boundary-test-baseline.json +3 -0
- package/catalog/rules/convex-multi-presentation/check.ts +271 -0
- package/catalog/rules/convex-multi-presentation/manifest.json +45 -0
- package/catalog/rules/convex-multi-presentation/policy.ts +261 -0
- package/catalog/rules/design-rules/SKILL.md +12 -0
- package/catalog/rules/design-rules/check.ts +83 -0
- package/catalog/rules/design-rules/config.json +5 -0
- package/catalog/rules/design-rules/manifest.json +40 -0
- package/catalog/rules/e2e-test-rules/SKILL.md +46 -0
- package/catalog/rules/e2e-test-rules/check.ts +144 -0
- package/catalog/rules/e2e-test-rules/config.json +32 -0
- package/catalog/rules/e2e-test-rules/manifest.json +40 -0
- package/catalog/rules/error-handling-rules/SKILL.md +21 -0
- package/catalog/rules/error-handling-rules/check.ts +72 -0
- package/catalog/rules/error-handling-rules/manifest.json +35 -0
- package/catalog/rules/layers-and-contracts/SKILL.md +36 -0
- package/catalog/rules/layers-and-contracts/check.ts +265 -0
- package/catalog/rules/layers-and-contracts/manifest.json +35 -0
- package/catalog/rules/layers-and-contracts-convex/SKILL.md +49 -0
- package/catalog/rules/layers-and-contracts-convex/check.ts +288 -0
- package/catalog/rules/layers-and-contracts-convex/manifest.json +40 -0
- package/catalog/rules/layers-and-contracts-convex/policy.ts +68 -0
- package/catalog/rules/layers-and-contracts-supabase/SKILL.md +52 -0
- package/catalog/rules/layers-and-contracts-supabase/check.ts +370 -0
- package/catalog/rules/layers-and-contracts-supabase/manifest.json +40 -0
- package/catalog/rules/layers-and-contracts-supabase/policy.ts +68 -0
- package/catalog/rules/module-size-rules/SKILL.md +5 -0
- package/catalog/rules/module-size-rules/check.ts +143 -0
- package/catalog/rules/module-size-rules/config.json +6 -0
- package/catalog/rules/module-size-rules/manifest.json +40 -0
- package/catalog/rules/module-size-rules-convex/SKILL.md +5 -0
- package/catalog/rules/module-size-rules-convex/check.ts +145 -0
- package/catalog/rules/module-size-rules-convex/config.json +6 -0
- package/catalog/rules/module-size-rules-convex/manifest.json +40 -0
- package/catalog/rules/module-size-rules-supabase/SKILL.md +5 -0
- package/catalog/rules/module-size-rules-supabase/check.ts +145 -0
- package/catalog/rules/module-size-rules-supabase/config.json +12 -0
- package/catalog/rules/module-size-rules-supabase/manifest.json +40 -0
- package/catalog/rules/mutation-command-rules/SKILL.md +15 -0
- package/catalog/rules/mutation-command-rules/check.ts +29 -0
- package/catalog/rules/mutation-command-rules/config.json +19 -0
- package/catalog/rules/mutation-command-rules/manifest.json +40 -0
- package/catalog/rules/nearby-contracts/SKILL.md +18 -0
- package/catalog/rules/nearby-contracts/check.ts +137 -0
- package/catalog/rules/nearby-contracts/config.json +10 -0
- package/catalog/rules/nearby-contracts/manifest.json +40 -0
- package/catalog/rules/no-raw-click-buttons/SKILL.md +5 -0
- package/catalog/rules/no-raw-click-buttons/check.ts +36 -0
- package/catalog/rules/no-raw-click-buttons/manifest.json +35 -0
- package/catalog/rules/public-api-export-barrels/SKILL.md +45 -0
- package/catalog/rules/public-api-export-barrels/check.ts +72 -0
- package/catalog/rules/public-api-export-barrels/config.json +4 -0
- package/catalog/rules/public-api-export-barrels/manifest.json +40 -0
- package/catalog/rules/route-tree-fresh/SKILL.md +16 -0
- package/catalog/rules/route-tree-fresh/check.ts +64 -0
- package/catalog/rules/route-tree-fresh/manifest.json +35 -0
- package/catalog/rules/strict-typescript/SKILL.md +3 -0
- package/catalog/rules/strict-typescript/check.ts +111 -0
- package/catalog/rules/strict-typescript/manifest.json +35 -0
- package/catalog/rules/supabase-contracts/SKILL.md +3 -0
- package/catalog/rules/supabase-contracts/check.ts +171 -0
- package/catalog/rules/supabase-contracts/manifest.json +35 -0
- package/catalog/rules/supabase-declarative-schema/SKILL.md +30 -0
- package/catalog/rules/supabase-declarative-schema/check.ts +261 -0
- package/catalog/rules/supabase-declarative-schema/config.json +8 -0
- package/catalog/rules/supabase-declarative-schema/manifest.json +40 -0
- package/catalog/rules/tanstack-form-rules/SKILL.md +11 -0
- package/catalog/rules/tanstack-form-rules/check.ts +57 -0
- package/catalog/rules/tanstack-form-rules/manifest.json +35 -0
- package/catalog/rules/unit-test-rules/SKILL.md +55 -0
- package/catalog/rules/unit-test-rules/check.ts +131 -0
- package/catalog/rules/unit-test-rules/config.json +22 -0
- package/catalog/rules/unit-test-rules/manifest.json +40 -0
- package/catalog/rules/unit-test-rules-convex/SKILL.md +41 -0
- package/catalog/rules/unit-test-rules-convex/check.ts +417 -0
- package/catalog/rules/unit-test-rules-convex/manifest.json +35 -0
- package/catalog/rules/unit-test-rules-supabase/SKILL.md +40 -0
- package/catalog/rules/unit-test-rules-supabase/check.ts +491 -0
- package/catalog/rules/unit-test-rules-supabase/manifest.json +35 -0
- package/catalog/rules/workstation-controller-rules/SKILL.md +22 -0
- package/catalog/rules/workstation-controller-rules/check.ts +107 -0
- package/catalog/rules/workstation-controller-rules/manifest.json +35 -0
- package/package.json +22 -0
- package/src/catalog-snapshot.js +39 -0
- package/src/catalog.js +117 -0
- package/src/cli.js +11 -0
- package/src/index.js +30 -0
- package/src/installer-primitives.js +198 -0
- package/src/project-operations.js +126 -0
- package/src/setup-requirements.js +82 -0
- package/src/shared-file.js +131 -0
- package/src/sync-core.js +276 -0
package/catalog/modules/e2e-playwright/.agents/skills/e2e-playwright/scripts/localEnvironment.mjs
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
export async function assertLocalEnvironment(input = {}) {
|
|
2
|
+
if (process.env.APP_ENV === "production") {
|
|
3
|
+
throw new Error("Refusing E2E Playwright run with APP_ENV=production.");
|
|
4
|
+
}
|
|
5
|
+
if (process.env.NODE_ENV === "production") {
|
|
6
|
+
throw new Error("Refusing E2E Playwright run with NODE_ENV=production.");
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
const baseUrl = process.env.E2E_BASE_URL ?? "http://127.0.0.1:5173";
|
|
10
|
+
assertLocalUrl(baseUrl, "E2E_BASE_URL");
|
|
11
|
+
|
|
12
|
+
if (input.requireFrontend ?? false) await assertReachable(baseUrl, "local frontend");
|
|
13
|
+
|
|
14
|
+
return { baseUrl };
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export function assertLocalUrl(rawUrl, label) {
|
|
18
|
+
const url = new URL(rawUrl, "http://127.0.0.1:5173");
|
|
19
|
+
const allowedHosts = new Set(["127.0.0.1", "localhost", "::1", "[::1]"]);
|
|
20
|
+
if (!allowedHosts.has(url.hostname)) {
|
|
21
|
+
throw new Error(`${label} must be local. Refusing URL: ${url.toString()}`);
|
|
22
|
+
}
|
|
23
|
+
return url;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
async function assertReachable(url, label) {
|
|
27
|
+
try {
|
|
28
|
+
const response = await fetch(url, { method: "HEAD" });
|
|
29
|
+
if (response.status < 500) return;
|
|
30
|
+
} catch {
|
|
31
|
+
// Some local apps reject HEAD. Retry with GET before failing.
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
try {
|
|
35
|
+
const response = await fetch(url, { method: "GET" });
|
|
36
|
+
if (response.status < 500) return;
|
|
37
|
+
throw new Error(`HTTP ${response.status}`);
|
|
38
|
+
} catch (error) {
|
|
39
|
+
throw new Error(
|
|
40
|
+
`${label} is not reachable at ${url}. Start the local app and retry. ${error instanceof Error ? error.message : String(error)}`,
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { stdin as input, stdout as output } from "node:process";
|
|
2
|
+
import { createInterface } from "node:readline/promises";
|
|
3
|
+
|
|
4
|
+
export async function promptText(inputConfig) {
|
|
5
|
+
if (!process.stdin.isTTY) {
|
|
6
|
+
if (inputConfig.defaultValue !== undefined) return inputConfig.defaultValue;
|
|
7
|
+
if (inputConfig.required) throw new Error(`Missing required input: ${inputConfig.label}`);
|
|
8
|
+
return "";
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const prompt = inputConfig.defaultValue
|
|
12
|
+
? `${inputConfig.label} [${inputConfig.defaultValue}]: `
|
|
13
|
+
: `${inputConfig.label}: `;
|
|
14
|
+
const readline = createInterface({ input, output });
|
|
15
|
+
|
|
16
|
+
try {
|
|
17
|
+
const value = (await readline.question(prompt)).trim();
|
|
18
|
+
const resolved = value || inputConfig.defaultValue || "";
|
|
19
|
+
if (inputConfig.required && !resolved)
|
|
20
|
+
throw new Error(`Missing required input: ${inputConfig.label}`);
|
|
21
|
+
return resolved;
|
|
22
|
+
} finally {
|
|
23
|
+
readline.close();
|
|
24
|
+
}
|
|
25
|
+
}
|
package/catalog/modules/e2e-playwright/.agents/skills/e2e-playwright/scripts/runActiveScenario.mjs
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { existsSync } from "node:fs";
|
|
2
|
+
import { spawn } from "node:child_process";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import { assertLocalEnvironment } from "./localEnvironment.mjs";
|
|
5
|
+
import { seedScenario } from "./seed.mjs";
|
|
6
|
+
import {
|
|
7
|
+
getRequiredActiveScenario,
|
|
8
|
+
repoRoot,
|
|
9
|
+
requireFile,
|
|
10
|
+
toRepoRelative,
|
|
11
|
+
} from "./activeScenario.mjs";
|
|
12
|
+
|
|
13
|
+
const scenario = await getRequiredActiveScenario();
|
|
14
|
+
|
|
15
|
+
requireFile(
|
|
16
|
+
scenario.seedPath,
|
|
17
|
+
`Missing seed: ${toRepoRelative(scenario.seedPath)}. Create seed.mjs first.`,
|
|
18
|
+
);
|
|
19
|
+
requireFile(
|
|
20
|
+
scenario.flowScriptPath,
|
|
21
|
+
`Missing flow script: ${toRepoRelative(scenario.flowScriptPath)}. Create flow.script.ts first.`,
|
|
22
|
+
);
|
|
23
|
+
|
|
24
|
+
if (!existsSync(scenario.specPath)) {
|
|
25
|
+
console.error(`Missing active scenario spec: ${toRepoRelative(scenario.specPath)}`);
|
|
26
|
+
console.error("Create the spec before running the active scenario.");
|
|
27
|
+
process.exit(2);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
await assertLocalEnvironment({ requireFrontend: true });
|
|
31
|
+
|
|
32
|
+
if (process.env.E2E_PLAYWRIGHT_SKIP_SEED !== "1") {
|
|
33
|
+
console.log("Seeding active E2E scenario before run.");
|
|
34
|
+
await seedScenario(scenario);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const playwrightBin = path.join(
|
|
38
|
+
repoRoot,
|
|
39
|
+
"node_modules",
|
|
40
|
+
".bin",
|
|
41
|
+
process.platform === "win32" ? "playwright.cmd" : "playwright",
|
|
42
|
+
);
|
|
43
|
+
const specPath = toRepoRelative(scenario.specPath);
|
|
44
|
+
const args = ["test", "--config", "playwright.e2e.config.ts", specPath];
|
|
45
|
+
|
|
46
|
+
console.log(`Running active E2E scenario: ${scenario.id}`);
|
|
47
|
+
console.log(`Spec: ${specPath}`);
|
|
48
|
+
console.log("Using local Playwright. No backend mocking is installed by this template.");
|
|
49
|
+
console.log("");
|
|
50
|
+
|
|
51
|
+
const child = spawn(playwrightBin, args, {
|
|
52
|
+
cwd: repoRoot,
|
|
53
|
+
env: {
|
|
54
|
+
...process.env,
|
|
55
|
+
E2E_PLAYWRIGHT_ACTIVE_SCENARIO_ID: scenario.id,
|
|
56
|
+
},
|
|
57
|
+
stdio: "inherit",
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
child.on("exit", (code, signal) => {
|
|
61
|
+
if (signal) {
|
|
62
|
+
console.error(`Active E2E scenario runner exited by signal ${signal}`);
|
|
63
|
+
process.exit(1);
|
|
64
|
+
}
|
|
65
|
+
process.exit(code ?? 1);
|
|
66
|
+
});
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
import { existsSync } from "node:fs";
|
|
2
|
+
import { spawn } from "node:child_process";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import { assertLocalEnvironment } from "./localEnvironment.mjs";
|
|
5
|
+
import { seedScenario } from "./seed.mjs";
|
|
6
|
+
import {
|
|
7
|
+
getRequiredActiveScenario,
|
|
8
|
+
repoRoot,
|
|
9
|
+
requireFile,
|
|
10
|
+
toRepoRelative,
|
|
11
|
+
} from "./activeScenario.mjs";
|
|
12
|
+
|
|
13
|
+
const scenario = await getRequiredActiveScenario();
|
|
14
|
+
const options = parseOptions(process.argv.slice(2));
|
|
15
|
+
|
|
16
|
+
requireFile(
|
|
17
|
+
scenario.seedPath,
|
|
18
|
+
`Missing seed: ${toRepoRelative(scenario.seedPath)}. Create seed.mjs first.`,
|
|
19
|
+
);
|
|
20
|
+
requireFile(
|
|
21
|
+
scenario.flowScriptPath,
|
|
22
|
+
`Missing flow script: ${toRepoRelative(scenario.flowScriptPath)}. Create flow.script.ts first.`,
|
|
23
|
+
);
|
|
24
|
+
|
|
25
|
+
if (!existsSync(scenario.specPath)) {
|
|
26
|
+
console.error(`Missing active scenario spec: ${toRepoRelative(scenario.specPath)}`);
|
|
27
|
+
console.error("Create the spec before running authoring mode.");
|
|
28
|
+
process.exit(2);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
await assertLocalEnvironment({ requireFrontend: true });
|
|
32
|
+
|
|
33
|
+
if (!options.skipSeed) {
|
|
34
|
+
console.log("Seeding active E2E scenario before authoring run.");
|
|
35
|
+
await seedScenario(scenario);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const playwrightBin = path.join(
|
|
39
|
+
repoRoot,
|
|
40
|
+
"node_modules",
|
|
41
|
+
".bin",
|
|
42
|
+
process.platform === "win32" ? "playwright.cmd" : "playwright",
|
|
43
|
+
);
|
|
44
|
+
const specPath = toRepoRelative(scenario.specPath);
|
|
45
|
+
const args = ["test", "--config", "playwright.e2e.config.ts", specPath];
|
|
46
|
+
|
|
47
|
+
if (options.debug) args.push("--debug");
|
|
48
|
+
else if (options.headed) args.push("--headed");
|
|
49
|
+
|
|
50
|
+
console.log(`Running active E2E scenario in authoring mode: ${scenario.id}`);
|
|
51
|
+
console.log(`Spec: ${specPath}`);
|
|
52
|
+
if (options.until) console.log(`Until step: ${options.until}`);
|
|
53
|
+
if (options.pauseAfter) console.log(`Pause after step: ${options.pauseAfter}`);
|
|
54
|
+
console.log("Using local Playwright. No backend mocking is installed by this template.");
|
|
55
|
+
console.log("");
|
|
56
|
+
|
|
57
|
+
const child = spawn(playwrightBin, args, {
|
|
58
|
+
cwd: repoRoot,
|
|
59
|
+
env: {
|
|
60
|
+
...process.env,
|
|
61
|
+
E2E_PLAYWRIGHT_ACTIVE_SCENARIO_ID: scenario.id,
|
|
62
|
+
E2E_PLAYWRIGHT_TRACE_STEPS: "1",
|
|
63
|
+
E2E_PLAYWRIGHT_UNTIL_STEP: options.until ?? "",
|
|
64
|
+
E2E_PLAYWRIGHT_PAUSE_AFTER_STEP: options.pauseAfter ?? "",
|
|
65
|
+
},
|
|
66
|
+
stdio: "inherit",
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
child.on("exit", (code, signal) => {
|
|
70
|
+
if (signal) {
|
|
71
|
+
console.error(`Active E2E authoring runner exited by signal ${signal}`);
|
|
72
|
+
process.exit(1);
|
|
73
|
+
}
|
|
74
|
+
process.exit(code ?? 1);
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
function parseOptions(args) {
|
|
78
|
+
let until;
|
|
79
|
+
let pauseAfter;
|
|
80
|
+
let debug = false;
|
|
81
|
+
let headed = true;
|
|
82
|
+
let skipSeed = process.env.E2E_PLAYWRIGHT_SKIP_SEED === "1";
|
|
83
|
+
|
|
84
|
+
for (let index = 0; index < args.length; index += 1) {
|
|
85
|
+
const arg = args[index];
|
|
86
|
+
if (!arg || arg === "--") continue;
|
|
87
|
+
|
|
88
|
+
if (arg === "--until") {
|
|
89
|
+
const parsed = readValueArgs(args, index, arg);
|
|
90
|
+
until = parsed.value;
|
|
91
|
+
index = parsed.nextIndex;
|
|
92
|
+
continue;
|
|
93
|
+
}
|
|
94
|
+
if (arg.startsWith("--until=")) {
|
|
95
|
+
until = arg.slice("--until=".length);
|
|
96
|
+
continue;
|
|
97
|
+
}
|
|
98
|
+
if (arg === "--pause-after") {
|
|
99
|
+
const parsed = readValueArgs(args, index, arg);
|
|
100
|
+
pauseAfter = parsed.value;
|
|
101
|
+
debug = true;
|
|
102
|
+
index = parsed.nextIndex;
|
|
103
|
+
continue;
|
|
104
|
+
}
|
|
105
|
+
if (arg.startsWith("--pause-after=")) {
|
|
106
|
+
pauseAfter = arg.slice("--pause-after=".length);
|
|
107
|
+
debug = true;
|
|
108
|
+
continue;
|
|
109
|
+
}
|
|
110
|
+
if (arg === "--debug") {
|
|
111
|
+
debug = true;
|
|
112
|
+
continue;
|
|
113
|
+
}
|
|
114
|
+
if (arg === "--headed") {
|
|
115
|
+
headed = true;
|
|
116
|
+
continue;
|
|
117
|
+
}
|
|
118
|
+
if (arg === "--headless") {
|
|
119
|
+
headed = false;
|
|
120
|
+
continue;
|
|
121
|
+
}
|
|
122
|
+
if (arg === "--skip-seed") {
|
|
123
|
+
skipSeed = true;
|
|
124
|
+
continue;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
throw new Error(`Unknown authoring option: ${arg}`);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
return { until, pauseAfter, debug, headed, skipSeed };
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
function readValueArgs(args, index, flag) {
|
|
134
|
+
const values = [];
|
|
135
|
+
let cursor = index + 1;
|
|
136
|
+
|
|
137
|
+
while (cursor < args.length) {
|
|
138
|
+
const value = args[cursor];
|
|
139
|
+
if (!value || value.startsWith("--")) break;
|
|
140
|
+
values.push(value);
|
|
141
|
+
cursor += 1;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
if (values.length === 0) throw new Error(`${flag} requires a value.`);
|
|
145
|
+
return { value: values.join(" "), nextIndex: cursor - 1 };
|
|
146
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { spawnSync } from "node:child_process";
|
|
2
|
+
import { pathToFileURL } from "node:url";
|
|
3
|
+
import { assertLocalEnvironment } from "./localEnvironment.mjs";
|
|
4
|
+
import { getRequiredActiveScenario, repoRoot, toRepoRelative } from "./activeScenario.mjs";
|
|
5
|
+
|
|
6
|
+
export async function seedScenario(scenario) {
|
|
7
|
+
await assertLocalEnvironment({ requireFrontend: false });
|
|
8
|
+
const moduleUrl = pathToFileURL(scenario.seedPath).href;
|
|
9
|
+
const seedModule = await import(moduleUrl);
|
|
10
|
+
|
|
11
|
+
if (typeof seedModule.seedScenario !== "function") {
|
|
12
|
+
throw new Error(`${toRepoRelative(scenario.seedPath)} must export seedScenario(context).`);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const context = {
|
|
16
|
+
projectRoot: repoRoot,
|
|
17
|
+
scenario,
|
|
18
|
+
now: new Date("2030-01-01T00:00:00.000Z").toISOString(),
|
|
19
|
+
env: { ...process.env },
|
|
20
|
+
executeCommand,
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
await seedModule.seedScenario(context);
|
|
24
|
+
if (typeof seedModule.verifySeed === "function") await seedModule.verifySeed(context);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export async function seedActiveScenario() {
|
|
28
|
+
await seedScenario(await getRequiredActiveScenario());
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
async function executeCommand(command, args = [], options = {}) {
|
|
32
|
+
const result = spawnSync(command, args, {
|
|
33
|
+
cwd: options.cwd ?? repoRoot,
|
|
34
|
+
encoding: "utf8",
|
|
35
|
+
env: { ...process.env, ...(options.env ?? {}) },
|
|
36
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
37
|
+
maxBuffer: 1024 * 1024 * 32,
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
if (result.status === 0) {
|
|
41
|
+
return {
|
|
42
|
+
stdout: result.stdout ?? "",
|
|
43
|
+
stderr: result.stderr ?? "",
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
throw new Error(
|
|
48
|
+
[
|
|
49
|
+
`Command failed: ${command} ${args.join(" ")}`,
|
|
50
|
+
result.stdout ? `stdout:\n${result.stdout}` : "",
|
|
51
|
+
result.stderr ? `stderr:\n${result.stderr}` : "",
|
|
52
|
+
]
|
|
53
|
+
.filter(Boolean)
|
|
54
|
+
.join("\n"),
|
|
55
|
+
);
|
|
56
|
+
}
|
package/catalog/modules/e2e-playwright/.agents/skills/e2e-playwright/scripts/seedActiveScenario.mjs
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { seedActiveScenario } from "./seed.mjs";
|
|
2
|
+
import { getRequiredActiveScenario, toRepoRelative } from "./activeScenario.mjs";
|
|
3
|
+
|
|
4
|
+
const scenario = await getRequiredActiveScenario();
|
|
5
|
+
await seedActiveScenario();
|
|
6
|
+
console.log(`Seeded active E2E scenario: ${toRepoRelative(scenario.root)}`);
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
# E2E Playwright
|
|
2
|
+
|
|
3
|
+
This template installs a generic Playwright E2E authoring flow for Vite/web projects.
|
|
4
|
+
|
|
5
|
+
## Commands
|
|
6
|
+
|
|
7
|
+
When the target project uses `package-scripts.yml` or `package-scripts.yaml`:
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
nps "e2e.playwright.0CreateActiveScenario -- <scenario-id>"
|
|
11
|
+
nps e2e.playwright.1CheckLocal
|
|
12
|
+
nps e2e.playwright.2SeedActiveScenario
|
|
13
|
+
nps e2e.playwright.5RunAuthoring
|
|
14
|
+
nps "e2e.playwright.5RunAuthoring -- --until <step-name>"
|
|
15
|
+
nps "e2e.playwright.5RunAuthoring -- --pause-after <step-name>"
|
|
16
|
+
nps e2e.playwright.3RunActiveScenario
|
|
17
|
+
nps "e2e.playwright.4CompleteActiveScenario -- <scenario-id>"
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
Without package-scripts/NPS:
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
npm run e2e:create -- <scenario-id>
|
|
24
|
+
npm run e2e:check-local
|
|
25
|
+
npm run e2e:seed
|
|
26
|
+
npm run e2e:author
|
|
27
|
+
npm run e2e:run
|
|
28
|
+
npm run e2e:complete -- <scenario-id>
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## Local service boundary
|
|
32
|
+
|
|
33
|
+
The template only permits local browser targets:
|
|
34
|
+
|
|
35
|
+
```txt
|
|
36
|
+
localhost
|
|
37
|
+
127.0.0.1
|
|
38
|
+
::1
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
Set the app URL with:
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
E2E_BASE_URL=http://127.0.0.1:5173
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
Override the Playwright web server command with:
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
E2E_WEB_SERVER_COMMAND="pnpm dev -- --host 127.0.0.1 --port 5173"
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
Do not point this flow at production services.
|
|
54
|
+
|
|
55
|
+
## Scenario folders
|
|
56
|
+
|
|
57
|
+
Active scenario:
|
|
58
|
+
|
|
59
|
+
```txt
|
|
60
|
+
tests/e2e/_active/<scenario-id>/
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
Completed scenario:
|
|
64
|
+
|
|
65
|
+
```txt
|
|
66
|
+
tests/e2e/scenarios/<scenario-id>/
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
Generated files:
|
|
70
|
+
|
|
71
|
+
```txt
|
|
72
|
+
intent.md
|
|
73
|
+
authoring.md
|
|
74
|
+
start-url.txt
|
|
75
|
+
seed.mjs
|
|
76
|
+
flow.script.ts
|
|
77
|
+
specs/<scenario-id>.spec.ts
|
|
78
|
+
artifacts/
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
## Authoring loop
|
|
82
|
+
|
|
83
|
+
```txt
|
|
84
|
+
1. Write rough business intent in intent.md.
|
|
85
|
+
2. Add deterministic project-owned data setup in seed.mjs.
|
|
86
|
+
3. Write named Playwright steps in flow.script.ts.
|
|
87
|
+
4. Run authoring mode with --until or --pause-after.
|
|
88
|
+
5. Fix one step at a time.
|
|
89
|
+
6. Remove exploratory pauses/noise.
|
|
90
|
+
7. Run clean verification from seed and step 0.
|
|
91
|
+
8. Complete the scenario.
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
## Seed hook
|
|
95
|
+
|
|
96
|
+
`seed.mjs` is intentionally project-specific. It receives:
|
|
97
|
+
|
|
98
|
+
```js
|
|
99
|
+
export async function seedScenario({ projectRoot, scenario, now, executeCommand }) {}
|
|
100
|
+
export async function verifySeed({ projectRoot, scenario, now, executeCommand }) {}
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
Use this to call project-owned seed scripts, local database tools, or fixture setup commands. The template does not own database schema, auth, routes, or business data.
|
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
{
|
|
2
|
+
"id": "e2e-playwright",
|
|
3
|
+
"kind": "module",
|
|
4
|
+
"version": "1.0.1",
|
|
5
|
+
"artifacts": [
|
|
6
|
+
{
|
|
7
|
+
"kind": "managed-file",
|
|
8
|
+
"path": ".agents/skills/e2e-playwright/SKILL.md",
|
|
9
|
+
"source": ".agents/skills/e2e-playwright/SKILL.md"
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
"kind": "managed-file",
|
|
13
|
+
"path": ".agents/skills/e2e-playwright/scripts/activeScenario.mjs",
|
|
14
|
+
"source": ".agents/skills/e2e-playwright/scripts/activeScenario.mjs"
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
"kind": "managed-file",
|
|
18
|
+
"path": ".agents/skills/e2e-playwright/scripts/checkLocalEnvironment.mjs",
|
|
19
|
+
"source": ".agents/skills/e2e-playwright/scripts/checkLocalEnvironment.mjs"
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
"kind": "managed-file",
|
|
23
|
+
"path": ".agents/skills/e2e-playwright/scripts/completeActiveScenario.mjs",
|
|
24
|
+
"source": ".agents/skills/e2e-playwright/scripts/completeActiveScenario.mjs"
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
"kind": "managed-file",
|
|
28
|
+
"path": ".agents/skills/e2e-playwright/scripts/createActiveScenario.mjs",
|
|
29
|
+
"source": ".agents/skills/e2e-playwright/scripts/createActiveScenario.mjs"
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
"kind": "managed-file",
|
|
33
|
+
"path": ".agents/skills/e2e-playwright/scripts/localEnvironment.mjs",
|
|
34
|
+
"source": ".agents/skills/e2e-playwright/scripts/localEnvironment.mjs"
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
"kind": "managed-file",
|
|
38
|
+
"path": ".agents/skills/e2e-playwright/scripts/prompt.mjs",
|
|
39
|
+
"source": ".agents/skills/e2e-playwright/scripts/prompt.mjs"
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
"kind": "managed-file",
|
|
43
|
+
"path": ".agents/skills/e2e-playwright/scripts/runActiveScenario.mjs",
|
|
44
|
+
"source": ".agents/skills/e2e-playwright/scripts/runActiveScenario.mjs"
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
"kind": "managed-file",
|
|
48
|
+
"path": ".agents/skills/e2e-playwright/scripts/runAuthoringScenario.mjs",
|
|
49
|
+
"source": ".agents/skills/e2e-playwright/scripts/runAuthoringScenario.mjs"
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
"kind": "managed-file",
|
|
53
|
+
"path": ".agents/skills/e2e-playwright/scripts/seed.mjs",
|
|
54
|
+
"source": ".agents/skills/e2e-playwright/scripts/seed.mjs"
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
"kind": "managed-file",
|
|
58
|
+
"path": ".agents/skills/e2e-playwright/scripts/seedActiveScenario.mjs",
|
|
59
|
+
"source": ".agents/skills/e2e-playwright/scripts/seedActiveScenario.mjs"
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
"kind": "managed-file",
|
|
63
|
+
"path": "docs/e2e-playwright/README.md",
|
|
64
|
+
"source": "docs/e2e-playwright/README.md"
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
"kind": "scaffold",
|
|
68
|
+
"path": "playwright.e2e.config.ts",
|
|
69
|
+
"source": "playwright.e2e.config.ts"
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
"kind": "managed-file",
|
|
73
|
+
"path": "tests/e2e/support/e2ePlaywrightFlow.ts",
|
|
74
|
+
"source": "tests/e2e/support/e2ePlaywrightFlow.ts"
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
"kind": "managed-file",
|
|
78
|
+
"path": "tests/e2e/support/fixtures.ts",
|
|
79
|
+
"source": "tests/e2e/support/fixtures.ts"
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
"kind": "shared-json-field",
|
|
83
|
+
"path": "package.json",
|
|
84
|
+
"fieldPath": [
|
|
85
|
+
"scripts",
|
|
86
|
+
"start:local"
|
|
87
|
+
],
|
|
88
|
+
"value": "vite --host 127.0.0.1 --port 5173 --strictPort"
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
"kind": "shared-json-field",
|
|
92
|
+
"path": "package.json",
|
|
93
|
+
"fieldPath": [
|
|
94
|
+
"scripts",
|
|
95
|
+
"test:e2e"
|
|
96
|
+
],
|
|
97
|
+
"value": "playwright test --config playwright.e2e.config.ts"
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
"kind": "shared-json-field",
|
|
101
|
+
"path": "package.json",
|
|
102
|
+
"fieldPath": [
|
|
103
|
+
"scripts",
|
|
104
|
+
"test:e2e:ui"
|
|
105
|
+
],
|
|
106
|
+
"value": "playwright test --config playwright.e2e.config.ts --ui"
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
"kind": "shared-json-field",
|
|
110
|
+
"path": "package.json",
|
|
111
|
+
"fieldPath": [
|
|
112
|
+
"scripts",
|
|
113
|
+
"test:e2e:report"
|
|
114
|
+
],
|
|
115
|
+
"value": "playwright show-report playwright-report/e2e"
|
|
116
|
+
},
|
|
117
|
+
{
|
|
118
|
+
"kind": "shared-json-field",
|
|
119
|
+
"path": "package.json",
|
|
120
|
+
"fieldPath": [
|
|
121
|
+
"scripts",
|
|
122
|
+
"e2e:create"
|
|
123
|
+
],
|
|
124
|
+
"value": "node .agents/skills/e2e-playwright/scripts/createActiveScenario.mjs"
|
|
125
|
+
},
|
|
126
|
+
{
|
|
127
|
+
"kind": "shared-json-field",
|
|
128
|
+
"path": "package.json",
|
|
129
|
+
"fieldPath": [
|
|
130
|
+
"scripts",
|
|
131
|
+
"e2e:check-local"
|
|
132
|
+
],
|
|
133
|
+
"value": "node .agents/skills/e2e-playwright/scripts/checkLocalEnvironment.mjs"
|
|
134
|
+
},
|
|
135
|
+
{
|
|
136
|
+
"kind": "shared-json-field",
|
|
137
|
+
"path": "package.json",
|
|
138
|
+
"fieldPath": [
|
|
139
|
+
"scripts",
|
|
140
|
+
"e2e:seed"
|
|
141
|
+
],
|
|
142
|
+
"value": "node .agents/skills/e2e-playwright/scripts/seedActiveScenario.mjs"
|
|
143
|
+
},
|
|
144
|
+
{
|
|
145
|
+
"kind": "shared-json-field",
|
|
146
|
+
"path": "package.json",
|
|
147
|
+
"fieldPath": [
|
|
148
|
+
"scripts",
|
|
149
|
+
"e2e:run"
|
|
150
|
+
],
|
|
151
|
+
"value": "node .agents/skills/e2e-playwright/scripts/runActiveScenario.mjs"
|
|
152
|
+
},
|
|
153
|
+
{
|
|
154
|
+
"kind": "shared-json-field",
|
|
155
|
+
"path": "package.json",
|
|
156
|
+
"fieldPath": [
|
|
157
|
+
"scripts",
|
|
158
|
+
"e2e:author"
|
|
159
|
+
],
|
|
160
|
+
"value": "node .agents/skills/e2e-playwright/scripts/runAuthoringScenario.mjs"
|
|
161
|
+
},
|
|
162
|
+
{
|
|
163
|
+
"kind": "shared-json-field",
|
|
164
|
+
"path": "package.json",
|
|
165
|
+
"fieldPath": [
|
|
166
|
+
"scripts",
|
|
167
|
+
"e2e:complete"
|
|
168
|
+
],
|
|
169
|
+
"value": "node .agents/skills/e2e-playwright/scripts/completeActiveScenario.mjs"
|
|
170
|
+
},
|
|
171
|
+
{
|
|
172
|
+
"kind": "shared-json-field",
|
|
173
|
+
"path": "package.json",
|
|
174
|
+
"fieldPath": [
|
|
175
|
+
"devDependencies",
|
|
176
|
+
"@playwright/test"
|
|
177
|
+
],
|
|
178
|
+
"value": "^1.57.0"
|
|
179
|
+
},
|
|
180
|
+
{
|
|
181
|
+
"kind": "shared-json-field",
|
|
182
|
+
"path": "package.json",
|
|
183
|
+
"fieldPath": [
|
|
184
|
+
"devDependencies",
|
|
185
|
+
"@types/node"
|
|
186
|
+
],
|
|
187
|
+
"value": "^25.9.4"
|
|
188
|
+
},
|
|
189
|
+
{
|
|
190
|
+
"kind": "shared-json-field",
|
|
191
|
+
"path": "package.json",
|
|
192
|
+
"fieldPath": [
|
|
193
|
+
"devDependencies",
|
|
194
|
+
"playwright"
|
|
195
|
+
],
|
|
196
|
+
"value": "^1.57.0"
|
|
197
|
+
},
|
|
198
|
+
{
|
|
199
|
+
"kind": "shared-markdown-section",
|
|
200
|
+
"path": "AGENTS.md",
|
|
201
|
+
"heading": "## E2E Playwright authoring",
|
|
202
|
+
"body": "Use `.agents/skills/e2e-playwright/SKILL.md` for local Playwright E2E scenario authoring. Keep app-specific selectors, routes, auth, seed data, and business flows in project scenarios. Never target production URLs."
|
|
203
|
+
}
|
|
204
|
+
],
|
|
205
|
+
"obsolete": []
|
|
206
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { defineConfig, devices } from "@playwright/test";
|
|
2
|
+
import { existsSync } from "node:fs";
|
|
3
|
+
|
|
4
|
+
const baseURL = process.env["E2E_BASE_URL"] ?? "http://127.0.0.1:5173";
|
|
5
|
+
const hasPackageScripts = existsSync("package-scripts.yml") || existsSync("package-scripts.yaml");
|
|
6
|
+
const webServerCommand =
|
|
7
|
+
process.env["E2E_WEB_SERVER_COMMAND"] ??
|
|
8
|
+
(hasPackageScripts ? "nps start.local" : "npm run start:local");
|
|
9
|
+
const isActiveScenarioRun = Boolean(process.env["E2E_PLAYWRIGHT_ACTIVE_SCENARIO_ID"]);
|
|
10
|
+
|
|
11
|
+
export default defineConfig({
|
|
12
|
+
testDir: "./tests/e2e",
|
|
13
|
+
testIgnore: isActiveScenarioRun ? [] : ["**/_active/**"],
|
|
14
|
+
timeout: 60_000,
|
|
15
|
+
expect: { timeout: 10_000 },
|
|
16
|
+
fullyParallel: false,
|
|
17
|
+
workers: 1,
|
|
18
|
+
outputDir: "test-results/playwright-artifacts",
|
|
19
|
+
reporter: [
|
|
20
|
+
["list"],
|
|
21
|
+
["html", { outputFolder: "playwright-report/e2e", open: "never" }],
|
|
22
|
+
["json", { outputFile: "test-results/e2e-report.json" }],
|
|
23
|
+
],
|
|
24
|
+
use: {
|
|
25
|
+
baseURL,
|
|
26
|
+
trace: "retain-on-failure",
|
|
27
|
+
screenshot: "only-on-failure",
|
|
28
|
+
video: "retain-on-failure",
|
|
29
|
+
actionTimeout: 10_000,
|
|
30
|
+
navigationTimeout: 30_000,
|
|
31
|
+
},
|
|
32
|
+
projects: [{ name: "chromium", use: { ...devices["Desktop Chrome"], channel: undefined } }],
|
|
33
|
+
webServer: {
|
|
34
|
+
command: webServerCommand,
|
|
35
|
+
url: baseURL,
|
|
36
|
+
reuseExistingServer: !process.env["CI"],
|
|
37
|
+
timeout: 120_000,
|
|
38
|
+
},
|
|
39
|
+
});
|