@rexezuge/tooling 1.5.1 → 1.5.2

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 (51) hide show
  1. package/dist/eslint-boundaries.js +1 -1
  2. package/dist/eslint-boundaries.js.map +2 -2
  3. package/dist/eslint.js +1 -1
  4. package/dist/eslint.js.map +2 -2
  5. package/dist/functions/pages-proxy.js +1 -1
  6. package/dist/functions/pages-proxy.js.map +2 -2
  7. package/dist/scripts/backup/d1-target.js +1 -1
  8. package/dist/scripts/backup/d1-target.js.map +2 -2
  9. package/dist/scripts/backup/destination-config.js +1 -1
  10. package/dist/scripts/backup/destination-config.js.map +2 -2
  11. package/dist/scripts/backup/naming.js +1 -1
  12. package/dist/scripts/backup/naming.js.map +2 -2
  13. package/dist/scripts/check-god-files.js +2 -2
  14. package/dist/scripts/check-god-files.js.map +2 -2
  15. package/dist/scripts/init-secrets.js +2 -2
  16. package/dist/scripts/init-secrets.js.map +2 -2
  17. package/dist/scripts/lib/cli-args.js +1 -1
  18. package/dist/scripts/lib/cli-args.js.map +2 -2
  19. package/dist/scripts/lib/github-actions.js +3 -3
  20. package/dist/scripts/lib/github-actions.js.map +2 -2
  21. package/dist/scripts/lib/wrangler-table.js +2 -2
  22. package/dist/scripts/lib/wrangler-table.js.map +2 -2
  23. package/dist/scripts/spa-shell.js +2 -2
  24. package/dist/scripts/spa-shell.js.map +2 -2
  25. package/dist/scripts/validate-locales.js +4 -4
  26. package/dist/scripts/validate-locales.js.map +2 -2
  27. package/dist/scripts/verify-migrations.js +2 -2
  28. package/dist/scripts/verify-migrations.js.map +2 -2
  29. package/dist/scripts/wrangler-config/cli.js +3 -3
  30. package/dist/scripts/wrangler-config/cli.js.map +2 -2
  31. package/dist/scripts/wrangler-config/patches.js +3 -3
  32. package/dist/scripts/wrangler-config/patches.js.map +2 -2
  33. package/dist/scripts/wrangler-config/resources.js +1 -1
  34. package/dist/scripts/wrangler-config/resources.js.map +2 -2
  35. package/dist/test/integration-migrations.js +2 -2
  36. package/dist/test/integration-migrations.js.map +2 -2
  37. package/dist/test/mocks/cloudflare-workers.js +1 -1
  38. package/dist/test/mocks/cloudflare-workers.js.map +2 -2
  39. package/dist/vite.js +3 -3
  40. package/dist/vite.js.map +2 -2
  41. package/dist/vitest-aliases.js +1 -1
  42. package/dist/vitest-aliases.js.map +2 -2
  43. package/dist/vitest-integration.js +1 -1
  44. package/dist/vitest-integration.js.map +2 -2
  45. package/dist/vitest-repo.js +1 -1
  46. package/dist/vitest-repo.js.map +2 -2
  47. package/dist/vitest-web.js +1 -1
  48. package/dist/vitest-web.js.map +2 -2
  49. package/dist/vitest.js +1 -1
  50. package/dist/vitest.js.map +2 -2
  51. package/package.json +2 -2
@@ -2,6 +2,6 @@
2
2
  "version": 3,
3
3
  "sources": ["../../../src/test/mocks/cloudflare-workers.ts"],
4
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"]
5
+ "mappings": "+EAiFA,MAAMA,CAAa,CAjFnB,MAiFmB,CAAAC,EAAA,sBACP,IACA,IAEV,YAAYC,EAAyBC,EAAS,CAC5C,KAAK,IAAMD,EACX,KAAK,IAAMC,CACb,EAOF,MAAMC,CAAS,CA/Ff,MA+Fe,CAAAH,EAAA,mBASf,MAAMI,CAAkB,CAxGxB,MAwGwB,CAAAJ,EAAA,2BACZ,IACA,IAEV,YAAYC,EAAuBC,EAAS,CAC1C,KAAK,IAAMD,EACX,KAAK,IAAMC,CACb",
6
+ "names": ["DurableObject", "__name", "ctx", "env", "RpcTarget", "WorkflowEntrypoint"]
7
7
  }
package/dist/vite.js CHANGED
@@ -1,3 +1,3 @@
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};
1
+ var l=Object.defineProperty;var t=(e,n)=>l(e,"name",{value:n,configurable:!0});import{existsSync as f,mkdirSync as p,readFileSync as c,writeFileSync as h}from"node:fs";import m from"node:path";import{fileURLToPath as i,pathToFileURL as x}from"node:url";import{defineConfig as a}from"vitest/config";function u(e){return typeof e=="string"?x(e):e}t(u,"toUrl");function y(e){const n=u(e);return n.href.endsWith("/")?n:new URL(`${n.href}/`)}t(y,"toDirUrl");function g(e){return{name:"spa-shell-embed",closeBundle(){const n=y(e.root??process.cwd()),r=i(new URL(e.path,n)),o=e.distIndex===void 0?i(new URL("dist/index.html",n)):i(u(e.distIndex));if(!f(o)){console.warn("spa-shell-embed: dist/index.html not found, skipping");return}const d=c(o,"utf8"),s=`// Auto-generated by Vite build plugin - DO NOT EDIT.
2
+ export const SPA_HTML: string = ${JSON.stringify(d)};
3
+ `;p(m.dirname(r),{recursive:!0}),h(r,s)}}}t(g,"spaShellEmbedPlugin");function L(e={}){const n=[...e.plugins??[]];return e.spaShell!==void 0&&n.push(g(e.spaShell)),a({...n.length>0&&{plugins:n},...e.proxy!==void 0&&{server:{proxy:{...e.proxy}}},build:{outDir:e.outDir??"dist",emptyOutDir:!0}})}t(L,"defineWebViteConfig");export{L as defineWebViteConfig,g as spaShellEmbedPlugin};
package/dist/vite.js.map CHANGED
@@ -2,6 +2,6 @@
2
2
  "version": 3,
3
3
  "sources": ["../src/vite.ts"],
4
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,SAASC,EAASD,EAAmB,CACnC,MAAME,EAAMH,EAAMC,CAAK,EACvB,OAAOE,EAAI,KAAK,SAAS,GAAG,EAAIA,EAAM,IAAI,IAAI,GAAGA,EAAI,IAAI,GAAG,CAC9D,CAEM,SAAUC,EAAoBC,EAAsB,CACxD,MAAO,CACL,KAAM,kBACN,aAAW,CAMT,MAAMC,EAAOJ,EAASG,EAAO,MAAQ,QAAQ,IAAG,CAAE,EAC5CE,EAAaV,EAAc,IAAI,IAAIQ,EAAO,KAAMC,CAAI,CAAC,EACrDE,EACJH,EAAO,YAAc,OAAYR,EAAc,IAAI,IAAI,kBAAmBS,CAAI,CAAC,EAAIT,EAAcG,EAAMK,EAAO,SAAS,CAAC,EAE1H,GAAI,CAACb,EAAWgB,CAAS,EAAG,CAC1B,QAAQ,KAAK,sDAAsD,EACnE,MACF,CAEA,MAAMC,EAAOf,EAAac,EAAW,MAAM,EACrCE,EAAS;kCAA0F,KAAK,UAAUD,CAAI,CAAC;EAE7HhB,EAAUG,EAAK,QAAQW,CAAU,EAAG,CAAE,UAAW,EAAI,CAAE,EACvDZ,EAAcY,EAAYG,CAAM,CAClC,EAEJ,CAiBM,SAAUC,EAAoBC,EAAgC,CAAA,EAAE,CACpE,MAAMC,EAAoB,CAAC,GAAID,EAAQ,SAAW,CAAA,CAAG,EACrD,OAAIA,EAAQ,WAAa,QACvBC,EAAQ,KAAKT,EAAoBQ,EAAQ,QAAQ,CAAC,EAG7Cb,EAAa,CAClB,GAAIc,EAAQ,OAAS,GAAK,CAAE,QAAAA,CAAO,EACnC,GAAID,EAAQ,QAAU,QAAa,CAAE,OAAQ,CAAE,MAAO,CAAE,GAAGA,EAAQ,KAAK,CAAE,CAAE,EAC5E,MAAO,CACL,OAAQA,EAAQ,QAAU,OAC1B,YAAa,IAEhB,CACH",
6
- "names": ["existsSync", "mkdirSync", "readFileSync", "writeFileSync", "path", "fileURLToPath", "pathToFileURL", "defineConfig", "toUrl", "value", "toDirUrl", "url", "spaShellEmbedPlugin", "target", "root", "outputPath", "indexPath", "html", "output", "defineWebViteConfig", "options", "plugins"]
5
+ "mappings": "+EA+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,SA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,EAAAU,EAAA",
6
+ "names": ["existsSync", "mkdirSync", "readFileSync", "writeFileSync", "path", "fileURLToPath", "pathToFileURL", "defineConfig", "toUrl", "value", "__name", "toDirUrl", "url", "spaShellEmbedPlugin", "target", "root", "outputPath", "indexPath", "html", "output", "defineWebViteConfig", "options", "plugins"]
7
7
  }
