@rexezuge/tooling 1.5.0 → 1.5.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. package/dist/eslint-boundaries.js +1 -1
  2. package/dist/eslint-boundaries.js.map +2 -2
  3. package/dist/eslint.d.ts.map +1 -1
  4. package/dist/eslint.js +1 -1
  5. package/dist/eslint.js.map +3 -3
  6. package/dist/functions/pages-proxy.js +1 -1
  7. package/dist/functions/pages-proxy.js.map +2 -2
  8. package/dist/scripts/backup/d1-target.js +1 -1
  9. package/dist/scripts/backup/d1-target.js.map +2 -2
  10. package/dist/scripts/backup/destination-config.js +1 -1
  11. package/dist/scripts/backup/destination-config.js.map +2 -2
  12. package/dist/scripts/backup/naming.js +1 -1
  13. package/dist/scripts/backup/naming.js.map +2 -2
  14. package/dist/scripts/check-god-files.js +2 -2
  15. package/dist/scripts/check-god-files.js.map +2 -2
  16. package/dist/scripts/init-secrets.js +2 -2
  17. package/dist/scripts/init-secrets.js.map +2 -2
  18. package/dist/scripts/lib/cli-args.js +1 -1
  19. package/dist/scripts/lib/cli-args.js.map +2 -2
  20. package/dist/scripts/lib/github-actions.js +3 -3
  21. package/dist/scripts/lib/github-actions.js.map +2 -2
  22. package/dist/scripts/lib/wrangler-table.js +2 -2
  23. package/dist/scripts/lib/wrangler-table.js.map +2 -2
  24. package/dist/scripts/spa-shell.js +2 -2
  25. package/dist/scripts/spa-shell.js.map +2 -2
  26. package/dist/scripts/validate-locales.js +4 -4
  27. package/dist/scripts/validate-locales.js.map +2 -2
  28. package/dist/scripts/verify-migrations.js +2 -2
  29. package/dist/scripts/verify-migrations.js.map +2 -2
  30. package/dist/scripts/wrangler-config/cli.js +3 -3
  31. package/dist/scripts/wrangler-config/cli.js.map +2 -2
  32. package/dist/scripts/wrangler-config/patches.js +3 -3
  33. package/dist/scripts/wrangler-config/patches.js.map +2 -2
  34. package/dist/scripts/wrangler-config/resources.js +1 -1
  35. package/dist/scripts/wrangler-config/resources.js.map +2 -2
  36. package/dist/test/integration-migrations.js +2 -2
  37. package/dist/test/integration-migrations.js.map +2 -2
  38. package/dist/test/mocks/cloudflare-workers.js +1 -1
  39. package/dist/test/mocks/cloudflare-workers.js.map +2 -2
  40. package/dist/vite.js +3 -3
  41. package/dist/vite.js.map +2 -2
  42. package/dist/vitest-aliases.js +1 -1
  43. package/dist/vitest-aliases.js.map +2 -2
  44. package/dist/vitest-integration.js +1 -1
  45. package/dist/vitest-integration.js.map +2 -2
  46. package/dist/vitest-repo.js +1 -1
  47. package/dist/vitest-repo.js.map +2 -2
  48. package/dist/vitest-web.js +1 -1
  49. package/dist/vitest-web.js.map +2 -2
  50. package/dist/vitest.js +1 -1
  51. package/dist/vitest.js.map +2 -2
  52. package/package.json +2 -2
  53. package/src/eslint.test.ts +20 -0
  54. package/src/eslint.ts +13 -3
@@ -1 +1 @@
1
- const n=["packages/shared","packages/backend-errors","packages/backend-runtime","packages/backend-data","packages/provider-clients","packages/webdav","packages/dav-store","packages/git-protocol","packages/git-service","packages/backend-services","apps/api","apps/background","apps/web"];function o(a){const e=s=>`${a}/${s}`;return[{dir:"packages/shared",ban:[e("*")],message:`${a} packages must not import from other ${a} packages \u2014 this is a zero-dependency base layer`},{dir:"packages/backend-errors",ban:[e("*")],message:`${a} packages must not import from other ${a} packages \u2014 this is a zero-dependency base layer`},{dir:"packages/backend-runtime",ban:[e("backend-data"),e("provider-clients"),e("webdav"),e("dav-store"),e("git-protocol"),e("git-service"),e("backend-services"),e("api"),e("background")],message:"backend-runtime must not import from a higher layer"},{dir:"packages/backend-data",ban:[e("backend-runtime"),e("provider-clients"),e("webdav"),e("dav-store"),e("git-protocol"),e("git-service"),e("backend-services"),e("api"),e("background")],message:"backend-data must not import from a higher layer"},{dir:"packages/provider-clients",ban:[e("backend-data"),e("backend-runtime"),e("backend-services"),e("api"),e("background")],message:"provider-clients must not import DAOs from backend-data"},{dir:"packages/webdav",ban:[e("backend-data"),e("backend-runtime"),e("dav-store"),e("backend-services"),e("api"),e("background")],message:"webdav must not import DAOs from backend-data"},{dir:"packages/git-protocol",ban:[e("backend-data"),e("backend-runtime"),e("git-service"),e("backend-services"),e("api"),e("background")],message:"git-protocol must not import DAOs from backend-data"},{dir:"packages/dav-store",ban:[e("backend-services"),e("api"),e("background")],message:"dav-store must not import from backend-services (higher layer)"},{dir:"packages/git-service",ban:[e("backend-services"),e("api"),e("background")],message:"git-service must not import from backend-services (higher layer)"},{dir:"packages/backend-services",ban:[e("api"),e("background")],message:"backend-services must not import from apps"},{dir:"apps/api",ban:[e("backend-data/dao"),e("backend-data")],allowTypeImports:!0,message:"apps/api must not import DAOs or backend-data values directly; use backend-services instead (type-only imports are allowed)"},{dir:"apps/api",ban:[e("provider-clients")],message:`apps/api must not import provider-clients directly; use ${a}/backend-services instead`},{dir:"apps/api",ban:[e("dav-store")],message:`apps/api must not import dav-store directly; use ${a}/webdav + DO RPC via ${a}/background instead`},{dir:"apps/api",ban:[e("git-service")],message:`apps/api must not import git-service directly; use ${a}/git-protocol + DO RPC via ${a}/background instead`},{dir:"apps/background",ban:[e("api")],message:"apps/background must not import from apps/api"},{dir:"apps/web",ban:[e("*")],message:`${e("apps/web")} ships zero backend dependencies \u2014 this module is the SPA's own copy`}]}function c(a){return a.map(({dir:e,ban:s,message:t,allowTypeImports:r})=>({files:[`${e}/**/*.{ts,js,mts,cts,mjs,cjs}`],rules:{"no-restricted-imports":["error",{patterns:s.map(i=>({group:[i,`${i}/*`],message:t,...r===!0&&{allowTypeImports:!0}}))}]}}))}function d(a){return a.map(({dir:e,ban:s,message:t})=>({files:[`${e}/**/*.{ts,js,mts,cts,mjs,cjs}`],rules:{"no-restricted-syntax":["error",...s.map(r=>({selector:`ImportExpression[source.type='Literal'][source.value=/^${r.replaceAll("/",String.raw`\/`)}/]`,message:`A dynamic import() is not covered by no-restricted-imports, so this layer reaches \`${r}\` through the one syntax that gate does not see. Both say no: ${t}`}))]}}))}export{n as DEFAULT_PROJECT_DIRS,o as layerBans,d as restrictedDynamicImports,c as restrictedImports};
1
+ var o=Object.defineProperty;var r=(a,e)=>o(a,"name",{value:e,configurable:!0});const d=["packages/shared","packages/backend-errors","packages/backend-runtime","packages/backend-data","packages/provider-clients","packages/webdav","packages/dav-store","packages/git-protocol","packages/git-service","packages/backend-services","apps/api","apps/background","apps/web"];function p(a){const e=r(s=>`${a}/${s}`,"at");return[{dir:"packages/shared",ban:[e("*")],message:`${a} packages must not import from other ${a} packages \u2014 this is a zero-dependency base layer`},{dir:"packages/backend-errors",ban:[e("*")],message:`${a} packages must not import from other ${a} packages \u2014 this is a zero-dependency base layer`},{dir:"packages/backend-runtime",ban:[e("backend-data"),e("provider-clients"),e("webdav"),e("dav-store"),e("git-protocol"),e("git-service"),e("backend-services"),e("api"),e("background")],message:"backend-runtime must not import from a higher layer"},{dir:"packages/backend-data",ban:[e("backend-runtime"),e("provider-clients"),e("webdav"),e("dav-store"),e("git-protocol"),e("git-service"),e("backend-services"),e("api"),e("background")],message:"backend-data must not import from a higher layer"},{dir:"packages/provider-clients",ban:[e("backend-data"),e("backend-runtime"),e("backend-services"),e("api"),e("background")],message:"provider-clients must not import DAOs from backend-data"},{dir:"packages/webdav",ban:[e("backend-data"),e("backend-runtime"),e("dav-store"),e("backend-services"),e("api"),e("background")],message:"webdav must not import DAOs from backend-data"},{dir:"packages/git-protocol",ban:[e("backend-data"),e("backend-runtime"),e("git-service"),e("backend-services"),e("api"),e("background")],message:"git-protocol must not import DAOs from backend-data"},{dir:"packages/dav-store",ban:[e("backend-services"),e("api"),e("background")],message:"dav-store must not import from backend-services (higher layer)"},{dir:"packages/git-service",ban:[e("backend-services"),e("api"),e("background")],message:"git-service must not import from backend-services (higher layer)"},{dir:"packages/backend-services",ban:[e("api"),e("background")],message:"backend-services must not import from apps"},{dir:"apps/api",ban:[e("backend-data/dao"),e("backend-data")],allowTypeImports:!0,message:"apps/api must not import DAOs or backend-data values directly; use backend-services instead (type-only imports are allowed)"},{dir:"apps/api",ban:[e("provider-clients")],message:`apps/api must not import provider-clients directly; use ${a}/backend-services instead`},{dir:"apps/api",ban:[e("dav-store")],message:`apps/api must not import dav-store directly; use ${a}/webdav + DO RPC via ${a}/background instead`},{dir:"apps/api",ban:[e("git-service")],message:`apps/api must not import git-service directly; use ${a}/git-protocol + DO RPC via ${a}/background instead`},{dir:"apps/background",ban:[e("api")],message:"apps/background must not import from apps/api"},{dir:"apps/web",ban:[e("*")],message:`${e("apps/web")} ships zero backend dependencies \u2014 this module is the SPA's own copy`}]}r(p,"layerBans");function m(a){return a.map(({dir:e,ban:s,message:i,allowTypeImports:t})=>({files:[`${e}/**/*.{ts,js,mts,cts,mjs,cjs}`],rules:{"no-restricted-imports":["error",{patterns:s.map(n=>({group:[n,`${n}/*`],message:i,...t===!0&&{allowTypeImports:!0}}))}]}}))}r(m,"restrictedImports");function b(a){return a.map(({dir:e,ban:s,message:i})=>({files:[`${e}/**/*.{ts,js,mts,cts,mjs,cjs}`],rules:{"no-restricted-syntax":["error",...s.map(t=>({selector:`ImportExpression[source.type='Literal'][source.value=/^${t.replaceAll("/",String.raw`\/`)}/]`,message:`A dynamic import() is not covered by no-restricted-imports, so this layer reaches \`${t}\` through the one syntax that gate does not see. Both say no: ${i}`}))]}}))}r(b,"restrictedDynamicImports");export{d as DEFAULT_PROJECT_DIRS,p as layerBans,b as restrictedDynamicImports,m as restrictedImports};
@@ -2,6 +2,6 @@
2
2
  "version": 3,
3
3
  "sources": ["../src/eslint-boundaries.ts"],
4
4
  "sourcesContent": ["import type tseslint from 'typescript-eslint';\n\n/**\n * The layer table behind the repo lint config's import boundaries.\n *\n * Provenance: the seven `no-restricted-imports` blocks in Durable-DAV's\n * `eslint.config.mjs`, with `@durable-dav/` replaced by the caller's scope.\n * Extracted from `eslint.ts` so the boundary rules — the part a repo actually\n * argues about — are their own module rather than the tail of a 640-line\n * config file.\n *\n * Converged across all nine family repos: `provider-clients` (AWS-AccessBridge,\n * CalDAV-Bridge, Mail-Meow, Mail-Otter), `webdav`/`dav-store` (Durable-DAV,\n * Durable-DAV-Router, Edge-Sonic), `git-protocol`/`git-service` (Edge-Git).\n * `media-tags`/`subsonic` (Edge-Sonic) carry no boundary block in their source\n * repo — they are unconstrained utility leaves — so they have no layer here.\n *\n * The table is data rather than inline blocks so the dynamic-`import()` guard\n * is generated from the same list: a rule that derived its banned set from\n * another rule's configuration would be a second source of truth for the layer\n * table, and that table is what the docs describe.\n *\n * The table is a superset: a repo without a domain package simply never imports\n * it, so its ban never fires. A layer entry for a directory that does not exist\n * in the consumer matches no file and costs nothing.\n */\n\n/**\n * The directories the boundary rules cover, in the canonical layout.\n *\n * Kept here, beside the table it scopes: `defineRepoLintConfig` filters the\n * canonical layers by `projectDirs`, and a reader of the layer table should not\n * have to open the config assembly to learn which directories it covers.\n */\nexport const DEFAULT_PROJECT_DIRS: readonly string[] = [\n 'packages/shared',\n 'packages/backend-errors',\n 'packages/backend-runtime',\n 'packages/backend-data',\n 'packages/provider-clients',\n 'packages/webdav',\n 'packages/dav-store',\n 'packages/git-protocol',\n 'packages/git-service',\n 'packages/backend-services',\n 'apps/api',\n 'apps/background',\n 'apps/web',\n];\n\n/**\n * One layer's ban list, as the repo-relative package suffixes it may not import.\n *\n * Converged from all nine family repos. `backend-data` and `backend-services`\n * appear in all nine; `provider-clients` is AWS-AccessBridge's, CalDAV-Bridge's,\n * Mail-Meow's and Mail-Otter's; `webdav`/`dav-store` are Durable-DAV's,\n * Durable-DAV-Router's and Edge-Sonic's; `git-protocol`/`git-service` are\n * Edge-Git's. A layer only bans what exists in its repo, so the\n * union is safe: a repo without `provider-clients` simply never imports it.\n *\n * One `dir` may appear in several entries (see `apps/api` below): each entry\n * carries its own message and `allowTypeImports`, because the DAO ban allows\n * type-only imports and the direct-client bans do not.\n */\nexport interface LayerBan {\n /**\n Directory the rule is scoped to.\n */\n readonly dir: string;\n /**\n Package suffixes (relative to `scope`) that may not be imported from here.\n */\n readonly ban: readonly string[];\n /**\n Message shown when the rule fires.\n */\n readonly message: string;\n /**\n Type-only imports are allowed, for the DAO boundary in `apps/api`.\n */\n readonly allowTypeImports?: boolean;\n}\n\n/**\n * The layer table, parameterized by `scope`.\n */\nexport function layerBans(scope: string): readonly LayerBan[] {\n const at = (name: string): string => `${scope}/${name}`;\n return [\n {\n dir: 'packages/shared',\n ban: [at('*')],\n message: `${scope} packages must not import from other ${scope} packages — this is a zero-dependency base layer`,\n },\n {\n dir: 'packages/backend-errors',\n ban: [at('*')],\n message: `${scope} packages must not import from other ${scope} packages — this is a zero-dependency base layer`,\n },\n {\n dir: 'packages/backend-runtime',\n ban: [\n at('backend-data'),\n at('provider-clients'),\n at('webdav'),\n at('dav-store'),\n at('git-protocol'),\n at('git-service'),\n at('backend-services'),\n at('api'),\n at('background'),\n ],\n message: 'backend-runtime must not import from a higher layer',\n },\n {\n dir: 'packages/backend-data',\n ban: [\n at('backend-runtime'),\n at('provider-clients'),\n at('webdav'),\n at('dav-store'),\n at('git-protocol'),\n at('git-service'),\n at('backend-services'),\n at('api'),\n at('background'),\n ],\n message: 'backend-data must not import from a higher layer',\n },\n // Domain protocol layers (layer 2, beside backend-data): each bans the DAO\n // layer, the runtime, its store counterpart where it has one, the service\n // layer and the apps. Sources: provider-clients (AWS-AccessBridge,\n // Mail-Meow), webdav (Durable-DAV, Edge-Sonic), git-protocol (Edge-Git).\n {\n dir: 'packages/provider-clients',\n ban: [at('backend-data'), at('backend-runtime'), at('backend-services'), at('api'), at('background')],\n message: 'provider-clients must not import DAOs from backend-data',\n },\n {\n dir: 'packages/webdav',\n ban: [at('backend-data'), at('backend-runtime'), at('dav-store'), at('backend-services'), at('api'), at('background')],\n message: 'webdav must not import DAOs from backend-data',\n },\n {\n dir: 'packages/git-protocol',\n ban: [at('backend-data'), at('backend-runtime'), at('git-service'), at('backend-services'), at('api'), at('background')],\n message: 'git-protocol must not import DAOs from backend-data',\n },\n // Domain store layers (layer 2-3): only layers 0-2, never services or apps.\n // Sources: dav-store (Durable-DAV), git-service (Edge-Git).\n {\n dir: 'packages/dav-store',\n ban: [at('backend-services'), at('api'), at('background')],\n message: 'dav-store must not import from backend-services (higher layer)',\n },\n {\n dir: 'packages/git-service',\n ban: [at('backend-services'), at('api'), at('background')],\n message: 'git-service must not import from backend-services (higher layer)',\n },\n {\n dir: 'packages/backend-services',\n ban: [at('api'), at('background')],\n message: 'backend-services must not import from apps',\n },\n {\n dir: 'apps/api',\n ban: [at('backend-data/dao'), at('backend-data')],\n allowTypeImports: true,\n message:\n 'apps/api must not import DAOs or backend-data values directly; use backend-services instead (type-only imports are allowed)',\n },\n // Direct-client bans: one entry per client package so each message names\n // the correct alternative. A repo holds at most one of these packages, so\n // the other two never fire. Sources: provider-clients (AWS-AccessBridge,\n // Mail-Meow, Mail-Otter, CalDAV-Bridge), dav-store (Durable-DAV),\n // git-service (Edge-Git).\n {\n dir: 'apps/api',\n ban: [at('provider-clients')],\n message: `apps/api must not import provider-clients directly; use ${scope}/backend-services instead`,\n },\n {\n dir: 'apps/api',\n ban: [at('dav-store')],\n message: `apps/api must not import dav-store directly; use ${scope}/webdav + DO RPC via ${scope}/background instead`,\n },\n {\n dir: 'apps/api',\n ban: [at('git-service')],\n message: `apps/api must not import git-service directly; use ${scope}/git-protocol + DO RPC via ${scope}/background instead`,\n },\n {\n dir: 'apps/background',\n ban: [at('api')],\n message: 'apps/background must not import from apps/api',\n },\n // The browser half, and the only layer that bans the namespace wholesale\n // rather than a list of siblings: a backend package imported by the SPA\n // typechecks and then fails at bundle time, with the error pointing at the\n // bundler rather than at the boundary. Edge-Sonic is the source; the others had\n // no block for it at all, which is how their layer table's \"may import: the\n // browser\" was a convention instead of a gate.\n {\n dir: 'apps/web',\n ban: [at('*')],\n message: `${at('apps/web')} ships zero backend dependencies — this module is the SPA's own copy`,\n },\n ];\n}\n\n/**\n * One argument to `tseslint.config()`, named here so the boundary builders\n * return the assembled type rather than a lookalike the assembly then has to\n * be argued into accepting.\n */\ntype ConfigInput = Parameters<typeof tseslint.config>[number];\n\n/**\n * The `no-restricted-imports` entries for one layer.\n *\n * Written as `group` patterns rather than exact `paths`, so `@myapp/backend-data`\n * and `@myapp/backend-data/dao` are both caught by one entry. `allowTypeImports`\n * is passed through only where the source repos set it, because `apps/api`\n * legitimately types its filters and models against DAO shapes.\n */\nexport function restrictedImports(bans: readonly LayerBan[]): ConfigInput[] {\n return bans.map(({ dir, ban, message, allowTypeImports }) => ({\n files: [`${dir}/**/*.{ts,js,mts,cts,mjs,cjs}`],\n rules: {\n 'no-restricted-imports': [\n 'error',\n {\n patterns: ban.map((group) => ({\n group: [group, `${group}/*`],\n message,\n ...(allowTypeImports === true && { allowTypeImports: true }),\n })),\n },\n ],\n },\n }));\n}\n\n/**\n * The dynamic-`import()` guard, generated from the same table.\n *\n * `no-restricted-imports` reads `ImportDeclaration` nodes only; a dynamic\n * `import()` is an `ImportExpression`, and this ESLint version does not report it\n * under that rule at all. Edge-Sonic verified this rather than assumed it — a\n * static import of a restricted specifier from the same file is an `error`, and\n * the identical specifier reached through `await import(...)` is silent. That\n * hole was load-bearing there: the credential path reached a banned module\n * through it. `no-restricted-syntax` sees `ImportExpression`, so the boundary is\n * stated a second way.\n */\nexport function restrictedDynamicImports(bans: readonly LayerBan[]): ConfigInput[] {\n return bans.map(({ dir, ban, message }) => ({\n files: [`${dir}/**/*.{ts,js,mts,cts,mjs,cjs}`],\n rules: {\n 'no-restricted-syntax': [\n 'error',\n ...ban.map((specifier) => ({\n selector: `ImportExpression[source.type='Literal'][source.value=/^${specifier.replaceAll('/', String.raw`\\/`)}/]`,\n message: `A dynamic import() is not covered by no-restricted-imports, so this layer reaches \\`${specifier}\\` through the one syntax that gate does not see. Both say no: ${message}`,\n })),\n ],\n },\n }));\n}\n"],
