@rexezuge/tooling 1.2.0 → 1.3.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 +66 -10
- package/dist/eslint-boundaries.d.ts +19 -3
- package/dist/eslint-boundaries.d.ts.map +1 -1
- package/dist/eslint-boundaries.js +89 -3
- package/dist/eslint-boundaries.js.map +1 -1
- package/dist/eslint.d.ts +12 -7
- package/dist/eslint.d.ts.map +1 -1
- package/dist/eslint.js +13 -8
- package/dist/eslint.js.map +1 -1
- package/dist/index.d.ts +20 -14
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +10 -7
- package/dist/index.js.map +1 -1
- package/dist/scripts/backup/d1-target.js +1 -1
- package/dist/scripts/backup/d1-target.js.map +1 -1
- package/dist/scripts/backup/encrypt-backup.js +2 -2
- package/dist/scripts/backup/encrypt-backup.js.map +1 -1
- package/dist/scripts/check-god-files.js +2 -2
- package/dist/scripts/check-god-files.js.map +1 -1
- package/dist/scripts/ensure-spa-shell-stub.js +1 -1
- package/dist/scripts/ensure-spa-shell-stub.js.map +1 -1
- package/dist/scripts/init-secrets.d.ts +1 -1
- package/dist/scripts/init-secrets.d.ts.map +1 -1
- package/dist/scripts/init-secrets.js +3 -3
- package/dist/scripts/init-secrets.js.map +1 -1
- package/dist/scripts/migrations-lock.js +1 -1
- package/dist/scripts/migrations-lock.js.map +1 -1
- package/dist/scripts/prepare-wrangler-config.js +3 -3
- package/dist/scripts/prepare-wrangler-config.js.map +1 -1
- package/dist/scripts/verify-spa-shell.js +1 -1
- package/dist/scripts/verify-spa-shell.js.map +1 -1
- package/dist/scripts/wrangler-config/patches.d.ts +1 -1
- package/dist/scripts/wrangler-config/patches.d.ts.map +1 -1
- package/dist/scripts/wrangler-config/patches.js +1 -1
- package/dist/scripts/wrangler-config/patches.js.map +1 -1
- package/dist/scripts/wrangler-config/resources.d.ts +1 -1
- package/dist/scripts/wrangler-config/resources.d.ts.map +1 -1
- package/dist/scripts/wrangler-config/resources.js +4 -4
- package/dist/scripts/wrangler-config/resources.js.map +1 -1
- package/dist/vitest-aliases.d.ts +90 -0
- package/dist/vitest-aliases.d.ts.map +1 -0
- package/dist/vitest-aliases.js +81 -0
- package/dist/vitest-aliases.js.map +1 -0
- package/dist/vitest-integration.d.ts +96 -0
- package/dist/vitest-integration.d.ts.map +1 -0
- package/dist/vitest-integration.js +64 -0
- package/dist/vitest-integration.js.map +1 -0
- package/dist/vitest-repo.d.ts +154 -0
- package/dist/vitest-repo.d.ts.map +1 -0
- package/dist/vitest-repo.js +146 -0
- package/dist/vitest-repo.js.map +1 -0
- package/dist/vitest-web.d.ts +76 -19
- package/dist/vitest-web.d.ts.map +1 -1
- package/dist/vitest-web.js +62 -25
- package/dist/vitest-web.js.map +1 -1
- package/dist/vitest.d.ts +70 -19
- package/dist/vitest.d.ts.map +1 -1
- package/dist/vitest.js +42 -37
- package/dist/vitest.js.map +1 -1
- package/package.json +8 -2
- package/src/eslint-boundaries.ts +99 -6
- package/src/eslint.test.ts +22 -1
- package/src/eslint.ts +14 -9
- package/src/functions/pages-proxy.test.ts +2 -2
- package/src/index.ts +23 -14
- package/src/scripts/backup/backup-rules.test.ts +3 -3
- package/src/scripts/backup/d1-target.ts +1 -1
- package/src/scripts/backup/encrypt-backup.ts +2 -2
- package/src/scripts/check-god-files.test.ts +1 -1
- package/src/scripts/check-god-files.ts +2 -2
- package/src/scripts/ensure-spa-shell-stub.ts +1 -1
- package/src/scripts/init-secrets.ts +3 -3
- package/src/scripts/migrations-lock.ts +1 -1
- package/src/scripts/prepare-wrangler-config.ts +3 -3
- package/src/scripts/spa-shell.test.ts +1 -1
- package/src/scripts/validate-locales.test.ts +1 -1
- package/src/scripts/verify-migrations.test.ts +1 -1
- package/src/scripts/verify-spa-shell.ts +1 -1
- package/src/scripts/wrangler-config/patches.ts +1 -1
- package/src/scripts/wrangler-config/resources.ts +4 -4
- package/src/test/integration-migrations.test.ts +1 -1
- package/src/vite.test.ts +1 -1
- package/src/vitest-aliases.test.ts +53 -0
- package/src/vitest-aliases.ts +127 -0
- package/src/vitest-factories.test.ts +127 -0
- package/src/vitest-integration.ts +118 -0
- package/src/vitest-repo.ts +269 -0
- package/src/vitest-web.ts +110 -28
- package/src/vitest.ts +96 -47
package/dist/vitest.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* The unit-test Vitest config for the worker-and-packages half of the suite.
|
|
3
3
|
*
|
|
4
|
-
* Provenance: converged from
|
|
4
|
+
* Provenance: converged from all nine repos' `vitest.config.mts`. The coverage
|
|
5
5
|
* block is Durable-DAV-Router's (the most complete: v8 provider, explicit
|
|
6
6
|
* include/exclude patterns, thresholds with the reasoning for why they sit just
|
|
7
|
-
* under the measured value); the alias block is Durable-DAV's
|
|
8
|
-
*
|
|
9
|
-
*
|
|
7
|
+
* under the measured value); the alias block is the union of Durable-DAV's
|
|
8
|
+
* `cloudflare:*` mocks, every repo's `@scope/* → src` workspace table, and the
|
|
9
|
+
* shared `@/` + `~/` prefixes — see {@link ./vitest-aliases.js}.
|
|
10
10
|
*
|
|
11
11
|
* Canonical decisions:
|
|
12
12
|
*
|
|
@@ -17,26 +17,24 @@
|
|
|
17
17
|
* invisible rather than counted as zero, which is the exact regression this
|
|
18
18
|
* gate exists to catch.
|
|
19
19
|
* 2. **The SPA is excluded here**, so this config and `defineWebVitestConfig()`
|
|
20
|
-
* partition the suite rather than each running all of it.
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
* files two directories away.
|
|
20
|
+
* partition the suite rather than each running all of it. The default covers
|
|
21
|
+
* every suite shape the family uses (`test/web/**`, `test/**/web-*`,
|
|
22
|
+
* `apps/web/**`); see `defineRepoVitestConfig()` for the single-file
|
|
23
|
+
* `projects` composition the AWS/Mail-Meow/CalDAV repos use.
|
|
25
24
|
* 3. **A custom `exclude` re-lists `node_modules`** — `test/` is a workspace
|
|
26
25
|
* project and therefore has its own, so without the re-list the glob reaches
|
|
27
26
|
* into `test/node_modules` and tries to run other packages' suites.
|
|
28
27
|
* 4. **Thresholds are a consumer argument**, not a kit default. A floor is a
|
|
29
28
|
* per-repo ratchet measured against that repo's suite; the kit cannot know a
|
|
30
29
|
* number, and guessing one is how floors get lowered.
|
|
30
|
+
* 5. **`@rexezuge/*` is never externalized** — see `KIT_NO_EXTERNAL`: the kit
|
|
31
|
+
* ships ESM `dist/` with bundler-style extensionless imports, which Node's
|
|
32
|
+
* resolver refuses, so the kit stays inside Vite's pipeline (the same
|
|
33
|
+
* resolver that bundles the worker).
|
|
31
34
|
*/
|
|
32
|
-
import { defineConfig } from 'vitest/config';
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
*/
|
|
36
|
-
export interface VitestAlias {
|
|
37
|
-
readonly find: string | RegExp;
|
|
38
|
-
readonly replacement: string;
|
|
39
|
-
}
|
|
35
|
+
import { defineConfig, type Plugin } from 'vitest/config';
|
|
36
|
+
import type { VitestAlias } from './vitest-aliases.ts';
|
|
37
|
+
export type { VitestAlias } from './vitest-aliases.ts';
|
|
40
38
|
/**
|
|
41
39
|
* Coverage thresholds, in the four figures Vitest gates on.
|
|
42
40
|
*/
|
|
@@ -53,14 +51,64 @@ export interface CoverageThresholds {
|
|
|
53
51
|
*/
|
|
54
52
|
export interface UnitVitestConfigOptions {
|
|
55
53
|
/**
|
|
56
|
-
*
|
|
54
|
+
* The consuming repo's npm scope, e.g. `'@myapp'`. When supplied, `@scope/*`
|
|
55
|
+
* workspace aliases are generated from `packages` (plus `background` under
|
|
56
|
+
* `apps/`); when omitted, only the `cloudflare:*`, `@/` and `~/` aliases
|
|
57
|
+
* apply and `aliases` carries the workspace table by hand.
|
|
58
|
+
*/
|
|
59
|
+
readonly scope?: string;
|
|
60
|
+
/**
|
|
61
|
+
* Workspace package directory names. Defaults to the family superset; a repo
|
|
62
|
+
* without a domain package keeps the default harmlessly (its alias never
|
|
63
|
+
* matches).
|
|
64
|
+
*/
|
|
65
|
+
readonly packages?: readonly string[];
|
|
66
|
+
/**
|
|
67
|
+
* Which `cloudflare:*` mocks to alias. Defaults to workers/sockets/workflows.
|
|
68
|
+
*/
|
|
69
|
+
readonly mocks?: readonly string[];
|
|
70
|
+
/**
|
|
71
|
+
* Extra resolver entries, applied after the canonical ones (e.g. the `hono`
|
|
72
|
+
* dedupe two repos carry, or an `/index.ts` exact entry).
|
|
57
73
|
*/
|
|
58
74
|
readonly aliases?: readonly VitestAlias[];
|
|
59
75
|
/**
|
|
60
76
|
* Where the repo root is, as a file URL. Defaults to the directory this
|
|
61
77
|
* factory is *called* from, which is the repo root's `vitest.config.mts`.
|
|
78
|
+
* Pass `new URL('.', import.meta.url).href` explicitly from the caller —
|
|
79
|
+
* never rely on this module's own URL, which points into `node_modules`.
|
|
62
80
|
*/
|
|
63
81
|
readonly root?: string;
|
|
82
|
+
/**
|
|
83
|
+
* Which suites to collect. Defaults to the whole unit suite.
|
|
84
|
+
*/
|
|
85
|
+
readonly include?: readonly string[];
|
|
86
|
+
/**
|
|
87
|
+
* Suite paths to skip, replacing the default. Defaults re-list
|
|
88
|
+
* `node_modules`/`dist`/`integration` plus every SPA shape.
|
|
89
|
+
*/
|
|
90
|
+
readonly exclude?: readonly string[];
|
|
91
|
+
/**
|
|
92
|
+
* `node_modules` specifiers to inline through Vite rather than externalize.
|
|
93
|
+
* Defaults to `['dofs']` (Durable-DAV: `dofs` imports `cloudflare:workers`,
|
|
94
|
+
* which Node rejects before `resolve.alias` is consulted).
|
|
95
|
+
*/
|
|
96
|
+
readonly serverDepsInline?: readonly string[];
|
|
97
|
+
/**
|
|
98
|
+
* Resolver `noExternal` patterns. Defaults to keeping `@rexezuge/*` inside
|
|
99
|
+
* Vite's pipeline; see `KIT_NO_EXTERNAL`.
|
|
100
|
+
*/
|
|
101
|
+
readonly noExternal?: readonly (string | RegExp)[];
|
|
102
|
+
/**
|
|
103
|
+
* Vite plugins for the suite (rare on the backend half; the SPA half passes
|
|
104
|
+
* `react()` here).
|
|
105
|
+
*/
|
|
106
|
+
readonly plugins?: readonly Plugin[];
|
|
107
|
+
/**
|
|
108
|
+
* Setup files run before each test file (e.g. AWS's floci guard, Meow's
|
|
109
|
+
* backend/web setups).
|
|
110
|
+
*/
|
|
111
|
+
readonly setupFiles?: readonly string[];
|
|
64
112
|
/**
|
|
65
113
|
* Coverage `include` globs. Defaults to the worker plus every workspace
|
|
66
114
|
* package's `src`.
|
|
@@ -85,7 +133,10 @@ export interface UnitVitestConfigOptions {
|
|
|
85
133
|
* ```ts
|
|
86
134
|
* // vitest.config.mts
|
|
87
135
|
* import { defineUnitVitestConfig } from '@rexezuge/tooling/vitest';
|
|
88
|
-
* export default defineUnitVitestConfig(
|
|
136
|
+
* export default defineUnitVitestConfig({
|
|
137
|
+
* scope: '@myapp',
|
|
138
|
+
* thresholds: { statements: 60, branches: 55, functions: 65, lines: 60 },
|
|
139
|
+
* });
|
|
89
140
|
* ```
|
|
90
141
|
*/
|
|
91
142
|
export declare function defineUnitVitestConfig(options?: UnitVitestConfigOptions): ReturnType<typeof defineConfig>;
|
package/dist/vitest.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vitest.d.ts","sourceRoot":"","sources":["../src/vitest.ts"],"names":[],"mappings":"AAAA
|
|
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;AAEvD;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;CACzB;AAED;;;;GAIG;AACH,MAAM,WAAW,uBAAuB;IACtC;;;;;OAKG;IACH,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IACxB;;;;OAIG;IACH,QAAQ,CAAC,QAAQ,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACtC;;OAEG;IACH,QAAQ,CAAC,KAAK,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACnC;;;OAGG;IACH,QAAQ,CAAC,OAAO,CAAC,EAAE,SAAS,WAAW,EAAE,CAAC;IAC1C;;;;;OAKG;IACH,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB;;OAEG;IACH,QAAQ,CAAC,OAAO,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACrC;;;OAGG;IACH,QAAQ,CAAC,OAAO,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACrC;;;;OAIG;IACH,QAAQ,CAAC,gBAAgB,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAC9C;;;OAGG;IACH,QAAQ,CAAC,UAAU,CAAC,EAAE,SAAS,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,CAAC;IACnD;;;OAGG;IACH,QAAQ,CAAC,OAAO,CAAC,EAAE,SAAS,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;;OAEG;IACH,QAAQ,CAAC,UAAU,CAAC,EAAE,kBAAkB,CAAC;IACzC;;OAEG;IACH,QAAQ,CAAC,gBAAgB,CAAC,EAAE,MAAM,CAAC;CACpC;AAoCD;;;;;;;;;;;GAWG;AACH,wBAAgB,sBAAsB,CAAC,OAAO,GAAE,uBAA4B,GAAG,UAAU,CAAC,OAAO,YAAY,CAAC,CAoD7G"}
|
package/dist/vitest.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* The unit-test Vitest config for the worker-and-packages half of the suite.
|
|
3
3
|
*
|
|
4
|
-
* Provenance: converged from
|
|
4
|
+
* Provenance: converged from all nine repos' `vitest.config.mts`. The coverage
|
|
5
5
|
* block is Durable-DAV-Router's (the most complete: v8 provider, explicit
|
|
6
6
|
* include/exclude patterns, thresholds with the reasoning for why they sit just
|
|
7
|
-
* under the measured value); the alias block is Durable-DAV's
|
|
8
|
-
*
|
|
9
|
-
*
|
|
7
|
+
* under the measured value); the alias block is the union of Durable-DAV's
|
|
8
|
+
* `cloudflare:*` mocks, every repo's `@scope/* → src` workspace table, and the
|
|
9
|
+
* shared `@/` + `~/` prefixes — see {@link ./vitest-aliases.js}.
|
|
10
10
|
*
|
|
11
11
|
* Canonical decisions:
|
|
12
12
|
*
|
|
@@ -17,45 +17,33 @@
|
|
|
17
17
|
* invisible rather than counted as zero, which is the exact regression this
|
|
18
18
|
* gate exists to catch.
|
|
19
19
|
* 2. **The SPA is excluded here**, so this config and `defineWebVitestConfig()`
|
|
20
|
-
* partition the suite rather than each running all of it.
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
* files two directories away.
|
|
20
|
+
* partition the suite rather than each running all of it. The default covers
|
|
21
|
+
* every suite shape the family uses (`test/web/**`, `test/**/web-*`,
|
|
22
|
+
* `apps/web/**`); see `defineRepoVitestConfig()` for the single-file
|
|
23
|
+
* `projects` composition the AWS/Mail-Meow/CalDAV repos use.
|
|
25
24
|
* 3. **A custom `exclude` re-lists `node_modules`** — `test/` is a workspace
|
|
26
25
|
* project and therefore has its own, so without the re-list the glob reaches
|
|
27
26
|
* into `test/node_modules` and tries to run other packages' suites.
|
|
28
27
|
* 4. **Thresholds are a consumer argument**, not a kit default. A floor is a
|
|
29
28
|
* per-repo ratchet measured against that repo's suite; the kit cannot know a
|
|
30
29
|
* number, and guessing one is how floors get lowered.
|
|
30
|
+
* 5. **`@rexezuge/*` is never externalized** — see `KIT_NO_EXTERNAL`: the kit
|
|
31
|
+
* ships ESM `dist/` with bundler-style extensionless imports, which Node's
|
|
32
|
+
* resolver refuses, so the kit stays inside Vite's pipeline (the same
|
|
33
|
+
* resolver that bundles the worker).
|
|
31
34
|
*/
|
|
32
35
|
import { defineConfig } from 'vitest/config';
|
|
33
|
-
import {
|
|
36
|
+
import { DEFAULT_CLOUDFLARE_MOCKS, DEFAULT_WORKSPACE_PACKAGES, KIT_NO_EXTERNAL, workspaceAliases } from "./vitest-aliases.js";
|
|
34
37
|
/**
|
|
35
38
|
* The SPA's suites, excluded here so the two configs partition the suite.
|
|
36
39
|
*
|
|
37
|
-
* Every
|
|
38
|
-
*
|
|
40
|
+
* Every shape the family uses: the `test/web/**` directory convention
|
|
41
|
+
* (CalDAV-Bridge, Mail-Meow), the root-suite `web-*` naming convention
|
|
42
|
+
* (Durable-DAV-Router), and suites bundled under `apps/web` (Mail-Otter).
|
|
43
|
+
* `defineWebVitestConfig()` includes the same globs, so a file is collected by
|
|
44
|
+
* exactly one config.
|
|
39
45
|
*/
|
|
40
|
-
const SPA_FILES = 'test/**/web-*.test.{ts,tsx}';
|
|
41
|
-
/**
|
|
42
|
-
* The canonical alias set.
|
|
43
|
-
*
|
|
44
|
-
* Built relative to the consumer's repo root rather than the kit's directory,
|
|
45
|
-
* so the factory describes *their* layout. A Vitest config is a standalone file
|
|
46
|
-
* with no module graph to share through, and a suite resolving a workspace
|
|
47
|
-
* import differently from its sibling fails in a way that looks like a product
|
|
48
|
-
* bug — which is why these are stated once, here, rather than duplicated.
|
|
49
|
-
*/
|
|
50
|
-
function canonicalAliases(root) {
|
|
51
|
-
const at = (relative) => fileURLToPath(new URL(relative, root));
|
|
52
|
-
return [
|
|
53
|
-
{ find: 'cloudflare:workers', replacement: at('test/mocks/cloudflare-workers.ts') },
|
|
54
|
-
{ find: 'cloudflare:sockets', replacement: at('test/mocks/cloudflare-sockets.ts') },
|
|
55
|
-
{ find: /^@\//, replacement: `${at('apps/api/src')}/` },
|
|
56
|
-
{ find: /^~\//, replacement: `${at('apps/web/src')}/` },
|
|
57
|
-
];
|
|
58
|
-
}
|
|
46
|
+
const SPA_FILES = ['test/web/**', 'test/**/web-*.test.{ts,tsx}', 'apps/web/**/*.test.{ts,tsx}'];
|
|
59
47
|
/**
|
|
60
48
|
* Coverage `exclude` globs converged from the source repos.
|
|
61
49
|
*
|
|
@@ -68,6 +56,7 @@ function canonicalAliases(root) {
|
|
|
68
56
|
const CANONICAL_COVERAGE_EXCLUDE = [
|
|
69
57
|
'scripts/**',
|
|
70
58
|
'**/*.test.ts',
|
|
59
|
+
'**/*.test.tsx',
|
|
71
60
|
'**/*.d.ts',
|
|
72
61
|
'**/index.ts',
|
|
73
62
|
'**/types.d.ts',
|
|
@@ -83,30 +72,46 @@ const CANONICAL_COVERAGE_EXCLUDE = [
|
|
|
83
72
|
* ```ts
|
|
84
73
|
* // vitest.config.mts
|
|
85
74
|
* import { defineUnitVitestConfig } from '@rexezuge/tooling/vitest';
|
|
86
|
-
* export default defineUnitVitestConfig(
|
|
75
|
+
* export default defineUnitVitestConfig({
|
|
76
|
+
* scope: '@myapp',
|
|
77
|
+
* thresholds: { statements: 60, branches: 55, functions: 65, lines: 60 },
|
|
78
|
+
* });
|
|
87
79
|
* ```
|
|
88
80
|
*/
|
|
89
81
|
export function defineUnitVitestConfig(options = {}) {
|
|
90
82
|
const root = options.root ?? new URL('.', import.meta.url).href;
|
|
91
83
|
const coverageInclude = options.coverageInclude ?? ['apps/api/src/**/*.ts', 'apps/background/src/**/*.ts', 'packages/**/src/**/*.ts'];
|
|
92
84
|
const coverageExclude = [...CANONICAL_COVERAGE_EXCLUDE, ...(options.coverageExclude ?? [])];
|
|
93
|
-
const
|
|
85
|
+
const baseAliases = workspaceAliases({
|
|
86
|
+
scope: options.scope ?? '@unused',
|
|
87
|
+
root,
|
|
88
|
+
packages: options.scope === undefined ? [] : (options.packages ?? DEFAULT_WORKSPACE_PACKAGES),
|
|
89
|
+
mocks: options.mocks ?? DEFAULT_CLOUDFLARE_MOCKS,
|
|
90
|
+
});
|
|
91
|
+
// A placeholder scope contributes no `@unused/*` entries; the mocks plus
|
|
92
|
+
// `@/`/`~/` survive either way.
|
|
93
|
+
const aliases = [
|
|
94
|
+
...baseAliases.filter((alias) => typeof alias.find !== 'string' || !alias.find.startsWith('@unused')),
|
|
95
|
+
...(options.aliases ?? []),
|
|
96
|
+
];
|
|
94
97
|
return defineConfig({
|
|
95
|
-
|
|
98
|
+
...(options.plugins !== undefined && { plugins: [...options.plugins] }),
|
|
99
|
+
resolve: { alias: aliases, noExternal: [...KIT_NO_EXTERNAL, ...(options.noExternal ?? [])] },
|
|
96
100
|
test: {
|
|
97
101
|
globals: true,
|
|
98
102
|
environment: 'node',
|
|
99
|
-
include: ['test/**/*.test.{ts,tsx}'],
|
|
103
|
+
include: [...(options.include ?? ['test/**/*.test.{ts,tsx}'])],
|
|
100
104
|
// `test` is a workspace project and therefore has its own node_modules;
|
|
101
105
|
// without the re-list, the glob reaches into it.
|
|
102
|
-
exclude: ['**/node_modules/**', '**/dist/**', 'test/integration/**', SPA_FILES],
|
|
106
|
+
exclude: [...(options.exclude ?? ['**/node_modules/**', '**/dist/**', 'test/integration/**', ...SPA_FILES])],
|
|
107
|
+
...(options.setupFiles !== undefined && { setupFiles: [...options.setupFiles] }),
|
|
103
108
|
server: {
|
|
104
109
|
deps: {
|
|
105
110
|
// A `node_modules` dependency is externalized by default, so Node's
|
|
106
111
|
// own ESM loader resolves a `cloudflare:workers` specifier and rejects
|
|
107
112
|
// the scheme before `resolve.alias` is ever consulted. Inlining routes
|
|
108
113
|
// it back through Vite, where the alias applies.
|
|
109
|
-
inline: ['dofs'],
|
|
114
|
+
inline: [...(options.serverDepsInline ?? ['dofs'])],
|
|
110
115
|
},
|
|
111
116
|
},
|
|
112
117
|
coverage: {
|
package/dist/vitest.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vitest.js","sourceRoot":"","sources":["../src/vitest.ts"],"names":[],"mappings":"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","sourcesContent":["/**\n * The unit-test Vitest config for the worker-and-packages half of the suite.\n *\n * Provenance: converged from the eight 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 Durable-DAV's, which is the only\n * one that also aliases `cloudflare:workers` and `cloudflare:sockets` to the\n * Node mocks.\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. Every SPA suite is\n * named `web-*`. One number could not honestly describe both halves: the SPA's\n * presentational modules pulled a shared floor down 16 points, so a change\n * adding legitimate code in `apps/api` could fail the gate on the strength of\n * files two directories away.\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 */\n\nimport { defineConfig } from 'vitest/config';\nimport { fileURLToPath } from 'node:url';\n\n/**\n * One `{ find, replacement }` pair for Vitest's resolver.\n */\nexport interface VitestAlias {\n readonly find: string | RegExp;\n readonly replacement: string;\n}\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 * Extra resolver entries, applied after the canonical ones.\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 */\n readonly root?: 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 SPA suite is named `web-*`. `defineWebVitestConfig()` includes the same\n * glob, so a file is collected by exactly one config.\n */\nconst SPA_FILES = 'test/**/web-*.test.{ts,tsx}';\n\n/**\n * The canonical alias set.\n *\n * Built relative to the consumer's repo root rather than the kit's directory,\n * so the factory describes *their* layout. A Vitest config is a standalone file\n * with no module graph to share through, and a suite resolving a workspace\n * import differently from its sibling fails in a way that looks like a product\n * bug — which is why these are stated once, here, rather than duplicated.\n */\nfunction canonicalAliases(root: string): VitestAlias[] {\n const at = (relative: string): string => fileURLToPath(new URL(relative, root));\n return [\n { find: 'cloudflare:workers', replacement: at('test/mocks/cloudflare-workers.ts') },\n { find: 'cloudflare:sockets', replacement: at('test/mocks/cloudflare-sockets.ts') },\n { find: /^@\\//, replacement: `${at('apps/api/src')}/` },\n { find: /^~\\//, replacement: `${at('apps/web/src')}/` },\n ];\n}\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 '**/*.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 * ```\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 aliases = [...canonicalAliases(root), ...(options.aliases ?? [])];\n\n return defineConfig({\n resolve: { alias: aliases },\n test: {\n globals: true,\n environment: 'node',\n 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: ['**/node_modules/**', '**/dist/**', 'test/integration/**', SPA_FILES],\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: ['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"]}
|
|
1
|
+
{"version":3,"file":"vitest.js","sourceRoot":"","sources":["../src/vitest.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AAEH,OAAO,EAAE,YAAY,EAAe,MAAM,eAAe,CAAC;AAC1D,OAAO,EAAE,wBAAwB,EAAE,0BAA0B,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAmG9H;;;;;;;;GAQG;AACH,MAAM,SAAS,GAAsB,CAAC,aAAa,EAAE,6BAA6B,EAAE,6BAA6B,CAAC,CAAC;AAEnH;;;;;;;;GAQG;AACH,MAAM,0BAA0B,GAAsB;IACpD,YAAY;IACZ,cAAc;IACd,eAAe;IACf,WAAW;IACX,aAAa;IACb,eAAe;IACf,aAAa;IACb,iBAAiB;IACjB,eAAe;IACf,kBAAkB;IAClB,aAAa;CACd,CAAC;AAEF;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,sBAAsB,CAAC,UAAmC,EAAE;IAC1E,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,IAAI,IAAI,GAAG,CAAC,GAAG,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC;IAChE,MAAM,eAAe,GAAG,OAAO,CAAC,eAAe,IAAI,CAAC,sBAAsB,EAAE,6BAA6B,EAAE,yBAAyB,CAAC,CAAC;IACtI,MAAM,eAAe,GAAG,CAAC,GAAG,0BAA0B,EAAE,GAAG,CAAC,OAAO,CAAC,eAAe,IAAI,EAAE,CAAC,CAAC,CAAC;IAC5F,MAAM,WAAW,GAAG,gBAAgB,CAAC;QACnC,KAAK,EAAE,OAAO,CAAC,KAAK,IAAI,SAAS;QACjC,IAAI;QACJ,QAAQ,EAAE,OAAO,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,QAAQ,IAAI,0BAA0B,CAAC;QAC7F,KAAK,EAAE,OAAO,CAAC,KAAK,IAAI,wBAAwB;KACjD,CAAC,CAAC;IACH,yEAAyE;IACzE,gCAAgC;IAChC,MAAM,OAAO,GAAG;QACd,GAAG,WAAW,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,OAAO,KAAK,CAAC,IAAI,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC;QACrG,GAAG,CAAC,OAAO,CAAC,OAAO,IAAI,EAAE,CAAC;KAC3B,CAAC;IAEF,OAAO,YAAY,CAAC;QAClB,GAAG,CAAC,OAAO,CAAC,OAAO,KAAK,SAAS,IAAI,EAAE,OAAO,EAAE,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;QACvE,OAAO,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE,UAAU,EAAE,CAAC,GAAG,eAAe,EAAE,GAAG,CAAC,OAAO,CAAC,UAAU,IAAI,EAAE,CAAC,CAAC,EAAE;QAC5F,IAAI,EAAE;YACJ,OAAO,EAAE,IAAI;YACb,WAAW,EAAE,MAAM;YACnB,OAAO,EAAE,CAAC,GAAG,CAAC,OAAO,CAAC,OAAO,IAAI,CAAC,yBAAyB,CAAC,CAAC,CAAC;YAC9D,wEAAwE;YACxE,iDAAiD;YACjD,OAAO,EAAE,CAAC,GAAG,CAAC,OAAO,CAAC,OAAO,IAAI,CAAC,oBAAoB,EAAE,YAAY,EAAE,qBAAqB,EAAE,GAAG,SAAS,CAAC,CAAC,CAAC;YAC5G,GAAG,CAAC,OAAO,CAAC,UAAU,KAAK,SAAS,IAAI,EAAE,UAAU,EAAE,CAAC,GAAG,OAAO,CAAC,UAAU,CAAC,EAAE,CAAC;YAChF,MAAM,EAAE;gBACN,IAAI,EAAE;oBACJ,oEAAoE;oBACpE,uEAAuE;oBACvE,uEAAuE;oBACvE,iDAAiD;oBACjD,MAAM,EAAE,CAAC,GAAG,CAAC,OAAO,CAAC,gBAAgB,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;iBACpD;aACF;YACD,QAAQ,EAAE;gBACR,QAAQ,EAAE,IAAI;gBACd,qEAAqE;gBACrE,sEAAsE;gBACtE,wEAAwE;gBACxE,sEAAsE;gBACtE,2DAA2D;gBAC3D,QAAQ,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC;gBAClC,gBAAgB,EAAE,OAAO,CAAC,gBAAgB,IAAI,YAAY;gBAC1D,OAAO,EAAE,CAAC,GAAG,eAAe,CAAC;gBAC7B,OAAO,EAAE,eAAe;gBACxB,GAAG,CAAC,OAAO,CAAC,UAAU,KAAK,SAAS,IAAI,EAAE,UAAU,EAAE,EAAE,GAAG,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC;aACnF;SACF;KACF,CAAC,CAAC;AACL,CAAC","sourcesContent":["/**\n * The unit-test Vitest config for the worker-and-packages half of the suite.\n *\n * Provenance: converged from all nine repos' `vitest.config.mts`. The coverage\n * block is Durable-DAV-Router's (the most complete: v8 provider, explicit\n * include/exclude patterns, thresholds with the reasoning for why they sit just\n * under the measured value); the alias block is the union of Durable-DAV's\n * `cloudflare:*` mocks, every repo's `@scope/* → src` workspace table, and the\n * shared `@/` + `~/` prefixes — see {@link ./vitest-aliases.js}.\n *\n * Canonical decisions:\n *\n * 1. **Every file matching `include` is reported** — Vitest 4 removed\n * `coverage.all`, and an explicit `include` now covers files no test\n * imported. That is the behaviour the source repos configured `all: true` for,\n * and the reason it mattered: without it a brand-new module with no test is\n * invisible rather than counted as zero, which is the exact regression this\n * gate exists to catch.\n * 2. **The SPA is excluded here**, so this config and `defineWebVitestConfig()`\n * partition the suite rather than each running all of it. The default covers\n * every suite shape the family uses (`test/web/**`, `test/**/web-*`,\n * `apps/web/**`); see `defineRepoVitestConfig()` for the single-file\n * `projects` composition the AWS/Mail-Meow/CalDAV repos use.\n * 3. **A custom `exclude` re-lists `node_modules`** — `test/` is a workspace\n * project and therefore has its own, so without the re-list the glob reaches\n * into `test/node_modules` and tries to run other packages' suites.\n * 4. **Thresholds are a consumer argument**, not a kit default. A floor is a\n * per-repo ratchet measured against that repo's suite; the kit cannot know a\n * number, and guessing one is how floors get lowered.\n * 5. **`@rexezuge/*` is never externalized** — see `KIT_NO_EXTERNAL`: the kit\n * ships ESM `dist/` with bundler-style extensionless imports, which Node's\n * resolver refuses, so the kit stays inside Vite's pipeline (the same\n * resolver that bundles the worker).\n */\n\nimport { defineConfig, type Plugin } from 'vitest/config';\nimport { DEFAULT_CLOUDFLARE_MOCKS, DEFAULT_WORKSPACE_PACKAGES, KIT_NO_EXTERNAL, workspaceAliases } from './vitest-aliases.ts';\nimport type { VitestAlias } from './vitest-aliases.ts';\n\nexport type { VitestAlias } from './vitest-aliases.ts';\n\n/**\n * Coverage thresholds, in the four figures Vitest gates on.\n */\nexport interface CoverageThresholds {\n readonly statements?: number;\n readonly branches?: number;\n readonly functions?: number;\n readonly lines?: number;\n}\n\n/**\n * What `defineUnitVitestConfig` accepts. Every field is optional: the defaults\n * cover the canonical monorepo layout, and a consumer overrides only what its\n * tree actually differs in.\n */\nexport interface UnitVitestConfigOptions {\n /**\n * The consuming repo's npm scope, e.g. `'@myapp'`. When supplied, `@scope/*`\n * workspace aliases are generated from `packages` (plus `background` under\n * `apps/`); when omitted, only the `cloudflare:*`, `@/` and `~/` aliases\n * apply and `aliases` carries the workspace table by hand.\n */\n readonly scope?: string;\n /**\n * Workspace package directory names. Defaults to the family superset; a repo\n * without a domain package keeps the default harmlessly (its alias never\n * matches).\n */\n readonly packages?: readonly string[];\n /**\n * Which `cloudflare:*` mocks to alias. Defaults to workers/sockets/workflows.\n */\n readonly mocks?: readonly string[];\n /**\n * Extra resolver entries, applied after the canonical ones (e.g. the `hono`\n * dedupe two repos carry, or an `/index.ts` exact entry).\n */\n readonly aliases?: readonly VitestAlias[];\n /**\n * Where the repo root is, as a file URL. Defaults to the directory this\n * factory is *called* from, which is the repo root's `vitest.config.mts`.\n * Pass `new URL('.', import.meta.url).href` explicitly from the caller —\n * never rely on this module's own URL, which points into `node_modules`.\n */\n readonly root?: string;\n /**\n * Which suites to collect. Defaults to the whole unit suite.\n */\n readonly include?: readonly string[];\n /**\n * Suite paths to skip, replacing the default. Defaults re-list\n * `node_modules`/`dist`/`integration` plus every SPA shape.\n */\n readonly exclude?: readonly string[];\n /**\n * `node_modules` specifiers to inline through Vite rather than externalize.\n * Defaults to `['dofs']` (Durable-DAV: `dofs` imports `cloudflare:workers`,\n * which Node rejects before `resolve.alias` is consulted).\n */\n readonly serverDepsInline?: readonly string[];\n /**\n * Resolver `noExternal` patterns. Defaults to keeping `@rexezuge/*` inside\n * Vite's pipeline; see `KIT_NO_EXTERNAL`.\n */\n readonly noExternal?: readonly (string | RegExp)[];\n /**\n * Vite plugins for the suite (rare on the backend half; the SPA half passes\n * `react()` here).\n */\n readonly plugins?: readonly Plugin[];\n /**\n * Setup files run before each test file (e.g. AWS's floci guard, Meow's\n * backend/web setups).\n */\n readonly setupFiles?: readonly string[];\n /**\n * Coverage `include` globs. Defaults to the worker plus every workspace\n * package's `src`.\n */\n readonly coverageInclude?: readonly string[];\n /**\n * Coverage `exclude` globs, merged with the canonical set.\n */\n readonly coverageExclude?: readonly string[];\n /**\n * Coverage floors. Omitted by default; a repo that wants them sets them.\n */\n readonly thresholds?: CoverageThresholds;\n /**\n * Where the coverage report is written.\n */\n readonly reportsDirectory?: string;\n}\n\n/**\n * The SPA's suites, excluded here so the two configs partition the suite.\n *\n * Every shape the family uses: the `test/web/**` directory convention\n * (CalDAV-Bridge, Mail-Meow), the root-suite `web-*` naming convention\n * (Durable-DAV-Router), and suites bundled under `apps/web` (Mail-Otter).\n * `defineWebVitestConfig()` includes the same globs, so a file is collected by\n * exactly one config.\n */\nconst SPA_FILES: readonly string[] = ['test/web/**', 'test/**/web-*.test.{ts,tsx}', 'apps/web/**/*.test.{ts,tsx}'];\n\n/**\n * Coverage `exclude` globs converged from the source repos.\n *\n * The categories: build and test tooling (`scripts/` grows with project surface,\n * not complexity, and the god-file guard excludes it for the same reason), test\n * files, declarations, re-export barrels (`index.ts` carries no logic of its\n * own), model records, generated files (the SPA shell is a one-line HTML blob\n * with no logic to exercise), and type-only modules.\n */\nconst CANONICAL_COVERAGE_EXCLUDE: readonly string[] = [\n 'scripts/**',\n '**/*.test.ts',\n '**/*.test.tsx',\n '**/*.d.ts',\n '**/index.ts',\n '**/types.d.ts',\n '**/model/**',\n '**/generated/**',\n '**/D1Types.ts',\n '**/ServiceEnv.ts',\n '**/env.d.ts',\n];\n\n/**\n * Build the unit-test config.\n *\n * ```ts\n * // vitest.config.mts\n * import { defineUnitVitestConfig } from '@rexezuge/tooling/vitest';\n * export default defineUnitVitestConfig({\n * scope: '@myapp',\n * thresholds: { statements: 60, branches: 55, functions: 65, lines: 60 },\n * });\n * ```\n */\nexport function defineUnitVitestConfig(options: UnitVitestConfigOptions = {}): ReturnType<typeof defineConfig> {\n const root = options.root ?? new URL('.', import.meta.url).href;\n const coverageInclude = options.coverageInclude ?? ['apps/api/src/**/*.ts', 'apps/background/src/**/*.ts', 'packages/**/src/**/*.ts'];\n const coverageExclude = [...CANONICAL_COVERAGE_EXCLUDE, ...(options.coverageExclude ?? [])];\n const baseAliases = workspaceAliases({\n scope: options.scope ?? '@unused',\n root,\n packages: options.scope === undefined ? [] : (options.packages ?? DEFAULT_WORKSPACE_PACKAGES),\n mocks: options.mocks ?? DEFAULT_CLOUDFLARE_MOCKS,\n });\n // A placeholder scope contributes no `@unused/*` entries; the mocks plus\n // `@/`/`~/` survive either way.\n const aliases = [\n ...baseAliases.filter((alias) => typeof alias.find !== 'string' || !alias.find.startsWith('@unused')),\n ...(options.aliases ?? []),\n ];\n\n return defineConfig({\n ...(options.plugins !== undefined && { plugins: [...options.plugins] }),\n resolve: { alias: aliases, noExternal: [...KIT_NO_EXTERNAL, ...(options.noExternal ?? [])] },\n test: {\n globals: true,\n environment: 'node',\n include: [...(options.include ?? ['test/**/*.test.{ts,tsx}'])],\n // `test` is a workspace project and therefore has its own node_modules;\n // without the re-list, the glob reaches into it.\n exclude: [...(options.exclude ?? ['**/node_modules/**', '**/dist/**', 'test/integration/**', ...SPA_FILES])],\n ...(options.setupFiles !== undefined && { setupFiles: [...options.setupFiles] }),\n server: {\n deps: {\n // A `node_modules` dependency is externalized by default, so Node's\n // own ESM loader resolves a `cloudflare:workers` specifier and rejects\n // the scheme before `resolve.alias` is ever consulted. Inlining routes\n // it back through Vite, where the alias applies.\n inline: [...(options.serverDepsInline ?? ['dofs'])],\n },\n },\n coverage: {\n provider: 'v8',\n // Vitest 4 removed `coverage.all`; an explicit `include` now reports\n // every matching file whether or not a test imported it, which is the\n // behaviour the source repos' `all: true` was there to get: a brand-new\n // module with no test is counted as zero rather than being invisible,\n // which is the exact regression this gate exists to catch.\n reporter: ['text', 'lcov', 'html'],\n reportsDirectory: options.reportsDirectory ?? './coverage',\n include: [...coverageInclude],\n exclude: coverageExclude,\n ...(options.thresholds !== undefined && { thresholds: { ...options.thresholds } }),\n },\n },\n });\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rexezuge/tooling",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -26,10 +26,16 @@
|
|
|
26
26
|
"src"
|
|
27
27
|
],
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@rexezuge/d1": "1.
|
|
29
|
+
"@rexezuge/d1": "1.3.0"
|
|
30
30
|
},
|
|
31
31
|
"peerDependencies": {
|
|
32
32
|
"eslint": "^10.0.0",
|
|
33
|
+
"eslint-config-prettier": "^10.1.8",
|
|
34
|
+
"eslint-plugin-prettier": "^5.5.6",
|
|
35
|
+
"eslint-plugin-regexp": "^3.3.1",
|
|
36
|
+
"eslint-plugin-sonarjs": "^4.2.2",
|
|
37
|
+
"eslint-plugin-unicorn": "^76.0.0",
|
|
38
|
+
"globals": "^17.13.0",
|
|
33
39
|
"jsonc-parser": "^3.3.1",
|
|
34
40
|
"prettier": "^3.9.0",
|
|
35
41
|
"typescript": "^6.0.0",
|
package/src/eslint-boundaries.ts
CHANGED
|
@@ -9,10 +9,20 @@ import type tseslint from 'typescript-eslint';
|
|
|
9
9
|
* argues about — are their own module rather than the tail of a 640-line
|
|
10
10
|
* config file.
|
|
11
11
|
*
|
|
12
|
+
* Converged across all nine family repos: `provider-clients` (AWS-AccessBridge,
|
|
13
|
+
* CalDAV-Bridge, Mail-Meow, Mail-Otter), `webdav`/`dav-store` (Durable-DAV,
|
|
14
|
+
* Durable-DAV-Router, Edge-Sonic), `git-protocol`/`git-service` (Edge-Git).
|
|
15
|
+
* `media-tags`/`subsonic` (Edge-Sonic) carry no boundary block in their source
|
|
16
|
+
* repo — they are unconstrained utility leaves — so they have no layer here.
|
|
17
|
+
*
|
|
12
18
|
* The table is data rather than inline blocks so the dynamic-`import()` guard
|
|
13
19
|
* is generated from the same list: a rule that derived its banned set from
|
|
14
20
|
* another rule's configuration would be a second source of truth for the layer
|
|
15
21
|
* table, and that table is what the docs describe.
|
|
22
|
+
*
|
|
23
|
+
* The table is a superset: a repo without a domain package simply never imports
|
|
24
|
+
* it, so its ban never fires. A layer entry for a directory that does not exist
|
|
25
|
+
* in the consumer matches no file and costs nothing.
|
|
16
26
|
*/
|
|
17
27
|
|
|
18
28
|
/**
|
|
@@ -27,6 +37,11 @@ export const DEFAULT_PROJECT_DIRS: readonly string[] = [
|
|
|
27
37
|
'packages/backend-errors',
|
|
28
38
|
'packages/backend-runtime',
|
|
29
39
|
'packages/backend-data',
|
|
40
|
+
'packages/provider-clients',
|
|
41
|
+
'packages/webdav',
|
|
42
|
+
'packages/dav-store',
|
|
43
|
+
'packages/git-protocol',
|
|
44
|
+
'packages/git-service',
|
|
30
45
|
'packages/backend-services',
|
|
31
46
|
'apps/api',
|
|
32
47
|
'apps/background',
|
|
@@ -36,10 +51,16 @@ export const DEFAULT_PROJECT_DIRS: readonly string[] = [
|
|
|
36
51
|
/**
|
|
37
52
|
* One layer's ban list, as the repo-relative package suffixes it may not import.
|
|
38
53
|
*
|
|
39
|
-
* Converged from
|
|
40
|
-
* appear in all
|
|
41
|
-
*
|
|
54
|
+
* Converged from all nine family repos. `backend-data` and `backend-services`
|
|
55
|
+
* appear in all nine; `provider-clients` is AWS-AccessBridge's, CalDAV-Bridge's,
|
|
56
|
+
* Mail-Meow's and Mail-Otter's; `webdav`/`dav-store` are Durable-DAV's,
|
|
57
|
+
* Durable-DAV-Router's and Edge-Sonic's; `git-protocol`/`git-service` are
|
|
58
|
+
* Edge-Git's. A layer only bans what exists in its repo, so the
|
|
42
59
|
* union is safe: a repo without `provider-clients` simply never imports it.
|
|
60
|
+
*
|
|
61
|
+
* One `dir` may appear in several entries (see `apps/api` below): each entry
|
|
62
|
+
* carries its own message and `allowTypeImports`, because the DAO ban allows
|
|
63
|
+
* type-only imports and the direct-client bans do not.
|
|
43
64
|
*/
|
|
44
65
|
export interface LayerBan {
|
|
45
66
|
/** Directory the rule is scoped to. */
|
|
@@ -70,14 +91,65 @@ export function layerBans(scope: string): readonly LayerBan[] {
|
|
|
70
91
|
},
|
|
71
92
|
{
|
|
72
93
|
dir: 'packages/backend-runtime',
|
|
73
|
-
ban: [
|
|
94
|
+
ban: [
|
|
95
|
+
at('backend-data'),
|
|
96
|
+
at('provider-clients'),
|
|
97
|
+
at('webdav'),
|
|
98
|
+
at('dav-store'),
|
|
99
|
+
at('git-protocol'),
|
|
100
|
+
at('git-service'),
|
|
101
|
+
at('backend-services'),
|
|
102
|
+
at('api'),
|
|
103
|
+
at('background'),
|
|
104
|
+
],
|
|
74
105
|
message: 'backend-runtime must not import from a higher layer',
|
|
75
106
|
},
|
|
76
107
|
{
|
|
77
108
|
dir: 'packages/backend-data',
|
|
78
|
-
ban: [
|
|
109
|
+
ban: [
|
|
110
|
+
at('backend-runtime'),
|
|
111
|
+
at('provider-clients'),
|
|
112
|
+
at('webdav'),
|
|
113
|
+
at('dav-store'),
|
|
114
|
+
at('git-protocol'),
|
|
115
|
+
at('git-service'),
|
|
116
|
+
at('backend-services'),
|
|
117
|
+
at('api'),
|
|
118
|
+
at('background'),
|
|
119
|
+
],
|
|
79
120
|
message: 'backend-data must not import from a higher layer',
|
|
80
121
|
},
|
|
122
|
+
// Domain protocol layers (layer 2, beside backend-data): each bans the DAO
|
|
123
|
+
// layer, the runtime, its store counterpart where it has one, the service
|
|
124
|
+
// layer and the apps. Sources: provider-clients (AWS-AccessBridge,
|
|
125
|
+
// Mail-Meow), webdav (Durable-DAV, Edge-Sonic), git-protocol (Edge-Git).
|
|
126
|
+
{
|
|
127
|
+
dir: 'packages/provider-clients',
|
|
128
|
+
ban: [at('backend-data'), at('backend-runtime'), at('backend-services'), at('api'), at('background')],
|
|
129
|
+
message: 'provider-clients must not import DAOs from backend-data',
|
|
130
|
+
},
|
|
131
|
+
{
|
|
132
|
+
dir: 'packages/webdav',
|
|
133
|
+
ban: [at('backend-data'), at('backend-runtime'), at('dav-store'), at('backend-services'), at('api'), at('background')],
|
|
134
|
+
message: 'webdav must not import DAOs from backend-data',
|
|
135
|
+
},
|
|
136
|
+
{
|
|
137
|
+
dir: 'packages/git-protocol',
|
|
138
|
+
ban: [at('backend-data'), at('backend-runtime'), at('git-service'), at('backend-services'), at('api'), at('background')],
|
|
139
|
+
message: 'git-protocol must not import DAOs from backend-data',
|
|
140
|
+
},
|
|
141
|
+
// Domain store layers (layer 2-3): only layers 0-2, never services or apps.
|
|
142
|
+
// Sources: dav-store (Durable-DAV), git-service (Edge-Git).
|
|
143
|
+
{
|
|
144
|
+
dir: 'packages/dav-store',
|
|
145
|
+
ban: [at('backend-services'), at('api'), at('background')],
|
|
146
|
+
message: 'dav-store must not import from backend-services (higher layer)',
|
|
147
|
+
},
|
|
148
|
+
{
|
|
149
|
+
dir: 'packages/git-service',
|
|
150
|
+
ban: [at('backend-services'), at('api'), at('background')],
|
|
151
|
+
message: 'git-service must not import from backend-services (higher layer)',
|
|
152
|
+
},
|
|
81
153
|
{
|
|
82
154
|
dir: 'packages/backend-services',
|
|
83
155
|
ban: [at('api'), at('background')],
|
|
@@ -87,7 +159,28 @@ export function layerBans(scope: string): readonly LayerBan[] {
|
|
|
87
159
|
dir: 'apps/api',
|
|
88
160
|
ban: [at('backend-data/dao'), at('backend-data')],
|
|
89
161
|
allowTypeImports: true,
|
|
90
|
-
message:
|
|
162
|
+
message:
|
|
163
|
+
'apps/api must not import DAOs or backend-data values directly; use backend-services instead (type-only imports are allowed)',
|
|
164
|
+
},
|
|
165
|
+
// Direct-client bans: one entry per client package so each message names
|
|
166
|
+
// the correct alternative. A repo holds at most one of these packages, so
|
|
167
|
+
// the other two never fire. Sources: provider-clients (AWS-AccessBridge,
|
|
168
|
+
// Mail-Meow, Mail-Otter, CalDAV-Bridge), dav-store (Durable-DAV),
|
|
169
|
+
// git-service (Edge-Git).
|
|
170
|
+
{
|
|
171
|
+
dir: 'apps/api',
|
|
172
|
+
ban: [at('provider-clients')],
|
|
173
|
+
message: `apps/api must not import provider-clients directly; use ${scope}/backend-services instead`,
|
|
174
|
+
},
|
|
175
|
+
{
|
|
176
|
+
dir: 'apps/api',
|
|
177
|
+
ban: [at('dav-store')],
|
|
178
|
+
message: `apps/api must not import dav-store directly; use ${scope}/webdav + DO RPC via ${scope}/background instead`,
|
|
179
|
+
},
|
|
180
|
+
{
|
|
181
|
+
dir: 'apps/api',
|
|
182
|
+
ban: [at('git-service')],
|
|
183
|
+
message: `apps/api must not import git-service directly; use ${scope}/git-protocol + DO RPC via ${scope}/background instead`,
|
|
91
184
|
},
|
|
92
185
|
{
|
|
93
186
|
dir: 'apps/background',
|
package/src/eslint.test.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { describe, expect, it } from 'vitest';
|
|
2
|
-
import { defineRepoLintConfig } from './eslint';
|
|
2
|
+
import { defineRepoLintConfig } from './eslint.ts';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Structural checks on the produced flat config.
|
|
@@ -155,6 +155,27 @@ describe('defineRepoLintConfig', () => {
|
|
|
155
155
|
);
|
|
156
156
|
});
|
|
157
157
|
|
|
158
|
+
it('covers the family superset of domain layers', () => {
|
|
159
|
+
// provider-clients (AWS/CalDAV/Meow/Otter), webdav/dav-store (DAV/Router/Sonic),
|
|
160
|
+
// git-protocol/git-service (Git): a repo without the package never imports it,
|
|
161
|
+
// so the union is safe and no repo needs extraLayers for a known package.
|
|
162
|
+
const rules = rulesJson(config);
|
|
163
|
+
expect(rules).toContain('@fixture/provider-clients');
|
|
164
|
+
expect(rules).toContain('@fixture/webdav');
|
|
165
|
+
expect(rules).toContain('@fixture/dav-store');
|
|
166
|
+
expect(rules).toContain('@fixture/git-protocol');
|
|
167
|
+
expect(rules).toContain('@fixture/git-service');
|
|
168
|
+
});
|
|
169
|
+
|
|
170
|
+
it('bans direct client imports from apps/api with the per-client alternative', () => {
|
|
171
|
+
const rules = rulesJson(config);
|
|
172
|
+
expect(rules).toContain('must not import provider-clients directly');
|
|
173
|
+
expect(rules).toContain('must not import dav-store directly');
|
|
174
|
+
expect(rules).toContain('must not import git-service directly');
|
|
175
|
+
// And the DAO ban still allows type-only imports beside them.
|
|
176
|
+
expect(rules).toContain('allowTypeImports');
|
|
177
|
+
});
|
|
178
|
+
|
|
158
179
|
it('accepts extra layers without losing the canonical ones', () => {
|
|
159
180
|
const extended = defineRepoLintConfig({
|
|
160
181
|
scope: '@fixture',
|
package/src/eslint.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* The converged ESLint flat config for a monorepo in the Rexezuge family.
|
|
3
3
|
*
|
|
4
|
-
* Provenance: the base is Durable-DAV's `eslint.config.mjs` (
|
|
4
|
+
* Provenance: the base is Durable-DAV's `eslint.config.mjs` (the most
|
|
5
5
|
* elaborate of the nine repos, with the layered `no-restricted-imports` boundary
|
|
6
|
-
* rules). Merged in from the
|
|
6
|
+
* rules). Merged in from the stacks that share the same plugin set:
|
|
7
7
|
*
|
|
8
8
|
* - **Edge-Sonic** — `test/**` is *not* ignored (it is linted like everything else,
|
|
9
9
|
* with a narrow override block for Vitest idioms), and `unicorn/prefer-ternary`
|
|
@@ -14,6 +14,9 @@
|
|
|
14
14
|
* `allowTypeImports` where the source repos do not. It is also the source for
|
|
15
15
|
* the anchored skip patterns and the symlink-safe walk that came out of its own
|
|
16
16
|
* backlog.
|
|
17
|
+
* - **CalDAV-Bridge, Mail-Otter, Durable-DAV-Router, Edge-Git, Agent-Router** —
|
|
18
|
+
* the `provider-clients` / `webdav`+`dav-store` / `git-protocol`+`git-service`
|
|
19
|
+
* layers and the per-client `apps/api` alternatives in the boundary table.
|
|
17
20
|
*
|
|
18
21
|
* Canonical decisions, and why each one:
|
|
19
22
|
*
|
|
@@ -21,9 +24,11 @@
|
|
|
21
24
|
* `warn`, which under `eslint --quiet` is unenforceable — a gate nobody can see
|
|
22
25
|
* is a gate that has never run. Formatting drift is therefore a hard failure.
|
|
23
26
|
* 2. **The layered boundary rules are parameterized by `scope`.** Every source
|
|
24
|
-
* repo wrote the same
|
|
27
|
+
* repo wrote the same blocks with a different npm scope hardcoded; the
|
|
25
28
|
* factory takes `scope` (`'@myapp'`) and generates the `@myapp/*` patterns.
|
|
26
|
-
* The table itself lives in {@link ./eslint-boundaries}
|
|
29
|
+
* The table itself lives in {@link ./eslint-boundaries.ts} and covers the
|
|
30
|
+
* family superset — a repo without a domain package never triggers its ban,
|
|
31
|
+
* so no repo needs `extraLayers` for a known package.
|
|
27
32
|
* 3. **`test/**` is linted, not ignored.** Durable-DAV/AWS/Mail-Meow ignored it;
|
|
28
33
|
* Edge-Sonic does not, and records why: ~200 KB of test code had accumulated
|
|
29
34
|
* violations that nothing reported.
|
|
@@ -39,8 +44,8 @@
|
|
|
39
44
|
* zero-dependency, and the plugin belongs to the app that has JSX. A consumer
|
|
40
45
|
* appends it — the README shows the four lines.
|
|
41
46
|
*
|
|
42
|
-
* The rule bodies live in {@link ./eslint-rules} and the boundary table in
|
|
43
|
-
* {@link ./eslint-boundaries}; this file is the assembly. A repo that needs a
|
|
47
|
+
* The rule bodies live in {@link ./eslint-rules.ts} and the boundary table in
|
|
48
|
+
* {@link ./eslint-boundaries.ts}; this file is the assembly. A repo that needs a
|
|
44
49
|
* boundary the canonical table does not name passes `extraLayers` — see
|
|
45
50
|
* {@link RepoLintConfigOptions}.
|
|
46
51
|
*/
|
|
@@ -53,9 +58,9 @@ import pluginRegexp from 'eslint-plugin-regexp';
|
|
|
53
58
|
import eslintConfigPrettier from 'eslint-config-prettier';
|
|
54
59
|
import prettier from 'eslint-plugin-prettier';
|
|
55
60
|
import type { FlatConfig } from 'typescript-eslint';
|
|
56
|
-
import { DEFAULT_PROJECT_DIRS, layerBans, restrictedDynamicImports, restrictedImports } from './eslint-boundaries';
|
|
57
|
-
import type { LayerBan } from './eslint-boundaries';
|
|
58
|
-
import { SONARJS_RULES, TEST_RULES, TYPESCRIPT_RULES, UNICORN_RULES } from './eslint-rules';
|
|
61
|
+
import { DEFAULT_PROJECT_DIRS, layerBans, restrictedDynamicImports, restrictedImports } from './eslint-boundaries.ts';
|
|
62
|
+
import type { LayerBan } from './eslint-boundaries.ts';
|
|
63
|
+
import { SONARJS_RULES, TEST_RULES, TYPESCRIPT_RULES, UNICORN_RULES } from './eslint-rules.ts';
|
|
59
64
|
|
|
60
65
|
/**
|
|
61
66
|
* What `defineRepoLintConfig` accepts.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { describe, expect, it } from 'vitest';
|
|
2
|
-
import { createPagesProxy } from './pages-proxy';
|
|
3
|
-
import type { PagesProxyEnv } from './pages-proxy';
|
|
2
|
+
import { createPagesProxy } from './pages-proxy.ts';
|
|
3
|
+
import type { PagesProxyEnv } from './pages-proxy.ts';
|
|
4
4
|
|
|
5
5
|
function fakeEnv(): { env: PagesProxyEnv; seen: { url: string; method: string; headers: Headers; body: string | null }[] } {
|
|
6
6
|
const seen: { url: string; method: string; headers: Headers; body: string | null }[] = [];
|