@zero2webmaster/starter-kit 0.4.0 → 0.5.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/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # z2w-starter-kit
2
2
 
3
- **Version:** 0.4.0 | **Framework:** 2.13.0
3
+ **Version:** 0.5.0 | **Framework:** 2.13.0
4
4
 
5
5
  > Node CLI to scaffold new Z2W projects from canonical Templates + AGENTS.md.
6
6
 
@@ -99,4 +99,4 @@ For licensing inquiries: kerry@zero2webmaster.com.
99
99
  ---
100
100
 
101
101
  *Scaffolded 2026-05-28 via the [[instantiate-z2w-project]] Claude Code skill v1; reconciled against the consolidated skill v1.1.0 (brief-first + Agent Coordination block) on 2026-05-29.*
102
- *Version: 0.4.0 | Last Updated: 2026-07-18*
102
+ *Version: 0.5.0 | Last Updated: 2026-07-19*
package/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { writeScaffold } from "./writer.js";
2
2
  import type { ScaffoldFile } from "./scaffolders/common.js";
3
3
  import type { StandardDecision } from "./standards.js";
4
- export declare const version = "0.4.0";
4
+ export declare const version = "0.5.0";
5
5
  export type ProjectType = "wp-plugin" | "cf-worker" | "cf-pages" | "nextjs" | "python-service" | "node-service" | "library" | "protocol-repo";
6
6
  export type BrandPreset = "save-the-frogs" | "bansuri-bliss" | "zero2webmaster" | "custom";
7
7
  export type DbStrategy = "none" | "neon-postgres" | "supabase" | "sqlite" | "mysql-wp" | "other";
package/dist/index.js CHANGED
@@ -21,7 +21,7 @@ import * as path from "node:path";
21
21
  import { Writable } from "node:stream";
22
22
  import { isValidSlug } from "./parse-brief.js";
23
23
  import { writeScaffold } from "./writer.js";
24
- export const version = "0.4.0";
24
+ export const version = "0.5.0";
25
25
  // Canonical enum value-arrays. These live here, next to the type unions they
26
26
  // enumerate, so both the CLI's confirm/wizard flows (which re-export them) and
27
27
  // the programmatic `validateScaffoldInputs` share one source of truth. Keep
@@ -22,6 +22,8 @@ npx wrangler deploy # deploy to Cloudflare
22
22
  **Secrets:** local secrets live in \`.dev.vars\` (gitignored). Production secrets via \`wrangler secret put\`.
23
23
 
24
24
  **Observability:** enabled in \`wrangler.jsonc\`.
25
+
26
+ **Tests:** \`npm test\` runs vitest against the Worker's fetch handler (a sample test in \`src/index.test.ts\` asserts the DB-free \`/health\` contract + a 404 fallback). These are **plain vitest** unit tests over the handler — they run on Node's global \`Request\`/\`Response\`, no \`workerd\` runtime needed. Once the Worker binds KV / Durable Objects / D1 / R2 that must be exercised in the real runtime, graduate to \`@cloudflare/vitest-pool-workers\`.
25
27
  `;
26
28
  const WRANGLER_TEMPLATE = `{
27
29
  "$schema": "node_modules/wrangler/config-schema.json",
@@ -64,15 +66,66 @@ const PACKAGE_JSON_TEMPLATE = `{
64
66
  "scripts": {
65
67
  "dev": "wrangler dev",
66
68
  "deploy": "wrangler deploy",
67
- "typecheck": "tsc --noEmit"
69
+ "typecheck": "tsc --noEmit",
70
+ "test": "vitest run",
71
+ "test:watch": "vitest"
68
72
  },
69
73
  "devDependencies": {
70
74
  "@cloudflare/workers-types": "^5.20260714.1",
71
75
  "typescript": "^5.4.0",
76
+ "vitest": "^4.1.0",
72
77
  "wrangler": "^4.112.0"
73
78
  }
74
79
  }
