@rexezuge/tooling 1.3.0 → 1.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.
Files changed (128) hide show
  1. package/dist/eslint-boundaries.d.ts +12 -4
  2. package/dist/eslint-boundaries.d.ts.map +1 -1
  3. package/dist/eslint-boundaries.js +1 -224
  4. package/dist/eslint-boundaries.js.map +7 -1
  5. package/dist/eslint-rules.js +1 -273
  6. package/dist/eslint-rules.js.map +7 -1
  7. package/dist/eslint.js +1 -194
  8. package/dist/eslint.js.map +7 -1
  9. package/dist/functions/pages-proxy.d.ts.map +1 -1
  10. package/dist/functions/pages-proxy.js +1 -131
  11. package/dist/functions/pages-proxy.js.map +7 -1
  12. package/dist/index.js +1 -31
  13. package/dist/index.js.map +7 -1
  14. package/dist/scripts/backup/d1-target.d.ts +15 -5
  15. package/dist/scripts/backup/d1-target.d.ts.map +1 -1
  16. package/dist/scripts/backup/d1-target.js +1 -31
  17. package/dist/scripts/backup/d1-target.js.map +7 -1
  18. package/dist/scripts/backup/destination-config.d.ts +24 -8
  19. package/dist/scripts/backup/destination-config.d.ts.map +1 -1
  20. package/dist/scripts/backup/destination-config.js +1 -57
  21. package/dist/scripts/backup/destination-config.js.map +7 -1
  22. package/dist/scripts/backup/encrypt-backup.js +2 -97
  23. package/dist/scripts/backup/encrypt-backup.js.map +7 -1
  24. package/dist/scripts/backup/naming.d.ts +3 -1
  25. package/dist/scripts/backup/naming.d.ts.map +1 -1
  26. package/dist/scripts/backup/naming.js +1 -58
  27. package/dist/scripts/backup/naming.js.map +7 -1
  28. package/dist/scripts/check-god-files.d.ts +40 -14
  29. package/dist/scripts/check-god-files.d.ts.map +1 -1
  30. package/dist/scripts/check-god-files.js +2 -271
  31. package/dist/scripts/check-god-files.js.map +7 -1
  32. package/dist/scripts/ensure-spa-shell-stub.js +1 -29
  33. package/dist/scripts/ensure-spa-shell-stub.js.map +7 -1
  34. package/dist/scripts/init-secrets.d.ts +0 -16
  35. package/dist/scripts/init-secrets.d.ts.map +1 -1
  36. package/dist/scripts/init-secrets.js +2 -239
  37. package/dist/scripts/init-secrets.js.map +7 -1
  38. package/dist/scripts/lib/cli-args.d.ts.map +1 -1
  39. package/dist/scripts/lib/cli-args.js +1 -116
  40. package/dist/scripts/lib/cli-args.js.map +7 -1
  41. package/dist/scripts/lib/github-actions.js +3 -38
  42. package/dist/scripts/lib/github-actions.js.map +7 -1
  43. package/dist/scripts/lib/wrangler-table.d.ts.map +1 -1
  44. package/dist/scripts/lib/wrangler-table.js +2 -99
  45. package/dist/scripts/lib/wrangler-table.js.map +7 -1
  46. package/dist/scripts/migrations-lock.js +1 -44
  47. package/dist/scripts/migrations-lock.js.map +7 -1
  48. package/dist/scripts/prepare-wrangler-config.js +1 -49
  49. package/dist/scripts/prepare-wrangler-config.js.map +7 -1
  50. package/dist/scripts/spa-shell.d.ts +12 -4
  51. package/dist/scripts/spa-shell.d.ts.map +1 -1
  52. package/dist/scripts/spa-shell.js +3 -160
  53. package/dist/scripts/spa-shell.js.map +7 -1
  54. package/dist/scripts/validate-locales.d.ts +13 -5
  55. package/dist/scripts/validate-locales.d.ts.map +1 -1
  56. package/dist/scripts/validate-locales.js +4 -350
  57. package/dist/scripts/validate-locales.js.map +7 -1
  58. package/dist/scripts/verify-migrations.d.ts +27 -9
  59. package/dist/scripts/verify-migrations.d.ts.map +1 -1
  60. package/dist/scripts/verify-migrations.js +2 -312
  61. package/dist/scripts/verify-migrations.js.map +7 -1
  62. package/dist/scripts/verify-spa-shell.js +1 -52
  63. package/dist/scripts/verify-spa-shell.js.map +7 -1
  64. package/dist/scripts/wrangler-config/cli.js +3 -51
  65. package/dist/scripts/wrangler-config/cli.js.map +7 -1
  66. package/dist/scripts/wrangler-config/patches.d.ts +9 -3
  67. package/dist/scripts/wrangler-config/patches.d.ts.map +1 -1
  68. package/dist/scripts/wrangler-config/patches.js +4 -141
  69. package/dist/scripts/wrangler-config/patches.js.map +7 -1
  70. package/dist/scripts/wrangler-config/resources.d.ts +18 -6
  71. package/dist/scripts/wrangler-config/resources.d.ts.map +1 -1
  72. package/dist/scripts/wrangler-config/resources.js +1 -290
  73. package/dist/scripts/wrangler-config/resources.js.map +7 -1
  74. package/dist/scripts/wrangler-config/types.d.ts +24 -8
  75. package/dist/scripts/wrangler-config/types.d.ts.map +1 -1
  76. package/dist/scripts/wrangler-config/types.js +1 -49
  77. package/dist/scripts/wrangler-config/types.js.map +7 -1
  78. package/dist/test/integration-migrations.d.ts +29 -12
  79. package/dist/test/integration-migrations.d.ts.map +1 -1
  80. package/dist/test/integration-migrations.js +2 -171
  81. package/dist/test/integration-migrations.js.map +7 -1
  82. package/dist/test/mocks/cloudflare-workers.js +1 -90
  83. package/dist/test/mocks/cloudflare-workers.js.map +7 -1
  84. package/dist/vite.d.ts +5 -3
  85. package/dist/vite.d.ts.map +1 -1
  86. package/dist/vite.js +3 -125
  87. package/dist/vite.js.map +7 -1
  88. package/dist/vitest-aliases.d.ts.map +1 -1
  89. package/dist/vitest-aliases.js +1 -81
  90. package/dist/vitest-aliases.js.map +7 -1
  91. package/dist/vitest-integration.js +1 -64
  92. package/dist/vitest-integration.js.map +7 -1
  93. package/dist/vitest-repo.js +1 -146
  94. package/dist/vitest-repo.js.map +7 -1
  95. package/dist/vitest-web.js +1 -109
  96. package/dist/vitest-web.js.map +7 -1
  97. package/dist/vitest.js +1 -133
  98. package/dist/vitest.js.map +7 -1
  99. package/package.json +3 -3
  100. package/src/eslint-boundaries.ts +13 -5
  101. package/src/eslint.test.ts +18 -8
  102. package/src/functions/pages-proxy.test.ts +1 -1
  103. package/src/functions/pages-proxy.ts +4 -2
  104. package/src/scripts/backup/backup-rules.test.ts +1 -1
  105. package/src/scripts/backup/d1-target.ts +15 -5
  106. package/src/scripts/backup/destination-config.ts +27 -9
  107. package/src/scripts/backup/encrypt-backup.ts +10 -8
  108. package/src/scripts/backup/naming.ts +3 -1
  109. package/src/scripts/check-god-files.test.ts +18 -18
  110. package/src/scripts/check-god-files.ts +60 -31
  111. package/src/scripts/init-secrets.ts +17 -7
  112. package/src/scripts/lib/cli-args.ts +6 -3
  113. package/src/scripts/lib/wrangler-table.ts +5 -3
  114. package/src/scripts/migrations-lock.ts +1 -1
  115. package/src/scripts/spa-shell.test.ts +17 -17
  116. package/src/scripts/spa-shell.ts +26 -14
  117. package/src/scripts/validate-locales.test.ts +17 -17
  118. package/src/scripts/validate-locales.ts +43 -25
  119. package/src/scripts/verify-migrations.test.ts +7 -7
  120. package/src/scripts/verify-migrations.ts +47 -24
  121. package/src/scripts/wrangler-config/patches.ts +12 -4
  122. package/src/scripts/wrangler-config/resources.ts +30 -14
  123. package/src/scripts/wrangler-config/types.ts +24 -8
  124. package/src/test/integration-migrations.test.ts +6 -6
  125. package/src/test/integration-migrations.ts +33 -14
  126. package/src/vite.test.ts +24 -13
  127. package/src/vite.ts +5 -5
  128. package/src/vitest-aliases.ts +1 -3