5
- "mappings": "AAkCO,MAAMA,EAA0C,CACrD,kBACA,0BACA,2BACA,wBACA,4BACA,kBACA,qBACA,wBACA,uBACA,4BACA,WACA,kBACA,YAuCI,SAAUC,EAAUC,EAAa,CAC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,EAAK,QAAAC,CAAO,KAAQ,CAC1C,MAAO,CAAC,GAAGF,CAAG,+BAA+B,EAC7C,MAAO,CACL,uBAAwB,CACtB,QACA,GAAGC,EAAI,IAAKK,IAAe,CACzB,SAAU,0DAA0DA,EAAU,WAAW,IAAK,OAAO,OAAO,CAAC,KAC7G,QAAS,uFAAuFA,CAAS,kEAAkEJ,CAAO,IAClL,KAGN,CACJ",
6
- "names": ["DEFAULT_PROJECT_DIRS", "layerBans", "scope", "at", "name", "restrictedImports", "bans", "dir", "ban", "message", "allowTypeImports", "group", "restrictedDynamicImports", "specifier"]
5
+ "mappings": "+EAkCO,MAAMA,EAA0C,CACrD,kBACA,0BACA,2BACA,wBACA,4BACA,kBACA,qBACA,wBACA,uBACA,4BACA,WACA,kBACA,YAuCI,SAAUC,EAAUC,EAAa,CACrC,MAAMC,EAAKC,EAACC,GAAyB,GAAGH,CAAK,IAAIG,CAAI,GAA1C,MACX,MAAO,CACL,CACE,IAAK,kBACL,IAAK,CAACF,EAAG,GAAG,CAAC,EACb,QAAS,GAAGD,CAAK,wCAAwCA,CAAK,yDAEhE,CACE,IAAK,0BACL,IAAK,CAACC,EAAG,GAAG,CAAC,EACb,QAAS,GAAGD,CAAK,wCAAwCA,CAAK,yDAEhE,CACE,IAAK,2BACL,IAAK,CACHC,EAAG,cAAc,EACjBA,EAAG,kBAAkB,EACrBA,EAAG,QAAQ,EACXA,EAAG,WAAW,EACdA,EAAG,cAAc,EACjBA,EAAG,aAAa,EAChBA,EAAG,kBAAkB,EACrBA,EAAG,KAAK,EACRA,EAAG,YAAY,GAEjB,QAAS,uDAEX,CACE,IAAK,wBACL,IAAK,CACHA,EAAG,iBAAiB,EACpBA,EAAG,kBAAkB,EACrBA,EAAG,QAAQ,EACXA,EAAG,WAAW,EACdA,EAAG,cAAc,EACjBA,EAAG,aAAa,EAChBA,EAAG,kBAAkB,EACrBA,EAAG,KAAK,EACRA,EAAG,YAAY,GAEjB,QAAS,oDAMX,CACE,IAAK,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,IAAK,CAACA,EAAG,GAAG,CAAC,EACb,QAAS,GAAGA,EAAG,UAAU,CAAC,6EAGhC,CA3HgBC,EAAAH,EAAA,aA4IV,SAAUK,EAAkBC,EAAyB,CACzD,OAAOA,EAAK,IAAI,CAAC,CAAE,IAAAC,EAAK,IAAAC,EAAK,QAAAC,EAAS,iBAAAC,CAAgB,KAAQ,CAC5D,MAAO,CAAC,GAAGH,CAAG,+BAA+B,EAC7C,MAAO,CACL,wBAAyB,CACvB,QACA,CACE,SAAUC,EAAI,IAAKG,IAAW,CAC5B,MAAO,CAACA,EAAO,GAAGA,CAAK,IAAI,EAC3B,QAAAF,EACA,GAAIC,IAAqB,IAAQ,CAAE,iBAAkB,EAAI,GACzD,MAIR,CACJ,CAhBgBP,EAAAE,EAAA,qBA8BV,SAAUO,EAAyBN,EAAyB,CAChE,OAAOA,EAAK,IAAI,CAAC,CAAE,IAAAC,EAAK,IAAAC,EAAK,QAAAC,CAAO,KAAQ,CAC1C,MAAO,CAAC,GAAGF,CAAG,+BAA+B,EAC7C,MAAO,CACL,uBAAwB,CACtB,QACA,GAAGC,EAAI,IAAKK,IAAe,CACzB,SAAU,0DAA0DA,EAAU,WAAW,IAAK,OAAO,OAAO,CAAC,KAC7G,QAAS,uFAAuFA,CAAS,kEAAkEJ,CAAO,IAClL,KAGN,CACJ,CAbgBN,EAAAS,EAAA",
6
+ "names": ["DEFAULT_PROJECT_DIRS", "layerBans", "scope", "at", "__name", "name", "restrictedImports", "bans", "dir", "ban", "message", "allowTypeImports", "group", "restrictedDynamicImports", "specifier"]
7
7
  }
