@rexezuge/tooling 1.12.0 → 1.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +149 -18
- package/dist/eslint-manifest.d.ts +25 -0
- package/dist/eslint-manifest.d.ts.map +1 -0
- package/dist/eslint-manifest.js +1 -0
- package/dist/eslint-manifest.js.map +7 -0
- package/dist/eslint-options.d.ts +54 -0
- package/dist/eslint-options.d.ts.map +1 -0
- package/dist/eslint-options.js +0 -0
- package/dist/eslint-options.js.map +7 -0
- package/dist/eslint-strict.d.ts +45 -0
- package/dist/eslint-strict.d.ts.map +1 -0
- package/dist/eslint-strict.js +1 -0
- package/dist/eslint-strict.js.map +7 -0
- package/dist/eslint.d.ts +2 -36
- package/dist/eslint.d.ts.map +1 -1
- package/dist/eslint.js +1 -1
- package/dist/eslint.js.map +3 -3
- package/dist/index.d.ts +5 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +3 -3
- package/dist/manifest-validate.d.ts +14 -0
- package/dist/manifest-validate.d.ts.map +1 -0
- package/dist/manifest-validate.js +1 -0
- package/dist/manifest-validate.js.map +7 -0
- package/dist/manifest.d.ts +159 -0
- package/dist/manifest.d.ts.map +1 -0
- package/dist/manifest.js +3 -0
- package/dist/manifest.js.map +7 -0
- package/dist/pages-proxy.d.ts +2 -0
- package/dist/pages-proxy.d.ts.map +1 -0
- package/dist/pages-proxy.js +1 -0
- package/dist/pages-proxy.js.map +7 -0
- package/dist/plugin-option.d.ts +15 -0
- package/dist/plugin-option.d.ts.map +1 -0
- package/dist/plugin-option.js +1 -0
- package/dist/plugin-option.js.map +7 -0
- package/dist/scripts/check-god-files.d.ts.map +1 -1
- package/dist/scripts/check-god-files.js +2 -2
- package/dist/scripts/check-god-files.js.map +3 -3
- package/dist/scripts/ensure-spa-shell-stub.d.ts +4 -2
- package/dist/scripts/ensure-spa-shell-stub.d.ts.map +1 -1
- package/dist/scripts/ensure-spa-shell-stub.js +1 -2
- package/dist/scripts/ensure-spa-shell-stub.js.map +3 -3
- package/dist/scripts/init-secrets.d.ts +1 -2
- package/dist/scripts/init-secrets.d.ts.map +1 -1
- package/dist/scripts/init-secrets.js +2 -3
- package/dist/scripts/init-secrets.js.map +3 -3
- package/dist/scripts/migrations-lock.d.ts +6 -2
- package/dist/scripts/migrations-lock.d.ts.map +1 -1
- package/dist/scripts/migrations-lock.js +1 -2
- package/dist/scripts/migrations-lock.js.map +3 -3
- package/dist/scripts/prepare-wrangler-config.d.ts +6 -2
- package/dist/scripts/prepare-wrangler-config.d.ts.map +1 -1
- package/dist/scripts/prepare-wrangler-config.js +1 -2
- package/dist/scripts/prepare-wrangler-config.js.map +3 -3
- package/dist/scripts/validate-locales.d.ts +20 -2
- package/dist/scripts/validate-locales.d.ts.map +1 -1
- package/dist/scripts/validate-locales.js +5 -5
- package/dist/scripts/validate-locales.js.map +3 -3
- package/dist/scripts/verify-spa-shell.d.ts +7 -2
- package/dist/scripts/verify-spa-shell.d.ts.map +1 -1
- package/dist/scripts/verify-spa-shell.js +1 -2
- package/dist/scripts/verify-spa-shell.js.map +3 -3
- package/dist/test/mocks/cloudflare-workers.d.ts +6 -103
- package/dist/test/mocks/cloudflare-workers.d.ts.map +1 -1
- package/dist/test/mocks/cloudflare-workers.js +1 -1
- package/dist/test/mocks/cloudflare-workers.js.map +3 -3
- package/dist/vite.d.ts +2 -1
- package/dist/vite.d.ts.map +1 -1
- package/dist/vite.js +3 -3
- package/dist/vite.js.map +3 -3
- package/dist/vitest-aliases.d.ts +3 -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-integration.d.ts +3 -2
- package/dist/vitest-integration.d.ts.map +1 -1
- package/dist/vitest-integration.js +1 -1
- package/dist/vitest-integration.js.map +3 -3
- package/dist/vitest-repo.d.ts +5 -3
- package/dist/vitest-repo.d.ts.map +1 -1
- package/dist/vitest-repo.js +1 -1
- package/dist/vitest-repo.js.map +3 -3
- package/dist/vitest-web.d.ts +3 -2
- package/dist/vitest-web.d.ts.map +1 -1
- package/dist/vitest-web.js +1 -1
- package/dist/vitest-web.js.map +3 -3
- package/dist/vitest.d.ts +5 -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 -3
- package/presets/prettier.d.mts +4 -0
- package/presets/prettier.mjs +16 -0
- package/presets/tsconfig/base.json +19 -0
- package/presets/tsconfig/web.json +10 -0
- package/presets/tsconfig/worker.json +9 -0
- package/schema/manifest.schema.json +105 -0
- package/src/eslint-manifest.ts +71 -0
- package/src/eslint-options.ts +54 -0
- package/src/eslint-strict.test.ts +106 -0
- package/src/eslint-strict.ts +191 -0
- package/src/eslint.ts +18 -41
- package/src/index.ts +15 -2
- package/src/manifest-validate.ts +202 -0
- package/src/manifest.test.ts +228 -0
- package/src/manifest.ts +194 -0
- package/src/pages-proxy.test.ts +8 -0
- package/src/pages-proxy.ts +13 -0
- package/src/plugin-option.test.ts +13 -0
- package/src/plugin-option.ts +18 -0
- package/src/presets.test.ts +63 -0
- package/src/scripts/check-god-files.ts +3 -0
- package/src/scripts/ensure-spa-shell-stub.ts +18 -10
- package/src/scripts/entrypoints.test.ts +55 -0
- package/src/scripts/init-secrets.ts +8 -6
- package/src/scripts/migrations-lock.ts +22 -17
- package/src/scripts/prepare-wrangler-config.ts +26 -14
- package/src/scripts/validate-locales.ts +39 -17
- package/src/scripts/verify-spa-shell.ts +21 -20
- package/src/test/mocks/cloudflare-workers.ts +6 -113
- package/src/vite.ts +6 -3
- package/src/vitest-aliases.test.ts +23 -0
- package/src/vitest-aliases.ts +22 -1
- package/src/vitest-factories.test.ts +30 -1
- package/src/vitest-integration.ts +5 -3
- package/src/vitest-repo.ts +10 -5
- package/src/vitest-web.ts +5 -3
- package/src/vitest.ts +10 -5
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AACnD,YAAY,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AAEzD,OAAO,EAAE,sBAAsB,EAAE,YAAY,EAAE,iBAAiB,EAAE,aAAa,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACxI,YAAY,EACV,cAAc,EACd,gBAAgB,EAChB,UAAU,EACV,gBAAgB,EAChB,aAAa,EACb,eAAe,EACf,kBAAkB,EAClB,WAAW,GACZ,MAAM,eAAe,CAAC;AAEvB,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,UAAU,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAC1I,YAAY,EAAE,WAAW,IAAI,cAAc,EAAE,uBAAuB,EAAE,MAAM,qBAAqB,CAAC;AAElG,OAAO,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AACrE,YAAY,EAAE,UAAU,EAAE,cAAc,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAC;AAElF,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAC9D,YAAY,EAAE,OAAO,EAAE,aAAa,EAAE,oBAAoB,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAOjI,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,kBAAkB,EAAE,MAAM,oCAAoC,CAAC;AAClG,YAAY,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,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{
|
|
1
|
+
import{defineRepoLintConfig as r}from"./eslint.js";import{FAMILY_GOD_FILE_LIMITS as i,loadManifest as f,MANIFEST_FILENAME as n,ManifestError as a,parseManifest as p,validateManifest as s}from"./manifest.js";import{defineUnitVitestConfig as g}from"./vitest.js";import{defineWebVitestConfig as m}from"./vitest-web.js";import{defineRepoVitestConfig as A}from"./vitest-repo.js";import{defineIntegrationVitestConfig as _}from"./vitest-integration.js";import{DEFAULT_CLOUDFLARE_MOCKS as C,DEFAULT_WORKSPACE_PACKAGES as L,KIT_DEDUPE as I,KIT_NO_EXTERNAL as F,workspaceAliases as T}from"./vitest-aliases.js";import{defineWebViteConfig as S,spaShellEmbedPlugin as O}from"./vite.js";import{createPagesProxy as R}from"./functions/pages-proxy.js";import{DurableObject as c,RpcTarget as K,WorkflowEntrypoint as U}from"./test/mocks/cloudflare-workers.js";import{createMigrationHelper as N,readMigrationFiles as W,splitSql as k}from"./test/integration-migrations.js";export{C as DEFAULT_CLOUDFLARE_MOCKS,L as DEFAULT_WORKSPACE_PACKAGES,c as DurableObject,i as FAMILY_GOD_FILE_LIMITS,I as KIT_DEDUPE,F as KIT_NO_EXTERNAL,n as MANIFEST_FILENAME,a as ManifestError,K as RpcTarget,U as WorkflowEntrypoint,N as createMigrationHelper,R as createPagesProxy,_ as defineIntegrationVitestConfig,r as defineRepoLintConfig,A as defineRepoVitestConfig,g as defineUnitVitestConfig,S as defineWebViteConfig,m as defineWebVitestConfig,f as loadManifest,p as parseManifest,W as readMigrationFiles,O as spaShellEmbedPlugin,k as splitSql,s as validateManifest,T 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_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": "
|
|
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"]
|
|
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 near-zero-dependency rule: nothing here imports another `@rexezuge/*` package\n * except `@rexezuge/testing` (the deprecated `cloudflare:workers` mock re-export). The\n * one other 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 { FAMILY_GOD_FILE_LIMITS, loadManifest, MANIFEST_FILENAME, ManifestError, parseManifest, validateManifest } from './manifest.ts';\nexport type {\n FamilyManifest,\n ManifestCoverage,\n ManifestD1,\n ManifestFeatures,\n ManifestLayer,\n ManifestQuality,\n ManifestValidation,\n ManifestWeb,\n} from './manifest.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": "AAkBA,OAAS,wBAAAA,MAA4B,cAGrC,OAAS,0BAAAC,EAAwB,gBAAAC,EAAc,qBAAAC,EAAmB,iBAAAC,EAAe,iBAAAC,EAAe,oBAAAC,MAAwB,gBAYxH,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", "FAMILY_GOD_FILE_LIMITS", "loadManifest", "MANIFEST_FILENAME", "ManifestError", "parseManifest", "validateManifest", "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
|
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { ManifestValidation } from './manifest.ts';
|
|
2
|
+
/**
|
|
3
|
+
Family default god-file limits: a manifest may only lower them.
|
|
4
|
+
*/
|
|
5
|
+
export declare const FAMILY_GOD_FILE_LIMITS: {
|
|
6
|
+
readonly soft: 300;
|
|
7
|
+
readonly hard: 400;
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* Validate an already-parsed value. Returns every problem found, not just the
|
|
11
|
+
* first, so one edit can fix them all.
|
|
12
|
+
*/
|
|
13
|
+
export declare function validateManifest(input: unknown): ManifestValidation;
|
|
14
|
+
//# sourceMappingURL=manifest-validate.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"manifest-validate.d.ts","sourceRoot":"","sources":["../src/manifest-validate.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAkB,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAExE;;EAEE;AACF,eAAO,MAAM,sBAAsB;;;CAAoC,CAAC;AAkLxE;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,OAAO,GAAG,kBAAkB,CAcnE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var b=Object.defineProperty;var o=(s,t)=>b(s,"name",{value:t,configurable:!0});const m={soft:300,hard:400},u=o(s=>typeof s=="object"&&s!==null&&!Array.isArray(s),"isObj"),c=/^@[a-z0-9][a-z0-9-]*$/,l=/^[a-z][a-z0-9-]*$/,y=["lines","branches","functions","statements"];class g{static{o(this,"Check")}errors=[];fail(t,e){this.errors.push(`${t}: ${e}`)}keys(t,e,i){for(const r of Object.keys(e))i.includes(r)||this.fail(`${t}.${r}`,`unknown key (allowed: ${i.join(", ")})`)}obj(t,e){return u(e)?e:(this.fail(t,"must be an object"),null)}str(t,e,i,r){return typeof e!="string"||e===""?(this.fail(t,"must be a non-empty string"),!1):i&&!i.test(e)?(this.fail(t,`${JSON.stringify(e)} is invalid${r?` (${r})`:""}`),!1):!0}bool(t,e){typeof e!="boolean"&&this.fail(t,"must be a boolean")}strings(t,e){return!Array.isArray(e)||e.some(i=>typeof i!="string"||i==="")?(this.fail(t,"must be an array of non-empty strings"),!1):!0}}function p(s,t){const e=s.obj("features",t);if(e){if(s.keys("features",e,["d1","web","background","backupD1","durableObjects","queues","workflows","email","android"]),e.d1!==void 0){const i=s.obj("features.d1",e.d1);i&&(s.keys("features.d1",i,["binding","database","migrationsDir"]),s.str("features.d1.binding",i.binding,/^[A-Z][A-Z0-9_]*$/,"an UPPER_SNAKE binding name"),s.str("features.d1.database",i.database),i.migrationsDir!==void 0&&s.str("features.d1.migrationsDir",i.migrationsDir))}if(e.web!==void 0){const i=s.obj("features.web",e.web);i&&(s.keys("features.web",i,["pages","spaShell"]),s.bool("features.web.pages",i.pages),s.bool("features.web.spaShell",i.spaShell))}for(const i of["background","backupD1","email","android"])e[i]!==void 0&&s.bool(`features.${i}`,e[i]);for(const i of["durableObjects","queues","workflows"])e[i]!==void 0&&s.strings(`features.${i}`,e[i])}}o(p,"checkFeatures");function h(s,t,e){s.keys(t,e,["name","dir","package","mayImport","typeOnly","forbid","forbidMessage","http","browser"]),s.str(`${t}.name`,e.name,l,"lower-case letters, digits and hyphens"),s.str(`${t}.dir`,e.dir)&&(/[*?{}]/.test(e.dir)||e.dir.startsWith("/")||e.dir.split("/").includes(".."))&&s.fail(`${t}.dir`,`${JSON.stringify(e.dir)} must be a repo-relative directory without globs`),e.package!==void 0&&s.str(`${t}.package`,e.package),e.forbidMessage!==void 0&&s.str(`${t}.forbidMessage`,e.forbidMessage);for(const i of["mayImport","typeOnly","forbid"])(e[i]!==void 0||i==="mayImport")&&s.strings(`${t}.${i}`,e[i]);for(const i of["http","browser"])e[i]!==void 0&&s.bool(`${t}.${i}`,e[i])}o(h,"checkLayer");function $(s,t){if(!Array.isArray(t)){s.fail("layers","must be an array of layers");return}const e=new Set,i=new Set;t.forEach((r,f)=>{const a=`layers[${f}]`,n=s.obj(a,r);n&&(h(s,a,n),typeof n.name=="string"&&(e.has(n.name)&&s.fail(`${a}.name`,`duplicate layer name ${JSON.stringify(n.name)}`),e.add(n.name)),typeof n.dir=="string"&&(i.has(n.dir)&&s.fail(`${a}.dir`,`duplicate layer dir ${JSON.stringify(n.dir)}`),i.add(n.dir)))}),t.forEach((r,f)=>{if(u(r))for(const a of["mayImport","typeOnly"]){const n=r[a];if(Array.isArray(n))for(const d of n)typeof d=="string"&&!e.has(d)&&s.fail(`layers[${f}].${a}`,`unknown layer ${JSON.stringify(d)}`),a==="typeOnly"&&Array.isArray(r.mayImport)&&r.mayImport.includes(d)&&s.fail(`layers[${f}].typeOnly`,`${JSON.stringify(d)} is already in mayImport`)}})}o($,"checkLayers");function k(s,t){const e=s.obj("quality",t);e&&(s.keys("quality",e,["coverage","godFiles"]),e.coverage!==void 0&&j(s,e.coverage),e.godFiles!==void 0&&w(s,e.godFiles))}o(k,"checkQuality");function w(s,t){const e=s.obj("quality.godFiles",t);if(e){s.keys("quality.godFiles",e,["soft","hard"]);for(const i of["soft","hard"]){const r=e[i],f=m[i];!Number.isInteger(r)||r<1?s.fail(`quality.godFiles.${i}`,"must be a positive integer"):r>f&&s.fail(`quality.godFiles.${i}`,`${String(r)} is above the family limit ${f}: god-file limits may only be lowered`)}typeof e.soft=="number"&&typeof e.hard=="number"&&e.soft>e.hard&&s.fail("quality.godFiles.soft","must not exceed quality.godFiles.hard")}}o(w,"checkGodFiles");function j(s,t){const e=s.obj("quality.coverage",t);if(e){s.keys("quality.coverage",e,y);for(const i of y){const r=e[i];(typeof r!="number"||!(r>=0&&r<=100))&&s.fail(`quality.coverage.${i}`,"must be a number from 0 to 100")}}}o(j,"checkCoverage");function O(s,t){const e=s.obj("extensions",t);if(e)for(const[i,r]of Object.entries(e))l.test(i)||s.fail(`extensions.${i}`,"namespace must be lower-case letters, digits and hyphens"),u(r)||s.fail(`extensions.${i}`,"must be an object (extensions are namespaced: one object per owner)")}o(O,"checkExtensions");function A(s){const t=new g,e=t.obj("manifest",s);return e&&(t.keys("manifest",e,["$schema","name","scope","features","layers","quality","extensions"]),e.$schema!==void 0&&t.str("$schema",e.$schema),t.str("name",e.name),t.str("scope",e.scope,c,'an npm scope such as "@mail-meow"'),e.features!==void 0&&p(t,e.features),e.layers!==void 0&&$(t,e.layers),e.quality!==void 0&&k(t,e.quality),e.extensions!==void 0&&O(t,e.extensions)),t.errors.length>0?{ok:!1,errors:t.errors}:{ok:!0,manifest:s}}o(A,"validateManifest");export{m as FAMILY_GOD_FILE_LIMITS,A as validateManifest};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/manifest-validate.ts"],
|
|
4
|
+
"sourcesContent": ["import type { FamilyManifest, ManifestValidation } from './manifest.ts';\n\n/**\nFamily default god-file limits: a manifest may only lower them.\n*/\nexport const FAMILY_GOD_FILE_LIMITS = { soft: 300, hard: 400 } as const;\n\ntype Obj = Record<string, unknown>;\n\nconst isObj = (value: unknown): value is Obj => typeof value === 'object' && value !== null && !Array.isArray(value);\nconst SCOPE_RE = /^@[a-z0-9][a-z0-9-]*$/;\nconst NAME_RE = /^[a-z][a-z0-9-]*$/;\nconst COVERAGE_KEYS = ['lines', 'branches', 'functions', 'statements'] as const;\n\n/**\nCollects errors under a dotted path so every message names its field.\n*/\nclass Check {\n readonly errors: string[] = [];\n fail(at: string, message: string): void {\n this.errors.push(`${at}: ${message}`);\n }\n /**\n Refuse unknown keys: the closed side.\n */\n keys(at: string, value: Obj, allowed: readonly string[]): void {\n for (const key of Object.keys(value)) {\n if (!allowed.includes(key)) this.fail(`${at}.${key}`, `unknown key (allowed: ${allowed.join(', ')})`);\n }\n }\n obj(at: string, value: unknown): Obj | null {\n if (isObj(value)) return value;\n this.fail(at, 'must be an object');\n return null;\n }\n str(at: string, value: unknown, pattern?: RegExp, hint?: string): value is string {\n if (typeof value !== 'string' || value === '') {\n this.fail(at, 'must be a non-empty string');\n return false;\n }\n if (pattern && !pattern.test(value)) {\n this.fail(at, `${JSON.stringify(value)} is invalid${hint ? ` (${hint})` : ''}`);\n return false;\n }\n return true;\n }\n bool(at: string, value: unknown): void {\n if (typeof value !== 'boolean') this.fail(at, 'must be a boolean');\n }\n strings(at: string, value: unknown): value is string[] {\n if (!Array.isArray(value) || value.some((item) => typeof item !== 'string' || item === '')) {\n this.fail(at, 'must be an array of non-empty strings');\n return false;\n }\n return true;\n }\n}\n\nfunction checkFeatures(c: Check, value: unknown): void {\n const features = c.obj('features', value);\n if (!features) return;\n c.keys('features', features, ['d1', 'web', 'background', 'backupD1', 'durableObjects', 'queues', 'workflows', 'email', 'android']);\n if (features.d1 !== undefined) {\n const d1 = c.obj('features.d1', features.d1);\n if (d1) {\n c.keys('features.d1', d1, ['binding', 'database', 'migrationsDir']);\n c.str('features.d1.binding', d1.binding, /^[A-Z][A-Z0-9_]*$/, 'an UPPER_SNAKE binding name');\n c.str('features.d1.database', d1.database);\n if (d1.migrationsDir !== undefined) c.str('features.d1.migrationsDir', d1.migrationsDir);\n }\n }\n if (features.web !== undefined) {\n const web = c.obj('features.web', features.web);\n if (web) {\n c.keys('features.web', web, ['pages', 'spaShell']);\n c.bool('features.web.pages', web.pages);\n c.bool('features.web.spaShell', web.spaShell);\n }\n }\n for (const flag of ['background', 'backupD1', 'email', 'android'] as const) {\n if (features[flag] !== undefined) c.bool(`features.${flag}`, features[flag]);\n }\n for (const list of ['durableObjects', 'queues', 'workflows'] as const) {\n if (features[list] !== undefined) c.strings(`features.${list}`, features[list]);\n }\n}\n\nfunction checkLayer(c: Check, at: string, layer: Obj): void {\n c.keys(at, layer, ['name', 'dir', 'package', 'mayImport', 'typeOnly', 'forbid', 'forbidMessage', 'http', 'browser']);\n c.str(`${at}.name`, layer.name, NAME_RE, 'lower-case letters, digits and hyphens');\n if (c.str(`${at}.dir`, layer.dir) && (/[*?{}]/.test(layer.dir) || layer.dir.startsWith('/') || layer.dir.split('/').includes('..'))) {\n c.fail(`${at}.dir`, `${JSON.stringify(layer.dir)} must be a repo-relative directory without globs`);\n }\n if (layer.package !== undefined) c.str(`${at}.package`, layer.package);\n if (layer.forbidMessage !== undefined) c.str(`${at}.forbidMessage`, layer.forbidMessage);\n for (const list of ['mayImport', 'typeOnly', 'forbid'] as const) {\n if (layer[list] !== undefined || list === 'mayImport') c.strings(`${at}.${list}`, layer[list]);\n }\n for (const flag of ['http', 'browser'] as const) if (layer[flag] !== undefined) c.bool(`${at}.${flag}`, layer[flag]);\n}\n\nfunction checkLayers(c: Check, value: unknown): void {\n if (!Array.isArray(value)) {\n c.fail('layers', 'must be an array of layers');\n return;\n }\n const names = new Set<string>();\n const dirs = new Set<string>();\n value.forEach((entry: unknown, index) => {\n const at = `layers[${index}]`;\n const layer = c.obj(at, entry);\n if (!layer) return;\n checkLayer(c, at, layer);\n if (typeof layer.name === 'string') {\n if (names.has(layer.name)) c.fail(`${at}.name`, `duplicate layer name ${JSON.stringify(layer.name)}`);\n names.add(layer.name);\n }\n if (typeof layer.dir !== 'string') {\n return;\n }\n\n if (dirs.has(layer.dir)) c.fail(`${at}.dir`, `duplicate layer dir ${JSON.stringify(layer.dir)}`);\n dirs.add(layer.dir);\n });\n value.forEach((entry: unknown, index) => {\n if (!isObj(entry)) return;\n for (const list of ['mayImport', 'typeOnly'] as const) {\n const refs = entry[list];\n if (!Array.isArray(refs)) continue;\n for (const ref of refs) {\n if (typeof ref === 'string' && !names.has(ref)) c.fail(`layers[${index}].${list}`, `unknown layer ${JSON.stringify(ref)}`);\n if (list === 'typeOnly' && Array.isArray(entry.mayImport) && entry.mayImport.includes(ref)) {\n c.fail(`layers[${index}].typeOnly`, `${JSON.stringify(ref)} is already in mayImport`);\n }\n }\n }\n });\n}\n\nfunction checkQuality(c: Check, value: unknown): void {\n const quality = c.obj('quality', value);\n if (!quality) return;\n c.keys('quality', quality, ['coverage', 'godFiles']);\n if (quality.coverage !== undefined) checkCoverage(c, quality.coverage);\n if (quality.godFiles !== undefined) checkGodFiles(c, quality.godFiles);\n}\n\nfunction checkGodFiles(c: Check, value: unknown): void {\n const god = c.obj('quality.godFiles', value);\n if (!god) return;\n c.keys('quality.godFiles', god, ['soft', 'hard']);\n for (const key of ['soft', 'hard'] as const) {\n const limit = god[key];\n const ceiling = FAMILY_GOD_FILE_LIMITS[key];\n if (!Number.isInteger(limit) || (limit as number) < 1) c.fail(`quality.godFiles.${key}`, 'must be a positive integer');\n else if ((limit as number) > ceiling) {\n c.fail(`quality.godFiles.${key}`, `${String(limit)} is above the family limit ${ceiling}: god-file limits may only be lowered`);\n }\n }\n if (typeof god.soft === 'number' && typeof god.hard === 'number' && god.soft > god.hard) {\n c.fail('quality.godFiles.soft', 'must not exceed quality.godFiles.hard');\n }\n}\n\nfunction checkCoverage(c: Check, value: unknown): void {\n const coverage = c.obj('quality.coverage', value);\n if (!coverage) return;\n c.keys('quality.coverage', coverage, COVERAGE_KEYS);\n for (const key of COVERAGE_KEYS) {\n const figure = coverage[key];\n if (typeof figure !== 'number' || !(figure >= 0 && figure <= 100)) c.fail(`quality.coverage.${key}`, 'must be a number from 0 to 100');\n }\n}\n\nfunction checkExtensions(c: Check, value: unknown): void {\n const extensions = c.obj('extensions', value);\n if (!extensions) return;\n for (const [key, entry] of Object.entries(extensions)) {\n if (!NAME_RE.test(key)) c.fail(`extensions.${key}`, 'namespace must be lower-case letters, digits and hyphens');\n if (!isObj(entry)) c.fail(`extensions.${key}`, 'must be an object (extensions are namespaced: one object per owner)');\n }\n}\n\n/**\n * Validate an already-parsed value. Returns every problem found, not just the\n * first, so one edit can fix them all.\n */\nexport function validateManifest(input: unknown): ManifestValidation {\n const c = new Check();\n const root = c.obj('manifest', input);\n if (root) {\n c.keys('manifest', root, ['$schema', 'name', 'scope', 'features', 'layers', 'quality', 'extensions']);\n if (root.$schema !== undefined) c.str('$schema', root.$schema);\n c.str('name', root.name);\n c.str('scope', root.scope, SCOPE_RE, 'an npm scope such as \"@mail-meow\"');\n if (root.features !== undefined) checkFeatures(c, root.features);\n if (root.layers !== undefined) checkLayers(c, root.layers);\n if (root.quality !== undefined) checkQuality(c, root.quality);\n if (root.extensions !== undefined) checkExtensions(c, root.extensions);\n }\n return c.errors.length > 0 ? { ok: false, errors: c.errors } : { ok: true, manifest: input as FamilyManifest };\n}\n"],
|
|
5
|
+
"mappings": "+EAKO,MAAMA,EAAyB,CAAE,KAAM,IAAK,KAAM,GAAG,EAItDC,EAAQC,EAACC,GAAiC,OAAOA,GAAU,UAAYA,IAAU,MAAQ,CAAC,MAAM,QAAQA,CAAK,EAArG,SACRC,EAAW,wBACXC,EAAU,oBACVC,EAAgB,CAAC,QAAS,WAAY,YAAa,YAAY,EAKrE,MAAMC,CAAK,CAfX,MAeW,CAAAL,EAAA,cACA,OAAmB,CAAA,EAC5B,KAAKM,EAAYC,EAAe,CAC9B,KAAK,OAAO,KAAK,GAAGD,CAAE,KAAKC,CAAO,EAAE,CACtC,CAIA,KAAKD,EAAYL,EAAYO,EAA0B,CACrD,UAAWC,KAAO,OAAO,KAAKR,CAAK,EAC5BO,EAAQ,SAASC,CAAG,GAAG,KAAK,KAAK,GAAGH,CAAE,IAAIG,CAAG,GAAI,yBAAyBD,EAAQ,KAAK,IAAI,CAAC,GAAG,CAExG,CACA,IAAIF,EAAYL,EAAc,CAC5B,OAAIF,EAAME,CAAK,EAAUA,GACzB,KAAK,KAAKK,EAAI,mBAAmB,EAC1B,KAC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ITS", "isObj", "__name", "value", "SCOPE_RE", "NAME_RE", "COVERAGE_KEYS", "Check", "at", "message", "allowed", "key", "pattern", "hint", "item", "checkFeatures", "c", "features", "d1", "web", "flag", "list", "checkLayer", "layer", "checkLayers", "names", "dirs", "entry", "index", "refs", "ref", "checkQuality", "quality", "checkCoverage", "checkGodFiles", "god", "limit", "ceiling", "coverage", "figure", "checkExtensions", "extensions", "validateManifest", "input", "root"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The family manifest: `.rexezuge.jsonc` at a repo root.
|
|
3
|
+
*
|
|
4
|
+
* One declarative file states what a repo *is* (its scope, the platform features
|
|
5
|
+
* it uses, its dependency layers) and how strict it holds itself (coverage
|
|
6
|
+
* floors, god-file limits). The tooling factories read it instead of each
|
|
7
|
+
* encoding consumer directory names, so the kit stays free of repo layouts and a
|
|
8
|
+
* repo's layout stays out of its lint config.
|
|
9
|
+
*
|
|
10
|
+
* The charter applies to the file itself. The **closed** side is the schema:
|
|
11
|
+
* unknown keys are refused (a typo is an error, not a silent no-op), and
|
|
12
|
+
* `quality.godFiles` may only be lowered below the family default, never raised.
|
|
13
|
+
* The **open** side is `extensions`: a free-form object, namespaced by the key
|
|
14
|
+
* that owns it, that the kit never reads.
|
|
15
|
+
*
|
|
16
|
+
* `manifest.schema.json` (shipped beside this module) describes the same shape
|
|
17
|
+
* for editor completion via `$schema`; a test keeps the two in step.
|
|
18
|
+
*/
|
|
19
|
+
export { FAMILY_GOD_FILE_LIMITS, validateManifest } from './manifest-validate.ts';
|
|
20
|
+
/**
|
|
21
|
+
The file name, resolved against a repo root.
|
|
22
|
+
*/
|
|
23
|
+
export declare const MANIFEST_FILENAME = ".rexezuge.jsonc";
|
|
24
|
+
export interface ManifestD1 {
|
|
25
|
+
readonly binding: string;
|
|
26
|
+
readonly database: string;
|
|
27
|
+
readonly migrationsDir?: string;
|
|
28
|
+
}
|
|
29
|
+
export interface ManifestWeb {
|
|
30
|
+
/**
|
|
31
|
+
The SPA is served by Cloudflare Pages.
|
|
32
|
+
*/
|
|
33
|
+
readonly pages: boolean;
|
|
34
|
+
/**
|
|
35
|
+
The SPA shell is embedded into the worker (`spa-shell` scripts).
|
|
36
|
+
*/
|
|
37
|
+
readonly spaShell: boolean;
|
|
38
|
+
}
|
|
39
|
+
export interface ManifestFeatures {
|
|
40
|
+
readonly d1?: ManifestD1;
|
|
41
|
+
readonly web?: ManifestWeb;
|
|
42
|
+
readonly background?: boolean;
|
|
43
|
+
readonly backupD1?: boolean;
|
|
44
|
+
/**
|
|
45
|
+
Durable Object class names.
|
|
46
|
+
*/
|
|
47
|
+
readonly durableObjects?: readonly string[];
|
|
48
|
+
/**
|
|
49
|
+
Queue names.
|
|
50
|
+
*/
|
|
51
|
+
readonly queues?: readonly string[];
|
|
52
|
+
/**
|
|
53
|
+
Workflow class names.
|
|
54
|
+
*/
|
|
55
|
+
readonly workflows?: readonly string[];
|
|
56
|
+
readonly email?: boolean;
|
|
57
|
+
readonly android?: boolean;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* One dependency layer: a directory, and the other layers it may import.
|
|
61
|
+
*
|
|
62
|
+
* Everything not named in `mayImport` / `typeOnly` is banned, by package name
|
|
63
|
+
* (`<scope>/<basename of dir>`, or `package`). `mayImport: []` isolates the layer
|
|
64
|
+
* from the whole scope (`<scope>/*`).
|
|
65
|
+
*/
|
|
66
|
+
export interface ManifestLayer {
|
|
67
|
+
readonly name: string;
|
|
68
|
+
/**
|
|
69
|
+
Repo-relative directory, no globs: `packages/backend-data`.
|
|
70
|
+
*/
|
|
71
|
+
readonly dir: string;
|
|
72
|
+
/**
|
|
73
|
+
Package suffix when it is not the directory's basename.
|
|
74
|
+
*/
|
|
75
|
+
readonly package?: string;
|
|
76
|
+
/**
|
|
77
|
+
Names of layers this layer may import.
|
|
78
|
+
*/
|
|
79
|
+
readonly mayImport: readonly string[];
|
|
80
|
+
/**
|
|
81
|
+
Names of layers importable as `import type` only.
|
|
82
|
+
*/
|
|
83
|
+
readonly typeOnly?: readonly string[];
|
|
84
|
+
/**
|
|
85
|
+
Extra external specifiers this layer may not import, e.g. `aws4fetch`.
|
|
86
|
+
*/
|
|
87
|
+
readonly forbid?: readonly string[];
|
|
88
|
+
/**
|
|
89
|
+
Message for `forbid`; defaults to a generic one.
|
|
90
|
+
*/
|
|
91
|
+
readonly forbidMessage?: string;
|
|
92
|
+
/**
|
|
93
|
+
May import `hono`/`chanfana` (and hand-build error envelopes).
|
|
94
|
+
*/
|
|
95
|
+
readonly http?: boolean;
|
|
96
|
+
/**
|
|
97
|
+
Browser code: may use `console`, and lints with browser globals.
|
|
98
|
+
*/
|
|
99
|
+
readonly browser?: boolean;
|
|
100
|
+
}
|
|
101
|
+
export interface ManifestCoverage {
|
|
102
|
+
readonly lines: number;
|
|
103
|
+
readonly branches: number;
|
|
104
|
+
readonly functions: number;
|
|
105
|
+
readonly statements: number;
|
|
106
|
+
}
|
|
107
|
+
export interface ManifestQuality {
|
|
108
|
+
readonly coverage?: ManifestCoverage;
|
|
109
|
+
readonly godFiles?: {
|
|
110
|
+
readonly soft: number;
|
|
111
|
+
readonly hard: number;
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
export interface FamilyManifest {
|
|
115
|
+
readonly $schema?: string;
|
|
116
|
+
readonly name: string;
|
|
117
|
+
/**
|
|
118
|
+
npm scope with the `@`, e.g. `@mail-meow`.
|
|
119
|
+
*/
|
|
120
|
+
readonly scope: string;
|
|
121
|
+
readonly features?: ManifestFeatures;
|
|
122
|
+
readonly layers?: readonly ManifestLayer[];
|
|
123
|
+
readonly quality?: ManifestQuality;
|
|
124
|
+
/**
|
|
125
|
+
Repo-specific settings, namespaced by key. Never read by the kit.
|
|
126
|
+
*/
|
|
127
|
+
readonly extensions?: Readonly<Record<string, Readonly<Record<string, unknown>>>>;
|
|
128
|
+
}
|
|
129
|
+
export type ManifestValidation = {
|
|
130
|
+
readonly ok: true;
|
|
131
|
+
readonly manifest: FamilyManifest;
|
|
132
|
+
} | {
|
|
133
|
+
readonly ok: false;
|
|
134
|
+
readonly errors: string[];
|
|
135
|
+
};
|
|
136
|
+
/**
|
|
137
|
+
Thrown by {@link loadManifest} and {@link parseManifest}; `errors` has one line per problem.
|
|
138
|
+
*/
|
|
139
|
+
export declare class ManifestError extends Error {
|
|
140
|
+
readonly errors: readonly string[];
|
|
141
|
+
constructor(source: string, errors: readonly string[]);
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
Parse JSONC text and validate it. Throws {@link ManifestError}.
|
|
145
|
+
*/
|
|
146
|
+
export declare function parseManifest(text: string, source?: string): FamilyManifest;
|
|
147
|
+
/**
|
|
148
|
+
* Load `<root>/.rexezuge.jsonc`. Returns `null` when the file is absent (the
|
|
149
|
+
* repo has not adopted a manifest) and throws {@link ManifestError} when it is
|
|
150
|
+
* present but invalid: a broken manifest must fail the gate, not fall back.
|
|
151
|
+
*/
|
|
152
|
+
export declare function loadManifest(root: string): FamilyManifest | null;
|
|
153
|
+
/**
|
|
154
|
+
* The manifest's coverage floor for a vitest config, or `undefined` when the
|
|
155
|
+
* repo has no manifest or declares none. `root` is what the factories take: a
|
|
156
|
+
* directory path or a `file:` URL (`new URL('.', import.meta.url).href`).
|
|
157
|
+
*/
|
|
158
|
+
export declare function manifestCoverageThresholds(root: string): ManifestCoverage | undefined;
|
|
159
|
+
//# sourceMappingURL=manifest.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"manifest.d.ts","sourceRoot":"","sources":["../src/manifest.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AASH,OAAO,EAAE,sBAAsB,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAElF;;EAEE;AACF,eAAO,MAAM,iBAAiB,oBAAoB,CAAC;AAEnD,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ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;IAAE,QAAQ,CAAC,EAAE,EAAE,KAAK,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,EAAE,CAAA;CAAE,CAAC;AAE/G;;EAEE;AACF,qBAAa,aAAc,SAAQ,KAAK;IACtC,QAAQ,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC;gBACvB,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,MAAM,EAAE;CAKtD;AAED;;EAEE;AACF,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,GAAE,MAA0B,GAAG,cAAc,CAY9F;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,cAAc,GAAG,IAAI,CAIhE;AAED;;;;GAIG;AACH,wBAAgB,0BAA0B,CAAC,IAAI,EAAE,MAAM,GAAG,gBAAgB,GAAG,SAAS,CAGrF"}
|
package/dist/manifest.js
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
var l=Object.defineProperty;var o=(t,r)=>l(t,"name",{value:r,configurable:!0});import{existsSync as m,readFileSync as p}from"node:fs";import c from"node:path";import{fileURLToPath as u}from"node:url";import{parse as x,printParseErrorCode as h}from"jsonc-parser";import{validateManifest as M}from"./manifest-validate.js";import{FAMILY_GOD_FILE_LIMITS as S,validateManifest as _}from"./manifest-validate.js";const i=".rexezuge.jsonc";class f extends Error{static{o(this,"ManifestError")}errors;constructor(r,e){super(`${r} is not a valid family manifest:
|
|
2
|
+
${e.map(n=>` - ${n}`).join(`
|
|
3
|
+
`)}`),this.name="ManifestError",this.errors=e}}function d(t,r=i){const e=[],n=x(t,e,{allowTrailingComma:!0});if(e.length>0)throw new f(r,e.map(a=>`syntax error at offset ${a.offset}: ${h(a.error)}`));const s=M(n);if(!s.ok)throw new f(r,s.errors);return s.manifest}o(d,"parseManifest");function E(t){const r=c.join(t,i);return m(r)?d(p(r,"utf8"),r):null}o(E,"loadManifest");function L(t){const r=t.startsWith("file:")?u(t):t;return E(r)?.quality?.coverage}o(L,"manifestCoverageThresholds");export{S as FAMILY_GOD_FILE_LIMITS,i as MANIFEST_FILENAME,f as ManifestError,E as loadManifest,L as manifestCoverageThresholds,d as parseManifest,_ as validateManifest};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/manifest.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * The family manifest: `.rexezuge.jsonc` at a repo root.\n *\n * One declarative file states what a repo *is* (its scope, the platform features\n * it uses, its dependency layers) and how strict it holds itself (coverage\n * floors, god-file limits). The tooling factories read it instead of each\n * encoding consumer directory names, so the kit stays free of repo layouts and a\n * repo's layout stays out of its lint config.\n *\n * The charter applies to the file itself. The **closed** side is the schema:\n * unknown keys are refused (a typo is an error, not a silent no-op), and\n * `quality.godFiles` may only be lowered below the family default, never raised.\n * The **open** side is `extensions`: a free-form object, namespaced by the key\n * that owns it, that the kit never reads.\n *\n * `manifest.schema.json` (shipped beside this module) describes the same shape\n * for editor completion via `$schema`; a test keeps the two in step.\n */\n\nimport { existsSync, readFileSync } from 'node:fs';\nimport path from 'node:path';\nimport { fileURLToPath } from 'node:url';\nimport { parse as parseJsonc, printParseErrorCode } from 'jsonc-parser';\nimport type { ParseError } from 'jsonc-parser';\nimport { validateManifest } from './manifest-validate.ts';\n\nexport { FAMILY_GOD_FILE_LIMITS, validateManifest } from './manifest-validate.ts';\n\n/**\nThe file name, resolved against a repo root.\n*/\nexport const MANIFEST_FILENAME = '.rexezuge.jsonc';\n\nexport interface ManifestD1 {\n readonly binding: string;\n readonly database: string;\n readonly migrationsDir?: string;\n}\n\nexport interface ManifestWeb {\n /**\n The SPA is served by Cloudflare Pages.\n */\n readonly pages: boolean;\n /**\n The SPA shell is embedded into the worker (`spa-shell` scripts).\n */\n readonly spaShell: boolean;\n}\n\nexport interface ManifestFeatures {\n readonly d1?: ManifestD1;\n readonly web?: ManifestWeb;\n readonly background?: boolean;\n readonly backupD1?: boolean;\n /**\n Durable Object class names.\n */\n readonly durableObjects?: readonly string[];\n /**\n Queue names.\n */\n readonly queues?: readonly string[];\n /**\n Workflow class names.\n */\n readonly workflows?: readonly string[];\n readonly email?: boolean;\n readonly android?: boolean;\n}\n\n/**\n * One dependency layer: a directory, and the other layers it may import.\n *\n * Everything not named in `mayImport` / `typeOnly` is banned, by package name\n * (`<scope>/<basename of dir>`, or `package`). `mayImport: []` isolates the layer\n * from the whole scope (`<scope>/*`).\n */\nexport interface ManifestLayer {\n readonly name: string;\n /**\n Repo-relative directory, no globs: `packages/backend-data`.\n */\n readonly dir: string;\n /**\n Package suffix when it is not the directory's basename.\n */\n readonly package?: string;\n /**\n Names of layers this layer may import.\n */\n readonly mayImport: readonly string[];\n /**\n Names of layers importable as `import type` only.\n */\n readonly typeOnly?: readonly string[];\n /**\n Extra external specifiers this layer may not import, e.g. `aws4fetch`.\n */\n readonly forbid?: readonly string[];\n /**\n Message for `forbid`; defaults to a generic one.\n */\n readonly forbidMessage?: string;\n /**\n May import `hono`/`chanfana` (and hand-build error envelopes).\n */\n readonly http?: boolean;\n /**\n Browser code: may use `console`, and lints with browser globals.\n */\n readonly browser?: boolean;\n}\n\nexport interface ManifestCoverage {\n readonly lines: number;\n readonly branches: number;\n readonly functions: number;\n readonly statements: number;\n}\n\nexport interface ManifestQuality {\n readonly coverage?: ManifestCoverage;\n readonly godFiles?: { readonly soft: number; readonly hard: number };\n}\n\nexport interface FamilyManifest {\n readonly $schema?: string;\n readonly name: string;\n /**\n npm scope with the `@`, e.g. `@mail-meow`.\n */\n readonly scope: string;\n readonly features?: ManifestFeatures;\n readonly layers?: readonly ManifestLayer[];\n readonly quality?: ManifestQuality;\n /**\n Repo-specific settings, namespaced by key. Never read by the kit.\n */\n readonly extensions?: Readonly<Record<string, Readonly<Record<string, unknown>>>>;\n}\n\nexport type ManifestValidation =\n { readonly ok: true; readonly manifest: FamilyManifest } | { readonly ok: false; readonly errors: string[] };\n\n/**\nThrown by {@link loadManifest} and {@link parseManifest}; `errors` has one line per problem.\n*/\nexport class ManifestError extends Error {\n readonly errors: readonly string[];\n constructor(source: string, errors: readonly string[]) {\n super(`${source} is not a valid family manifest:\\n${errors.map((line) => ` - ${line}`).join('\\n')}`);\n this.name = 'ManifestError';\n this.errors = errors;\n }\n}\n\n/**\nParse JSONC text and validate it. Throws {@link ManifestError}.\n*/\nexport function parseManifest(text: string, source: string = MANIFEST_FILENAME): FamilyManifest {\n const syntax: ParseError[] = [];\n const value: unknown = parseJsonc(text, syntax, { allowTrailingComma: true });\n if (syntax.length > 0) {\n throw new ManifestError(\n source,\n syntax.map((error) => `syntax error at offset ${error.offset}: ${printParseErrorCode(error.error)}`),\n );\n }\n const result = validateManifest(value);\n if (!result.ok) throw new ManifestError(source, result.errors);\n return result.manifest;\n}\n\n/**\n * Load `<root>/.rexezuge.jsonc`. Returns `null` when the file is absent (the\n * repo has not adopted a manifest) and throws {@link ManifestError} when it is\n * present but invalid: a broken manifest must fail the gate, not fall back.\n */\nexport function loadManifest(root: string): FamilyManifest | null {\n const file = path.join(root, MANIFEST_FILENAME);\n if (!existsSync(file)) return null;\n return parseManifest(readFileSync(file, 'utf8'), file);\n}\n\n/**\n * The manifest's coverage floor for a vitest config, or `undefined` when the\n * repo has no manifest or declares none. `root` is what the factories take: a\n * directory path or a `file:` URL (`new URL('.', import.meta.url).href`).\n */\nexport function manifestCoverageThresholds(root: string): ManifestCoverage | undefined {\n const dir = root.startsWith('file:') ? fileURLToPath(root) : root;\n return loadManifest(dir)?.quality?.coverage;\n}\n"],
|
|
5
|
+
"mappings": "+EAmBA,OAAS,cAAAA,EAAY,gBAAAC,MAAoB,UACzC,OAAOC,MAAU,YACjB,OAAS,iBAAAC,MAAqB,WAC9B,OAAS,SAASC,EAAY,uBAAAC,MAA2B,eAEzD,OAAS,oBAAAC,MAAwB,yBAEjC,OAAS,0BAAAC,EAAwB,oBAAAD,MAAwB,yBAKlD,MAAME,EAAoB,kBAqH3B,MAAOC,UAAsB,KAAK,CApJxC,MAoJwC,CAAAC,EAAA,sBAC7B,OACT,YAAYC,EAAgBC,EAAyB,CACnD,MAAM,GAAGD,CAAM;EAAqCC,EAAO,IAAKC,GAAS,OAAOA,CAAI,EAAE,EAAE,KAAK;CAAI,CAAC,EAAE,EACpG,KAAK,KAAO,gBACZ,KAAK,OAASD,CAChB,EAMI,SAAUE,EAAcC,EAAcJ,EAAiBH,EAAiB,CAC5E,MAAMQ,EAAuB,CAAA,EACvBC,EAAiBb,EAAWW,EAAMC,EAAQ,CAAE,mBAAoB,EAAI,CAAE,EAC5E,GAAIA,EAAO,OAAS,EAClB,MAAM,IAAIP,EACRE,EACAK,EAAO,IAAKE,GAAU,0BAA0BA,EAAM,MAAM,KAAKb,EAAoBa,EAAM,KAAK,CAAC,EAAE,CAAC,EAGxG,MAAMC,EAASb,EAAiBW,CAAK,EACrC,GAAI,CAACE,EAAO,GAAI,MAAM,IAAIV,EAAcE,EAAQQ,EAAO,MAAM,EAC7D,OAAOA,EAAO,QAChB,CAZgBT,EAAAI,EAAA,iBAmBV,SAAUM,EAAaC,EAAY,CACvC,MAAMC,EAAOpB,EAAK,KAAKmB,EAAMb,CAAiB,EAC9C,OAAKR,EAAWsB,CAAI,EACbR,EAAcb,EAAaqB,EAAM,MAAM,EAAGA,CAAI,EADvB,IAEhC,CAJgBZ,EAAAU,EAAA,gBAWV,SAAUG,EAA2BF,EAAY,CACrD,MAAMG,EAAMH,EAAK,WAAW,OAAO,EAAIlB,EAAckB,CAAI,EAAIA,EAC7D,OAAOD,EAAaI,CAAG,GAAG,SAAS,QACrC,CAHgBd,EAAAa,EAAA",
|
|
6
|
+
"names": ["existsSync", "readFileSync", "path", "fileURLToPath", "parseJsonc", "printParseErrorCode", "validateManifest", "FAMILY_GOD_FILE_LIMITS", "MANIFEST_FILENAME", "ManifestError", "__name", "source", "errors", "line", "parseManifest", "text", "syntax", "value", "error", "result", "loadManifest", "root", "file", "manifestCoverageThresholds", "dir"]
|
|
7
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pages-proxy.d.ts","sourceRoot":"","sources":["../src/pages-proxy.ts"],"names":[],"mappings":"AAYA,eAAO,MAAM,SAAS,oCAAqB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{createPagesProxy as e}from"./functions/pages-proxy.js";const r=e();export{r as onRequest};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/pages-proxy.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * The whole `functions/[[path]].ts` of a Pages project that proxies to `API_WORKER`, as a re-export:\n *\n * ```ts\n * export { onRequest } from '@rexezuge/tooling/pages-proxy';\n * ```\n *\n * The default `createPagesProxy()`. A repo that needs an option (`forwardClientIp: false`) keeps\n * the two-line `createPagesProxy({ ... })` form from `@rexezuge/tooling/functions/pages-proxy`.\n */\nimport { createPagesProxy } from './functions/pages-proxy.ts';\n\nexport const onRequest = createPagesProxy();\n"],
|
|
5
|
+
"mappings": "AAUA,OAAS,oBAAAA,MAAwB,6BAE1B,MAAMC,EAAYD,EAAgB",
|
|
6
|
+
"names": ["createPagesProxy", "onRequest"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { ViteUserConfig } from 'vitest/config';
|
|
2
|
+
/**
|
|
3
|
+
* What a `plugins` option accepts: whatever a Vite `plugins` array does (a plugin, a nested array of them as
|
|
4
|
+
* `@vitejs/plugin-react` and `@tailwindcss/vite` return, a promise, a falsy placeholder).
|
|
5
|
+
*
|
|
6
|
+
* Deliberately structural rather than Vite's own `PluginOption`: the app's `vite` and the `vite` that
|
|
7
|
+
* `vitest` brings are separate installs more often than not, and their `Plugin` types are not assignable to
|
|
8
|
+
* each other even at the same version ("Excessive stack depth comparing types"). The kit never inspects a plugin.
|
|
9
|
+
*/
|
|
10
|
+
export type PluginOption = object | false | null | undefined;
|
|
11
|
+
/**
|
|
12
|
+
* Hand the plugins to Vite. One assertion, here, for the reason above.
|
|
13
|
+
*/
|
|
14
|
+
export declare function asVitePlugins(plugins: readonly PluginOption[]): NonNullable<ViteUserConfig['plugins']>;
|
|
15
|
+
//# sourceMappingURL=plugin-option.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin-option.d.ts","sourceRoot":"","sources":["../src/plugin-option.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAEpD;;;;;;;GAOG;AACH,MAAM,MAAM,YAAY,GAAG,MAAM,GAAG,KAAK,GAAG,IAAI,GAAG,SAAS,CAAC;AAE7D;;GAEG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,SAAS,YAAY,EAAE,GAAG,WAAW,CAAC,cAAc,CAAC,SAAS,CAAC,CAAC,CAEtG"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var i=Object.defineProperty;var t=(n,e)=>i(n,"name",{value:e,configurable:!0});function u(n){return[...n]}t(u,"asVitePlugins");export{u as asVitePlugins};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/plugin-option.ts"],
|
|
4
|
+
"sourcesContent": ["import type { ViteUserConfig } from 'vitest/config';\n\n/**\n * What a `plugins` option accepts: whatever a Vite `plugins` array does (a plugin, a nested array of them as\n * `@vitejs/plugin-react` and `@tailwindcss/vite` return, a promise, a falsy placeholder).\n *\n * Deliberately structural rather than Vite's own `PluginOption`: the app's `vite` and the `vite` that\n * `vitest` brings are separate installs more often than not, and their `Plugin` types are not assignable to\n * each other even at the same version (\"Excessive stack depth comparing types\"). The kit never inspects a plugin.\n */\nexport type PluginOption = object | false | null | undefined;\n\n/**\n * Hand the plugins to Vite. One assertion, here, for the reason above.\n */\nexport function asVitePlugins(plugins: readonly PluginOption[]): NonNullable<ViteUserConfig['plugins']> {\n return [...plugins] as NonNullable<ViteUserConfig['plugins']>;\n}\n"],
|
|
5
|
+
"mappings": "+EAeM,SAAUA,EAAcC,EAAgC,CAC5D,MAAO,CAAC,GAAGA,CAAO,CACpB,CAFgBC,EAAAF,EAAA",
|
|
6
|
+
"names": ["asVitePlugins", "plugins", "__name"]
|
|
7
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"check-god-files.d.ts","sourceRoot":"","sources":["../../src/scripts/check-god-files.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8CG;
|
|
1
|
+
{"version":3,"file":"check-god-files.d.ts","sourceRoot":"","sources":["../../src/scripts/check-god-files.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8CG;AASH;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B;;MAEE;IACF,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB;;MAEE;IACF,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB;;MAEE;IACF,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,UAAU,CAAC;CACrC;AAED;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B;;MAEE;IACF,QAAQ,CAAC,QAAQ,EAAE,SAAS,cAAc,EAAE,CAAC;IAC7C;;MAEE;IACF,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB;;MAEE;IACF,QAAQ,CAAC,WAAW,EAAE,SAAS,cAAc,EAAE,CAAC;IAChD;;;;;OAKG;IACH,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;IACzB;;MAEE;IACF,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;CAC3B;AAED;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B;;MAEE;IACF,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB;;;;OAIG;IACH,QAAQ,CAAC,SAAS,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACvC;;MAEE;IACF,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB;;MAEE;IACF,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB;;MAEE;IACF,QAAQ,CAAC,UAAU,CAAC,EAAE,OAAO,CAAC;CAC/B;AAED;;EAEE;AACF,eAAO,MAAM,UAAU,MAAM,CAAC;AAC9B;;EAEE;AACF,eAAO,MAAM,UAAU,MAAM,CAAC;AA+B9B;;;;;;;;;;;;;GAaG;AACH,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAc/C;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,EAAE,SAAS,EAAE,SAAS,MAAM,EAAE,GAAG,OAAO,CAEhF;AAED;;;;;GAKG;AACH,wBAAgB,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAqB3C;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,cAAc,GAAG,aAAa,CA+BpE;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAiBpD;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,GAAE,SAAS,MAAM,EAA0B,GAAG,MAAM,CA4BxF"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var w=Object.defineProperty;var a=(t,s)=>w(t,"name",{value:s,configurable:!0});import{readdirSync as S,readFileSync as u,statSync as $}from"node:fs";import d from"node:path";import{fail as v}from"./lib/github-actions.js";import{isEntrypoint as j}from"./lib/entrypoint.js";import{isSet as _,parseFlags as x,splitPositional as
|
|
2
|
-
`).length;if(f<=s)continue;const p={file:l,lines:f,level:f>e?"critical":"warn"};L(l,o)?
|
|
1
|
+
var w=Object.defineProperty;var a=(t,s)=>w(t,"name",{value:s,configurable:!0});import{readdirSync as S,readFileSync as u,statSync as $}from"node:fs";import d from"node:path";import{fail as v}from"./lib/github-actions.js";import{isEntrypoint as j}from"./lib/entrypoint.js";import{isSet as _,parseFlags as x,splitPositional as y,valueOf as g}from"./lib/cli-args.js";import{loadManifest as E}from"../manifest.js";const O=300,I=400,W=new Set(["node_modules","dist",".wrangler","coverage","coverage-integration","coverage-web",".git"]),k=/\.(?:ts|tsx|js|mjs|cjs|css)$/,A=["test","spec"].flatMap(t=>[".ts",".tsx",".js",".jsx",".mjs",".cjs"].map(s=>`.${t}${s}`));function F(t){return/(?:^|\/)(?:locales|generated)\//.test(t)||/(?:^|\/)__(?:tests|mocks)__(?:\/|$)/.test(t)||/(?:^|\/)scripts\//.test(t)||/(?:^|\/)(?:test|tests|__tests__)\//.test(t)||/\.config\.(?:m?[jt]s|cjs)$/.test(t)||t.endsWith(".d.ts")||t.endsWith(".json")||t.endsWith(".sql")||t.endsWith(".md")?!0:A.some(s=>t.endsWith(s))}a(F,"shouldSkip");function L(t,s){return s.some(e=>e.endsWith("/")?t.startsWith(e):t===e)}a(L,"isAllowlisted");function T(t){const s=[],e=a(o=>{for(const i of S(o)){const r=d.join(o,i);let n;try{n=$(r)}catch{continue}if(n.isDirectory()){if(W.has(i))continue;e(r)}else k.test(i)&&s.push(d.relative(t,r))}},"visit");return e(t),s}a(T,"walk");function C(t){const s=t.soft??O,e=t.hard??I,o=t.allowlist??[],i=T(t.root).filter(l=>!F(l)),r=[],n=[];for(const l of i){const f=u(d.join(t.root,l),"utf8").split(`
|
|
2
|
+
`).length;if(f<=s)continue;const p={file:l,lines:f,level:f>e?"critical":"warn"};L(l,o)?n.push(p):r.push(p)}r.sort((l,f)=>f.lines-l.lines),n.sort((l,f)=>f.lines-l.lines);const c=r.filter(l=>l.level==="critical"),h=t.failOnHard!==!0||c.length===0,m=h?`God-file check passed (${i.length} files, ${r.length} over soft limit ${s}, ${n.length} allowlisted).`:`God-file check failed: ${c.length} file(s) exceed ${e} LOC. Split them, or add them to the allowlist in the same commit that grows them.`;return{findings:r,allowlisted:n,scanned:i.length,passed:h,reported:m}}a(C,"checkGodFiles");function N(t){let s;try{s=u(t,"utf8")}catch{return[]}let e;try{e=JSON.parse(s)}catch(o){throw new Error(`${t} is not valid JSON: ${o instanceof Error?o.message:String(o)}`,{cause:o})}if(!Array.isArray(e)||e.some(o=>typeof o!="string"))throw new Error(`${t} must be a JSON array of repo-relative path strings.`);return e}a(N,"readAllowlist");function D(t=process.argv.slice(2)){const{positional:s,rest:e}=y(t,["root","allowlist"]),o=x(e,{value:["root","allowlist"],boolean:["fail-on-hard"]}),i=g(o,"root")??s[0]??".",r=g(o,"allowlist")??d.join(i,"scripts/god-files.allowlist.json"),n=C({root:i,allowlist:N(r),...E(i)?.quality?.godFiles,failOnHard:_(o,"fail-on-hard")});console.log(n.reported);for(const c of n.findings)console.log(`${c.level==="critical"?"CRITICAL":"WARN"} ${c.lines} ${c.file}`);for(const c of n.allowlisted)console.log(`ALLOWLISTED ${c.lines} ${c.file}`);return n.passed||v(`God-file check failed: run with --root ${i} to see the report.`),0}a(D,"checkGodFilesCli"),j(import.meta.url)&&process.exit(D(process.argv.slice(2)));export{I as HARD_LIMIT,O as SOFT_LIMIT,C as checkGodFiles,D as checkGodFilesCli,L as isAllowlisted,N as readAllowlist,F as shouldSkip,T as walk};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/scripts/check-god-files.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * The rules behind `scripts/check-god-files.ts`.\n *\n * Provenance: converged from the seven `.mjs` copies (AWS-AccessBridge,\n * CalDAV-Bridge, ChordDHT-Tracker, Durable-DAV, Durable-DAV-Router, Edge-Git,\n * Mail-Meow, Mail-Otter) and the typed ratchet in Edge-Sonic.\n *\n * All seven `.mjs` copies are one script with two constants: soft 300 (warn),\n * hard 400 (error). The typed variant is not a different rule so much as a\n * different answer to \"what does the gate enforce\", and that is the decision this\n * module has to take once for the whole family.\n *\n * ### The convergence: warn-only, with an allowlist\n *\n * The two source designs:\n *\n * - **Ceiling** (six repos) — 300 warn, 400 error, `exit 1` on 400. Durable-DAV's\n * own `AGENTS.md` records what that measures: **ten** files sit just over 300\n * and none is a god file, so `WARN` reports every run and `HARD` has never\n * fired. A ceiling set above the largest file in the tree cannot tell a\n * repository getting worse from one that never got better, and raising it is\n * always available.\n * - **Ratchet** (Edge-Sonic) — a committed baseline records every file's size; a\n * file may shrink freely and grow only to its recorded size. It cannot be\n * satisfied by raising a number, which is its whole strength.\n *\n * The ratchet is the better *rule*, and the ceiling is the better *gate*: the\n * ratchet needs a baseline maintained per file and fails the first time somebody\n * writes a legitimate 320-line module, which is the failure mode that trains\n * everyone to ignore a report. So the converged script keeps the 300/400\n * thresholds — every repo's CI already prints them — and makes the verdict\n * **warn-only by default**, with two escape valves that are both visible in a\n * diff:\n *\n * 1. `--fail-on-hard` turns the 400 line back into a failing gate, for a repo\n * that has paid its debt and wants the ceiling enforced.\n * 2. An **allowlist** records the files that are over the line and known, so the\n * report names only the ones that are *new*. That is the ratchet's\n * \"recorded size\" idea without its per-file bookkeeping: the allowlist is\n * reviewed by the same commit that grows the file, because the diff shows what\n * was added to it.\n *\n * Tests are excluded, as every source does. A double modelling the platform grows\n * with the platform's surface, not with the complexity of the code it stands in\n * for — Edge-Sonic's ratchet holds them too, and its own notes record a 4,343-line\n * fixture, so this is a documented disagreement rather than an oversight.\n */\n\nimport { readdirSync, readFileSync, statSync } from 'node:fs';\nimport path from 'node:path';\nimport { fail } from './lib/github-actions.ts';\nimport { isEntrypoint } from './lib/entrypoint.ts';\nimport { isSet, parseFlags, splitPositional, valueOf } from './lib/cli-args.ts';\n\n/**\n * A file past a size the guard reports on.\n */\nexport interface GodFileFinding {\n /**\n Path relative to the root the check ran against.\n */\n readonly file: string;\n /**\n Lines it has.\n */\n readonly lines: number;\n /**\n `warn` past the soft limit, `critical` past the hard one.\n */\n readonly level: 'warn' | 'critical';\n}\n\n/**\n * The outcome of one run.\n */\nexport interface GodFileReport {\n /**\n Files over a limit, worst first, minus the allowlisted.\n */\n readonly findings: readonly GodFileFinding[];\n /**\n How many files the walk measured.\n */\n readonly scanned: number;\n /**\n Allowlisted files that are over a limit — reported, never counted.\n */\n readonly allowlisted: readonly GodFileFinding[];\n /**\n * Whether the tree may be committed as it stands.\n *\n * `true` in warn-only mode, which is the default; a `critical` finding fails\n * only when the caller asked for the gate.\n */\n readonly passed: boolean;\n /**\n The message to print, either way.\n */\n readonly reported: string;\n}\n\n/**\n * What `checkGodFiles` accepts.\n */\nexport interface GodFileOptions {\n /**\n Directory to walk.\n */\n readonly root: string;\n /**\n * Repo-relative paths (or directory prefixes ending in `/`) exempt from the\n * report. Defaults to `god-files.allowlist.json` beside the caller's script\n * when that file exists — see `readAllowlist`.\n */\n readonly allowlist?: readonly string[];\n /**\n Soft limit, past which a file is reported as `warn`.\n */\n readonly soft?: number;\n /**\n Hard limit, past which a file is reported as `critical`.\n */\n readonly hard?: number;\n /**\n Make a `critical` finding fail the run.\n */\n readonly failOnHard?: boolean;\n}\n\n/**\nDefault soft limit, as every source repo uses.\n*/\nexport const SOFT_LIMIT = 300;\n/**\nDefault hard limit, as every source repo uses.\n*/\nexport const HARD_LIMIT = 400;\n\n/**\n * Directories the walker never enters.\n *\n * Build output and VCS state; `coverage` is here because a generated HTML report\n * is thousands of \"lines\" of nothing.\n */\nconst EXCLUDE_DIRS = new Set(['node_modules', 'dist', '.wrangler', 'coverage', 'coverage-integration', 'coverage-web', '.git']);\n\n/**\n * Source extensions the guard counts.\n *\n * `css` is in the set because every source repo counts it, and a 400-line\n * stylesheet is the same reading problem as a 400-line module.\n */\nconst SOURCE_EXTENSIONS = /\\.(?:ts|tsx|js|mjs|cjs|css)$/;\n\n/**\n * The test-file suffixes the guard skips.\n *\n * `.test.tsx` matter as much as `.test.ts`: the walker collects both, so a list\n * that only named the `.ts` forms let every React test file through the guard and\n * reported them as god files — which is how Durable-DAV-Router discovered it.\n * Built from the kinds and extensions rather than enumerated, so a new test\n * extension cannot silently escape.\n */\nconst TEST_SUFFIXES: readonly string[] = ['test', 'spec'].flatMap((kind) =>\n ['.ts', '.tsx', '.js', '.jsx', '.mjs', '.cjs'].map((ext) => `.${kind}${ext}`),\n);\n\n/**\n * Whether a repo-relative path is exempt from the guard.\n *\n * Provenance: AWS-AccessBridge's version is the canonical one, because it\n * documents and fixes two live bugs in the others.\n *\n * Every directory pattern is anchored with `(?:^|/)` rather than a bare leading\n * `/`. `relative()` yields `test/helpers/x.ts` for a top-level test directory and\n * `scripts/lib/x.ts` for the scripts directory — **no leading separator** — so a\n * pattern written as `/\\/(?:test|tests|__tests__)\\//` never matches either one.\n * It looks right, it does match when handed an absolute path, and against these\n * layouts it is silently a no-op. Durable-DAV and ChordDHT-Tracker ship exactly\n * that dead pattern.\n */\nexport function shouldSkip(rel: string): boolean {\n if (\n /(?:^|\\/)(?:locales|generated)\\//.test(rel) ||\n /(?:^|\\/)__(?:tests|mocks)__(?:\\/|$)/.test(rel) ||\n /(?:^|\\/)scripts\\//.test(rel) ||\n /(?:^|\\/)(?:test|tests|__tests__)\\//.test(rel) ||\n /\\.config\\.(?:m?[jt]s|cjs)$/.test(rel) ||\n rel.endsWith('.d.ts') ||\n rel.endsWith('.json') ||\n rel.endsWith('.sql') ||\n rel.endsWith('.md')\n )\n return true;\n return TEST_SUFFIXES.some((suffix) => rel.endsWith(suffix));\n}\n\n/**\n * Whether a repo-relative path is on the allowlist.\n *\n * An entry ending in `/` exempts a whole directory; any other entry is matched\n * exactly, so `apps/api/src/index.ts` does not exempt `apps/api/src/index.util.ts`.\n */\nexport function isAllowlisted(rel: string, allowlist: readonly string[]): boolean {\n return allowlist.some((entry) => (entry.endsWith('/') ? rel.startsWith(entry) : rel === entry));\n}\n\n/**\n * Every source file under `root`, as repo-relative paths.\n *\n * Symlink-safe: a dangling symlink or a file removed mid-walk is skipped rather\n * than thrown, because neither is a god-file problem.\n */\nexport function walk(root: string): string[] {\n const out: string[] = [];\n const visit = (dir: string): void => {\n for (const entry of readdirSync(dir)) {\n const full = path.join(dir, entry);\n let stat;\n try {\n stat = statSync(full);\n } catch {\n continue;\n }\n if (stat.isDirectory()) {\n if (EXCLUDE_DIRS.has(entry)) continue;\n visit(full);\n } else if (SOURCE_EXTENSIONS.test(entry)) {\n out.push(path.relative(root, full));\n }\n }\n };\n visit(root);\n return out;\n}\n\n/**\n * Run the guard over a tree.\n *\n * Pure with respect to the verdict — the only I/O is the walk and a line count —\n * so a test drives it against a temporary directory.\n */\nexport function checkGodFiles(options: GodFileOptions): GodFileReport {\n const soft = options.soft ?? SOFT_LIMIT;\n const hard = options.hard ?? HARD_LIMIT;\n const allowlist = options.allowlist ?? [];\n\n const scanned = walk(options.root).filter((rel) => !shouldSkip(rel));\n const findings: GodFileFinding[] = [];\n const allowlisted: GodFileFinding[] = [];\n\n for (const rel of scanned) {\n const lines = readFileSync(path.join(options.root, rel), 'utf8').split('\\n').length;\n if (lines <= soft) continue;\n const finding: GodFileFinding = { file: rel, lines, level: lines > hard ? 'critical' : 'warn' };\n if (isAllowlisted(rel, allowlist)) {\n allowlisted.push(finding);\n } else {\n findings.push(finding);\n }\n }\n\n findings.sort((left, right) => right.lines - left.lines);\n allowlisted.sort((left, right) => right.lines - left.lines);\n\n const critical = findings.filter((finding) => finding.level === 'critical');\n const passed = options.failOnHard !== true || critical.length === 0;\n\n const reported = passed\n ? `God-file check passed (${scanned.length} files, ${findings.length} over soft limit ${soft}, ${allowlisted.length} allowlisted).`\n : `God-file check failed: ${critical.length} file(s) exceed ${hard} LOC. Split them, or add them to the allowlist in the same commit that grows them.`;\n\n return { findings, allowlisted, scanned: scanned.length, passed, reported };\n}\n\n/**\n * Read an allowlist file, or `[]` when it is absent.\n *\n * The file is `scripts/god-files.allowlist.json`: a JSON array of repo-relative\n * paths. Absence is the normal case for a repo with no known offenders, so it is\n * not an error — a guard that fails on a first run nobody has filled in yet is a\n * guard that gets disabled.\n *\n * A malformed file is an error rather than an empty list, because \"the allowlist\n * is empty\" silently un-reports every known offender.\n */\nexport function readAllowlist(file: string): string[] {\n let raw: string;\n try {\n raw = readFileSync(file, 'utf8');\n } catch {\n return [];\n }\n let parsed: unknown;\n try {\n parsed = JSON.parse(raw);\n } catch (error: unknown) {\n throw new Error(`${file} is not valid JSON: ${error instanceof Error ? error.message : String(error)}`, { cause: error });\n }\n if (!Array.isArray(parsed) || parsed.some((entry) => typeof entry !== 'string')) {\n throw new Error(`${file} must be a JSON array of repo-relative path strings.`);\n }\n return parsed as string[];\n}\n\n/**\n * CLI entry: `checkGodFilesCli(['.', '--fail-on-hard'])`.\n *\n * The directory is a positional argument **or** `--root <dir>`, because every other\n * script in this tree takes its target positionally and a gate that has to be\n * invoked one way in one script and another way in the next is a gate somebody\n * invokes wrong. A second positional is an error.\n *\n * Flags (see FlagSpec): `--root <dir>` (default `.`), `--allowlist <file>`\n * (default `scripts/god-files.allowlist.json` beside the root, absent = none),\n * `--fail-on-hard` (default off, matching every source repo's warn-only gate).\n * Returns 0 unless `--fail-on-hard` is set and a critical file is found.\n */\nexport function checkGodFilesCli(argv: readonly string[] = process.argv.slice(2)): number {\n // Split before parsing, because parseFlags rejects anything that is not a declared\n // flag and a positional directory is neither a mistake nor a flag.\n const { positional, rest } = splitPositional(argv, ['root', 'allowlist']);\n const flags = parseFlags(rest, {\n value: ['root', 'allowlist'],\n boolean: ['fail-on-hard'],\n });\n const root = valueOf(flags, 'root') ?? positional[0] ?? '.';\n const allowlistPath = valueOf(flags, 'allowlist') ?? path.join(root, 'scripts/god-files.allowlist.json');\n const report = checkGodFiles({\n root,\n allowlist: readAllowlist(allowlistPath),\n failOnHard: isSet(flags, 'fail-on-hard'),\n });\n console.log(report.reported);\n for (const finding of report.findings) {\n console.log(`${finding.level === 'critical' ? 'CRITICAL' : 'WARN'} ${finding.lines} ${finding.file}`);\n }\n for (const finding of report.allowlisted) {\n console.log(`ALLOWLISTED ${finding.lines} ${finding.file}`);\n }\n if (!report.passed) {\n fail(`God-file check failed: run with --root ${root} to see the report.`);\n }\n return 0;\n}\n\n// Run only when this file is the entrypoint.\n//\n// The rules above are pure and the tests import them directly, so a module-level\n// call would shell out (and exit) during a test run. The URL comparison rather than\n// an unconditional call is the same guard Durable-DAV's init-secrets.ts uses, and\n// it is what keeps the rule modules importable — which is the whole reason they are\n// separate modules in the first place.\nif (isEntrypoint(import.meta.url)) {\n process.exit(checkGodFilesCli(process.argv.slice(2)));\n}\n"],
|
|
5
|
-
"mappings": "+EAgDA,OAAS,eAAAA,EAAa,gBAAAC,EAAc,YAAAC,MAAgB,UACpD,OAAOC,MAAU,YACjB,OAAS,QAAAC,MAAY,0BACrB,OAAS,gBAAAC,MAAoB,sBAC7B,OAAS,SAAAC,EAAO,cAAAC,EAAY,mBAAAC,EAAiB,WAAAC,MAAe,
|
|
6
|
-
"names": ["readdirSync", "readFileSync", "statSync", "path", "fail", "isEntrypoint", "isSet", "parseFlags", "splitPositional", "valueOf", "SOFT_LIMIT", "HARD_LIMIT", "EXCLUDE_DIRS", "SOURCE_EXTENSIONS", "TEST_SUFFIXES", "kind", "ext", "shouldSkip", "rel", "suffix", "__name", "isAllowlisted", "allowlist", "entry", "walk", "root", "out", "visit", "dir", "full", "stat", "checkGodFiles", "options", "soft", "hard", "scanned", "findings", "allowlisted", "lines", "finding", "left", "right", "critical", "passed", "reported", "readAllowlist", "file", "raw", "parsed", "error", "checkGodFilesCli", "argv", "positional", "rest", "flags", "allowlistPath", "report"]
|
|
4
|
+
"sourcesContent": ["/**\n * The rules behind `scripts/check-god-files.ts`.\n *\n * Provenance: converged from the seven `.mjs` copies (AWS-AccessBridge,\n * CalDAV-Bridge, ChordDHT-Tracker, Durable-DAV, Durable-DAV-Router, Edge-Git,\n * Mail-Meow, Mail-Otter) and the typed ratchet in Edge-Sonic.\n *\n * All seven `.mjs` copies are one script with two constants: soft 300 (warn),\n * hard 400 (error). The typed variant is not a different rule so much as a\n * different answer to \"what does the gate enforce\", and that is the decision this\n * module has to take once for the whole family.\n *\n * ### The convergence: warn-only, with an allowlist\n *\n * The two source designs:\n *\n * - **Ceiling** (six repos) — 300 warn, 400 error, `exit 1` on 400. Durable-DAV's\n * own `AGENTS.md` records what that measures: **ten** files sit just over 300\n * and none is a god file, so `WARN` reports every run and `HARD` has never\n * fired. A ceiling set above the largest file in the tree cannot tell a\n * repository getting worse from one that never got better, and raising it is\n * always available.\n * - **Ratchet** (Edge-Sonic) — a committed baseline records every file's size; a\n * file may shrink freely and grow only to its recorded size. It cannot be\n * satisfied by raising a number, which is its whole strength.\n *\n * The ratchet is the better *rule*, and the ceiling is the better *gate*: the\n * ratchet needs a baseline maintained per file and fails the first time somebody\n * writes a legitimate 320-line module, which is the failure mode that trains\n * everyone to ignore a report. So the converged script keeps the 300/400\n * thresholds — every repo's CI already prints them — and makes the verdict\n * **warn-only by default**, with two escape valves that are both visible in a\n * diff:\n *\n * 1. `--fail-on-hard` turns the 400 line back into a failing gate, for a repo\n * that has paid its debt and wants the ceiling enforced.\n * 2. An **allowlist** records the files that are over the line and known, so the\n * report names only the ones that are *new*. That is the ratchet's\n * \"recorded size\" idea without its per-file bookkeeping: the allowlist is\n * reviewed by the same commit that grows the file, because the diff shows what\n * was added to it.\n *\n * Tests are excluded, as every source does. A double modelling the platform grows\n * with the platform's surface, not with the complexity of the code it stands in\n * for — Edge-Sonic's ratchet holds them too, and its own notes record a 4,343-line\n * fixture, so this is a documented disagreement rather than an oversight.\n */\n\nimport { readdirSync, readFileSync, statSync } from 'node:fs';\nimport path from 'node:path';\nimport { fail } from './lib/github-actions.ts';\nimport { isEntrypoint } from './lib/entrypoint.ts';\nimport { isSet, parseFlags, splitPositional, valueOf } from './lib/cli-args.ts';\nimport { loadManifest } from '../manifest.ts';\n\n/**\n * A file past a size the guard reports on.\n */\nexport interface GodFileFinding {\n /**\n Path relative to the root the check ran against.\n */\n readonly file: string;\n /**\n Lines it has.\n */\n readonly lines: number;\n /**\n `warn` past the soft limit, `critical` past the hard one.\n */\n readonly level: 'warn' | 'critical';\n}\n\n/**\n * The outcome of one run.\n */\nexport interface GodFileReport {\n /**\n Files over a limit, worst first, minus the allowlisted.\n */\n readonly findings: readonly GodFileFinding[];\n /**\n How many files the walk measured.\n */\n readonly scanned: number;\n /**\n Allowlisted files that are over a limit — reported, never counted.\n */\n readonly allowlisted: readonly GodFileFinding[];\n /**\n * Whether the tree may be committed as it stands.\n *\n * `true` in warn-only mode, which is the default; a `critical` finding fails\n * only when the caller asked for the gate.\n */\n readonly passed: boolean;\n /**\n The message to print, either way.\n */\n readonly reported: string;\n}\n\n/**\n * What `checkGodFiles` accepts.\n */\nexport interface GodFileOptions {\n /**\n Directory to walk.\n */\n readonly root: string;\n /**\n * Repo-relative paths (or directory prefixes ending in `/`) exempt from the\n * report. Defaults to `god-files.allowlist.json` beside the caller's script\n * when that file exists — see `readAllowlist`.\n */\n readonly allowlist?: readonly string[];\n /**\n Soft limit, past which a file is reported as `warn`.\n */\n readonly soft?: number;\n /**\n Hard limit, past which a file is reported as `critical`.\n */\n readonly hard?: number;\n /**\n Make a `critical` finding fail the run.\n */\n readonly failOnHard?: boolean;\n}\n\n/**\nDefault soft limit, as every source repo uses.\n*/\nexport const SOFT_LIMIT = 300;\n/**\nDefault hard limit, as every source repo uses.\n*/\nexport const HARD_LIMIT = 400;\n\n/**\n * Directories the walker never enters.\n *\n * Build output and VCS state; `coverage` is here because a generated HTML report\n * is thousands of \"lines\" of nothing.\n */\nconst EXCLUDE_DIRS = new Set(['node_modules', 'dist', '.wrangler', 'coverage', 'coverage-integration', 'coverage-web', '.git']);\n\n/**\n * Source extensions the guard counts.\n *\n * `css` is in the set because every source repo counts it, and a 400-line\n * stylesheet is the same reading problem as a 400-line module.\n */\nconst SOURCE_EXTENSIONS = /\\.(?:ts|tsx|js|mjs|cjs|css)$/;\n\n/**\n * The test-file suffixes the guard skips.\n *\n * `.test.tsx` matter as much as `.test.ts`: the walker collects both, so a list\n * that only named the `.ts` forms let every React test file through the guard and\n * reported them as god files — which is how Durable-DAV-Router discovered it.\n * Built from the kinds and extensions rather than enumerated, so a new test\n * extension cannot silently escape.\n */\nconst TEST_SUFFIXES: readonly string[] = ['test', 'spec'].flatMap((kind) =>\n ['.ts', '.tsx', '.js', '.jsx', '.mjs', '.cjs'].map((ext) => `.${kind}${ext}`),\n);\n\n/**\n * Whether a repo-relative path is exempt from the guard.\n *\n * Provenance: AWS-AccessBridge's version is the canonical one, because it\n * documents and fixes two live bugs in the others.\n *\n * Every directory pattern is anchored with `(?:^|/)` rather than a bare leading\n * `/`. `relative()` yields `test/helpers/x.ts` for a top-level test directory and\n * `scripts/lib/x.ts` for the scripts directory — **no leading separator** — so a\n * pattern written as `/\\/(?:test|tests|__tests__)\\//` never matches either one.\n * It looks right, it does match when handed an absolute path, and against these\n * layouts it is silently a no-op. Durable-DAV and ChordDHT-Tracker ship exactly\n * that dead pattern.\n */\nexport function shouldSkip(rel: string): boolean {\n if (\n /(?:^|\\/)(?:locales|generated)\\//.test(rel) ||\n /(?:^|\\/)__(?:tests|mocks)__(?:\\/|$)/.test(rel) ||\n /(?:^|\\/)scripts\\//.test(rel) ||\n /(?:^|\\/)(?:test|tests|__tests__)\\//.test(rel) ||\n /\\.config\\.(?:m?[jt]s|cjs)$/.test(rel) ||\n rel.endsWith('.d.ts') ||\n rel.endsWith('.json') ||\n rel.endsWith('.sql') ||\n rel.endsWith('.md')\n )\n return true;\n return TEST_SUFFIXES.some((suffix) => rel.endsWith(suffix));\n}\n\n/**\n * Whether a repo-relative path is on the allowlist.\n *\n * An entry ending in `/` exempts a whole directory; any other entry is matched\n * exactly, so `apps/api/src/index.ts` does not exempt `apps/api/src/index.util.ts`.\n */\nexport function isAllowlisted(rel: string, allowlist: readonly string[]): boolean {\n return allowlist.some((entry) => (entry.endsWith('/') ? rel.startsWith(entry) : rel === entry));\n}\n\n/**\n * Every source file under `root`, as repo-relative paths.\n *\n * Symlink-safe: a dangling symlink or a file removed mid-walk is skipped rather\n * than thrown, because neither is a god-file problem.\n */\nexport function walk(root: string): string[] {\n const out: string[] = [];\n const visit = (dir: string): void => {\n for (const entry of readdirSync(dir)) {\n const full = path.join(dir, entry);\n let stat;\n try {\n stat = statSync(full);\n } catch {\n continue;\n }\n if (stat.isDirectory()) {\n if (EXCLUDE_DIRS.has(entry)) continue;\n visit(full);\n } else if (SOURCE_EXTENSIONS.test(entry)) {\n out.push(path.relative(root, full));\n }\n }\n };\n visit(root);\n return out;\n}\n\n/**\n * Run the guard over a tree.\n *\n * Pure with respect to the verdict — the only I/O is the walk and a line count —\n * so a test drives it against a temporary directory.\n */\nexport function checkGodFiles(options: GodFileOptions): GodFileReport {\n const soft = options.soft ?? SOFT_LIMIT;\n const hard = options.hard ?? HARD_LIMIT;\n const allowlist = options.allowlist ?? [];\n\n const scanned = walk(options.root).filter((rel) => !shouldSkip(rel));\n const findings: GodFileFinding[] = [];\n const allowlisted: GodFileFinding[] = [];\n\n for (const rel of scanned) {\n const lines = readFileSync(path.join(options.root, rel), 'utf8').split('\\n').length;\n if (lines <= soft) continue;\n const finding: GodFileFinding = { file: rel, lines, level: lines > hard ? 'critical' : 'warn' };\n if (isAllowlisted(rel, allowlist)) {\n allowlisted.push(finding);\n } else {\n findings.push(finding);\n }\n }\n\n findings.sort((left, right) => right.lines - left.lines);\n allowlisted.sort((left, right) => right.lines - left.lines);\n\n const critical = findings.filter((finding) => finding.level === 'critical');\n const passed = options.failOnHard !== true || critical.length === 0;\n\n const reported = passed\n ? `God-file check passed (${scanned.length} files, ${findings.length} over soft limit ${soft}, ${allowlisted.length} allowlisted).`\n : `God-file check failed: ${critical.length} file(s) exceed ${hard} LOC. Split them, or add them to the allowlist in the same commit that grows them.`;\n\n return { findings, allowlisted, scanned: scanned.length, passed, reported };\n}\n\n/**\n * Read an allowlist file, or `[]` when it is absent.\n *\n * The file is `scripts/god-files.allowlist.json`: a JSON array of repo-relative\n * paths. Absence is the normal case for a repo with no known offenders, so it is\n * not an error — a guard that fails on a first run nobody has filled in yet is a\n * guard that gets disabled.\n *\n * A malformed file is an error rather than an empty list, because \"the allowlist\n * is empty\" silently un-reports every known offender.\n */\nexport function readAllowlist(file: string): string[] {\n let raw: string;\n try {\n raw = readFileSync(file, 'utf8');\n } catch {\n return [];\n }\n let parsed: unknown;\n try {\n parsed = JSON.parse(raw);\n } catch (error: unknown) {\n throw new Error(`${file} is not valid JSON: ${error instanceof Error ? error.message : String(error)}`, { cause: error });\n }\n if (!Array.isArray(parsed) || parsed.some((entry) => typeof entry !== 'string')) {\n throw new Error(`${file} must be a JSON array of repo-relative path strings.`);\n }\n return parsed as string[];\n}\n\n/**\n * CLI entry: `checkGodFilesCli(['.', '--fail-on-hard'])`.\n *\n * The directory is a positional argument **or** `--root <dir>`, because every other\n * script in this tree takes its target positionally and a gate that has to be\n * invoked one way in one script and another way in the next is a gate somebody\n * invokes wrong. A second positional is an error.\n *\n * Flags (see FlagSpec): `--root <dir>` (default `.`), `--allowlist <file>`\n * (default `scripts/god-files.allowlist.json` beside the root, absent = none),\n * `--fail-on-hard` (default off, matching every source repo's warn-only gate).\n * Returns 0 unless `--fail-on-hard` is set and a critical file is found.\n */\nexport function checkGodFilesCli(argv: readonly string[] = process.argv.slice(2)): number {\n // Split before parsing, because parseFlags rejects anything that is not a declared\n // flag and a positional directory is neither a mistake nor a flag.\n const { positional, rest } = splitPositional(argv, ['root', 'allowlist']);\n const flags = parseFlags(rest, {\n value: ['root', 'allowlist'],\n boolean: ['fail-on-hard'],\n });\n const root = valueOf(flags, 'root') ?? positional[0] ?? '.';\n const allowlistPath = valueOf(flags, 'allowlist') ?? path.join(root, 'scripts/god-files.allowlist.json');\n const report = checkGodFiles({\n root,\n allowlist: readAllowlist(allowlistPath),\n // A manifest may only lower the family limits (the validator refuses more).\n ...loadManifest(root)?.quality?.godFiles,\n failOnHard: isSet(flags, 'fail-on-hard'),\n });\n console.log(report.reported);\n for (const finding of report.findings) {\n console.log(`${finding.level === 'critical' ? 'CRITICAL' : 'WARN'} ${finding.lines} ${finding.file}`);\n }\n for (const finding of report.allowlisted) {\n console.log(`ALLOWLISTED ${finding.lines} ${finding.file}`);\n }\n if (!report.passed) {\n fail(`God-file check failed: run with --root ${root} to see the report.`);\n }\n return 0;\n}\n\n// Run only when this file is the entrypoint.\n//\n// The rules above are pure and the tests import them directly, so a module-level\n// call would shell out (and exit) during a test run. The URL comparison rather than\n// an unconditional call is the same guard Durable-DAV's init-secrets.ts uses, and\n// it is what keeps the rule modules importable — which is the whole reason they are\n// separate modules in the first place.\nif (isEntrypoint(import.meta.url)) {\n process.exit(checkGodFilesCli(process.argv.slice(2)));\n}\n"],
|
|
5
|
+
"mappings": "+EAgDA,OAAS,eAAAA,EAAa,gBAAAC,EAAc,YAAAC,MAAgB,UACpD,OAAOC,MAAU,YACjB,OAAS,QAAAC,MAAY,0BACrB,OAAS,gBAAAC,MAAoB,sBAC7B,OAAS,SAAAC,EAAO,cAAAC,EAAY,mBAAAC,EAAiB,WAAAC,MAAe,oBAC5D,OAAS,gBAAAC,MAAoB,iBAgFtB,MAAMC,EAAa,IAIbC,EAAa,IAQpBC,EAAe,IAAI,IAAI,CAAC,eAAgB,OAAQ,YAAa,WAAY,uBAAwB,eAAgB,MAAM,CAAC,EAQxHC,EAAoB,+BAWpBC,EAAmC,CAAC,OAAQ,MAAM,EAAE,QAASC,GACjE,CAAC,MAAO,OAAQ,MAAO,OAAQ,OAAQ,MAAM,EAAE,IAAKC,GAAQ,IAAID,CAAI,GAAGC,CAAG,EAAE,CAAC,EAiBzE,SAAUC,EAAWC,EAAW,CACpC,MACE,kCAAkC,KAAKA,CAAG,GAC1C,sCAAsC,KAAKA,CAAG,GAC9C,oBAAoB,KAAKA,CAAG,GAC5B,qCAAqC,KAAKA,CAAG,GAC7C,6BAA6B,KAAKA,CAAG,GACrCA,EAAI,SAAS,OAAO,GACpBA,EAAI,SAAS,OAAO,GACpBA,EAAI,S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CAG9E,KAAM,CAAE,WAAAC,EAAY,KAAAC,CAAI,EAAK9C,EAAgB4C,EAAM,CAAC,OAAQ,WAAW,CAAC,EAClEG,EAAQhD,EAAW+C,EAAM,CAC7B,MAAO,CAAC,OAAQ,WAAW,EAC3B,QAAS,CAAC,cAAc,EACzB,EACK5B,EAAOjB,EAAQ8C,EAAO,MAAM,GAAKF,EAAW,CAAC,GAAK,IAClDG,EAAgB/C,EAAQ8C,EAAO,WAAW,GAAKpD,EAAK,KAAKuB,EAAM,kCAAkC,EACjG+B,EAASzB,EAAc,CAC3B,KAAAN,EACA,UAAWoB,EAAcU,CAAa,EAEtC,GAAG9C,EAAagB,CAAI,GAAG,SAAS,SAChC,WAAYpB,EAAMiD,EAAO,cAAc,EACxC,EACD,QAAQ,IAAIE,EAAO,QAAQ,EAC3B,UAAWjB,KAAWiB,EAAO,SAC3B,QAAQ,IAAI,GAAGjB,EAAQ,QAAU,WAAa,WAAa,MAAM,IAAIA,EAAQ,KAAK,IAAIA,EAAQ,IAAI,EAAE,EAEtG,UAAWA,KAAWiB,EAAO,YAC3B,QAAQ,IAAI,eAAejB,EAAQ,KAAK,IAAIA,EAAQ,IAAI,EAAE,EAE5D,OAAKiB,EAAO,QACVrD,EAAK,0CAA0CsB,CAAI,qBAAqB,EAEnE,CACT,CA5BgBL,EAAA8B,EAAA,oBAqCZ9C,EAAa,YAAY,GAAG,GAC9B,QAAQ,KAAK8C,EAAiB,QAAQ,KAAK,MAAM,CAAC,CAAC,CAAC",
|
|
6
|
+
"names": ["readdirSync", "readFileSync", "statSync", "path", "fail", "isEntrypoint", "isSet", "parseFlags", "splitPositional", "valueOf", "loadManifest", "SOFT_LIMIT", "HARD_LIMIT", "EXCLUDE_DIRS", "SOURCE_EXTENSIONS", "TEST_SUFFIXES", "kind", "ext", "shouldSkip", "rel", "suffix", "__name", "isAllowlisted", "allowlist", "entry", "walk", "root", "out", "visit", "dir", "full", "stat", "checkGodFiles", "options", "soft", "hard", "scanned", "findings", "allowlisted", "lines", "finding", "left", "right", "critical", "passed", "reported", "readAllowlist", "file", "raw", "parsed", "error", "checkGodFilesCli", "argv", "positional", "rest", "flags", "allowlistPath", "report"]
|
|
7
7
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ensure-spa-shell-stub.d.ts","sourceRoot":"","sources":["../../src/scripts/ensure-spa-shell-stub.ts"],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"ensure-spa-shell-stub.d.ts","sourceRoot":"","sources":["../../src/scripts/ensure-spa-shell-stub.ts"],"names":[],"mappings":"AAwBA;;GAEG;AACH,wBAAgB,IAAI,CAAC,IAAI,GAAE,SAAS,MAAM,EAA0B,GAAG,MAAM,CAU5E"}
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import e from"node:path";import{fileURLToPath as t}from"node:url";import{ensureSpaShellStub as s}from"./spa-shell.js";const o=e.resolve(e.dirname(t(import.meta.url)),".."),a=process.argv[2]===void 0?o:e.resolve(process.argv[2]),r=s({root:a});console.log(r.created?`ensure-spa-shell-stub: created stub at ${r.path}`:`ensure-spa-shell-stub: ${r.path} already present, left untouched`);
|
|
1
|
+
var p=Object.defineProperty;var s=(e,t)=>p(e,"name",{value:t,configurable:!0});import o from"node:path";import{fileURLToPath as i}from"node:url";import{isEntrypoint as l}from"./lib/entrypoint.js";import{ensureSpaShellStub as a}from"./spa-shell.js";function u(e=process.argv.slice(2)){const t=o.resolve(o.dirname(i(import.meta.url)),".."),n=e[0]===void 0?t:o.resolve(e[0]),r=a({root:n});return console.log(r.created?`ensure-spa-shell-stub: created stub at ${r.path}`:`ensure-spa-shell-stub: ${r.path} already present, left untouched`),0}s(u,"main"),l(import.meta.url)&&process.exit(u());export{u as main};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/scripts/ensure-spa-shell-stub.ts"],
|
|
4
|
-
"sourcesContent": ["
|
|
5
|
-
"mappings": "
|
|
6
|
-
"names": ["path", "fileURLToPath", "ensureSpaShellStub", "
|
|
4
|
+
"sourcesContent": ["/**\n * Write a placeholder `apps/api/src/generated/spa-shell.ts` when it is absent.\n *\n * Provenance: Durable-DAV's `scripts/ensure-spa-shell-stub.mjs` and Edge-Sonic's\n * `scripts/build/ensure-spa-shell-stub.ts`. The rule lives in `spa-shell.ts`; this\n * is the entrypoint that runs it from `postinstall`.\n *\n * `pnpm install` runs this before `typegen` so the API worker typechecks in a\n * fresh clone, where the real file has not been produced by the Vite build yet.\n * It exits having done nothing when the file already exists, so a real build\n * output is never overwritten — overwriting would erase the last build with a\n * stub on the next install. The file is gitignored.\n *\n * Usage, from the repo root (typically wired as `postinstall`):\n *\n * ```bash\n * pnpm exec tsx scripts/ensure-spa-shell-stub.ts [repo-root]\n * ```\n */\nimport path from 'node:path';\nimport { fileURLToPath } from 'node:url';\nimport { isEntrypoint } from './lib/entrypoint.ts';\nimport { ensureSpaShellStub } from './spa-shell.ts';\n\n/**\n * Run the stub writer. `args[0]` is the repo root (default: the repo this file sits in).\n */\nexport function main(args: readonly string[] = process.argv.slice(2)): number {\n const repositoryRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');\n const root = args[0] === undefined ? repositoryRoot : path.resolve(args[0]);\n const result = ensureSpaShellStub({ root });\n console.log(\n result.created\n ? `ensure-spa-shell-stub: created stub at ${result.path}`\n : `ensure-spa-shell-stub: ${result.path} already present, left untouched`,\n );\n return 0;\n}\n\nif (isEntrypoint(import.meta.url)) {\n process.exit(main());\n}\n"],
|
|
5
|
+
"mappings": "+EAmBA,OAAOA,MAAU,YACjB,OAAS,iBAAAC,MAAqB,WAC9B,OAAS,gBAAAC,MAAoB,sBAC7B,OAAS,sBAAAC,MAA0B,iBAK7B,SAAUC,EAAKC,EAA0B,QAAQ,KAAK,MAAM,CAAC,EAAC,CAClE,MAAMC,EAAiBN,EAAK,QAAQA,EAAK,QAAQC,EAAc,YAAY,GAAG,CAAC,EAAG,IAAI,EAChFM,EAAOF,EAAK,CAAC,IAAM,OAAYC,EAAiBN,EAAK,QAAQK,EAAK,CAAC,CAAC,EACpEG,EAASL,EAAmB,CAAE,KAAAI,CAAI,CAAE,EAC1C,eAAQ,IACNC,EAAO,QACH,0CAA0CA,EAAO,IAAI,GACrD,0BAA0BA,EAAO,IAAI,kCAAkC,EAEtE,CACT,CAVgBC,EAAAL,EAAA,QAYZF,EAAa,YAAY,GAAG,GAC9B,QAAQ,KAAKE,EAAI,CAAE",
|
|
6
|
+
"names": ["path", "fileURLToPath", "isEntrypoint", "ensureSpaShellStub", "main", "args", "repositoryRoot", "root", "result", "__name"]
|
|
7
7
|
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
#!/usr/bin/env tsx
|
|
2
1
|
/**
|
|
3
2
|
* Create the Secrets Store entries declared in `wrangler.jsonc`, generating a fresh
|
|
4
3
|
* value for each one that does not exist yet.
|
|
@@ -43,5 +42,5 @@
|
|
|
43
42
|
* config is missing, because a step reporting "Secret initialization complete"
|
|
44
43
|
* having created nothing is worse than a named error.
|
|
45
44
|
*/
|
|
46
|
-
export
|
|
45
|
+
export declare function main(): Promise<void>;
|
|
47
46
|
//# sourceMappingURL=init-secrets.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"init-secrets.d.ts","sourceRoot":"","sources":["../../src/scripts/init-secrets.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"init-secrets.d.ts","sourceRoot":"","sources":["../../src/scripts/init-secrets.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;AA6LH,wBAAsB,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CA8B1C"}
|