@@ -1 +1 @@
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
+ var l=Object.defineProperty;var a=(c,o)=>l(c,"name",{value:o,configurable:!0});import{fileURLToPath as f}from"node:url";const m=["shared","backend-errors","backend-runtime","backend-data","provider-clients","webdav","dav-store","git-protocol","git-service","backend-services","background"],u=["workers","sockets","workflows"],A=[/(^|[/\\])@rexezuge\//];function w(c){const{scope:o,root:t}=c,n=c.packages??m,p=c.mocks??u,s=a(e=>f(new URL(e,t)),"at"),r=[];for(const e of n){const i=e==="background"?"apps/background/src":`packages/${e}/src`;r.push({find:`${o}/${e}`,replacement:s(i)})}for(const e of p)r.push({find:`cloudflare:${e}`,replacement:s(`test/mocks/cloudflare-${e}.ts`)});const d=s("apps/api/src"),k=s("apps/web/src");return r.push({find:/^@\//,replacement:`${d}/`},{find:/^~\//,replacement:`${k}/`},...c.extraAliases??[]),r}a(w,"workspaceAliases");export{u as DEFAULT_CLOUDFLARE_MOCKS,m as DEFAULT_WORKSPACE_PACKAGES,A as KIT_NO_EXTERNAL,w as workspaceAliases};
@@ -2,6 +2,6 @@
2
2
  "version": 3,
3
3
  "sources": ["../src/vitest-aliases.ts"],
4
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"]
5
+ "mappings": "+EAAA,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,EAAKC,EAACC,GAA6BZ,EAAc,IAAI,IAAIY,EAAUL,CAAI,CAAC,EAAnE,MACLM,EAAyB,CAAA,EAC/B,UAAWC,KAAQN,EAAU,CAC3B,MAAMO,EAAMD,IAAS,aAAe,sBAAwB,YAAYA,CAAI,OAC5ED,EAAQ,KAAK,CAAE,KAAM,GAAGP,CAAK,IAAIQ,CAAI,GAAI,YAAaJ,EAAGK,CAAG,CAAC,CAAE,CACjE,CACA,UAAWC,KAAQP,EACjBI,EAAQ,KAAK,CAAE,KAAM,cAAcG,CAAI,GAAI,YAAaN,EAAG,yBAAyBM,CAAI,KAAK,CAAC,CAAE,EAElG,MAAMC,EAASP,EAAG,cAAc,EAC1BQ,EAASR,EAAG,cAAc,EAChC,OAAAG,EAAQ,KAAK,CAAE,KAAM,OAAQ,YAAa,GAAGI,CAAM,GAAG,EAAI,CAAE,KAAM,OAAQ,YAAa,GAAGC,CAAM,GAAG,EAAI,GAAIb,EAAQ,cAAgB,CAAA,CAAG,EAC/HQ,CACT,CAjBgBF,EAAAP,EAAA",
6
+ "names": ["fileURLToPath", "DEFAULT_WORKSPACE_PACKAGES", "DEFAULT_CLOUDFLARE_MOCKS", "KIT_NO_EXTERNAL", "workspaceAliases", "options", "scope", "root", "packages", "mocks", "at", "__name", "relative", "aliases", "name", "dir", "mock", "apiSrc", "webSrc"]
7
7
  }
@@ -1 +1 @@
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
+ var l=Object.defineProperty;var r=(e,n)=>l(e,"name",{value:n,configurable:!0});import{defineConfig as s}from"vitest/config";import{DEFAULT_WORKSPACE_PACKAGES as i,workspaceAliases as t}from"./vitest-aliases.js";function c(e){const n=e.root??new URL(".",import.meta.url).href,a=[...t({scope:e.scope,root:n,packages:e.packages??i,mocks:[]}),...e.aliases??[]];return s({...e.define!==void 0&&{define:{...e.define}},...e.plugins!==void 0&&{plugins:[...e.plugins]},resolve:{alias:a},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]}}})}r(c,"defineIntegrationVitestConfig");export{c as defineIntegrationVitestConfig};
@@ -2,6 +2,6 @@
2
2
  "version": 3,
3
3
  "sources": ["../src/vitest-integration.ts"],
4
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,MAAi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,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,CAnBgBG,EAAAJ,EAAA",
6
+ "names": ["defineConfig", "DEFAULT_WORKSPACE_PACKAGES", "workspaceAliases", "defineIntegrationVitestConfig", "options", "root", "aliases", "__name"]
7
7
  }