@@ -1 +1 @@
1
- {"version":3,"file":"eslint.d.ts","sourceRoot":"","sources":["../src/eslint.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkDG;AASH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAEpD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAA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O,EAAE,qBAAqB,GAAG,UAAU,CAAC,WAAW,CA4H3F"}
package/dist/eslint.js CHANGED
@@ -1 +1 @@
1
- import t from"globals";import r from"typescript-eslint";import p from"eslint-plugin-unicorn";import{configs as f}from"eslint-plugin-sonarjs";import g from"eslint-plugin-regexp";import l from"eslint-config-prettier";import d from"eslint-plugin-prettier";import{DEFAULT_PROJECT_DIRS as u,layerBans as x,restrictedDynamicImports as j,restrictedImports as R}from"./eslint-boundaries.js";import{SONARJS_RULES as S,TEST_RULES as b,TYPESCRIPT_RULES as C,UNICORN_RULES as E}from"./eslint-rules.js";function y(s){return s}function P(s){return s}function N(s){const{scope:o}=s,i=s.projectDirs??u,n=x(o).filter(a=>i.some(m=>a.dir.startsWith(m))),c=s.extraLayers??[],e=[...n,...c];return r.config({ignores:["eslint.config.mjs","eslint.config.js","scripts/**","worker-configuration.d.ts","local/**","app/dist/**","apps/web/dist/**","apps/*/dist/**","src/generated/**","apps/api/src/generated/**","coverage/**","coverage-integration/**","coverage-web/**","node_modules/**",...s.extraIgnores??[]]},{files:["**/*.{js,mjs,cjs,ts,mts,cts,tsx,jsx}"],languageOptions:{globals:t.node}},{files:["**/*.{ts,mts,cts,tsx}"],extends:r.configs.recommendedTypeChecked,languageOptions:{parserOptions:{projectService:!0,tsconfigRootDir:s.tsconfigRootDir??process.cwd()}}},{files:["**/*.{ts,mts,cts,tsx}"],rules:C},p.configs["flat/recommended"],{rules:E},f.recommended,{rules:S},g.configs["flat/recommended"],l,{plugins:{prettier:d},rules:{"prettier/prettier":"error"}},...R(e),...j(e),{files:["apps/web/**/*.{ts,tsx,js,jsx,mts,cts,mjs,cjs}"],languageOptions:{globals:{...t.node,...t.browser}}},{files:["test/**/*.{ts,tsx,mts,cts}","**/*.test.{ts,tsx,mts,cts}","**/*.spec.{ts,tsx,mts,cts}"],rules:b})}export{N as defineRepoLintConfig};
1
+ var f=Object.defineProperty;var t=(s,e)=>f(s,"name",{value:e,configurable:!0});import r from"globals";import i from"typescript-eslint";import g from"eslint-plugin-unicorn";import{configs as l}from"eslint-plugin-sonarjs";import d from"eslint-plugin-regexp";import u from"eslint-config-prettier";import x from"eslint-plugin-prettier";import{DEFAULT_PROJECT_DIRS as j,layerBans as R,restrictedDynamicImports as S,restrictedImports as b}from"./eslint-boundaries.js";import{SONARJS_RULES as C,TEST_RULES as E,TYPESCRIPT_RULES as D,UNICORN_RULES as L}from"./eslint-rules.js";function h(s){return s}t(h,"asConfig");function k(s){return s}t(k,"asRules");function A(s){const{scope:e}=s,n=s.projectDirs??j,c=R(e).filter(m=>n.some(p=>m.dir.startsWith(p))),a=s.extraLayers??[],o=[...c,...a];return i.config({ignores:["eslint.config.mjs","eslint.config.js","scripts/**","worker-configuration.d.ts","local/**","app/dist/**","apps/web/dist/**","apps/*/dist/**","src/generated/**","apps/api/src/generated/**","coverage/**","coverage-integration/**","coverage-web/**","node_modules/**",...s.extraIgnores??[]]},{files:["**/*.{js,mjs,cjs,ts,mts,cts,tsx,jsx}"],languageOptions:{globals:r.node}},{files:["**/*.{ts,mts,cts,tsx}"],extends:i.configs.recommendedTypeChecked,languageOptions:{parserOptions:{projectService:!0,tsconfigRootDir:s.tsconfigRootDir??process.cwd()}}},{files:["**/*.{ts,mts,cts,tsx}"],rules:D},g.configs["flat/recommended"],l.recommended,{rules:L},{rules:C},d.configs["flat/recommended"],u,{plugins:{prettier:x},rules:{"prettier/prettier":"error"}},...b(o),...S(o),{files:["apps/web/**/*.{ts,tsx,js,jsx,mts,cts,mjs,cjs}"],languageOptions:{globals:{...r.node,...r.browser}}},{files:["test/**/*.{ts,tsx,mts,cts}","**/*.test.{ts,tsx,mts,cts}","**/*.spec.{ts,tsx,mts,cts}"],rules:E})}t(A,"defineRepoLintConfig");export{A as defineRepoLintConfig};
@@ -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 { 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 workspace directories the layered boundary rules are scoped to, as repo-\n * relative globs. Defaults to the canonical layout the nine repos share.\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 { scope } = options;\n const projectDirs = options.projectDirs ?? DEFAULT_PROJECT_DIRS;\n const canonical = layerBans(scope).filter((layer) => projectDirs.some((dir) => layer.dir.startsWith(dir)));\n const extra = options.extraLayers ?? [];\n const bans = [...canonical, ...extra];\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: modern JS/TS quality rules ---\n asConfig(unicorn.configs['flat/recommended']),\n {\n rules: asRules(UNICORN_RULES),\n },\n\n // --- SonarJS: code smell and bug detection ---\n asConfig(sonarjsConfigs.recommended),\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 // --- 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: ['apps/web/**/*.{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": "AAoDA,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,iBAAAC,EAAe,cAAAC,EAAY,oBAAAC,EAAkB,iBAAAC,MAAqB,oBAwD3E,SAASC,EAASC,EAAmB,CACnC,OAAOA,CACT,CAYA,SAASC,EAAQC,EAAwC,CACvD,OAAOA,CACT,CAaM,SAAUC,EAAqBC,EAA8B,CACjE,KAAM,CAAE,MAAAC,CAAK,EAAKD,EACZE,EAAcF,EAAQ,aAAeb,EACrCgB,EAAYf,EAAUa,CAAK,EAAE,OAAQG,GAAUF,EAAY,KAAMG,GAAQD,EAAM,IAAI,WAAWC,CAAG,CAAC,CAAC,EACnGC,EAAQN,EAAQ,aAAe,CAAA,EAC/BO,EAAO,CAAC,GAAGJ,EAAW,GAAGG,CAAK,EAEpC,OAAOzB,EAAS,OACd,CACE,QAAS,CACP,oBACA,mBACA,aACA,4BACA,WACA,cACA,mBACA,iBACA,mBACA,4BACA,cACA,0BACA,kBACA,kBACA,GAAImB,EAAQ,cAAgB,CAAA,IAQhC,CACE,MAAO,CAAC,sCAAsC,EAC9C,gBAAiB,CACf,QAASpB,EAAQ,OAKrB,CACE,MAAO,CAAC,uBAAuB,EAC/B,QAASC,EAAS,QAAQ,uBAC1B,gBAAiB,CACf,cAAe,CACb,eAAgB,GAChB,gBAAiBmB,EAAQ,iBAAmB,QAAQ,IAAG,KAM7D,CACE,MAAO,CAAC,uBAAuB,EAC/B,MAAeP,GAIRX,EAAQ,QAAQ,kBAAkB,EAC3C,CACE,MAAeY,GAIRX,EAAe,YACxB,CACE,MAAeQ,GAIRP,EAAa,QAAQ,kBAAkB,EASvCC,EACT,CACE,QAAS,CAAE,SAAAC,CAAQ,EACnB,MAAO,CACL,oBAAqB,UAKzB,GAAGI,EAAkBiB,CAAI,EACzB,GAAGlB,EAAyBkB,CAAI,EAShC,CACE,MAAO,CAAC,+CAA+C,EACvD,gBAAiB,CACf,QAAS,CAAE,GAAG3B,EAAQ,KAAM,GAAGA,EAAQ,OAAO,IAQlD,CACE,MAAO,CAAC,6BAA8B,6BAA8B,4BAA4B,EAChG,MAAeY,EAChB,CAEL",
6
- "names": ["globals", "tseslint", "unicorn", "sonarjsConfigs", "pluginRegexp", "eslintConfigPrettier", "prettier", "DEFAULT_PROJECT_DIRS", "layerBans", "restrictedDynamicImports", "restrictedImports", "SONARJS_RULES", "TEST_RULES", "TYPESCRIPT_RULES", "UNICORN_RULES", "asConfig", "config", "asRules", "block", "defineRepoLintConfig", "options", "scope", "projectDirs", "canonical", "layer", "dir", "extra", "bans"]
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 { 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 workspace directories the layered boundary rules are scoped to, as repo-\n * relative globs. Defaults to the canonical layout the nine repos share.\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 { scope } = options;\n const projectDirs = options.projectDirs ?? DEFAULT_PROJECT_DIRS;\n const canonical = layerBans(scope).filter((layer) => projectDirs.some((dir) => layer.dir.startsWith(dir)));\n const extra = options.extraLayers ?? [];\n const bans = [...canonical, ...extra];\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 asConfig(unicorn.configs['flat/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 // --- 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: ['apps/web/**/*.{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,iBAAAC,EAAe,cAAAC,EAAY,oBAAAC,EAAkB,iBAAAC,MAAqB,oBAwD3E,SAASC,EAASC,EAAmB,CACnC,OAAOA,CACT,CAFSC,EAAAF,EAAA,YAcT,SAASG,EAAQC,EAAwC,CACvD,OAAOA,CACT,CAFSF,EAAAC,EAAA,WAeH,SAAUE,EAAqBC,EAA8B,CACjE,KAAM,CAAE,MAAAC,CAAK,EAAKD,EACZE,EAAcF,EAAQ,aAAed,EACrCiB,EAAYhB,EAAUc,CAAK,EAAE,OAAQG,GAAUF,EAAY,KAAMG,GAAQD,EAAM,IAAI,WAAWC,CAAG,CAAC,CAAC,EACnGC,EAAQN,EAAQ,aAAe,CAAA,EAC/BO,EAAO,CAAC,GAAGJ,EAAW,GAAGG,CAAK,EAEpC,OAAO1B,EAAS,OACd,CACE,QAAS,CACP,oBACA,mBACA,aACA,4BACA,WACA,cACA,mBACA,iBACA,mBACA,4BACA,cACA,0BACA,kBACA,kBACA,GAAIoB,EAAQ,cAAgB,CAAA,IAQhC,CACE,MAAO,CAAC,sCAAsC,EAC9C,gBAAiB,CACf,QAASrB,EAAQ,OAKrB,CACE,MAAO,CAAC,uBAAuB,EAC/B,QAASC,EAAS,QAAQ,uBAC1B,gBAAiB,CACf,cAAe,CACb,eAAgB,GAChB,gBAAiBoB,EAAQ,iBAAmB,QAAQ,IAAG,KAM7D,CACE,MAAO,CAAC,uBAAuB,EAC/B,MAAeR,GAcRX,EAAQ,QAAQ,kBAAkB,EAClCC,EAAe,YACxB,CACE,MAAeW,GAIjB,CACE,MAAeH,GAIRP,EAAa,QAAQ,kBAAkB,EASvCC,EACT,CACE,QAAS,CAAE,SAAAC,CAAQ,EACnB,MAAO,CACL,oBAAqB,UAKzB,GAAGI,EAAkBkB,CAAI,EACzB,GAAGnB,EAAyBmB,CAAI,EAShC,CACE,MAAO,CAAC,+CAA+C,EACvD,gBAAiB,CACf,QAAS,CAAE,GAAG5B,EAAQ,KAAM,GAAGA,EAAQ,OAAO,IAQlD,CACE,MAAO,CAAC,6BAA8B,6BAA8B,4BAA4B,EAChG,MAAeY,EAChB,CAEL,CA5HgBK,EAAAG,EAAA",
6
+ "names": ["globals", "tseslint", "unicorn", "sonarjsConfigs", "pluginRegexp", "eslintConfigPrettier", "prettier", "DEFAULT_PROJECT_DIRS", "layerBans", "restrictedDynamicImports", "restrictedImports", "SONARJS_RULES", "TEST_RULES", "TYPESCRIPT_RULES", "UNICORN_RULES", "asConfig", "config", "__name", "asRules", "block", "defineRepoLintConfig", "options", "scope", "projectDirs", "canonical", "layer", "dir", "extra", "bans"]
7
7
  }
@@ -1 +1 @@
1
- const s=["connection","keep-alive","proxy-authenticate","proxy-authorization","te","trailer","transfer-encoding","upgrade","X-Forwarded-For","X-Forwarded-Host","X-Forwarded-Proto","X-Forwarded-Uri","Forwarded","True-Client-IP","X-Real-Ip"],h="CF-Connecting-IP";function l(n={}){const a=n.forwardClientIp??!0;return async({request:e,env:c})=>{const o=new URL(e.url),r=new Headers(e.headers);for(const t of s)r.delete(t);if(r.set("X-Forwarded-Host",o.host),r.set("X-Forwarded-Proto",o.protocol.replace(":","")),r.set("X-Forwarded-Uri",`${o.pathname}${o.search}`),a){const t=e.headers.get(h);t&&r.set("X-Forwarded-For",t)}const d=e.method!=="GET"&&e.method!=="HEAD",i=new Request(o.href,{method:e.method,headers:r,body:d?e.body:void 0,...d&&{duplex:"half"},redirect:e.redirect});return c.API_WORKER.fetch(i)}}export{l as createPagesProxy};
1
+ var h=Object.defineProperty;var c=(d,n)=>h(d,"name",{value:n,configurable:!0});const l=["connection","keep-alive","proxy-authenticate","proxy-authorization","te","trailer","transfer-encoding","upgrade","X-Forwarded-For","X-Forwarded-Host","X-Forwarded-Proto","X-Forwarded-Uri","Forwarded","True-Client-IP","X-Real-Ip"],p="CF-Connecting-IP";function F(d={}){const n=d.forwardClientIp??!0;return async({request:e,env:i})=>{const o=new URL(e.url),r=new Headers(e.headers);for(const t of l)r.delete(t);if(r.set("X-Forwarded-Host",o.host),r.set("X-Forwarded-Proto",o.protocol.replace(":","")),r.set("X-Forwarded-Uri",`${o.pathname}${o.search}`),n){const t=e.headers.get(p);t&&r.set("X-Forwarded-For",t)}const a=e.method!=="GET"&&e.method!=="HEAD",s=new Request(o.href,{method:e.method,headers:r,body:a?e.body:void 0,...a&&{duplex:"half"},redirect:e.redirect});return i.API_WORKER.fetch(s)}}c(F,"createPagesProxy");export{F as createPagesProxy};
@@ -2,6 +2,6 @@
2
2
  "version": 3,
3
3
  "sources": ["../../src/functions/pages-proxy.ts"],
4
4
  "sourcesContent": ["/**\n * The Cloudflare Pages catch-all proxy.\n *\n * Provenance: the `functions/[[path]].ts` shim duplicated in Durable-DAV,\n * Mail-Meow and Edge-Git (and present in nine repos in total). Each copy is an\n * `onRequest` handler that forwards the request to the API worker through a\n * service binding, rewriting the three headers the worker routes on.\n *\n * What each source contributes:\n *\n * - **Durable-DAV / Edge-Git** — the core shape: set `X-Forwarded-Host`,\n * `X-Forwarded-Proto` and `X-Forwarded-Uri` from the original URL, forward the\n * body for non-GET/HEAD methods, and hand the request to `env.API_WORKER`.\n * - **Mail-Meow** — the hop-by-hop header strip, and the decision to *always*\n * delete `X-Forwarded-For` before conditionally setting it from\n * `CF-Connecting-IP`. Setting it only when the header was present left a\n * caller-supplied value intact on any request that reached Pages without\n * `CF-Connecting-IP`, so the origin would trust an attacker-chosen client IP.\n * - **Durable-DAV-Router** — `duplex: 'half'`, required whenever the forwarded\n * body is a stream. Without it this threw a `TypeError` on every non-GET\n * request rather than proxying it.\n * - **Edge-Sonic** — the client-forwarding-header strip list, which additionally\n * removes `Forwarded`, `True-Client-IP` and `X-Real-Ip`. Edge-Sonic goes\n * further and *never* sets `X-Forwarded-For` at all, because its worker keys\n * the rate limiter on `CF-Connecting-IP` and refuses `X-Forwarded-For` on\n * purpose.\n *\n * ### The convergence decision on `X-Forwarded-For`\n *\n * The two families disagree, and the disagreement is about which worker is\n * behind the binding. Mail-Meow's behaviour is kept as the default because it is\n * the only one that preserves the client IP for the audit trail, which five repos\n * read. A repo whose worker refuses the header — Edge-Sonic's — passes\n * `forwardClientIp: false`, which deletes it and sets nothing. What is *not*\n * available is the source repos' conditional `if (clientIp) set(...)`: that is\n * the defect Mail-Meow recorded fixing, and a factory that could reintroduce it\n * would be a factory that carries the bug forward.\n *\n * ### `duplex: 'half'` rides with the body\n *\n * Required by the Fetch spec whenever a `Request` is constructed with a **stream**\n * body. workerd does not throw without it, which is why the line was absent from\n * every Pages copy — and Node does, which is why `test/pages-proxy.test.ts` in\n * Edge-Sonic could not drive the handler at all. It is spread only where a body\n * is forwarded, because a `RequestInit` carrying `duplex` and no body is a shape\n * no runtime documents; the cast is `as RequestInit` either way, since `duplex`\n * is not in the DOM lib's type.\n *\n * The result is a handler factory, so a consumer's `functions/[[path]].ts` is a\n * one-line re-export. Structural `Fetcher` and `PagesFunction` types are declared\n * here rather than imported from `@cloudflare/workers-types`, so the kit stays\n * zero-dependency and this module typechecks without the generated\n * `worker-configuration.d.ts`.\n */\n\n/**\n * The subset of Cloudflare's `Fetcher` this proxy uses.\n *\n * Structural, not imported: the shim only ever calls `fetch`, and requiring\n * `@cloudflare/workers-types` for one method would couple the kit to a generated\n * types file that only exists inside a Wrangler project.\n */\nexport interface Fetcher {\n fetch(input: string | URL | Request, init?: RequestInit): Promise<Response>;\n}\n\n/**\n * The environment a Pages Function is invoked with.\n */\nexport interface PagesProxyEnv {\n readonly API_WORKER: Fetcher;\n}\n\n/**\n * The context Cloudflare passes to `onRequest`.\n *\n * Only the fields this proxy reads are declared. `params` and `waitUntil` are\n * omitted because the catch-all does not use them — a shim that named them would\n * be claiming a contract it does not exercise.\n */\nexport interface PagesFunctionContext {\n readonly request: Request;\n readonly env: PagesProxyEnv;\n}\n\n/**\n * A Pages Function handler.\n */\nexport type PagesFunction = (context: PagesFunctionContext) => Promise<Response>;\n\n/**\n * Headers a *client* may have set, stripped before the request crosses the\n * binding.\n *\n * These describe the connection between the client and the proxy. Forwarding\n * them would let the origin believe the proxy's view of the client is the\n * client's own claim about itself. The three the proxy sets itself are set from\n * values it reads off the request, not from the client's headers.\n */\nconst CLIENT_FORWARDING_HEADERS: readonly string[] = [\n 'connection',\n 'keep-alive',\n 'proxy-authenticate',\n 'proxy-authorization',\n 'te',\n 'trailer',\n 'transfer-encoding',\n 'upgrade',\n 'X-Forwarded-For',\n 'X-Forwarded-Host',\n 'X-Forwarded-Proto',\n 'X-Forwarded-Uri',\n 'Forwarded',\n 'True-Client-IP',\n 'X-Real-Ip',\n];\n\n/**\nThe header Cloudflare sets with the socket's peer address.\n*/\nconst CF_CONNECTING_IP_HEADER = 'CF-Connecting-IP';\n\n/**\n * What `createPagesProxy` accepts.\n */\nexport interface PagesProxyOptions {\n /**\n * Set `X-Forwarded-For` from `CF-Connecting-IP`.\n *\n * Default `true` — Mail-Meow's behaviour, which five repos rely on for their\n * audit trail. Pass `false` for a worker that refuses the header outright\n * (Edge-Sonic's does), and the header is deleted and nothing set.\n */\n readonly forwardClientIp?: boolean;\n}\n\n/**\n * The `onRequest` handler for `functions/[[path]].ts`.\n *\n * Usage — the consumer's `functions/[[path]].ts` becomes two lines:\n *\n * ```ts\n * import { createPagesProxy } from '@rexezuge/tooling/functions/pages-proxy';\n * export const onRequest = createPagesProxy();\n * ```\n *\n * @param options see {@link PagesProxyOptions}. Omitted gives the family's\n * majority behaviour.\n */\nexport function createPagesProxy(options: PagesProxyOptions = {}): PagesFunction {\n const forwardClientIp = options.forwardClientIp ?? true;\n\n return async ({ request, env }: PagesFunctionContext): Promise<Response> => {\n const originalUrl: URL = new URL(request.url);\n\n const headers: Headers = new Headers(request.headers);\n for (const header of CLIENT_FORWARDING_HEADERS) headers.delete(header);\n\n // Set from values read off the request rather than from the client: only the\n // proxy knows which host it served, and a service binding hands over a\n // rewritten URL, so the original path is what has to be carried across.\n headers.set('X-Forwarded-Host', originalUrl.host);\n headers.set('X-Forwarded-Proto', originalUrl.protocol.replace(':', ''));\n headers.set('X-Forwarded-Uri', `${originalUrl.pathname}${originalUrl.search}`);\n\n if (forwardClientIp) {\n const clientIp: string | null = request.headers.get(CF_CONNECTING_IP_HEADER);\n if (clientIp) headers.set('X-Forwarded-For', clientIp);\n }\n\n // `GET`/`HEAD` carry no body, and a `Request` with one is rejected outright\n // for those methods. The body is forwarded as a *stream*, so a large upload\n // does not have to fit in memory on the Pages side.\n const hasBody: boolean = request.method !== 'GET' && request.method !== 'HEAD';\n\n const proxyRequest: Request = new Request(originalUrl.href, {\n method: request.method,\n headers,\n body: hasBody ? request.body : undefined,\n // See the header: `duplex` is not in the DOM lib's `RequestInit` type, and\n // removing the cast would mean not forwarding bodies at all, which is a\n // worse answer than one assertion.\n ...(hasBody && { duplex: 'half' }),\n redirect: request.redirect,\n });\n\n return env.API_WORKER.fetch(proxyRequest);\n };\n}\n"],
5
- "mappings": "AAmGA,MAAMA,EAA+C,CACnD,aACA,aACA,qBACA,sBACA,KACA,UACA,oBACA,UACA,kBACA,mBACA,oBACA,kBACA,YACA,iBACA,aAMIC,EAA0B,mBA6B1B,SAAUC,EAAiBC,EAA6B,CAAA,EAAE,CAC9D,MAAMC,EAAkBD,EAAQ,iBAAmB,GAEnD,MAAO,OAAO,CAAE,QAAAE,EAAS,IAAAC,CAAG,IAA+C,CACzE,MAAMC,EAAmB,IAAI,IAAIF,EAAQ,GAAG,EAEtCG,EAAmB,IAAI,QAAQH,EAAQ,OAAO,EACpD,UAAWI,KAAUT,EAA2BQ,EAAQ,OAAOC,CAAM,EASrE,GAJAD,EAAQ,IAAI,mBAAoBD,EAAY,IAAI,EAChDC,EAAQ,IAAI,oBAAqBD,EAAY,SAAS,QAAQ,IAAK,EAAE,CAAC,EACtEC,EAAQ,IAAI,kBAAmB,GAAGD,EAAY,QAAQ,GAAGA,EAAY,MAAM,EAAE,EAEzEH,EAAiB,CACnB,MAAMM,EAA0BL,EAAQ,QAAQ,IAAIJ,CAAuB,EACvES,GAAUF,EAAQ,IAAI,kBAAmBE,CAAQ,CACvD,CAKA,MAAMC,EAAmBN,EAAQ,SAAW,OAASA,EAAQ,SAAW,OAElEO,EAAwB,IAAI,QAAQL,EAAY,KAAM,CAC1D,OAAQF,EAAQ,OAChB,QAAAG,EACA,KAAMG,EAAUN,EAAQ,KAAO,OAI/B,GAAIM,GAAW,CAAE,OAAQ,MAAM,EAC/B,SAAUN,EAAQ,SACnB,EAED,OAAOC,EAAI,WAAW,MAAMM,CAAY,CAC1C,CACF",
6
- "names": ["CLIENT_FORWARDING_HEADERS", "CF_CONNECTING_IP_HEADER", "createPagesProxy", "options", "forwardClientIp", "request", "env", "originalUrl", "headers", "header", "clientIp", "hasBody", "proxyRequest"]
5
+ "mappings": "+EAmGA,MAAMA,EAA+C,CACnD,aACA,aACA,qBACA,sBACA,KACA,UACA,oBACA,UACA,kBACA,mBACA,oBACA,kBACA,YACA,iBACA,aAMIC,EAA0B,mBA6B1B,SAAUC,EAAiBC,EAA6B,CAAA,EAAE,CAC9D,MAAMC,EAAkBD,EAAQ,iBAAmB,GAEnD,MAAO,OAAO,CAAE,QAAAE,EAAS,IAAAC,CAAG,IAA+C,CACzE,MAAMC,EAAmB,IAAI,IAAIF,EAAQ,GAAG,EAEtCG,EAAmB,IAAI,QAAQH,EAAQ,OAAO,EACpD,UAAWI,KAAUT,EAA2BQ,EAAQ,OAAOC,CAAM,EASrE,GAJAD,EAAQ,IAAI,mBAAoBD,EAAY,IAAI,EAChDC,EAAQ,IAAI,oBAAqBD,EAAY,SAAS,QAAQ,IAAK,EAAE,CAAC,EACtEC,EAAQ,IAAI,kBAAmB,GAAGD,EAAY,QAAQ,GAAGA,EAAY,MAAM,EAAE,EAEzEH,EAAiB,CACnB,MAAMM,EAA0BL,EAAQ,QAAQ,IAAIJ,CAAuB,EACvES,GAAUF,EAAQ,IAAI,kBAAmBE,CAAQ,CACvD,CAKA,MAAMC,EAAmBN,EAAQ,SAAW,OAASA,EAAQ,SAAW,OAElEO,EAAwB,IAAI,QAAQL,EAAY,KAAM,CAC1D,OAAQF,EAAQ,OAChB,QAAAG,EACA,KAAMG,EAAUN,EAAQ,KAAO,OAI/B,GAAIM,GAAW,CAAE,OAAQ,MAAM,EAC/B,SAAUN,EAAQ,SACnB,EAED,OAAOC,EAAI,WAAW,MAAMM,CAAY,CAC1C,CACF,CAvCgBC,EAAAX,EAAA",
6
+ "names": ["CLIENT_FORWARDING_HEADERS", "CF_CONNECTING_IP_HEADER", "createPagesProxy", "options", "forwardClientIp", "request", "env", "originalUrl", "headers", "header", "clientIp", "hasBody", "proxyRequest", "__name"]
7
7
  }
@@ -1 +1 @@
1
- import{DEFAULT_UUID as i}from"../wrangler-config/types.js";function s(n){const a=n.d1_databases?.[0],t=a?.binding?.trim();if(t===void 0||t==="")throw new Error("No d1_databases entry with a binding found in wrangler.jsonc.");const e=a?.database_id?.trim()??"";if(e===i)throw new Error(`D1 database_id for ${t} is still the template placeholder. The database does not exist yet, so there is nothing to back up.`);const r=a?.database_name?.trim()||t;return{binding:t,databaseId:e,target:r}}export{s as resolveD1Target};
1
+ var o=Object.defineProperty;var r=(e,t)=>o(e,"name",{value:t,configurable:!0});import{DEFAULT_UUID as s}from"../wrangler-config/types.js";function c(e){const t=e.d1_databases?.[0],a=t?.binding?.trim();if(a===void 0||a==="")throw new Error("No d1_databases entry with a binding found in wrangler.jsonc.");const n=t?.database_id?.trim()??"";if(n===s)throw new Error(`D1 database_id for ${a} is still the template placeholder. The database does not exist yet, so there is nothing to back up.`);const i=t?.database_name?.trim()||a;return{binding:a,databaseId:n,target:i}}r(c,"resolveD1Target");export{c as resolveD1Target};
@@ -2,6 +2,6 @@
2
2
  "version": 3,
3
3
  "sources": ["../../../src/scripts/backup/d1-target.ts"],
4
4
  "sourcesContent": ["/**\n * Choosing which D1 database the backup workflow exports.\n *\n * Provenance: ported from Edge-Sonic's `scripts/backup/d1-target.ts`. Pure, so the\n * empty-database guard is asserted without running Actions or touching a real\n * account.\n */\n\nimport { DEFAULT_UUID } from '../wrangler-config/types.ts';\n\n/**\nA D1 binding as a parsed wrangler config carries one.\n*/\nexport interface D1DatabaseBinding {\n binding?: string;\n database_id?: string;\n database_name?: string;\n}\n\n/**\nThe resolved export target.\n*/\nexport interface D1Target {\n /**\n The binding name, used for log output and as the export fallback.\n */\n binding: string;\n /**\n The database id, verified against Cloudflare by the caller.\n */\n databaseId: string;\n /**\n What `wrangler d1 export` should be pointed at.\n */\n target: string;\n}\n\n/**\n * Pick the export target from a parsed wrangler config.\n *\n * `wrangler d1 export` takes a database *name*, so `database_name` wins when\n * present. Hand-written configs that omit it fall back to the binding name.\n *\n * @throws when there is no binding, or when `database_id` is still the template\n * placeholder — meaning the database was auto-provisioned and holds no data.\n */\nexport function resolveD1Target(config: { d1_databases?: D1DatabaseBinding[] }): D1Target {\n const database = config.d1_databases?.[0];\n\n const binding = database?.binding?.trim();\n if (binding === undefined || binding === '') {\n throw new Error('No d1_databases entry with a binding found in wrangler.jsonc.');\n }\n\n const databaseId = database?.database_id?.trim() ?? '';\n if (databaseId === DEFAULT_UUID) {\n throw new Error(\n `D1 database_id for ${binding} is still the template placeholder. The database does not exist yet, so there is nothing to back up.`,\n );\n }\n\n const target = database?.database_name?.trim() || binding;\n return { binding, databaseId, target };\n}\n"],
5
- "mappings": "AAQA,OAAS,gBAAAA,MAAoB,8BAsCvB,SAAUC,EAAgBC,EAA8C,CAC5E,MAAMC,EAAWD,EAAO,eAAe,CAAC,EAElCE,EAAUD,GAAU,SAAS,KAAI,EACvC,GAAIC,IAAY,QAAaA,IAAY,GACvC,MAAM,IAAI,MAAM,+DAA+D,EAGjF,MAAMC,EAAaF,GAAU,aAAa,KAAI,GAAM,GACpD,GAAIE,IAAeL,EACjB,MAAM,IAAI,MACR,sBAAsBI,CAAO,sGAAsG,EAIvI,MAAME,EAASH,GAAU,eAAe,KAAI,GAAMC,EAClD,MAAO,CAAE,QAAAA,EAAS,WAAAC,EAAY,OAAAC,CAAM,CACtC",
6
- "names": ["DEFAULT_UUID", "resolveD1Target", "config", "database", "binding", "databaseId", "target"]
5
+ "mappings": "+EAQA,OAAS,gBAAAA,MAAoB,8BAsCvB,SAAUC,EAAgBC,EAA8C,CAC5E,MAAMC,EAAWD,EAAO,eAAe,CAAC,EAElCE,EAAUD,GAAU,SAAS,KAAI,EACvC,GAAIC,IAAY,QAAaA,IAAY,GACvC,MAAM,IAAI,MAAM,+DAA+D,EAGjF,MAAMC,EAAaF,GAAU,aAAa,KAAI,GAAM,GACpD,GAAIE,IAAeL,EACjB,MAAM,IAAI,MACR,sBAAsBI,CAAO,sGAAsG,EAIvI,MAAME,EAASH,GAAU,eAAe,KAAI,GAAMC,EAClD,MAAO,CAAE,QAAAA,EAAS,WAAAC,EAAY,OAAAC,CAAM,CACtC,CAjBgBC,EAAAN,EAAA",
6
+ "names": ["DEFAULT_UUID", "resolveD1Target", "config", "database", "binding", "databaseId", "target", "__name"]
7
7
  }
@@ -1 +1 @@
1
- function s(t){return typeof t=="string"&&t.trim().length>0}function r(t){const o=s(t.CLOUDFLARE_API_TOKEN)&&s(t.CLOUDFLARE_ACCOUNT_ID),n=s(t.BACKUP_ENCRYPTION_KEY),E=s(t.S3_ACCESS_KEY_ID)&&s(t.S3_SECRET_ACCESS_KEY)&&s(t.S3_BUCKET),_=s(t.WEBDAV_URL)&&s(t.WEBDAV_USER)&&s(t.WEBDAV_PASSWORD),e=E||_,i=[];return e&&(o||i.push("A backup destination is configured but CLOUDFLARE_API_TOKEN / CLOUDFLARE_ACCOUNT_ID are missing."),n||i.push("BACKUP_ENCRYPTION_KEY is required. The D1 dump holds AES-GCM-obfuscated credentials \u2014 obfuscation that, by its own design, assumes the dump is not in hand \u2014 plus every user history and the full schema topology.")),{cloudflare:o,encryption:n,anyDestination:e,s3:E,webdav:_,errors:i}}export{r as evaluateConfig};
1
+ var C=Object.defineProperty;var n=(t,i)=>C(t,"name",{value:i,configurable:!0});function s(t){return typeof t=="string"&&t.trim().length>0}n(s,"isSet");function A(t){const i=s(t.CLOUDFLARE_API_TOKEN)&&s(t.CLOUDFLARE_ACCOUNT_ID),E=s(t.BACKUP_ENCRYPTION_KEY),_=s(t.S3_ACCESS_KEY_ID)&&s(t.S3_SECRET_ACCESS_KEY)&&s(t.S3_BUCKET),e=s(t.WEBDAV_URL)&&s(t.WEBDAV_USER)&&s(t.WEBDAV_PASSWORD),r=_||e,o=[];return r&&(i||o.push("A backup destination is configured but CLOUDFLARE_API_TOKEN / CLOUDFLARE_ACCOUNT_ID are missing."),E||o.push("BACKUP_ENCRYPTION_KEY is required. The D1 dump holds AES-GCM-obfuscated credentials \u2014 obfuscation that, by its own design, assumes the dump is not in hand \u2014 plus every user history and the full schema topology.")),{cloudflare:i,encryption:E,anyDestination:r,s3:_,webdav:e,errors:o}}n(A,"evaluateConfig");export{A as evaluateConfig};
@@ -2,6 +2,6 @@
2
2
  "version": 3,
3
3
  "sources": ["../../../src/scripts/backup/destination-config.ts"],
4
4
  "sourcesContent": ["/**\n * Destination and encryption policy for the D1 backup workflow.\n *\n * Provenance: ported from Edge-Sonic's `scripts/backup/destination-config.ts`.\n * Pure and side-effect free, so the fail-closed rules are asserted without running\n * Actions.\n */\n\n/**\nThe environment the `check-secrets` job is given, as repository secrets.\n*/\nexport interface BackupSecretEnvironment {\n CLOUDFLARE_API_TOKEN?: string;\n CLOUDFLARE_ACCOUNT_ID?: string;\n BACKUP_ENCRYPTION_KEY?: string;\n S3_ACCESS_KEY_ID?: string;\n S3_SECRET_ACCESS_KEY?: string;\n S3_BUCKET?: string;\n WEBDAV_URL?: string;\n WEBDAV_USER?: string;\n WEBDAV_PASSWORD?: string;\n}\n\n/**\nWhat is configured, and why the run cannot proceed when it is not.\n*/\nexport interface DestinationConfig {\n /**\n Cloudflare credentials present, so the export job can run.\n */\n cloudflare: boolean;\n /**\n An encryption passphrase is available.\n */\n encryption: boolean;\n /**\n At least one upload destination is configured.\n */\n anyDestination: boolean;\n /**\n The S3 destination is fully configured.\n */\n s3: boolean;\n /**\n The WebDAV destination is fully configured.\n */\n webdav: boolean;\n /**\n Human-readable reasons the run cannot proceed, empty when it can.\n */\n errors: string[];\n}\n\n/**\nA secret counts as set only when it has non-whitespace content.\n*/\nfunction isSet(value: string | undefined): boolean {\n return typeof value === 'string' && value.trim().length > 0;\n}\n\n/**\n * Decides which destinations are configured and enforces fail-closed encryption.\n *\n * ### Why the encryption requirement is not optional here\n *\n * Two independent reasons, and they have different consequences so both are stated.\n *\n * **The at-rest protection assumes the dump is not in hand.** Every repo in this\n * family seals credentials with AES-256-GCM, and each one's migration notes say the\n * same thing: *obfuscation against a D1 dump, not protection against a full worker\n * compromise.* An unencrypted backup inverts that assumption — dump plus the\n * Secrets Store key is a complete credential set, and the WebDAV key is read on\n * every scan and every stream.\n *\n * **The dump is a listening history.** Stars, ratings, play counts, play queues and\n * auth failures record what each user does and when, and the schema records the\n * full topology and every file path. None of that is credential material, and all\n * of it is nobody else's to read.\n *\n * `S3_REGION` is deliberately not part of the S3 gate. R2 and MinIO have no\n * meaningful region — Cloudflare documents an R2 bucket's region as `auto`, with\n * empty and `us-east-1` both aliasing to it — so requiring the secret would\n * silently disable backups for anyone using such a provider. The upload script\n * defaults `AWS_DEFAULT_REGION` to `auto` instead.\n */\nexport function evaluateConfig(env: BackupSecretEnvironment): DestinationConfig {\n const cloudflare = isSet(env.CLOUDFLARE_API_TOKEN) && isSet(env.CLOUDFLARE_ACCOUNT_ID);\n const encryption = isSet(env.BACKUP_ENCRYPTION_KEY);\n const s3 = isSet(env.S3_ACCESS_KEY_ID) && isSet(env.S3_SECRET_ACCESS_KEY) && isSet(env.S3_BUCKET);\n const webdav = isSet(env.WEBDAV_URL) && isSet(env.WEBDAV_USER) && isSet(env.WEBDAV_PASSWORD);\n const anyDestination = s3 || webdav;\n\n const errors: string[] = [];\n\n // Fail closed, but only once someone has opted into a destination. An\n // unconfigured repository is a legitimate \"I do not want off-site backups\" state\n // and must not turn the schedule red.\n if (anyDestination) {\n if (!cloudflare) {\n errors.push('A backup destination is configured but CLOUDFLARE_API_TOKEN / CLOUDFLARE_ACCOUNT_ID are missing.');\n }\n if (!encryption) {\n errors.push(\n 'BACKUP_ENCRYPTION_KEY is required. The D1 dump holds AES-GCM-obfuscated credentials — obfuscation that, by its own design, assumes the dump is not in hand — plus every user history and the full schema topology.',\n );\n }\n }\n\n return { cloudflare, encryption, anyDestination, s3, webdav, errors };\n}\n"],
5
- "mappings": "AAwDA,SAASA,EAAMC,EAAyB,CACtC,OAAO,OAAOA,GAAU,UAAYA,EAAM,KAAI,EAAG,OAAS,CAC5D,CA2BM,SAAUC,EAAeC,EAA4B,CACzD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C,EAAQ,OAAAE,CAAM,CACrE,CAxBgBR,EAAAC,EAAA",
6
+ "names": ["isSet", "value", "__name", "evaluateConfig", "env", "cloudflare", "encryption", "s3", "webdav", "anyDestination", "errors"]
7
7
  }
@@ -1 +1 @@
1
- const r="backup_prod_";function n(e){const t=e.toISOString();return`${t.slice(0,10)}_${t.slice(11,19).replaceAll(":","-")}`}function o(e){return`${r}${n(e)}.sql.xz.enc`}function i(e,t){return new Date(e.getTime()-t*24*60*60*1e3).toISOString().slice(0,10)}function c(){const e=process.env.BACKUP_RETENTION_DAYS,t=Number(e);if(!Number.isFinite(t)||t<=0)throw new Error(`BACKUP_RETENTION_DAYS must be a positive number, got ${JSON.stringify(e)}.`);return t}export{r as BACKUP_FILE_PREFIX,o as backupFileName,n as backupStamp,c as requireRetentionDays,i as retentionCutoff};
1
+ var n=Object.defineProperty;var r=(e,t)=>n(e,"name",{value:t,configurable:!0});const o="backup_prod_";function i(e){const t=e.toISOString();return`${t.slice(0,10)}_${t.slice(11,19).replaceAll(":","-")}`}r(i,"backupStamp");function s(e){return`${o}${i(e)}.sql.xz.enc`}r(s,"backupFileName");function u(e,t){return new Date(e.getTime()-t*24*60*60*1e3).toISOString().slice(0,10)}r(u,"retentionCutoff");function p(){const e=process.env.BACKUP_RETENTION_DAYS,t=Number(e);if(!Number.isFinite(t)||t<=0)throw new Error(`BACKUP_RETENTION_DAYS must be a positive number, got ${JSON.stringify(e)}.`);return t}r(p,"requireRetentionDays");export{o as BACKUP_FILE_PREFIX,s as backupFileName,i as backupStamp,p as requireRetentionDays,u as retentionCutoff};
@@ -2,6 +2,6 @@
2
2
  "version": 3,
3
3
  "sources": ["../../../src/scripts/backup/naming.ts"],
4
4
  "sourcesContent": ["/**\n * Backup artifact naming and retention-window handling.\n *\n * Provenance: Edge-Sonic's `scripts/backup/naming.ts` and `retention.ts`,\n * converged into one module because the two answer the same question from either\n * side — what a file is called, and which of them are still worth keeping — and a\n * consumer only ever imports one.\n */\n\n/**\n * The filename prefix.\n *\n * Exported rather than inlined, because the workflow uploads with\n * `<prefix>_*.sql.xz.enc` and `if-no-files-found: error`. That glob and this prefix\n * are one fact written in two places — the failure mode being a rename here that\n * silently stops every upload while each upload job still reports success, since\n * the upload jobs skip on `needs` rather than failing.\n */\nexport const BACKUP_FILE_PREFIX = 'backup_prod_';\n\n/**\n * `2026-10-01_04-15-00` — sortable, filename-safe, and UTC.\n *\n * UTC rather than local: a retention window computed across a DST boundary is one\n * day wide in one direction, and a backup pruned a day early is a backup that was\n * never needed.\n */\nexport function backupStamp(date: Date): string {\n const iso = date.toISOString();\n return `${iso.slice(0, 10)}_${iso.slice(11, 19).replaceAll(':', '-')}`;\n}\n\n/**\nThe full artifact name: `<prefix><stamp>.sql.xz.enc`.\n*/\nexport function backupFileName(date: Date): string {\n return `${BACKUP_FILE_PREFIX}${backupStamp(date)}.sql.xz.enc`;\n}\n\n/**\n * `YYYY-MM-DD`, `days` before `now`.\n */\nexport function retentionCutoff(now: Date, days: number): string {\n return new Date(now.getTime() - days * 24 * 60 * 60 * 1000).toISOString().slice(0, 10);\n}\n\n/**\n * Read `BACKUP_RETENTION_DAYS` from the environment, rejecting bad values.\n *\n * Rejected rather than defaulted: silently falling back would either prune\n * everything or keep backups forever, and both are worse than a failed run that\n * names the problem.\n *\n * `Number()` rather than `parseInt()`: `parseInt('30d')` yields 30, which would\n * silently accept a mistyped value and prune against the wrong window.\n */\nexport function requireRetentionDays(): number {\n const raw = process.env['BACKUP_RETENTION_DAYS'];\n const days = Number(raw);\n if (!Number.isFinite(days) || days <= 0) {\n throw new Error(`BACKUP_RETENTION_DAYS must be a positive number, got ${JSON.stringify(raw)}.`);\n }\n return days;\n}\n"],
5
- "mappings": "AAkBO,MAAMA,EAAqB,eAS5B,SAAUC,EAAYC,EAAU,CACpC,MAAMC,EAAMD,EAAK,YAAW,EAC5B,MAAO,GAAGC,EAAI,MAAM,EAAG,EAAE,CAAC,IAAIA,EAAI,MAAM,GAAI,EAAE,EAAE,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AM,IAAI,MAAM,wDAAwD,KAAK,UAAUE,CAAG,CAAC,GAAG,EAEhG,OAAOF,CACT,CAPgBJ,EAAAK,EAAA",
6
+ "names": ["BACKUP_FILE_PREFIX", "backupStamp", "date", "iso", "__name", "backupFileName", "retentionCutoff", "now", "days", "requireRetentionDays", "raw"]
7
7
  }
@@ -1,2 +1,2 @@
1
- import{readdirSync as m,readFileSync as p,statSync as w}from"node:fs";import{pathToFileURL as S}from"node:url";import f from"node:path";import{fail as $}from"./lib/github-actions.js";import{isSet as v,parseFlags as j,splitPositional as _,valueOf as g}from"./lib/cli-args.js";const x=300,E=400,O=new Set(["node_modules","dist",".wrangler","coverage","coverage-integration","coverage-web",".git"]),y=/\.(?:ts|tsx|js|mjs|cjs|css)$/,I=["test","spec"].flatMap(t=>[".ts",".tsx",".js",".jsx",".mjs",".cjs"].map(s=>`.${t}${s}`));function L(t){return/(?:^|\/)(?:locales|generated)\//.test(t)||/(?:^|\/)__(?:tests|mocks)__(?:\/|$)/.test(t)||/(?:^|\/)scripts\//.test(t)||/(?:^|\/)(?:test|tests|__tests__)\//.test(t)||/\.config\.(?:m?[jt]s|cjs)$/.test(t)||t.endsWith(".d.ts")||t.endsWith(".json")||t.endsWith(".sql")||t.endsWith(".md")?!0:I.some(s=>t.endsWith(s))}function T(t,s){return s.some(e=>e.endsWith("/")?t.startsWith(e):t===e)}function W(t){const s=[],e=o=>{for(const r of m(o)){const n=f.join(o,r);let i;try{i=w(n)}catch{continue}if(i.isDirectory()){if(O.has(r))continue;e(n)}else y.test(r)&&s.push(f.relative(t,n))}};return e(t),s}function k(t){const s=t.soft??x,e=t.hard??E,o=t.allowlist??[],r=W(t.root).filter(l=>!L(l)),n=[],i=[];for(const l of r){const a=p(f.join(t.root,l),"utf8").split(`
2
- `).length;if(a<=s)continue;const h={file:l,lines:a,level:a>e?"critical":"warn"};T(l,o)?i.push(h):n.push(h)}n.sort((l,a)=>a.lines-l.lines),i.sort((l,a)=>a.lines-l.lines);const c=n.filter(l=>l.level==="critical"),d=t.failOnHard!==!0||c.length===0,u=d?`God-file check passed (${r.length} files, ${n.length} over soft limit ${s}, ${i.length} allowlisted).`:`God-file check failed: ${c.length} file(s) exceed ${e} LOC. Split them, or add them to the allowlist in the same commit that grows them.`;return{findings:n,allowlisted:i,scanned:r.length,passed:d,reported:u}}function A(t){let s;try{s=p(t,"utf8")}catch{return[]}let e;try{e=JSON.parse(s)}catch(o){throw new Error(`${t} is not valid JSON: ${o instanceof Error?o.message:String(o)}`,{cause:o})}if(!Array.isArray(e)||e.some(o=>typeof o!="string"))throw new Error(`${t} must be a JSON array of repo-relative path strings.`);return e}function F(t=process.argv.slice(2)){const{positional:s,rest:e}=_(t,["root","allowlist"]),o=j(e,{value:["root","allowlist"],boolean:["fail-on-hard"]}),r=g(o,"root")??s[0]??".",n=g(o,"allowlist")??f.join(r,"scripts/god-files.allowlist.json"),i=k({root:r,allowlist:A(n),failOnHard:v(o,"fail-on-hard")});console.log(i.reported);for(const c of i.findings)console.log(`${c.level==="critical"?"CRITICAL":"WARN"} ${c.lines} ${c.file}`);for(const c of i.allowlisted)console.log(`ALLOWLISTED ${c.lines} ${c.file}`);return i.passed||$(`God-file check failed: run with --root ${r} to see the report.`),0}process.argv[1]!==void 0&&import.meta.url===S(process.argv[1]).href&&process.exit(F(process.argv.slice(2)));export{E as HARD_LIMIT,x as SOFT_LIMIT,k as checkGodFiles,F as checkGodFilesCli,T as isAllowlisted,A as readAllowlist,L as shouldSkip,W as walk};
1
+ var w=Object.defineProperty;var a=(t,s)=>w(t,"name",{value:s,configurable:!0});import{readdirSync as S,readFileSync as g,statSync as $}from"node:fs";import{pathToFileURL as v}from"node:url";import d from"node:path";import{fail as j}from"./lib/github-actions.js";import{isSet as _,parseFlags as x,splitPositional as E,valueOf as u}from"./lib/cli-args.js";const O=300,y=400,I=new Set(["node_modules","dist",".wrangler","coverage","coverage-integration","coverage-web",".git"]),L=/\.(?:ts|tsx|js|mjs|cjs|css)$/,T=["test","spec"].flatMap(t=>[".ts",".tsx",".js",".jsx",".mjs",".cjs"].map(s=>`.${t}${s}`));function W(t){return/(?:^|\/)(?:locales|generated)\//.test(t)||/(?:^|\/)__(?:tests|mocks)__(?:\/|$)/.test(t)||/(?:^|\/)scripts\//.test(t)||/(?:^|\/)(?:test|tests|__tests__)\//.test(t)||/\.config\.(?:m?[jt]s|cjs)$/.test(t)||t.endsWith(".d.ts")||t.endsWith(".json")||t.endsWith(".sql")||t.endsWith(".md")?!0:T.some(s=>t.endsWith(s))}a(W,"shouldSkip");function k(t,s){return s.some(e=>e.endsWith("/")?t.startsWith(e):t===e)}a(k,"isAllowlisted");function A(t){const s=[],e=a(o=>{for(const r of S(o)){const n=d.join(o,r);let i;try{i=$(n)}catch{continue}if(i.isDirectory()){if(I.has(r))continue;e(n)}else L.test(r)&&s.push(d.relative(t,n))}},"visit");return e(t),s}a(A,"walk");function F(t){const s=t.soft??O,e=t.hard??y,o=t.allowlist??[],r=A(t.root).filter(l=>!W(l)),n=[],i=[];for(const l of r){const f=g(d.join(t.root,l),"utf8").split(`
2
+ `).length;if(f<=s)continue;const p={file:l,lines:f,level:f>e?"critical":"warn"};k(l,o)?i.push(p):n.push(p)}n.sort((l,f)=>f.lines-l.lines),i.sort((l,f)=>f.lines-l.lines);const c=n.filter(l=>l.level==="critical"),h=t.failOnHard!==!0||c.length===0,m=h?`God-file check passed (${r.length} files, ${n.length} over soft limit ${s}, ${i.length} allowlisted).`:`God-file check failed: ${c.length} file(s) exceed ${e} LOC. Split them, or add them to the allowlist in the same commit that grows them.`;return{findings:n,allowlisted:i,scanned:r.length,passed:h,reported:m}}a(F,"checkGodFiles");function C(t){let s;try{s=g(t,"utf8")}catch{return[]}let e;try{e=JSON.parse(s)}catch(o){throw new Error(`${t} is not valid JSON: ${o instanceof Error?o.message:String(o)}`,{cause:o})}if(!Array.isArray(e)||e.some(o=>typeof o!="string"))throw new Error(`${t} must be a JSON array of repo-relative path strings.`);return e}a(C,"readAllowlist");function N(t=process.argv.slice(2)){const{positional:s,rest:e}=E(t,["root","allowlist"]),o=x(e,{value:["root","allowlist"],boolean:["fail-on-hard"]}),r=u(o,"root")??s[0]??".",n=u(o,"allowlist")??d.join(r,"scripts/god-files.allowlist.json"),i=F({root:r,allowlist:C(n),failOnHard:_(o,"fail-on-hard")});console.log(i.reported);for(const c of i.findings)console.log(`${c.level==="critical"?"CRITICAL":"WARN"} ${c.lines} ${c.file}`);for(const c of i.allowlisted)console.log(`ALLOWLISTED ${c.lines} ${c.file}`);return i.passed||j(`God-file check failed: run with --root ${r} to see the report.`),0}a(N,"checkGodFilesCli"),process.argv[1]!==void 0&&import.meta.url===v(process.argv[1]).href&&process.exit(N(process.argv.slice(2)));export{y as HARD_LIMIT,O as SOFT_LIMIT,F as checkGodFiles,N as checkGodFilesCli,k as isAllowlisted,C as readAllowlist,W as shouldSkip,A as walk};
@@ -2,6 +2,6 @@
2
2
  "version": 3,
3
3
  "sources": ["../../src/scripts/check-god-files.ts"],
4
4
  "sourcesContent": ["/**\n * The rules behind `scripts/check-god-files.ts`.\n *\n * Provenance: converged from the seven `.mjs` copies (AWS-AccessBridge,\n * CalDAV-Bridge, ChordDHT-Tracker, Durable-DAV, Durable-DAV-Router, Edge-Git,\n * Mail-Meow, Mail-Otter) and the typed ratchet in Edge-Sonic.\n *\n * All seven `.mjs` copies are one script with two constants: soft 300 (warn),\n * hard 400 (error). The typed variant is not a different rule so much as a\n * different answer to \"what does the gate enforce\", and that is the decision this\n * module has to take once for the whole family.\n *\n * ### The convergence: warn-only, with an allowlist\n *\n * The two source designs:\n *\n * - **Ceiling** (six repos) — 300 warn, 400 error, `exit 1` on 400. Durable-DAV's\n * own `AGENTS.md` records what that measures: **ten** files sit just over 300\n * and none is a god file, so `WARN` reports every run and `HARD` has never\n * fired. A ceiling set above the largest file in the tree cannot tell a\n * repository getting worse from one that never got better, and raising it is\n * always available.\n * - **Ratchet** (Edge-Sonic) — a committed baseline records every file's size; a\n * file may shrink freely and grow only to its recorded size. It cannot be\n * satisfied by raising a number, which is its whole strength.\n *\n * The ratchet is the better *rule*, and the ceiling is the better *gate*: the\n * ratchet needs a baseline maintained per file and fails the first time somebody\n * writes a legitimate 320-line module, which is the failure mode that trains\n * everyone to ignore a report. So the converged script keeps the 300/400\n * thresholds — every repo's CI already prints them — and makes the verdict\n * **warn-only by default**, with two escape valves that are both visible in a\n * diff:\n *\n * 1. `--fail-on-hard` turns the 400 line back into a failing gate, for a repo\n * that has paid its debt and wants the ceiling enforced.\n * 2. An **allowlist** records the files that are over the line and known, so the\n * report names only the ones that are *new*. That is the ratchet's\n * \"recorded size\" idea without its per-file bookkeeping: the allowlist is\n * reviewed by the same commit that grows the file, because the diff shows what\n * was added to it.\n *\n * Tests are excluded, as every source does. A double modelling the platform grows\n * with the platform's surface, not with the complexity of the code it stands in\n * for — Edge-Sonic's ratchet holds them too, and its own notes record a 4,343-line\n * fixture, so this is a documented disagreement rather than an oversight.\n */\n\nimport { readdirSync, readFileSync, statSync } from 'node:fs';\nimport { pathToFileURL } from 'node:url';\nimport path from 'node:path';\nimport { fail } from './lib/github-actions.ts';\nimport { isSet, parseFlags, splitPositional, valueOf } from './lib/cli-args.ts';\n\n/**\n * A file past a size the guard reports on.\n */\nexport interface GodFileFinding {\n /**\n Path relative to the root the check ran against.\n */\n readonly file: string;\n /**\n Lines it has.\n */\n readonly lines: number;\n /**\n `warn` past the soft limit, `critical` past the hard one.\n */\n readonly level: 'warn' | 'critical';\n}\n\n/**\n * The outcome of one run.\n */\nexport interface GodFileReport {\n /**\n Files over a limit, worst first, minus the allowlisted.\n */\n readonly findings: readonly GodFileFinding[];\n /**\n How many files the walk measured.\n */\n readonly scanned: number;\n /**\n Allowlisted files that are over a limit — reported, never counted.\n */\n readonly allowlisted: readonly GodFileFinding[];\n /**\n * Whether the tree may be committed as it stands.\n *\n * `true` in warn-only mode, which is the default; a `critical` finding fails\n * only when the caller asked for the gate.\n */\n readonly passed: boolean;\n /**\n The message to print, either way.\n */\n readonly reported: string;\n}\n\n/**\n * What `checkGodFiles` accepts.\n */\nexport interface GodFileOptions {\n /**\n Directory to walk.\n */\n readonly root: string;\n /**\n * Repo-relative paths (or directory prefixes ending in `/`) exempt from the\n * report. Defaults to `god-files.allowlist.json` beside the caller's script\n * when that file exists — see `readAllowlist`.\n */\n readonly allowlist?: readonly string[];\n /**\n Soft limit, past which a file is reported as `warn`.\n */\n readonly soft?: number;\n /**\n Hard limit, past which a file is reported as `critical`.\n */\n readonly hard?: number;\n /**\n Make a `critical` finding fail the run.\n */\n readonly failOnHard?: boolean;\n}\n\n/**\nDefault soft limit, as every source repo uses.\n*/\nexport const SOFT_LIMIT = 300;\n/**\nDefault hard limit, as every source repo uses.\n*/\nexport const HARD_LIMIT = 400;\n\n/**\n * Directories the walker never enters.\n *\n * Build output and VCS state; `coverage` is here because a generated HTML report\n * is thousands of \"lines\" of nothing.\n */\nconst EXCLUDE_DIRS = new Set(['node_modules', 'dist', '.wrangler', 'coverage', 'coverage-integration', 'coverage-web', '.git']);\n\n/**\n * Source extensions the guard counts.\n *\n * `css` is in the set because every source repo counts it, and a 400-line\n * stylesheet is the same reading problem as a 400-line module.\n */\nconst SOURCE_EXTENSIONS = /\\.(?:ts|tsx|js|mjs|cjs|css)$/;\n\n/**\n * The test-file suffixes the guard skips.\n *\n * `.test.tsx` matter as much as `.test.ts`: the walker collects both, so a list\n * that only named the `.ts` forms let every React test file through the guard and\n * reported them as god files — which is how Durable-DAV-Router discovered it.\n * Built from the kinds and extensions rather than enumerated, so a new test\n * extension cannot silently escape.\n */\nconst TEST_SUFFIXES: readonly string[] = ['test', 'spec'].flatMap((kind) =>\n ['.ts', '.tsx', '.js', '.jsx', '.mjs', '.cjs'].map((ext) => `.${kind}${ext}`),\n);\n\n/**\n * Whether a repo-relative path is exempt from the guard.\n *\n * Provenance: AWS-AccessBridge's version is the canonical one, because it\n * documents and fixes two live bugs in the others.\n *\n * Every directory pattern is anchored with `(?:^|/)` rather than a bare leading\n * `/`. `relative()` yields `test/helpers/x.ts` for a top-level test directory and\n * `scripts/lib/x.ts` for the scripts directory — **no leading separator** — so a\n * pattern written as `/\\/(?:test|tests|__tests__)\\//` never matches either one.\n * It looks right, it does match when handed an absolute path, and against these\n * layouts it is silently a no-op. Durable-DAV and ChordDHT-Tracker ship exactly\n * that dead pattern.\n */\nexport function shouldSkip(rel: string): boolean {\n if (\n /(?:^|\\/)(?:locales|generated)\\//.test(rel) ||\n /(?:^|\\/)__(?:tests|mocks)__(?:\\/|$)/.test(rel) ||\n /(?:^|\\/)scripts\\//.test(rel) ||\n /(?:^|\\/)(?:test|tests|__tests__)\\//.test(rel) ||\n /\\.config\\.(?:m?[jt]s|cjs)$/.test(rel) ||\n rel.endsWith('.d.ts') ||\n rel.endsWith('.json') ||\n rel.endsWith('.sql') ||\n rel.endsWith('.md')\n )\n return true;\n return TEST_SUFFIXES.some((suffix) => rel.endsWith(suffix));\n}\n\n/**\n * Whether a repo-relative path is on the allowlist.\n *\n * An entry ending in `/` exempts a whole directory; any other entry is matched\n * exactly, so `apps/api/src/index.ts` does not exempt `apps/api/src/index.util.ts`.\n */\nexport function isAllowlisted(rel: string, allowlist: readonly string[]): boolean {\n return allowlist.some((entry) => (entry.endsWith('/') ? rel.startsWith(entry) : rel === entry));\n}\n\n/**\n * Every source file under `root`, as repo-relative paths.\n *\n * Symlink-safe: a dangling symlink or a file removed mid-walk is skipped rather\n * than thrown, because neither is a god-file problem.\n */\nexport function walk(root: string): string[] {\n const out: string[] = [];\n const visit = (dir: string): void => {\n for (const entry of readdirSync(dir)) {\n const full = path.join(dir, entry);\n let stat;\n try {\n stat = statSync(full);\n } catch {\n continue;\n }\n if (stat.isDirectory()) {\n if (EXCLUDE_DIRS.has(entry)) continue;\n visit(full);\n } else if (SOURCE_EXTENSIONS.test(entry)) {\n out.push(path.relative(root, full));\n }\n }\n };\n visit(root);\n return out;\n}\n\n/**\n * Run the guard over a tree.\n *\n * Pure with respect to the verdict — the only I/O is the walk and a line count —\n * so a test drives it against a temporary directory.\n */\nexport function checkGodFiles(options: GodFileOptions): GodFileReport {\n const soft = options.soft ?? SOFT_LIMIT;\n const hard = options.hard ?? HARD_LIMIT;\n const allowlist = options.allowlist ?? [];\n\n const scanned = walk(options.root).filter((rel) => !shouldSkip(rel));\n const findings: GodFileFinding[] = [];\n const allowlisted: GodFileFinding[] = [];\n\n for (const rel of scanned) {\n const lines = readFileSync(path.join(options.root, rel), 'utf8').split('\\n').length;\n if (lines <= soft) continue;\n const finding: GodFileFinding = { file: rel, lines, level: lines > hard ? 'critical' : 'warn' };\n if (isAllowlisted(rel, allowlist)) {\n allowlisted.push(finding);\n } else {\n findings.push(finding);\n }\n }\n\n findings.sort((left, right) => right.lines - left.lines);\n allowlisted.sort((left, right) => right.lines - left.lines);\n\n const critical = findings.filter((finding) => finding.level === 'critical');\n const passed = options.failOnHard !== true || critical.length === 0;\n\n const reported = passed\n ? `God-file check passed (${scanned.length} files, ${findings.length} over soft limit ${soft}, ${allowlisted.length} allowlisted).`\n : `God-file check failed: ${critical.length} file(s) exceed ${hard} LOC. Split them, or add them to the allowlist in the same commit that grows them.`;\n\n return { findings, allowlisted, scanned: scanned.length, passed, reported };\n}\n\n/**\n * Read an allowlist file, or `[]` when it is absent.\n *\n * The file is `scripts/god-files.allowlist.json`: a JSON array of repo-relative\n * paths. Absence is the normal case for a repo with no known offenders, so it is\n * not an error — a guard that fails on a first run nobody has filled in yet is a\n * guard that gets disabled.\n *\n * A malformed file is an error rather than an empty list, because \"the allowlist\n * is empty\" silently un-reports every known offender.\n */\nexport function readAllowlist(file: string): string[] {\n let raw: string;\n try {\n raw = readFileSync(file, 'utf8');\n } catch {\n return [];\n }\n let parsed: unknown;\n try {\n parsed = JSON.parse(raw);\n } catch (error: unknown) {\n throw new Error(`${file} is not valid JSON: ${error instanceof Error ? error.message : String(error)}`, { cause: error });\n }\n if (!Array.isArray(parsed) || parsed.some((entry) => typeof entry !== 'string')) {\n throw new Error(`${file} must be a JSON array of repo-relative path strings.`);\n }\n return parsed as string[];\n}\n\n/**\n * CLI entry: `checkGodFilesCli(['.', '--fail-on-hard'])`.\n *\n * The directory is a positional argument **or** `--root <dir>`, because every other\n * script in this tree takes its target positionally and a gate that has to be\n * invoked one way in one script and another way in the next is a gate somebody\n * invokes wrong. A second positional is an error.\n *\n * Flags (see FlagSpec): `--root <dir>` (default `.`), `--allowlist <file>`\n * (default `scripts/god-files.allowlist.json` beside the root, absent = none),\n * `--fail-on-hard` (default off, matching every source repo's warn-only gate).\n * Returns 0 unless `--fail-on-hard` is set and a critical file is found.\n */\nexport function checkGodFilesCli(argv: readonly string[] = process.argv.slice(2)): number {\n // Split before parsing, because parseFlags rejects anything that is not a declared\n // flag and a positional directory is neither a mistake nor a flag.\n const { positional, rest } = splitPositional(argv, ['root', 'allowlist']);\n const flags = parseFlags(rest, {\n value: ['root', 'allowlist'],\n boolean: ['fail-on-hard'],\n });\n const root = valueOf(flags, 'root') ?? positional[0] ?? '.';\n const allowlistPath = valueOf(flags, 'allowlist') ?? path.join(root, 'scripts/god-files.allowlist.json');\n const report = checkGodFiles({\n root,\n allowlist: readAllowlist(allowlistPath),\n failOnHard: isSet(flags, 'fail-on-hard'),\n });\n console.log(report.reported);\n for (const finding of report.findings) {\n console.log(`${finding.level === 'critical' ? 'CRITICAL' : 'WARN'} ${finding.lines} ${finding.file}`);\n }\n for (const finding of report.allowlisted) {\n console.log(`ALLOWLISTED ${finding.lines} ${finding.file}`);\n }\n if (!report.passed) {\n fail(`God-file check failed: run with --root ${root} to see the report.`);\n }\n return 0;\n}\n\n// Run only when this file is the entrypoint.\n//\n// The rules above are pure and the tests import them directly, so a module-level\n// call would shell out (and exit) during a test run. The URL comparison rather than\n// an unconditional call is the same guard Durable-DAV's init-secrets.ts uses, and\n// it is what keeps the rule modules importable — which is the whole reason they are\n// separate modules in the first place.\nif (process.argv[1] !== undefined && import.meta.url === pathToFileURL(process.argv[1]).href) {\n process.exit(checkGodFilesCli(process.argv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AAWA,KAAWiB,EAAO,YAC3B,QAAQ,IAAI,eAAejB,EAAQ,KAAK,IAAIA,EAAQ,IAAI,EAAE,EAE5D,OAAKiB,EAAO,QACVlD,EAAK,0CAA0CmB,CAAI,qBAAqB,EAEnE,CACT,CASI,QAAQ,KAAK,CAAC,IAAM,QAAa,YAAY,MAAQrB,EAAc,QAAQ,KAAK,CAAC,CAAC,EAAE,MACtF,QAAQ,KAAK8C,EAAiB,QAAQ,KAAK,MAAM,CAAC,CAAC,CAAC",
6
- "names": ["readdirSync", "readFileSync", "statSync", "pathToFileURL", "path", "fail", "isSet", "parseFlags", "splitPositional", "valueOf", "SOFT_LIMIT", "HARD_LIMIT", "EXCLUDE_DIRS", "SOURCE_EXTENSIONS", "TEST_SUFFIXES", "kind", "ext", "shouldSkip", "rel", "suffix", "isAllowlisted", "allowlist", "entry", "walk", "root", "out", "visit", "dir", "full", "stat", "checkGodFiles", "options", "soft", "hard", "scanned", "findings", "allowlisted", "lines", "finding", "left", "right", "critical", "passed", "reported", "readAllowlist", "file", "raw", "parsed", "error", "checkGodFilesCli", "argv", "positional", "rest", "flags", "allowlistPath", "report"]
5
+ "mappings": "+EAgDA,OAAS,eAAAA,EAAa,gBAAAC,EAAc,YAAAC,MAAgB,UACpD,OAAS,iBAAAC,MAAqB,WAC9B,OAAOC,MAAU,YACjB,OAAS,QAAAC,MAAY,0BACrB,OAAS,SAAAC,EAAO,cAAAC,EAAY,mBAAAC,EAAiB,WAAAC,MAAe,oBAgFrD,MAAMC,EAAa,IAIbC,EAAa,IAQpBC,EAAe,IAAI,IAAI,CAAC,eAAgB,OAAQ,YAAa,WAAY,uBAAwB,eAAgB,MAAM,CAAC,EAQxHC,EAAoB,+BAWpBC,EAAmC,CAAC,OAAQ,MAAM,EAAE,QAASC,GACjE,CAAC,MAAO,OAAQ,MAAO,OAAQ,OAAQ,MAAM,EAAE,IAAKC,GAAQ,IAAID,CAAI,GAAGC,CAAG,EAAE,CAAC,EAiBzE,SAAUC,E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"isSet", "parseFlags", "splitPositional", "valueOf", "SOFT_LIMIT", "HARD_LIMIT", "EXCLUDE_DIRS", "SOURCE_EXTENSIONS", "TEST_SUFFIXES", "kind", "ext", "shouldSkip", "rel", "suffix", "__name", "isAllowlisted", "allowlist", "entry", "walk", "root", "out", "visit", "dir", "full", "stat", "checkGodFiles", "options", "soft", "hard", "scanned", "findings", "allowlisted", "lines", "finding", "left", "right", "critical", "passed", "reported", "readAllowlist", "file", "raw", "parsed", "error", "checkGodFilesCli", "argv", "positional", "rest", "flags", "allowlistPath", "report"]
7
7
  }
@@ -1,3 +1,3 @@
1
1
  #!/usr/bin/env tsx
2
- import{execFileSync as l}from"node:child_process";import{existsSync as d,readFileSync as g}from"node:fs";import{parse as u}from"jsonc-parser";import{fail as p}from"./lib/github-actions.js";import{isEmptySecretsStoreListing as m,parseWranglerNames as y}from"./lib/wrangler-table.js";import{CONFIG_PATH as c}from"./wrangler-config/types.js";const w="-encryption-key",h="-signing-secret";async function S(){const e=await crypto.subtle.generateKey({name:"AES-GCM",length:256},!0,["encrypt","decrypt"]),r=await crypto.subtle.exportKey("raw",e);let n="";for(const t of new Uint8Array(r))n+=String.fromCodePoint(t);return btoa(n)}function E(){let e="";for(const r of crypto.getRandomValues(new Uint8Array(32)))e+=r.toString(16).padStart(2,"0");return Promise.resolve(e)}function a(e){if(e.endsWith(w))return S;if(e.endsWith(h))return E;throw new Error(`Unknown secret: ${e}. Name it '*-encryption-key' for a generated 32-byte AES-GCM key, or '*-signing-secret' for 32 random bytes, and teach this script the shape if neither fits.`)}function b(e){try{return a(e),!0}catch{return!1}}function f(e,r){try{return l("pnpm",["exec","wrangler",...e],{encoding:"utf8",stdio:[r===void 0?"ignore":"pipe","pipe","pipe"],...r!==void 0&&{input:r}})}catch(n){const t=n,o=t.stdout?t.stdout.toString():"",s=t.stderr?t.stderr.toString():"";throw new Error(`Command failed: pnpm exec wrangler ${e.join(" ")}
3
- ${o}${s||t.message||""}`)}}function _(){if(!d(c))throw new Error(`${c} not found. Run scripts/prepare-wrangler-config.ts first \u2014 it is what creates the file this script reads.`);const e=u(g(c,"utf8"));if(e.secrets_store_secrets===void 0&&Object.keys(e).length===0)throw new Error(`${c} is empty or not valid JSONC. Run scripts/prepare-wrangler-config.ts to regenerate it.`);return e}function $(e){const r=[];for(const[n,t]of(e.secrets_store_secrets??[]).entries()){const o=t.binding??`index ${n}`,s=t.store_id,i=t.secret_name;if(s===void 0||s===""||i===void 0||i==="")throw new Error(`secrets_store_secrets[${n}] ("${o}") needs both store_id and secret_name; store_id is normally filled in by scripts/prepare-wrangler-config.ts.`);if(!b(i))throw new Error(`No generator for secret "${i}" (binding "${o}").`);r.push({storeId:s,secretName:i})}return r}function C(e){let r;try{r=f(["secrets-store","secret","list",e,"--remote"])}catch(n){if(m(n))return console.log(`Secrets Store ${e} is empty`),new Set;console.warn(`Unable to list secrets in store ${e}:`,n instanceof Error?n.message:"unknown error");return}return y(r)}function x(e,r,n){console.log(`Creating secret: ${r}`),f(["secrets-store","secret","create",e,"--name",r,"--scopes","workers","--remote"],n)}async function N(){console.log("Initializing Cloudflare secrets...");const e=_(),r=$(e);if(r.length===0)throw new Error("wrangler.jsonc declares no secrets_store_secrets entries, so there is nothing to initialize.");const n=new Map;for(const{storeId:t,secretName:o}of r){n.has(t)||n.set(t,C(t));const s=n.get(t);if(s===void 0)throw new Error(`Could not list secrets in store ${t}; refusing to create ${o} without confirming it is absent.`);if(s.has(o)){console.log(`Secret ${o} already exists; leaving it untouched.`);continue}x(t,o,await a(o)()),s.add(o)}console.log("Secret initialization complete")}try{await N()}catch(e){p(e instanceof Error?`Secret initialization failed: ${e.message}`:String(e))}
2
+ var d=Object.defineProperty;var s=(e,r)=>d(e,"name",{value:r,configurable:!0});import{execFileSync as g}from"node:child_process";import{existsSync as u,readFileSync as p}from"node:fs";import{parse as m}from"jsonc-parser";import{fail as y}from"./lib/github-actions.js";import{isEmptySecretsStoreListing as w,parseWranglerNames as h}from"./lib/wrangler-table.js";import{CONFIG_PATH as a}from"./wrangler-config/types.js";const S="-encryption-key",E="-signing-secret";async function b(){const e=await crypto.subtle.generateKey({name:"AES-GCM",length:256},!0,["encrypt","decrypt"]),r=await crypto.subtle.exportKey("raw",e);let n="";for(const t of new Uint8Array(r))n+=String.fromCodePoint(t);return btoa(n)}s(b,"generateAESGCMKey");function _(){let e="";for(const r of crypto.getRandomValues(new Uint8Array(32)))e+=r.toString(16).padStart(2,"0");return Promise.resolve(e)}s(_,"generateSigningSecret");function f(e){if(e.endsWith(S))return b;if(e.endsWith(E))return _;throw new Error(`Unknown secret: ${e}. Name it '*-encryption-key' for a generated 32-byte AES-GCM key, or '*-signing-secret' for 32 random bytes, and teach this script the shape if neither fits.`)}s(f,"generatorFor");function $(e){try{return f(e),!0}catch{return!1}}s($,"canProvisionSecret");function l(e,r){try{return g("pnpm",["exec","wrangler",...e],{encoding:"utf8",stdio:[r===void 0?"ignore":"pipe","pipe","pipe"],...r!==void 0&&{input:r}})}catch(n){const t=n,o=t.stdout?t.stdout.toString():"",i=t.stderr?t.stderr.toString():"";throw new Error(`Command failed: pnpm exec wrangler ${e.join(" ")}
3
+ ${o}${i||t.message||""}`)}}s(l,"wrangler");function C(){if(!u(a))throw new Error(`${a} not found. Run scripts/prepare-wrangler-config.ts first \u2014 it is what creates the file this script reads.`);const e=m(p(a,"utf8"));if(e.secrets_store_secrets===void 0&&Object.keys(e).length===0)throw new Error(`${a} is empty or not valid JSONC. Run scripts/prepare-wrangler-config.ts to regenerate it.`);return e}s(C,"parseWranglerConfig");function x(e){const r=[];for(const[n,t]of(e.secrets_store_secrets??[]).entries()){const o=t.binding??`index ${n}`,i=t.store_id,c=t.secret_name;if(i===void 0||i===""||c===void 0||c==="")throw new Error(`secrets_store_secrets[${n}] ("${o}") needs both store_id and secret_name; store_id is normally filled in by scripts/prepare-wrangler-config.ts.`);if(!$(c))throw new Error(`No generator for secret "${c}" (binding "${o}").`);r.push({storeId:i,secretName:c})}return r}s(x,"planSecrets");function N(e){let r;try{r=l(["secrets-store","secret","list",e,"--remote"])}catch(n){if(w(n))return console.log(`Secrets Store ${e} is empty`),new Set;console.warn(`Unable to list secrets in store ${e}:`,n instanceof Error?n.message:"unknown error");return}return h(r)}s(N,"listSecretNames");function k(e,r,n){console.log(`Creating secret: ${r}`),l(["secrets-store","secret","create",e,"--name",r,"--scopes","workers","--remote"],n)}s(k,"createSecret");async function F(){console.log("Initializing Cloudflare secrets...");const e=C(),r=x(e);if(r.length===0)throw new Error("wrangler.jsonc declares no secrets_store_secrets entries, so there is nothing to initialize.");const n=new Map;for(const{storeId:t,secretName:o}of r){n.has(t)||n.set(t,N(t));const i=n.get(t);if(i===void 0)throw new Error(`Could not list secrets in store ${t}; refusing to create ${o} without confirming it is absent.`);if(i.has(o)){console.log(`Secret ${o} already exists; leaving it untouched.`);continue}k(t,o,await f(o)()),i.add(o)}console.log("Secret initialization complete")}s(F,"main");try{await F()}catch(e){y(e instanceof Error?`Secret initialization failed: ${e.message}`:String(e))}
@@ -2,6 +2,6 @@
2
2
  "version": 3,
3
3
  "sources": ["../../src/scripts/init-secrets.ts"],
4
4
  "sourcesContent": ["#!/usr/bin/env tsx\n/**\n * Create the Secrets Store entries declared in `wrangler.jsonc`, generating a fresh\n * value for each one that does not exist yet.\n *\n * Provenance: Edge-Sonic's `scripts/deploy/init-secrets.ts` and Durable-DAV's\n * `scripts/init-secrets.ts`, converged. Both record the same two defects that hid\n * a broken deploy for a whole release, and both fixes are carried over.\n *\n * ### Why this script exists at all\n *\n * A `secrets_store_secrets` binding fails the deploy unless the named secret\n * already exists inside the named store. Nothing creates it: Cloudflare will not\n * generate a value, and the template cannot carry one. So this script is the only\n * thing standing between a fresh account and a deploy that cannot succeed.\n *\n * ### The two defects that hid a broken deploy\n *\n * **The generator list was stale.** Durable-DAV's copy carried an allowlist of\n * exact names from the repository it was inherited from, all deleted when the repo\n * was renamed, so the very first iteration threw `Unknown secret` and never created\n * anything. So the rule here is the secret's **name shape**, not a list of names:\n * `*-encryption-key` gets a generated AES-GCM key and `*-signing-secret` gets 32\n * random bytes. Adding a secret to the template is then a one-line change needing\n * no matching edit here, which is the property the exact-name list did not have.\n *\n * **The throw was swallowed.** The original ended in `main().catch(console.error)`.\n * `console.error` returns `undefined` and never sets an exit status, so the process\n * exited **0** and CI marked the step green — the failure only surfaced one step\n * later, as an unexplainable `wrangler deploy` failure. Hence: the whole plan is\n * validated **before** any Cloudflare call, and a rejection reaches the runner as\n * a non-zero exit with a workflow annotation.\n *\n * ### Create-if-absent is a correctness property, not laziness\n *\n * An existing secret is left untouched. A replication encryption key seals every\n * remote target's credential; regenerating it on a redeploy would strand them all\n * as undecryptable. Rotation has to be a deliberate act with a re-encrypt path,\n * not a side effect of deploying.\n *\n * Requires a materialized `wrangler.jsonc` — run\n * `scripts/prepare-wrangler-config.ts` first. Fails rather than skipping when the\n * config is missing, because a step reporting \"Secret initialization complete\"\n * having created nothing is worse than a named error.\n */\n\nimport { execFileSync } from 'node:child_process';\nimport { existsSync, readFileSync } from 'node:fs';\nimport { parse } from 'jsonc-parser';\nimport { fail } from './lib/github-actions.ts';\nimport { isEmptySecretsStoreListing, parseWranglerNames } from './lib/wrangler-table.ts';\nimport { CONFIG_PATH, type WranglerConfig } from './wrangler-config/types.ts';\n\n/**\n * The secret names the AES-GCM key generator produces, matched by **shape**.\n *\n * Keyed on the suffix because the alternative is the exact-name map that went\n * stale. See the header: a template naming `*-encryption-key` is then a one-line\n * change with no matching edit here, and a new secret breaks the deploy loudly\n * instead of silently.\n */\nconst ENCRYPTION_KEY_SUFFIX = '-encryption-key';\n\n/**\nThe secret names the random signing secret generator produces.\n*/\nconst SIGNING_SECRET_SUFFIX = '-signing-secret';\n\n/**\nA 256-bit AES-GCM key, base64-encoded — the shape the worker's crypto layer accepts.\n*/\nasync function generateAESGCMKey(): Promise<string> {\n const key = await crypto.subtle.generateKey({ name: 'AES-GCM', length: 256 }, true, ['encrypt', 'decrypt']);\n const exported = await crypto.subtle.exportKey('raw', key);\n // Chunked rather than spread: `String.fromCharCode(...bytes)` passes 32 arguments,\n // which is fine today and is a stack overflow the day the key is longer.\n let binary = '';\n for (const byte of new Uint8Array(exported)) {\n binary += String.fromCodePoint(byte);\n }\n return btoa(binary);\n}\n\n/**\nA 256-bit random signing secret for internal self-calls, hex-encoded.\n*/\nfunction generateSigningSecret(): Promise<string> {\n let hex = '';\n for (const byte of crypto.getRandomValues(new Uint8Array(32))) {\n hex += byte.toString(16).padStart(2, '0');\n }\n return Promise.resolve(hex);\n}\n\n/**\n * The generator for a secret name, chosen by the name's shape.\n *\n * A name matching neither is still refused rather than given a guess: the generator\n * is not the only thing that has to be right, and an unusable value that looks\n * provisioned is worse than a failure.\n */\nfunction generatorFor(secretName: string): () => Promise<string> {\n if (secretName.endsWith(ENCRYPTION_KEY_SUFFIX)) return generateAESGCMKey;\n if (secretName.endsWith(SIGNING_SECRET_SUFFIX)) return generateSigningSecret;\n throw new Error(\n `Unknown secret: ${secretName}. Name it '*-encryption-key' for a generated 32-byte AES-GCM key, ` +\n `or '*-signing-secret' for 32 random bytes, and teach this script the shape if neither fits.`,\n );\n}\n\n/**\nWhether this script can produce a value for `secretName`.\n*/\nfunction canProvisionSecret(secretName: string): boolean {\n try {\n generatorFor(secretName);\n return true;\n } catch {\n return false;\n }\n}\n\n/**\n * Runs a wrangler subcommand, optionally feeding `input` on stdin.\n *\n * Arguments are passed as an argv array rather than interpolated into a shell\n * string, so a value containing shell metacharacters cannot alter the command.\n */\nfunction wrangler(args: readonly string[], input?: string): string {\n try {\n // eslint-disable-next-line sonarjs/no-os-command-from-path\n return execFileSync('pnpm', ['exec', 'wrangler', ...args], {\n encoding: 'utf8',\n stdio: [input === undefined ? 'ignore' : 'pipe', 'pipe', 'pipe'],\n ...(input !== undefined && { input }),\n });\n } catch (error: unknown) {\n const maybeProcessError = error as { stdout?: string | Buffer; stderr?: string | Buffer; message?: string };\n const stdout: string = maybeProcessError.stdout ? maybeProcessError.stdout.toString() : '';\n const stderr: string = maybeProcessError.stderr ? maybeProcessError.stderr.toString() : '';\n throw new Error(`Command failed: pnpm exec wrangler ${args.join(' ')}\\n${stdout}${stderr || maybeProcessError.message || ''}`);\n }\n}\n\nfunction parseWranglerConfig(): WranglerConfig {\n if (!existsSync(CONFIG_PATH)) {\n throw new Error(\n `${CONFIG_PATH} not found. Run scripts/prepare-wrangler-config.ts first — it is what creates the file this script reads.`,\n );\n }\n // `parse` is error-tolerant and returns a partial object, so an empty result means\n // malformed JSON rather than \"no secrets declared\". Treating that as an empty list\n // would report success having created nothing.\n const config = parse(readFileSync(CONFIG_PATH, 'utf8')) as WranglerConfig;\n if (config.secrets_store_secrets === undefined && Object.keys(config).length === 0) {\n throw new Error(`${CONFIG_PATH} is empty or not valid JSONC. Run scripts/prepare-wrangler-config.ts to regenerate it.`);\n }\n return config;\n}\n\n/**\nOne secret to create, as the plan names it.\n*/\ninterface PlannedSecret {\n storeId: string;\n secretName: string;\n}\n\n/**\n * Turn the config's bindings into a validated work list.\n *\n * Every entry is checked *before* the first Cloudflare call, so an\n * unprovisionable secret fails the step in milliseconds instead of after some other\n * secret has already been created.\n */\nfunction planSecrets(config: WranglerConfig): PlannedSecret[] {\n const plan: PlannedSecret[] = [];\n for (const [index, secret] of (config.secrets_store_secrets ?? []).entries()) {\n const label = secret.binding ?? `index ${index}`;\n const storeId = secret.store_id;\n const secretName = secret.secret_name;\n if (storeId === undefined || storeId === '' || secretName === undefined || secretName === '') {\n throw new Error(\n `secrets_store_secrets[${index}] (\"${label}\") needs both store_id and secret_name; ` +\n 'store_id is normally filled in by scripts/prepare-wrangler-config.ts.',\n );\n }\n if (!canProvisionSecret(secretName)) {\n throw new Error(`No generator for secret \"${secretName}\" (binding \"${label}\").`);\n }\n plan.push({ storeId, secretName });\n }\n return plan;\n}\n\n/**\n * List the secret names present in a store.\n *\n * Returns `undefined` when the listing itself failed, which is deliberately\n * distinct from an empty set: a transient CLI failure must not be read as \"the\n * secret is missing\" and cause a duplicate insert over a live value. An empty store\n * *is* a confirmed absence, so it maps to an empty set rather than `undefined`.\n *\n * The name is taken exactly. `output.includes(secretName)` is not a membership test:\n * `my-replication-encryption-key-2` satisfies a search for\n * `my-replication-encryption-key`, so a store holding only the suffixed entry would\n * report the unsuffixed one as already present and it would never be created.\n */\nfunction listSecretNames(storeId: string): Set<string> | undefined {\n let output: string;\n try {\n output = wrangler(['secrets-store', 'secret', 'list', storeId, '--remote']);\n } catch (error: unknown) {\n if (isEmptySecretsStoreListing(error)) {\n console.log(`Secrets Store ${storeId} is empty`);\n return new Set();\n }\n console.warn(`Unable to list secrets in store ${storeId}:`, error instanceof Error ? error.message : 'unknown error');\n return undefined;\n }\n return parseWranglerNames(output);\n}\n\nfunction createSecret(storeId: string, secretName: string, secretValue: string): void {\n console.log(`Creating secret: ${secretName}`);\n // The value goes in on stdin, never as an argv entry: an argv is visible to every\n // process on the runner through `ps`, and the previous\n // `echo \"${value}\" | wrangler … ${name}` also broke on `\"`, `$`, backticks and\n // newlines.\n wrangler(['secrets-store', 'secret', 'create', storeId, '--name', secretName, '--scopes', 'workers', '--remote'], secretValue);\n}\n\nasync function main(): Promise<void> {\n console.log('Initializing Cloudflare secrets...');\n const config = parseWranglerConfig();\n const plan = planSecrets(config);\n\n if (plan.length === 0) {\n throw new Error('wrangler.jsonc declares no secrets_store_secrets entries, so there is nothing to initialize.');\n }\n\n const listedByStore = new Map<string, Set<string> | undefined>();\n\n for (const { storeId, secretName } of plan) {\n if (!listedByStore.has(storeId)) {\n listedByStore.set(storeId, listSecretNames(storeId));\n }\n const existing = listedByStore.get(storeId);\n if (existing === undefined) {\n // Refuse to guess: creating a secret we could not read back risks overwriting\n // a live value with a freshly generated one.\n throw new Error(`Could not list secrets in store ${storeId}; refusing to create ${secretName} without confirming it is absent.`);\n }\n if (existing.has(secretName)) {\n console.log(`Secret ${secretName} already exists; leaving it untouched.`);\n continue;\n }\n createSecret(storeId, secretName, await generatorFor(secretName)());\n existing.add(secretName);\n }\n\n console.log('Secret initialization complete');\n}\n\n// Top-level await rather than `.catch(console.error)`, so a rejected `main` surfaces\n// as a stack trace with its cause intact and the process exits non-zero. Either way\n// the exit status has to be right: this runs in the deploy pipeline, and swallowing\n// the rejection reported a failed key bootstrap as a green step.\ntry {\n await main();\n} catch (error: unknown) {\n fail(error instanceof Error ? `Secret initialization failed: ${error.message}` : String(error));\n}\n"],
5
- "mappings": ";AA8CA,OAAS,gBAAAA,MAAoB,qBAC7B,OAAS,cAAAC,EAAY,gBAAAC,MAAoB,UACzC,OAAS,SAAAC,MAAa,eACtB,OAAS,QAAAC,MAAY,0BACrB,OAAS,8BAAAC,EAA4B,sBAAAC,MAA0B,0BAC/D,OAAS,eAAAC,MAAwC,6BAUjD,MAAMC,EAAwB,kBAKxBC,EAAwB,kBAK9B,eAAeC,GAAiB,CAC9B,MAAMC,EAAM,MAAM,OAAO,OAAO,YAAY,CAAE,KAAM,UAAW,OAAQ,GAAG,EAAI,GAAM,CAAC,UAAW,SAAS,CAAC,EACpGC,EAAW,MAAM,OAAO,OAAO,UAAU,MAAOD,CAAG,EAGzD,IAAIE,EAAS,GACb,UAAWC,KAAQ,IAAI,WAAWF,CAAQ,EACxCC,GAAU,OAAO,cAAcC,CAAI,EAErC,OAAO,KAAKD,CAAM,CACpB,CAKA,SAASE,GAAqB,CAC5B,IAAIC,EAAM,GACV,UAAWF,KAAQ,OAAO,gBAAgB,IAAI,WAAW,EAAE,CAAC,EAC1DE,GAAOF,EAAK,SAAS,EAAE,EAAE,SAAS,EAAG,GAAG,EAE1C,OAAO,QAAQ,QAAQE,CAAG,CAC5B,CASA,SAASC,EAAaC,EAAkB,CACtC,GAAIA,EAAW,SAASV,CAAqB,EAAG,OAAOE,EACvD,GAAIQ,EAAW,SAAST,CAAqB,EAAG,OAAOM,EACvD,MAAM,IAAI,MACR,mBAAmBG,CAAU,+JACkE,CAEnG,CAKA,SAASC,EAAmBD,EAAkB,CAC5C,GAAI,CACF,OAAAD,EAAaC,CAAU,EA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,EAAC,CAAE,EAClEuB,EAAS,IAAIvB,CAAU,CACzB,CAEA,QAAQ,IAAI,gCAAgC,CAC9C,CAMA,GAAI,CACF,MAAMqB,EAAI,CACZ,OAAShB,EAAgB,CACvBnB,EAAKmB,aAAiB,MAAQ,iCAAiCA,EAAM,OAAO,GAAK,OAAOA,CAAK,CAAC,CAChG",
6
- "names": ["execFileSync", "existsSync", "readFileSync", "parse", "fail", "isEmptySecretsStoreListing", "parseWranglerNames", "CONFIG_PATH", "ENCRYPTION_KEY_SUFFIX", "SIGNING_SECRET_SUFFIX", "generateAESGCMKey", "key", "exported", "binary", "byte", "generateSigningSecret", "hex", "generatorFor", "secretName", "canProvisionSecret", "wrangler", "args", "input", "error", "maybeProcessError", "stdout", "stderr", "parseWranglerConfig", "config", "planSecrets", "plan", "index", "secret", "label", "storeId", "listSecretNames", "output", "createSecret", "secretValue", "main", "listedByStore", "existing"]
5
+ "mappings": ";+EA8CA,OAAS,gBAAAA,MAAoB,qBAC7B,OAAS,cAAAC,EAAY,gBAAAC,MAAoB,UACzC,OAAS,SAAAC,MAAa,eACtB,OAAS,QAAAC,MAAY,0BACrB,OAAS,8BAAAC,EAA4B,sBAAAC,MAA0B,0BAC/D,OAAS,eAAAC,MAAwC,6BAUjD,MAAMC,EAAwB,kBAKxBC,EAAwB,kBAK9B,eAAeC,GAAiB,CAC9B,MAAMC,EAAM,MAAM,OAAO,OAAO,YAAY,CAAE,KAAM,UAAW,OAAQ,GAAG,EAAI,GAAM,CAAC,UAAW,SAAS,CAAC,EACpGC,EAAW,MAAM,OAAO,OAAO,UAAU,MAAOD,CAAG,EAGzD,IAAIE,EAAS,GACb,UAAWC,KAAQ,IAAI,WAAWF,CAAQ,EACxCC,GAAU,OAAO,cAAcC,CAAI,EAErC,OAAO,KAAKD,CAAM,CACpB,CAVeE,EAAAL,EAAA,qBAef,SAASM,GAAqB,CAC5B,IAAIC,EAAM,GACV,UAAWH,KAAQ,OAAO,gBAAgB,IAAI,WAAW,EA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,EAAmB,EAC5BG,EAAOD,EAAYD,CAAM,EAE/B,GAAIE,EAAK,SAAW,EAClB,MAAM,IAAI,MAAM,8FAA8F,EAGhH,MAAMU,EAAgB,IAAI,IAE1B,SAAW,CAAE,QAAAN,EAAS,WAAAhB,CAAU,IAAMY,EAAM,CACrCU,EAAc,IAAIN,CAAO,GAC5BM,EAAc,IAAIN,EAASC,EAAgBD,CAAO,CAAC,EAErD,MAAMO,EAAWD,EAAc,IAAIN,CAAO,EAC1C,GAAIO,IAAa,OAGf,MAAM,IAAI,MAAM,mCAAmCP,CAAO,wBAAwBhB,CAAU,mCAAmC,EAEjI,GAAIuB,EAAS,IAAIvB,CAAU,EAAG,CAC5B,QAAQ,IAAI,UAAUA,CAAU,wCAAwC,EACxE,QACF,CACAmB,EAAaH,EAAShB,EAAY,MAAMD,EAAaC,CAAU,EAAC,CAAE,EAClEuB,EAAS,IAAIvB,CAAU,CACzB,CAEA,QAAQ,IAAI,gCAAgC,CAC9C,CA9BeJ,EAAAyB,EAAA,QAoCf,GAAI,CACF,MAAMA,EAAI,CACZ,OAAShB,EAAgB,CACvBpB,EAAKoB,aAAiB,MAAQ,iCAAiCA,EAAM,OAAO,GAAK,OAAOA,CAAK,CAAC,CAChG",
6
+ "names": ["execFileSync", "existsSync", "readFileSync", "parse", "fail", "isEmptySecretsStoreListing", "parseWranglerNames", "CONFIG_PATH", "ENCRYPTION_KEY_SUFFIX", "SIGNING_SECRET_SUFFIX", "generateAESGCMKey", "key", "exported", "binary", "byte", "__name", "generateSigningSecret", "hex", "generatorFor", "secretName", "canProvisionSecret", "wrangler", "args", "input", "error", "maybeProcessError", "stdout", "stderr", "parseWranglerConfig", "config", "planSecrets", "plan", "index", "secret", "label", "storeId", "listSecretNames", "output", "createSecret", "secretValue", "main", "listedByStore", "existing"]
7
7
  }
