@rexezuge/tooling 1.13.0 → 1.15.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.
Files changed (138) hide show
  1. package/README.md +67 -34
  2. package/dist/eslint-options.d.ts +54 -0
  3. package/dist/eslint-options.d.ts.map +1 -0
  4. package/dist/eslint-options.js +0 -0
  5. package/dist/eslint-options.js.map +7 -0
  6. package/dist/eslint-rules.d.ts.map +1 -1
  7. package/dist/eslint-rules.js +1 -1
  8. package/dist/eslint-rules.js.map +2 -2
  9. package/dist/eslint-strict.d.ts +2 -1
  10. package/dist/eslint-strict.d.ts.map +1 -1
  11. package/dist/eslint-strict.js +2 -1
  12. package/dist/eslint-strict.js.map +3 -3
  13. package/dist/eslint.d.ts +2 -53
  14. package/dist/eslint.d.ts.map +1 -1
  15. package/dist/eslint.js.map +2 -2
  16. package/dist/manifest-validate.d.ts.map +1 -1
  17. package/dist/manifest-validate.js +1 -1
  18. package/dist/manifest-validate.js.map +3 -3
  19. package/dist/manifest.d.ts +21 -0
  20. package/dist/manifest.d.ts.map +1 -1
  21. package/dist/manifest.js.map +2 -2
  22. package/dist/pages-proxy.d.ts +2 -0
  23. package/dist/pages-proxy.d.ts.map +1 -0
  24. package/dist/pages-proxy.js +1 -0
  25. package/dist/pages-proxy.js.map +7 -0
  26. package/dist/plugin-option.d.ts +15 -0
  27. package/dist/plugin-option.d.ts.map +1 -0
  28. package/dist/plugin-option.js +1 -0
  29. package/dist/plugin-option.js.map +7 -0
  30. package/dist/scripts/backup/destinations.d.ts +40 -0
  31. package/dist/scripts/backup/destinations.d.ts.map +1 -0
  32. package/dist/scripts/backup/destinations.js +1 -0
  33. package/dist/scripts/backup/destinations.js.map +7 -0
  34. package/dist/scripts/backup/encrypt-backup.d.ts +5 -2
  35. package/dist/scripts/backup/encrypt-backup.d.ts.map +1 -1
  36. package/dist/scripts/backup/encrypt-backup.js +2 -3
  37. package/dist/scripts/backup/encrypt-backup.js.map +3 -3
  38. package/dist/scripts/backup/naming.d.ts +1 -1
  39. package/dist/scripts/backup/naming.d.ts.map +1 -1
  40. package/dist/scripts/backup/naming.js +1 -1
  41. package/dist/scripts/backup/naming.js.map +3 -3
  42. package/dist/scripts/ensure-spa-shell-stub.d.ts +4 -2
  43. package/dist/scripts/ensure-spa-shell-stub.d.ts.map +1 -1
  44. package/dist/scripts/ensure-spa-shell-stub.js +1 -2
  45. package/dist/scripts/ensure-spa-shell-stub.js.map +3 -3
  46. package/dist/scripts/init-secrets.d.ts +1 -2
  47. package/dist/scripts/init-secrets.d.ts.map +1 -1
  48. package/dist/scripts/init-secrets.js +2 -3
  49. package/dist/scripts/init-secrets.js.map +3 -3
  50. package/dist/scripts/migrations-lock.d.ts +6 -2
  51. package/dist/scripts/migrations-lock.d.ts.map +1 -1
  52. package/dist/scripts/migrations-lock.js +1 -2
  53. package/dist/scripts/migrations-lock.js.map +3 -3
  54. package/dist/scripts/prepare-wrangler-config.d.ts +6 -2
  55. package/dist/scripts/prepare-wrangler-config.d.ts.map +1 -1
  56. package/dist/scripts/prepare-wrangler-config.js +1 -2
  57. package/dist/scripts/prepare-wrangler-config.js.map +3 -3
  58. package/dist/scripts/validate-locales.d.ts +20 -2
  59. package/dist/scripts/validate-locales.d.ts.map +1 -1
  60. package/dist/scripts/validate-locales.js +5 -5
  61. package/dist/scripts/validate-locales.js.map +3 -3
  62. package/dist/scripts/verify-spa-shell.d.ts +7 -2
  63. package/dist/scripts/verify-spa-shell.d.ts.map +1 -1
  64. package/dist/scripts/verify-spa-shell.js +1 -2
  65. package/dist/scripts/verify-spa-shell.js.map +3 -3
  66. package/dist/scripts/wrangler-config/resources.d.ts +11 -2
  67. package/dist/scripts/wrangler-config/resources.d.ts.map +1 -1
  68. package/dist/scripts/wrangler-config/resources.js +1 -1
  69. package/dist/scripts/wrangler-config/resources.js.map +3 -3
  70. package/dist/vite.d.ts +2 -1
  71. package/dist/vite.d.ts.map +1 -1
  72. package/dist/vite.js +3 -3
  73. package/dist/vite.js.map +3 -3
  74. package/dist/vitest-aliases.d.ts +7 -1
  75. package/dist/vitest-aliases.d.ts.map +1 -1
  76. package/dist/vitest-aliases.js +1 -1
  77. package/dist/vitest-aliases.js.map +3 -3
  78. package/dist/vitest-integration.d.ts +3 -2
  79. package/dist/vitest-integration.d.ts.map +1 -1
  80. package/dist/vitest-integration.js +1 -1
  81. package/dist/vitest-integration.js.map +3 -3
  82. package/dist/vitest-repo.d.ts +3 -2
  83. package/dist/vitest-repo.d.ts.map +1 -1
  84. package/dist/vitest-repo.js +1 -1
  85. package/dist/vitest-repo.js.map +3 -3
  86. package/dist/vitest-web.d.ts +3 -2
  87. package/dist/vitest-web.d.ts.map +1 -1
  88. package/dist/vitest-web.js +1 -1
  89. package/dist/vitest-web.js.map +3 -3
  90. package/dist/vitest.d.ts +4 -3
  91. package/dist/vitest.d.ts.map +1 -1
  92. package/dist/vitest.js +1 -1
  93. package/dist/vitest.js.map +3 -3
  94. package/package.json +3 -3
  95. package/presets/tsconfig/web.json +2 -2
  96. package/schema/manifest.schema.json +28 -1
  97. package/src/eslint-options.ts +54 -0
  98. package/src/eslint-rules.ts +4 -0
  99. package/src/eslint-strict.test.ts +29 -0
  100. package/src/eslint-strict.ts +36 -4
  101. package/src/eslint.ts +2 -53
  102. package/src/github/dependabot.yml +14 -4
  103. package/src/github/workflows/backup-d1.yml +15 -0
  104. package/src/github/workflows/backup-main.yml +9 -126
  105. package/src/github/workflows/continuous-deployment.yml +11 -180
  106. package/src/github/workflows/continuous-integration.yml +9 -249
  107. package/src/github/workflows/scheduled-version-update.yml +8 -31
  108. package/src/github/workflows/upstream-sync.yml +8 -49
  109. package/src/manifest-validate.ts +31 -2
  110. package/src/manifest.test.ts +22 -0
  111. package/src/manifest.ts +22 -0
  112. package/src/pages-proxy.test.ts +8 -0
  113. package/src/pages-proxy.ts +13 -0
  114. package/src/plugin-option.test.ts +13 -0
  115. package/src/plugin-option.ts +18 -0
  116. package/src/presets.test.ts +5 -1
  117. package/src/scripts/backup/backup-rules.test.ts +22 -0
  118. package/src/scripts/backup/destinations.ts +59 -0
  119. package/src/scripts/backup/encrypt-backup.ts +58 -48
  120. package/src/scripts/backup/naming.ts +2 -2
  121. package/src/scripts/ensure-spa-shell-stub.ts +18 -10
  122. package/src/scripts/entrypoints.test.ts +55 -0
  123. package/src/scripts/init-secrets.ts +8 -6
  124. package/src/scripts/migrations-lock.ts +22 -17
  125. package/src/scripts/prepare-wrangler-config.ts +34 -14
  126. package/src/scripts/validate-locales.ts +39 -17
  127. package/src/scripts/verify-spa-shell.ts +21 -20
  128. package/src/scripts/wrangler-config/resources.test.ts +10 -0
  129. package/src/scripts/wrangler-config/resources.ts +21 -4
  130. package/src/vite.ts +5 -3
  131. package/src/vitest-aliases.test.ts +33 -0
  132. package/src/vitest-aliases.ts +37 -7
  133. package/src/vitest-integration.ts +7 -8
  134. package/src/vitest-repo.ts +7 -5
  135. package/src/vitest-web.ts +7 -5
  136. package/src/vitest.ts +8 -6
  137. package/src/github/actions/retry-step/action.yml +0 -55
  138. package/src/github/actions/setup-env/action.yml +0 -20
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../src/vitest.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 { manifestCoverageThresholds } from './manifest.ts';\nimport { DEFAULT_CLOUDFLARE_MOCKS, DEFAULT_WORKSPACE_PACKAGES, KIT_DEDUPE, KIT_NO_EXTERNAL, workspaceAliases } from './vitest-aliases.ts';\nimport type { VitestAlias } from './vitest-aliases.ts';\n\nexport type { VitestAlias } from './vitest-aliases.ts';\n// Re-exported from this sub-barrel as well as the root, because a consumer\n// configuring **Vite** reaches for this path to find the same constants the vitest\n// factory applies — `KIT_DEDUPE` first, to keep one React between the app and the\n// kit's components. Exporting it only from the root meant that import failed with\n// `does not provide an export named 'KIT_DEDUPE'` at config-load time, which is a\n// build failure before any test runs and no error that names the install.\nexport { KIT_DEDUPE, KIT_NO_EXTERNAL } from './vitest-aliases.ts';\n\n/**\n * Coverage thresholds, in the four figures Vitest gates on.\n */\nexport interface CoverageThresholds {\n readonly statements?: number;\n readonly branches?: number;\n readonly functions?: number;\n readonly lines?: number;\n}\n\n/**\n * What `defineUnitVitestConfig` accepts. Every field is optional: the defaults\n * cover the canonical monorepo layout, and a consumer overrides only what its\n * tree actually differs in.\n */\nexport interface UnitVitestConfigOptions {\n /**\n * The consuming repo's npm scope, e.g. `'@myapp'`. When supplied, `@scope/*`\n * workspace aliases are generated from `packages` (plus `background` under\n * `apps/`); when omitted, only the `cloudflare:*`, `@/` and `~/` aliases\n * apply and `aliases` carries the workspace table by hand.\n */\n readonly scope?: string;\n /**\n * Workspace package directory names. Defaults to the family superset; a repo\n * without a domain package keeps the default harmlessly (its alias never\n * matches).\n */\n readonly packages?: readonly string[];\n /**\n * Which `cloudflare:*` mocks to alias. Defaults to workers/sockets/workflows.\n */\n readonly mocks?: readonly string[];\n /**\n * Extra resolver entries, applied after the canonical ones (e.g. the `hono`\n * dedupe two repos carry, or an `/index.ts` exact entry).\n */\n readonly aliases?: readonly VitestAlias[];\n /**\n * Where the repo root is, as a file URL. Defaults to the directory this\n * factory is *called* from, which is the repo root's `vitest.config.mts`.\n * Pass `new URL('.', import.meta.url).href` explicitly from the caller —\n * never rely on this module's own URL, which points into `node_modules`.\n */\n readonly root?: string;\n /**\n * Which suites to collect. Defaults to the whole unit suite.\n */\n readonly include?: readonly string[];\n /**\n * Suite paths to skip, replacing the default. Defaults re-list\n * `node_modules`/`dist`/`integration` plus every SPA shape.\n */\n readonly exclude?: readonly string[];\n /**\n * `node_modules` specifiers to inline through Vite rather than externalize.\n * Defaults to `['dofs']` (Durable-DAV: `dofs` imports `cloudflare:workers`,\n * which Node rejects before `resolve.alias` is consulted).\n */\n readonly serverDepsInline?: readonly string[];\n /**\n * Resolver `noExternal` patterns. Defaults to keeping `@rexezuge/*` inside\n * Vite's pipeline; see `KIT_NO_EXTERNAL`.\n */\n readonly noExternal?: readonly (string | RegExp)[];\n /**\n * Vite plugins for the suite (rare on the backend half; the SPA half passes\n * `react()` here).\n */\n readonly plugins?: readonly Plugin[];\n /**\n * Setup files run before each test file (e.g. AWS's floci guard, Meow's\n * backend/web setups).\n */\n readonly setupFiles?: readonly string[];\n /**\n * Coverage `include` globs. Defaults to the worker plus every workspace\n * package's `src`.\n */\n readonly coverageInclude?: readonly string[];\n /**\n * Coverage `exclude` globs, merged with the canonical set.\n */\n readonly coverageExclude?: readonly string[];\n /**\n * Report coverage for `index.ts` re-export barrels.\n *\n * The canonical set excludes them because a barrel carries no logic of its\n * own. Two repos in the family read that differently and deliberately keep\n * them in: a barrel with no importer shows up as an uncovered file, which is\n * the point — it is the only signal that the barrel is dead. Excluding them\n * is what let four entirely unused root barrels sit in the tree unnoticed, one\n * per repo that carried the habit.\n *\n * `coverageExclude` cannot express this, because it is merged with the\n * canonical set rather than replacing it, so a consumer could not opt back in.\n * Hence a named flag. Default `false`: today’s behaviour, unchanged for the\n * seven repos that never asked.\n */\n readonly includeIndexBarrels?: boolean;\n /**\n * Coverage floors. Defaults to the manifest's `quality.coverage` (`.rexezuge.jsonc`\n * at `root`); without one, no floor.\n */\n readonly thresholds?: CoverageThresholds;\n /**\n * Where the coverage report is written.\n */\n readonly reportsDirectory?: string;\n}\n\n/**\n * The SPA's suites, excluded here so the two configs partition the suite.\n *\n * Every shape the family uses: the `test/web/**` directory convention\n * (CalDAV-Bridge, Mail-Meow), the root-suite `web-*` naming convention\n * (Durable-DAV-Router), and suites bundled under `apps/web` (Mail-Otter).\n * `defineWebVitestConfig()` includes the same globs, so a file is collected by\n * exactly one config.\n */\nconst SPA_FILES: readonly string[] = ['test/web/**', 'test/**/web-*.test.{ts,tsx}', 'apps/web/**/*.test.{ts,tsx}'];\n\n/**\n * Coverage `exclude` globs converged from the source repos.\n *\n * The categories: build and test tooling (`scripts/` grows with project surface,\n * not complexity, and the god-file guard excludes it for the same reason), test\n * files, declarations, re-export barrels (`index.ts` carries no logic of its\n * own), model records, generated files (the SPA shell is a one-line HTML blob\n * with no logic to exercise), and type-only modules.\n */\nconst CANONICAL_COVERAGE_EXCLUDE: readonly string[] = [\n 'scripts/**',\n '**/*.test.ts',\n '**/*.test.tsx',\n '**/*.d.ts',\n '**/index.ts',\n '**/types.d.ts',\n '**/model/**',\n '**/generated/**',\n '**/D1Types.ts',\n '**/ServiceEnv.ts',\n '**/env.d.ts',\n];\n\n/**\n * The barrel exclusion, named so `includeIndexBarrels` can lift it.\n */\nconst INDEX_BARREL_EXCLUDE = '**/index.ts';\n\n/**\n * The canonical exclude set, with the barrel entry lifted for a caller that\n * asked to keep barrels in their coverage report.\n */\nfunction coverageExcludeFor(options: { coverageExclude?: readonly string[]; includeIndexBarrels?: boolean }): string[] {\n const canonical = options.includeIndexBarrels\n ? CANONICAL_COVERAGE_EXCLUDE.filter((glob) => glob !== INDEX_BARREL_EXCLUDE)\n : CANONICAL_COVERAGE_EXCLUDE;\n return [...canonical, ...(options.coverageExclude ?? [])];\n}\n\n/**\n * Build the unit-test config.\n *\n * ```ts\n * // vitest.config.mts\n * import { defineUnitVitestConfig } from '@rexezuge/tooling/vitest';\n * export default defineUnitVitestConfig({\n * scope: '@myapp',\n * thresholds: { statements: 60, branches: 55, functions: 65, lines: 60 },\n * });\n * ```\n */\nexport function defineUnitVitestConfig(options: UnitVitestConfigOptions = {}): ReturnType<typeof defineConfig> {\n const root = options.root ?? new URL('.', import.meta.url).href;\n const thresholds = options.thresholds ?? manifestCoverageThresholds(root);\n const coverageInclude = options.coverageInclude ?? ['apps/api/src/**/*.ts', 'apps/background/src/**/*.ts', 'packages/**/src/**/*.ts'];\n const coverageExclude = coverageExcludeFor(options);\n const baseAliases = workspaceAliases({\n scope: options.scope ?? '@unused',\n root,\n packages: options.scope === undefined ? [] : (options.packages ?? DEFAULT_WORKSPACE_PACKAGES),\n mocks: options.mocks ?? DEFAULT_CLOUDFLARE_MOCKS,\n });\n // A placeholder scope contributes no `@unused/*` entries; the mocks plus\n // `@/`/`~/` survive either way.\n const aliases = [\n ...baseAliases.filter((alias) => typeof alias.find !== 'string' || !alias.find.startsWith('@unused')),\n ...(options.aliases ?? []),\n ];\n\n return defineConfig({\n ...(options.plugins !== undefined && { plugins: [...options.plugins] }),\n resolve: {\n alias: aliases,\n noExternal: [...KIT_NO_EXTERNAL, ...(options.noExternal ?? [])],\n // The peer runtime a consumer and the kit must agree on. `@rexezuge/web`\n // declares `react`, `react-dom` and `lucide-react` as peers, which under a\n // registry install means neither package carries its own copy. Under the\n // `link:` workflow this repo's own README recommends, the symlinked\n // directory **does** have one — so the kit resolves its own React and the\n // consumer resolves theirs, and every hook in a kit component throws\n // `Cannot read properties of null (reading 'useState')`. Dedupe points the\n // bare specifier at one copy for both.\n dedupe: [...KIT_DEDUPE],\n },\n test: {\n globals: true,\n environment: 'node',\n include: [...(options.include ?? ['test/**/*.test.{ts,tsx}'])],\n // `test` is a workspace project and therefore has its own node_modules;\n // without the re-list, the glob reaches into it.\n exclude: [...(options.exclude ?? ['**/node_modules/**', '**/dist/**', 'test/integration/**', ...SPA_FILES])],\n ...(options.setupFiles !== undefined && { setupFiles: [...options.setupFiles] }),\n server: {\n deps: {\n // A `node_modules` dependency is externalized by default, so Node's\n // own ESM loader resolves a `cloudflare:workers` specifier and rejects\n // the scheme before `resolve.alias` is ever consulted. Inlining routes\n // it back through Vite, where the alias applies.\n inline: [...(options.serverDepsInline ?? ['dofs'])],\n },\n },\n coverage: {\n provider: 'v8',\n // Vitest 4 removed `coverage.all`; an explicit `include` now reports\n // every matching file whether or not a test imported it, which is the\n // behaviour the source repos' `all: true` was there to get: a brand-new\n // module with no test is counted as zero rather than being invisible,\n // which is the exact regression this gate exists to catch.\n reporter: ['text', 'lcov', 'html'],\n reportsDirectory: options.reportsDirectory ?? './coverage',\n include: [...coverageInclude],\n exclude: coverageExclude,\n ...(thresholds !== undefined && { thresholds: { ...thresholds } }),\n },\n },\n });\n}\n"],
5
- "mappings": "+EAmCA,OAAS,gBAAAA,MAAiC,gBAC1C,OAAS,8BAAAC,MAAkC,gBAC3C,OAAS,4BAAAC,EAA0B,8BAAAC,EAA4B,cAAAC,EAAY,mBAAAC,EAAiB,oBAAAC,MAAwB,sBAUpH,OAAS,cAAAF,EAAY,mBAAAC,MAAuB,sBA0H5C,MAAME,EAA+B,CAAC,cAAe,8BAA+B,6BAA6B,EAW3GC,EAAgD,CACpD,aACA,eACA,gBACA,YACA,cACA,gBACA,cACA,kBACA,gBACA,mBACA,eAMIC,EAAuB,cAM7B,SAASC,EAAmBC,EAA+E,CAIzG,MAAO,CAAC,GAHUA,EAAQ,oBACtBH,EAA2B,OAAQI,GAASA,IAASH,CAAoB,EACzED,EACkB,GAAIG,EAAQ,iBAAmB,CAAA,CAAG,CAC1D,CALSE,EAAAH,EAAA,sBAmBH,SAAUI,EAAuBH,EAAmC,CAAA,EAAE,CAC1E,MAAMI,EAAOJ,EAAQ,MAAQ,IAAI,IAAI,IAAK,YAAY,GAAG,EAAE,KACrDK,EAAaL,EAAQ,YAAcV,EAA2Bc,CAAI,EAClEE,EAAkBN,EAAQ,iBAAmB,CAAC,uBAAwB,8BAA+B,yBAAyB,EAC9HO,EAAkBR,EAAmBC,CAAO,EAS5CQ,EAAU,CACd,GATkBb,EAAiB,CACnC,MAAOK,EAAQ,OAAS,UACxB,KAAAI,EACA,SAAUJ,EAAQ,QAAU,OAAY,CAAA,EAAMA,EAAQ,UAAYR,EAClE,MAAOQ,EAAQ,OAAST,EACzB,EAIgB,OAAQkB,GAAU,OAAOA,EAAM,MAAS,UAAY,CAACA,EAAM,KAAK,WAAW,SAAS,CAAC,EACpG,GAAIT,EAAQ,SAAW,CAAA,GAGzB,OAAOX,EAAa,CAClB,GAAIW,EAAQ,UAAY,QAAa,CAAE,QAAS,CAAC,GAAGA,EAAQ,OAAO,CAAC,EACpE,QAAS,CACP,MAAOQ,EACP,WAAY,CAAC,GAAGd,EAAiB,GAAIM,EAAQ,YAAc,CAAA,CAAG,EAS9D,OAAQ,CAAC,GAAGP,CAAU,GAExB,KAAM,CACJ,QAAS,GACT,YAAa,OACb,QAAS,CAAC,GAAIO,EAAQ,SAAW,CAAC,yBAAyB,CAAE,EAG7D,QAAS,CAAC,GAAIA,EAAQ,SAAW,CAAC,qBAAsB,aAAc,sBAAuB,GAAGJ,CAAS,CAAE,EAC3G,GAAII,EAAQ,aAAe,QAAa,CAAE,WAAY,CAAC,GAAGA,EAAQ,UAAU,CAAC,EAC7E,OAAQ,CACN,KAAM,CAKJ,OAAQ,CAAC,GAAIA,EAAQ,kBAAoB,CAAC,MAAM,CAAE,IAGtD,SAAU,CACR,SAAU,KAMV,SAAU,CAAC,OAAQ,OAAQ,MAAM,EACjC,iBAAkBA,EAAQ,kBAAoB,aAC9C,QAAS,CAAC,GAAGM,CAAe,EAC5B,QAASC,EACT,GAAIF,IAAe,QAAa,CAAE,WAAY,CAAE,GAAGA,CAAU,CAAE,IAGpE,CACH,CAjEgBH,EAAAC,EAAA",
6
- "names": ["defineConfig", "manifestCoverageThresholds", "DEFAULT_CLOUDFLARE_MOCKS", "DEFAULT_WORKSPACE_PACKAGES", "KIT_DEDUPE", "KIT_NO_EXTERNAL", "workspaceAliases", "SPA_FILES", "CANONICAL_COVERAGE_EXCLUDE", "INDEX_BARREL_EXCLUDE", "coverageExcludeFor", "options", "glob", "__name", "defineUnitVitestConfig", "root", "thresholds", "coverageInclude", "coverageExclude", "aliases", "alias"]
4
+ "sourcesContent": ["/**\n * The unit-test Vitest config for the worker-and-packages half of the suite.\n *\n * Provenance: converged from all nine repos' `vitest.config.mts`. The coverage\n * block is Durable-DAV-Router's (the most complete: v8 provider, explicit\n * include/exclude patterns, thresholds with the reasoning for why they sit just\n * under the measured value); the alias block is the union of Durable-DAV's\n * `cloudflare:*` mocks, every repo's `@scope/* → src` workspace table, and the\n * shared `@/` + `~/` prefixes — see {@link ./vitest-aliases.js}.\n *\n * Canonical decisions:\n *\n * 1. **Every file matching `include` is reported** — Vitest 4 removed\n * `coverage.all`, and an explicit `include` now covers files no test\n * imported. That is the behaviour the source repos configured `all: true` for,\n * and the reason it mattered: without it a brand-new module with no test is\n * invisible rather than counted as zero, which is the exact regression this\n * gate exists to catch.\n * 2. **The SPA is excluded here**, so this config and `defineWebVitestConfig()`\n * partition the suite rather than each running all of it. The default covers\n * every suite shape the family uses (`test/web/**`, `test/**​/web-*`,\n * `apps/web/**`); see `defineRepoVitestConfig()` for the single-file\n * `projects` composition the AWS/Mail-Meow/CalDAV repos use.\n * 3. **A custom `exclude` re-lists `node_modules`** — `test/` is a workspace\n * project and therefore has its own, so without the re-list the glob reaches\n * into `test/node_modules` and tries to run other packages' suites.\n * 4. **Thresholds are a consumer argument**, not a kit default. A floor is a\n * per-repo ratchet measured against that repo's suite; the kit cannot know a\n * number, and guessing one is how floors get lowered.\n * 5. **`@rexezuge/*` is never externalized** — see `KIT_NO_EXTERNAL`: the kit\n * ships ESM `dist/` with bundler-style extensionless imports, which Node's\n * resolver refuses, so the kit stays inside Vite's pipeline (the same\n * resolver that bundles the worker).\n */\n\nimport { defineConfig } from 'vitest/config';\nimport { asVitePlugins } from './plugin-option.ts';\nimport type { PluginOption } from './plugin-option.ts';\nimport { manifestCoverageThresholds } from './manifest.ts';\nimport { DEFAULT_CLOUDFLARE_MOCKS, KIT_DEDUPE, KIT_NO_EXTERNAL, workspaceAliases } from './vitest-aliases.ts';\nimport type { VitestAlias } from './vitest-aliases.ts';\n\nexport type { VitestAlias } from './vitest-aliases.ts';\n// Re-exported from this sub-barrel as well as the root, because a consumer\n// configuring **Vite** reaches for this path to find the same constants the vitest\n// factory applies — `KIT_DEDUPE` first, to keep one React between the app and the\n// kit's components. Exporting it only from the root meant that import failed with\n// `does not provide an export named 'KIT_DEDUPE'` at config-load time, which is a\n// build failure before any test runs and no error that names the install.\nexport { DEFAULT_WORKSPACE_PACKAGES, KIT_DEDUPE, KIT_NO_EXTERNAL } from './vitest-aliases.ts';\n\n/**\n * Coverage thresholds, in the four figures Vitest gates on.\n */\nexport interface CoverageThresholds {\n readonly statements?: number;\n readonly branches?: number;\n readonly functions?: number;\n readonly lines?: number;\n}\n\n/**\n * What `defineUnitVitestConfig` accepts. Every field is optional: the defaults\n * cover the canonical monorepo layout, and a consumer overrides only what its\n * tree actually differs in.\n */\nexport interface UnitVitestConfigOptions {\n /**\n * The consuming repo's npm scope, e.g. `'@myapp'`. When supplied, `@scope/*`\n * workspace aliases are generated from `packages` (plus `background` under\n * `apps/`); when omitted, only the `cloudflare:*`, `@/` and `~/` aliases\n * apply and `aliases` carries the workspace table by hand.\n */\n readonly scope?: string;\n /**\n * Workspace package directory names. Defaults to the family superset; a repo\n * without a domain package keeps the default harmlessly (its alias never\n * matches).\n */\n readonly packages?: readonly string[];\n /**\n * Which `cloudflare:*` mocks to alias. Defaults to workers/sockets/workflows.\n */\n readonly mocks?: readonly string[];\n /**\n * Extra resolver entries, applied after the canonical ones (e.g. the `hono`\n * dedupe two repos carry, or an `/index.ts` exact entry).\n */\n readonly aliases?: readonly VitestAlias[];\n /**\n * Where the repo root is, as a file URL. Defaults to the directory this\n * factory is *called* from, which is the repo root's `vitest.config.mts`.\n * Pass `new URL('.', import.meta.url).href` explicitly from the caller —\n * never rely on this module's own URL, which points into `node_modules`.\n */\n readonly root?: string;\n /**\n * Which suites to collect. Defaults to the whole unit suite.\n */\n readonly include?: readonly string[];\n /**\n * Suite paths to skip, replacing the default. Defaults re-list\n * `node_modules`/`dist`/`integration` plus every SPA shape.\n */\n readonly exclude?: readonly string[];\n /**\n * `node_modules` specifiers to inline through Vite rather than externalize.\n * Defaults to `['dofs']` (Durable-DAV: `dofs` imports `cloudflare:workers`,\n * which Node rejects before `resolve.alias` is consulted).\n */\n readonly serverDepsInline?: readonly string[];\n /**\n * Resolver `noExternal` patterns. Defaults to keeping `@rexezuge/*` inside\n * Vite's pipeline; see `KIT_NO_EXTERNAL`.\n */\n readonly noExternal?: readonly (string | RegExp)[];\n /**\n * Vite plugins for the suite (rare on the backend half; the SPA half passes\n * `react()` here).\n */\n readonly plugins?: readonly PluginOption[];\n /**\n * Setup files run before each test file (e.g. AWS's floci guard, Meow's\n * backend/web setups).\n */\n readonly setupFiles?: readonly string[];\n /**\n * Coverage `include` globs. Defaults to the worker plus every workspace\n * package's `src`.\n */\n readonly coverageInclude?: readonly string[];\n /**\n * Coverage `exclude` globs, merged with the canonical set.\n */\n readonly coverageExclude?: readonly string[];\n /**\n * Report coverage for `index.ts` re-export barrels.\n *\n * The canonical set excludes them because a barrel carries no logic of its\n * own. Two repos in the family read that differently and deliberately keep\n * them in: a barrel with no importer shows up as an uncovered file, which is\n * the point — it is the only signal that the barrel is dead. Excluding them\n * is what let four entirely unused root barrels sit in the tree unnoticed, one\n * per repo that carried the habit.\n *\n * `coverageExclude` cannot express this, because it is merged with the\n * canonical set rather than replacing it, so a consumer could not opt back in.\n * Hence a named flag. Default `false`: today’s behaviour, unchanged for the\n * seven repos that never asked.\n */\n readonly includeIndexBarrels?: boolean;\n /**\n * Coverage floors. Defaults to the manifest's `quality.coverage` (`.rexezuge.jsonc`\n * at `root`); without one, no floor.\n */\n readonly thresholds?: CoverageThresholds;\n /**\n * Where the coverage report is written.\n */\n readonly reportsDirectory?: string;\n}\n\n/**\n * The SPA's suites, excluded here so the two configs partition the suite.\n *\n * Every shape the family uses: the `test/web/**` directory convention\n * (CalDAV-Bridge, Mail-Meow), the root-suite `web-*` naming convention\n * (Durable-DAV-Router), and suites bundled under `apps/web` (Mail-Otter).\n * `defineWebVitestConfig()` includes the same globs, so a file is collected by\n * exactly one config.\n */\nconst SPA_FILES: readonly string[] = ['test/web/**', 'test/**/web-*.test.{ts,tsx}', 'apps/web/**/*.test.{ts,tsx}'];\n\n/**\n * Coverage `exclude` globs converged from the source repos.\n *\n * The categories: build and test tooling (`scripts/` grows with project surface,\n * not complexity, and the god-file guard excludes it for the same reason), test\n * files, declarations, re-export barrels (`index.ts` carries no logic of its\n * own), model records, generated files (the SPA shell is a one-line HTML blob\n * with no logic to exercise), and type-only modules.\n */\nconst CANONICAL_COVERAGE_EXCLUDE: readonly string[] = [\n 'scripts/**',\n '**/*.test.ts',\n '**/*.test.tsx',\n '**/*.d.ts',\n '**/index.ts',\n '**/types.d.ts',\n '**/model/**',\n '**/generated/**',\n '**/D1Types.ts',\n '**/ServiceEnv.ts',\n '**/env.d.ts',\n];\n\n/**\n * The barrel exclusion, named so `includeIndexBarrels` can lift it.\n */\nconst INDEX_BARREL_EXCLUDE = '**/index.ts';\n\n/**\n * The canonical exclude set, with the barrel entry lifted for a caller that\n * asked to keep barrels in their coverage report.\n */\nfunction coverageExcludeFor(options: { coverageExclude?: readonly string[]; includeIndexBarrels?: boolean }): string[] {\n const canonical = options.includeIndexBarrels\n ? CANONICAL_COVERAGE_EXCLUDE.filter((glob) => glob !== INDEX_BARREL_EXCLUDE)\n : CANONICAL_COVERAGE_EXCLUDE;\n return [...canonical, ...(options.coverageExclude ?? [])];\n}\n\n/**\n * Build the unit-test config.\n *\n * ```ts\n * // vitest.config.mts\n * import { defineUnitVitestConfig } from '@rexezuge/tooling/vitest';\n * export default defineUnitVitestConfig({\n * scope: '@myapp',\n * thresholds: { statements: 60, branches: 55, functions: 65, lines: 60 },\n * });\n * ```\n */\nexport function defineUnitVitestConfig(options: UnitVitestConfigOptions = {}): ReturnType<typeof defineConfig> {\n const root = options.root ?? new URL('.', import.meta.url).href;\n const thresholds = options.thresholds ?? manifestCoverageThresholds(root);\n const coverageInclude = options.coverageInclude ?? ['apps/api/src/**/*.ts', 'apps/background/src/**/*.ts', 'packages/**/src/**/*.ts'];\n const coverageExclude = coverageExcludeFor(options);\n const baseAliases = workspaceAliases({\n scope: options.scope ?? '@unused',\n root,\n packages: options.scope === undefined ? [] : options.packages,\n mocks: options.mocks ?? DEFAULT_CLOUDFLARE_MOCKS,\n });\n // A placeholder scope contributes no `@unused/*` entries; the mocks plus\n // `@/`/`~/` survive either way.\n const aliases = [\n ...baseAliases.filter((alias) => typeof alias.find !== 'string' || !alias.find.startsWith('@unused')),\n ...(options.aliases ?? []),\n ];\n\n return defineConfig({\n ...(options.plugins !== undefined && { plugins: asVitePlugins(options.plugins) }),\n resolve: {\n alias: aliases,\n noExternal: [...KIT_NO_EXTERNAL, ...(options.noExternal ?? [])],\n // The peer runtime a consumer and the kit must agree on. `@rexezuge/web`\n // declares `react`, `react-dom` and `lucide-react` as peers, which under a\n // registry install means neither package carries its own copy. Under the\n // `link:` workflow this repo's own README recommends, the symlinked\n // directory **does** have one — so the kit resolves its own React and the\n // consumer resolves theirs, and every hook in a kit component throws\n // `Cannot read properties of null (reading 'useState')`. Dedupe points the\n // bare specifier at one copy for both.\n dedupe: [...KIT_DEDUPE],\n },\n test: {\n globals: true,\n environment: 'node',\n include: [...(options.include ?? ['test/**/*.test.{ts,tsx}'])],\n // `test` is a workspace project and therefore has its own node_modules;\n // without the re-list, the glob reaches into it.\n exclude: [...(options.exclude ?? ['**/node_modules/**', '**/dist/**', 'test/integration/**', ...SPA_FILES])],\n ...(options.setupFiles !== undefined && { setupFiles: [...options.setupFiles] }),\n server: {\n deps: {\n // A `node_modules` dependency is externalized by default, so Node's\n // own ESM loader resolves a `cloudflare:workers` specifier and rejects\n // the scheme before `resolve.alias` is ever consulted. Inlining routes\n // it back through Vite, where the alias applies.\n inline: [...(options.serverDepsInline ?? ['dofs'])],\n },\n },\n coverage: {\n provider: 'v8',\n // Vitest 4 removed `coverage.all`; an explicit `include` now reports\n // every matching file whether or not a test imported it, which is the\n // behaviour the source repos' `all: true` was there to get: a brand-new\n // module with no test is counted as zero rather than being invisible,\n // which is the exact regression this gate exists to catch.\n reporter: ['text', 'lcov', 'html'],\n reportsDirectory: options.reportsDirectory ?? './coverage',\n include: [...coverageInclude],\n exclude: coverageExclude,\n ...(thresholds !== undefined && { thresholds: { ...thresholds } }),\n },\n },\n });\n}\n"],
5
+ "mappings": "+EAmCA,OAAS,gBAAAA,MAAoB,gBAC7B,OAAS,iBAAAC,MAAqB,qBAE9B,OAAS,8BAAAC,MAAkC,gBAC3C,OAAS,4BAAAC,EAA0B,cAAAC,EAAY,mBAAAC,EAAiB,oBAAAC,MAAwB,sBAUxF,OAAS,8BAAAC,EAA4B,cAAAH,EAAY,mBAAAC,MAAuB,sBA0HxE,MAAMG,EAA+B,CAAC,cAAe,8BAA+B,6BAA6B,EAW3GC,EAAgD,CACpD,aACA,eACA,gBACA,YACA,cACA,gBACA,cACA,kBACA,gBACA,mBACA,eAMIC,EAAuB,cAM7B,SAASC,EAAmBC,EAA+E,CAIzG,MAAO,CAAC,GAHUA,EAAQ,oBACtBH,EAA2B,OAAQI,GAASA,IAASH,CAAoB,EACzED,EACkB,GAAIG,EAAQ,iBAAmB,CAAA,CAAG,CAC1D,CALSE,EAAAH,EAAA,sBAmBH,SAAUI,EAAuBH,EAAmC,CAAA,EAAE,CAC1E,MAAMI,EAAOJ,EAAQ,MAAQ,IAAI,IAAI,IAAK,YAAY,GAAG,EAAE,KACrDK,EAAaL,EAAQ,YAAcV,EAA2Bc,CAAI,EAClEE,EAAkBN,EAAQ,iBAAmB,CAAC,uBAAwB,8BAA+B,yBAAyB,EAC9HO,EAAkBR,EAAmBC,CAAO,EAS5CQ,EAAU,CACd,GATkBd,EAAiB,CACnC,MAAOM,EAAQ,OAAS,UACxB,KAAAI,EACA,SAAUJ,EAAQ,QAAU,OAAY,CAAA,EAAKA,EAAQ,SACrD,MAAOA,EAAQ,OAAST,EACzB,EAIgB,OAAQkB,GAAU,OAAOA,EAAM,MAAS,UAAY,CAACA,EAAM,KAAK,WAAW,SAAS,CAAC,EACpG,GAAIT,EAAQ,SAAW,CAAA,GAGzB,OAAOZ,EAAa,CAClB,GAAIY,EAAQ,UAAY,QAAa,CAAE,QAASX,EAAcW,EAAQ,OAAO,CAAC,EAC9E,QAAS,CACP,MAAOQ,EACP,WAAY,CAAC,GAAGf,EAAiB,GAAIO,EAAQ,YAAc,CAAA,CAAG,EAS9D,OAAQ,CAAC,GAAGR,CAAU,GAExB,KAAM,CACJ,QAAS,GACT,YAAa,OACb,QAAS,CAAC,GAAIQ,EAAQ,SAAW,CAAC,yBAAyB,CAAE,EAG7D,QAAS,CAAC,GAAIA,EAAQ,SAAW,CAAC,qBAAsB,aAAc,sBAAuB,GAAGJ,CAAS,CAAE,EAC3G,GAAII,EAAQ,aAAe,QAAa,CAAE,WAAY,CAAC,GAAGA,EAAQ,UAAU,CAAC,EAC7E,OAAQ,CACN,KAAM,CAKJ,OAAQ,CAAC,GAAIA,EAAQ,kBAAoB,CAAC,MAAM,CAAE,IAGtD,SAAU,CACR,SAAU,KAMV,SAAU,CAAC,OAAQ,OAAQ,MAAM,EACjC,iBAAkBA,EAAQ,kBAAoB,aAC9C,QAAS,CAAC,GAAGM,CAAe,EAC5B,QAASC,EACT,GAAIF,IAAe,QAAa,CAAE,WAAY,CAAE,GAAGA,CAAU,CAAE,IAGpE,CACH,CAjEgBH,EAAAC,EAAA",
6
+ "names": ["defineConfig", "asVitePlugins", "manifestCoverageThresholds", "DEFAULT_CLOUDFLARE_MOCKS", "KIT_DEDUPE", "KIT_NO_EXTERNAL", "workspaceAliases", "DEFAULT_WORKSPACE_PACKAGES", "SPA_FILES", "CANONICAL_COVERAGE_EXCLUDE", "INDEX_BARREL_EXCLUDE", "coverageExcludeFor", "options", "glob", "__name", "defineUnitVitestConfig", "root", "thresholds", "coverageInclude", "coverageExclude", "aliases", "alias"]
7
7
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rexezuge/tooling",
3
- "version": "1.13.0",
3
+ "version": "1.15.0",
4
4
  "private": false,
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -48,8 +48,8 @@
48
48
  "presets"
