@rexezuge/create-worker 0.0.0-stage → 1.13.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.
Files changed (63) hide show
  1. package/README.md +67 -2
  2. package/dist/bin.d.ts +3 -0
  3. package/dist/bin.d.ts.map +1 -0
  4. package/dist/bin.js +4 -0
  5. package/dist/bin.js.map +7 -0
  6. package/dist/cli.d.ts +11 -0
  7. package/dist/cli.d.ts.map +1 -0
  8. package/dist/cli.js +11 -0
  9. package/dist/cli.js.map +7 -0
  10. package/dist/configs.d.ts +25 -0
  11. package/dist/configs.d.ts.map +1 -0
  12. package/dist/configs.js +21 -0
  13. package/dist/configs.js.map +7 -0
  14. package/dist/features.d.ts +8 -0
  15. package/dist/features.d.ts.map +1 -0
  16. package/dist/features.js +1 -0
  17. package/dist/features.js.map +7 -0
  18. package/dist/index.d.ts +7 -0
  19. package/dist/index.d.ts.map +1 -0
  20. package/dist/index.js +1 -0
  21. package/dist/index.js.map +7 -0
  22. package/dist/render.d.ts +19 -0
  23. package/dist/render.d.ts.map +1 -0
  24. package/dist/render.js +1 -0
  25. package/dist/render.js.map +7 -0
  26. package/dist/scaffold.d.ts +36 -0
  27. package/dist/scaffold.d.ts.map +1 -0
  28. package/dist/scaffold.js +2 -0
  29. package/dist/scaffold.js.map +7 -0
  30. package/dist/versions.d.ts +2 -0
  31. package/dist/versions.d.ts.map +1 -0
  32. package/dist/versions.js +1 -0
  33. package/dist/versions.js.map +7 -0
  34. package/package.json +43 -3
  35. package/templates/background/apps/background/src/index.ts.tpl +21 -0
  36. package/templates/base/.editorconfig.tpl +12 -0
  37. package/templates/base/.gitignore.tpl +10 -0
  38. package/templates/base/.nvmrc.tpl +1 -0
  39. package/templates/base/.prettierignore.tpl +6 -0
  40. package/templates/base/AGENTS.md.tpl +37 -0
  41. package/templates/base/LICENSE.tpl +21 -0
  42. package/templates/base/README.md.tpl +11 -0
  43. package/templates/base/apps/api/src/app.ts.tpl +35 -0
  44. package/templates/base/apps/api/src/env.d.ts.tpl +21 -0
  45. package/templates/base/apps/api/src/index.ts.tpl +38 -0
  46. package/templates/base/eslint.config.mjs.tpl +3 -0
  47. package/templates/base/packages/contracts/src/index.ts.tpl +20 -0
  48. package/templates/base/packages/domain/src/index.ts.tpl +8 -0
  49. package/templates/base/test/unit/user-me.test.ts.tpl +34 -0
  50. package/templates/base/tsconfig.json.tpl +5 -0
  51. package/templates/base/vitest.config.mts.tpl +14 -0
  52. package/templates/web/apps/web/index.html.tpl +12 -0
  53. package/templates/web/apps/web/src/App.tsx.tpl +26 -0
  54. package/templates/web/apps/web/src/api.ts.tpl +8 -0
  55. package/templates/web/apps/web/src/i18n.ts.tpl +10 -0
  56. package/templates/web/apps/web/src/locales/en/translation.json.tpl +12 -0
  57. package/templates/web/apps/web/src/main.tsx.tpl +12 -0
  58. package/templates/web/apps/web/src/styles.css.tpl +2 -0
  59. package/templates/web/apps/web/src/vite-env.d.ts.tpl +1 -0
  60. package/templates/web/apps/web/vite.config.ts.tpl +8 -0
  61. package/templates/web/functions/[[path]].ts.tpl +1 -0
  62. package/templates/web/test/web/app.test.tsx.tpl +9 -0
  63. package/templates/web/test/web/spa.test.ts.tpl +18 -0