@@ -1 +1 @@
1
- function h(t,o){const a=new Set(o.value),l=new Set(o.boolean),i=o.alias??{},r=new Map;for(let e=0;e<t.length;e+=1){const s=t[e];if(!s.startsWith("-"))throw new Error(`Unexpected argument: ${s}`);const u=s.replace(/^--?/,""),n=i[u]??u;if(l.has(n)){if(r.has(n))throw new Error(`--${n} was given more than once`);r.set(n,!0);continue}if(!a.has(n))throw new Error(`Unknown argument: ${s}`);if(r.has(n))throw new Error(`--${n} was given more than once`);const c=e+1<t.length?t[e+1]:void 0;if(c===void 0||c.startsWith("-"))throw new Error(`--${n} requires a value`);r.set(n,c),e+=1}return r}function f(t,o){const a=t.get(o);return typeof a=="string"?a:void 0}function w(t,o){return t.get(o)===!0}function g(t,o,a=1){const l=new Set(o),i=[],r=[];for(let e=0;e<t.length;e+=1){const s=t[e];if(s.startsWith("-")){r.push(s);continue}const u=t[e-1];if(u!==void 0&&u.startsWith("-")&&l.has(u.replace(/^--?/,""))){r.push(s);continue}i.push(s)}if(i.length>a)throw new Error(`Expected at most ${a} positional argument(s), got: ${i.join(", ")}`);return{positional:i,rest:r}}export{w as isSet,h as parseFlags,g as splitPositional,f as valueOf};
1
+ var f=Object.defineProperty;var l=(t,e)=>f(t,"name",{value:e,configurable:!0});function g(t,e){const a=new Set(e.value),c=new Set(e.boolean),i=e.alias??{},r=new Map;for(let n=0;n<t.length;n+=1){const s=t[n];if(!s.startsWith("-"))throw new Error(`Unexpected argument: ${s}`);const u=s.replace(/^--?/,""),o=i[u]??u;if(c.has(o)){if(r.has(o))throw new Error(`--${o} was given more than once`);r.set(o,!0);continue}if(!a.has(o))throw new Error(`Unknown argument: ${s}`);if(r.has(o))throw new Error(`--${o} was given more than once`);const h=n+1<t.length?t[n+1]:void 0;if(h===void 0||h.startsWith("-"))throw new Error(`--${o} requires a value`);r.set(o,h),n+=1}return r}l(g,"parseFlags");function p(t,e){const a=t.get(e);return typeof a=="string"?a:void 0}l(p,"valueOf");function d(t,e){return t.get(e)===!0}l(d,"isSet");function m(t,e,a=1){const c=new Set(e),i=[],r=[];for(let n=0;n<t.length;n+=1){const s=t[n];if(s.startsWith("-")){r.push(s);continue}const u=t[n-1];if(u!==void 0&&u.startsWith("-")&&c.has(u.replace(/^--?/,""))){r.push(s);continue}i.push(s)}if(i.length>a)throw new Error(`Expected at most ${a} positional argument(s), got: ${i.join(", ")}`);return{positional:i,rest:r}}l(m,"splitPositional");export{d as isSet,g as parseFlags,m as splitPositional,p as valueOf};
@@ -2,6 +2,6 @@
2
2
  "version": 3,
