create-waygraph 0.0.1

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 ADDED
@@ -0,0 +1,34 @@
1
+ # create-waygraph
2
+
3
+ Scaffolds a new [waygraph](https://github.com/deviate-dv8/waygraph) project - one fixed
4
+ shape, no prompts, no template picker.
5
+
6
+ ```bash
7
+ npx create-waygraph my-project
8
+ cd my-project
9
+ npm install
10
+ npx playwright install chromium
11
+ npm test
12
+ ```
13
+
14
+ Generates:
15
+
16
+ ```
17
+ my-project/
18
+ package.json waygraph + @playwright/test
19
+ tsconfig.json
20
+ playwright.config.ts
21
+ .gitignore
22
+ src/
23
+ blocks/load-page.block.ts one real Block (act/resolve/verify)
24
+ flows/example.flow.ts Engine.defineFlow([start, LoadPageBlock, end])
25
+ tests/
26
+ example.spec.ts runs the flow, asserts the terminal Checkpoint
27
+ ```
28
+
29
+ `npm test` goes green immediately, offline - the example Block navigates to a self-contained
30
+ `data:` URL, not a live site, so scaffolding a project never depends on network access.
31
+
32
+ Ships as its own package rather than a `waygraph init` subcommand, so consuming `waygraph`
33
+ at runtime never pulls in scaffolding code - `npx create-waygraph` resolves and runs without
34
+ adding anything to your own `node_modules`.
@@ -0,0 +1,38 @@
1
+ #!/usr/bin/env node
2
+ import { fileURLToPath } from "node:url";
3
+ import path from "node:path";
4
+ import fs from "node:fs";
5
+
6
+ const projectName = process.argv[2];
7
+
8
+ if (!projectName) {
9
+ console.error("Usage: npx create-waygraph <project-name>");
10
+ process.exit(1);
11
+ }
12
+
13
+ const templatesDir = path.join(path.dirname(fileURLToPath(import.meta.url)), "..", "templates");
14
+ const targetDir = path.resolve(process.cwd(), projectName);
15
+
16
+ if (fs.existsSync(targetDir)) {
17
+ const stat = fs.statSync(targetDir);
18
+ if (!stat.isDirectory() || fs.readdirSync(targetDir).length > 0) {
19
+ console.error(`create-waygraph: "${targetDir}" already exists - refusing to overwrite it.`);
20
+ process.exit(1);
21
+ }
22
+ }
23
+
24
+ fs.mkdirSync(targetDir, { recursive: true });
25
+ fs.cpSync(templatesDir, targetDir, { recursive: true });
26
+
27
+ fs.renameSync(path.join(targetDir, "gitignore"), path.join(targetDir, ".gitignore"));
28
+
29
+ const packageJsonPath = path.join(targetDir, "package.json");
30
+ const packageJson = fs.readFileSync(packageJsonPath, "utf8").replace("__PROJECT_NAME__", projectName);
31
+ fs.writeFileSync(packageJsonPath, packageJson);
32
+
33
+ console.log(`Scaffolded ${projectName}/`);
34
+ console.log("");
35
+ console.log(` cd ${projectName}`);
36
+ console.log(" npm install");
37
+ console.log(" npx playwright install chromium");
38
+ console.log(" npm test");
package/package.json ADDED
@@ -0,0 +1,20 @@
1
+ {
2
+ "name": "create-waygraph",
3
+ "version": "0.0.1",
4
+ "description": "Scaffold a new waygraph project - package.json, tsconfig, playwright.config, and one working example flow.",
5
+ "type": "module",
6
+ "bin": {
7
+ "create-waygraph": "bin/create-waygraph.js"
8
+ },
9
+ "files": [
10
+ "bin",
11
+ "templates"
12
+ ],
13
+ "engines": {
14
+ "node": ">=22"
15
+ },
16
+ "repository": {
17
+ "type": "git",
18
+ "url": "git+https://github.com/deviate-dv8/create-waygraph.git"
19
+ }
20
+ }
@@ -0,0 +1,4 @@
1
+ node_modules/
2
+ dist/
3
+ test-results/
4
+ playwright-report/
@@ -0,0 +1,20 @@
1
+ {
2
+ "name": "__PROJECT_NAME__",
3
+ "version": "0.0.1",
4
+ "private": true,
5
+ "type": "module",
6
+ "scripts": {
7
+ "typecheck": "tsc --noEmit",
8
+ "test": "playwright test",
9
+ "flows": "waygraph list .",
10
+ "nav": "waygraph nav ."
11
+ },
12
+ "dependencies": {
13
+ "waygraph": "^0.1.0"
14
+ },
15
+ "devDependencies": {
16
+ "@playwright/test": "^1.55.0",
17
+ "@types/node": "^22.0.0",
18
+ "typescript": "^5.6.0"
19
+ }
20
+ }
@@ -0,0 +1,15 @@
1
+ import { defineConfig } from "@playwright/test";
2
+
3
+ export default defineConfig({
4
+ testDir: "./tests",
5
+ fullyParallel: true,
6
+ reporter: "list",
7
+ use: {
8
+ launchOptions: {
9
+ // If CHROME_PATH/CHROMIUM_PATH is set (e.g. a Flatpak/system Chromium),
10
+ // use it instead of downloading Playwright's own bundled binary.
11
+ // Falls through to Playwright's default when unset - safe either way.
12
+ executablePath: process.env.CHROME_PATH || process.env.CHROMIUM_PATH,
13
+ },
14
+ },
15
+ });
@@ -0,0 +1,18 @@
1
+ import { defineBlock, checkpoint, Trait } from "waygraph";
2
+ import type { Checkpoint } from "waygraph";
3
+
4
+ export type Start = Checkpoint<"__start__">;
5
+ export type Loaded = Checkpoint<"Loaded">;
6
+
7
+ const PAGE_URL = "data:text/html,<h1>Hello Waygraph</h1>";
8
+
9
+ export const LoadPageBlock = defineBlock<Start, Loaded>({
10
+ name: "load-page",
11
+ instruction: {
12
+ async act(page) {
13
+ await page.goto(PAGE_URL);
14
+ },
15
+ resolve: () => checkpoint("Loaded"),
16
+ verify: [Trait.text("h1", "Hello Waygraph")],
17
+ },
18
+ });
@@ -0,0 +1,6 @@
1
+ import { Engine, start, end } from "waygraph";
2
+ import { LoadPageBlock } from "../blocks/load-page.block.js";
3
+
4
+ const engine = new Engine();
5
+
6
+ export const exampleFlow = engine.defineFlow([start, LoadPageBlock, end]);
@@ -0,0 +1,8 @@
1
+ import { test, expect } from "@playwright/test";
2
+ import { MemPage, checkpoint } from "waygraph";
3
+ import { exampleFlow } from "../src/flows/example.flow.js";
4
+
5
+ test("example flow reaches Loaded", async ({ context }) => {
6
+ const result = await exampleFlow.run(context, new MemPage());
7
+ expect(result).toEqual(checkpoint("Loaded"));
8
+ });
@@ -0,0 +1,14 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2022",
4
+ "module": "NodeNext",
5
+ "moduleResolution": "NodeNext",
6
+ "lib": ["ES2022"],
7
+ "strict": true,
8
+ "noImplicitAny": true,
9
+ "esModuleInterop": true,
10
+ "skipLibCheck": true,
11
+ "forceConsistentCasingInFileNames": true
12
+ },
13
+ "include": ["src/**/*.ts", "tests/**/*.ts"]
14
+ }