@webpieces/rules-config 0.4.983 → 0.4.985
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 +5 -5
- package/src/cli-args.d.ts +4 -5
- package/src/cli-args.js +4 -5
- package/src/cli-args.js.map +1 -1
- package/src/commands-config.d.ts +2 -2
- package/src/commands-config.js +2 -2
- package/src/commands-config.js.map +1 -1
- package/src/commands-section-validators.js +1 -1
- package/src/commands-section-validators.js.map +1 -1
- package/src/constants.js +2 -2
- package/src/constants.js.map +1 -1
- package/src/index.d.ts +1 -1
- package/src/index.js +3 -3
- package/src/index.js.map +1 -1
- package/src/pr-gate-config.d.ts +3 -3
- package/src/pr-gate-config.js +3 -3
- package/src/pr-gate-config.js.map +1 -1
- package/src/pr-gate-section-validators.d.ts +1 -1
- package/src/pr-gate-section-validators.js +4 -4
- package/src/pr-gate-section-validators.js.map +1 -1
- package/src/sync-flow-guidance.d.ts +2 -2
- package/src/sync-flow-guidance.js +15 -12
- package/src/sync-flow-guidance.js.map +1 -1
- package/src/validate-pr-gate.js +1 -1
- package/src/validate-pr-gate.js.map +1 -1
- package/templates/webpieces.config-policy.md +3 -3
- package/templates/webpieces.git-workflow.md +68 -61
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validate-pr-gate.js","sourceRoot":"","sources":["../../../../../packages/tooling/rules-config/src/validate-pr-gate.ts"],"names":[],"mappings":";;AAyGA,sDA8DC;AAvKD,iEAA6D;AAC7D,6EAAkL;AAGlL,MAAM,aAAa,GAAG,CAAC,IAAI,EAAE,KAAK,CAAU,CAAC;AAC7C,6FAA6F;AAC7F,yFAAyF;AACzF,MAAM,mBAAmB,GAAG,CAAC,MAAM,EAAE,MAAM,CAAU,CAAC;AAEtD,iGAAiG;AACjG,kGAAkG;AAClG,+FAA+F;AAC/F,MAAM,eAAe,GACjB,mBAAmB,mBAAmB,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK;IACtD,8FAA8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,CAAC;QACpF,CAAC;aAAM,IACH,OAAO,EAAE,KAAK,QAAQ;YACtB,CAAC,mBAAmB,CAAC,QAAQ,CAAC,EAA0C,CAAC,EAC3E,CAAC;YACC,MAAM,CAAC,IAAI,CAAC,4BAA4B,MAAM,CAAC,EAAE,CAAC,mBAAmB,eAAe,EAAE,CAAC,CAAC;QAC5F,CAAC;QACD,MAAM,CAAC,IAAI,CAAC,GAAG,IAAA,sDAAyB,EAAC,CAAC,EAAE,QAAQ,CAAC,CAAC,CAAC;IAC3D,CAAC;IAED,OAAO,MAAM,CAAC;AAClB,CAAC","sourcesContent":["import { ConfigDocumentation } from './config-documentation';\nimport { validateChecklistsSection, validateDevDeploySection, validateLandPrSection, validateNoGateSaltRationale, validateReviewerAgentKeys } from './pr-gate-section-validators';\nimport * as fs from 'fs';\nimport * as path from 'path';\nconst PR_GATE_MODES = ['ON', 'OFF'] as const;\n// Optional — omitted means DETECT. Kept inline (like prGateExample) to avoid a load-config ↔\n// pr-gate-config import cycle; the canonical list + semantics live in pr-gate-config.ts.\nconst PR_GATE_MERGE_MODES = ['AUTO', 'NONE'] as const;\n\n// Spelled out because the choice is a POLICY decision with a consequence the chooser cannot see:\n// only the AUTO path can put the compact risk/flags body in main's history, because a UI merge is\n// composed from the repo's squash_merge_commit_title/message settings, which the tooling pins.\nconst MERGE_MODE_HELP =\n `Must be one of: ${PR_GATE_MERGE_MODES.join(', ')}.\\n` +\n ` \"AUTO\" — wp-finish-upsert-pr lands the PR: it squash-merges when mergeable, else enables\\n` +\n ` GitHub auto-merge, both with an explicit --subject/--body-file so main's history\\n` +\n ` gets the PR title + the compact risk/flags body. Needs allow_auto_merge on the repo\\n` +\n ` (gh api repos/{owner}/{repo} --jq .allow_auto_merge).\\n` +\n ` \"NONE\" — wp-finish-upsert-pr only opens/updates the PR without attempting to merge. It still\\n` +\n ` lands the compact body: the PR DESCRIPTION *is* that body, and stage \\u2462 keeps the repo's\\n` +\n ` squash_merge_commit_title/message pinned to PR_TITLE/PR_BODY so a UI merge copies it\\n` +\n ` verbatim (SquashSettingsEnforcer). Nothing to set by hand.\\n` +\n ` This is tooling behavior, not an authorization requirement. Honor existing user\\n` +\n ` instructions, including $full-cycle; use pnpm wp-land-pr when landing was requested.`;\n\n// Copy-paste example for the top-level `pr-gate` block (sibling of `rules`). Kept inline rather\n// than imported from pr-gate-config.ts to avoid a load-config ↔ pr-gate-config import cycle.\n// webpieces-disable no-function-outside-class -- pure example renderer beside the public command validator\nfunction prGateExample(): string {\n return (\n ` \"pr-gate\": {\\n` +\n ` \"mode\": \"ON\",\\n` +\n ` \"buildCommand\": \"<command CI runs to validate a PR, e.g. pnpm nx affected --target=ci --base=$(git merge-base origin/main HEAD)>\",\\n` +\n ` \"gates\": [\\n` +\n ` { \"name\": \"API Changed\", \"patterns\": [\"libraries/apis/**\", \"**/*Api.ts\"], \"warningColor\": \"yellow\" }\\n` +\n ` ],\\n` +\n ` \"reviewerAgents\": 1, // REQUIRED — 0 disables reviews; positive values cap subagents per round\\n` +\n ` \"maxReviewerRounds\": 2, // REQUIRED positive integer — caps complete global review rounds\\n` +\n ` \"checklists\": [ // OPTIONAL — per-area review, each against its own doc\\n` +\n ` { \"id\": \"db-migrations\", \"doc\": \".claude/review/db-migrations.md\", \"patterns\": [\"**/*.sql\"], \"required\": true }\\n` +\n ` ]\\n` +\n ` }`\n );\n}\n\n// The `gates` array: dashboard-only warning flags. Extracted from validatePrGateSection to keep that\n// method inside the length limit.\n// webpieces-disable no-any-unknown -- `value` is the opaque consumer `gates` value until narrowed here\n// webpieces-disable no-function-outside-class -- module-level config validator, matches the rest of this file\nfunction validateGatesSection(value: unknown): string[] {\n if (!Array.isArray(value)) {\n return [\n `[pr-gate] \"gates\" must be an array of { name, patterns, warningColor, disabled? }.`,\n ];\n }\n const errors: string[] = [];\n for (let i = 0; i < value.length; i += 1) {\n errors.push(...validateGate(value[i], i));\n }\n return errors;\n}\n\n// webpieces-disable no-any-unknown -- one gate entry from opaque consumer JSON, validated field-by-field\n// webpieces-disable no-function-outside-class -- pure field validator beside the public command validator\nfunction validateGate(gate: unknown, index: number): string[] {\n if (typeof gate !== 'object' || gate === null) {\n return [\n `[pr-gate] gates[${index}] must be an object { name, patterns, warningColor, disabled? }.`,\n ];\n }\n // webpieces-disable no-any-unknown -- narrowing one opaque gate object from consumer JSON\n const g = gate as Record<string, unknown>;\n const errors: string[] = [];\n if (typeof g['name'] !== 'string')\n errors.push(`[pr-gate] gates[${index}].name must be a string.`);\n if (\n !Array.isArray(g['patterns']) ||\n // webpieces-disable no-any-unknown -- opaque config patterns are checked before use\n !g['patterns'].every((p: unknown) => typeof p === 'string')\n )\n errors.push(`[pr-gate] gates[${index}].patterns must be string[].`);\n if (g['warningColor'] === undefined)\n errors.push(\n `[pr-gate] gates[${index}].warningColor is required — set it to \"yellow\" or \"red\" (green is implicit when nothing matches).`,\n );\n else if (g['warningColor'] !== 'yellow' && g['warningColor'] !== 'red')\n errors.push(\n `[pr-gate] gates[${index}].warningColor must be \"yellow\" or \"red\" (green is implicit when nothing matches).`,\n );\n if (g['disabled'] !== undefined && typeof g['disabled'] !== 'boolean')\n errors.push(\n `[pr-gate] gates[${index}].disabled must be a boolean (example/inactive gate kept in the file).`,\n );\n return errors;\n}\n\n/**\n * Validate the top-level `pr-gate` section. It is REQUIRED (a client that opts out sets mode \"OFF\").\n * `buildCommand` is required unless mode is \"OFF\". Returns human-readable, copy-paste-friendly errors\n * — never throws. The pr-gate block lives outside the FieldDef-driven `rules` schema because its\n * nested `gates`/`checklists` arrays can't be expressed there, so they get structural validation here.\n * `repoRoot` (when known) lets the `checklists[].docs` existence check run.\n */\n// webpieces-disable no-any-unknown -- `section` is opaque consumer JSON until narrowed below\n// webpieces-disable no-function-outside-class -- module-level config validator, matches the rest of this file\nexport function validatePrGateSection(section: unknown, repoRoot?: string): string[] {\n if (section === undefined || section === null) {\n return [\n `[pr-gate] Not configured in webpieces.config.json. Add this block under the \"commands\" ` +\n `section (set \"mode\": \"OFF\" to opt out):\\n\\n${prGateExample()}`,\n ];\n }\n if (typeof section !== 'object' || Array.isArray(section)) {\n return [`[pr-gate] Must be an object. Example:\\n\\n${prGateExample()}`];\n }\n // webpieces-disable no-any-unknown -- narrowing the opaque pr-gate section from consumer JSON\n const s = section as Record<string, unknown>;\n const errors: string[] = new ConfigDocumentation().inlineErrors(section, '[pr-gate]');\n\n if (!('mode' in s)) {\n errors.push(\n `[pr-gate] Missing required field \"mode\". Must be one of: ${PR_GATE_MODES.join(', ')}.`,\n );\n } else if (\n typeof s['mode'] !== 'string' ||\n !PR_GATE_MODES.includes(s['mode'] as (typeof PR_GATE_MODES)[number])\n ) {\n errors.push(\n `[pr-gate] \"mode\" = \"${String(s['mode'])}\" is not valid. Must be one of: ${PR_GATE_MODES.join(', ')}.`,\n );\n }\n\n errors.push(...validateActiveGatePolicy(s, repoRoot));\n\n if ('gates' in s) errors.push(...validateGatesSection(s['gates']));\n\n // Optional extension point: company review checklists, as an ARRAY right here in the config. Absent ⇒\n // none. The removed { doc } manifest shape is rejected with the exact migration edit.\n if ('checklists' in s) errors.push(...validateChecklistsSection(s['checklists'], repoRoot));\n\n // Optional server-token salt. Absent ⇒ no token minted, CI enforcement is a no-op. Present ⇒ must be\n // a non-empty string (an empty salt would mint a token anyone can forge from a known-empty secret).\n if ('gateSalt' in s) {\n const salt = s['gateSalt'];\n if (typeof salt !== 'string' || salt.trim() === '') {\n errors.push(\n `[pr-gate] \"gateSalt\" must be a non-empty string — it is the shared secret the gate token is HMAC'd with. Omit the key entirely to disable server-side token enforcement.`,\n );\n }\n }\n\n // Optional: what happens to the LOCAL branch once its PR lands. Absent ⇒ \"archive-tag\".\n if ('landPr' in s) errors.push(...validateLandPrSection(s['landPr']));\n\n // Optional: where wp-push-dev publishes the disposable copy. Absent ⇒ \"dev-include\" / \"dev\".\n if ('devDeploy' in s) errors.push(...validateDevDeploySection(s['devDeploy']));\n\n errors.push(...validateNoGateSaltRationale(s));\n\n // Optional: publish reviewer output as a PR comment (defaults true). Must be a boolean when present.\n if ('checklistComments' in s && typeof s['checklistComments'] !== 'boolean') {\n errors.push(\n `[pr-gate] \"checklistComments\" must be a boolean (defaults to true; set false to keep the PR body-only).`,\n );\n }\n\n return errors;\n}\n\n\n// webpieces-disable no-any-unknown -- explicit command configuration JSON is checked field by field\n// webpieces-disable no-function-outside-class -- pure validation helper\nfunction validateActiveGatePolicy(s: Record<string, unknown>, repoRoot: string | undefined): string[] {\n const errors: string[] = [];\n // buildCommand and mergeMode are both required whenever the gate is active (mode !== OFF). There\n // is deliberately NO default for mergeMode: whether the tooling may land your PRs is a policy\n // decision, and either guess is wrong for somebody.\n if (s['mode'] !== 'OFF') {\n const cmd = s['buildCommand'];\n if (typeof cmd !== 'string' || cmd.trim() === '') {\n errors.push(\n `[pr-gate] Missing required field \"buildCommand\" — the command CI runs to validate a PR. ` +\n `Add e.g. \"buildCommand\": \"pnpm nx affected --target=ci --base=$(git merge-base origin/main HEAD)\".`,\n );\n }\n const mm = s['mergeMode'];\n if (!('mergeMode' in s)) {\n errors.push(`[pr-gate] Missing required field \"mergeMode\". ${MERGE_MODE_HELP}`);\n } else if (\n typeof mm !== 'string' ||\n !PR_GATE_MERGE_MODES.includes(mm as (typeof PR_GATE_MERGE_MODES)[number])\n ) {\n errors.push(`[pr-gate] \"mergeMode\" = \"${String(mm)}\" is not valid. ${MERGE_MODE_HELP}`);\n }\n errors.push(...validateReviewerAgentKeys(s, repoRoot));\n }\n\n return errors;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"validate-pr-gate.js","sourceRoot":"","sources":["../../../../../packages/tooling/rules-config/src/validate-pr-gate.ts"],"names":[],"mappings":";;AAyGA,sDA8DC;AAvKD,iEAA6D;AAC7D,6EAAkL;AAGlL,MAAM,aAAa,GAAG,CAAC,IAAI,EAAE,KAAK,CAAU,CAAC;AAC7C,6FAA6F;AAC7F,yFAAyF;AACzF,MAAM,mBAAmB,GAAG,CAAC,MAAM,EAAE,MAAM,CAAU,C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AC,WAAW,CAAC,CAAC;QAC1B,IAAI,CAAC,CAAC,WAAW,IAAI,CAAC,CAAC,EAAE,CAAC;YACtB,MAAM,CAAC,IAAI,CAAC,iDAAiD,eAAe,EAAE,CAAC,CAAC;QACpF,CAAC;aAAM,IACH,OAAO,EAAE,KAAK,QAAQ;YACtB,CAAC,mBAAmB,CAAC,QAAQ,CAAC,EAA0C,CAAC,EAC3E,CAAC;YACC,MAAM,CAAC,IAAI,CAAC,4BAA4B,MAAM,CAAC,EAAE,CAAC,mBAAmB,eAAe,EAAE,CAAC,CAAC;QAC5F,CAAC;QACD,MAAM,CAAC,IAAI,CAAC,GAAG,IAAA,sDAAyB,EAAC,CAAC,EAAE,QAAQ,CAAC,CAAC,CAAC;IAC3D,CAAC;IAED,OAAO,MAAM,CAAC;AAClB,CAAC","sourcesContent":["import { ConfigDocumentation } from './config-documentation';\nimport { validateChecklistsSection, validateDevDeploySection, validateLandPrSection, validateNoGateSaltRationale, validateReviewerAgentKeys } from './pr-gate-section-validators';\nimport * as fs from 'fs';\nimport * as path from 'path';\nconst PR_GATE_MODES = ['ON', 'OFF'] as const;\n// Optional — omitted means DETECT. Kept inline (like prGateExample) to avoid a load-config ↔\n// pr-gate-config import cycle; the canonical list + semantics live in pr-gate-config.ts.\nconst PR_GATE_MERGE_MODES = ['AUTO', 'NONE'] as const;\n\n// Spelled out because the choice is a POLICY decision with a consequence the chooser cannot see:\n// only the AUTO path can put the compact risk/flags body in main's history, because a UI merge is\n// composed from the repo's squash_merge_commit_title/message settings, which the tooling pins.\nconst MERGE_MODE_HELP =\n `Must be one of: ${PR_GATE_MERGE_MODES.join(', ')}.\\n` +\n ` \"AUTO\" — wp-finish-upsert-pr lands the PR: it squash-merges when mergeable, else enables\\n` +\n ` GitHub auto-merge, both with an explicit --subject/--body-file so main's history\\n` +\n ` gets the PR title + the compact risk/flags body. Needs allow_auto_merge on the repo\\n` +\n ` (gh api repos/{owner}/{repo} --jq .allow_auto_merge).\\n` +\n ` \"NONE\" — wp-finish-upsert-pr only opens/updates the PR without attempting to merge. It still\\n` +\n ` lands the compact body: the PR DESCRIPTION *is* that body, and stage \\u2462 keeps the repo's\\n` +\n ` squash_merge_commit_title/message pinned to PR_TITLE/PR_BODY so a UI merge copies it\\n` +\n ` verbatim (SquashSettingsEnforcer). Nothing to set by hand.\\n` +\n ` This is tooling behavior, not an authorization requirement. Honor existing user\\n` +\n ` instructions, including $full-cycle; use pnpm wp-land-pr when landing was requested.`;\n\n// Copy-paste example for the top-level `pr-gate` block (sibling of `rules`). Kept inline rather\n// than imported from pr-gate-config.ts to avoid a load-config ↔ pr-gate-config import cycle.\n// webpieces-disable no-function-outside-class -- pure example renderer beside the public command validator\nfunction prGateExample(): string {\n return (\n ` \"pr-gate\": {\\n` +\n ` \"mode\": \"ON\",\\n` +\n ` \"buildCommand\": \"<command CI runs to validate a PR, e.g. pnpm nx affected --target=ci --base=$(git merge-base origin/main HEAD)>\",\\n` +\n ` \"gates\": [\\n` +\n ` { \"name\": \"API Changed\", \"patterns\": [\"libraries/apis/**\", \"**/*Api.ts\"], \"warningColor\": \"yellow\" }\\n` +\n ` ],\\n` +\n ` \"reviewerAgents\": 1, // REQUIRED — 0 disables reviews; positive values cap subagents per round\\n` +\n ` \"maxReviewerRounds\": 2, // REQUIRED positive integer — caps complete global review rounds\\n` +\n ` \"checklists\": [ // OPTIONAL — per-area review, each against its own doc\\n` +\n ` { \"id\": \"db-migrations\", \"doc\": \".claude/review/db-migrations.md\", \"patterns\": [\"**/*.sql\"], \"required\": true }\\n` +\n ` ]\\n` +\n ` }`\n );\n}\n\n// The `gates` array: dashboard-only warning flags. Extracted from validatePrGateSection to keep that\n// method inside the length limit.\n// webpieces-disable no-any-unknown -- `value` is the opaque consumer `gates` value until narrowed here\n// webpieces-disable no-function-outside-class -- module-level config validator, matches the rest of this file\nfunction validateGatesSection(value: unknown): string[] {\n if (!Array.isArray(value)) {\n return [\n `[pr-gate] \"gates\" must be an array of { name, patterns, warningColor, disabled? }.`,\n ];\n }\n const errors: string[] = [];\n for (let i = 0; i < value.length; i += 1) {\n errors.push(...validateGate(value[i], i));\n }\n return errors;\n}\n\n// webpieces-disable no-any-unknown -- one gate entry from opaque consumer JSON, validated field-by-field\n// webpieces-disable no-function-outside-class -- pure field validator beside the public command validator\nfunction validateGate(gate: unknown, index: number): string[] {\n if (typeof gate !== 'object' || gate === null) {\n return [\n `[pr-gate] gates[${index}] must be an object { name, patterns, warningColor, disabled? }.`,\n ];\n }\n // webpieces-disable no-any-unknown -- narrowing one opaque gate object from consumer JSON\n const g = gate as Record<string, unknown>;\n const errors: string[] = [];\n if (typeof g['name'] !== 'string')\n errors.push(`[pr-gate] gates[${index}].name must be a string.`);\n if (\n !Array.isArray(g['patterns']) ||\n // webpieces-disable no-any-unknown -- opaque config patterns are checked before use\n !g['patterns'].every((p: unknown) => typeof p === 'string')\n )\n errors.push(`[pr-gate] gates[${index}].patterns must be string[].`);\n if (g['warningColor'] === undefined)\n errors.push(\n `[pr-gate] gates[${index}].warningColor is required — set it to \"yellow\" or \"red\" (green is implicit when nothing matches).`,\n );\n else if (g['warningColor'] !== 'yellow' && g['warningColor'] !== 'red')\n errors.push(\n `[pr-gate] gates[${index}].warningColor must be \"yellow\" or \"red\" (green is implicit when nothing matches).`,\n );\n if (g['disabled'] !== undefined && typeof g['disabled'] !== 'boolean')\n errors.push(\n `[pr-gate] gates[${index}].disabled must be a boolean (example/inactive gate kept in the file).`,\n );\n return errors;\n}\n\n/**\n * Validate the top-level `pr-gate` section. It is REQUIRED (a client that opts out sets mode \"OFF\").\n * `buildCommand` is required unless mode is \"OFF\". Returns human-readable, copy-paste-friendly errors\n * — never throws. The pr-gate block lives outside the FieldDef-driven `rules` schema because its\n * nested `gates`/`checklists` arrays can't be expressed there, so they get structural validation here.\n * `repoRoot` (when known) lets the `checklists[].docs` existence check run.\n */\n// webpieces-disable no-any-unknown -- `section` is opaque consumer JSON until narrowed below\n// webpieces-disable no-function-outside-class -- module-level config validator, matches the rest of this file\nexport function validatePrGateSection(section: unknown, repoRoot?: string): string[] {\n if (section === undefined || section === null) {\n return [\n `[pr-gate] Not configured in webpieces.config.json. Add this block under the \"commands\" ` +\n `section (set \"mode\": \"OFF\" to opt out):\\n\\n${prGateExample()}`,\n ];\n }\n if (typeof section !== 'object' || Array.isArray(section)) {\n return [`[pr-gate] Must be an object. Example:\\n\\n${prGateExample()}`];\n }\n // webpieces-disable no-any-unknown -- narrowing the opaque pr-gate section from consumer JSON\n const s = section as Record<string, unknown>;\n const errors: string[] = new ConfigDocumentation().inlineErrors(section, '[pr-gate]');\n\n if (!('mode' in s)) {\n errors.push(\n `[pr-gate] Missing required field \"mode\". Must be one of: ${PR_GATE_MODES.join(', ')}.`,\n );\n } else if (\n typeof s['mode'] !== 'string' ||\n !PR_GATE_MODES.includes(s['mode'] as (typeof PR_GATE_MODES)[number])\n ) {\n errors.push(\n `[pr-gate] \"mode\" = \"${String(s['mode'])}\" is not valid. Must be one of: ${PR_GATE_MODES.join(', ')}.`,\n );\n }\n\n errors.push(...validateActiveGatePolicy(s, repoRoot));\n\n if ('gates' in s) errors.push(...validateGatesSection(s['gates']));\n\n // Optional extension point: company review checklists, as an ARRAY right here in the config. Absent ⇒\n // none. The removed { doc } manifest shape is rejected with the exact migration edit.\n if ('checklists' in s) errors.push(...validateChecklistsSection(s['checklists'], repoRoot));\n\n // Optional server-token salt. Absent ⇒ no token minted, CI enforcement is a no-op. Present ⇒ must be\n // a non-empty string (an empty salt would mint a token anyone can forge from a known-empty secret).\n if ('gateSalt' in s) {\n const salt = s['gateSalt'];\n if (typeof salt !== 'string' || salt.trim() === '') {\n errors.push(\n `[pr-gate] \"gateSalt\" must be a non-empty string — it is the shared secret the gate token is HMAC'd with. Omit the key entirely to disable server-side token enforcement.`,\n );\n }\n }\n\n // Optional: what happens to the LOCAL branch once its PR lands. Absent ⇒ \"archive-tag\".\n if ('landPr' in s) errors.push(...validateLandPrSection(s['landPr']));\n\n // Optional: where wp-finish-push-dev publishes the disposable copy. Absent ⇒ \"dev-include\" / \"dev\".\n if ('devDeploy' in s) errors.push(...validateDevDeploySection(s['devDeploy']));\n\n errors.push(...validateNoGateSaltRationale(s));\n\n // Optional: publish reviewer output as a PR comment (defaults true). Must be a boolean when present.\n if ('checklistComments' in s && typeof s['checklistComments'] !== 'boolean') {\n errors.push(\n `[pr-gate] \"checklistComments\" must be a boolean (defaults to true; set false to keep the PR body-only).`,\n );\n }\n\n return errors;\n}\n\n\n// webpieces-disable no-any-unknown -- explicit command configuration JSON is checked field by field\n// webpieces-disable no-function-outside-class -- pure validation helper\nfunction validateActiveGatePolicy(s: Record<string, unknown>, repoRoot: string | undefined): string[] {\n const errors: string[] = [];\n // buildCommand and mergeMode are both required whenever the gate is active (mode !== OFF). There\n // is deliberately NO default for mergeMode: whether the tooling may land your PRs is a policy\n // decision, and either guess is wrong for somebody.\n if (s['mode'] !== 'OFF') {\n const cmd = s['buildCommand'];\n if (typeof cmd !== 'string' || cmd.trim() === '') {\n errors.push(\n `[pr-gate] Missing required field \"buildCommand\" — the command CI runs to validate a PR. ` +\n `Add e.g. \"buildCommand\": \"pnpm nx affected --target=ci --base=$(git merge-base origin/main HEAD)\".`,\n );\n }\n const mm = s['mergeMode'];\n if (!('mergeMode' in s)) {\n errors.push(`[pr-gate] Missing required field \"mergeMode\". ${MERGE_MODE_HELP}`);\n } else if (\n typeof mm !== 'string' ||\n !PR_GATE_MERGE_MODES.includes(mm as (typeof PR_GATE_MERGE_MODES)[number])\n ) {\n errors.push(`[pr-gate] \"mergeMode\" = \"${String(mm)}\" is not valid. ${MERGE_MODE_HELP}`);\n }\n errors.push(...validateReviewerAgentKeys(s, repoRoot));\n }\n\n return errors;\n}\n"]}
|
|
@@ -77,10 +77,10 @@ put reusable config instructions in this guide's source template. Generated file
|
|
|
77
77
|
|
|
78
78
|
## The dev-deploy build: `commands.push-dev.buildCommand`
|
|
79
79
|
|
|
80
|
-
`wp-push-dev` merges `origin/dev` into a throwaway branch and runs this command
|
|
81
|
-
|
|
80
|
+
`wp-build-push-dev` merges `origin/dev` into a throwaway branch, runs `pnpm install`, and runs this command
|
|
81
|
+
on the merged tree; `wp-finish-push-dev` publishes only the copy it verified. It has NO default — which
|
|
82
82
|
build vouches for a dev publish is this repo's decision. The section is optional (a repo that never
|
|
83
|
-
publishes to a shared dev server needs none), but
|
|
83
|
+
publishes to a shared dev server needs none), but `wp-build-push-dev` refuses without it, and a present
|
|
84
84
|
`push-dev` section must carry a non-empty `buildCommand`:
|
|
85
85
|
|
|
86
86
|
```json
|
|
@@ -189,11 +189,11 @@ There are **two destinations**, and they are opposites. Answer this first:
|
|
|
189
189
|
| You want… | Use | It touches |
|
|
190
190
|
|---|---|---|
|
|
191
191
|
| the change **landed on `main`** (prod-quality, reviewed) | the PR flow below | your branch, a PR, eventually `main` |
|
|
192
|
-
| the change **running on the shared dev server**, no PR | `pnpm wp-push-dev` |
|
|
192
|
+
| the change **running on the shared dev server**, no PR | `pnpm wp-start-push-dev` → `wp-build-push-dev` → `wp-finish-push-dev` | your branch (brought up to date with main), then a disposable copy |
|
|
193
193
|
|
|
194
194
|
**Do NOT open a PR to `main` just to test something in a shared dev environment.** That is the single
|
|
195
195
|
most expensive mistake available here: it ships unreviewed work toward production to answer a question
|
|
196
|
-
the dev environment exists to answer.
|
|
196
|
+
the dev environment exists to answer. That three-stage flow is the answer to "get my branch onto dev", and
|
|
197
197
|
the push guard's block message will say so when your `git push` targets the dev refs.
|
|
198
198
|
|
|
199
199
|
See "Publishing to the shared dev server" below. Everything from here to that section is the **main**
|
|
@@ -303,36 +303,59 @@ snapshots are never loaded as active summaries; a new PR requires its own author
|
|
|
303
303
|
The numbers in a `--delete-*` flag are the numbers printed on the SAME run — wp-cleanup renumbers
|
|
304
304
|
from a fresh scan every time, and a number past the end of the block stops the run rather than
|
|
305
305
|
deleting the wrong ref. An explicit flag always beats the terminal sniff.
|
|
306
|
-
8. **`pnpm wp-push-dev`** —
|
|
307
|
-
|
|
308
|
-
See below.
|
|
309
|
-
9. **`pnpm wp-
|
|
310
|
-
|
|
311
|
-
10. **`pnpm wp-
|
|
306
|
+
8. **`pnpm wp-start-push-dev`** — stage ① of publishing to the shared dev server: bring this branch up to
|
|
307
|
+
date with `origin/main` (the same 3-point merge as `wp-start-update`), ONLY if it is behind. No PR is
|
|
308
|
+
opened. See below.
|
|
309
|
+
9. **`pnpm wp-build-push-dev`** — stage ②: check this branch against `origin/dev` on a throwaway merge,
|
|
310
|
+
`pnpm install`, and run `commands.push-dev.buildCommand`. Publishes nothing.
|
|
311
|
+
10. **`pnpm wp-finish-push-dev`** — stage ③: publish the copy stage ② verified as `dev-include/<branch>`.
|
|
312
|
+
Also `--list` (what is in the pool) and `--remove` (the rollback).
|
|
312
313
|
|
|
313
314
|
## Publishing to the shared dev server (no PR, nothing lands on main)
|
|
314
315
|
|
|
315
|
-
Some repos deploy a shared `dev` branch that is a **build artifact, not a source of truth**: CI
|
|
316
|
-
|
|
317
|
-
|
|
316
|
+
Some repos deploy a shared `dev` branch that is a **build artifact, not a source of truth**: CI composes
|
|
317
|
+
it from `origin/main` plus every published copy and deploys it. Nobody ever checks it out.
|
|
318
|
+
|
|
319
|
+
Publishing is three stages, the same shape as the PR flow:
|
|
318
320
|
|
|
319
321
|
```bash
|
|
320
|
-
pnpm wp-push-dev
|
|
321
|
-
|
|
322
|
-
pnpm wp-push-dev
|
|
323
|
-
|
|
322
|
+
pnpm wp-start-push-dev # ① 3-point merge from origin/main — ONLY if your branch is behind it
|
|
323
|
+
# conflict → resolve with /wp-merge, then go on to ②
|
|
324
|
+
pnpm wp-build-push-dev # ② merge origin/dev into a throwaway, pnpm install, run the dev build
|
|
325
|
+
# conflict → resolve on the throwaway, `git add`, re-run ②
|
|
326
|
+
pnpm wp-finish-push-dev # ③ publish the copy ② verified as dev-include/<your-branch>
|
|
327
|
+
|
|
328
|
+
pnpm wp-finish-push-dev --list # what is currently in the pool
|
|
329
|
+
pnpm wp-finish-push-dev --remove # take your branch back out (this is the rollback)
|
|
324
330
|
```
|
|
325
331
|
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
332
|
+
`--remove` is for rolling back a copy that broke dev. When you are done testing, or after your PR lands,
|
|
333
|
+
leave the copy alone: the business-day reset removes it. Re-publishing replaces your own copy, so you
|
|
334
|
+
don't need to remove it first.
|
|
335
|
+
|
|
336
|
+
**① Why every copy starts from the latest main.** A branch forked from an old main builds against a
|
|
337
|
+
`node_modules` that is missing whatever main added since, and dev already contains it — so the dev build
|
|
338
|
+
fails for reasons that have nothing to do with your change. `wp-start-push-dev` runs the SAME 3-point
|
|
339
|
+
merge as `wp-start-update` / `wp-start-upsert-pr`, and does nothing when the branch already contains
|
|
340
|
+
`origin/main`. It REWRITES your branch (that is expected). With no open PR it pushes the rewrite to
|
|
341
|
+
`origin/<your-branch>` like `wp-start-update`; with an open PR it keeps it local like
|
|
342
|
+
`wp-start-upsert-pr`, and the PR is updated by your next `wp-start-upsert-pr` → `wp-finish-upsert-pr`. A
|
|
343
|
+
conflict is resolved with `/wp-merge` on your own branch; `wp-build-push-dev` then validates and
|
|
344
|
+
finalizes that merge before anything else. `wp-build-push-dev` refuses a branch that is still behind
|
|
345
|
+
`origin/main`, naming `wp-start-push-dev`.
|
|
346
|
+
|
|
347
|
+
**② What `wp-build-push-dev` checks.** It fetches `origin/dev`, merges it into a THROWAWAY branch
|
|
348
|
+
(`<your-branch>DevResolve`, never your branch), runs `pnpm install` — other copies on dev can add
|
|
349
|
+
workspace packages main does not have yet — and runs `commands.push-dev.buildCommand` on the merged tree.
|
|
329
350
|
So a conflict or a broken build is found on your machine, in a minute, instead of after the shared
|
|
330
351
|
composition fails. The build output goes to a log file; read the `FullLog :` path it prints rather than
|
|
331
|
-
re-running it.
|
|
352
|
+
re-running it. When it is green it records the copy it verified and puts you back on your branch.
|
|
332
353
|
|
|
333
|
-
**What
|
|
354
|
+
**What ③ publishes is never that merge.** The copy is your branch exactly as it is, plus — only when
|
|
334
355
|
something conflicted — ONE commit holding the files you resolved. A copy that contained `dev` would carry
|
|
335
356
|
every other copy's history, and a later `--remove` of one of them would leave it on dev through yours.
|
|
357
|
+
`wp-finish-push-dev` refuses when your branch moved after ② verified it (re-run ②), and force-pushes the
|
|
358
|
+
copy (leased against the sha ② saw), so the push event carries the previous copy's sha.
|
|
336
359
|
|
|
337
360
|
**`commands.push-dev.buildCommand` has no default.** Configure the dev-scoped build in
|
|
338
361
|
`webpieces.config.json` (it should build only what differs from `origin/dev`, so it stays fast):
|
|
@@ -341,8 +364,9 @@ every other copy's history, and a later `--remove` of one of them would leave it
|
|
|
341
364
|
"commands": { "push-dev": { "buildCommand": "pnpm nx affected --target=ci --base=origin/dev --head=HEAD" } }
|
|
342
365
|
```
|
|
343
366
|
|
|
344
|
-
Without it, `wp-push-dev`
|
|
345
|
-
|
|
367
|
+
Without it, `wp-build-push-dev` refuses before touching anything and prints that entry. When `origin/dev`
|
|
368
|
+
does not exist yet (the very first composition), ② has nothing to check against and verifies the branch
|
|
369
|
+
as it is.
|
|
346
370
|
|
|
347
371
|
`--remove` deletes `dev-include/<your-branch>` **and then** pushes a content-free marker
|
|
348
372
|
`dev-remove/<your-branch>` at the `origin/main` tip. The marker push is the rebuild signal: a deletion
|
|
@@ -350,6 +374,12 @@ alone can only be heard by a workflow's `on: delete:`, which GitHub cannot filte
|
|
|
350
374
|
branch deletion in the repo would start a dev-deploy run. If the marker push fails, the command stops
|
|
351
375
|
and says so — your copy is already gone, but `dev` was **not** rebuilt; follow what it prints.
|
|
352
376
|
|
|
377
|
+
`--remove` **refuses** when the copy is already on `origin/main` — every file it changes (relative to its
|
|
378
|
+
merge-base with `origin/main`) already has the copy's content there. Removing it would take nothing off
|
|
379
|
+
dev, because main keeps it there, and would only force a full recompose; nothing is deleted and no marker
|
|
380
|
+
is pushed. If that code is what broke dev, the fix is a revert PR against main. When only SOME of those
|
|
381
|
+
files are on main, `--remove` warns, naming them, and removes the rest.
|
|
382
|
+
|
|
353
383
|
The three names come from `pr-gate.devDeploy` in `webpieces.config.json` — `branchNamespace`
|
|
354
384
|
(default `dev-include`), `devBranch` (default `dev`) and `removeNamespace` (default `dev-remove`) —
|
|
355
385
|
substitute them below if the repo overrides any.
|
|
@@ -363,25 +393,26 @@ on:
|
|
|
363
393
|
# no `delete:` trigger — it cannot be filtered by branch, so every deletion in the repo would start a run
|
|
364
394
|
```
|
|
365
395
|
|
|
366
|
-
On a `dev-remove/**` push the workflow deletes that marker ref
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
396
|
+
On a `dev-remove/**` push the workflow deletes that marker ref and takes the copy back out of `dev`. A
|
|
397
|
+
workflow still listening on `on: delete:` keeps working too, because `--remove` still deletes the copy —
|
|
398
|
+
add the `dev-remove/**` trigger first, upgrade webpieces, then drop `delete:`. Because ① rewrites the
|
|
399
|
+
branch, a re-published copy is usually a rewrite of the previous one; the push event's `before` sha is
|
|
400
|
+
that previous copy, which is what a workflow needs to apply only the difference.
|
|
370
401
|
|
|
371
402
|
**The cardinal rule, and the reason a COPY exists at all:** your feature branch is the PR head, so it
|
|
372
403
|
must **never** acquire another developer's commits — landing that PR would ship their unreviewed work to
|
|
373
|
-
production.
|
|
374
|
-
|
|
404
|
+
production. The dev merge and any resolution of it therefore happen on the throwaway, never on your
|
|
405
|
+
branch. (① merges `origin/main` into your branch, which is exactly what the PR flow does anyway.)
|
|
375
406
|
|
|
376
407
|
### Is it deployed yet? — two questions, in this order
|
|
377
408
|
|
|
378
|
-
`wp-push-dev` prints both, **fully substituted with your sha and refs**, so you can paste them straight
|
|
409
|
+
`wp-finish-push-dev` prints both, **fully substituted with your sha and refs**, so you can paste them straight
|
|
379
410
|
in. Nothing here is blocked: they are read-only git queries plus `gh run list|watch|view`.
|
|
380
411
|
|
|
381
412
|
1. **Did YOUR code land in the composed branch?** Pure git, works whatever the CI is:
|
|
382
413
|
```bash
|
|
383
414
|
git fetch origin dev
|
|
384
|
-
git merge-base --is-ancestor <the sha wp-push-dev printed> origin/dev && echo IN || echo "not yet"
|
|
415
|
+
git merge-base --is-ancestor <the sha wp-finish-push-dev printed> origin/dev && echo IN || echo "not yet"
|
|
385
416
|
```
|
|
386
417
|
`dev` is rebuilt from `origin/main` plus every copy on each run, so **ancestry is inclusion**. If it
|
|
387
418
|
says "not yet", the composition simply has not run since you published — re-check, do not re-push.
|
|
@@ -399,48 +430,24 @@ in. Nothing here is blocked: they are read-only git queries plus `gh run list|wa
|
|
|
399
430
|
composition may have excluded yours. Question 1 is the one that answers for *your* code; question 2 only
|
|
400
431
|
tells you the machinery finished. Answer them in that order, and report both.
|
|
401
432
|
|
|
402
|
-
### When `wp-push-dev` stops on a conflict
|
|
433
|
+
### When `wp-build-push-dev` stops on a conflict with dev
|
|
403
434
|
|
|
404
435
|
It stops on the THROWAWAY branch and lists the files. Resolve them, `git add` each one, then:
|
|
405
436
|
|
|
406
437
|
```bash
|
|
407
|
-
pnpm wp-
|
|
408
|
-
pnpm wp-
|
|
409
|
-
```
|
|
410
|
-
|
|
411
|
-
### When two branches conflict in the composition
|
|
412
|
-
|
|
413
|
-
CI will name the branch you conflict with. Compose locally, so what you resolve is what CI will build:
|
|
414
|
-
|
|
415
|
-
```bash
|
|
416
|
-
pnpm wp-push-dev --resolve # merge every OTHER copy, in CI's order
|
|
417
|
-
pnpm wp-push-dev --resolve <their-branch> # or just the one CI named
|
|
418
|
-
# clean → nothing to publish: CI already composes your copy as it is
|
|
419
|
-
# CONFLICT → it stops on a THROWAWAY branch and lists the files
|
|
420
|
-
# resolve them, `git add` each one, then:
|
|
421
|
-
pnpm wp-finish-push-dev # commits, resumes the queue, publishes
|
|
422
|
-
pnpm wp-finish-push-dev --abort # or throw it all away
|
|
438
|
+
pnpm wp-build-push-dev # commits the resolution, pnpm install, runs the dev build
|
|
439
|
+
pnpm wp-build-push-dev --abort # or throw it all away
|
|
423
440
|
```
|
|
424
441
|
|
|
425
|
-
Either way, what is published is your copy plus ONE commit holding the resolved files — never a merge of
|
|
426
|
-
the other copies.
|
|
427
|
-
|
|
428
442
|
While a resolve is half-finished the other `wp-*` commands refuse (you are parked on a throwaway branch,
|
|
429
443
|
not your feature branch). The block message lists exactly which ones and how to get out.
|
|
430
444
|
|
|
431
445
|
**Do not run `git merge --continue`, `git commit` or `git push` yourself** — they are blocked, and
|
|
432
|
-
`wp-finish-push-dev`
|
|
433
|
-
them; neither is blocked.
|
|
434
|
-
|
|
435
|
-
### If your copy already holds a resolution
|
|
436
|
-
|
|
437
|
-
`wp-push-dev` **refuses** rather than force-pushing over commits the copy has and your branch does not —
|
|
438
|
-
that is somebody's real work, and it exists only there, by design. (A resolution commit `wp-push-dev`
|
|
439
|
-
recorded itself is the exception: the next publish re-checks against dev and records it again, so it is
|
|
440
|
-
replaced without asking.) Two ways forward:
|
|
446
|
+
`wp-build-push-dev` / `wp-finish-push-dev` do them for you. Your only job is editing the conflicted files
|
|
447
|
+
and `git add`-ing them; neither is blocked.
|
|
441
448
|
|
|
442
|
-
|
|
443
|
-
|
|
449
|
+
Conflicts between two developers' published copies are not resolved here: ② merges `origin/dev`, which
|
|
450
|
+
already holds the other copies, so what you resolve is what the composition will meet.
|
|
444
451
|
|
|
445
452
|
## Worktrees (works the same as a primary clone)
|
|
446
453
|
|