3
3
  "sources": ["../../../src/scripts/lib/cli-args.ts"],
4
4
  "sourcesContent": ["/**\n * Minimal flag parsing for the operator scripts.\n *\n * Provenance: ported from Edge-Sonic's `scripts/lib/cli-args.ts`, which is the\n * only typed arg parser in the family — every other repo reads `process.argv`\n * with `includes('--flag')` inline.\n *\n * The shape is generic: a declared set of value flags and boolean flags, so an\n * unknown or valueless flag is rejected **by name** rather than silently ignored.\n * A mistyped `--write` must not degrade into \"ran with no flags\" — which is what\n * an inline `argv.includes()` does, and what turns a migration-lock invocation\n * that misspelled the flag into a read-only run that reports success.\n *\n * Usage:\n *\n * ```ts\n * const flags = parseFlags(process.argv.slice(2), {\n * boolean: ['write', 'dry-run'],\n * value: ['locales-dir', 'root'],\n * });\n * if (isSet(flags, 'write')) { ... }\n * const dir = valueOf(flags, 'locales-dir');\n * ```\n */\n\n/**\n * Parsed flags: value flags map to their string, boolean flags to `true`.\n */\nexport type ParsedFlags = Map<string, string | true>;\n\n/**\n * Declares which flags take a value and which are bare switches.\n */\nexport interface FlagSpec {\n /**\n * `--name` takes a value, e.g. `--to new@example.com`.\n */\n value?: readonly string[];\n /**\n * `--dry-run` takes no value.\n */\n boolean?: readonly string[];\n /**\n * Short form → long form, e.g. `{ h: 'help' }`.\n */\n alias?: Readonly<Record<string, string>>;\n}\n\n/**\n * Parses `--flag value` and `--boolean` pairs out of `argv`.\n *\n * @throws when a value flag is missing its value, when a flag is repeated, or\n * when an undeclared flag is seen. Each case names the offending flag.\n */\nexport function parseFlags(argv: readonly string[], spec: FlagSpec): ParsedFlags {\n const valueFlags = new Set(spec.value);\n const booleanFlags = new Set(spec.boolean);\n const aliases = spec.alias ?? {};\n const flags: ParsedFlags = new Map();\n\n for (let index = 0; index < argv.length; index += 1) {\n const arg = argv[index];\n if (!arg.startsWith('-')) {\n throw new Error(`Unexpected argument: ${arg}`);\n }\n const raw = arg.replace(/^--?/, '');\n const name = aliases[raw] ?? raw;\n\n if (booleanFlags.has(name)) {\n if (flags.has(name)) {\n throw new Error(`--${name} was given more than once`);\n }\n flags.set(name, true);\n continue;\n }\n\n if (!valueFlags.has(name)) {\n throw new Error(`Unknown argument: ${arg}`);\n }\n if (flags.has(name)) {\n throw new Error(`--${name} was given more than once`);\n }\n\n // `argv[index + 1]` is statically a string, but a value flag in last\n // position has no next element at runtime — the length check is what makes\n // the `undefined` below reachable rather than dead.\n const value = index + 1 < argv.length ? argv[index + 1] : undefined;\n // A value that starts with `-` is treated as a missing value so that\n // `--to --dry-run` reports the real problem instead of capturing the flag.\n if (value === undefined || value.startsWith('-')) {\n throw new Error(`--${name} requires a value`);\n }\n flags.set(name, value);\n index += 1;\n }\n\n return flags;\n}\n\n/**\n * Reads a value flag, or `undefined` when it was not supplied.\n */\nexport function valueOf(flags: ParsedFlags, name: string): string | undefined {\n const value = flags.get(name);\n return typeof value === 'string' ? value : undefined;\n}\n\n/**\n * Reads a boolean flag, defaulting to `false`.\n */\nexport function isSet(flags: ParsedFlags, name: string): boolean {\n return flags.get(name) === true;\n}\n\n/**\n * Split `argv` into its positional arguments and the rest, so a caller can accept\n * `tsx script.ts <dir>` alongside `--root <dir>`.\n *\n * A token that follows a value flag *is* that flag's value, not a positional: the\n * naive `argv.filter((arg) => !arg.startsWith('-'))` takes `.` out of\n * `--root . --fail-on-hard` and then `parseFlags` reports `--root requires a value`.\n * The value flags are passed in rather than inferred, because only the caller knows\n * which of its declared flags take one.\n *\n * @throws when more than `expected` positionals are given, naming them: a second\n * directory is far more likely to be a mistyped flag than an intended argument.\n */\nexport function splitPositional(\n argv: readonly string[],\n valueFlags: readonly string[],\n expected = 1,\n): { positional: string[]; rest: string[] } {\n const takes = new Set(valueFlags);\n const positional: string[] = [];\n const rest: string[] = [];\n\n for (let index = 0; index < argv.length; index += 1) {\n const arg = argv[index];\n if (arg.startsWith('-')) {\n rest.push(arg);\n continue;\n }\n const previous = argv[index - 1] as string | undefined;\n const isFlagValue = previous !== undefined && previous.startsWith('-') && takes.has(previous.replace(/^--?/, ''));\n if (isFlagValue) {\n rest.push(arg);\n continue;\n }\n positional.push(arg);\n }\n\n if (positional.length > expected) {\n throw new Error(`Expected at most ${expected} positional argument(s), got: ${positional.join(', ')}`);\n }\n return { positional, rest };\n}\n"],