package/README.md CHANGED
@@ -1,3 +1,68 @@
1
- # Temporary Holding Version
1
+ # `@rexezuge/create-worker`
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Scaffold a Rexezuge-CloudflareWorkers repo: the canonical tree from RFC 0001 ("Canonical consumer repo"), wired to the kit, passing `rexezuge doctor` at 100%.
4
+
5
+ ```bash
6
+ pnpm create @rexezuge/worker my-service --features d1,web,background,backup-d1
7
+ cd my-service
8
+ pnpm install
9
+ pnpm run checks
10
+ ```
11
+
12
+ `pnpm create @rexezuge/worker` resolves to this package (`@rexezuge/create-worker`, bin `create-worker`). Flags only; there are no prompts.
13
+
14
+ | Flag | Meaning |
15
+ | ------------------- | ----------------------------------------------------------------------------------- |
16
+ | `--features <list>` | Comma-separated: `d1`, `web`, `background`, `backup-d1` (needs `d1`). Default none. |
17
+ | `--name <name>` | Package name; defaults to the directory's name (lower-case letters, digits, `-`). |
18
+ | `--scope <@scope>` | npm scope of the workspace packages; defaults to `@<name>`. |
19
+ | `--author <text>` | Copyright holder for the `LICENSE`; defaults to `The <Title> Authors`. |
20
+ | `--no-doctor` | Skip the conformance check after writing. |
21
+
22
+ The target directory must not exist or must be empty. Exit 0 means the repo was written and doctor scored it 100; 1 otherwise.
23
+
24
+ ## What you get
25
+
26
+ ```
27
+ .rexezuge.jsonc manifest: features, layers, coverage floor (a ratchet: raise it as tests grow)
28
+ pnpm-workspace.yaml catalog for every @rexezuge/* and toolchain dependency; no overrides
29
+ eslint.config.mjs vitest.config.mts tsconfig.json package.json "prettier" all presets
30
+ apps/api/ createApiApp + accessAuth + registerContract(userContract), GET /user/me; wrangler.template.jsonc
31
+ apps/background/ CronTasksDurableObject + TaskRegistry (background)
32
+ apps/web/ React 19 + Vite + Tailwind 4: createSpaI18n, useCurrentUser, createContractClient (web)
33
+ functions/[[path]].ts export { onRequest } from '@rexezuge/tooling/pages-proxy' (web)
34
+ packages/contracts/ the endpoint definition both sides share
35
+ packages/domain/ services and DAOs
36
+ migrations/ + migrations.lock.json the @rexezuge/identity migration, locked (d1)
37
+ test/unit, test/web @rexezuge/testing: forged Access tokens, in-memory D1; contract client through jsdom
38
+ .github/workflows/*.yml thin callers of the SDK reusable workflows (@v1) (backup-d1 adds backup-d1.yml)
39
+ AGENTS.md, CLAUDE.md -> AGENTS.md links the SDK conventions
40
+ LICENSE .editorconfig .nvmrc .gitignore .prettierignore
41
+ ```
42
+
43
+ Identity is the family's `UserIdentityService` when `d1` is on (the verified address resolves to a stable `usr_` account key); without D1 the lower-cased address is the key.
44
+ The Workers types come from `@cloudflare/workers-types` and a hand-written `Env` in `apps/api/src/env.d.ts`, so the repo typechecks before `pnpm run typegen`.
45
+
46
+ ## Templates
47
+
48
+ `templates/` ships with the package (`files`). Each file is rendered by token replacement only (no template engine):
49
+
50
+ - `{{name}}`, `{{scope}}`, `{{Title}}`, `{{year}}`, `{{author}}`. Any other `{{token}}` (the SPA's i18next `{{email}}`) is left as written.
51
+ - `{{#d1}} ... {{/d1}}` keeps its body when the feature is on, `{{^d1}} ... {{/d1}}` when off. Features: `d1`, `web`, `background`, `backup`. Tags alone on a line take the line with them.
52
+ - A trailing `.tpl` is stripped from the output name, so dotfiles and `.ts` sources are not linted, formatted or published as real files.
53
+
54
+ `templates/base` is always written; `web` and `background` are added with their feature. Generated files (`.rexezuge.jsonc`, the package.json files, `pnpm-workspace.yaml`, tsconfigs, the wrangler template, the migration and its lock, the workflow callers)
55
+ come from `src/configs.ts` and `@rexezuge/cli`, formatted the way Prettier would, so a fresh repo passes `format:check`.
56
+
57
+ ## Extending
58
+
59
+ The generated repo is yours: it holds no reference to this package after the scaffold. To change what new repos start with, edit the templates here and keep the integration test
60
+ (`src/create-worker.test.ts`: scaffold into a temp dir, run `rexezuge doctor`) green for every feature combination.
61
+
62
+ ## Verifying this package
63
+
64
+ ```bash
65
+ pnpm --filter @rexezuge/create-worker build
66
+ pnpm --filter @rexezuge/create-worker typecheck
67
+ pnpm --filter @rexezuge/create-worker test:coverage
68
+ ```
package/dist/bin.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ export {};
3
+ //# sourceMappingURL=bin.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bin.d.ts","sourceRoot":"","sources":["../src/bin.ts"],"names":[],"mappings":""}
package/dist/bin.js ADDED
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env node
2
+ var o=Object.defineProperty;var e=(r,s)=>o(r,"name",{value:s,configurable:!0});import{run as t}from"./cli.js";process.exitCode=await t(process.argv.slice(2),{out:e(r=>process.stdout.write(`${r}
3
+ `),"out"),err:e(r=>process.stderr.write(`${r}
4
+ `),"err")});
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/bin.ts"],
4
+ "sourcesContent": ["#!/usr/bin/env node\nimport { run } from './cli.ts';\n\nprocess.exitCode = await run(process.argv.slice(2), {\n out: (line) => process.stdout.write(`${line}\\n`),\n err: (line) => process.stderr.write(`${line}\\n`),\n});\n"],
5
+ "mappings": ";+EACA,OAAS,OAAAA,MAAW,WAEpB,QAAQ,SAAW,MAAMA,EAAI,QAAQ,KAAK,MAAM,CAAC,EAAG,CAClD,IAAKC,EAACC,GAAS,QAAQ,OAAO,MAAM,GAAGA,CAAI;CAAI,EAA1C,OACL,IAAKD,EAACC,GAAS,QAAQ,OAAO,MAAM,GAAGA,CAAI;CAAI,EAA1C,OACN",
6
+ "names": ["run", "__name", "line"]
7
+ }
package/dist/cli.d.ts ADDED
@@ -0,0 +1,11 @@
1
+ interface Io {
2
+ out(line: string): void;
3
+ err(line: string): void;
4
+ }
5
+ /**
6
+ * `create-worker <dir> --features d1,web,background,backup-d1`: flags only, no prompts. Exit 0 when the repo was
7
+ * written and `rexezuge doctor` scored it 100%; 1 otherwise.
8
+ */
9
+ export declare function run(argv: readonly string[], io: Io): Promise<number>;
10
+ export {};
11
+ //# sourceMappingURL=cli.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"AAKA,UAAU,EAAE;IACV,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;CACzB;AAcD;;;GAGG;AACH,wBAAsB,GAAG,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,EAAE,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,CA+C1E"}
package/dist/cli.js ADDED
@@ -0,0 +1,11 @@
1
+ var l=Object.defineProperty;var c=(n,r)=>l(n,"name",{value:r,configurable:!0});import{parseArgs as m}from"node:util";import i from"node:path";import{parseFeatures as h}from"./features.js";import{doctorOf as g,scaffold as y}from"./scaffold.js";const p=`Usage: pnpm create @rexezuge/worker <dir> [options]
2
+ create-worker <dir> [options]
3
+
4
+ Options:
5
+ --features <list> comma-separated: d1, web, background, backup-d1 (default: none)
6
+ --name <name> package name (default: the directory's name)
7
+ --scope <@scope> npm scope (default: @<name>)
8
+ --author <text> copyright holder for the LICENSE
9
+ --no-doctor skip the conformance check after scaffolding
10
+ -h, --help
11
+ `;async function E(n,r){try{const{values:e,positionals:u}=m({args:[...n],allowPositionals:!0,strict:!0,options:{features:{type:"string"},name:{type:"string"},scope:{type:"string"},author:{type:"string"},"no-doctor":{type:"boolean"},help:{type:"boolean",short:"h"}}});if(e.help===!0)return r.out(p),0;const[t,...f]=u;if(t===void 0||f.length>0)return r.err(p),1;const s=y({dir:t,name:e.name??i.basename(i.resolve(t)),features:h(e.features),scope:e.scope,author:e.author});if(r.out(`Created ${s.dir} (${s.files.length} files)`),e["no-doctor"]!==!0){const a=await g(s.dir);if(r.out(`rexezuge doctor: ${a.score}/100`),a.score<100){const d=a.findings.filter(o=>o.status==="fail");for(const o of d)r.err(` ${o.id}: ${o.details.join("; ")}`);return 1}}return r.out(`Next: cd ${t} && pnpm install && pnpm run checks`),0}catch(e){return r.err(`create-worker: ${e instanceof Error?e.message:String(e)}`),1}}c(E,"run");export{E as run};
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/cli.ts"],
4
+ "sourcesContent": ["import { parseArgs } from 'node:util';\nimport path from 'node:path';\nimport { parseFeatures } from './features.ts';\nimport { doctorOf, scaffold } from './scaffold.ts';\n\ninterface Io {\n out(line: string): void;\n err(line: string): void;\n}\n\nconst USAGE = `Usage: pnpm create @rexezuge/worker <dir> [options]\n create-worker <dir> [options]\n\nOptions:\n --features <list> comma-separated: d1, web, background, backup-d1 (default: none)\n --name <name> package name (default: the directory's name)\n --scope <@scope> npm scope (default: @<name>)\n --author <text> copyright holder for the LICENSE\n --no-doctor skip the conformance check after scaffolding\n -h, --help\n`;\n\n/**\n * `create-worker <dir> --features d1,web,background,backup-d1`: flags only, no prompts. Exit 0 when the repo was\n * written and `rexezuge doctor` scored it 100%; 1 otherwise.\n */\nexport async function run(argv: readonly string[], io: Io): Promise<number> {\n try {\n const { values, positionals } = parseArgs({\n args: [...argv],\n allowPositionals: true,\n strict: true,\n options: {\n features: { type: 'string' },\n name: { type: 'string' },\n scope: { type: 'string' },\n author: { type: 'string' },\n 'no-doctor': { type: 'boolean' },\n help: { type: 'boolean', short: 'h' },\n },\n });\n if (values.help === true) {\n io.out(USAGE);\n return 0;\n }\n const [dir, ...extra] = positionals;\n if (dir === undefined || extra.length > 0) {\n io.err(USAGE);\n return 1;\n }\n const result = scaffold({\n dir,\n name: values.name ?? path.basename(path.resolve(dir)),\n features: parseFeatures(values.features),\n scope: values.scope,\n author: values.author,\n });\n io.out(`Created ${result.dir} (${result.files.length} files)`);\n if (values['no-doctor'] !== true) {\n const report = await doctorOf(result.dir);\n io.out(`rexezuge doctor: ${report.score}/100`);\n if (report.score < 100) {\n const failed = report.findings.filter((entry) => entry.status === 'fail');\n for (const finding of failed) io.err(` ${finding.id}: ${finding.details.join('; ')}`);\n return 1;\n }\n }\n io.out(`Next: cd ${dir} && pnpm install && pnpm run checks`);\n return 0;\n } catch (error: unknown) {\n io.err(`create-worker: ${error instanceof Error ? error.message : String(error)}`);\n return 1;\n }\n}\n"],
5
+ "mappings": "+EAAA,OAAS,aAAAA,MAAiB,YAC1B,OAAOC,MAAU,YACjB,OAAS,iBAAAC,MAAqB,gBAC9B,OAAS,YAAAC,EAAU,YAAAC,MAAgB,gBAOnC,MAAMC,EAAQ;;;;;;;;;;EAgBd,eAAsBC,EAAIC,EAAyBC,EAAM,CACvD,GAAI,CACF,KAAM,CAAE,OAAAC,EAAQ,YAAAC,CAAW,EAAKV,EAAU,CACxC,KAAM,CAAC,GAAGO,CAAI,EACd,iBAAkB,GAClB,OAAQ,GACR,QAAS,CACP,SAAU,CAAE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"io", "values", "positionals", "dir", "extra", "result", "report", "failed", "entry", "finding", "error", "__name"]
7
+ }
@@ -0,0 +1,25 @@
1
+ import type { FeatureFlags } from './render.ts';
2
+ type Json = Record<string, unknown>;
3
+ /**
4
+ * JSON the way Prettier prints it, so a fresh repo passes `format:check`: objects stay expanded, arrays of
5
+ * primitives sit on one line when they fit, anything else breaks per element.
6
+ */
7
+ export declare function jsonText(value: unknown, indent?: string, trailing?: boolean): string;
8
+ /**
9
+ * `.rexezuge.jsonc`: the manifest. Layers mirror the canonical tree, and the coverage floor starts where
10
+ * the scaffold's own tests land so the first `test:coverage` passes and every later one ratchets.
11
+ */
12
+ export declare function manifestText(name: string, scope: string, flags: FeatureFlags): string;
13
+ export declare function rootPackage(name: string, scope: string, flags: FeatureFlags): Json;
14
+ export declare function apiPackage(scope: string, flags: FeatureFlags): Json;
15
+ export declare function backgroundPackage(scope: string): Json;
16
+ export declare function webPackage(scope: string): Json;
17
+ export declare function libraryPackage(scope: string, dir: 'contracts' | 'domain'): Json;
18
+ export declare function tsconfigText(preset: 'base' | 'worker' | 'web', include: readonly string[], types?: readonly string[]): string;
19
+ /**
20
+ * `pnpm-workspace.yaml`: the packages, and a catalog of exactly the names the generated package.json files take from it.
21
+ */
22
+ export declare function workspaceYaml(packages: readonly Json[]): string;
23
+ export declare function wranglerTemplate(name: string, flags: FeatureFlags): string;
24
+ export {};
25
+ //# sourceMappingURL=configs.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"configs.d.ts","sourceRoot":"","sources":["../src/configs.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAEhD,KAAK,IAAI,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAEpC;;;GAGG;AACH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,OAAO,EAAE,MAAM,SAAK,EAAE,QAAQ,UAAQ,GAAG,MAAM,CAgB9E;AAQD;;;GAGG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,YAAY,GAAG,MAAM,CAyBrF;AAqBD,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,YAAY,GAAG,IAAI,CAuClF;AAED,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,YAAY,GAAG,IAAI,CAenE;AAED,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAWrD;AAED,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAsB9C;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,WAAW,GAAG,QAAQ,GAAG,IAAI,CAY/E;AAED,wBAAgB,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,QAAQ,GAAG,KAAK,EAAE,OAAO,EAAE,SAAS,MAAM,EAAE,EAAE,KAAK,CAAC,EAAE,SAAS,MAAM,EAAE,GAAG,MAAM,CAI7H;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,QAAQ,EAAE,SAAS,IAAI,EAAE,GAAG,MAAM,CAe/D;AAED,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,YAAY,GAAG,MAAM,CAqB1E"}
@@ -0,0 +1,21 @@
1
+ var u=Object.defineProperty;var s=(e,t)=>u(e,"name",{value:t,configurable:!0});import{CATALOG as m}from"./versions.js";function a(e,t="",n=!1){const r=`${t} `;if(Array.isArray(e)){if(e.length===0)return"[]";if(e.every(i=>typeof i!="object"||i===null)){const i=`[${e.map(c=>JSON.stringify(c)).join(", ")}]`;if(t.length+i.length<120)return i}return`[
2
+ ${e.map(i=>`${r}${a(i,r,n)}`).join(`,
3
+ `)}${n?",":""}
4
+ ${t}]`}if(typeof e=="object"&&e!==null){const i=Object.entries(e);return i.length===0?"{}":`{
5
+ ${i.map(([c,p])=>`${r}${JSON.stringify(c)}: ${a(p,r,n)}`).join(`,
6
+ `)}${n?",":""}
7
+ ${t}}`}return JSON.stringify(e)}s(a,"jsonText");const o=s(e=>Object.fromEntries([...e].sort((t,n)=>t.localeCompare(n)).map(t=>[t,"catalog:"])),"catalog"),d=s(e=>Object.fromEntries([...e].sort((t,n)=>t.localeCompare(n)).map(t=>[t,"workspace:*"])),"workspace");function b(e,t,n){const r={};n.d1&&(r.d1={binding:"DB",database:e,migrationsDir:"migrations"}),n.web&&(r.web={pages:!0,spaShell:!1}),n.background&&(r.background=!0,r.durableObjects=["CronTasks"]),n.backup&&(r.backupD1=!0);const i=[{name:"contracts",dir:"packages/contracts",mayImport:[]},{name:"domain",dir:"packages/domain",mayImport:["contracts"]},{name:"api",dir:"apps/api",mayImport:["domain","contracts",...n.background?["background"]:[]],http:!0}];return n.background&&i.push({name:"background",dir:"apps/background",mayImport:["domain","contracts"]}),n.web&&i.push({name:"web",dir:"apps/web",mayImport:["contracts"],browser:!0}),`${a({$schema:"./node_modules/@rexezuge/tooling/schema/manifest.schema.json",name:e,scope:t,features:r,layers:i,quality:{coverage:{lines:70,branches:15,functions:80,statements:70},godFiles:{soft:300,hard:400}}},"",!0)}
8
+ `}s(b,"manifestText");const g=["@types/node","@vitest/coverage-v8","@cloudflare/workers-types","eslint","eslint-config-prettier","eslint-plugin-prettier","eslint-plugin-regexp","eslint-plugin-sonarjs","eslint-plugin-unicorn","globals","jsonc-parser","prettier","typescript","typescript-eslint","vitest","wrangler"];function k(e,t,n){const r=n.web?["@rexezuge/web","@vitejs/plugin-react","eslint-plugin-react-hooks","jsdom","react","react-dom","@types/react","@types/react-dom"]:[];return{name:e,version:"0.0.0",private:!0,type:"module",packageManager:"pnpm@11.2.2",engines:{node:">=24"},scripts:{checks:"pnpm run typecheck && pnpm run lint:check && pnpm run test && pnpm run format:check",typecheck:"pnpm -r --if-present run typecheck && tsc --noEmit",lint:"NODE_OPTIONS=--max-old-space-size=6144 eslint --fix --quiet .","lint:check":"NODE_OPTIONS=--max-old-space-size=6144 eslint --quiet .",format:"prettier --write .","format:check":"prettier --check .",test:"vitest run","test:coverage":"vitest run --coverage",typegen:"wrangler types --config apps/api/wrangler.template.jsonc",doctor:"rexezuge doctor",...n.d1&&{"migrations:verify":"rexezuge migrations verify"}},prettier:"@rexezuge/tooling/prettier",devDependencies:{...o(["@rexezuge/cli","@rexezuge/testing","@rexezuge/tooling",...g,...r]),[`${t}/contracts`]:"workspace:*"}}}s(k,"rootPackage");function y(e,t){const n=["@rexezuge/http","@rexezuge/runtime",...t.d1?["@rexezuge/d1","@rexezuge/errors","@rexezuge/identity"]:[]];return{name:`${e}/api`,version:"0.0.0",private:!0,type:"module",main:"src/index.ts",scripts:{typecheck:"tsc --noEmit"},dependencies:{...o([...n,"chanfana","hono","zod"]),...d([`${e}/contracts`,`${e}/domain`,...t.background?[`${e}/background`]:[]])},devDependencies:o(["@cloudflare/workers-types","typescript"])}}s(y,"apiPackage");function x(e){return{name:`${e}/background`,version:"0.0.0",private:!0,type:"module",main:"src/index.ts",scripts:{typecheck:"tsc --noEmit"},dependencies:o(["@rexezuge/runtime"]),devDependencies:o(["@cloudflare/workers-types","typescript"])}}s(x,"backgroundPackage");function h(e){return{name:`${e}/web`,version:"0.0.0",private:!0,type:"module",scripts:{dev:"vite",build:"vite build",typecheck:"tsc --noEmit"},dependencies:{...o(["@rexezuge/web","i18next","lucide-react","react","react-dom","react-i18next","zod"]),...d([`${e}/contracts`])},devDependencies:o(["@rexezuge/tooling","@tailwindcss/vite","@types/react","@types/react-dom","@vitejs/plugin-react","tailwindcss","typescript","vite"])}}s(h,"webPackage");function $(e,t){return{name:`${e}/${t}`,version:"0.0.0",private:!0,type:"module",main:"src/index.ts",types:"src/index.ts",scripts:{typecheck:"tsc --noEmit"},dependencies:t==="contracts"?{...o(["@rexezuge/contracts","zod"])}:d([`${e}/contracts`]),devDependencies:o(["typescript"])}}s($,"libraryPackage");function w(e,t,n){const r={extends:`@rexezuge/tooling/tsconfig/${e}.json`,include:t};return n!==void 0&&(r.compilerOptions={types:n}),`${a(r)}
9
+ `}s(w,"tsconfigText");function v(e){const t=new Set;for(const r of e)for(const i of["dependencies","devDependencies"])for(const[c,p]of Object.entries(r[i]??{}))p==="catalog:"&&t.add(c);return`packages:
10
+ - 'apps/*'
11
+ - 'packages/*'
12
+
13
+ catalog:
14
+ ${[...t].sort((r,i)=>r.localeCompare(i)).map(r=>{const i=m[r];if(i===void 0)throw new Error(`no catalog version for ${r}`);return` ${r.startsWith("@")?`'${r}'`:r}: ${i}`}).join(`
15
+ `)}
16
+
17
+ allowBuilds:
18
+ esbuild: true
19
+ workerd: true
20
+ `}s(v,"workspaceYaml");function j(e,t){const n={$schema:"node_modules/wrangler/config-schema.json",name:e,main:"apps/api/src/index.ts",compatibility_date:"2026-11-01",compatibility_flags:["nodejs_compat"],observability:{enabled:!0},vars:{TEAM_DOMAIN:"https://REPLACE_ME.cloudflareaccess.com",POLICY_AUD:"REPLACE_ME"}};return t.d1&&(n.d1_databases=[{binding:"DB",database_name:e,database_id:"00000000-0000-0000-0000-000000000000",migrations_dir:"migrations"}]),t.background&&(n.durable_objects={bindings:[{name:"CRON_TASKS",class_name:"CronTasks"}]},n.migrations=[{tag:"v1",new_sqlite_classes:["CronTasks"]}],n.triggers={crons:["*/15 * * * *"]}),`${a(n,"",!0)}
21
+ `}s(j,"wranglerTemplate");export{y as apiPackage,x as backgroundPackage,a as jsonText,$ as libraryPackage,b as manifestText,k as rootPackage,w as tsconfigText,h as webPackage,v as workspaceYaml,j as wranglerTemplate};
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/configs.ts"],
4
+ "sourcesContent": ["import { CATALOG } from './versions.ts';\nimport type { FeatureFlags } from './render.ts';\n\ntype Json = Record<string, unknown>;\n\n/**\n * JSON the way Prettier prints it, so a fresh repo passes `format:check`: objects stay expanded, arrays of\n * primitives sit on one line when they fit, anything else breaks per element.\n */\nexport function jsonText(value: unknown, indent = '', trailing = false): string {\n const inner = `${indent} `;\n if (Array.isArray(value)) {\n if (value.length === 0) return '[]';\n if (value.every((item) => typeof item !== 'object' || item === null)) {\n const line = `[${value.map((item) => JSON.stringify(item)).join(', ')}]`;\n if (indent.length + line.length < 120) return line;\n }\n return `[\\n${value.map((item) => `${inner}${jsonText(item, inner, trailing)}`).join(',\\n')}${trailing ? ',' : ''}\\n${indent}]`;\n }\n if (typeof value === 'object' && value !== null) {\n const entries = Object.entries(value);\n if (entries.length === 0) return '{}';\n return `{\\n${entries.map(([key, item]) => `${inner}${JSON.stringify(key)}: ${jsonText(item, inner, trailing)}`).join(',\\n')}${trailing ? ',' : ''}\\n${indent}}`;\n }\n return JSON.stringify(value);\n}\ntype DepMap = Record<string, string>;\n\nconst catalog = (names: readonly string[]): DepMap =>\n Object.fromEntries([...names].sort((a, b) => a.localeCompare(b)).map((name) => [name, 'catalog:']));\nconst workspace = (names: readonly string[]): DepMap =>\n Object.fromEntries([...names].sort((a, b) => a.localeCompare(b)).map((name) => [name, 'workspace:*']));\n\n/**\n * `.rexezuge.jsonc`: the manifest. Layers mirror the canonical tree, and the coverage floor starts where\n * the scaffold's own tests land so the first `test:coverage` passes and every later one ratchets.\n */\nexport function manifestText(name: string, scope: string, flags: FeatureFlags): string {\n const features: Json = {};\n if (flags.d1) features['d1'] = { binding: 'DB', database: name, migrationsDir: 'migrations' };\n if (flags.web) features['web'] = { pages: true, spaShell: false };\n if (flags.background) {\n features['background'] = true;\n features['durableObjects'] = ['CronTasks'];\n }\n if (flags.backup) features['backupD1'] = true;\n const layers: Json[] = [\n { name: 'contracts', dir: 'packages/contracts', mayImport: [] },\n { name: 'domain', dir: 'packages/domain', mayImport: ['contracts'] },\n { name: 'api', dir: 'apps/api', mayImport: ['domain', 'contracts', ...(flags.background ? ['background'] : [])], http: true },\n ];\n if (flags.background) layers.push({ name: 'background', dir: 'apps/background', mayImport: ['domain', 'contracts'] });\n if (flags.web) layers.push({ name: 'web', dir: 'apps/web', mayImport: ['contracts'], browser: true });\n const manifest: Json = {\n $schema: './node_modules/@rexezuge/tooling/schema/manifest.schema.json',\n name,\n scope,\n features,\n layers,\n quality: { coverage: { lines: 70, branches: 15, functions: 80, statements: 70 }, godFiles: { soft: 300, hard: 400 } },\n };\n return `${jsonText(manifest, '', true)}\\n`;\n}\n\nconst TOOLCHAIN = [\n '@types/node',\n '@vitest/coverage-v8',\n '@cloudflare/workers-types',\n 'eslint',\n 'eslint-config-prettier',\n 'eslint-plugin-prettier',\n 'eslint-plugin-regexp',\n 'eslint-plugin-sonarjs',\n 'eslint-plugin-unicorn',\n 'globals',\n 'jsonc-parser',\n 'prettier',\n 'typescript',\n 'typescript-eslint',\n 'vitest',\n 'wrangler',\n];\n\nexport function rootPackage(name: string, scope: string, flags: FeatureFlags): Json {\n const web = flags.web\n ? [\n '@rexezuge/web',\n '@vitejs/plugin-react',\n 'eslint-plugin-react-hooks',\n 'jsdom',\n 'react',\n 'react-dom',\n '@types/react',\n '@types/react-dom',\n ]\n : [];\n return {\n name,\n version: '0.0.0',\n private: true,\n type: 'module',\n packageManager: 'pnpm@11.2.2',\n engines: { node: '>=24' },\n scripts: {\n checks: 'pnpm run typecheck && pnpm run lint:check && pnpm run test && pnpm run format:check',\n typecheck: 'pnpm -r --if-present run typecheck && tsc --noEmit',\n lint: 'NODE_OPTIONS=--max-old-space-size=6144 eslint --fix --quiet .',\n 'lint:check': 'NODE_OPTIONS=--max-old-space-size=6144 eslint --quiet .',\n format: 'prettier --write .',\n 'format:check': 'prettier --check .',\n test: 'vitest run',\n 'test:coverage': 'vitest run --coverage',\n typegen: 'wrangler types --config apps/api/wrangler.template.jsonc',\n doctor: 'rexezuge doctor',\n ...(flags.d1 && { 'migrations:verify': 'rexezuge migrations verify' }),\n },\n prettier: '@rexezuge/tooling/prettier',\n devDependencies: {\n ...catalog(['@rexezuge/cli', '@rexezuge/testing', '@rexezuge/tooling', ...TOOLCHAIN, ...web]),\n [`${scope}/contracts`]: 'workspace:*',\n },\n };\n}\n\nexport function apiPackage(scope: string, flags: FeatureFlags): Json {\n const kit = ['@rexezuge/http', '@rexezuge/runtime', ...(flags.d1 ? ['@rexezuge/d1', '@rexezuge/errors', '@rexezuge/identity'] : [])];\n return {\n name: `${scope}/api`,\n version: '0.0.0',\n private: true,\n type: 'module',\n main: 'src/index.ts',\n scripts: { typecheck: 'tsc --noEmit' },\n dependencies: {\n ...catalog([...kit, 'chanfana', 'hono', 'zod']),\n ...workspace([`${scope}/contracts`, `${scope}/domain`, ...(flags.background ? [`${scope}/background`] : [])]),\n },\n devDependencies: catalog(['@cloudflare/workers-types', 'typescript']),\n };\n}\n\nexport function backgroundPackage(scope: string): Json {\n return {\n name: `${scope}/background`,\n version: '0.0.0',\n private: true,\n type: 'module',\n main: 'src/index.ts',\n scripts: { typecheck: 'tsc --noEmit' },\n dependencies: catalog(['@rexezuge/runtime']),\n devDependencies: catalog(['@cloudflare/workers-types', 'typescript']),\n };\n}\n\nexport function webPackage(scope: string): Json {\n return {\n name: `${scope}/web`,\n version: '0.0.0',\n private: true,\n type: 'module',\n scripts: { dev: 'vite', build: 'vite build', typecheck: 'tsc --noEmit' },\n dependencies: {\n ...catalog(['@rexezuge/web', 'i18next', 'lucide-react', 'react', 'react-dom', 'react-i18next', 'zod']),\n ...workspace([`${scope}/contracts`]),\n },\n devDependencies: catalog([\n '@rexezuge/tooling',\n '@tailwindcss/vite',\n '@types/react',\n '@types/react-dom',\n '@vitejs/plugin-react',\n 'tailwindcss',\n 'typescript',\n 'vite',\n ]),\n };\n}\n\nexport function libraryPackage(scope: string, dir: 'contracts' | 'domain'): Json {\n return {\n name: `${scope}/${dir}`,\n version: '0.0.0',\n private: true,\n type: 'module',\n main: 'src/index.ts',\n types: 'src/index.ts',\n scripts: { typecheck: 'tsc --noEmit' },\n dependencies: dir === 'contracts' ? { ...catalog(['@rexezuge/contracts', 'zod']) } : workspace([`${scope}/contracts`]),\n devDependencies: catalog(['typescript']),\n };\n}\n\nexport function tsconfigText(preset: 'base' | 'worker' | 'web', include: readonly string[], types?: readonly string[]): string {\n const config: Json = { extends: `@rexezuge/tooling/tsconfig/${preset}.json`, include };\n if (types !== undefined) config['compilerOptions'] = { types };\n return `${jsonText(config)}\\n`;\n}\n\n/**\n * `pnpm-workspace.yaml`: the packages, and a catalog of exactly the names the generated package.json files take from it.\n */\nexport function workspaceYaml(packages: readonly Json[]): string {\n const used = new Set<string>();\n for (const pkg of packages) {\n for (const field of ['dependencies', 'devDependencies']) {\n for (const [dep, spec] of Object.entries((pkg[field] ?? {}) as DepMap)) if (spec === 'catalog:') used.add(dep);\n }\n }\n const entries = [...used]\n .sort((a, b) => a.localeCompare(b))\n .map((name) => {\n const version = CATALOG[name];\n if (version === undefined) throw new Error(`no catalog version for ${name}`);\n return ` ${name.startsWith('@') ? `'${name}'` : name}: ${version}`;\n });\n return `packages:\\n - 'apps/*'\\n - 'packages/*'\\n\\ncatalog:\\n${entries.join('\\n')}\\n\\nallowBuilds:\\n esbuild: true\\n workerd: true\\n`;\n}\n\nexport function wranglerTemplate(name: string, flags: FeatureFlags): string {\n const config: Json = {\n $schema: 'node_modules/wrangler/config-schema.json',\n name,\n main: 'apps/api/src/index.ts',\n compatibility_date: '2026-11-01',\n compatibility_flags: ['nodejs_compat'],\n observability: { enabled: true },\n vars: { TEAM_DOMAIN: 'https://REPLACE_ME.cloudflareaccess.com', POLICY_AUD: 'REPLACE_ME' },\n };\n if (flags.d1) {\n config['d1_databases'] = [\n { binding: 'DB', database_name: name, database_id: '00000000-0000-0000-0000-000000000000', migrations_dir: 'migrations' },\n ];\n }\n if (flags.background) {\n config['durable_objects'] = { bindings: [{ name: 'CRON_TASKS', class_name: 'CronTasks' }] };\n config['migrations'] = [{ tag: 'v1', new_sqlite_classes: ['CronTasks'] }];\n config['triggers'] = { crons: ['*/15 * * * *'] };\n }\n return `${jsonText(config, '', true)}\\n`;\n}\n"],
5
+ "m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ent", "trailing", "inner", "item", "line", "entries", "key", "__name", "catalog", "names", "a", "b", "name", "workspace", "manifestText", "scope", "flags", "features", "layers", "TOOLCHAIN", "rootPackage", "web", "apiPackage", "kit", "backgroundPackage", "webPackage", "libraryPackage", "dir", "tsconfigText", "preset", "include", "types", "config", "workspaceYaml", "packages", "used", "pkg", "field", "dep", "spec", "version", "wranglerTemplate"]
7
+ }
@@ -0,0 +1,8 @@
1
+ import type { FeatureFlags } from './render.ts';
2
+ export declare const KNOWN_FEATURES: readonly ["d1", "web", "background", "backup-d1"];
3
+ /**
4
+ * Parse `--features d1,web,background,backup-d1`. An unknown name is an error (a typo must not scaffold a
5
+ * smaller repo than asked for), and `backup-d1` needs `d1`.
6
+ */
7
+ export declare function parseFeatures(list: string | undefined): FeatureFlags;
8
+ //# sourceMappingURL=features.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"features.d.ts","sourceRoot":"","sources":["../src/features.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAEhD,eAAO,MAAM,cAAc,mDAAoD,CAAC;AAEhF;;;GAGG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,GAAG,YAAY,CAUpE"}
@@ -0,0 +1 @@
1
+ var u=Object.defineProperty;var t=(a,r)=>u(a,"name",{value:r,configurable:!0});const s=["d1","web","background","backup-d1"];function d(a){const r=(a??"").split(",").map(e=>e.trim()).filter(e=>e!==""),o=r.filter(e=>!s.includes(e));if(o.length>0)throw new Error(`unknown feature(s): ${o.join(", ")} (known: ${s.join(", ")})`);const n=new Set(r);if(n.has("backup-d1")&&!n.has("d1"))throw new Error("feature backup-d1 needs d1");return{d1:n.has("d1"),web:n.has("web"),background:n.has("background"),backup:n.has("backup-d1")}}t(d,"parseFeatures");export{s as KNOWN_FEATURES,d as parseFeatures};
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/features.ts"],
4
+ "sourcesContent": ["import type { FeatureFlags } from './render.ts';\n\nexport const KNOWN_FEATURES = ['d1', 'web', 'background', 'backup-d1'] as const;\n\n/**\n * Parse `--features d1,web,background,backup-d1`. An unknown name is an error (a typo must not scaffold a\n * smaller repo than asked for), and `backup-d1` needs `d1`.\n */\nexport function parseFeatures(list: string | undefined): FeatureFlags {\n const names = (list ?? '')\n .split(',')\n .map((entry) => entry.trim())\n .filter((entry) => entry !== '');\n const unknown = names.filter((entry) => !(KNOWN_FEATURES as readonly string[]).includes(entry));\n if (unknown.length > 0) throw new Error(`unknown feature(s): ${unknown.join(', ')} (known: ${KNOWN_FEATURES.join(', ')})`);\n const on = new Set(names);\n if (on.has('backup-d1') && !on.has('d1')) throw new Error('feature backup-d1 needs d1');\n return { d1: on.has('d1'), web: on.has('web'), background: on.has('background'), backup: on.has('backup-d1') };\n}\n"],
5
+ "mappings": "+EAEO,MAAMA,EAAiB,CAAC,KAAM,MAAO,aAAc,WAAW,EAM/D,SAAUC,EAAcC,EAAwB,CACpD,MAAMC,GAASD,GAAQ,IACpB,MAAM,GAAG,EACT,IAAKE,GAAUA,EAAM,KAAI,CAAE,EAC3B,OAAQA,GAAUA,IAAU,EAAE,EAC3BC,EAAUF,EAAM,OAAQC,GAAU,CAAEJ,EAAqC,SAASI,CAAK,CAAC,EAC9F,GAAIC,EAAQ,OAAS,EAAG,MAAM,IAAI,MAAM,uBAAuBA,EAAQ,KAAK,IAAI,CAAC,YAAYL,EAAe,KAAK,IAAI,CAAC,GAAG,EACzH,MAAMM,EAAK,IAAI,IAAIH,CAAK,EACxB,GAAIG,EAAG,IAAI,WAAW,GAAK,CAACA,EAAG,IAAI,IAAI,EAAG,MAAM,IAAI,MAAM,4BAA4B,EACtF,MAAO,CAAE,GAAIA,EAAG,IAAI,IAAI,EAAG,IAAKA,EAAG,IAAI,KAAK,EAAG,WAAYA,EAAG,IAAI,YAAY,EAAG,OAAQA,EAAG,IAAI,WAAW,CAAC,CAC9G,CAVgBC,EAAAN,EAAA",
6
+ "names": ["KNOWN_FEATURES", "parseFeatures", "list", "names", "entry", "unknown", "on", "__name"]
7
+ }
@@ -0,0 +1,7 @@
1
+ export { parseFeatures, KNOWN_FEATURES } from './features.ts';
2
+ export { render } from './render.ts';
3
+ export type { FeatureFlags, TemplateVars } from './render.ts';
4
+ export { doctorOf, scaffold } from './scaffold.ts';
5
+ export type { ScaffoldOptions, ScaffoldResult } from './scaffold.ts';
6
+ export { run } from './cli.ts';
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC9D,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,YAAY,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC9D,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACnD,YAAY,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AACrE,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1 @@
1
+ import{parseFeatures as e,KNOWN_FEATURES as f}from"./features.js";import{render as p}from"./render.js";import{doctorOf as x,scaffold as a}from"./scaffold.js";import{run as s}from"./cli.js";export{f as KNOWN_FEATURES,x as doctorOf,e as parseFeatures,p as render,s as run,a as scaffold};
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/index.ts"],
4
+ "sourcesContent": ["export { parseFeatures, KNOWN_FEATURES } from './features.ts';\nexport { render } from './render.ts';\nexport type { FeatureFlags, TemplateVars } from './render.ts';\nexport { doctorOf, scaffold } from './scaffold.ts';\nexport type { ScaffoldOptions, ScaffoldResult } from './scaffold.ts';\nexport { run } from './cli.ts';\n"],
5
+ "mappings": "AAAA,OAAS,iBAAAA,EAAe,kBAAAC,MAAsB,gBAC9C,OAAS,UAAAC,MAAc,cAEvB,OAAS,YAAAC,EAAU,YAAAC,MAAgB,gBAEnC,OAAS,OAAAC,MAAW",
6
+ "names": ["parseFeatures", "KNOWN_FEATURES", "render", "doctorOf", "scaffold", "run"]
7
+ }
@@ -0,0 +1,19 @@
1
+ /**
2
+ * The template renderer: token replacement and feature blocks, nothing else.
3
+ *
4
+ * - `{{name}}`, `{{scope}}`, `{{Title}}`, `{{year}}`, `{{author}}` are replaced. Any other `{{token}}`
5
+ * is left exactly as written (the SPA's `{{email}}` i18next placeholder is not ours).
6
+ * - `{{#feature}} ... {{/feature}}` keeps its body when the feature is on; `{{^feature}} ... {{/feature}}`
7
+ * when it is off. Tags alone on a line take the line with them; tags inline leave the surrounding text alone.
8
+ */
9
+ export type FeatureName = 'd1' | 'web' | 'background' | 'backup';
10
+ export type FeatureFlags = Readonly<Record<FeatureName, boolean>>;
11
+ export interface TemplateVars {
12
+ readonly name: string;
13
+ readonly scope: string;
14
+ readonly Title: string;
15
+ readonly year: string;
16
+ readonly author: string;
17
+ }
18
+ export declare function render(template: string, vars: TemplateVars, flags: FeatureFlags): string;
19
+ //# sourceMappingURL=render.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"render.d.ts","sourceRoot":"","sources":["../src/render.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,MAAM,MAAM,WAAW,GAAG,IAAI,GAAG,KAAK,GAAG,YAAY,GAAG,QAAQ,CAAC;AAEjE,MAAM,MAAM,YAAY,GAAG,QAAQ,CAAC,MAAM,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC,CAAC;AAElE,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB;AAKD,wBAAgB,MAAM,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,YAAY,EAAE,KAAK,EAAE,YAAY,GAAG,MAAM,CAUxF"}
package/dist/render.js ADDED
@@ -0,0 +1 @@
1
+ var b=Object.defineProperty;var p=(a,l)=>b(a,"name",{value:l,configurable:!0});const d=/^[ \t]*\{\{([#^])(d1|web|background|backup)\}\}[ \t]*\n([\s\S]*?)^[ \t]*\{\{\/\2\}\}[ \t]*\n/gm,g=/\{\{([#^])(d1|web|background|backup)\}\}([^\n]*?)\{\{\/\2\}\}/g;function _(a,l,s){const u=p((t,c,r)=>t==="#"===s[c]?r:"","resolve");let e=a;for(let t="";t!==e;)t=e,e=e.replaceAll(d,(c,r,n,o)=>u(r,n,o)).replaceAll(g,(c,r,n,o)=>u(r,n,o));return e.replaceAll(/\{\{(name|scope|Title|year|author)\}\}/g,(t,c)=>l[c])}p(_,"render");export{_ as render};
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/render.ts"],
4
+ "sourcesContent": ["/**\n * The template renderer: token replacement and feature blocks, nothing else.\n *\n * - `{{name}}`, `{{scope}}`, `{{Title}}`, `{{year}}`, `{{author}}` are replaced. Any other `{{token}}`\n * is left exactly as written (the SPA's `{{email}}` i18next placeholder is not ours).\n * - `{{#feature}} ... {{/feature}}` keeps its body when the feature is on; `{{^feature}} ... {{/feature}}`\n * when it is off. Tags alone on a line take the line with them; tags inline leave the surrounding text alone.\n */\nexport type FeatureName = 'd1' | 'web' | 'background' | 'backup';\n\nexport type FeatureFlags = Readonly<Record<FeatureName, boolean>>;\n\nexport interface TemplateVars {\n readonly name: string;\n readonly scope: string;\n readonly Title: string;\n readonly year: string;\n readonly author: string;\n}\n\nconst LINE_BLOCK = /^[ \\t]*\\{\\{([#^])(d1|web|background|backup)\\}\\}[ \\t]*\\n([\\s\\S]*?)^[ \\t]*\\{\\{\\/\\2\\}\\}[ \\t]*\\n/gm;\nconst INLINE_BLOCK = /\\{\\{([#^])(d1|web|background|backup)\\}\\}([^\\n]*?)\\{\\{\\/\\2\\}\\}/g;\n\nexport function render(template: string, vars: TemplateVars, flags: FeatureFlags): string {\n const resolve = (kind: string, feature: string, body: string): string => ((kind === '#') === flags[feature as FeatureName] ? body : '');\n let text = template;\n for (let previous = ''; previous !== text;) {\n previous = text;\n text = text\n .replaceAll(LINE_BLOCK, (_match, kind: string, feature: string, body: string) => resolve(kind, feature, body))\n .replaceAll(INLINE_BLOCK, (_match, kind: string, feature: string, body: string) => resolve(kind, feature, body));\n }\n return text.replaceAll(/\\{\\{(name|scope|Title|year|author)\\}\\}/g, (_match, key: keyof TemplateVars) => vars[key]);\n}\n"],
5
+ "mappings": "+EAoBA,MAAMA,EAAa,iGACbC,EAAe,iEAEf,SAAUC,EAAOC,EAAkBC,EAAoBC,EAAmB,CAC9E,MAAMC,EAAUC,EAAA,CAACC,EAAcC,EAAiBC,IAA2BF,IAAS,MAASH,EAAMI,CAAsB,EAAIC,EAAO,GAApH,WAChB,IAAIC,EAAOR,EACX,QAASS,EAAW,GAAIA,IAAaD,GACnCC,EAAWD,EACXA,EAAOA,EACJ,WAAWX,EAAY,CAACa,EAAQL,EAAcC,EAAiBC,IAAiBJ,EAAQE,EAAMC,EAASC,CAAI,CAAC,EAC5G,WAAWT,EAAc,CAACY,EAAQL,EAAcC,EAAiBC,IAAiBJ,EAAQE,EAAMC,EAASC,CAAI,CAAC,EAEnH,OAAOC,EAAK,WAAW,0CAA2C,CAACE,EAAQC,IAA4BV,EAAKU,CAAG,CAAC,CAClH,CAVgBP,EAAAL,EAAA",
6
+ "names": ["LINE_BLOCK", "INLINE_BLOCK", "render", "template", "vars", "flags", "resolve", "__name", "kind", "feature", "body", "text", "previous", "_match", "key"]
7
+ }
@@ -0,0 +1,36 @@
1
+ import type { DoctorReport } from '@rexezuge/cli';
2
+ import type { FeatureFlags } from './render.ts';
3
+ export interface ScaffoldOptions {
4
+ /**
5
+ Directory to create; it must not exist or must be empty.
6
+ */
7
+ readonly dir: string;
8
+ /**
9
+ npm-style name: lower-case letters, digits, hyphens. Also the default scope.
10
+ */
11
+ readonly name: string;
12
+ readonly features: FeatureFlags;
13
+ /**
14
+ npm scope with its `@`. Defaults to `@<name>`.
15
+ */
16
+ readonly scope?: string;
17
+ /**
18
+ Copyright holder for the LICENSE. Defaults to `The <Title> Authors`.
19
+ */
20
+ readonly author?: string;
21
+ readonly year?: string;
22
+ }
23
+ export interface ScaffoldResult {
24
+ readonly dir: string;
25
+ readonly files: readonly string[];
26
+ }
27
+ /**
28
+ * Write the canonical repo (RFC 0001, "Canonical consumer repo") for the chosen features into `options.dir`.
29
+ * Nothing is installed; the caller runs `pnpm install`.
30
+ */
31
+ export declare function scaffold(options: ScaffoldOptions): ScaffoldResult;
32
+ /**
33
+ * Run `rexezuge doctor` against a scaffolded directory (no install needed).
34
+ */
35
+ export declare function doctorOf(dir: string): Promise<DoctorReport>;
36
+ //# sourceMappingURL=scaffold.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scaffold.d.ts","sourceRoot":"","sources":["../src/scaffold.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAgBlD,OAAO,KAAK,EAAE,YAAY,EAAgB,MAAM,aAAa,CAAC;AAE9D,MAAM,WAAW,eAAe;IAC9B;;MAEE;IACF,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB;;MAEE;IACF,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,QAAQ,EAAE,YAAY,CAAC;IAChC;;MAEE;IACF,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IACxB;;MAEE;IACF,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,CAAC;CACnC;AAqBD;;;GAGG;AACH,wBAAgB,QAAQ,CAAC,OAAO,EAAE,eAAe,GAAG,cAAc,CAmEjE;AAgBD;;GAEG;AACH,wBAAgB,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC,CAE3D"}
@@ -0,0 +1,2 @@
1
+ var S=Object.defineProperty;var p=(o,t)=>S(o,"name",{value:t,configurable:!0});import{existsSync as x,mkdirSync as b,readdirSync as j,readFileSync as A,symlinkSync as M,writeFileSync as h}from"node:fs";import n from"node:path";import{fileURLToPath as P}from"node:url";import{callersFor as F,planIdentity as z,runDoctor as D}from"@rexezuge/cli";import{parseManifest as y}from"@rexezuge/tooling/manifest";import{verifyMigrations as L}from"@rexezuge/tooling/scripts/verify-migrations";import{apiPackage as U,backgroundPackage as C,libraryPackage as $,jsonText as O,manifestText as N,rootPackage as R,tsconfigText as g,webPackage as Y,workspaceYaml as q,wranglerTemplate as G}from"./configs.js";import{render as I}from"./render.js";const B=P(new URL("../templates",import.meta.url)),H=/^[a-z][a-z0-9-]*$/;function J(o){return o.split("-").map(t=>`${t.charAt(0).toUpperCase()}${t.slice(1)}`).join(" ")}p(J,"titleOf");function T(o,t=""){return j(n.join(o,t),{withFileTypes:!0}).flatMap(e=>{const s=t===""?e.name:`${t}/${e.name}`;return e.isDirectory()?T(o,s):[s]})}p(T,"templateFiles");const f=p(o=>`${O(o)}
2
+ `,"json");function re(o){const{name:t,features:e}=o;if(!H.test(t))throw new Error(`invalid name "${t}": use lower-case letters, digits and hyphens, starting with a letter`);const s=o.scope??`@${t}`;if(!/^@[a-z][a-z0-9-]*$/.test(s))throw new Error(`invalid scope "${s}": expected @lower-case-name`);const a=n.resolve(o.dir);if(x(a)&&j(a).length>0)throw new Error(`${a} is not empty`);const d=J(t),E={name:t,scope:s,Title:d,year:o.year??String(new Date().getFullYear()),author:o.author??`The ${d} Authors`},r=new Map,v=["base",...e.web?["web"]:[],...e.background?["background"]:[]];for(const c of v){const l=n.join(B,c);for(const m of T(l))r.set(m.replace(/\.tpl$/,""),I(A(n.join(l,m),"utf8"),E,e))}const w=N(t,s,e);y(w),r.set(".rexezuge.jsonc",w);const i={root:R(t,s,e),api:U(s,e),contracts:$(s,"contracts"),domain:$(s,"domain"),...e.background&&{background:C(s)},...e.web&&{web:Y(s)}};r.set("package.json",f(i.root)),r.set("apps/api/package.json",f(i.api)),r.set("packages/contracts/package.json",f(i.contracts)),r.set("packages/domain/package.json",f(i.domain)),e.background&&r.set("apps/background/package.json",f(i.background)),e.web&&r.set("apps/web/package.json",f(i.web)),r.set("pnpm-workspace.yaml",q(Object.values(i)));const u=["@cloudflare/workers-types"];r.set("apps/api/tsconfig.json",g("worker",["src/**/*.ts"],u)),r.set("packages/contracts/tsconfig.json",g("worker",["src/**/*.ts"],u)),r.set("packages/domain/tsconfig.json",g("worker",["src/**/*.ts"],u)),e.background&&r.set("apps/background/tsconfig.json",g("worker",["src/**/*.ts","../api/src/env.d.ts"],u)),e.web&&r.set("apps/web/tsconfig.json",g("web",["src/**/*.ts","src/**/*.tsx","vite.config.ts"])),r.set("apps/api/wrangler.template.jsonc",G(t,e));for(const c of F(y(w)))r.set(c.path,c.content);for(const[c,l]of r){const m=n.join(a,c);b(n.dirname(m),{recursive:!0}),h(m,l)}M("AGENTS.md",n.join(a,"CLAUDE.md"));const k=[...r.keys(),"CLAUDE.md"];return e.d1&&k.push(...K(a)),k.sort((c,l)=>c.localeCompare(l)),{dir:a,files:k}}p(re,"scaffold");function K(o){const t=n.join(o,"migrations"),e=z(t);if(e.action!=="write")throw new Error(`cannot scaffold migrations: ${e.reason}`);b(t,{recursive:!0}),h(n.join(t,e.file),e.sql);const s=L(t,{write:!0});if(s.problems.length>0)throw new Error(`migrations lock failed: ${s.problems.map(a=>a.problem).join("; ")}`);return[`migrations/${e.file}`,"migrations/migrations.lock.json"]}p(K,"writeMigrations");function se(o){return D(o)}p(se,"doctorOf");export{se as doctorOf,re as scaffold};
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/scaffold.ts"],
4
+ "sourcesContent": ["import { existsSync, mkdirSync, readdirSync, readFileSync, symlinkSync, writeFileSync } from 'node:fs';\nimport path from 'node:path';\nimport { fileURLToPath } from 'node:url';\nimport { callersFor, planIdentity, runDoctor } from '@rexezuge/cli';\nimport type { DoctorReport } from '@rexezuge/cli';\nimport { parseManifest } from '@rexezuge/tooling/manifest';\nimport { verifyMigrations } from '@rexezuge/tooling/scripts/verify-migrations';\nimport {\n apiPackage,\n backgroundPackage,\n libraryPackage,\n jsonText,\n manifestText,\n rootPackage,\n tsconfigText,\n webPackage,\n workspaceYaml,\n wranglerTemplate,\n} from './configs.ts';\nimport { render } from './render.ts';\nimport type { FeatureFlags, TemplateVars } from './render.ts';\n\nexport interface ScaffoldOptions {\n /**\n Directory to create; it must not exist or must be empty.\n */\n readonly dir: string;\n /**\n npm-style name: lower-case letters, digits, hyphens. Also the default scope.\n */\n readonly name: string;\n readonly features: FeatureFlags;\n /**\n npm scope with its `@`. Defaults to `@<name>`.\n */\n readonly scope?: string;\n /**\n Copyright holder for the LICENSE. Defaults to `The <Title> Authors`.\n */\n readonly author?: string;\n readonly year?: string;\n}\n\nexport interface ScaffoldResult {\n readonly dir: string;\n readonly files: readonly string[];\n}\n\nconst TEMPLATES = fileURLToPath(new URL('../templates', import.meta.url));\nconst NAME = /^[a-z][a-z0-9-]*$/;\n\nfunction titleOf(name: string): string {\n return name\n .split('-')\n .map((word) => `${word.charAt(0).toUpperCase()}${word.slice(1)}`)\n .join(' ');\n}\n\nfunction templateFiles(dir: string, prefix = ''): string[] {\n return readdirSync(path.join(dir, prefix), { withFileTypes: true }).flatMap((entry) => {\n const rel = prefix === '' ? entry.name : `${prefix}/${entry.name}`;\n return entry.isDirectory() ? templateFiles(dir, rel) : [rel];\n });\n}\n\nconst json = (value: unknown): string => `${jsonText(value)}\\n`;\n\n/**\n * Write the canonical repo (RFC 0001, \"Canonical consumer repo\") for the chosen features into `options.dir`.\n * Nothing is installed; the caller runs `pnpm install`.\n */\nexport function scaffold(options: ScaffoldOptions): ScaffoldResult {\n const { name, features: flags } = options;\n if (!NAME.test(name)) throw new Error(`invalid name \"${name}\": use lower-case letters, digits and hyphens, starting with a letter`);\n const scope = options.scope ?? `@${name}`;\n if (!/^@[a-z][a-z0-9-]*$/.test(scope)) throw new Error(`invalid scope \"${scope}\": expected @lower-case-name`);\n const dir = path.resolve(options.dir);\n if (existsSync(dir) && readdirSync(dir).length > 0) throw new Error(`${dir} is not empty`);\n\n const title = titleOf(name);\n const vars: TemplateVars = {\n name,\n scope,\n Title: title,\n year: options.year ?? String(new Date().getFullYear()),\n author: options.author ?? `The ${title} Authors`,\n };\n const out = new Map<string, string>();\n\n const groups = ['base', ...(flags.web ? ['web'] : []), ...(flags.background ? ['background'] : [])];\n for (const group of groups) {\n const root = path.join(TEMPLATES, group);\n for (const file of templateFiles(root)) {\n out.set(file.replace(/\\.tpl$/, ''), render(readFileSync(path.join(root, file), 'utf8'), vars, flags));\n }\n }\n\n const manifest = manifestText(name, scope, flags);\n parseManifest(manifest); // the scaffold must never write a manifest its own tooling refuses\n out.set('.rexezuge.jsonc', manifest);\n\n const packages = {\n root: rootPackage(name, scope, flags),\n api: apiPackage(scope, flags),\n contracts: libraryPackage(scope, 'contracts'),\n domain: libraryPackage(scope, 'domain'),\n ...(flags.background && { background: backgroundPackage(scope) }),\n ...(flags.web && { web: webPackage(scope) }),\n };\n out.set('package.json', json(packages.root));\n out.set('apps/api/package.json', json(packages.api));\n out.set('packages/contracts/package.json', json(packages.contracts));\n out.set('packages/domain/package.json', json(packages.domain));\n if (flags.background) out.set('apps/background/package.json', json(packages.background));\n if (flags.web) out.set('apps/web/package.json', json(packages.web));\n out.set('pnpm-workspace.yaml', workspaceYaml(Object.values(packages)));\n\n const workersTypes = ['@cloudflare/workers-types'];\n out.set('apps/api/tsconfig.json', tsconfigText('worker', ['src/**/*.ts'], workersTypes));\n out.set('packages/contracts/tsconfig.json', tsconfigText('worker', ['src/**/*.ts'], workersTypes));\n out.set('packages/domain/tsconfig.json', tsconfigText('worker', ['src/**/*.ts'], workersTypes));\n if (flags.background)\n out.set('apps/background/tsconfig.json', tsconfigText('worker', ['src/**/*.ts', '../api/src/env.d.ts'], workersTypes));\n if (flags.web) out.set('apps/web/tsconfig.json', tsconfigText('web', ['src/**/*.ts', 'src/**/*.tsx', 'vite.config.ts']));\n out.set('apps/api/wrangler.template.jsonc', wranglerTemplate(name, flags));\n for (const caller of callersFor(parseManifest(manifest))) out.set(caller.path, caller.content);\n\n for (const [rel, content] of out) {\n const target = path.join(dir, rel);\n mkdirSync(path.dirname(target), { recursive: true });\n writeFileSync(target, content);\n }\n symlinkSync('AGENTS.md', path.join(dir, 'CLAUDE.md'));\n\n const files = [...out.keys(), 'CLAUDE.md'];\n if (flags.d1) files.push(...writeMigrations(dir));\n files.sort((a, b) => a.localeCompare(b));\n return { dir, files };\n}\n\n/**\n * The identity migration (the same SQL `rexezuge migrations add-identity` writes) and its lock.\n */\nfunction writeMigrations(dir: string): string[] {\n const migrations = path.join(dir, 'migrations');\n const plan = planIdentity(migrations);\n if (plan.action !== 'write') throw new Error(`cannot scaffold migrations: ${plan.reason}`);\n mkdirSync(migrations, { recursive: true });\n writeFileSync(path.join(migrations, plan.file), plan.sql);\n const report = verifyMigrations(migrations, { write: true });\n if (report.problems.length > 0) throw new Error(`migrations lock failed: ${report.problems.map((p) => p.problem).join('; ')}`);\n return [`migrations/${plan.file}`, 'migrations/migrations.lock.json'];\n}\n\n/**\n * Run `rexezuge doctor` against a scaffolded directory (no install needed).\n */\nexport function doctorOf(dir: string): Promise<DoctorReport> {\n return runDoctor(dir);\n}\n"],
5
+ "mappings": "+EAAA,OAAS,cAAAA,EAAY,aAAAC,E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AE,EACnDhD,EAAcgD,EAAQD,CAAO,CAC/B,CACAhD,EAAY,YAAaE,EAAK,KAAKyB,EAAK,WAAW,CAAC,EAEpD,MAAMuB,EAAQ,CAAC,GAAGX,EAAI,KAAI,EAAI,WAAW,EACzC,OAAIJ,EAAM,IAAIe,EAAM,KAAK,GAAGC,EAAgBxB,CAAG,CAAC,EAChDuB,EAAM,KAAK,CAACE,EAAGC,IAAMD,EAAE,cAAcC,CAAC,CAAC,EAChC,CAAE,IAAA1B,EAAK,MAAAuB,CAAK,CACrB,CAnEgBzB,EAAAQ,GAAA,YAwEhB,SAASkB,EAAgBxB,EAAW,CAClC,MAAM2B,EAAapD,EAAK,KAAKyB,EAAK,YAAY,EACxC4B,EAAOlD,EAAaiD,CAAU,EACpC,GAAIC,EAAK,SAAW,QAAS,MAAM,IAAI,MAAM,+BAA+BA,EAAK,MAAM,EAAE,EACzF1D,EAAUyD,EAAY,CAAE,UAAW,EAAI,CAAE,EACzCrD,EAAcC,EAAK,KAAKoD,EAAYC,EAAK,IAAI,EAAGA,EAAK,GAAG,EACxD,MAAMC,EAAShD,EAAiB8C,EAAY,CAAE,MAAO,EAAI,CAAE,EAC3D,GAAIE,EAAO,SAAS,OAAS,EAAG,MAAM,IAAI,MAAM,2BAA2BA,EAAO,SAAS,IAAKC,GAAMA,EAAE,OAAO,EAAE,KAAK,IAAI,CAAC,EAAE,EAC7H,MAAO,CAAC,cAAcF,EAAK,IAAI,GAAI,iCAAiC,CACtE,CATS9B,EAAA0B,EAAA,mBAcH,SAAUO,GAAS/B,EAAW,CAClC,OAAOrB,EAAUqB,CAAG,CACtB,CAFgBF,EAAAiC,GAAA",
6
+ "names": ["existsSync", "mkdirSync", "readdirSync", "readFileSync", "symlinkSync", "writeFileSync", "path", "fileURLToPath", "callersFor", "planIdentity", "runDoctor", "parseManifest", "verifyMigrations", "apiPackage", "backgroundPackage", "libraryPackage", "jsonText", "manifestText", "rootPackage", "tsconfigText", "webPackage", "workspaceYaml", "wranglerTemplate", "render", "TEMPLATES", "NAME", "titleOf", "name", "word", "__name", "templateFiles", "dir", "prefix", "entry", "rel", "json", "value", "scaffold", "options", "flags", "scope", "title", "vars", "out", "groups", "group", "root", "file", "manifest", "packages", "workersTypes", "caller", "content", "target", "files", "writeMigrations", "a", "b", "migrations", "plan", "report", "p", "doctorOf"]
7
+ }
@@ -0,0 +1,2 @@
1
+ export declare const CATALOG: Readonly<Record<string, string>>;
2
+ //# sourceMappingURL=versions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"versions.d.ts","sourceRoot":"","sources":["../src/versions.ts"],"names":[],"mappings":"AAQA,eAAO,MAAM,OAAO,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CA4CpD,CAAC"}
@@ -0,0 +1 @@
1
+ import{CLI_VERSION as t}from"@rexezuge/cli";const e=`^${t}`,i={"@rexezuge/cli":e,"@rexezuge/contracts":e,"@rexezuge/d1":e,"@rexezuge/errors":e,"@rexezuge/http":e,"@rexezuge/identity":e,"@rexezuge/runtime":e,"@rexezuge/shared":e,"@rexezuge/testing":e,"@rexezuge/tooling":e,"@rexezuge/web":e,"@cloudflare/workers-types":"^5.20261129.1","@tailwindcss/vite":"4.3.5","@types/node":"26.6.4","@types/react":"19.3.0","@types/react-dom":"19.3.0","@vitejs/plugin-react":"6.3.0","@vitest/coverage-v8":"4.1.11",chanfana:"3.7.0",eslint:"10.11.0","eslint-config-prettier":"10.1.8","eslint-plugin-prettier":"5.5.6","eslint-plugin-react-hooks":"7.1.1","eslint-plugin-regexp":"3.3.1","eslint-plugin-sonarjs":"4.2.2","eslint-plugin-unicorn":"76.0.0",globals:"17.13.0",hono:"4.13.19",i18next:"^27.2.2","jsonc-parser":"3.3.1",jsdom:"^31.0.1","lucide-react":"1.77.0",prettier:"3.9.9",react:"19.3.1","react-dom":"19.3.1","react-i18next":"^17.1.13",tailwindcss:"4.3.5",typescript:"6.0.3","typescript-eslint":"8.71.1",vite:"8.3.8",vitest:"4.1.11",wrangler:"4.161.0",zod:"^4.6.7"};export{i as CATALOG};
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/versions.ts"],
4
+ "sourcesContent": ["import { CLI_VERSION } from '@rexezuge/cli';\n\n/**\n * The `catalog:` of a scaffolded repo. The `@rexezuge/*` entries follow this CLI (the packages release in lockstep);\n * the rest are the toolchain pins the family converged on.\n */\nconst KIT = `^${CLI_VERSION}`;\n\nexport const CATALOG: Readonly<Record<string, string>> = {\n '@rexezuge/cli': KIT,\n '@rexezuge/contracts': KIT,\n '@rexezuge/d1': KIT,\n '@rexezuge/errors': KIT,\n '@rexezuge/http': KIT,\n '@rexezuge/identity': KIT,\n '@rexezuge/runtime': KIT,\n '@rexezuge/shared': KIT,\n '@rexezuge/testing': KIT,\n '@rexezuge/tooling': KIT,\n '@rexezuge/web': KIT,\n '@cloudflare/workers-types': '^5.20261129.1',\n '@tailwindcss/vite': '4.3.5',\n '@types/node': '26.6.4',\n '@types/react': '19.3.0',\n '@types/react-dom': '19.3.0',\n '@vitejs/plugin-react': '6.3.0',\n '@vitest/coverage-v8': '4.1.11',\n chanfana: '3.7.0',\n eslint: '10.11.0',\n 'eslint-config-prettier': '10.1.8',\n 'eslint-plugin-prettier': '5.5.6',\n 'eslint-plugin-react-hooks': '7.1.1',\n 'eslint-plugin-regexp': '3.3.1',\n 'eslint-plugin-sonarjs': '4.2.2',\n 'eslint-plugin-unicorn': '76.0.0',\n globals: '17.13.0',\n hono: '4.13.19',\n i18next: '^27.2.2',\n 'jsonc-parser': '3.3.1',\n jsdom: '^31.0.1',\n 'lucide-react': '1.77.0',\n prettier: '3.9.9',\n react: '19.3.1',\n 'react-dom': '19.3.1',\n 'react-i18next': '^17.1.13',\n tailwindcss: '4.3.5',\n typescript: '6.0.3',\n 'typescript-eslint': '8.71.1',\n vite: '8.3.8',\n vitest: '4.1.11',\n wrangler: '4.161.0',\n zod: '^4.6.7',\n};\n"],
5
+ "mappings": "AAAA,OAAS,eAAAA,MAAmB,gBAM5B,MAAMC,EAAM,IAAID,CAAW,GAEdE,EAA4C,CACvD,gBAAiBD,EACjB,sBAAuBA,EACvB,eAAgBA,EAChB,mBAAoBA,EACpB,iBAAkBA,EAClB,qBAAsBA,EACtB,oBAAqBA,EACrB,mBAAoBA,EACpB,oBAAqBA,EACrB,oBAAqBA,EACrB,gBAAiBA,EACjB,4BAA6B,gBAC7B,oBAAqB,QACrB,cAAe,SACf,eAAgB,SAChB,mBAAoB,SACpB,uBAAwB,QACxB,sBAAuB,SACvB,SAAU,QACV,OAAQ,UACR,yBAA0B,SAC1B,yBAA0B,QAC1B,4BAA6B,QAC7B,uBAAwB,QACxB,wBAAyB,QACzB,wBAAyB,SACzB,QAAS,UACT,KAAM,UACN,QAAS,UACT,eAAgB,QAChB,MAAO,UACP,eAAgB,SAChB,SAAU,QACV,MAAO,SACP,YAAa,SACb,gBAAiB,WACjB,YAAa,QACb,WAAY,QACZ,oBAAqB,SACrB,KAAM,QACN,OAAQ,SACR,SAAU,UACV,IAAK",
6
+ "names": ["CLI_VERSION", "KIT", "CATALOG"]
7
+ }
package/package.json CHANGED
@@ -1,6 +1,46 @@
1
1
  {
2
2
  "name": "@rexezuge/create-worker",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "1.13.0",
4
+ "private": false,
5
+ "license": "MIT",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/Rexezuge-CloudflareWorkers/SDK.git",
9
+ "directory": "packages/create-worker"
10
+ },
11
+ "type": "module",
12
+ "bin": {
13
+ "create-worker": "./dist/bin.js"
14
+ },
15
+ "main": "./dist/index.js",
16
+ "types": "./dist/index.d.ts",
17
+ "exports": {
18
+ ".": {
19
+ "types": "./dist/index.d.ts",
20
+ "default": "./dist/index.js"
21
+ }
22
+ },
23
+ "files": [
24
+ "dist",
25
+ "templates"
26
+ ],
27
+ "engines": {
28
+ "node": ">=24"
29
+ },
30
+ "dependencies": {
31
+ "@rexezuge/cli": "1.13.0",
32
+ "@rexezuge/tooling": "1.13.0"
33
+ },
34
+ "devDependencies": {
35
+ "@types/node": "26.6.4",
36
+ "typescript": "6.0.3",
37
+ "vitest": "4.1.11"
38
+ },
39
+ "description": "Scaffold a Rexezuge-CloudflareWorkers repo: pnpm create @rexezuge/worker <dir> --features d1,web,background,backup-d1.",
40
+ "scripts": {
41
+ "build": "tsc -p tsconfig.json && node ../../scripts/minify-dist.mjs",
42
+ "typecheck": "tsc -p tsconfig.test.json --noEmit",
43
+ "test": "vitest run",
44
+ "test:coverage": "vitest run --coverage"
45
+ }
6
46
  }