75
80
  `;
81
+ // Plain vitest over the fetch handler (NOT @cloudflare/vitest-pool-workers).
82
+ // The Worker's routing + DB-free /health logic is pure Request→Response and runs
83
+ // on Node 20+'s global Request/Response/URL, so it needs no workerd runtime — the
84
+ // lightest thing that lets a fresh scaffold pass `npm test` out of the box,
85
+ // matching the node-service / library pattern. Include only src test files; the
86
+ // deployed bundle (main = src/index.ts) never imports them, so they're excluded
87
+ // from `wrangler deploy` automatically.
88
+ const VITEST_CONFIG_TEMPLATE = `import { defineConfig } from "vitest/config";
89
+
90
+ export default defineConfig({
91
+ test: {
92
+ include: ["src/**/*.test.ts"],
93
+ },
94
+ });
95
+ `;
96
+ // Sample test proving a brand-new cf-worker scaffold is green on first `npm test`.
97
+ // tsconfig already sets skipLibCheck, so vitest's own types resolve without
98
+ // pulling in @types/node (which would collide with @cloudflare/workers-types on
99
+ // the global Request/Response). The handler is imported and driven directly.
100
+ const SRC_INDEX_TEST_TEMPLATE = `// Smoke test for the {{slug}} Worker fetch handler.
101
+ //
102
+ // Plain vitest (Node), not @cloudflare/vitest-pool-workers: the /health and 404
103
+ // paths are pure Request→Response and read neither bindings nor the execution
104
+ // context, so Node's global Request/Response is enough. If this Worker later
105
+ // binds KV / Durable Objects / D1 / R2 (or reads \`cf\` request properties) that
106
+ // must run in the real runtime, graduate to @cloudflare/vitest-pool-workers.
107
+
108
+ import { describe, expect, it } from "vitest";
109
+
110
+ import worker, { type Env } from "./index";
111
+
112
+ // Minimal stand-ins — the routes under test touch neither.
113
+ const env = {} as Env;
114
+ const ctx = {} as ExecutionContext;
115
+
116
+ describe("{{slug}} Worker fetch handler", () => {
117
+ it("GET /health returns 200 {status: ok} without touching the database", async () => {
118
+ const res = await worker.fetch(new Request("https://example.com/health"), env, ctx);
119
+ expect(res.status).toBe(200);
120
+ expect(await res.json()).toEqual({ status: "ok" });
121
+ });
122
+
123
+ it("unknown routes return 404", async () => {
124
+ const res = await worker.fetch(new Request("https://example.com/nope"), env, ctx);
125
+ expect(res.status).toBe(404);
126
+ });
127
+ });
128
+ `;
76
129
  const TSCONFIG_TEMPLATE = `{
77
130
  "compilerOptions": {
78
131
  "target": "ES2022",
@@ -103,8 +156,10 @@ export function scaffoldCfWorker(inputs, opts) {
103
156
  const typeSpecific = [
104
157
  { path: "wrangler.jsonc", content: sub(WRANGLER_TEMPLATE, inputs, opts, spec) },
105
158
  { path: "src/index.ts", content: sub(SRC_INDEX_TEMPLATE, inputs, opts, spec) },
159
+ { path: "src/index.test.ts", content: sub(SRC_INDEX_TEST_TEMPLATE, inputs, opts, spec) },
106
160
  { path: "package.json", content: sub(PACKAGE_JSON_TEMPLATE, inputs, opts, spec) },
107
161
  { path: "tsconfig.json", content: sub(TSCONFIG_TEMPLATE, inputs, opts, spec) },
162
+ { path: "vitest.config.ts", content: sub(VITEST_CONFIG_TEMPLATE, inputs, opts, spec) },
108
163
  { path: ".dev.vars", content: sub(DEV_VARS_TEMPLATE, inputs, opts, spec) },
109
164
  ];
110
165
  return [...base, ...typeSpecific];
@@ -71,6 +71,7 @@ function quickStartFor(inputs) {
71
71
  "```bash",
72
72
  "npm install",
73
73
  "npm run dev # local wrangler dev server",
74
+ "npm test # vitest (fetch-handler unit tests)",
74
75
  "npm run deploy # wrangler deploy",
75
76
  "```",
76
77
  ].join("\n");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zero2webmaster/starter-kit",
3
- "version": "0.4.0",
3
+ "version": "0.5.0",
4
4
  "description": "Node CLI to scaffold new Z2W projects from canonical Templates + AGENTS.md.",
5
5
  "author": {
6
6
  "name": "Dr. Kerry Kriger",