5
- "mappings": "AAsDM,SAAUA,EAAWC,EAAyBC,EAAc,CAChE,MAAMC,EAAa,IAAI,IAAID,EAAK,KAAK,EAC/BE,EAAe,IAAI,IAAIF,EAAK,OAAO,EACnCG,EAAUH,EAAK,OAAS,CAAA,EACxBI,EAAqB,IAAI,IAE/B,QAASC,EAAQ,EAAGA,EAAQN,EAAK,OAAQM,GAAS,EAAG,CACnD,MAAMC,EAAMP,EAAKM,CAAK,EACtB,GAAI,CAACC,EAAI,WAAW,GAAG,EACrB,MAAM,IAAI,MAAM,wBAAwBA,CAAG,EAAE,EAE/C,MAAMC,EAAMD,EAAI,QAAQ,OAAQ,EAAE,EAC5BE,EAAOL,EAAQI,CAAG,GAAKA,EAE7B,GAAIL,EAAa,IAAIM,CAAI,EAAG,CAC1B,GAAIJ,EAAM,IAAII,CAAI,EAChB,MAAM,IAAI,MAAM,KAAKA,CAAI,2BAA2B,EAEtDJ,EAAM,IAAII,EAAM,EAAI,EACpB,QACF,CAEA,GAAI,CAACP,EAAW,IAAIO,CAAI,EACtB,MAAM,IAAI,MAAM,qBAAqBF,CAAG,EAAE,EAE5C,GAAIF,EAAM,IAAII,CAAI,EAChB,MAAM,IAAI,MAAM,KAAKA,CAAI,2BAA2B,EAMtD,MAAMC,EAAQJ,EAAQ,EAAIN,EAAK,OAASA,EAAKM,EAAQ,CAAC,EAAI,OAG1D,GAAII,IAAU,QAAaA,EAAM,WAAW,GAAG,EAC7C,MAAM,IAAI,MAAM,KAAKD,CAAI,mBAAmB,EAE9CJ,EAAM,IAAII,EAAMC,CAAK,EACrBJ,GAAS,CACX,CAEA,OAAOD,CACT,CAKM,SAAUM,EAAQN,EAAoBI,EAAY,CACtD,MAAMC,EAAQL,EAAM,IAAII,CAAI,EAC5B,OAAO,OAAOC,GAAU,SAAWA,EAAQ,MAC7C,CAKM,SAAUE,EAAMP,EAAoBI,EAAY,CACpD,OAAOJ,EAAM,IAAII,CAAI,IAAM,EAC7B,CAeM,SAAUI,EACdb,EACAE,EACAY,EAAW,EAAC,CAEZ,MAAMC,EAAQ,IAAI,IAAIb,CAAU,EAC1Bc,EAAuB,CAAA,EACvBC,EAAiB,CAAA,EAEvB,QAASX,EAAQ,EAAGA,EAAQN,EAAK,OAAQM,GAAS,EAAG,CACnD,MAAMC,EAAMP,EAAKM,CAAK,EACtB,GAAIC,EAAI,WAAW,GAAG,EAAG,CACvBU,EAAK,KAAKV,CAAG,EACb,QACF,CACA,MAAMW,EAAWlB,EAAKM,EAAQ,CAAC,EAE/B,GADoBY,IAAa,QAAaA,EAAS,WAAW,GAAG,GAAKH,EAAM,IAAIG,EAAS,QAAQ,OAAQ,EAAE,CAAC,EAC/F,CACfD,EAAK,KAAKV,CAAG,EACb,QACF,CACAS,EAAW,KAAKT,CAAG,CACrB,CAEA,GAAIS,EAAW,OAASF,EACtB,MAAM,IAAI,MAAM,oBAAoBA,CAAQ,iCAAiCE,EAAW,KAAK,IAAI,CAAC,EAAE,EAEtG,MAAO,CAAE,WAAAA,EAAY,KAAAC,CAAI,CAC3B",
6
- "names": ["parseFlags", "argv", "spec", "valueFlags", "booleanFlags", "aliases", "flags", "index", "arg", "raw", "name", "value", "valueOf", "isSet", "splitPositional", "expected", "takes", "positional", "rest", "previous"]
5
+ "mappings": "+EAsDM,SAAUA,EAAWC,EAAyBC,EAAc,CAChE,MAAMC,EAAa,IAAI,IAAID,EAAK,KAAK,EAC/B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,MAAMC,EAAQ,IAAI,IAAId,CAAU,EAC1Be,EAAuB,CAAA,EACvBC,EAAiB,CAAA,EAEvB,QAASZ,EAAQ,EAAGA,EAAQN,EAAK,OAAQM,GAAS,EAAG,CACnD,MAAMC,EAAMP,EAAKM,CAAK,EACtB,GAAIC,EAAI,WAAW,GAAG,EAAG,CACvBW,EAAK,KAAKX,CAAG,EACb,QACF,CACA,MAAMY,EAAWnB,EAAKM,EAAQ,CAAC,EAE/B,GADoBa,IAAa,QAAaA,EAAS,WAAW,GAAG,GAAKH,EAAM,IAAIG,EAAS,QAAQ,OAAQ,EAAE,CAAC,EAC/F,CACfD,EAAK,KAAKX,CAAG,EACb,QACF,CACAU,EAAW,KAAKV,CAAG,CACrB,CAEA,GAAIU,EAAW,OAASF,EACtB,MAAM,IAAI,MAAM,oBAAoBA,CAAQ,iCAAiCE,EAAW,KAAK,IAAI,CAAC,EAAE,EAEtG,MAAO,CAAE,WAAAA,EAAY,KAAAC,CAAI,CAC3B,CA5BgBP,EAAAG,EAAA",
6
+ "names": ["parseFlags", "argv", "spec", "valueFlags", "booleanFlags", "aliases", "flags", "index", "arg", "raw", "name", "value", "__name", "valueOf", "isSet", "splitPositional", "expected", "takes", "positional", "rest", "previous"]
7
7
  }