49
49
  ],
50
50
  "dependencies": {
51
- "@rexezuge/d1": "1.13.0",
52
- "@rexezuge/testing": "1.13.0"
51
+ "@rexezuge/d1": "1.15.0",
52
+ "@rexezuge/testing": "1.15.0"
53
53
  },
54
54
  "peerDependencies": {
55
55
  "eslint": "^10.0.0",
@@ -3,8 +3,8 @@
3
3
  "display": "Rexezuge family: React SPA (apps/web)",
4
4
  "extends": "./base.json",
5
5
  "compilerOptions": {
6
- "target": "ES2020",
7
- "lib": ["ES2020", "DOM", "DOM.Iterable"],
6
+ "target": "ES2022",
7
+ "lib": ["ES2022", "DOM", "DOM.Iterable"],
8
8
  "jsx": "react-jsx"
9
9
  }
10
10
  }
@@ -24,11 +24,38 @@
24
24
  "migrationsDir": { "type": "string", "minLength": 1 }
25
25
  }
26
26
  },
27
+ "kv": {
28
+ "type": "object",
29
+ "additionalProperties": false,
30
+ "required": ["bindings"],
31
+ "description": "KV bindings prepare-wrangler provisions. Absent: no KV binding or namespace is added.",
32
+ "properties": {
33
+ "bindings": { "type": "array", "items": { "type": "string", "pattern": "^[A-Z][A-Z0-9_]*$" } },
34
+ "namespaceNames": {
35
+ "type": "object",
36
+ "description": "Binding to namespace name, for namespaces that predate the <worker>-<binding> convention.",
37
+ "additionalProperties": { "type": "string", "minLength": 1 }
38
+ }
39
+ }
40
+ },
27
41
  "web": {
28
42
  "type": "object",
29
43
  "additionalProperties": false,
30
44
  "required": ["pages", "spaShell"],
31
- "properties": { "pages": { "type": "boolean" }, "spaShell": { "type": "boolean" } }
45
+ "properties": {
46
+ "pages": { "type": "boolean" },
47
+ "spaShell": { "type": "boolean" },
48
+ "buildScript": {
49
+ "type": "string",
50
+ "pattern": "^[\\w:.-]+$",
51
+ "description": "A root package.json script that builds the SPA; CI and CD run it instead of pnpm --filter <web> run build."
52
+ },
53
+ "pagesProject": {
54
+ "type": "string",
55
+ "pattern": "^[a-z0-9][a-z0-9-]{0,57}$",
56
+ "description": "The Cloudflare Pages project, when it is not <name>-web. Wins over CLOUDFLARE_PAGES_PROJECT_NAME."
57
+ }
58
+ }
32
59
  },