@@ -0,0 +1,21 @@
1
+ import { AbstractScheduledTask, CronTasksDurableObject, createLogger, TaskRegistry } from '@rexezuge/runtime';
2
+
3
+ /**
4
+ * An example phase-1 task. Replace it with the repo's own; every run is contained, expired and bookkept by the base class.
5
+ */
6
+ class HeartbeatTask extends AbstractScheduledTask {
7
+ protected handleScheduledTask(): Promise<void> {
8
+ createLogger('background', '{{name}}').info('cron tick');
9
+ return Promise.resolve();
10
+ }
11
+ }
12
+
13
+ /**
14
+ * The standard cron Durable Object: `scheduled()` in the entry worker forwards each tick here.
15
+ * `fetch` and `onRequest` are the kit's `/run` contract; this class only decides what runs.
16
+ */
17
+ export class CronTasks extends CronTasksDurableObject<Env> {
18
+ protected createRegistry(): TaskRegistry {
19
+ return new TaskRegistry().register(1, new HeartbeatTask());
20
+ }
21
+ }
@@ -0,0 +1,12 @@
1
+ root = true
2
+
3
+ [*]
4
+ charset = utf-8
5
+ end_of_line = lf
6
+ indent_style = space
7
+ indent_size = 2
8
+ insert_final_newline = true
9
+ trim_trailing_whitespace = true
10
+
11
+ [*.md]
12
+ trim_trailing_whitespace = false
@@ -0,0 +1,10 @@
1
+ node_modules/
2
+ dist/
3
+ coverage/
4
+ .wrangler/
5
+ .dev.vars
6
+ /wrangler.jsonc
7
+ *.tsbuildinfo
8
+ {{#web}}
9
+ apps/web/dist/
10
+ {{/web}}
@@ -0,0 +1 @@
1
+ 24
@@ -0,0 +1,6 @@
1
+ dist/
2
+ coverage/
3
+ node_modules/
4
+ .wrangler/
5
+ pnpm-lock.yaml
6
+ worker-configuration.d.ts
@@ -0,0 +1,37 @@
1
+ # AGENTS.md
2
+
3
+ `{{name}}` is a Rexezuge-CloudflareWorkers family repo (pnpm workspace, Node 24). It owns its domain code; everything else
4
+ comes from `@rexezuge/*`. The conventions every family repo follows (commits, branches, god-file limits, `null` vs
5
+ `undefined`, UI copy casing) are in
6
+ [`docs/conventions.md` of the SDK](https://github.com/Rexezuge-CloudflareWorkers/SDK/blob/main/docs/conventions.md); the
7
+ design rules behind the kit are in its [design charter](https://github.com/Rexezuge-CloudflareWorkers/SDK/blob/main/docs/design-charter.md).
8
+
9
+ ## Commands
10
+
11
+ - `pnpm install`, then `pnpm run checks` (typecheck, lint, test, format).
12
+ - `pnpm exec rexezuge doctor` scores this repo against the family conventions and must stay at 100%;
13
+ `pnpm exec rexezuge sync --write` repairs what it can.
14
+ - `pnpm run lint` and `pnpm run format` repair in place; `lint:check` and `format:check` are the gates.
15
+ - `pnpm run typegen` regenerates the Workers types from the wrangler template.
16
+
17
+ ## Layout
18
+
19
+ - `.rexezuge.jsonc` is the manifest: features, import layers, coverage floor. The lint, test and CI tooling read it.
20
+ - `apps/api` is the entry worker: `createApiApp` plus routes registered from `packages/contracts`. Entry and routes only.
21
+ {{#background}}
22
+ - `apps/background` holds the Durable Objects: `CronTasksDurableObject` plus a `TaskRegistry`.
23
+ {{/background}}
24
+ {{#web}}
25
+ - `apps/web` is the React SPA (`@rexezuge/web`); `functions/[[path]].ts` is the Pages proxy to the API worker.
26
+ {{/web}}
27
+ - `packages/contracts` is the endpoint definitions both sides share. `packages/domain` is the services and data access.
28
+ {{#d1}}
29
+ - `migrations/` plus `migrations.lock.json`: `pnpm exec rexezuge migrations verify` is the gate, `migrations lock` records new files.
30
+ {{/d1}}
31
+
32
+ ## Rules
33
+
34
+ - No vendored copies of kit code: import it. Config files stay presets (`defineRepoLintConfig`, the Vitest factories, the tsconfig and Prettier presets).
35
+ - `@rexezuge/*` versions live in the pnpm `catalog:` only; no `overrides` pins.
36
+ - No `console` outside `apps/web`: use `createLogger`. No `hono`/`chanfana` outside the API layer.
37
+ - Workflows are callers of the SDK's reusable workflows; do not copy pipelines into this repo.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) {{year}} {{author}}
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,11 @@
1
+ # {{name}}
2
+
3
+ A Cloudflare Workers service on the Rexezuge family stack, scaffolded with `pnpm create @rexezuge/worker`.
4
+
5
+ ```bash
6
+ pnpm install
7
+ pnpm run checks
8
+ pnpm exec rexezuge doctor
9
+ ```
10
+
11
+ Endpoints are defined once in `packages/contracts` and served by `apps/api`. See `AGENTS.md` for the layout and rules.
@@ -0,0 +1,35 @@
1
+ import { createLogger } from '@rexezuge/runtime';
2
+ {{#d1}}
3
+ import { isD1DailyLimitError, openSession, readBookmark, withBookmark } from '@rexezuge/d1';
4
+ {{/d1}}
5
+ import { accessAuth, createApiApp, registerContract } from '@rexezuge/http/hono';
6
+ import type { ApiApp } from '@rexezuge/http/hono';
7
+ import { userContract } from '{{scope}}/contracts';
8
+ import { toUserProfile } from '{{scope}}/domain';
9
+
10
+ /**
11
+ * Maps a verified sign-in address to the stable account key. The worker injects the real one; a test injects a stub.
12
+ */
13
+ export type ResolveUserId = (email: string, env: Env) => Promise<string>;
14
+
15
+ export function createApp(resolveUserId: ResolveUserId): ApiApp<Env> {
16
+ return createApiApp<Env>({
17
+ logger: (env) => createLogger('api', '{{name}}', env),
18
+ {{#d1}}
19
+ d1: { binding: 'DB', bookmarks: { openSession, readBookmark, withBookmark } },
20
+ errors: { dailyLimit: isD1DailyLimitError },
21
+ {{/d1}}
22
+ auth: {
23
+ '/user/*': accessAuth<Env>({
24
+ teamDomain: (env) => env.TEAM_DOMAIN,
25
+ policyAud: (env) => env.POLICY_AUD,
26
+ devBypass: (env) => ({ allowed: env.DEV_AUTH_EMAIL !== undefined, email: env.DEV_AUTH_EMAIL }),
27
+ resolveUserId: (email, c) => resolveUserId(email, c.env),
28
+ }),
29
+ },
30
+ routes: (app) =>
31
+ registerContract(app, userContract, {
32
+ getMe: (_input, c) => Promise.resolve(toUserProfile(c.get('AuthenticatedUserId'), c.get('AuthenticatedUserEmailAddress'))),
33
+ }),
34
+ });
35
+ }
@@ -0,0 +1,21 @@
1
+ // The Worker's bindings, declared by hand so the repo typechecks before `pnpm run typegen`.
2
+ interface Env {
3
+ /**
4
+ * `https://<team>.cloudflareaccess.com`
5
+ */
6
+ TEAM_DOMAIN: string;
7
+ /**
8
+ * The Access application's audience tag.
9
+ */
10
+ POLICY_AUD: string;
11
+ /**
12
+ * Local development only: sign in as this address without a token. Never set in production.
13
+ */
14
+ DEV_AUTH_EMAIL?: string;
15
+ {{#d1}}
16
+ DB: D1Database;
17
+ {{/d1}}
18
+ {{#background}}
19
+ CRON_TASKS: DurableObjectNamespace;
20
+ {{/background}}
21
+ }
@@ -0,0 +1,38 @@
1
+ import { AbstractEntrypointWorker } from '@rexezuge/runtime';
2
+ {{#d1}}
3
+ import { UserIdentityService } from '@rexezuge/identity';
4
+ import { UnauthorizedError } from '@rexezuge/errors';
5
+ {{/d1}}
6
+ import { createApp } from './app';
7
+ import type { ResolveUserId } from './app';
8
+ {{#background}}
9
+ export { CronTasks } from '{{scope}}/background';
10
+ {{/background}}
11
+
12
+ {{#d1}}
13
+ const resolveUserId: ResolveUserId = async (email, env) => {
14
+ const account = await new UserIdentityService({ DB: env.DB }).resolveOrRegister(email);
15
+ if (account === null) throw new UnauthorizedError('Unrecognized account');
16
+ return account.id;
17
+ };
18
+ {{/d1}}
19
+ {{^d1}}
20
+ // No database: the verified address is the account key. Add the `d1` feature for the family identity layer.
21
+ const resolveUserId: ResolveUserId = (email) => Promise.resolve(email.trim().toLowerCase());
22
+ {{/d1}}
23
+
24
+ class ApiWorker extends AbstractEntrypointWorker {
25
+ private readonly app = createApp(resolveUserId);
26
+
27
+ protected onRequest(request: Request, env: Env, ctx: ExecutionContext): Promise<Response> {
28
+ return Promise.resolve(this.app.fetch(request, env, ctx));
29
+ }
30
+ {{#background}}
31
+
32
+ protected override cronTasksNamespace(env: Env) {
33
+ return env.CRON_TASKS;
34
+ }
35
+ {{/background}}
36
+ }
37
+
38
+ export default ApiWorker;
@@ -0,0 +1,3 @@
1
+ import { defineRepoLintConfig } from '@rexezuge/tooling/eslint';
2
+
3
+ export default defineRepoLintConfig({ scope: '{{scope}}' });
@@ -0,0 +1,20 @@
1
+ import { defineContract, defineEndpoint } from '@rexezuge/contracts';
2
+ import { z } from 'zod';
3
+
4
+ export const userProfileSchema = z.object({ id: z.string(), email: z.string() });
5
+ export type UserProfile = z.infer<typeof userProfileSchema>;
6
+
7
+ /**
8
+ * One definition, two consumers: `apps/api` registers it as a route (`registerContract`), `apps/web` calls it
9
+ * as a typed function (`createContractClient`).
10
+ */
11
+ export const userContract = defineContract({
12
+ getMe: defineEndpoint({
13
+ method: 'GET',
14
+ path: '/user/me',
15
+ summary: 'The signed-in account',
16
+ tags: ['user'],
17
+ auth: 'access',
18
+ response: userProfileSchema,
19
+ }),
20
+ });
@@ -0,0 +1,8 @@
1
+ import type { UserProfile } from '{{scope}}/contracts';
2
+
3
+ /**
4
+ * The profile the API reports for an authenticated account. Domain code lives here, not in the entry worker.
5
+ */
6
+ export function toUserProfile(id: string, email: string): UserProfile {
7
+ return { id, email: email.trim().toLowerCase() };
8
+ }
@@ -0,0 +1,34 @@
1
+ import { accessJwksFetch, {{#d1}}createMemoryD1, {{/d1}}createTestApp, forgeAccessRequest } from '@rexezuge/testing';
2
+ import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
3
+ import { createApp } from '../../apps/api/src/app';
4
+
5
+ const TEAM = 'https://team.example.com';
6
+ const AUD = 'aud-123';
7
+ const env = {
8
+ TEAM_DOMAIN: TEAM,
9
+ POLICY_AUD: AUD,
10
+ {{#d1}}
11
+ DB: createMemoryD1().asD1<D1Database>(),
12
+ {{/d1}}
13
+ } as Env;
14
+ const app = createApp(() => Promise.resolve('usr_1'));
15
+
16
+ describe('GET /user/me', () => {
17
+ beforeEach(() => vi.stubGlobal('fetch', accessJwksFetch(TEAM)));
18
+ afterEach(() => vi.unstubAllGlobals());
19
+
20
+ it('answers 401 without an Access token', async () => {
21
+ const api = createTestApp(app, { env });
22
+ const { status, body } = await api.json<{ Exception: { Type: string } }>('/user/me');
23
+ expect(status).toBe(401);
24
+ expect(body.Exception.Type).toBeDefined();
25
+ });
26
+
27
+ it('answers the signed-in account with a valid token', async () => {
28
+ const request = await forgeAccessRequest('https://app.example.com/user/me', { email: 'Alice@Example.com', aud: AUD, teamDomain: TEAM });
29
+ const api = createTestApp(app, { env, headers: request.headers });
30
+ const { status, body } = await api.json<{ id: string; email: string }>('/user/me');
31
+ expect(status).toBe(200);
32
+ expect(body).toEqual({ id: 'usr_1', email: 'alice@example.com' });
33
+ });
34
+ });
@@ -0,0 +1,5 @@
1
+ {
2
+ "extends": "@rexezuge/tooling/tsconfig/base.json",
3
+ "compilerOptions": { "lib": ["ES2022", "DOM"], "types": ["@cloudflare/workers-types"]{{#web}}, "jsx": "react-jsx"{{/web}} },
4
+ "include": ["apps/api/src/env.d.ts", "test/**/*.ts"{{#web}}, "test/**/*.tsx"{{/web}}, "vitest.config.mts"]
5
+ }
@@ -0,0 +1,14 @@
1
+ {{#web}}
2
+ import react from '@vitejs/plugin-react';
3
+ {{/web}}
4
+ import { defineRepoVitestConfig } from '@rexezuge/tooling/vitest-repo';
5
+
6
+ export default defineRepoVitestConfig({
7
+ scope: '{{scope}}',
8
+ root: new URL('.', import.meta.url).href,
9
+ packages: ['contracts', 'domain'{{#background}}, 'background'{{/background}}],
10
+ {{#web}}
11
+ web: { plugins: [react()] },
12
+ coverageExclude: ['apps/web/src/main.tsx'],
13
+ {{/web}}
14
+ });
@@ -0,0 +1,12 @@
1
+ <!doctype html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8" />
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
+ <title>{{name}}</title>
7
+ </head>
8
+ <body>
9
+ <div id="root"></div>
10
+ <script type="module" src="/src/main.tsx"></script>
11
+ </body>
12
+ </html>
@@ -0,0 +1,26 @@
1
+ import { Unauthorized, useCurrentUser } from '@rexezuge/web';
2
+ import type { UserProfile } from '{{scope}}/contracts';
3
+ import { apiClient } from './api';
4
+ import { t } from './i18n';
5
+
6
+ export function App() {
7
+ const { user, loading, error, reload } = useCurrentUser<UserProfile>(apiClient);
8
+
9
+ if (loading) return <p>{t('app.loading')}</p>;
10
+ if (error !== null || user === null) {
11
+ return (
12
+ <Unauthorized
13
+ title={t('unauthorized.title')}
14
+ message={t('unauthorized.message')}
15
+ actionLabel={t('unauthorized.action')}
16
+ onAuthenticate={reload}
17
+ />
18
+ );
19
+ }
20
+ return (
21
+ <main>
22
+ <h1>{t('app.title')}</h1>
23
+ <p>{t('app.signedInAs', { email: user.email })}</p>
24
+ </main>
25
+ );
26
+ }
@@ -0,0 +1,8 @@
1
+ import { createApiClient, createContractClient } from '@rexezuge/web';
2
+ import { userContract } from '{{scope}}/contracts';
3
+
4
+ /**
5
+ * One transport (credentials, error decoding, D1 bookmarks) shared by the contract client and the kit hooks.
6
+ */
7
+ export const apiClient = createApiClient((input, init) => fetch(input, init));
8
+ export const api = createContractClient(userContract, { apiClient });
@@ -0,0 +1,10 @@
1
+ import { createSpaI18n } from '@rexezuge/web/i18n';
2
+ import en from './locales/en/translation.json';
3
+
4
+ export const spaI18n = createSpaI18n({
5
+ supported: ['en'],
6
+ fallback: 'en',
7
+ resources: { en },
8
+ storageKey: '{{name}}-lng',
9
+ });
10
+ export const { t } = spaI18n;
@@ -0,0 +1,12 @@
1
+ {
2
+ "app": {
3
+ "title": "{{Title}}",
4
+ "signedInAs": "Signed in as {{email}}",
5
+ "loading": "Loading"
6
+ },
7
+ "unauthorized": {
8
+ "title": "Sign In Required",
9
+ "message": "Sign in with Cloudflare Access to continue.",
10
+ "action": "Sign In"
11
+ }
12
+ }
@@ -0,0 +1,12 @@
1
+ import { StrictMode } from 'react';
2
+ import { createRoot } from 'react-dom/client';
3
+ import { App } from './App';
4
+ import './styles.css';
5
+
6
+ const root = document.querySelector('#root');
7
+ if (root === null) throw new Error('index.html has no #root element');
8
+ createRoot(root).render(
9
+ <StrictMode>
10
+ <App />
11
+ </StrictMode>,
12
+ );
@@ -0,0 +1,2 @@
1
+ @import 'tailwindcss';
2
+ @import '@rexezuge/web/styles.css';
@@ -0,0 +1 @@
1
+ /// <reference types="vite/client" />
@@ -0,0 +1,8 @@
1
+ import tailwindcss from '@tailwindcss/vite';
2
+ import react from '@vitejs/plugin-react';
3
+ import { defineWebViteConfig } from '@rexezuge/tooling/vite';
4
+
5
+ export default defineWebViteConfig({
6
+ plugins: [react(), tailwindcss()],
7
+ proxy: { '/user': { target: 'http://localhost:8787', changeOrigin: true } },
8
+ });
@@ -0,0 +1 @@
1
+ export { onRequest } from '@rexezuge/tooling/pages-proxy';
@@ -0,0 +1,9 @@
1
+ import { renderToString } from 'react-dom/server';
2
+ import { describe, expect, it } from 'vitest';
3
+ import { App } from '../../apps/web/src/App';
4
+
5
+ describe('App', () => {
6
+ it('renders the loading state until the account resolves', () => {
7
+ expect(renderToString(<App />)).toContain('Loading');
8
+ });
9
+ });
@@ -0,0 +1,18 @@
1
+ import { createApiClient, createContractClient } from '@rexezuge/web';
2
+ import { describe, expect, it, vi } from 'vitest';
3
+ import { userContract } from '{{scope}}/contracts';
4
+ import { t } from '../../apps/web/src/i18n';
5
+
6
+ describe('the SPA data layer', () => {
7
+ it('calls GET /user/me through the shared contract', async () => {
8
+ const profile = JSON.stringify({ id: 'usr_1', email: 'alice@example.com' });
9
+ const fetchFn = vi.fn(() => Promise.resolve(new Response(profile, { headers: { 'content-type': 'application/json' } })));
10
+ const api = createContractClient(userContract, { apiClient: createApiClient(fetchFn) });
11
+ await expect(api.getMe({})).resolves.toEqual({ id: 'usr_1', email: 'alice@example.com' });
12
+ expect(fetchFn).toHaveBeenCalledTimes(1);
13
+ });
14
+
15
+ it('resolves UI copy through createSpaI18n', () => {
16
+ expect(t('unauthorized.title')).toBe('Sign In Required');
17
+ });
18
+ });