@@ -1,3 +1,3 @@
1
- import{appendFileSync as o}from"node:fs";function i(r,e){const t=process.env.GITHUB_OUTPUT;t&&o(t,`${r}=${e}
2
- `)}function n(r){process.stderr.write(`::error::${r}
3
- `)}function s(r){n(r),process.exit(1)}export{s as fail,n as logError,i as setOutput};
1
+ var n=Object.defineProperty;var t=(r,e)=>n(r,"name",{value:e,configurable:!0});import{appendFileSync as p}from"node:fs";function u(r,e){const o=process.env.GITHUB_OUTPUT;o&&p(o,`${r}=${e}
2
+ `)}t(u,"setOutput");function i(r){process.stderr.write(`::error::${r}
3
+ `)}t(i,"logError");function f(r){i(r),process.exit(1)}t(f,"fail");export{f as fail,i as logError,u as setOutput};
@@ -2,6 +2,6 @@
2
2
  "version": 3,
3
3
  "sources": ["../../../src/scripts/lib/github-actions.ts"],
4
4
  "sourcesContent": ["/**\n * Minimal GitHub Actions step helpers shared by the CI scripts.\n *\n * Provenance: ported from Edge-Sonic's `scripts/lib/github-actions.ts`, the only\n * repo that factored these out. The scripts deliberately avoid `@actions/*`\n * dependencies so they stay runnable with plain `tsx` from a local shell, which\n * is how they are tested.\n */\n\nimport { appendFileSync } from 'node:fs';\n\n/**\n * Append `name=value` to the step's output file. No-op outside Actions.\n */\nexport function setOutput(name: string, value: string): void {\n const outputFile = process.env.GITHUB_OUTPUT;\n if (!outputFile) {\n return;\n }\n appendFileSync(outputFile, `${name}=${value}\\n`);\n}\n\n/**\n * Emit a workflow-command annotation so the failure is visible in the run log.\n */\nexport function logError(message: string): void {\n process.stderr.write(`::error::${message}\\n`);\n}\n\n/**\n * Report a fatal error and exit non-zero.\n *\n * The annotation is written *before* exiting so the reason survives in the run\n * log. This is the whole point of the helper: the failure mode it exists to\n * prevent is a script that ends in `.catch(console.error)`, which reports success\n * while every side effect it was supposed to perform did not happen.\n */\nexport function fail(message: string): never {\n logError(message);\n process.exit(1);\n}\n"],