33
60
  "background": { "type": "boolean" },
34
61
  "backupD1": { "type": "boolean" },
@@ -0,0 +1,54 @@
1
+ import type { LayerBan } from './eslint-boundaries.ts';
2
+ import type { FamilyManifest } from './manifest.ts';
3
+
4
+ /**
5
+ * What `defineRepoLintConfig` accepts.
6
+ */
7
+ export interface RepoLintConfigOptions {
8
+ /**
9
+ * The consuming repo's npm scope, e.g. `'@myapp'`. Every `no-restricted-imports`
10
+ * pattern in the boundary rules is derived from it, so the same factory serves
11
+ * all nine repos.
12
+ */
13
+ readonly scope?: string;
14
+ /**
15
+ * The family manifest. Omitted: `<tsconfigRootDir or cwd>/.rexezuge.jsonc` is
16
+ * loaded when it exists. Pass `false` to ignore the file. A manifest supplies
17
+ * `scope` (unless given here), replaces the canonical layer table with its own
18
+ * `layers` (when it declares any), and names the http and browser directories
19
+ * the strict rules exempt.
20
+ */
21
+ readonly manifest?: FamilyManifest | false;
22
+ /**
23
+ * Extra http-layer directories (may import `hono`/`chanfana`, hand-build the
24
+ * error envelope), beside `apps/api` and the manifest's `http: true` layers.
25
+ */
26
+ readonly httpDirs?: readonly string[];
27
+ /**
28
+ * The workspace directories the legacy canonical layer table is scoped to, as
29
+ * repo-relative globs. Only used when no manifest declares `layers`.
30
+ *
31
+ * @deprecated Declare `layers` in `.rexezuge.jsonc` instead: the canonical
32
+ * table encodes consumer package names.
33
+ */
34
+ readonly projectDirs?: readonly string[];
35
+ /**
36
+ * Extra ignore globs, merged with the canonical set.
37
+ */
38
+ readonly extraIgnores?: readonly string[];
39
+ /**
40
+ * Where `projectService` resolves the tsconfig from. Defaults to the directory
41
+ * ESLint is invoked in, which is the repo root in every CI job.
42
+ */
43
+ readonly tsconfigRootDir?: string;
44
+ /**
45
+ * Extra boundary layers, appended to the canonical table.
46
+ *
47
+ * The escape valve for a repo whose layout has a boundary the canonical table
48
+ * does not name — AWS-AccessBridge's `apps/api/src/endpoints/**` rule ("route
49
+ * classes must not import DAOs directly") and its `aws4fetch` ban are the shape.
50
+ * Same {@link LayerBan} form, so `extraLayers` flows through the
51
+ * `no-restricted-imports` and the `no-restricted-syntax` guard alike.
52
+ */
53
+ readonly extraLayers?: readonly LayerBan[];
54
+ }
@@ -193,6 +193,10 @@ export const SONARJS_RULES: Readonly<Record<string, unknown>> = {
193
193
  // False positives: connection method names like 'imap-password' and field
194
194
  // names like 'password_hash'.
195
195
  'sonarjs/no-hardcoded-passwords': 'off',
196
+ // Task markers are governed by `rexezuge/todo-format` (`TODO(<scope>): <text>` is the family form);
197
+ // the stock tags flag even the scoped form, so every tracked gap became an error.
198
+ 'sonarjs/todo-tag': 'off',
199
+ 'sonarjs/fixme-tag': 'off',
196
200
  // Third-party deprecations are warnings, not errors.
197
201
  'sonarjs/deprecation': 'warn',
198
202
  // Nested ternaries in complex data-mapping code.
@@ -104,3 +104,32 @@ describe('defineRepoLintConfig integration', () => {
104
104
  expect(() => defineRepoLintConfig({ manifest: false })).toThrow(/scope/);
105
105
  });
106
106
  });
