@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.
- package/README.md +67 -34
- package/dist/eslint-options.d.ts +54 -0
- package/dist/eslint-options.d.ts.map +1 -0
- package/dist/eslint-options.js +0 -0
- package/dist/eslint-options.js.map +7 -0
- package/dist/eslint-rules.d.ts.map +1 -1
- package/dist/eslint-rules.js +1 -1
- package/dist/eslint-rules.js.map +2 -2
- package/dist/eslint-strict.d.ts +2 -1
- package/dist/eslint-strict.d.ts.map +1 -1
- package/dist/eslint-strict.js +2 -1
- package/dist/eslint-strict.js.map +3 -3
- package/dist/eslint.d.ts +2 -53
- package/dist/eslint.d.ts.map +1 -1
- package/dist/eslint.js.map +2 -2
- package/dist/manifest-validate.d.ts.map +1 -1
- package/dist/manifest-validate.js +1 -1
- package/dist/manifest-validate.js.map +3 -3
- package/dist/manifest.d.ts +21 -0
- package/dist/manifest.d.ts.map +1 -1
- package/dist/manifest.js.map +2 -2
- package/dist/pages-proxy.d.ts +2 -0
- package/dist/pages-proxy.d.ts.map +1 -0
- package/dist/pages-proxy.js +1 -0
- package/dist/pages-proxy.js.map +7 -0
- package/dist/plugin-option.d.ts +15 -0
- package/dist/plugin-option.d.ts.map +1 -0
- package/dist/plugin-option.js +1 -0
- package/dist/plugin-option.js.map +7 -0
- package/dist/scripts/backup/destinations.d.ts +40 -0
- package/dist/scripts/backup/destinations.d.ts.map +1 -0
- package/dist/scripts/backup/destinations.js +1 -0
- package/dist/scripts/backup/destinations.js.map +7 -0
- package/dist/scripts/backup/encrypt-backup.d.ts +5 -2
- package/dist/scripts/backup/encrypt-backup.d.ts.map +1 -1
- package/dist/scripts/backup/encrypt-backup.js +2 -3
- package/dist/scripts/backup/encrypt-backup.js.map +3 -3
- package/dist/scripts/backup/naming.d.ts +1 -1
- package/dist/scripts/backup/naming.d.ts.map +1 -1
- package/dist/scripts/backup/naming.js +1 -1
- package/dist/scripts/backup/naming.js.map +3 -3
- package/dist/scripts/ensure-spa-shell-stub.d.ts +4 -2
- package/dist/scripts/ensure-spa-shell-stub.d.ts.map +1 -1
- package/dist/scripts/ensure-spa-shell-stub.js +1 -2
- package/dist/scripts/ensure-spa-shell-stub.js.map +3 -3
- package/dist/scripts/init-secrets.d.ts +1 -2
- package/dist/scripts/init-secrets.d.ts.map +1 -1
- package/dist/scripts/init-secrets.js +2 -3
- package/dist/scripts/init-secrets.js.map +3 -3
- package/dist/scripts/migrations-lock.d.ts +6 -2
- package/dist/scripts/migrations-lock.d.ts.map +1 -1
- package/dist/scripts/migrations-lock.js +1 -2
- package/dist/scripts/migrations-lock.js.map +3 -3
- package/dist/scripts/prepare-wrangler-config.d.ts +6 -2
- package/dist/scripts/prepare-wrangler-config.d.ts.map +1 -1
- package/dist/scripts/prepare-wrangler-config.js +1 -2
- package/dist/scripts/prepare-wrangler-config.js.map +3 -3
- package/dist/scripts/validate-locales.d.ts +20 -2
- package/dist/scripts/validate-locales.d.ts.map +1 -1
- package/dist/scripts/validate-locales.js +5 -5
- package/dist/scripts/validate-locales.js.map +3 -3
- package/dist/scripts/verify-spa-shell.d.ts +7 -2
- package/dist/scripts/verify-spa-shell.d.ts.map +1 -1
- package/dist/scripts/verify-spa-shell.js +1 -2
- package/dist/scripts/verify-spa-shell.js.map +3 -3
- package/dist/scripts/wrangler-config/resources.d.ts +11 -2
- package/dist/scripts/wrangler-config/resources.d.ts.map +1 -1
- package/dist/scripts/wrangler-config/resources.js +1 -1
- package/dist/scripts/wrangler-config/resources.js.map +3 -3
- package/dist/vite.d.ts +2 -1
- package/dist/vite.d.ts.map +1 -1
- package/dist/vite.js +3 -3
- package/dist/vite.js.map +3 -3
- package/dist/vitest-aliases.d.ts +7 -1
- package/dist/vitest-aliases.d.ts.map +1 -1
- package/dist/vitest-aliases.js +1 -1
- package/dist/vitest-aliases.js.map +3 -3
- package/dist/vitest-integration.d.ts +3 -2
- package/dist/vitest-integration.d.ts.map +1 -1
- package/dist/vitest-integration.js +1 -1
- package/dist/vitest-integration.js.map +3 -3
- package/dist/vitest-repo.d.ts +3 -2
- package/dist/vitest-repo.d.ts.map +1 -1
- package/dist/vitest-repo.js +1 -1
- package/dist/vitest-repo.js.map +3 -3
- package/dist/vitest-web.d.ts +3 -2
- package/dist/vitest-web.d.ts.map +1 -1
- package/dist/vitest-web.js +1 -1
- package/dist/vitest-web.js.map +3 -3
- package/dist/vitest.d.ts +4 -3
- package/dist/vitest.d.ts.map +1 -1
- package/dist/vitest.js +1 -1
- package/dist/vitest.js.map +3 -3
- package/package.json +3 -3
- package/presets/tsconfig/web.json +2 -2
- package/schema/manifest.schema.json +28 -1
- package/src/eslint-options.ts +54 -0
- package/src/eslint-rules.ts +4 -0
- package/src/eslint-strict.test.ts +29 -0
- package/src/eslint-strict.ts +36 -4
- package/src/eslint.ts +2 -53
- package/src/github/dependabot.yml +14 -4
- package/src/github/workflows/backup-d1.yml +15 -0
- package/src/github/workflows/backup-main.yml +9 -126
- package/src/github/workflows/continuous-deployment.yml +11 -180
- package/src/github/workflows/continuous-integration.yml +9 -249
- package/src/github/workflows/scheduled-version-update.yml +8 -31
- package/src/github/workflows/upstream-sync.yml +8 -49
- package/src/manifest-validate.ts +31 -2
- package/src/manifest.test.ts +22 -0
- package/src/manifest.ts +22 -0
- package/src/pages-proxy.test.ts +8 -0
- package/src/pages-proxy.ts +13 -0
- package/src/plugin-option.test.ts +13 -0
- package/src/plugin-option.ts +18 -0
- package/src/presets.test.ts +5 -1
- package/src/scripts/backup/backup-rules.test.ts +22 -0
- package/src/scripts/backup/destinations.ts +59 -0
- package/src/scripts/backup/encrypt-backup.ts +58 -48
- package/src/scripts/backup/naming.ts +2 -2
- package/src/scripts/ensure-spa-shell-stub.ts +18 -10
- package/src/scripts/entrypoints.test.ts +55 -0
- package/src/scripts/init-secrets.ts +8 -6
- package/src/scripts/migrations-lock.ts +22 -17
- package/src/scripts/prepare-wrangler-config.ts +34 -14
- package/src/scripts/validate-locales.ts +39 -17
- package/src/scripts/verify-spa-shell.ts +21 -20
- package/src/scripts/wrangler-config/resources.test.ts +10 -0
- package/src/scripts/wrangler-config/resources.ts +21 -4
- package/src/vite.ts +5 -3
- package/src/vitest-aliases.test.ts +33 -0
- package/src/vitest-aliases.ts +37 -7
- package/src/vitest-integration.ts +7 -8
- package/src/vitest-repo.ts +7 -5
- package/src/vitest-web.ts +7 -5
- package/src/vitest.ts +8 -6
- package/src/github/actions/retry-step/action.yml +0 -55
- package/src/github/actions/setup-env/action.yml +0 -20
package/dist/eslint.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/eslint.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * The converged ESLint flat config for a monorepo in the Rexezuge family.\n *\n * Provenance: the base is Durable-DAV's `eslint.config.mjs` (the most\n * elaborate of the nine repos, with the layered `no-restricted-imports` boundary\n * rules). Merged in from the stacks that share the same plugin set:\n *\n * - **Edge-Sonic** — `test/**` is *not* ignored (it is linted like everything else,\n * with a narrow override block for Vitest idioms), and `unicorn/prefer-ternary`\n * is off. Edge-Sonic is also the source for the dynamic-`import()` boundary\n * guard and its `apps/web` layer block.\n * - **Mail-Meow** — `prettier/prettier` is an **error**, not a warning.\n * - **AWS-AccessBridge** — the `apps/api` DAO/service boundary uses\n * `allowTypeImports` where the source repos do not. It is also the source for\n * the anchored skip patterns and the symlink-safe walk that came out of its own\n * backlog.\n * - **CalDAV-Bridge, Mail-Otter, Durable-DAV-Router, Edge-Git, Agent-Router** —\n * the `provider-clients` / `webdav`+`dav-store` / `git-protocol`+`git-service`\n * layers and the per-client `apps/api` alternatives in the boundary table.\n *\n * Canonical decisions, and why each one:\n *\n * 1. **`prettier/prettier: 'error'`.** Three of the four source repos had it at\n * `warn`, which under `eslint --quiet` is unenforceable — a gate nobody can see\n * is a gate that has never run. Formatting drift is therefore a hard failure.\n * 2. **The layered boundary rules are parameterized by `scope`.** Every source\n * repo wrote the same blocks with a different npm scope hardcoded; the\n * factory takes `scope` (`'@myapp'`) and generates the `@myapp/*` patterns.\n * The table itself lives in {@link ./eslint-boundaries.ts} and covers the\n * family superset — a repo without a domain package never triggers its ban,\n * so no repo needs `extraLayers` for a known package.\n * 3. **`test/**` is linted, not ignored.** Durable-DAV/AWS/Mail-Meow ignored it;\n * Edge-Sonic does not, and records why: ~200 KB of test code had accumulated\n * violations that nothing reported.\n * 4. **`apps/web` is a layer in its own right**, banned from every `@scope/*`\n * package. Edge-Sonic is the only source with that block; the others had none,\n * which is how their layer table's \"may import: the browser\" was a convention\n * rather than a gate. A backend package imported by the SPA compiles and then\n * fails at bundle time, with the error pointing at the bundler.\n * 5. **jsdom + node globals for web files.** The sources ran `globals.node` only;\n * `apps/web` needs browser globals as well, and the vitest config for the SPA\n * runs under jsdom, so the lint environment matches the test environment.\n * 6. **`eslint-plugin-react-hooks` is NOT imported here.** The kit stays\n * zero-dependency, and the plugin belongs to the app that has JSX. A consumer\n * appends it — the README shows the four lines.\n *\n * The rule bodies live in {@link ./eslint-rules.ts} and the boundary table in\n * {@link ./eslint-boundaries.ts}; this file is the assembly. A repo that needs a\n * boundary the canonical table does not name passes `extraLayers` — see\n * {@link RepoLintConfigOptions}.\n */\n\nimport globals from 'globals';\nimport tseslint from 'typescript-eslint';\nimport unicorn from 'eslint-plugin-unicorn';\nimport { configs as sonarjsConfigs } from 'eslint-plugin-sonarjs';\nimport pluginRegexp from 'eslint-plugin-regexp';\nimport eslintConfigPrettier from 'eslint-config-prettier';\nimport prettier from 'eslint-plugin-prettier';\nimport type { FlatConfig } from 'typescript-eslint';\nimport { DEFAULT_PROJECT_DIRS, layerBans, restrictedDynamicImports, restrictedImports } from './eslint-boundaries.ts';\nimport type { LayerBan } from './eslint-boundaries.ts';\nimport { manifestBrowserDirs, manifestHttpDirs, manifestLayerBans } from './eslint-manifest.ts';\nimport { strictConfigs } from './eslint-strict.ts';\nimport { loadManifest } from './manifest.ts';\nimport type { FamilyManifest } from './manifest.ts';\nimport { SONARJS_RULES, TEST_RULES, TYPESCRIPT_RULES, UNICORN_RULES } from './eslint-rules.ts';\n\n/**\n * What `defineRepoLintConfig` accepts.\n */\nexport interface RepoLintConfigOptions {\n /**\n * The consuming repo's npm scope, e.g. `'@myapp'`. Every `no-restricted-imports`\n * pattern in the boundary rules is derived from it, so the same factory serves\n * all nine repos.\n */\n readonly scope?: string;\n /**\n * The family manifest. Omitted: `<tsconfigRootDir or cwd>/.rexezuge.jsonc` is\n * loaded when it exists. Pass `false` to ignore the file. A manifest supplies\n * `scope` (unless given here), replaces the canonical layer table with its own\n * `layers` (when it declares any), and names the http and browser directories\n * the strict rules exempt.\n */\n readonly manifest?: FamilyManifest | false;\n /**\n * Extra http-layer directories (may import `hono`/`chanfana`, hand-build the\n * error envelope), beside `apps/api` and the manifest's `http: true` layers.\n */\n readonly httpDirs?: readonly string[];\n /**\n * The workspace directories the legacy canonical layer table is scoped to, as\n * repo-relative globs. Only used when no manifest declares `layers`.\n *\n * @deprecated Declare `layers` in `.rexezuge.jsonc` instead: the canonical\n * table encodes consumer package names.\n */\n readonly projectDirs?: readonly string[];\n /**\n * Extra ignore globs, merged with the canonical set.\n */\n readonly extraIgnores?: readonly string[];\n /**\n * Where `projectService` resolves the tsconfig from. Defaults to the directory\n * ESLint is invoked in, which is the repo root in every CI job.\n */\n readonly tsconfigRootDir?: string;\n /**\n * Extra boundary layers, appended to the canonical table.\n *\n * The escape valve for a repo whose layout has a boundary the canonical table\n * does not name — AWS-AccessBridge's `apps/api/src/endpoints/**` rule (\"route\n * classes must not import DAOs directly\") and its `aws4fetch` ban are the shape.\n * Same {@link LayerBan} form, so `extraLayers` flows through the\n * `no-restricted-imports` and the `no-restricted-syntax` guard alike.\n */\n readonly extraLayers?: readonly LayerBan[];\n}\n\n/**\n * One argument to `tseslint.config()`.\n */\ntype ConfigInput = Parameters<typeof tseslint.config>[number];\n\n/**\n * A plugin preset or config object as the source repos pass it.\n */\ntype MaybeConfig = FlatConfig.Config | readonly FlatConfig.Config[];\n\n/**\n * Bridge a third-party preset into `tseslint.config()`.\n *\n * `sonarjs`' `recommended` preset is typed as a union that includes the legacy\n * config shape, which `tseslint.config()` does not accept — but ESLint accepts it\n * at runtime, which is the only thing that matters here. One checked assertion,\n * rather than forking the plugin's own types.\n */\nfunction asConfig(config: MaybeConfig): ConfigInput {\n return config as ConfigInput;\n}\n\n/**\n * Bridge a rule block onto `tseslint.config()`'s `rules` field.\n *\n * The blocks in `eslint-rules.ts` are written as ESLint expects them —\n * `'off' | 'warn' | 'error' | [level, ...options]` — but spelled as data so a\n * rule's reason comment sits beside the rule itself. ESLint's own `RuleEntry`\n * union is narrower than the data shape, and widening every entry to that union\n * would buy nothing; one assertion here, with the reason, is the cheaper and\n * more honest of the two.\n */\nfunction asRules(block: Readonly<Record<string, unknown>>): FlatConfig.Config['rules'] {\n return block as FlatConfig.Config['rules'];\n}\n\n/**\n * Build the repo's flat config.\n *\n * Consumed from the repo root as three lines:\n *\n * ```js\n * // eslint.config.mjs\n * import { defineRepoLintConfig } from '@rexezuge/tooling/eslint';\n * export default defineRepoLintConfig({ scope: '@myapp' });\n * ```\n */\nexport function defineRepoLintConfig(options: RepoLintConfigOptions): FlatConfig.ConfigArray {\n const manifest = options.manifest === false ? null : (options.manifest ?? loadManifest(options.tsconfigRootDir ?? process.cwd()));\n const scope = options.scope ?? manifest?.scope;\n if (scope === undefined) throw new Error('defineRepoLintConfig: pass `scope`, or add a `.rexezuge.jsonc` manifest that declares it.');\n const projectDirs = options.projectDirs ?? DEFAULT_PROJECT_DIRS;\n const layerRows =\n manifest?.layers === undefined\n ? layerBans(scope).filter((layer) => projectDirs.some((dir) => layer.dir.startsWith(dir)))\n : manifestLayerBans(manifest);\n const bans = [...layerRows, ...(options.extraLayers ?? [])];\n const browserDirs = manifestBrowserDirs(manifest);\n\n return tseslint.config(\n {\n ignores: [\n 'eslint.config.mjs',\n 'eslint.config.js',\n 'scripts/**',\n 'worker-configuration.d.ts',\n 'local/**',\n 'app/dist/**',\n 'apps/web/dist/**',\n 'apps/*/dist/**',\n 'src/generated/**',\n 'apps/api/src/generated/**',\n 'coverage/**',\n 'coverage-integration/**',\n 'coverage-web/**',\n 'node_modules/**',\n ...(options.extraIgnores ?? []),\n ],\n },\n\n // Base: globals for all JS/TS source files. Node is the floor because the\n // scripts and the workers both run on it; the web block below adds browser\n // globals rather than replacing them, so a shared file that touches both\n // (there are several in `shared/`) still lints.\n {\n files: ['**/*.{js,mjs,cjs,ts,mts,cts,tsx,jsx}'],\n languageOptions: {\n globals: globals.node,\n },\n },\n\n // Type-aware TS rules, scoped to TS files only.\n {\n files: ['**/*.{ts,mts,cts,tsx}'],\n extends: tseslint.configs.recommendedTypeChecked,\n languageOptions: {\n parserOptions: {\n projectService: true,\n tsconfigRootDir: options.tsconfigRootDir ?? process.cwd(),\n },\n },\n },\n\n // --- typescript-eslint overrides (identical in all four source stacks) ---\n {\n files: ['**/*.{ts,mts,cts,tsx}'],\n rules: asRules(TYPESCRIPT_RULES),\n },\n\n // --- Unicorn + SonarJS presets, then the family's off-block ---\n //\n // Both presets come first on purpose: UNICORN_RULES carries `sonarjs/*`\n // offs as well as `unicorn/*` ones (it is the family's single\n // \"deliberately does not follow\" block), and a preset applied after it\n // would re-enable them. That is exactly what shipped — the sonarjs preset\n // sat between the block and the rules it relaxed, so `void-use`,\n // `different-types-comparison`, `use-type-alias`, `redundant-type-aliases`,\n // `no-nested-assignment` and `no-all-duplicated-branches` linted as errors\n // in every consumer. The two presets do not share rule names, so their\n // relative order decides nothing.\n //\n // The unicorn preset is read from whichever spelling the installed major\n // publishes. v78 dropped the `flat/`-prefixed aliases and exports the flat\n // configs directly, so `configs['flat/recommended']` is `undefined` there —\n // and a config object built around it is `undefined` too, which ESLint\n // rejects outright with \"Unexpected undefined config\". The fallback is\n // what makes the factory work on both majors rather than only the one the\n // kit was written against.\n asConfig(unicorn.configs['flat/recommended'] ?? unicorn.configs.recommended),\n asConfig(sonarjsConfigs.recommended),\n {\n rules: asRules(UNICORN_RULES),\n },\n\n // --- SonarJS advisories ---\n {\n rules: asRules(SONARJS_RULES),\n },\n\n // --- Regexp: static analysis for regular expressions ---\n asConfig(pluginRegexp.configs['flat/recommended']),\n\n // --- Prettier: formatting drift is a hard error ---\n //\n // Mail-Meow's decision, adopted repo-wide because the alternative is\n // unenforceable: `pnpm run lint` is `eslint --fix --quiet` in three of the\n // four source repos, and `--quiet` discards every warning, so a\n // `prettier/prettier` *warning* is a silent no-op. 242 files were in that\n // state in Edge-Sonic: the gate had never run.\n asConfig(eslintConfigPrettier),\n {\n plugins: { prettier },\n rules: {\n 'prettier/prettier': 'error',\n },\n },\n\n // --- Import direction guardrails (parameterized by scope) ---\n ...restrictedImports(bans),\n ...restrictedDynamicImports(bans),\n\n // --- Strict side: family rules a repo waives per file, never wholesale ---\n ...strictConfigs({ httpDirs: [...manifestHttpDirs(manifest), ...(options.httpDirs ?? [])], browserDirs }),\n\n // --- Web: browser globals, matching the jsdom test environment ---\n //\n // The sources linted `apps/web` under `globals.node` only, so `window`,\n // `document` and `localStorage` read as undefined globals. The vitest web\n // config runs those suites under jsdom; the lint environment should agree\n // with the environment the code is executed in, or the rule is reporting\n // something untrue about how the file behaves.\n {\n files: browserDirs.map((dir) => `${dir}/**/*.{ts,tsx,js,jsx,mts,cts,mjs,cjs}`),\n languageOptions: {\n globals: { ...globals.node, ...globals.browser },\n },\n },\n\n // --- Test suite ---\n //\n // `test/**` is deliberately NOT in the ignores list above. See TEST_RULES\n // for the override block and the reasoning behind it.\n {\n files: ['test/**/*.{ts,tsx,mts,cts}', '**/*.test.{ts,tsx,mts,cts}', '**/*.spec.{ts,tsx,mts,cts}'],\n rules: asRules(TEST_RULES),\n },\n );\n}\n"],
|
|
5
|
-
"mappings": "+EAoDA,OAAOA,MAAa,UACpB,OAAOC,MAAc,oBACrB,OAAOC,MAAa,wBACpB,OAAS,WAAWC,MAAsB,wBAC1C,OAAOC,MAAkB,uBACzB,OAAOC,MAA0B,yBACjC,OAAOC,MAAc,yBAErB,OAAS,wBAAAC,EAAsB,aAAAC,EAAW,4BAAAC,EAA0B,qBAAAC,MAAyB,yBAE7F,OAAS,uBAAAC,EAAqB,oBAAAC,EAAkB,qBAAAC,MAAyB,uBACzE,OAAS,iBAAAC,MAAqB,qBAC9B,OAAS,gBAAAC,MAAoB,
|
|
4
|
+
"sourcesContent": ["/**\n * The converged ESLint flat config for a monorepo in the Rexezuge family.\n *\n * Provenance: the base is Durable-DAV's `eslint.config.mjs` (the most\n * elaborate of the nine repos, with the layered `no-restricted-imports` boundary\n * rules). Merged in from the stacks that share the same plugin set:\n *\n * - **Edge-Sonic** — `test/**` is *not* ignored (it is linted like everything else,\n * with a narrow override block for Vitest idioms), and `unicorn/prefer-ternary`\n * is off. Edge-Sonic is also the source for the dynamic-`import()` boundary\n * guard and its `apps/web` layer block.\n * - **Mail-Meow** — `prettier/prettier` is an **error**, not a warning.\n * - **AWS-AccessBridge** — the `apps/api` DAO/service boundary uses\n * `allowTypeImports` where the source repos do not. It is also the source for\n * the anchored skip patterns and the symlink-safe walk that came out of its own\n * backlog.\n * - **CalDAV-Bridge, Mail-Otter, Durable-DAV-Router, Edge-Git, Agent-Router** —\n * the `provider-clients` / `webdav`+`dav-store` / `git-protocol`+`git-service`\n * layers and the per-client `apps/api` alternatives in the boundary table.\n *\n * Canonical decisions, and why each one:\n *\n * 1. **`prettier/prettier: 'error'`.** Three of the four source repos had it at\n * `warn`, which under `eslint --quiet` is unenforceable — a gate nobody can see\n * is a gate that has never run. Formatting drift is therefore a hard failure.\n * 2. **The layered boundary rules are parameterized by `scope`.** Every source\n * repo wrote the same blocks with a different npm scope hardcoded; the\n * factory takes `scope` (`'@myapp'`) and generates the `@myapp/*` patterns.\n * The table itself lives in {@link ./eslint-boundaries.ts} and covers the\n * family superset — a repo without a domain package never triggers its ban,\n * so no repo needs `extraLayers` for a known package.\n * 3. **`test/**` is linted, not ignored.** Durable-DAV/AWS/Mail-Meow ignored it;\n * Edge-Sonic does not, and records why: ~200 KB of test code had accumulated\n * violations that nothing reported.\n * 4. **`apps/web` is a layer in its own right**, banned from every `@scope/*`\n * package. Edge-Sonic is the only source with that block; the others had none,\n * which is how their layer table's \"may import: the browser\" was a convention\n * rather than a gate. A backend package imported by the SPA compiles and then\n * fails at bundle time, with the error pointing at the bundler.\n * 5. **jsdom + node globals for web files.** The sources ran `globals.node` only;\n * `apps/web` needs browser globals as well, and the vitest config for the SPA\n * runs under jsdom, so the lint environment matches the test environment.\n * 6. **`eslint-plugin-react-hooks` is NOT imported here.** The kit stays\n * zero-dependency, and the plugin belongs to the app that has JSX. A consumer\n * appends it — the README shows the four lines.\n *\n * The rule bodies live in {@link ./eslint-rules.ts} and the boundary table in\n * {@link ./eslint-boundaries.ts}; this file is the assembly. A repo that needs a\n * boundary the canonical table does not name passes `extraLayers` — see\n * {@link RepoLintConfigOptions}.\n */\n\nimport globals from 'globals';\nimport tseslint from 'typescript-eslint';\nimport unicorn from 'eslint-plugin-unicorn';\nimport { configs as sonarjsConfigs } from 'eslint-plugin-sonarjs';\nimport pluginRegexp from 'eslint-plugin-regexp';\nimport eslintConfigPrettier from 'eslint-config-prettier';\nimport prettier from 'eslint-plugin-prettier';\nimport type { FlatConfig } from 'typescript-eslint';\nimport { DEFAULT_PROJECT_DIRS, layerBans, restrictedDynamicImports, restrictedImports } from './eslint-boundaries.ts';\nimport type { RepoLintConfigOptions } from './eslint-options.ts';\nimport { manifestBrowserDirs, manifestHttpDirs, manifestLayerBans } from './eslint-manifest.ts';\nimport { strictConfigs } from './eslint-strict.ts';\nimport { loadManifest } from './manifest.ts';\nimport { SONARJS_RULES, TEST_RULES, TYPESCRIPT_RULES, UNICORN_RULES } from './eslint-rules.ts';\n\nexport type { RepoLintConfigOptions } from './eslint-options.ts';\n\n/**\n * One argument to `tseslint.config()`.\n */\ntype ConfigInput = Parameters<typeof tseslint.config>[number];\n\n/**\n * A plugin preset or config object as the source repos pass it.\n */\ntype MaybeConfig = FlatConfig.Config | readonly FlatConfig.Config[];\n\n/**\n * Bridge a third-party preset into `tseslint.config()`.\n *\n * `sonarjs`' `recommended` preset is typed as a union that includes the legacy\n * config shape, which `tseslint.config()` does not accept — but ESLint accepts it\n * at runtime, which is the only thing that matters here. One checked assertion,\n * rather than forking the plugin's own types.\n */\nfunction asConfig(config: MaybeConfig): ConfigInput {\n return config as ConfigInput;\n}\n\n/**\n * Bridge a rule block onto `tseslint.config()`'s `rules` field.\n *\n * The blocks in `eslint-rules.ts` are written as ESLint expects them —\n * `'off' | 'warn' | 'error' | [level, ...options]` — but spelled as data so a\n * rule's reason comment sits beside the rule itself. ESLint's own `RuleEntry`\n * union is narrower than the data shape, and widening every entry to that union\n * would buy nothing; one assertion here, with the reason, is the cheaper and\n * more honest of the two.\n */\nfunction asRules(block: Readonly<Record<string, unknown>>): FlatConfig.Config['rules'] {\n return block as FlatConfig.Config['rules'];\n}\n\n/**\n * Build the repo's flat config.\n *\n * Consumed from the repo root as three lines:\n *\n * ```js\n * // eslint.config.mjs\n * import { defineRepoLintConfig } from '@rexezuge/tooling/eslint';\n * export default defineRepoLintConfig({ scope: '@myapp' });\n * ```\n */\nexport function defineRepoLintConfig(options: RepoLintConfigOptions): FlatConfig.ConfigArray {\n const manifest = options.manifest === false ? null : (options.manifest ?? loadManifest(options.tsconfigRootDir ?? process.cwd()));\n const scope = options.scope ?? manifest?.scope;\n if (scope === undefined) throw new Error('defineRepoLintConfig: pass `scope`, or add a `.rexezuge.jsonc` manifest that declares it.');\n const projectDirs = options.projectDirs ?? DEFAULT_PROJECT_DIRS;\n const layerRows =\n manifest?.layers === undefined\n ? layerBans(scope).filter((layer) => projectDirs.some((dir) => layer.dir.startsWith(dir)))\n : manifestLayerBans(manifest);\n const bans = [...layerRows, ...(options.extraLayers ?? [])];\n const browserDirs = manifestBrowserDirs(manifest);\n\n return tseslint.config(\n {\n ignores: [\n 'eslint.config.mjs',\n 'eslint.config.js',\n 'scripts/**',\n 'worker-configuration.d.ts',\n 'local/**',\n 'app/dist/**',\n 'apps/web/dist/**',\n 'apps/*/dist/**',\n 'src/generated/**',\n 'apps/api/src/generated/**',\n 'coverage/**',\n 'coverage-integration/**',\n 'coverage-web/**',\n 'node_modules/**',\n ...(options.extraIgnores ?? []),\n ],\n },\n\n // Base: globals for all JS/TS source files. Node is the floor because the\n // scripts and the workers both run on it; the web block below adds browser\n // globals rather than replacing them, so a shared file that touches both\n // (there are several in `shared/`) still lints.\n {\n files: ['**/*.{js,mjs,cjs,ts,mts,cts,tsx,jsx}'],\n languageOptions: {\n globals: globals.node,\n },\n },\n\n // Type-aware TS rules, scoped to TS files only.\n {\n files: ['**/*.{ts,mts,cts,tsx}'],\n extends: tseslint.configs.recommendedTypeChecked,\n languageOptions: {\n parserOptions: {\n projectService: true,\n tsconfigRootDir: options.tsconfigRootDir ?? process.cwd(),\n },\n },\n },\n\n // --- typescript-eslint overrides (identical in all four source stacks) ---\n {\n files: ['**/*.{ts,mts,cts,tsx}'],\n rules: asRules(TYPESCRIPT_RULES),\n },\n\n // --- Unicorn + SonarJS presets, then the family's off-block ---\n //\n // Both presets come first on purpose: UNICORN_RULES carries `sonarjs/*`\n // offs as well as `unicorn/*` ones (it is the family's single\n // \"deliberately does not follow\" block), and a preset applied after it\n // would re-enable them. That is exactly what shipped — the sonarjs preset\n // sat between the block and the rules it relaxed, so `void-use`,\n // `different-types-comparison`, `use-type-alias`, `redundant-type-aliases`,\n // `no-nested-assignment` and `no-all-duplicated-branches` linted as errors\n // in every consumer. The two presets do not share rule names, so their\n // relative order decides nothing.\n //\n // The unicorn preset is read from whichever spelling the installed major\n // publishes. v78 dropped the `flat/`-prefixed aliases and exports the flat\n // configs directly, so `configs['flat/recommended']` is `undefined` there —\n // and a config object built around it is `undefined` too, which ESLint\n // rejects outright with \"Unexpected undefined config\". The fallback is\n // what makes the factory work on both majors rather than only the one the\n // kit was written against.\n asConfig(unicorn.configs['flat/recommended'] ?? unicorn.configs.recommended),\n asConfig(sonarjsConfigs.recommended),\n {\n rules: asRules(UNICORN_RULES),\n },\n\n // --- SonarJS advisories ---\n {\n rules: asRules(SONARJS_RULES),\n },\n\n // --- Regexp: static analysis for regular expressions ---\n asConfig(pluginRegexp.configs['flat/recommended']),\n\n // --- Prettier: formatting drift is a hard error ---\n //\n // Mail-Meow's decision, adopted repo-wide because the alternative is\n // unenforceable: `pnpm run lint` is `eslint --fix --quiet` in three of the\n // four source repos, and `--quiet` discards every warning, so a\n // `prettier/prettier` *warning* is a silent no-op. 242 files were in that\n // state in Edge-Sonic: the gate had never run.\n asConfig(eslintConfigPrettier),\n {\n plugins: { prettier },\n rules: {\n 'prettier/prettier': 'error',\n },\n },\n\n // --- Import direction guardrails (parameterized by scope) ---\n ...restrictedImports(bans),\n ...restrictedDynamicImports(bans),\n\n // --- Strict side: family rules a repo waives per file, never wholesale ---\n ...strictConfigs({ httpDirs: [...manifestHttpDirs(manifest), ...(options.httpDirs ?? [])], browserDirs }),\n\n // --- Web: browser globals, matching the jsdom test environment ---\n //\n // The sources linted `apps/web` under `globals.node` only, so `window`,\n // `document` and `localStorage` read as undefined globals. The vitest web\n // config runs those suites under jsdom; the lint environment should agree\n // with the environment the code is executed in, or the rule is reporting\n // something untrue about how the file behaves.\n {\n files: browserDirs.map((dir) => `${dir}/**/*.{ts,tsx,js,jsx,mts,cts,mjs,cjs}`),\n languageOptions: {\n globals: { ...globals.node, ...globals.browser },\n },\n },\n\n // --- Test suite ---\n //\n // `test/**` is deliberately NOT in the ignores list above. See TEST_RULES\n // for the override block and the reasoning behind it.\n {\n files: ['test/**/*.{ts,tsx,mts,cts}', '**/*.test.{ts,tsx,mts,cts}', '**/*.spec.{ts,tsx,mts,cts}'],\n rules: asRules(TEST_RULES),\n },\n );\n}\n"],
|
|
5
|
+
"mappings": "+EAoDA,OAAOA,MAAa,UACpB,OAAOC,MAAc,oBACrB,OAAOC,MAAa,wBACpB,OAAS,WAAW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QAAQ,uBAC1B,gBAAiB,CACf,cAAe,CACb,eAAgB,GAChB,gBAAiByB,EAAQ,iBAAmB,QAAQ,IAAG,KAM7D,CACE,MAAO,CAAC,uBAAuB,EAC/B,MAAeR,GAsBRhB,EAAQ,QAAQ,kBAAkB,GAAKA,EAAQ,QAAQ,YACvDC,EAAe,YACxB,CACE,MAAegB,GAIjB,CACE,MAAeH,GAIRZ,EAAa,QAAQ,kBAAkB,EASvCC,EACT,CACE,QAAS,CAAE,SAAAC,CAAQ,EACnB,MAAO,CACL,oBAAqB,UAKzB,GAAGI,EAAkBoB,CAAI,EACzB,GAAGrB,EAAyBqB,CAAI,EAGhC,GAAGhB,EAAc,CAAE,SAAU,CAAC,GAAGF,EAAiBe,CAAQ,EAAG,GAAID,EAAQ,UAAY,CAAA,CAAG,EAAG,YAAAO,CAAW,CAAE,EASxG,CACE,MAAOA,EAAY,IAAKD,GAAQ,GAAGA,CAAG,uCAAuC,EAC7E,gBAAiB,CACf,QAAS,CAAE,GAAGhC,EAAQ,KAAM,GAAGA,EAAQ,OAAO,IAQlD,CACE,MAAO,CAAC,6BAA8B,6BAA8B,4BAA4B,EAChG,MAAeiB,EAChB,CAEL,CA5IgBK,EAAAG,EAAA",
|
|
6
6
|
"names": ["globals", "tseslint", "unicorn", "sonarjsConfigs", "pluginRegexp", "eslintConfigPrettier", "prettier", "DEFAULT_PROJECT_DIRS", "layerBans", "restrictedDynamicImports", "restrictedImports", "manifestBrowserDirs", "manifestHttpDirs", "manifestLayerBans", "strictConfigs", "loadManifest", "SONARJS_RULES", "TEST_RULES", "TYPESCRIPT_RULES", "UNICORN_RULES", "asConfig", "config", "__name", "asRules", "block", "defineRepoLintConfig", "options", "manifest", "scope", "projectDirs", "bans", "layer", "dir", "browserDirs"]
|
|
7
7
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"manifest-validate.d.ts","sourceRoot":"","sources":["../src/manifest-validate.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAkB,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAExE;;EAEE;AACF,eAAO,MAAM,sBAAsB;;;CAAoC,CAAC;
|
|
1
|
+
{"version":3,"file":"manifest-validate.d.ts","sourceRoot":"","sources":["../src/manifest-validate.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAkB,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAExE;;EAEE;AACF,eAAO,MAAM,sBAAsB;;;CAAoC,CAAC;AA+MxE;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,OAAO,GAAG,kBAAkB,CAcnE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var
|
|
1
|
+
var c=Object.defineProperty;var o=(s,t)=>c(s,"name",{value:t,configurable:!0});const m={soft:300,hard:400},u=o(s=>typeof s=="object"&&s!==null&&!Array.isArray(s),"isObj"),y=/^@[a-z0-9][a-z0-9-]*$/,l=/^[a-z][a-z0-9-]*$/,b=["lines","branches","functions","statements"];class g{static{o(this,"Check")}errors=[];fail(t,e){this.errors.push(`${t}: ${e}`)}keys(t,e,i){for(const n of Object.keys(e))i.includes(n)||this.fail(`${t}.${n}`,`unknown key (allowed: ${i.join(", ")})`)}obj(t,e){return u(e)?e:(this.fail(t,"must be an object"),null)}str(t,e,i,n){return typeof e!="string"||e===""?(this.fail(t,"must be a non-empty string"),!1):i&&!i.test(e)?(this.fail(t,`${JSON.stringify(e)} is invalid${n?` (${n})`:""}`),!1):!0}bool(t,e){typeof e!="boolean"&&this.fail(t,"must be a boolean")}strings(t,e){return!Array.isArray(e)||e.some(i=>typeof i!="string"||i==="")?(this.fail(t,"must be an array of non-empty strings"),!1):!0}}const p=/^[A-Z][A-Z0-9_]*$/;function k(s,t){const e=s.obj("features.kv",t);if(!e)return;s.keys("features.kv",e,["bindings","namespaceNames"]);const i=s.strings("features.kv.bindings",e.bindings)?e.bindings:[];for(const a of i)s.str("features.kv.bindings",a,p,"an UPPER_SNAKE binding name");if(e.namespaceNames===void 0)return;const n=s.obj("features.kv.namespaceNames",e.namespaceNames);if(n)for(const[a,f]of Object.entries(n)){const r=`features.kv.namespaceNames.${a}`;i.includes(a)||s.fail(r,"is not listed in features.kv.bindings"),s.str(r,f)}}o(k,"checkKv");function h(s,t){const e=s.obj("features",t);if(e){if(s.keys("features",e,["d1","kv","web","background","backupD1","durableObjects","queues","workflows","email","android"]),e.d1!==void 0){const i=s.obj("features.d1",e.d1);i&&(s.keys("features.d1",i,["binding","database","migrationsDir"]),s.str("features.d1.binding",i.binding,/^[A-Z][A-Z0-9_]*$/,"an UPPER_SNAKE binding name"),s.str("features.d1.database",i.database),i.migrationsDir!==void 0&&s.str("features.d1.migrationsDir",i.migrationsDir))}if(e.kv!==void 0&&k(s,e.kv),e.web!==void 0){const i=s.obj("features.web",e.web);i&&(s.keys("features.web",i,["pages","spaShell","buildScript","pagesProject"]),s.bool("features.web.pages",i.pages),s.bool("features.web.spaShell",i.spaShell),i.buildScript!==void 0&&s.str("features.web.buildScript",i.buildScript,/^[\w:.-]+$/,"a root package.json script name"),i.pagesProject!==void 0&&s.str("features.web.pagesProject",i.pagesProject,/^[a-z0-9][a-z0-9-]{0,57}$/,"lower-case letters, digits and hyphens, at most 58"))}for(const i of["background","backupD1","email","android"])e[i]!==void 0&&s.bool(`features.${i}`,e[i]);for(const i of["durableObjects","queues","workflows"])e[i]!==void 0&&s.strings(`features.${i}`,e[i])}}o(h,"checkFeatures");function $(s,t,e){s.keys(t,e,["name","dir","package","mayImport","typeOnly","forbid","forbidMessage","http","browser"]),s.str(`${t}.name`,e.name,l,"lower-case letters, digits and hyphens"),s.str(`${t}.dir`,e.dir)&&(/[*?{}]/.test(e.dir)||e.dir.startsWith("/")||e.dir.split("/").includes(".."))&&s.fail(`${t}.dir`,`${JSON.stringify(e.dir)} must be a repo-relative directory without globs`),e.package!==void 0&&s.str(`${t}.package`,e.package),e.forbidMessage!==void 0&&s.str(`${t}.forbidMessage`,e.forbidMessage);for(const i of["mayImport","typeOnly","forbid"])(e[i]!==void 0||i==="mayImport")&&s.strings(`${t}.${i}`,e[i]);for(const i of["http","browser"])e[i]!==void 0&&s.bool(`${t}.${i}`,e[i])}o($,"checkLayer");function w(s,t){if(!Array.isArray(t)){s.fail("layers","must be an array of layers");return}const e=new Set,i=new Set;t.forEach((n,a)=>{const f=`layers[${a}]`,r=s.obj(f,n);r&&($(s,f,r),typeof r.name=="string"&&(e.has(r.name)&&s.fail(`${f}.name`,`duplicate layer name ${JSON.stringify(r.name)}`),e.add(r.name)),typeof r.dir=="string"&&(i.has(r.dir)&&s.fail(`${f}.dir`,`duplicate layer dir ${JSON.stringify(r.dir)}`),i.add(r.dir)))}),t.forEach((n,a)=>{if(u(n))for(const f of["mayImport","typeOnly"]){const r=n[f];if(Array.isArray(r))for(const d of r)typeof d=="string"&&!e.has(d)&&s.fail(`layers[${a}].${f}`,`unknown layer ${JSON.stringify(d)}`),f==="typeOnly"&&Array.isArray(n.mayImport)&&n.mayImport.includes(d)&&s.fail(`layers[${a}].typeOnly`,`${JSON.stringify(d)} is already in mayImport`)}})}o(w,"checkLayers");function j(s,t){const e=s.obj("quality",t);e&&(s.keys("quality",e,["coverage","godFiles"]),e.coverage!==void 0&&O(s,e.coverage),e.godFiles!==void 0&&S(s,e.godFiles))}o(j,"checkQuality");function S(s,t){const e=s.obj("quality.godFiles",t);if(e){s.keys("quality.godFiles",e,["soft","hard"]);for(const i of["soft","hard"]){const n=e[i],a=m[i];!Number.isInteger(n)||n<1?s.fail(`quality.godFiles.${i}`,"must be a positive integer"):n>a&&s.fail(`quality.godFiles.${i}`,`${String(n)} is above the family limit ${a}: god-file limits may only be lowered`)}typeof e.soft=="number"&&typeof e.hard=="number"&&e.soft>e.hard&&s.fail("quality.godFiles.soft","must not exceed quality.godFiles.hard")}}o(S,"checkGodFiles");function O(s,t){const e=s.obj("quality.coverage",t);if(e){s.keys("quality.coverage",e,b);for(const i of b){const n=e[i];(typeof n!="number"||!(n>=0&&n<=100))&&s.fail(`quality.coverage.${i}`,"must be a number from 0 to 100")}}}o(O,"checkCoverage");function A(s,t){const e=s.obj("extensions",t);if(e)for(const[i,n]of Object.entries(e))l.test(i)||s.fail(`extensions.${i}`,"namespace must be lower-case letters, digits and hyphens"),u(n)||s.fail(`extensions.${i}`,"must be an object (extensions are namespaced: one object per owner)")}o(A,"checkExtensions");function N(s){const t=new g,e=t.obj("manifest",s);return e&&(t.keys("manifest",e,["$schema","name","scope","features","layers","quality","extensions"]),e.$schema!==void 0&&t.str("$schema",e.$schema),t.str("name",e.name),t.str("scope",e.scope,y,'an npm scope such as "@mail-meow"'),e.features!==void 0&&h(t,e.features),e.layers!==void 0&&w(t,e.layers),e.quality!==void 0&&j(t,e.quality),e.extensions!==void 0&&A(t,e.extensions)),t.errors.length>0?{ok:!1,errors:t.errors}:{ok:!0,manifest:s}}o(N,"validateManifest");export{m as FAMILY_GOD_FILE_LIMITS,N as validateManifest};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/manifest-validate.ts"],
|
|
4
|
-
"sourcesContent": ["import type { FamilyManifest, ManifestValidation } from './manifest.ts';\n\n/**\nFamily default god-file limits: a manifest may only lower them.\n*/\nexport const FAMILY_GOD_FILE_LIMITS = { soft: 300, hard: 400 } as const;\n\ntype Obj = Record<string, unknown>;\n\nconst isObj = (value: unknown): value is Obj => typeof value === 'object' && value !== null && !Array.isArray(value);\nconst SCOPE_RE = /^@[a-z0-9][a-z0-9-]*$/;\nconst NAME_RE = /^[a-z][a-z0-9-]*$/;\nconst COVERAGE_KEYS = ['lines', 'branches', 'functions', 'statements'] as const;\n\n/**\nCollects errors under a dotted path so every message names its field.\n*/\nclass Check {\n readonly errors: string[] = [];\n fail(at: string, message: string): void {\n this.errors.push(`${at}: ${message}`);\n }\n /**\n Refuse unknown keys: the closed side.\n */\n keys(at: string, value: Obj, allowed: readonly string[]): void {\n for (const key of Object.keys(value)) {\n if (!allowed.includes(key)) this.fail(`${at}.${key}`, `unknown key (allowed: ${allowed.join(', ')})`);\n }\n }\n obj(at: string, value: unknown): Obj | null {\n if (isObj(value)) return value;\n this.fail(at, 'must be an object');\n return null;\n }\n str(at: string, value: unknown, pattern?: RegExp, hint?: string): value is string {\n if (typeof value !== 'string' || value === '') {\n this.fail(at, 'must be a non-empty string');\n return false;\n }\n if (pattern && !pattern.test(value)) {\n this.fail(at, `${JSON.stringify(value)} is invalid${hint ? ` (${hint})` : ''}`);\n return false;\n }\n return true;\n }\n bool(at: string, value: unknown): void {\n if (typeof value !== 'boolean') this.fail(at, 'must be a boolean');\n }\n strings(at: string, value: unknown): value is string[] {\n if (!Array.isArray(value) || value.some((item) => typeof item !== 'string' || item === '')) {\n this.fail(at, 'must be an array of non-empty strings');\n return false;\n }\n return true;\n }\n}\n\nfunction checkFeatures(c: Check, value: unknown): void {\n const features = c.obj('features', value);\n if (!features) return;\n c.keys('features', features, ['d1', 'web', 'background', 'backupD1', 'durableObjects', 'queues', 'workflows', 'email', 'android']);\n if (features.d1 !== undefined) {\n const d1 = c.obj('features.d1', features.d1);\n if (d1) {\n c.keys('features.d1', d1, ['binding', 'database', 'migrationsDir']);\n c.str('features.d1.binding', d1.binding, /^[A-Z][A-Z0-9_]*$/, 'an UPPER_SNAKE binding name');\n c.str('features.d1.database', d1.database);\n if (d1.migrationsDir !== undefined) c.str('features.d1.migrationsDir', d1.migrationsDir);\n }\n }\n if (features.web !== undefined) {\n const web = c.obj('features.web', features.web);\n if (web) {\n c.keys('features.web', web, ['pages', 'spaShell']);\n c.bool('features.web.pages', web.pages);\n c.bool('features.web.spaShell', web.spaShell);\n }\n }\n for (const flag of ['background', 'backupD1', 'email', 'android'] as const) {\n if (features[flag] !== undefined) c.bool(`features.${flag}`, features[flag]);\n }\n for (const list of ['durableObjects', 'queues', 'workflows'] as const) {\n if (features[list] !== undefined) c.strings(`features.${list}`, features[list]);\n }\n}\n\nfunction checkLayer(c: Check, at: string, layer: Obj): void {\n c.keys(at, layer, ['name', 'dir', 'package', 'mayImport', 'typeOnly', 'forbid', 'forbidMessage', 'http', 'browser']);\n c.str(`${at}.name`, layer.name, NAME_RE, 'lower-case letters, digits and hyphens');\n if (c.str(`${at}.dir`, layer.dir) && (/[*?{}]/.test(layer.dir) || layer.dir.startsWith('/') || layer.dir.split('/').includes('..'))) {\n c.fail(`${at}.dir`, `${JSON.stringify(layer.dir)} must be a repo-relative directory without globs`);\n }\n if (layer.package !== undefined) c.str(`${at}.package`, layer.package);\n if (layer.forbidMessage !== undefined) c.str(`${at}.forbidMessage`, layer.forbidMessage);\n for (const list of ['mayImport', 'typeOnly', 'forbid'] as const) {\n if (layer[list] !== undefined || list === 'mayImport') c.strings(`${at}.${list}`, layer[list]);\n }\n for (const flag of ['http', 'browser'] as const) if (layer[flag] !== undefined) c.bool(`${at}.${flag}`, layer[flag]);\n}\n\nfunction checkLayers(c: Check, value: unknown): void {\n if (!Array.isArray(value)) {\n c.fail('layers', 'must be an array of layers');\n return;\n }\n const names = new Set<string>();\n const dirs = new Set<string>();\n value.forEach((entry: unknown, index) => {\n const at = `layers[${index}]`;\n const layer = c.obj(at, entry);\n if (!layer) return;\n checkLayer(c, at, layer);\n if (typeof layer.name === 'string') {\n if (names.has(layer.name)) c.fail(`${at}.name`, `duplicate layer name ${JSON.stringify(layer.name)}`);\n names.add(layer.name);\n }\n if (typeof layer.dir !== 'string') {\n return;\n }\n\n if (dirs.has(layer.dir)) c.fail(`${at}.dir`, `duplicate layer dir ${JSON.stringify(layer.dir)}`);\n dirs.add(layer.dir);\n });\n value.forEach((entry: unknown, index) => {\n if (!isObj(entry)) return;\n for (const list of ['mayImport', 'typeOnly'] as const) {\n const refs = entry[list];\n if (!Array.isArray(refs)) continue;\n for (const ref of refs) {\n if (typeof ref === 'string' && !names.has(ref)) c.fail(`layers[${index}].${list}`, `unknown layer ${JSON.stringify(ref)}`);\n if (list === 'typeOnly' && Array.isArray(entry.mayImport) && entry.mayImport.includes(ref)) {\n c.fail(`layers[${index}].typeOnly`, `${JSON.stringify(ref)} is already in mayImport`);\n }\n }\n }\n });\n}\n\nfunction checkQuality(c: Check, value: unknown): void {\n const quality = c.obj('quality', value);\n if (!quality) return;\n c.keys('quality', quality, ['coverage', 'godFiles']);\n if (quality.coverage !== undefined) checkCoverage(c, quality.coverage);\n if (quality.godFiles !== undefined) checkGodFiles(c, quality.godFiles);\n}\n\nfunction checkGodFiles(c: Check, value: unknown): void {\n const god = c.obj('quality.godFiles', value);\n if (!god) return;\n c.keys('quality.godFiles', god, ['soft', 'hard']);\n for (const key of ['soft', 'hard'] as const) {\n const limit = god[key];\n const ceiling = FAMILY_GOD_FILE_LIMITS[key];\n if (!Number.isInteger(limit) || (limit as number) < 1) c.fail(`quality.godFiles.${key}`, 'must be a positive integer');\n else if ((limit as number) > ceiling) {\n c.fail(`quality.godFiles.${key}`, `${String(limit)} is above the family limit ${ceiling}: god-file limits may only be lowered`);\n }\n }\n if (typeof god.soft === 'number' && typeof god.hard === 'number' && god.soft > god.hard) {\n c.fail('quality.godFiles.soft', 'must not exceed quality.godFiles.hard');\n }\n}\n\nfunction checkCoverage(c: Check, value: unknown): void {\n const coverage = c.obj('quality.coverage', value);\n if (!coverage) return;\n c.keys('quality.coverage', coverage, COVERAGE_KEYS);\n for (const key of COVERAGE_KEYS) {\n const figure = coverage[key];\n if (typeof figure !== 'number' || !(figure >= 0 && figure <= 100)) c.fail(`quality.coverage.${key}`, 'must be a number from 0 to 100');\n }\n}\n\nfunction checkExtensions(c: Check, value: unknown): void {\n const extensions = c.obj('extensions', value);\n if (!extensions) return;\n for (const [key, entry] of Object.entries(extensions)) {\n if (!NAME_RE.test(key)) c.fail(`extensions.${key}`, 'namespace must be lower-case letters, digits and hyphens');\n if (!isObj(entry)) c.fail(`extensions.${key}`, 'must be an object (extensions are namespaced: one object per owner)');\n }\n}\n\n/**\n * Validate an already-parsed value. Returns every problem found, not just the\n * first, so one edit can fix them all.\n */\nexport function validateManifest(input: unknown): ManifestValidation {\n const c = new Check();\n const root = c.obj('manifest', input);\n if (root) {\n c.keys('manifest', root, ['$schema', 'name', 'scope', 'features', 'layers', 'quality', 'extensions']);\n if (root.$schema !== undefined) c.str('$schema', root.$schema);\n c.str('name', root.name);\n c.str('scope', root.scope, SCOPE_RE, 'an npm scope such as \"@mail-meow\"');\n if (root.features !== undefined) checkFeatures(c, root.features);\n if (root.layers !== undefined) checkLayers(c, root.layers);\n if (root.quality !== undefined) checkQuality(c, root.quality);\n if (root.extensions !== undefined) checkExtensions(c, root.extensions);\n }\n return c.errors.length > 0 ? { ok: false, errors: c.errors } : { ok: true, manifest: input as FamilyManifest };\n}\n"],
|
|
5
|
-
"mappings": "+EAKO,MAAMA,EAAyB,CAAE,KAAM,IAAK,KAAM,GAAG,EAItDC,EAAQC,EAACC,GAAiC,OAAOA,GAAU,UAAYA,IAAU,MAAQ,CAAC,MAAM,QAAQA,CAAK,EAArG,SACRC,EAAW,wBACXC,EAAU,oBACVC,EAAgB,CAAC,QAAS,WAAY,YAAa,YAAY,EAKrE,MAAMC,CAAK,CAfX,MAeW,CAAAL,EAAA,cACA,OAAmB,CAAA,EAC5B,KAAKM,EAAYC,EAAe,CAC9B,KAAK,OAAO,KAAK,GAAGD,CAAE,KAAKC,CAAO,EAAE,CACtC,CAIA,KAAKD,EAAYL,EAAYO,EAA0B,CACrD,UAAWC,KAAO,OAAO,KAAKR,CAAK,EAC5BO,EAAQ,SAASC,CAAG,GAAG,KAAK,KAAK,GAAGH,CAAE,IAAIG,CAAG,GAAI,yBAAyBD,EAAQ,KAAK,IAAI,CAAC,GAAG,CAExG,CACA,IAAIF,EAAYL,EAAc,CAC5B,OAAIF,EAAME,CAAK,EAAUA,GACzB,KAAK,KAAKK,EAAI,mBAAmB,EAC1B,KACT,CACA,IAAIA,EAAYL,EAAgBS,EAAkBC,EAAa,CAC7D,OAAI,OAAOV,GAAU,UAAYA,IAAU,IACzC,KAAK,KAAKK,EAAI,4BAA4B,EACnC,IAELI,GAAW,CAACA,EAAQ,KAAKT,CAAK,GAChC,KAAK,KAAKK,EAAI,GAAG,KAAK,UAAUL,CAAK,CAAC,cAAcU,EAAO,KAAKA,CAAI,IAAM,EAAE,EAAE,EACvE,IAEF,EACT,CACA,KAAKL,EAAYL,EAAc,CACzB,OAAOA,GAAU,WAAW,KAAK,KAAKK,EAAI,mBAAmB,CACnE,CACA,QAAQA,EAAYL,EAAc,CAChC,MAAI,CAAC,MAAM,QAAQA,CAAK,GAAKA,EAAM,KAAMW,GAAS,OAAOA,GAAS,UAAYA,IAAS,EAAE,GACvF,KAAK,KAAKN,EAAI,uCAAuC,EAC9C,IAEF,EACT,EAGF,SAASO,
|
|
6
|
-
"names": ["FAMILY_GOD_FILE_LIMITS", "isObj", "__name", "value", "SCOPE_RE", "NAME_RE", "COVERAGE_KEYS", "Check", "at", "message", "allowed", "key", "pattern", "hint", "item", "
|
|
4
|
+
"sourcesContent": ["import type { FamilyManifest, ManifestValidation } from './manifest.ts';\n\n/**\nFamily default god-file limits: a manifest may only lower them.\n*/\nexport const FAMILY_GOD_FILE_LIMITS = { soft: 300, hard: 400 } as const;\n\ntype Obj = Record<string, unknown>;\n\nconst isObj = (value: unknown): value is Obj => typeof value === 'object' && value !== null && !Array.isArray(value);\nconst SCOPE_RE = /^@[a-z0-9][a-z0-9-]*$/;\nconst NAME_RE = /^[a-z][a-z0-9-]*$/;\nconst COVERAGE_KEYS = ['lines', 'branches', 'functions', 'statements'] as const;\n\n/**\nCollects errors under a dotted path so every message names its field.\n*/\nclass Check {\n readonly errors: string[] = [];\n fail(at: string, message: string): void {\n this.errors.push(`${at}: ${message}`);\n }\n /**\n Refuse unknown keys: the closed side.\n */\n keys(at: string, value: Obj, allowed: readonly string[]): void {\n for (const key of Object.keys(value)) {\n if (!allowed.includes(key)) this.fail(`${at}.${key}`, `unknown key (allowed: ${allowed.join(', ')})`);\n }\n }\n obj(at: string, value: unknown): Obj | null {\n if (isObj(value)) return value;\n this.fail(at, 'must be an object');\n return null;\n }\n str(at: string, value: unknown, pattern?: RegExp, hint?: string): value is string {\n if (typeof value !== 'string' || value === '') {\n this.fail(at, 'must be a non-empty string');\n return false;\n }\n if (pattern && !pattern.test(value)) {\n this.fail(at, `${JSON.stringify(value)} is invalid${hint ? ` (${hint})` : ''}`);\n return false;\n }\n return true;\n }\n bool(at: string, value: unknown): void {\n if (typeof value !== 'boolean') this.fail(at, 'must be a boolean');\n }\n strings(at: string, value: unknown): value is string[] {\n if (!Array.isArray(value) || value.some((item) => typeof item !== 'string' || item === '')) {\n this.fail(at, 'must be an array of non-empty strings');\n return false;\n }\n return true;\n }\n}\n\nconst BINDING_RE = /^[A-Z][A-Z0-9_]*$/;\n\nfunction checkKv(c: Check, value: unknown): void {\n const kv = c.obj('features.kv', value);\n if (!kv) return;\n c.keys('features.kv', kv, ['bindings', 'namespaceNames']);\n const bindings = c.strings('features.kv.bindings', kv.bindings) ? kv.bindings : [];\n for (const binding of bindings) c.str('features.kv.bindings', binding, BINDING_RE, 'an UPPER_SNAKE binding name');\n if (kv.namespaceNames === undefined) return;\n const names = c.obj('features.kv.namespaceNames', kv.namespaceNames);\n if (!names) return;\n for (const [binding, name] of Object.entries(names)) {\n const at = `features.kv.namespaceNames.${binding}`;\n if (!bindings.includes(binding)) c.fail(at, 'is not listed in features.kv.bindings');\n c.str(at, name);\n }\n}\n\nfunction checkFeatures(c: Check, value: unknown): void {\n const features = c.obj('features', value);\n if (!features) return;\n c.keys('features', features, ['d1', 'kv', 'web', 'background', 'backupD1', 'durableObjects', 'queues', 'workflows', 'email', 'android']);\n if (features.d1 !== undefined) {\n const d1 = c.obj('features.d1', features.d1);\n if (d1) {\n c.keys('features.d1', d1, ['binding', 'database', 'migrationsDir']);\n c.str('features.d1.binding', d1.binding, /^[A-Z][A-Z0-9_]*$/, 'an UPPER_SNAKE binding name');\n c.str('features.d1.database', d1.database);\n if (d1.migrationsDir !== undefined) c.str('features.d1.migrationsDir', d1.migrationsDir);\n }\n }\n if (features.kv !== undefined) checkKv(c, features.kv);\n if (features.web !== undefined) {\n const web = c.obj('features.web', features.web);\n if (web) {\n c.keys('features.web', web, ['pages', 'spaShell', 'buildScript', 'pagesProject']);\n c.bool('features.web.pages', web.pages);\n c.bool('features.web.spaShell', web.spaShell);\n if (web.buildScript !== undefined)\n c.str('features.web.buildScript', web.buildScript, /^[\\w:.-]+$/, 'a root package.json script name');\n if (web.pagesProject !== undefined) {\n c.str(\n 'features.web.pagesProject',\n web.pagesProject,\n /^[a-z0-9][a-z0-9-]{0,57}$/,\n 'lower-case letters, digits and hyphens, at most 58',\n );\n }\n }\n }\n for (const flag of ['background', 'backupD1', 'email', 'android'] as const) {\n if (features[flag] !== undefined) c.bool(`features.${flag}`, features[flag]);\n }\n for (const list of ['durableObjects', 'queues', 'workflows'] as const) {\n if (features[list] !== undefined) c.strings(`features.${list}`, features[list]);\n }\n}\n\nfunction checkLayer(c: Check, at: string, layer: Obj): void {\n c.keys(at, layer, ['name', 'dir', 'package', 'mayImport', 'typeOnly', 'forbid', 'forbidMessage', 'http', 'browser']);\n c.str(`${at}.name`, layer.name, NAME_RE, 'lower-case letters, digits and hyphens');\n if (c.str(`${at}.dir`, layer.dir) && (/[*?{}]/.test(layer.dir) || layer.dir.startsWith('/') || layer.dir.split('/').includes('..'))) {\n c.fail(`${at}.dir`, `${JSON.stringify(layer.dir)} must be a repo-relative directory without globs`);\n }\n if (layer.package !== undefined) c.str(`${at}.package`, layer.package);\n if (layer.forbidMessage !== undefined) c.str(`${at}.forbidMessage`, layer.forbidMessage);\n for (const list of ['mayImport', 'typeOnly', 'forbid'] as const) {\n if (layer[list] !== undefined || list === 'mayImport') c.strings(`${at}.${list}`, layer[list]);\n }\n for (const flag of ['http', 'browser'] as const) if (layer[flag] !== undefined) c.bool(`${at}.${flag}`, layer[flag]);\n}\n\nfunction checkLayers(c: Check, value: unknown): void {\n if (!Array.isArray(value)) {\n c.fail('layers', 'must be an array of layers');\n return;\n }\n const names = new Set<string>();\n const dirs = new Set<string>();\n value.forEach((entry: unknown, index) => {\n const at = `layers[${index}]`;\n const layer = c.obj(at, entry);\n if (!layer) return;\n checkLayer(c, at, layer);\n if (typeof layer.name === 'string') {\n if (names.has(layer.name)) c.fail(`${at}.name`, `duplicate layer name ${JSON.stringify(layer.name)}`);\n names.add(layer.name);\n }\n if (typeof layer.dir !== 'string') {\n return;\n }\n\n if (dirs.has(layer.dir)) c.fail(`${at}.dir`, `duplicate layer dir ${JSON.stringify(layer.dir)}`);\n dirs.add(layer.dir);\n });\n value.forEach((entry: unknown, index) => {\n if (!isObj(entry)) return;\n for (const list of ['mayImport', 'typeOnly'] as const) {\n const refs = entry[list];\n if (!Array.isArray(refs)) continue;\n for (const ref of refs) {\n if (typeof ref === 'string' && !names.has(ref)) c.fail(`layers[${index}].${list}`, `unknown layer ${JSON.stringify(ref)}`);\n if (list === 'typeOnly' && Array.isArray(entry.mayImport) && entry.mayImport.includes(ref)) {\n c.fail(`layers[${index}].typeOnly`, `${JSON.stringify(ref)} is already in mayImport`);\n }\n }\n }\n });\n}\n\nfunction checkQuality(c: Check, value: unknown): void {\n const quality = c.obj('quality', value);\n if (!quality) return;\n c.keys('quality', quality, ['coverage', 'godFiles']);\n if (quality.coverage !== undefined) checkCoverage(c, quality.coverage);\n if (quality.godFiles !== undefined) checkGodFiles(c, quality.godFiles);\n}\n\nfunction checkGodFiles(c: Check, value: unknown): void {\n const god = c.obj('quality.godFiles', value);\n if (!god) return;\n c.keys('quality.godFiles', god, ['soft', 'hard']);\n for (const key of ['soft', 'hard'] as const) {\n const limit = god[key];\n const ceiling = FAMILY_GOD_FILE_LIMITS[key];\n if (!Number.isInteger(limit) || (limit as number) < 1) c.fail(`quality.godFiles.${key}`, 'must be a positive integer');\n else if ((limit as number) > ceiling) {\n c.fail(`quality.godFiles.${key}`, `${String(limit)} is above the family limit ${ceiling}: god-file limits may only be lowered`);\n }\n }\n if (typeof god.soft === 'number' && typeof god.hard === 'number' && god.soft > god.hard) {\n c.fail('quality.godFiles.soft', 'must not exceed quality.godFiles.hard');\n }\n}\n\nfunction checkCoverage(c: Check, value: unknown): void {\n const coverage = c.obj('quality.coverage', value);\n if (!coverage) return;\n c.keys('quality.coverage', coverage, COVERAGE_KEYS);\n for (const key of COVERAGE_KEYS) {\n const figure = coverage[key];\n if (typeof figure !== 'number' || !(figure >= 0 && figure <= 100)) c.fail(`quality.coverage.${key}`, 'must be a number from 0 to 100');\n }\n}\n\nfunction checkExtensions(c: Check, value: unknown): void {\n const extensions = c.obj('extensions', value);\n if (!extensions) return;\n for (const [key, entry] of Object.entries(extensions)) {\n if (!NAME_RE.test(key)) c.fail(`extensions.${key}`, 'namespace must be lower-case letters, digits and hyphens');\n if (!isObj(entry)) c.fail(`extensions.${key}`, 'must be an object (extensions are namespaced: one object per owner)');\n }\n}\n\n/**\n * Validate an already-parsed value. Returns every problem found, not just the\n * first, so one edit can fix them all.\n */\nexport function validateManifest(input: unknown): ManifestValidation {\n const c = new Check();\n const root = c.obj('manifest', input);\n if (root) {\n c.keys('manifest', root, ['$schema', 'name', 'scope', 'features', 'layers', 'quality', 'extensions']);\n if (root.$schema !== undefined) c.str('$schema', root.$schema);\n c.str('name', root.name);\n c.str('scope', root.scope, SCOPE_RE, 'an npm scope such as \"@mail-meow\"');\n if (root.features !== undefined) checkFeatures(c, root.features);\n if (root.layers !== undefined) checkLayers(c, root.layers);\n if (root.quality !== undefined) checkQuality(c, root.quality);\n if (root.extensions !== undefined) checkExtensions(c, root.extensions);\n }\n return c.errors.length > 0 ? { ok: false, errors: c.errors } : { ok: true, manifest: input as FamilyManifest };\n}\n"],
|
|
5
|
+
"mappings": "+EAKO,MAAMA,EAAyB,CAAE,KAAM,IAAK,KAAM,GAAG,EAItDC,EAAQC,EAACC,GAAiC,OAAOA,GAAU,UAAYA,IAAU,MAAQ,CAAC,MAAM,QAAQA,CAAK,EAArG,SACRC,EAAW,wBACXC,EAAU,oBACVC,EAAgB,CAAC,QAAS,WAAY,YA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O,OAAQA,EAAE,MAAM,EAAK,CAAE,GAAI,GAAM,SAAUgC,CAAuB,CAC9G,CAdgB/C,EAAA8C,EAAA",
|
|
6
|
+
"names": ["FAMILY_GOD_FILE_LIMITS", "isObj", "__name", "value", "SCOPE_RE", "NAME_RE", "COVERAGE_KEYS", "Check", "at", "message", "allowed", "key", "pattern", "hint", "item", "BINDING_RE", "checkKv", "c", "kv", "bindings", "binding", "names", "name", "checkFeatures", "features", "d1", "web", "flag", "list", "checkLayer", "layer", "checkLayers", "dirs", "entry", "index", "refs", "ref", "checkQuality", "quality", "checkCoverage", "checkGodFiles", "god", "limit", "ceiling", "coverage", "figure", "checkExtensions", "extensions", "validateManifest", "input", "root"]
|
|
7
7
|
}
|
package/dist/manifest.d.ts
CHANGED
|
@@ -26,6 +26,17 @@ export interface ManifestD1 {
|
|
|
26
26
|
readonly database: string;
|
|
27
27
|
readonly migrationsDir?: string;
|
|
28
28
|
}
|
|
29
|
+
export interface ManifestKv {
|
|
30
|
+
/**
|
|
31
|
+
KV binding names the deployment needs (UPPER_SNAKE). `prepare-wrangler` adds any a hand-written config lacks and provisions
|
|
32
|
+
their namespaces; a repo that declares none gets no KV binding and no namespace.
|
|
33
|
+
*/
|
|
34
|
+
readonly bindings: readonly string[];
|
|
35
|
+
/**
|
|
36
|
+
Binding to namespace name, for a namespace that predates the kit's `<worker>-<binding>` convention. Keys must be listed in `bindings`.
|
|
37
|
+
*/
|
|
38
|
+
readonly namespaceNames?: Readonly<Record<string, string>>;
|
|
39
|
+
}
|
|
29
40
|
export interface ManifestWeb {
|
|
30
41
|
/**
|
|
31
42
|
The SPA is served by Cloudflare Pages.
|
|
@@ -35,9 +46,19 @@ export interface ManifestWeb {
|
|
|
35
46
|
The SPA shell is embedded into the worker (`spa-shell` scripts).
|
|
36
47
|
*/
|
|
37
48
|
readonly spaShell: boolean;
|
|
49
|
+
/**
|
|
50
|
+
A **root** `package.json` script that builds the SPA, for a repo whose build has wrappers (`verify:tailwind && build`).
|
|
51
|
+
CI and CD run `pnpm run <script>` instead of `pnpm --filter <scope>/web run build`.
|
|
52
|
+
*/
|
|
53
|
+
readonly buildScript?: string;
|
|
54
|
+
/**
|
|
55
|
+
The Cloudflare Pages project, when it is not `<name>-web`. Wins over the `CLOUDFLARE_PAGES_PROJECT_NAME` variable.
|
|
56
|
+
*/
|
|
57
|
+
readonly pagesProject?: string;
|
|
38
58
|
}
|
|
39
59
|
export interface ManifestFeatures {
|
|
40
60
|
readonly d1?: ManifestD1;
|
|
61
|
+
readonly kv?: ManifestKv;
|
|
41
62
|
readonly web?: ManifestWeb;
|
|
42
63
|
readonly background?: boolean;
|
|
43
64
|
readonly backupD1?: boolean;
|
package/dist/manifest.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"manifest.d.ts","sourceRoot":"","sources":["../src/manifest.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AASH,OAAO,EAAE,sBAAsB,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAElF;;EAEE;AACF,eAAO,MAAM,iBAAiB,oBAAoB,CAAC;AAEnD,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,aAAa,CAAC,EAAE,MAAM,CAAC;CACjC;AAED,MAAM,WAAW,WAAW;IAC1B;;MAEE;IACF,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;IACxB;;MAEE;IACF,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"manifest.d.ts","sourceRoot":"","sources":["../src/manifest.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AASH,OAAO,EAAE,sBAAsB,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAElF;;EAEE;AACF,eAAO,MAAM,iBAAiB,oBAAoB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AM,CAAC;IACvB,QAAQ,CAAC,QAAQ,CAAC,EAAE,gBAAgB,CAAC;IACrC,QAAQ,CAAC,MAAM,CAAC,EAAE,SAAS,aAAa,EAAE,CAAC;IAC3C,QAAQ,CAAC,OAAO,CAAC,EAAE,eAAe,CAAC;IACnC;;MAEE;IACF,QAAQ,CAAC,UAAU,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC;CACnF;AAED,MAAM,MAAM,kBAAkB,GAC5B;IAAE,QAAQ,CAAC,EAAE,EAAE,IAAI,CAAC;IAAC,QAAQ,CAAC,QAAQ,EAAE,cAAc,CAAA;CAAE,GAAG;IAAE,QAAQ,CAAC,EAAE,EAAE,KAAK,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,EAAE,CAAA;CAAE,CAAC;AAE/G;;EAEE;AACF,qBAAa,aAAc,SAAQ,KAAK;IACtC,QAAQ,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC;gBACvB,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,MAAM,EAAE;CAKtD;AAED;;EAEE;AACF,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,GAAE,MAA0B,GAAG,cAAc,CAY9F;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,cAAc,GAAG,IAAI,CAIhE;AAED;;;;GAIG;AACH,wBAAgB,0BAA0B,CAAC,IAAI,EAAE,MAAM,GAAG,gBAAgB,GAAG,SAAS,CAGrF"}
|
package/dist/manifest.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/manifest.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * The family manifest: `.rexezuge.jsonc` at a repo root.\n *\n * One declarative file states what a repo *is* (its scope, the platform features\n * it uses, its dependency layers) and how strict it holds itself (coverage\n * floors, god-file limits). The tooling factories read it instead of each\n * encoding consumer directory names, so the kit stays free of repo layouts and a\n * repo's layout stays out of its lint config.\n *\n * The charter applies to the file itself. The **closed** side is the schema:\n * unknown keys are refused (a typo is an error, not a silent no-op), and\n * `quality.godFiles` may only be lowered below the family default, never raised.\n * The **open** side is `extensions`: a free-form object, namespaced by the key\n * that owns it, that the kit never reads.\n *\n * `manifest.schema.json` (shipped beside this module) describes the same shape\n * for editor completion via `$schema`; a test keeps the two in step.\n */\n\nimport { existsSync, readFileSync } from 'node:fs';\nimport path from 'node:path';\nimport { fileURLToPath } from 'node:url';\nimport { parse as parseJsonc, printParseErrorCode } from 'jsonc-parser';\nimport type { ParseError } from 'jsonc-parser';\nimport { validateManifest } from './manifest-validate.ts';\n\nexport { FAMILY_GOD_FILE_LIMITS, validateManifest } from './manifest-validate.ts';\n\n/**\nThe file name, resolved against a repo root.\n*/\nexport const MANIFEST_FILENAME = '.rexezuge.jsonc';\n\nexport interface ManifestD1 {\n readonly binding: string;\n readonly database: string;\n readonly migrationsDir?: string;\n}\n\nexport interface ManifestWeb {\n /**\n The SPA is served by Cloudflare Pages.\n */\n readonly pages: boolean;\n /**\n The SPA shell is embedded into the worker (`spa-shell` scripts).\n */\n readonly spaShell: boolean;\n}\n\nexport interface ManifestFeatures {\n readonly d1?: ManifestD1;\n readonly web?: ManifestWeb;\n readonly background?: boolean;\n readonly backupD1?: boolean;\n /**\n Durable Object class names.\n */\n readonly durableObjects?: readonly string[];\n /**\n Queue names.\n */\n readonly queues?: readonly string[];\n /**\n Workflow class names.\n */\n readonly workflows?: readonly string[];\n readonly email?: boolean;\n readonly android?: boolean;\n}\n\n/**\n * One dependency layer: a directory, and the other layers it may import.\n *\n * Everything not named in `mayImport` / `typeOnly` is banned, by package name\n * (`<scope>/<basename of dir>`, or `package`). `mayImport: []` isolates the layer\n * from the whole scope (`<scope>/*`).\n */\nexport interface ManifestLayer {\n readonly name: string;\n /**\n Repo-relative directory, no globs: `packages/backend-data`.\n */\n readonly dir: string;\n /**\n Package suffix when it is not the directory's basename.\n */\n readonly package?: string;\n /**\n Names of layers this layer may import.\n */\n readonly mayImport: readonly string[];\n /**\n Names of layers importable as `import type` only.\n */\n readonly typeOnly?: readonly string[];\n /**\n Extra external specifiers this layer may not import, e.g. `aws4fetch`.\n */\n readonly forbid?: readonly string[];\n /**\n Message for `forbid`; defaults to a generic one.\n */\n readonly forbidMessage?: string;\n /**\n May import `hono`/`chanfana` (and hand-build error envelopes).\n */\n readonly http?: boolean;\n /**\n Browser code: may use `console`, and lints with browser globals.\n */\n readonly browser?: boolean;\n}\n\nexport interface ManifestCoverage {\n readonly lines: number;\n readonly branches: number;\n readonly functions: number;\n readonly statements: number;\n}\n\nexport interface ManifestQuality {\n readonly coverage?: ManifestCoverage;\n readonly godFiles?: { readonly soft: number; readonly hard: number };\n}\n\nexport interface FamilyManifest {\n readonly $schema?: string;\n readonly name: string;\n /**\n npm scope with the `@`, e.g. `@mail-meow`.\n */\n readonly scope: string;\n readonly features?: ManifestFeatures;\n readonly layers?: readonly ManifestLayer[];\n readonly quality?: ManifestQuality;\n /**\n Repo-specific settings, namespaced by key. Never read by the kit.\n */\n readonly extensions?: Readonly<Record<string, Readonly<Record<string, unknown>>>>;\n}\n\nexport type ManifestValidation =\n { readonly ok: true; readonly manifest: FamilyManifest } | { readonly ok: false; readonly errors: string[] };\n\n/**\nThrown by {@link loadManifest} and {@link parseManifest}; `errors` has one line per problem.\n*/\nexport class ManifestError extends Error {\n readonly errors: readonly string[];\n constructor(source: string, errors: readonly string[]) {\n super(`${source} is not a valid family manifest:\\n${errors.map((line) => ` - ${line}`).join('\\n')}`);\n this.name = 'ManifestError';\n this.errors = errors;\n }\n}\n\n/**\nParse JSONC text and validate it. Throws {@link ManifestError}.\n*/\nexport function parseManifest(text: string, source: string = MANIFEST_FILENAME): FamilyManifest {\n const syntax: ParseError[] = [];\n const value: unknown = parseJsonc(text, syntax, { allowTrailingComma: true });\n if (syntax.length > 0) {\n throw new ManifestError(\n source,\n syntax.map((error) => `syntax error at offset ${error.offset}: ${printParseErrorCode(error.error)}`),\n );\n }\n const result = validateManifest(value);\n if (!result.ok) throw new ManifestError(source, result.errors);\n return result.manifest;\n}\n\n/**\n * Load `<root>/.rexezuge.jsonc`. Returns `null` when the file is absent (the\n * repo has not adopted a manifest) and throws {@link ManifestError} when it is\n * present but invalid: a broken manifest must fail the gate, not fall back.\n */\nexport function loadManifest(root: string): FamilyManifest | null {\n const file = path.join(root, MANIFEST_FILENAME);\n if (!existsSync(file)) return null;\n return parseManifest(readFileSync(file, 'utf8'), file);\n}\n\n/**\n * The manifest's coverage floor for a vitest config, or `undefined` when the\n * repo has no manifest or declares none. `root` is what the factories take: a\n * directory path or a `file:` URL (`new URL('.', import.meta.url).href`).\n */\nexport function manifestCoverageThresholds(root: string): ManifestCoverage | undefined {\n const dir = root.startsWith('file:') ? fileURLToPath(root) : root;\n return loadManifest(dir)?.quality?.coverage;\n}\n"],
|
|
5
|
-
"mappings": "+EAmBA,OAAS,cAAAA,EAAY,gBAAAC,MAAoB,UACzC,OAAOC,MAAU,YACjB,OAAS,iBAAAC,MAAqB,WAC9B,OAAS,SAASC,EAAY,uBAAAC,MAA2B,eAEzD,OAAS,oBAAAC,MAAwB,yBAEjC,OAAS,0BAAAC,EAAwB,oBAAAD,MAAwB,yBAKlD,MAAME,EAAoB,
|
|
4
|
+
"sourcesContent": ["/**\n * The family manifest: `.rexezuge.jsonc` at a repo root.\n *\n * One declarative file states what a repo *is* (its scope, the platform features\n * it uses, its dependency layers) and how strict it holds itself (coverage\n * floors, god-file limits). The tooling factories read it instead of each\n * encoding consumer directory names, so the kit stays free of repo layouts and a\n * repo's layout stays out of its lint config.\n *\n * The charter applies to the file itself. The **closed** side is the schema:\n * unknown keys are refused (a typo is an error, not a silent no-op), and\n * `quality.godFiles` may only be lowered below the family default, never raised.\n * The **open** side is `extensions`: a free-form object, namespaced by the key\n * that owns it, that the kit never reads.\n *\n * `manifest.schema.json` (shipped beside this module) describes the same shape\n * for editor completion via `$schema`; a test keeps the two in step.\n */\n\nimport { existsSync, readFileSync } from 'node:fs';\nimport path from 'node:path';\nimport { fileURLToPath } from 'node:url';\nimport { parse as parseJsonc, printParseErrorCode } from 'jsonc-parser';\nimport type { ParseError } from 'jsonc-parser';\nimport { validateManifest } from './manifest-validate.ts';\n\nexport { FAMILY_GOD_FILE_LIMITS, validateManifest } from './manifest-validate.ts';\n\n/**\nThe file name, resolved against a repo root.\n*/\nexport const MANIFEST_FILENAME = '.rexezuge.jsonc';\n\nexport interface ManifestD1 {\n readonly binding: string;\n readonly database: string;\n readonly migrationsDir?: string;\n}\n\nexport interface ManifestKv {\n /**\n KV binding names the deployment needs (UPPER_SNAKE). `prepare-wrangler` adds any a hand-written config lacks and provisions\n their namespaces; a repo that declares none gets no KV binding and no namespace.\n */\n readonly bindings: readonly string[];\n /**\n Binding to namespace name, for a namespace that predates the kit's `<worker>-<binding>` convention. Keys must be listed in `bindings`.\n */\n readonly namespaceNames?: Readonly<Record<string, string>>;\n}\n\nexport interface ManifestWeb {\n /**\n The SPA is served by Cloudflare Pages.\n */\n readonly pages: boolean;\n /**\n The SPA shell is embedded into the worker (`spa-shell` scripts).\n */\n readonly spaShell: boolean;\n /**\n A **root** `package.json` script that builds the SPA, for a repo whose build has wrappers (`verify:tailwind && build`).\n CI and CD run `pnpm run <script>` instead of `pnpm --filter <scope>/web run build`.\n */\n readonly buildScript?: string;\n /**\n The Cloudflare Pages project, when it is not `<name>-web`. Wins over the `CLOUDFLARE_PAGES_PROJECT_NAME` variable.\n */\n readonly pagesProject?: string;\n}\n\nexport interface ManifestFeatures {\n readonly d1?: ManifestD1;\n readonly kv?: ManifestKv;\n readonly web?: ManifestWeb;\n readonly background?: boolean;\n readonly backupD1?: boolean;\n /**\n Durable Object class names.\n */\n readonly durableObjects?: readonly string[];\n /**\n Queue names.\n */\n readonly queues?: readonly string[];\n /**\n Workflow class names.\n */\n readonly workflows?: readonly string[];\n readonly email?: boolean;\n readonly android?: boolean;\n}\n\n/**\n * One dependency layer: a directory, and the other layers it may import.\n *\n * Everything not named in `mayImport` / `typeOnly` is banned, by package name\n * (`<scope>/<basename of dir>`, or `package`). `mayImport: []` isolates the layer\n * from the whole scope (`<scope>/*`).\n */\nexport interface ManifestLayer {\n readonly name: string;\n /**\n Repo-relative directory, no globs: `packages/backend-data`.\n */\n readonly dir: string;\n /**\n Package suffix when it is not the directory's basename.\n */\n readonly package?: string;\n /**\n Names of layers this layer may import.\n */\n readonly mayImport: readonly string[];\n /**\n Names of layers importable as `import type` only.\n */\n readonly typeOnly?: readonly string[];\n /**\n Extra external specifiers this layer may not import, e.g. `aws4fetch`.\n */\n readonly forbid?: readonly string[];\n /**\n Message for `forbid`; defaults to a generic one.\n */\n readonly forbidMessage?: string;\n /**\n May import `hono`/`chanfana` (and hand-build error envelopes).\n */\n readonly http?: boolean;\n /**\n Browser code: may use `console`, and lints with browser globals.\n */\n readonly browser?: boolean;\n}\n\nexport interface ManifestCoverage {\n readonly lines: number;\n readonly branches: number;\n readonly functions: number;\n readonly statements: number;\n}\n\nexport interface ManifestQuality {\n readonly coverage?: ManifestCoverage;\n readonly godFiles?: { readonly soft: number; readonly hard: number };\n}\n\nexport interface FamilyManifest {\n readonly $schema?: string;\n readonly name: string;\n /**\n npm scope with the `@`, e.g. `@mail-meow`.\n */\n readonly scope: string;\n readonly features?: ManifestFeatures;\n readonly layers?: readonly ManifestLayer[];\n readonly quality?: ManifestQuality;\n /**\n Repo-specific settings, namespaced by key. Never read by the kit.\n */\n readonly extensions?: Readonly<Record<string, Readonly<Record<string, unknown>>>>;\n}\n\nexport type ManifestValidation =\n { readonly ok: true; readonly manifest: FamilyManifest } | { readonly ok: false; readonly errors: string[] };\n\n/**\nThrown by {@link loadManifest} and {@link parseManifest}; `errors` has one line per problem.\n*/\nexport class ManifestError extends Error {\n readonly errors: readonly string[];\n constructor(source: string, errors: readonly string[]) {\n super(`${source} is not a valid family manifest:\\n${errors.map((line) => ` - ${line}`).join('\\n')}`);\n this.name = 'ManifestError';\n this.errors = errors;\n }\n}\n\n/**\nParse JSONC text and validate it. Throws {@link ManifestError}.\n*/\nexport function parseManifest(text: string, source: string = MANIFEST_FILENAME): FamilyManifest {\n const syntax: ParseError[] = [];\n const value: unknown = parseJsonc(text, syntax, { allowTrailingComma: true });\n if (syntax.length > 0) {\n throw new ManifestError(\n source,\n syntax.map((error) => `syntax error at offset ${error.offset}: ${printParseErrorCode(error.error)}`),\n );\n }\n const result = validateManifest(value);\n if (!result.ok) throw new ManifestError(source, result.errors);\n return result.manifest;\n}\n\n/**\n * Load `<root>/.rexezuge.jsonc`. Returns `null` when the file is absent (the\n * repo has not adopted a manifest) and throws {@link ManifestError} when it is\n * present but invalid: a broken manifest must fail the gate, not fall back.\n */\nexport function loadManifest(root: string): FamilyManifest | null {\n const file = path.join(root, MANIFEST_FILENAME);\n if (!existsSync(file)) return null;\n return parseManifest(readFileSync(file, 'utf8'), file);\n}\n\n/**\n * The manifest's coverage floor for a vitest config, or `undefined` when the\n * repo has no manifest or declares none. `root` is what the factories take: a\n * directory path or a `file:` URL (`new URL('.', import.meta.url).href`).\n */\nexport function manifestCoverageThresholds(root: string): ManifestCoverage | undefined {\n const dir = root.startsWith('file:') ? fileURLToPath(root) : root;\n return loadManifest(dir)?.quality?.coverage;\n}\n"],
|
|
5
|
+
"mappings": "+EAmBA,OAAS,cAAAA,EAAY,gBAAAC,MAAoB,UACzC,OAAOC,MAAU,YACjB,OAAS,iBAAAC,MAAqB,WAC9B,OAAS,SAASC,EAAY,uBAAAC,MAA2B,eAEzD,OAAS,oBAAAC,MAAwB,yBAEjC,OAAS,0BAAAC,EAAwB,oBAAAD,MAAwB,yBAKlD,MAAME,EAAoB,kBA2I3B,MAAOC,UAAsB,KAAK,CA1KxC,MA0KwC,CAAAC,EAAA,sBAC7B,OACT,YAAYC,EAAgBC,EAAyB,CACnD,MAAM,GAAGD,CAAM;EAAqCC,EAAO,IAAKC,GAAS,OAAOA,CAAI,EAAE,EAAE,KAAK;CAAI,CAAC,EAAE,EACpG,KAAK,KAAO,gBACZ,KAAK,OAASD,CAChB,EAMI,SAAUE,EAAcC,EAAcJ,EAAiBH,EAAiB,CAC5E,MAAMQ,EAAuB,CAAA,EACvBC,EAAiBb,EAAWW,EAAMC,EAAQ,CAAE,mBAAoB,EAAI,CAAE,EAC5E,GAAIA,EAAO,OAAS,EAClB,MAAM,IAAIP,EACRE,EACAK,EAAO,IAAKE,GAAU,0BAA0BA,EAAM,MAAM,KAAKb,EAAoBa,EAAM,KAAK,CAAC,EAAE,CAAC,EAGxG,MAAMC,EAASb,EAAiBW,CAAK,EACrC,GAAI,CAACE,EAAO,GAAI,MAAM,IAAIV,EAAcE,EAAQQ,EAAO,MAAM,EAC7D,OAAOA,EAAO,QAChB,CAZgBT,EAAAI,EAAA,iBAmBV,SAAUM,EAAaC,EAAY,CACvC,MAAMC,EAAOpB,EAAK,KAAKmB,EAAMb,CAAiB,EAC9C,OAAKR,EAAWsB,CAAI,EACbR,EAAcb,EAAaqB,EAAM,MAAM,EAAGA,CAAI,EADvB,IAEhC,CAJgBZ,EAAAU,EAAA,gBAWV,SAAUG,EAA2BF,EAAY,CACrD,MAAMG,EAAMH,EAAK,WAAW,OAAO,EAAIlB,EAAckB,CAAI,EAAIA,EAC7D,OAAOD,EAAaI,CAAG,GAAG,SAAS,QACrC,CAHgBd,EAAAa,EAAA",
|
|
6
6
|
"names": ["existsSync", "readFileSync", "path", "fileURLToPath", "parseJsonc", "printParseErrorCode", "validateManifest", "FAMILY_GOD_FILE_LIMITS", "MANIFEST_FILENAME", "ManifestError", "__name", "source", "errors", "line", "parseManifest", "text", "syntax", "value", "error", "result", "loadManifest", "root", "file", "manifestCoverageThresholds", "dir"]
|
|
7
7
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pages-proxy.d.ts","sourceRoot":"","sources":["../src/pages-proxy.ts"],"names":[],"mappings":"AAYA,eAAO,MAAM,SAAS,oCAAqB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{createPagesProxy as e}from"./functions/pages-proxy.js";const r=e();export{r as onRequest};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/pages-proxy.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * The whole `functions/[[path]].ts` of a Pages project that proxies to `API_WORKER`, as a re-export:\n *\n * ```ts\n * export { onRequest } from '@rexezuge/tooling/pages-proxy';\n * ```\n *\n * The default `createPagesProxy()`. A repo that needs an option (`forwardClientIp: false`) keeps\n * the two-line `createPagesProxy({ ... })` form from `@rexezuge/tooling/functions/pages-proxy`.\n */\nimport { createPagesProxy } from './functions/pages-proxy.ts';\n\nexport const onRequest = createPagesProxy();\n"],
|
|
5
|
+
"mappings": "AAUA,OAAS,oBAAAA,MAAwB,6BAE1B,MAAMC,EAAYD,EAAgB",
|
|
6
|
+
"names": ["createPagesProxy", "onRequest"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { ViteUserConfig } from 'vitest/config';
|
|
2
|
+
/**
|
|
3
|
+
* What a `plugins` option accepts: whatever a Vite `plugins` array does (a plugin, a nested array of them as
|
|
4
|
+
* `@vitejs/plugin-react` and `@tailwindcss/vite` return, a promise, a falsy placeholder).
|
|
5
|
+
*
|
|
6
|
+
* Deliberately structural rather than Vite's own `PluginOption`: the app's `vite` and the `vite` that
|
|
7
|
+
* `vitest` brings are separate installs more often than not, and their `Plugin` types are not assignable to
|
|
8
|
+
* each other even at the same version ("Excessive stack depth comparing types"). The kit never inspects a plugin.
|
|
9
|
+
*/
|
|
10
|
+
export type PluginOption = object | false | null | undefined;
|
|
11
|
+
/**
|
|
12
|
+
* Hand the plugins to Vite. One assertion, here, for the reason above.
|
|
13
|
+
*/
|
|
14
|
+
export declare function asVitePlugins(plugins: readonly PluginOption[]): NonNullable<ViteUserConfig['plugins']>;
|
|
15
|
+
//# sourceMappingURL=plugin-option.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin-option.d.ts","sourceRoot":"","sources":["../src/plugin-option.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAEpD;;;;;;;GAOG;AACH,MAAM,MAAM,YAAY,GAAG,MAAM,GAAG,KAAK,GAAG,IAAI,GAAG,SAAS,CAAC;AAE7D;;GAEG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,SAAS,YAAY,EAAE,GAAG,WAAW,CAAC,cAAc,CAAC,SAAS,CAAC,CAAC,CAEtG"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var i=Object.defineProperty;var t=(n,e)=>i(n,"name",{value:e,configurable:!0});function u(n){return[...n]}t(u,"asVitePlugins");export{u as asVitePlugins};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/plugin-option.ts"],
|
|
4
|
+
"sourcesContent": ["import type { ViteUserConfig } from 'vitest/config';\n\n/**\n * What a `plugins` option accepts: whatever a Vite `plugins` array does (a plugin, a nested array of them as\n * `@vitejs/plugin-react` and `@tailwindcss/vite` return, a promise, a falsy placeholder).\n *\n * Deliberately structural rather than Vite's own `PluginOption`: the app's `vite` and the `vite` that\n * `vitest` brings are separate installs more often than not, and their `Plugin` types are not assignable to\n * each other even at the same version (\"Excessive stack depth comparing types\"). The kit never inspects a plugin.\n */\nexport type PluginOption = object | false | null | undefined;\n\n/**\n * Hand the plugins to Vite. One assertion, here, for the reason above.\n */\nexport function asVitePlugins(plugins: readonly PluginOption[]): NonNullable<ViteUserConfig['plugins']> {\n return [...plugins] as NonNullable<ViteUserConfig['plugins']>;\n}\n"],
|
|
5
|
+
"mappings": "+EAeM,SAAUA,EAAcC,EAAgC,CAC5D,MAAO,CAAC,GAAGA,CAAO,CACpB,CAFgBC,EAAAF,EAAA",
|
|
6
|
+
"names": ["asVitePlugins", "plugins", "__name"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Where backups land, and which listed objects the retention prune may delete.
|
|
3
|
+
*
|
|
4
|
+
* Provenance: the `s3-prune.ts` and `webdav-target.ts` that Mail-Meow, Edge-Sonic and AWS-AccessBridge each carry,
|
|
5
|
+
* converged with the repo-specific prefix lifted into a parameter (the manifest's `name`). Pure, so the safety rules
|
|
6
|
+
* are asserted without a bucket or a WebDAV host.
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Every backup of one repo lives under `<name>/production`, so a prune can never touch an unrelated object.
|
|
10
|
+
*/
|
|
11
|
+
export declare function backupPrefix(name: string): string;
|
|
12
|
+
export interface BackupListingEntry {
|
|
13
|
+
/**
|
|
14
|
+
`YYYY-MM-DD` as reported by `aws s3 ls`.
|
|
15
|
+
*/
|
|
16
|
+
fileDate: string;
|
|
17
|
+
fileName: string;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* True only for files this workflow produced. The prune is the one destructive operation in the backup, so it refuses
|
|
21
|
+
* anything that is not a backup artifact. `.gz` is kept so objects written before the switch to xz still age out.
|
|
22
|
+
*/
|
|
23
|
+
export declare function isBackupArtifact(fileName: string): boolean;
|
|
24
|
+
/**
|
|
25
|
+
* Parse one `aws s3 ls` row: `<date> <time> <size> <key>`.
|
|
26
|
+
*/
|
|
27
|
+
export declare function parseS3ListRow(line: string): BackupListingEntry | undefined;
|
|
28
|
+
/**
|
|
29
|
+
* Decide whether a listed object should be pruned. Dates are `YYYY-MM-DD`, so lexicographic and chronological order agree.
|
|
30
|
+
*/
|
|
31
|
+
export declare function shouldDeleteBackup(entry: BackupListingEntry, cutoffDate: string): boolean;
|
|
32
|
+
/**
|
|
33
|
+
* The rclone remote name the WebDAV upload configures from the environment.
|
|
34
|
+
*/
|
|
35
|
+
export declare const WEBDAV_REMOTE = "webdav";
|
|
36
|
+
/**
|
|
37
|
+
* Where backups land on the remote, e.g. `webdav:my-app/production`. An empty base path falls back to `name`.
|
|
38
|
+
*/
|
|
39
|
+
export declare function webdavTargetDir(basePath: string, name: string): string;
|
|
40
|
+
//# sourceMappingURL=destinations.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"destinations.d.ts","sourceRoot":"","sources":["../../../src/scripts/backup/destinations.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH;;GAEG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAEjD;AAED,MAAM,WAAW,kBAAkB;IACjC;;MAEE;IACF,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAI1D;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,kBAAkB,GAAG,SAAS,CAG3E;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,kBAAkB,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAEzF;AAED;;GAEG;AACH,eAAO,MAAM,aAAa,WAAW,CAAC;AAEtC;;GAEG;AACH,wBAAgB,eAAe,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAEtE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var i=Object.defineProperty;var n=(t,e)=>i(t,"name",{value:e,configurable:!0});function u(t){return`${t}/production`}n(u,"backupPrefix");function r(t){return t.endsWith(".sql.xz")||t.endsWith(".sql.xz.enc")||t.endsWith(".sql.gz")||t.endsWith(".sql.gz.enc")}n(r,"isBackupArtifact");function c(t){const e=t.trim().split(/\s+/);return e.length<4?void 0:{fileDate:e[0],fileName:e.slice(3).join(" ")}}n(c,"parseS3ListRow");function p(t,e){return r(t.fileName)&&t.fileDate<e}n(p,"shouldDeleteBackup");const o="webdav";function d(t,e){return`${o}:${t||e}/production`}n(d,"webdavTargetDir");export{o as WEBDAV_REMOTE,u as backupPrefix,r as isBackupArtifact,c as parseS3ListRow,p as shouldDeleteBackup,d as webdavTargetDir};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/scripts/backup/destinations.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * Where backups land, and which listed objects the retention prune may delete.\n *\n * Provenance: the `s3-prune.ts` and `webdav-target.ts` that Mail-Meow, Edge-Sonic and AWS-AccessBridge each carry,\n * converged with the repo-specific prefix lifted into a parameter (the manifest's `name`). Pure, so the safety rules\n * are asserted without a bucket or a WebDAV host.\n */\n\n/**\n * Every backup of one repo lives under `<name>/production`, so a prune can never touch an unrelated object.\n */\nexport function backupPrefix(name: string): string {\n return `${name}/production`;\n}\n\nexport interface BackupListingEntry {\n /**\n `YYYY-MM-DD` as reported by `aws s3 ls`.\n */\n fileDate: string;\n fileName: string;\n}\n\n/**\n * True only for files this workflow produced. The prune is the one destructive operation in the backup, so it refuses\n * anything that is not a backup artifact. `.gz` is kept so objects written before the switch to xz still age out.\n */\nexport function isBackupArtifact(fileName: string): boolean {\n return (\n fileName.endsWith('.sql.xz') || fileName.endsWith('.sql.xz.enc') || fileName.endsWith('.sql.gz') || fileName.endsWith('.sql.gz.enc')\n );\n}\n\n/**\n * Parse one `aws s3 ls` row: `<date> <time> <size> <key>`.\n */\nexport function parseS3ListRow(line: string): BackupListingEntry | undefined {\n const fields = line.trim().split(/\\s+/);\n return fields.length < 4 ? undefined : { fileDate: fields[0], fileName: fields.slice(3).join(' ') };\n}\n\n/**\n * Decide whether a listed object should be pruned. Dates are `YYYY-MM-DD`, so lexicographic and chronological order agree.\n */\nexport function shouldDeleteBackup(entry: BackupListingEntry, cutoffDate: string): boolean {\n return isBackupArtifact(entry.fileName) && entry.fileDate < cutoffDate;\n}\n\n/**\n * The rclone remote name the WebDAV upload configures from the environment.\n */\nexport const WEBDAV_REMOTE = 'webdav';\n\n/**\n * Where backups land on the remote, e.g. `webdav:my-app/production`. An empty base path falls back to `name`.\n */\nexport function webdavTargetDir(basePath: string, name: string): string {\n return `${WEBDAV_REMOTE}:${basePath || name}/production`;\n}\n"],
|
|
5
|
+
"mappings": "+EAWM,SAAUA,EAAaC,EAAY,CACvC,MAAO,GAAGA,CAAI,aAChB,CAFgBC,EAAAF,EAAA,gBAgBV,SAAUG,EAAiBC,EAAgB,CAC/C,OACEA,EAAS,SAAS,SAAS,GAAKA,EAAS,SAAS,aAAa,GAAKA,EAAS,SAAS,SAAS,GAAKA,EAAS,SAAS,aAAa,CAEvI,CAJgBF,EAAAC,EAAA,oBASV,SAAUE,EAAeC,EAAY,CACzC,MAAMC,EAASD,EAAK,KAAI,EAAG,MAAM,KAAK,EACtC,OAAOC,EAAO,OAAS,EAAI,OAAY,CAAE,SAAUA,EAAO,CAAC,EAAG,SAAUA,EAAO,MAAM,CAAC,EAAE,KAAK,GAAG,CAAC,CACnG,CAHgBL,EAAAG,EAAA,kBAQV,SAAUG,EAAmBC,EAA2BC,EAAkB,CAC9E,OAAOP,EAAiBM,EAAM,QAAQ,GAAKA,EAAM,SAAWC,CAC9D,CAFgBR,EAAAM,EAAA,sBAOT,MAAMG,EAAgB,SAKvB,SAAUC,EAAgBC,EAAkBZ,EAAY,CAC5D,MAAO,GAAGU,CAAa,IAAIE,GAAYZ,CAAI,aAC7C,CAFgBC,EAAAU,EAAA",
|
|
6
|
+
"names": ["backupPrefix", "name", "__name", "isBackupArtifact", "fileName", "parseS3ListRow", "line", "fields", "shouldDeleteBackup", "entry", "cutoffDate", "WEBDAV_REMOTE", "webdavTargetDir", "basePath"]
|
|
7
|
+
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
#!/usr/bin/env tsx
|
|
2
1
|
/**
|
|
3
2
|
* Compress and encrypt the exported D1 dump.
|
|
4
3
|
*
|
|
@@ -31,5 +30,9 @@
|
|
|
31
30
|
* BACKUP_ENCRYPTION_KEY=… pnpm exec tsx scripts/backup/encrypt-backup.ts
|
|
32
31
|
* ```
|
|
33
32
|
*/
|
|
34
|
-
|
|
33
|
+
/**
|
|
34
|
+
* Compress and encrypt `backup.sql` in the working directory, remove the plaintext, and publish the file name as the
|
|
35
|
+
* `file` step output. Calls `fail` (exits 1) on any problem, so no unencrypted dump is left for an upload job.
|
|
36
|
+
*/
|
|
37
|
+
export declare function main(): Promise<void>;
|
|
35
38
|
//# sourceMappingURL=encrypt-backup.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"encrypt-backup.d.ts","sourceRoot":"","sources":["../../../src/scripts/backup/encrypt-backup.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"encrypt-backup.d.ts","sourceRoot":"","sources":["../../../src/scripts/backup/encrypt-backup.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAuBH;;;GAGG;AACH,wBAAsB,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAwD1C"}
|
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
`,"utf8"),m(t,{force:!0}),console.log(`Backup encrypted: ${o} (${n.byteLength} compressed bytes)`),y("file",o);
|
|
1
|
+
var p=Object.defineProperty;var c=(n,o)=>p(n,"name",{value:o,configurable:!0});import{encryptSecret as m}from"@rexezuge/d1";import{execFileSync as f}from"node:child_process";import{existsSync as l,readFileSync as u,rmSync as y,writeFileSync as d}from"node:fs";import E from"node:path";import{fail as r,setOutput as S}from"../lib/github-actions.js";import{isEntrypoint as g}from"../lib/entrypoint.js";import{backupFileName as x}from"./naming.js";const t="backup.sql",$=["-T0","-6"];async function b(){process.env.BACKUP_ENCRYPTION_KEY||r("BACKUP_ENCRYPTION_KEY is not set. Refusing to export an unencrypted database."),l(t)||r(`Expected ${t} from the export step, but it does not exist.`);const n=process.env.BACKUP_ENCRYPTION_KEY,o=x(new Date);let i;try{i=u(t,"utf8")}catch(e){r(`Could not read ${t}: ${e instanceof Error?e.message:String(e)}`)}i===""&&r(`${t} is empty. An empty dump is not a backup, and uploading one is a false sense of safety.`);let s;try{s=f("xz",[...$,"--keep","--stdout",t],{maxBuffer:512*1024*1024})}catch(e){r(`xz failed on ${t}: ${e instanceof Error?e.message:String(e)}`)}let a;try{a=await m(s.toString("base64"),n)}catch(e){r(`Could not encrypt the dump: ${e instanceof Error?e.message:String(e)}`)}d(o,`${JSON.stringify({...a,source:E.basename(t)},null,2)}
|
|
2
|
+
`,"utf8"),y(t,{force:!0}),console.log(`Backup encrypted: ${o} (${s.byteLength} compressed bytes)`),S("file",o)}c(b,"main"),g(import.meta.url)&&await b();export{b as main};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/scripts/backup/encrypt-backup.ts"],
|
|
4
|
-
"sourcesContent": ["
|
|
5
|
-
"mappings": "
|
|
6
|
-
"names": ["encryptSecret", "execFileSync", "existsSync", "readFileSync", "rmSync", "writeFileSync", "path", "fail", "setOutput", "backupFileName", "SOURCE_FILE", "XZ_ARGS", "key", "file", "plaintext", "error", "compressed", "envelope"]
|
|
4
|
+
"sourcesContent": ["/**\n * Compress and encrypt the exported D1 dump.\n *\n * Provenance: Edge-Sonic's `scripts/backup/encrypt-backup.ts`, converged with the\n * AES-GCM envelope every repo in the family already uses for its secrets. This is\n * the one backup script that ported cleanly and changed *for the better* on the way\n * in: the source shelled out to `openssl enc -aes-256-cbc -pbkdf2`, which is a\n * password-derived key with a KDF whose cost is a constant somebody chose once,\n * and which is not authenticated — a flipped byte in the ciphertext is undetectable.\n *\n * The kit's version uses `@rexezuge/d1`'s `encryptSecret`, the same WebCrypto\n * AES-256-GCM primitive the workers use, over a base64 32-byte key — the same key\n * format `resolveReplicationKey` reads. One definition of \"what an encryption key\n * looks like\" across the deploy path and the backup path is the point: a second\n * implementation is how a deploy ends up generating something the worker cannot\n * read, and here it would be how a backup ends up unreadable by the restore path.\n *\n * Fail-closed: without `BACKUP_ENCRYPTION_KEY` the script refuses to run and\n * deletes nothing, so an unencrypted dump can never reach the artifact store the\n * upload jobs read from.\n *\n * The passphrase is read from the environment rather than passed as an argument,\n * because command-line arguments are visible to any process on the runner via `ps`.\n *\n * Emits the resulting file name as the `file` step output.\n *\n * Usage, from the repo root (after `wrangler d1 export … --output=backup.sql`):\n *\n * ```bash\n * BACKUP_ENCRYPTION_KEY=… pnpm exec tsx scripts/backup/encrypt-backup.ts\n * ```\n */\n\nimport { encryptSecret } from '@rexezuge/d1';\nimport { execFileSync } from 'node:child_process';\nimport { existsSync, readFileSync, rmSync, writeFileSync } from 'node:fs';\nimport path from 'node:path';\nimport { fail, setOutput } from '../lib/github-actions.ts';\nimport { isEntrypoint } from '../lib/entrypoint.ts';\nimport { backupFileName } from './naming.ts';\n\n/**\nThe dump the export step leaves in the working directory.\n*/\nconst SOURCE_FILE = 'backup.sql';\n\n/**\n * xz preset 6, chosen for ratio over speed: this runs once a day against a dump\n * that is mostly SQL text and JSON blobs, and LZMA typically beats gzip by 20-30%\n * there. `-T0` uses every available thread, which matters because xz is markedly\n * slower than gzip and the job is wall-clock bound.\n */\nconst XZ_ARGS = ['-T0', '-6'];\n\n/**\n * Compress and encrypt `backup.sql` in the working directory, remove the plaintext, and publish the file name as the\n * `file` step output. Calls `fail` (exits 1) on any problem, so no unencrypted dump is left for an upload job.\n */\nexport async function main(): Promise<void> {\n if (!process.env['BACKUP_ENCRYPTION_KEY']) {\n fail('BACKUP_ENCRYPTION_KEY is not set. Refusing to export an unencrypted database.');\n }\n\n if (!existsSync(SOURCE_FILE)) {\n fail(`Expected ${SOURCE_FILE} from the export step, but it does not exist.`);\n }\n\n const key = process.env['BACKUP_ENCRYPTION_KEY'];\n const file = backupFileName(new Date());\n\n let plaintext: string;\n try {\n plaintext = readFileSync(SOURCE_FILE, 'utf8');\n } catch (error: unknown) {\n fail(`Could not read ${SOURCE_FILE}: ${error instanceof Error ? error.message : String(error)}`);\n }\n\n if (plaintext === '') {\n fail(`${SOURCE_FILE} is empty. An empty dump is not a backup, and uploading one is a false sense of safety.`);\n }\n\n /**\n * Compress first, then encrypt.\n *\n * The order matters: compression over ciphertext buys nothing, and encrypting the\n * compressed bytes means the plaintext is never re-materialised on disk at full\n * size. Unlike gzip, xz leaves its input in place, so the plaintext SQL has to be\n * removed explicitly here or it survives into the artifact store.\n */\n let compressed: Buffer;\n try {\n // `xz` is resolved from PATH deliberately: the script runs wherever the\n // operator compresses backups, and pinning an absolute path would break\n // every platform but one.\n // eslint-disable-next-line sonarjs/no-os-command-from-path\n compressed = execFileSync('xz', [...XZ_ARGS, '--keep', '--stdout', SOURCE_FILE], { maxBuffer: 512 * 1024 * 1024 });\n } catch (error: unknown) {\n fail(`xz failed on ${SOURCE_FILE}: ${error instanceof Error ? error.message : String(error)}`);\n }\n\n let envelope: { ciphertext: string; iv: string };\n try {\n envelope = await encryptSecret(compressed.toString('base64'), key);\n } catch (error: unknown) {\n // A key that is not 32 base64 bytes, or not valid base64 at all, fails here\n // rather than producing a file nothing can open.\n fail(`Could not encrypt the dump: ${error instanceof Error ? error.message : String(error)}`);\n }\n\n writeFileSync(file, `${JSON.stringify({ ...envelope, source: path.basename(SOURCE_FILE) }, null, 2)}\\n`, 'utf8');\n rmSync(SOURCE_FILE, { force: true });\n\n console.log(`Backup encrypted: ${file} (${compressed.byteLength} compressed bytes)`);\n setOutput('file', file);\n}\n\nif (isEntrypoint(import.meta.url)) {\n await main();\n}\n"],
|
|
5
|
+
"mappings": "+EAiCA,OAAS,iBAAAA,MAAqB,eAC9B,OAAS,gBAAAC,MAAoB,qBAC7B,OAAS,cAAAC,EAAY,gBAAAC,EAAc,UAAAC,EAAQ,iBAAAC,M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AKG,EAAW,UAAU,oBAAoB,EACnFV,EAAU,OAAQO,CAAI,CACxB,CAxDsBK,EAAAP,EAAA,QA0DlBJ,EAAa,YAAY,GAAG,GAC9B,MAAMI,EAAI",
|
|
6
|
+
"names": ["encryptSecret", "execFileSync", "existsSync", "readFileSync", "rmSync", "writeFileSync", "path", "fail", "setOutput", "isEntrypoint", "backupFileName", "SOURCE_FILE", "XZ_ARGS", "main", "key", "file", "plaintext", "error", "compressed", "envelope", "__name"]
|
|
7
7
|
}
|
|
@@ -42,5 +42,5 @@ export declare function retentionCutoff(now: Date, days: number): string;
|
|
|
42
42
|
* `Number()` rather than `parseInt()`: `parseInt('30d')` yields 30, which would
|
|
43
43
|
* silently accept a mistyped value and prune against the wrong window.
|
|
44
44
|
*/
|
|
45
|
-
export declare function requireRetentionDays(): number;
|
|
45
|
+
export declare function requireRetentionDays(env?: NodeJS.ProcessEnv): number;
|
|
46
46
|
//# sourceMappingURL=naming.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"naming.d.ts","sourceRoot":"","sources":["../../../src/scripts/backup/naming.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH;;;;;;;;GAQG;AACH,eAAO,MAAM,kBAAkB,iBAAiB,CAAC;AAEjD;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,IAAI,GAAG,MAAM,CAG9C;AAED;;EAEE;AACF,wBAAgB,cAAc,CAAC,IAAI,EAAE,IAAI,GAAG,MAAM,CAEjD;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAE/D;AAED;;;;;;;;;GASG;AACH,wBAAgB,oBAAoB,
|
|
1
|
+
{"version":3,"file":"naming.d.ts","sourceRoot":"","sources":["../../../src/scripts/backup/naming.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH;;;;;;;;GAQG;AACH,eAAO,MAAM,kBAAkB,iBAAiB,CAAC;AAEjD;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,IAAI,GAAG,MAAM,CAG9C;AAED;;EAEE;AACF,wBAAgB,cAAc,CAAC,IAAI,EAAE,IAAI,GAAG,MAAM,CAEjD;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAE/D;AAED;;;;;;;;;GASG;AACH,wBAAgB,oBAAoB,CAAC,GAAG,GAAE,MAAM,CAAC,UAAwB,GAAG,MAAM,CAOjF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var
|
|
1
|
+
var o=Object.defineProperty;var r=(e,t)=>o(e,"name",{value:t,configurable:!0});const i="backup_prod_";function c(e){const t=e.toISOString();return`${t.slice(0,10)}_${t.slice(11,19).replaceAll(":","-")}`}r(c,"backupStamp");function u(e){return`${i}${c(e)}.sql.xz.enc`}r(u,"backupFileName");function p(e,t){return new Date(e.getTime()-t*24*60*60*1e3).toISOString().slice(0,10)}r(p,"retentionCutoff");function a(e=process.env){const t=e.BACKUP_RETENTION_DAYS,n=Number(t);if(!Number.isFinite(n)||n<=0)throw new Error(`BACKUP_RETENTION_DAYS must be a positive number, got ${JSON.stringify(t)}.`);return n}r(a,"requireRetentionDays");export{i as BACKUP_FILE_PREFIX,u as backupFileName,c as backupStamp,a as requireRetentionDays,p as retentionCutoff};
|