@@ -1,90 +1 @@
1
- /**
2
- * Stand-in for the `cloudflare:workers` module, which has no Node equivalent.
3
- *
4
- * Provenance: converged from the eight copies at `test/mocks/cloudflare-workers.ts`
5
- * (AWS-AccessBridge, CalDAV-Bridge, ChordDHT-Tracker, Durable-DAV, Edge-Git,
6
- * Edge-Sonic, Mail-Meow, Mail-Otter). All eight are the same twenty lines; the
7
- * union is three base classes and the union exists because each repo discovered a
8
- * missing one the hard way.
9
- *
10
- * ### What each source contributes
11
- *
12
- * - **DurableObject** — every copy. Stores `ctx` and `env` so a real DO class can
13
- * be constructed and its lifecycle RPCs driven directly, without Miniflare.
14
- * - **`RpcTarget`** — Durable-DAV's, and the reason is load-bearing rather than
15
- * tidy: `dofs`' `Fs` class `extends RpcTarget`, so the module fails to evaluate
16
- * with *"Class extends value undefined"* when the base is missing. That is a
17
- * module-load error, not a test failure, so it surfaces as an unimportable
18
- * `dav-store` barrel and no unit test can reach `DavRepository`. Deliberately
19
- * empty: on the platform it marks which methods are callable across an RPC
20
- * boundary, and nothing in a Node suite calls those through RPC. An empty base
21
- * keeps the fake honest instead of pretending to implement dispatch.
22
- * - **`WorkflowEntrypoint`** — Edge-Git, Edge-Sonic, Mail-Meow, Mail-Otter. A
23
- * Workflow class extends it, so the mock must provide it or the module fails the
24
- * same way — a **startup** error, which therefore takes down every suite that
25
- * reaches `apps/background` for an unrelated reason. Edge-Sonic's is the shape
26
- * kept: it stores `ctx` as well as `env`, because the failure policy under test
27
- * in `runWorkflow` lives in a plain function precisely so it can be exercised
28
- * without workerd, and that policy reads the execution context.
29
- *
30
- * ### Why the ambient types are declared here rather than imported
31
- *
32
- * The source repos name `DurableObjectState`, `ExecutionContext` and `Env`
33
- * unqualified, which resolves only because `worker-configuration.d.ts` and
34
- * `@cloudflare/workers-types` are ambient inside a Wrangler project. This copy is
35
- * imported by the kit's own typecheck, where neither exists, so the two state
36
- * shapes are declared locally and `TEnv` defaults to `unknown` instead of `Env`
37
- * (Edge-Sonic's form). A local declaration shadows the ambient one inside this
38
- * file only, so a consumer's copy typechecks against their generated types
39
- * exactly as the original did.
40
- *
41
- * ### Usage in a consumer
42
- *
43
- * Copy this file to `<repo>/test/mocks/cloudflare-workers.ts` and alias the
44
- * specifier in the Vitest config — `defineUnitVitestConfig()` already does:
45
- *
46
- * ```jsonc
47
- * // wrangler.jsonc / vitest alias
48
- * "cloudflare:workers": "test/mocks/cloudflare-workers.ts"
49
- * ```
50
- *
51
- * Only what a test actually imports is exported. A symbol here that nothing
52
- * imports is not a safety net; it is a claim that something depends on it.
53
- */
54
- /**
55
- * The base class every Durable Object extends.
56
- *
57
- * `protected`, exactly as on the platform: a DO subclass reads `this.env` and
58
- * `this.ctx`, and nothing outside it may.
59
- */
60
- class DurableObject {
61
- ctx;
62
- env;
63
- constructor(ctx, env) {
64
- this.ctx = ctx;
65
- this.env = env;
66
- }
67
- }
68
- /**
69
- * The base class `dofs`' `Fs` extends. See the header: an empty body is the
70
- * whole point, and a missing class is a module-load failure.
71
- */
72
- class RpcTarget {
73
- }
74
- /**
75
- * The base class every Workflow extends.
76
- *
77
- * `ctx` is `ExecutionContext` rather than `unknown` (Mail-Meow/Mail-Otter's
78
- * form) because a Workflow's step code reads it; `void ctx` to silence the unused
79
- * warning would be a lie about which of the two a subclass uses.
80
- */
81
- class WorkflowEntrypoint {
82
- ctx;
83
- env;
84
- constructor(ctx, env) {
85
- this.ctx = ctx;
86
- this.env = env;
87
- }
88
- }
89
- export { DurableObject, RpcTarget, WorkflowEntrypoint };
90
- //# sourceMappingURL=cloudflare-workers.js.map
1
+ class r{ctx;env;constructor(t,c){this.ctx=t,this.env=c}}class e{}class n{ctx;env;constructor(t,c){this.ctx=t,this.env=c}}export{r as DurableObject,e as RpcTarget,n as WorkflowEntrypoint};
@@ -1 +1,7 @@
1
- {"version":3,"file":"cloudflare-workers.js","sourceRoot":"","sources":["../../../src/test/mocks/cloudflare-workers.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoDG;AAuBH;;;;;GAKG;AACH,MAAM,aAAa;IACP,GAAG,CAAqB;IACxB,GAAG,CAAO;IAEpB,YAAY,GAAuB,EAAE,GAAS;QAC5C,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QACf,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;IACjB,CAAC;CACF;AAED;;;GAGG;AACH,MAAM,SAAS;CAAG;AAElB;;;;;;GAMG;AACH,MAAM,kBAAkB;IACZ,GAAG,CAAmB;IACtB,GAAG,CAAO;IAEpB,YAAY,GAAqB,EAAE,GAAS;QAC1C,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QACf,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;IACjB,CAAC;CACF;AAED,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,kBAAkB,EAAE,CAAC","sourcesContent":["/**\n * Stand-in for the `cloudflare:workers` module, which has no Node equivalent.\n *\n * Provenance: converged from the eight copies at `test/mocks/cloudflare-workers.ts`\n * (AWS-AccessBridge, CalDAV-Bridge, ChordDHT-Tracker, Durable-DAV, Edge-Git,\n * Edge-Sonic, Mail-Meow, Mail-Otter). All eight are the same twenty lines; the\n * union is three base classes and the union exists because each repo discovered a\n * missing one the hard way.\n *\n * ### What each source contributes\n *\n * - **DurableObject** — every copy. Stores `ctx` and `env` so a real DO class can\n * be constructed and its lifecycle RPCs driven directly, without Miniflare.\n * - **`RpcTarget`** — Durable-DAV's, and the reason is load-bearing rather than\n * tidy: `dofs`' `Fs` class `extends RpcTarget`, so the module fails to evaluate\n * with *\"Class extends value undefined\"* when the base is missing. That is a\n * module-load error, not a test failure, so it surfaces as an unimportable\n * `dav-store` barrel and no unit test can reach `DavRepository`. Deliberately\n * empty: on the platform it marks which methods are callable across an RPC\n * boundary, and nothing in a Node suite calls those through RPC. An empty base\n * keeps the fake honest instead of pretending to implement dispatch.\n * - **`WorkflowEntrypoint`** — Edge-Git, Edge-Sonic, Mail-Meow, Mail-Otter. A\n * Workflow class extends it, so the mock must provide it or the module fails the\n * same way — a **startup** error, which therefore takes down every suite that\n * reaches `apps/background` for an unrelated reason. Edge-Sonic's is the shape\n * kept: it stores `ctx` as well as `env`, because the failure policy under test\n * in `runWorkflow` lives in a plain function precisely so it can be exercised\n * without workerd, and that policy reads the execution context.\n *\n * ### Why the ambient types are declared here rather than imported\n *\n * The source repos name `DurableObjectState`, `ExecutionContext` and `Env`\n * unqualified, which resolves only because `worker-configuration.d.ts` and\n * `@cloudflare/workers-types` are ambient inside a Wrangler project. This copy is\n * imported by the kit's own typecheck, where neither exists, so the two state\n * shapes are declared locally and `TEnv` defaults to `unknown` instead of `Env`\n * (Edge-Sonic's form). A local declaration shadows the ambient one inside this\n * file only, so a consumer's copy typechecks against their generated types\n * exactly as the original did.\n *\n * ### Usage in a consumer\n *\n * Copy this file to `<repo>/test/mocks/cloudflare-workers.ts` and alias the\n * specifier in the Vitest config — `defineUnitVitestConfig()` already does:\n *\n * ```jsonc\n * // wrangler.jsonc / vitest alias\n * \"cloudflare:workers\": \"test/mocks/cloudflare-workers.ts\"\n * ```\n *\n * Only what a test actually imports is exported. A symbol here that nothing\n * imports is not a safety net; it is a claim that something depends on it.\n */\n\n/**\n * The subset of `DurableObjectState` a Node test reaches.\n *\n * Declared structurally rather than imported: `id`, `storage` and `waitUntil` are\n * the three a hand-driven lifecycle touches, and nothing here needs the rest.\n */\nexport interface DurableObjectState {\n readonly id: { toString(): string; readonly name?: string };\n}\n\n/**\n * The subset of `ExecutionContext` a Node test reaches.\n *\n * `waitUntil` is present because a Workflow's `run()` is driven through it, and\n * `passThroughOnException` is absent on purpose — nothing in a Node suite wires a\n * request through it.\n */\nexport interface ExecutionContext {\n waitUntil(promise: Promise<unknown>): void;\n}\n\n/**\n * The base class every Durable Object extends.\n *\n * `protected`, exactly as on the platform: a DO subclass reads `this.env` and\n * `this.ctx`, and nothing outside it may.\n */\nclass DurableObject<TEnv = unknown> {\n protected ctx: DurableObjectState;\n protected env: TEnv;\n\n constructor(ctx: DurableObjectState, env: TEnv) {\n this.ctx = ctx;\n this.env = env;\n }\n}\n\n/**\n * The base class `dofs`' `Fs` extends. See the header: an empty body is the\n * whole point, and a missing class is a module-load failure.\n */\nclass RpcTarget {}\n\n/**\n * The base class every Workflow extends.\n *\n * `ctx` is `ExecutionContext` rather than `unknown` (Mail-Meow/Mail-Otter's\n * form) because a Workflow's step code reads it; `void ctx` to silence the unused\n * warning would be a lie about which of the two a subclass uses.\n */\nclass WorkflowEntrypoint<TEnv = unknown> {\n protected ctx: ExecutionContext;\n protected env: TEnv;\n\n constructor(ctx: ExecutionContext, env: TEnv) {\n this.ctx = ctx;\n this.env = env;\n }\n}\n\nexport { DurableObject, RpcTarget, WorkflowEntrypoint };\n"]}
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/test/mocks/cloudflare-workers.ts"],
4
+ "sourcesContent": ["/**\n * Stand-in for the `cloudflare:workers` module, which has no Node equivalent.\n *\n * Provenance: converged from the eight copies at `test/mocks/cloudflare-workers.ts`\n * (AWS-AccessBridge, CalDAV-Bridge, ChordDHT-Tracker, Durable-DAV, Edge-Git,\n * Edge-Sonic, Mail-Meow, Mail-Otter). All eight are the same twenty lines; the\n * union is three base classes and the union exists because each repo discovered a\n * missing one the hard way.\n *\n * ### What each source contributes\n *\n * - **DurableObject** — every copy. Stores `ctx` and `env` so a real DO class can\n * be constructed and its lifecycle RPCs driven directly, without Miniflare.\n * - **`RpcTarget`** — Durable-DAV's, and the reason is load-bearing rather than\n * tidy: `dofs`' `Fs` class `extends RpcTarget`, so the module fails to evaluate\n * with *\"Class extends value undefined\"* when the base is missing. That is a\n * module-load error, not a test failure, so it surfaces as an unimportable\n * `dav-store` barrel and no unit test can reach `DavRepository`. Deliberately\n * empty: on the platform it marks which methods are callable across an RPC\n * boundary, and nothing in a Node suite calls those through RPC. An empty base\n * keeps the fake honest instead of pretending to implement dispatch.\n * - **`WorkflowEntrypoint`** — Edge-Git, Edge-Sonic, Mail-Meow, Mail-Otter. A\n * Workflow class extends it, so the mock must provide it or the module fails the\n * same way — a **startup** error, which therefore takes down every suite that\n * reaches `apps/background` for an unrelated reason. Edge-Sonic's is the shape\n * kept: it stores `ctx` as well as `env`, because the failure policy under test\n * in `runWorkflow` lives in a plain function precisely so it can be exercised\n * without workerd, and that policy reads the execution context.\n *\n * ### Why the ambient types are declared here rather than imported\n *\n * The source repos name `DurableObjectState`, `ExecutionContext` and `Env`\n * unqualified, which resolves only because `worker-configuration.d.ts` and\n * `@cloudflare/workers-types` are ambient inside a Wrangler project. This copy is\n * imported by the kit's own typecheck, where neither exists, so the two state\n * shapes are declared locally and `TEnv` defaults to `unknown` instead of `Env`\n * (Edge-Sonic's form). A local declaration shadows the ambient one inside this\n * file only, so a consumer's copy typechecks against their generated types\n * exactly as the original did.\n *\n * ### Usage in a consumer\n *\n * Copy this file to `<repo>/test/mocks/cloudflare-workers.ts` and alias the\n * specifier in the Vitest config — `defineUnitVitestConfig()` already does:\n *\n * ```jsonc\n * // wrangler.jsonc / vitest alias\n * \"cloudflare:workers\": \"test/mocks/cloudflare-workers.ts\"\n * ```\n *\n * Only what a test actually imports is exported. A symbol here that nothing\n * imports is not a safety net; it is a claim that something depends on it.\n */\n\n/**\n * The subset of `DurableObjectState` a Node test reaches.\n *\n * Declared structurally rather than imported: `id`, `storage` and `waitUntil` are\n * the three a hand-driven lifecycle touches, and nothing here needs the rest.\n */\nexport interface DurableObjectState {\n readonly id: { toString(): string; readonly name?: string };\n}\n\n/**\n * The subset of `ExecutionContext` a Node test reaches.\n *\n * `waitUntil` is present because a Workflow's `run()` is driven through it, and\n * `passThroughOnException` is absent on purpose — nothing in a Node suite wires a\n * request through it.\n */\nexport interface ExecutionContext {\n waitUntil(promise: Promise<unknown>): void;\n}\n\n/**\n * The base class every Durable Object extends.\n *\n * `protected`, exactly as on the platform: a DO subclass reads `this.env` and\n * `this.ctx`, and nothing outside it may.\n */\nclass DurableObject<TEnv = unknown> {\n protected ctx: DurableObjectState;\n protected env: TEnv;\n\n constructor(ctx: DurableObjectState, env: TEnv) {\n this.ctx = ctx;\n this.env = env;\n }\n}\n\n/**\n * The base class `dofs`' `Fs` extends. See the header: an empty body is the\n * whole point, and a missing class is a module-load failure.\n */\nclass RpcTarget {}\n\n/**\n * The base class every Workflow extends.\n *\n * `ctx` is `ExecutionContext` rather than `unknown` (Mail-Meow/Mail-Otter's\n * form) because a Workflow's step code reads it; `void ctx` to silence the unused\n * warning would be a lie about which of the two a subclass uses.\n */\nclass WorkflowEntrypoint<TEnv = unknown> {\n protected ctx: ExecutionContext;\n protected env: TEnv;\n\n constructor(ctx: ExecutionContext, env: TEnv) {\n this.ctx = ctx;\n this.env = env;\n }\n}\n\nexport { DurableObject, RpcTarget, WorkflowEntrypoint };\n"],
5
+ "mappings": "AAiFA,MAAMA,CAAa,CACP,IACA,IAEV,YAAYC,EAAyBC,EAAS,CAC5C,KAAK,IAAMD,EACX,KAAK,IAAMC,CACb,EAOF,MAAMC,CAAS,EASf,MAAMC,CAAkB,CACZ,IACA,IAEV,YAAYH,EAAuBC,EAAS,CAC1C,KAAK,IAAMD,EACX,KAAK,IAAMC,CACb",
6
+ "names": ["DurableObject", "ctx", "env", "RpcTarget", "WorkflowEntrypoint"]
7
+ }
package/dist/vite.d.ts CHANGED
@@ -28,7 +28,7 @@
28
28
  * The consumer's `apps/web/vite.config.ts` becomes a handful of lines — see the