107
+
108
+ describe('strict: task markers', () => {
109
+ const lintTodo = (code: string): string[] => lint(code, 'apps/api/src/a.ts');
110
+ it.each([
111
+ '// TODO(sdk): replace this with the kit helper',
112
+ '// FIXME(totp-generator): the proxy drops the header',
113
+ '/**\n * TODO(pilot.1): a block comment\n */',
114
+ '// the TODO list is kept in the README',
115
+ '// TODOS are tracked elsewhere',
116
+ ])('allows %s', (code) => {
117
+ expect(lintTodo(code)).toEqual([]);
118
+ });
119
+ it.each(['// TODO', '// TODO: later', '// FIXME fix it', '// TODO(sdk)', '// TODO(sdk):', '/*\n * some text\n * TODO( ): x\n */'])(
120
+ 'refuses %s',
121
+ (code) => {
122
+ expect(lintTodo(code)[0]).toContain('rexezuge/todo-format');
123
+ },
124
+ );
125
+ it('names the tag and the form in the message, and also lints scripts', () => {
126
+ expect(lintTodo('// FIXME')[0]).toContain('FIXME(<scope>): <what is to be done>');
127
+ expect(lint('// TODO', 'scripts/a.mjs')[0]).toContain('rexezuge/todo-format');
128
+ });
129
+ it('turns the stock sonarjs tags off in the repo config', () => {
130
+ const rules = Object.assign({}, ...(defineRepoLintConfig({ scope: '@x' }) as Array<{ rules?: object }>).map((entry) => entry.rules));
131
+ expect((rules as Record<string, unknown>)['sonarjs/todo-tag']).toBe('off');
132
+ expect((rules as Record<string, unknown>)['sonarjs/fixme-tag']).toBe('off');
133
+ expect((rules as Record<string, unknown>)['rexezuge/todo-format']).toBe('error');
134
+ });
135
+ });
@@ -7,7 +7,7 @@ import type tseslint from 'typescript-eslint';
7
7
  *
