@rexezuge/tooling 1.12.0 → 1.14.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 +149 -18
- 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-options.d.ts +54 -0
- package/dist/eslint-options.d.ts.map +1 -0
- package/dist/eslint-options.js +0 -0
- package/dist/eslint-options.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 +2 -36
- 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/pages-proxy.d.ts +2 -0
- package/dist/pages-proxy.d.ts.map +1 -0
- package/dist/pages-proxy.js +1 -0
- package/dist/pages-proxy.js.map +7 -0
- package/dist/plugin-option.d.ts +15 -0
- package/dist/plugin-option.d.ts.map +1 -0
- package/dist/plugin-option.js +1 -0
- package/dist/plugin-option.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/scripts/ensure-spa-shell-stub.d.ts +4 -2
- package/dist/scripts/ensure-spa-shell-stub.d.ts.map +1 -1
- package/dist/scripts/ensure-spa-shell-stub.js +1 -2
- package/dist/scripts/ensure-spa-shell-stub.js.map +3 -3
- package/dist/scripts/init-secrets.d.ts +1 -2
- package/dist/scripts/init-secrets.d.ts.map +1 -1
- package/dist/scripts/init-secrets.js +2 -3
- package/dist/scripts/init-secrets.js.map +3 -3
- package/dist/scripts/migrations-lock.d.ts +6 -2
- package/dist/scripts/migrations-lock.d.ts.map +1 -1
- package/dist/scripts/migrations-lock.js +1 -2
- package/dist/scripts/migrations-lock.js.map +3 -3
- package/dist/scripts/prepare-wrangler-config.d.ts +6 -2
- package/dist/scripts/prepare-wrangler-config.d.ts.map +1 -1
- package/dist/scripts/prepare-wrangler-config.js +1 -2
- package/dist/scripts/prepare-wrangler-config.js.map +3 -3
- package/dist/scripts/validate-locales.d.ts +20 -2
- package/dist/scripts/validate-locales.d.ts.map +1 -1
- package/dist/scripts/validate-locales.js +5 -5
- package/dist/scripts/validate-locales.js.map +3 -3
- package/dist/scripts/verify-spa-shell.d.ts +7 -2
- package/dist/scripts/verify-spa-shell.d.ts.map +1 -1
- package/dist/scripts/verify-spa-shell.js +1 -2
- package/dist/scripts/verify-spa-shell.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 +2 -1
- package/dist/vite.d.ts.map +1 -1
- package/dist/vite.js +3 -3
- package/dist/vite.js.map +3 -3
- 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-integration.d.ts +3 -2
- package/dist/vitest-integration.d.ts.map +1 -1
- package/dist/vitest-integration.js +1 -1
- package/dist/vitest-integration.js.map +3 -3
- package/dist/vitest-repo.d.ts +5 -3
- 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-web.d.ts +3 -2
- package/dist/vitest-web.d.ts.map +1 -1
- package/dist/vitest-web.js +1 -1
- package/dist/vitest-web.js.map +3 -3
- package/dist/vitest.d.ts +5 -3
- 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-options.ts +54 -0
- package/src/eslint-strict.test.ts +106 -0
- package/src/eslint-strict.ts +191 -0
- package/src/eslint.ts +18 -41
- 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/pages-proxy.test.ts +8 -0
- package/src/pages-proxy.ts +13 -0
- package/src/plugin-option.test.ts +13 -0
- package/src/plugin-option.ts +18 -0
- package/src/presets.test.ts +63 -0
- package/src/scripts/check-god-files.ts +3 -0
- package/src/scripts/ensure-spa-shell-stub.ts +18 -10
- package/src/scripts/entrypoints.test.ts +55 -0
- package/src/scripts/init-secrets.ts +8 -6
- package/src/scripts/migrations-lock.ts +22 -17
- package/src/scripts/prepare-wrangler-config.ts +26 -14
- package/src/scripts/validate-locales.ts +39 -17
- package/src/scripts/verify-spa-shell.ts +21 -20
- package/src/test/mocks/cloudflare-workers.ts +6 -113
- package/src/vite.ts +6 -3
- 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-integration.ts +5 -3
- package/src/vitest-repo.ts +10 -5
- package/src/vitest-web.ts +5 -3
- package/src/vitest.ts +10 -5
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,
|
|
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 } from 'vitest/config';\nimport { asVitePlugins } from './plugin-option.ts';\nimport type { PluginOption } from './plugin-option.ts';\nimport { fileURLToPath } from 'node:url';\nimport { manifestCoverageThresholds } from './manifest.ts';\nimport { DEFAULT_CLOUDFLARE_MOCKS, DEFAULT_WORKSPACE_PACKAGES, KIT_NO_EXTERNAL, workspaceAliases } from './vitest-aliases.ts';\nimport type { VitestAlias } from './vitest-aliases.ts';\nimport type { CoverageThresholds } from './vitest.ts';\n\n/**\n * The backend half of the `projects` pair.\n */\nexport interface RepoBackendOptions {\n /**\n * Which suites to collect. Defaults to the whole unit suite minus SPA and\n * integration shapes.\n */\n readonly include?: readonly string[];\n /**\n * Suite paths to skip, replacing the default.\n */\n readonly exclude?: readonly string[];\n /**\n * Setup files run before each backend test file.\n */\n readonly setupFiles?: readonly string[];\n /**\n * `node_modules` specifiers to inline through Vite. Defaults to `['dofs']`.\n */\n readonly serverDepsInline?: readonly string[];\n /**\n * Extra resolver entries for the backend project only.\n */\n readonly aliases?: readonly VitestAlias[];\n}\n\n/**\n * The SPA half of the `projects` pair.\n */\nexport interface RepoWebOptions {\n /**\n * The DOM implementation. `jsdom` is the family default; `happy-dom` is\n * CalDAV-Bridge's.\n */\n readonly environment?: 'jsdom' | 'happy-dom';\n /**\n * Which suites to collect. Defaults to every SPA shape the family uses.\n */\n readonly include?: readonly string[];\n /**\n * Suite paths to skip, replacing the default.\n */\n readonly exclude?: readonly string[];\n /**\n * Setup files run before each SPA test file.\n */\n readonly setupFiles?: readonly string[];\n /**\n * Vite plugins the SPA needs (`react()` for JSX).\n */\n readonly plugins?: readonly PluginOption[];\n /**\n * Extra resolver entries for the web project only.\n */\n readonly aliases?: readonly VitestAlias[];\n}\n\n/**\n * What `defineRepoVitestConfig` accepts.\n */\nexport interface RepoVitestConfigOptions {\n /**\n * The consuming repo's npm scope, e.g. `'@myapp'`.\n */\n readonly scope: string;\n /**\n * Workspace package directory names. Defaults to the family superset.\n */\n readonly packages?: readonly string[];\n /**\n * Which `cloudflare:*` mocks to alias. Defaults to workers/sockets/workflows.\n */\n readonly mocks?: readonly string[];\n /**\n * The repo root, as a file URL.\n */\n readonly root?: string;\n /**\n * Extra resolver entries applied to *both* projects (e.g. the `hono`\n * dedupe). Per-project extras go on `backend.aliases` / `web.aliases`.\n */\n readonly aliases?: readonly VitestAlias[];\n /**\n * Resolver `noExternal` patterns, merged after {@link KIT_NO_EXTERNAL}.\n */\n readonly noExternal?: readonly (string | RegExp)[];\n /**\n * The backend half. Omitted fields take the `defineUnitVitestConfig`\n * defaults.\n */\n readonly backend?: RepoBackendOptions;\n /**\n * The SPA half. Omitted fields take the `defineWebVitestConfig` defaults.\n */\n readonly web?: RepoWebOptions;\n /**\n * Coverage `include` globs. Defaults to the worker, the SPA and every\n * workspace package's `src`.\n */\n readonly coverageInclude?: readonly string[];\n /**\n * Coverage `exclude` globs, merged with the canonical set.\n */\n readonly coverageExclude?: readonly string[];\n /**\n * Report coverage for `index.ts` re-export barrels. See\n * `defineUnitVitestConfig`'s option of the same name.\n */\n readonly includeIndexBarrels?: boolean;\n /**\n * Coverage floors. Defaults to the manifest's `quality.coverage` (`.rexezuge.jsonc`\n * at `root`); without one, no floor.\n */\n readonly thresholds?: CoverageThresholds;\n /**\n * Where the coverage report is written.\n */\n readonly reportsDirectory?: string;\n}\n\n/**\n * Backend suites excluded from the backend project: the SPA shapes live in the\n * web project, and integration is its own config.\n */\nconst BACKEND_EXCLUDE: readonly string[] = [\n '**/node_modules/**',\n '**/dist/**',\n 'test/integration/**',\n 'test/web/**',\n 'test/**/web-*.test.{ts,tsx}',\n 'apps/web/**/*.test.{ts,tsx}',\n];\n\n/**\n * SPA suite shapes collected by the web project.\n */\nconst WEB_INCLUDE: readonly string[] = ['test/web/**/*.test.{ts,tsx}', 'test/**/web-*.test.{ts,tsx}', 'apps/web/**/*.test.{ts,tsx}'];\n\n/**\n * Coverage `exclude`: the union of the unit and web halves' canonical sets.\n */\nconst CANONICAL_COVERAGE_EXCLUDE: readonly string[] = [\n 'scripts/**',\n '**/*.test.ts',\n '**/*.test.tsx',\n '**/*.d.ts',\n '**/index.ts',\n '**/types.d.ts',\n '**/types.ts',\n '**/model/**',\n '**/generated/**',\n '**/D1Types.ts',\n '**/ServiceEnv.ts',\n '**/env.d.ts',\n];\n\n/**\n * The barrel exclusion, named so `includeIndexBarrels` can lift it. See the\n * unit factory's option for why a consumer might want it.\n */\nconst INDEX_BARREL_EXCLUDE = '**/index.ts';\n\n/**\n * Build the single-file `projects` config.\n *\n * ```ts\n * // vitest.config.mts\n * import { defineRepoVitestConfig } from '@rexezuge/tooling/vitest-repo';\n * export default defineRepoVitestConfig({\n * scope: '@myapp',\n * web: { environment: 'happy-dom' },\n * thresholds: { statements: 87, branches: 77, functions: 88, lines: 90 },\n * });\n * ```\n */\nexport function defineRepoVitestConfig(options: RepoVitestConfigOptions): ReturnType<typeof defineConfig> {\n const root = options.root ?? new URL('.', import.meta.url).href;\n const thresholds = options.thresholds ?? manifestCoverageThresholds(root);\n const packages = options.packages ?? DEFAULT_WORKSPACE_PACKAGES;\n const mocks = options.mocks ?? DEFAULT_CLOUDFLARE_MOCKS;\n const noExternal = [...KIT_NO_EXTERNAL, ...(options.noExternal ?? [])];\n const backend = options.backend ?? {};\n const web = options.web ?? {};\n\n const backendAliases = [\n ...workspaceAliases({ scope: options.scope, root, packages, mocks }),\n ...(options.aliases ?? []),\n ...(backend.aliases ?? []),\n ];\n // `@/` means the SPA in the web project (Mail-Otter's SPA source imports\n // through it); the workspace table's `@/` → API entry is dropped and the\n // SPA's own prepended. `~/` → SPA either way.\n const webSrc = fileURLToPath(new URL('apps/web/src', root));\n const webAliases: VitestAlias[] = [\n { find: /^@\\//, replacement: `${webSrc}/` },\n { find: /^~\\//, replacement: `${webSrc}/` },\n // Drop the workspace table's `@/`/`~/` (RegExp) entries — the SPA's own\n // prepended above win — and keep the `@scope/*` + `cloudflare:*` strings.\n ...workspaceAliases({ scope: options.scope, root, packages, mocks }).filter((alias) => typeof alias.find === 'string'),\n ...(options.aliases ?? []),\n ...(web.aliases ?? []),\n ];\n\n return defineConfig({\n test: {\n projects: [\n {\n resolve: { alias: backendAliases, noExternal },\n test: {\n name: 'backend',\n globals: true,\n environment: 'node',\n include: [...(backend.include ?? ['test/**/*.test.{ts,tsx}'])],\n exclude: [...(backend.exclude ?? BACKEND_EXCLUDE)],\n ...(backend.setupFiles !== undefined && { setupFiles: [...backend.setupFiles] }),\n server: { deps: { inline: [...(backend.serverDepsInline ?? ['dofs'])] } },\n },\n },\n {\n ...(web.plugins !== undefined && { plugins: asVitePlugins(web.plugins) }),\n resolve: { alias: webAliases, noExternal },\n test: {\n name: 'web',\n globals: true,\n environment: web.environment ?? 'jsdom',\n include: [...(web.include ?? WEB_INCLUDE)],\n exclude: [...(web.exclude ?? ['**/node_modules/**', '**/dist/**', 'test/integration/**'])],\n pool: 'threads',\n ...(web.setupFiles !== undefined && { setupFiles: [...web.setupFiles] }),\n },\n },\n ],\n coverage: {\n provider: 'v8',\n reporter: ['text', 'lcov', 'html'],\n reportsDirectory: options.reportsDirectory ?? './coverage',\n include: [\n ...(options.coverageInclude ?? [\n 'apps/api/src/**/*.ts',\n 'apps/background/src/**/*.ts',\n 'apps/web/src/**/*.{ts,tsx}',\n 'packages/**/src/**/*.ts',\n ]),\n ],\n exclude: options.includeIndexBarrels\n ? [...CANONICAL_COVERAGE_EXCLUDE.filter((glob) => glob !== INDEX_BARREL_EXCLUDE), ...(options.coverageExclude ?? [])]\n : [...CANONICAL_COVERAGE_EXCLUDE, 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H,CAAC,GAAGH,EAA4B,GAAIG,EAAQ,iBAAmB,CAAA,CAAG,EACtE,GAAIE,IAAe,QAAa,CAAE,WAAY,CAAE,GAAGA,CAAU,CAAE,IAGpE,CACH,CA5EgBW,EAAAd,EAAA",
|
|
6
|
+
"names": ["defineConfig", "asVitePlugins", "fileURLToPath", "manifestCoverageThresholds", "DEFAULT_CLOUDFLARE_MOCKS", "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-web.d.ts
CHANGED
|
@@ -38,7 +38,8 @@
|
|
|
38
38
|
* `apps/web/src`. Workspace `@scope/*` imports still resolve to the
|
|
39
39
|
* packages, so web tests reach shared logic the same way backend tests do.
|
|
40
40
|
*/
|
|
41
|
-
import { defineConfig
|
|
41
|
+
import { defineConfig } from 'vitest/config';
|
|
42
|
+
import type { PluginOption } from './plugin-option.ts';
|
|
42
43
|
import type { VitestAlias } from './vitest-aliases.ts';
|
|
43
44
|
import type { CoverageThresholds } from './vitest.ts';
|
|
44
45
|
/**
|
|
@@ -64,7 +65,7 @@ export interface WebVitestConfigOptions {
|
|
|
64
65
|
* by the consumer rather than imported here, because the kit must stay
|
|
65
66
|
* zero-dependency and the plugin belongs to the app, not the harness.
|
|
66
67
|
*/
|
|
67
|
-
readonly plugins?: readonly
|
|
68
|
+
readonly plugins?: readonly PluginOption[];
|
|
68
69
|
/**
|
|
69
70
|
* Extra resolver entries, applied after the canonical ones.
|
|
70
71
|
*/
|
package/dist/vitest-web.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vitest-web.d.ts","sourceRoot":"","sources":["../src/vitest-web.ts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;IACxC;;OAEG;IACH,QAAQ,CAAC,gBAAgB,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAC9C;;OAEG;IACH,QAAQ,CAAC,UAAU,CAAC,EAAE,SAAS,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,CAAC;IACnD;;OAEG;IACH,QAAQ,CAAC,eAAe,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAC7C;;OAEG;IACH,QAAQ,CAAC,eAAe,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAC7C;;OAEG;IACH,QAAQ,CAAC,UAAU,CAAC,EAAE,kBAAkB,CAAC;IACzC;;;OAGG;IACH,QAAQ,CAAC,gBAAgB,CAAC,EAAE,MAAM,CAAC;CACpC;AAcD;;;;;;;;;GASG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,GAAE,sBAA2B,GAAG,UAAU,CAAC,OAAO,YAAY,CAAC,CA6C3G"}
|
package/dist/vitest-web.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var c=Object.defineProperty;var n=(e,s)=>c(e,"name",{value:s,configurable:!0});import{defineConfig as i}from"vitest/config";import{
|
|
1
|
+
var c=Object.defineProperty;var n=(e,s)=>c(e,"name",{value:s,configurable:!0});import{defineConfig as i}from"vitest/config";import{asVitePlugins as a}from"./plugin-option.js";import{fileURLToPath as u}from"node:url";import{DEFAULT_CLOUDFLARE_MOCKS as f,DEFAULT_WORKSPACE_PACKAGES as o,KIT_NO_EXTERNAL as p,workspaceAliases as m}from"./vitest-aliases.js";const g=["test/web/**/*.test.{ts,tsx}","test/**/web-*.test.{ts,tsx}","apps/web/**/*.test.{ts,tsx}"],E=["**/*.test.{ts,tsx}","**/*.d.ts","**/types.ts","**/generated/**"];function C(e={}){const s=e.root??new URL(".",import.meta.url).href,r=u(new URL("apps/web/src",s)),d=m({scope:e.scope??"@unused",root:s,packages:e.packages??o,mocks:e.mocks??f}).filter(t=>typeof t.find=="string"&&!t.find.startsWith("@unused")),l=[{find:/^@\//,replacement:`${r}/`},{find:/^~\//,replacement:`${r}/`},...d.filter(t=>typeof t.find=="string"&&(t.find.startsWith("cloudflare:")||e.scope!==void 0)),...e.aliases??[]];return i({...e.plugins!==void 0&&{plugins:a(e.plugins)},resolve:{alias:l,noExternal:[...p,...e.noExternal??[]]},test:{globals:!0,environment:e.environment??"jsdom",include:[...e.include??g],pool:"threads",exclude:[...e.exclude??["**/node_modules/**","**/dist/**","test/integration/**"]],...e.setupFiles!==void 0&&{setupFiles:[...e.setupFiles]},...e.serverDepsInline!==void 0&&{server:{deps:{inline:[...e.serverDepsInline]}}},coverage:{provider:"v8",reporter:["text","lcov"],reportsDirectory:e.reportsDirectory??"./coverage-spa",include:[...e.coverageInclude??["apps/web/src/**/*.{ts,tsx}"]],exclude:[...E,...e.coverageExclude??[]],...e.thresholds!==void 0&&{thresholds:{...e.thresholds}}}}})}n(C,"defineWebVitestConfig");export{C as defineWebVitestConfig};
|
package/dist/vitest-web.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/vitest-web.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * The SPA's test and coverage gate.\n *\n * Provenance: converged from all nine repos' SPA suites — Durable-DAV-Router's\n * and Mail-Otter's `vitest.web.config.mts` (the two repos that gave the frontend\n * its own file), Mail-Meow's and CalDAV-Bridge's `projects` entries (the two\n * that keep backend and SPA in one file), and AWS-AccessBridge's\n * extension-split `dom` project. Durable-DAV-Router's file is the canonical\n * shape — it is the one that records *why* the split exists; Mail-Otter's\n * contributes the React plugin and the `apps/web/**` include; CalDAV-Bridge\n * contributes `happy-dom` and the `test/web/**` directory convention;\n * Mail-Meow contributes `setupFiles` and the note that projects do not inherit\n * the root `resolve`.\n *\n * Canonical decisions:\n *\n * 1. **A DOM for every file here**, rather than a `@vitest-environment` pragma\n * per file: these are the tests that need a DOM, and the pragma is one more\n * place to forget. `jsdom` is the family default (seven repos);\n * `happy-dom` is CalDAV-Bridge's, and is one option away.\n * 2. **`pool: 'threads'`, bounded, rather than one forked worker per file.** Each\n * jsdom document is a whole browser environment; a fork per file exhausts\n * memory on a constrained machine, and when it does the run dies partway with\n * a bare \"Worker exited unexpectedly\" and no test reports a failure — which\n * reads as a flaky suite rather than as an out-of-memory kill.\n * 3. **`include` covers every shape the family uses** — the `test/web/**`\n * directory convention, the root-suite `web-*` naming convention, and suites\n * bundled under `apps/web` — and the same globs are what\n * `defineUnitVitestConfig()` excludes, so a file is collected by exactly one\n * config.\n * 4. **Projects do not inherit the root `resolve`** (Mail-Meow): a\n * single-file `projects` composition must repeat the alias table per\n * project. `defineRepoVitestConfig()` does that; two-file repos get it from\n * these factories directly.\n * 5. **`@/` means the SPA here, not the API worker.** The unit config maps\n * `@/` to `apps/api/src`; this config maps both `@/` (Mail-Otter's SPA\n * source) and `~/` (Mail-Meow's and CalDAV-Bridge's SPA tests) to\n * `apps/web/src`. Workspace `@scope/*` imports still resolve to the\n * packages, so web tests reach shared logic the same way backend tests do.\n */\n\nimport { defineConfig
|
|
5
|
-
"mappings": "+EAyCA,OAAS,gBAAAA,
|
|
6
|
-
"names": ["defineConfig", "fileURLToPath", "DEFAULT_CLOUDFLARE_MOCKS", "DEFAULT_WORKSPACE_PACKAGES", "KIT_NO_EXTERNAL", "workspaceAliases", "DEFAULT_INCLUDE", "CANONICAL_COVERAGE_EXCLUDE", "defineWebVitestConfig", "options", "root", "webSrc", "scopePart", "alias", "aliases", "__name"]
|
|
4
|
+
"sourcesContent": ["/**\n * The SPA's test and coverage gate.\n *\n * Provenance: converged from all nine repos' SPA suites — Durable-DAV-Router's\n * and Mail-Otter's `vitest.web.config.mts` (the two repos that gave the frontend\n * its own file), Mail-Meow's and CalDAV-Bridge's `projects` entries (the two\n * that keep backend and SPA in one file), and AWS-AccessBridge's\n * extension-split `dom` project. Durable-DAV-Router's file is the canonical\n * shape — it is the one that records *why* the split exists; Mail-Otter's\n * contributes the React plugin and the `apps/web/**` include; CalDAV-Bridge\n * contributes `happy-dom` and the `test/web/**` directory convention;\n * Mail-Meow contributes `setupFiles` and the note that projects do not inherit\n * the root `resolve`.\n *\n * Canonical decisions:\n *\n * 1. **A DOM for every file here**, rather than a `@vitest-environment` pragma\n * per file: these are the tests that need a DOM, and the pragma is one more\n * place to forget. `jsdom` is the family default (seven repos);\n * `happy-dom` is CalDAV-Bridge's, and is one option away.\n * 2. **`pool: 'threads'`, bounded, rather than one forked worker per file.** Each\n * jsdom document is a whole browser environment; a fork per file exhausts\n * memory on a constrained machine, and when it does the run dies partway with\n * a bare \"Worker exited unexpectedly\" and no test reports a failure — which\n * reads as a flaky suite rather than as an out-of-memory kill.\n * 3. **`include` covers every shape the family uses** — the `test/web/**`\n * directory convention, the root-suite `web-*` naming convention, and suites\n * bundled under `apps/web` — and the same globs are what\n * `defineUnitVitestConfig()` excludes, so a file is collected by exactly one\n * config.\n * 4. **Projects do not inherit the root `resolve`** (Mail-Meow): a\n * single-file `projects` composition must repeat the alias table per\n * project. `defineRepoVitestConfig()` does that; two-file repos get it from\n * these factories directly.\n * 5. **`@/` means the SPA here, not the API worker.** The unit config maps\n * `@/` to `apps/api/src`; this config maps both `@/` (Mail-Otter's SPA\n * source) and `~/` (Mail-Meow's and CalDAV-Bridge's SPA tests) to\n * `apps/web/src`. Workspace `@scope/*` imports still resolve to the\n * packages, so web tests reach shared logic the same way backend tests do.\n */\n\nimport { defineConfig } from 'vitest/config';\nimport { asVitePlugins } from './plugin-option.ts';\nimport type { PluginOption } from './plugin-option.ts';\nimport { fileURLToPath } from 'node:url';\nimport { DEFAULT_CLOUDFLARE_MOCKS, DEFAULT_WORKSPACE_PACKAGES, KIT_NO_EXTERNAL, workspaceAliases } from './vitest-aliases.ts';\nimport type { VitestAlias } from './vitest-aliases.ts';\nimport type { CoverageThresholds } from './vitest.ts';\n\n/**\n * What `defineWebVitestConfig` accepts.\n */\nexport interface WebVitestConfigOptions {\n /**\n * The consuming repo's npm scope, e.g. `'@myapp'`. When supplied, `@scope/*`\n * workspace aliases are generated so web tests reach shared logic; when\n * omitted, only the `cloudflare:*`, `@/` and `~/` aliases apply.\n */\n readonly scope?: string;\n /**\n * Workspace package directory names. Defaults to the family superset.\n */\n readonly packages?: readonly string[];\n /**\n * Which `cloudflare:*` mocks to alias. Defaults to workers/sockets/workflows.\n */\n readonly mocks?: readonly string[];\n /**\n * Vite plugins the SPA needs — `@vitejs/plugin-react` for a React app. Passed\n * by the consumer rather than imported here, because the kit must stay\n * zero-dependency and the plugin belongs to the app, not the harness.\n */\n readonly plugins?: readonly PluginOption[];\n /**\n * Extra resolver entries, applied after the canonical ones.\n */\n readonly aliases?: readonly VitestAlias[];\n /**\n * The repo root, as a file URL.\n */\n readonly root?: string;\n /**\n * The DOM implementation. `jsdom` is the family default; `happy-dom` is\n * CalDAV-Bridge's (lighter, and sufficient for its hook/service suites).\n */\n readonly environment?: 'jsdom' | 'happy-dom';\n /**\n * Which suites to collect. Defaults to every shape the family uses.\n */\n readonly include?: readonly string[];\n /**\n * Suite paths to skip, replacing the default.\n */\n readonly exclude?: readonly string[];\n /**\n * Setup files run before each test file.\n */\n readonly setupFiles?: readonly string[];\n /**\n * `node_modules` specifiers to inline through Vite rather than externalize.\n */\n readonly serverDepsInline?: readonly string[];\n /**\n * Resolver `noExternal` patterns, merged after {@link KIT_NO_EXTERNAL}.\n */\n readonly noExternal?: readonly (string | RegExp)[];\n /**\n * Coverage `include` globs. Defaults to the SPA source.\n */\n readonly coverageInclude?: readonly string[];\n /**\n * Coverage `exclude` globs, merged with the canonical set.\n */\n readonly coverageExclude?: readonly string[];\n /**\n * Coverage floors. Omitted by default; see `defineUnitVitestConfig`.\n */\n readonly thresholds?: CoverageThresholds;\n /**\n * Where the coverage report is written. Separate from the unit config's, so\n * the two gates never overwrite each other's report.\n */\n readonly reportsDirectory?: string;\n}\n\n/**\n * The default suite globs: every shape the family uses — the `test/web/**`\n * directory convention, the root-suite `web-*` convention, and the\n * bundled-under-`apps/web` convention — so any layout works unchanged.\n */\nconst DEFAULT_INCLUDE: readonly string[] = ['test/web/**/*.test.{ts,tsx}', 'test/**/web-*.test.{ts,tsx}', 'apps/web/**/*.test.{ts,tsx}'];\n\n/**\n * Coverage `exclude` globs for the SPA half.\n */\nconst CANONICAL_COVERAGE_EXCLUDE: readonly string[] = ['**/*.test.{ts,tsx}', '**/*.d.ts', '**/types.ts', '**/generated/**'];\n\n/**\n * Build the SPA's test config.\n *\n * ```ts\n * // vitest.web.config.mts\n * import react from '@vitejs/plugin-react';\n * import { defineWebVitestConfig } from '@rexezuge/tooling/vitest-web';\n * export default defineWebVitestConfig({ scope: '@myapp', plugins: [react()] });\n * ```\n */\nexport function defineWebVitestConfig(options: WebVitestConfigOptions = {}): ReturnType<typeof defineConfig> {\n const root = options.root ?? new URL('.', import.meta.url).href;\n const webSrc = fileURLToPath(new URL('apps/web/src', root));\n // The workspace table maps `@/` to the API worker; here `@/` means the SPA,\n // so drop its `@/`/`~/` entries and prepend the SPA's own. String finds\n // (`@scope/*`, `cloudflare:*`) survive; a placeholder scope contributes none.\n const scopePart = workspaceAliases({\n scope: options.scope ?? '@unused',\n root,\n packages: options.packages ?? DEFAULT_WORKSPACE_PACKAGES,\n mocks: options.mocks ?? DEFAULT_CLOUDFLARE_MOCKS,\n }).filter((alias) => typeof alias.find === 'string' && !alias.find.startsWith('@unused'));\n const aliases: VitestAlias[] = [\n { find: /^@\\//, replacement: `${webSrc}/` },\n { find: /^~\\//, replacement: `${webSrc}/` },\n ...scopePart.filter((alias) => typeof alias.find === 'string' && (alias.find.startsWith('cloudflare:') || options.scope !== undefined)),\n ...(options.aliases ?? []),\n ];\n\n return defineConfig({\n ...(options.plugins !== undefined && { plugins: asVitePlugins(options.plugins) }),\n resolve: { alias: aliases, noExternal: [...KIT_NO_EXTERNAL, ...(options.noExternal ?? [])] },\n test: {\n globals: true,\n environment: options.environment ?? 'jsdom',\n include: [...(options.include ?? DEFAULT_INCLUDE)],\n // Threads, bounded, rather than one forked worker per file — see the\n // header. A custom `exclude` replaces Vitest's defaults, so `node_modules`\n // must be re-listed.\n pool: 'threads',\n exclude: [...(options.exclude ?? ['**/node_modules/**', '**/dist/**', 'test/integration/**'])],\n ...(options.setupFiles !== undefined && { setupFiles: [...options.setupFiles] }),\n ...(options.serverDepsInline !== undefined && {\n server: { deps: { inline: [...options.serverDepsInline] } },\n }),\n coverage: {\n provider: 'v8',\n reporter: ['text', 'lcov'],\n reportsDirectory: options.reportsDirectory ?? './coverage-spa',\n include: [...(options.coverageInclude ?? ['apps/web/src/**/*.{ts,tsx}'])],\n exclude: [...CANONICAL_COVERAGE_EXCLUDE, ...(options.coverageExclude ?? [])],\n ...(options.thresholds !== undefined && { thresholds: { ...options.thresholds } }),\n },\n },\n });\n}\n"],
|
|
5
|
+
"mappings": "+EAyCA,OAAS,gBAAAA,MAAoB,gBAC7B,OAAS,iBAAAC,MAAqB,qBAE9B,OAAS,iBAAAC,MAAqB,WAC9B,OAAS,4BAAAC,EAA0B,8BAAAC,EAA4B,mBAAAC,EAAiB,oBAAAC,MAAwB,sBAqFxG,MAAMC,EAAqC,CAAC,8BAA+B,8BAA+B,6BAA6B,EAKjIC,EAAgD,CAAC,qBAAsB,YAAa,cAAe,iBAAiB,EAYpH,SAAUC,EAAsBC,EAAkC,CAAA,EAAE,CACxE,MAAMC,EAAOD,EAAQ,MAAQ,IAAI,IAAI,IAAK,YAAY,GAAG,EAAE,KACrDE,EAASV,EAAc,IAAI,IAAI,eAAgBS,CAAI,CAAC,EAIpDE,EAAYP,EAAiB,CACjC,MAAOI,EAAQ,OAAS,UACxB,KAAAC,EACA,SAAUD,EAAQ,UAAYN,EAC9B,MAAOM,EAAQ,OAASP,EACzB,EAAE,OAAQW,GAAU,OAAOA,EAAM,MAAS,UAAY,CAACA,EAAM,KAAK,WAAW,SAAS,CAAC,EAClFC,EAAyB,CAC7B,CAAE,KAAM,OAAQ,YAAa,GAAGH,CAAM,GAAG,EACzC,CAAE,K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ANONICAL_COVERAGE_EXCLUDE", "defineWebVitestConfig", "options", "root", "webSrc", "scopePart", "alias", "aliases", "__name"]
|
|
7
7
|
}
|
package/dist/vitest.d.ts
CHANGED
|
@@ -32,7 +32,8 @@
|
|
|
32
32
|
* resolver refuses, so the kit stays inside Vite's pipeline (the same
|
|
33
33
|
* resolver that bundles the worker).
|
|
34
34
|
*/
|
|
35
|
-
import { defineConfig
|
|
35
|
+
import { defineConfig } from 'vitest/config';
|
|
36
|
+
import type { PluginOption } from './plugin-option.ts';
|
|
36
37
|
import type { VitestAlias } from './vitest-aliases.ts';
|
|
37
38
|
export type { VitestAlias } from './vitest-aliases.ts';
|
|
38
39
|
export { KIT_DEDUPE, KIT_NO_EXTERNAL } from './vitest-aliases.ts';
|
|
@@ -104,7 +105,7 @@ export interface UnitVitestConfigOptions {
|
|
|
104
105
|
* Vite plugins for the suite (rare on the backend half; the SPA half passes
|
|
105
106
|
* `react()` here).
|
|
106
107
|
*/
|
|
107
|
-
readonly plugins?: readonly
|
|
108
|
+
readonly plugins?: readonly PluginOption[];
|
|
108
109
|
/**
|
|
109
110
|
* Setup files run before each test file (e.g. AWS's floci guard, Meow's
|
|
110
111
|
* backend/web setups).
|
|
@@ -136,7 +137,8 @@ export interface UnitVitestConfigOptions {
|
|
|
136
137
|
*/
|
|
137
138
|
readonly includeIndexBarrels?: boolean;
|
|
138
139
|
/**
|
|
139
|
-
* Coverage floors.
|
|
140
|
+
* Coverage floors. Defaults to the manifest's `quality.coverage` (`.rexezuge.jsonc`
|
|
141
|
+
* at `root`); without one, no floor.
|
|
140
142
|
*/
|
|
141
143
|
readonly thresholds?: CoverageThresholds;
|
|
142
144
|
/**
|
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,EAA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IG;IACH,QAAQ,CAAC,gBAAgB,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAC9C;;;OAGG;IACH,QAAQ,CAAC,UAAU,CAAC,EAAE,SAAS,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,CAAC;IACnD;;;OAGG;IACH,QAAQ,CAAC,OAAO,CAAC,EAAE,SAAS,YAAY,EAAE,CAAC;IAC3C;;;OAGG;IACH,QAAQ,CAAC,UAAU,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACxC;;;OAGG;IACH,QAAQ,CAAC,eAAe,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAC7C;;OAEG;IACH,QAAQ,CAAC,eAAe,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAC7C;;;;;;;;;;;;;;OAcG;IACH,QAAQ,CAAC,mBAAmB,CAAC,EAAE,OAAO,CAAC;IACvC;;;OAGG;IACH,QAAQ,CAAC,UAAU,CAAC,EAAE,kBAAkB,CAAC;IACzC;;OAEG;IACH,QAAQ,CAAC,gBAAgB,CAAC,EAAE,MAAM,CAAC;CACpC;AAoDD;;;;;;;;;;;GAWG;AACH,wBAAgB,sBAAsB,CAAC,OAAO,GAAE,uBAA4B,GAAG,UAAU,CAAC,OAAO,YAAY,CAAC,CAiE7G"}
|
package/dist/vitest.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var
|
|
1
|
+
var i=Object.defineProperty;var r=(e,s)=>i(e,"name",{value:s,configurable:!0});import{defineConfig as u}from"vitest/config";import{asVitePlugins as o}from"./plugin-option.js";import{manifestCoverageThresholds as E}from"./manifest.js";import{DEFAULT_CLOUDFLARE_MOCKS as f,DEFAULT_WORKSPACE_PACKAGES as g,KIT_DEDUPE as p,KIT_NO_EXTERNAL as m,workspaceAliases as v}from"./vitest-aliases.js";import{KIT_DEDUPE as b,KIT_NO_EXTERNAL as k}from"./vitest-aliases.js";const x=["test/web/**","test/**/web-*.test.{ts,tsx}","apps/web/**/*.test.{ts,tsx}"],c=["scripts/**","**/*.test.ts","**/*.test.tsx","**/*.d.ts","**/index.ts","**/types.d.ts","**/model/**","**/generated/**","**/D1Types.ts","**/ServiceEnv.ts","**/env.d.ts"],A="**/index.ts";function _(e){return[...e.includeIndexBarrels?c.filter(t=>t!==A):c,...e.coverageExclude??[]]}r(_,"coverageExcludeFor");function U(e={}){const s=e.root??new URL(".",import.meta.url).href,t=e.thresholds??E(s),d=e.coverageInclude??["apps/api/src/**/*.ts","apps/background/src/**/*.ts","packages/**/src/**/*.ts"],l=_(e),a=[...v({scope:e.scope??"@unused",root:s,packages:e.scope===void 0?[]:e.packages??g,mocks:e.mocks??f}).filter(n=>typeof n.find!="string"||!n.find.startsWith("@unused")),...e.aliases??[]];return u({...e.plugins!==void 0&&{plugins:o(e.plugins)},resolve:{alias:a,noExternal:[...m,...e.noExternal??[]],dedupe:[...p]},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(U,"defineUnitVitestConfig");export{b as KIT_DEDUPE,k as KIT_NO_EXTERNAL,U 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,
|
|
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 } from 'vitest/config';\nimport { asVitePlugins } from './plugin-option.ts';\nimport type { PluginOption } from './plugin-option.ts';\nimport { manifestCoverageThresholds } from './manifest.ts';\nimport { DEFAULT_CLOUDFLARE_MOCKS, DEFAULT_WORKSPACE_PACKAGES, KIT_DEDUPE, KIT_NO_EXTERNAL, workspaceAliases } from './vitest-aliases.ts';\nimport type { VitestAlias } from './vitest-aliases.ts';\n\nexport type { VitestAlias } from './vitest-aliases.ts';\n// Re-exported from this sub-barrel as well as the root, because a consumer\n// configuring **Vite** reaches for this path to find the same constants the vitest\n// factory applies — `KIT_DEDUPE` first, to keep one React between the app and the\n// kit's components. Exporting it only from the root meant that import failed with\n// `does not provide an export named 'KIT_DEDUPE'` at config-load time, which is a\n// build failure before any test runs and no error that names the install.\nexport { KIT_DEDUPE, KIT_NO_EXTERNAL } from './vitest-aliases.ts';\n\n/**\n * Coverage thresholds, in the four figures Vitest gates on.\n */\nexport interface CoverageThresholds {\n readonly statements?: number;\n readonly branches?: number;\n readonly functions?: number;\n readonly lines?: number;\n}\n\n/**\n * What `defineUnitVitestConfig` accepts. Every field is optional: the defaults\n * cover the canonical monorepo layout, and a consumer overrides only what its\n * tree actually differs in.\n */\nexport interface UnitVitestConfigOptions {\n /**\n * The consuming repo's npm scope, e.g. `'@myapp'`. When supplied, `@scope/*`\n * workspace aliases are generated from `packages` (plus `background` under\n * `apps/`); when omitted, only the `cloudflare:*`, `@/` and `~/` aliases\n * apply and `aliases` carries the workspace table by hand.\n */\n readonly scope?: string;\n /**\n * Workspace package directory names. Defaults to the family superset; a repo\n * without a domain package keeps the default harmlessly (its alias never\n * matches).\n */\n readonly packages?: readonly string[];\n /**\n * Which `cloudflare:*` mocks to alias. Defaults to workers/sockets/workflows.\n */\n readonly mocks?: readonly string[];\n /**\n * Extra resolver entries, applied after the canonical ones (e.g. the `hono`\n * dedupe two repos carry, or an `/index.ts` exact entry).\n */\n readonly aliases?: readonly VitestAlias[];\n /**\n * Where the repo root is, as a file URL. Defaults to the directory this\n * factory is *called* from, which is the repo root's `vitest.config.mts`.\n * Pass `new URL('.', import.meta.url).href` explicitly from the caller —\n * never rely on this module's own URL, which points into `node_modules`.\n */\n readonly root?: string;\n /**\n * Which suites to collect. Defaults to the whole unit suite.\n */\n readonly include?: readonly string[];\n /**\n * Suite paths to skip, replacing the default. Defaults re-list\n * `node_modules`/`dist`/`integration` plus every SPA shape.\n */\n readonly exclude?: readonly string[];\n /**\n * `node_modules` specifiers to inline through Vite rather than externalize.\n * Defaults to `['dofs']` (Durable-DAV: `dofs` imports `cloudflare:workers`,\n * which Node rejects before `resolve.alias` is consulted).\n */\n readonly serverDepsInline?: readonly string[];\n /**\n * Resolver `noExternal` patterns. Defaults to keeping `@rexezuge/*` inside\n * Vite's pipeline; see `KIT_NO_EXTERNAL`.\n */\n readonly noExternal?: readonly (string | RegExp)[];\n /**\n * Vite plugins for the suite (rare on the backend half; the SPA half passes\n * `react()` here).\n */\n readonly plugins?: readonly PluginOption[];\n /**\n * Setup files run before each test file (e.g. AWS's floci guard, Meow's\n * backend/web setups).\n */\n readonly setupFiles?: readonly string[];\n /**\n * Coverage `include` globs. Defaults to the worker plus every workspace\n * package's `src`.\n */\n readonly coverageInclude?: readonly string[];\n /**\n * Coverage `exclude` globs, merged with the canonical set.\n */\n readonly coverageExclude?: readonly string[];\n /**\n * Report coverage for `index.ts` re-export barrels.\n *\n * The canonical set excludes them because a barrel carries no logic of its\n * own. Two repos in the family read that differently and deliberately keep\n * them in: a barrel with no importer shows up as an uncovered file, which is\n * the point — it is the only signal that the barrel is dead. Excluding them\n * is what let four entirely unused root barrels sit in the tree unnoticed, one\n * per repo that carried the habit.\n *\n * `coverageExclude` cannot express this, because it is merged with the\n * canonical set rather than replacing it, so a consumer could not opt back in.\n * Hence a named flag. Default `false`: today’s behaviour, unchanged for the\n * seven repos that never asked.\n */\n readonly includeIndexBarrels?: boolean;\n /**\n * Coverage floors. Defaults to the manifest's `quality.coverage` (`.rexezuge.jsonc`\n * at `root`); without one, no floor.\n */\n readonly thresholds?: CoverageThresholds;\n /**\n * Where the coverage report is written.\n */\n readonly reportsDirectory?: string;\n}\n\n/**\n * The SPA's suites, excluded here so the two configs partition the suite.\n *\n * Every shape the family uses: the `test/web/**` directory convention\n * (CalDAV-Bridge, Mail-Meow), the root-suite `web-*` naming convention\n * (Durable-DAV-Router), and suites bundled under `apps/web` (Mail-Otter).\n * `defineWebVitestConfig()` includes the same globs, so a file is collected by\n * exactly one config.\n */\nconst SPA_FILES: readonly string[] = ['test/web/**', 'test/**/web-*.test.{ts,tsx}', 'apps/web/**/*.test.{ts,tsx}'];\n\n/**\n * Coverage `exclude` globs converged from the source repos.\n *\n * The categories: build and test tooling (`scripts/` grows with project surface,\n * not complexity, and the god-file guard excludes it for the same reason), test\n * files, declarations, re-export barrels (`index.ts` carries no logic of its\n * own), model records, generated files (the SPA shell is a one-line HTML blob\n * with no logic to exercise), and type-only modules.\n */\nconst CANONICAL_COVERAGE_EXCLUDE: readonly string[] = [\n 'scripts/**',\n '**/*.test.ts',\n '**/*.test.tsx',\n '**/*.d.ts',\n '**/index.ts',\n '**/types.d.ts',\n '**/model/**',\n '**/generated/**',\n '**/D1Types.ts',\n '**/ServiceEnv.ts',\n '**/env.d.ts',\n];\n\n/**\n * The barrel exclusion, named so `includeIndexBarrels` can lift it.\n */\nconst INDEX_BARREL_EXCLUDE = '**/index.ts';\n\n/**\n * The canonical exclude set, with the barrel entry lifted for a caller that\n * asked to keep barrels in their coverage report.\n */\nfunction coverageExcludeFor(options: { coverageExclude?: readonly string[]; includeIndexBarrels?: boolean }): string[] {\n const canonical = options.includeIndexBarrels\n ? CANONICAL_COVERAGE_EXCLUDE.filter((glob) => glob !== INDEX_BARREL_EXCLUDE)\n : CANONICAL_COVERAGE_EXCLUDE;\n return [...canonical, ...(options.coverageExclude ?? [])];\n}\n\n/**\n * Build the unit-test config.\n *\n * ```ts\n * // vitest.config.mts\n * import { defineUnitVitestConfig } from '@rexezuge/tooling/vitest';\n * export default defineUnitVitestConfig({\n * scope: '@myapp',\n * thresholds: { statements: 60, branches: 55, functions: 65, lines: 60 },\n * });\n * ```\n */\nexport function defineUnitVitestConfig(options: UnitVitestConfigOptions = {}): ReturnType<typeof defineConfig> {\n const root = options.root ?? new URL('.', import.meta.url).href;\n const thresholds = options.thresholds ?? manifestCoverageThresholds(root);\n const coverageInclude = options.coverageInclude ?? ['apps/api/src/**/*.ts', 'apps/background/src/**/*.ts', 'packages/**/src/**/*.ts'];\n const coverageExclude = coverageExcludeFor(options);\n const baseAliases = workspaceAliases({\n scope: options.scope ?? '@unused',\n root,\n packages: options.scope === undefined ? [] : (options.packages ?? DEFAULT_WORKSPACE_PACKAGES),\n mocks: options.mocks ?? DEFAULT_CLOUDFLARE_MOCKS,\n });\n // A placeholder scope contributes no `@unused/*` entries; the mocks plus\n // `@/`/`~/` survive either way.\n const aliases = [\n ...baseAliases.filter((alias) => typeof alias.find !== 'string' || !alias.find.startsWith('@unused')),\n ...(options.aliases ?? []),\n ];\n\n return defineConfig({\n ...(options.plugins !== undefined && { plugins: asVitePlugins(options.plugins) }),\n resolve: {\n alias: aliases,\n noExternal: [...KIT_NO_EXTERNAL, ...(options.noExternal ?? [])],\n // The peer runtime a consumer and the kit must agree on. `@rexezuge/web`\n // declares `react`, `react-dom` and `lucide-react` as peers, which under a\n // registry install means neither package carries its own copy. Under the\n // `link:` workflow this repo's own README recommends, the symlinked\n // directory **does** have one — so the kit resolves its own React and the\n // consumer resolves theirs, and every hook in a kit component throws\n // `Cannot read properties of null (reading 'useState')`. Dedupe points the\n // bare specifier at one copy for both.\n dedupe: [...KIT_DEDUPE],\n },\n test: {\n globals: true,\n environment: 'node',\n include: [...(options.include ?? ['test/**/*.test.{ts,tsx}'])],\n // `test` is a workspace project and therefore has its own node_modules;\n // without the re-list, the glob reaches into it.\n exclude: [...(options.exclude ?? ['**/node_modules/**', '**/dist/**', 'test/integration/**', ...SPA_FILES])],\n ...(options.setupFiles !== undefined && { setupFiles: [...options.setupFiles] }),\n server: {\n deps: {\n // A `node_modules` dependency is externalized by default, so Node's\n // own ESM loader resolves a `cloudflare:workers` specifier and rejects\n // the scheme before `resolve.alias` is ever consulted. Inlining routes\n // it back through Vite, where the alias applies.\n inline: [...(options.serverDepsInline ?? ['dofs'])],\n },\n },\n coverage: {\n provider: 'v8',\n // Vitest 4 removed `coverage.all`; an explicit `include` now reports\n // every matching file whether or not a test imported it, which is the\n // behaviour the source repos' `all: true` was there to get: a brand-new\n // module with no test is counted as zero rather than being invisible,\n // which is the exact regression this gate exists to catch.\n reporter: ['text', 'lcov', 'html'],\n reportsDirectory: options.reportsDirectory ?? './coverage',\n include: [...coverageInclude],\n exclude: coverageExclude,\n ...(thresholds !== undefined && { thresholds: { ...thresholds } }),\n },\n },\n });\n}\n"],
|
|
5
|
+
"mappings": "+EAmCA,OAAS,gBAAAA,MAAoB,gBAC7B,OAAS,iBAAAC,MAAqB,qBAE9B,OAAS,8BAAAC,MAAkC,gBAC3C,OAAS,4BAAAC,EAA0B,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,EAA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DFLARE_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.14.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.14.0",
|
|
52
|
+
"@rexezuge/testing": "1.14.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
|
+
}
|