@rexezuge/tooling 1.12.0 → 1.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +124 -14
- package/dist/eslint-manifest.d.ts +25 -0
- package/dist/eslint-manifest.d.ts.map +1 -0
- package/dist/eslint-manifest.js +1 -0
- package/dist/eslint-manifest.js.map +7 -0
- package/dist/eslint-strict.d.ts +45 -0
- package/dist/eslint-strict.d.ts.map +1 -0
- package/dist/eslint-strict.js +1 -0
- package/dist/eslint-strict.js.map +7 -0
- package/dist/eslint.d.ts +20 -3
- package/dist/eslint.d.ts.map +1 -1
- package/dist/eslint.js +1 -1
- package/dist/eslint.js.map +3 -3
- package/dist/index.d.ts +5 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +3 -3
- package/dist/manifest-validate.d.ts +14 -0
- package/dist/manifest-validate.d.ts.map +1 -0
- package/dist/manifest-validate.js +1 -0
- package/dist/manifest-validate.js.map +7 -0
- package/dist/manifest.d.ts +159 -0
- package/dist/manifest.d.ts.map +1 -0
- package/dist/manifest.js +3 -0
- package/dist/manifest.js.map +7 -0
- package/dist/scripts/check-god-files.d.ts.map +1 -1
- package/dist/scripts/check-god-files.js +2 -2
- package/dist/scripts/check-god-files.js.map +3 -3
- package/dist/test/mocks/cloudflare-workers.d.ts +6 -103
- package/dist/test/mocks/cloudflare-workers.d.ts.map +1 -1
- package/dist/test/mocks/cloudflare-workers.js +1 -1
- package/dist/test/mocks/cloudflare-workers.js.map +3 -3
- package/dist/vite.d.ts.map +1 -1
- package/dist/vite.js.map +2 -2
- package/dist/vitest-aliases.d.ts +3 -0
- 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-repo.d.ts +2 -1
- package/dist/vitest-repo.d.ts.map +1 -1
- package/dist/vitest-repo.js +1 -1
- package/dist/vitest-repo.js.map +3 -3
- package/dist/vitest.d.ts +2 -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 +14 -3
- package/presets/prettier.d.mts +4 -0
- package/presets/prettier.mjs +16 -0
- package/presets/tsconfig/base.json +19 -0
- package/presets/tsconfig/web.json +10 -0
- package/presets/tsconfig/worker.json +9 -0
- package/schema/manifest.schema.json +105 -0
- package/src/eslint-manifest.ts +71 -0
- package/src/eslint-strict.test.ts +106 -0
- package/src/eslint-strict.ts +191 -0
- package/src/eslint.ts +36 -8
- package/src/index.ts +15 -2
- package/src/manifest-validate.ts +202 -0
- package/src/manifest.test.ts +228 -0
- package/src/manifest.ts +194 -0
- package/src/presets.test.ts +63 -0
- package/src/scripts/check-god-files.ts +3 -0
- package/src/test/mocks/cloudflare-workers.ts +6 -113
- package/src/vite.ts +1 -0
- package/src/vitest-aliases.test.ts +23 -0
- package/src/vitest-aliases.ts +22 -1
- package/src/vitest-factories.test.ts +30 -1
- package/src/vitest-repo.ts +5 -2
- package/src/vitest.ts +5 -2
package/dist/vitest-aliases.d.ts
CHANGED
|
@@ -96,6 +96,9 @@ export interface WorkspaceAliasesOptions {
|
|
|
96
96
|
/**
|
|
97
97
|
* Build the workspace alias table for a consumer repo.
|
|
98
98
|
*
|
|
99
|
+
* `cloudflare:workers` resolves to `<root>/test/mocks/cloudflare-workers.ts` when
|
|
100
|
+
* that file exists, and otherwise to `@rexezuge/testing/cloudflare-workers`.
|
|
101
|
+
*
|
|
99
102
|
* Aliases point at source rather than at built output, so a test exercises the
|
|
100
103
|
* code the worker would run without a build step. `background` resolves under
|
|
101
104
|
* `apps/`; every other package under `packages/`. `@/` maps to the API worker
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vitest-aliases.d.ts","sourceRoot":"","sources":["../src/vitest-aliases.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"vitest-aliases.d.ts","sourceRoot":"","sources":["../src/vitest-aliases.ts"],"names":[],"mappings":"AAIA;;;;;;;GAOG;AACH,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC;IAC/B,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;CAC9B;AAED;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,0BAA0B,EAAE,SAAS,MAAM,EAYvD,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,wBAAwB,EAAE,SAAS,MAAM,EAAwC,CAAC;AAE/F;;;;;;;;;;GAUG;AACH,eAAO,MAAM,eAAe,EAAE,SAAS,MAAM,EAA6B,CAAC;AAE3E;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,UAAU,EAAE,SAAS,MAAM,EAAgE,CAAC;AAEzG;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACtC;;;OAGG;IACH,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB;;;;OAIG;IACH,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB;;;OAGG;IACH,QAAQ,CAAC,QAAQ,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACtC;;OAEG;IACH,QAAQ,CAAC,KAAK,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACnC;;OAEG;IACH,QAAQ,CAAC,YAAY,CAAC,EAAE,SAAS,WAAW,EAAE,CAAC;CAChD;AAcD;;;;;;;;;;;GAWG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,uBAAuB,GAAG,WAAW,EAAE,CAqBhF"}
|
package/dist/vitest-aliases.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var
|
|
1
|
+
var d=Object.defineProperty;var s=(r,a)=>d(r,"name",{value:a,configurable:!0});import{existsSync as m}from"node:fs";import{createRequire as f}from"node:module";import{fileURLToPath as g}from"node:url";const b=["shared","backend-errors","backend-runtime","backend-data","provider-clients","webdav","dav-store","git-protocol","git-service","backend-services","background"],w=["workers","sockets","workflows"],$=[/(^|[/\\])@rexezuge\//],h=["react","react-dom","react/jsx-runtime","lucide-react"];function x(){try{return f(import.meta.url).resolve("@rexezuge/testing/cloudflare-workers")}catch{return null}}s(x,"kitWorkersMock");function v(r){const{scope:a,root:n}=r,i=r.packages??b,p=r.mocks??w,c=s(e=>g(new URL(e,n)),"at"),o=[];for(const e of i){const t=e==="background"?"apps/background/src":`packages/${e}/src`;o.push({find:`${a}/${e}`,replacement:c(t)})}for(const e of p){const t=c(`test/mocks/cloudflare-${e}.ts`),u=e==="workers"&&!m(t)?x():null;o.push({find:`cloudflare:${e}`,replacement:u??t})}const l=c("apps/api/src"),k=c("apps/web/src");return o.push({find:/^@\//,replacement:`${l}/`},{find:/^~\//,replacement:`${k}/`},...r.extraAliases??[]),o}s(v,"workspaceAliases");export{w as DEFAULT_CLOUDFLARE_MOCKS,b as DEFAULT_WORKSPACE_PACKAGES,h as KIT_DEDUPE,$ as KIT_NO_EXTERNAL,v as workspaceAliases};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/vitest-aliases.ts"],
|
|
4
|
-
"sourcesContent": ["import { fileURLToPath } from 'node:url';\n\n/**\n * One `{ find, replacement }` pair for Vitest's resolver.\n *\n * A `string` find is a prefix match in Vite; a `RegExp` find is tested against\n * the specifier. Workspace scopes use plain strings (`'@scope/name'` matches\n * `'@scope/name'` and `'@scope/name/sub'` alike); `@/` and `~/` use regexps so\n * the trailing slash is part of the match.\n */\nexport interface VitestAlias {\n readonly find: string | RegExp;\n readonly replacement: string;\n}\n\n/**\n * Every workspace package the family has converged on, as directory names under\n * `packages/`.\n *\n * The union across all nine repos: the universal core (`shared`,\n * `backend-errors`, `backend-runtime`, `backend-data`, `backend-services`) plus\n * the domain packages (`provider-clients`, `webdav`, `dav-store`,\n * `git-protocol`, `git-service`). `media-tags`/`subsonic` (Edge-Sonic) are\n * unconstrained utility leaves with no boundary block and no alias in their\n * source repo, so they are not listed — a repo that needs them passes\n * `packages` explicitly or appends `aliases`.\n *\n * A superset is safe: an alias for a package the consumer does not have never\n * matches a specifier, and Vite only resolves the replacement when something\n * imports it.\n */\nexport const DEFAULT_WORKSPACE_PACKAGES: readonly string[] = [\n 'shared',\n 'backend-errors',\n 'backend-runtime',\n 'backend-data',\n 'provider-clients',\n 'webdav',\n 'dav-store',\n 'git-protocol',\n 'git-service',\n 'backend-services',\n 'background',\n];\n\n/**\n * The Cloudflare runtime mocks the unit suite aliases.\n *\n * `workers` exists in every repo; `sockets` in five; `workflows` in four. All\n * three are listed by default: an alias whose mock file is absent never fires\n * unless a test imports the specifier, and then the missing file is the correct\n * error rather than Node's `ERR_UNKNOWN_SCHEME` for `cloudflare:*`.\n */\nexport const DEFAULT_CLOUDFLARE_MOCKS: readonly string[] = ['workers', 'sockets', 'workflows'];\n\n/**\n * Keep the kit's own `dist/` inside Vite's pipeline.\n *\n * The kit ships ESM `dist/` with bundler-style extensionless relative imports\n * (its tsconfig is `moduleResolution: Bundler`), which Node's ESM resolver\n * refuses. Vitest externalizes `node_modules` deps by default and would import\n * that dist with Node; `noExternal` routes `@rexezuge/*` back through Vite —\n * the same resolver that bundles the worker — so a test loads the very dist\n * the worker ships. Without this, the run dies on `./BaseDAO` inside\n * `@rexezuge/d1`'s `dist/index.js`.\n */\nexport const KIT_NO_EXTERNAL: readonly RegExp[] = [/(^|[/\\\\])@rexezuge\\//];\n\n/**\n * 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/`). Defaults to {@link DEFAULT_WORKSPACE_PACKAGES}.\n */\n readonly packages?: readonly string[];\n /**\n * Which `cloudflare:*` mocks to alias. Defaults to {@link DEFAULT_CLOUDFLARE_MOCKS}.\n */\n readonly mocks?: readonly string[];\n /**\n * Extra resolver entries, applied after the canonical ones.\n */\n readonly extraAliases?: readonly VitestAlias[];\n}\n\n/**\n * Build the workspace alias table for a consumer repo.\n *\n * Aliases point at source rather than at built output, so a test exercises the\n * code the worker would run without a build step. `background` resolves under\n * `apps/`; every other package under `packages/`. `@/` maps to the API worker\n * source and `~/` to the SPA source, matching the two `tsconfig` path prefixes\n * every repo shares.\n */\nexport function workspaceAliases(options: WorkspaceAliasesOptions): VitestAlias[] {\n const { scope, root } = options;\n const packages = options.packages ?? DEFAULT_WORKSPACE_PACKAGES;\n const mocks = options.mocks ?? DEFAULT_CLOUDFLARE_MOCKS;\n const at = (relative: string): string => fileURLToPath(new URL(relative, root));\n const aliases: VitestAlias[] = [];\n for (const name of packages) {\n const dir = name === 'background' ? 'apps/background/src' : `packages/${name}/src`;\n aliases.push({ find: `${scope}/${name}`, replacement: at(dir) });\n }\n for (const mock of mocks) {\n aliases.push({ find: `cloudflare:${mock}`, replacement:
|
|
5
|
-
"mappings": "+EAAA,OAAS,
|
|
6
|
-
"names": ["fileURLToPath", "DEFAULT_WORKSPACE_PACKAGES", "DEFAULT_CLOUDFLARE_MOCKS", "KIT_NO_EXTERNAL", "KIT_DEDUPE", "workspaceAliases", "options", "scope", "root", "packages", "mocks", "at", "
|
|
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/`). Defaults to {@link DEFAULT_WORKSPACE_PACKAGES}.\n */\n readonly packages?: readonly string[];\n /**\n * Which `cloudflare:*` mocks to alias. Defaults to {@link DEFAULT_CLOUDFLARE_MOCKS}.\n */\n readonly mocks?: readonly string[];\n /**\n * Extra resolver entries, applied after the canonical ones.\n */\n readonly extraAliases?: readonly VitestAlias[];\n}\n\n/**\n * 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\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 packages = options.packages ?? DEFAULT_WORKSPACE_PACKAGES;\n const mocks = options.mocks ?? DEFAULT_CLOUDFLARE_MOCKS;\n const at = (relative: string): string => fileURLToPath(new URL(relative, root));\n const aliases: VitestAlias[] = [];\n for (const name of packages) {\n const dir = name === 'background' ? 'apps/background/src' : `packages/${name}/src`;\n aliases.push({ find: `${scope}/${name}`, replacement: at(dir) });\n }\n for (const mock of mocks) {\n 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":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a,GAAGC,CAAM,GAAG,EAAI,GAAId,EAAQ,cAAgB,CAAA,CAAG,EAC/HO,CACT,CArBgBT,EAAAC,EAAA",
|
|
6
|
+
"names": ["existsSync", "createRequire", "fileURLToPath", "DEFAULT_WORKSPACE_PACKAGES", "DEFAULT_CLOUDFLARE_MOCKS", "KIT_NO_EXTERNAL", "KIT_DEDUPE", "kitWorkersMock", "__name", "workspaceAliases", "options", "scope", "root", "packages", "mocks", "at", "relative", "aliases", "name", "dir", "mock", "local", "kit", "apiSrc", "webSrc"]
|
|
7
7
|
}
|
package/dist/vitest-repo.d.ts
CHANGED
|
@@ -134,7 +134,8 @@ export interface RepoVitestConfigOptions {
|
|
|
134
134
|
*/
|
|
135
135
|
readonly includeIndexBarrels?: boolean;
|
|
136
136
|
/**
|
|
137
|
-
* Coverage floors.
|
|
137
|
+
* Coverage floors. Defaults to the manifest's `quality.coverage` (`.rexezuge.jsonc`
|
|
138
|
+
* at `root`); without one, no floor.
|
|
138
139
|
*/
|
|
139
140
|
readonly thresholds?: CoverageThresholds;
|
|
140
141
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vitest-repo.d.ts","sourceRoot":"","sources":["../src/vitest-repo.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,OAAO,EAAE,YAAY,EAAE,KAAK,MAAM,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"vitest-repo.d.ts","sourceRoot":"","sources":["../src/vitest-repo.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,OAAO,EAAE,YAAY,EAAE,KAAK,MAAM,EAAE,MAAM,eAAe,CAAC;AAI1D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAEtD;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC;;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C;IAC1C;;OAEG;IACH,QAAQ,CAAC,UAAU,CAAC,EAAE,SAAS,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,CAAC;IACnD;;;OAGG;IACH,QAAQ,CAAC,OAAO,CAAC,EAAE,kBAAkB,CAAC;IACtC;;OAEG;IACH,QAAQ,CAAC,GAAG,CAAC,EAAE,cAAc,CAAC;IAC9B;;;OAGG;IACH,QAAQ,CAAC,eAAe,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAC7C;;OAEG;IACH,QAAQ,CAAC,eAAe,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAC7C;;;OAGG;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;AA4CD;;;;;;;;;;;;GAYG;AACH,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,uBAAuB,GAAG,UAAU,CAAC,OAAO,YAAY,CAAC,CA4ExG"}
|
package/dist/vitest-repo.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var
|
|
1
|
+
var f=Object.defineProperty;var o=(e,t)=>f(e,"name",{value:t,configurable:!0});import{defineConfig as x}from"vitest/config";import{fileURLToPath as g}from"node:url";import{manifestCoverageThresholds as b}from"./manifest.js";import{DEFAULT_CLOUDFLARE_MOCKS as v,DEFAULT_WORKSPACE_PACKAGES as w,KIT_NO_EXTERNAL as A,workspaceAliases as p}from"./vitest-aliases.js";const C=["**/node_modules/**","**/dist/**","test/integration/**","test/web/**","test/**/web-*.test.{ts,tsx}","apps/web/**/*.test.{ts,tsx}"],L=["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"],_="**/index.ts";function F(e){const t=e.root??new URL(".",import.meta.url).href,c=e.thresholds??b(t),l=e.packages??w,a=e.mocks??v,d=[...A,...e.noExternal??[]],r=e.backend??{},s=e.web??{},m=[...p({scope:e.scope,root:t,packages:l,mocks:a}),...e.aliases??[],...r.aliases??[]],i=g(new URL("apps/web/src",t)),E=[{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??C],...r.setupFiles!==void 0&&{setupFiles:[...r.setupFiles]},server:{deps:{inline:[...r.serverDepsInline??["dofs"]]}}}},{...s.plugins!==void 0&&{plugins:[...s.plugins]},resolve:{alias:E,noExternal:d},test:{name:"web",globals:!0,environment:s.environment??"jsdom",include:[...s.include??L],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!==_),...e.coverageExclude??[]]:[...u,...e.coverageExclude??[]],...c!==void 0&&{thresholds:{...c}}}}})}o(F,"defineRepoVitestConfig");export{F 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, type Plugin } from 'vitest/config';\nimport { fileURLToPath } from 'node:url';\nimport { DEFAULT_CLOUDFLARE_MOCKS, DEFAULT_WORKSPACE_PACKAGES, KIT_NO_EXTERNAL, workspaceAliases } from './vitest-aliases.ts';\nimport type { VitestAlias } from './vitest-aliases.ts';\nimport type { CoverageThresholds } from './vitest.ts';\n\n/**\n * The backend half of the `projects` pair.\n */\nexport interface RepoBackendOptions {\n /**\n * Which suites to collect. Defaults to the whole unit suite minus SPA and\n * integration shapes.\n */\n readonly include?: readonly string[];\n /**\n * Suite paths to skip, replacing the default.\n */\n readonly exclude?: readonly string[];\n /**\n * Setup files run before each backend test file.\n */\n readonly setupFiles?: readonly string[];\n /**\n * `node_modules` specifiers to inline through Vite. Defaults to `['dofs']`.\n */\n readonly serverDepsInline?: readonly string[];\n /**\n * Extra resolver entries for the backend project only.\n */\n readonly aliases?: readonly VitestAlias[];\n}\n\n/**\n * The SPA half of the `projects` pair.\n */\nexport interface RepoWebOptions {\n /**\n * The DOM implementation. `jsdom` is the family default; `happy-dom` is\n * CalDAV-Bridge's.\n */\n readonly environment?: 'jsdom' | 'happy-dom';\n /**\n * Which suites to collect. Defaults to every SPA shape the family uses.\n */\n readonly include?: readonly string[];\n /**\n * Suite paths to skip, replacing the default.\n */\n readonly exclude?: readonly string[];\n /**\n * Setup files run before each SPA test file.\n */\n readonly setupFiles?: readonly string[];\n /**\n * Vite plugins the SPA needs (`react()` for JSX).\n */\n readonly plugins?: readonly Plugin[];\n /**\n * Extra resolver entries for the web project only.\n */\n readonly aliases?: readonly VitestAlias[];\n}\n\n/**\n * What `defineRepoVitestConfig` accepts.\n */\nexport interface RepoVitestConfigOptions {\n /**\n * The consuming repo's npm scope, e.g. `'@myapp'`.\n */\n readonly scope: string;\n /**\n * Workspace package directory names. Defaults to the family superset.\n */\n readonly packages?: readonly string[];\n /**\n * Which `cloudflare:*` mocks to alias. Defaults to workers/sockets/workflows.\n */\n readonly mocks?: readonly string[];\n /**\n * The repo root, as a file URL.\n */\n readonly root?: string;\n /**\n * Extra resolver entries applied to *both* projects (e.g. the `hono`\n * dedupe). Per-project extras go on `backend.aliases` / `web.aliases`.\n */\n readonly aliases?: readonly VitestAlias[];\n /**\n * Resolver `noExternal` patterns, merged after {@link KIT_NO_EXTERNAL}.\n */\n readonly noExternal?: readonly (string | RegExp)[];\n /**\n * The backend half. Omitted fields take the `defineUnitVitestConfig`\n * defaults.\n */\n readonly backend?: RepoBackendOptions;\n /**\n * The SPA half. Omitted fields take the `defineWebVitestConfig` defaults.\n */\n readonly web?: RepoWebOptions;\n /**\n * Coverage `include` globs. Defaults to the worker, the SPA and every\n * workspace package's `src`.\n */\n readonly coverageInclude?: readonly string[];\n /**\n * Coverage `exclude` globs, merged with the canonical set.\n */\n readonly coverageExclude?: readonly string[];\n /**\n * 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. Omitted by default; a repo that wants them sets them.\n */\n readonly thresholds?: CoverageThresholds;\n /**\n * Where the coverage report is written.\n */\n readonly reportsDirectory?: string;\n}\n\n/**\n * Backend suites excluded from the backend project: the SPA shapes live in the\n * web project, and integration is its own config.\n */\nconst BACKEND_EXCLUDE: readonly string[] = [\n '**/node_modules/**',\n '**/dist/**',\n 'test/integration/**',\n 'test/web/**',\n 'test/**/web-*.test.{ts,tsx}',\n 'apps/web/**/*.test.{ts,tsx}',\n];\n\n/**\n * SPA suite shapes collected by the web project.\n */\nconst WEB_INCLUDE: readonly string[] = ['test/web/**/*.test.{ts,tsx}', 'test/**/web-*.test.{ts,tsx}', 'apps/web/**/*.test.{ts,tsx}'];\n\n/**\n * Coverage `exclude`: the union of the unit and web halves' canonical sets.\n */\nconst CANONICAL_COVERAGE_EXCLUDE: readonly string[] = [\n 'scripts/**',\n '**/*.test.ts',\n '**/*.test.tsx',\n '**/*.d.ts',\n '**/index.ts',\n '**/types.d.ts',\n '**/types.ts',\n '**/model/**',\n '**/generated/**',\n '**/D1Types.ts',\n '**/ServiceEnv.ts',\n '**/env.d.ts',\n];\n\n/**\n * 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 packages = options.packages ?? DEFAULT_WORKSPACE_PACKAGES;\n const mocks = options.mocks ?? DEFAULT_CLOUDFLARE_MOCKS;\n const noExternal = [...KIT_NO_EXTERNAL, ...(options.noExternal ?? [])];\n const backend = options.backend ?? {};\n const web = options.web ?? {};\n\n const backendAliases = [\n ...workspaceAliases({ scope: options.scope, root, packages, mocks }),\n ...(options.aliases ?? []),\n ...(backend.aliases ?? []),\n ];\n // `@/` means the SPA in the web project (Mail-Otter's SPA source imports\n // through it); the workspace table's `@/` → API entry is dropped and the\n // SPA's own prepended. `~/` → SPA either way.\n const webSrc = fileURLToPath(new URL('apps/web/src', root));\n const webAliases: VitestAlias[] = [\n { find: /^@\\//, replacement: `${webSrc}/` },\n { find: /^~\\//, replacement: `${webSrc}/` },\n // Drop the workspace table's `@/`/`~/` (RegExp) entries — the SPA's own\n // prepended above win — and keep the `@scope/*` + `cloudflare:*` strings.\n ...workspaceAliases({ scope: options.scope, root, packages, mocks }).filter((alias) => typeof alias.find === 'string'),\n ...(options.aliases ?? []),\n ...(web.aliases ?? []),\n ];\n\n return defineConfig({\n test: {\n projects: [\n {\n resolve: { alias: backendAliases, noExternal },\n test: {\n name: 'backend',\n globals: true,\n environment: 'node',\n include: [...(backend.include ?? ['test/**/*.test.{ts,tsx}'])],\n exclude: [...(backend.exclude ?? BACKEND_EXCLUDE)],\n ...(backend.setupFiles !== undefined && { setupFiles: [...backend.setupFiles] }),\n server: { deps: { inline: [...(backend.serverDepsInline ?? ['dofs'])] } },\n },\n },\n {\n ...(web.plugins !== undefined && { plugins: [...web.plugins] }),\n resolve: { alias: webAliases, noExternal },\n test: {\n name: 'web',\n globals: true,\n environment: web.environment ?? 'jsdom',\n include: [...(web.include ?? WEB_INCLUDE)],\n exclude: [...(web.exclude ?? ['**/node_modules/**', '**/dist/**', 'test/integration/**'])],\n pool: 'threads',\n ...(web.setupFiles !== undefined && { setupFiles: [...web.setupFiles] }),\n },\n },\n ],\n coverage: {\n provider: 'v8',\n reporter: ['text', 'lcov', 'html'],\n reportsDirectory: options.reportsDirectory ?? './coverage',\n include: [\n ...(options.coverageInclude ?? [\n 'apps/api/src/**/*.ts',\n 'apps/background/src/**/*.ts',\n 'apps/web/src/**/*.{ts,tsx}',\n 'packages/**/src/**/*.ts',\n ]),\n ],\n exclude: options.includeIndexBarrels\n ? [...CANONICAL_COVERAGE_EXCLUDE.filter((glob) => glob !== INDEX_BARREL_EXCLUDE), ...(options.coverageExclude ?? [])]\n : [...CANONICAL_COVERAGE_EXCLUDE, ...(options.coverageExclude ?? [])],\n ...(options.thresholds !== undefined && { thresholds: { ...options.thresholds } }),\n },\n },\n });\n}\n"],
|
|
5
|
-
"mappings": "+EAyBA,OAAS,gBAAAA,MAAiC,gBAC1C,OAAS,iBAAAC,MAAqB,WAC9B,OAAS,4BAAAC,EAA0B,8BAAAC,EAA4B,mBAAAC,EAAiB,oBAAAC,MAAwB,
|
|
6
|
-
"names": ["defineConfig", "fileURLToPath", "DEFAULT_CLOUDFLARE_MOCKS", "DEFAULT_WORKSPACE_PACKAGES", "KIT_NO_EXTERNAL", "workspaceAliases", "BACKEND_EXCLUDE", "WEB_INCLUDE", "CANONICAL_COVERAGE_EXCLUDE", "INDEX_BARREL_EXCLUDE", "defineRepoVitestConfig", "options", "root", "packages", "mocks", "noExternal", "backend", "web", "backendAliases", "webSrc", "webAliases", "alias", "glob", "__name"]
|
|
4
|
+
"sourcesContent": ["/**\n * The single-file `projects` composition: backend (`node`) plus SPA (DOM).\n *\n * Provenance: AWS-AccessBridge (split by `.ts`/`.tsx` extension),\n * Mail-Meow (split by `test/web/**` directory, with per-project `setupFiles`\n * and the React plugin on the web project), CalDAV-Bridge (split by directory\n * with `happy-dom`). The two-file repos (Durable-DAV-Router, Mail-Otter) keep\n * `defineUnitVitestConfig()` + `defineWebVitestConfig()`; this factory is the\n * same two halves as `projects` entries in one file, sharing one root coverage\n * gate.\n *\n * Canonical decisions (all three sources agree):\n *\n * 1. **Coverage lives at the root**, not per project: one floor for the whole\n * unit suite. (Durable-DAV-Router's warning about a shared floor stands for\n * the two-file split; within one file the three sources all gate once.)\n * 2. **Each project repeats the alias table.** Vitest projects do not inherit\n * the root `resolve` (Mail-Meow), so a suite resolving `@scope/*`\n * differently from its sibling fails like a product bug. Both entries carry\n * the full table — backend with `@/` → API, web with `@/` + `~/` → SPA.\n * 3. **The web project keeps `pool: 'threads'`** and its DOM from\n * `defineWebVitestConfig()`; the backend project keeps `environment:\n * 'node'` and `server.deps.inline` from `defineUnitVitestConfig()`.\n */\n\nimport { defineConfig, type Plugin } from 'vitest/config';\nimport { fileURLToPath } from 'node:url';\nimport { 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 Plugin[];\n /**\n * Extra resolver entries for the web project only.\n */\n readonly aliases?: readonly VitestAlias[];\n}\n\n/**\n * What `defineRepoVitestConfig` accepts.\n */\nexport interface RepoVitestConfigOptions {\n /**\n * The consuming repo's npm scope, e.g. `'@myapp'`.\n */\n readonly scope: string;\n /**\n * Workspace package directory names. Defaults to the family superset.\n */\n readonly packages?: readonly string[];\n /**\n * Which `cloudflare:*` mocks to alias. Defaults to workers/sockets/workflows.\n */\n readonly mocks?: readonly string[];\n /**\n * The repo root, as a file URL.\n */\n readonly root?: string;\n /**\n * Extra resolver entries applied to *both* projects (e.g. the `hono`\n * dedupe). Per-project extras go on `backend.aliases` / `web.aliases`.\n */\n readonly aliases?: readonly VitestAlias[];\n /**\n * Resolver `noExternal` patterns, merged after {@link KIT_NO_EXTERNAL}.\n */\n readonly noExternal?: readonly (string | RegExp)[];\n /**\n * The backend half. Omitted fields take the `defineUnitVitestConfig`\n * defaults.\n */\n readonly backend?: RepoBackendOptions;\n /**\n * The SPA half. Omitted fields take the `defineWebVitestConfig` defaults.\n */\n readonly web?: RepoWebOptions;\n /**\n * Coverage `include` globs. Defaults to the worker, the SPA and every\n * workspace package's `src`.\n */\n readonly coverageInclude?: readonly string[];\n /**\n * Coverage `exclude` globs, merged with the canonical set.\n */\n readonly coverageExclude?: readonly string[];\n /**\n * 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: [...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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AY,CAAE,GAAGA,CAAU,CAAE,IAGpE,CACH,CA5EgBW,EAAAd,EAAA",
|
|
6
|
+
"names": ["defineConfig", "fileURLToPath", "manifestCoverageThresholds", "DEFAULT_CLOUDFLARE_MOCKS", "DEFAULT_WORKSPACE_PACKAGES", "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.d.ts
CHANGED
|
@@ -136,7 +136,8 @@ export interface UnitVitestConfigOptions {
|
|
|
136
136
|
*/
|
|
137
137
|
readonly includeIndexBarrels?: boolean;
|
|
138
138
|
/**
|
|
139
|
-
* Coverage floors.
|
|
139
|
+
* Coverage floors. Defaults to the manifest's `quality.coverage` (`.rexezuge.jsonc`
|
|
140
|
+
* at `root`); without one, no floor.
|
|
140
141
|
*/
|
|
141
142
|
readonly thresholds?: CoverageThresholds;
|
|
142
143
|
/**
|
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,YAAY,EAAE,KAAK,MAAM,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"vitest.d.ts","sourceRoot":"","sources":["../src/vitest.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AAEH,OAAO,EAAE,YAAY,EAAE,KAAK,MAAM,EAAE,MAAM,eAAe,CAAC;AAG1D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAEvD,YAAY,EAAE,WA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AAQ,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
|
|
1
|
+
var i=Object.defineProperty;var r=(e,s)=>i(e,"name",{value:s,configurable:!0});import{defineConfig as u}from"vitest/config";import{manifestCoverageThresholds as o}from"./manifest.js";import{DEFAULT_CLOUDFLARE_MOCKS as E,DEFAULT_WORKSPACE_PACKAGES as f,KIT_DEDUPE as g,KIT_NO_EXTERNAL as p,workspaceAliases as v}from"./vitest-aliases.js";import{KIT_DEDUPE as F,KIT_NO_EXTERNAL as R}from"./vitest-aliases.js";const x=["test/web/**","test/**/web-*.test.{ts,tsx}","apps/web/**/*.test.{ts,tsx}"],n=["scripts/**","**/*.test.ts","**/*.test.tsx","**/*.d.ts","**/index.ts","**/types.d.ts","**/model/**","**/generated/**","**/D1Types.ts","**/ServiceEnv.ts","**/env.d.ts"],m="**/index.ts";function A(e){return[...e.includeIndexBarrels?n.filter(t=>t!==m):n,...e.coverageExclude??[]]}r(A,"coverageExcludeFor");function I(e={}){const s=e.root??new URL(".",import.meta.url).href,t=e.thresholds??o(s),d=e.coverageInclude??["apps/api/src/**/*.ts","apps/background/src/**/*.ts","packages/**/src/**/*.ts"],l=A(e),a=[...v({scope:e.scope??"@unused",root:s,packages:e.scope===void 0?[]:e.packages??f,mocks:e.mocks??E}).filter(c=>typeof c.find!="string"||!c.find.startsWith("@unused")),...e.aliases??[]];return u({...e.plugins!==void 0&&{plugins:[...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/**",...x]],...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(I,"defineUnitVitestConfig");export{F as KIT_DEDUPE,R as KIT_NO_EXTERNAL,I 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, type Plugin } from 'vitest/config';\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 Plugin[];\n /**\n * Setup files run before each test file (e.g. AWS's floci guard, Meow's\n * backend/web setups).\n */\n readonly setupFiles?: readonly string[];\n /**\n * Coverage `include` globs. Defaults to the worker plus every workspace\n * package's `src`.\n */\n readonly coverageInclude?: readonly string[];\n /**\n * Coverage `exclude` globs, merged with the canonical set.\n */\n readonly coverageExclude?: readonly string[];\n /**\n * 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. Omitted by default; a repo that wants them sets them.\n */\n readonly thresholds?: CoverageThresholds;\n /**\n * Where the coverage report is written.\n */\n readonly reportsDirectory?: string;\n}\n\n/**\n * The SPA's suites, excluded here so the two configs partition the suite.\n *\n * Every shape the family uses: the `test/web/**` directory convention\n * (CalDAV-Bridge, Mail-Meow), the root-suite `web-*` naming convention\n * (Durable-DAV-Router), and suites bundled under `apps/web` (Mail-Otter).\n * `defineWebVitestConfig()` includes the same globs, so a file is collected by\n * exactly one config.\n */\nconst SPA_FILES: readonly string[] = ['test/web/**', 'test/**/web-*.test.{ts,tsx}', 'apps/web/**/*.test.{ts,tsx}'];\n\n/**\n * Coverage `exclude` globs converged from the source repos.\n *\n * The categories: build and test tooling (`scripts/` grows with project surface,\n * not complexity, and the god-file guard excludes it for the same reason), test\n * files, declarations, re-export barrels (`index.ts` carries no logic of its\n * own), model records, generated files (the SPA shell is a one-line HTML blob\n * with no logic to exercise), and type-only modules.\n */\nconst CANONICAL_COVERAGE_EXCLUDE: readonly string[] = [\n 'scripts/**',\n '**/*.test.ts',\n '**/*.test.tsx',\n '**/*.d.ts',\n '**/index.ts',\n '**/types.d.ts',\n '**/model/**',\n '**/generated/**',\n '**/D1Types.ts',\n '**/ServiceEnv.ts',\n '**/env.d.ts',\n];\n\n/**\n * 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 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: [...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 ...(options.thresholds !== undefined && { thresholds: { ...options.thresholds } }),\n },\n },\n });\n}\n"],
|
|
5
|
-
"mappings": "+EAmCA,OAAS,gBAAAA,MAAiC,gBAC1C,OAAS,4BAAAC,EAA0B,8BAAAC,EAA4B,cAAAC,EAAY,mBAAAC,EAAiB,oBAAAC,MAAwB,sBAUpH,OAAS,cAAAF,EAAY,mBAAAC,MAAuB,
|
|
6
|
-
"names": ["defineConfig", "DEFAULT_CLOUDFLARE_MOCKS", "DEFAULT_WORKSPACE_PACKAGES", "KIT_DEDUPE", "KIT_NO_EXTERNAL", "workspaceAliases", "SPA_FILES", "CANONICAL_COVERAGE_EXCLUDE", "INDEX_BARREL_EXCLUDE", "coverageExcludeFor", "options", "glob", "__name", "defineUnitVitestConfig", "root", "coverageInclude", "coverageExclude", "aliases", "alias"]
|
|
4
|
+
"sourcesContent": ["/**\n * The unit-test Vitest config for the worker-and-packages half of the suite.\n *\n * Provenance: converged from all nine repos' `vitest.config.mts`. The coverage\n * block is Durable-DAV-Router's (the most complete: v8 provider, explicit\n * include/exclude patterns, thresholds with the reasoning for why they sit just\n * under the measured value); the alias block is the union of Durable-DAV's\n * `cloudflare:*` mocks, every repo's `@scope/* → src` workspace table, and the\n * shared `@/` + `~/` prefixes — see {@link ./vitest-aliases.js}.\n *\n * Canonical decisions:\n *\n * 1. **Every file matching `include` is reported** — Vitest 4 removed\n * `coverage.all`, and an explicit `include` now covers files no test\n * imported. That is the behaviour the source repos configured `all: true` for,\n * and the reason it mattered: without it a brand-new module with no test is\n * invisible rather than counted as zero, which is the exact regression this\n * gate exists to catch.\n * 2. **The SPA is excluded here**, so this config and `defineWebVitestConfig()`\n * partition the suite rather than each running all of it. The default covers\n * every suite shape the family uses (`test/web/**`, `test/**/web-*`,\n * `apps/web/**`); see `defineRepoVitestConfig()` for the single-file\n * `projects` composition the AWS/Mail-Meow/CalDAV repos use.\n * 3. **A custom `exclude` re-lists `node_modules`** — `test/` is a workspace\n * project and therefore has its own, so without the re-list the glob reaches\n * into `test/node_modules` and tries to run other packages' suites.\n * 4. **Thresholds are a consumer argument**, not a kit default. A floor is a\n * per-repo ratchet measured against that repo's suite; the kit cannot know a\n * number, and guessing one is how floors get lowered.\n * 5. **`@rexezuge/*` is never externalized** — see `KIT_NO_EXTERNAL`: the kit\n * ships ESM `dist/` with bundler-style extensionless imports, which Node's\n * resolver refuses, so the kit stays inside Vite's pipeline (the same\n * resolver that bundles the worker).\n */\n\nimport { defineConfig, type Plugin } from 'vitest/config';\nimport { 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 Plugin[];\n /**\n * Setup files run before each test file (e.g. AWS's floci guard, Meow's\n * backend/web setups).\n */\n readonly setupFiles?: readonly string[];\n /**\n * Coverage `include` globs. Defaults to the worker plus every workspace\n * package's `src`.\n */\n readonly coverageInclude?: readonly string[];\n /**\n * Coverage `exclude` globs, merged with the canonical set.\n */\n readonly coverageExclude?: readonly string[];\n /**\n * 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: [...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,MAAiC,gBAC1C,OAAS,8BAAAC,MAAkC,gBAC3C,OAAS,4BAAAC,EAA0B,8BAAAC,EAA4B,cAAAC,EAAY,mBAAAC,EAAiB,oBAAAC,MAAwB,sBAUpH,OAAS,cAAAF,EAAY,mBAAAC,MAAuB,sBA0H5C,MAAME,EAA+B,CAAC,cAAe,8BAA+B,6BAA6B,EAW3GC,EAAgD,CACpD,aACA,eACA,gBACA,YACA,cACA,gBACA,cACA,kBACA,gBACA,mBACA,eAMIC,EAAuB,cAM7B,SAASC,EAAmBC,EAA+E,CAIzG,MAAO,CAAC,GAHUA,EAAQ,oBACtBH,EAA2B,OAAQI,GAASA,IAASH,CAAoB,EACzED,EACkB,GAAIG,EAAQ,iBAAmB,CAAA,CAAG,CAC1D,CALSE,EAAAH,EAAA,sBAmBH,SAAUI,EAAuBH,EAAmC,CAAA,EAAE,CAC1E,MAAMI,EAAOJ,EAAQ,MAAQ,IAAI,IAAI,IAAK,YAAY,GAAG,EAAE,KACrDK,EAAaL,EAAQ,YAAcV,EAA2Bc,CAAI,EAClEE,EAAkBN,EAAQ,iBAAmB,CAAC,uBAAwB,8BAA+B,yBAAyB,EAC9HO,EAAkBR,EAAmBC,CAAO,EAS5CQ,EAAU,CACd,GATkBb,EAAiB,CACnC,MAAOK,EAAQ,OAAS,UACxB,KAAAI,EACA,SAAUJ,EAAQ,QAAU,OAAY,CAAA,EAAMA,EAAQ,UAAYR,EAClE,MAAOQ,EAAQ,OAAST,EACzB,EAIgB,OAAQkB,GAAU,OAAOA,EAAM,MAAS,UAAY,CAACA,EAAM,KAAK,WAAW,SAAS,CAAC,EACpG,GAAIT,EAAQ,SAAW,CAAA,GAGzB,OAAOX,EAAa,CAClB,GAAIW,EAAQ,UAAY,QAAa,CAAE,QAAS,CAAC,GAAGA,EAAQ,OAAO,CAAC,EACpE,QAAS,CACP,MAAOQ,EACP,WAAY,CAAC,GAAGd,EAAiB,GAAIM,EAAQ,YAAc,CAAA,CAAG,EAS9D,OAAQ,CAAC,GAAGP,CAAU,GAExB,KAAM,CACJ,QAAS,GACT,YAAa,OACb,QAAS,CAAC,GAAIO,EAAQ,SAAW,CAAC,yBAAyB,CAAE,EAG7D,QAAS,CAAC,GAAIA,EAAQ,SAAW,CAAC,qBAAsB,aAAc,sBAAuB,GAAGJ,CAAS,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", "manifestCoverageThresholds", "DEFAULT_CLOUDFLARE_MOCKS", "DEFAULT_WORKSPACE_PACKAGES", "KIT_DEDUPE", "KIT_NO_EXTERNAL", "workspaceAliases", "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.13.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -16,6 +16,14 @@
|
|
|
16
16
|
"types": "./dist/index.d.ts",
|
|
17
17
|
"default": "./dist/index.js"
|
|
18
18
|
},
|
|
19
|
+
"./manifest.schema.json": "./schema/manifest.schema.json",
|
|
20
|
+
"./tsconfig/base.json": "./presets/tsconfig/base.json",
|
|
21
|
+
"./tsconfig/worker.json": "./presets/tsconfig/worker.json",
|
|
22
|
+
"./tsconfig/web.json": "./presets/tsconfig/web.json",
|
|
23
|
+
"./prettier": {
|
|
24
|
+
"types": "./presets/prettier.d.mts",
|
|
25
|
+
"default": "./presets/prettier.mjs"
|
|
26
|
+
},
|
|
19
27
|
"./*": {
|
|
20
28
|
"types": "./dist/*.d.ts",
|
|
21
29
|
"default": "./dist/*.js"
|
|
@@ -35,10 +43,13 @@
|
|
|
35
43
|
},
|
|
36
44
|
"files": [
|
|
37
45
|
"dist",
|
|
38
|
-
"src"
|
|
46
|
+
"src",
|
|
47
|
+
"schema",
|
|
48
|
+
"presets"
|
|
39
49
|
],
|
|
40
50
|
"dependencies": {
|
|
41
|
-
"@rexezuge/d1": "1.
|
|
51
|
+
"@rexezuge/d1": "1.13.0",
|
|
52
|
+
"@rexezuge/testing": "1.13.0"
|
|
42
53
|
},
|
|
43
54
|
"peerDependencies": {
|
|
44
55
|
"eslint": "^10.0.0",
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The family's Prettier config: the identical `.prettierrc` every repo carried.
|
|
3
|
+
* Use it from `package.json`: `"prettier": "@rexezuge/tooling/prettier"`.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
@type {import('prettier').Config}
|
|
8
|
+
*/
|
|
9
|
+
const config = {
|
|
10
|
+
printWidth: 140,
|
|
11
|
+
singleQuote: true,
|
|
12
|
+
semi: true,
|
|
13
|
+
useTabs: false,
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export default config;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json.schemastore.org/tsconfig",
|
|
3
|
+
"display": "Rexezuge family: base",
|
|
4
|
+
"compilerOptions": {
|
|
5
|
+
"target": "ES2022",
|
|
6
|
+
"lib": ["ES2022", "DOM"],
|
|
7
|
+
"module": "ES2022",
|
|
8
|
+
"moduleResolution": "Bundler",
|
|
9
|
+
"resolveJsonModule": true,
|
|
10
|
+
"allowJs": false,
|
|
11
|
+
"checkJs": false,
|
|
12
|
+
"noEmit": true,
|
|
13
|
+
"isolatedModules": true,
|
|
14
|
+
"allowSyntheticDefaultImports": true,
|
|
15
|
+
"forceConsistentCasingInFileNames": true,
|
|
16
|
+
"strict": true,
|
|
17
|
+
"skipLibCheck": true
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
3
|
+
"$id": "https://unpkg.com/@rexezuge/tooling/schema/manifest.schema.json",
|
|
4
|
+
"title": "Rexezuge family manifest (.rexezuge.jsonc)",
|
|
5
|
+
"type": "object",
|
|
6
|
+
"additionalProperties": false,
|
|
7
|
+
"required": ["name", "scope"],
|
|
8
|
+
"properties": {
|
|
9
|
+
"$schema": { "type": "string" },
|
|
10
|
+
"name": { "type": "string", "minLength": 1, "description": "The repository's name." },
|
|
11
|
+
"scope": { "type": "string", "pattern": "^@[a-z0-9][a-z0-9-]*$", "description": "The repo's npm scope, e.g. \"@mail-meow\"." },
|
|
12
|
+
"features": {
|
|
13
|
+
"type": "object",
|
|
14
|
+
"additionalProperties": false,
|
|
15
|
+
"description": "Platform features the repo uses; tooling enables the matching scripts and checks.",
|
|
16
|
+
"properties": {
|
|
17
|
+
"d1": {
|
|
18
|
+
"type": "object",
|
|
19
|
+
"additionalProperties": false,
|
|
20
|
+
"required": ["binding", "database"],
|
|
21
|
+
"properties": {
|
|
22
|
+
"binding": { "type": "string", "pattern": "^[A-Z][A-Z0-9_]*$" },
|
|
23
|
+
"database": { "type": "string", "minLength": 1 },
|
|
24
|
+
"migrationsDir": { "type": "string", "minLength": 1 }
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
"web": {
|
|
28
|
+
"type": "object",
|
|
29
|
+
"additionalProperties": false,
|
|
30
|
+
"required": ["pages", "spaShell"],
|
|
31
|
+
"properties": { "pages": { "type": "boolean" }, "spaShell": { "type": "boolean" } }
|
|
32
|
+
},
|
|
33
|
+
"background": { "type": "boolean" },
|
|
34
|
+
"backupD1": { "type": "boolean" },
|
|
35
|
+
"durableObjects": { "type": "array", "items": { "type": "string", "minLength": 1 }, "description": "Durable Object class names." },
|
|
36
|
+
"queues": { "type": "array", "items": { "type": "string", "minLength": 1 }, "description": "Queue names." },
|
|
37
|
+
"workflows": { "type": "array", "items": { "type": "string", "minLength": 1 }, "description": "Workflow class names." },
|
|
38
|
+
"email": { "type": "boolean" },
|
|
39
|
+
"android": { "type": "boolean" }
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
"layers": {
|
|
43
|
+
"type": "array",
|
|
44
|
+
"description": "The repo's dependency layering. Anything a layer does not list in mayImport/typeOnly is banned by lint.",
|
|
45
|
+
"items": {
|
|
46
|
+
"type": "object",
|
|
47
|
+
"additionalProperties": false,
|
|
48
|
+
"required": ["name", "dir", "mayImport"],
|
|
49
|
+
"properties": {
|
|
50
|
+
"name": { "type": "string", "pattern": "^[a-z][a-z0-9-]*$" },
|
|
51
|
+
"dir": { "type": "string", "minLength": 1, "pattern": "^[^*?{}/][^*?{}]*$", "description": "Repo-relative directory, no globs." },
|
|
52
|
+
"package": { "type": "string", "minLength": 1, "description": "Package suffix when it is not the directory's basename." },
|
|
53
|
+
"mayImport": {
|
|
54
|
+
"type": "array",
|
|
55
|
+
"items": { "type": "string" },
|
|
56
|
+
"description": "Layer names this layer may import. [] isolates it from the whole scope."
|
|
57
|
+
},
|
|
58
|
+
"typeOnly": { "type": "array", "items": { "type": "string" }, "description": "Layer names importable as `import type` only." },
|
|
59
|
+
"forbid": {
|
|
60
|
+
"type": "array",
|
|
61
|
+
"items": { "type": "string", "minLength": 1 },
|
|
62
|
+
"description": "Extra external specifiers this layer may not import."
|
|
63
|
+
},
|
|
64
|
+
"forbidMessage": { "type": "string", "minLength": 1 },
|
|
65
|
+
"http": { "type": "boolean", "description": "May import hono/chanfana and build error envelopes (the http layer)." },
|
|
66
|
+
"browser": { "type": "boolean", "description": "Browser code: console allowed, browser globals." }
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
},
|
|
70
|
+
"quality": {
|
|
71
|
+
"type": "object",
|
|
72
|
+
"additionalProperties": false,
|
|
73
|
+
"properties": {
|
|
74
|
+
"coverage": {
|
|
75
|
+
"type": "object",
|
|
76
|
+
"additionalProperties": false,
|
|
77
|
+
"required": ["lines", "branches", "functions", "statements"],
|
|
78
|
+
"description": "Default coverage floor for the vitest factories.",
|
|
79
|
+
"properties": {
|
|
80
|
+
"lines": { "type": "number", "minimum": 0, "maximum": 100 },
|
|
81
|
+
"branches": { "type": "number", "minimum": 0, "maximum": 100 },
|
|
82
|
+
"functions": { "type": "number", "minimum": 0, "maximum": 100 },
|
|
83
|
+
"statements": { "type": "number", "minimum": 0, "maximum": 100 }
|
|
84
|
+
}
|
|
85
|
+
},
|
|
86
|
+
"godFiles": {
|
|
87
|
+
"type": "object",
|
|
88
|
+
"additionalProperties": false,
|
|
89
|
+
"required": ["soft", "hard"],
|
|
90
|
+
"description": "God-file limits. They may only be lowered below the family 300/400.",
|
|
91
|
+
"properties": {
|
|
92
|
+
"soft": { "type": "integer", "minimum": 1, "maximum": 300 },
|
|
93
|
+
"hard": { "type": "integer", "minimum": 1, "maximum": 400 }
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
},
|
|
98
|
+
"extensions": {
|
|
99
|
+
"type": "object",
|
|
100
|
+
"description": "The open side: repo-specific settings, one object per owner namespace. The kit never reads it.",
|
|
101
|
+
"propertyNames": { "pattern": "^[a-z][a-z0-9-]*$" },
|
|
102
|
+
"additionalProperties": { "type": "object" }
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import type { FamilyManifest, ManifestLayer } from './manifest.ts';
|
|
2
|
+
import type { LayerBan } from './eslint-boundaries.ts';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Turn a manifest's `layers` into the {@link LayerBan} rows the boundary rules
|
|
6
|
+
* consume, so the manifest replaces the kit's canonical (consumer-shaped) table
|
|
7
|
+
* rather than adding a second mechanism.
|
|
8
|
+
*
|
|
9
|
+
* A layer's package is `<scope>/<basename of dir>` unless `package` says
|
|
10
|
+
* otherwise. Every layer it does not list in `mayImport` or `typeOnly` is banned;
|
|
11
|
+
* `mayImport: []` bans the whole scope, so an isolated layer (the SPA) also
|
|
12
|
+
* refuses packages the manifest never declared. `typeOnly` layers become a second
|
|
13
|
+
* row with `allowTypeImports`, because the two carry different messages.
|
|
14
|
+
*/
|
|
15
|
+
export function manifestLayerBans(manifest: FamilyManifest): LayerBan[] {
|
|
16
|
+
const layers = manifest.layers ?? [];
|
|
17
|
+
const scope = manifest.scope;
|
|
18
|
+
const pkg = (layer: ManifestLayer): string => `${scope}/${layer.package ?? layer.dir.split('/').at(-1) ?? layer.dir}`;
|
|
19
|
+
const byName = new Map(layers.map((layer) => [layer.name, layer]));
|
|
20
|
+
const bans: LayerBan[] = [];
|
|
21
|
+
for (const layer of layers) {
|
|
22
|
+
const allowed = new Set([layer.name, ...layer.mayImport, ...(layer.typeOnly ?? [])]);
|
|
23
|
+
if (layer.mayImport.length === 0 && (layer.typeOnly ?? []).length === 0) {
|
|
24
|
+
bans.push({
|
|
25
|
+
dir: layer.dir,
|
|
26
|
+
ban: [`${scope}/*`],
|
|
27
|
+
message: `${layer.name} may not import any ${scope} package (.rexezuge.jsonc layers: mayImport is empty)`,
|
|
28
|
+
});
|
|
29
|
+
} else {
|
|
30
|
+
const banned = layers.filter((other) => !allowed.has(other.name)).map(pkg);
|
|
31
|
+
if (banned.length > 0) {
|
|
32
|
+
bans.push({
|
|
33
|
+
dir: layer.dir,
|
|
34
|
+
ban: banned,
|
|
35
|
+
message: `${layer.name} may only import ${layer.mayImport.join(', ') || 'nothing'} (.rexezuge.jsonc layers)`,
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
const typeOnly = (layer.typeOnly ?? []).flatMap((name) => byName.get(name) ?? []).map(pkg);
|
|
40
|
+
if (typeOnly.length > 0) {
|
|
41
|
+
bans.push({
|
|
42
|
+
dir: layer.dir,
|
|
43
|
+
ban: typeOnly,
|
|
44
|
+
allowTypeImports: true,
|
|
45
|
+
message: `${layer.name} may import ${(layer.typeOnly ?? []).join(', ')} as types only (.rexezuge.jsonc layers)`,
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
if (layer.forbid && layer.forbid.length > 0) {
|
|
49
|
+
bans.push({ dir: layer.dir, ban: layer.forbid, message: layer.forbidMessage ?? `${layer.name} may not import this package` });
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
return bans;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
Directories declared `http: true`, plus `apps/api` which is the http layer by definition.
|
|
57
|
+
*/
|
|
58
|
+
export function manifestHttpDirs(manifest: FamilyManifest | null): string[] {
|
|
59
|
+
return (manifest?.layers ?? []).filter((layer) => layer.http === true).map((layer) => layer.dir);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Browser directories: layers declared `browser: true`, or `apps/web` when the
|
|
64
|
+
* manifest declares the web feature. Without a manifest, `apps/web` (the
|
|
65
|
+
* long-standing default).
|
|
66
|
+
*/
|
|
67
|
+
export function manifestBrowserDirs(manifest: FamilyManifest | null): string[] {
|
|
68
|
+
if (manifest === null) return ['apps/web'];
|
|
69
|
+
const declared = (manifest.layers ?? []).filter((layer) => layer.browser === true).map((layer) => layer.dir);
|
|
70
|
+
return manifest.features?.web ? [...new Set(['apps/web', ...declared])] : declared;
|
|
71
|
+
}
|