8
8
  * Every rule here exists because a family repo once re-implemented something the
9
9
  * kit now owns; each message names the kit API to use instead. They use two
10
- * kit-local rules (`rexezuge/restricted-import`, `rexezuge/no-hand-built-envelope`)
10
+ * kit-local rules (`rexezuge/restricted-import`, `rexezuge/no-hand-built-envelope`, `rexezuge/todo-format`)
11
11
  * and `no-restricted-globals` rather than `no-restricted-imports` /
12
12
  * `no-restricted-syntax`: flat config replaces a rule's options per file instead
13
13
  * of merging them, so a strict entry in those two would silently erase the layer
@@ -96,7 +96,39 @@ const noHandBuiltEnvelope: Rule.RuleModule = {
96
96
  },
97
97
  };
98
98
 
99
- export const REXEZUGE_PLUGIN = { rules: { 'restricted-import': restrictedImport, 'no-hand-built-envelope': noHandBuiltEnvelope } };
99
+ /**
100
+ * A task marker is `TODO(<scope>): <text>` (or `FIXME(...)`): who or what it waits on, and what is to be done.
101
+ * A bare `TODO`, `TODO:` or `TODO(sdk)` with no text is a note nobody can act on, so it is an error.
102
+ * Only a marker that starts a comment line is a marker, so prose that mentions the word is left alone.
103
+ * This replaces `sonarjs/todo-tag` and `sonarjs/fixme-tag`, which flagged the scoped form too.
104
+ */
105
+ const TODO_MARKER = /^[\s*/]*(TODO|FIXME)\b(.*)$/;
106
+ const TODO_FORMAT = /^\([^()\s]+\):\s*\S/;
107
+
108
+ const todoFormat: Rule.RuleModule = {
109
+ meta: {
110
+ type: 'suggestion',
111
+ schema: [],
112
+ messages: { bare: '`{{tag}}` needs a scope and a description: `{{tag}}(<scope>): <what is to be done>`.' },
113
+ },
114
+ create(context) {
115
+ return {
116
+ Program() {
117
+ for (const comment of context.sourceCode.getAllComments()) {
118
+ for (const line of comment.value.split('\n')) {
119
+ const match = TODO_MARKER.exec(line);
120
+ if (match === null || TODO_FORMAT.test(match[2] ?? '')) continue;
121
+ context.report({ loc: comment.loc ?? { line: 1, column: 0 }, messageId: 'bare', data: { tag: match[1] ?? 'TODO' } });
122
+ }
123
+ }
124
+ },
125
+ };
126
+ },
127
+ };
128
+
129
+ export const REXEZUGE_PLUGIN = {
130
+ rules: { 'restricted-import': restrictedImport, 'no-hand-built-envelope': noHandBuiltEnvelope, 'todo-format': todoFormat },
131
+ };
100
132
 