5
- "mappings": "AASA,OAAS,kBAAAA,MAAsB,UAKzB,SAAUC,EAAUC,EAAcC,EAAa,CACnD,MAAMC,EAAa,QAAQ,IAAI,cAC1BA,GAGLJ,EAAeI,EAAY,GAAGF,CAAI,IAAIC,CAAK;CAAI,CACjD,CAKM,SAAUE,EAASC,EAAe,CACtC,QAAQ,OAAO,MAAM,YAAYA,CAAO;CAAI,CAC9C,CAUM,SAAUC,EAAKD,EAAe,CAClCD,EAASC,CAAO,EAChB,QAAQ,KAAK,CAAC,CAChB",
6
- "names": ["appendFileSync", "setOutput", "name", "value", "outputFile", "logError", "message", "fail"]
5
+ "mappings": "+EASA,OAAS,kBAAAA,MAAsB,UAKzB,SAAUC,EAAUC,EAAcC,EAAa,CACnD,MAAMC,EAAa,QAAQ,IAAI,cAC1BA,GAGLJ,EAAeI,EAAY,GAAGF,CAAI,IAAIC,CAAK;CAAI,CACjD,CANgBE,EAAAJ,EAAA,aAWV,SAAUK,EAASC,EAAe,CACtC,QAAQ,OAAO,MAAM,YAAYA,CAAO;CAAI,CAC9C,CAFgBF,EAAAC,EAAA,YAYV,SAAUE,EAAKD,EAAe,CAClCD,EAASC,CAAO,EAChB,QAAQ,KAAK,CAAC,CAChB,CAHgBF,EAAAG,EAAA",
6
+ "names": ["appendFileSync", "setOutput", "name", "value", "outputFile", "__name", "logError", "message", "fail"]
7
7
  }
@@ -1,2 +1,2 @@
1
- const i=String.fromCodePoint(9474),c=String.fromCodePoint(9472),a="Name";function f(n){const e=[];for(const s of n.split(`
2
- `)){if(!s.includes(i))continue;const t=s.split(i).map(r=>r.trim()).filter(Boolean);if(t.length<2)continue;const o=t[0];o===a||o.includes(c)||e.push(t)}return e}function u(n){const e=new Set;for(const s of f(n)){const t=s.at(0);t!==void 0&&e.add(t)}return e}const l="List request returned no secrets";function m(n){return(n instanceof Error?n.message:String(n)).includes(l)}export{m as isEmptySecretsStoreListing,u as parseWranglerNames,f as parseWranglerTableRows};
1
+ var a=Object.defineProperty;var o=(n,e)=>a(n,"name",{value:e,configurable:!0});const r=String.fromCodePoint(9474),f=String.fromCodePoint(9472),l="Name";function u(n){const e=[];for(const s of n.split(`
2
+ `)){if(!s.includes(r))continue;const t=s.split(r).map(c=>c.trim()).filter(Boolean);if(t.length<2)continue;const i=t[0];i===l||i.includes(f)||e.push(t)}return e}o(u,"parseWranglerTableRows");function S(n){const e=new Set;for(const s of u(n)){const t=s.at(0);t!==void 0&&e.add(t)}return e}o(S,"parseWranglerNames");const m="List request returned no secrets";function d(n){return(n instanceof Error?n.message:String(n)).includes(m)}o(d,"isEmptySecretsStoreListing");export{d as isEmptySecretsStoreListing,S as parseWranglerNames,u as parseWranglerTableRows};