29
29
  * README.
30
30
  */
31
- import { defineConfig, type Plugin } from 'vitest/config';
31
+ import { type Plugin, type ViteUserConfig } from 'vitest/config';
32
32
  /**
33
33
  * One dev-server proxy entry, as Vite's `server.proxy` accepts it.
34
34
  */
@@ -97,7 +97,9 @@ export interface WebViteConfigOptions {
97
97
  */
98
98
  readonly root?: string;
99
99
  }
100
- export declare function spaShellEmbedPlugin(target: SpaShellTarget): Plugin;
100
+ export declare function spaShellEmbedPlugin(target: SpaShellTarget): Plugin & {
101
+ closeBundle: () => void;
102
+ };
101
103
  /**
102
104
  * Build the SPA's Vite config.
103
105
  *
@@ -113,5 +115,5 @@ export declare function spaShellEmbedPlugin(target: SpaShellTarget): Plugin;
113
115
  * });
114
116
  * ```
115
117
  */
116
- export declare function defineWebViteConfig(options?: WebViteConfigOptions): ReturnType<typeof defineConfig>;
118
+ export declare function defineWebViteConfig(options?: WebViteConfigOptions): ViteUserConfig;
117
119
  //# sourceMappingURL=vite.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"vite.d.ts","sourceRoot":"","sources":["../src/vite.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAKH,OAAO,EAAE,YAAY,EAAE,KAAK,MAAM,EAAE,MAAM,eAAe,CAAC;AAE1D;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,YAAY,CAAC,EAAE,OAAO,CAAC;IAChC,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE;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* Provenance: converged from the `apps/web/vite.config.ts` of the eight repos