101
133
  const TS_FILES = ['**/*.{ts,mts,cts,tsx}'];
102
134
  const SOURCE_FILES = ['**/*.{js,mjs,cjs,ts,mts,cts,tsx,jsx}'];
@@ -158,9 +190,9 @@ export function strictConfigs(options: StrictOptions): ConfigInput[] {
158
190
  },
159
191
  },
160
192
  {
161
- files: TS_FILES,
193
+ files: SOURCE_FILES,
162
194
  plugins: { rexezuge: REXEZUGE_PLUGIN },
163
- rules: {},
195
+ rules: { 'rexezuge/todo-format': 'error' },
164
196
  },
165
197
  // Rules of one name replace each other per file, so each region states its
166
198
  // whole ban list: framework + kit outside the http layer and apps/api (the
package/src/eslint.ts CHANGED
@@ -59,64 +59,13 @@ import eslintConfigPrettier from 'eslint-config-prettier';
59
59
  import prettier from 'eslint-plugin-prettier';
60
60
  import type { FlatConfig } from 'typescript-eslint';
61
61
  import { DEFAULT_PROJECT_DIRS, layerBans, restrictedDynamicImports, restrictedImports } from './eslint-boundaries.ts';
62
- import type { LayerBan } from './eslint-boundaries.ts';
62
+ import type { RepoLintConfigOptions } from './eslint-options.ts';
63
63
  import { manifestBrowserDirs, manifestHttpDirs, manifestLayerBans } from './eslint-manifest.ts';
