@webpieces/rules-config 0.4.847 → 0.4.848
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/package.json +10 -7
- package/src/WebpiecesRulesConfig.d.ts +1 -2
- package/src/WebpiecesRulesConfig.js +0 -1
- package/src/WebpiecesRulesConfig.js.map +1 -1
- package/src/client-module-resolution.d.ts +9 -0
- package/src/client-module-resolution.js +102 -0
- package/src/client-module-resolution.js.map +1 -0
- package/src/config-error-banner.d.ts +0 -2
- package/src/config-error-banner.js +1 -3
- package/src/config-error-banner.js.map +1 -1
- package/src/config-file.d.ts +3 -6
- package/src/config-file.js +14 -1
- package/src/config-file.js.map +1 -1
- package/src/config-key-rules.js +16 -5
- package/src/config-key-rules.js.map +1 -1
- package/src/config-pruner.d.ts +5 -42
- package/src/config-pruner.js +31 -76
- package/src/config-pruner.js.map +1 -1
- package/src/config-repair-access.d.ts +4 -0
- package/src/config-repair-access.js +17 -0
- package/src/config-repair-access.js.map +1 -0
- package/src/config-repair-bootstrap-source.d.ts +2 -0
- package/src/config-repair-bootstrap-source.js +7 -0
- package/src/config-repair-bootstrap-source.js.map +1 -0
- package/src/config-repair-probe.d.ts +13 -0
- package/src/config-repair-probe.js +115 -0
- package/src/config-repair-probe.js.map +1 -0
- package/src/first-path-match.d.ts +14 -0
- package/src/first-path-match.js +35 -0
- package/src/first-path-match.js.map +1 -0
- package/src/index.d.ts +15 -8
- package/src/index.js +40 -10
- package/src/index.js.map +1 -1
- package/src/legacy-config-upgrade.d.ts +22 -0
- package/src/legacy-config-upgrade.js +328 -0
- package/src/legacy-config-upgrade.js.map +1 -0
- package/src/load-config.d.ts +11 -23
- package/src/load-config.js +50 -138
- package/src/load-config.js.map +1 -1
- package/src/pack-policy-files.d.ts +29 -0
- package/src/pack-policy-files.js +194 -0
- package/src/pack-policy-files.js.map +1 -0
- package/src/policy-field-constraints.d.ts +9 -0
- package/src/policy-field-constraints.js +31 -0
- package/src/policy-field-constraints.js.map +1 -0
- package/src/repository-path.d.ts +7 -0
- package/src/repository-path.js +50 -0
- package/src/repository-path.js.map +1 -0
- package/src/rule-pack-artifacts.d.ts +23 -0
- package/src/rule-pack-artifacts.js +180 -0
- package/src/rule-pack-artifacts.js.map +1 -0
- package/src/rule-pack-registry.d.ts +7 -0
- package/src/rule-pack-registry.js +149 -47
- package/src/rule-pack-registry.js.map +1 -1
- package/src/rule-pack-sync.d.ts +26 -0
- package/src/rule-pack-sync.js +236 -0
- package/src/rule-pack-sync.js.map +1 -0
- package/src/rule-runtime-modules.d.ts +27 -0
- package/src/rule-runtime-modules.js +135 -0
- package/src/rule-runtime-modules.js.map +1 -0
- package/src/rules-sync-cli.d.ts +7 -0
- package/src/rules-sync-cli.js +48 -0
- package/src/rules-sync-cli.js.map +1 -0
- package/src/seed-entry.js +1 -3
- package/src/seed-entry.js.map +1 -1
- package/src/types.d.ts +4 -6
- package/src/types.js +4 -7
- package/src/types.js.map +1 -1
- package/src/validate-config.d.ts +3 -29
- package/src/validate-config.js +99 -244
- package/src/validate-config.js.map +1 -1
- package/src/validate-pr-gate.d.ts +8 -0
- package/src/validate-pr-gate.js +161 -0
- package/src/validate-pr-gate.js.map +1 -0
- package/templates/webpieces.guard-matrix.md +5 -4
- package/src/rule-pack-selection.d.ts +0 -6
- package/src/rule-pack-selection.js +0 -50
- package/src/rule-pack-selection.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"legacy-config-upgrade.js","sourceRoot":"","sources":["../../../../../packages/tooling/rules-config/src/legacy-config-upgrade.ts"],"names":[],"mappings":";;;AA+QA,oDAiEC;AA9UD,uDAAmE;AACnE,iDAAkD;AAClD,yCAAyD;AACzD,6DAA2D;AAC3D,qDAAyD;AACzD,+DAA2D;AAE3D,oFAAoF;AACpF,MAAM,iBAAiB,GAAG,yBAAyB,CAAC;AACpD,MAAM,sBAAsB,GAAG,0BAA0B,CAAC;AAS1D,MAAa,oBAAoB;IAKhB;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AG,KAAK,CAAC,IAAI,CAAC,CAAC;YAC/B,OAAO,KAAK,CAAC,IAAI,CAAC,CAAC;YACnB,OAAO,CAAC,IAAI,CAAC,UAAU,IAAI,2BAA2B,CAAC,CAAC;QAC5D,CAAC;IACL,CAAC;IACD,mEAAmE;IACnE,KAAK,MAAM,IAAI,IAAI,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE,CAAC;QACzC,IAAI,CAAC,IAAA,sBAAW,EAAC,IAAI,EAAE,QAAQ,CAAC,IAAI,IAAA,8BAAY,EAAC,QAAQ,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;YACxE,KAAK,CAAC,IAAI,CAAC,GAAG,UAAU,CAAC,IAAI,CAAC,CAAC;YAC/B,OAAO,UAAU,CAAC,IAAI,CAAC,CAAC;YACxB,OAAO,CAAC,IAAI,CAAC,UAAU,IAAI,2BAA2B,CAAC,CAAC;QAC5D,CAAC;IACL,CAAC;AACL,CAAC;AAED,kFAAkF;AAClF,SAAS,iBAAiB,CAAC,QAAc,EAAE,OAAiB;IACxD,mGAAmG;IACnG,2EAA2E;IAC3E,IAAI,UAAkB,CAAC;IACvB,IAAI,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAC,CAAC,EAAE,CAAC;QACzC,UAAU,GAAG,QAAQ,CAAC,aAAa,CAAW,CAAC;IACnD,CAAC;SAAM,CAAC;QACJ,UAAU,GAAG,cAAc,EAAE,CAAC;QAC9B,OAAO,CAAC,IAAI,CAAC,sDAAsD,CAAC,CAAC;IACzE,CAAC;IAED,OAAO,UAAU,CAAC;AACtB,CAAC","sourcesContent":["/** Previous-root conversion is reachable only through an explicit upgrade command; normal loading never calls it. */\nimport { RulePackRegistry } from './rule-pack-registry';\nimport { allRuleNames, seedEntryForRule } from './validate-config';\nimport { schemaFieldNames } from './rule-schemas';\nimport { sectionForRule, isHookGuard } from './sections';\nimport { DEFAULT_MATCH_RULES } from './match-rules-config';\nimport { DEFAULT_BUILD_COMMAND } from './pr-gate-config';\nimport { RETIRED_SCOPE_RULE } from './retired-config-keys';\n\n// Explicit upgrade applies owner-declared retirements and writes reviewed settings.\nconst DEFAULT_UPSERT_PR = 'pnpm wp-start-upsert-pr';\nconst DEFAULT_MERGE_COMPLETE = 'pnpm wp-finish-upsert-pr';\n// ---------------------------------------------------------------------------\n// webpieces.config.json seeding + migration to the rules / hookGuards / commands layout.\n// ---------------------------------------------------------------------------\n// webpieces-disable no-any-unknown -- webpieces.config.json / settings.json are opaque consumer JSON\ntype Json = Record<string, unknown>;\ntype RuleEntry = Json;\ntype Section = Record<string, RuleEntry>;\n\nexport class LegacyConfigDocument {\n readonly 'match-rules': Json[];\n readonly extends: string | undefined;\n // eslint-disable-next-line @typescript-eslint/max-params\n constructor(\n readonly rules: Section,\n readonly hookGuards: Section,\n readonly commands: Json,\n readonly excludePaths: string[],\n matches: Json[],\n readonly rulesDir: string[],\n inheritedFrom: string | undefined,\n ) {\n this['match-rules'] = matches;\n this.extends = inheritedFrom;\n }\n}\n\nexport class LegacyUpgradeResult {\n constructor(\n readonly config: LegacyConfigDocument,\n readonly changes: string[],\n ) {}\n}\n\n// webpieces-disable no-function-outside-class -- sibling of the other seed* helpers; this module is config-shape builders by design\nfunction seedRule(ruleName: string, registry: RulePackRegistry): RuleEntry {\n // Both escape hatches are seeded (and REQUIRED) so every rule block shows them: 0 = active,\n // null = no branch scoping. A human/AI edits these to time-box or branch-scope a rule off.\n //\n // The ENTIRE entry comes from rules-config's seedEntryForRule() — the same module that owns the\n // schema the loader validates against, so the installer can never emit an entry the loader\n // rejects. It supplies: the recommended mode (the SAME recommendation the validator prints in its\n // copy-paste snippet, so seed and advice cannot disagree), both hatches, and a default for every\n // other schema-REQUIRED field. Seeding used to be a flat 'OFF' plus the two hatches, which was\n // wrong twice over: adopters got nothing enforced, AND the entry was missing required fields\n // (e.g. branch-creation-guard.autoReapMergedBranches), so the config failed to load on first run.\n return seedEntryForRule(ruleName, registry);\n}\n\n// The guard-hint command strings live under `guardHints`. The flat `upsertPr`/`mergeComplete` keys this\n// used to seed are RETIRED and now fail validation — seeding them meant every freshly installed repo was\n// born on a shape the validator rejects.\n\n// Required excludePaths block: ONE glob list suppressing hook enforcement per file path. Seeded empty\n// (enforce everywhere) — a client adds paths (e.g. \"repositories/**\") to exempt vendored trees.\n//\n// Deliberately NOT seeded with webpieces' own `.webpieces/` state dir. That exemption lives in CODE\n// (`isWebpiecesStateDir`, consulted by `filterByExcludedPaths` ahead of this list and regardless of it),\n// and a glob here would be a second, weaker spelling of it — weaker because `.webpieces/**` compiles to\n// an anchored regex that misses the bare directory the predicate matches, and because a config entry\n// invites a consumer to delete it and believe the exemption went with it.\n\n// Bring an existing `excludePaths` forward to the single-list shape. Already a list → untouched.\n// Legacy `{ rules, guards }` → unioned (order preserved, duplicates dropped) and recorded as a change\n// so `pnpm wp-rules-sync --upgrade` is the migration path rather than a hand-edit. Anything else → seeded [].\n// webpieces-disable no-any-unknown -- opaque legacy JSON is narrowed before use\n// webpieces-disable no-function-outside-class -- pure legacy config conversion helper\nfunction migrateExcludePaths(raw: unknown, changes: string[]): string[] {\n if (Array.isArray(raw)) return (raw as string[]).filter((p: string) => typeof p === 'string');\n if (typeof raw === 'object' && raw !== null) {\n // webpieces-disable no-any-unknown -- narrowing the opaque legacy block from consumer JSON\n const legacy = raw as Record<string, unknown>;\n const rules = Array.isArray(legacy['rules']) ? (legacy['rules'] as string[]) : [];\n const guards = Array.isArray(legacy['guards']) ? (legacy['guards'] as string[]) : [];\n const merged = [\n ...new Set([...rules, ...guards].filter((p: string) => typeof p === 'string')),\n ];\n changes.push(`migrated excludePaths {rules,guards} -> one list (${merged.length} path(s))`);\n return merged;\n }\n changes.push('added excludePaths ([])');\n return [];\n}\n\n/** One retired flat command string and the guardHints field it becomes. Data-only (per CLAUDE.md). */\nclass GuardHintMove {\n retiredKey: string;\n hintKey: string;\n fallback: string;\n\n constructor(retiredKey: string, hintKey: string, fallback: string) {\n this.retiredKey = retiredKey;\n this.hintKey = hintKey;\n this.fallback = fallback;\n }\n}\n\n/**\n * Bring `commands` forward to the `guardHints` shape, moving the RETIRED flat `upsertPr`/`mergeComplete`\n * strings and DELETING them. Deleting is the point: the validator now rejects them, so leaving them behind\n * would keep the config failing after a \"successful\" sync.\n *\n * The consumer's own value wins over the default — a repo that renamed its gated command keeps that name.\n */\n// webpieces-disable no-function-outside-class -- sibling of the other seed*/migrate* helpers; this module is config-shape builders by design\nfunction migrateGuardHints(commands: Json, changes: string[]): void {\n const hints: Json =\n typeof commands['guardHints'] === 'object' && commands['guardHints'] !== null\n ? (commands['guardHints'] as Json)\n : {};\n const moves: readonly GuardHintMove[] = [\n new GuardHintMove('upsertPr', 'prCreationOrPush', DEFAULT_UPSERT_PR),\n new GuardHintMove('mergeComplete', 'mergeInProgress', DEFAULT_MERGE_COMPLETE),\n ];\n for (const move of moves) {\n const retiredKey = move.retiredKey;\n const hintKey = move.hintKey;\n const fallback = move.fallback;\n const carried = commands[retiredKey];\n if (carried !== undefined) {\n delete commands[retiredKey];\n if (hints[hintKey] === undefined) hints[hintKey] = carried;\n changes.push(`moved retired commands.${retiredKey} -> commands.guardHints.${hintKey}`);\n }\n if (hints[hintKey] === undefined) {\n hints[hintKey] = fallback;\n changes.push(`added commands.guardHints.${hintKey}`);\n }\n }\n commands['guardHints'] = hints;\n}\n\n/**\n * Apply the RETIRED rule/guard retirements in place. These used to be rewritten silently at load time, so\n * a consumer's file kept the dead name forever; the loader now rejects it, which makes this the one\n * command that can fix the file. Skips a rename when the new name is already configured, so an explicit\n * entry is never clobbered by a stale one.\n *\n * NOT EVERY RETIREMENT IS A RENAME, and treating them all as one produced garbage. `whole-repo-build-guard`\n * moved OUT of webpieces.config.json entirely — its `movedTo` is the PROSE destination\n * `~/.webpieces/config.json → experimental.whole-repo-build-guard`, not a sibling key — so the rename\n * branch below would have created a hookGuards entry literally named that whole sentence, which no\n * validator knows and which the next run reports as another unknown rule. `prunable` is the discriminator:\n * when the entry says deleting is the whole fix, DELETE it, exactly as `ConfigPruner` does.\n */\n// webpieces-disable no-function-outside-class -- sibling of the other seed*/migrate* helpers; this module is config-shape builders by design\nfunction migrateRetiredRuleNames(\n section: Section,\n changes: string[],\n registry: RulePackRegistry,\n): void {\n for (const entry of registry.migrations()) {\n if (entry.scope !== RETIRED_SCOPE_RULE) continue;\n if (!(entry.key in section)) continue;\n if (entry.prunable) {\n delete section[entry.key];\n changes.push(`deleted retired \"${entry.key}\" (it moved to ${entry.movedTo})`);\n continue;\n }\n mergeIntoDestination(section, entry.key, entry.movedTo, changes, registry);\n }\n fillRequiredFields(section, changes, registry);\n}\n\n/**\n * Fold one retired key's entry into its destination, whether the destination exists yet or not.\n *\n * THIS IS N→1, NOT 1:1, and the difference is the whole reason this helper exists. Four retired keys\n * now point at ONE destination (`branch-state-guard`, `pr-lifecycle-guard`). The previous code renamed\n * the first key it met and then, finding the destination already present, DELETED each of the other\n * three outright — so which guard's settings survived depended on RETIRED_CONFIG_KEYS declaration\n * order rather than on the consumer's file, and the survivor carried only that one guard's fields, so\n * it was missing required fields of the merged schema. `pnpm wp-rules-sync --upgrade` is the command advertised\n * as the migration path; half-migrating every consumer into an invalid config is not an option.\n *\n * UNION, first writer wins per field. Earlier-declared keys are the more specific ones (only\n * feature-branch-guard carries `branchNamingConvention`), and a field already present on the\n * destination — because the consumer wrote it, or an earlier key contributed it — is never overwritten.\n * Fields the merged schema does not know are dropped by the same pass, since carrying a deleted field\n * across (`upsertPrCommand`) would produce a config the validator immediately rejects.\n */\n// webpieces-disable no-function-outside-class -- sibling of the other seed*/migrate* helpers; this module is config-shape builders by design\nfunction mergeIntoDestination(\n section: Section,\n key: string,\n destination: string,\n changes: string[],\n registry: RulePackRegistry,\n): void {\n const source = asSection(section[key]);\n delete section[key];\n const fields = schemaFieldNames(destination, registry);\n const target = asSection(section[destination]);\n const existed = destination in section;\n const carried: string[] = [];\n const dropped: string[] = [];\n for (const field of Object.keys(source)) {\n if (fields !== null && !fields.includes(field)) {\n dropped.push(field);\n continue;\n }\n if (field in target) continue;\n target[field] = source[field];\n carried.push(field);\n }\n section[destination] = target;\n const verb = existed ? 'merged' : 'renamed';\n const droppedNote =\n dropped.length > 0 ? `; dropped deleted field(s) ${dropped.join(', ')}` : '';\n changes.push(\n `${verb} retired \"${key}\" -> \"${destination}\" (carried ${carried.join(', ') || 'nothing new'}${droppedNote})`,\n );\n}\n\n/**\n * Fill any schema-REQUIRED field a migrated entry ended up without.\n *\n * A union of four partial entries is not guaranteed to satisfy the destination's schema — the merged\n * `branch-state-guard` needs `mode` and both escape hatches, and a consumer whose four old entries\n * predate one of them would land short. Seeding the gap from the SAME source the installer and the\n * validator use (seedEntryForRule) is what makes the install command a complete instruction\n * rather than a first step. Only ever ADDS; a value the consumer stated is never touched.\n */\n// webpieces-disable no-function-outside-class -- sibling of the other seed*/migrate* helpers; this module is config-shape builders by design\nfunction fillRequiredFields(section: Section, changes: string[], registry: RulePackRegistry): void {\n for (const name of Object.keys(section)) {\n if (schemaFieldNames(name, registry) === null) continue;\n // A rule ENTRY is a flat bag of scalars, so it is read as Json here rather than through\n // asSection (whose values are whole entries). Same object either way; only the view differs.\n const entry: Json = asSection(section[name]);\n const seed = seedEntryForRule(name, registry);\n const added: string[] = [];\n for (const field of Object.keys(seed)) {\n if (field in entry) continue;\n entry[field] = seed[field];\n added.push(field);\n }\n if (added.length === 0) continue;\n section[name] = entry;\n changes.push(`filled required field(s) on \"${name}\": ${added.join(', ')}`);\n }\n}\n\n// Deep-copy the framework's default match-rules (the no-fetch guard) into plain JSON for the config\n// file. Round-tripping through JSON turns the MatchRuleConfig instances into plain objects.\n// webpieces-disable no-function-outside-class -- this module is deliberately DI-FREE: `pnpm wp-rules-sync --upgrade` must run on a half-written node_modules (see install-entry.ts), so it cannot build a container to hold a method\nfunction seedMatchRules(): Json[] {\n return JSON.parse(JSON.stringify(DEFAULT_MATCH_RULES)) as Json[];\n}\n\n// webpieces-disable no-function-outside-class -- this module is deliberately DI-FREE: `pnpm wp-rules-sync --upgrade` must run on a half-written node_modules (see install-entry.ts), so it cannot build a container to hold a method\nfunction asSection(value: Json[string]): Section {\n return typeof value === 'object' && value !== null && !Array.isArray(value)\n ? (value as Section)\n : {};\n}\n\n// Migrate an existing config to the rules / hookGuards / commands layout and add any missing rules.\n// Returns a human-readable list of what changed (empty = already up to date).\n// webpieces-disable no-function-outside-class -- this module is deliberately DI-FREE: `pnpm wp-rules-sync --upgrade` must run on a half-written node_modules (see install-entry.ts), so it cannot build a container to hold a method\nexport function prepareLegacyUpgrade(\n existing: Json,\n registry: RulePackRegistry,\n): LegacyUpgradeResult {\n const changes: string[] = [];\n const rules: Section = asSection(existing['rules']);\n const hookGuards: Section = asSection(existing['hookGuards']);\n const commands: Json =\n typeof existing['commands'] === 'object' && existing['commands'] !== null\n ? (existing['commands'] as Json)\n : {};\n\n // Move a deprecated top-level pr-gate block under commands.\n if (existing['pr-gate'] !== undefined && commands['pr-gate'] === undefined) {\n commands['pr-gate'] = existing['pr-gate'];\n changes.push('moved top-level \"pr-gate\" → commands[\"pr-gate\"]');\n }\n // Apply retired RENAMES first, so a renamed guard is placed and presence-checked under its new name\n // rather than being treated as unknown and re-added alongside its own stale entry.\n migrateRetiredRuleNames(rules, changes, registry);\n migrateRetiredRuleNames(hookGuards, changes, registry);\n\n migratePolicySections(rules, hookGuards, changes, registry);\n // Add any missing built-in into its correct section, ENFORCING at its recommended mode (not OFF).\n for (const name of allRuleNames(registry)) {\n const target = sectionForRule(name, registry) === 'hookGuards' ? hookGuards : rules;\n if (!(name in target)) {\n const entry = seedRule(name, registry);\n target[name] = entry;\n changes.push(\n `added \"${name}\" (${String(entry['mode'])}) to ${sectionForRule(name, registry)}`,\n );\n }\n }\n // Fill command defaults.\n if (commands['pr-gate'] === undefined) {\n commands['pr-gate'] = { mode: 'OFF', buildCommand: DEFAULT_BUILD_COMMAND, gates: [] };\n changes.push('added commands[\"pr-gate\"] (OFF)');\n }\n migrateGuardHints(commands, changes);\n\n // Seed the now-required excludePaths list (empty = enforce everywhere) if the config predates it,\n // and MIGRATE the legacy `{ rules: [], guards: [] }` object to the single list by unioning them.\n // The union is behaviour-preserving for every config we have seen (both lists set identically), and\n // widening is the safe direction anyway: a path either side excluded stays excluded.\n const excludePaths: string[] = migrateExcludePaths(existing['excludePaths'], changes);\n\n const matchRules = upgradeMatchRules(existing, changes);\n\n const rulesDir: string[] = Array.isArray(existing['rulesDir'])\n ? (existing['rulesDir'] as string[])\n : [];\n const inherited = typeof existing['extends'] === 'string' ? existing['extends'] : undefined;\n return new LegacyUpgradeResult(\n new LegacyConfigDocument(\n rules,\n hookGuards,\n commands,\n excludePaths,\n matchRules,\n rulesDir,\n inherited,\n ),\n changes,\n );\n}\n\n// webpieces-disable no-function-outside-class -- explicit upgrade conversion remains independent of DI\nfunction migratePolicySections(rules: Section, hookGuards: Section, changes: string[], registry: RulePackRegistry): void {\n // Move guards mistakenly left in rules into hookGuards.\n for (const name of Object.keys(rules)) {\n if (isHookGuard(name, registry)) {\n hookGuards[name] = rules[name];\n delete rules[name];\n changes.push(`moved \"${name}\" from rules → hookGuards`);\n }\n }\n // Move code rules mistakenly placed in hookGuards back into rules.\n for (const name of Object.keys(hookGuards)) {\n if (!isHookGuard(name, registry) && allRuleNames(registry).includes(name)) {\n rules[name] = hookGuards[name];\n delete hookGuards[name];\n changes.push(`moved \"${name}\" from hookGuards → rules`);\n }\n }\n}\n\n// webpieces-disable no-function-outside-class -- pure explicit-upgrade conversion\nfunction upgradeMatchRules(existing: Json, changes: string[]): Json[] {\n // Seed the now-required match-rules array (with the default no-fetch guard) if the config predates\n // it. A client that has already customized it keeps their array untouched.\n let matchRules: Json[];\n if (Array.isArray(existing['match-rules'])) {\n matchRules = existing['match-rules'] as Json[];\n } else {\n matchRules = seedMatchRules();\n changes.push('added \"match-rules\" (seeded with the no-fetch guard)');\n }\n\n return matchRules;\n}\n"]}
|
package/src/load-config.d.ts
CHANGED
|
@@ -1,16 +1,14 @@
|
|
|
1
1
|
import { CommandsConfig } from './commands-config';
|
|
2
2
|
import { ConfigFile } from './config-file';
|
|
3
3
|
import { RulePackRegistry } from './rule-pack-registry';
|
|
4
|
-
import {
|
|
4
|
+
import { PackPolicyFiles, PackPolicyFilesResult } from './pack-policy-files';
|
|
5
|
+
import { RulePackArtifacts } from './rule-pack-artifacts';
|
|
5
6
|
import { ExcludePaths } from './exclude-hook-paths';
|
|
6
7
|
import { PrGateConfig } from './pr-gate-config';
|
|
7
8
|
import { ResolvedConfig } from './types';
|
|
8
9
|
import { MatchRuleConfig } from './match-rules-config';
|
|
9
10
|
import { WebpiecesRulesConfig } from './WebpiecesRulesConfig';
|
|
10
|
-
/**
|
|
11
|
-
* Everything a consumer might need from webpieces.config.json, produced from ONE parse + ONE
|
|
12
|
-
* validation pass. Data-only (per CLAUDE.md, classes for data).
|
|
13
|
-
*/
|
|
11
|
+
/** One root parse and one owner-resolution pass supply all consumers with the same registry and settings. */
|
|
14
12
|
export declare class LoadedConfig {
|
|
15
13
|
readonly resolved: ResolvedConfig;
|
|
16
14
|
readonly rulesConfig: WebpiecesRulesConfig;
|
|
@@ -20,27 +18,17 @@ export declare class LoadedConfig {
|
|
|
20
18
|
readonly matchRules: readonly MatchRuleConfig[];
|
|
21
19
|
readonly configPath: string | null;
|
|
22
20
|
readonly ruleRegistry: RulePackRegistry;
|
|
23
|
-
|
|
21
|
+
readonly policyFiles: PackPolicyFilesResult | null;
|
|
22
|
+
constructor(resolved: ResolvedConfig, rulesConfig: WebpiecesRulesConfig, commands: CommandsConfig, prGate: PrGateConfig, excludePaths: ExcludePaths, matchRules: readonly MatchRuleConfig[], configPath: string | null, ruleRegistry: RulePackRegistry, policyFiles: PackPolicyFilesResult | null);
|
|
24
23
|
}
|
|
25
|
-
/**
|
|
26
|
-
* The single load+validate entry point for ALL consumers (ai-hook-rules, code-rules,
|
|
27
|
-
* nx-webpieces-rules, pr-gate scripts). `@injectable(bindingScopeValues.Singleton)` + injects {@link ConfigFile} so it appears
|
|
28
|
-
* in the rules-config DI design.
|
|
29
|
-
*/
|
|
30
24
|
export declare class ConfigLoader {
|
|
31
25
|
private readonly configFile;
|
|
32
|
-
private readonly
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
* Reads webpieces.config.json once, validates BOTH the `rules` map and the top-level `pr-gate`
|
|
36
|
-
* block, and throws one InformAiError listing every error. When no config file is found it returns
|
|
37
|
-
* lenient empties/defaults (matching prior no-file behavior).
|
|
38
|
-
*/
|
|
26
|
+
private readonly files;
|
|
27
|
+
private readonly artifacts;
|
|
28
|
+
constructor(configFile: ConfigFile, files: PackPolicyFiles, artifacts: RulePackArtifacts);
|
|
39
29
|
loadAndValidate(cwd: string): LoadedConfig;
|
|
40
|
-
private
|
|
41
|
-
private
|
|
42
|
-
private parseMatchRules;
|
|
43
|
-
private buildWebpiecesRulesConfig;
|
|
44
|
-
private formatConfigErrorsBanner;
|
|
30
|
+
private loaded;
|
|
31
|
+
private empty;
|
|
45
32
|
}
|
|
33
|
+
/** Public function entry point and injected service use the same implementation. */
|
|
46
34
|
export declare function loadAndValidate(cwd: string): LoadedConfig;
|
package/src/load-config.js
CHANGED
|
@@ -3,24 +3,23 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.ConfigLoader = exports.LoadedConfig = void 0;
|
|
4
4
|
exports.loadAndValidate = loadAndValidate;
|
|
5
5
|
const tslib_1 = require("tslib");
|
|
6
|
-
const path = tslib_1.__importStar(require("path"));
|
|
6
|
+
const path = tslib_1.__importStar(require("node:path"));
|
|
7
7
|
const inversify_1 = require("inversify");
|
|
8
|
+
const rules_sdk_1 = require("@webpieces/rules-sdk");
|
|
9
|
+
const tooling_common_1 = require("@webpieces/tooling-common");
|
|
8
10
|
const commands_config_1 = require("./commands-config");
|
|
9
|
-
const config_error_banner_1 = require("./config-error-banner");
|
|
10
11
|
const config_file_1 = require("./config-file");
|
|
11
12
|
const rule_pack_registry_1 = require("./rule-pack-registry");
|
|
12
|
-
const
|
|
13
|
+
const pack_policy_files_1 = require("./pack-policy-files");
|
|
14
|
+
const rule_pack_artifacts_1 = require("./rule-pack-artifacts");
|
|
13
15
|
const exclude_hook_paths_1 = require("./exclude-hook-paths");
|
|
14
|
-
const tooling_common_1 = require("@webpieces/tooling-common");
|
|
15
16
|
const types_1 = require("./types");
|
|
16
17
|
const commands_section_validators_1 = require("./commands-section-validators");
|
|
17
18
|
const config_key_rules_1 = require("./config-key-rules");
|
|
18
19
|
const validate_config_1 = require("./validate-config");
|
|
19
20
|
const WebpiecesRulesConfig_1 = require("./WebpiecesRulesConfig");
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
* validation pass. Data-only (per CLAUDE.md, classes for data).
|
|
23
|
-
*/
|
|
21
|
+
const config_error_banner_1 = require("./config-error-banner");
|
|
22
|
+
/** One root parse and one owner-resolution pass supply all consumers with the same registry and settings. */
|
|
24
23
|
class LoadedConfig {
|
|
25
24
|
resolved;
|
|
26
25
|
rulesConfig;
|
|
@@ -30,8 +29,9 @@ class LoadedConfig {
|
|
|
30
29
|
matchRules;
|
|
31
30
|
configPath;
|
|
32
31
|
ruleRegistry;
|
|
32
|
+
policyFiles;
|
|
33
33
|
// eslint-disable-next-line @typescript-eslint/max-params
|
|
34
|
-
constructor(resolved, rulesConfig, commands, prGate, excludePaths, matchRules, configPath, ruleRegistry) {
|
|
34
|
+
constructor(resolved, rulesConfig, commands, prGate, excludePaths, matchRules, configPath, ruleRegistry, policyFiles) {
|
|
35
35
|
this.resolved = resolved;
|
|
36
36
|
this.rulesConfig = rulesConfig;
|
|
37
37
|
this.commands = commands;
|
|
@@ -40,155 +40,67 @@ class LoadedConfig {
|
|
|
40
40
|
this.matchRules = matchRules;
|
|
41
41
|
this.configPath = configPath;
|
|
42
42
|
this.ruleRegistry = ruleRegistry;
|
|
43
|
+
this.policyFiles = policyFiles;
|
|
43
44
|
}
|
|
44
45
|
}
|
|
45
46
|
exports.LoadedConfig = LoadedConfig;
|
|
46
|
-
// Renamed rules used to be normalized here — a DEPRECATED_RULE_ALIASES table rewrote the old key to its
|
|
47
|
-
// canonical name BEFORE validation, so no validator ever saw it and no consumer was ever told. That is why
|
|
48
|
-
// the aliases could never be removed: the old names kept working forever. The renames now live in
|
|
49
|
-
// RETIRED_CONFIG_KEYS as hard errors naming the new key. See retired-config-keys.ts for the policy.
|
|
50
|
-
/**
|
|
51
|
-
* The single load+validate entry point for ALL consumers (ai-hook-rules, code-rules,
|
|
52
|
-
* nx-webpieces-rules, pr-gate scripts). `@injectable(bindingScopeValues.Singleton)` + injects {@link ConfigFile} so it appears
|
|
53
|
-
* in the rules-config DI design.
|
|
54
|
-
*/
|
|
55
47
|
let ConfigLoader = class ConfigLoader {
|
|
56
48
|
configFile;
|
|
57
|
-
|
|
58
|
-
|
|
49
|
+
files;
|
|
50
|
+
artifacts;
|
|
51
|
+
constructor(configFile, files, artifacts) {
|
|
59
52
|
this.configFile = configFile;
|
|
60
|
-
this.
|
|
53
|
+
this.files = files;
|
|
54
|
+
this.artifacts = artifacts;
|
|
61
55
|
}
|
|
62
|
-
/**
|
|
63
|
-
* Reads webpieces.config.json once, validates BOTH the `rules` map and the top-level `pr-gate`
|
|
64
|
-
* block, and throws one InformAiError listing every error. When no config file is found it returns
|
|
65
|
-
* lenient empties/defaults (matching prior no-file behavior).
|
|
66
|
-
*/
|
|
67
|
-
// webpieces-disable max-lines-new-methods -- the single load+validate pass is one cohesive method
|
|
68
56
|
loadAndValidate(cwd) {
|
|
69
57
|
const configPath = this.configFile.findConfigFile(cwd);
|
|
70
|
-
if (!configPath)
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
const
|
|
75
|
-
const rulesSection = consumerConfig.rules || {};
|
|
76
|
-
const hookGuardsSection = consumerConfig.hookGuards || {};
|
|
77
|
-
// Read only so validateCommandsSection can REJECT it. There is no fallback to it — a config
|
|
78
|
-
// carrying the retired top-level block never loads, so reading it as a value would be dead code.
|
|
79
|
-
const legacyPrGate = consumerConfig['pr-gate'];
|
|
80
|
-
// rules + hookGuards are validated/loaded as one flat name→config map (the runtime dispatches
|
|
81
|
-
// by each rule's own `scope`). Placement is enforced separately.
|
|
82
|
-
const overrideRules = { ...rulesSection, ...hookGuardsSection };
|
|
83
|
-
const rulesDir = consumerConfig.rulesDir ?? [];
|
|
84
|
-
// The repo root (dir holding webpieces.config.json) lets checklists[].docs existence be checked.
|
|
85
|
-
const repoRoot = path.dirname(configPath);
|
|
86
|
-
const registry = this.rulePacks.loadFrom(repoRoot);
|
|
58
|
+
if (!configPath)
|
|
59
|
+
return this.empty();
|
|
60
|
+
const raw = this.configFile.readRawConfig(configPath), root = path.dirname(configPath);
|
|
61
|
+
// webpieces-disable no-any-unknown -- the root parser returns opaque client JSON; these validators narrow every accepted field
|
|
62
|
+
const document = raw;
|
|
87
63
|
const errors = [
|
|
88
|
-
|
|
89
|
-
...(0,
|
|
90
|
-
...(0, validate_config_1.
|
|
91
|
-
...(0, validate_config_1.
|
|
92
|
-
...(0, commands_section_validators_1.validateCommandsSection)(consumerConfig.commands, legacyPrGate, repoRoot),
|
|
93
|
-
...(0, validate_config_1.validateExcludePaths)(consumerConfig.excludePaths),
|
|
94
|
-
...(0, validate_config_1.validateMatchRulesSection)(consumerConfig['match-rules']),
|
|
64
|
+
...(0, config_key_rules_1.validateTopLevelKeys)(document),
|
|
65
|
+
...(0, commands_section_validators_1.validateCommandsSection)(raw.commands, document['pr-gate'], root),
|
|
66
|
+
...(0, validate_config_1.validateExcludePaths)(raw.excludePaths),
|
|
67
|
+
...(0, validate_config_1.validateMatchRulesSection)(raw['match-rules']),
|
|
95
68
|
];
|
|
96
|
-
if (errors.length
|
|
97
|
-
throw new tooling_common_1.InformAiError(
|
|
98
|
-
|
|
99
|
-
const
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
const allRuleNames = new Set([
|
|
103
|
-
...registry.ruleIds(),
|
|
104
|
-
...Object.keys(overrideRules),
|
|
105
|
-
]);
|
|
106
|
-
for (const name of allRuleNames) {
|
|
107
|
-
mergedRules.set(name, this.mergeRule(registry.hasRule(name) ? registry.optionalTuningFor(name) : undefined, overrideRules[name]));
|
|
108
|
-
}
|
|
109
|
-
const resolved = new types_1.ResolvedConfig(mergedRules, userConfiguredRuleNames, rulesDir, configPath);
|
|
110
|
-
const rulesConfig = this.buildWebpiecesRulesConfig(overrideRules, rulesDir);
|
|
111
|
-
const excludePaths = this.parseExcludePaths(consumerConfig.excludePaths);
|
|
112
|
-
const matchRules = this.parseMatchRules(consumerConfig['match-rules']);
|
|
113
|
-
return new LoadedConfig(resolved, rulesConfig, commands, commands.prGate, excludePaths, matchRules, configPath, registry);
|
|
114
|
-
}
|
|
115
|
-
// There is deliberately NO applyCommandDefaults here any more.
|
|
116
|
-
//
|
|
117
|
-
// It used to WRITE `commands.guardHints` values into two guard entries under the literal keys
|
|
118
|
-
// 'pr-creation-or-push-guard' / 'merge-in-progress-guard', as a default beneath the guards' own
|
|
119
|
-
// `upsertPrCommand` / `mergeCompleteCommand` fields. Two defects in one method: those per-guard
|
|
120
|
-
// fields were a second spelling that BEAT the commands section (so the "one place" promise was
|
|
121
|
-
// false), and the injection was keyed on guard-name literals — a key rename that missed it did NOT
|
|
122
|
-
// fail the build, the lookup simply missed and both guards quietly printed their local defaults.
|
|
123
|
-
//
|
|
124
|
-
// Both fields are now deleted (see PrLifecycleGuardConfig and RETIRED_FIELD_HINTS), and the
|
|
125
|
-
// resolved `CommandsConfig` strings are handed to the two rules at CONSTRUCTION — a compile-time
|
|
126
|
-
// wire that cannot silently miss. whole-repo-build-guard was already fed that way off
|
|
127
|
-
// LoadedConfig.prGate; this makes the guard-hint strings match.
|
|
128
|
-
// webpieces-disable no-any-unknown -- merging opaque option bags from config JSON
|
|
129
|
-
mergeRule(
|
|
130
|
-
// webpieces-disable no-any-unknown -- opaque option bag
|
|
131
|
-
baseRule,
|
|
132
|
-
// webpieces-disable no-any-unknown -- opaque option bag
|
|
133
|
-
overrideRule) {
|
|
134
|
-
if (!baseRule && !overrideRule)
|
|
135
|
-
return new types_1.ResolvedRuleConfig({ mode: 'OFF' });
|
|
136
|
-
if (!baseRule)
|
|
137
|
-
return new types_1.ResolvedRuleConfig(overrideRule);
|
|
138
|
-
if (!overrideRule)
|
|
139
|
-
return new types_1.ResolvedRuleConfig(baseRule);
|
|
140
|
-
// webpieces-disable no-any-unknown -- building merged option bag
|
|
141
|
-
const merged = {};
|
|
142
|
-
for (const key of Object.keys(baseRule))
|
|
143
|
-
merged[key] = baseRule[key];
|
|
144
|
-
for (const key of Object.keys(overrideRule))
|
|
145
|
-
merged[key] = overrideRule[key];
|
|
146
|
-
return new types_1.ResolvedRuleConfig(merged);
|
|
147
|
-
}
|
|
148
|
-
// Parse the (already-validated) raw excludePaths block into the typed ExcludePaths. The ONLY accepted
|
|
149
|
-
// shape is a bare string[]; the retired two-list object cannot reach here, because validateExcludePaths
|
|
150
|
-
// has already failed the load with the migration instruction.
|
|
151
|
-
// webpieces-disable no-any-unknown -- `raw` is opaque consumer JSON until narrowed here
|
|
152
|
-
parseExcludePaths(raw) {
|
|
153
|
-
if (!Array.isArray(raw))
|
|
154
|
-
return new exclude_hook_paths_1.ExcludePaths([]);
|
|
155
|
-
return new exclude_hook_paths_1.ExcludePaths(raw.filter(p => typeof p === 'string'));
|
|
156
|
-
}
|
|
157
|
-
// Parse the (already-validated) raw match-rules array into typed MatchRuleConfig[]. The entries use
|
|
158
|
-
// the canonical field names (turnOffRuleUntilEpoch / turnOffRuleWhileOnBranch) that the match-rules
|
|
159
|
-
// engine reads directly, so no normalization is needed.
|
|
160
|
-
// webpieces-disable no-any-unknown -- validated array; each entry cast to the typed MatchRuleConfig
|
|
161
|
-
parseMatchRules(raw) {
|
|
162
|
-
if (!Array.isArray(raw))
|
|
163
|
-
return [];
|
|
164
|
-
return raw;
|
|
69
|
+
if (errors.length)
|
|
70
|
+
throw new tooling_common_1.InformAiError((0, config_error_banner_1.formatConfigErrorsBanner)(errors));
|
|
71
|
+
const declarations = this.files.declarations(raw.rulePacks, root);
|
|
72
|
+
const policy = this.files.resolve(root, this.files.select(root, declarations));
|
|
73
|
+
this.artifacts.check(root, policy);
|
|
74
|
+
return this.loaded(configPath, raw.commands, raw.excludePaths, raw['match-rules'], policy);
|
|
165
75
|
}
|
|
166
|
-
|
|
167
|
-
// webpieces-disable no-any-unknown -- JSON
|
|
168
|
-
|
|
169
|
-
const
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
76
|
+
loaded(configPath,
|
|
77
|
+
// webpieces-disable no-any-unknown -- external JSON or runtime exports are validated before policy execution
|
|
78
|
+
commandsRaw, excluded, matches, policy) {
|
|
79
|
+
const commands = (0, commands_config_1.buildCommandsConfig)(commandsRaw), values = new WebpiecesRulesConfig_1.WebpiecesRulesConfig();
|
|
80
|
+
const resolved = new Map();
|
|
81
|
+
for (const id of policy.registry.ruleIds()) {
|
|
82
|
+
const explicit = policy.values[id];
|
|
83
|
+
values[id] = explicit;
|
|
84
|
+
const options = Object.assign(new rules_sdk_1.ConfigObject(), policy.registry.optionalTuningFor(id), explicit);
|
|
85
|
+
resolved.set(id, new types_1.ResolvedRuleConfig(options));
|
|
173
86
|
}
|
|
174
|
-
|
|
175
|
-
return typed;
|
|
87
|
+
return new LoadedConfig(new types_1.ResolvedConfig(resolved, new Set(policy.registry.ruleIds()), configPath), values, commands, commands.prGate, new exclude_hook_paths_1.ExcludePaths([...excluded]), matches, configPath, policy.registry, policy);
|
|
176
88
|
}
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
return (0, config_error_banner_1.formatConfigErrorsBanner)(errors);
|
|
89
|
+
empty() {
|
|
90
|
+
const commands = (0, commands_config_1.buildCommandsConfig)(undefined);
|
|
91
|
+
return new LoadedConfig(new types_1.ResolvedConfig(new Map(), new Set(), null), new WebpiecesRulesConfig_1.WebpiecesRulesConfig(), commands, commands.prGate, new exclude_hook_paths_1.ExcludePaths([]), [], null, new rule_pack_registry_1.RulePackRegistry([]), null);
|
|
181
92
|
}
|
|
182
93
|
};
|
|
183
94
|
exports.ConfigLoader = ConfigLoader;
|
|
184
95
|
exports.ConfigLoader = ConfigLoader = tslib_1.__decorate([
|
|
185
96
|
(0, inversify_1.injectable)(inversify_1.bindingScopeValues.Singleton),
|
|
186
|
-
tslib_1.__metadata("design:paramtypes", [config_file_1.ConfigFile,
|
|
97
|
+
tslib_1.__metadata("design:paramtypes", [config_file_1.ConfigFile,
|
|
98
|
+
pack_policy_files_1.PackPolicyFiles,
|
|
99
|
+
rule_pack_artifacts_1.RulePackArtifacts])
|
|
187
100
|
], ConfigLoader);
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
// webpieces-disable no-function-outside-class -- temporary back-compat delegator to ConfigLoader; removed once all 118 consumers inject it
|
|
101
|
+
const configLoaderSvc = new ConfigLoader(new config_file_1.ConfigFile(), new pack_policy_files_1.PackPolicyFiles(), new rule_pack_artifacts_1.RulePackArtifacts(new tooling_common_1.AtomicFile()));
|
|
102
|
+
/** Public function entry point and injected service use the same implementation. */
|
|
103
|
+
// webpieces-disable no-function-outside-class -- canonical public loader function for CLI and executor entry points
|
|
192
104
|
function loadAndValidate(cwd) {
|
|
193
105
|
return configLoaderSvc.loadAndValidate(cwd);
|
|
194
106
|
}
|
package/src/load-config.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"load-config.js","sourceRoot":"","sources":["../../../../../packages/tooling/rules-config/src/load-config.ts"],"names":[],"mappings":";;;AAqMA,0CAEC;;AAvMD,mDAA6B;AAC7B,yCAA2D;AAE3D,uDAAwE;AACxE,+DAAiE;AACjE,+CAA2C;AAC3C,6DAAwD;AACxD,+DAA0D;AAC1D,6DAAoD;AACpD,8DAA0D;AAE1D,mCAA0E;AAC1E,+EAAwE;AACxE,yDAA0D;AAC1D,uDAAuI;AAEvI,iEAA8D;AAE9D;;;GAGG;AACH,MAAa,YAAY;IAGR;IACA;IACA;IACA;IACA;IACA;IAC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AC,GAAY;QAChC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC;YAAE,OAAO,EAAE,CAAC;QACnC,OAAO,GAAwB,CAAC;IACpC,CAAC;IAEO,yBAAyB;IAC7B,4FAA4F;IAC5F,QAAiD,EACjD,QAAkB;QAElB,MAAM,KAAK,GAAG,IAAI,2CAAoB,EAAE,CAAC;QACzC,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC;YACtC,4EAA4E;YAC3E,KAAiC,CAAC,GAAG,CAAC,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC;QAC5D,CAAC;QACD,KAAK,CAAC,QAAQ,GAAG,QAAQ,CAAC;QAC1B,OAAO,KAAK,CAAC;IACjB,CAAC;IAED,kGAAkG;IAClG,gGAAgG;IACxF,wBAAwB,CAAC,MAAgB;QAC7C,OAAO,IAAA,8CAAwB,EAAC,MAAM,CAAC,CAAC;IAC5C,CAAC;CACJ,CAAA;AA/IY,oCAAY;uBAAZ,YAAY;IADxB,IAAA,sBAAU,EAAC,8BAAkB,CAAC,SAAS,CAAC;6CAEI,wBAAU,EAA8B,uCAAiB;GADzF,YAAY,CA+IxB;AAED,kGAAkG;AAClG,8FAA8F;AAC9F,MAAM,eAAe,GAAG,IAAI,YAAY,CAAC,IAAI,wBAAU,EAAE,EAAE,IAAI,uCAAiB,EAAE,CAAC,CAAC;AAEpF,2IAA2I;AAC3I,SAAgB,eAAe,CAAC,GAAW;IACvC,OAAO,eAAe,CAAC,eAAe,CAAC,GAAG,CAAC,CAAC;AAChD,CAAC","sourcesContent":["import * as path from 'path';\nimport { injectable, bindingScopeValues } from 'inversify';\n\nimport { buildCommandsConfig, CommandsConfig } from './commands-config';\nimport { formatConfigErrorsBanner } from './config-error-banner';\nimport { ConfigFile } from './config-file';\nimport { RulePackRegistry } from './rule-pack-registry';\nimport { RulePackSelection } from './rule-pack-selection';\nimport { ExcludePaths } from './exclude-hook-paths';\nimport { InformAiError } from '@webpieces/tooling-common';\nimport { PrGateConfig } from './pr-gate-config';\nimport { ResolvedConfig, ResolvedRuleConfig, RuleOptions } from './types';\nimport { validateCommandsSection } from './commands-section-validators';\nimport { validateTopLevelKeys } from './config-key-rules';\nimport { validateExcludePaths, validateMatchRulesSection, validateSectionPlacement, validateWebpiecesConfig } from './validate-config';\nimport { MatchRuleConfig } from './match-rules-config';\nimport { WebpiecesRulesConfig } from './WebpiecesRulesConfig';\n\n/**\n * Everything a consumer might need from webpieces.config.json, produced from ONE parse + ONE\n * validation pass. Data-only (per CLAUDE.md, classes for data).\n */\nexport class LoadedConfig {\n // eslint-disable-next-line @typescript-eslint/max-params\n constructor(\n readonly resolved: ResolvedConfig,\n readonly rulesConfig: WebpiecesRulesConfig,\n readonly commands: CommandsConfig,\n readonly prGate: PrGateConfig,\n readonly excludePaths: ExcludePaths,\n readonly matchRules: readonly MatchRuleConfig[],\n readonly configPath: string | null,\n readonly ruleRegistry: RulePackRegistry,\n ) {}\n}\n\n// Renamed rules used to be normalized here — a DEPRECATED_RULE_ALIASES table rewrote the old key to its\n// canonical name BEFORE validation, so no validator ever saw it and no consumer was ever told. That is why\n// the aliases could never be removed: the old names kept working forever. The renames now live in\n// RETIRED_CONFIG_KEYS as hard errors naming the new key. See retired-config-keys.ts for the policy.\n\n/**\n * The single load+validate entry point for ALL consumers (ai-hook-rules, code-rules,\n * nx-webpieces-rules, pr-gate scripts). `@injectable(bindingScopeValues.Singleton)` + injects {@link ConfigFile} so it appears\n * in the rules-config DI design.\n */\n@injectable(bindingScopeValues.Singleton)\nexport class ConfigLoader {\n constructor(private readonly configFile: ConfigFile, private readonly rulePacks: RulePackSelection) {}\n\n /**\n * Reads webpieces.config.json once, validates BOTH the `rules` map and the top-level `pr-gate`\n * block, and throws one InformAiError listing every error. When no config file is found it returns\n * lenient empties/defaults (matching prior no-file behavior).\n */\n // webpieces-disable max-lines-new-methods -- the single load+validate pass is one cohesive method\n loadAndValidate(cwd: string): LoadedConfig {\n const configPath = this.configFile.findConfigFile(cwd);\n if (!configPath) {\n const emptyCommands = buildCommandsConfig(undefined);\n return new LoadedConfig(\n new ResolvedConfig(new Map(), new Set(), [], null),\n new WebpiecesRulesConfig(),\n emptyCommands,\n emptyCommands.prGate,\n new ExcludePaths([]),\n [],\n null,\n new RulePackRegistry([]),\n );\n }\n\n const consumerConfig = this.configFile.readRawConfig(configPath);\n const rulesSection = consumerConfig.rules || {};\n const hookGuardsSection = consumerConfig.hookGuards || {};\n // Read only so validateCommandsSection can REJECT it. There is no fallback to it — a config\n // carrying the retired top-level block never loads, so reading it as a value would be dead code.\n const legacyPrGate = consumerConfig['pr-gate'];\n\n // rules + hookGuards are validated/loaded as one flat name→config map (the runtime dispatches\n // by each rule's own `scope`). Placement is enforced separately.\n const overrideRules = { ...rulesSection, ...hookGuardsSection };\n\n const rulesDir = consumerConfig.rulesDir ?? [];\n\n // The repo root (dir holding webpieces.config.json) lets checklists[].docs existence be checked.\n const repoRoot = path.dirname(configPath);\n const registry = this.rulePacks.loadFrom(repoRoot);\n const errors = [\n // webpieces-disable no-any-unknown -- the raw parsed config is opaque; only key names are read\n ...validateTopLevelKeys(consumerConfig as unknown as Record<string, unknown>),\n ...validateWebpiecesConfig(overrideRules, registry, rulesDir.length > 0),\n ...validateSectionPlacement(rulesSection, hookGuardsSection, registry),\n ...validateCommandsSection(consumerConfig.commands, legacyPrGate, repoRoot),\n ...validateExcludePaths(consumerConfig.excludePaths),\n ...validateMatchRulesSection(consumerConfig['match-rules']),\n ];\n if (errors.length > 0) {\n throw new InformAiError(this.formatConfigErrorsBanner(errors));\n }\n\n const commands = buildCommandsConfig(consumerConfig.commands);\n\n const userConfiguredRuleNames = new Set(Object.keys(overrideRules));\n const mergedRules = new Map<string, ResolvedRuleConfig>();\n const allRuleNames = new Set([\n ...registry.ruleIds(),\n ...Object.keys(overrideRules),\n ]);\n for (const name of allRuleNames) {\n mergedRules.set(name, this.mergeRule(registry.hasRule(name) ? registry.optionalTuningFor(name) : undefined, overrideRules[name]));\n }\n const resolved = new ResolvedConfig(mergedRules, userConfiguredRuleNames, rulesDir, configPath);\n\n const rulesConfig = this.buildWebpiecesRulesConfig(overrideRules, rulesDir);\n const excludePaths = this.parseExcludePaths(consumerConfig.excludePaths);\n const matchRules = this.parseMatchRules(consumerConfig['match-rules']);\n\n return new LoadedConfig(resolved, rulesConfig, commands, commands.prGate, excludePaths, matchRules, configPath, registry);\n }\n\n // There is deliberately NO applyCommandDefaults here any more.\n //\n // It used to WRITE `commands.guardHints` values into two guard entries under the literal keys\n // 'pr-creation-or-push-guard' / 'merge-in-progress-guard', as a default beneath the guards' own\n // `upsertPrCommand` / `mergeCompleteCommand` fields. Two defects in one method: those per-guard\n // fields were a second spelling that BEAT the commands section (so the \"one place\" promise was\n // false), and the injection was keyed on guard-name literals — a key rename that missed it did NOT\n // fail the build, the lookup simply missed and both guards quietly printed their local defaults.\n //\n // Both fields are now deleted (see PrLifecycleGuardConfig and RETIRED_FIELD_HINTS), and the\n // resolved `CommandsConfig` strings are handed to the two rules at CONSTRUCTION — a compile-time\n // wire that cannot silently miss. whole-repo-build-guard was already fed that way off\n // LoadedConfig.prGate; this makes the guard-hint strings match.\n\n // webpieces-disable no-any-unknown -- merging opaque option bags from config JSON\n private mergeRule(\n // webpieces-disable no-any-unknown -- opaque option bag\n baseRule: Record<string, unknown> | undefined,\n // webpieces-disable no-any-unknown -- opaque option bag\n overrideRule: Record<string, unknown> | undefined,\n ): ResolvedRuleConfig {\n if (!baseRule && !overrideRule) return new ResolvedRuleConfig({ mode: 'OFF' });\n if (!baseRule) return new ResolvedRuleConfig(overrideRule! as RuleOptions);\n if (!overrideRule) return new ResolvedRuleConfig(baseRule as RuleOptions);\n\n // webpieces-disable no-any-unknown -- building merged option bag\n const merged: Record<string, unknown> = {};\n for (const key of Object.keys(baseRule)) merged[key] = baseRule[key];\n for (const key of Object.keys(overrideRule)) merged[key] = overrideRule[key];\n return new ResolvedRuleConfig(merged as RuleOptions);\n }\n\n // Parse the (already-validated) raw excludePaths block into the typed ExcludePaths. The ONLY accepted\n // shape is a bare string[]; the retired two-list object cannot reach here, because validateExcludePaths\n // has already failed the load with the migration instruction.\n // webpieces-disable no-any-unknown -- `raw` is opaque consumer JSON until narrowed here\n private parseExcludePaths(raw: unknown): ExcludePaths {\n if (!Array.isArray(raw)) return new ExcludePaths([]);\n return new ExcludePaths(raw.filter(p => typeof p === 'string'));\n }\n\n // Parse the (already-validated) raw match-rules array into typed MatchRuleConfig[]. The entries use\n // the canonical field names (turnOffRuleUntilEpoch / turnOffRuleWhileOnBranch) that the match-rules\n // engine reads directly, so no normalization is needed.\n // webpieces-disable no-any-unknown -- validated array; each entry cast to the typed MatchRuleConfig\n private parseMatchRules(raw: unknown): MatchRuleConfig[] {\n if (!Array.isArray(raw)) return [];\n return raw as MatchRuleConfig[];\n }\n\n private buildWebpiecesRulesConfig(\n // webpieces-disable no-any-unknown -- JSON values are opaque until assigned to typed fields\n rawRules: Record<string, Record<string, unknown>>,\n rulesDir: string[],\n ): WebpiecesRulesConfig {\n const typed = new WebpiecesRulesConfig();\n for (const key of Object.keys(rawRules)) {\n // webpieces-disable no-any-unknown -- dynamic key assignment to typed class\n (typed as Record<string, unknown>)[key] = rawRules[key];\n }\n typed.rulesDir = rulesDir;\n return typed;\n }\n\n // Assemble the validation-failure banner. Every error here came from validating this ONE file, so\n // the cure is always \"edit it\" — see config-error-banner.ts for why nothing else belongs in it.\n private formatConfigErrorsBanner(errors: string[]): string {\n return formatConfigErrorsBanner(errors);\n }\n}\n\n// Temporary migration delegator — consumers migrate to injecting ConfigLoader over follow-up PRs,\n// then this free function is removed. The logic now lives in the injected ConfigLoader class.\nconst configLoaderSvc = new ConfigLoader(new ConfigFile(), new RulePackSelection());\n\n// webpieces-disable no-function-outside-class -- temporary back-compat delegator to ConfigLoader; removed once all 118 consumers inject it\nexport function loadAndValidate(cwd: string): LoadedConfig {\n return configLoaderSvc.loadAndValidate(cwd);\n}\n"]}
|
|
1
|
+
{"version":3,"file":"load-config.js","sourceRoot":"","sources":["../../../../../packages/tooling/rules-config/src/load-config.ts"],"names":[],"mappings":";;;AA+HA,0CAEC;;AAjID,wDAAkC;AAClC,yCAA2D;AAC3D,oDAAoD;AACpD,8DAAsE;AACtE,uDAAwE;AACxE,+CAA2C;AAC3C,6DAAwD;AACxD,2DAA6E;AAC7E,+DAA0D;AAC1D,6DAAoD;AAEpD,mCAA6D;AAC7D,+EAAwE;AACxE,yDAA0D;AAC1D,uDAAoF;AAEpF,iEAA8D;AAC9D,+DAAiE;AAEjE,6GAA6G;AAC7G,MAAa,YAAY;IAGR;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IAVb,yDAAyD;IACzD,YACa,QAAwB,EACxB,WAAiC,EACjC,QAAwB,EACxB,MAAoB,EACpB,YAA0B,EAC1B,UAAsC,EACtC,UAAyB,EACzB,YAA8B,EAC9B,WAAyC;QARzC,aAAQ,GAAR,QAAQ,CAAgB;QACxB,gBAAW,GAAX,WAAW,CAAsB;QACjC,aAAQ,GAAR,QAAQ,CAAgB;QACxB,WAAM,GAAN,MAAM,CAAc;QACpB,iBAAY,GAAZ,YAAY,CAAc;QAC1B,eAAU,GAAV,UAAU,CAA4B;QACtC,eAAU,GAAV,UAAU,CAAe;QACzB,iBAAY,GAAZ,YAAY,CAAkB;QAC9B,gBAAW,GAAX,WAAW,CAA8B;IACnD,CAAC;CACP;AAbD,oCAaC;AAGM,IAAM,YAAY,GAAlB,MAAM,YAAY;IAEA;IACA;IACA;IAHrB,YACqB,UAAsB,EACtB,KAAsB,EACtB,SAA4B;QAF5B,eAAU,GAAV,UAAU,CAAY;QACtB,UAAK,GAAL,KAAK,CAAiB;QACtB,cAAS,GAAT,SAAS,CAAmB;IAC9C,CAAC;IAEJ,eAAe,CAAC,GAAW;QACvB,MAAM,UAAU,GAAG,IAAI,CAAC,UAAU,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC;QACvD,IAAI,CAAC,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B,CAAC,EAAE,CAAC,EACxB,IAAI,CACP,CAAC;IACN,CAAC;CACJ,CAAA;AAjFY,oCAAY;uBAAZ,YAAY;IADxB,IAAA,sBAAU,EAAC,8BAAkB,CAAC,SAAS,CAAC;6CAGJ,wBAAU;QACf,mCAAe;QACX,uCAAiB;GAJxC,YAAY,CAiFxB;AAED,MAAM,eAAe,GAAG,IAAI,YAAY,CACpC,IAAI,wBAAU,EAAE,EAChB,IAAI,mCAAe,EAAE,EACrB,IAAI,uCAAiB,CAAC,IAAI,2BAAU,EAAE,CAAC,CAC1C,CAAC;AAEF,oFAAoF;AACpF,oHAAoH;AACpH,SAAgB,eAAe,CAAC,GAAW;IACvC,OAAO,eAAe,CAAC,eAAe,CAAC,GAAG,CAAC,CAAC;AAChD,CAAC","sourcesContent":["import * as path from 'node:path';\nimport { injectable, bindingScopeValues } from 'inversify';\nimport { ConfigObject } from '@webpieces/rules-sdk';\nimport { InformAiError, AtomicFile } from '@webpieces/tooling-common';\nimport { buildCommandsConfig, CommandsConfig } from './commands-config';\nimport { ConfigFile } from './config-file';\nimport { RulePackRegistry } from './rule-pack-registry';\nimport { PackPolicyFiles, PackPolicyFilesResult } from './pack-policy-files';\nimport { RulePackArtifacts } from './rule-pack-artifacts';\nimport { ExcludePaths } from './exclude-hook-paths';\nimport { PrGateConfig } from './pr-gate-config';\nimport { ResolvedConfig, ResolvedRuleConfig } from './types';\nimport { validateCommandsSection } from './commands-section-validators';\nimport { validateTopLevelKeys } from './config-key-rules';\nimport { validateExcludePaths, validateMatchRulesSection } from './validate-config';\nimport { MatchRuleConfig } from './match-rules-config';\nimport { WebpiecesRulesConfig } from './WebpiecesRulesConfig';\nimport { formatConfigErrorsBanner } from './config-error-banner';\n\n/** One root parse and one owner-resolution pass supply all consumers with the same registry and settings. */\nexport class LoadedConfig {\n // eslint-disable-next-line @typescript-eslint/max-params\n constructor(\n readonly resolved: ResolvedConfig,\n readonly rulesConfig: WebpiecesRulesConfig,\n readonly commands: CommandsConfig,\n readonly prGate: PrGateConfig,\n readonly excludePaths: ExcludePaths,\n readonly matchRules: readonly MatchRuleConfig[],\n readonly configPath: string | null,\n readonly ruleRegistry: RulePackRegistry,\n readonly policyFiles: PackPolicyFilesResult | null,\n ) {}\n}\n\n@injectable(bindingScopeValues.Singleton)\nexport class ConfigLoader {\n constructor(\n private readonly configFile: ConfigFile,\n private readonly files: PackPolicyFiles,\n private readonly artifacts: RulePackArtifacts,\n ) {}\n\n loadAndValidate(cwd: string): LoadedConfig {\n const configPath = this.configFile.findConfigFile(cwd);\n if (!configPath) return this.empty();\n const raw = this.configFile.readRawConfig(configPath),\n root = path.dirname(configPath);\n // webpieces-disable no-any-unknown -- the root parser returns opaque client JSON; these validators narrow every accepted field\n const document = raw as Record<string, unknown>;\n const errors = [\n ...validateTopLevelKeys(document),\n ...validateCommandsSection(raw.commands, document['pr-gate'], root),\n ...validateExcludePaths(raw.excludePaths),\n ...validateMatchRulesSection(raw['match-rules']),\n ];\n if (errors.length) throw new InformAiError(formatConfigErrorsBanner(errors));\n const declarations = this.files.declarations(raw.rulePacks, root);\n const policy = this.files.resolve(root, this.files.select(root, declarations));\n this.artifacts.check(root, policy);\n return this.loaded(\n configPath,\n raw.commands,\n raw.excludePaths as string[],\n raw['match-rules'] as MatchRuleConfig[],\n policy,\n );\n }\n\n private loaded(\n configPath: string,\n // webpieces-disable no-any-unknown -- external JSON or runtime exports are validated before policy execution\n commandsRaw: unknown,\n excluded: readonly string[],\n matches: readonly MatchRuleConfig[],\n policy: PackPolicyFilesResult,\n ): LoadedConfig {\n const commands = buildCommandsConfig(commandsRaw),\n values = new WebpiecesRulesConfig();\n const resolved = new Map<string, ResolvedRuleConfig>();\n for (const id of policy.registry.ruleIds()) {\n const explicit = policy.values[id];\n values[id] = explicit;\n const options = Object.assign(\n new ConfigObject(),\n policy.registry.optionalTuningFor(id),\n explicit,\n );\n resolved.set(id, new ResolvedRuleConfig(options));\n }\n return new LoadedConfig(\n new ResolvedConfig(resolved, new Set(policy.registry.ruleIds()), configPath),\n values,\n commands,\n commands.prGate,\n new ExcludePaths([...excluded]),\n matches,\n configPath,\n policy.registry,\n policy,\n );\n }\n\n private empty(): LoadedConfig {\n const commands = buildCommandsConfig(undefined);\n return new LoadedConfig(\n new ResolvedConfig(new Map(), new Set(), null),\n new WebpiecesRulesConfig(),\n commands,\n commands.prGate,\n new ExcludePaths([]),\n [],\n null,\n new RulePackRegistry([]),\n null,\n );\n }\n}\n\nconst configLoaderSvc = new ConfigLoader(\n new ConfigFile(),\n new PackPolicyFiles(),\n new RulePackArtifacts(new AtomicFile()),\n);\n\n/** Public function entry point and injected service use the same implementation. */\n// webpieces-disable no-function-outside-class -- canonical public loader function for CLI and executor entry points\nexport function loadAndValidate(cwd: string): LoadedConfig {\n return configLoaderSvc.loadAndValidate(cwd);\n}\n"]}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { RulePackManifest, ConfigObject } from '@webpieces/rules-sdk';
|
|
2
|
+
import { RulePackRegistry } from './rule-pack-registry';
|
|
3
|
+
/** The root declaration identifies an exact package/module and its owner-specific config file. */
|
|
4
|
+
export declare class PackPolicyDeclaration {
|
|
5
|
+
readonly config: string;
|
|
6
|
+
readonly package: string;
|
|
7
|
+
constructor(packageName: string, config: string);
|
|
8
|
+
moduleName(): string;
|
|
9
|
+
}
|
|
10
|
+
export declare class SelectedPolicyPack {
|
|
11
|
+
readonly declaration: PackPolicyDeclaration;
|
|
12
|
+
readonly manifest: RulePackManifest;
|
|
13
|
+
constructor(declaration: PackPolicyDeclaration, manifest: RulePackManifest);
|
|
14
|
+
}
|
|
15
|
+
export declare class PackPolicyFilesResult {
|
|
16
|
+
readonly registry: RulePackRegistry;
|
|
17
|
+
readonly selected: readonly SelectedPolicyPack[];
|
|
18
|
+
readonly values: Record<string, ConfigObject>;
|
|
19
|
+
readonly targetFiles: ReadonlyMap<string, string>;
|
|
20
|
+
constructor(registry: RulePackRegistry, selected: readonly SelectedPolicyPack[], values: Record<string, ConfigObject>, targetFiles: ReadonlyMap<string, string>);
|
|
21
|
+
}
|
|
22
|
+
/** Configuration belongs to explicitly selected owners; loading never supplies recommended seeds. */
|
|
23
|
+
export declare class PackPolicyFiles {
|
|
24
|
+
declarations(raw: unknown, root: string): PackPolicyDeclaration[];
|
|
25
|
+
select(root: string, declarations: readonly PackPolicyDeclaration[]): SelectedPolicyPack[];
|
|
26
|
+
resolve(root: string, selected: readonly SelectedPolicyPack[]): PackPolicyFilesResult;
|
|
27
|
+
configPath(root: string, relative: string): string;
|
|
28
|
+
read(filename: string): Record<string, ConfigObject>;
|
|
29
|
+
}
|