5
- * that build a Vite SPA. They are one file with three variables: the plugin list
6
- * (`@vitejs/plugin-react` + `@tailwindcss/vite`), the dev-server proxy target,
7
- * and the `spa-shell-embed` plugin that copies `dist/index.html` into
8
- * `apps/api/src/generated/spa-shell.ts`.
9
- *
10
- * Canonical decisions:
11
- *
12
- * 1. **The plugins are passed in, not imported.** The kit stays zero-dependency:
13
- * `react`, `@vitejs/plugin-react` and `@tailwindcss/vite` belong to the app
14
- * that uses them, and importing them here would make the tooling package
15
- * undownloadable for a consumer without a React SPA.
16
- * 2. **The `spa-shell-embed` hook stays per-repo, and is passed in.** It is the
17
- * one genuinely repo-specific piece: each repo names its own worker and its
18
- * own generated-module path. What the kit provides is the *contract* — see
19
- * `spaShellEmbedPlugin`, which is the converged body of all eight copies.
20
- * 3. **`server.proxy` is data, not code.** The paths differ per repo
21
- * (`/user` + `/rest` in Edge-Sonic, `/api` in CalDAV-Bridge, `/tracker` in
22
- * ChordDHT-Tracker) but the shape never does, so it is an option with a
23
- * default.
24
- * 4. **`build.emptyOutDir: true`** is the default, because a stale asset in
25
- * `dist/` is served as a live bundle — the same half-refreshed build
26
- * `scripts/verify-spa-shell.ts` rejects.
27
- *
28
- * The consumer's `apps/web/vite.config.ts` becomes a handful of lines — see the
29
- * README.
30
- */
31
- import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';
32
- import { dirname } from 'node:path';
33
- import { fileURLToPath, pathToFileURL } from 'node:url';
34
- import { defineConfig } from 'vitest/config';
35
- /**
36
- * The `spa-shell-embed` plugin, converged from all eight copies.
37
- *
38
- * It exists because the API worker serves `SPA_HTML` from a module in its own
39
- * source tree, and both that module and `dist/` are gitignored — so a fresh
40
- * clone gets an empty stub from `postinstall` and every `GET /` returns a blank
41
- * page until someone runs a build. This plugin is what makes the build write the
42
- * real artefact, and `scripts/verify-spa-shell.ts` is what refuses to deploy
43
- * without it.
44
- *
45
- * Written as a factory rather than inlined so the exit conditions are in one
46
- * place: the `closeBundle` hook runs on every build, including the ones where
47
- * `dist/index.html` was never produced, and a plugin that throws there fails
48
- * builds that legitimately emit nothing.
49
- */
50
- /**
51
- * Normalise a path-or-URL option to a URL, so `new URL(...)` can be used on it.
52
- *
53
- * Small, and here because two options accept either form: a path is what a consumer
54
- * naturally writes in a config, and a URL is what `import.meta.url` hands them.
55
- * Accepting both is one line and saves a `fileURLToPath` at every call site.
56
- */
57
- function toUrl(value) {
58
- return typeof value === 'string' ? pathToFileURL(value) : value;
59
- }
60
- /**
61
- * The same, as a **directory** URL — with the trailing separator `new URL(rel, base)`
62
- * needs.
63
- *
64
- * `new URL('apps/api/x.ts', 'file:///repo')` resolves to `/apps/api/x.ts`, silently
65
- * dropping the base. The base has to end in a separator, and a path from
66
- * `process.cwd()` never does, so this is where the plugin would otherwise write the
67
- * shell into the filesystem root.
68
- */
69
- function toDirUrl(value) {
70
- const url = toUrl(value);
71
- return url.href.endsWith('/') ? url : new URL(`${url.href}/`);
72
- }
73
- export function spaShellEmbedPlugin(target) {
74
- return {
75
- name: 'spa-shell-embed',
76
- closeBundle() {
77
- // Resolved from the directory the build runs in, never from this module's own
78
- // URL: the plugin object is created here but executes in the consumer's Vite
79
- // process, and `new URL(path, import.meta.url)` would resolve against
80
- // `node_modules/@rexezuge/tooling`. `process.cwd()` is the repo root for
81
- // `pnpm --filter @scope/web build`, which is how every consumer runs it.
82
- const root = toDirUrl(target.root ?? process.cwd());
83
- const outputPath = fileURLToPath(new URL(target.path, root));
84
- const indexPath = target.distIndex === undefined ? fileURLToPath(new URL('dist/index.html', root)) : fileURLToPath(toUrl(target.distIndex));
85
- if (!existsSync(indexPath)) {
86
- console.warn('spa-shell-embed: dist/index.html not found, skipping');
87
- return;
88
- }
89
- const html = readFileSync(indexPath, 'utf8');
90
- const output = `// Auto-generated by Vite build plugin - DO NOT EDIT.\nexport const SPA_HTML: string = ${JSON.stringify(html)};\n`;
91
- mkdirSync(dirname(outputPath), { recursive: true });
92
- writeFileSync(outputPath, output);
93
- },
94
- };
95
- }
96
- /**
97
- * Build the SPA's Vite config.
98
- *
99
- * ```ts
100
- * // apps/web/vite.config.ts
101
- * import react from '@vitejs/plugin-react';
102
- * import { defineWebViteConfig, spaShellEmbedPlugin } from '@rexezuge/tooling/vite';
103
- *
104
- * export default defineWebViteConfig({
105
- * plugins: [react()],
106
- * proxy: { '/user': { target: 'http://localhost:8787', changeOrigin: true } },
107
- * spaShell: { path: '../../apps/api/src/generated/spa-shell.ts' },
108
- * });
109
- * ```
110
- */
111
- export function defineWebViteConfig(options = {}) {
112
- const plugins = [...(options.plugins ?? [])];
113
- if (options.spaShell !== undefined) {
114
- plugins.push(spaShellEmbedPlugin(options.spaShell));
115
- }
116
- return defineConfig({
117
- ...(plugins.length > 0 && { plugins }),
118
- ...(options.proxy !== undefined && { server: { proxy: { ...options.proxy } } }),
119
- build: {
120
- outDir: options.outDir ?? 'dist',
121
- emptyOutDir: true,
122
- },
123
- });
124
- }
125
- //# sourceMappingURL=vite.js.map
1
+ import{existsSync as s,mkdirSync as l,readFileSync as f,writeFileSync as p}from"node:fs";import c from"node:path";import{fileURLToPath as t,pathToFileURL as h}from"node:url";import{defineConfig as m}from"vitest/config";function o(e){return typeof e=="string"?h(e):e}function x(e){const n=o(e);return n.href.endsWith("/")?n:new URL(`${n.href}/`)}function a(e){return{name:"spa-shell-embed",closeBundle(){const n=x(e.root??process.cwd()),i=t(new URL(e.path,n)),r=e.distIndex===void 0?t(new URL("dist/index.html",n)):t(o(e.distIndex));if(!s(r)){console.warn("spa-shell-embed: dist/index.html not found, skipping");return}const u=f(r,"utf8"),d=`// Auto-generated by Vite build plugin - DO NOT EDIT.
2
+ export const SPA_HTML: string = ${JSON.stringify(u)};
3
+ `;l(c.dirname(i),{recursive:!0}),p(i,d)}}}function U(e={}){const n=[...e.plugins??[]];return e.spaShell!==void 0&&n.push(a(e.spaShell)),m({...n.length>0&&{plugins:n},...e.proxy!==void 0&&{server:{proxy:{...e.proxy}}},build:{outDir:e.outDir??"dist",emptyOutDir:!0}})}export{U as defineWebViteConfig,a as spaShellEmbedPlugin};
package/dist/vite.js.map CHANGED
@@ -1 +1,7 @@
1
- {"version":3,"file":"vite.js","sourceRoot":"","sources":["../src/vite.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAEH,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC7E,OAAO,EAAE,OAAO,EAAW,MAAM,WAAW,CAAC;AAC7C,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACxD,OAAO,EAAE,YAAY,EAAe,MAAM,eAAe,CAAC;AAuE1D;;;;;;;;;;;;;;GAcG;AACH;;;;;;GAMG;AACH,SAAS,KAAK,CAAC,KAAmB;IAChC,OAAO,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;AAClE,CAAC;AAED;;;;;;;;GAQG;AACH,SAAS,QAAQ,CAAC,KAAmB;IACnC,MAAM,GAAG,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC;IACzB,OAAO,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,GAAG,GAAG,CAAC,IAAI,GAAG,CAAC,CAAC;AAChE,CAAC;AAED,MAAM,UAAU,mBAAmB,CAAC,MAAsB;IACxD,OAAO;QACL,IAAI,EAAE,iBAAiB;QACvB,WAAW;YACT,8EAA8E;YAC9E,6EAA6E;YAC7E,sEAAsE;YACtE,yEAAyE;YACzE,yEAAyE;YACzE,MAAM,IAAI,GAAG,QAAQ,CAAC,MAAM,CAAC,IAAI,IAAI,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC;YACpD,MAAM,UAAU,GAAG,a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,KAAK,EAAE,EAAE,GAAG,OAAO,CAAC,KAAK,EAAE,EAAE,EAAE,CAAC;QAC/E,KAAK,EAAE;YACL,MAAM,EAAE,OAAO,CAAC,MAAM,IAAI,MAAM;YAChC,WAAW,EAAE,IAAI;SAClB;KACF,CAAC,CAAC;AACL,CAAC","sourcesContent":["/**\n * The SPA's Vite config.\n *\n * Provenance: converged from the `apps/web/vite.config.ts` of the eight repos\n * that build a Vite SPA. They are one file with three variables: the plugin list\n * (`@vitejs/plugin-react` + `@tailwindcss/vite`), the dev-server proxy target,\n * and the `spa-shell-embed` plugin that copies `dist/index.html` into\n * `apps/api/src/generated/spa-shell.ts`.\n *\n * Canonical decisions:\n *\n * 1. **The plugins are passed in, not imported.** The kit stays zero-dependency:\n * `react`, `@vitejs/plugin-react` and `@tailwindcss/vite` belong to the app\n * that uses them, and importing them here would make the tooling package\n * undownloadable for a consumer without a React SPA.\n * 2. **The `spa-shell-embed` hook stays per-repo, and is passed in.** It is the\n * one genuinely repo-specific piece: each repo names its own worker and its\n * own generated-module path. What the kit provides is the *contract* — see\n * `spaShellEmbedPlugin`, which is the converged body of all eight copies.\n * 3. **`server.proxy` is data, not code.** The paths differ per repo\n * (`/user` + `/rest` in Edge-Sonic, `/api` in CalDAV-Bridge, `/tracker` in\n * ChordDHT-Tracker) but the shape never does, so it is an option with a\n * default.\n * 4. **`build.emptyOutDir: true`** is the default, because a stale asset in\n * `dist/` is served as a live bundle — the same half-refreshed build\n * `scripts/verify-spa-shell.ts` rejects.\n *\n * The consumer's `apps/web/vite.config.ts` becomes a handful of lines — see the\n * README.\n */\n\nimport { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';\nimport { dirname, resolve } from 'node:path';\nimport { fileURLToPath, pathToFileURL } from 'node:url';\nimport { defineConfig, type Plugin } from 'vitest/config';\n\n/**\n * One dev-server proxy entry, as Vite's `server.proxy` accepts it.\n */\nexport interface ProxyEntry {\n readonly target: string;\n readonly changeOrigin?: boolean;\n readonly bypass?: (request: { headers: Record<string, string | string[] | undefined> }) => string | undefined;\n}\n\n/**\n * Where the SPA's built `index.html` is copied to, and under what module name.\n */\nexport interface SpaShellTarget {\n /**\n * Path of the generated module, relative to the repository root.\n *\n * `apps/api/src/generated/spa-shell.ts` in every repo that embeds a shell; the\n * parameter exists because the path is the one thing that genuinely differs.\n */\n readonly path: string;\n /**\n * The repository root the path is resolved against, as a file URL or a path.\n *\n * Defaults to the directory the build runs in (`process.cwd()`), which is the\n * repo root when the build is `pnpm --filter @scope/web build`. Passed in by the\n * Vite config, not derived from `import.meta.url`: this plugin object is created\n * inside the kit's own module, so a URL relative to it points into\n * `node_modules/@rexezuge/tooling` and writes the shell somewhere no compiler\n * will ever look.\n */\n readonly root?: string | URL;\n /**\n * The built `index.html`, as a path or file URL.\n *\n * Defaults to `dist/index.html` under the same root. Vite's `closeBundle` runs\n * after the bundle is written, so this is the file the build just produced.\n */\n readonly distIndex?: string | URL;\n}\n\n/**\n * What `defineWebViteConfig` accepts.\n */\nexport interface WebViteConfigOptions {\n /**\n * The SPA's plugins — `react()`, `tailwindcss()`, and anything else the app\n * needs. Applied before the spa-shell plugin so the shell is written after the\n * bundle exists.\n */\n readonly plugins?: readonly Plugin[];\n /**\n * Dev-server proxy entries. Keyed by path prefix.\n */\n readonly proxy?: Readonly<Record<string, ProxyEntry>>;\n /**\n * Where the built shell is embedded. Omit to skip the embedding entirely.\n */\n readonly spaShell?: SpaShellTarget;\n /**\n * The build output directory.\n */\n readonly outDir?: string;\n /**\n * The directory this config is resolved from, as a file URL. Defaults to the\n * caller's location.\n */\n readonly root?: string;\n}\n\n/**\n * The `spa-shell-embed` plugin, converged from all eight copies.\n *\n * It exists because the API worker serves `SPA_HTML` from a module in its own\n * source tree, and both that module and `dist/` are gitignored — so a fresh\n * clone gets an empty stub from `postinstall` and every `GET /` returns a blank\n * page until someone runs a build. This plugin is what makes the build write the\n * real artefact, and `scripts/verify-spa-shell.ts` is what refuses to deploy\n * without it.\n *\n * Written as a factory rather than inlined so the exit conditions are in one\n * place: the `closeBundle` hook runs on every build, including the ones where\n * `dist/index.html` was never produced, and a plugin that throws there fails\n * builds that legitimately emit nothing.\n */\n/**\n * Normalise a path-or-URL option to a URL, so `new URL(...)` can be used on it.\n *\n * Small, and here because two options accept either form: a path is what a consumer\n * naturally writes in a config, and a URL is what `import.meta.url` hands them.\n * Accepting both is one line and saves a `fileURLToPath` at every call site.\n */\nfunction toUrl(value: string | URL): URL {\n return typeof value === 'string' ? pathToFileURL(value) : value;\n}\n\n/**\n * The same, as a **directory** URL — with the trailing separator `new URL(rel, base)`\n * needs.\n *\n * `new URL('apps/api/x.ts', 'file:///repo')` resolves to `/apps/api/x.ts`, silently\n * dropping the base. The base has to end in a separator, and a path from\n * `process.cwd()` never does, so this is where the plugin would otherwise write the\n * shell into the filesystem root.\n */\nfunction toDirUrl(value: string | URL): URL {\n const url = toUrl(value);\n return url.href.endsWith('/') ? url : new URL(`${url.href}/`);\n}\n\nexport function spaShellEmbedPlugin(target: SpaShellTarget): Plugin {\n return {\n name: 'spa-shell-embed',\n closeBundle() {\n // Resolved from the directory the build runs in, never from this module's own\n // URL: the plugin object is created here but executes in the consumer's Vite\n // process, and `new URL(path, import.meta.url)` would resolve against\n // `node_modules/@rexezuge/tooling`. `process.cwd()` is the repo root for\n // `pnpm --filter @scope/web build`, which is how every consumer runs it.\n const root = toDirUrl(target.root ?? process.cwd());\n const outputPath = fileURLToPath(new URL(target.path, root));\n const indexPath =\n target.distIndex === undefined ? fileURLToPath(new URL('dist/index.html', root)) : fileURLToPath(toUrl(target.distIndex));\n\n if (!existsSync(indexPath)) {\n console.warn('spa-shell-embed: dist/index.html not found, skipping');\n return;\n }\n\n const html = readFileSync(indexPath, 'utf8');\n const output = `// Auto-generated by Vite build plugin - DO NOT EDIT.\\nexport const SPA_HTML: string = ${JSON.stringify(html)};\\n`;\n\n mkdirSync(dirname(outputPath), { recursive: true });\n writeFileSync(outputPath, output);\n },\n };\n}\n\n/**\n * Build the SPA's Vite config.\n *\n * ```ts\n * // apps/web/vite.config.ts\n * import react from '@vitejs/plugin-react';\n * import { defineWebViteConfig, spaShellEmbedPlugin } from '@rexezuge/tooling/vite';\n *\n * export default defineWebViteConfig({\n * plugins: [react()],\n * proxy: { '/user': { target: 'http://localhost:8787', changeOrigin: true } },\n * spaShell: { path: '../../apps/api/src/generated/spa-shell.ts' },\n * });\n * ```\n */\nexport function defineWebViteConfig(options: WebViteConfigOptions = {}): ReturnType<typeof defineConfig> {\n const plugins: Plugin[] = [...(options.plugins ?? [])];\n if (options.spaShell !== undefined) {\n plugins.push(spaShellEmbedPlugin(options.spaShell));\n }\n\n return defineConfig({\n ...(plugins.length > 0 && { plugins }),\n ...(options.proxy !== undefined && { server: { proxy: { ...options.proxy } } }),\n build: {\n outDir: options.outDir ?? 'dist',\n emptyOutDir: true,\n },\n });\n}\n"]}
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/vite.ts"],
4
+ "sourcesContent": ["/**\n * The SPA's Vite config.\n *\n * Provenance: converged from the `apps/web/vite.config.ts` of the eight repos\n * that build a Vite SPA. They are one file with three variables: the plugin list\n * (`@vitejs/plugin-react` + `@tailwindcss/vite`), the dev-server proxy target,\n * and the `spa-shell-embed` plugin that copies `dist/index.html` into\n * `apps/api/src/generated/spa-shell.ts`.\n *\n * Canonical decisions:\n *\n * 1. **The plugins are passed in, not imported.** The kit stays zero-dependency:\n * `react`, `@vitejs/plugin-react` and `@tailwindcss/vite` belong to the app\n * that uses them, and importing them here would make the tooling package\n * undownloadable for a consumer without a React SPA.\n * 2. **The `spa-shell-embed` hook stays per-repo, and is passed in.** It is the\n * one genuinely repo-specific piece: each repo names its own worker and its\n * own generated-module path. What the kit provides is the *contract* — see\n * `spaShellEmbedPlugin`, which is the converged body of all eight copies.\n * 3. **`server.proxy` is data, not code.** The paths differ per repo\n * (`/user` + `/rest` in Edge-Sonic, `/api` in CalDAV-Bridge, `/tracker` in\n * ChordDHT-Tracker) but the shape never does, so it is an option with a\n * default.\n * 4. **`build.emptyOutDir: true`** is the default, because a stale asset in\n * `dist/` is served as a live bundle — the same half-refreshed build\n * `scripts/verify-spa-shell.ts` rejects.\n *\n * The consumer's `apps/web/vite.config.ts` becomes a handful of lines — see the\n * README.\n */\n\nimport { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';\nimport path from 'node:path';\nimport { fileURLToPath, pathToFileURL } from 'node:url';\nimport { defineConfig, type Plugin, type ViteUserConfig } from 'vitest/config';\n\n/**\n * One dev-server proxy entry, as Vite's `server.proxy` accepts it.\n */\nexport interface ProxyEntry {\n readonly target: string;\n readonly changeOrigin?: boolean;\n readonly bypass?: (request: { headers: Record<string, string | string[] | undefined> }) => string | undefined;\n}\n\n/**\n * Where the SPA's built `index.html` is copied to, and under what module name.\n */\nexport interface SpaShellTarget {\n /**\n * Path of the generated module, relative to the repository root.\n *\n * `apps/api/src/generated/spa-shell.ts` in every repo that embeds a shell; the\n * parameter exists because the path is the one thing that genuinely differs.\n */\n readonly path: string;\n /**\n * The repository root the path is resolved against, as a file URL or a path.\n *\n * Defaults to the directory the build runs in (`process.cwd()`), which is the\n * repo root when the build is `pnpm --filter @scope/web build`. Passed in by the\n * Vite config, not derived from `import.meta.url`: this plugin object is created\n * inside the kit's own module, so a URL relative to it points into\n * `node_modules/@rexezuge/tooling` and writes the shell somewhere no compiler\n * will ever look.\n */\n readonly root?: string | URL;\n /**\n * The built `index.html`, as a path or file URL.\n *\n * Defaults to `dist/index.html` under the same root. Vite's `closeBundle` runs\n * after the bundle is written, so this is the file the build just produced.\n */\n readonly distIndex?: string | URL;\n}\n\n/**\n * What `defineWebViteConfig` accepts.\n */\nexport interface WebViteConfigOptions {\n /**\n * The SPA's plugins — `react()`, `tailwindcss()`, and anything else the app\n * needs. Applied before the spa-shell plugin so the shell is written after the\n * bundle exists.\n */\n readonly plugins?: readonly Plugin[];\n /**\n * Dev-server proxy entries. Keyed by path prefix.\n */\n readonly proxy?: Readonly<Record<string, ProxyEntry>>;\n /**\n * Where the built shell is embedded. Omit to skip the embedding entirely.\n */\n readonly spaShell?: SpaShellTarget;\n /**\n * The build output directory.\n */\n readonly outDir?: string;\n /**\n * The directory this config is resolved from, as a file URL. Defaults to the\n * caller's location.\n */\n readonly root?: string;\n}\n\n/**\n * The `spa-shell-embed` plugin, converged from all eight copies.\n *\n * It exists because the API worker serves `SPA_HTML` from a module in its own\n * source tree, and both that module and `dist/` are gitignored — so a fresh\n * clone gets an empty stub from `postinstall` and every `GET /` returns a blank\n * page until someone runs a build. This plugin is what makes the build write the\n * real artefact, and `scripts/verify-spa-shell.ts` is what refuses to deploy\n * without it.\n *\n * Written as a factory rather than inlined so the exit conditions are in one\n * place: the `closeBundle` hook runs on every build, including the ones where\n * `dist/index.html` was never produced, and a plugin that throws there fails\n * builds that legitimately emit nothing.\n */\n/**\n * Normalise a path-or-URL option to a URL, so `new URL(...)` can be used on it.\n *\n * Small, and here because two options accept either form: a path is what a consumer\n * naturally writes in a config, and a URL is what `import.meta.url` hands them.\n * Accepting both is one line and saves a `fileURLToPath` at every call site.\n */\nfunction toUrl(value: string | URL): URL {\n return typeof value === 'string' ? pathToFileURL(value) : value;\n}\n\n/**\n * The same, as a **directory** URL — with the trailing separator `new URL(rel, base)`\n * needs.\n *\n * `new URL('apps/api/x.ts', 'file:///repo')` resolves to `/apps/api/x.ts`, silently\n * dropping the base. The base has to end in a separator, and a path from\n * `process.cwd()` never does, so this is where the plugin would otherwise write the\n * shell into the filesystem root.\n */\nfunction toDirUrl(value: string | URL): URL {\n const url = toUrl(value);\n return url.href.endsWith('/') ? url : new URL(`${url.href}/`);\n}\n\nexport function spaShellEmbedPlugin(target: SpaShellTarget): Plugin & { closeBundle: () => void } {\n return {\n name: 'spa-shell-embed',\n closeBundle() {\n // Resolved from the directory the build runs in, never from this module's own\n // URL: the plugin object is created here but executes in the consumer's Vite\n // process, and `new URL(path, import.meta.url)` would resolve against\n // `node_modules/@rexezuge/tooling`. `process.cwd()` is the repo root for\n // `pnpm --filter @scope/web build`, which is how every consumer runs it.\n const root = toDirUrl(target.root ?? process.cwd());\n const outputPath = fileURLToPath(new URL(target.path, root));\n const indexPath =\n target.distIndex === undefined ? fileURLToPath(new URL('dist/index.html', root)) : fileURLToPath(toUrl(target.distIndex));\n\n if (!existsSync(indexPath)) {\n console.warn('spa-shell-embed: dist/index.html not found, skipping');\n return;\n }\n\n const html = readFileSync(indexPath, 'utf8');\n const output = `// Auto-generated by Vite build plugin - DO NOT EDIT.\\nexport const SPA_HTML: string = ${JSON.stringify(html)};\\n`;\n\n mkdirSync(path.dirname(outputPath), { recursive: true });\n writeFileSync(outputPath, output);\n },\n };\n}\n\n/**\n * Build the SPA's Vite config.\n *\n * ```ts\n * // apps/web/vite.config.ts\n * import react from '@vitejs/plugin-react';\n * import { defineWebViteConfig, spaShellEmbedPlugin } from '@rexezuge/tooling/vite';\n *\n * export default defineWebViteConfig({\n * plugins: [react()],\n * proxy: { '/user': { target: 'http://localhost:8787', changeOrigin: true } },\n * spaShell: { path: '../../apps/api/src/generated/spa-shell.ts' },\n * });\n * ```\n */\nexport function defineWebViteConfig(options: WebViteConfigOptions = {}): ViteUserConfig {\n const plugins: Plugin[] = [...(options.plugins ?? [])];\n if (options.spaShell !== undefined) {\n plugins.push(spaShellEmbedPlugin(options.spaShell));\n }\n\n return defineConfig({\n ...(plugins.length > 0 && { plugins }),\n ...(options.proxy !== undefined && { server: { proxy: { ...options.proxy } } }),\n build: {\n outDir: options.outDir ?? 'dist',\n emptyOutDir: true,\n },\n });\n}\n"],
5
+ "mappings": "AA+BA,OAAS,cAAAA,EAAY,aAAAC,EAAW,gBAAAC,EAAc,iBAAAC,MAAqB,UACnE,OAAOC,MAAU,YACjB,OAAS,iBAAAC,EAAe,iBAAAC,MAAqB,WAC7C,OAAS,gBAAAC,MAAsD,gBA6F/D,SAASC,EAAMC,EAAmB,CAChC,OAAO,OAAOA,GAAU,SAAWH,EAAcG,CAAK,EAAIA,CAC5D,CAWA,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mbedPlugin", "target", "root", "outputPath", "indexPath", "html", "output", "defineWebViteConfig", "options", "plugins"]
7
+ }
@@ -1 +1 @@
1
- {"version":3,"file":"vitest-aliases.d.ts","sourceRoot":"","sources":["../src/vitest-aliases.ts"],"names":[],"mappings":"AAEA;;;;;;;GAOG;AACH,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC;IAC/B,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;CAC9B;AAED;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,0BAA0B,EAAE,SAAS,MAAM,EAYvD,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,wBAAwB,EAAE,SAAS,MAAM,EAAwC,CAAC;AAE/F;;;;;;;;;;GAUG;AACH,eAAO,MAAM,eAAe,EAAE,SAAS,MAAM,EAA6B,CAAC;AAE3E;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACtC;;;OAGG;IACH,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB;;;;OAIG;IACH,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB;;;OAGG;IACH,QAAQ,CAAC,QAAQ,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACtC;;OAEG;IACH,QAAQ,CAAC,KAAK,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACnC;;OAEG;IACH,QAAQ,CAAC,YAAY,CAAC,EAAE,SAAS,WAAW,EAAE,CAAC;CAChD;AAED;;;;;;;;GAQG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,uBAAuB,GAAG,WAAW,EAAE,CAmBhF"}
1
+ {"version":3,"file":"vitest-aliases.d.ts","sourceRoot":"","sources":["../src/vitest-aliases.ts"],"names":[],"mappings":"AAEA;;;;;;;GAOG;AACH,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC;IAC/B,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;CAC9B;AAED;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,0BAA0B,EAAE,SAAS,MAAM,EAYvD,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,wBAAwB,EAAE,SAAS,MAAM,EAAwC,CAAC;AAE/F;;;;;;;;;;GAUG;AACH,eAAO,MAAM,eAAe,EAAE,SAAS,MAAM,EAA6B,CAAC;AAE3E;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACtC;;;OAGG;IACH,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB;;;;OAIG;IACH,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB;;;OAGG;IACH,QAAQ,CAAC,QAAQ,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACtC;;OAEG;IACH,QAAQ,CAAC,KAAK,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACnC;;OAEG;IACH,QAAQ,CAAC,YAAY,CAAC,EAAE,SAAS,WAAW,EAAE,CAAC;CAChD;AAED;;;;;;;;GAQG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,uBAAuB,GAAG,WAAW,EAAE,CAiBhF"}
@@ -1,81 +1 @@
1
- import { fileURLToPath } from 'node:url';
2
- /**
3
- * Every workspace package the family has converged on, as directory names under
4
- * `packages/`.
5
- *
6
- * The union across all nine repos: the universal core (`shared`,
7
- * `backend-errors`, `backend-runtime`, `backend-data`, `backend-services`) plus
8
- * the domain packages (`provider-clients`, `webdav`, `dav-store`,
9
- * `git-protocol`, `git-service`). `media-tags`/`subsonic` (Edge-Sonic) are
10
- * unconstrained utility leaves with no boundary block and no alias in their
11
- * source repo, so they are not listed — a repo that needs them passes
12
- * `packages` explicitly or appends `aliases`.
13
- *
14
- * A superset is safe: an alias for a package the consumer does not have never
15
- * matches a specifier, and Vite only resolves the replacement when something
16
- * imports it.
17
- */
18
- export const DEFAULT_WORKSPACE_PACKAGES = [
19
- 'shared',
20
- 'backend-errors',
21
- 'backend-runtime',
22
- 'backend-data',
23
- 'provider-clients',
24
- 'webdav',
25
- 'dav-store',
26
- 'git-protocol',
27
- 'git-service',
28
- 'backend-services',
29
- 'background',
30
- ];
31
- /**
32
- * The Cloudflare runtime mocks the unit suite aliases.
33
- *
34
- * `workers` exists in every repo; `sockets` in five; `workflows` in four. All
35
- * three are listed by default: an alias whose mock file is absent never fires
36
- * unless a test imports the specifier, and then the missing file is the correct
37
- * error rather than Node's `ERR_UNKNOWN_SCHEME` for `cloudflare:*`.
38
- */
39
- export const DEFAULT_CLOUDFLARE_MOCKS = ['workers', 'sockets', 'workflows'];
40
- /**
41
- * Keep the kit's own `dist/` inside Vite's pipeline.
42
- *
43
- * The kit ships ESM `dist/` with bundler-style extensionless relative imports
44
- * (its tsconfig is `moduleResolution: Bundler`), which Node's ESM resolver
45
- * refuses. Vitest externalizes `node_modules` deps by default and would import
46
- * that dist with Node; `noExternal` routes `@rexezuge/*` back through Vite —
47
- * the same resolver that bundles the worker — so a test loads the very dist
48
- * the worker ships. Without this, the run dies on `./BaseDAO` inside
49
- * `@rexezuge/d1`'s `dist/index.js`.
50
- */
51
- export const KIT_NO_EXTERNAL = [/(^|[/\\])@rexezuge\//];
52
- /**
53
- * Build the workspace alias table for a consumer repo.
54
- *
55
- * Aliases point at source rather than at built output, so a test exercises the
56
- * code the worker would run without a build step. `background` resolves under
57
- * `apps/`; every other package under `packages/`. `@/` maps to the API worker
58
- * source and `~/` to the SPA source, matching the two `tsconfig` path prefixes
59
- * every repo shares.
60
- */
61
- export function workspaceAliases(options) {
62
- const { scope, root } = options;
63
- const packages = options.packages ?? DEFAULT_WORKSPACE_PACKAGES;
64
- const mocks = options.mocks ?? DEFAULT_CLOUDFLARE_MOCKS;
65
- const at = (relative) => fileURLToPath(new URL(relative, root));
66
- const aliases = [];
67
- for (const name of packages) {
68
- const dir = name === 'background' ? 'apps/background/src' : `packages/${name}/src`;
69
- aliases.push({ find: `${scope}/${name}`, replacement: at(dir) });
70
- }
71
- for (const mock of mocks) {
72
- aliases.push({ find: `cloudflare:${mock}`, replacement: at(`test/mocks/cloudflare-${mock}.ts`) });
73
- }
74
- const apiSrc = at('apps/api/src');
75
- const webSrc = at('apps/web/src');
76
- aliases.push({ find: /^@\//, replacement: `${apiSrc}/` });
77
- aliases.push({ find: /^~\//, replacement: `${webSrc}/` });
78
- aliases.push(...(options.extraAliases ?? []));
79
- return aliases;
80
- }
81
- //# sourceMappingURL=vitest-aliases.js.map
1
+ import{fileURLToPath as i}from"node:url";const l=["shared","backend-errors","backend-runtime","backend-data","provider-clients","webdav","dav-store","git-protocol","git-service","backend-services","background"],f=["workers","sockets","workflows"],u=[/(^|[/\\])@rexezuge\//];function b(c){const{scope:o,root:a}=c,t=c.packages??l,n=c.mocks??f,s=e=>i(new URL(e,a)),r=[];for(const e of t){const k=e==="background"?"apps/background/src":`packages/${e}/src`;r.push({find:`${o}/${e}`,replacement:s(k)})}for(const e of n)r.push({find:`cloudflare:${e}`,replacement:s(`test/mocks/cloudflare-${e}.ts`)});const p=s("apps/api/src"),d=s("apps/web/src");return r.push({find:/^@\//,replacement:`${p}/`},{find:/^~\//,replacement:`${d}/`},...c.extraAliases??[]),r}export{f as DEFAULT_CLOUDFLARE_MOCKS,l as DEFAULT_WORKSPACE_PACKAGES,u as KIT_NO_EXTERNAL,b as workspaceAliases};
@@ -1 +1,7 @@
1
- {"version":3,"file":"vitest-aliases.js","sourceRoot":"","sources":["../src/vitest-aliases.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAezC;;;;;;;;;;;;;;;GAeG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAsB;IAC3D,QAAQ;IACR,gBAAgB;IAChB,iBAAiB;IACjB,cAAc;IACd,kBAAkB;IAClB,QAAQ;IACR,WAAW;IACX,cAAc;IACd,aAAa;IACb,kBAAkB;IAClB,YAAY;CACb,CAAC;AAEF;;;;;;;GAOG;AACH,MAA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AI,EAAE,MAAM,EAAE,WAAW,EAAE,GAAG,MAAM,GAAG,EAAE,CAAC,CAAC;IAC1D,OAAO,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,WAAW,EAAE,GAAG,MAAM,GAAG,EAAE,CAAC,CAAC;IAC1D,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,YAAY,IAAI,EAAE,CAAC,CAAC,CAAC;IAC9C,OAAO,OAAO,CAAC;AACjB,CAAC","sourcesContent":["import { fileURLToPath } from 'node:url';\n\n/**\n * One `{ find, replacement }` pair for Vitest's resolver.\n *\n * A `string` find is a prefix match in Vite; a `RegExp` find is tested against\n * the specifier. Workspace scopes use plain strings (`'@scope/name'` matches\n * `'@scope/name'` and `'@scope/name/sub'` alike); `@/` and `~/` use regexps so\n * the trailing slash is part of the match.\n */\nexport interface VitestAlias {\n readonly find: string | RegExp;\n readonly replacement: string;\n}\n\n/**\n * Every workspace package the family has converged on, as directory names under\n * `packages/`.\n *\n * The union across all nine repos: the universal core (`shared`,\n * `backend-errors`, `backend-runtime`, `backend-data`, `backend-services`) plus\n * the domain packages (`provider-clients`, `webdav`, `dav-store`,\n * `git-protocol`, `git-service`). `media-tags`/`subsonic` (Edge-Sonic) are\n * unconstrained utility leaves with no boundary block and no alias in their\n * source repo, so they are not listed — a repo that needs them passes\n * `packages` explicitly or appends `aliases`.\n *\n * A superset is safe: an alias for a package the consumer does not have never\n * matches a specifier, and Vite only resolves the replacement when something\n * imports it.\n */\nexport const DEFAULT_WORKSPACE_PACKAGES: readonly string[] = [\n 'shared',\n 'backend-errors',\n 'backend-runtime',\n 'backend-data',\n 'provider-clients',\n 'webdav',\n 'dav-store',\n 'git-protocol',\n 'git-service',\n 'backend-services',\n 'background',\n];\n\n/**\n * The Cloudflare runtime mocks the unit suite aliases.\n *\n * `workers` exists in every repo; `sockets` in five; `workflows` in four. All\n * three are listed by default: an alias whose mock file is absent never fires\n * unless a test imports the specifier, and then the missing file is the correct\n * error rather than Node's `ERR_UNKNOWN_SCHEME` for `cloudflare:*`.\n */\nexport const DEFAULT_CLOUDFLARE_MOCKS: readonly string[] = ['workers', 'sockets', 'workflows'];\n\n/**\n * Keep the kit's own `dist/` inside Vite's pipeline.\n *\n * The kit ships ESM `dist/` with bundler-style extensionless relative imports\n * (its tsconfig is `moduleResolution: Bundler`), which Node's ESM resolver\n * refuses. Vitest externalizes `node_modules` deps by default and would import\n * that dist with Node; `noExternal` routes `@rexezuge/*` back through Vite —\n * the same resolver that bundles the worker — so a test loads the very dist\n * the worker ships. Without this, the run dies on `./BaseDAO` inside\n * `@rexezuge/d1`'s `dist/index.js`.\n */\nexport const KIT_NO_EXTERNAL: readonly RegExp[] = [/(^|[/\\\\])@rexezuge\\//];\n\n/**\n * What `workspaceAliases` accepts.\n */\nexport interface WorkspaceAliasesOptions {\n /**\n * The consuming repo's npm scope, e.g. `'@myapp'`. Every `@scope/*` alias is\n * derived from it, so the same factory serves all nine repos.\n */\n readonly scope: string;\n /**\n * The repo root, as a file URL. Pass `new URL('.', import.meta.url).href`\n * from the calling config — never `import.meta.url` of this module, which\n * points inside `node_modules/@rexezuge/tooling`.\n */\n readonly root: string;\n /**\n * Workspace package directory names under `packages/` plus `background`\n * (which lives under `apps/`). Defaults to {@link DEFAULT_WORKSPACE_PACKAGES}.\n */\n readonly packages?: readonly string[];\n /**\n * Which `cloudflare:*` mocks to alias. Defaults to {@link DEFAULT_CLOUDFLARE_MOCKS}.\n */\n readonly mocks?: readonly string[];\n /**\n * Extra resolver entries, applied after the canonical ones.\n */\n readonly extraAliases?: readonly VitestAlias[];\n}\n\n/**\n * Build the workspace alias table for a consumer repo.\n *\n * Aliases point at source rather than at built output, so a test exercises the\n * code the worker would run without a build step. `background` resolves under\n * `apps/`; every other package under `packages/`. `@/` maps to the API worker\n * source and `~/` to the SPA source, matching the two `tsconfig` path prefixes\n * every repo shares.\n */\nexport function workspaceAliases(options: WorkspaceAliasesOptions): VitestAlias[] {\n const { scope, root } = options;\n const packages = options.packages ?? DEFAULT_WORKSPACE_PACKAGES;\n const mocks = options.mocks ?? DEFAULT_CLOUDFLARE_MOCKS;\n const at = (relative: string): string => fileURLToPath(new URL(relative, root));\n const aliases: VitestAlias[] = [];\n for (const name of packages) {\n const dir = name === 'background' ? 'apps/background/src' : `packages/${name}/src`;\n aliases.push({ find: `${scope}/${name}`, replacement: at(dir) });\n }\n for (const mock of mocks) {\n aliases.push({ find: `cloudflare:${mock}`, replacement: at(`test/mocks/cloudflare-${mock}.ts`) });\n }\n const apiSrc = at('apps/api/src');\n const webSrc = at('apps/web/src');\n aliases.push({ find: /^@\\//, replacement: `${apiSrc}/` });\n aliases.push({ find: /^~\\//, replacement: `${webSrc}/` });\n aliases.push(...(options.extraAliases ?? []));\n return aliases;\n}\n"]}
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/vitest-aliases.ts"],
4
+ "sourcesContent": ["import { fileURLToPath } from 'node:url';\n\n/**\n * One `{ find, replacement }` pair for Vitest's resolver.\n *\n * A `string` find is a prefix match in Vite; a `RegExp` find is tested against\n * the specifier. Workspace scopes use plain strings (`'@scope/name'` matches\n * `'@scope/name'` and `'@scope/name/sub'` alike); `@/` and `~/` use regexps so\n * the trailing slash is part of the match.\n */\nexport interface VitestAlias {\n readonly find: string | RegExp;\n readonly replacement: string;\n}\n\n/**\n * Every workspace package the family has converged on, as directory names under\n * `packages/`.\n *\n * The union across all nine repos: the universal core (`shared`,\n * `backend-errors`, `backend-runtime`, `backend-data`, `backend-services`) plus\n * the domain packages (`provider-clients`, `webdav`, `dav-store`,\n * `git-protocol`, `git-service`). `media-tags`/`subsonic` (Edge-Sonic) are\n * unconstrained utility leaves with no boundary block and no alias in their\n * source repo, so they are not listed — a repo that needs them passes\n * `packages` explicitly or appends `aliases`.\n *\n * A superset is safe: an alias for a package the consumer does not have never\n * matches a specifier, and Vite only resolves the replacement when something\n * imports it.\n */\nexport const DEFAULT_WORKSPACE_PACKAGES: readonly string[] = [\n 'shared',\n 'backend-errors',\n 'backend-runtime',\n 'backend-data',\n 'provider-clients',\n 'webdav',\n 'dav-store',\n 'git-protocol',\n 'git-service',\n 'backend-services',\n 'background',\n];\n\n/**\n * The Cloudflare runtime mocks the unit suite aliases.\n *\n * `workers` exists in every repo; `sockets` in five; `workflows` in four. All\n * three are listed by default: an alias whose mock file is absent never fires\n * unless a test imports the specifier, and then the missing file is the correct\n * error rather than Node's `ERR_UNKNOWN_SCHEME` for `cloudflare:*`.\n */\nexport const DEFAULT_CLOUDFLARE_MOCKS: readonly string[] = ['workers', 'sockets', 'workflows'];\n\n/**\n * Keep the kit's own `dist/` inside Vite's pipeline.\n *\n * The kit ships ESM `dist/` with bundler-style extensionless relative imports\n * (its tsconfig is `moduleResolution: Bundler`), which Node's ESM resolver\n * refuses. Vitest externalizes `node_modules` deps by default and would import\n * that dist with Node; `noExternal` routes `@rexezuge/*` back through Vite —\n * the same resolver that bundles the worker — so a test loads the very dist\n * the worker ships. Without this, the run dies on `./BaseDAO` inside\n * `@rexezuge/d1`'s `dist/index.js`.\n */\nexport const KIT_NO_EXTERNAL: readonly RegExp[] = [/(^|[/\\\\])@rexezuge\\//];\n\n/**\n * What `workspaceAliases` accepts.\n */\nexport interface WorkspaceAliasesOptions {\n /**\n * The consuming repo's npm scope, e.g. `'@myapp'`. Every `@scope/*` alias is\n * derived from it, so the same factory serves all nine repos.\n */\n readonly scope: string;\n /**\n * The repo root, as a file URL. Pass `new URL('.', import.meta.url).href`\n * from the calling config — never `import.meta.url` of this module, which\n * points inside `node_modules/@rexezuge/tooling`.\n */\n readonly root: string;\n /**\n * Workspace package directory names under `packages/` plus `background`\n * (which lives under `apps/`). Defaults to {@link DEFAULT_WORKSPACE_PACKAGES}.\n */\n readonly packages?: readonly string[];\n /**\n * Which `cloudflare:*` mocks to alias. Defaults to {@link DEFAULT_CLOUDFLARE_MOCKS}.\n */\n readonly mocks?: readonly string[];\n /**\n * Extra resolver entries, applied after the canonical ones.\n */\n readonly extraAliases?: readonly VitestAlias[];\n}\n\n/**\n * Build the workspace alias table for a consumer repo.\n *\n * Aliases point at source rather than at built output, so a test exercises the\n * code the worker would run without a build step. `background` resolves under\n * `apps/`; every other package under `packages/`. `@/` maps to the API worker\n * source and `~/` to the SPA source, matching the two `tsconfig` path prefixes\n * every repo shares.\n */\nexport function workspaceAliases(options: WorkspaceAliasesOptions): VitestAlias[] {\n const { scope, root } = options;\n const packages = options.packages ?? DEFAULT_WORKSPACE_PACKAGES;\n const mocks = options.mocks ?? DEFAULT_CLOUDFLARE_MOCKS;\n const at = (relative: string): string => fileURLToPath(new URL(relative, root));\n const aliases: VitestAlias[] = [];\n for (const name of packages) {\n const dir = name === 'background' ? 'apps/background/src' : `packages/${name}/src`;\n aliases.push({ find: `${scope}/${name}`, replacement: at(dir) });\n }\n for (const mock of mocks) {\n aliases.push({ find: `cloudflare:${mock}`, replacement: at(`test/mocks/cloudflare-${mock}.ts`) });\n }\n const apiSrc = at('apps/api/src');\n const webSrc = at('apps/web/src');\n aliases.push({ find: /^@\\//, replacement: `${apiSrc}/` }, { find: /^~\\//, replacement: `${webSrc}/` }, ...(options.extraAliases ?? []));\n return aliases;\n}\n"],
5
+ "mappings": "AAAA,OAAS,iBAAAA,MAAqB,WA+BvB,MAAMC,EAAgD,CAC3D,SACA,iBACA,kBACA,eACA,mBACA,SACA,YACA,eACA,cACA,mBACA,cAWWC,EAA8C,CAAC,UAAW,UAAW,WAAW,EAahFC,EAAqC,CAAC,sBAAsB,EAyCnE,SAAUC,EAAiBC,EAAgC,CAC/D,KAAM,CAAE,MAAAC,EAAO,KAAAC,CAAI,EAAKF,EAClBG,EAAWH,EAAQ,UAAYJ,EAC/BQ,EAAQJ,EAAQ,OAASH,EACzBQ,EAAMC,GAA6BX,EAAc,IAAI,IAAIW,EAAUJ,CAAI,CAAC,EACxEK,EAAyB,CAAA,EAC/B,UAAWC,KAAQL,EAAU,CAC3B,MAAMM,EAAMD,IAAS,aAAe,sBAAwB,YAAYA,CAAI,OAC5ED,EAAQ,KAAK,CAAE,KAAM,GAAGN,CAAK,IAAIO,CAAI,GAAI,YAAaH,EAAGI,CAAG,CAAC,CAAE,CACjE,CACA,UAAWC,KAAQN,EACjBG,EAAQ,KAAK,CAAE,KAAM,cAAcG,CAAI,GAAI,YAAaL,EAAG,yBAAyBK,CAAI,KAAK,CAAC,CAAE,EAElG,MAAMC,EAASN,EAAG,cAAc,EAC1BO,EAASP,EAAG,cAAc,EAChC,OAAAE,EAAQ,KAAK,CAAE,KAAM,OAAQ,YAAa,GAAGI,CAAM,GAAG,EAAI,CAAE,KAAM,OAAQ,YAAa,GAAGC,CAAM,GAAG,EAAI,GAAIZ,EAAQ,cAAgB,CAAA,CAAG,EAC/HO,CACT",
6
+ "names": ["fileURLToPath", "DEFAULT_WORKSPACE_PACKAGES", "DEFAULT_CLOUDFLARE_MOCKS", "KIT_NO_EXTERNAL", "workspaceAliases", "options", "scope", "root", "packages", "mocks", "at", "relative", "aliases", "name", "dir", "mock", "apiSrc", "webSrc"]
7
+ }
@@ -1,64 +1 @@
1
- /**
2
- * The integration-suite Vitest config.
3
- *
4
- * Provenance: the eight `test/integration/vitest.config.mts` workerd suites
5
- * plus CalDAV-Bridge's `node:sqlite` suite. Every one hand-writes the same
6
- * `@scope/* → src` workspace table (8–20 entries) beside its own harness
7
- * wiring; this factory generates that table from `scope` so the two cannot
8
- * drift apart — a suite resolving a workspace import differently from the unit
9
- * suite fails in a way that looks like a product bug.
10
- *
11
- * What the factory does not do, deliberately: the workerd suites' `plugins`
12
- * (`@cloudflare/vitest-pool-workers`), `pool` and migration-SQL `define` are
13
- * harness wiring that belongs to the repo, and importing the workerd plugin
14
- * here would make the tooling package undownloadable for a consumer without
15
- * it. The factory takes them as opaque pass-through and returns them
16
- * untouched. CalDAV-Bridge's suite passes none of them (plain `node` +
17
- * `node:sqlite`, no coverage); the workerd suites pass all three.
18
- */
19
- import { defineConfig } from 'vitest/config';
20
- import { DEFAULT_WORKSPACE_PACKAGES, workspaceAliases } from "./vitest-aliases.js";
21
- /**
22
- * Build the integration-suite config.
23
- *
24
- * ```ts
25
- * // test/integration/vitest.config.mts — workerd suite
26
- * import { cloudflareTest, cloudflarePool } from '@cloudflare/vitest-pool-workers';
27
- * import { defineIntegrationVitestConfig } from '@rexezuge/tooling/vitest-integration';
28
- * export default defineIntegrationVitestConfig({
29
- * scope: '@myapp',
30
- * define: { __INTEGRATION_MIGRATION_SQL__: JSON.stringify(migrationSql) },
31
- * plugins: [cloudflareTest({ wrangler: { configPath: './test/integration/wrangler.test.jsonc' } })],
32
- * pool: cloudflarePool({ wrangler: { configPath: './test/integration/wrangler.test.jsonc' } }),
33
- * });
34
- * ```
35
- *
36
- * ```ts
37
- * // test/integration/vitest.config.mts — sqlite suite (no workerd)
38
- * import { defineIntegrationVitestConfig } from '@rexezuge/tooling/vitest-integration';
39
- * export default defineIntegrationVitestConfig({
40
- * scope: '@myapp',
41
- * include: ['test/integration/**​/*.test.ts'],
42
- * });
43
- * ```
44
- */
45
- export function defineIntegrationVitestConfig(options) {
46
- const root = options.root ?? new URL('.', import.meta.url).href;
47
- const aliases = [
48
- ...workspaceAliases({ scope: options.scope, root, packages: options.packages ?? DEFAULT_WORKSPACE_PACKAGES, mocks: [] }),
49
- ...(options.aliases ?? []),
50
- ];
51
- return defineConfig({
52
- ...(options.define !== undefined && { define: { ...options.define } }),
53
- ...(options.plugins !== undefined && { plugins: [...options.plugins] }),
54
- resolve: { alias: aliases },
55
- test: {
56
- globals: true,
57
- environment: 'node',
58
- include: [...(options.include ?? ['test/integration/**/*.int.test.ts'])],
59
- ...(options.pool !== undefined && { pool: options.pool }),
60
- },
61
- ...(options.ssrNoExternal !== undefined && { ssr: { noExternal: [...options.ssrNoExternal] } }),
62
- });
63
- }
64
- //# sourceMappingURL=vitest-integration.js.map
1
+ import{defineConfig as a}from"vitest/config";import{DEFAULT_WORKSPACE_PACKAGES as l,workspaceAliases as s}from"./vitest-aliases.js";function d(e){const n=e.root??new URL(".",import.meta.url).href,r=[...s({scope:e.scope,root:n,packages:e.packages??l,mocks:[]}),...e.aliases??[]];return a({...e.define!==void 0&&{define:{...e.define}},...e.plugins!==void 0&&{plugins:[...e.plugins]},resolve:{alias:r},test:{globals:!0,environment:"node",include:[...e.include??["test/integration/**/*.int.test.ts"]],...e.pool!==void 0&&{pool:e.pool}},...e.ssrNoExternal!==void 0&&{ssr:{noExternal:[...e.ssrNoExternal]}}})}export{d as defineIntegrationVitestConfig};
@@ -1 +1,7 @@
1
- {"version":3,"file":"vitest-integration.js","sourceRoot":"","sources":["../src/vitest-integration.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EAAE,YAAY,EAAe,MAAM,eAAe,CAAC;AAE1D,OAAO,EAAE,0BAA0B,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAqDnF;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAM,UAAU,6BAA6B,CAAC,OAAuC;IACnF,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,IAAI,IAAI,GAAG,CAAC,GAAG,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC;IAChE,MAAM,OAAO,GAAG;QACd,GAAG,gBAAgB,CAAC,EAAE,KAAK,EAAE,OAAO,CAAC,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,CAAC,QAAQ,IAAI,0BAA0B,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC;QACxH,GAAG,CAAC,OAAO,CAAC,OAAO,IAAI,EAAE,CAAC;KAC3B,CAAC;IAEF,OAAO,YAAY,CAAC;QAClB,GAAG,CAAC,OAAO,CAAC,MAAM,KAAK,SAAS,IAAI,EAAE,MAAM,EAAE,EAAE,GAAG,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC;QACtE,GAAG,CAAC,OAAO,CAAC,OAAO,KAAK,SAAS,IAAI,EAAE,OAAO,EAAE,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;QACvE,OAAO,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE;QAC3B,IAAI,EAAE;YACJ,OAAO,EAAE,IAAI;YACb,WAAW,EAAE,MAAM;YACnB,OAAO,EAAE,CAAC,GAAG,CAAC,OAAO,CAAC,OAAO,IAAI,CAAC,mCAAmC,CAAC,CAAC,CAAC;YACxE,GAAG,CAAC,OAAO,CAAC,IAAI,KAAK,SAAS,IAAI,EAAE,IAAI,EAAE,OAAO,CAAC,IAAI,EAAE,CAAC;SAC1D;QACD,GAAG,CAAC,OAAO,CAAC,aAAa,KAAK,SAAS,IAAI,EAAE,GAAG,EAAE,EAAE,UAAU,EAAE,CAAC,GAAG,OAAO,CAAC,aAAa,CAAC,EAAE,EAAE,CAAC;KAChG,CAAC,CAAC;AACL,CAAC","sourcesContent":["/**\n * The integration-suite Vitest config.\n *\n * Provenance: the eight `test/integration/vitest.config.mts` workerd suites\n * plus CalDAV-Bridge's `node:sqlite` suite. Every one hand-writes the same\n * `@scope/* → src` workspace table (8–20 entries) beside its own harness\n * wiring; this factory generates that table from `scope` so the two cannot\n * drift apart — a suite resolving a workspace import differently from the unit\n * suite fails in a way that looks like a product bug.\n *\n * What the factory does not do, deliberately: the workerd suites' `plugins`\n * (`@cloudflare/vitest-pool-workers`), `pool` and migration-SQL `define` are\n * harness wiring that belongs to the repo, and importing the workerd plugin\n * here would make the tooling package undownloadable for a consumer without\n * it. The factory takes them as opaque pass-through and returns them\n * untouched. CalDAV-Bridge's suite passes none of them (plain `node` +\n * `node:sqlite`, no coverage); the workerd suites pass all three.\n */\n\nimport { defineConfig, type Plugin } from 'vitest/config';\nimport type { Pool } from 'vitest/node';\nimport { DEFAULT_WORKSPACE_PACKAGES, workspaceAliases } from './vitest-aliases.ts';\nimport type { VitestAlias } from './vitest-aliases.ts';\n\n/**\n * What `defineIntegrationVitestConfig` accepts.\n */\nexport interface IntegrationVitestConfigOptions {\n /**\n * The consuming repo's npm scope, e.g. `'@myapp'`.\n */\n readonly scope: string;\n /**\n * Workspace package directory names. Defaults to the family superset.\n */\n readonly packages?: readonly string[];\n /**\n * The repo root, as a file URL.\n */\n readonly root?: string;\n /**\n * Extra resolver entries, applied after the workspace table (e.g. the\n * `hono` dedupe two repos carry).\n */\n readonly aliases?: readonly VitestAlias[];\n /**\n * Which suites to collect. Workerd suites use\n * `test/integration/​**​/*.int.test.ts`; CalDAV-Bridge's sqlite suite uses\n * `test/integration/​**​/*.test.ts`.\n */\n readonly include?: readonly string[];\n /**\n * The Vitest plugins (the workerd `cloudflareTest()` plugin). Typed as the\n * runner's own plugin so a workerd plugin is accepted and nothing new is\n * imported — this package stays dependency-free.\n */\n readonly plugins?: readonly Plugin[];\n /**\n * The pool (the workerd `cloudflarePool()`). The runner's own `Pool` type,\n * so a custom pool is accepted without importing its provider.\n */\n readonly pool?: Pool;\n /**\n * Compile-time defines (the migration SQL/SQLite bundle each suite injects).\n * Opaque, passed through.\n */\n readonly define?: Readonly<Record<string, string>>;\n /**\n * SSR `noExternal` (workerd suites list `hono`, `chanfana` and their scope).\n * Passed through untouched.\n */\n readonly ssrNoExternal?: readonly string[];\n}\n\n/**\n * Build the integration-suite config.\n *\n * ```ts\n * // test/integration/vitest.config.mts — workerd suite\n * import { cloudflareTest, cloudflarePool } from '@cloudflare/vitest-pool-workers';\n * import { defineIntegrationVitestConfig } from '@rexezuge/tooling/vitest-integration';\n * export default defineIntegrationVitestConfig({\n * scope: '@myapp',\n * define: { __INTEGRATION_MIGRATION_SQL__: JSON.stringify(migrationSql) },\n * plugins: [cloudflareTest({ wrangler: { configPath: './test/integration/wrangler.test.jsonc' } })],\n * pool: cloudflarePool({ wrangler: { configPath: './test/integration/wrangler.test.jsonc' } }),\n * });\n * ```\n *\n * ```ts\n * // test/integration/vitest.config.mts — sqlite suite (no workerd)\n * import { defineIntegrationVitestConfig } from '@rexezuge/tooling/vitest-integration';\n * export default defineIntegrationVitestConfig({\n * scope: '@myapp',\n * include: ['test/integration/**​/*.test.ts'],\n * });\n * ```\n */\nexport function defineIntegrationVitestConfig(options: IntegrationVitestConfigOptions): ReturnType<typeof defineConfig> {\n const root = options.root ?? new URL('.', import.meta.url).href;\n const aliases = [\n ...workspaceAliases({ scope: options.scope, root, packages: options.packages ?? DEFAULT_WORKSPACE_PACKAGES, mocks: [] }),\n ...(options.aliases ?? []),\n ];\n\n return defineConfig({\n ...(options.define !== undefined && { define: { ...options.define } }),\n ...(options.plugins !== undefined && { plugins: [...options.plugins] }),\n resolve: { alias: aliases },\n test: {\n globals: true,\n environment: 'node',\n include: [...(options.include ?? ['test/integration/**/*.int.test.ts'])],\n ...(options.pool !== undefined && { pool: options.pool }),\n },\n ...(options.ssrNoExternal !== undefined && { ssr: { noExternal: [...options.ssrNoExternal] } }),\n });\n}\n"]}
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/vitest-integration.ts"],
4
+ "sourcesContent": ["/**\n * The integration-suite Vitest config.\n *\n * Provenance: the eight `test/integration/vitest.config.mts` workerd suites\n * plus CalDAV-Bridge's `node:sqlite` suite. Every one hand-writes the same\n * `@scope/* → src` workspace table (8–20 entries) beside its own harness\n * wiring; this factory generates that table from `scope` so the two cannot\n * drift apart — a suite resolving a workspace import differently from the unit\n * suite fails in a way that looks like a product bug.\n *\n * What the factory does not do, deliberately: the workerd suites' `plugins`\n * (`@cloudflare/vitest-pool-workers`), `pool` and migration-SQL `define` are\n * harness wiring that belongs to the repo, and importing the workerd plugin\n * here would make the tooling package undownloadable for a consumer without\n * it. The factory takes them as opaque pass-through and returns them\n * untouched. CalDAV-Bridge's suite passes none of them (plain `node` +\n * `node:sqlite`, no coverage); the workerd suites pass all three.\n */\n\nimport { defineConfig, type Plugin } from 'vitest/config';\nimport type { Pool } from 'vitest/node';\nimport { DEFAULT_WORKSPACE_PACKAGES, workspaceAliases } from './vitest-aliases.ts';\nimport type { VitestAlias } from './vitest-aliases.ts';\n\n/**\n * What `defineIntegrationVitestConfig` accepts.\n */\nexport interface IntegrationVitestConfigOptions {\n /**\n * The consuming repo's npm scope, e.g. `'@myapp'`.\n */\n readonly scope: string;\n /**\n * Workspace package directory names. Defaults to the family superset.\n */\n readonly packages?: readonly string[];\n /**\n * The repo root, as a file URL.\n */\n readonly root?: string;\n /**\n * Extra resolver entries, applied after the workspace table (e.g. the\n * `hono` dedupe two repos carry).\n */\n readonly aliases?: readonly VitestAlias[];\n /**\n * Which suites to collect. Workerd suites use\n * `test/integration/​**​/*.int.test.ts`; CalDAV-Bridge's sqlite suite uses\n * `test/integration/​**​/*.test.ts`.\n */\n readonly include?: readonly string[];\n /**\n * The Vitest plugins (the workerd `cloudflareTest()` plugin). Typed as the\n * runner's own plugin so a workerd plugin is accepted and nothing new is\n * imported — this package stays dependency-free.\n */\n readonly plugins?: readonly Plugin[];\n /**\n * The pool (the workerd `cloudflarePool()`). The runner's own `Pool` type,\n * so a custom pool is accepted without importing its provider.\n */\n readonly pool?: Pool;\n /**\n * Compile-time defines (the migration SQL/SQLite bundle each suite injects).\n * Opaque, passed through.\n */\n readonly define?: Readonly<Record<string, string>>;\n /**\n * SSR `noExternal` (workerd suites list `hono`, `chanfana` and their scope).\n * Passed through untouched.\n */\n readonly ssrNoExternal?: readonly string[];\n}\n\n/**\n * Build the integration-suite config.\n *\n * ```ts\n * // test/integration/vitest.config.mts — workerd suite\n * import { cloudflareTest, cloudflarePool } from '@cloudflare/vitest-pool-workers';\n * import { defineIntegrationVitestConfig } from '@rexezuge/tooling/vitest-integration';\n * export default defineIntegrationVitestConfig({\n * scope: '@myapp',\n * define: { __INTEGRATION_MIGRATION_SQL__: JSON.stringify(migrationSql) },\n * plugins: [cloudflareTest({ wrangler: { configPath: './test/integration/wrangler.test.jsonc' } })],\n * pool: cloudflarePool({ wrangler: { configPath: './test/integration/wrangler.test.jsonc' } }),\n * });\n * ```\n *\n * ```ts\n * // test/integration/vitest.config.mts — sqlite suite (no workerd)\n * import { defineIntegrationVitestConfig } from '@rexezuge/tooling/vitest-integration';\n * export default defineIntegrationVitestConfig({\n * scope: '@myapp',\n * include: ['test/integration/**​/*.test.ts'],\n * });\n * ```\n */\nexport function defineIntegrationVitestConfig(options: IntegrationVitestConfigOptions): ReturnType<typeof defineConfig> {\n const root = options.root ?? new URL('.', import.meta.url).href;\n const aliases = [\n ...workspaceAliases({ scope: options.scope, root, packages: options.packages ?? DEFAULT_WORKSPACE_PACKAGES, mocks: [] }),\n ...(options.aliases ?? []),\n ];\n\n return defineConfig({\n ...(options.define !== undefined && { define: { ...options.define } }),\n ...(options.plugins !== undefined && { plugins: [...options.plugins] }),\n resolve: { alias: aliases },\n test: {\n globals: true,\n environment: 'node',\n include: [...(options.include ?? ['test/integration/**/*.int.test.ts'])],\n ...(options.pool !== undefined && { pool: options.pool }),\n },\n ...(options.ssrNoExternal !== undefined && { ssr: { noExternal: [...options.ssrNoExternal] } }),\n });\n}\n"],
5
+ "mappings": "AAmBA,OAAS,gBAAAA,MAAiC,gBAE1C,OAAS,8BAAAC,EAA4B,oBAAAC,MAAwB,sBA6EvD,SAAUC,EAA8BC,EAAuC,CACnF,MAAMC,EAAOD,EAAQ,MAAQ,IAAI,IAAI,IAAK,YAAY,GAAG,EAAE,KACrDE,EAAU,CACd,GAAGJ,EAAiB,CAAE,MAAOE,EAAQ,MAAO,KAAAC,EAAM,SAAUD,EAAQ,UAAYH,EAA4B,MAAO,CAAA,CAAE,CAAE,EACvH,GAAIG,EAAQ,SAAW,CAAA,GAGzB,OAAOJ,EAAa,CAClB,GAAII,EAAQ,SAAW,QAAa,CAAE,OAAQ,CAAE,GAAGA,EAAQ,MAAM,CAAE,EACnE,GAAIA,EAAQ,UAAY,QAAa,CAAE,QAAS,CAAC,GAAGA,EAAQ,OAAO,CAAC,EACpE,QAAS,CAAE,MAAOE,CAAO,EACzB,KAAM,CACJ,QAAS,GACT,YAAa,OACb,QAAS,CAAC,GAAIF,EAAQ,SAAW,CAAC,mCAAmC,CAAE,EACvE,GAAIA,EAAQ,OAAS,QAAa,CAAE,KAAMA,EAAQ,IAAI,GAExD,GAAIA,EAAQ,gBAAkB,QAAa,CAAE,IAAK,CAAE,WAAY,CAAC,GAAGA,EAAQ,aAAa,CAAC,CAAE,EAC7F,CACH",
6
+ "names": ["defineConfig", "DEFAULT_WORKSPACE_PACKAGES", "workspaceAliases", "defineIntegrationVitestConfig", "options", "root", "aliases"]
7
+ }