64
64
  import { strictConfigs } from './eslint-strict.ts';
65
65
  import { loadManifest } from './manifest.ts';
66
- import type { FamilyManifest } from './manifest.ts';
67
66
  import { SONARJS_RULES, TEST_RULES, TYPESCRIPT_RULES, UNICORN_RULES } from './eslint-rules.ts';
68
67
 
69
- /**
70
- * What `defineRepoLintConfig` accepts.
71
- */
72
- export interface RepoLintConfigOptions {
73
- /**
74
- * The consuming repo's npm scope, e.g. `'@myapp'`. Every `no-restricted-imports`
75
- * pattern in the boundary rules is derived from it, so the same factory serves
76
- * all nine repos.
77
- */
78
- readonly scope?: string;
79
- /**
80
- * The family manifest. Omitted: `<tsconfigRootDir or cwd>/.rexezuge.jsonc` is
81
- * loaded when it exists. Pass `false` to ignore the file. A manifest supplies
82
- * `scope` (unless given here), replaces the canonical layer table with its own
83
- * `layers` (when it declares any), and names the http and browser directories
84
- * the strict rules exempt.
85
- */
86
- readonly manifest?: FamilyManifest | false;
87
- /**
88
- * Extra http-layer directories (may import `hono`/`chanfana`, hand-build the
89
- * error envelope), beside `apps/api` and the manifest's `http: true` layers.
90
- */
91
- readonly httpDirs?: readonly string[];
92
- /**
93
- * The workspace directories the legacy canonical layer table is scoped to, as
94
- * repo-relative globs. Only used when no manifest declares `layers`.
95
- *
96
- * @deprecated Declare `layers` in `.rexezuge.jsonc` instead: the canonical
97
- * table encodes consumer package names.
98
- */
99
- readonly projectDirs?: readonly string[];
100
- /**
101
- * Extra ignore globs, merged with the canonical set.
102
- */
103
- readonly extraIgnores?: readonly string[];
104
- /**
105
- * Where `projectService` resolves the tsconfig from. Defaults to the directory
106
- * ESLint is invoked in, which is the repo root in every CI job.
107
- */
108
- readonly tsconfigRootDir?: string;
109
- /**
110
- * Extra boundary layers, appended to the canonical table.
111
- *
112
- * The escape valve for a repo whose layout has a boundary the canonical table
113
- * does not name — AWS-AccessBridge's `apps/api/src/endpoints/**` rule ("route
114
- * classes must not import DAOs directly") and its `aws4fetch` ban are the shape.
115
- * Same {@link LayerBan} form, so `extraLayers` flows through the
116
- * `no-restricted-imports` and the `no-restricted-syntax` guard alike.
117
- */
118
- readonly extraLayers?: readonly LayerBan[];
119
- }
68
+ export type { RepoLintConfigOptions } from './eslint-options.ts';
120
69
 
