@rexezuge/tooling 1.6.0 → 1.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +3 -3
- package/dist/scripts/lib/cli-args.d.ts.map +1 -1
- package/dist/scripts/lib/cli-args.js +1 -1
- package/dist/scripts/lib/cli-args.js.map +2 -2
- package/dist/scripts/lib/wrangler-table.d.ts.map +1 -1
- package/dist/scripts/lib/wrangler-table.js +2 -2
- package/dist/scripts/lib/wrangler-table.js.map +2 -2
- package/dist/scripts/validate-locales.d.ts +7 -1
- package/dist/scripts/validate-locales.d.ts.map +1 -1
- package/dist/scripts/validate-locales.js +5 -4
- package/dist/scripts/validate-locales.js.map +3 -3
- package/dist/vitest-aliases.d.ts +16 -0
- package/dist/vitest-aliases.d.ts.map +1 -1
- package/dist/vitest-aliases.js +1 -1
- package/dist/vitest-aliases.js.map +3 -3
- package/dist/vitest.d.ts.map +1 -1
- package/dist/vitest.js +1 -1
- package/dist/vitest.js.map +3 -3
- package/package.json +14 -2
- package/src/index.ts +1 -1
- package/src/scripts/lib/cli-args.ts +9 -2
- package/src/scripts/lib/wrangler-table.ts +7 -3
- package/src/scripts/validate-locales.convergence.test.ts +190 -0
- package/src/scripts/validate-locales.ts +218 -15
- package/src/vitest-aliases.ts +17 -0
- package/src/vitest.ts +14 -2
package/dist/index.d.ts
CHANGED
|
@@ -24,7 +24,7 @@ export { defineRepoVitestConfig } from './vitest-repo.ts';
|
|
|
24
24
|
export type { RepoBackendOptions, RepoVitestConfigOptions, RepoWebOptions } from './vitest-repo.ts';
|
|
25
25
|
export { defineIntegrationVitestConfig } from './vitest-integration.ts';
|
|
26
26
|
export type { IntegrationVitestConfigOptions } from './vitest-integration.ts';
|
|
27
|
-
export { DEFAULT_CLOUDFLARE_MOCKS, DEFAULT_WORKSPACE_PACKAGES, KIT_NO_EXTERNAL, workspaceAliases } from './vitest-aliases.ts';
|
|
27
|
+
export { DEFAULT_CLOUDFLARE_MOCKS, DEFAULT_WORKSPACE_PACKAGES, KIT_DEDUPE, KIT_NO_EXTERNAL, workspaceAliases } from './vitest-aliases.ts';
|
|
28
28
|
export type { VitestAlias as WorkspaceAlias, WorkspaceAliasesOptions } from './vitest-aliases.ts';
|
|
29
29
|
export { defineWebViteConfig, spaShellEmbedPlugin } from './vite.ts';
|
|
30
30
|
export type { ProxyEntry, SpaShellTarget, WebViteConfigOptions } from './vite.ts';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AACnD,YAAY,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AAEzD,OAAO,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AACrD,YAAY,EAAE,kBAAkB,EAAE,uBAAuB,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE5F,OAAO,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AACxD,YAAY,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AAE9D,OAAO,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAC;AAC1D,YAAY,EAAE,kBAAkB,EAAE,uBAAuB,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAEpG,OAAO,EAAE,6BAA6B,EAAE,MAAM,yBAAyB,CAAC;AACxE,YAAY,EAAE,8BAA8B,EAAE,MAAM,yBAAyB,CAAC;AAE9E,OAAO,EAAE,wBAAwB,EAAE,0BAA0B,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],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AoC,CAAC;AAE/F,OAAO,EAAE,qBAAqB,EAAE,kBAAkB,EAAE,QAAQ,EAAE,MAAM,kCAAkC,CAAC;AACvG,YAAY,EACV,cAAc,EACd,uBAAuB,EACvB,aAAa,EACb,eAAe,EACf,sBAAsB,EACtB,cAAc,GACf,MAAM,kCAAkC,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{defineRepoLintConfig as r}from"./eslint.js";import{defineUnitVitestConfig as i}from"./vitest.js";import{defineWebVitestConfig as n}from"./vitest-web.js";import{defineRepoVitestConfig as a}from"./vitest-repo.js";import{defineIntegrationVitestConfig as m}from"./vitest-integration.js";import{DEFAULT_CLOUDFLARE_MOCKS as x,DEFAULT_WORKSPACE_PACKAGES as l,KIT_NO_EXTERNAL as C,workspaceAliases as
|
|
1
|
+
import{defineRepoLintConfig as r}from"./eslint.js";import{defineUnitVitestConfig as i}from"./vitest.js";import{defineWebVitestConfig as n}from"./vitest-web.js";import{defineRepoVitestConfig as a}from"./vitest-repo.js";import{defineIntegrationVitestConfig as m}from"./vitest-integration.js";import{DEFAULT_CLOUDFLARE_MOCKS as x,DEFAULT_WORKSPACE_PACKAGES as E,KIT_DEDUPE as l,KIT_NO_EXTERNAL as C,workspaceAliases as d}from"./vitest-aliases.js";import{defineWebViteConfig as _,spaShellEmbedPlugin as D}from"./vite.js";import{createPagesProxy as P}from"./functions/pages-proxy.js";import{DurableObject as T,RpcTarget as b,WorkflowEntrypoint as c}from"./test/mocks/cloudflare-workers.js";import{createMigrationHelper as O,readMigrationFiles as S,splitSql as U}from"./test/integration-migrations.js";export{x as DEFAULT_CLOUDFLARE_MOCKS,E as DEFAULT_WORKSPACE_PACKAGES,T as DurableObject,l as KIT_DEDUPE,C as KIT_NO_EXTERNAL,b as RpcTarget,c as WorkflowEntrypoint,O as createMigrationHelper,P as createPagesProxy,m as defineIntegrationVitestConfig,r as defineRepoLintConfig,a as defineRepoVitestConfig,i as defineUnitVitestConfig,_ as defineWebViteConfig,n as defineWebVitestConfig,S as readMigrationFiles,D as spaShellEmbedPlugin,U as splitSql,d as workspaceAliases};
|
package/dist/index.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/index.ts"],
|
|
4
|
-
"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.ts';\nexport type { RepoLintConfigOptions } from './eslint.ts';\n\nexport { defineUnitVitestConfig } from './vitest.ts';\nexport type { CoverageThresholds, UnitVitestConfigOptions, VitestAlias } from './vitest.ts';\n\nexport { defineWebVitestConfig } from './vitest-web.ts';\nexport type { WebVitestConfigOptions } from './vitest-web.ts';\n\nexport { defineRepoVitestConfig } from './vitest-repo.ts';\nexport type { RepoBackendOptions, RepoVitestConfigOptions, RepoWebOptions } from './vitest-repo.ts';\n\nexport { defineIntegrationVitestConfig } from './vitest-integration.ts';\nexport type { IntegrationVitestConfigOptions } from './vitest-integration.ts';\n\nexport { DEFAULT_CLOUDFLARE_MOCKS, DEFAULT_WORKSPACE_PACKAGES, KIT_NO_EXTERNAL, workspaceAliases } from './vitest-aliases.ts';\nexport type { VitestAlias as WorkspaceAlias, WorkspaceAliasesOptions } from './vitest-aliases.ts';\n\nexport { defineWebViteConfig, spaShellEmbedPlugin } from './vite.ts';\nexport type { ProxyEntry, SpaShellTarget, WebViteConfigOptions } from './vite.ts';\n\nexport { createPagesProxy } from './functions/pages-proxy.ts';\nexport type { Fetcher, PagesFunction, PagesFunctionContext, PagesProxyEnv, PagesProxyOptions } from './functions/pages-proxy.ts';\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.ts';\nexport type { DurableObjectState, ExecutionContext } from './test/mocks/cloudflare-workers.ts';\n\nexport { createMigrationHelper, readMigrationFiles, splitSql } from './test/integration-migrations.ts';\nexport type {\n D1DatabaseLike,\n D1PreparedStatementLike,\n MigrationFile,\n MigrationHelper,\n MigrationHelperOptions,\n MigrationRange,\n} from './test/integration-migrations.ts';\n"],
|
|
5
|
-
"mappings": "AAiBA,OAAS,wBAAAA,MAA4B,cAGrC,OAAS,0BAAAC,MAA8B,cAGvC,OAAS,yBAAAC,MAA6B,kBAGtC,OAAS,0BAAAC,MAA8B,mBAGvC,OAAS,iCAAAC,MAAqC,0BAG9C,OAAS,4BAAAC,EAA0B,8BAAAC,EAA4B,mBAAAC,EAAiB,oBAAAC,MAAwB,
|
|
6
|
-
"names": ["defineRepoLintConfig", "defineUnitVitestConfig", "defineWebVitestConfig", "defineRepoVitestConfig", "defineIntegrationVitestConfig", "DEFAULT_CLOUDFLARE_MOCKS", "DEFAULT_WORKSPACE_PACKAGES", "KIT_NO_EXTERNAL", "workspaceAliases", "defineWebViteConfig", "spaShellEmbedPlugin", "createPagesProxy", "DurableObject", "RpcTarget", "WorkflowEntrypoint", "createMigrationHelper", "readMigrationFiles", "splitSql"]
|
|
4
|
+
"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.ts';\nexport type { RepoLintConfigOptions } from './eslint.ts';\n\nexport { defineUnitVitestConfig } from './vitest.ts';\nexport type { CoverageThresholds, UnitVitestConfigOptions, VitestAlias } from './vitest.ts';\n\nexport { defineWebVitestConfig } from './vitest-web.ts';\nexport type { WebVitestConfigOptions } from './vitest-web.ts';\n\nexport { defineRepoVitestConfig } from './vitest-repo.ts';\nexport type { RepoBackendOptions, RepoVitestConfigOptions, RepoWebOptions } from './vitest-repo.ts';\n\nexport { defineIntegrationVitestConfig } from './vitest-integration.ts';\nexport type { IntegrationVitestConfigOptions } from './vitest-integration.ts';\n\nexport { DEFAULT_CLOUDFLARE_MOCKS, DEFAULT_WORKSPACE_PACKAGES, KIT_DEDUPE, KIT_NO_EXTERNAL, workspaceAliases } from './vitest-aliases.ts';\nexport type { VitestAlias as WorkspaceAlias, WorkspaceAliasesOptions } from './vitest-aliases.ts';\n\nexport { defineWebViteConfig, spaShellEmbedPlugin } from './vite.ts';\nexport type { ProxyEntry, SpaShellTarget, WebViteConfigOptions } from './vite.ts';\n\nexport { createPagesProxy } from './functions/pages-proxy.ts';\nexport type { Fetcher, PagesFunction, PagesFunctionContext, PagesProxyEnv, PagesProxyOptions } from './functions/pages-proxy.ts';\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.ts';\nexport type { DurableObjectState, ExecutionContext } from './test/mocks/cloudflare-workers.ts';\n\nexport { createMigrationHelper, readMigrationFiles, splitSql } from './test/integration-migrations.ts';\nexport type {\n D1DatabaseLike,\n D1PreparedStatementLike,\n MigrationFile,\n MigrationHelper,\n MigrationHelperOptions,\n MigrationRange,\n} from './test/integration-migrations.ts';\n"],
|
|
5
|
+
"mappings": "AAiBA,OAAS,wBAAAA,MAA4B,cAGrC,OAAS,0BAAAC,MAA8B,cAGvC,OAAS,yBAAAC,MAA6B,kBAGtC,OAAS,0BAAAC,MAA8B,mBAGvC,OAAS,iCAAAC,MAAqC,0BAG9C,OAAS,4BAAAC,EAA0B,8BAAAC,EAA4B,cAAAC,EAAY,mBAAAC,EAAiB,oBAAAC,MAAwB,sBAGpH,OAAS,uBAAAC,EAAqB,uBAAAC,MAA2B,YAGzD,OAAS,oBAAAC,MAAwB,6BAQjC,OAAS,iBAAAC,EAAe,aAAAC,EAAW,sBAAAC,MAA0B,qCAG7D,OAAS,yBAAAC,EAAuB,sBAAAC,EAAoB,YAAAC,MAAgB",
|
|
6
|
+
"names": ["defineRepoLintConfig", "defineUnitVitestConfig", "defineWebVitestConfig", "defineRepoVitestConfig", "defineIntegrationVitestConfig", "DEFAULT_CLOUDFLARE_MOCKS", "DEFAULT_WORKSPACE_PACKAGES", "KIT_DEDUPE", "KIT_NO_EXTERNAL", "workspaceAliases", "defineWebViteConfig", "spaShellEmbedPlugin", "createPagesProxy", "DurableObject", "RpcTarget", "WorkflowEntrypoint", "createMigrationHelper", "readMigrationFiles", "splitSql"]
|
|
7
7
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli-args.d.ts","sourceRoot":"","sources":["../../../src/scripts/lib/cli-args.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH;;GAEG;AACH,MAAM,MAAM,WAAW,GAAG,GAAG,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC,CAAC;AAErD;;GAEG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AI,EAAE,SAAS,MAAM,EAAE,EACvB,UAAU,EAAE,SAAS,MAAM,EAAE,EAC7B,QAAQ,SAAI,GACX;IAAE,UAAU,EAAE,MAAM,EAAE,CAAC;IAAC,IAAI,EAAE,MAAM,EAAE,CAAA;CAAE,CAwB1C"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var f=Object.defineProperty;var l=(t,e)=>f(t,"name",{value:e,configurable:!0});function g(t,e){const a=new Set(e.value),c=new Set(e.boolean),i=e.alias??{},r=new Map;for(let n=0;n<t.length;n+=1){const s=t[n];if(!s.startsWith("-"))throw new Error(`Unexpected argument: ${s}`);const u=s.replace(/^--?/,""),o=i[u]??u;if(c.has(o)){if(r.has(o))throw new Error(`--${o} was given more than once`);r.set(o,!0);continue}if(!a.has(o))throw new Error(`Unknown argument: ${s}`);if(r.has(o))throw new Error(`--${o} was given more than once`);const h=n+1<t.length?t[n+1]:void 0;if(h===void 0||h.startsWith("-"))throw new Error(`--${o} requires a value`);r.set(o,h),n+=1}return r}l(g,"parseFlags");function p(t,e){const a=t.get(e);return typeof a=="string"?a:void 0}l(p,"valueOf");function d(t,e){return t.get(e)===!0}l(d,"isSet");function m(t,e,a=1){const c=new Set(e),i=[],r=[];for(let n=0;n<t.length;n+=1){const s=t[n];if(s.startsWith("-")){r.push(s);continue}const u=t[n-1];if(u!==void 0&&u.startsWith("-")&&c.has(u.replace(/^--?/,""))){r.push(s);continue}i.push(s)}if(i.length>a)throw new Error(`Expected at most ${a} positional argument(s), got: ${i.join(", ")}`);return{positional:i,rest:r}}l(m,"splitPositional");export{d as isSet,g as parseFlags,m as splitPositional,p as valueOf};
|
|
1
|
+
var f=Object.defineProperty;var l=(t,e)=>f(t,"name",{value:e,configurable:!0});function g(t,e){const a=new Set(e.value),c=new Set(e.boolean),i=e.alias??{},r=new Map;for(let n=0;n<t.length;n+=1){const s=t[n]??"";if(!s.startsWith("-"))throw new Error(`Unexpected argument: ${s}`);const u=s.replace(/^--?/,""),o=i[u]??u;if(c.has(o)){if(r.has(o))throw new Error(`--${o} was given more than once`);r.set(o,!0);continue}if(!a.has(o))throw new Error(`Unknown argument: ${s}`);if(r.has(o))throw new Error(`--${o} was given more than once`);const h=n+1<t.length?t[n+1]:void 0;if(h===void 0||h.startsWith("-"))throw new Error(`--${o} requires a value`);r.set(o,h),n+=1}return r}l(g,"parseFlags");function p(t,e){const a=t.get(e);return typeof a=="string"?a:void 0}l(p,"valueOf");function d(t,e){return t.get(e)===!0}l(d,"isSet");function m(t,e,a=1){const c=new Set(e),i=[],r=[];for(let n=0;n<t.length;n+=1){const s=t[n]??"";if(s.startsWith("-")){r.push(s);continue}const u=t[n-1];if(u!==void 0&&u.startsWith("-")&&c.has(u.replace(/^--?/,""))){r.push(s);continue}i.push(s)}if(i.length>a)throw new Error(`Expected at most ${a} positional argument(s), got: ${i.join(", ")}`);return{positional:i,rest:r}}l(m,"splitPositional");export{d as isSet,g as parseFlags,m as splitPositional,p as valueOf};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/scripts/lib/cli-args.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * Minimal flag parsing for the operator scripts.\n *\n * Provenance: ported from Edge-Sonic's `scripts/lib/cli-args.ts`, which is the\n * only typed arg parser in the family — every other repo reads `process.argv`\n * with `includes('--flag')` inline.\n *\n * The shape is generic: a declared set of value flags and boolean flags, so an\n * unknown or valueless flag is rejected **by name** rather than silently ignored.\n * A mistyped `--write` must not degrade into \"ran with no flags\" — which is what\n * an inline `argv.includes()` does, and what turns a migration-lock invocation\n * that misspelled the flag into a read-only run that reports success.\n *\n * Usage:\n *\n * ```ts\n * const flags = parseFlags(process.argv.slice(2), {\n * boolean: ['write', 'dry-run'],\n * value: ['locales-dir', 'root'],\n * });\n * if (isSet(flags, 'write')) { ... }\n * const dir = valueOf(flags, 'locales-dir');\n * ```\n */\n\n/**\n * Parsed flags: value flags map to their string, boolean flags to `true`.\n */\nexport type ParsedFlags = Map<string, string | true>;\n\n/**\n * Declares which flags take a value and which are bare switches.\n */\nexport interface FlagSpec {\n /**\n * `--name` takes a value, e.g. `--to new@example.com`.\n */\n value?: readonly string[];\n /**\n * `--dry-run` takes no value.\n */\n boolean?: readonly string[];\n /**\n * Short form → long form, e.g. `{ h: 'help' }`.\n */\n alias?: Readonly<Record<string, string>>;\n}\n\n/**\n * Parses `--flag value` and `--boolean` pairs out of `argv`.\n *\n * @throws when a value flag is missing its value, when a flag is repeated, or\n * when an undeclared flag is seen. Each case names the offending flag.\n */\nexport function parseFlags(argv: readonly string[], spec: FlagSpec): ParsedFlags {\n const valueFlags = new Set(spec.value);\n const booleanFlags = new Set(spec.boolean);\n const aliases = spec.alias ?? {};\n const flags: ParsedFlags = new Map();\n\n for (let index = 0; index < argv.length; index += 1) {\n const arg = argv[index];\n if (!arg.startsWith('-')) {\n throw new Error(`Unexpected argument: ${arg}`);\n }\n const raw = arg.replace(/^--?/, '');\n const name = aliases[raw] ?? raw;\n\n if (booleanFlags.has(name)) {\n if (flags.has(name)) {\n throw new Error(`--${name} was given more than once`);\n }\n flags.set(name, true);\n continue;\n }\n\n if (!valueFlags.has(name)) {\n throw new Error(`Unknown argument: ${arg}`);\n }\n if (flags.has(name)) {\n throw new Error(`--${name} was given more than once`);\n }\n\n // `argv[index + 1]` is statically a string, but a value flag in last\n // position has no next element at runtime — the length check is what makes\n // the `undefined` below reachable rather than dead.\n const value = index + 1 < argv.length ? argv[index + 1] : undefined;\n // A value that starts with `-` is treated as a missing value so that\n // `--to --dry-run` reports the real problem instead of capturing the flag.\n if (value === undefined || value.startsWith('-')) {\n throw new Error(`--${name} requires a value`);\n }\n flags.set(name, value);\n index += 1;\n }\n\n return flags;\n}\n\n/**\n * Reads a value flag, or `undefined` when it was not supplied.\n */\nexport function valueOf(flags: ParsedFlags, name: string): string | undefined {\n const value = flags.get(name);\n return typeof value === 'string' ? value : undefined;\n}\n\n/**\n * Reads a boolean flag, defaulting to `false`.\n */\nexport function isSet(flags: ParsedFlags, name: string): boolean {\n return flags.get(name) === true;\n}\n\n/**\n * Split `argv` into its positional arguments and the rest, so a caller can accept\n * `tsx script.ts <dir>` alongside `--root <dir>`.\n *\n * A token that follows a value flag *is* that flag's value, not a positional: the\n * naive `argv.filter((arg) => !arg.startsWith('-'))` takes `.` out of\n * `--root . --fail-on-hard` and then `parseFlags` reports `--root requires a value`.\n * The value flags are passed in rather than inferred, because only the caller knows\n * which of its declared flags take one.\n *\n * @throws when more than `expected` positionals are given, naming them: a second\n * directory is far more likely to be a mistyped flag than an intended argument.\n */\nexport function splitPositional(\n argv: readonly string[],\n valueFlags: readonly string[],\n expected = 1,\n): { positional: string[]; rest: string[] } {\n const takes = new Set(valueFlags);\n const positional: string[] = [];\n const rest: string[] = [];\n\n for (let index = 0; index < argv.length; index += 1) {\n const arg = argv[index];\n if (arg.startsWith('-')) {\n rest.push(arg);\n continue;\n }\n const previous = argv[index - 1] as string | undefined;\n const isFlagValue = previous !== undefined && previous.startsWith('-') && takes.has(previous.replace(/^--?/, ''));\n if (isFlagValue) {\n rest.push(arg);\n continue;\n }\n positional.push(arg);\n }\n\n if (positional.length > expected) {\n throw new Error(`Expected at most ${expected} positional argument(s), got: ${positional.join(', ')}`);\n }\n return { positional, rest };\n}\n"],
|
|
5
|
-
"mappings": "+EAsDM,SAAUA,EAAWC,EAAyBC,EAAc,CAChE,MAAMC,EAAa,IAAI,IAAID,EAAK,KAAK,EAC/BE,EAAe,IAAI,IAAIF,EAAK,OAAO,EACnCG,EAAUH,EAAK,OAAS,CAAA,EACxBI,EAAqB,IAAI,IAE/B,QAASC,EAAQ,EAAGA,EAAQN,EAAK,OAAQM,GAAS,EAAG,
|
|
4
|
+
"sourcesContent": ["/**\n * Minimal flag parsing for the operator scripts.\n *\n * Provenance: ported from Edge-Sonic's `scripts/lib/cli-args.ts`, which is the\n * only typed arg parser in the family — every other repo reads `process.argv`\n * with `includes('--flag')` inline.\n *\n * The shape is generic: a declared set of value flags and boolean flags, so an\n * unknown or valueless flag is rejected **by name** rather than silently ignored.\n * A mistyped `--write` must not degrade into \"ran with no flags\" — which is what\n * an inline `argv.includes()` does, and what turns a migration-lock invocation\n * that misspelled the flag into a read-only run that reports success.\n *\n * Usage:\n *\n * ```ts\n * const flags = parseFlags(process.argv.slice(2), {\n * boolean: ['write', 'dry-run'],\n * value: ['locales-dir', 'root'],\n * });\n * if (isSet(flags, 'write')) { ... }\n * const dir = valueOf(flags, 'locales-dir');\n * ```\n */\n\n/**\n * Parsed flags: value flags map to their string, boolean flags to `true`.\n */\nexport type ParsedFlags = Map<string, string | true>;\n\n/**\n * Declares which flags take a value and which are bare switches.\n */\nexport interface FlagSpec {\n /**\n * `--name` takes a value, e.g. `--to new@example.com`.\n */\n value?: readonly string[];\n /**\n * `--dry-run` takes no value.\n */\n boolean?: readonly string[];\n /**\n * Short form → long form, e.g. `{ h: 'help' }`.\n */\n alias?: Readonly<Record<string, string>>;\n}\n\n/**\n * Parses `--flag value` and `--boolean` pairs out of `argv`.\n *\n * @throws when a value flag is missing its value, when a flag is repeated, or\n * when an undeclared flag is seen. Each case names the offending flag.\n */\nexport function parseFlags(argv: readonly string[], spec: FlagSpec): ParsedFlags {\n const valueFlags = new Set(spec.value);\n const booleanFlags = new Set(spec.boolean);\n const aliases = spec.alias ?? {};\n const flags: ParsedFlags = new Map();\n\n for (let index = 0; index < argv.length; index += 1) {\n // `?? ''` rather than `as string`. `argv[index]` is `string | undefined` under\n // `noUncheckedIndexedAccess`, which this package's own tsconfig does not enable\n // and a consuming repo's does — so an assertion is redundant here and required\n // there, and a script that only typechecks in its author's repository is a\n // script a consumer cannot adopt. The loop bound already proves the element is\n // present, and `''` is not a flag, so the fallthrough reports it rather than\n // hiding it.\n const arg = argv[index] ?? '';\n if (!arg.startsWith('-')) {\n throw new Error(`Unexpected argument: ${arg}`);\n }\n const raw = arg.replace(/^--?/, '');\n const name = aliases[raw] ?? raw;\n\n if (booleanFlags.has(name)) {\n if (flags.has(name)) {\n throw new Error(`--${name} was given more than once`);\n }\n flags.set(name, true);\n continue;\n }\n\n if (!valueFlags.has(name)) {\n throw new Error(`Unknown argument: ${arg}`);\n }\n if (flags.has(name)) {\n throw new Error(`--${name} was given more than once`);\n }\n\n // `argv[index + 1]` is statically a string, but a value flag in last\n // position has no next element at runtime — the length check is what makes\n // the `undefined` below reachable rather than dead.\n const value = index + 1 < argv.length ? argv[index + 1] : undefined;\n // A value that starts with `-` is treated as a missing value so that\n // `--to --dry-run` reports the real problem instead of capturing the flag.\n if (value === undefined || value.startsWith('-')) {\n throw new Error(`--${name} requires a value`);\n }\n flags.set(name, value);\n index += 1;\n }\n\n return flags;\n}\n\n/**\n * Reads a value flag, or `undefined` when it was not supplied.\n */\nexport function valueOf(flags: ParsedFlags, name: string): string | undefined {\n const value = flags.get(name);\n return typeof value === 'string' ? value : undefined;\n}\n\n/**\n * Reads a boolean flag, defaulting to `false`.\n */\nexport function isSet(flags: ParsedFlags, name: string): boolean {\n return flags.get(name) === true;\n}\n\n/**\n * Split `argv` into its positional arguments and the rest, so a caller can accept\n * `tsx script.ts <dir>` alongside `--root <dir>`.\n *\n * A token that follows a value flag *is* that flag's value, not a positional: the\n * naive `argv.filter((arg) => !arg.startsWith('-'))` takes `.` out of\n * `--root . --fail-on-hard` and then `parseFlags` reports `--root requires a value`.\n * The value flags are passed in rather than inferred, because only the caller knows\n * which of its declared flags take one.\n *\n * @throws when more than `expected` positionals are given, naming them: a second\n * directory is far more likely to be a mistyped flag than an intended argument.\n */\nexport function splitPositional(\n argv: readonly string[],\n valueFlags: readonly string[],\n expected = 1,\n): { positional: string[]; rest: string[] } {\n const takes = new Set(valueFlags);\n const positional: string[] = [];\n const rest: string[] = [];\n\n for (let index = 0; index < argv.length; index += 1) {\n const arg = argv[index] ?? '';\n if (arg.startsWith('-')) {\n rest.push(arg);\n continue;\n }\n const previous = argv[index - 1] as string | undefined;\n const isFlagValue = previous !== undefined && previous.startsWith('-') && takes.has(previous.replace(/^--?/, ''));\n if (isFlagValue) {\n rest.push(arg);\n continue;\n }\n positional.push(arg);\n }\n\n if (positional.length > expected) {\n throw new Error(`Expected at most ${expected} positional argument(s), got: ${positional.join(', ')}`);\n }\n return { positional, rest };\n}\n"],
|
|
5
|
+
"mappings": "+EAsDM,SAAUA,EAAWC,EAAyBC,EAAc,CAChE,MAAMC,EAAa,IAAI,IAAID,EAAK,KAAK,EAC/BE,EAAe,IAAI,IAAIF,EAAK,OAAO,EACnCG,EAAUH,EAAK,OAAS,CAAA,EACxBI,EAAqB,IAAI,IAE/B,QAASC,EAAQ,EAAGA,EAAQN,EAAK,OAAQM,GAAS,EAAG,CAQnD,MAAMC,EAAMP,EAAKM,CAAK,GAAK,GAC3B,GAAI,CAACC,EAAI,WAAW,GAAG,EACrB,MAAM,IAAI,MAAM,wBAAwBA,CAAG,EAAE,EAE/C,MAAMC,EAAMD,EAAI,QAAQ,OAAQ,EAAE,EAC5BE,EAAOL,EAAQI,CAAG,GAAKA,EAE7B,GAAIL,EAAa,IAAIM,CAAI,EAAG,CAC1B,GAAIJ,EAAM,IAAII,CAAI,EAChB,MAAM,IAAI,MAAM,KAAKA,CAAI,2BAA2B,EAEtDJ,EAAM,IAAII,EAAM,EAAI,EACpB,QACF,CAEA,GAAI,CAACP,EAAW,IAAIO,CAAI,EACtB,MAAM,IAAI,MAAM,qBAAqBF,CAAG,EAAE,EAE5C,GAAIF,EAAM,IAAII,CAAI,EAChB,MAAM,IAAI,MAAM,KAAKA,CAAI,2BAA2B,EAMtD,MAAMC,EAAQJ,EAAQ,EAAIN,EAAK,OAASA,EAAKM,EAAQ,CAAC,EAAI,OAG1D,GAAII,IAAU,QAAaA,EAAM,WAAW,GAAG,EAC7C,MAAM,IAAI,MAAM,KAAKD,CAAI,mBAAmB,EAE9CJ,EAAM,IAAII,EAAMC,CAAK,EACrBJ,GAAS,CACX,CAEA,OAAOD,CACT,CAlDgBM,EAAAZ,EAAA,cAuDV,SAAUa,EAAQP,EAAoBI,EAAY,CACtD,MAAMC,EAAQL,EAAM,IAAII,CAAI,EAC5B,OAAO,OAAOC,GAAU,SAAWA,EAAQ,MAC7C,CAHgBC,EAAAC,EAAA,WAQV,SAAUC,EAAMR,EAAoBI,EAAY,CACpD,OAAOJ,EAAM,IAAII,CAAI,IAAM,EAC7B,CAFgBE,EAAAE,EAAA,SAiBV,SAAUC,EACdd,EACAE,EACAa,EAAW,EAAC,CAEZ,MAAMC,EAAQ,IAAI,IAAId,CAAU,EAC1Be,EAAuB,CAAA,EACvBC,EAAiB,CAAA,EAEvB,QAASZ,EAAQ,EAAGA,EAAQN,EAAK,OAAQM,GAAS,EAAG,CACnD,MAAMC,EAAMP,EAAKM,CAAK,GAAK,GAC3B,GAAIC,EAAI,WAAW,GAAG,EAAG,CACvBW,EAAK,KAAKX,CAAG,EACb,QACF,CACA,MAAMY,EAAWnB,EAAKM,EAAQ,CAAC,EAE/B,GADoBa,IAAa,QAAaA,EAAS,WAAW,GAAG,GAAKH,EAAM,IAAIG,EAAS,QAAQ,OAAQ,EAAE,CAAC,EAC/F,CACfD,EAAK,KAAKX,CAAG,EACb,QACF,CACAU,EAAW,KAAKV,CAAG,CACrB,CAEA,GAAIU,EAAW,OAASF,EACtB,MAAM,IAAI,MAAM,oBAAoBA,CAAQ,iCAAiCE,EAAW,KAAK,IAAI,CAAC,EAAE,EAEtG,MAAO,CAAE,WAAAA,EAAY,KAAAC,CAAI,CAC3B,CA5BgBP,EAAAG,EAAA",
|
|
6
6
|
"names": ["parseFlags", "argv", "spec", "valueFlags", "booleanFlags", "aliases", "flags", "index", "arg", "raw", "name", "value", "__name", "valueOf", "isSet", "splitPositional", "expected", "takes", "positional", "rest", "previous"]
|
|
7
7
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wrangler-table.d.ts","sourceRoot":"","sources":["../../../src/scripts/lib/wrangler-table.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAiBH;;;;;;;GAOG;AACH,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,EAAE,
|
|
1
|
+
{"version":3,"file":"wrangler-table.d.ts","sourceRoot":"","sources":["../../../src/scripts/lib/wrangler-table.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAiBH;;;;;;;GAOG;AACH,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,EAAE,CA6BjE;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,MAAM,GAAG,GAAG,CAAC,MAAM,CAAC,CAS9D;AASD;;;;;;;GAOG;AACH,wBAAgB,0BAA0B,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAGlE"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var
|
|
2
|
-
`)){if(!s.includes(r))continue;const t=s.split(r).map(c=>c.trim()).filter(Boolean);if(t.length<2)continue;const
|
|
1
|
+
var f=Object.defineProperty;var o=(n,e)=>f(n,"name",{value:e,configurable:!0});const r=String.fromCodePoint(9474),a=String.fromCodePoint(9472),u="Name";function l(n){const e=[];for(const s of n.split(`
|
|
2
|
+
`)){if(!s.includes(r))continue;const t=s.split(r).map(c=>c.trim()).filter(Boolean);if(t.length<2)continue;const[i]=t;i===void 0||i===u||i.includes(a)||e.push(t)}return e}o(l,"parseWranglerTableRows");function E(n){const e=new Set;for(const s of l(n)){const t=s.at(0);t!==void 0&&e.add(t)}return e}o(E,"parseWranglerNames");const d="List request returned no secrets";function S(n){return(n instanceof Error?n.message:String(n)).includes(d)}o(S,"isEmptySecretsStoreListing");export{S as isEmptySecretsStoreListing,E as parseWranglerNames,l as parseWranglerTableRows};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/scripts/lib/wrangler-table.ts"],
|
|
4
|
-
"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 if (cells.length < 2) {\n continue;\n }\n
|
|
5
|
-
"mappings": "+EAwBA,MAAMA,EAAmB,OAAO,cAAc,IAAO,EAK/CC,EAAiB,OAAO,cAAc,IAAO,EAK7CC,EAAoB,OAUpB,SAAUC,EAAuBC,EAAc,CACnD,MAAMC,EAAmB,CAAA,EACzB,UAAWC,KAAQF,EAAO,MAAM;CAAI,EAAG,CAIrC,GAAI,CAACE,EAAK,SAASN,CAAgB,EACjC,SAGF,MAAMO,EAAkBD,EACrB,MAAMN,CAAgB,EACtB,IAAKQ,GAASA,EAAK,KAAI,CAAE,EACzB,OAAO,OAAO,EACjB,GAAID,EAAM,OAAS,EACjB,
|
|
4
|
+
"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 if (cells.length < 2) {\n continue;\n }\n // The header row and the horizontal rules are frame, not data; an empty row is\n // frame too. Destructured rather than indexed so it is total under\n // `noUncheckedIndexedAccess` as well as without it — a consuming repo enables\n // that flag and this package does not, and a script that only typechecks in its\n // author's repository is a script a consumer cannot adopt.\n const [firstCell] = cells;\n if (firstCell === undefined || 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 // `.at()` rather than `[0]`: the absence case is real for a hand-built row\n // in a test double, and the guard below is what keeps it out of the set.\n const name = row.at(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"],
|
|
5
|
+
"mappings": "+EAwBA,MAAMA,EAAmB,OAAO,cAAc,IAAO,EAK/CC,EAAiB,OAAO,cAAc,IAAO,EAK7CC,EAAoB,OAUpB,SAAUC,EAAuBC,EAAc,CACnD,MAAMC,EAAmB,CAAA,EACzB,UAAWC,KAAQF,EAAO,MAAM;CAAI,EAAG,CAIrC,GAAI,CAACE,EAAK,SAASN,CAAgB,EACjC,SAGF,MAAMO,EAAkBD,EACrB,MAAMN,CAAgB,EACtB,IAAKQ,GAASA,EAAK,KAAI,CAAE,EACzB,OAAO,OAAO,EACjB,GAAID,EAAM,OAAS,EACjB,SAOF,KAAM,CAACE,CAAS,EAAIF,EAChBE,IAAc,QAAaA,IAAcP,GAAqBO,EAAU,SAASR,CAAc,GAGnGI,EAAK,KAAKE,CAAK,CACjB,CACA,OAAOF,CACT,CA7BgBK,EAAAP,EAAA,0BAqCV,SAAUQ,EAAmBP,EAAc,CAC/C,MAAMQ,EAAQ,IAAI,IAClB,UAAWC,KAAOV,EAAuBC,CAAM,EAAG,CAGhD,MAAMU,EAAOD,EAAI,GAAG,CAAC,EACjBC,IAAS,QAAWF,EAAM,IAAIE,CAAI,CACxC,CACA,OAAOF,CACT,CATgBF,EAAAC,EAAA,sBAgBhB,MAAMI,EAAsB,mCAUtB,SAAUC,EAA2BC,EAAc,CAEvD,OADwBA,aAAiB,MAAQA,EAAM,QAAU,OAAOA,CAAK,GAC9D,SAASF,CAAmB,CAC7C,CAHgBL,EAAAM,EAAA",
|
|
6
6
|
"names": ["COLUMN_SEPARATOR", "RULE_CHARACTER", "HEADER_FIRST_CELL", "parseWranglerTableRows", "output", "rows", "line", "cells", "cell", "firstCell", "__name", "parseWranglerNames", "names", "row", "name", "EMPTY_STORE_MESSAGE", "isEmptySecretsStoreListing", "error"]
|
|
7
7
|
}
|
|
@@ -26,7 +26,13 @@ declare function parseObjectLiteral(source: string, file: string): unknown;
|
|
|
26
26
|
*/
|
|
27
27
|
declare function validateLocales(localesDir: string, baseLocale?: string, shape?: LocaleShape): LocaleReport;
|
|
28
28
|
/**
|
|
29
|
-
CLI entry: `validateLocalesCli(['[locales-dir]?', '--shape=auto|dir|file|module'?, '--base=<tag>'?])`.
|
|
29
|
+
CLI entry: `validateLocalesCli(['[locales-dir]?', '--shape=auto|dir|file|module'?, '--base=<tag>'?, '--call-sites=<src-dir>'?])`.
|
|
30
|
+
|
|
31
|
+
`--call-sites=<dir>` opts into the application-side checks: every `t('key')` under
|
|
32
|
+
`<dir>` must resolve against the base bundle, and any inline default must equal the
|
|
33
|
+
bundled value. Without the flag the script stays bundle-to-bundle, because that is
|
|
34
|
+
the only part it can answer for a repo whose bundles are consumed by something
|
|
35
|
+
other than `t()` — a backend string table, for instance.
|
|
30
36
|
*/
|
|
31
37
|
declare function validateLocalesCli(argv?: readonly string[]): number;
|
|
32
38
|
export { parseObjectLiteral, validateLocales, validateLocalesCli };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validate-locales.d.ts","sourceRoot":"","sources":["../../src/scripts/validate-locales.ts"],"names":[],"mappings":"AAyCA;;EAEE;AACF,KAAK,WAAW,GAAG,MAAM,GAAG,KAAK,GAAG,MAAM,GAAG,QAAQ,CAAC;AAEtD;;EAEE;AACF,UAAU,aAAa;IACrB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;CACjB;AAED;;EAEE;AACF,UAAU,YAAY;IACpB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,aAAa,EAAE,CAAC;CAC3B;
|
|
1
|
+
{"version":3,"file":"validate-locales.d.ts","sourceRoot":"","sources":["../../src/scripts/validate-locales.ts"],"names":[],"mappings":"AAyCA;;EAEE;AACF,KAAK,WAAW,GAAG,MAAM,GAAG,KAAK,GAAG,MAAM,GAAG,QAAQ,CAAC;AAEtD;;EAEE;AACF,UAAU,aAAa;IACrB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;CACjB;AAED;;EAEE;AACF,UAAU,YAAY;IACpB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,aAAa,EAAE,CAAC;CAC3B;AAsID,iBAAS,kBAAkB,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CA4EjE;AAqFD;;;;;GAKG;AACH,iBAAS,eAAe,CAAC,UAAU,EAAE,MAAM,EAAE,UAAU,SAAO,EAAE,KAAK,GAAE,WAAoB,GAAG,YAAY,CA2EzG;AAmHD;;;;;;;;EAQE;AACF,iBAAS,kBAAkB,CAAC,IAAI,GAAE,SAAS,MAAM,EAA0B,GAAG,MAAM,CAyBnF;AAED,OAAO,EAAE,kBAAkB,EAAE,eAAe,EAAE,kBAAkB,EAAE,CAAC;AACnE,YAAY,EAAE,aAAa,EAAE,YAAY,EAAE,WAAW,EAAE,CAAC"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
var
|
|
2
|
-
`&&(
|
|
3
|
-
`&&(
|
|
4
|
-
`).replaceAll(String.raw`\t`," ").replaceAll(String.raw`\\`,"\\")}
|
|
1
|
+
var J=Object.defineProperty;var d=(e,t)=>J(e,"name",{value:t,configurable:!0});import{existsSync as $,readdirSync as w,readFileSync as A}from"node:fs";import{pathToFileURL as W}from"node:url";import g from"node:path";function b(e,t="",r=new Map){if(e===null||typeof e!="object"||Array.isArray(e))return t&&r.set(t,e),r;const n=Object.entries(e);if(n.length===0)return t&&r.set(t,e),r;for(const[o,i]of n)b(i,t?`${t}.${o}`:o,r);return r}d(b,"flatten");function j(e){return typeof e!="string"?[]:[...new Set(e.match(/\{\{[^{}]+\}\}/g))].sort((t,r)=>t.localeCompare(r))}d(j,"placeholdersOf");function S(e){const t=A(e,"utf8");return e.endsWith(".ts")?x(t,e):JSON.parse(t)}d(S,"readBundle");function T(e){let t="",r=!1,n=!1;for(let o=0;o<e.length;o+=1){const i=e[o];if(r){i===`
|
|
2
|
+
`&&(r=!1);continue}const l=e[o+1];if(n){i==="*"&&l==="/"&&(n=!1,o+=1);continue}if(t!==""){if(i==="\\"){o+=1;continue}i===t&&(t="");continue}if(i==="-"&&l==="-"){r=!0;continue}if(i==="/"&&l==="*"){n=!0;continue}if(i==="'"||i==='"'||i==="`"){t=i;continue}const s=e[o-1];if(i==="="&&l!=="="&&l!==">"&&s!=="="&&s!=="!"&&s!=="<"&&s!==">"){const a=e.indexOf("{",o);return a===-1?-1:a}}return-1}d(T,"objectLiteralStart");function x(e,t){const r=T(e);if(r===-1)throw new Error(`${t} has no object literal`);let n=0,o=-1,i="",l=!1,s=!1;for(let f=r;f<e.length;f+=1){const c=e[f];if(l){c===`
|
|
3
|
+
`&&(l=!1);continue}const p=e[f+1];if(s){c==="*"&&p==="/"&&(s=!1,f+=1);continue}if(i!==""){if(c==="\\"){f+=1;continue}c===i&&(i="");continue}if(c==="-"&&p==="-"){l=!0;continue}if(c==="/"&&p==="*"){s=!0;continue}if(c==="'"||c==='"'||c==="`"){i=c;continue}if(c==="{")n+=1;else if(c==="}"&&(n-=1,n===0)){o=f;break}}if(o===-1)throw new Error(`${t} has an unterminated object literal`);const u=e.slice(r,o+1).replaceAll(/'((?:[^'\\]|\\.)*)'/g,(f,c)=>JSON.stringify(q(c))).replaceAll(/([{,]\s*)([A-Z_$][\w$]*)(\s*:)/gi,'$1"$2"$3').replaceAll(/,(\s*[}\]])/g,"$1");try{return JSON.parse(u)}catch(f){throw new Error(`${t} object literal could not be parsed: ${f instanceof Error?f.message:String(f)}`)}}d(x,"parseObjectLiteral");function q(e){return e.replaceAll(String.raw`\'`,"'").replaceAll(String.raw`\"`,'"').replaceAll(String.raw`\n`,`
|
|
4
|
+
`).replaceAll(String.raw`\t`," ").replaceAll(String.raw`\\`,"\\")}d(q,"unescapeLiteral");const O={file:"json",module:"ts"};function y(e){return e==="auto"?["dir","file","module"]:[e]}d(y,"layouts");function v(e,t){const r=[];y(t).includes("dir")&&r.push(...w(e,{withFileTypes:!0}).filter(n=>n.isDirectory()).map(n=>n.name));for(const n of y(t)){if(n==="dir")continue;const o=O[n];r.push(...w(e).filter(i=>i.endsWith(`.${o}`)).map(i=>i.slice(0,-o.length-1)))}return r}d(v,"tagsOnDisk");function k(e,t,r){const n=[];y(r).includes("dir")&&n.push(g.join(e,t,"translation.json"));for(const o of y(r))o!=="dir"&&n.push(g.join(e,`${t}.${O[o]}`));return n.find(o=>$(o))}d(k,"bundleFor");function B(e,t,r){const n=k(e,t,r);if(n===void 0)throw new Error(`no bundle found for the base locale (expected ${t}/translation.json)`);return b(S(n))}d(B,"bundleAt");function E(e,t="en",r="auto"){const n=[];if(!$(e))return n.push({locale:t,problem:`${e} does not exist`}),{locales:[],keys:0,problems:n};const o=k(e,t,r);if(o===void 0)return n.push({locale:t,problem:`no bundle found for the base locale (expected ${t}/translation.json)`}),{locales:[],keys:0,problems:n};let i;try{i=b(S(o))}catch(a){return n.push({locale:t,problem:`${o}: ${a instanceof Error?a.message:String(a)}`}),{locales:[],keys:0,problems:n}}const l=new Set(i.keys());if(l.size===0)return n.push({locale:t,problem:`${o} has no keys \u2014 the base bundle is empty or unreadable`}),{locales:[t],keys:0,problems:n};const s=[...new Set([...v(e,r),t])].sort((a,m)=>a.localeCompare(m));for(const a of s){const m=k(e,a,r);if(m===void 0){n.push({locale:a,problem:"no bundle found"});continue}let h;try{h=b(S(m))}catch(u){n.push({locale:a,problem:`${m}: ${u instanceof Error?u.message:String(u)}`});continue}for(const u of l)h.has(u)||n.push({locale:a,problem:`missing key: ${u}`});for(const[u,f]of h){if(!l.has(u)){n.push({locale:a,problem:`extra key not in ${t}: ${u}`});continue}if(typeof f!="string"||f===""){n.push({locale:a,problem:`empty value: ${u} \u2014 indistinguishable from a missing key at runtime`});continue}const c=j(i.get(u));if(c.length===0)continue;const p=j(f);(c.length!==p.length||c.some((N,F)=>N!==p[F]))&&n.push({locale:a,problem:`placeholder mismatch at ${u}: ${a} has ${JSON.stringify(p)}, ${t} has ${JSON.stringify(c)}`})}}return{locales:s,keys:l.size,problems:n}}d(E,"validateLocales");function _(e,t,r){const n=[],o=d(i=>{for(const l of w(i,{withFileTypes:!0})){const s=g.join(i,l.name);if(l.isDirectory()){if(l.name==="node_modules"||l.name==="dist"||l.name==="coverage")continue;o(s);continue}if(e.extensions.every(h=>!l.name.endsWith(h)))continue;const a=A(s,"utf8"),m=/\bt\(\s*(['"])((?:[^'"\\]|\\.)*)\1\s*(,)?/g;for(const h of a.matchAll(m)){const u=h[2];if(u.includes("${")||u.includes("{{"))continue;const f=g.relative(process.cwd(),s)||s;if(!t.has(u)){n.push({locale:"call-site",problem:`${f}: t('${u}') is not in the bundle \u2014 it renders as the inline default and is untranslatable`});continue}if(!h[3])continue;const c=K(a,h.index+h[0].length);if(c===null)continue;const p=r.get(u);c!==p&&n.push({locale:"call-site",problem:`${f}: t('${u}', \u2026) default disagrees with the bundle \u2014 bundle=${JSON.stringify(p)} default=${JSON.stringify(c)}`})}}},"walk");return o(e.dir),n}d(_,"collectCallSites");function K(e,t){const r=e.slice(t).replace(/^\s+/,""),n=r[0];if(n!=="'"&&n!=='"')return null;const o=r.slice(1),l=(n==="'"?/^(?:[^'\\]|\\.)*'/:/^(?:[^"\\]|\\.)*"/).exec(o);return l?z(o.slice(0,l[0].length-1)):null}d(K,"readDefault");function z(e){return e.replaceAll(/\\(.)/gs,(t,r)=>{switch(r){case"n":return`
|
|
5
|
+
`;case"t":return" ";case"r":return"\r";case"\\":case"'":case'"':case"`":return r;default:return t}})}d(z,"decodeStringLiteral");function C(e=process.argv.slice(2)){const t=e.find(s=>!s.startsWith("--"))??"apps/web/src/locales",r=e.find(s=>s.startsWith("--shape="))?.slice(8)??"auto",n=e.find(s=>s.startsWith("--base="))?.slice(7)??"en",o=e.find(s=>s.startsWith("--call-sites="))?.slice(13),i=E(t,n,r),l=[...i.problems];if(o!==void 0&&$(o))try{const s=B(t,n,r);l.push(..._({dir:o,extensions:[".ts",".tsx"]},new Set(s.keys()),s))}catch(s){l.push({locale:"call-site",problem:`${o}: ${s instanceof Error?s.message:String(s)}`})}if(l.length>0){console.error(`Locale validation failed for ${t} (${l.length} problem(s)):`);for(const s of l)console.error(` - ${s.locale}: ${s.problem}`);return 1}return console.log(`Locale validation passed (${i.locales.length} locales, ${i.keys} keys each, shape ${r}).`),0}d(C,"validateLocalesCli");process.argv[1]!==void 0&&import.meta.url===W(process.argv[1]).href&&process.exit(C(process.argv.slice(2)));export{x as parseObjectLiteral,E as validateLocales,C as validateLocalesCli};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/scripts/validate-locales.ts"],
|
|
4
|
-
"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 path from 'node:path';\n\n/**\nThe bundle layouts the checker understands.\n*/\ntype LocaleShape = 'auto' | 'dir' | 'file' | 'module';\n\n/**\nOne defect, kept as a locale plus a message so a caller can group them.\n*/\ninterface LocaleProblem {\n locale: string;\n problem: string;\n}\n\n/**\nThe outcome of one run.\n*/\ninterface LocaleReport {\n locales: string[];\n keys: number;\n problems: LocaleProblem[];\n}\n\n/**\nEvery dotted key path in a bundle, depth first.\n*/\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(file: string): unknown {\n const source = readFileSync(file, '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 file.endsWith('.ts') ? parseObjectLiteral(source, file) : (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];\n\n if (inLineComment) {\n if (char === '\\n') inLineComment = false;\n continue;\n }\n const next = source[index + 1];\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, file: string): unknown {\n const start = objectLiteralStart(source);\n if (start === -1) {\n throw new Error(`${file} 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];\n\n if (inLineComment) {\n if (char === '\\n') inLineComment = false;\n continue;\n }\n const next = source[index + 1];\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(`${file} 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-Z_$][\\w$]*)(\\s*:)/gi, '$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(`${file} object literal could not be parsed: ${error instanceof Error ? error.message : String(error)}`);\n }\n}\n\n/**\nThe escapes a translator file actually uses; anything else is passed through.\n*/\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/**\nThe extensions a flat layout uses, keyed by shape.\n*/\nconst FLAT_EXTENSION: Record<'file' | 'module', string> = { file: 'json', module: 'ts' };\n\n/**\nThe layouts `shape` covers. `auto` covers all three, in the order they are tried.\n*/\nfunction layouts(shape: LocaleShape): Array<'dir' | 'file' | 'module'> {\n return shape === 'auto' ? ['dir', 'file', 'module'] : [shape];\n}\n\n/**\nThe tags on disk, in whichever layouts `shape` covers.\n*/\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(path.join(localesDir, locale, 'translation.json'));\n }\n for (const layout of layouts(shape)) {\n if (layout === 'dir') continue;\n candidates.push(path.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((a, b) => a.localeCompare(b));\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/**\nCLI entry: `validateLocalesCli(['[locales-dir]?', '--shape=auto|dir|file|module'?, '--base=<tag>'?])`.\n*/\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"],
|
|
5
|
-
"mappings": "+EAqCA,OAAS,cAAAA,EAAY,eAAAC,EAAa,gBAAAC,MAAoB,UACtD,OAAS,iBAAAC,MAAqB,WAC9B,OAAOC,MAAU,YA2BjB,SAASC,EAAQC,EAAgBC,EAAS,
|
|
6
|
-
"names": ["existsSync", "readdirSync", "readFileSync", "pathToFileURL", "path", "flatten", "value", "prefix", "entries", "key", "child", "__name", "readBundle", "file", "source", "parseObjectLiteral", "objectLiteralStart", "quote", "inLineComment", "inBlockComment", "index", "char", "next", "previous", "brace", "start", "depth", "end", "withoutTrailingCommas", "_match", "body", "unescapeLiteral", "error", "FLAT_EXTENSION", "layouts", "shape", "tagsOnDisk", "localesDir", "tags", "entry", "layout", "extension", "name", "bundleFor", "locale", "candidates", "candidate", "
|
|
4
|
+
"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 path from 'node:path';\n\n/**\nThe bundle layouts the checker understands.\n*/\ntype LocaleShape = 'auto' | 'dir' | 'file' | 'module';\n\n/**\nOne defect, kept as a locale plus a message so a caller can group them.\n*/\ninterface LocaleProblem {\n locale: string;\n problem: string;\n}\n\n/**\nThe outcome of one run.\n*/\ninterface LocaleReport {\n locales: string[];\n keys: number;\n problems: LocaleProblem[];\n}\n\n/**\nEvery dotted key path in a bundle, depth first.\n*/\nfunction flatten(value: unknown, prefix = '', out: Map<string, unknown> = new Map()): Map<string, unknown> {\n if (value === null || typeof value !== 'object' || Array.isArray(value)) {\n if (prefix) out.set(prefix, value);\n return out;\n }\n const entries = Object.entries(value as Record<string, unknown>);\n if (entries.length === 0) {\n if (prefix) out.set(prefix, value);\n return out;\n }\n for (const [key, child] of entries) {\n flatten(child, prefix ? `${prefix}.${key}` : key, out);\n }\n return out;\n}\n\n/**\n * The interpolation tokens in a value, sorted.\n *\n * Sorted so two values carrying the same tokens in different orders compare equal —\n * substitution is by name, so order carries no meaning. `localeCompare` rather than\n * the default comparator so a reported mismatch does not change with the machine's\n * locale.\n */\nfunction placeholdersOf(value: unknown): string[] {\n if (typeof value !== 'string') return [];\n return [...new Set(value.match(/\\{\\{[^{}]+\\}\\}/g))].sort((left: string, right: string) => left.localeCompare(right));\n}\n\n/**\n * A source file to check `t()` call sites under, and how far down to look.\n */\ninterface CallSiteScope {\n /**\n Directory walked for source files.\n */\n dir: string;\n /**\n Extensions treated as source.\n */\n extensions: readonly string[];\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(file: string): unknown {\n const source = readFileSync(file, '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 file.endsWith('.ts') ? parseObjectLiteral(source, file) : (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];\n\n if (inLineComment) {\n if (char === '\\n') inLineComment = false;\n continue;\n }\n const next = source[index + 1];\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, file: string): unknown {\n const start = objectLiteralStart(source);\n if (start === -1) {\n throw new Error(`${file} 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];\n\n if (inLineComment) {\n if (char === '\\n') inLineComment = false;\n continue;\n }\n const next = source[index + 1];\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(`${file} 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-Z_$][\\w$]*)(\\s*:)/gi, '$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(`${file} object literal could not be parsed: ${error instanceof Error ? error.message : String(error)}`);\n }\n}\n\n/**\nThe escapes a translator file actually uses; anything else is passed through.\n*/\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/**\nThe extensions a flat layout uses, keyed by shape.\n*/\nconst FLAT_EXTENSION: Record<'file' | 'module', string> = { file: 'json', module: 'ts' };\n\n/**\nThe layouts `shape` covers. `auto` covers all three, in the order they are tried.\n*/\nfunction layouts(shape: LocaleShape): Array<'dir' | 'file' | 'module'> {\n return shape === 'auto' ? ['dir', 'file', 'module'] : [shape];\n}\n\n/**\nThe tags on disk, in whichever layouts `shape` covers.\n*/\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(path.join(localesDir, locale, 'translation.json'));\n }\n for (const layout of layouts(shape)) {\n if (layout === 'dir') continue;\n candidates.push(path.join(localesDir, `${locale}.${FLAT_EXTENSION[layout]}`));\n }\n return candidates.find((candidate) => existsSync(candidate));\n}\n\n/**\n * The base bundle, flattened, for a scope that checks the application against it.\n *\n * @throws when the bundle cannot be found or parsed — the caller reports that as a\n * problem rather than reporting \"all clear\" against an empty key set, which is\n * the one outcome a locale gate must never produce silently.\n */\nfunction bundleAt(localesDir: string, baseLocale: string, shape: LocaleShape): Map<string, unknown> {\n const file = bundleFor(localesDir, baseLocale, shape);\n if (file === undefined) {\n throw new Error(`no bundle found for the base locale (expected ${baseLocale}/translation.json)`);\n }\n return flatten(readBundle(file));\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 baseBundle: Map<string, unknown>;\n try {\n baseBundle = 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 const baseKeys = new Set(baseBundle.keys());\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((a, b) => a.localeCompare(b));\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 bundle: Map<string, unknown>;\n try {\n bundle = 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 (!bundle.has(key)) problems.push({ locale, problem: `missing key: ${key}` });\n }\n for (const [key, value] of bundle) {\n if (!baseKeys.has(key)) {\n problems.push({ locale, problem: `extra key not in ${baseLocale}: ${key}` });\n continue;\n }\n // An empty value is reported for the base too. i18next renders `''` for a key\n // whose value is empty and for a key that is absent, so the two are the same\n // blank screen — which is why a \"translated\" locale can look complete in a\n // diff and be missing on the page.\n if (typeof value !== 'string' || value === '') {\n problems.push({ locale, problem: `empty value: ${key} — indistinguishable from a missing key at runtime` });\n continue;\n }\n // Placeholder parity. Substitution is by name, so a translation that drops\n // `{{count}}` renders the sentence with a hole in it and no error anywhere.\n const expected = placeholdersOf(baseBundle.get(key));\n if (expected.length === 0) continue;\n const actual = placeholdersOf(value);\n if (expected.length !== actual.length || expected.some((token, index) => token !== actual[index])) {\n problems.push({\n locale,\n problem: `placeholder mismatch at ${key}: ${locale} has ${JSON.stringify(actual)}, ${baseLocale} has ${JSON.stringify(expected)}`,\n });\n }\n }\n }\n\n return { locales, keys: baseKeys.size, problems };\n}\n\n/**\n * Every `t('key')` call site under a scope, with its inline default if it has one.\n *\n * This is the only part of the check that reaches the application rather than the\n * bundles: the rest compare bundle to bundle, so with one shipped language the whole\n * per-tag body is skipped and the script reports `ALL OK` having checked nothing\n * about the product — it cannot see that a key was used and absent, because the\n * string in the bundle did not exist to be wrong *about* anything.\n *\n * Dynamic keys cannot be resolved statically and are skipped rather than guessed:\n * a computed key that happens to start with a literal is a finding nobody can act\n * on, and one finding nobody can act on trains people to ignore the report.\n */\nfunction collectCallSites(scope: CallSiteScope, baseKeys: Set<string>, baseBundle: Map<string, unknown>): LocaleProblem[] {\n const problems: LocaleProblem[] = [];\n const walk = (dir: string): void => {\n for (const entry of readdirSync(dir, { withFileTypes: true })) {\n const full = path.join(dir, entry.name);\n if (entry.isDirectory()) {\n if (entry.name === 'node_modules' || entry.name === 'dist' || entry.name === 'coverage') continue;\n walk(full);\n continue;\n }\n if (scope.extensions.every((extension) => !entry.name.endsWith(extension))) continue;\n const source = readFileSync(full, 'utf8');\n // `t('…')` / `t(\"…\")` with a string literal first argument. The key is the\n // single source of truth for what is rendered, so anything else is out of scope.\n const pattern = /\\bt\\(\\s*(['\"])((?:[^'\"\\\\]|\\\\.)*)\\1\\s*(,)?/g;\n for (const match of source.matchAll(pattern)) {\n const key = match[2];\n if (key.includes('${') || key.includes('{{')) continue;\n const where = path.relative(process.cwd(), full) || full;\n if (!baseKeys.has(key)) {\n problems.push({\n locale: 'call-site',\n problem: `${where}: t('${key}') is not in the bundle — it renders as the inline default and is untranslatable`,\n });\n continue;\n }\n // A default that disagrees with the shipped bundle **fails**: one of the two\n // is a bug, and the default is the one that renders verbatim the day the key\n // goes missing — which is the fallback path the whole check is about.\n if (!match[3]) continue;\n const inline = readDefault(source, match.index + match[0].length);\n if (inline === null) continue;\n const bundled = baseBundle.get(key);\n if (inline !== bundled) {\n problems.push({\n locale: 'call-site',\n problem: `${where}: t('${key}', …) default disagrees with the bundle — bundle=${JSON.stringify(bundled)} default=${JSON.stringify(inline)}`,\n });\n }\n }\n }\n };\n walk(scope.dir);\n return problems;\n}\n\n/**\n * The first string literal at `from`, or `null` when the next token is not one.\n *\n * The terminator is the literal's **own** quote character and never the other one.\n * A default that contains an apostrophe is the ordinary case here — these bundles\n * say things like `D1's daily write allowance` — so a scan that accepts either\n * quote stops at the apostrophe and reports `D1` as the whole default, turning a\n * correct file into a \"default disagrees\" failure on every line that quotes an\n * English possessive.\n */\nfunction readDefault(source: string, from: number): string | null {\n const rest = source.slice(from).replace(/^\\s+/, '');\n const quote = rest[0];\n if (quote !== \"'\" && quote !== '\"') return null;\n const body = rest.slice(1);\n const closer = quote === \"'\" ? /^(?:[^'\\\\]|\\\\.)*'/ : /^(?:[^\"\\\\]|\\\\.)*\"/;\n const match = closer.exec(body);\n if (!match) return null;\n return decodeStringLiteral(body.slice(0, match[0].length - 1));\n}\n\n/**\n * Decode a JS string literal as written in source, escapes and all.\n *\n * Only the escapes these bundles use are handled. An unrecognised one is passed\n * through as the backslash plus the character rather than throwing: a validator\n * that crashes on an unfamiliar escape reports nothing at all, which is worse than\n * reporting a value it had to guess at.\n */\nfunction decodeStringLiteral(raw: string): string {\n return raw.replaceAll(/\\\\(.)/gs, (whole, char: string) => {\n switch (char) {\n case 'n': {\n return '\\n';\n }\n case 't': {\n return '\\t';\n }\n case 'r': {\n return '\\r';\n }\n case '\\\\':\n case \"'\":\n case '\"':\n case '`': {\n return char;\n }\n default: {\n return whole;\n }\n }\n });\n}\n\n/**\nCLI entry: `validateLocalesCli(['[locales-dir]?', '--shape=auto|dir|file|module'?, '--base=<tag>'?, '--call-sites=<src-dir>'?])`.\n\n`--call-sites=<dir>` opts into the application-side checks: every `t('key')` under\n`<dir>` must resolve against the base bundle, and any inline default must equal the\nbundled value. Without the flag the script stays bundle-to-bundle, because that is\nthe only part it can answer for a repo whose bundles are consumed by something\nother than `t()` — a backend string table, for instance.\n*/\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 const callSiteDir = argv.find((arg) => arg.startsWith('--call-sites='))?.slice('--call-sites='.length);\n\n const report = validateLocales(dir, base, shape);\n const problems = [...report.problems];\n\n if (callSiteDir !== undefined && existsSync(callSiteDir)) {\n try {\n const baseBundle = bundleAt(dir, base, shape);\n problems.push(...collectCallSites({ dir: callSiteDir, extensions: ['.ts', '.tsx'] }, new Set(baseBundle.keys()), baseBundle));\n } catch (error: unknown) {\n problems.push({ locale: 'call-site', problem: `${callSiteDir}: ${error instanceof Error ? error.message : String(error)}` });\n }\n }\n\n if (problems.length > 0) {\n console.error(`Locale validation failed for ${dir} (${problems.length} problem(s)):`);\n for (const problem of 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"],
|
|
5
|
+
"mappings": "+EAqCA,OAAS,cAAAA,EAAY,eAAAC,EAAa,gBAAAC,MAAo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AiB,CAAE,IAAKoB,EAAa,WAAY,CAAC,MAAO,MAAM,CAAC,EAAI,IAAI,IAAI5B,EAAW,KAAI,CAAE,EAAGA,CAAU,CAAC,CAC9H,OAASpB,EAAgB,CACvBkB,EAAS,KAAK,CAAE,OAAQ,YAAa,QAAS,GAAG8B,CAAW,KAAKhD,aAAiB,MAAQA,EAAM,QAAU,OAAOA,CAAK,CAAC,EAAE,CAAE,CAC7H,CAGF,GAAIkB,EAAS,OAAS,EAAG,CACvB,QAAQ,MAAM,gCAAgCa,CAAG,KAAKb,EAAS,MAAM,eAAe,EACpF,UAAWgC,KAAWhC,EAAU,QAAQ,MAAM,OAAOgC,EAAQ,MAAM,KAAKA,EAAQ,OAAO,EAAE,EACzF,MAAO,EACT,CACA,eAAQ,IAAI,6BAA6BD,EAAO,QAAQ,MAAM,aAAaA,EAAO,IAAI,qBAAqB9C,CAAK,IAAI,EAC7G,CACT,CAzBS3B,EAAAoE,EAAA,sBAqCL,QAAQ,KAAK,CAAC,IAAM,QAAa,YAAY,MAAQ7E,EAAc,QAAQ,KAAK,CAAC,CAAC,EAAE,MACtF,QAAQ,KAAK6E,EAAmB,QAAQ,KAAK,MAAM,CAAC,CAAC,CAAC",
|
|
6
|
+
"names": ["existsSync", "readdirSync", "readFileSync", "pathToFileURL", "path", "flatten", "value", "prefix", "out", "entries", "key", "child", "__name", "placeholdersOf", "left", "right", "readBundle", "file", "source", "parseObjectLiteral", "objectLiteralStart", "quote", "inLineComment", "inBlockComment", "index", "char", "next", "previous", "brace", "start", "depth", "end", "withoutTrailingCommas", "_match", "body", "unescapeLiteral", "error", "FLAT_EXTENSION", "layouts", "shape", "tagsOnDisk", "localesDir", "tags", "entry", "layout", "extension", "name", "bundleFor", "locale", "candidates", "candidate", "bundleAt", "baseLocale", "validateLocales", "problems", "baseFile", "baseBundle", "baseKeys", "locales", "b", "bundle", "expected", "actual", "token", "collectCallSites", "scope", "walk", "dir", "full", "pattern", "match", "where", "inline", "readDefault", "bundled", "from", "rest", "decodeStringLiteral", "raw", "whole", "validateLocalesCli", "argv", "arg", "base", "callSiteDir", "report", "problem"]
|
|
7
7
|
}
|
package/dist/vitest-aliases.d.ts
CHANGED
|
@@ -48,6 +48,22 @@ export declare const DEFAULT_CLOUDFLARE_MOCKS: readonly string[];
|
|
|
48
48
|
* `@rexezuge/d1`'s `dist/index.js`.
|
|
49
49
|
*/
|
|
50
50
|
export declare const KIT_NO_EXTERNAL: readonly RegExp[];
|
|
51
|
+
/**
|
|
52
|
+
* Bare specifiers the kit and its consumer must resolve to **one** copy.
|
|
53
|
+
*
|
|
54
|
+
* Every entry is a peer of a kit package rather than a dependency, which is
|
|
55
|
+
* exactly why it is needed: a peer is not installed twice under a registry
|
|
56
|
+
* install, so the two sides already agree. A `link:` install breaks that
|
|
57
|
+
* agreement — the symlinked package directory carries its own `node_modules`, and
|
|
58
|
+
* with `@rexezuge/*` inlined into Vite's pipeline (see {@link KIT_NO_EXTERNAL})
|
|
59
|
+
* the kit's copy wins for its own imports while the consumer's wins for the app's.
|
|
60
|
+
*
|
|
61
|
+
* Two Reacts is not a warning: `useState` is read off a module-level hook
|
|
62
|
+
* dispatcher that only one of them initialises, so every hook inside a kit
|
|
63
|
+
* component throws `Cannot read properties of null (reading 'useState')`. The
|
|
64
|
+
* failure names the kit, and the cause is the install layout.
|
|
65
|
+
*/
|
|
66
|
+
export declare const KIT_DEDUPE: readonly string[];
|
|
51
67
|
/**
|
|
52
68
|
* What `workspaceAliases` accepts.
|
|
53
69
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vitest-aliases.d.ts","sourceRoot":"","sources":["../src/vitest-aliases.ts"],"names":[],"mappings":"AAEA;;;;;;;GAOG;AACH,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC;IAC/B,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;CAC9B;AAED;;;;;;;;;;;;;;;GAeG;AACH,e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gE,CAAC;AAEzG;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACtC;;;OAGG;IACH,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB;;;;OAIG;IACH,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB;;;OAGG;IACH,QAAQ,CAAC,QAAQ,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACtC;;OAEG;IACH,QAAQ,CAAC,KAAK,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACnC;;OAEG;IACH,QAAQ,CAAC,YAAY,CAAC,EAAE,SAAS,WAAW,EAAE,CAAC;CAChD;AAED;;;;;;;;GAQG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,uBAAuB,GAAG,WAAW,EAAE,CAiBhF"}
|
package/dist/vitest-aliases.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var l=Object.defineProperty;var
|
|
1
|
+
var l=Object.defineProperty;var t=(c,o)=>l(c,"name",{value:o,configurable:!0});import{fileURLToPath as f}from"node:url";const m=["shared","backend-errors","backend-runtime","backend-data","provider-clients","webdav","dav-store","git-protocol","git-service","backend-services","background"],u=["workers","sockets","workflows"],A=[/(^|[/\\])@rexezuge\//],E=["react","react-dom","react/jsx-runtime","lucide-react"];function w(c){const{scope:o,root:a}=c,n=c.packages??m,p=c.mocks??u,r=t(e=>f(new URL(e,a)),"at"),s=[];for(const e of n){const k=e==="background"?"apps/background/src":`packages/${e}/src`;s.push({find:`${o}/${e}`,replacement:r(k)})}for(const e of p)s.push({find:`cloudflare:${e}`,replacement:r(`test/mocks/cloudflare-${e}.ts`)});const d=r("apps/api/src"),i=r("apps/web/src");return s.push({find:/^@\//,replacement:`${d}/`},{find:/^~\//,replacement:`${i}/`},...c.extraAliases??[]),s}t(w,"workspaceAliases");export{u as DEFAULT_CLOUDFLARE_MOCKS,m as DEFAULT_WORKSPACE_PACKAGES,E as KIT_DEDUPE,A as KIT_NO_EXTERNAL,w as workspaceAliases};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/vitest-aliases.ts"],
|
|
4
|
-
"sourcesContent": ["import { fileURLToPath } from 'node:url';\n\n/**\n * One `{ find, replacement }` pair for Vitest's resolver.\n *\n * A `string` find is a prefix match in Vite; a `RegExp` find is tested against\n * the specifier. Workspace scopes use plain strings (`'@scope/name'` matches\n * `'@scope/name'` and `'@scope/name/sub'` alike); `@/` and `~/` use regexps so\n * the trailing slash is part of the match.\n */\nexport interface VitestAlias {\n readonly find: string | RegExp;\n readonly replacement: string;\n}\n\n/**\n * Every workspace package the family has converged on, as directory names under\n * `packages/`.\n *\n * The union across all nine repos: the universal core (`shared`,\n * `backend-errors`, `backend-runtime`, `backend-data`, `backend-services`) plus\n * the domain packages (`provider-clients`, `webdav`, `dav-store`,\n * `git-protocol`, `git-service`). `media-tags`/`subsonic` (Edge-Sonic) are\n * unconstrained utility leaves with no boundary block and no alias in their\n * source repo, so they are not listed — a repo that needs them passes\n * `packages` explicitly or appends `aliases`.\n *\n * A superset is safe: an alias for a package the consumer does not have never\n * matches a specifier, and Vite only resolves the replacement when something\n * imports it.\n */\nexport const DEFAULT_WORKSPACE_PACKAGES: readonly string[] = [\n 'shared',\n 'backend-errors',\n 'backend-runtime',\n 'backend-data',\n 'provider-clients',\n 'webdav',\n 'dav-store',\n 'git-protocol',\n 'git-service',\n 'backend-services',\n 'background',\n];\n\n/**\n * The Cloudflare runtime mocks the unit suite aliases.\n *\n * `workers` exists in every repo; `sockets` in five; `workflows` in four. All\n * three are listed by default: an alias whose mock file is absent never fires\n * unless a test imports the specifier, and then the missing file is the correct\n * error rather than Node's `ERR_UNKNOWN_SCHEME` for `cloudflare:*`.\n */\nexport const DEFAULT_CLOUDFLARE_MOCKS: readonly string[] = ['workers', 'sockets', 'workflows'];\n\n/**\n * Keep the kit's own `dist/` inside Vite's pipeline.\n *\n * The kit ships ESM `dist/` with bundler-style extensionless relative imports\n * (its tsconfig is `moduleResolution: Bundler`), which Node's ESM resolver\n * refuses. Vitest externalizes `node_modules` deps by default and would import\n * that dist with Node; `noExternal` routes `@rexezuge/*` back through Vite —\n * the same resolver that bundles the worker — so a test loads the very dist\n * the worker ships. Without this, the run dies on `./BaseDAO` inside\n * `@rexezuge/d1`'s `dist/index.js`.\n */\nexport const KIT_NO_EXTERNAL: readonly RegExp[] = [/(^|[/\\\\])@rexezuge\\//];\n\n/**\n * What `workspaceAliases` accepts.\n */\nexport interface WorkspaceAliasesOptions {\n /**\n * The consuming repo's npm scope, e.g. `'@myapp'`. Every `@scope/*` alias is\n * derived from it, so the same factory serves all nine repos.\n */\n readonly scope: string;\n /**\n * The repo root, as a file URL. Pass `new URL('.', import.meta.url).href`\n * from the calling config — never `import.meta.url` of this module, which\n * points inside `node_modules/@rexezuge/tooling`.\n */\n readonly root: string;\n /**\n * Workspace package directory names under `packages/` plus `background`\n * (which lives under `apps/`). Defaults to {@link DEFAULT_WORKSPACE_PACKAGES}.\n */\n readonly packages?: readonly string[];\n /**\n * Which `cloudflare:*` mocks to alias. Defaults to {@link DEFAULT_CLOUDFLARE_MOCKS}.\n */\n readonly mocks?: readonly string[];\n /**\n * Extra resolver entries, applied after the canonical ones.\n */\n readonly extraAliases?: readonly VitestAlias[];\n}\n\n/**\n * Build the workspace alias table for a consumer repo.\n *\n * Aliases point at source rather than at built output, so a test exercises the\n * code the worker would run without a build step. `background` resolves under\n * `apps/`; every other package under `packages/`. `@/` maps to the API worker\n * source and `~/` to the SPA source, matching the two `tsconfig` path prefixes\n * every repo shares.\n */\nexport function workspaceAliases(options: WorkspaceAliasesOptions): VitestAlias[] {\n const { scope, root } = options;\n const packages = options.packages ?? DEFAULT_WORKSPACE_PACKAGES;\n const mocks = options.mocks ?? DEFAULT_CLOUDFLARE_MOCKS;\n const at = (relative: string): string => fileURLToPath(new URL(relative, root));\n const aliases: VitestAlias[] = [];\n for (const name of packages) {\n const dir = name === 'background' ? 'apps/background/src' : `packages/${name}/src`;\n aliases.push({ find: `${scope}/${name}`, replacement: at(dir) });\n }\n for (const mock of mocks) {\n aliases.push({ find: `cloudflare:${mock}`, replacement: at(`test/mocks/cloudflare-${mock}.ts`) });\n }\n const apiSrc = at('apps/api/src');\n const webSrc = at('apps/web/src');\n aliases.push({ find: /^@\\//, replacement: `${apiSrc}/` }, { find: /^~\\//, replacement: `${webSrc}/` }, ...(options.extraAliases ?? []));\n return aliases;\n}\n"],
|
|
5
|
-
"mappings": "+EAAA,OAAS,iBAAAA,MAAqB,WA+BvB,MAAMC,EAAgD,CAC3D,SACA,iBACA,kBACA,eACA,mBACA,SACA,YACA,eACA,cACA,mBACA,cAWWC,EAA8C,CAAC,UAAW,UAAW,WAAW,EAahFC,EAAqC,CAAC,sBAAsB,
|
|
6
|
-
"names": ["fileURLToPath", "DEFAULT_WORKSPACE_PACKAGES", "DEFAULT_CLOUDFLARE_MOCKS", "KIT_NO_EXTERNAL", "workspaceAliases", "options", "scope", "root", "packages", "mocks", "at", "__name", "relative", "aliases", "name", "dir", "mock", "apiSrc", "webSrc"]
|
|
4
|
+
"sourcesContent": ["import { fileURLToPath } from 'node:url';\n\n/**\n * One `{ find, replacement }` pair for Vitest's resolver.\n *\n * A `string` find is a prefix match in Vite; a `RegExp` find is tested against\n * the specifier. Workspace scopes use plain strings (`'@scope/name'` matches\n * `'@scope/name'` and `'@scope/name/sub'` alike); `@/` and `~/` use regexps so\n * the trailing slash is part of the match.\n */\nexport interface VitestAlias {\n readonly find: string | RegExp;\n readonly replacement: string;\n}\n\n/**\n * Every workspace package the family has converged on, as directory names under\n * `packages/`.\n *\n * The union across all nine repos: the universal core (`shared`,\n * `backend-errors`, `backend-runtime`, `backend-data`, `backend-services`) plus\n * the domain packages (`provider-clients`, `webdav`, `dav-store`,\n * `git-protocol`, `git-service`). `media-tags`/`subsonic` (Edge-Sonic) are\n * unconstrained utility leaves with no boundary block and no alias in their\n * source repo, so they are not listed — a repo that needs them passes\n * `packages` explicitly or appends `aliases`.\n *\n * A superset is safe: an alias for a package the consumer does not have never\n * matches a specifier, and Vite only resolves the replacement when something\n * imports it.\n */\nexport const DEFAULT_WORKSPACE_PACKAGES: readonly string[] = [\n 'shared',\n 'backend-errors',\n 'backend-runtime',\n 'backend-data',\n 'provider-clients',\n 'webdav',\n 'dav-store',\n 'git-protocol',\n 'git-service',\n 'backend-services',\n 'background',\n];\n\n/**\n * The Cloudflare runtime mocks the unit suite aliases.\n *\n * `workers` exists in every repo; `sockets` in five; `workflows` in four. All\n * three are listed by default: an alias whose mock file is absent never fires\n * unless a test imports the specifier, and then the missing file is the correct\n * error rather than Node's `ERR_UNKNOWN_SCHEME` for `cloudflare:*`.\n */\nexport const DEFAULT_CLOUDFLARE_MOCKS: readonly string[] = ['workers', 'sockets', 'workflows'];\n\n/**\n * Keep the kit's own `dist/` inside Vite's pipeline.\n *\n * The kit ships ESM `dist/` with bundler-style extensionless relative imports\n * (its tsconfig is `moduleResolution: Bundler`), which Node's ESM resolver\n * refuses. Vitest externalizes `node_modules` deps by default and would import\n * that dist with Node; `noExternal` routes `@rexezuge/*` back through Vite —\n * the same resolver that bundles the worker — so a test loads the very dist\n * the worker ships. Without this, the run dies on `./BaseDAO` inside\n * `@rexezuge/d1`'s `dist/index.js`.\n */\nexport const KIT_NO_EXTERNAL: readonly RegExp[] = [/(^|[/\\\\])@rexezuge\\//];\n\n/**\n * Bare specifiers the kit and its consumer must resolve to **one** copy.\n *\n * Every entry is a peer of a kit package rather than a dependency, which is\n * exactly why it is needed: a peer is not installed twice under a registry\n * install, so the two sides already agree. A `link:` install breaks that\n * agreement — the symlinked package directory carries its own `node_modules`, and\n * with `@rexezuge/*` inlined into Vite's pipeline (see {@link KIT_NO_EXTERNAL})\n * the kit's copy wins for its own imports while the consumer's wins for the app's.\n *\n * Two Reacts is not a warning: `useState` is read off a module-level hook\n * dispatcher that only one of them initialises, so every hook inside a kit\n * component throws `Cannot read properties of null (reading 'useState')`. The\n * failure names the kit, and the cause is the install layout.\n */\nexport const KIT_DEDUPE: readonly string[] = ['react', 'react-dom', 'react/jsx-runtime', 'lucide-react'];\n\n/**\n * What `workspaceAliases` accepts.\n */\nexport interface WorkspaceAliasesOptions {\n /**\n * The consuming repo's npm scope, e.g. `'@myapp'`. Every `@scope/*` alias is\n * derived from it, so the same factory serves all nine repos.\n */\n readonly scope: string;\n /**\n * The repo root, as a file URL. Pass `new URL('.', import.meta.url).href`\n * from the calling config — never `import.meta.url` of this module, which\n * points inside `node_modules/@rexezuge/tooling`.\n */\n readonly root: string;\n /**\n * Workspace package directory names under `packages/` plus `background`\n * (which lives under `apps/`). Defaults to {@link DEFAULT_WORKSPACE_PACKAGES}.\n */\n readonly packages?: readonly string[];\n /**\n * Which `cloudflare:*` mocks to alias. Defaults to {@link DEFAULT_CLOUDFLARE_MOCKS}.\n */\n readonly mocks?: readonly string[];\n /**\n * Extra resolver entries, applied after the canonical ones.\n */\n readonly extraAliases?: readonly VitestAlias[];\n}\n\n/**\n * Build the workspace alias table for a consumer repo.\n *\n * Aliases point at source rather than at built output, so a test exercises the\n * code the worker would run without a build step. `background` resolves under\n * `apps/`; every other package under `packages/`. `@/` maps to the API worker\n * source and `~/` to the SPA source, matching the two `tsconfig` path prefixes\n * every repo shares.\n */\nexport function workspaceAliases(options: WorkspaceAliasesOptions): VitestAlias[] {\n const { scope, root } = options;\n const packages = options.packages ?? DEFAULT_WORKSPACE_PACKAGES;\n const mocks = options.mocks ?? DEFAULT_CLOUDFLARE_MOCKS;\n const at = (relative: string): string => fileURLToPath(new URL(relative, root));\n const aliases: VitestAlias[] = [];\n for (const name of packages) {\n const dir = name === 'background' ? 'apps/background/src' : `packages/${name}/src`;\n aliases.push({ find: `${scope}/${name}`, replacement: at(dir) });\n }\n for (const mock of mocks) {\n aliases.push({ find: `cloudflare:${mock}`, replacement: at(`test/mocks/cloudflare-${mock}.ts`) });\n }\n const apiSrc = at('apps/api/src');\n const webSrc = at('apps/web/src');\n aliases.push({ find: /^@\\//, replacement: `${apiSrc}/` }, { find: /^~\\//, replacement: `${webSrc}/` }, ...(options.extraAliases ?? []));\n return aliases;\n}\n"],
|
|
5
|
+
"mappings": "+EAAA,OAAS,iBAAAA,MAAqB,WA+BvB,MAAMC,EAAgD,CAC3D,SACA,iBACA,kBACA,eACA,mBACA,SACA,YACA,eACA,cACA,mBACA,cAWWC,EAA8C,CAAC,UAAW,UAAW,WAAW,EAahFC,EAAqC,CAAC,sBAAsB,EAiB5DC,EAAgC,CAAC,QAAS,YAAa,oBAAqB,cAAc,EAyCjG,SAAUC,EAAiBC,EAAgC,CAC/D,KAAM,CAAE,MAAAC,EAAO,KAAAC,CAAI,EAAKF,EAClBG,EAAWH,EAAQ,UAAYL,EAC/BS,EAAQJ,EAAQ,OAASJ,EACzBS,EAAKC,EAACC,GAA6Bb,EAAc,IAAI,IAAIa,EAAUL,CAAI,CAAC,EAAnE,MACLM,EAAyB,CAAA,EAC/B,UAAWC,KAAQN,EAAU,CAC3B,MAAMO,EAAMD,IAAS,aAAe,sBAAwB,YAAYA,CAAI,OAC5ED,EAAQ,KAAK,CAAE,KAAM,GAAGP,CAAK,IAAIQ,CAAI,GAAI,YAAaJ,EAAGK,CAAG,CAAC,CAAE,CACjE,CACA,UAAWC,KAAQP,EACjBI,EAAQ,KAAK,CAAE,KAAM,cAAcG,CAAI,GAAI,YAAaN,EAAG,yBAAyBM,CAAI,KAAK,CAAC,CAAE,EAElG,MAAMC,EAASP,EAAG,cAAc,EAC1BQ,EAASR,EAAG,cAAc,EAChC,OAAAG,EAAQ,KAAK,CAAE,KAAM,OAAQ,YAAa,GAAGI,CAAM,GAAG,EAAI,CAAE,KAAM,OAAQ,YAAa,GAAGC,CAAM,GAAG,EAAI,GAAIb,EAAQ,cAAgB,CAAA,CAAG,EAC/HQ,CACT,CAjBgBF,EAAAP,EAAA",
|
|
6
|
+
"names": ["fileURLToPath", "DEFAULT_WORKSPACE_PACKAGES", "DEFAULT_CLOUDFLARE_MOCKS", "KIT_NO_EXTERNAL", "KIT_DEDUPE", "workspaceAliases", "options", "scope", "root", "packages", "mocks", "at", "__name", "relative", "aliases", "name", "dir", "mock", "apiSrc", "webSrc"]
|
|
7
7
|
}
|
package/dist/vitest.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vitest.d.ts","sourceRoot":"","sources":["../src/vitest.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AAEH,OAAO,EAAE,YAAY,EAAE,KAAK,MAAM,EAAE,MAAM,eAAe,CAAC;AAE1D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAEvD,YAAY,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAEvD;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;CACzB;AAED;;;;GAIG;AACH,MAAM,WAAW,uBAAuB;IACtC;;;;;OAKG;IACH,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IACxB;;;;OAIG;IACH,QAAQ,CAAC,QAAQ,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACtC;;OAEG;IACH,QAAQ,CAAC,KAAK,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACnC;;;OAGG;IACH,QAAQ,CAAC,OAAO,CAAC,EAAE,SAAS,WAAW,EAAE,CAAC;IAC1C;;;;;OAKG;IACH,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB;;OAEG;IACH,QAAQ,CAAC,OAAO,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACrC;;;OAGG;IACH,QAAQ,CAAC,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;CACpC;AAoCD;;;;;;;;;;;GAWG;AACH,wBAAgB,sBAAsB,CAAC,OAAO,GAAE,uBAA4B,GAAG,UAAU,CAAC,OAAO,YAAY,CAAC,CAgE7G"}
|
package/dist/vitest.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var l=Object.defineProperty;var r=(e,s)=>l(e,"name",{value:s,configurable:!0});import{defineConfig as a}from"vitest/config";import{DEFAULT_CLOUDFLARE_MOCKS as u,DEFAULT_WORKSPACE_PACKAGES as i,
|
|
1
|
+
var l=Object.defineProperty;var r=(e,s)=>l(e,"name",{value:s,configurable:!0});import{defineConfig as a}from"vitest/config";import{DEFAULT_CLOUDFLARE_MOCKS as u,DEFAULT_WORKSPACE_PACKAGES as i,KIT_DEDUPE as g,KIT_NO_EXTERNAL as o,workspaceAliases as E}from"./vitest-aliases.js";const f=["test/web/**","test/**/web-*.test.{ts,tsx}","apps/web/**/*.test.{ts,tsx}"],p=["scripts/**","**/*.test.ts","**/*.test.tsx","**/*.d.ts","**/index.ts","**/types.d.ts","**/model/**","**/generated/**","**/D1Types.ts","**/ServiceEnv.ts","**/env.d.ts"];function _(e={}){const s=e.root??new URL(".",import.meta.url).href,d=e.coverageInclude??["apps/api/src/**/*.ts","apps/background/src/**/*.ts","packages/**/src/**/*.ts"],c=[...p,...e.coverageExclude??[]],n=[...E({scope:e.scope??"@unused",root:s,packages:e.scope===void 0?[]:e.packages??i,mocks:e.mocks??u}).filter(t=>typeof t.find!="string"||!t.find.startsWith("@unused")),...e.aliases??[]];return a({...e.plugins!==void 0&&{plugins:[...e.plugins]},resolve:{alias:n,noExternal:[...o,...e.noExternal??[]],dedupe:[...g]},test:{globals:!0,environment:"node",include:[...e.include??["test/**/*.test.{ts,tsx}"]],exclude:[...e.exclude??["**/node_modules/**","**/dist/**","test/integration/**",...f]],...e.setupFiles!==void 0&&{setupFiles:[...e.setupFiles]},server:{deps:{inline:[...e.serverDepsInline??["dofs"]]}},coverage:{provider:"v8",reporter:["text","lcov","html"],reportsDirectory:e.reportsDirectory??"./coverage",include:[...d],exclude:c,...e.thresholds!==void 0&&{thresholds:{...e.thresholds}}}}})}r(_,"defineUnitVitestConfig");export{_ as defineUnitVitestConfig};
|