@rexezuge/tooling 1.14.0 → 1.16.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +42 -30
- package/dist/eslint-rules.d.ts.map +1 -1
- package/dist/eslint-rules.js +1 -1
- package/dist/eslint-rules.js.map +2 -2
- package/dist/eslint-strict.d.ts +2 -1
- package/dist/eslint-strict.d.ts.map +1 -1
- package/dist/eslint-strict.js +2 -1
- package/dist/eslint-strict.js.map +3 -3
- package/dist/manifest-validate.d.ts.map +1 -1
- package/dist/manifest-validate.js +1 -1
- package/dist/manifest-validate.js.map +3 -3
- package/dist/manifest.d.ts +21 -0
- package/dist/manifest.d.ts.map +1 -1
- package/dist/manifest.js.map +2 -2
- package/dist/scripts/backup/destinations.d.ts +40 -0
- package/dist/scripts/backup/destinations.d.ts.map +1 -0
- package/dist/scripts/backup/destinations.js +1 -0
- package/dist/scripts/backup/destinations.js.map +7 -0
- package/dist/scripts/backup/encrypt-backup.d.ts +5 -2
- package/dist/scripts/backup/encrypt-backup.d.ts.map +1 -1
- package/dist/scripts/backup/encrypt-backup.js +2 -3
- package/dist/scripts/backup/encrypt-backup.js.map +3 -3
- package/dist/scripts/backup/naming.d.ts +1 -1
- package/dist/scripts/backup/naming.d.ts.map +1 -1
- package/dist/scripts/backup/naming.js +1 -1
- package/dist/scripts/backup/naming.js.map +3 -3
- package/dist/scripts/prepare-wrangler-config.d.ts.map +1 -1
- package/dist/scripts/prepare-wrangler-config.js +1 -1
- package/dist/scripts/prepare-wrangler-config.js.map +3 -3
- package/dist/scripts/wrangler-config/resources.d.ts +11 -2
- package/dist/scripts/wrangler-config/resources.d.ts.map +1 -1
- package/dist/scripts/wrangler-config/resources.js +1 -1
- package/dist/scripts/wrangler-config/resources.js.map +3 -3
- package/dist/vitest-aliases.d.ts +7 -1
- package/dist/vitest-aliases.d.ts.map +1 -1
- package/dist/vitest-aliases.js +1 -1
- package/dist/vitest-aliases.js.map +3 -3
- package/dist/vitest-integration.d.ts.map +1 -1
- package/dist/vitest-integration.js +1 -1
- package/dist/vitest-integration.js.map +3 -3
- package/dist/vitest-repo.js +1 -1
- package/dist/vitest-repo.js.map +3 -3
- package/dist/vitest-web.js +1 -1
- package/dist/vitest-web.js.map +3 -3
- package/dist/vitest.d.ts +1 -1
- package/dist/vitest.d.ts.map +1 -1
- package/dist/vitest.js +1 -1
- package/dist/vitest.js.map +3 -3
- package/package.json +3 -3
- package/presets/tsconfig/web.json +2 -2
- package/schema/manifest.schema.json +28 -1
- package/src/eslint-rules.ts +4 -0
- package/src/eslint-strict.test.ts +29 -0
- package/src/eslint-strict.ts +36 -4
- package/src/github/dependabot.yml +14 -4
- package/src/github/workflows/backup-d1.yml +15 -0
- package/src/github/workflows/backup-main.yml +9 -126
- package/src/github/workflows/continuous-deployment.yml +11 -180
- package/src/github/workflows/continuous-integration.yml +9 -249
- package/src/github/workflows/scheduled-version-update.yml +8 -31
- package/src/github/workflows/upstream-sync.yml +8 -49
- package/src/manifest-validate.ts +31 -2
- package/src/manifest.test.ts +22 -0
- package/src/manifest.ts +22 -0
- package/src/presets.test.ts +5 -1
- package/src/scripts/backup/backup-rules.test.ts +22 -0
- package/src/scripts/backup/destinations.ts +59 -0
- package/src/scripts/backup/encrypt-backup.ts +58 -48
- package/src/scripts/backup/naming.ts +2 -2
- package/src/scripts/prepare-wrangler-config.ts +9 -1
- package/src/scripts/wrangler-config/resources.test.ts +10 -0
- package/src/scripts/wrangler-config/resources.ts +21 -4
- package/src/vitest-aliases.test.ts +33 -0
- package/src/vitest-aliases.ts +37 -7
- package/src/vitest-integration.ts +2 -5
- package/src/vitest-repo.ts +2 -2
- package/src/vitest-web.ts +2 -2
- package/src/vitest.ts +3 -3
- package/src/github/actions/retry-step/action.yml +0 -55
- package/src/github/actions/setup-env/action.yml +0 -20
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/vitest-aliases.ts"],
|
|
4
|
-
"sourcesContent": ["import { existsSync } from 'node:fs';\nimport { createRequire } from 'node:module';\nimport { 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 * Bare specifiers the kit and its consumer must resolve to **one** copy.\n *\n * Every entry is a peer of a kit package rather than a dependency, which is\n * exactly why it is needed: a peer is not installed twice under a registry\n * install, so the two sides already agree. A `link:` install breaks that\n * agreement — the symlinked package directory carries its own `node_modules`, and\n * with `@rexezuge/*` inlined into Vite's pipeline (see {@link KIT_NO_EXTERNAL})\n * the kit's copy wins for its own imports while the consumer's wins for the app's.\n *\n * Two Reacts is not a warning: `useState` is read off a module-level hook\n * dispatcher that only one of them initialises, so every hook inside a kit\n * component throws `Cannot read properties of null (reading 'useState')`. The\n * failure names the kit, and the cause is the install layout.\n */\nexport const KIT_DEDUPE: readonly string[] = ['react', 'react-dom', 'react/jsx-runtime', 'lucide-react'];\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/`).
|
|
5
|
-
"mappings": "+EAAA,OAAS,cAAAA,MAAkB,UAC3B,OAAS,iBAAAC,MAAqB,cAC9B,OAAS,iBAAAC,MAAqB,
|
|
6
|
-
"names": ["existsSync", "createRequire", "fileURLToPath", "DEFAULT_WORKSPACE_PACKAGES", "DEFAULT_CLOUDFLARE_MOCKS", "KIT_NO_EXTERNAL", "KIT_DEDUPE", "kitWorkersMock", "__name", "
|
|
4
|
+
"sourcesContent": ["import { existsSync } from 'node:fs';\nimport { createRequire } from 'node:module';\nimport path from 'node:path';\nimport { fileURLToPath } from 'node:url';\nimport { loadManifest } from './manifest.ts';\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 * `contracts` is the shared endpoint-contracts package the API and the SPA both import. A repo with a manifest\n * that declares `layers` does not use this list at all: its aliases come from `layers[].package` / `dir`\n * (see {@link WorkspaceAliasesOptions.packages}).\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 'contracts',\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 * Bare specifiers the kit and its consumer must resolve to **one** copy.\n *\n * Every entry is a peer of a kit package rather than a dependency, which is\n * exactly why it is needed: a peer is not installed twice under a registry\n * install, so the two sides already agree. A `link:` install breaks that\n * agreement — the symlinked package directory carries its own `node_modules`, and\n * with `@rexezuge/*` inlined into Vite's pipeline (see {@link KIT_NO_EXTERNAL})\n * the kit's copy wins for its own imports while the consumer's wins for the app's.\n *\n * Two Reacts is not a warning: `useState` is read off a module-level hook\n * dispatcher that only one of them initialises, so every hook inside a kit\n * component throws `Cannot read properties of null (reading 'useState')`. The\n * failure names the kit, and the cause is the install layout.\n */\nexport const KIT_DEDUPE: readonly string[] = ['react', 'react-dom', 'react/jsx-runtime', 'lucide-react'];\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/`). When omitted: the manifest's `layers` if `<root>/.rexezuge.jsonc` declares any\n * (each layer `dir` is aliased as `<scope>/<package or basename of dir>`), else {@link DEFAULT_WORKSPACE_PACKAGES}.\n * An explicit list always wins.\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 * Where the kit's own `cloudflare:workers` mock lives, or `null` when\n * `@rexezuge/testing` is not resolvable from here.\n */\nfunction kitWorkersMock(): string | null {\n try {\n return createRequire(import.meta.url).resolve('@rexezuge/testing/cloudflare-workers');\n } catch {\n return null;\n }\n}\n\ninterface AliasTarget {\n readonly find: string;\n readonly dir: string;\n}\n\n/**\n * The manifest's layers as alias targets, or `null` when there is no readable manifest with layers.\n */\nfunction manifestTargets(scope: string, root: string): AliasTarget[] | null {\n try {\n const layers = loadManifest(fileURLToPath(root))?.layers;\n if (layers === undefined || layers.length === 0) return null;\n return layers.map((layer) => ({ find: `${scope}/${layer.package ?? path.posix.basename(layer.dir)}`, dir: `${layer.dir}/src` }));\n } catch {\n return null; // an invalid manifest is doctor's to report; the aliases fall back to the family list\n }\n}\n\nfunction defaultTargets(scope: string, names: readonly string[]): AliasTarget[] {\n return names.map((name) => ({ find: `${scope}/${name}`, dir: name === 'background' ? 'apps/background/src' : `packages/${name}/src` }));\n}\n\n/**\n * Build the workspace alias table for a consumer repo.\n *\n * `cloudflare:workers` resolves to `<root>/test/mocks/cloudflare-workers.ts` when\n * that file exists, and otherwise to `@rexezuge/testing/cloudflare-workers`.\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 targets =\n options.packages === undefined\n ? (manifestTargets(scope, root) ?? defaultTargets(scope, DEFAULT_WORKSPACE_PACKAGES))\n : defaultTargets(scope, options.packages);\n const mocks = options.mocks ?? DEFAULT_CLOUDFLARE_MOCKS;\n const at = (relative: string): string => fileURLToPath(new URL(relative, root));\n const aliases: VitestAlias[] = Array.from(targets, (target) => ({ find: target.find, replacement: at(target.dir) }));\n for (const mock of mocks) {\n const local = at(`test/mocks/cloudflare-${mock}.ts`);\n // A repo with no copy of its own gets the kit's: the `workers` mock is a\n // superset of the thirteen family copies, so deleting yours is safe.\n const kit = mock === 'workers' && !existsSync(local) ? kitWorkersMock() : null;\n aliases.push({ find: `cloudflare:${mock}`, replacement: kit ?? local });\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": "+EAAA,OAAS,cAAAA,MAAkB,UAC3B,OAAS,iBAAAC,MAAqB,cAC9B,OAAOC,MAAU,YACjB,OAAS,iBAAAC,MAAqB,WAC9B,OAAS,gBAAAC,MAAoB,gBAmCtB,MAAMC,EAAgD,CAC3D,SACA,YACA,iBACA,kBACA,eACA,mBACA,SACA,YACA,eACA,cACA,mBACA,cAWWC,EAA8C,CAAC,UAAW,UAAW,WAAW,EAahFC,EAAqC,CAAC,sBAAsB,EAiB5DC,EAAgC,CAAC,QAAS,YAAa,oBAAqB,cAAc,EAsCvG,SAASC,GAAc,CACrB,GAAI,CACF,OAAOR,EAAc,YAAY,GAAG,EAAE,QAAQ,sCAAsC,CACtF,MAAQ,CACN,OAAO,IACT,CACF,CANSS,EAAAD,EAAA,kBAgBT,SAASE,EAAgBC,EAAeC,EAAY,CAClD,GAAI,CACF,MAAMC,EAASV,EAAaD,EAAcU,CAAI,CAAC,GAAG,OAClD,OAAIC,IAAW,QAAaA,EAAO,SAAW,EAAU,KACjDA,EAAO,IAA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AgB,CAAA,CAAG,EAC/HK,CACT,CApBgBf,EAAAS,EAAA",
|
|
6
|
+
"names": ["existsSync", "createRequire", "path", "fileURLToPath", "loadManifest", "DEFAULT_WORKSPACE_PACKAGES", "DEFAULT_CLOUDFLARE_MOCKS", "KIT_NO_EXTERNAL", "KIT_DEDUPE", "kitWorkersMock", "__name", "manifestTargets", "scope", "root", "layers", "layer", "defaultTargets", "names", "name", "workspaceAliases", "options", "targets", "mocks", "at", "relative", "aliases", "target", "mock", "local", "kit", "apiSrc", "webSrc"]
|
|
7
7
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vitest-integration.d.ts","sourceRoot":"","sources":["../src/vitest-integration.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAE7C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AAExC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAEvD;;GAEG;AACH,MAAM,WAAW,8BAA8B;IAC7C;;OAEG;IACH,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB;;OAEG;IACH,QAAQ,CAAC,QAAQ,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACtC;;OAEG;IACH,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB;;;OAGG;IACH,QAAQ,CAAC,OAAO,CAAC,EAAE,SAAS,WAAW,EAAE,CAAC;IAC1C;;;;OAIG;IACH,QAAQ,CAAC,OAAO,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACrC;;;;OAIG;IACH,QAAQ,CAAC,OAAO,CAAC,EAAE,SAAS,YAAY,EAAE,CAAC;IAC3C;;;OAGG;IACH,QAAQ,CAAC,IAAI,CAAC,EAAE,IAAI,CAAC;IACrB;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MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IACnD;;;OAGG;IACH,QAAQ,CAAC,aAAa,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;CAC5C;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,6BAA6B,CAAC,OAAO,EAAE,8BAA8B,GAAG,UAAU,CAAC,OAAO,YAAY,CAAC,CAgBtH"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var s=Object.defineProperty;var r=(e,n)=>s(e,"name",{value:n,configurable:!0});import{defineConfig as a}from"vitest/config";import{asVitePlugins as l}from"./plugin-option.js";import{
|
|
1
|
+
var s=Object.defineProperty;var r=(e,n)=>s(e,"name",{value:n,configurable:!0});import{defineConfig as a}from"vitest/config";import{asVitePlugins as l}from"./plugin-option.js";import{workspaceAliases as t}from"./vitest-aliases.js";function c(e){const n=e.root??new URL(".",import.meta.url).href,i=[...t({scope:e.scope,root:n,packages:e.packages,mocks:[]}),...e.aliases??[]];return a({...e.define!==void 0&&{define:{...e.define}},...e.plugins!==void 0&&{plugins:l(e.plugins)},resolve:{alias:i},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};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
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 } from 'vitest/config';\nimport { asVitePlugins } from './plugin-option.ts';\nimport type { PluginOption } from './plugin-option.ts';\nimport type { Pool } from 'vitest/node';\nimport {
|
|
5
|
-
"mappings": "+EAmBA,OAAS,gBAAAA,MAAoB,gBAC7B,OAAS,iBAAAC,MAAqB,qBAG9B,OAAS,
|
|
6
|
-
"names": ["defineConfig", "asVitePlugins", "
|
|
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 } from 'vitest/config';\nimport { asVitePlugins } from './plugin-option.ts';\nimport type { PluginOption } from './plugin-option.ts';\nimport type { Pool } from 'vitest/node';\nimport { 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 PluginOption[];\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 = [...workspaceAliases({ scope: options.scope, root, packages: options.packages, mocks: [] }), ...(options.aliases ?? [])];\n\n return defineConfig({\n ...(options.define !== undefined && { define: { ...options.define } }),\n ...(options.plugins !== undefined && { plugins: asVitePlugins(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": "+EAmBA,OAAS,gBAAAA,MAAoB,gBAC7B,OAAS,iBAAAC,MAAqB,qBAG9B,OAAS,oBAAAC,MAAwB,sBA6E3B,SAAUC,EAA8BC,EAAuC,CACnF,MAAMC,EAAOD,EAAQ,MAAQ,IAAI,IAAI,IAAK,YAAY,GAAG,EAAE,KACrDE,EAAU,CAAC,GAAGJ,EAAiB,CAAE,MAAOE,EAAQ,MAAO,KAAAC,EAAM,SAAUD,EAAQ,SAAU,MAAO,CAAA,CAAE,CAAE,EAAG,GAAIA,EAAQ,SAAW,CAAA,CAAG,EAEvI,OAAOJ,EAAa,CAClB,GAAII,EAAQ,SAAW,QAAa,CAAE,OAAQ,CAAE,GAAGA,EAAQ,MAAM,CAAE,EACnE,GAAIA,EAAQ,UAAY,QAAa,CAAE,QAASH,EAAcG,EAAQ,OAAO,CAAC,EAC9E,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,CAhBgBG,EAAAJ,EAAA",
|
|
6
|
+
"names": ["defineConfig", "asVitePlugins", "workspaceAliases", "defineIntegrationVitestConfig", "options", "root", "aliases", "__name"]
|
|
7
7
|
}
|
package/dist/vitest-repo.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var
|
|
1
|
+
var g=Object.defineProperty;var o=(e,t)=>g(e,"name",{value:t,configurable:!0});import{defineConfig as x}from"vitest/config";import{asVitePlugins as E}from"./plugin-option.js";import{fileURLToPath as b}from"node:url";import{manifestCoverageThresholds as v}from"./manifest.js";import{DEFAULT_CLOUDFLARE_MOCKS as w,KIT_NO_EXTERNAL as C,workspaceAliases as p}from"./vitest-aliases.js";const L=["**/node_modules/**","**/dist/**","test/integration/**","test/web/**","test/**/web-*.test.{ts,tsx}","apps/web/**/*.test.{ts,tsx}"],h=["test/web/**/*.test.{ts,tsx}","test/**/web-*.test.{ts,tsx}","apps/web/**/*.test.{ts,tsx}"],u=["scripts/**","**/*.test.ts","**/*.test.tsx","**/*.d.ts","**/index.ts","**/types.d.ts","**/types.ts","**/model/**","**/generated/**","**/D1Types.ts","**/ServiceEnv.ts","**/env.d.ts"],D="**/index.ts";function I(e){const t=e.root??new URL(".",import.meta.url).href,c=e.thresholds??v(t),l=e.packages,a=e.mocks??w,d=[...C,...e.noExternal??[]],r=e.backend??{},s=e.web??{},m=[...p({scope:e.scope,root:t,packages:l,mocks:a}),...e.aliases??[],...r.aliases??[]],i=b(new URL("apps/web/src",t)),f=[{find:/^@\//,replacement:`${i}/`},{find:/^~\//,replacement:`${i}/`},...p({scope:e.scope,root:t,packages:l,mocks:a}).filter(n=>typeof n.find=="string"),...e.aliases??[],...s.aliases??[]];return x({test:{projects:[{resolve:{alias:m,noExternal:d},test:{name:"backend",globals:!0,environment:"node",include:[...r.include??["test/**/*.test.{ts,tsx}"]],exclude:[...r.exclude??L],...r.setupFiles!==void 0&&{setupFiles:[...r.setupFiles]},server:{deps:{inline:[...r.serverDepsInline??["dofs"]]}}}},{...s.plugins!==void 0&&{plugins:E(s.plugins)},resolve:{alias:f,noExternal:d},test:{name:"web",globals:!0,environment:s.environment??"jsdom",include:[...s.include??h],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:e.includeIndexBarrels?[...u.filter(n=>n!==D),...e.coverageExclude??[]]:[...u,...e.coverageExclude??[]],...c!==void 0&&{thresholds:{...c}}}}})}o(I,"defineRepoVitestConfig");export{I as defineRepoVitestConfig};
|
package/dist/vitest-repo.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/vitest-repo.ts"],
|
|
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 } from 'vitest/config';\nimport { asVitePlugins } from './plugin-option.ts';\nimport type { PluginOption } from './plugin-option.ts';\nimport { fileURLToPath } from 'node:url';\nimport { manifestCoverageThresholds } from './manifest.ts';\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 PluginOption[];\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 * Report coverage for `index.ts` re-export barrels. See\n * `defineUnitVitestConfig`'s option of the same name.\n */\n readonly includeIndexBarrels?: boolean;\n /**\n * Coverage floors. Defaults to the manifest's `quality.coverage` (`.rexezuge.jsonc`\n * at `root`); without one, no floor.\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 * The barrel exclusion, named so `includeIndexBarrels` can lift it. See the\n * unit factory's option for why a consumer might want it.\n */\nconst INDEX_BARREL_EXCLUDE = '**/index.ts';\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 thresholds = options.thresholds ?? manifestCoverageThresholds(root);\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: asVitePlugins(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: options.includeIndexBarrels\n ? [...CANONICAL_COVERAGE_EXCLUDE.filter((glob) => glob !== INDEX_BARREL_EXCLUDE), ...(options.coverageExclude ?? [])]\n : [...CANONICAL_COVERAGE_EXCLUDE, ...(options.coverageExclude ?? [])],\n ...(thresholds !== undefined && { thresholds: { ...thresholds } }),\n },\n },\n });\n}\n"],
|
|
5
|
-
"mappings": "+EAyBA,OAAS,gBAAAA,MAAoB,gBAC7B,OAAS,iBAAAC,MAAqB,qBAE9B,OAAS,iBAAAC,MAAqB,WAC9B,OAAS,8BAAAC,MAAkC,gBAC3C,OAAS,4BAAAC,EAA0B,
|
|
6
|
-
"names": ["defineConfig", "asVitePlugins", "fileURLToPath", "manifestCoverageThresholds", "DEFAULT_CLOUDFLARE_MOCKS", "
|
|
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 } from 'vitest/config';\nimport { asVitePlugins } from './plugin-option.ts';\nimport type { PluginOption } from './plugin-option.ts';\nimport { fileURLToPath } from 'node:url';\nimport { manifestCoverageThresholds } from './manifest.ts';\nimport { DEFAULT_CLOUDFLARE_MOCKS, 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 PluginOption[];\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 * Report coverage for `index.ts` re-export barrels. See\n * `defineUnitVitestConfig`'s option of the same name.\n */\n readonly includeIndexBarrels?: boolean;\n /**\n * Coverage floors. Defaults to the manifest's `quality.coverage` (`.rexezuge.jsonc`\n * at `root`); without one, no floor.\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 * The barrel exclusion, named so `includeIndexBarrels` can lift it. See the\n * unit factory's option for why a consumer might want it.\n */\nconst INDEX_BARREL_EXCLUDE = '**/index.ts';\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 thresholds = options.thresholds ?? manifestCoverageThresholds(root);\n const packages = options.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: asVitePlugins(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: options.includeIndexBarrels\n ? [...CANONICAL_COVERAGE_EXCLUDE.filter((glob) => glob !== INDEX_BARREL_EXCLUDE), ...(options.coverageExclude ?? [])]\n : [...CANONICAL_COVERAGE_EXCLUDE, ...(options.coverageExclude ?? [])],\n ...(thresholds !== undefined && { thresholds: { ...thresholds } }),\n },\n },\n });\n}\n"],
|
|
5
|
+
"mappings": "+EAyBA,OAAS,gBAAAA,MAAoB,gBAC7B,OAAS,iBAAAC,MAAqB,qBAE9B,OAAS,iBAAAC,MAAqB,WAC9B,OAAS,8BAAAC,MAAkC,gBAC3C,OAAS,4BAAAC,EAA0B,mBAAAC,EAAiB,oBAAAC,MAAwB,sBAiI5E,MAAMC,EAAqC,CACzC,qBACA,aACA,sBACA,cACA,8BACA,+BAMIC,EAAiC,CAAC,8BAA+B,8BAA+B,6BAA6B,EAK7HC,EAAgD,CACpD,aACA,eACA,gBACA,YACA,cACA,gBACA,cACA,cACA,kBACA,gBACA,mBACA,eAOIC,EAAuB,cAevB,SAAUC,EAAuBC,EAAgC,CACrE,MAAMC,EAAOD,EAAQ,MAAQ,IAAI,IAAI,IAAK,YAAY,GAAG,EAAE,KACrDE,EAAaF,EAAQ,Y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AAckB,EAAI,OAAO,CAAC,EACtE,QAAS,CAAE,MAAOG,EAAY,WAAAL,CAAU,EACxC,KAAM,CACJ,KAAM,MACN,QAAS,GACT,YAAaE,EAAI,aAAe,QAChC,QAAS,CAAC,GAAIA,EAAI,SAAWX,CAAY,EACzC,QAAS,CAAC,GAAIW,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,iBAAkBP,EAAQ,kBAAoB,aAC9C,QAAS,CACP,GAAIA,EAAQ,iBAAmB,CAC7B,uBACA,8BACA,6BACA,4BAGJ,QAASA,EAAQ,oBACb,CAAC,GAAGH,EAA2B,OAAQe,GAASA,IAASd,CAAoB,EAAG,GAAIE,EAAQ,iBAAmB,CAAA,CAAG,EAClH,CAAC,GAAGH,EAA4B,GAAIG,EAAQ,iBAAmB,CAAA,CAAG,EACtE,GAAIE,IAAe,QAAa,CAAE,WAAY,CAAE,GAAGA,CAAU,CAAE,IAGpE,CACH,CA5EgBW,EAAAd,EAAA",
|
|
6
|
+
"names": ["defineConfig", "asVitePlugins", "fileURLToPath", "manifestCoverageThresholds", "DEFAULT_CLOUDFLARE_MOCKS", "KIT_NO_EXTERNAL", "workspaceAliases", "BACKEND_EXCLUDE", "WEB_INCLUDE", "CANONICAL_COVERAGE_EXCLUDE", "INDEX_BARREL_EXCLUDE", "defineRepoVitestConfig", "options", "root", "thresholds", "packages", "mocks", "noExternal", "backend", "web", "backendAliases", "webSrc", "webAliases", "alias", "glob", "__name"]
|
|
7
7
|
}
|
package/dist/vitest-web.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var c=Object.defineProperty;var n=(e,s)=>c(e,"name",{value:s,configurable:!0});import{defineConfig as i}from"vitest/config";import{asVitePlugins as a}from"./plugin-option.js";import{fileURLToPath as u}from"node:url";import{DEFAULT_CLOUDFLARE_MOCKS as f,
|
|
1
|
+
var c=Object.defineProperty;var n=(e,s)=>c(e,"name",{value:s,configurable:!0});import{defineConfig as i}from"vitest/config";import{asVitePlugins as a}from"./plugin-option.js";import{fileURLToPath as u}from"node:url";import{DEFAULT_CLOUDFLARE_MOCKS as f,KIT_NO_EXTERNAL as o,workspaceAliases as p}from"./vitest-aliases.js";const m=["test/web/**/*.test.{ts,tsx}","test/**/web-*.test.{ts,tsx}","apps/web/**/*.test.{ts,tsx}"],g=["**/*.test.{ts,tsx}","**/*.d.ts","**/types.ts","**/generated/**"];function w(e={}){const s=e.root??new URL(".",import.meta.url).href,r=u(new URL("apps/web/src",s)),d=p({scope:e.scope??"@unused",root:s,packages:e.packages,mocks:e.mocks??f}).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:a(e.plugins)},resolve:{alias:l,noExternal:[...o,...e.noExternal??[]]},test:{globals:!0,environment:e.environment??"jsdom",include:[...e.include??m],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:[...g,...e.coverageExclude??[]],...e.thresholds!==void 0&&{thresholds:{...e.thresholds}}}}})}n(w,"defineWebVitestConfig");export{w as defineWebVitestConfig};
|
package/dist/vitest-web.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/vitest-web.ts"],
|
|
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 } from 'vitest/config';\nimport { asVitePlugins } from './plugin-option.ts';\nimport type { PluginOption } from './plugin-option.ts';\nimport { fileURLToPath } from 'node:url';\nimport { DEFAULT_CLOUDFLARE_MOCKS,
|
|
5
|
-
"mappings": "+EAyCA,OAAS,gBAAAA,MAAoB,gBAC7B,OAAS,iBAAAC,MAAqB,qBAE9B,OAAS,iBAAAC,MAAqB,WAC9B,OAAS,4BAAAC,EAA0B,
|
|
6
|
-
"names": ["defineConfig", "asVitePlugins", "fileURLToPath", "DEFAULT_CLOUDFLARE_MOCKS", "
|
|
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 } from 'vitest/config';\nimport { asVitePlugins } from './plugin-option.ts';\nimport type { PluginOption } from './plugin-option.ts';\nimport { fileURLToPath } from 'node:url';\nimport { DEFAULT_CLOUDFLARE_MOCKS, 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 PluginOption[];\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,\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: asVitePlugins(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": "+EAyCA,OAAS,gBAAAA,MAAoB,gBAC7B,OAAS,iBAAAC,MAAqB,qBAE9B,OAAS,iBAAAC,MAAqB,WAC9B,OAAS,4BAAAC,EAA0B,mBAAAC,EAAiB,oBAAAC,M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,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", "asVitePlugins", "fileURLToPath", "DEFAULT_CLOUDFLARE_MOCKS", "KIT_NO_EXTERNAL", "workspaceAliases", "DEFAULT_INCLUDE", "CANONICAL_COVERAGE_EXCLUDE", "defineWebVitestConfig", "options", "root", "webSrc", "scopePart", "alias", "aliases", "__name"]
|
|
7
7
|
}
|
package/dist/vitest.d.ts
CHANGED
|
@@ -36,7 +36,7 @@ import { defineConfig } from 'vitest/config';
|
|
|
36
36
|
import type { PluginOption } from './plugin-option.ts';
|
|
37
37
|
import type { VitestAlias } from './vitest-aliases.ts';
|
|
38
38
|
export type { VitestAlias } from './vitest-aliases.ts';
|
|
39
|
-
export { KIT_DEDUPE, KIT_NO_EXTERNAL } from './vitest-aliases.ts';
|
|
39
|
+
export { DEFAULT_WORKSPACE_PACKAGES, KIT_DEDUPE, KIT_NO_EXTERNAL } from './vitest-aliases.ts';
|
|
40
40
|
/**
|
|
41
41
|
* Coverage thresholds, in the four figures Vitest gates on.
|
|
42
42
|
*/
|
package/dist/vitest.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vitest.d.ts","sourceRoot":"","sources":["../src/vitest.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AAEH,OAAO,EAAE,YA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AE,SAAS,WAAW,EAAE,CAAC;IAC1C;;;;;OAKG;IACH,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB;;OAEG;IACH,QAAQ,CAAC,OAAO,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACrC;;;OAGG;IACH,QAAQ,CAAC,OAAO,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACrC;;;;OAIG;IACH,QAAQ,CAAC,gBAAgB,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAC9C;;;OAGG;IACH,QAAQ,CAAC,UAAU,CAAC,EAAE,SAAS,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,CAAC;IACnD;;;OAGG;IACH,QAAQ,CAAC,OAAO,CAAC,EAAE,SAAS,YAAY,EAAE,CAAC;IAC3C;;;OAGG;IACH,QAAQ,CAAC,UAAU,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACxC;;;OAGG;IACH,QAAQ,CAAC,eAAe,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAC7C;;OAEG;IACH,QAAQ,CAAC,eAAe,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAC7C;;;;;;;;;;;;;;OAcG;IACH,QAAQ,CAAC,mBAAmB,CAAC,EAAE,OAAO,CAAC;IACvC;;;OAGG;IACH,QAAQ,CAAC,UAAU,CAAC,EAAE,kBAAkB,CAAC;IACzC;;OAEG;IACH,QAAQ,CAAC,gBAAgB,CAAC,EAAE,MAAM,CAAC;CACpC;AAoDD;;;;;;;;;;;GAWG;AACH,wBAAgB,sBAAsB,CAAC,OAAO,GAAE,uBAA4B,GAAG,UAAU,CAAC,OAAO,YAAY,CAAC,CAiE7G"}
|
package/dist/vitest.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var i=Object.defineProperty;var r=(e,s)=>i(e,"name",{value:s,configurable:!0});import{defineConfig as u}from"vitest/config";import{asVitePlugins as o}from"./plugin-option.js";import{manifestCoverageThresholds as E}from"./manifest.js";import{DEFAULT_CLOUDFLARE_MOCKS as f,
|
|
1
|
+
var i=Object.defineProperty;var r=(e,s)=>i(e,"name",{value:s,configurable:!0});import{defineConfig as u}from"vitest/config";import{asVitePlugins as o}from"./plugin-option.js";import{manifestCoverageThresholds as E}from"./manifest.js";import{DEFAULT_CLOUDFLARE_MOCKS as f,KIT_DEDUPE as g,KIT_NO_EXTERNAL as p,workspaceAliases as m}from"./vitest-aliases.js";import{DEFAULT_WORKSPACE_PACKAGES as R,KIT_DEDUPE as b,KIT_NO_EXTERNAL as k}from"./vitest-aliases.js";const v=["test/web/**","test/**/web-*.test.{ts,tsx}","apps/web/**/*.test.{ts,tsx}"],c=["scripts/**","**/*.test.ts","**/*.test.tsx","**/*.d.ts","**/index.ts","**/types.d.ts","**/model/**","**/generated/**","**/D1Types.ts","**/ServiceEnv.ts","**/env.d.ts"],x="**/index.ts";function A(e){return[...e.includeIndexBarrels?c.filter(t=>t!==x):c,...e.coverageExclude??[]]}r(A,"coverageExcludeFor");function T(e={}){const s=e.root??new URL(".",import.meta.url).href,t=e.thresholds??E(s),d=e.coverageInclude??["apps/api/src/**/*.ts","apps/background/src/**/*.ts","packages/**/src/**/*.ts"],l=A(e),a=[...m({scope:e.scope??"@unused",root:s,packages:e.scope===void 0?[]:e.packages,mocks:e.mocks??f}).filter(n=>typeof n.find!="string"||!n.find.startsWith("@unused")),...e.aliases??[]];return u({...e.plugins!==void 0&&{plugins:o(e.plugins)},resolve:{alias:a,noExternal:[...p,...e.noExternal??[]],dedupe:[...g]},test:{globals:!0,environment:"node",include:[...e.include??["test/**/*.test.{ts,tsx}"]],exclude:[...e.exclude??["**/node_modules/**","**/dist/**","test/integration/**",...v]],...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:[...d],exclude:l,...t!==void 0&&{thresholds:{...t}}}}})}r(T,"defineUnitVitestConfig");export{R as DEFAULT_WORKSPACE_PACKAGES,b as KIT_DEDUPE,k as KIT_NO_EXTERNAL,T as defineUnitVitestConfig};
|
package/dist/vitest.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/vitest.ts"],
|
|
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 } from 'vitest/config';\nimport { asVitePlugins } from './plugin-option.ts';\nimport type { PluginOption } from './plugin-option.ts';\nimport { manifestCoverageThresholds } from './manifest.ts';\nimport { DEFAULT_CLOUDFLARE_MOCKS, DEFAULT_WORKSPACE_PACKAGES, KIT_DEDUPE, KIT_NO_EXTERNAL, workspaceAliases } from './vitest-aliases.ts';\nimport type { VitestAlias } from './vitest-aliases.ts';\n\nexport type { VitestAlias } from './vitest-aliases.ts';\n// Re-exported from this sub-barrel as well as the root, because a consumer\n// configuring **Vite** reaches for this path to find the same constants the vitest\n// factory applies — `KIT_DEDUPE` first, to keep one React between the app and the\n// kit's components. Exporting it only from the root meant that import failed with\n// `does not provide an export named 'KIT_DEDUPE'` at config-load time, which is a\n// build failure before any test runs and no error that names the install.\nexport { KIT_DEDUPE, KIT_NO_EXTERNAL } 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 PluginOption[];\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 * Report coverage for `index.ts` re-export barrels.\n *\n * The canonical set excludes them because a barrel carries no logic of its\n * own. Two repos in the family read that differently and deliberately keep\n * them in: a barrel with no importer shows up as an uncovered file, which is\n * the point — it is the only signal that the barrel is dead. Excluding them\n * is what let four entirely unused root barrels sit in the tree unnoticed, one\n * per repo that carried the habit.\n *\n * `coverageExclude` cannot express this, because it is merged with the\n * canonical set rather than replacing it, so a consumer could not opt back in.\n * Hence a named flag. Default `false`: today’s behaviour, unchanged for the\n * seven repos that never asked.\n */\n readonly includeIndexBarrels?: boolean;\n /**\n * Coverage floors. Defaults to the manifest's `quality.coverage` (`.rexezuge.jsonc`\n * at `root`); without one, no floor.\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 * The barrel exclusion, named so `includeIndexBarrels` can lift it.\n */\nconst INDEX_BARREL_EXCLUDE = '**/index.ts';\n\n/**\n * The canonical exclude set, with the barrel entry lifted for a caller that\n * asked to keep barrels in their coverage report.\n */\nfunction coverageExcludeFor(options: { coverageExclude?: readonly string[]; includeIndexBarrels?: boolean }): string[] {\n const canonical = options.includeIndexBarrels\n ? CANONICAL_COVERAGE_EXCLUDE.filter((glob) => glob !== INDEX_BARREL_EXCLUDE)\n : CANONICAL_COVERAGE_EXCLUDE;\n return [...canonical, ...(options.coverageExclude ?? [])];\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 thresholds = options.thresholds ?? manifestCoverageThresholds(root);\n const coverageInclude = options.coverageInclude ?? ['apps/api/src/**/*.ts', 'apps/background/src/**/*.ts', 'packages/**/src/**/*.ts'];\n const coverageExclude = coverageExcludeFor(options);\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: asVitePlugins(options.plugins) }),\n resolve: {\n alias: aliases,\n noExternal: [...KIT_NO_EXTERNAL, ...(options.noExternal ?? [])],\n // The peer runtime a consumer and the kit must agree on. `@rexezuge/web`\n // declares `react`, `react-dom` and `lucide-react` as peers, which under a\n // registry install means neither package carries its own copy. Under the\n // `link:` workflow this repo's own README recommends, the symlinked\n // directory **does** have one — so the kit resolves its own React and the\n // consumer resolves theirs, and every hook in a kit component throws\n // `Cannot read properties of null (reading 'useState')`. Dedupe points the\n // bare specifier at one copy for both.\n dedupe: [...KIT_DEDUPE],\n },\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 ...(thresholds !== undefined && { thresholds: { ...thresholds } }),\n },\n },\n });\n}\n"],
|
|
5
|
-
"mappings": "+EAmCA,OAAS,gBAAAA,MAAoB,gBAC7B,OAAS,iBAAAC,MAAqB,qBAE9B,OAAS,8BAAAC,MAAkC,gBAC3C,OAAS,4BAAAC,EAA0B,
|
|
6
|
-
"names": ["defineConfig", "asVitePlugins", "manifestCoverageThresholds", "DEFAULT_CLOUDFLARE_MOCKS", "
|
|
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 } from 'vitest/config';\nimport { asVitePlugins } from './plugin-option.ts';\nimport type { PluginOption } from './plugin-option.ts';\nimport { manifestCoverageThresholds } from './manifest.ts';\nimport { DEFAULT_CLOUDFLARE_MOCKS, KIT_DEDUPE, KIT_NO_EXTERNAL, workspaceAliases } from './vitest-aliases.ts';\nimport type { VitestAlias } from './vitest-aliases.ts';\n\nexport type { VitestAlias } from './vitest-aliases.ts';\n// Re-exported from this sub-barrel as well as the root, because a consumer\n// configuring **Vite** reaches for this path to find the same constants the vitest\n// factory applies — `KIT_DEDUPE` first, to keep one React between the app and the\n// kit's components. Exporting it only from the root meant that import failed with\n// `does not provide an export named 'KIT_DEDUPE'` at config-load time, which is a\n// build failure before any test runs and no error that names the install.\nexport { DEFAULT_WORKSPACE_PACKAGES, KIT_DEDUPE, KIT_NO_EXTERNAL } 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 PluginOption[];\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 * Report coverage for `index.ts` re-export barrels.\n *\n * The canonical set excludes them because a barrel carries no logic of its\n * own. Two repos in the family read that differently and deliberately keep\n * them in: a barrel with no importer shows up as an uncovered file, which is\n * the point — it is the only signal that the barrel is dead. Excluding them\n * is what let four entirely unused root barrels sit in the tree unnoticed, one\n * per repo that carried the habit.\n *\n * `coverageExclude` cannot express this, because it is merged with the\n * canonical set rather than replacing it, so a consumer could not opt back in.\n * Hence a named flag. Default `false`: today’s behaviour, unchanged for the\n * seven repos that never asked.\n */\n readonly includeIndexBarrels?: boolean;\n /**\n * Coverage floors. Defaults to the manifest's `quality.coverage` (`.rexezuge.jsonc`\n * at `root`); without one, no floor.\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 * The barrel exclusion, named so `includeIndexBarrels` can lift it.\n */\nconst INDEX_BARREL_EXCLUDE = '**/index.ts';\n\n/**\n * The canonical exclude set, with the barrel entry lifted for a caller that\n * asked to keep barrels in their coverage report.\n */\nfunction coverageExcludeFor(options: { coverageExclude?: readonly string[]; includeIndexBarrels?: boolean }): string[] {\n const canonical = options.includeIndexBarrels\n ? CANONICAL_COVERAGE_EXCLUDE.filter((glob) => glob !== INDEX_BARREL_EXCLUDE)\n : CANONICAL_COVERAGE_EXCLUDE;\n return [...canonical, ...(options.coverageExclude ?? [])];\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 thresholds = options.thresholds ?? manifestCoverageThresholds(root);\n const coverageInclude = options.coverageInclude ?? ['apps/api/src/**/*.ts', 'apps/background/src/**/*.ts', 'packages/**/src/**/*.ts'];\n const coverageExclude = coverageExcludeFor(options);\n const baseAliases = workspaceAliases({\n scope: options.scope ?? '@unused',\n root,\n packages: options.scope === undefined ? [] : options.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: asVitePlugins(options.plugins) }),\n resolve: {\n alias: aliases,\n noExternal: [...KIT_NO_EXTERNAL, ...(options.noExternal ?? [])],\n // The peer runtime a consumer and the kit must agree on. `@rexezuge/web`\n // declares `react`, `react-dom` and `lucide-react` as peers, which under a\n // registry install means neither package carries its own copy. Under the\n // `link:` workflow this repo's own README recommends, the symlinked\n // directory **does** have one — so the kit resolves its own React and the\n // consumer resolves theirs, and every hook in a kit component throws\n // `Cannot read properties of null (reading 'useState')`. Dedupe points the\n // bare specifier at one copy for both.\n dedupe: [...KIT_DEDUPE],\n },\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 ...(thresholds !== undefined && { thresholds: { ...thresholds } }),\n },\n },\n });\n}\n"],
|
|
5
|
+
"mappings": "+EAmCA,OAAS,gBAAAA,MAAoB,gBAC7B,OAAS,iBAAAC,MAAqB,qBAE9B,OAAS,8BAAAC,MAAkC,gBAC3C,OAAS,4BAAAC,EAA0B,cAAAC,EAAY,mBAAAC,EAAiB,oBAAAC,MAAwB,sBAUxF,OAAS,8BAAAC,EAA4B,cAAAH,EAAY,mBAAAC,MAAuB,sBA0HxE,M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S,CAAE,EAC3G,GAAII,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,GAAGM,CAAe,EAC5B,QAASC,EACT,GAAIF,IAAe,QAAa,CAAE,WAAY,CAAE,GAAGA,CAAU,CAAE,IAGpE,CACH,CAjEgBH,EAAAC,EAAA",
|
|
6
|
+
"names": ["defineConfig", "asVitePlugins", "manifestCoverageThresholds", "DEFAULT_CLOUDFLARE_MOCKS", "KIT_DEDUPE", "KIT_NO_EXTERNAL", "workspaceAliases", "DEFAULT_WORKSPACE_PACKAGES", "SPA_FILES", "CANONICAL_COVERAGE_EXCLUDE", "INDEX_BARREL_EXCLUDE", "coverageExcludeFor", "options", "glob", "__name", "defineUnitVitestConfig", "root", "thresholds", "coverageInclude", "coverageExclude", "aliases", "alias"]
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rexezuge/tooling",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.16.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -48,8 +48,8 @@
|
|
|
48
48
|
"presets"
|
|
49
49
|
],
|
|
50
50
|
"dependencies": {
|
|
51
|
-
"@rexezuge/d1": "1.
|
|
52
|
-
"@rexezuge/testing": "1.
|
|
51
|
+
"@rexezuge/d1": "1.16.0",
|
|
52
|
+
"@rexezuge/testing": "1.16.0"
|
|
53
53
|
},
|
|
54
54
|
"peerDependencies": {
|
|
55
55
|
"eslint": "^10.0.0",
|
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
"display": "Rexezuge family: React SPA (apps/web)",
|
|
4
4
|
"extends": "./base.json",
|
|
5
5
|
"compilerOptions": {
|
|
6
|
-
"target": "
|
|
7
|
-
"lib": ["
|
|
6
|
+
"target": "ES2022",
|
|
7
|
+
"lib": ["ES2022", "DOM", "DOM.Iterable"],
|
|
8
8
|
"jsx": "react-jsx"
|
|
9
9
|
}
|
|
10
10
|
}
|
|
@@ -24,11 +24,38 @@
|
|
|
24
24
|
"migrationsDir": { "type": "string", "minLength": 1 }
|
|
25
25
|
}
|
|
26
26
|
},
|
|
27
|
+
"kv": {
|
|
28
|
+
"type": "object",
|
|
29
|
+
"additionalProperties": false,
|
|
30
|
+
"required": ["bindings"],
|
|
31
|
+
"description": "KV bindings prepare-wrangler provisions. Absent: no KV binding or namespace is added.",
|
|
32
|
+
"properties": {
|
|
33
|
+
"bindings": { "type": "array", "items": { "type": "string", "pattern": "^[A-Z][A-Z0-9_]*$" } },
|
|
34
|
+
"namespaceNames": {
|
|
35
|
+
"type": "object",
|
|
36
|
+
"description": "Binding to namespace name, for namespaces that predate the <worker>-<binding> convention.",
|
|
37
|
+
"additionalProperties": { "type": "string", "minLength": 1 }
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
},
|
|
27
41
|
"web": {
|
|
28
42
|
"type": "object",
|
|
29
43
|
"additionalProperties": false,
|
|
30
44
|
"required": ["pages", "spaShell"],
|
|
31
|
-
"properties": {
|
|
45
|
+
"properties": {
|
|
46
|
+
"pages": { "type": "boolean" },
|
|
47
|
+
"spaShell": { "type": "boolean" },
|
|
48
|
+
"buildScript": {
|
|
49
|
+
"type": "string",
|
|
50
|
+
"pattern": "^[\\w:.-]+$",
|
|
51
|
+
"description": "A root package.json script that builds the SPA; CI and CD run it instead of pnpm --filter <web> run build."
|
|
52
|
+
},
|
|
53
|
+
"pagesProject": {
|
|
54
|
+
"type": "string",
|
|
55
|
+
"pattern": "^[a-z0-9][a-z0-9-]{0,57}$",
|
|
56
|
+
"description": "The Cloudflare Pages project, when it is not <name>-web. Wins over CLOUDFLARE_PAGES_PROJECT_NAME."
|
|
57
|
+
}
|
|
58
|
+
}
|
|
32
59
|
},
|
|
33
60
|
"background": { "type": "boolean" },
|
|
34
61
|
"backupD1": { "type": "boolean" },
|
package/src/eslint-rules.ts
CHANGED
|
@@ -193,6 +193,10 @@ export const SONARJS_RULES: Readonly<Record<string, unknown>> = {
|
|
|
193
193
|
// False positives: connection method names like 'imap-password' and field
|
|
194
194
|
// names like 'password_hash'.
|
|
195
195
|
'sonarjs/no-hardcoded-passwords': 'off',
|
|
196
|
+
// Task markers are governed by `rexezuge/todo-format` (`TODO(<scope>): <text>` is the family form);
|
|
197
|
+
// the stock tags flag even the scoped form, so every tracked gap became an error.
|
|
198
|
+
'sonarjs/todo-tag': 'off',
|
|
199
|
+
'sonarjs/fixme-tag': 'off',
|
|
196
200
|
// Third-party deprecations are warnings, not errors.
|
|
197
201
|
'sonarjs/deprecation': 'warn',
|
|
198
202
|
// Nested ternaries in complex data-mapping code.
|
|
@@ -104,3 +104,32 @@ describe('defineRepoLintConfig integration', () => {
|
|
|
104
104
|
expect(() => defineRepoLintConfig({ manifest: false })).toThrow(/scope/);
|
|
105
105
|
});
|
|
106
106
|
});
|
|
107
|
+
|
|
108
|
+
describe('strict: task markers', () => {
|
|
109
|
+
const lintTodo = (code: string): string[] => lint(code, 'apps/api/src/a.ts');
|
|
110
|
+
it.each([
|
|
111
|
+
'// TODO(sdk): replace this with the kit helper',
|
|
112
|
+
'// FIXME(totp-generator): the proxy drops the header',
|
|
113
|
+
'/**\n * TODO(pilot.1): a block comment\n */',
|
|
114
|
+
'// the TODO list is kept in the README',
|
|
115
|
+
'// TODOS are tracked elsewhere',
|
|
116
|
+
])('allows %s', (code) => {
|
|
117
|
+
expect(lintTodo(code)).toEqual([]);
|
|
118
|
+
});
|
|
119
|
+
it.each(['// TODO', '// TODO: later', '// FIXME fix it', '// TODO(sdk)', '// TODO(sdk):', '/*\n * some text\n * TODO( ): x\n */'])(
|
|
120
|
+
'refuses %s',
|
|
121
|
+
(code) => {
|
|
122
|
+
expect(lintTodo(code)[0]).toContain('rexezuge/todo-format');
|
|
123
|
+
},
|
|
124
|
+
);
|
|
125
|
+
it('names the tag and the form in the message, and also lints scripts', () => {
|
|
126
|
+
expect(lintTodo('// FIXME')[0]).toContain('FIXME(<scope>): <what is to be done>');
|
|
127
|
+
expect(lint('// TODO', 'scripts/a.mjs')[0]).toContain('rexezuge/todo-format');
|
|
128
|
+
});
|
|
129
|
+
it('turns the stock sonarjs tags off in the repo config', () => {
|
|
130
|
+
const rules = Object.assign({}, ...(defineRepoLintConfig({ scope: '@x' }) as Array<{ rules?: object }>).map((entry) => entry.rules));
|
|
131
|
+
expect((rules as Record<string, unknown>)['sonarjs/todo-tag']).toBe('off');
|
|
132
|
+
expect((rules as Record<string, unknown>)['sonarjs/fixme-tag']).toBe('off');
|
|
133
|
+
expect((rules as Record<string, unknown>)['rexezuge/todo-format']).toBe('error');
|
|
134
|
+
});
|
|
135
|
+
});
|