121
70
  /**
122
71
  * One argument to `tseslint.config()`.
@@ -1,7 +1,13 @@
1
- # Dependabot — weekly dependency updates, grouped so one PR covers the
2
- # toolchain rather than twelve separate ones. @rexezuge/* updates land in
3
- # their own group, which is the kit's upgrade path: a bump PR per repo, and
4
- # the repo's own CI is the gate.
1
+ # Dependabot: weekly dependency updates, grouped so one PR covers a concern instead of a dozen.
2
+ #
3
+ # The npm ecosystem at `/` reads the pnpm workspace's `catalog:` in pnpm-workspace.yaml, so a bump edits the
4
+ # catalog entry once instead of every package.json that uses it. Groups:
5
+ # kit @rexezuge/*, the family SDK.
6
+ # toolchain the compiler, test runner, bundler, linters and wrangler.
7
+ # cloudflare @cloudflare/*.
8
+ # worker-ci.yml auto-merges a PR of these three groups once CI is green, and only when every update in it is a patch
9
+ # or a minor (never a major). It reads the group from Dependabot itself (dependabot/fetch-metadata's `dependency-group`),
10
+ # so renaming a group here changes what is auto-merged: keep the names.
5
11
 
6
12
  version: 2
7
13
  updates:
@@ -20,8 +26,12 @@ updates:
20
26
  patterns:
21
27
  - 'typescript'
22
28
  - 'vitest'
29
+ - '@vitest/*'
23
30
  - 'vite'
31
+ - '@vitejs/*'
24
32
  - 'eslint'
33
+ - 'eslint-*'
34
+ - '@eslint/*'
25
35
  - 'typescript-eslint'
26
36
  - 'prettier'
27
37
  - 'wrangler'
@@ -0,0 +1,15 @@
1
+ # A thin caller: the pipeline lives in Rexezuge-CloudflareWorkers/SDK/.github/workflows/backup-d1.yml (tag v1).
2
+ # Jobs switch on .rexezuge.jsonc features; change behaviour there or in the SDK, not here.
3
+ name: Backup D1
4
+
5
+ on:
6
+ schedule:
7
+ - cron: '15 4 * * *'
8
+ workflow_dispatch:
9
+
10
+ jobs:
11
+ backup-d1:
12
+ permissions:
13
+ contents: read
14
+ uses: Rexezuge-CloudflareWorkers/SDK/.github/workflows/backup-d1.yml@v1
15
+ secrets: inherit
@@ -1,133 +1,16 @@
1
- # Backup Main Branch — mirror the repository to secondary git forges.
2
- #
3
- # Converged from the family's backup-main.yml. Destinations are opt-in by
4
- # secret: with neither BACKUP_REPO_AZURE_DEVOPS_SSH_KEY nor
5
- # BACKUP_REPO_GITLAB_* configured, the check job reports both false and every
6
- # downstream job is skipped. Push to main seeds the mirror; the monthly
7
- # schedule re-verifies it.
8
- #
9
- # No REPLACE_ME placeholders: every repo-specific value is a secret, so this
10
- # file copies verbatim. It needs .github/actions/retry-step alongside it.
11
-
12
- name: Backup Main Branch
13
-
14
- permissions:
15
- contents: read
1
+ # A thin caller: the pipeline lives in Rexezuge-CloudflareWorkers/SDK/.github/workflows/backup-main.yml (tag v1).
2
+ # Jobs switch on .rexezuge.jsonc features; change behaviour there or in the SDK, not here.
3
+ name: Backup Main
16
4
 
17
5
  on:
18
6
  push:
19
- branches:
20
- - main
7
+ branches: [main]
21
8
  schedule:
22
9
  - cron: '0 0 5 * *'
23
10
 
24
11
  jobs:
25
- check-secrets:
26
- name: Check Secrets
27
- runs-on: ubuntu-latest
28
- outputs:
29
- azure-configured: ${{ steps.check.outputs.azure }}
30
- gitlab-configured: ${{ steps.check.outputs.gitlab }}
31
- steps:
32
- - name: Detect Configured Destinations
33
- id: check
34
- env:
35
- AZURE_KEY: ${{ secrets.BACKUP_REPO_AZURE_DEVOPS_SSH_KEY }}
36
- AZURE_URL: ${{ secrets.BACKUP_REPO_AZURE_DEVOPS_REPO_URL }}
37
- GITLAB_KEY: ${{ secrets.BACKUP_REPO_GITLAB_SSH_KEY }}
38
- GITLAB_URL: ${{ secrets.BACKUP_REPO_GITLAB_REPO_URL }}
39
- run: |
40
- if [ -n "$AZURE_KEY" ] && [ -n "$AZURE_URL" ]; then
41
- echo "azure=true" >> "$GITHUB_OUTPUT"
42
- else
43
- echo "azure=false" >> "$GITHUB_OUTPUT"
44
- fi
45
- if [ -n "$GITLAB_KEY" ] && [ -n "$GITLAB_URL" ]; then
46
- echo "gitlab=true" >> "$GITHUB_OUTPUT"
47
- else
48
- echo "gitlab=false" >> "$GITHUB_OUTPUT"
49
- fi
50
-
51
- backup-azure-devops:
52
- needs: check-secrets
53
- if: >-
54
- ${{ !github.event.repository.fork &&
55
- needs.check-secrets.outputs.azure-configured == 'true' }}
56
- name: Azure DevOps
57
- runs-on: ubuntu-latest
58
-
59
- steps:
60
- - name: Checkout Source Repository
61
- uses: actions/checkout@v6
62
- with:
63
- fetch-depth: 0
64
-
65
- - name: Configure Git
66
- run: |
67
- git config user.name "Actions"
68
- git config user.email "actions@github.com"
69
-
70
- # The key reaches the shell through env, never through `${{ }}` inside the
71
- # script, and is written by printf (no echo escape interpretation) into a
72
- # file created 0600 from the start. accept-new pins the forge's host key on
73
- # first contact and refuses a changed one, unlike `no`.
74
- - name: Set Up SSH for Azure DevOps
75
- env:
76
- SSH_KEY: ${{ secrets.BACKUP_REPO_AZURE_DEVOPS_SSH_KEY }}
77
- run: |
78
- install -d -m 700 ~/.ssh
79
- install -m 600 /dev/null ~/.ssh/id_rsa
80
- printf '%s\n' "$SSH_KEY" > ~/.ssh/id_rsa
81
- printf 'Host *\n\tStrictHostKeyChecking accept-new\n\tIdentityFile ~/.ssh/id_rsa\n' > ~/.ssh/config
82
- chmod 600 ~/.ssh/config
83
-
84
- - name: Add SSH Remote
85
- env:
86
- REPO_URL: ${{ secrets.BACKUP_REPO_AZURE_DEVOPS_REPO_URL }}
87
- run: git remote add backup "$REPO_URL"
88
-
89
- - name: Push main Branch to Azure DevOps
90
- uses: ./.github/actions/retry-step
91
- with:
92
- command: git push --force backup main:main
93
- max_attempts: '3'
94
-
95
- backup-gitlab:
96
- needs: check-secrets
97
- if: >-
98
- ${{ !github.event.repository.fork &&
99
- needs.check-secrets.outputs.gitlab-configured == 'true' }}
100
- name: GitLab
101
- runs-on: ubuntu-latest
102
-
103
- steps:
104
- - name: Checkout Source Repository
105
- uses: actions/checkout@v6
106
- with:
107
- fetch-depth: 0
108
-
109
- - name: Configure Git
110
- run: |
111
- git config user.name "Actions"
112
- git config user.email "actions@github.com"
113
-
114
- - name: Set Up SSH for GitLab
115
- env:
116
- SSH_KEY: ${{ secrets.BACKUP_REPO_GITLAB_SSH_KEY }}
117
- run: |
118
- install -d -m 700 ~/.ssh
119
- install -m 600 /dev/null ~/.ssh/id_rsa
120
- printf '%s\n' "$SSH_KEY" > ~/.ssh/id_rsa
121
- printf 'Host *\n\tStrictHostKeyChecking accept-new\n\tIdentityFile ~/.ssh/id_rsa\n' > ~/.ssh/config
122
- chmod 600 ~/.ssh/config
123
-
124
- - name: Add SSH Remote
125
- env:
126
- REPO_URL: ${{ secrets.BACKUP_REPO_GITLAB_REPO_URL }}
127
- run: git remote add backup "$REPO_URL"
128
-
129
- - name: Push main Branch to GitLab
130
- uses: ./.github/actions/retry-step
131
- with:
132
- command: git push --force backup main:main
133
- max_attempts: '3'
12
+ backup-main:
13
+ permissions:
14
+ contents: read
15
+ uses: Rexezuge-CloudflareWorkers/SDK/.github/workflows/backup-main.yml@v1
16
+ secrets: inherit