@@ -1 +1 @@
1
- import{defineConfig as u}from"vitest/config";import{fileURLToPath as m}from"node:url";import{DEFAULT_CLOUDFLARE_MOCKS as b,DEFAULT_WORKSPACE_PACKAGES as f,KIT_NO_EXTERNAL as E,workspaceAliases as d}from"./vitest-aliases.js";const g=["**/node_modules/**","**/dist/**","test/integration/**","test/web/**","test/**/web-*.test.{ts,tsx}","apps/web/**/*.test.{ts,tsx}"],x=["test/web/**/*.test.{ts,tsx}","test/**/web-*.test.{ts,tsx}","apps/web/**/*.test.{ts,tsx}"],v=["scripts/**","**/*.test.ts","**/*.test.tsx","**/*.d.ts","**/index.ts","**/types.d.ts","**/types.ts","**/model/**","**/generated/**","**/D1Types.ts","**/ServiceEnv.ts","**/env.d.ts"];function L(e){const r=e.root??new URL(".",import.meta.url).href,n=e.packages??f,c=e.mocks??b,l=[...E,...e.noExternal??[]],t=e.backend??{},s=e.web??{},i=[...d({scope:e.scope,root:r,packages:n,mocks:c}),...e.aliases??[],...t.aliases??[]],a=m(new URL("apps/web/src",r)),o=[{find:/^@\//,replacement:`${a}/`},{find:/^~\//,replacement:`${a}/`},...d({scope:e.scope,root:r,packages:n,mocks:c}).filter(p=>typeof p.find=="string"),...e.aliases??[],...s.aliases??[]];return u({test:{projects:[{resolve:{alias:i,noExternal:l},test:{name:"backend",globals:!0,environment:"node",include:[...t.include??["test/**/*.test.{ts,tsx}"]],exclude:[...t.exclude??g],...t.setupFiles!==void 0&&{setupFiles:[...t.setupFiles]},server:{deps:{inline:[...t.serverDepsInline??["dofs"]]}}}},{...s.plugins!==void 0&&{plugins:[...s.plugins]},resolve:{alias:o,noExternal:l},test:{name:"web",globals:!0,environment:s.environment??"jsdom",include:[...s.include??x],exclude:[...s.exclude??["**/node_modules/**","**/dist/**","test/integration/**"]],pool:"threads",...s.setupFiles!==void 0&&{setupFiles:[...s.setupFiles]}}}],coverage:{provider:"v8",reporter:["text","lcov","html"],reportsDirectory:e.reportsDirectory??"./coverage",include:[...e.coverageInclude??["apps/api/src/**/*.ts","apps/background/src/**/*.ts","apps/web/src/**/*.{ts,tsx}","packages/**/src/**/*.ts"]],exclude:[...v,...e.coverageExclude??[]],...e.thresholds!==void 0&&{thresholds:{...e.thresholds}}}}})}export{L as defineRepoVitestConfig};
1
+ var m=Object.defineProperty;var d=(e,r)=>m(e,"name",{value:r,configurable:!0});import{defineConfig as b}from"vitest/config";import{fileURLToPath as f}from"node:url";import{DEFAULT_CLOUDFLARE_MOCKS as E,DEFAULT_WORKSPACE_PACKAGES as g,KIT_NO_EXTERNAL as x,workspaceAliases as i}from"./vitest-aliases.js";const v=["**/node_modules/**","**/dist/**","test/integration/**","test/web/**","test/**/web-*.test.{ts,tsx}","apps/web/**/*.test.{ts,tsx}"],w=["test/web/**/*.test.{ts,tsx}","test/**/web-*.test.{ts,tsx}","apps/web/**/*.test.{ts,tsx}"],A=["scripts/**","**/*.test.ts","**/*.test.tsx","**/*.d.ts","**/index.ts","**/types.d.ts","**/types.ts","**/model/**","**/generated/**","**/D1Types.ts","**/ServiceEnv.ts","**/env.d.ts"];function D(e){const r=e.root??new URL(".",import.meta.url).href,n=e.packages??g,c=e.mocks??E,l=[...x,...e.noExternal??[]],t=e.backend??{},s=e.web??{},o=[...i({scope:e.scope,root:r,packages:n,mocks:c}),...e.aliases??[],...t.aliases??[]],a=f(new URL("apps/web/src",r)),p=[{find:/^@\//,replacement:`${a}/`},{find:/^~\//,replacement:`${a}/`},...i({scope:e.scope,root:r,packages:n,mocks:c}).filter(u=>typeof u.find=="string"),...e.aliases??[],...s.aliases??[]];return b({test:{projects:[{resolve:{alias:o,noExternal:l},test:{name:"backend",globals:!0,environment:"node",include:[...t.include??["test/**/*.test.{ts,tsx}"]],exclude:[...t.exclude??v],...t.setupFiles!==void 0&&{setupFiles:[...t.setupFiles]},server:{deps:{inline:[...t.serverDepsInline??["dofs"]]}}}},{...s.plugins!==void 0&&{plugins:[...s.plugins]},resolve:{alias:p,noExternal:l},test:{name:"web",globals:!0,environment:s.environment??"jsdom",include:[...s.include??w],exclude:[...s.exclude??["**/node_modules/**","**/dist/**","test/integration/**"]],pool:"threads",...s.setupFiles!==void 0&&{setupFiles:[...s.setupFiles]}}}],coverage:{provider:"v8",reporter:["text","lcov","html"],reportsDirectory:e.reportsDirectory??"./coverage",include:[...e.coverageInclude??["apps/api/src/**/*.ts","apps/background/src/**/*.ts","apps/web/src/**/*.{ts,tsx}","packages/**/src/**/*.ts"]],exclude:[...A,...e.coverageExclude??[]],...e.thresholds!==void 0&&{thresholds:{...e.thresholds}}}}})}d(D,"defineRepoVitestConfig");export{D as defineRepoVitestConfig};
@@ -2,6 +2,6 @@
2
2
  "version": 3,
3
3
  "sources": ["../src/vitest-repo.ts"],
4
4
  "sourcesContent": ["/**\n * The single-file `projects` composition: backend (`node`) plus SPA (DOM).\n *\n * Provenance: AWS-AccessBridge (split by `.ts`/`.tsx` extension),\n * Mail-Meow (split by `test/web/**` directory, with per-project `setupFiles`\n * and the React plugin on the web project), CalDAV-Bridge (split by directory\n * with `happy-dom`). The two-file repos (Durable-DAV-Router, Mail-Otter) keep\n * `defineUnitVitestConfig()` + `defineWebVitestConfig()`; this factory is the\n * same two halves as `projects` entries in one file, sharing one root coverage\n * gate.\n *\n * Canonical decisions (all three sources agree):\n *\n * 1. **Coverage lives at the root**, not per project: one floor for the whole\n * unit suite. (Durable-DAV-Router's warning about a shared floor stands for\n * the two-file split; within one file the three sources all gate once.)\n * 2. **Each project repeats the alias table.** Vitest projects do not inherit\n * the root `resolve` (Mail-Meow), so a suite resolving `@scope/*`\n * differently from its sibling fails like a product bug. Both entries carry\n * the full table — backend with `@/` → API, web with `@/` + `~/` → SPA.\n * 3. **The web project keeps `pool: 'threads'`** and its DOM from\n * `defineWebVitestConfig()`; the backend project keeps `environment:\n * 'node'` and `server.deps.inline` from `defineUnitVitestConfig()`.\n */\n\nimport { defineConfig, type Plugin } from 'vitest/config';\nimport { fileURLToPath } from 'node:url';\nimport { DEFAULT_CLOUDFLARE_MOCKS, DEFAULT_WORKSPACE_PACKAGES, KIT_NO_EXTERNAL, workspaceAliases } from './vitest-aliases.ts';\nimport type { VitestAlias } from './vitest-aliases.ts';\nimport type { CoverageThresholds } from './vitest.ts';\n\n/**\n * The backend half of the `projects` pair.\n */\nexport interface RepoBackendOptions {\n /**\n * Which suites to collect. Defaults to the whole unit suite minus SPA and\n * integration shapes.\n */\n readonly include?: readonly string[];\n /**\n * Suite paths to skip, replacing the default.\n */\n readonly exclude?: readonly string[];\n /**\n * Setup files run before each backend test file.\n */\n readonly setupFiles?: readonly string[];\n /**\n * `node_modules` specifiers to inline through Vite. Defaults to `['dofs']`.\n */\n readonly serverDepsInline?: readonly string[];\n /**\n * Extra resolver entries for the backend project only.\n */\n readonly aliases?: readonly VitestAlias[];\n}\n\n/**\n * The SPA half of the `projects` pair.\n */\nexport interface RepoWebOptions {\n /**\n * The DOM implementation. `jsdom` is the family default; `happy-dom` is\n * CalDAV-Bridge's.\n */\n readonly environment?: 'jsdom' | 'happy-dom';\n /**\n * Which suites to collect. Defaults to every SPA shape the family uses.\n */\n readonly include?: readonly string[];\n /**\n * Suite paths to skip, replacing the default.\n */\n readonly exclude?: readonly string[];\n /**\n * Setup files run before each SPA test file.\n */\n readonly setupFiles?: readonly string[];\n /**\n * Vite plugins the SPA needs (`react()` for JSX).\n */\n readonly plugins?: readonly Plugin[];\n /**\n * Extra resolver entries for the web project only.\n */\n readonly aliases?: readonly VitestAlias[];\n}\n\n/**\n * What `defineRepoVitestConfig` accepts.\n */\nexport interface RepoVitestConfigOptions {\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 * Which `cloudflare:*` mocks to alias. Defaults to workers/sockets/workflows.\n */\n readonly mocks?: readonly string[];\n /**\n * The repo root, as a file URL.\n */\n readonly root?: string;\n /**\n * Extra resolver entries applied to *both* projects (e.g. the `hono`\n * dedupe). Per-project extras go on `backend.aliases` / `web.aliases`.\n */\n readonly aliases?: readonly VitestAlias[];\n /**\n * Resolver `noExternal` patterns, merged after {@link KIT_NO_EXTERNAL}.\n */\n readonly noExternal?: readonly (string | RegExp)[];\n /**\n * The backend half. Omitted fields take the `defineUnitVitestConfig`\n * defaults.\n */\n readonly backend?: RepoBackendOptions;\n /**\n * The SPA half. Omitted fields take the `defineWebVitestConfig` defaults.\n */\n readonly web?: RepoWebOptions;\n /**\n * Coverage `include` globs. Defaults to the worker, the SPA and every\n * workspace package's `src`.\n */\n readonly coverageInclude?: readonly string[];\n /**\n * Coverage `exclude` globs, merged with the canonical set.\n */\n readonly coverageExclude?: readonly string[];\n /**\n * Coverage floors. Omitted by default; a repo that wants them sets them.\n */\n readonly thresholds?: CoverageThresholds;\n /**\n * Where the coverage report is written.\n */\n readonly reportsDirectory?: string;\n}\n\n/**\n * Backend suites excluded from the backend project: the SPA shapes live in the\n * web project, and integration is its own config.\n */\nconst BACKEND_EXCLUDE: readonly string[] = [\n '**/node_modules/**',\n '**/dist/**',\n 'test/integration/**',\n 'test/web/**',\n 'test/**/web-*.test.{ts,tsx}',\n 'apps/web/**/*.test.{ts,tsx}',\n];\n\n/**\n * SPA suite shapes collected by the web project.\n */\nconst WEB_INCLUDE: readonly string[] = ['test/web/**/*.test.{ts,tsx}', 'test/**/web-*.test.{ts,tsx}', 'apps/web/**/*.test.{ts,tsx}'];\n\n/**\n * Coverage `exclude`: the union of the unit and web halves' canonical sets.\n */\nconst CANONICAL_COVERAGE_EXCLUDE: readonly string[] = [\n 'scripts/**',\n '**/*.test.ts',\n '**/*.test.tsx',\n '**/*.d.ts',\n '**/index.ts',\n '**/types.d.ts',\n '**/types.ts',\n '**/model/**',\n '**/generated/**',\n '**/D1Types.ts',\n '**/ServiceEnv.ts',\n '**/env.d.ts',\n];\n\n/**\n * Build the single-file `projects` config.\n *\n * ```ts\n * // vitest.config.mts\n * import { defineRepoVitestConfig } from '@rexezuge/tooling/vitest-repo';\n * export default defineRepoVitestConfig({\n * scope: '@myapp',\n * web: { environment: 'happy-dom' },\n * thresholds: { statements: 87, branches: 77, functions: 88, lines: 90 },\n * });\n * ```\n */\nexport function defineRepoVitestConfig(options: RepoVitestConfigOptions): ReturnType<typeof defineConfig> {\n const root = options.root ?? new URL('.', import.meta.url).href;\n const packages = options.packages ?? DEFAULT_WORKSPACE_PACKAGES;\n const mocks = options.mocks ?? DEFAULT_CLOUDFLARE_MOCKS;\n const noExternal = [...KIT_NO_EXTERNAL, ...(options.noExternal ?? [])];\n const backend = options.backend ?? {};\n const web = options.web ?? {};\n\n const backendAliases = [\n ...workspaceAliases({ scope: options.scope, root, packages, mocks }),\n ...(options.aliases ?? []),\n ...(backend.aliases ?? []),\n ];\n // `@/` means the SPA in the web project (Mail-Otter's SPA source imports\n // through it); the workspace table's `@/` → API entry is dropped and the\n // SPA's own prepended. `~/` → SPA either way.\n const webSrc = fileURLToPath(new URL('apps/web/src', root));\n const webAliases: VitestAlias[] = [\n { find: /^@\\//, replacement: `${webSrc}/` },\n { find: /^~\\//, replacement: `${webSrc}/` },\n // Drop the workspace table's `@/`/`~/` (RegExp) entries — the SPA's own\n // prepended above win — and keep the `@scope/*` + `cloudflare:*` strings.\n ...workspaceAliases({ scope: options.scope, root, packages, mocks }).filter((alias) => typeof alias.find === 'string'),\n ...(options.aliases ?? []),\n ...(web.aliases ?? []),\n ];\n\n return defineConfig({\n test: {\n projects: [\n {\n resolve: { alias: backendAliases, noExternal },\n test: {\n name: 'backend',\n globals: true,\n environment: 'node',\n include: [...(backend.include ?? ['test/**/*.test.{ts,tsx}'])],\n exclude: [...(backend.exclude ?? BACKEND_EXCLUDE)],\n ...(backend.setupFiles !== undefined && { setupFiles: [...backend.setupFiles] }),\n server: { deps: { inline: [...(backend.serverDepsInline ?? ['dofs'])] } },\n },\n },\n {\n ...(web.plugins !== undefined && { plugins: [...web.plugins] }),\n resolve: { alias: webAliases, noExternal },\n test: {\n name: 'web',\n globals: true,\n environment: web.environment ?? 'jsdom',\n include: [...(web.include ?? WEB_INCLUDE)],\n exclude: [...(web.exclude ?? ['**/node_modules/**', '**/dist/**', 'test/integration/**'])],\n pool: 'threads',\n ...(web.setupFiles !== undefined && { setupFiles: [...web.setupFiles] }),\n },\n },\n ],\n coverage: {\n provider: 'v8',\n reporter: ['text', 'lcov', 'html'],\n reportsDirectory: options.reportsDirectory ?? './coverage',\n include: [\n ...(options.coverageInclude ?? [\n 'apps/api/src/**/*.ts',\n 'apps/background/src/**/*.ts',\n 'apps/web/src/**/*.{ts,tsx}',\n 'packages/**/src/**/*.ts',\n ]),\n ],\n exclude: [...CANONICAL_COVERAGE_EXCLUDE, ...(options.coverageExclude ?? [])],\n ...(options.thresholds !== undefined && { thresholds: { ...options.thresholds } }),\n },\n },\n });\n}\n"],
5
- "mappings": "AAyBA,OAAS,gBAAAA,MAAiC,gBAC1C,OAAS,iBAAAC,MAAqB,WAC9B,OAAS,4BAAAC,EAA0B,8BAAAC,EAA4B,mBAAAC,EAAiB,oBAAAC,MAAwB,sBA2HxG,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CAAC,GAAIA,EAAQ,SAAWT,CAAgB,EACjD,GAAIS,EAAQ,aAAe,QAAa,CAAE,WAAY,CAAC,GAAGA,EAAQ,UAAU,CAAC,EAC7E,OAAQ,CAAE,KAAM,CAAE,OAAQ,CAAC,GAAIA,EAAQ,kBAAoB,CAAC,MAAM,CAAE,CAAC,CAAE,IAG3E,CACE,GAAIC,EAAI,UAAY,QAAa,CAAE,QAAS,CAAC,GAAGA,EAAI,OAAO,CAAC,EAC5D,QAAS,CAAE,MAAOG,EAAY,WAAAL,CAAU,EACxC,KAAM,CACJ,KAAM,MACN,QAAS,GACT,YAAaE,EAAI,aAAe,QAChC,QAAS,CAAC,GAAIA,EAAI,SAAWT,CAAY,EACzC,QAAS,CAAC,GAAIS,EAAI,SAAW,CAAC,qBAAsB,aAAc,qBAAqB,CAAE,EACzF,KAAM,UACN,GAAIA,EAAI,aAAe,QAAa,CAAE,WAAY,CAAC,GAAGA,EAAI,UAAU,CAAC,KAI3E,SAAU,CACR,SAAU,KACV,SAAU,CAAC,OAAQ,OAAQ,MAAM,EACjC,iBAAkBN,EAAQ,kBAAoB,aAC9C,QAAS,CACP,GAAIA,EAAQ,iBAAmB,CAC7B,uBACA,8BACA,6BACA,4BAGJ,QAAS,CAAC,GAAGF,EAA4B,GAAIE,EAAQ,iBAAmB,CAAA,CAAG,EAC3E,GAAIA,EAAQ,aAAe,QAAa,CAAE,WAAY,CAAE,GAAGA,EAAQ,UAAU,CAAE,IAGpF,CACH",
6
- "names": ["defineConfig", "fileURLToPath", "DEFAULT_CLOUDFLARE_MOCKS", "DEFAULT_WORKSPACE_PACKAGES", "KIT_NO_EXTERNAL", "workspaceAliases", "BACKEND_EXCLUDE", "WEB_INCLUDE", "CANONICAL_COVERAGE_EXCLUDE", "defineRepoVitestConfig", "options", "root", "packages", "mocks", "noExternal", "backend", "web", "backendAliases", "webSrc", "webAliases", "alias"]
5
+ "mappings": "+EAyBA,OAAS,gBAAAA,MAAiC,gBAC1C,OAAS,iBA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options", "root", "packages", "mocks", "noExternal", "backend", "web", "backendAliases", "webSrc", "webAliases", "alias", "__name"]
7
7
  }
@@ -1 +1 @@
1
- import{defineConfig as l}from"vitest/config";import{fileURLToPath as c}from"node:url";import{DEFAULT_CLOUDFLARE_MOCKS as i,DEFAULT_WORKSPACE_PACKAGES as a,KIT_NO_EXTERNAL as u,workspaceAliases as f}from"./vitest-aliases.js";const o=["test/web/**/*.test.{ts,tsx}","test/**/web-*.test.{ts,tsx}","apps/web/**/*.test.{ts,tsx}"],p=["**/*.test.{ts,tsx}","**/*.d.ts","**/types.ts","**/generated/**"];function v(e={}){const s=e.root??new URL(".",import.meta.url).href,r=c(new URL("apps/web/src",s)),n=f({scope:e.scope??"@unused",root:s,packages:e.packages??a,mocks:e.mocks??i}).filter(t=>typeof t.find=="string"&&!t.find.startsWith("@unused")),d=[{find:/^@\//,replacement:`${r}/`},{find:/^~\//,replacement:`${r}/`},...n.filter(t=>typeof t.find=="string"&&(t.find.startsWith("cloudflare:")||e.scope!==void 0)),...e.aliases??[]];return l({...e.plugins!==void 0&&{plugins:[...e.plugins]},resolve:{alias:d,noExternal:[...u,...e.noExternal??[]]},test:{globals:!0,environment:e.environment??"jsdom",include:[...e.include??o],pool:"threads",exclude:[...e.exclude??["**/node_modules/**","**/dist/**","test/integration/**"]],...e.setupFiles!==void 0&&{setupFiles:[...e.setupFiles]},...e.serverDepsInline!==void 0&&{server:{deps:{inline:[...e.serverDepsInline]}}},coverage:{provider:"v8",reporter:["text","lcov"],reportsDirectory:e.reportsDirectory??"./coverage-spa",include:[...e.coverageInclude??["apps/web/src/**/*.{ts,tsx}"]],exclude:[...p,...e.coverageExclude??[]],...e.thresholds!==void 0&&{thresholds:{...e.thresholds}}}}})}export{v as defineWebVitestConfig};
1
+ var c=Object.defineProperty;var n=(e,s)=>c(e,"name",{value:s,configurable:!0});import{defineConfig as i}from"vitest/config";import{fileURLToPath as a}from"node:url";import{DEFAULT_CLOUDFLARE_MOCKS as u,DEFAULT_WORKSPACE_PACKAGES as f,KIT_NO_EXTERNAL as o,workspaceAliases as p}from"./vitest-aliases.js";const g=["test/web/**/*.test.{ts,tsx}","test/**/web-*.test.{ts,tsx}","apps/web/**/*.test.{ts,tsx}"],m=["**/*.test.{ts,tsx}","**/*.d.ts","**/types.ts","**/generated/**"];function L(e={}){const s=e.root??new URL(".",import.meta.url).href,r=a(new URL("apps/web/src",s)),d=p({scope:e.scope??"@unused",root:s,packages:e.packages??f,mocks:e.mocks??u}).filter(t=>typeof t.find=="string"&&!t.find.startsWith("@unused")),l=[{find:/^@\//,replacement:`${r}/`},{find:/^~\//,replacement:`${r}/`},...d.filter(t=>typeof t.find=="string"&&(t.find.startsWith("cloudflare:")||e.scope!==void 0)),...e.aliases??[]];return i({...e.plugins!==void 0&&{plugins:[...e.plugins]},resolve:{alias:l,noExternal:[...o,...e.noExternal??[]]},test:{globals:!0,environment:e.environment??"jsdom",include:[...e.include??g],pool:"threads",exclude:[...e.exclude??["**/node_modules/**","**/dist/**","test/integration/**"]],...e.setupFiles!==void 0&&{setupFiles:[...e.setupFiles]},...e.serverDepsInline!==void 0&&{server:{deps:{inline:[...e.serverDepsInline]}}},coverage:{provider:"v8",reporter:["text","lcov"],reportsDirectory:e.reportsDirectory??"./coverage-spa",include:[...e.coverageInclude??["apps/web/src/**/*.{ts,tsx}"]],exclude:[...m,...e.coverageExclude??[]],...e.thresholds!==void 0&&{thresholds:{...e.thresholds}}}}})}n(L,"defineWebVitestConfig");export{L as defineWebVitestConfig};
@@ -2,6 +2,6 @@
2
2
  "version": 3,
3
3
  "sources": ["../src/vitest-web.ts"],
4
4
  "sourcesContent": ["/**\n * The SPA's test and coverage gate.\n *\n * Provenance: converged from all nine repos' SPA suites — Durable-DAV-Router's\n * and Mail-Otter's `vitest.web.config.mts` (the two repos that gave the frontend\n * its own file), Mail-Meow's and CalDAV-Bridge's `projects` entries (the two\n * that keep backend and SPA in one file), and AWS-AccessBridge's\n * extension-split `dom` project. Durable-DAV-Router's file is the canonical\n * shape — it is the one that records *why* the split exists; Mail-Otter's\n * contributes the React plugin and the `apps/web/**` include; CalDAV-Bridge\n * contributes `happy-dom` and the `test/web/**` directory convention;\n * Mail-Meow contributes `setupFiles` and the note that projects do not inherit\n * the root `resolve`.\n *\n * Canonical decisions:\n *\n * 1. **A DOM for every file here**, rather than a `@vitest-environment` pragma\n * per file: these are the tests that need a DOM, and the pragma is one more\n * place to forget. `jsdom` is the family default (seven repos);\n * `happy-dom` is CalDAV-Bridge's, and is one option away.\n * 2. **`pool: 'threads'`, bounded, rather than one forked worker per file.** Each\n * jsdom document is a whole browser environment; a fork per file exhausts\n * memory on a constrained machine, and when it does the run dies partway with\n * a bare \"Worker exited unexpectedly\" and no test reports a failure — which\n * reads as a flaky suite rather than as an out-of-memory kill.\n * 3. **`include` covers every shape the family uses** — the `test/web/**`\n * directory convention, the root-suite `web-*` naming convention, and suites\n * bundled under `apps/web` — and the same globs are what\n * `defineUnitVitestConfig()` excludes, so a file is collected by exactly one\n * config.\n * 4. **Projects do not inherit the root `resolve`** (Mail-Meow): a\n * single-file `projects` composition must repeat the alias table per\n * project. `defineRepoVitestConfig()` does that; two-file repos get it from\n * these factories directly.\n * 5. **`@/` means the SPA here, not the API worker.** The unit config maps\n * `@/` to `apps/api/src`; this config maps both `@/` (Mail-Otter's SPA\n * source) and `~/` (Mail-Meow's and CalDAV-Bridge's SPA tests) to\n * `apps/web/src`. Workspace `@scope/*` imports still resolve to the\n * packages, so web tests reach shared logic the same way backend tests do.\n */\n\nimport { defineConfig, type Plugin } from 'vitest/config';\nimport { fileURLToPath } from 'node:url';\nimport { DEFAULT_CLOUDFLARE_MOCKS, DEFAULT_WORKSPACE_PACKAGES, KIT_NO_EXTERNAL, workspaceAliases } from './vitest-aliases.ts';\nimport type { VitestAlias } from './vitest-aliases.ts';\nimport type { CoverageThresholds } from './vitest.ts';\n\n/**\n * What `defineWebVitestConfig` accepts.\n */\nexport interface WebVitestConfigOptions {\n /**\n * The consuming repo's npm scope, e.g. `'@myapp'`. When supplied, `@scope/*`\n * workspace aliases are generated so web tests reach shared logic; when\n * omitted, only the `cloudflare:*`, `@/` and `~/` aliases apply.\n */\n readonly scope?: string;\n /**\n * Workspace package directory names. Defaults to the family superset.\n */\n readonly packages?: readonly string[];\n /**\n * Which `cloudflare:*` mocks to alias. Defaults to workers/sockets/workflows.\n */\n readonly mocks?: readonly string[];\n /**\n * Vite plugins the SPA needs — `@vitejs/plugin-react` for a React app. Passed\n * by the consumer rather than imported here, because the kit must stay\n * zero-dependency and the plugin belongs to the app, not the harness.\n */\n readonly plugins?: readonly Plugin[];\n /**\n * Extra resolver entries, applied after the canonical ones.\n */\n readonly aliases?: readonly VitestAlias[];\n /**\n * The repo root, as a file URL.\n */\n readonly root?: string;\n /**\n * The DOM implementation. `jsdom` is the family default; `happy-dom` is\n * CalDAV-Bridge's (lighter, and sufficient for its hook/service suites).\n */\n readonly environment?: 'jsdom' | 'happy-dom';\n /**\n * Which suites to collect. Defaults to every shape the family uses.\n */\n readonly include?: readonly string[];\n /**\n * Suite paths to skip, replacing the default.\n */\n readonly exclude?: readonly string[];\n /**\n * Setup files run before each test file.\n */\n readonly setupFiles?: readonly string[];\n /**\n * `node_modules` specifiers to inline through Vite rather than externalize.\n */\n readonly serverDepsInline?: readonly string[];\n /**\n * Resolver `noExternal` patterns, merged after {@link KIT_NO_EXTERNAL}.\n */\n readonly noExternal?: readonly (string | RegExp)[];\n /**\n * Coverage `include` globs. Defaults to the SPA source.\n */\n readonly coverageInclude?: readonly string[];\n /**\n * Coverage `exclude` globs, merged with the canonical set.\n */\n readonly coverageExclude?: readonly string[];\n /**\n * Coverage floors. Omitted by default; see `defineUnitVitestConfig`.\n */\n readonly thresholds?: CoverageThresholds;\n /**\n * Where the coverage report is written. Separate from the unit config's, so\n * the two gates never overwrite each other's report.\n */\n readonly reportsDirectory?: string;\n}\n\n/**\n * The default suite globs: every shape the family uses — the `test/web/**`\n * directory convention, the root-suite `web-*` convention, and the\n * bundled-under-`apps/web` convention — so any layout works unchanged.\n */\nconst DEFAULT_INCLUDE: readonly string[] = ['test/web/**/*.test.{ts,tsx}', 'test/**/web-*.test.{ts,tsx}', 'apps/web/**/*.test.{ts,tsx}'];\n\n/**\n * Coverage `exclude` globs for the SPA half.\n */\nconst CANONICAL_COVERAGE_EXCLUDE: readonly string[] = ['**/*.test.{ts,tsx}', '**/*.d.ts', '**/types.ts', '**/generated/**'];\n\n/**\n * Build the SPA's test config.\n *\n * ```ts\n * // vitest.web.config.mts\n * import react from '@vitejs/plugin-react';\n * import { defineWebVitestConfig } from '@rexezuge/tooling/vitest-web';\n * export default defineWebVitestConfig({ scope: '@myapp', plugins: [react()] });\n * ```\n */\nexport function defineWebVitestConfig(options: WebVitestConfigOptions = {}): ReturnType<typeof defineConfig> {\n const root = options.root ?? new URL('.', import.meta.url).href;\n const webSrc = fileURLToPath(new URL('apps/web/src', root));\n // The workspace table maps `@/` to the API worker; here `@/` means the SPA,\n // so drop its `@/`/`~/` entries and prepend the SPA's own. String finds\n // (`@scope/*`, `cloudflare:*`) survive; a placeholder scope contributes none.\n const scopePart = workspaceAliases({\n scope: options.scope ?? '@unused',\n root,\n packages: options.packages ?? DEFAULT_WORKSPACE_PACKAGES,\n mocks: options.mocks ?? DEFAULT_CLOUDFLARE_MOCKS,\n }).filter((alias) => typeof alias.find === 'string' && !alias.find.startsWith('@unused'));\n const aliases: VitestAlias[] = [\n { find: /^@\\//, replacement: `${webSrc}/` },\n { find: /^~\\//, replacement: `${webSrc}/` },\n ...scopePart.filter((alias) => typeof alias.find === 'string' && (alias.find.startsWith('cloudflare:') || options.scope !== undefined)),\n ...(options.aliases ?? []),\n ];\n\n return defineConfig({\n ...(options.plugins !== undefined && { plugins: [...options.plugins] }),\n resolve: { alias: aliases, noExternal: [...KIT_NO_EXTERNAL, ...(options.noExternal ?? [])] },\n test: {\n globals: true,\n environment: options.environment ?? 'jsdom',\n include: [...(options.include ?? DEFAULT_INCLUDE)],\n // Threads, bounded, rather than one forked worker per file — see the\n // header. A custom `exclude` replaces Vitest's defaults, so `node_modules`\n // must be re-listed.\n pool: 'threads',\n exclude: [...(options.exclude ?? ['**/node_modules/**', '**/dist/**', 'test/integration/**'])],\n ...(options.setupFiles !== undefined && { setupFiles: [...options.setupFiles] }),\n ...(options.serverDepsInline !== undefined && {\n server: { deps: { inline: [...options.serverDepsInline] } },\n }),\n coverage: {\n provider: 'v8',\n reporter: ['text', 'lcov'],\n reportsDirectory: options.reportsDirectory ?? './coverage-spa',\n include: [...(options.coverageInclude ?? ['apps/web/src/**/*.{ts,tsx}'])],\n exclude: [...CANONICAL_COVERAGE_EXCLUDE, ...(options.coverageExclude ?? [])],\n ...(options.thresholds !== undefined && { thresholds: { ...options.thresholds } }),\n },\n },\n });\n}\n"],
5
- "mappings": "AAyCA,OAAS,gBAAAA,MAAiC,gBAC1C,OAAS,iBAAAC,MAAqB,WAC9B,OAAS,4BAAAC,EAA0B,8BAAAC,EAA4B,mBAAAC,EAAiB,oBAAAC,MAAwB,sBAqFxG,MAAMC,EAAqC,CAAC,8BAA+B,8BAA+B,6BAA6B,EAKjIC,EAAgD,CAAC,qBAAsB,YAAa,cAAe,iBAAiB,EAYpH,SAAUC,EAAsBC,EAAkC,CAAA,EAAE,CACxE,MAAMC,EAAOD,EAAQ,MAAQ,IAAI,IAAI,IAAK,YAAY,GAAG,EAAE,KACrDE,EAASV,EAAc,IAAI,IAAI,eAAgBS,CAAI,CAAC,EAIpDE,EAAYP,EAAiB,CACjC,MAAOI,EAAQ,OAAS,UACxB,KAAAC,EACA,SAAUD,EAAQ,UAAYN,EAC9B,MAAOM,EAAQ,OAASP,EACzB,EAAE,OAAQW,GAAU,OAAOA,EAAM,MAAS,UAAY,CAACA,EAAM,KAAK,WAAW,SAAS,CAAC,EAClFC,EAAyB,CAC7B,CAAE,KAAM,OAAQ,YAAa,GAAGH,CAAM,GAAG,EACzC,CAAE,KAAM,OAAQ,YAAa,GAAGA,CAAM,GAAG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BAAsB,aAAc,qBAAqB,CAAE,EAC7F,GAAIA,EAAQ,aAAe,QAAa,CAAE,WAAY,CAAC,GAAGA,EAAQ,UAAU,CAAC,EAC7E,GAAIA,EAAQ,mBAAqB,QAAa,CAC5C,OAAQ,CAAE,KAAM,CAAE,OAAQ,CAAC,GAAGA,EAAQ,gBAAgB,CAAC,CAAE,GAE3D,SAAU,CACR,SAAU,KACV,SAAU,CAAC,OAAQ,MAAM,EACzB,iBAAkBA,EAAQ,kBAAoB,iBAC9C,QAAS,CAAC,GAAIA,EAAQ,iBAAmB,CAAC,4BAA4B,CAAE,EACxE,QAAS,CAAC,GAAGF,EAA4B,GAAIE,EAAQ,iBAAmB,CAAA,CAAG,EAC3E,GAAIA,EAAQ,aAAe,QAAa,CAAE,WAAY,CAAE,GAAGA,EAAQ,UAAU,CAAE,IAGpF,CACH,CA7CgBM,EAAAP,EAAA",
6
+ "names": ["defineConfig", "fileURLToPath", "DEFAULT_CLOUDFLARE_MOCKS", "DEFAULT_WORKSPACE_PACKAGES", "KIT_NO_EXTERNAL", "workspaceAliases", "DEFAULT_INCLUDE", "CANONICAL_COVERAGE_EXCLUDE", "defineWebVitestConfig", "options", "root", "webSrc", "scopePart", "alias", "aliases", "__name"]
7
7
  }
package/dist/vitest.js CHANGED
@@ -1 +1 @@
1
- import{defineConfig as n}from"vitest/config";import{DEFAULT_CLOUDFLARE_MOCKS as l,DEFAULT_WORKSPACE_PACKAGES as a,KIT_NO_EXTERNAL as u,workspaceAliases as i}from"./vitest-aliases.js";const g=["test/web/**","test/**/web-*.test.{ts,tsx}","apps/web/**/*.test.{ts,tsx}"],o=["scripts/**","**/*.test.ts","**/*.test.tsx","**/*.d.ts","**/index.ts","**/types.d.ts","**/model/**","**/generated/**","**/D1Types.ts","**/ServiceEnv.ts","**/env.d.ts"];function v(e={}){const t=e.root??new URL(".",import.meta.url).href,r=e.coverageInclude??["apps/api/src/**/*.ts","apps/background/src/**/*.ts","packages/**/src/**/*.ts"],c=[...o,...e.coverageExclude??[]],d=[...i({scope:e.scope??"@unused",root:t,packages:e.scope===void 0?[]:e.packages??a,mocks:e.mocks??l}).filter(s=>typeof s.find!="string"||!s.find.startsWith("@unused")),...e.aliases??[]];return n({...e.plugins!==void 0&&{plugins:[...e.plugins]},resolve:{alias:d,noExternal:[...u,...e.noExternal??[]]},test:{globals:!0,environment:"node",include:[...e.include??["test/**/*.test.{ts,tsx}"]],exclude:[...e.exclude??["**/node_modules/**","**/dist/**","test/integration/**",...g]],...e.setupFiles!==void 0&&{setupFiles:[...e.setupFiles]},server:{deps:{inline:[...e.serverDepsInline??["dofs"]]}},coverage:{provider:"v8",reporter:["text","lcov","html"],reportsDirectory:e.reportsDirectory??"./coverage",include:[...r],exclude:c,...e.thresholds!==void 0&&{thresholds:{...e.thresholds}}}}})}export{v as defineUnitVitestConfig};
1
+ var l=Object.defineProperty;var r=(e,s)=>l(e,"name",{value:s,configurable:!0});import{defineConfig as a}from"vitest/config";import{DEFAULT_CLOUDFLARE_MOCKS as u,DEFAULT_WORKSPACE_PACKAGES as i,KIT_NO_EXTERNAL as g,workspaceAliases as o}from"./vitest-aliases.js";const f=["test/web/**","test/**/web-*.test.{ts,tsx}","apps/web/**/*.test.{ts,tsx}"],E=["scripts/**","**/*.test.ts","**/*.test.tsx","**/*.d.ts","**/index.ts","**/types.d.ts","**/model/**","**/generated/**","**/D1Types.ts","**/ServiceEnv.ts","**/env.d.ts"];function m(e={}){const s=e.root??new URL(".",import.meta.url).href,c=e.coverageInclude??["apps/api/src/**/*.ts","apps/background/src/**/*.ts","packages/**/src/**/*.ts"],d=[...E,...e.coverageExclude??[]],n=[...o({scope:e.scope??"@unused",root:s,packages:e.scope===void 0?[]:e.packages??i,mocks:e.mocks??u}).filter(t=>typeof t.find!="string"||!t.find.startsWith("@unused")),...e.aliases??[]];return a({...e.plugins!==void 0&&{plugins:[...e.plugins]},resolve:{alias:n,noExternal:[...g,...e.noExternal??[]]},test:{globals:!0,environment:"node",include:[...e.include??["test/**/*.test.{ts,tsx}"]],exclude:[...e.exclude??["**/node_modules/**","**/dist/**","test/integration/**",...f]],...e.setupFiles!==void 0&&{setupFiles:[...e.setupFiles]},server:{deps:{inline:[...e.serverDepsInline??["dofs"]]}},coverage:{provider:"v8",reporter:["text","lcov","html"],reportsDirectory:e.reportsDirectory??"./coverage",include:[...c],exclude:d,...e.thresholds!==void 0&&{thresholds:{...e.thresholds}}}}})}r(m,"defineUnitVitestConfig");export{m as defineUnitVitestConfig};
@@ -2,6 +2,6 @@
2
2
  "version": 3,
3
3
  "sources": ["../src/vitest.ts"],
4
4
  "sourcesContent": ["/**\n * The unit-test Vitest config for the worker-and-packages half of the suite.\n *\n * Provenance: converged from all nine repos' `vitest.config.mts`. The coverage\n * block is Durable-DAV-Router's (the most complete: v8 provider, explicit\n * include/exclude patterns, thresholds with the reasoning for why they sit just\n * under the measured value); the alias block is the union of Durable-DAV's\n * `cloudflare:*` mocks, every repo's `@scope/* → src` workspace table, and the\n * shared `@/` + `~/` prefixes — see {@link ./vitest-aliases.js}.\n *\n * Canonical decisions:\n *\n * 1. **Every file matching `include` is reported** — Vitest 4 removed\n * `coverage.all`, and an explicit `include` now covers files no test\n * imported. That is the behaviour the source repos configured `all: true` for,\n * and the reason it mattered: without it a brand-new module with no test is\n * invisible rather than counted as zero, which is the exact regression this\n * gate exists to catch.\n * 2. **The SPA is excluded here**, so this config and `defineWebVitestConfig()`\n * partition the suite rather than each running all of it. The default covers\n * every suite shape the family uses (`test/web/**`, `test/**​/web-*`,\n * `apps/web/**`); see `defineRepoVitestConfig()` for the single-file\n * `projects` composition the AWS/Mail-Meow/CalDAV repos use.\n * 3. **A custom `exclude` re-lists `node_modules`** — `test/` is a workspace\n * project and therefore has its own, so without the re-list the glob reaches\n * into `test/node_modules` and tries to run other packages' suites.\n * 4. **Thresholds are a consumer argument**, not a kit default. A floor is a\n * per-repo ratchet measured against that repo's suite; the kit cannot know a\n * number, and guessing one is how floors get lowered.\n * 5. **`@rexezuge/*` is never externalized** — see `KIT_NO_EXTERNAL`: the kit\n * ships ESM `dist/` with bundler-style extensionless imports, which Node's\n * resolver refuses, so the kit stays inside Vite's pipeline (the same\n * resolver that bundles the worker).\n */\n\nimport { defineConfig, type Plugin } from 'vitest/config';\nimport { DEFAULT_CLOUDFLARE_MOCKS, DEFAULT_WORKSPACE_PACKAGES, KIT_NO_EXTERNAL, workspaceAliases } from './vitest-aliases.ts';\nimport type { VitestAlias } from './vitest-aliases.ts';\n\nexport type { VitestAlias } from './vitest-aliases.ts';\n\n/**\n * Coverage thresholds, in the four figures Vitest gates on.\n */\nexport interface CoverageThresholds {\n readonly statements?: number;\n readonly branches?: number;\n readonly functions?: number;\n readonly lines?: number;\n}\n\n/**\n * What `defineUnitVitestConfig` accepts. Every field is optional: the defaults\n * cover the canonical monorepo layout, and a consumer overrides only what its\n * tree actually differs in.\n */\nexport interface UnitVitestConfigOptions {\n /**\n * The consuming repo's npm scope, e.g. `'@myapp'`. When supplied, `@scope/*`\n * workspace aliases are generated from `packages` (plus `background` under\n * `apps/`); when omitted, only the `cloudflare:*`, `@/` and `~/` aliases\n * apply and `aliases` carries the workspace table by hand.\n */\n readonly scope?: string;\n /**\n * Workspace package directory names. Defaults to the family superset; a repo\n * without a domain package keeps the default harmlessly (its alias never\n * matches).\n */\n readonly packages?: readonly string[];\n /**\n * Which `cloudflare:*` mocks to alias. Defaults to workers/sockets/workflows.\n */\n readonly mocks?: readonly string[];\n /**\n * Extra resolver entries, applied after the canonical ones (e.g. the `hono`\n * dedupe two repos carry, or an `/index.ts` exact entry).\n */\n readonly aliases?: readonly VitestAlias[];\n /**\n * Where the repo root is, as a file URL. Defaults to the directory this\n * factory is *called* from, which is the repo root's `vitest.config.mts`.\n * Pass `new URL('.', import.meta.url).href` explicitly from the caller —\n * never rely on this module's own URL, which points into `node_modules`.\n */\n readonly root?: string;\n /**\n * Which suites to collect. Defaults to the whole unit suite.\n */\n readonly include?: readonly string[];\n /**\n * Suite paths to skip, replacing the default. Defaults re-list\n * `node_modules`/`dist`/`integration` plus every SPA shape.\n */\n readonly exclude?: readonly string[];\n /**\n * `node_modules` specifiers to inline through Vite rather than externalize.\n * Defaults to `['dofs']` (Durable-DAV: `dofs` imports `cloudflare:workers`,\n * which Node rejects before `resolve.alias` is consulted).\n */\n readonly serverDepsInline?: readonly string[];\n /**\n * Resolver `noExternal` patterns. Defaults to keeping `@rexezuge/*` inside\n * Vite's pipeline; see `KIT_NO_EXTERNAL`.\n */\n readonly noExternal?: readonly (string | RegExp)[];\n /**\n * Vite plugins for the suite (rare on the backend half; the SPA half passes\n * `react()` here).\n */\n readonly plugins?: readonly Plugin[];\n /**\n * Setup files run before each test file (e.g. AWS's floci guard, Meow's\n * backend/web setups).\n */\n readonly setupFiles?: readonly string[];\n /**\n * Coverage `include` globs. Defaults to the worker plus every workspace\n * package's `src`.\n */\n readonly coverageInclude?: readonly string[];\n /**\n * Coverage `exclude` globs, merged with the canonical set.\n */\n readonly coverageExclude?: readonly string[];\n /**\n * Coverage floors. Omitted by default; a repo that wants them sets them.\n */\n readonly thresholds?: CoverageThresholds;\n /**\n * Where the coverage report is written.\n */\n readonly reportsDirectory?: string;\n}\n\n/**\n * The SPA's suites, excluded here so the two configs partition the suite.\n *\n * Every shape the family uses: the `test/web/**` directory convention\n * (CalDAV-Bridge, Mail-Meow), the root-suite `web-*` naming convention\n * (Durable-DAV-Router), and suites bundled under `apps/web` (Mail-Otter).\n * `defineWebVitestConfig()` includes the same globs, so a file is collected by\n * exactly one config.\n */\nconst SPA_FILES: readonly string[] = ['test/web/**', 'test/**/web-*.test.{ts,tsx}', 'apps/web/**/*.test.{ts,tsx}'];\n\n/**\n * Coverage `exclude` globs converged from the source repos.\n *\n * The categories: build and test tooling (`scripts/` grows with project surface,\n * not complexity, and the god-file guard excludes it for the same reason), test\n * files, declarations, re-export barrels (`index.ts` carries no logic of its\n * own), model records, generated files (the SPA shell is a one-line HTML blob\n * with no logic to exercise), and type-only modules.\n */\nconst CANONICAL_COVERAGE_EXCLUDE: readonly string[] = [\n 'scripts/**',\n '**/*.test.ts',\n '**/*.test.tsx',\n '**/*.d.ts',\n '**/index.ts',\n '**/types.d.ts',\n '**/model/**',\n '**/generated/**',\n '**/D1Types.ts',\n '**/ServiceEnv.ts',\n '**/env.d.ts',\n];\n\n/**\n * Build the unit-test config.\n *\n * ```ts\n * // vitest.config.mts\n * import { defineUnitVitestConfig } from '@rexezuge/tooling/vitest';\n * export default defineUnitVitestConfig({\n * scope: '@myapp',\n * thresholds: { statements: 60, branches: 55, functions: 65, lines: 60 },\n * });\n * ```\n */\nexport function defineUnitVitestConfig(options: UnitVitestConfigOptions = {}): ReturnType<typeof defineConfig> {\n const root = options.root ?? new URL('.', import.meta.url).href;\n const coverageInclude = options.coverageInclude ?? ['apps/api/src/**/*.ts', 'apps/background/src/**/*.ts', 'packages/**/src/**/*.ts'];\n const coverageExclude = [...CANONICAL_COVERAGE_EXCLUDE, ...(options.coverageExclude ?? [])];\n const baseAliases = workspaceAliases({\n scope: options.scope ?? '@unused',\n root,\n packages: options.scope === undefined ? [] : (options.packages ?? DEFAULT_WORKSPACE_PACKAGES),\n mocks: options.mocks ?? DEFAULT_CLOUDFLARE_MOCKS,\n });\n // A placeholder scope contributes no `@unused/*` entries; the mocks plus\n // `@/`/`~/` survive either way.\n const aliases = [\n ...baseAliases.filter((alias) => typeof alias.find !== 'string' || !alias.find.startsWith('@unused')),\n ...(options.aliases ?? []),\n ];\n\n return defineConfig({\n ...(options.plugins !== undefined && { plugins: [...options.plugins] }),\n resolve: { alias: aliases, noExternal: [...KIT_NO_EXTERNAL, ...(options.noExternal ?? [])] },\n test: {\n globals: true,\n environment: 'node',\n include: [...(options.include ?? ['test/**/*.test.{ts,tsx}'])],\n // `test` is a workspace project and therefore has its own node_modules;\n // without the re-list, the glob reaches into it.\n exclude: [...(options.exclude ?? ['**/node_modules/**', '**/dist/**', 'test/integration/**', ...SPA_FILES])],\n ...(options.setupFiles !== undefined && { setupFiles: [...options.setupFiles] }),\n server: {\n deps: {\n // A `node_modules` dependency is externalized by default, so Node's\n // own ESM loader resolves a `cloudflare:workers` specifier and rejects\n // the scheme before `resolve.alias` is ever consulted. Inlining routes\n // it back through Vite, where the alias applies.\n inline: [...(options.serverDepsInline ?? ['dofs'])],\n },\n },\n coverage: {\n provider: 'v8',\n // Vitest 4 removed `coverage.all`; an explicit `include` now reports\n // every matching file whether or not a test imported it, which is the\n // behaviour the source repos' `all: true` was there to get: a brand-new\n // module with no test is counted as zero rather than being invisible,\n // which is the exact regression this gate exists to catch.\n reporter: ['text', 'lcov', 'html'],\n reportsDirectory: options.reportsDirectory ?? './coverage',\n include: [...coverageInclude],\n exclude: coverageExclude,\n ...(options.thresholds !== undefined && { thresholds: { ...options.thresholds } }),\n },\n },\n });\n}\n"],
5
- "mappings": "AAmCA,OAAS,gBAAAA,MAAiC,gBAC1C,OAAS,4BAAAC,EAA0B,8BAAAC,EAA4B,mBAAAC,EAAiB,oBAAAC,MAAwB,sBA4GxG,MAAMC,EAA+B,CAAC,cAAe,8BAA+B,6BAA6B,EAW3GC,EAAgD,CACpD,aACA,eACA,gBACA,YACA,cACA,gBACA,cACA,kBACA,gBACA,mBACA,eAeI,SAAUC,EAAuBC,EAAmC,CAAA,EAAE,CAC1E,MAAMC,EAAOD,EAAQ,MAAQ,IAAI,IAAI,IAAK,YAAY,GAAG,EAAE,KACrDE,EAAkBF,EAAQ,iBAAmB,CAAC,uBAAwB,8BAA+B,yBAAyB,EAC9HG,EAAkB,CAAC,GAAGL,EAA4B,GAAIE,EAAQ,iBAAmB,CAAA,CAAG,EASpFI,EAAU,CACd,GATkBR,EAAiB,CACnC,MAAOI,EAAQ,OAAS,UACxB,KAAAC,EACA,SAAUD,EAAQ,QAAU,OAAY,CAAA,EAAMA,EAAQ,UAAYN,EAClE,MAAOM,EAAQ,OAASP,EACzB,EAIgB,OAAQY,GAAU,OAAOA,EAAM,MAAS,UAAY,CAACA,EAAM,KAAK,WAAW,SAAS,CAAC,EACpG,GAAIL,EAAQ,SAAW,CAAA,GAGzB,OAAOR,EAAa,CAClB,GAAIQ,EAAQ,UAAY,QAAa,CAAE,QAAS,CAAC,GAAGA,EAAQ,OAAO,CAAC,EACpE,QAAS,CAAE,MAAOI,EAAS,WAAY,CAAC,GAAGT,EAAiB,GAAIK,EAAQ,YAAc,CAAA,CAAG,CAAC,EAC1F,KAAM,CACJ,QAAS,GACT,YAAa,OACb,QAAS,CAAC,GAAIA,EAAQ,SAAW,CAAC,yBAAyB,CAAE,EAG7D,QAAS,CAAC,GAAIA,EAAQ,SAAW,CAAC,qBAAsB,aAAc,sBAAuB,GAAGH,CAAS,CAAE,EAC3G,GAAIG,EAAQ,aAAe,QAAa,CAAE,WAAY,CAAC,GAAGA,EAAQ,UAAU,CAAC,EAC7E,OAAQ,CACN,KAAM,CAKJ,OAAQ,CAAC,GAAIA,EAAQ,kBAAoB,CAAC,MAAM,CAAE,IAGtD,SAAU,CACR,SAAU,KAMV,SAAU,CAAC,OAAQ,OAAQ,MAAM,EACjC,iBAAkBA,EAAQ,kBAAoB,aAC9C,QAAS,CAAC,GAAGE,CAAe,EAC5B,QAASC,EACT,GAAIH,EAAQ,aAAe,QAAa,CAAE,WAAY,CAAE,GAAGA,EAAQ,UAAU,CAAE,IAGpF,CACH",
6
- "names": ["defineConfig", "DEFAULT_CLOUDFLARE_MOCKS", "DEFAULT_WORKSPACE_PACKAGES", "KIT_NO_EXTERNAL", "workspaceAliases", "SPA_FILES", "CANONICAL_COVERAGE_EXCLUDE", "defineUnitVitestConfig", "options", "root", "coverageInclude", "coverageExclude", "aliases", "alias"]
5
+ "mappings": "+EAmCA,OAAS,gBAAAA,MAAiC,gBAC1C,OAAS,4BAAAC,EAA0B,8BAAAC,EAA4B,mBAAAC,EAAiB,oBAAAC,MAAwB,sBA4GxG,MAAMC,EAA+B,CAAC,cAAe,8BAA+B,6BAA6B,EAW3GC,EAAgD,CACpD,aACA,eACA,gBACA,YACA,cACA,g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,EACT,GAAIH,EAAQ,aAAe,QAAa,CAAE,WAAY,CAAE,GAAGA,EAAQ,UAAU,CAAE,IAGpF,CACH,CApDgBM,EAAAP,EAAA",
6
+ "names": ["defineConfig", "DEFAULT_CLOUDFLARE_MOCKS", "DEFAULT_WORKSPACE_PACKAGES", "KIT_NO_EXTERNAL", "workspaceAliases", "SPA_FILES", "CANONICAL_COVERAGE_EXCLUDE", "defineUnitVitestConfig", "options", "root", "coverageInclude", "coverageExclude", "aliases", "alias", "__name"]
7
7
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rexezuge/tooling",
3
- "version": "1.5.1",
3
+ "version": "1.5.2",
4
4
  "private": false,
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -26,7 +26,7 @@
26
26
  "src"
27
27
  ],
28
28
  "dependencies": {
29
- "@rexezuge/d1": "1.5.1"
29
+ "@rexezuge/d1": "1.5.2"
30
30
  },
31
31
  "peerDependencies": {
32
32
  "eslint": "^10.0.0",