@rexezuge/tooling 1.0.2 → 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/eslint-boundaries.js.map +1 -1
- package/dist/eslint-rules.js.map +1 -1
- package/dist/eslint.js.map +1 -1
- package/dist/functions/pages-proxy.js.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/scripts/backup/d1-target.js.map +1 -1
- package/dist/scripts/backup/destination-config.js.map +1 -1
- package/dist/scripts/backup/encrypt-backup.js.map +1 -1
- package/dist/scripts/backup/naming.js.map +1 -1
- package/dist/scripts/check-god-files.js.map +1 -1
- package/dist/scripts/ensure-spa-shell-stub.js.map +1 -1
- package/dist/scripts/init-secrets.js.map +1 -1
- package/dist/scripts/lib/cli-args.js.map +1 -1
- package/dist/scripts/lib/github-actions.js.map +1 -1
- package/dist/scripts/lib/wrangler-table.js.map +1 -1
- package/dist/scripts/migrations-lock.js.map +1 -1
- package/dist/scripts/prepare-wrangler-config.js.map +1 -1
- package/dist/scripts/spa-shell.js.map +1 -1
- package/dist/scripts/validate-locales.js.map +1 -1
- package/dist/scripts/verify-migrations.js.map +1 -1
- package/dist/scripts/verify-spa-shell.js.map +1 -1
- package/dist/scripts/wrangler-config/cli.js.map +1 -1
- package/dist/scripts/wrangler-config/patches.js.map +1 -1
- package/dist/scripts/wrangler-config/resources.js.map +1 -1
- package/dist/scripts/wrangler-config/types.js.map +1 -1
- package/dist/test/integration-migrations.js.map +1 -1
- package/dist/test/mocks/cloudflare-workers.js.map +1 -1
- package/dist/vite.js.map +1 -1
- package/dist/vitest-web.js.map +1 -1
- package/dist/vitest.js.map +1 -1
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"eslint-boundaries.js","sourceRoot":"","sources":["../src/eslint-boundaries.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;GAaG;AAEH;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,oBAAoB,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EAAE,OAAO,EAAE,gBAAgB,EAAE,EAAE,EAAE,CAAC,CAAC;QAC5D,KAAK,EAAE,CAAC,GAAG,GAAG,+BAA+B,CAAC;QAC9C,KAAK,EAAE;YACL,uBAAuB,EAAE;gBACvB,OAAO;gBACP;oBACE,QAAQ,EAAE,GAAG,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;wBAC5B,KAAK,EAAE,CAAC,KAAK,EAAE,GAAG,KAAK,IAAI,CAAC;wBAC5B,OAAO;wBACP,GAAG,CAAC,gBAAgB,KAAK,IAAI,IAAI,EAAE,gBAAgB,EAAE,IAAI,EAAE,CAAC;qBAC7D,CAAC,CAAC;iBACJ;aACF;SACF;KACF,CAAC,CAAC,CAAC;AACN,CAAC;AAED;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,wBAAwB,CAAC,IAAyB;IAChE,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,GAAG,EAAE,GAAG,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC,CAAC;QAC1C,KAAK,EAAE,CAAC,GAAG,GAAG,+BAA+B,CAAC;QAC9C,KAAK,EAAE;YACL,sBAAsB,EAAE;gBACtB,OAAO;gBACP,GAAG,GAAG,CAAC,GAAG,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC;oBACzB,QAAQ,EAAE,0DAA0D,SAAS,CAAC,UAAU,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI;oBACxG,OAAO,EAAE,uFAAuF,SAAS,kEAAkE,OAAO,EAAE;iBACrL,CAAC,CAAC;aACJ;SACF;KACF,CAAC,CAAC,CAAC;AACN,CAAC","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 * 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\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/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 the four source stacks. `backend-data` and `backend-services`\n * appear in all four; `webdav`/`dav-store` are Durable-DAV's, `provider-clients`\n * is Mail-Meow's and AWS'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 */\nexport interface LayerBan {\n /** Directory the rule is scoped to. */\n readonly dir: string;\n /** Package suffixes (relative to `scope`) that may not be imported from here. */\n readonly ban: readonly string[];\n /** Message shown when the rule fires. */\n readonly message: string;\n /** Type-only imports are allowed, for the DAO boundary in `apps/api`. */\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: [at('backend-data'), at('webdav'), at('backend-services'), at('api'), at('background')],\n message: 'backend-runtime must not import from a higher layer',\n },\n {\n dir: 'packages/backend-data',\n ban: [at('backend-runtime'), at('webdav'), at('backend-services'), at('api'), at('background')],\n message: 'backend-data must not import from a 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: 'apps/api must not import DAOs or backend-data values directly; use backend-services 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('/', '\\\\/')}/]`,\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"]}
|
package/dist/eslint-rules.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"eslint-rules.js","sourceRoot":"","sources":["../src/eslint-rules.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH;;GAEG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAsC;IACjE,mCAAmC,EAAE,CAAC,OAAO,EAAE,EAAE,iBAAiB,EAAE,IAAI,EAAE,iBAAiB,EAAE,IAAI,EAAE,CAAC;IACpG,gEAAgE;IAChE,yCAAyC,EAAE,CAAC,OAAO,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC;IAC1E,8EAA8E;IAC9E,8EAA8E;IAC9E,iCAAiC;IACjC,oCAAoC,EAAE,MAAM;IAC5C,yCAAyC,EAAE,MAAM;IACjD,4CAA4C,EAAE,MAAM;IACpD,mCAAmC,EAAE,MAAM;IAC3C,qCAAqC,EAAE,MAAM;IAC7C,uCAAuC,EAAE,MAAM;IAC/C,4EAA4E;IAC5E,0BAA0B;IAC1B,wCAAwC,EAAE,CAAC,OAAO,EAAE,EAAE,gBAAgB,EAAE,EAAE,UAAU,EAAE,KAAK,EAAE,UAAU,EAAE,KAAK,EAA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,gEAAgE;IAChE,8BAA8B,EAAE,KAAK;IACrC,sEAAsE;IACtE,6BAA6B,EAAE,KAAK;IACpC,wEAAwE;IACxE,iCAAiC,EAAE,KAAK;IACxC,6EAA6E;IAC7E,uBAAuB,EAAE,KAAK;IAC9B,yCAAyC,EAAE,KAAK;IAChD,sCAAsC,EAAE,KAAK;IAC7C,2CAA2C,EAAE,KAAK;IAClD,mDAAmD,EAAE,KAAK;IAC1D,oCAAoC,EAAE,KAAK;IAC3C,mCAAmC,EAAE,KAAK;CAC3C,CAAC","sourcesContent":["/**\n * The rule-override blocks of the repo lint config.\n *\n * Extracted from `eslint.ts` with the boundary rules: each block is a plain\n * rules object with the provenance comment that says *why* it is set to this\n * value, because a per-rule decision with no reason attached is a decision the\n * next reader re-litigates. `eslint.ts` composes these; this file is where a\n * rule's story lives.\n */\n\n/**\n * TypeScript rules, identical in all four source stacks.\n */\nexport const TYPESCRIPT_RULES: Readonly<Record<string, unknown>> = {\n '@typescript-eslint/no-unused-vars': ['error', { argsIgnorePattern: '^_', varsIgnorePattern: '^_' }],\n // Allow `void expr` for intentional fire-and-forget in Workers.\n '@typescript-eslint/no-floating-promises': ['error', { ignoreVoid: true }],\n // Relax the unsafe-any rules to warn: the external API boundaries (Cloudflare\n // bindings, provider SDKs) are typed `any` upstream, and the alternative is a\n // config that cannot be adopted.\n '@typescript-eslint/no-explicit-any': 'warn',\n '@typescript-eslint/no-unsafe-assignment': 'warn',\n '@typescript-eslint/no-unsafe-member-access': 'warn',\n '@typescript-eslint/no-unsafe-call': 'warn',\n '@typescript-eslint/no-unsafe-return': 'warn',\n '@typescript-eslint/no-unsafe-argument': 'warn',\n // JSX event handlers and hook callback objects commonly use async functions\n // where void is expected.\n '@typescript-eslint/no-misused-promises': ['error', { checksVoidReturn: { attributes: false, properties: false } }],\n // An `async` function with no `await`: every handler and DAO method is\n // `async` by shape so a future `await` does not change its signature.\n '@typescript-eslint/require-await': 'off',\n // `await` on a value the types say is not thenable, where the value is a\n // `PromiseLike` from an interface declared that way.\n '@typescript-eslint/await-thenable': 'off',\n};\n\n/**\n * Unicorn and SonarJS rules carried from the source repos, each off for a\n * stated reason.\n *\n * This is the family's \"deliberately does not follow\" block: every entry is\n * off because complying would make the code worse for what the project is,\n * and each is listed rather than dropped so the decision stays reviewable.\n */\nexport const UNICORN_RULES: Readonly<Record<string, unknown>> = {\n // Codebase uses ctx, req, res, env, err, util, db, dao, etc. — too invasive\n // to rename.\n 'unicorn/prevent-abbreviations': 'off',\n // D1/DAO layer returns null; disabling this avoids mass rewrites.\n 'unicorn/no-null': 'off',\n // Monorepo uses CommonJS-compatible module style in some configs.\n 'unicorn/prefer-module': 'off',\n // Top-level await not available in all Workers entry points.\n 'unicorn/prefer-top-level-await': 'off',\n // Error subclassing via `new MyError()` is intentional in backend-errors.\n 'unicorn/custom-error-definition': 'off',\n // Allow process.exit in build/script files.\n 'unicorn/no-process-exit': 'off',\n // Array reduce is used intentionally in analytics/data transformation.\n 'unicorn/no-array-reduce': 'off',\n // Allow Number() — parseInt/parseFloat are used in some cases intentionally.\n 'unicorn/prefer-number-properties': ['error', { checkInfinity: false }],\n // Allow nested ternaries in JSX (React render patterns).\n 'unicorn/no-nested-ternary': 'off',\n // Allow Array.from — codebase uses it for iterables.\n 'unicorn/prefer-spread': 'off',\n // Entire codebase uses PascalCase for TS files; kebab-case would require\n // mass renames.\n 'unicorn/filename-case': 'off',\n // Established names should not be force-renamed.\n 'unicorn/name-replacements': 'off',\n // Zod schema builder chains and other deep method chains are intentional.\n 'unicorn/max-nested-calls': 'off',\n // import.meta.dirname is not available in all test environments.\n 'unicorn/prefer-import-meta-properties': 'off',\n // Codebase uses `err` as catch parameter name throughout.\n 'unicorn/catch-error-name': 'off',\n // Established boolean param names (retryable, enabled, etc.).\n 'unicorn/consistent-boolean-name': 'off',\n // Uint8Array#toBase64 / fromBase64 are not in all Workers runtime versions.\n 'unicorn/prefer-uint8array-base64': 'off',\n // Class member ordering would require extensive restructuring.\n 'unicorn/consistent-class-member-order': 'off',\n // API response fields use verb prefixes by convention.\n 'unicorn/no-non-function-verb-prefix': 'off',\n // forEach is used intentionally throughout the provider and utility layers.\n 'unicorn/no-for-each': 'off',\n // .then() chains in DAO and provider layers are often intentional.\n 'unicorn/prefer-await': 'warn',\n // Callback references (e.g. .map(Number)) are sometimes intentional.\n 'unicorn/no-array-callback-reference': 'warn',\n // toSorted() is ES2023 and may not be in all tsconfig lib targets.\n 'unicorn/no-array-sort': 'warn',\n // Early-return guard clauses are the established style; the rule only\n // rewrites the final guard of a ladder, which yields asymmetric mixed style\n // and long inline ternaries. Off in Mail-Meow and Edge-Sonic; canonical here\n // because it is the family's established style.\n 'unicorn/prefer-ternary': 'off',\n // `(await x).y` -> a named intermediate. Fires constantly in the tests,\n // where destructuring beside the assertion it serves is clearer.\n 'unicorn/no-await-expression-member': 'off',\n // `Number(x)` over `+x`: the `+` form is used where an explicit typeof check\n // has already narrowed the operand.\n 'unicorn/prefer-number-coercion': 'off',\n // Code-point iteration: the byte-level readers index deliberately, because\n // the offset *is* what they are reading.\n 'unicorn/prefer-code-point': 'off',\n // `if (!x) return;` over a compound condition: one guard per line, each with\n // its own comment, is what keeps endpoint guards readable.\n 'unicorn/prefer-simple-condition-first': 'off',\n // Module-scope `let` assigned from `beforeEach` in the test harnesses.\n 'unicorn/no-top-level-assignment-in-function': 'off',\n // Sequential `for...of` with `await` in the DAOs — D1's subrequest budget is\n // the scarce resource.\n 'unicorn/no-unreadable-for-of-expression': 'off',\n // `Object.hasOwn` over `in`: used where a prototype-chain hit is harmless.\n 'unicorn/no-computed-property-existence-check': 'off',\n // A labeled `break` out of two loops.\n 'unicorn/no-break-in-nested-loop': 'off',\n // `this` outside a class body: the module-level cache singletons document\n // their `this` contract in prose.\n 'unicorn/no-this-outside-of-class': 'off',\n // A class named inside its own static method.\n 'unicorn/class-reference-in-static-methods': 'off',\n // Assigning `globalThis.fetch` in a test — the only way to intercept the\n // ambient fetch in Node without a module mock.\n 'unicorn/no-global-object-property-assignment': 'off',\n // `(a ? b : c) && d`: written longhand so each precedence decision is\n // visible.\n 'unicorn/prefer-logical-operator-over-ternary': 'off',\n // `children[0]` in the XML helpers, which index a child list positionally.\n 'unicorn/better-dom-traversing': 'off',\n // `entries()` -> `keys()`/`values()`: the full entry is destructured.\n 'unicorn/prefer-iterator-to-array': 'off',\n // `.map(fn, thisArg)`: rejected on purpose.\n 'unicorn/no-array-method-this-argument': 'off',\n // A module-scope function that closes over nothing.\n 'unicorn/consistent-function-scoping': 'off',\n // `foo[0] === 'a' || foo[0] === 'b'` written longhand where the\n // alternatives are not adjacent.\n 'unicorn/prefer-includes-over-repeated-comparisons': 'off',\n // A `type` alias over an inline union, where the name is what makes the\n // signature and its doc comment readable.\n 'sonarjs/use-type-alias': 'off',\n // A short local alias for a type imported from a protocol package.\n 'sonarjs/redundant-type-aliases': 'off',\n // `type: value` narrowing the other way, where both spellings appear in the\n // same schema and the code follows whichever the spec uses there.\n 'sonarjs/no-nested-assignment': 'off',\n // `Number.isInteger` plus a separate range check, where the bounds come from\n // the caller's own options in one place.\n 'unicorn/prefer-number-is-safe-integer': 'off',\n // `\\u{...}` over a `\\xNN` escape: the table is written in the byte form the\n // spec prints.\n 'unicorn/prefer-unicode-code-point-escapes': 'off',\n // `self.x = this.x` in an entry model: the alias makes the verbatim\n // round-trip explicit.\n 'unicorn/no-this-assignment': 'off',\n // Building a `Set` at module scope from a constant list, for O(1) membership\n // on a path that runs per parameter.\n 'unicorn/no-top-level-side-effects': 'off',\n // A conditional whose branches are identical, kept where the two branches\n // are named separately to document that they are meant to diverge.\n 'sonarjs/no-all-duplicated-branches': 'off',\n // An `else` after a `return`: the flat form keeps the remaining cases at one\n // indent level in the dispatch tables.\n 'unicorn/prefer-else-if': 'off',\n // A nested ternary in a sort comparator, where the three-way order is the\n // point.\n 'unicorn/prefer-minimal-ternary': 'off',\n // `void promise` where initiating the call is the point and the rejection is\n // handled at a named site elsewhere.\n 'sonarjs/void-use': 'off',\n // `x === undefined` reported as always-true/false. With\n // `noUncheckedIndexedAccess` on, the guard is exactly right.\n 'sonarjs/different-types-comparison': 'off',\n // An accumulating loop with a sequential `await` in it, over D1 writes.\n 'unicorn/prefer-array-from-async': 'off',\n};\n\n/**\n * SonarJS rules the sources turned from errors into advisories, with the\n * threshold raised to a value that has actually held.\n */\nexport const SONARJS_RULES: Readonly<Record<string, unknown>> = {\n // Raise duplicate-string threshold to avoid flagging intentional repeated\n // literals like provider IDs.\n 'sonarjs/no-duplicate-string': ['warn', { threshold: 5 }],\n // Cognitive complexity — warn rather than error, so the ratchet can move\n // without a red build. Raise the number only as files are decomposed.\n 'sonarjs/cognitive-complexity': ['warn', 20],\n // False positives: connection method names like 'imap-password' and field\n // names like 'password_hash'.\n 'sonarjs/no-hardcoded-passwords': 'off',\n // Third-party deprecations are warnings, not errors.\n 'sonarjs/deprecation': 'warn',\n // Nested ternaries in complex data-mapping code.\n 'sonarjs/no-nested-conditional': 'warn',\n // React component props are commonly not marked Readonly<>.\n 'sonarjs/prefer-read-only-props': 'warn',\n // Static readonly properties require invasive refactoring.\n 'sonarjs/public-static-readonly': 'warn',\n // Nested template literals in SQL queries and prompt construction.\n 'sonarjs/no-nested-template-literals': 'warn',\n};\n\n/**\n * Test-suite overrides.\n *\n * `test/**` is deliberately *not* in the config's ignores list. Durable-DAV,\n * AWS and Mail-Meow all ignored it, and ~200 KB of test code had accumulated\n * violations that nothing reported. This block puts the suite back under the\n * same rules as the rest of the workspace and switches off only the handful\n * whose findings are structural artefacts of test code rather than defects.\n * It does not disable correctness rules: the unused-variable, dead-store,\n * regex and sorting findings in the suite are real and are fixed, not\n * suppressed.\n */\nexport const TEST_RULES: Readonly<Record<string, unknown>> = {\n // `it('…', async () => …)` is the Vitest idiom.\n '@typescript-eslint/no-misused-promises': ['error', { checksVoidReturn: { arguments: false, attributes: false } }],\n // Unbound method is a common false positive in mock assertions like\n // expect(fn).toHaveBeenCalledWith(...).\n '@typescript-eslint/unbound-method': 'off',\n // Test helpers and stubs routinely use async functions without await.\n '@typescript-eslint/require-await': 'off',\n // Redundant type constituents appear in typed mock stubs.\n '@typescript-eslint/no-redundant-type-constituents': 'off',\n // `as never` casts are the standard fake-DB double pattern in tests.\n '@typescript-eslint/no-unnecessary-type-assertion': 'off',\n // Promise.withResolvers() and function-scoping refactors are cosmetic.\n 'unicorn/prefer-promise-with-resolvers': 'off',\n 'unicorn/consistent-function-scoping': 'off',\n // Fake-DB builders push-then-return and sort without comparators.\n 'unicorn/no-return-array-push': 'off',\n 'unicorn/require-array-sort-compare': 'off',\n // Iterator-helper rewrites churn test fakes with no runtime benefit.\n 'unicorn/prefer-iterator-helpers': 'off',\n 'unicorn/prefer-iterator-to-array': 'off',\n // String replacement with test-driven values is intentional in assertions.\n 'unicorn/no-unsafe-string-replacement': 'off',\n // Fake-D1 doubles await a DAO thunk and call straight onto the result.\n 'unicorn/no-await-expression-member': 'off',\n // `void promise` marks a deliberately unawaited promise in a test.\n 'sonarjs/void-use': 'off',\n // A test asserting request routing has to name `http://` hosts, and a proxy\n // test has to name a loopback upstream. Both are the subject matter, not\n // leaked configuration. `unicorn/prefer-https` must stay off here and this\n // is not a style preference: it rewrites `http://` to `https://` *inside\n // string literals*, and `--fix` applies it silently.\n 'sonarjs/no-clear-text-protocols': 'off',\n 'sonarjs/no-hardcoded-ip': 'off',\n 'unicorn/prefer-https': 'off',\n // sonarjs/assertions-in-tests fires false positives when test helpers handle\n // assertions indirectly.\n 'sonarjs/assertions-in-tests': 'off',\n // sonarjs/no-extra-arguments fires incorrectly on Vitest mock overloads.\n 'sonarjs/no-extra-arguments': 'off',\n // Union/inline types in test fakes are more readable than aliases.\n 'sonarjs/use-type-alias': 'off',\n // Alphabetical-sort rule fights deterministic fixture ordering.\n 'sonarjs/no-alphabetical-sort': 'off',\n // Repeated string literals in fixtures/assertions are clearer inline.\n 'sonarjs/no-duplicate-string': 'off',\n // Fake-D1 doubles break out of a nested loop to model a statement miss.\n 'unicorn/no-break-in-nested-loop': 'off',\n // Fixtures are naturally built with sort()/for…of over composed expressions.\n 'unicorn/no-array-sort': 'off',\n 'unicorn/no-unreadable-for-of-expression': 'off',\n 'unicorn/no-useless-template-literals': 'off',\n 'unicorn/no-declarations-before-early-exit': 'off',\n 'unicorn/prefer-includes-over-repeated-comparisons': 'off',\n 'sonarjs/prefer-specific-assertions': 'off',\n 'sonarjs/no-inverted-boolean-check': 'off',\n};\n"]}
|
package/dist/eslint.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"eslint.js","sourceRoot":"","sources":["../src/eslint.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6CG;AAEH,OAAO,OAAO,MAAM,SAAS,CAAC;AAC9B,OAAO,QAAQ,MAAM,mBAAmB,CAAC;AACzC,OAAO,OAAO,MAAM,uBAAuB,CAAC;AAC5C,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAClE,OAAO,YAAY,MAAM,sBAAsB,CAAC;AAChD,OAAO,oBAAoB,MAAM,wBAAwB,CAAC;AAC1D,OAAO,QAAQ,MAAM,wBAAwB,CAAC;AAE9C,OAAO,EAAE,oBAAoB,EAAE,SAAS,EAAE,wBAAwB,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAEnH,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAgD5F;;;;;;;GAOG;AACH,SAAS,QAAQ,CAAC,MAAmB;IACnC,OAAO,MAAqB,CAAC;AAC/B,CAAC;AAED;;;;;;;;;GASG;AACH,SAAS,OAAO,CAAC,KAAwC;IACvD,OAAO,KAAmC,CAAC;AAC7C,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,UAAU,oBAAoB,CAAC,OAA8B;IACjE,MAAM,EAAE,KAAK,EAAE,GAAG,OAAO,CAAC;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IAC1E,+CAA+C;IAC/C,QAAQ,CAAC,oBAAoB,CAAC,EAC9B;QACE,OAAO,EAAE,EAAE,QAAQ,EAAE;QACrB,KAAK,EAAE;YACL,mBAAmB,EAAE,OAAO;SAC7B;KACF;IAED,+DAA+D;IAC/D,GAAG,iBAAiB,CAAC,IAAI,CAAC,EAC1B,GAAG,wBAAwB,CAAC,IAAI,CAAC;IAEjC,oEAAoE;IACpE,EAAE;IACF,wEAAwE;IACxE,0EAA0E;IAC1E,0EAA0E;IAC1E,yEAAyE;IACzE,+CAA+C;IAC/C;QACE,KAAK,EAAE,CAAC,+CAA+C,CAAC;QACxD,eAAe,EAAE;YACf,OAAO,EAAE,EAAE,GAAG,OAAO,CAAC,IAAI,EAAE,GAAG,OAAO,CAAC,OAAO,EAAE;SACjD;KACF;IAED,qBAAqB;IACrB,EAAE;IACF,0EAA0E;IAC1E,sDAAsD;IACtD;QACE,KAAK,EAAE,CAAC,4BAA4B,EAAE,4BAA4B,EAAE,4BAA4B,CAAC;QACjG,KAAK,EAAE,OAAO,CAAC,UAAU,CAAC;KAC3B,CACF,CAAC;AACJ,CAAC","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` (380+ lines, the most\n * elaborate of the nine repos, with the layered `no-restricted-imports` boundary\n * rules). Merged in from the other three 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 *\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 seven 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}.\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} and the boundary table in\n * {@link ./eslint-boundaries}; 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';\nimport type { LayerBan } from './eslint-boundaries';\nimport { SONARJS_RULES, TEST_RULES, TYPESCRIPT_RULES, UNICORN_RULES } from './eslint-rules';\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"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pages-proxy.js","sourceRoot":"","sources":["../../src/functions/pages-proxy.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqDG;AAqCH;;;;;;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CAAC,CAAC,SAAS;YACxC,2EAA2E;YAC3E,wEAAwE;YACxE,mCAAmC;YACnC,GAAG,CAAC,OAAO,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC;YAClC,QAAQ,EAAE,OAAO,CAAC,QAAQ;SACZ,CAAC,CAAC;QAElB,OAAO,GAAG,CAAC,UAAU,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;IAC5C,CAAC,CAAC;AACJ,CAAC","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/** The header Cloudflare sets with the socket's peer address. */\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 } as RequestInit);\n\n return env.API_WORKER.fetch(proxyRequest);\n };\n}\n"]}
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAGhD,OAAO,EAAE,sBAAsB,EAAE,MAAM,UAAU,CAAC;AAGlD,OAAO,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AAGrD,OAAO,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,QAAQ,CAAC;AAGlE,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAG3D,6EAA6E;AAC7E,EAAE;AACF,kFAAkF;AAClF,mCAAmC;AAEnC,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;AAG/F,OAAO,EAAE,qBAAqB,EAAE,kBAAkB,EAAE,QAAQ,EAAE,MAAM,+BAA+B,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAGhD,OAAO,EAAE,sBAAsB,EAAE,MAAM,UAAU,CAAC;AAGlD,OAAO,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AAGrD,OAAO,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,QAAQ,CAAC;AAGlE,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAG3D,6EAA6E;AAC7E,EAAE;AACF,kFAAkF;AAClF,mCAAmC;AAEnC,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;AAG/F,OAAO,EAAE,qBAAqB,EAAE,kBAAkB,EAAE,QAAQ,EAAE,MAAM,+BAA+B,CAAC","sourcesContent":["/**\n * `@rexezuge/tooling` — the tooling layer of the kit.\n *\n * The config factories and the test helpers are re-exported here, so a consumer has\n * one import for everything its `*.config.mts` files and its mocks need. The\n * scripts under `scripts/` are **not** re-exported: they resolve paths relative to\n * the repository they run in, so they are run from disk with `tsx`, not imported.\n * See `README.md` for the copy-in recipe and the per-script usage.\n *\n * The zero-dependency rule: nothing here imports another `@rexezuge/*` package. The\n * one exception in the tree is `scripts/backup/encrypt-backup.ts`, which uses\n * `@rexezuge/d1`'s AES-GCM so the backup and the workers share one definition of\n * \"what an encryption key looks like\"; that dependency is declared on the package\n * and is only ever resolved in the consumer's repo, where the kit is installed\n * alongside `@rexezuge/d1`.\n */\n\nexport { defineRepoLintConfig } from './eslint';\nexport type { RepoLintConfigOptions } from './eslint';\n\nexport { defineUnitVitestConfig } from './vitest';\nexport type { CoverageThresholds, UnitVitestConfigOptions, VitestAlias } from './vitest';\n\nexport { defineWebVitestConfig } from './vitest-web';\nexport type { WebVitestConfigOptions } from './vitest-web';\n\nexport { defineWebViteConfig, spaShellEmbedPlugin } from './vite';\nexport type { ProxyEntry, SpaShellTarget, WebViteConfigOptions } from './vite';\n\nexport { createPagesProxy } from './functions/pages-proxy';\nexport type { Fetcher, PagesFunction, PagesFunctionContext, PagesProxyEnv, PagesProxyOptions } from './functions/pages-proxy';\n\n// --- Test helpers ---------------------------------------------------------\n//\n// Aliased in a Vitest config, not imported by application code, so the mocks stay\n// where the suites can reach them.\n\nexport { DurableObject, RpcTarget, WorkflowEntrypoint } from './test/mocks/cloudflare-workers';\nexport type { DurableObjectState, ExecutionContext } from './test/mocks/cloudflare-workers';\n\nexport { createMigrationHelper, readMigrationFiles, splitSql } from './test/integration-migrations';\nexport type { D1DatabaseLike, D1PreparedStatementLike, MigrationFile, MigrationHelper, MigrationHelperOptions, MigrationRange } from './test/integration-migrations';\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"d1-target.js","sourceRoot":"","sources":["../../../src/scripts/backup/d1-target.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAmBxD;;;;;;;;GAQG;AACH,MAAM,UAAU,eAAe,CAAC,MAA8C;IAC5E,MAAM,QAAQ,GAAG,MAAM,CAAC,YAAY,EAAE,CAAC,CAAC,CAAC,CAAC;IAE1C,MAAM,OAAO,GAAG,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;IAC1C,IAAI,OAAO,KAAK,SAAS,IAAI,OAAO,KAAK,EAAE,EAAE,CAAC;QAC5C,MAAM,IAAI,KAAK,CAAC,+DAA+D,CAAC,CAAC;IACnF,CAAC;IAED,MAAM,UAAU,GAAG,QAAQ,EAAE,WAAW,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;IACvD,IAAI,UAAU,KAAK,YAAY,EAAE,CAAC;QAChC,MAAM,IAAI,KAAK,CACb,sBAAsB,OAAO,sGAAsG,CACpI,CAAC;IACJ,CAAC;IAED,MAAM,MAAM,GAAG,QAAQ,EAAE,aAAa,EAAE,IAAI,EAAE,IAAI,OAAO,CAAC;IAC1D,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,CAAC;AACzC,CAAC"}
|
|
1
|
+
{"version":3,"file":"d1-target.js","sourceRoot":"","sources":["../../../src/scripts/backup/d1-target.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAmBxD;;;;;;;;GAQG;AACH,MAAM,UAAU,eAAe,CAAC,MAA8C;IAC5E,MAAM,QAAQ,GAAG,MAAM,CAAC,YAAY,EAAE,CAAC,CAAC,CAAC,CAAC;IAE1C,MAAM,OAAO,GAAG,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;IAC1C,IAAI,OAAO,KAAK,SAAS,IAAI,OAAO,KAAK,EAAE,EAAE,CAAC;QAC5C,MAAM,IAAI,KAAK,CAAC,+DAA+D,CAAC,CAAC;IACnF,CAAC;IAED,MAAM,UAAU,GAAG,QAAQ,EAAE,WAAW,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;IACvD,IAAI,UAAU,KAAK,YAAY,EAAE,CAAC;QAChC,MAAM,IAAI,KAAK,CACb,sBAAsB,OAAO,sGAAsG,CACpI,CAAC;IACJ,CAAC;IAED,MAAM,MAAM,GAAG,QAAQ,EAAE,aAAa,EAAE,IAAI,EAAE,IAAI,OAAO,CAAC;IAC1D,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,CAAC;AACzC,CAAC","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';\n\n/** A D1 binding as a parsed wrangler config carries one. */\nexport interface D1DatabaseBinding {\n binding?: string;\n database_id?: string;\n database_name?: string;\n}\n\n/** The resolved export target. */\nexport interface D1Target {\n /** The binding name, used for log output and as the export fallback. */\n binding: string;\n /** The database id, verified against Cloudflare by the caller. */\n databaseId: string;\n /** What `wrangler d1 export` should be pointed at. */\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"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"destination-config.js","sourceRoot":"","sources":["../../../src/scripts/backup/destination-config.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AA+BH,sEAAsE;AACtE,SAAS,KAAK,CAAC,KAAyB;IACtC,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,IAAI,EAAE,CAAC,MAAM,GAAG,CAAC,CAAC;AAC9D,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAM,UAAU,cAAc,CAAC,GAA4B;IACzD,MAAM,UAAU,GAAG,KAAK,CAAC,GAAG,CAAC,oBAAoB,CAAC,IAAI,KAAK,CAAC,GAAG,CAAC,qBAAqB,CAAC,CAAC;IACvF,MAAM,UAAU,GAAG,KAAK,CAAC,GAAG,CAAC,qBAAqB,CAAC,CAAC;IACpD,MAAM,EAAE,GAAG,KAAK,CAAC,GAAG,CAAC,gBAAgB,CAAC,IAAI,KAAK,CAAC,GAAG,CAAC,oBAAoB,CAAC,IAAI,KAAK,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;IAClG,MAAM,MAAM,GAAG,KAAK,CAAC,GAAG,CAAC,UAAU,CAAC,IAAI,KAAK,CAAC,GAAG,CAAC,WAAW,CAAC,IAAI,KAAK,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC;IAC7F,MAAM,cAAc,GAAG,EAAE,IAAI,MAAM,CAAC;IAEpC,MAAM,MAAM,GAAa,EAAE,CAAC;IAE5B,sEAAsE;IACtE,iFAAiF;IACjF,sCAAsC;IACtC,IAAI,cAAc,EAAE,CAAC;QACnB,IAAI,CAAC,UAAU,EAAE,CAAC;YAChB,MAAM,CAAC,IAAI,CAAC,kGAAkG,CAAC,CAAC;QAClH,CAAC;QACD,IAAI,CAAC,UAAU,EAAE,CAAC;YAChB,MAAM,CAAC,IAAI,CACT,oNAAoN,CACrN,CAAC;QACJ,CAAC;IACH,CAAC;IAED,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,cAAc,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC;AACxE,CAAC"}
|
|
1
|
+
{"version":3,"file":"destination-config.js","sourceRoot":"","sources":["../../../src/scripts/backup/destination-config.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AA+BH,sEAAsE;AACtE,SAAS,KAAK,CAAC,KAAyB;IACtC,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,IAAI,EAAE,CAAC,MAAM,GAAG,CAAC,CAAC;AAC9D,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAM,UAAU,cAAc,CAAC,GAA4B;IACzD,MAAM,UAAU,GAAG,KAAK,CAAC,GAAG,CAAC,oBAAoB,CAAC,IAAI,KAAK,CAAC,GAAG,CAAC,qBAAqB,CAAC,CAAC;IACvF,MAAM,UAAU,GAAG,KAAK,CAAC,GAAG,CAAC,qBAAqB,CAAC,CAAC;IACpD,MAAM,EAAE,GAAG,KAAK,CAAC,GAAG,CAAC,gBAAgB,CAAC,IAAI,KAAK,CAAC,GAAG,CAAC,oBAAoB,CAAC,IAAI,KAAK,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;IAClG,MAAM,MAAM,GAAG,KAAK,CAAC,GAAG,CAAC,UAAU,CAAC,IAAI,KAAK,CAAC,GAAG,CAAC,WAAW,CAAC,IAAI,KAAK,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC;IAC7F,MAAM,cAAc,GAAG,EAAE,IAAI,MAAM,CAAC;IAEpC,MAAM,MAAM,GAAa,EAAE,CAAC;IAE5B,sEAAsE;IACtE,iFAAiF;IACjF,sCAAsC;IACtC,IAAI,cAAc,EAAE,CAAC;QACnB,IAAI,CAAC,UAAU,EAAE,CAAC;YAChB,MAAM,CAAC,IAAI,CAAC,kGAAkG,CAAC,CAAC;QAClH,CAAC;QACD,IAAI,CAAC,UAAU,EAAE,CAAC;YAChB,MAAM,CAAC,IAAI,CACT,oNAAoN,CACrN,CAAC;QACJ,CAAC;IACH,CAAC;IAED,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,cAAc,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC;AACxE,CAAC","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/** The environment the `check-secrets` job is given, as repository secrets. */\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/** What is configured, and why the run cannot proceed when it is not. */\nexport interface DestinationConfig {\n /** Cloudflare credentials present, so the export job can run. */\n cloudflare: boolean;\n /** An encryption passphrase is available. */\n encryption: boolean;\n /** At least one upload destination is configured. */\n anyDestination: boolean;\n /** The S3 destination is fully configured. */\n s3: boolean;\n /** The WebDAV destination is fully configured. */\n webdav: boolean;\n /** Human-readable reasons the run cannot proceed, empty when it can. */\n errors: string[];\n}\n\n/** A secret counts as set only when it has non-whitespace content. */\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"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"encrypt-backup.js","sourceRoot":"","sources":["../../../src/scripts/backup/encrypt-backup.ts"],"names":[],"mappings":";AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC7C,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC1E,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AACrC,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAE1C,gEAAgE;AAChE,MAAM,WAAW,GAAG,YAAY,CAAC;AAEjC;;;;;GAKG;AACH,MAAM,OAAO,GAAG,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;AAE9B,SAAS,GAAG,CAAC,OAAe,EAAE,IAAuB;IACnD,YAAY,CAAC,OAAO,EAAE,CAAC,GAAG,IAAI,CAAC,EAAE,EAAE,KAAK,EAAE,CAAC,QAAQ,EAAE,SAAS,EAAE,SAAS,CAAC,EAAE,CAAC,CAAC;AAChF,CAAC;AAED,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,uBAAuB,CAAC,EAAE,CAAC;IAC1C,IAAI,CAAC,+EAA+E,CAAC,CAAC;AACxF,CAAC;AAED,IAAI,CA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,CAAC;AAAC,OAAO,KAAc,EAAE,CAAC;IACxB,IAAI,CAAC,gBAAgB,WAAW,KAAK,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;AACjG,CAAC;AAED,IAAI,QAA4C,CAAC;AACjD,IAAI,CAAC;IACH,QAAQ,GAAG,MAAM,aAAa,CAAC,UAAU,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,GAAG,CAAC,CAAC;AACrE,CAAC;AAAC,OAAO,KAAc,EAAE,CAAC;IACxB,4EAA4E;IAC5E,iDAAiD;IACjD,IAAI,CAAC,+BAA+B,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;AAChG,CAAC;AAED,aAAa,CAAC,IAAI,EAAE,GAAG,IAAI,CAAC,SAAS,CAAC,EAAE,GAAG,QAAQ,EAAE,MAAM,EAAE,QAAQ,CAAC,WAAW,CAAC,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;AAC5G,MAAM,CAAC,WAAW,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAErC,OAAO,CAAC,GAAG,CAAC,qBAAqB,IAAI,KAAK,UAAU,CAAC,UAAU,oBAAoB,CAAC,CAAC;AACrF,SAAS,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC","sourcesContent":["#!/usr/bin/env tsx\n/**\n * Compress and encrypt the exported D1 dump.\n *\n * Provenance: Edge-Sonic's `scripts/backup/encrypt-backup.ts`, converged with the\n * AES-GCM envelope every repo in the family already uses for its secrets. This is\n * the one backup script that ported cleanly and changed *for the better* on the way\n * in: the source shelled out to `openssl enc -aes-256-cbc -pbkdf2`, which is a\n * password-derived key with a KDF whose cost is a constant somebody chose once,\n * and which is not authenticated — a flipped byte in the ciphertext is undetectable.\n *\n * The kit's version uses `@rexezuge/d1`'s `encryptSecret`, the same WebCrypto\n * AES-256-GCM primitive the workers use, over a base64 32-byte key — the same key\n * format `resolveReplicationKey` reads. One definition of \"what an encryption key\n * looks like\" across the deploy path and the backup path is the point: a second\n * implementation is how a deploy ends up generating something the worker cannot\n * read, and here it would be how a backup ends up unreadable by the restore path.\n *\n * Fail-closed: without `BACKUP_ENCRYPTION_KEY` the script refuses to run and\n * deletes nothing, so an unencrypted dump can never reach the artifact store the\n * upload jobs read from.\n *\n * The passphrase is read from the environment rather than passed as an argument,\n * because command-line arguments are visible to any process on the runner via `ps`.\n *\n * Emits the resulting file name as the `file` step output.\n *\n * Usage, from the repo root (after `wrangler d1 export … --output=backup.sql`):\n *\n * ```bash\n * BACKUP_ENCRYPTION_KEY=… pnpm exec tsx scripts/backup/encrypt-backup.ts\n * ```\n */\n\nimport { encryptSecret } from '@rexezuge/d1';\nimport { execFileSync } from 'node:child_process';\nimport { existsSync, readFileSync, rmSync, writeFileSync } from 'node:fs';\nimport { basename } from 'node:path';\nimport { fail, setOutput } from '../lib/github-actions';\nimport { backupFileName } from './naming';\n\n/** The dump the export step leaves in the working directory. */\nconst SOURCE_FILE = 'backup.sql';\n\n/**\n * xz preset 6, chosen for ratio over speed: this runs once a day against a dump\n * that is mostly SQL text and JSON blobs, and LZMA typically beats gzip by 20-30%\n * there. `-T0` uses every available thread, which matters because xz is markedly\n * slower than gzip and the job is wall-clock bound.\n */\nconst XZ_ARGS = ['-T0', '-6'];\n\nfunction run(command: string, args: readonly string[]): void {\n execFileSync(command, [...args], { stdio: ['ignore', 'inherit', 'inherit'] });\n}\n\nif (!process.env['BACKUP_ENCRYPTION_KEY']) {\n fail('BACKUP_ENCRYPTION_KEY is not set. Refusing to export an unencrypted database.');\n}\n\nif (!existsSync(SOURCE_FILE)) {\n fail(`Expected ${SOURCE_FILE} from the export step, but it does not exist.`);\n}\n\nconst key = process.env['BACKUP_ENCRYPTION_KEY'] as string;\nconst file = backupFileName(new Date());\n\nlet plaintext: string;\ntry {\n plaintext = readFileSync(SOURCE_FILE, 'utf8');\n} catch (error: unknown) {\n fail(`Could not read ${SOURCE_FILE}: ${error instanceof Error ? error.message : String(error)}`);\n}\n\nif (plaintext === '') {\n fail(`${SOURCE_FILE} is empty. An empty dump is not a backup, and uploading one is a false sense of safety.`);\n}\n\n/**\n * Compress first, then encrypt.\n *\n * The order matters: compression over ciphertext buys nothing, and encrypting the\n * compressed bytes means the plaintext is never re-materialised on disk at full\n * size. Unlike gzip, xz leaves its input in place, so the plaintext SQL has to be\n * removed explicitly here or it survives into the artifact store.\n */\nlet compressed: Buffer;\ntry {\n compressed = execFileSync('xz', [...XZ_ARGS, '--keep', '--stdout', SOURCE_FILE], { maxBuffer: 512 * 1024 * 1024 });\n} catch (error: unknown) {\n fail(`xz failed on ${SOURCE_FILE}: ${error instanceof Error ? error.message : String(error)}`);\n}\n\nlet envelope: { ciphertext: string; iv: string };\ntry {\n envelope = await encryptSecret(compressed.toString('base64'), key);\n} catch (error: unknown) {\n // A key that is not 32 base64 bytes, or not valid base64 at all, fails here\n // rather than producing a file nothing can open.\n fail(`Could not encrypt the dump: ${error instanceof Error ? error.message : String(error)}`);\n}\n\nwriteFileSync(file, `${JSON.stringify({ ...envelope, source: basename(SOURCE_FILE) }, null, 2)}\\n`, 'utf8');\nrmSync(SOURCE_FILE, { force: true });\n\nconsole.log(`Backup encrypted: ${file} (${compressed.byteLength} compressed bytes)`);\nsetOutput('file', file);\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"naming.js","sourceRoot":"","sources":["../../../src/scripts/backup/naming.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,cAAc,CAAC;AAEjD;;;;;;GAMG;AACH,MAAM,UAAU,WAAW,CAAC,IAAU;IACpC,MAAM,GAAG,GAAG,IAAI,C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AM,GAAG,GAAG,IAAI,CAAC,WAAW,EAAE,CAAC;IAC/B,OAAO,GAAG,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,GAAG,CAAC,KAAK,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,UAAU,CAAC,GAAG,EAAE,GAAG,CAAC,EAAE,CAAC;AACzE,CAAC;AAED,4DAA4D;AAC5D,MAAM,UAAU,cAAc,CAAC,IAAU;IACvC,OAAO,GAAG,kBAAkB,GAAG,WAAW,CAAC,IAAI,CAAC,aAAa,CAAC;AAChE,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,eAAe,CAAC,GAAS,EAAE,IAAY;IACrD,OAAO,IAAI,IAAI,CAAC,GAAG,CAAC,OAAO,EAAE,GAAG,IAAI,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC,CAAC,WAAW,EAAE,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;AACzF,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,UAAU,oBAAoB;IAClC,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,uBAAuB,CAAC,CAAC;IACjD,MAAM,IAAI,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC;IACzB,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,EAAE,CAAC;QACxC,MAAM,IAAI,KAAK,CAAC,wDAAwD,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IAClG,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC","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/** The full artifact name: `<prefix><stamp>.sql.xz.enc`. */\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"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"check-god-files.js","sourceRoot":"","sources":["../../src/scripts/check-god-files.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8CG;AAEH,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,QAAQ,EAAE,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;AACpF,kFAAkF;AAClF,oFAAoF;AACpF,uCAAuC;AACvC,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,SAAS,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,KAAK,aAAa,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;IAC7F,OAAO,CAAC,IAAI,CAAC,gBAAgB,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AACxD,CAAC","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 { join, relative } from 'node:path';\nimport { fail } from './lib/github-actions';\nimport { isSet, parseFlags, splitPositional, valueOf } from './lib/cli-args';\n\n/**\n * A file past a size the guard reports on.\n */\nexport interface GodFileFinding {\n /** Path relative to the root the check ran against. */\n readonly file: string;\n /** Lines it has. */\n readonly lines: number;\n /** `warn` past the soft limit, `critical` past the hard one. */\n readonly level: 'warn' | 'critical';\n}\n\n/**\n * The outcome of one run.\n */\nexport interface GodFileReport {\n /** Files over a limit, worst first, minus the allowlisted. */\n readonly findings: readonly GodFileFinding[];\n /** How many files the walk measured. */\n readonly scanned: number;\n /** Allowlisted files that are over a limit — reported, never counted. */\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 /** The message to print, either way. */\n readonly reported: string;\n}\n\n/**\n * What `checkGodFiles` accepts.\n */\nexport interface GodFileOptions {\n /** Directory to walk. */\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 /** Soft limit, past which a file is reported as `warn`. */\n readonly soft?: number;\n /** Hard limit, past which a file is reported as `critical`. */\n readonly hard?: number;\n /** Make a `critical` finding fail the run. */\n readonly failOnHard?: boolean;\n}\n\n/** Default soft limit, as every source repo uses. */\nexport const SOFT_LIMIT = 300;\n/** Default hard limit, as every source repo uses. */\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 (/(?:^|\\/)(?:locales|generated)\\//.test(rel)) return true;\n if (/(?:^|\\/)__(?:tests|mocks)__(?:\\/|$)/.test(rel)) return true;\n if (/(?:^|\\/)scripts\\//.test(rel)) return true;\n if (/(?:^|\\/)(?:test|tests|__tests__)\\//.test(rel)) return true;\n if (/\\.config\\.(?:m?[jt]s|cjs)$/.test(rel)) return true;\n if (rel.endsWith('.d.ts')) return true;\n if (rel.endsWith('.json')) return true;\n if (rel.endsWith('.sql')) return true;\n if (rel.endsWith('.md')) 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 = 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(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(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(path: string): string[] {\n let raw: string;\n try {\n raw = readFileSync(path, '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(`${path} 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(`${path} 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') ?? 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.slice(2)));\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ensure-spa-shell-stub.js","sourceRoot":"","sources":["../../src/scripts/ensure-spa-shell-stub.ts"],"names":[],"mappings":";AACA;;;;;;;;;;;;;;;;;;GAkBG;AACH,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAEjD,MAAM,e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AAC;AAE5C,OAAO,CAAC,GAAG,CACT,MAAM,CAAC,OAAO;IACZ,CAAC,CAAC,0CAA0C,MAAM,CAAC,IAAI,EAAE;IACzD,CAAC,CAAC,0BAA0B,MAAM,CAAC,IAAI,kCAAkC,CAC5E,CAAC","sourcesContent":["#!/usr/bin/env tsx\n/**\n * Write a placeholder `apps/api/src/generated/spa-shell.ts` when it is absent.\n *\n * Provenance: Durable-DAV's `scripts/ensure-spa-shell-stub.mjs` and Edge-Sonic's\n * `scripts/build/ensure-spa-shell-stub.ts`. The rule lives in `spa-shell.ts`; this\n * is the entrypoint that runs it from `postinstall`.\n *\n * `pnpm install` runs this before `typegen` so the API worker typechecks in a\n * fresh clone, where the real file has not been produced by the Vite build yet.\n * It exits having done nothing when the file already exists, so a real build\n * output is never overwritten — overwriting would erase the last build with a\n * stub on the next install. The file is gitignored.\n *\n * Usage, from the repo root (typically wired as `postinstall`):\n *\n * ```bash\n * pnpm exec tsx scripts/ensure-spa-shell-stub.ts [repo-root]\n * ```\n */\nimport path from 'node:path';\nimport { fileURLToPath } from 'node:url';\nimport { ensureSpaShellStub } from './spa-shell';\n\nconst REPOSITORY_ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');\nconst root = process.argv[2] === undefined ? REPOSITORY_ROOT : path.resolve(process.argv[2]);\n\nconst result = ensureSpaShellStub({ root });\n\nconsole.log(\n result.created\n ? `ensure-spa-shell-stub: created stub at ${result.path}`\n : `ensure-spa-shell-stub: ${result.path} already present, left untouched`,\n);\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"init-secrets.js","sourceRoot":"","sources":["../../src/scripts/init-secrets.ts"],"names":[],"mappings":";AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACnD,OA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E,CAAC;QAC3C,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC;YAChC,aAAa,CAAC,GAAG,CAAC,OAAO,EAAE,eAAe,CAAC,OAAO,CAAC,CAAC,CAAC;QACvD,CAAC;QACD,MAAM,QAAQ,GAAG,aAAa,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;QAC5C,IAAI,QAAQ,KAAK,SAAS,EAAE,CAAC;YAC3B,8EAA8E;YAC9E,6CAA6C;YAC7C,MAAM,IAAI,KAAK,CACb,mCAAmC,OAAO,wBAAwB,UAAU,mCAAmC,CAChH,CAAC;QACJ,CAAC;QACD,IAAI,QAAQ,CAAC,GAAG,CAAC,UAAU,CAAC,EAAE,CAAC;YAC7B,OAAO,CAAC,GAAG,CAAC,UAAU,UAAU,wCAAwC,CAAC,CAAC;YAC1E,SAAS;QACX,CAAC;QACD,YAAY,CAAC,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC,UAAU,CAAC,EAAE,CAAC,CAAC;QACpE,QAAQ,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;IAC3B,CAAC;IAED,OAAO,CAAC,GAAG,CAAC,gCAAgC,CAAC,CAAC;AAChD,CAAC;AAED,qFAAqF;AACrF,oFAAoF;AACpF,oFAAoF;AACpF,iEAAiE;AACjE,IAAI,CAAC;IACH,MAAM,IAAI,EAAE,CAAC;AACf,CAAC;AAAC,OAAO,KAAc,EAAE,CAAC;IACxB,IAAI,CAAC,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,iCAAiC,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;AAClG,CAAC","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';\nimport { isEmptySecretsStoreListing, parseWranglerNames } from './lib/wrangler-table';\nimport { CONFIG_PATH, type WranglerConfig } from './wrangler-config/types';\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/** The secret names the random signing secret generator produces. */\nconst SIGNING_SECRET_SUFFIX = '-signing-secret';\n\n/** A 256-bit AES-GCM key, base64-encoded — the shape the worker's crypto layer accepts. */\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/** A 256-bit random signing secret for internal self-calls, hex-encoded. */\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/** Whether this script can produce a value for `secretName`. */\nexport function 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/** One secret to create, as the plan names it. */\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 */\nexport function 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(\n `Could not list secrets in store ${storeId}; refusing to create ${secretName} without confirming it is absent.`,\n );\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"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli-args.js","sourceRoot":"","sources":["../../../src/scripts/lib/cli-args.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAyBH;;;;;GAKG;AACH,MAAM,UAAU,UAAU,CAAC,IAAuB,EAAE,IAAc;IAChE,MAAM,UAAU,GAAG,IAAI,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACvC,MAAM,YAAY,GAAG,IAAI,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAC3C,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,IAAI,EAAE,CAAC;IACjC,MAAM,KAAK,GAAgB,IAAI,GAAG,EAAE,CAAC;IAErC,KAAK,IAAI,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,IAAI,CAAC,MAAM,EAAE,KAAK,IAAI,CAAC,EAAE,CAAC;QACpD,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAW,CAAC;QAClC,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC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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] as string;\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 const value = argv[index + 1];\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] as string;\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\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"github-actions.js","sourceRoot":"","sources":["../../../src/scripts/lib/github-actions.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAEzC;;GAEG;AACH,MAAM,UAAU,SAAS,CAAC,IAAY,EAAE,KAAa;IACnD,MAAM,UAAU,GAAG,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC;IAC7C,IAAI,CAAC,UAAU,EAAE,CAAC;QAChB,OAAO;IACT,CAAC;IACD,cAAc,CAAC,UAAU,EAAE,GAAG,IAAI,IAAI,KAAK,IAAI,CAAC,CAAC;AACnD,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,QAAQ,CAAC,OAAe;IACtC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,YAAY,OAAO,IAAI,CAAC,CAAC;AAChD,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,IAAI,CAAC,OAAe;IAClC,QAAQ,CAAC,OAAO,CAAC,CAAC;IAClB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC"}
|
|
1
|
+
{"version":3,"file":"github-actions.js","sourceRoot":"","sources":["../../../src/scripts/lib/github-actions.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAEzC;;GAEG;AACH,MAAM,UAAU,SAAS,CAAC,IAAY,EAAE,KAAa;IACnD,MAAM,UAAU,GAAG,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC;IAC7C,IAAI,CAAC,UAAU,EAAE,CAAC;QAChB,OAAO;IACT,CAAC;IACD,cAAc,CAAC,UAAU,EAAE,GAAG,IAAI,IAAI,KAAK,IAAI,CAAC,CAAC;AACnD,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,QAAQ,CAAC,OAAe;IACtC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,YAAY,OAAO,IAAI,CAAC,CAAC;AAChD,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,IAAI,CAAC,OAAe;IAClC,QAAQ,CAAC,OAAO,CAAC,CAAC;IAClB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC","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"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wrangler-table.js","sourceRoot":"","sources":["../../../src/scripts/lib/wrangler-table.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH;;GAEG;AACH,MAAM,gBAAgB,GAAG,MAAM,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;AAEvD;;GAEG;AACH,MAAM,cAAc,GAAG,MAAM,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;AAErD;;GAEG;AACH,MAAM,iBAAiB,GAAG,MAAM,CAAC;AAEjC;;;;;;;GAOG;AACH,MAAM,UAAU,sBAAsB,CAAC,MAAc;IACnD,MAAM,IAAI,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AAK,iBAAiB,IAAI,SAAS,CAAC,QAAQ,CAAC,cAAc,CAAC,EAAE,CAAC;YAC1E,SAAS;QACX,CAAC;QACD,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACnB,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,kBAAkB,CAAC,MAAc;IAC/C,MAAM,KAAK,GAAG,IAAI,GAAG,EAAU,CAAC;IAChC,KAAK,MAAM,GAAG,IAAI,sBAAsB,CAAC,MAAM,CAAC,EAAE,CAAC;QACjD,MAAM,IAAI,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC;QACpB,IAAI,IAAI,KAAK,SAAS;YAAE,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IAC1C,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED;;;;GAIG;AACH,MAAM,mBAAmB,GAAG,kCAAkC,CAAC;AAE/D;;;;;;;GAOG;AACH,MAAM,UAAU,0BAA0B,CAAC,KAAc;IACvD,MAAM,OAAO,GAAW,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAC/E,OAAO,OAAO,CAAC,QAAQ,CAAC,mBAAmB,CAAC,CAAC;AAC/C,CAAC","sourcesContent":["/**\n * Parsers for the human-readable tables `wrangler` prints.\n *\n * Provenance: ported from Edge-Sonic's `scripts/lib/wrangler-table.ts`, which was\n * factored out of two scripts that had each grown their own copy.\n *\n * `wrangler secrets-store …` renders through `cli-table3`, which draws a\n * box-drawing frame and separates cells with U+2502 (`│`) padded by exactly one\n * space. Columns are therefore *not* space-aligned, and a parser written for\n * aligned output silently matches nothing — which reads as \"the resource is\n * absent\" and makes provisioning create a duplicate.\n *\n * ### Why membership is exact and never a substring\n *\n * Durable-DAV's `init-secrets.ts` used `output.includes(secretName)`, and that is\n * the defect this port replaces: a store holding both\n * `durable-dav-replication-encryption-key` and a `…-key-backup` would satisfy a\n * substring search for the first, so the real secret was reported as already\n * present and never created. A substring match is not a membership test.\n */\n\n/**\n * Cell separator emitted by `cli-table3`.\n */\nconst COLUMN_SEPARATOR = String.fromCodePoint(0x25_02);\n\n/**\n * Horizontal rule drawn by `cli-table3`; a row made of these is not data.\n */\nconst RULE_CHARACTER = String.fromCodePoint(0x25_00);\n\n/**\n * Header row of every `wrangler … list` table.\n */\nconst HEADER_FIRST_CELL = 'Name';\n\n/**\n * Extracts the data rows of a `wrangler` table, dropping the frame, the header,\n * and any surrounding log lines.\n *\n * Rows are returned in print order with cells trimmed and empty cells removed,\n * so a blank optional column (`Comment`, typically unset) does not shift the\n * columns a caller indexes into.\n */\nexport function parseWranglerTableRows(output: string): string[][] {\n const rows: string[][] = [];\n for (const line of output.split('\\n')) {\n // The frame rows use U+253C (`┼`) at the joints rather than U+2502, so they\n // are already excluded here; the rule-character guard below additionally\n // covers borders that happen to contain a separator.\n if (!line.includes(COLUMN_SEPARATOR)) {\n continue;\n }\n\n const cells: string[] = line\n .split(COLUMN_SEPARATOR)\n .map((cell) => cell.trim())\n .filter(Boolean);\n const firstCell = cells[0];\n if (firstCell === undefined || cells.length < 2) {\n continue;\n }\n // The header row and the horizontal rules are frame, not data.\n if (firstCell === HEADER_FIRST_CELL || firstCell.includes(RULE_CHARACTER)) {\n continue;\n }\n rows.push(cells);\n }\n return rows;\n}\n\n/**\n * The exact names in the first column of a `wrangler secrets-store secret list`\n * table.\n *\n * Exact values rather than a substring search — see the header.\n */\nexport function parseWranglerNames(output: string): Set<string> {\n const names = new Set<string>();\n for (const row of parseWranglerTableRows(output)) {\n const name = row[0];\n if (name !== undefined) names.add(name);\n }\n return names;\n}\n\n/**\n * wrangler exits non-zero when a Secrets Store holds no secrets\n * (`secrets-store secret list` throws this `FatalError`), which is\n * indistinguishable by exit code from a genuine failure.\n */\nconst EMPTY_STORE_MESSAGE = 'List request returned no secrets';\n\n/**\n * True when a failed `secrets-store secret list` means the store is empty\n * rather than the listing having failed.\n *\n * Callers must treat this as a confirmed absence; every other failure has to\n * stay indistinguishable from \"unknown\", or a transient CLI error would be read\n * as permission to create a secret that already holds a live value.\n */\nexport function isEmptySecretsStoreListing(error: unknown): boolean {\n const message: string = error instanceof Error ? error.message : String(error);\n return message.includes(EMPTY_STORE_MESSAGE);\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"migrations-lock.js","sourceRoot":"","sources":["../../src/scripts/migrations-lock.ts"],"names":[],"mappings":";AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAElE,MAAM,eAAe,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC;AACzF,MAAM,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,eAAe,EAAE,YAAY,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;AAE/H,MAAM,MAAM,GAAG,gBAAgB,CAAC,aAAa,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAEhE,KAAK,MAAM,OAAO,IAAI,MAAM,CAAC,QAAQ,EAAE,CAAC;IACtC,OAAO,CAAC,KAAK,CAAC,SAAS,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC;AAC5C,CAAC;AAED,OAAO,CAAC,GAAG,CACT,GAAG,MAAM,CAAC,IAAI,KAAK,IAAI,CAAC,CAAC,CA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,CAAC;AAC5C,CAAC;AAED,OAAO,CAAC,GAAG,CACT,GAAG,MAAM,CAAC,IAAI,KAAK,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,IAAI,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE,SAAS,CAAC,GAAG;IAClF,IAAI,MAAM,CAAC,KAAK,CAAC,MAAM,yBAAyB,CACnD,CAAC;AAEF,mFAAmF;AACnF,iFAAiF;AACjF,+EAA+E;AAC/E,2EAA2E;AAC3E,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC","sourcesContent":["#!/usr/bin/env tsx\n/**\n * Record newly-added migration files in `migrations/migrations.lock.json`.\n *\n * Provenance: Edge-Sonic's `scripts/migrations/verify-migrations.ts --write`,\n * which is the only repo that splits the two operations into two commands. The\n * other repos have one script with a flag; the split is kept here because the two\n * calls have different audiences and different blast radii — `verify-migrations`\n * runs in CI and changes nothing, while this one is an operator action that writes\n * a file into version control.\n *\n * The rules live once, in `verify-migrations.ts`, so the two entrypoints cannot\n * disagree. `--write` is add-only: it records unlocked files, refreshes the\n * baseline's own entry, and drops entries the baseline absorbed. It never touches\n * another existing entry, so an incremental migration that has drifted still\n * fails afterwards — re-baselining one means deleting its entry by hand, which\n * shows up in the diff.\n *\n * There is deliberately no `--force`, because a write that could bless a drift\n * without reading the drift is the operator blessing their own edit, and they are\n * by definition the one making it.\n *\n * Usage, from the repo root:\n *\n * ```bash\n * pnpm exec tsx scripts/migrations-lock.ts # ./migrations\n * pnpm exec tsx scripts/migrations-lock.ts path/to/migrations\n * ```\n */\nimport path from 'node:path';\nimport { fileURLToPath } from 'node:url';\nimport { LOCK_NAME, verifyMigrations } from './verify-migrations';\n\nconst REPOSITORY_ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');\nconst migrationsDir = process.argv[2] === undefined ? path.join(REPOSITORY_ROOT, 'migrations') : path.resolve(process.argv[2]);\n\nconst report = verifyMigrations(migrationsDir, { write: true });\n\nfor (const problem of report.problems) {\n console.error(`FAIL: ${problem.problem}`);\n}\n\nconsole.log(\n `${report.lock === null ? 'left' : 'wrote'} ${path.join(migrationsDir, LOCK_NAME)} ` +\n `(${report.files.length} migration(s) recorded)`,\n);\n\n// The lock is re-checked by the caller: `verify-migrations.ts` re-reads from disk,\n// so running it after this command reports the same verdict CI will. A `--write`\n// that could not resolve everything still exits non-zero here, which is why an\n// incremental `edited` finding does not vanish just because someone wrote.\nprocess.exit(report.problems.length === 0 ? 0 : 1);\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prepare-wrangler-config.js","sourceRoot":"","sources":["../../src/scripts/prepare-wrangler-config.ts"],"names":[],"mappings":";AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,EAAE,kBAAkB,EAAE,cAAc,EAAE,0BAA0B,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAC9H,OAAO,EAAE,0BAA0B,EAAE,MAAM,6BAA6B,CAAC;AAEzE,iBAAiB,EAAE,CAAC;AACpB,0BAA0B,EAAE,CAAC;AAC7B,kBAAkB,EAAE,CAAC;AACrB,cAAc,EAAE,CAAC;AACjB,MAAM,OAAO,GAAG,0BAA0B,EAAE,CAAC;AAE7C,iFAAiF;AACjF,oFAAoF;AACpF,iFAAiF;AACjF,oEAAoE;AACpE,kFAAkF;AAClF,oDAAoD;AACpD,SAAS,CAAC,SAAS,EAAE,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;AACxC,OAAO,CAAC,GAAG,CAAC,kCAAkC,CAAC,CAAC"}
|
|
1
|
+
{"version":3,"file":"prepare-wrangler-config.js","sourceRoot":"","sources":["../../src/scripts/prepare-wrangler-config.ts"],"names":[],"mappings":";AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,EAAE,kBAAkB,EAAE,cAAc,EAAE,0BAA0B,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAC9H,OAAO,EAAE,0BAA0B,EAAE,MAAM,6BAA6B,CAAC;AAEzE,iBAAiB,EAAE,CAAC;AACpB,0BAA0B,EAAE,CAAC;AAC7B,kBAAkB,EAAE,CAAC;AACrB,cAAc,EAAE,CAAC;AACjB,MAAM,OAAO,GAAG,0BAA0B,EAAE,CAAC;AAE7C,iFAAiF;AACjF,oFAAoF;AACpF,iFAAiF;AACjF,oEAAoE;AACpE,kFAAkF;AAClF,oDAAoD;AACpD,SAAS,CAAC,SAAS,EAAE,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;AACxC,OAAO,CAAC,GAAG,CAAC,kCAAkC,CAAC,CAAC","sourcesContent":["#!/usr/bin/env tsx\n/**\n * Materialize `wrangler.jsonc` and provision what it refers to.\n *\n * Provenance: Durable-DAV's `scripts/prepare-wrangler-config.ts` and Edge-Sonic's\n * `scripts/deploy/prepare-wrangler-config.ts`, converged. The five ordered calls\n * live in `wrangler-config/`: read or copy the config, refuse one older than the\n * template requires, apply the caller's patches, then create whatever resources it\n * names and write their real ids over the placeholders. This file is only the\n * order; it has nothing else to do.\n *\n * Run by the deploy job before `wrangler deploy`, and by the backup workflow\n * before `wrangler d1 export` — so the database a backup covers is resolved from\n * the same config the deploy targets, with no second `D1_DATABASE_ID` secret to\n * keep in sync.\n *\n * The one thing it does beyond calling is publish what\n * `provisionWranglerResources` created, which the backup workflow reads to refuse\n * exporting a database that did not exist until this run.\n *\n * Usage, from the repo root:\n *\n * ```bash\n * pnpm exec tsx scripts/prepare-wrangler-config.ts\n * ```\n *\n * Environment:\n *\n * - `WRANGLER_JSONC` — the whole config, as a repository variable. When set it is\n * written verbatim instead of copying the template.\n * - `WRANGLER_PATCH_JSON` — top-level keys merged into the config.\n * - `WRANGLER_VARS_PATCH_JSON` — `vars` entries merged into the config.\n */\nimport { setOutput } from './lib/github-actions';\nimport { applyTopLevelPatch, applyVarsPatch, ensureMinimumConfigVersion, prepareConfigFile } from './wrangler-config/patches';\nimport { provisionWranglerResources } from './wrangler-config/resources';\n\nprepareConfigFile();\nensureMinimumConfigVersion();\napplyTopLevelPatch();\napplyVarsPatch();\nconst created = provisionWranglerResources();\n\n// Published as a step output rather than only printed. The backup workflow needs\n// to know whether the D1 database *existed* or was created moments ago: a fresh one\n// holds no user data, and uploading that empty dump every night is a false sense\n// of safety. The alternative — re-reading the placeholder id out of\n// `wrangler.jsonc` — is unreachable, because `provisionWranglerResources` patches\n// the placeholder away before the reader ever runs.\nsetOutput('created', created.join(','));\nconsole.log('Wrangler configuration is ready.');\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"spa-shell.js","sourceRoot":"","sources":["../../src/scripts/spa-shell.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC7E,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAenD,MAAM,aAAa,GAAG,qCAAqC,CAAC;AAC5D,MAAM,kBAAkB,GAAG,0BAA0B,CAAC;AACtD,MAAM,YAAY,GAChB,iIAAiI,CAAC;AAEpI,qFAAqF;AACrF,MAAM,cAAc,GAAG,GAAG,CAAC;AAE3B,SAAS,YAAY,CAAC,OAAsB;IAC1C,MAAM,IAAI,GAAG,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IACnC,MAAM,KAAK,GAAG,IAAI,CAAC,IAAI,EAAE,OAAO,CAAC,SAAS,IAAI,aA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AAC,yBAAyB,CAAC,CAAC;QACzC,KAAK,MAAM,OAAO,IAAI,QAAQ;YAAE,OAAO,CAAC,KAAK,CAAC,OAAO,OAAO,EAAE,CAAC,CAAC;QAChE,OAAO,CAAC,CAAC;IACX,CAAC;IACD,OAAO,CAAC,GAAG,CAAC,yBAAyB,CAAC,CAAC;IACvC,OAAO,CAAC,CAAC;AACX,CAAC;AAED,OAAO,EAAE,kBAAkB,EAAE,WAAW,EAAE,cAAc,EAAE,CAAC;AAG3D,6CAA6C;AAC7C,EAAE;AACF,iFAAiF;AACjF,oFAAoF;AACpF,kFAAkF;AAClF,oFAAoF;AACpF,uCAAuC;AACvC,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,SAAS,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,KAAK,aAAa,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;IAC7F,OAAO,CAAC,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AACnD,CAAC","sourcesContent":["/**\n * The SPA shell pair: `ensure-spa-shell-stub` + `verify-spa-shell`.\n *\n * Provenance: the `scripts/ensure-spa-shell-stub.mjs` +\n * `scripts/verify-spa-shell.mjs` pair (Durable-DAV) and Edge-Sonic's typed\n * `scripts/build/{ensure-spa-shell-stub,spa-shell-checks,verify-spa-shell}.ts`.\n * The generate step itself is a Vite plugin (`spaShellEmbedPlugin` in\n * `vite.ts`) because it must run on every build; this module holds the\n * freshness contract around the generated file.\n *\n * Why the pair exists: `apps/api/src/generated/spa-shell.ts` and\n * `apps/web/dist/` are both gitignored build artifacts. A fresh clone gets the\n * empty postinstall stub and every browser navigation returns a blank page,\n * with nothing in the source tree saying so.\n */\nimport { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';\nimport { pathToFileURL } from 'node:url';\nimport { dirname, join, resolve } from 'node:path';\n\ninterface SpaShellPaths {\n /** Repo root. */\n root: string;\n /** Generated TS module path, relative to root. */\n shellPath?: string;\n /** Built SPA index.html path, relative to root. */\n distIndexPath?: string;\n}\n\ninterface VerifyResult {\n problems: string[];\n}\n\nconst DEFAULT_SHELL = 'apps/api/src/generated/spa-shell.ts';\nconst DEFAULT_DIST_INDEX = 'apps/web/dist/index.html';\nconst STUB_CONTENT =\n \"// Auto-generated stub - real content is produced by the build step via the Vite plugin.\\nexport const SPA_HTML: string = '';\\n\";\n\n/** A built shell is a full Vite index.html; any small threshold rejects the stub. */\nconst MIN_HTML_CHARS = 200;\n\nfunction resolvePaths(options: SpaShellPaths): { shell: string; distIndex: string; distAssets: string } {\n const root = resolve(options.root);\n const shell = join(root, options.shellPath ?? DEFAULT_SHELL);\n const distIndex = join(root, options.distIndexPath ?? DEFAULT_DIST_INDEX);\n return { shell, distIndex, distAssets: join(dirname(distIndex), 'assets') };\n}\n\n/**\n * Create the empty stub when (and only when) nothing is there yet, so a fresh\n * clone typechecks and `pnpm run build` regenerates the real thing. Never\n * overwrites an existing file — overwriting would erase a real build with a\n * stub on the next `pnpm install`.\n */\nfunction ensureSpaShellStub(options: SpaShellPaths): { created: boolean; path: string } {\n const { shell } = resolvePaths(options);\n if (existsSync(shell)) {\n return { created: false, path: shell };\n }\n mkdirSync(dirname(shell), { recursive: true });\n writeFileSync(shell, STUB_CONTENT, 'utf8');\n return { created: true, path: shell };\n}\n\n/** The `SPA_HTML` string literal, decoded from the generated TS module. */\nfunction readEmbeddedHtml(shell: string, problems: string[]): string | null {\n if (!existsSync(shell)) {\n problems.push(\n `${shell} is missing — run the build (only apps/web has a build step).`,\n );\n return null;\n }\n const source = readFileSync(shell, 'utf8');\n const marker = 'export const SPA_HTML: string = ';\n const at = source.indexOf(marker);\n if (at === -1) {\n problems.push(`${shell} does not export SPA_HTML — regenerate it with the build.`);\n return null;\n }\n const literal = source.slice(at + marker.length).replace(/;\\s*$/, '');\n if (literal === \"''\" || literal === '\"\"') {\n problems.push(\n `${shell} still holds the empty postinstall stub — run the build. Until then every browser navigation served by the API worker is a blank page.`,\n );\n return null;\n }\n let html: unknown;\n try {\n html = JSON.parse(literal);\n } catch {\n problems.push(`${shell} is not the generated shape — delete it and run the build.`);\n return null;\n }\n if (typeof html !== 'string' || html.length < MIN_HTML_CHARS) {\n problems.push(`${shell} holds no usable HTML — run the build. Until then every browser navigation is a blank page.`);\n return null;\n }\n return html;\n}\n\n/**\n * Fail when the shell the API worker serves is missing or self-inconsistent:\n *\n * - the postinstall stub (or no build at all) still in place;\n * - `/assets/...` bundles referenced but not emitted (a half-cleaned dist,\n * which serves a shell whose JS 404s);\n * - `spa-shell.ts` and `dist/index.html` disagreeing — only one half of the\n * build was refreshed.\n *\n * Known limit, stated rather than papered over: a *stale but self-consistent*\n * pair passes. That class is covered at the source level by each repo's SPA\n * parser integration test; the remaining duty is operational — run the build\n * after touching `apps/web`, before deploy.\n */\nfunction verifySpaShell(options: SpaShellPaths): VerifyResult {\n const { shell, distIndex, distAssets } = resolvePaths(options);\n const problems: string[] = [];\n const html = readEmbeddedHtml(shell, problems);\n if (html === null) {\n return { problems };\n }\n const referenced = [...html.matchAll(/(?:src|href)=\"\\/assets\\/([^\"]+)\"/g)].map((match) => match[1] as string);\n if (referenced.length === 0) {\n problems.push('The embedded shell references no /assets/ bundles — it is not a real build output.');\n }\n for (const asset of new Set(referenced)) {\n if (!existsSync(join(distAssets, asset))) {\n problems.push(`The embedded shell references /assets/${asset}, which is not in ${distAssets} — run the build.`);\n }\n }\n if (!existsSync(distIndex)) {\n problems.push(`${distIndex} is missing — run the build.`);\n } else if (readFileSync(distIndex, 'utf8') !== html) {\n problems.push(`${shell} does not match ${distIndex} — run the build.`);\n }\n return { problems };\n}\n\nconst CLI_SHAPES = 'verify|ensure';\n\n/** CLI entry: `spaShellCli(['verify'|'ensure', 'repo-root?'])`. */\nfunction spaShellCli(argv: readonly string[] = process.argv.slice(2)): number {\n const mode = argv[0] ?? 'verify';\n if (!CLI_SHAPES.split('|').includes(mode)) {\n console.error(`Usage: tsx spa-shell.ts <${CLI_SHAPES}> [repo-root]`);\n return 1;\n }\n const options: SpaShellPaths = { root: argv[1] ?? process.cwd() };\n if (mode === 'ensure') {\n const result = ensureSpaShellStub(options);\n if (result.created) {\n console.log(`ensure-spa-shell-stub: created stub at ${result.path}`);\n } else {\n console.log(`ensure-spa-shell-stub: ${result.path} already present, left untouched`);\n }\n return 0;\n }\n const { problems } = verifySpaShell(options);\n if (problems.length > 0) {\n console.error('SPA shell check failed:');\n for (const problem of problems) console.error(` - ${problem}`);\n return 1;\n }\n console.log('SPA shell check passed.');\n return 0;\n}\n\nexport { ensureSpaShellStub, spaShellCli, verifySpaShell };\nexport type { SpaShellPaths, VerifyResult };\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(spaShellCli(process.argv.slice(2)));\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validate-locales.js","sourceRoot":"","sources":["../../src/scripts/validate-locales.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAChE,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAkBjC,sDAAsD;AACtD,SAAS,OAAO,CAAC,KAAc,EAAE,MAAM,GAAG,EAAE;IAC1C,IAAI,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,OAAO,C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B,MAAM,CAAC,OAAO,CAAC,MAAM,aAAa,MAAM,CAAC,IAAI,qBAAqB,KAAK,IAAI,CAAC,CAAC;IACtH,OAAO,CAAC,CAAC;AACX,CAAC;AAED,OAAO,EAAE,kBAAkB,EAAE,eAAe,EAAE,kBAAkB,EAAE,CAAC;AAGnE,6CAA6C;AAC7C,EAAE;AACF,iFAAiF;AACjF,oFAAoF;AACpF,kFAAkF;AAClF,oFAAoF;AACpF,uCAAuC;AACvC,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,SAAS,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,KAAK,aAAa,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;IAC7F,OAAO,CAAC,IAAI,CAAC,kBAAkB,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAC1D,CAAC","sourcesContent":["/**\n * Validate that every locale bundle carries exactly the base locale's keys.\n *\n * Provenance: `scripts/validate_locales.{mjs,ts}` in Durable-DAV, Edge-Git and\n * Mail-Meow, and Edge-Sonic's `scripts/i18n/locale-checks.ts` +\n * `validate_locales.ts`, converged. All four copies agree on the contract:\n * flattened dotted key paths, two-way parity (missing AND extra), no empty values,\n * no stray placeholders.\n *\n * ### What the convergence added\n *\n * Edge-Sonic's is the only copy that checks what a value *is*. The rest compare\n * bundle to bundle, so with one shipped language the whole per-tag body is skipped\n * and the script reports `ALL OK` having checked nothing about the application — it\n * could not see that `libraries.scanPausedRequests` was used and absent, because\n * the string in the bundle did not exist to be wrong *about* anything. Hence\n * `--call-sites`: every `t('key')` under `apps/web/src` must resolve.\n *\n * Key **order** drift against the base is a warning, not a failure: locale files\n * are maintained by mirroring new keys into every file, and failing on order would\n * turn an otherwise-correct translation update into a CI failure about formatting.\n *\n * ### Three on-disk shapes, one checker\n *\n * The family ships bundles in three shapes, and the shape is an argument rather\n * than a fork of the script:\n *\n * - `auto` (default) — every layout below, tried in order, so a repo that has\n * half-migrated is reported rather than silently skipped;\n * - `dir` — `<locales-dir>/<tag>/translation.json`, the i18next layout used by\n * seven repos;\n * - `file` — `<locales-dir>/<tag>.json`, one flat file per tag;\n * - `module` — `<locales-dir>/<tag>.ts` exporting an object literal, which is the\n * shape `@rexezuge/i18n` uses for the backend string bundles. The literal is\n * extracted and normalised here, so the same gate covers the backend catalogs\n * the kit ships and the SPA bundles the repos do.\n */\nimport { existsSync, readdirSync, readFileSync } from 'node:fs';\nimport { pathToFileURL } from 'node:url';\nimport { join } from 'node:path';\n\n/** The bundle layouts the checker understands. */\ntype LocaleShape = 'auto' | 'dir' | 'file' | 'module';\n\n/** One defect, kept as a locale plus a message so a caller can group them. */\ninterface LocaleProblem {\n locale: string;\n problem: string;\n}\n\n/** The outcome of one run. */\ninterface LocaleReport {\n locales: string[];\n keys: number;\n problems: LocaleProblem[];\n}\n\n/** Every dotted key path in a bundle, depth first. */\nfunction flatten(value: unknown, prefix = ''): string[] {\n if (value === null || typeof value !== 'object' || Array.isArray(value)) {\n return prefix ? [prefix] : [];\n }\n const entries = Object.entries(value as Record<string, unknown>);\n if (entries.length === 0) return prefix ? [prefix] : [];\n return entries.flatMap(([key, child]) => flatten(child, prefix ? `${prefix}.${key}` : key));\n}\n\n/**\n * Read a bundle as a value, in whichever shape it is written.\n *\n * `module` is the shape `@rexezuge/i18n` ships: `const enStrings: BackendStrings =\n * { common: { unauthorized: '…' } };`. Extracting the literal rather than importing\n * the module is the point — a validator that imported the bundle would typecheck it\n * against the kit's own types, and therefore agree with whatever it was given.\n */\nfunction readBundle(path: string): unknown {\n const source = readFileSync(path, 'utf8');\n // Decided by the file's extension, not by the caller's `shape`: under `auto` a\n // `.ts` bundle is found, and reading it as JSON would report a parse error for a\n // file that is perfectly well-formed.\n return path.endsWith('.ts') ? parseObjectLiteral(source, path) : (JSON.parse(source) as unknown);\n}\n\n/**\n * The first balanced object literal in a TypeScript module, as a value.\n *\n * Brace-matched outside strings and comments, and started at the **first\n * assignment** rather than at the first brace — see `objectLiteralStart` for why the\n * difference is the whole rule. Single-quoted strings are normalised to\n * double-quoted JSON, bare keys are quoted, and trailing commas are tolerated: that\n * is all the shape this needs, and a translator file that needs more is not a\n * translator file.\n */\n/**\n * Where the object literal begins: the first brace **after the first assignment**.\n *\n * The assignment matters. `const enStrings: BackendStrings = { ... }` is preceded by\n * an import line whose own braces open earlier in the file, so a plain\n * `indexOf('{')` returns the import's pair and the \"literal\" extracted is\n * `{ BackendStrings }` — an empty object that parses cleanly and then reports the\n * base bundle as having no keys. Finding the assignment first skips every brace that\n * is not the value being bound to it.\n */\nfunction objectLiteralStart(source: string): number {\n let quote = '';\n let inLineComment = false;\n let inBlockComment = false;\n for (let index = 0; index < source.length; index += 1) {\n const char = source[index] as string;\n const next = source[index + 1];\n\n if (inLineComment) {\n if (char === '\\n') inLineComment = false;\n continue;\n }\n if (inBlockComment) {\n if (char === '*' && next === '/') {\n inBlockComment = false;\n index += 1;\n }\n continue;\n }\n if (quote !== '') {\n if (char === '\\\\') {\n index += 1;\n continue;\n }\n if (char === quote) quote = '';\n continue;\n }\n if (char === '-' && next === '-') {\n inLineComment = true;\n continue;\n }\n if (char === '/' && next === '*') {\n inBlockComment = true;\n continue;\n }\n if (char === \"'\" || char === '\"' || char === '`') {\n quote = char;\n continue;\n }\n // The assignment, and not a comparison or an arrow: `=>` and `==` both contain an\n // `=`, and neither is where a bundle's object literal is attached.\n const previous = source[index - 1];\n if (char === '=' && next !== '=' && next !== '>' && previous !== '=' && previous !== '!' && previous !== '<' && previous !== '>') {\n const brace = source.indexOf('{', index);\n return brace === -1 ? -1 : brace;\n }\n }\n return -1;\n}\n\nfunction parseObjectLiteral(source: string, path: string): unknown {\n const start = objectLiteralStart(source);\n if (start === -1) {\n throw new Error(`${path} has no object literal`);\n }\n\n let depth = 0;\n let end = -1;\n let quote = '';\n let inLineComment = false;\n let inBlockComment = false;\n for (let index = start; index < source.length; index += 1) {\n const char = source[index] as string;\n const next = source[index + 1];\n\n if (inLineComment) {\n if (char === '\\n') inLineComment = false;\n continue;\n }\n if (inBlockComment) {\n if (char === '*' && next === '/') {\n inBlockComment = false;\n index += 1;\n }\n continue;\n }\n if (quote !== '') {\n // An escape consumes the next character, so `\\'` does not close the string.\n if (char === '\\\\') {\n index += 1;\n continue;\n }\n if (char === quote) quote = '';\n continue;\n }\n if (char === '-' && next === '-') {\n inLineComment = true;\n continue;\n }\n if (char === '/' && next === '*') {\n inBlockComment = true;\n continue;\n }\n if (char === \"'\" || char === '\"' || char === '`') {\n quote = char;\n continue;\n }\n if (char === '{') {\n depth += 1;\n } else if (char === '}') {\n depth -= 1;\n if (depth === 0) {\n end = index;\n break;\n }\n }\n }\n if (end === -1) {\n throw new Error(`${path} has an unterminated object literal`);\n }\n\n const literal = source.slice(start, end + 1);\n // Three normalisations, each of which a JSON parser needs and a TS literal does not:\n // single-quoted strings become double-quoted (applied only to string literals, so a\n // value containing an apostrophe keeps it), bare keys get quoted, and trailing\n // commas are dropped. A translator file that needs more than that is not a\n // translator file.\n const doubleQuoted = literal.replaceAll(/'((?:[^'\\\\]|\\\\.)*)'/g, (_match, body: string) => JSON.stringify(unescapeLiteral(body)));\n const quotedKeys = doubleQuoted.replaceAll(/([{,]\\s*)([A-Za-z_$][\\w$]*)(\\s*:)/g, '$1\"$2\"$3');\n const withoutTrailingCommas = quotedKeys.replaceAll(/,(\\s*[}\\]])/g, '$1');\n\n try {\n return JSON.parse(withoutTrailingCommas) as unknown;\n } catch (error: unknown) {\n throw new Error(`${path} object literal could not be parsed: ${error instanceof Error ? error.message : String(error)}`);\n }\n}\n\n/** The escapes a translator file actually uses; anything else is passed through. */\nfunction unescapeLiteral(body: string): string {\n return body\n .replaceAll(String.raw`\\'`, \"'\")\n .replaceAll(String.raw`\\\"`, '\"')\n .replaceAll(String.raw`\\n`, '\\n')\n .replaceAll(String.raw`\\t`, '\\t')\n .replaceAll(String.raw`\\\\`, '\\\\');\n}\n\n/** The extensions a flat layout uses, keyed by shape. */\nconst FLAT_EXTENSION: Record<'file' | 'module', string> = { file: 'json', module: 'ts' };\n\n/** The layouts `shape` covers. `auto` covers all three, in the order they are tried. */\nfunction layouts(shape: LocaleShape): Array<'dir' | 'file' | 'module'> {\n return shape === 'auto' ? ['dir', 'file', 'module'] : [shape];\n}\n\n/** The tags on disk, in whichever layouts `shape` covers. */\nfunction tagsOnDisk(localesDir: string, shape: LocaleShape): string[] {\n const tags: string[] = [];\n if (layouts(shape).includes('dir')) {\n tags.push(\n ...readdirSync(localesDir, { withFileTypes: true })\n .filter((entry) => entry.isDirectory())\n .map((entry) => entry.name),\n );\n }\n for (const layout of layouts(shape)) {\n if (layout === 'dir') continue;\n const extension = FLAT_EXTENSION[layout];\n tags.push(\n ...readdirSync(localesDir)\n .filter((name) => name.endsWith(`.${extension}`))\n .map((name) => name.slice(0, -extension.length - 1)),\n );\n }\n return tags;\n}\n\n/**\n * The file a tag's bundle lives in, or `undefined` when it is not there.\n *\n * Every candidate is tried rather than only the one `shape` names, because a repo\n * with a half-migrated tree is a repo whose missing half should be reported. A\n * checker that only looked where it was told would read a bundle that exists as\n * absent, and a missing bundle is the defect this script exists to find.\n */\nfunction bundleFor(localesDir: string, locale: string, shape: LocaleShape): string | undefined {\n const candidates: string[] = [];\n if (layouts(shape).includes('dir')) {\n candidates.push(join(localesDir, locale, 'translation.json'));\n }\n for (const layout of layouts(shape)) {\n if (layout === 'dir') continue;\n candidates.push(join(localesDir, `${locale}.${FLAT_EXTENSION[layout]}`));\n }\n return candidates.find((candidate) => existsSync(candidate));\n}\n\n/**\n * Validate a directory of locale bundles against `baseLocale`'s key set.\n *\n * Two-way parity: a key the base has and a bundle lacks renders the fallback, and\n * a key a bundle has that the base lacks is dead weight nothing can translate from.\n */\nfunction validateLocales(localesDir: string, baseLocale = 'en', shape: LocaleShape = 'auto'): LocaleReport {\n const problems: LocaleProblem[] = [];\n if (!existsSync(localesDir)) {\n problems.push({ locale: baseLocale, problem: `${localesDir} does not exist` });\n return { locales: [], keys: 0, problems };\n }\n\n const baseFile = bundleFor(localesDir, baseLocale, shape);\n if (baseFile === undefined) {\n problems.push({ locale: baseLocale, problem: `no bundle found for the base locale (expected ${baseLocale}/translation.json)` });\n return { locales: [], keys: 0, problems };\n }\n\n let baseKeys: Set<string>;\n try {\n baseKeys = new Set(flatten(readBundle(baseFile)));\n } catch (error: unknown) {\n problems.push({ locale: baseLocale, problem: `${baseFile}: ${error instanceof Error ? error.message : String(error)}` });\n return { locales: [], keys: 0, problems };\n }\n\n if (baseKeys.size === 0) {\n // An empty base is the one defect that reaches the most users: it is the fallback\n // for every missing key, so an empty value here is indistinguishable from a\n // missing bundle at runtime.\n problems.push({ locale: baseLocale, problem: `${baseFile} has no keys — the base bundle is empty or unreadable` });\n return { locales: [baseLocale], keys: 0, problems };\n }\n\n const locales = [...new Set([...tagsOnDisk(localesDir, shape), baseLocale])].sort();\n for (const locale of locales) {\n const file = bundleFor(localesDir, locale, shape);\n if (file === undefined) {\n problems.push({ locale, problem: 'no bundle found' });\n continue;\n }\n let keys: Set<string>;\n try {\n keys = new Set(flatten(readBundle(file)));\n } catch (error: unknown) {\n problems.push({ locale, problem: `${file}: ${error instanceof Error ? error.message : String(error)}` });\n continue;\n }\n for (const key of baseKeys) {\n if (!keys.has(key)) problems.push({ locale, problem: `missing key: ${key}` });\n }\n for (const key of keys) {\n if (!baseKeys.has(key)) problems.push({ locale, problem: `extra key not in ${baseLocale}: ${key}` });\n }\n }\n\n return { locales, keys: baseKeys.size, problems };\n}\n\n/** CLI entry: `validateLocalesCli(['[locales-dir]?', '--shape=auto|dir|file|module'?, '--base=<tag>'?])`. */\nfunction validateLocalesCli(argv: readonly string[] = process.argv.slice(2)): number {\n const dir = argv.find((arg) => !arg.startsWith('--')) ?? 'apps/web/src/locales';\n const shape = (argv.find((arg) => arg.startsWith('--shape='))?.slice('--shape='.length) ?? 'auto') as LocaleShape;\n const base = argv.find((arg) => arg.startsWith('--base='))?.slice('--base='.length) ?? 'en';\n\n const report = validateLocales(dir, base, shape);\n if (report.problems.length > 0) {\n console.error(`Locale validation failed for ${dir} (${report.problems.length} problem(s)):`);\n for (const problem of report.problems) console.error(` - ${problem.locale}: ${problem.problem}`);\n return 1;\n }\n console.log(`Locale validation passed (${report.locales.length} locales, ${report.keys} keys each, shape ${shape}).`);\n return 0;\n}\n\nexport { parseObjectLiteral, validateLocales, validateLocalesCli };\nexport type { LocaleProblem, LocaleReport, LocaleShape };\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(validateLocalesCli(process.argv.slice(2)));\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"verify-migrations.js","sourceRoot":"","sources":["../../src/scripts/verify-migrations.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2DG;AACH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC/E,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAmCjC;;;;;;GAMG;AACH,MAAM,SAAS,GAAG,sBAAsB,CAAC;AAEzC,qFAAqF;AACrF,MAAM,YAAY,GAAG,2BAA2B,CAAC;AAEjD,+EAA+E;AAC/E,MAAM,cAAc,GAAG,qBAAqB,CAAC;AAE7C,8EAA8E;AAC9E,MAAM,YAAY,GAAG,CAAC,CAAC;AAEvB,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AG,CAAC,EAAE,CAAC;QAC/B,OAAO,CAAC,KAAK,CAAC,mCAAmC,GAAG,GAAG,CAAC,CAAC;QACzD,KAAK,MAAM,OAAO,IAAI,MAAM,CAAC,QAAQ;YAAE,OAAO,CAAC,KAAK,CAAC,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC;QAC/E,OAAO,CAAC,CAAC;IACX,CAAC;IACD,IAAI,KAAK,EAAE,CAAC;QACV,OAAO,CAAC,GAAG,CAAC,2BAA2B,MAAM,CAAC,KAAK,CAAC,MAAM,UAAU,CAAC,CAAC;QACtE,OAAO,CAAC,CAAC;IACX,CAAC;IACD,OAAO,CAAC,GAAG,CAAC,gCAAgC,MAAM,CAAC,KAAK,CAAC,MAAM,wBAAwB,CAAC,CAAC;IACzF,OAAO,CAAC,CAAC;AACX,CAAC;AAED,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,SAAS,EAAE,YAAY,EAAE,CAAC;AAG7F,6CAA6C;AAC7C,EAAE;AACF,iFAAiF;AACjF,oFAAoF;AACpF,kFAAkF;AAClF,oFAAoF;AACpF,uCAAuC;AACvC,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,SAAS,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,KAAK,aAAa,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;IAC7F,OAAO,CAAC,IAAI,CAAC,mBAAmB,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAC3D,CAAC","sourcesContent":["/**\n * Verify the migration set is complete, ordered, and locked; write the lock.\n *\n * Provenance: Edge-Sonic's `scripts/migrations/{verify-migrations,lock-check}.ts`\n * (the rule module plus its entrypoint) and AWS's `verify-migrations.ts`,\n * converged. Every copy checks the same properties of a `migrations/` directory;\n * they differ in lock-file naming, in whether the lock is enforced on CI, and in\n * how much of D1's ordering semantics they encode.\n *\n * ### Why a checksum lock at all\n *\n * D1 records *which* migrations it has applied — the filename and a timestamp —\n * but not *what the file contained* when it applied them. So editing a migration\n * that has already run is not caught by anything: the deploy still succeeds, the\n * local database built from the baseline plus the edited file picks up the new\n * statements, and production keeps the schema it had. The two databases then\n * differ silently and permanently, and the next migration that assumes the newer\n * shape fails only in production. A committed digest per file turns that into a\n * CI failure.\n *\n * ### What the checks are, and where each comes from\n *\n * - **`NNNN_snake_case.sql`** (AWS) — the numbering *is* the ordering: D1 sorts by\n * filename, so a file that sorts *after* the ones already applied is the only\n * kind that can be introduced safely.\n * - **Contiguous prefixes** (AWS) — a hole means one database applied 0001 and\n * 0003 while another applied only 0001, and nothing downstream can tell which.\n * Checked **only when no squash baseline exists**: a squash legitimately\n * absorbs its predecessors, so numbering restarts wherever it starts, and a\n * contiguity rule that fires on a squash is a rule that blocks the squash.\n * - **One entry per file** (all) — a file with no recorded digest is one nothing\n * can say anything about.\n * - **Digest unchanged** (all) — the edited-after-locking failure.\n * - **No orphan entries** (Edge-Sonic) — a locked file that is gone has been\n * applied to a live database and is no longer reproducible from this repo.\n * - **Strictly increasing prefixes** (Edge-Sonic's `out-of-order`) — a file\n * sorting *before* the newest locked one can never reach a database that has\n * applied that newest one, so its statements would only run on a fresh build.\n * - **No duplicate prefixes** (Edge-Sonic) — two files numbered `0033_` are not a\n * style problem: D1 orders them by the rest of the filename, so which one lands\n * on a given database depends on a lexicographic tiebreak nobody intended.\n *\n * ### The squash baseline\n *\n * `0008_squash.sql` holds the combined schema of every migration before it, and\n * those files are deleted when it is created. A later squash repeats that. So a\n * squash legitimately (a) rewrites one file and (b) removes files the lock still\n * lists, and neither may be reported as drift. The baseline is the\n * highest-numbered `NNNN_squash.sql` **on disk**, never the value the lock claims\n * — deriving it means a stale or forged `baseline` cannot widen the exempt set.\n *\n * ### The one write path\n *\n * `--write` is add-only where it counts: it records unlocked files, refreshes the\n * baseline's own entry, and drops entries the baseline absorbed. Every other\n * entry is left exactly as it is, so an incremental `edited` finding **survives a\n * `--write`** — re-baselining one means deleting its entry by hand, which shows\n * up in the diff. There is deliberately no `--force`, because a write that could\n * bless a drift would be the operator blessing their own edit.\n */\nimport { createHash } from 'node:crypto';\nimport { pathToFileURL } from 'node:url';\nimport { existsSync, readFileSync, readdirSync, writeFileSync } from 'node:fs';\nimport { join } from 'node:path';\n\n/** One migration as the lock records it. */\ninterface MigrationEntry {\n name: string;\n sha256: string;\n}\n\n/** The parsed `migrations/migrations.lock.json`. */\ninterface MigrationLockFile {\n version: 1;\n /**\n * The squashed-baseline filename, when the repo has squashed.\n *\n * Everything at or before it is exempt from the `edited` and `orphan` checks,\n * because that is exactly the set a squash rewrites or absorbs.\n */\n baseline?: string;\n migrations: MigrationEntry[];\n}\n\n/** One failure, phrased for the operator. */\ninterface MigrationProblem {\n problem: string;\n}\n\n/** The outcome of one run. */\ninterface MigrationReport {\n /** Migration filenames, in apply order. */\n files: string[];\n problems: MigrationProblem[];\n /** The lock as it reads after the run. */\n lock: MigrationLockFile | null;\n}\n\n/**\n * The lock's filename, beside the `.sql` files.\n *\n * Named `migrations.lock.json` rather than `migrations.json` so it cannot be\n * mistaken for a migration: wrangler applies `*.sql` only, and a lock named like\n * one would be a deploy-time mystery.\n */\nconst LOCK_NAME = 'migrations.lock.json';\n\n/** The filename shape every migration must have. `NNNN_` is fixed at four digits. */\nconst NAME_PATTERN = /^(\\d{4})_[a-z0-9_]+\\.sql$/;\n\n/** The squashed-baseline shape. The highest-numbered match is the baseline. */\nconst SQUASH_PATTERN = /^\\d{4}_squash\\.sql$/;\n\n/** The lock's format version. Bumped only on an incompatible shape change. */\nconst LOCK_VERSION = 1;\n\nfunction sha256Hex(content: string): string {\n return createHash('sha256').update(content, 'utf8').digest('hex');\n}\n\n/**\n * The highest-numbered `NNNN_squash.sql` on disk, or `undefined` when the repo\n * has not squashed — in which case every migration is incremental and therefore\n * every one of them is immutable.\n */\nexport function baselineOf(files: readonly string[]): string | undefined {\n let highest: string | undefined;\n for (const name of files) {\n if (SQUASH_PATTERN.test(name) && (highest === undefined || name > highest)) {\n highest = name;\n }\n }\n return highest;\n}\n\n/** True when `name` is at or before the baseline, i.e. the set a squash absorbs. */\nfunction isSubsumed(name: string, baseline: string | undefined): boolean {\n return baseline !== undefined && name <= baseline;\n}\n\n/**\n * Read the migration set and validate its shape without consulting the lock.\n *\n * The lock is read here too, so one walk answers both \"what is on disk\" and \"what\n * is recorded\"; a lock that is merely *absent* is reported by `verifyMigrations`\n * rather than here, because that is the bootstrap case rather than a defect.\n */\nfunction inspectMigrations(migrationsDir: string): MigrationReport {\n const problems: MigrationProblem[] = [];\n if (!existsSync(migrationsDir)) {\n problems.push({ problem: `${migrationsDir} does not exist` });\n return { files: [], problems, lock: null };\n }\n\n // Top level only, matching wrangler's default `${migrationsDir}/*.sql`, so the\n // lock describes exactly the set wrangler will run. `migrations.lock.json` is\n // not one of them, because it is not a `.sql` file.\n const files = readdirSync(migrationsDir)\n .filter((name) => name.endsWith('.sql'))\n .sort((left, right) => left.localeCompare(right));\n\n for (const name of files) {\n if (!NAME_PATTERN.test(name)) {\n problems.push({ problem: `${name} does not match NNNN_snake_case.sql` });\n }\n }\n\n const baseline = baselineOf(files);\n const prefixes = files.map((name) => NAME_PATTERN.exec(name)?.[1]);\n\n // Strictly increasing: the property D1 actually depends on. A duplicate or a\n // descending prefix means two files compete for the same slot in the apply\n // order, and which one wins is a lexicographic tiebreak nobody intended.\n for (let index = 1; index < prefixes.length; index += 1) {\n const previous = prefixes[index - 1];\n const current = prefixes[index];\n if (previous !== undefined && current !== undefined && current <= previous) {\n problems.push({\n problem: `${files[index] ?? '?'} sorts at or before ${files[index - 1] ?? '?'} — D1 applies in filename order, so one of the two can never run`,\n });\n }\n }\n\n // Contiguity is checked only with no squash on disk: a squash deletes the files\n // it absorbs, so numbering restarts wherever it starts and a hole is the\n // expected shape rather than a defect.\n if (baseline === undefined) {\n for (let index = 0; index < prefixes.length; index += 1) {\n const expected = String(index + 1).padStart(4, '0');\n if (prefixes[index] !== expected) {\n problems.push({\n problem: `migration numbering is not contiguous: expected ${expected}_*.sql, found ${files[index] ?? '?'}`,\n });\n }\n }\n }\n\n const lockPath = join(migrationsDir, LOCK_NAME);\n let lock: MigrationLockFile | null = null;\n if (existsSync(lockPath)) {\n try {\n lock = JSON.parse(readFileSync(lockPath, 'utf8')) as MigrationLockFile;\n } catch {\n problems.push({ problem: `${LOCK_NAME} is not valid JSON` });\n }\n }\n\n return { files, problems, lock };\n}\n\n/**\n * The lock as `--write` would leave it.\n *\n * `null` when the existing lock cannot be trusted as a base, which is exactly\n * when a `--write` must refuse rather than overwrite contents it failed to\n * understand. A lock that is merely *absent* is not malformed: that is the\n * bootstrap case, and it is built from disk like any other.\n */\nfunction buildUpdatedLock(\n migrationsDir: string,\n files: readonly string[],\n existing: MigrationLockFile | null,\n baseline: string | undefined,\n): MigrationLockFile | null {\n const digestOf = (name: string): string => sha256Hex(readFileSync(join(migrationsDir, name), 'utf8'));\n\n if (existing === null) {\n return { version: LOCK_VERSION, ...(baseline !== undefined && { baseline }), migrations: files.map((name) => ({ name, sha256: digestOf(name) })) };\n }\n\n const kept = new Map<string, string>();\n for (const file of files) {\n const recorded = existing.migrations.find((entry) => entry.name === file);\n if (recorded === undefined) continue;\n // The baseline is the one file a squash is allowed to rewrite.\n kept.set(file, file === baseline ? digestOf(file) : recorded.sha256);\n }\n // Unlocked files are added — that is the new-migration case. Every other entry\n // is carried across untouched, so an `edited` finding survives the write.\n for (const file of files) {\n if (!kept.has(file) && !existing.migrations.some((entry) => entry.name === file)) {\n kept.set(file, digestOf(file));\n }\n }\n // Entries the baseline absorbed are dropped: committing a squash looks exactly\n // like this, and neither it nor a rewritten baseline can hide a divergence,\n // because a database that applied those files already has them recorded in D1's\n // own `d1_migrations`.\n for (const entry of existing.migrations) {\n if (!files.includes(entry.name) && !isSubsumed(entry.name, baseline)) {\n kept.set(entry.name, entry.sha256);\n }\n }\n\n return {\n version: LOCK_VERSION,\n ...(baseline !== undefined && { baseline }),\n migrations: [...kept]\n .sort(([left], [right]) => left.localeCompare(right))\n .map(([name, sha256]) => ({ name, sha256 })),\n };\n}\n\n/** Verify (or with `write: true`, record) the lock against the files. */\nfunction verifyMigrations(migrationsDir: string, options: { write?: boolean } = {}): MigrationReport {\n const report = inspectMigrations(migrationsDir);\n const baseline = baselineOf(report.files);\n\n // A malformed lock is a finding in its own right, and a `--write` must not\n // overwrite contents it failed to understand.\n if (report.problems.length > 0) {\n return report;\n }\n\n if (options.write === true) {\n const updated = buildUpdatedLock(migrationsDir, report.files, report.lock, baseline);\n const next = `${JSON.stringify(updated, null, 2)}\\n`;\n const path = join(migrationsDir, LOCK_NAME);\n const before = existsSync(path) ? readFileSync(path, 'utf8') : null;\n if (before !== next) {\n writeFileSync(path, next, 'utf8');\n }\n report.lock = updated;\n return report;\n }\n\n const lock = report.lock;\n if (lock === null) {\n report.problems.push({ problem: `${LOCK_NAME} is missing — run migrations:lock` });\n return report;\n }\n\n const recorded = new Map(lock.migrations.map((entry) => [entry.name, entry.sha256]));\n for (const name of report.files) {\n const expected = recorded.get(name);\n if (expected === undefined) {\n report.problems.push({ problem: `${name} has no lock entry — run migrations:lock` });\n continue;\n }\n // At or before the baseline, a squash rewrites its own file, and that is the\n // whole reason a baseline exists.\n if (isSubsumed(name, baseline)) continue;\n const actual = sha256Hex(readFileSync(join(migrationsDir, name), 'utf8'));\n if (actual !== expected) {\n report.problems.push({\n problem: `${name} changed after locking (expected ${expected.slice(0, 12)}…, got ${actual.slice(0, 12)}…)`,\n });\n }\n }\n\n for (const entry of lock.migrations) {\n if (report.files.includes(entry.name)) continue;\n if (isSubsumed(entry.name, baseline)) continue;\n report.problems.push({ problem: `${entry.name} is in the lock but no longer exists` });\n }\n\n // A file sorting before the newest locked one can never reach a database that\n // has already applied that newest one, so its statements would only run on a\n // fresh build — the same silent split the checksum exists to prevent.\n const newest = [...recorded.keys()].sort((left, right) => left.localeCompare(right)).at(-1);\n if (newest !== undefined) {\n for (const name of report.files) {\n if (name < newest && !recorded.has(name)) {\n report.problems.push({\n problem: `${name} sorts before ${newest}, which is already locked — D1 applies in filename order, so it would never run on a database that has applied ${newest}`,\n });\n }\n }\n }\n\n return report;\n}\n\n/** CLI entry: `verifyMigrationsCli(['[migrations-dir]?', '--write'?'])`. */\nfunction verifyMigrationsCli(argv: readonly string[] = process.argv.slice(2)): number {\n const dir = argv.find((arg) => !arg.startsWith('--')) ?? 'migrations';\n const write = argv.includes('--write');\n const report = verifyMigrations(dir, { write });\n if (report.problems.length > 0) {\n console.error(`Migration validation failed for ${dir}:`);\n for (const problem of report.problems) console.error(` - ${problem.problem}`);\n return 1;\n }\n if (write) {\n console.log(`Migration lock written (${report.files.length} files).`);\n return 0;\n }\n console.log(`Migration validation passed (${report.files.length} files, lock in sync).`);\n return 0;\n}\n\nexport { inspectMigrations, verifyMigrations, verifyMigrationsCli, LOCK_NAME, LOCK_VERSION };\nexport type { MigrationEntry, MigrationLockFile, MigrationProblem, MigrationReport };\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(verifyMigrationsCli(process.argv.slice(2)));\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"verify-spa-shell.js","sourceRoot":"","sources":["../../src/scripts/verify-spa-shell.ts"],"names":[],"mappings":";AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAE7C;;;;;;;GAOG;AACH,MAAM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GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC;AAEzF,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,SAAS,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;AAE7F,MAAM,EAAE,QAAQ,EAAE,GAAG,cAAc,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC;AAE9C,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;IACxB,OAAO,CAAC,KAAK,CAAC,yBAAyB,CAAC,CAAC;IACzC,KAAK,MAAM,OAAO,IAAI,QAAQ;QAAE,OAAO,CAAC,KAAK,CAAC,OAAO,OAAO,EAAE,CAAC,CAAC;IAChE,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC;AAED,OAAO,CAAC,GAAG,CAAC,2BAA2B,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,qCAAqC,CAAC,YAAY,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,eAAe,CAAC,IAAI,CAAC,CAAC","sourcesContent":["#!/usr/bin/env tsx\n/**\n * Fail when the SPA shell the API worker serves is missing or self-inconsistent.\n *\n * Provenance: Durable-DAV's and Durable-DAV-Router's `scripts/verify-spa-shell.mjs`\n * and Edge-Sonic's typed `scripts/build/verify-spa-shell.ts`. The rules — which of\n * the ways a shell can be wrong to look for — live in `spa-shell.ts`, so they are\n * unit tested without a build on disk; this file is the entrypoint that turns the\n * verdict into an exit code.\n *\n * What it catches:\n *\n * - the `postinstall` stub, or no build at all, still in place;\n * - `spa-shell.ts` referencing `/assets/...` bundles that were not emitted (a\n * partially cleaned or half-copied `dist/`, which serves a shell whose JS 404s\n * and therefore renders no operator UI at all);\n * - `spa-shell.ts` and `apps/web/dist/index.html` disagreeing, i.e. only one of\n * the two halves of the build was refreshed.\n *\n * **The build is a precondition of this check, not a convenience.** Both paths are\n * gitignored and `postinstall` writes a deliberately empty stub, so verifying\n * without building cannot pass — and it fails with precisely the message above,\n * which is the check working rather than the check being wrong.\n *\n * Usage, from the repo root:\n *\n * ```bash\n * pnpm exec tsx scripts/verify-spa-shell.ts # defaults to ./ as root\n * pnpm exec tsx scripts/verify-spa-shell.ts --root /path/to/repo\n * ```\n */\nimport path from 'node:path';\nimport { fileURLToPath } from 'node:url';\nimport { verifySpaShell } from './spa-shell';\n\n/**\n * The repository root, derived from this file rather than from `process.cwd()`.\n *\n * Two levels up, because this file sits in `scripts/`. Deriving it means the gate\n * reads the same tree whatever directory it is invoked from — which is the\n * difference between a gate and a gate that passes because nobody ran it from the\n * right place.\n */\nconst REPOSITORY_ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');\n\nconst root = process.argv[2] === undefined ? REPOSITORY_ROOT : path.resolve(process.argv[2]);\n\nconst { problems } = verifySpaShell({ root });\n\nif (problems.length > 0) {\n console.error('SPA shell check failed:');\n for (const problem of problems) console.error(` - ${problem}`);\n process.exit(1);\n}\n\nconsole.log(`SPA shell check passed (${path.join(root, 'apps/api/src/generated/spa-shell.ts')} matches ${path.join(root, 'apps/web/dist')}).`);\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../../../src/scripts/wrangler-config/cli.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAElD;;;;;GAKG;AACH,MAAM,UAAU,WAAW,CAAC,IAAuB,EAAE,KAAc;IACjE,IAAI,CAAC;QACH,+EAA+E;QAC/E,qDAAqD;QACrD,2DAA2D;QAC3D,OAAO,YAAY,CAAC,MAAM,EAAE,CAAC,MAAM,EAAE,UAAU,EAAE,GAAG,IAAI,CAAC,EAAE;YACzD,QAAQ,EAAE,MAAM;YAChB,KAAK,EAAE,CAAC,KAAK,KAAK,SAAS,CAAC,CA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AAC;IAAC,MAAM,CAAC;QACP,4CAA4C;IAC9C,CAAC;IACD,MAAM,IAAI,KAAK,CAAC,mCAAmC,kBAAkB,cAAc,MAAM,EAAE,CAAC,CAAC;AAC/F,CAAC","sourcesContent":["/**\n * Running `wrangler` and reading its output.\n *\n * Provenance: ported from Edge-Sonic's `scripts/lib/wrangler-config/cli.ts`.\n */\n\nimport { execFileSync } from 'node:child_process';\n\n/**\n * Runs a wrangler subcommand and returns stdout.\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 */\nexport function runWrangler(args: readonly string[], input?: string): string {\n try {\n // `pnpm` is resolved from PATH deliberately: the scripts run on CI runners and\n // in local shells, and both resolve it the same way.\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\n/**\n * Parses a JSON array from a command's stdout, naming the command on failure.\n *\n * Several wrangler subcommands print a human-readable table when they detect a\n * TTY, so \"not JSON\" is an expected outcome that the caller often has a table\n * parser for. Passing the command description turns that into a catchable,\n * self-explanatory error instead of an unlabelled `SyntaxError`.\n */\nexport function parseJsonArray<T>(output: string, commandDescription: string): T[] {\n try {\n const parsed: unknown = JSON.parse(output);\n if (Array.isArray(parsed)) {\n return parsed as T[];\n }\n } catch {\n // Fall through to the explicit error below.\n }\n throw new Error(`Expected JSON array output from ${commandDescription}. Output:\\n${output}`);\n}\n"]}
|
|
@@ -1 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IAAI,QAAQ,CAAC,MAAM,CAAC,IAAI,KAAK,SAAS,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,KAAK,IAAI,IAAI,OAAO,QAAQ,CAAC,MAAM,CAAC,IAAI,KAAK,QAAQ,IAAI,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC;QAC7J,MAAM,IAAI,KAAK,CAAC,iFAAiF,CAAC,CAAC;IACrG,CAAC;IACD,IAAI,QAAQ,CAAC,MAAM,CAAC,IAAI,KAAK,SAAS,IAAI,QAAQ,CAAC,MAAM,CAAC,IAAI,KAAK,IAAI,EAAE,CAAC;QACxE,OAAO,GAAG,gBAAgB,CAAC,OAAO,EAAE,CAAC,MAAM,CAAC,EAAE,EAAE,CAAC,CAAC;IACpD,CAAC;IACD,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,OAAO,EAAE,CAAC;QACnC,OAAO,GAAG,gBAAgB,CAAC,OAAO,EAAE,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,KAAK,CAAC,CAAC;IAC5D,CAAC;IACD,WAAW,CAAC,OAAO,CAAC,CAAC;IACrB,OAAO,CAAC,GAAG,CAAC,WAAW,OAAO,CAAC,MAAM,4BAA4B,OAAO,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC;AAC1G,CAAC","sourcesContent":["/**\n * Reading, writing and patching `wrangler.jsonc`.\n *\n * Provenance: ported from Edge-Sonic's `scripts/lib/wrangler-config/patches.ts`.\n *\n * The config is JSONC — `//` comments and trailing commas — so it is edited\n * through jsonc-parser's `modify`/`applyEdits` rather than parsed and re-serialized.\n * A round trip through `JSON.parse` would drop every comment and reformat the\n * file, which is a diff nobody can review and a reason to regenerate the config by\n * hand instead.\n */\n\nimport { copyFileSync, readFileSync, writeFileSync } from 'node:fs';\nimport { applyEdits, modify, parse } from 'jsonc-parser';\nimport { CONFIG_PATH, TEMPLATE_PATH, type WranglerConfig } from './types';\n\n/** The config's current text and its parsed form. */\nexport interface ConfigFile {\n content: string;\n config: WranglerConfig;\n}\n\nexport function readConfig(): ConfigFile {\n const content = readFileSync(CONFIG_PATH, 'utf8');\n return { content, config: parse(content) as WranglerConfig };\n}\n\n/**\n * Apply one edit to the config text, preserving comments and formatting.\n */\nexport function writeConfigValue(content: string, path: Array<string | number>, value: unknown): string {\n const edits = modify(content, path, value, { formattingOptions: { insertSpaces: true, tabSize: 2, eol: '\\n' } });\n return applyEdits(content, edits);\n}\n\n/** Write the config, guaranteeing a trailing newline so Prettier sees a fixed point. */\nexport function writeConfig(content: string): void {\n writeFileSync(CONFIG_PATH, content.endsWith('\\n') ? content : `${content}\\n`);\n}\n\n/**\n * The top-level keys a caller wants to merge into the config, from the environment.\n *\n * `WRANGLER_PATCH_JSON` is how a repository variable supplies per-environment\n * settings without a second file: a repo with one worker and three environments\n * patches the routes and the vars rather than keeping three templates in step.\n */\nexport function parseTopLevelPatch(): Record<string, unknown> | undefined {\n return parseJsonObject(process.env['WRANGLER_PATCH_JSON'], 'WRANGLER_PATCH_JSON', 'a JSON object');\n}\n\n/** The `vars` entries a caller wants to merge, from the environment. */\nexport function parseVarsPatch(): Record<string, string> | undefined {\n const parsed = parseJsonObject(process.env['WRANGLER_VARS_PATCH_JSON'], 'WRANGLER_VARS_PATCH_JSON', 'a JSON object of string values');\n if (parsed === undefined) {\n return undefined;\n }\n const patch: Record<string, string> = {};\n for (const [key, value] of Object.entries(parsed)) {\n if (!key.trim()) {\n throw new Error('WRANGLER_VARS_PATCH_JSON contains an empty variable name.');\n }\n if (typeof value !== 'string') {\n throw new TypeError(`WRANGLER_VARS_PATCH_JSON value for ${key} must be a string.`);\n }\n patch[key] = value;\n }\n return patch;\n}\n\nfunction parseJsonObject(raw: string | undefined, name: string, expected: string): Record<string, unknown> | undefined {\n if (raw === undefined || !raw.trim()) {\n return undefined;\n }\n let parsed: unknown;\n try {\n parsed = JSON.parse(raw) as unknown;\n } catch {\n throw new Error(`${name} must be ${expected}.`);\n }\n if (parsed === null || typeof parsed !== 'object' || Array.isArray(parsed)) {\n throw new Error(`${name} must be ${expected}.`);\n }\n return parsed as Record<string, unknown>;\n}\n\n/**\n * Materialize the config: the repository variable when it is set, otherwise the\n * committed template.\n */\nexport function prepareConfigFile(): void {\n const dumpedConfig = process.env['WRANGLER_JSONC'];\n if (dumpedConfig?.trim()) {\n writeConfig(dumpedConfig);\n console.log('Wrote wrangler.jsonc from WRANGLER_JSONC repository variable.');\n return;\n }\n copyFileSync(TEMPLATE_PATH, CONFIG_PATH);\n console.log('WRANGLER_JSONC is empty; copied apps/api/wrangler.template.jsonc to wrangler.jsonc.');\n}\n\n/**\n * Refuse a config older than the template requires.\n *\n * The template is the one file in the repo that says which wrangler behaviour the\n * worker was written against, and a config written by an older template can name\n * bindings the worker no longer reads. Failing here rather than at deploy time is\n * the whole reason the check exists.\n */\nexport function ensureMinimumConfigVersion(): void {\n const template = parse(readFileSync(TEMPLATE_PATH, 'utf8')) as { $minimumVersion?: unknown };\n if (typeof template.$minimumVersion !== 'number') {\n return;\n }\n const { config } = readConfig();\n const currentVersion = config.$version;\n if (typeof currentVersion !== 'number' || currentVersion < template.$minimumVersion) {\n throw new Error(\n `wrangler.jsonc version (${typeof currentVersion === 'number' ? currentVersion : 'missing'}) is below minimum template version (${template.$minimumVersion}). Regenerate it from apps/api/wrangler.template.jsonc.`,\n );\n }\n}\n\nexport function applyTopLevelPatch(): void {\n const patch = parseTopLevelPatch();\n const entries = Object.entries(patch ?? {});\n if (entries.length === 0) {\n return;\n }\n let { content } = readConfig();\n for (const [key, value] of entries) {\n content = writeConfigValue(content, [key], value);\n }\n writeConfig(content);\n console.log(`Applied ${entries.length} Wrangler top-level patch entr${entries.length === 1 ? 'y' : 'ies'}.`);\n}\n\nexport function applyVarsPatch(): void {\n const patch = parseVarsPatch();\n const entries = Object.entries(patch ?? {});\n if (entries.length === 0) {\n return;\n }\n const prepared = readConfig();\n let content = prepared.content;\n if (prepared.config.vars !== undefined && (prepared.config.vars === null || typeof prepared.config.vars !== 'object' || Array.isArray(prepared.config.vars))) {\n throw new Error('wrangler.jsonc vars must be an object before applying WRANGLER_VARS_PATCH_JSON.');\n }\n if (prepared.config.vars === undefined || prepared.config.vars === null) {\n content = writeConfigValue(content, ['vars'], {});\n }\n for (const [key, value] of entries) {\n content = writeConfigValue(content, ['vars', key], value);\n }\n writeConfig(content);\n console.log(`Applied ${entries.length} Wrangler vars patch entr${entries.length === 1 ? 'y' : 'ies'}.`);\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resources.js","sourceRoot":"","sources":["../../../src/scripts/wrangler-config/resources.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAGH,OAAO,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AACrC,OAAO,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AAC/D,OAAO,EAEL,cAAc,EACd,0BAA0B,EAC1B,yBAAyB,EACzB,YAAY,EACZ,mBAAmB,EACnB,oBAAoB,GAKrB,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AACpD,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAQtE,0EAA0E;AAC1E,MAAM,UAAU,OAAO,CAAC,QAAoB;IAC1C,OAAO,QAAQ,CAAC,IAAI,IAAI,QAAQ,CAAC,WAAW,IAAI,QAAQ,CAAC,EAAE,CAAC;AAC9D,CAAC;AAED,MAAM,UAAU,eAAe;IAC7B,OAAO,cAAc,CAAa,WAAW,CAAC,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC,EAAE,yBAAyB,CAAC,CAAC;AACtG,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,gBAAgB,CAA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,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC","sourcesContent":["/**\n * Creating the resources `wrangler.jsonc` names, and writing their real ids over\n * the placeholders.\n *\n * Provenance: ported from Edge-Sonic's `scripts/lib/wrangler-config/resources.ts`.\n *\n * The placeholder rule: a template carries an all-zero id meaning \"resolve me\",\n * and a config carrying one cannot be deployed. So provisioning walks the config,\n * creates what is missing, and patches the id in place. A placeholder with nothing\n * to create it *under* — a KV id with no binding, a D1 id with no name — is\n * refused rather than skipped, because a silently skipped placeholder is a deploy\n * that fails later with no link back to the reason.\n */\n\nimport { writeFileSync } from 'node:fs';\nimport { parse } from 'jsonc-parser';\nimport { parseWranglerTableRows } from '../lib/wrangler-table';\nimport {\n CONFIG_PATH,\n DEFAULT_HEX_ID,\n DEFAULT_KV_NAMESPACE_NAMES,\n DEFAULT_SECRET_STORE_NAME,\n DEFAULT_UUID,\n DEFAULT_WORKER_NAME,\n VECTORIZE_DIMENSIONS,\n type D1Database,\n type KVNamespace,\n type SecretStore,\n type WranglerConfig,\n} from './types';\nimport { parseJsonArray, runWrangler } from './cli';\nimport { readConfig, writeConfig, writeConfigValue } from './patches';\n\n/** What `ensure*` did, so a caller can act on the difference. */\nexport interface Provisioned {\n id: string;\n created: boolean;\n}\n\n/** The id a D1 database is reported under, whichever key the CLI used. */\nexport function getD1Id(database: D1Database): string | undefined {\n return database.uuid ?? database.database_id ?? database.id;\n}\n\nexport function listD1Databases(): D1Database[] {\n return parseJsonArray<D1Database>(runWrangler(['d1', 'list', '--json']), 'wrangler d1 list --json');\n}\n\n/**\n * The D1 database `binding` names, created when it does not exist.\n *\n * Whether it was created is reported, not inferred: a database created moments ago\n * holds no user data, so a backup workflow must refuse to upload its empty dump.\n * The caller cannot re-derive that from the config, because this very function\n * patches the placeholder away before the reader ever runs.\n */\nexport function ensureD1Database(databaseName: string): Provisioned {\n let database = listD1Databases().find((candidate) => candidate.name === databaseName);\n let created = false;\n if (database === undefined) {\n console.log(`Creating D1 database: ${databaseName}`);\n runWrangler(['d1', 'create', databaseName]);\n database = listD1Databases().find((candidate) => candidate.name === databaseName);\n created = true;\n }\n const databaseId = database === undefined ? undefined : getD1Id(database);\n if (databaseId === undefined || databaseId === '') {\n throw new Error(`Unable to discover D1 database ID for ${databaseName}.`);\n }\n return { id: databaseId, created };\n}\n\nexport function listKVNamespaces(): KVNamespace[] {\n return parseJsonArray<KVNamespace>(runWrangler(['kv', 'namespace', 'list']), 'wrangler kv namespace list');\n}\n\n/** The namespace name a binding's namespace is created under. */\nexport function getKVNamespaceName(config: WranglerConfig, binding: string): string {\n return DEFAULT_KV_NAMESPACE_NAMES[binding] ?? `${config.name ?? DEFAULT_WORKER_NAME}-${binding.toLowerCase()}`;\n}\n\nexport function ensureKVNamespace(config: WranglerConfig, binding: string): Provisioned {\n const namespaceName = getKVNamespaceName(config, binding);\n const candidateNames = new Set([namespaceName, `${config.name ?? DEFAULT_WORKER_NAME}-${binding}`, binding]);\n let namespace = listKVNamespaces().find((candidate) => {\n const candidateName = candidate.title ?? candidate.name;\n return candidate.id !== undefined && candidateName !== undefined && candidateNames.has(candidateName);\n });\n let created = false;\n if (namespace === undefined) {\n console.log(`Creating KV namespace: ${namespaceName}`);\n runWrangler(['kv', 'namespace', 'create', namespaceName]);\n namespace = listKVNamespaces().find(\n (candidate) => candidate.id !== undefined && (candidate.title ?? candidate.name) === namespaceName,\n );\n created = true;\n }\n if (namespace?.id === undefined) {\n throw new Error(`Unable to discover KV namespace ID for ${namespaceName}.`);\n }\n return { id: namespace.id, created };\n}\n\n/** The bindings a deployment always needs, whether or not a custom config lists them. */\nexport function getRequiredKvBindings(): string[] {\n return Object.keys(DEFAULT_KV_NAMESPACE_NAMES);\n}\n\n/**\n * Add the always-needed KV bindings a hand-written config left out.\n *\n * A config supplied through `WRANGLER_JSONC` is edited by hand and drifts; without\n * this the worker starts with an unbound `CACHE` and fails on the first read.\n */\nexport function ensureRequiredKvBindings(content: string, config: WranglerConfig): string {\n const existing = new Set((config.kv_namespaces ?? []).map((namespace) => namespace.binding).filter((binding) => binding !== undefined));\n const missing = getRequiredKvBindings().filter((binding) => !existing.has(binding));\n if (missing.length === 0) {\n return content;\n }\n const next = [...(config.kv_namespaces ?? [])];\n for (const binding of missing) {\n console.log(`Adding missing KV namespace binding: ${binding}`);\n next.push({ binding, id: DEFAULT_HEX_ID });\n }\n return writeConfigValue(content, ['kv_namespaces'], next);\n}\n\n/** The stores in a `secrets-store store list` table. */\nexport function parseSecretStoresTable(output: string): SecretStore[] {\n const stores: SecretStore[] = [];\n // Through the shared table parser rather than a second inline split: `wrangler`\n // renders through `cli-table3`, whose cells are separated by U+2502 and are *not*\n // space-aligned, so a parser written for aligned output silently matches nothing\n // — which reads as \"the store does not exist\" and makes provisioning create a\n // duplicate.\n for (const row of parseWranglerTableRows(output)) {\n const name = row[0];\n const id = row[1];\n // Store ids are 32 hex characters; a row without one is a header, a border, or\n // an unrelated column, and is skipped rather than stored with an undefined id.\n if (name !== undefined && id !== undefined && /^[a-f0-9]{32}$/i.test(id)) {\n stores.push({ name, id });\n }\n }\n return stores;\n}\n\nexport function listSecretStores(): SecretStore[] {\n const output = runWrangler(['secrets-store', 'store', 'list', '--remote']);\n try {\n return parseJsonArray<SecretStore>(output, 'wrangler secrets-store store list --remote');\n } catch {\n // The subcommand prints a table rather than JSON on some versions.\n return parseSecretStoresTable(output);\n }\n}\n\nexport function ensureSecretStore(): string {\n const stores = listSecretStores();\n const existing = stores.find((candidate) => candidate.name === DEFAULT_SECRET_STORE_NAME) ?? stores[0];\n if (existing !== undefined) {\n return existing.id;\n }\n console.log(`Creating Secrets Store: ${DEFAULT_SECRET_STORE_NAME}`);\n const output = runWrangler(['secrets-store', 'store', 'create', DEFAULT_SECRET_STORE_NAME, '--remote']);\n const createdStoreId = /ID:\\s*([a-f0-9]{32})/i.exec(output)?.[1];\n if (createdStoreId !== undefined) {\n return createdStoreId;\n }\n // The create output did not name the id, so read it back rather than guessing.\n const refreshed = listSecretStores();\n const store = refreshed.find((candidate) => candidate.name === DEFAULT_SECRET_STORE_NAME) ?? refreshed[0];\n if (store?.id === undefined) {\n throw new Error(`Unable to discover Secrets Store ID for ${DEFAULT_SECRET_STORE_NAME}.`);\n }\n return store.id;\n}\n\n/** Create a queue when it is absent, reporting whether it had to be created. */\nexport function ensureQueue(queueName: string): boolean {\n try {\n runWrangler(['queues', 'info', queueName]);\n console.log(`Queue ${queueName} already exists.`);\n return false;\n } catch {\n console.log(`Creating queue: ${queueName}`);\n runWrangler(['queues', 'create', queueName]);\n return true;\n }\n}\n\n/**\n * Queue names a deployment needs, in first-seen order.\n *\n * Producers and consumers name the same queue twice — one queue, two roles — and a\n * name appearing in both must be created once. Pure so it is testable without\n * wrangler.\n */\nexport function queueNamesIn(config: WranglerConfig): string[] {\n const names: string[] = [];\n const seen = new Set<string>();\n for (const producer of config.queues?.producers ?? []) {\n if (producer.queue === '' || seen.has(producer.queue)) continue;\n seen.add(producer.queue);\n names.push(producer.queue);\n }\n for (const consumer of config.queues?.consumers ?? []) {\n if (consumer.queue === '' || seen.has(consumer.queue)) continue;\n seen.add(consumer.queue);\n names.push(consumer.queue);\n }\n return names;\n}\n\nexport function ensureVectorizeIndex(indexName: string, dimensions: number): void {\n try {\n runWrangler(['vectorize', 'info', indexName]);\n console.log(`Vectorize index ${indexName} already exists.`);\n } catch {\n console.log(`Creating Vectorize index: ${indexName} with ${dimensions} dimensions`);\n runWrangler(['vectorize', 'create', indexName, `--dimensions=${dimensions}`, '--metric=cosine']);\n }\n}\n\n/** Replace each placeholder D1 `database_id` with a real one. */\nfunction provisionD1Databases(content: string, config: WranglerConfig, created: string[]): string {\n let patched = content;\n for (const [index, database] of config.d1_databases?.entries() ?? []) {\n if (database.database_id !== DEFAULT_UUID) continue;\n if (database.database_name === undefined || database.database_name === '') {\n throw new Error(`D1 database binding ${database.binding ?? index} has a placeholder database_id but no database_name.`);\n }\n const resolved = ensureD1Database(database.database_name);\n if (resolved.created) {\n created.push(`d1:${database.database_name}`);\n }\n console.log(`Using D1 database ${database.database_name}: ${resolved.id}`);\n patched = writeConfigValue(patched, ['d1_databases', index, 'database_id'], resolved.id);\n }\n return patched;\n}\n\n/** Replace each placeholder KV namespace id with a real one. */\nfunction provisionKvNamespaces(content: string, config: WranglerConfig, created: string[]): string {\n let patched = content;\n for (const [index, namespace] of config.kv_namespaces?.entries() ?? []) {\n if (namespace.id !== DEFAULT_HEX_ID) continue;\n if (namespace.binding === undefined || namespace.binding === '') {\n throw new Error(`KV namespace at index ${index} has a placeholder id but no binding.`);\n }\n const resolved = ensureKVNamespace(config, namespace.binding);\n const namespaceName = getKVNamespaceName(config, namespace.binding);\n if (resolved.created) {\n created.push(`kv:${namespaceName}`);\n }\n console.log(`Using KV namespace ${namespaceName}: ${resolved.id}`);\n patched = writeConfigValue(patched, ['kv_namespaces', index, 'id'], resolved.id);\n }\n return patched;\n}\n\n/**\n * Point every placeholder Secrets Store `store_id` at one store, creating it if\n * absent. `existed` is read **before** the create, because whether the store was\n * created is what the caller reports.\n */\nfunction provisionSecretStore(content: string, config: WranglerConfig, created: string[]): string {\n const placeholders = (config.secrets_store_secrets ?? [])\n .map((secret, index) => ({ secret, index }))\n .filter(({ secret }) => secret.store_id === DEFAULT_HEX_ID);\n if (placeholders.length === 0) {\n return content;\n }\n const existed = listSecretStores().some((store) => store.name === DEFAULT_SECRET_STORE_NAME);\n const storeId = ensureSecretStore();\n if (!existed) {\n created.push(`secrets-store:${DEFAULT_SECRET_STORE_NAME}`);\n }\n console.log(`Using Secrets Store: ${storeId}`);\n return placeholders.reduce((patched, { index }) => writeConfigValue(patched, ['secrets_store_secrets', index, 'store_id'], storeId), content);\n}\n\n/**\n * Create every resource the config names, and write the real ids over the\n * placeholders.\n *\n * Returns what it had to create, as `<kind>:<name>` — returned rather than logged,\n * because a caller acts on it: the backup workflow refuses to export a D1 database\n * that appears here, since one created moments ago holds no user data and an empty\n * dump uploaded on schedule is a false sense of safety.\n */\nexport function provisionWranglerResources(): string[] {\n const created: string[] = [];\n let { content, config } = readConfig();\n\n content = ensureRequiredKvBindings(content, config);\n config = parse(content) as WranglerConfig;\n\n // Each of the three below re-parses before it patches, because each writes into\n // the config text the previous one produced. They are separate functions because\n // they are separate resources with separate rules, and one loop holding all\n // three would read as a single resource list with the differences hidden in the\n // bodies.\n content = provisionD1Databases(content, config, created);\n config = parse(content) as WranglerConfig;\n\n content = provisionKvNamespaces(content, config, created);\n config = parse(content) as WranglerConfig;\n\n content = provisionSecretStore(content, config, created);\n\n writeConfig(content);\n\n config = parse(content) as WranglerConfig;\n for (const queueName of queueNamesIn(config)) {\n if (ensureQueue(queueName)) {\n created.push(`queue:${queueName}`);\n }\n }\n\n // Vectorize indexes are name-based, so nothing in the file is patched — but the\n // created names are still reported like every other resource, so a deploy log\n // shows what appeared.\n for (const binding of config.vectorize ?? []) {\n ensureVectorizeIndex(binding.index_name, VECTORIZE_DIMENSIONS);\n }\n\n return created;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/scripts/wrangler-config/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,qCAAqC;AACrC,MAAM,CAAC,MAAM,WAAW,GAAG,OAAO,CAAC,GAAG,CAAC,sBAAsB,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,gBAAgB,CAAC,CAAC;AAE7G,8DAA8D;AAC9D,MAAM,CAAC,MAAM,aAAa,GAAG,OAAO,CAAC,GAAG,CAAC,wBAAwB,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,kCAAkC,CAAC,CAAC;AAEnI;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,sCAAsC,CAAC;AAEnE,wEAAwE;AACxE,MAAM,CAAC,MAAM,cAAc,GAAG,kCAAkC,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AAE,GAAG,mBAAmB,QAAQ;CACtC,CAAC;AAEF,2DAA2D;AAC3D,MAAM,CAAC,MAAM,oBAAoB,GAAG,IAAI,CAAC","sourcesContent":["/**\n * Shared paths, placeholders and shape definitions for the wrangler config helpers.\n *\n * Provenance: ported from Edge-Sonic's `scripts/lib/wrangler-config/types.ts`.\n * Every script that reads or writes `wrangler.jsonc` resolves it here, so the\n * backup workflow cannot end up inspecting a different file than the deploy\n * materialized.\n *\n * The paths default to `process.cwd()`, which is the repo root in every consumer:\n * the scripts run as `pnpm exec tsx scripts/deploy/…` from there. `WRANGLER_CONFIG_PATH`\n * / `WRANGLER_TEMPLATE_PATH` override them for a caller that is not in the repo\n * root, which is the one case the cwd default gets wrong.\n */\n\nimport path from 'node:path';\n\n/** The config the deploy targets. */\nexport const CONFIG_PATH = process.env['WRANGLER_CONFIG_PATH'] ?? path.join(process.cwd(), 'wrangler.jsonc');\n\n/** The committed template the config is materialized from. */\nexport const TEMPLATE_PATH = process.env['WRANGLER_TEMPLATE_PATH'] ?? path.join(process.cwd(), 'apps/api/wrangler.template.jsonc');\n\n/**\n * The id a template carries for a D1 database that does not exist yet.\n *\n * `provisionWranglerResources` replaces it with a real id; the backup scripts\n * refuse to export while it is still in place, because a database that was just\n * created holds no user data.\n */\nexport const DEFAULT_UUID = '00000000-0000-0000-0000-000000000000';\n\n/** The placeholder for a KV namespace id and for a Secrets Store id. */\nexport const DEFAULT_HEX_ID = '00000000000000000000000000000000';\n\n/** The Secrets Store name a deployment uses. */\nexport const DEFAULT_SECRET_STORE_NAME = 'default';\n\n/**\n * Fallback when the config declares no `name`, used to derive resource names.\n *\n * Overridable per consumer with `WRANGLER_WORKER_NAME`, which keeps the default\n * honest rather than baking one repo's name into the kit.\n */\nexport const DEFAULT_WORKER_NAME = process.env['WRANGLER_WORKER_NAME'] ?? 'my-worker';\n\n/**\n * KV bindings a deployment always needs, and the namespace each maps to.\n *\n * A consumer whose worker has no cache binding passes an empty map; a consumer\n * with one names it here or leaves the derived `<worker>-<BINDING>` convention.\n */\nexport const DEFAULT_KV_NAMESPACE_NAMES: Record<string, string> = {\n CACHE: `${DEFAULT_WORKER_NAME}-cache`,\n};\n\n/** Dimensions of a Vectorize index this kit provisions. */\nexport const VECTORIZE_DIMENSIONS = 1024;\n\n/**\n * The parsed shape of a wrangler config.\n *\n * `vars` is widened with `null` on purpose: jsonc-parser yields `null` for an\n * explicit `vars: null`, and the vars-patch path must be able to reject that\n * rather than treat the field as absent.\n */\nexport interface WranglerConfig {\n name?: string;\n $version?: number;\n vars?: Record<string, unknown> | null;\n d1_databases?: Array<{\n binding?: string;\n database_id?: string;\n database_name?: string;\n }>;\n kv_namespaces?: Array<{\n binding?: string;\n id?: string;\n }>;\n secrets_store_secrets?: Array<{\n binding?: string;\n store_id?: string;\n secret_name?: string;\n }>;\n queues?: {\n producers?: Array<{ binding: string; queue: string }>;\n consumers?: Array<{ queue: string }>;\n };\n vectorize?: Array<{\n binding: string;\n index_name: string;\n }>;\n}\n\n/** A D1 database as `wrangler d1 list --json` reports one. */\nexport interface D1Database {\n name?: string;\n uuid?: string;\n id?: string;\n database_id?: string;\n}\n\n/** A KV namespace as `wrangler kv namespace list` reports one. */\nexport interface KVNamespace {\n title?: string;\n name?: string;\n id?: string;\n}\n\n/** A Secrets Store as `wrangler secrets-store store list` reports one. */\nexport interface SecretStore {\n name: string;\n id: string;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"integration-migrations.js","sourceRoot":"","sources":["../../src/test/integration-migrations.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiEG;AAEH,OAAO,EAAE,oBAAoB,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAC9D,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACpD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,C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AC,CAAC,CAAC,MAAM,CAAC,KAAK,CACvD,EAAE,EACF,EAAE,KAAK,EAAE,KAAK,EAAE,CACjB,CAAC;oBACJ,CAAC;oBACD,SAAS;gBACX,CAAC;gBAED,KAAK,MAAM,GAAG,IAAI,UAAU,EAAE,CAAC;oBAC7B,MAAM,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,CAAC;gBAC9B,CAAC;YACH,CAAC;YAED,OAAO,CAAC,GAAG,CAAC,EAAE,EAAE,GAAG,CAAC,CAAC;QACvB,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["/**\n * Applying the migration directory to a D1 binding — as a factory.\n *\n * Provenance: converged from `test/integration/helpers/migrations.ts` in six repos\n * (AWS-AccessBridge, ChordDHT-Tracker, Durable-DAV, Durable-DAV-Router, Edge-Git,\n * Mail-Meow) and `test/helpers/migrations.ts` in two more (CalDAV-Bridge,\n * Edge-Sonic). All eight are the same file: a SQL splitter plus a range-addressed\n * `applyMigrations`.\n *\n * ### Why it is a factory and not a module\n *\n * Every source file hardcodes where the migrations live, either as a\n * `__INTEGRATION_MIGRATION_FILES__` binding injected by the Vitest config's\n * `define`, or as a path derived from `import.meta.url`. The kit cannot know\n * either, so the directory is an argument and the injection stays available as an\n * option. One call to `createMigrationHelper({ migrationsDir })` gives the consumer\n * the same helper their repo already has.\n *\n * ### What each source contributes\n *\n * - **Durable-DAV** — the trigger-aware splitter. `CREATE TRIGGER … BEGIN … END;`\n * bodies contain semicolons that must not split, and a naive splitter produces\n * statements SQLite rejects mid-migration. The BEGIN/END depth is tracked only\n * outside strings and comments, and the word *before* `TRIGGER` disambiguates\n * `CREATE TRIGGER` from a table called `trigger`. Durable-DAV also applies one\n * file per `batch()` and names the offending statement in the error, which is\n * the difference between \"0007 failed\" and a line number.\n * - **AWS-AccessBridge** — the once-per-database guard. D1 records which\n * migrations have run; this helper does the same, because `ALTER TABLE … ADD\n * COLUMN` is not idempotent in SQLite and re-running the bundle fails with\n * \"duplicate column name\". A `WeakMap` keyed on the binding is the right scope\n * because each test file gets its own database. AWS also keeps `next` out of the\n * line-comment branch, which never reads it, and preserves newlines inside block\n * comments so an error's line numbers still point at the file.\n * - **Edge-Sonic** — reading the directory off disk rather than a `define`\n * binding, because a test that names one hardcoded file cannot tell **a new\n * migration** from **an edit to an old one**, so it goes on passing through a\n * schema change that never reached production.\n *\n * ### The splitter is not here\n *\n * The statement splitter — with all of Durable-DAV's trigger-aware rules and its\n * comment-level history — lives once, in `@rexezuge/d1`. `@rexezuge/identity`'s\n * migration applier delegates to the same module, so the splitter cannot drift\n * between the suite helper and the production applier. The re-exports below keep\n * this file's public surface identical to the source repos'.\n *\n * ### The lock is asserted, not reimplemented\n *\n * D1 records applied migrations by *filename*, so an applied migration is immutable\n * in fact while being an ordinary text file in appearance. That fact lives in\n * `migrations/migrations.lock.json`, and the rules that check it live once, in\n * `scripts/verify-migrations.ts` — the same module the CI gate runs. This helper\n * deliberately does not parse the lock itself: a second implementation of a thing\n * already written is free to disagree with the first, and the two disagreeing would\n * leave a suite green against a lock CI rejects.\n *\n * ### Generic over the binding\n *\n * `D1DatabaseLike` is structural — `prepare`, and `batch` when the runtime has it\n * — so a fake D1 in a unit test, a real D1 in the workerd integration suite, and\n * Miniflare's D1 all satisfy it without an import of `@cloudflare/workers-types`.\n * `batch` is used when present (Durable-DAV's shape: one round trip per file, and\n * the failure names the file) and a sequential `prepare().run()` loop otherwise\n * (AWS's shape: works on a binding with no batch support).\n */\n\nimport { executableStatements, splitSql } from '@rexezuge/d1';\nimport { readdirSync, readFileSync } from 'node:fs';\nimport { join } from 'node:path';\n\n/**\n * One migration file, as it is read.\n */\nexport interface MigrationFile {\n /** Bare filename, e.g. `0007_replication.sql`. */\n name: string;\n /** The file's full text. */\n sql: string;\n}\n\n/**\n * The subset of a D1 prepared statement this helper uses.\n */\nexport interface D1PreparedStatementLike {\n run(): Promise<unknown>;\n}\n\n/**\n * The subset of a D1 binding this helper uses.\n *\n * `batch` is optional because not every binding that can prepare a statement can\n * batch one; where it exists it is the better path, and where it does not the\n * sequential loop is equivalent for a migration whose statements are independent.\n */\nexport interface D1DatabaseLike {\n prepare(sql: string): D1PreparedStatementLike;\n batch?(statements: readonly D1PreparedStatementLike[]): Promise<unknown>;\n}\n\n/**\n * A closed range of migration files, by filename.\n *\n * Both ends inclusive, because \"up to and including 0006\" is the natural way to\n * seed a pre-migration database and then apply the migration under test.\n */\nexport interface MigrationRange {\n from?: string;\n to?: string;\n}\n\n/**\n * What `createMigrationHelper` accepts.\n */\nexport interface MigrationHelperOptions {\n /**\n * Directory holding the `.sql` files. Read top-level only, matching wrangler's\n * default `${migrationsDir}/*.sql`, so the helper describes exactly the set\n * wrangler will run.\n */\n readonly migrationsDir: string;\n /**\n * Migration files to use instead of reading `migrationsDir`.\n *\n * The escape hatch for a harness that embeds the SQL at build time. Same shape\n * as the `__INTEGRATION_MIGRATION_FILES__` binding the source repos inject.\n */\n readonly files?: readonly MigrationFile[];\n}\n\n/**\n * A bound migration helper.\n */\nexport interface MigrationHelper {\n /** Every migration, in apply order. */\n migrationFiles(): MigrationFile[];\n /** The filenames, in apply order. */\n migrationFileNames(): string[];\n /** The concatenation of every file, in apply order — what a fresh database becomes. */\n migrationSql(): string;\n /** One file's SQL, by name. \"What does *this* file say\", not \"what does the set say\". */\n migrationSqlOf(name: string): string;\n /** Split one file into statements, comments included. */\n splitSql(sql: string): string[];\n /** The statements of one file that SQLite will actually execute. */\n executableStatements(sql: string): string[];\n /**\n * Apply a range of migrations, at most once per database and range.\n *\n * Per file rather than one batch for everything, so a test can stop between\n * files: the identity-upgrade test needs to seed the *pre-0004* shape and then\n * apply 0004 to it.\n */\n applyMigrations(db: D1DatabaseLike, range?: MigrationRange): Promise<void>;\n}\n\n/**\n * Reads every `.sql` file in `dir`, in apply order.\n *\n * Sort is the filename sort D1 itself uses, rather than a numeric parse of the\n * prefix: wrangler hands the directory to SQLite in lexicographic order, so a\n * suite that reads it numerically disagrees with production on any prefix wider\n * than four digits.\n */\nexport function readMigrationFiles(dir: string): MigrationFile[] {\n const entries = readdirSync(dir, { withFileTypes: true });\n return entries\n .filter((entry) => entry.isFile() && entry.name.endsWith('.sql'))\n .map((entry) => ({ name: entry.name, sql: readFileSync(join(dir, entry.name), 'utf8') }))\n .sort((left, right) => left.name.localeCompare(right.name));\n}\n\n/**\n * Strip leading `--` and block comments, which the splitter folds into the\n * statement it then reports on.\n */\nfunction stripLeadingComments(statement: string): string {\n let out = statement;\n for (;;) {\n const next = out.replace(/^\\s*(?:--[^\\n]*\\n|\\/\\*[\\s\\S]*?\\*\\/)\\s*/, '');\n if (next === out) return out.trim();\n out = next;\n }\n}\n\n/** Re-exported for surface parity with the source repos — the rules live in @rexezuge/d1. */\nexport { executableStatements, splitSql };\n\n/**\n * Bind a migration directory into a helper.\n *\n * ```ts\n * const migrations = createMigrationHelper({ migrationsDir: path.join(REPO_ROOT, 'migrations') });\n * await migrations.applyMigrations(env.DB);\n * ```\n */\nexport function createMigrationHelper(options: MigrationHelperOptions): MigrationHelper {\n const files = options.files !== undefined ? [...options.files] : readMigrationFiles(options.migrationsDir);\n\n /**\n * Databases this helper has already migrated, keyed by the range applied.\n *\n * A `WeakMap` rather than a module-level `Set`, because the guard is per\n * binding: two databases in one suite each need the bundle applied once, and a\n * module-level set would silently skip the second.\n */\n const applied = new WeakMap<D1DatabaseLike, string>();\n\n const indexOf = (name: string | undefined, fallback: number): number => {\n if (name === undefined) return fallback;\n const found = files.findIndex((file) => file.name === name);\n if (found === -1) {\n throw new Error(`Unknown migration file: ${name}. Available: ${files.map((file) => file.name).join(', ')}`);\n }\n return found;\n };\n\n return {\n migrationFiles: () => files.map((file) => ({ ...file })),\n migrationFileNames: () => files.map((file) => file.name),\n migrationSql: () => files.map((file) => file.sql).join('\\n'),\n migrationSqlOf: (name: string) => {\n const file = files.find((candidate) => candidate.name === name);\n if (file === undefined) {\n throw new Error(`Unknown migration file: ${name}. Available: ${files.map((candidate) => candidate.name).join(', ')}`);\n }\n return file.sql;\n },\n splitSql,\n executableStatements,\n applyMigrations: async (db: D1DatabaseLike, range?: MigrationRange): Promise<void> => {\n const start = indexOf(range?.from, 0);\n const end = indexOf(range?.to, files.length - 1);\n const key = `${start}:${end}`;\n if (applied.get(db) === key) return;\n const applicable = files.slice(start, end + 1);\n\n for (const file of applicable) {\n const statements = executableStatements(file.sql);\n if (statements.length === 0) continue;\n\n if (typeof db.batch === 'function') {\n try {\n await db.batch(statements.map((sql) => db.prepare(sql)));\n } catch (error: unknown) {\n // A batch reports only the file's single failure, so name the statement:\n // a migration error that says nothing about which of its nine statements\n // broke is a migration error nobody fixes.\n throw new Error(\n `${file.name}: batch of ${statements.length} statements failed at ${stripLeadingComments(statements.at(-1) ?? '').slice(0, 200)}: ${\n error instanceof Error ? error.message : String(error)\n }`,\n { cause: error },\n );\n }\n continue;\n }\n\n for (const sql of statements) {\n await db.prepare(sql).run();\n }\n }\n\n applied.set(db, key);\n },\n };\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cloudflare-workers.js","sourceRoot":"","sources":["../../../src/test/mocks/cloudflare-workers.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoDG;AAuBH;;;;;GAKG;AACH,MAAM,aAAa;IACP,GAAG,CAAqB;IACxB,GAAG,CAAO;IAEpB,YAAY,GAAuB,EAAE,GAAS;QAC5C,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QACf,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;IACjB,CAAC;CACF;AAED;;;GAGG;AACH,MAAM,SAAS;CAAG;AAElB;;;;;;GAMG;AACH,MAAM,kBAAkB;IACZ,GAAG,CAAmB;IACtB,GAAG,CAAO;IAEpB,YAAY,GAAqB,EAAE,GAAS;QAC1C,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QACf,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;IACjB,CAAC;CACF;AAED,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,kBAAkB,EAAE,CAAC"}
|
|
1
|
+
{"version":3,"file":"cloudflare-workers.js","sourceRoot":"","sources":["../../../src/test/mocks/cloudflare-workers.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoDG;AAuBH;;;;;GAKG;AACH,MAAM,aAAa;IACP,GAAG,CAAqB;IACxB,GAAG,CAAO;IAEpB,YAAY,GAAuB,EAAE,GAAS;QAC5C,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QACf,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;IACjB,CAAC;CACF;AAED;;;GAGG;AACH,MAAM,SAAS;CAAG;AAElB;;;;;;GAMG;AACH,MAAM,kBAAkB;IACZ,GAAG,CAAmB;IACtB,GAAG,CAAO;IAEpB,YAAY,GAAqB,EAAE,GAAS;QAC1C,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QACf,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;IACjB,CAAC;CACF;AAED,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,kBAAkB,EAAE,CAAC","sourcesContent":["/**\n * Stand-in for the `cloudflare:workers` module, which has no Node equivalent.\n *\n * Provenance: converged from the eight copies at `test/mocks/cloudflare-workers.ts`\n * (AWS-AccessBridge, CalDAV-Bridge, ChordDHT-Tracker, Durable-DAV, Edge-Git,\n * Edge-Sonic, Mail-Meow, Mail-Otter). All eight are the same twenty lines; the\n * union is three base classes and the union exists because each repo discovered a\n * missing one the hard way.\n *\n * ### What each source contributes\n *\n * - **DurableObject** — every copy. Stores `ctx` and `env` so a real DO class can\n * be constructed and its lifecycle RPCs driven directly, without Miniflare.\n * - **`RpcTarget`** — Durable-DAV's, and the reason is load-bearing rather than\n * tidy: `dofs`' `Fs` class `extends RpcTarget`, so the module fails to evaluate\n * with *\"Class extends value undefined\"* when the base is missing. That is a\n * module-load error, not a test failure, so it surfaces as an unimportable\n * `dav-store` barrel and no unit test can reach `DavRepository`. Deliberately\n * empty: on the platform it marks which methods are callable across an RPC\n * boundary, and nothing in a Node suite calls those through RPC. An empty base\n * keeps the fake honest instead of pretending to implement dispatch.\n * - **`WorkflowEntrypoint`** — Edge-Git, Edge-Sonic, Mail-Meow, Mail-Otter. A\n * Workflow class extends it, so the mock must provide it or the module fails the\n * same way — a **startup** error, which therefore takes down every suite that\n * reaches `apps/background` for an unrelated reason. Edge-Sonic's is the shape\n * kept: it stores `ctx` as well as `env`, because the failure policy under test\n * in `runWorkflow` lives in a plain function precisely so it can be exercised\n * without workerd, and that policy reads the execution context.\n *\n * ### Why the ambient types are declared here rather than imported\n *\n * The source repos name `DurableObjectState`, `ExecutionContext` and `Env`\n * unqualified, which resolves only because `worker-configuration.d.ts` and\n * `@cloudflare/workers-types` are ambient inside a Wrangler project. This copy is\n * imported by the kit's own typecheck, where neither exists, so the two state\n * shapes are declared locally and `TEnv` defaults to `unknown` instead of `Env`\n * (Edge-Sonic's form). A local declaration shadows the ambient one inside this\n * file only, so a consumer's copy typechecks against their generated types\n * exactly as the original did.\n *\n * ### Usage in a consumer\n *\n * Copy this file to `<repo>/test/mocks/cloudflare-workers.ts` and alias the\n * specifier in the Vitest config — `defineUnitVitestConfig()` already does:\n *\n * ```jsonc\n * // wrangler.jsonc / vitest alias\n * \"cloudflare:workers\": \"test/mocks/cloudflare-workers.ts\"\n * ```\n *\n * Only what a test actually imports is exported. A symbol here that nothing\n * imports is not a safety net; it is a claim that something depends on it.\n */\n\n/**\n * The subset of `DurableObjectState` a Node test reaches.\n *\n * Declared structurally rather than imported: `id`, `storage` and `waitUntil` are\n * the three a hand-driven lifecycle touches, and nothing here needs the rest.\n */\nexport interface DurableObjectState {\n readonly id: { toString(): string; readonly name?: string };\n}\n\n/**\n * The subset of `ExecutionContext` a Node test reaches.\n *\n * `waitUntil` is present because a Workflow's `run()` is driven through it, and\n * `passThroughOnException` is absent on purpose — nothing in a Node suite wires a\n * request through it.\n */\nexport interface ExecutionContext {\n waitUntil(promise: Promise<unknown>): void;\n}\n\n/**\n * The base class every Durable Object extends.\n *\n * `protected`, exactly as on the platform: a DO subclass reads `this.env` and\n * `this.ctx`, and nothing outside it may.\n */\nclass DurableObject<TEnv = unknown> {\n protected ctx: DurableObjectState;\n protected env: TEnv;\n\n constructor(ctx: DurableObjectState, env: TEnv) {\n this.ctx = ctx;\n this.env = env;\n }\n}\n\n/**\n * The base class `dofs`' `Fs` extends. See the header: an empty body is the\n * whole point, and a missing class is a module-load failure.\n */\nclass RpcTarget {}\n\n/**\n * The base class every Workflow extends.\n *\n * `ctx` is `ExecutionContext` rather than `unknown` (Mail-Meow/Mail-Otter's\n * form) because a Workflow's step code reads it; `void ctx` to silence the unused\n * warning would be a lie about which of the two a subclass uses.\n */\nclass WorkflowEntrypoint<TEnv = unknown> {\n protected ctx: ExecutionContext;\n protected env: TEnv;\n\n constructor(ctx: ExecutionContext, env: TEnv) {\n this.ctx = ctx;\n this.env = env;\n }\n}\n\nexport { DurableObject, RpcTarget, WorkflowEntrypoint };\n"]}
|
package/dist/vite.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vite.js","sourceRoot":"","sources":["../src/vite.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAEH,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC7E,OAAO,EAAE,OAAO,EAAW,MAAM,WAAW,CAAC;AAC7C,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACxD,OAAO,EAAE,YAAY,EAAe,MAAM,eAAe,CAAC;AAuE1D;;;;;;;;;;;;;;GAcG;AACH;;;;;;GAMG;AACH,SAAS,KAAK,CAAC,KAAmB;IAChC,OAAO,OAAO,KAAK,KAAK,QAAQ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MAAM,MAAM,GAAG,0FAA0F,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC;YAEnI,SAAS,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;YACpD,aAAa,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC;QACpC,CAAC;KACF,CAAC;AACJ,CAAC;AAED;;;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU,mBAAmB,CAAC,UAAgC,EAAE;IACpE,MAAM,OAAO,GAAa,CAAC,GAAG,CAAC,OAAO,CAAC,OAAO,IAAI,EAAE,CAAC,CAAC,CAAC;IACvD,IAAI,OAAO,CAAC,QAAQ,KAAK,SAAS,EAAE,CAAC;QACnC,OAAO,CAAC,IAAI,CAAC,mBAAmB,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC;IACtD,CAAC;IAED,OAAO,YAAY,CAAC;QAClB,GAAG,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,IAAI,EAAE,OAAO,EAAE,CAAC;QACtC,GAAG,CAAC,OAAO,CAAC,KAAK,KAAK,SAAS,IAAI,EAAE,MAAM,EAAE,EAAE,KAAK,EAAE,EAAE,GAAG,OAAO,CAAC,KAAK,EAAE,EAAE,EAAE,CAAC;QAC/E,KAAK,EAAE;YACL,MAAM,EAAE,OAAO,CAAC,MAAM,IAAI,MAAM;YAChC,WAAW,EAAE,IAAI;SAClB;KACF,CAAC,CAAC;AACL,CAAC","sourcesContent":["/**\n * The SPA's Vite config.\n *\n * Provenance: converged from the `apps/web/vite.config.ts` of the eight repos\n * that build a Vite SPA. They are one file with three variables: the plugin list\n * (`@vitejs/plugin-react` + `@tailwindcss/vite`), the dev-server proxy target,\n * and the `spa-shell-embed` plugin that copies `dist/index.html` into\n * `apps/api/src/generated/spa-shell.ts`.\n *\n * Canonical decisions:\n *\n * 1. **The plugins are passed in, not imported.** The kit stays zero-dependency:\n * `react`, `@vitejs/plugin-react` and `@tailwindcss/vite` belong to the app\n * that uses them, and importing them here would make the tooling package\n * undownloadable for a consumer without a React SPA.\n * 2. **The `spa-shell-embed` hook stays per-repo, and is passed in.** It is the\n * one genuinely repo-specific piece: each repo names its own worker and its\n * own generated-module path. What the kit provides is the *contract* — see\n * `spaShellEmbedPlugin`, which is the converged body of all eight copies.\n * 3. **`server.proxy` is data, not code.** The paths differ per repo\n * (`/user` + `/rest` in Edge-Sonic, `/api` in CalDAV-Bridge, `/tracker` in\n * ChordDHT-Tracker) but the shape never does, so it is an option with a\n * default.\n * 4. **`build.emptyOutDir: true`** is the default, because a stale asset in\n * `dist/` is served as a live bundle — the same half-refreshed build\n * `scripts/verify-spa-shell.ts` rejects.\n *\n * The consumer's `apps/web/vite.config.ts` becomes a handful of lines — see the\n * README.\n */\n\nimport { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';\nimport { dirname, resolve } from 'node:path';\nimport { fileURLToPath, pathToFileURL } from 'node:url';\nimport { defineConfig, type Plugin } from 'vitest/config';\n\n/**\n * One dev-server proxy entry, as Vite's `server.proxy` accepts it.\n */\nexport interface ProxyEntry {\n readonly target: string;\n readonly changeOrigin?: boolean;\n readonly bypass?: (request: { headers: Record<string, string | string[] | undefined> }) => string | undefined;\n}\n\n/**\n * Where the SPA's built `index.html` is copied to, and under what module name.\n */\nexport interface SpaShellTarget {\n /**\n * Path of the generated module, relative to the repository root.\n *\n * `apps/api/src/generated/spa-shell.ts` in every repo that embeds a shell; the\n * parameter exists because the path is the one thing that genuinely differs.\n */\n readonly path: string;\n /**\n * The repository root the path is resolved against, as a file URL or a path.\n *\n * Defaults to the directory the build runs in (`process.cwd()`), which is the\n * repo root when the build is `pnpm --filter @scope/web build`. Passed in by the\n * Vite config, not derived from `import.meta.url`: this plugin object is created\n * inside the kit's own module, so a URL relative to it points into\n * `node_modules/@rexezuge/tooling` and writes the shell somewhere no compiler\n * will ever look.\n */\n readonly root?: string | URL;\n /**\n * The built `index.html`, as a path or file URL.\n *\n * Defaults to `dist/index.html` under the same root. Vite's `closeBundle` runs\n * after the bundle is written, so this is the file the build just produced.\n */\n readonly distIndex?: string | URL;\n}\n\n/**\n * What `defineWebViteConfig` accepts.\n */\nexport interface WebViteConfigOptions {\n /**\n * The SPA's plugins — `react()`, `tailwindcss()`, and anything else the app\n * needs. Applied before the spa-shell plugin so the shell is written after the\n * bundle exists.\n */\n readonly plugins?: readonly Plugin[];\n /**\n * Dev-server proxy entries. Keyed by path prefix.\n */\n readonly proxy?: Readonly<Record<string, ProxyEntry>>;\n /**\n * Where the built shell is embedded. Omit to skip the embedding entirely.\n */\n readonly spaShell?: SpaShellTarget;\n /**\n * The build output directory.\n */\n readonly outDir?: string;\n /**\n * The directory this config is resolved from, as a file URL. Defaults to the\n * caller's location.\n */\n readonly root?: string;\n}\n\n/**\n * The `spa-shell-embed` plugin, converged from all eight copies.\n *\n * It exists because the API worker serves `SPA_HTML` from a module in its own\n * source tree, and both that module and `dist/` are gitignored — so a fresh\n * clone gets an empty stub from `postinstall` and every `GET /` returns a blank\n * page until someone runs a build. This plugin is what makes the build write the\n * real artefact, and `scripts/verify-spa-shell.ts` is what refuses to deploy\n * without it.\n *\n * Written as a factory rather than inlined so the exit conditions are in one\n * place: the `closeBundle` hook runs on every build, including the ones where\n * `dist/index.html` was never produced, and a plugin that throws there fails\n * builds that legitimately emit nothing.\n */\n/**\n * Normalise a path-or-URL option to a URL, so `new URL(...)` can be used on it.\n *\n * Small, and here because two options accept either form: a path is what a consumer\n * naturally writes in a config, and a URL is what `import.meta.url` hands them.\n * Accepting both is one line and saves a `fileURLToPath` at every call site.\n */\nfunction toUrl(value: string | URL): URL {\n return typeof value === 'string' ? pathToFileURL(value) : value;\n}\n\n/**\n * The same, as a **directory** URL — with the trailing separator `new URL(rel, base)`\n * needs.\n *\n * `new URL('apps/api/x.ts', 'file:///repo')` resolves to `/apps/api/x.ts`, silently\n * dropping the base. The base has to end in a separator, and a path from\n * `process.cwd()` never does, so this is where the plugin would otherwise write the\n * shell into the filesystem root.\n */\nfunction toDirUrl(value: string | URL): URL {\n const url = toUrl(value);\n return url.href.endsWith('/') ? url : new URL(`${url.href}/`);\n}\n\nexport function spaShellEmbedPlugin(target: SpaShellTarget): Plugin {\n return {\n name: 'spa-shell-embed',\n closeBundle() {\n // Resolved from the directory the build runs in, never from this module's own\n // URL: the plugin object is created here but executes in the consumer's Vite\n // process, and `new URL(path, import.meta.url)` would resolve against\n // `node_modules/@rexezuge/tooling`. `process.cwd()` is the repo root for\n // `pnpm --filter @scope/web build`, which is how every consumer runs it.\n const root = toDirUrl(target.root ?? process.cwd());\n const outputPath = fileURLToPath(new URL(target.path, root));\n const indexPath = target.distIndex === undefined ? fileURLToPath(new URL('dist/index.html', root)) : fileURLToPath(toUrl(target.distIndex));\n\n if (!existsSync(indexPath)) {\n console.warn('spa-shell-embed: dist/index.html not found, skipping');\n return;\n }\n\n const html = readFileSync(indexPath, 'utf8');\n const output = `// Auto-generated by Vite build plugin - DO NOT EDIT.\\nexport const SPA_HTML: string = ${JSON.stringify(html)};\\n`;\n\n mkdirSync(dirname(outputPath), { recursive: true });\n writeFileSync(outputPath, output);\n },\n };\n}\n\n/**\n * Build the SPA's Vite config.\n *\n * ```ts\n * // apps/web/vite.config.ts\n * import react from '@vitejs/plugin-react';\n * import { defineWebViteConfig, spaShellEmbedPlugin } from '@rexezuge/tooling/vite';\n *\n * export default defineWebViteConfig({\n * plugins: [react()],\n * proxy: { '/user': { target: 'http://localhost:8787', changeOrigin: true } },\n * spaShell: { path: '../../apps/api/src/generated/spa-shell.ts' },\n * });\n * ```\n */\nexport function defineWebViteConfig(options: WebViteConfigOptions = {}): ReturnType<typeof defineConfig> {\n const plugins: Plugin[] = [...(options.plugins ?? [])];\n if (options.spaShell !== undefined) {\n plugins.push(spaShellEmbedPlugin(options.spaShell));\n }\n\n return defineConfig({\n ...(plugins.length > 0 && { plugins }),\n ...(options.proxy !== undefined && { server: { proxy: { ...options.proxy } } }),\n build: {\n outDir: options.outDir ?? 'dist',\n emptyOutDir: true,\n },\n });\n}\n"]}
|
package/dist/vitest-web.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vitest-web.js","sourceRoot":"","sources":["../src/vitest-web.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,OAAO,EAAE,YAAY,EAAe,MAAM,eAAe,CAAC;AAC1D,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAoCzC;;;GAGG;AACH,MAAM,eAAe,GAAsB,CAAC,6BAA6B,EAAE,6BAA6B,CAAC,CAAC;AAE1G;;;;;;;;;GASG;AACH,MAAM,UAAU,qBAAqB,CAAC,UAAkC,EAAE;IACxE,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,IAAI,IAAI,GAAG,CAAC,GAAG,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC;IAChE,MAAM,MAAM,GAAG,aAAa,CAAC,IAAI,GAAG,CAAC,cAAc,EAAE,IAAI,CAAC,CAAC,CAAC;IAC5D,MAAM,OAAO,GAAkB,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,WAAW,EAAE,GAAG,MAAM,GAAG,EAAE,EAAE,GAAG,CAAC,OAAO,CAAC,OAAO,IAAI,EAAE,CAAC,CAAC,CAAC;IAEzG,OAAO,YAAY,CAAC;QAClB,GAAG,CAAC,OAAO,CAAC,OAAO,KAAK,SAAS,IAAI,EAAE,OAAO,EAAE,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;QACvE,OAAO,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE;QAC3B,IAAI,EAAE;YACJ,OAAO,EAAE,IAAI;YACb,WAAW,EAAE,OAAO;YACpB,OAAO,EAAE,CAAC,GAAG,CAAC,OAAO,CAAC,OAAO,IAAI,eAAe,CAAC,CAAC;YAClD,qEAAqE;YACrE,2EAA2E;YAC3E,qBAAqB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AO,CAAC,OAAO,IAAI,EAAE,CAAC,CAAC,CAAC;IAEzG,OAAO,YAAY,CAAC;QAClB,GAAG,CAAC,OAAO,CAAC,OAAO,KAAK,SAAS,IAAI,EAAE,OAAO,EAAE,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;QACvE,OAAO,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE;QAC3B,IAAI,EAAE;YACJ,OAAO,EAAE,IAAI;YACb,WAAW,EAAE,OAAO;YACpB,OAAO,EAAE,CAAC,GAAG,CAAC,OAAO,CAAC,OAAO,IAAI,eAAe,CAAC,CAAC;YAClD,qEAAqE;YACrE,2EAA2E;YAC3E,qBAAqB;YACrB,IAAI,EAAE,SAAS;YACf,OAAO,EAAE,CAAC,oBAAoB,EAAE,YAAY,EAAE,qBAAqB,CAAC;YACpE,QAAQ,EAAE;gBACR,QAAQ,EAAE,IAAI;gBACd,QAAQ,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC;gBAC1B,gBAAgB,EAAE,OAAO,CAAC,gBAAgB,IAAI,gBAAgB;gBAC9D,OAAO,EAAE,CAAC,4BAA4B,CAAC;gBACvC,OAAO,EAAE,CAAC,oBAAoB,EAAE,WAAW,EAAE,aAAa,EAAE,iBAAiB,CAAC;gBAC9E,GAAG,CAAC,OAAO,CAAC,UAAU,KAAK,SAAS,IAAI,EAAE,UAAU,EAAE,EAAE,GAAG,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC;aACnF;SACF;KACF,CAAC,CAAC;AACL,CAAC","sourcesContent":["/**\n * The SPA's test and coverage gate.\n *\n * Provenance: converged from Durable-DAV-Router's and Mail-Otter's\n * `vitest.web.config.mts`, which are the two repos that gave the frontend its own\n * suite. Durable-DAV-Router's is the canonical shape — it is the one that records\n * *why* the split exists; Mail-Otter's contributes the React plugin and the\n * `apps/web/**` include.\n *\n * Canonical decisions:\n *\n * 1. **It is a separate config, not a `projects` entry in one.** With a single\n * config the SPA suites ran under `node` and the worker suites under `jsdom`\n * in the same pass, so a test could pass in one environment and fail in the\n * other with neither run noticing.\n * 2. **`pool: 'threads'`, bounded, rather than one forked worker per file.** Each\n * jsdom document is a whole browser environment; a fork per file exhausts\n * memory on a constrained machine, and when it does the run dies partway with\n * a bare \"Worker exited unexpectedly\" and no test reports a failure — which\n * reads as a flaky suite rather than as an out-of-memory kill.\n * 3. **jsdom is set here for every file**, rather than a `@vitest-environment`\n * pragma per file: these are the tests that need a DOM, and the pragma is one\n * more place to forget.\n * 4. **`include` covers both shapes the repos use** — the root-suite `web-*`\n * naming convention and suites bundled under `apps/web` — and the same globs\n * are what `defineUnitVitestConfig()` excludes.\n */\n\nimport { defineConfig, type Plugin } from 'vitest/config';\nimport { fileURLToPath } from 'node:url';\nimport type { CoverageThresholds, VitestAlias } from './vitest';\n\n/**\n * What `defineWebVitestConfig` accepts.\n */\nexport interface WebVitestConfigOptions {\n /**\n * Vite plugins the SPA needs — `@vitejs/plugin-react` for a React app. Passed\n * by the consumer rather than imported here, because the kit must stay\n * zero-dependency and the plugin belongs to the app, not the harness.\n */\n readonly plugins?: readonly Plugin[];\n /**\n * Extra resolver entries.\n */\n readonly aliases?: readonly VitestAlias[];\n /**\n * The repo root, as a file URL.\n */\n readonly root?: string;\n /**\n * Which suites to collect. Defaults to both shapes the source repos use.\n */\n readonly include?: readonly string[];\n /**\n * Coverage floors. Omitted by default; see `defineUnitVitestConfig`.\n */\n readonly thresholds?: CoverageThresholds;\n /**\n * Where the coverage report is written. Separate from the unit config's, so\n * the two gates never overwrite each other's report.\n */\n readonly reportsDirectory?: string;\n}\n\n/**\n * The default suite globs: the root-suite `web-*` convention and the\n * bundled-under-`apps/web` convention, so either layout works unchanged.\n */\nconst DEFAULT_INCLUDE: readonly string[] = ['test/**/web-*.test.{ts,tsx}', 'apps/web/**/*.test.{ts,tsx}'];\n\n/**\n * Build the SPA's test config.\n *\n * ```ts\n * // vitest.web.config.mts\n * import react from '@vitejs/plugin-react';\n * import { defineWebVitestConfig } from '@rexezuge/tooling/vitest-web';\n * export default defineWebVitestConfig({ plugins: [react()] });\n * ```\n */\nexport function defineWebVitestConfig(options: WebVitestConfigOptions = {}): ReturnType<typeof defineConfig> {\n const root = options.root ?? new URL('.', import.meta.url).href;\n const webSrc = fileURLToPath(new URL('apps/web/src', root));\n const aliases: VitestAlias[] = [{ find: /^@\\//, replacement: `${webSrc}/` }, ...(options.aliases ?? [])];\n\n return defineConfig({\n ...(options.plugins !== undefined && { plugins: [...options.plugins] }),\n resolve: { alias: aliases },\n test: {\n globals: true,\n environment: 'jsdom',\n include: [...(options.include ?? DEFAULT_INCLUDE)],\n // Threads, bounded, rather than one forked worker per file — see the\n // header. A custom `exclude` replaces Vitest's defaults, so `node_modules`\n // must be re-listed.\n pool: 'threads',\n exclude: ['**/node_modules/**', '**/dist/**', 'test/integration/**'],\n coverage: {\n provider: 'v8',\n reporter: ['text', 'lcov'],\n reportsDirectory: options.reportsDirectory ?? './coverage-spa',\n include: ['apps/web/src/**/*.{ts,tsx}'],\n exclude: ['**/*.test.{ts,tsx}', '**/*.d.ts', '**/types.ts', '**/generated/**'],\n ...(options.thresholds !== undefined && { thresholds: { ...options.thresholds } }),\n },\n },\n });\n}\n"]}
|
package/dist/vitest.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vitest.js","sourceRoot":"","sources":["../src/vitest.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAsDzC;;;;;GAKG;AACH,MAAM,SAAS,GAAG,6BAA6B,CAAC;AAEhD;;;;;;;;GAQG;AACH,SAAS,gBAAgB,CAAC,IAAY;IACpC,MAAM,EAAE,GAAG,CAAC,QAAgB,EAAU,EAAE,CAAC,aAAa,CAAC,IAAI,GAAG,CAAC,QAAQ,EAAE,IAAI,CAA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E,MAAM;YACnB,OAAO,EAAE,CAAC,yBAAyB,CAAC;YACpC,wEAAwE;YACxE,iDAAiD;YACjD,OAAO,EAAE,CAAC,oBAAoB,EAAE,YAAY,EAAE,qBAAqB,EAAE,SAAS,CAAC;YAC/E,MAAM,EAAE;gBACN,IAAI,EAAE;oBACJ,oEAAoE;oBACpE,uEAAuE;oBACvE,uEAAuE;oBACvE,iDAAiD;oBACjD,MAAM,EAAE,CAAC,MAAM,CAAC;iBACjB;aACF;YACD,QAAQ,EAAE;gBACR,QAAQ,EAAE,IAAI;gBACd,qEAAqE;gBACrE,sEAAsE;gBACtE,wEAAwE;gBACxE,sEAAsE;gBACtE,2DAA2D;gBAC3D,QAAQ,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC;gBAClC,gBAAgB,EAAE,OAAO,CAAC,gBAAgB,IAAI,YAAY;gBAC1D,OAAO,EAAE,CAAC,GAAG,eAAe,CAAC;gBAC7B,OAAO,EAAE,eAAe;gBACxB,GAAG,CAAC,OAAO,CAAC,UAAU,KAAK,SAAS,IAAI,EAAE,UAAU,EAAE,EAAE,GAAG,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC;aACnF;SACF;KACF,CAAC,CAAC;AACL,CAAC","sourcesContent":["/**\n * The unit-test Vitest config for the worker-and-packages half of the suite.\n *\n * Provenance: converged from the eight repos' `vitest.config.mts`. The coverage\n * block is Durable-DAV-Router's (the most complete: v8 provider, explicit\n * include/exclude patterns, thresholds with the reasoning for why they sit just\n * under the measured value); the alias block is Durable-DAV's, which is the only\n * one that also aliases `cloudflare:workers` and `cloudflare:sockets` to the\n * Node mocks.\n *\n * Canonical decisions:\n *\n * 1. **Every file matching `include` is reported** — Vitest 4 removed\n * `coverage.all`, and an explicit `include` now covers files no test\n * imported. That is the behaviour the source repos configured `all: true` for,\n * and the reason it mattered: without it a brand-new module with no test is\n * invisible rather than counted as zero, which is the exact regression this\n * gate exists to catch.\n * 2. **The SPA is excluded here**, so this config and `defineWebVitestConfig()`\n * partition the suite rather than each running all of it. Every SPA suite is\n * named `web-*`. One number could not honestly describe both halves: the SPA's\n * presentational modules pulled a shared floor down 16 points, so a change\n * adding legitimate code in `apps/api` could fail the gate on the strength of\n * files two directories away.\n * 3. **A custom `exclude` re-lists `node_modules`** — `test/` is a workspace\n * project and therefore has its own, so without the re-list the glob reaches\n * into `test/node_modules` and tries to run other packages' suites.\n * 4. **Thresholds are a consumer argument**, not a kit default. A floor is a\n * per-repo ratchet measured against that repo's suite; the kit cannot know a\n * number, and guessing one is how floors get lowered.\n */\n\nimport { defineConfig } from 'vitest/config';\nimport { fileURLToPath } from 'node:url';\n\n/**\n * One `{ find, replacement }` pair for Vitest's resolver.\n */\nexport interface VitestAlias {\n readonly find: string | RegExp;\n readonly replacement: string;\n}\n\n/**\n * Coverage thresholds, in the four figures Vitest gates on.\n */\nexport interface CoverageThresholds {\n readonly statements?: number;\n readonly branches?: number;\n readonly functions?: number;\n readonly lines?: number;\n}\n\n/**\n * What `defineUnitVitestConfig` accepts. Every field is optional: the defaults\n * cover the canonical monorepo layout, and a consumer overrides only what its\n * tree actually differs in.\n */\nexport interface UnitVitestConfigOptions {\n /**\n * Extra resolver entries, applied after the canonical ones.\n */\n readonly aliases?: readonly VitestAlias[];\n /**\n * Where the repo root is, as a file URL. Defaults to the directory this\n * factory is *called* from, which is the repo root's `vitest.config.mts`.\n */\n readonly root?: string;\n /**\n * Coverage `include` globs. Defaults to the worker plus every workspace\n * package's `src`.\n */\n readonly coverageInclude?: readonly string[];\n /**\n * Coverage `exclude` globs, merged with the canonical set.\n */\n readonly coverageExclude?: readonly string[];\n /**\n * Coverage floors. Omitted by default; a repo that wants them sets them.\n */\n readonly thresholds?: CoverageThresholds;\n /**\n * Where the coverage report is written.\n */\n readonly reportsDirectory?: string;\n}\n\n/**\n * The SPA's suites, excluded here so the two configs partition the suite.\n *\n * Every SPA suite is named `web-*`. `defineWebVitestConfig()` includes the same\n * glob, so a file is collected by exactly one config.\n */\nconst SPA_FILES = 'test/**/web-*.test.{ts,tsx}';\n\n/**\n * The canonical alias set.\n *\n * Built relative to the consumer's repo root rather than the kit's directory,\n * so the factory describes *their* layout. A Vitest config is a standalone file\n * with no module graph to share through, and a suite resolving a workspace\n * import differently from its sibling fails in a way that looks like a product\n * bug — which is why these are stated once, here, rather than duplicated.\n */\nfunction canonicalAliases(root: string): VitestAlias[] {\n const at = (relative: string): string => fileURLToPath(new URL(relative, root));\n return [\n { find: 'cloudflare:workers', replacement: at('test/mocks/cloudflare-workers.ts') },\n { find: 'cloudflare:sockets', replacement: at('test/mocks/cloudflare-sockets.ts') },\n { find: /^@\\//, replacement: `${at('apps/api/src')}/` },\n { find: /^~\\//, replacement: `${at('apps/web/src')}/` },\n ];\n}\n\n/**\n * Coverage `exclude` globs converged from the source repos.\n *\n * The categories: build and test tooling (`scripts/` grows with project surface,\n * not complexity, and the god-file guard excludes it for the same reason), test\n * files, declarations, re-export barrels (`index.ts` carries no logic of its\n * own), model records, generated files (the SPA shell is a one-line HTML blob\n * with no logic to exercise), and type-only modules.\n */\nconst CANONICAL_COVERAGE_EXCLUDE: readonly string[] = [\n 'scripts/**',\n '**/*.test.ts',\n '**/*.d.ts',\n '**/index.ts',\n '**/types.d.ts',\n '**/model/**',\n '**/generated/**',\n '**/D1Types.ts',\n '**/ServiceEnv.ts',\n '**/env.d.ts',\n];\n\n/**\n * Build the unit-test config.\n *\n * ```ts\n * // vitest.config.mts\n * import { defineUnitVitestConfig } from '@rexezuge/tooling/vitest';\n * export default defineUnitVitestConfig();\n * ```\n */\nexport function defineUnitVitestConfig(options: UnitVitestConfigOptions = {}): ReturnType<typeof defineConfig> {\n const root = options.root ?? new URL('.', import.meta.url).href;\n const coverageInclude = options.coverageInclude ?? ['apps/api/src/**/*.ts', 'apps/background/src/**/*.ts', 'packages/**/src/**/*.ts'];\n const coverageExclude = [...CANONICAL_COVERAGE_EXCLUDE, ...(options.coverageExclude ?? [])];\n const aliases = [...canonicalAliases(root), ...(options.aliases ?? [])];\n\n return defineConfig({\n resolve: { alias: aliases },\n test: {\n globals: true,\n environment: 'node',\n include: ['test/**/*.test.{ts,tsx}'],\n // `test` is a workspace project and therefore has its own node_modules;\n // without the re-list, the glob reaches into it.\n exclude: ['**/node_modules/**', '**/dist/**', 'test/integration/**', SPA_FILES],\n server: {\n deps: {\n // A `node_modules` dependency is externalized by default, so Node's\n // own ESM loader resolves a `cloudflare:workers` specifier and rejects\n // the scheme before `resolve.alias` is ever consulted. Inlining routes\n // it back through Vite, where the alias applies.\n inline: ['dofs'],\n },\n },\n coverage: {\n provider: 'v8',\n // Vitest 4 removed `coverage.all`; an explicit `include` now reports\n // every matching file whether or not a test imported it, which is the\n // behaviour the source repos' `all: true` was there to get: a brand-new\n // module with no test is counted as zero rather than being invisible,\n // which is the exact regression this gate exists to catch.\n reporter: ['text', 'lcov', 'html'],\n reportsDirectory: options.reportsDirectory ?? './coverage',\n include: [...coverageInclude],\n exclude: coverageExclude,\n ...(options.thresholds !== undefined && { thresholds: { ...options.thresholds } }),\n },\n },\n });\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rexezuge/tooling",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.3",
|
|
4
4
|
"private": false,
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"src"
|
|
27
27
|
],
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@rexezuge/d1": "1.0.
|
|
29
|
+
"@rexezuge/d1": "1.0.3"
|
|
30
30
|
},
|
|
31
31
|
"peerDependencies": {
|
|
32
32
|
"eslint": "^10.0.0",
|