@rexezuge/tooling 1.8.2 → 1.9.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.
@@ -128,6 +128,11 @@ export interface RepoVitestConfigOptions {
128
128
  * Coverage `exclude` globs, merged with the canonical set.
129
129
  */
130
130
  readonly coverageExclude?: readonly string[];
131
+ /**
132
+ * Report coverage for `index.ts` re-export barrels. See
133
+ * `defineUnitVitestConfig`'s option of the same name.
134
+ */
135
+ readonly includeIndexBarrels?: boolean;
131
136
  /**
132
137
  * Coverage floors. Omitted by default; a repo that wants them sets them.
133
138
  */
@@ -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;AAG1D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAEtD;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC;;;OAGG;IACH,QAAQ,CAAC,OAAO,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACrC;;OAEG;IACH,QAAQ,CAAC,OAAO,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACrC;;OAEG;IACH,QAAQ,CAAC,UAAU,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACxC;;OAEG;IACH,QAAQ,CAAC,gBAAgB,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAC9C;;OAEG;IACH,QAAQ,CAAC,OAAO,CAAC,EAAE,SAAS,WAAW,EAAE,CAAC;CAC3C;AAED;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B;;;OAGG;IACH,QAAQ,CAAC,WAAW,CAAC,EAAE,OAAO,GAAG,WAAW,CAAC;IAC7C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m(e,"name",{value:r,configurable:!0});import{defineConfig as b}from"vitest/config";import{fileURLToPath as f}from"node:url";import{DEFAULT_CLOUDFLARE_MOCKS as E,DEFAULT_WORKSPACE_PACKAGES as g,KIT_NO_EXTERNAL as x,workspaceAliases as i}from"./vitest-aliases.js";const v=["**/node_modules/**","**/dist/**","test/integration/**","test/web/**","test/**/web-*.test.{ts,tsx}","apps/web/**/*.test.{ts,tsx}"],w=["test/web/**/*.test.{ts,tsx}","test/**/web-*.test.{ts,tsx}","apps/web/**/*.test.{ts,tsx}"],A=["scripts/**","**/*.test.ts","**/*.test.tsx","**/*.d.ts","**/index.ts","**/types.d.ts","**/types.ts","**/model/**","**/generated/**","**/D1Types.ts","**/ServiceEnv.ts","**/env.d.ts"];function D(e){const r=e.root??new URL(".",import.meta.url).href,n=e.packages??g,c=e.mocks??E,l=[...x,...e.noExternal??[]],t=e.backend??{},s=e.web??{},o=[...i({scope:e.scope,root:r,packages:n,mocks:c}),...e.aliases??[],...t.aliases??[]],a=f(new URL("apps/web/src",r)),p=[{find:/^@\//,replacement:`${a}/`},{find:/^~\//,replacement:`${a}/`},...i({scope:e.scope,root:r,packages:n,mocks:c}).filter(u=>typeof u.find=="string"),...e.aliases??[],...s.aliases??[]];return b({test:{projects:[{resolve:{alias:o,noExternal:l},test:{name:"backend",globals:!0,environment:"node",include:[...t.include??["test/**/*.test.{ts,tsx}"]],exclude:[...t.exclude??v],...t.setupFiles!==void 0&&{setupFiles:[...t.setupFiles]},server:{deps:{inline:[...t.serverDepsInline??["dofs"]]}}}},{...s.plugins!==void 0&&{plugins:[...s.plugins]},resolve:{alias:p,noExternal:l},test:{name:"web",globals:!0,environment:s.environment??"jsdom",include:[...s.include??w],exclude:[...s.exclude??["**/node_modules/**","**/dist/**","test/integration/**"]],pool:"threads",...s.setupFiles!==void 0&&{setupFiles:[...s.setupFiles]}}}],coverage:{provider:"v8",reporter:["text","lcov","html"],reportsDirectory:e.reportsDirectory??"./coverage",include:[...e.coverageInclude??["apps/api/src/**/*.ts","apps/background/src/**/*.ts","apps/web/src/**/*.{ts,tsx}","packages/**/src/**/*.ts"]],exclude:[...A,...e.coverageExclude??[]],...e.thresholds!==void 0&&{thresholds:{...e.thresholds}}}}})}d(D,"defineRepoVitestConfig");export{D as defineRepoVitestConfig};
1
+ var m=Object.defineProperty;var i=(e,r)=>m(e,"name",{value:r,configurable:!0});import{defineConfig as x}from"vitest/config";import{fileURLToPath as f}from"node:url";import{DEFAULT_CLOUDFLARE_MOCKS as b,DEFAULT_WORKSPACE_PACKAGES as g,KIT_NO_EXTERNAL as v,workspaceAliases as o}from"./vitest-aliases.js";const w=["**/node_modules/**","**/dist/**","test/integration/**","test/web/**","test/**/web-*.test.{ts,tsx}","apps/web/**/*.test.{ts,tsx}"],A=["test/web/**/*.test.{ts,tsx}","test/**/web-*.test.{ts,tsx}","apps/web/**/*.test.{ts,tsx}"],p=["scripts/**","**/*.test.ts","**/*.test.tsx","**/*.d.ts","**/index.ts","**/types.d.ts","**/types.ts","**/model/**","**/generated/**","**/D1Types.ts","**/ServiceEnv.ts","**/env.d.ts"],C="**/index.ts";function h(e){const r=e.root??new URL(".",import.meta.url).href,c=e.packages??g,l=e.mocks??b,d=[...v,...e.noExternal??[]],t=e.backend??{},s=e.web??{},u=[...o({scope:e.scope,root:r,packages:c,mocks:l}),...e.aliases??[],...t.aliases??[]],a=f(new URL("apps/web/src",r)),E=[{find:/^@\//,replacement:`${a}/`},{find:/^~\//,replacement:`${a}/`},...o({scope:e.scope,root:r,packages:c,mocks:l}).filter(n=>typeof n.find=="string"),...e.aliases??[],...s.aliases??[]];return x({test:{projects:[{resolve:{alias:u,noExternal:d},test:{name:"backend",globals:!0,environment:"node",include:[...t.include??["test/**/*.test.{ts,tsx}"]],exclude:[...t.exclude??w],...t.setupFiles!==void 0&&{setupFiles:[...t.setupFiles]},server:{deps:{inline:[...t.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??A],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?[...p.filter(n=>n!==C),...e.coverageExclude??[]]:[...p,...e.coverageExclude??[]],...e.thresholds!==void 0&&{thresholds:{...e.thresholds}}}}})}i(h,"defineRepoVitestConfig");export{h as defineRepoVitestConfig};
@@ -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 * Coverage floors. Omitted by default; a repo that wants them sets them.\n */\n readonly thresholds?: CoverageThresholds;\n /**\n * Where the coverage report is written.\n */\n readonly reportsDirectory?: string;\n}\n\n/**\n * Backend suites excluded from the backend project: the SPA shapes live in the\n * web project, and integration is its own config.\n */\nconst BACKEND_EXCLUDE: readonly string[] = [\n '**/node_modules/**',\n '**/dist/**',\n 'test/integration/**',\n 'test/web/**',\n 'test/**/web-*.test.{ts,tsx}',\n 'apps/web/**/*.test.{ts,tsx}',\n];\n\n/**\n * SPA suite shapes collected by the web project.\n */\nconst WEB_INCLUDE: readonly string[] = ['test/web/**/*.test.{ts,tsx}', 'test/**/web-*.test.{ts,tsx}', 'apps/web/**/*.test.{ts,tsx}'];\n\n/**\n * Coverage `exclude`: the union of the unit and web halves' canonical sets.\n */\nconst CANONICAL_COVERAGE_EXCLUDE: readonly string[] = [\n 'scripts/**',\n '**/*.test.ts',\n '**/*.test.tsx',\n '**/*.d.ts',\n '**/index.ts',\n '**/types.d.ts',\n '**/types.ts',\n '**/model/**',\n '**/generated/**',\n '**/D1Types.ts',\n '**/ServiceEnv.ts',\n '**/env.d.ts',\n];\n\n/**\n * Build the single-file `projects` config.\n *\n * ```ts\n * // vitest.config.mts\n * import { defineRepoVitestConfig } from '@rexezuge/tooling/vitest-repo';\n * export default defineRepoVitestConfig({\n * scope: '@myapp',\n * web: { environment: 'happy-dom' },\n * thresholds: { statements: 87, branches: 77, functions: 88, lines: 90 },\n * });\n * ```\n */\nexport function defineRepoVitestConfig(options: RepoVitestConfigOptions): ReturnType<typeof defineConfig> {\n const root = options.root ?? new URL('.', import.meta.url).href;\n const packages = options.packages ?? DEFAULT_WORKSPACE_PACKAGES;\n const mocks = options.mocks ?? DEFAULT_CLOUDFLARE_MOCKS;\n const noExternal = [...KIT_NO_EXTERNAL, ...(options.noExternal ?? [])];\n const backend = options.backend ?? {};\n const web = options.web ?? {};\n\n const backendAliases = [\n ...workspaceAliases({ scope: options.scope, root, packages, mocks }),\n ...(options.aliases ?? []),\n ...(backend.aliases ?? []),\n ];\n // `@/` means the SPA in the web project (Mail-Otter's SPA source imports\n // through it); the workspace table's `@/` → API entry is dropped and the\n // SPA's own prepended. `~/` → SPA either way.\n const webSrc = fileURLToPath(new URL('apps/web/src', root));\n const webAliases: VitestAlias[] = [\n { find: /^@\\//, replacement: `${webSrc}/` },\n { find: /^~\\//, replacement: `${webSrc}/` },\n // Drop the workspace table's `@/`/`~/` (RegExp) entries — the SPA's own\n // prepended above win — and keep the `@scope/*` + `cloudflare:*` strings.\n ...workspaceAliases({ scope: options.scope, root, packages, mocks }).filter((alias) => typeof alias.find === 'string'),\n ...(options.aliases ?? []),\n ...(web.aliases ?? []),\n ];\n\n return defineConfig({\n test: {\n projects: [\n {\n resolve: { alias: backendAliases, noExternal },\n test: {\n name: 'backend',\n globals: true,\n environment: 'node',\n include: [...(backend.include ?? ['test/**/*.test.{ts,tsx}'])],\n exclude: [...(backend.exclude ?? BACKEND_EXCLUDE)],\n ...(backend.setupFiles !== undefined && { setupFiles: [...backend.setupFiles] }),\n server: { deps: { inline: [...(backend.serverDepsInline ?? ['dofs'])] } },\n },\n },\n {\n ...(web.plugins !== undefined && { plugins: [...web.plugins] }),\n resolve: { alias: webAliases, noExternal },\n test: {\n name: 'web',\n globals: true,\n environment: web.environment ?? 'jsdom',\n include: [...(web.include ?? WEB_INCLUDE)],\n exclude: [...(web.exclude ?? ['**/node_modules/**', '**/dist/**', 'test/integration/**'])],\n pool: 'threads',\n ...(web.setupFiles !== undefined && { setupFiles: [...web.setupFiles] }),\n },\n },\n ],\n coverage: {\n provider: 'v8',\n reporter: ['text', 'lcov', 'html'],\n reportsDirectory: options.reportsDirectory ?? './coverage',\n include: [\n ...(options.coverageInclude ?? [\n 'apps/api/src/**/*.ts',\n 'apps/background/src/**/*.ts',\n 'apps/web/src/**/*.{ts,tsx}',\n 'packages/**/src/**/*.ts',\n ]),\n ],\n exclude: [...CANONICAL_COVERAGE_EXCLUDE, ...(options.coverageExclude ?? [])],\n ...(options.thresholds !== undefined && { thresholds: { ...options.thresholds } }),\n },\n },\n });\n}\n"],
5
- "mappings": "+EAyBA,OAAS,gBAAAA,MAAiC,gBAC1C,OAAS,iBAAAC,MAAqB,WAC9B,OAAS,4BAAAC,EAA0B,8BAAAC,EAA4B,mBAAAC,EAAiB,oBAAAC,MAAwB,sBA2HxG,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,eAgBI,SAAUC,EAAuBC,EAAgC,CACrE,MAAMC,EAAOD,EAAQ,MAAQ,IAAI,IAAI,IAAK,YAAY,GAAG,EAAE,KACrDE,EAAWF,EAAQ,UAAYP,EAC/BU,EAAQH,EAAQ,OAASR,EACzBY,EAAa,CAAC,GAAGV,EAAiB,GAAIM,EAAQ,YAAc,CAAA,CAAG,EAC/DK,EAAUL,EAAQ,SAAW,CAAA,EAC7BM,EAAMN,EAAQ,KAAO,CAAA,EAErBO,EAAiB,CACrB,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,aAAc,qBAAqB,CAAE,EACzF,KAAM,UACN,GAAIA,EAAI,aAAe,QAAa,CAAE,WAAY,CAAC,GAAGA,EAAI,UAAU,CAAC,KAI3E,SAAU,CACR,SAAU,KACV,SAAU,CAAC,OAAQ,OAAQ,MAAM,EACjC,iBAAkBN,EAAQ,kBAAoB,aAC9C,QAAS,CACP,GAAIA,EAAQ,iBAAmB,CAC7B,uBACA,8BACA,6BACA,4BAGJ,QAAS,CAAC,GAAGF,EAA4B,GAAIE,EAAQ,iBAAmB,CAAA,CAAG,EAC3E,GAAIA,EAAQ,aAAe,QAAa,CAAE,WAAY,CAAE,GAAGA,EAAQ,UAAU,CAAE,IAGpF,CACH,CAzEgBW,EAAAZ,EAAA",
6
- "names": ["defineConfig", "fileURLToPath", "DEFAULT_CLOUDFLARE_MOCKS", "DEFAULT_WORKSPACE_PACKAGES", "KIT_NO_EXTERNAL", "workspaceAliases", "BACKEND_EXCLUDE", "WEB_INCLUDE", "CANONICAL_COVERAGE_EXCLUDE", "defineRepoVitestConfig", "options", "root", "packages", "mocks", "noExternal", "backend", "web", "backendAliases", "webSrc", "webAliases", "alias", "__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 { 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,sBAgIxG,MAAMC,EAA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ARREL_EXCLUDE", "defineRepoVitestConfig", "options", "root", "packages", "mocks", "noExternal", "backend", "web", "backendAliases", "webSrc", "webAliases", "alias", "glob", "__name"]
7
7
  }
package/dist/vitest.d.ts CHANGED
@@ -119,6 +119,22 @@ export interface UnitVitestConfigOptions {
119
119
  * Coverage `exclude` globs, merged with the canonical set.
120
120
  */
121
121
  readonly coverageExclude?: readonly string[];
122
+ /**
123
+ * Report coverage for `index.ts` re-export barrels.
124
+ *
125
+ * The canonical set excludes them because a barrel carries no logic of its
126
+ * own. Two repos in the family read that differently and deliberately keep
127
+ * them in: a barrel with no importer shows up as an uncovered file, which is
128
+ * the point — it is the only signal that the barrel is dead. Excluding them
129
+ * is what let four entirely unused root barrels sit in the tree unnoticed, one
130
+ * per repo that carried the habit.
131
+ *
132
+ * `coverageExclude` cannot express this, because it is merged with the
133
+ * canonical set rather than replacing it, so a consumer could not opt back in.
134
+ * Hence a named flag. Default `false`: today’s behaviour, unchanged for the
135
+ * seven repos that never asked.
136
+ */
137
+ readonly includeIndexBarrels?: boolean;
122
138
  /**
123
139
  * Coverage floors. Omitted by default; a repo that wants them sets them.
124
140
  */
@@ -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;AAE1D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAEvD,YAAY,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAOvD,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAElE;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B,QA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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,MAAM,EAAE,CAAC;IACrC;;;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;;OAEG;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,CAgE7G"}
package/dist/vitest.js CHANGED
@@ -1 +1 @@
1
- var l=Object.defineProperty;var r=(e,s)=>l(e,"name",{value:s,configurable:!0});import{defineConfig as a}from"vitest/config";import{DEFAULT_CLOUDFLARE_MOCKS as u,DEFAULT_WORKSPACE_PACKAGES as i,KIT_DEDUPE as E,KIT_NO_EXTERNAL as o,workspaceAliases as g}from"./vitest-aliases.js";import{KIT_DEDUPE as L,KIT_NO_EXTERNAL as h}from"./vitest-aliases.js";const f=["test/web/**","test/**/web-*.test.{ts,tsx}","apps/web/**/*.test.{ts,tsx}"],p=["scripts/**","**/*.test.ts","**/*.test.tsx","**/*.d.ts","**/index.ts","**/types.d.ts","**/model/**","**/generated/**","**/D1Types.ts","**/ServiceEnv.ts","**/env.d.ts"];function m(e={}){const s=e.root??new URL(".",import.meta.url).href,d=e.coverageInclude??["apps/api/src/**/*.ts","apps/background/src/**/*.ts","packages/**/src/**/*.ts"],c=[...p,...e.coverageExclude??[]],n=[...g({scope:e.scope??"@unused",root:s,packages:e.scope===void 0?[]:e.packages??i,mocks:e.mocks??u}).filter(t=>typeof t.find!="string"||!t.find.startsWith("@unused")),...e.aliases??[]];return a({...e.plugins!==void 0&&{plugins:[...e.plugins]},resolve:{alias:n,noExternal:[...o,...e.noExternal??[]],dedupe:[...E]},test:{globals:!0,environment:"node",include:[...e.include??["test/**/*.test.{ts,tsx}"]],exclude:[...e.exclude??["**/node_modules/**","**/dist/**","test/integration/**",...f]],...e.setupFiles!==void 0&&{setupFiles:[...e.setupFiles]},server:{deps:{inline:[...e.serverDepsInline??["dofs"]]}},coverage:{provider:"v8",reporter:["text","lcov","html"],reportsDirectory:e.reportsDirectory??"./coverage",include:[...d],exclude:c,...e.thresholds!==void 0&&{thresholds:{...e.thresholds}}}}})}r(m,"defineUnitVitestConfig");export{L as KIT_DEDUPE,h as KIT_NO_EXTERNAL,m as defineUnitVitestConfig};
1
+ var a=Object.defineProperty;var r=(e,s)=>a(e,"name",{value:s,configurable:!0});import{defineConfig as u}from"vitest/config";import{DEFAULT_CLOUDFLARE_MOCKS as i,DEFAULT_WORKSPACE_PACKAGES as E,KIT_DEDUPE as o,KIT_NO_EXTERNAL as f,workspaceAliases as g}from"./vitest-aliases.js";import{KIT_DEDUPE as h,KIT_NO_EXTERNAL as T}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"],p="**/index.ts";function v(e){return[...e.includeIndexBarrels?n.filter(t=>t!==p):n,...e.coverageExclude??[]]}r(v,"coverageExcludeFor");function L(e={}){const s=e.root??new URL(".",import.meta.url).href,t=e.coverageInclude??["apps/api/src/**/*.ts","apps/background/src/**/*.ts","packages/**/src/**/*.ts"],d=v(e),l=[...g({scope:e.scope??"@unused",root:s,packages:e.scope===void 0?[]:e.packages??E,mocks:e.mocks??i}).filter(c=>typeof c.find!="string"||!c.find.startsWith("@unused")),...e.aliases??[]];return u({...e.plugins!==void 0&&{plugins:[...e.plugins]},resolve:{alias:l,noExternal:[...f,...e.noExternal??[]],dedupe:[...o]},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:[...t],exclude:d,...e.thresholds!==void 0&&{thresholds:{...e.thresholds}}}}})}r(L,"defineUnitVitestConfig");export{h as KIT_DEDUPE,T as KIT_NO_EXTERNAL,L as defineUnitVitestConfig};
@@ -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 * Coverage floors. Omitted by default; a repo that wants them sets them.\n */\n readonly thresholds?: CoverageThresholds;\n /**\n * Where the coverage report is written.\n */\n readonly reportsDirectory?: string;\n}\n\n/**\n * The SPA's suites, excluded here so the two configs partition the suite.\n *\n * Every shape the family uses: the `test/web/**` directory convention\n * (CalDAV-Bridge, Mail-Meow), the root-suite `web-*` naming convention\n * (Durable-DAV-Router), and suites bundled under `apps/web` (Mail-Otter).\n * `defineWebVitestConfig()` includes the same globs, so a file is collected by\n * exactly one config.\n */\nconst SPA_FILES: readonly string[] = ['test/web/**', 'test/**/web-*.test.{ts,tsx}', 'apps/web/**/*.test.{ts,tsx}'];\n\n/**\n * Coverage `exclude` globs converged from the source repos.\n *\n * The categories: build and test tooling (`scripts/` grows with project surface,\n * not complexity, and the god-file guard excludes it for the same reason), test\n * files, declarations, re-export barrels (`index.ts` carries no logic of its\n * own), model records, generated files (the SPA shell is a one-line HTML blob\n * with no logic to exercise), and type-only modules.\n */\nconst CANONICAL_COVERAGE_EXCLUDE: readonly string[] = [\n 'scripts/**',\n '**/*.test.ts',\n '**/*.test.tsx',\n '**/*.d.ts',\n '**/index.ts',\n '**/types.d.ts',\n '**/model/**',\n '**/generated/**',\n '**/D1Types.ts',\n '**/ServiceEnv.ts',\n '**/env.d.ts',\n];\n\n/**\n * Build the unit-test config.\n *\n * ```ts\n * // vitest.config.mts\n * import { defineUnitVitestConfig } from '@rexezuge/tooling/vitest';\n * export default defineUnitVitestConfig({\n * scope: '@myapp',\n * thresholds: { statements: 60, branches: 55, functions: 65, lines: 60 },\n * });\n * ```\n */\nexport function defineUnitVitestConfig(options: UnitVitestConfigOptions = {}): ReturnType<typeof defineConfig> {\n const root = options.root ?? new URL('.', import.meta.url).href;\n const coverageInclude = options.coverageInclude ?? ['apps/api/src/**/*.ts', 'apps/background/src/**/*.ts', 'packages/**/src/**/*.ts'];\n const coverageExclude = [...CANONICAL_COVERAGE_EXCLUDE, ...(options.coverageExclude ?? [])];\n const baseAliases = workspaceAliases({\n scope: options.scope ?? '@unused',\n root,\n packages: options.scope === undefined ? [] : (options.packages ?? DEFAULT_WORKSPACE_PACKAGES),\n mocks: options.mocks ?? DEFAULT_CLOUDFLARE_MOCKS,\n });\n // A placeholder scope contributes no `@unused/*` entries; the mocks plus\n // `@/`/`~/` survive either way.\n const aliases = [\n ...baseAliases.filter((alias) => typeof alias.find !== 'string' || !alias.find.startsWith('@unused')),\n ...(options.aliases ?? []),\n ];\n\n return defineConfig({\n ...(options.plugins !== undefined && { plugins: [...options.plugins] }),\n resolve: {\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,sBAyG5C,MAAME,EAA+B,CAAC,cAAe,8BAA+B,6BAA6B,EAW3GC,EAAgD,CACpD,aACA,eACA,gBACA,YACA,cACA,gBACA,cACA,kBACA,gBACA,mBACA,eAeI,SAAUC,EAAuBC,EAAmC,CAAA,EAAE,CAC1E,MAAMC,EAAOD,EAAQ,MAAQ,IAAI,IAAI,IAAK,YAAY,GAAG,EAAE,KACrDE,EAAkBF,EAAQ,iBAAmB,CAAC,uBAAwB,8BAA+B,yBAAyB,EAC9HG,EAAkB,CAAC,GAAGL,EAA4B,GAAIE,EAAQ,iBAAmB,CAAA,CAAG,EASpFI,EAAU,CACd,GATkBR,EAAiB,CACnC,MAAOI,EAAQ,OAAS,UACxB,KAAAC,EACA,SAAUD,EAAQ,QAAU,OAAY,CAAA,EAAMA,EAAQ,UAAYP,EAClE,MAAOO,EAAQ,OAASR,EACzB,EAIgB,OAAQa,GAAU,OAAOA,EAAM,MAAS,UAAY,CAACA,EAAM,KAAK,WAAW,SAAS,CAAC,EACpG,GAAIL,EAAQ,SAAW,CAAA,GAGzB,OAAOT,EAAa,CAClB,GAAIS,EAAQ,UAAY,QAAa,CAAE,QAAS,CAAC,GAAGA,EAAQ,OAAO,CAAC,EACpE,QAAS,CACP,MAAOI,EACP,WAAY,CAAC,GAAGT,EAAiB,GAAIK,EAAQ,YAAc,CAAA,CAAG,EAS9D,OAAQ,CAAC,GAAGN,CAAU,GAExB,KAAM,CACJ,QAAS,GACT,YAAa,OACb,QAAS,CAAC,GAAIM,EAAQ,SAAW,CAAC,yBAAyB,CAAE,EAG7D,QAAS,CAAC,GAAIA,EAAQ,SAAW,CAAC,qBAAsB,aAAc,sBAAuB,GAAGH,CAAS,CAAE,EAC3G,GAAIG,EAAQ,aAAe,QAAa,CAAE,WAAY,CAAC,GAAGA,EAAQ,UAAU,CAAC,EAC7E,OAAQ,CACN,KAAM,CAKJ,OAAQ,CAAC,GAAIA,EAAQ,kBAAoB,CAAC,MAAM,CAAE,IAGtD,SAAU,CACR,SAAU,KAMV,SAAU,CAAC,OAAQ,OAAQ,MAAM,EACjC,iBAAkBA,EAAQ,kBAAoB,aAC9C,QAAS,CAAC,GAAGE,CAAe,EAC5B,QAASC,EACT,GAAIH,EAAQ,aAAe,QAAa,CAAE,WAAY,CAAE,GAAGA,EAAQ,UAAU,CAAE,IAGpF,CACH,CAhEgBM,EAAAP,EAAA",
6
- "names": ["defineConfig", "DEFAULT_CLOUDFLARE_MOCKS", "DEFAULT_WORKSPACE_PACKAGES", "KIT_DEDUPE", "KIT_NO_EXTERNAL", "workspaceAliases", "SPA_FILES", "CANONICAL_COVERAGE_EXCLUDE", "defineUnitVitestConfig", "options", "root", "coverageInclude", "coverageExclude", "aliases", "alias", "__name"]
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,sBAyH5C,MAAME,EAA+B,CAAC,c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AC,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,GAAGK,CAAe,EAC5B,QAASC,EACT,GAAIN,EAAQ,aAAe,QAAa,CAAE,WAAY,CAAE,GAAGA,EAAQ,UAAU,CAAE,IAGpF,CACH,CAhEgBE,EAAAC,EAAA",
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"]
7
7
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rexezuge/tooling",
3
- "version": "1.8.2",
3
+ "version": "1.9.0",
4
4
  "private": false,
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -38,7 +38,7 @@
38
38
  "src"
39
39
  ],
40
40
  "dependencies": {
41
- "@rexezuge/d1": "1.8.2"
41
+ "@rexezuge/d1": "1.9.0"
42
42
  },
43
43
  "peerDependencies": {
44
44
  "eslint": "^10.0.0",
@@ -134,6 +134,11 @@ export interface RepoVitestConfigOptions {
134
134
  * Coverage `exclude` globs, merged with the canonical set.
135
135
  */
136
136
  readonly coverageExclude?: readonly string[];
137
+ /**
138
+ * Report coverage for `index.ts` re-export barrels. See
139
+ * `defineUnitVitestConfig`'s option of the same name.
140
+ */
141
+ readonly includeIndexBarrels?: boolean;
137
142
  /**
138
143
  * Coverage floors. Omitted by default; a repo that wants them sets them.
139
144
  */
@@ -180,6 +185,12 @@ const CANONICAL_COVERAGE_EXCLUDE: readonly string[] = [
180
185
  '**/env.d.ts',
181
186
  ];
182
187
 
188
+ /**
189
+ * The barrel exclusion, named so `includeIndexBarrels` can lift it. See the
190
+ * unit factory's option for why a consumer might want it.
191
+ */
192
+ const INDEX_BARREL_EXCLUDE = '**/index.ts';
193
+
183
194
  /**
184
195
  * Build the single-file `projects` config.
185
196
  *
@@ -261,7 +272,9 @@ export function defineRepoVitestConfig(options: RepoVitestConfigOptions): Return
261
272
  'packages/**/src/**/*.ts',
262
273
  ]),
263
274
  ],
264
- exclude: [...CANONICAL_COVERAGE_EXCLUDE, ...(options.coverageExclude ?? [])],
275
+ exclude: options.includeIndexBarrels
276
+ ? [...CANONICAL_COVERAGE_EXCLUDE.filter((glob) => glob !== INDEX_BARREL_EXCLUDE), ...(options.coverageExclude ?? [])]
277
+ : [...CANONICAL_COVERAGE_EXCLUDE, ...(options.coverageExclude ?? [])],
265
278
  ...(options.thresholds !== undefined && { thresholds: { ...options.thresholds } }),
266
279
  },
267
280
  },
package/src/vitest.ts CHANGED
@@ -130,6 +130,22 @@ export interface UnitVitestConfigOptions {
130
130
  * Coverage `exclude` globs, merged with the canonical set.
131
131
  */
132
132
  readonly coverageExclude?: readonly string[];
133
+ /**
134
+ * Report coverage for `index.ts` re-export barrels.
135
+ *
136
+ * The canonical set excludes them because a barrel carries no logic of its
137
+ * own. Two repos in the family read that differently and deliberately keep
138
+ * them in: a barrel with no importer shows up as an uncovered file, which is
139
+ * the point — it is the only signal that the barrel is dead. Excluding them
140
+ * is what let four entirely unused root barrels sit in the tree unnoticed, one
141
+ * per repo that carried the habit.
142
+ *
143
+ * `coverageExclude` cannot express this, because it is merged with the
144
+ * canonical set rather than replacing it, so a consumer could not opt back in.
145
+ * Hence a named flag. Default `false`: today’s behaviour, unchanged for the
146
+ * seven repos that never asked.
147
+ */
148
+ readonly includeIndexBarrels?: boolean;
133
149
  /**
134
150
  * Coverage floors. Omitted by default; a repo that wants them sets them.
135
151
  */
@@ -174,6 +190,22 @@ const CANONICAL_COVERAGE_EXCLUDE: readonly string[] = [
174
190
  '**/env.d.ts',
175
191
  ];
176
192
 
193
+ /**
194
+ * The barrel exclusion, named so `includeIndexBarrels` can lift it.
195
+ */
196
+ const INDEX_BARREL_EXCLUDE = '**/index.ts';
197
+
198
+ /**
199
+ * The canonical exclude set, with the barrel entry lifted for a caller that
200
+ * asked to keep barrels in their coverage report.
201
+ */
202
+ function coverageExcludeFor(options: { coverageExclude?: readonly string[]; includeIndexBarrels?: boolean }): string[] {
203
+ const canonical = options.includeIndexBarrels
204
+ ? CANONICAL_COVERAGE_EXCLUDE.filter((glob) => glob !== INDEX_BARREL_EXCLUDE)
205
+ : CANONICAL_COVERAGE_EXCLUDE;
206
+ return [...canonical, ...(options.coverageExclude ?? [])];
207
+ }
208
+
177
209
  /**
178
210
  * Build the unit-test config.
179
211
  *
@@ -189,7 +221,7 @@ const CANONICAL_COVERAGE_EXCLUDE: readonly string[] = [
189
221
  export function defineUnitVitestConfig(options: UnitVitestConfigOptions = {}): ReturnType<typeof defineConfig> {
190
222
  const root = options.root ?? new URL('.', import.meta.url).href;
191
223
  const coverageInclude = options.coverageInclude ?? ['apps/api/src/**/*.ts', 'apps/background/src/**/*.ts', 'packages/**/src/**/*.ts'];
192
- const coverageExclude = [...CANONICAL_COVERAGE_EXCLUDE, ...(options.coverageExclude ?? [])];
224
+ const coverageExclude = coverageExcludeFor(options);
193
225
  const baseAliases = workspaceAliases({
194
226
  scope: options.scope ?? '@unused',
195
227
  root,