@webpieces/pr-gate 0.4.828 → 0.4.830
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 +4 -3
- package/src/dashboard/dashboard.js +8 -5
- package/src/dashboard/dashboard.js.map +1 -1
- package/src/index.js +1 -1
- package/src/index.js.map +1 -1
- package/src/scripts/commands/finish-upsert-pr-command.d.ts +4 -7
- package/src/scripts/commands/finish-upsert-pr-command.js +11 -29
- package/src/scripts/commands/finish-upsert-pr-command.js.map +1 -1
- package/src/scripts/commands/review-upsert-pr-command.d.ts +4 -5
- package/src/scripts/commands/review-upsert-pr-command.js +7 -13
- package/src/scripts/commands/review-upsert-pr-command.js.map +1 -1
- package/src/scripts/commands/start-upsert-pr-command.d.ts +4 -6
- package/src/scripts/commands/start-upsert-pr-command.js +12 -24
- package/src/scripts/commands/start-upsert-pr-command.js.map +1 -1
- package/src/scripts/commands/upsert-hotfix-pr-command.d.ts +73 -0
- package/src/scripts/commands/upsert-hotfix-pr-command.js +277 -0
- package/src/scripts/commands/upsert-hotfix-pr-command.js.map +1 -0
- package/src/scripts/pr-gate-app.d.ts +8 -1
- package/src/scripts/pr-gate-app.js +13 -1
- package/src/scripts/pr-gate-app.js.map +1 -1
- package/src/scripts/workflow/hotfix-pr-publisher.d.ts +21 -0
- package/src/scripts/workflow/hotfix-pr-publisher.js +46 -0
- package/src/scripts/workflow/hotfix-pr-publisher.js.map +1 -0
- package/src/scripts/workflow/hotfix-redirect.d.ts +20 -0
- package/src/scripts/workflow/hotfix-redirect.js +53 -0
- package/src/scripts/workflow/hotfix-redirect.js.map +1 -0
- package/src/scripts/workflow/push-dev-state.js +1 -0
- package/src/scripts/workflow/push-dev-state.js.map +1 -1
- package/src/scripts/wp-upsert-hotfix-pr.d.ts +2 -0
- package/src/scripts/wp-upsert-hotfix-pr.js +17 -0
- package/src/scripts/wp-upsert-hotfix-pr.js.map +1 -0
- package/src/scripts/workflow/hotfix-finish-preparer.d.ts +0 -38
- package/src/scripts/workflow/hotfix-finish-preparer.js +0 -114
- package/src/scripts/workflow/hotfix-finish-preparer.js.map +0 -1
- package/src/scripts/workflow/hotfix-instructions.d.ts +0 -5
- package/src/scripts/workflow/hotfix-instructions.js +0 -46
- package/src/scripts/workflow/hotfix-instructions.js.map +0 -1
|
@@ -22,6 +22,7 @@ const await_checks_command_1 = require("./commands/await-checks-command");
|
|
|
22
22
|
const push_dev_command_1 = require("./commands/push-dev-command");
|
|
23
23
|
const finish_push_dev_command_1 = require("./commands/finish-push-dev-command");
|
|
24
24
|
const human_post_pr_command_1 = require("./commands/human-post-pr-command");
|
|
25
|
+
const upsert_hotfix_pr_command_1 = require("./commands/upsert-hotfix-pr-command");
|
|
25
26
|
const push_dev_state_1 = require("./workflow/push-dev-state");
|
|
26
27
|
const rules_config_2 = require("@webpieces/rules-config");
|
|
27
28
|
/**
|
|
@@ -49,9 +50,10 @@ let PrGateApp = class PrGateApp {
|
|
|
49
50
|
pushDevCommand;
|
|
50
51
|
finishPushDevCommand;
|
|
51
52
|
humanPostPrCommand;
|
|
53
|
+
upsertHotfixPrCommand;
|
|
52
54
|
pushDevStateStore;
|
|
53
55
|
repoRootFinder;
|
|
54
|
-
constructor(startUpdateCommand, finishUpdateCommand, startUpsertPrCommand, finishUpsertPrCommand, cleanupCommand, syncMainCommand, landPrCommand, checkPrCommand, reviewUpsertPrCommand, reapWorktreeCommand, buildCommand, awaitReviewsCommand, writeReviewCommand, writeReviewFixesCommand, awaitChecksCommand, pushDevCommand, finishPushDevCommand, humanPostPrCommand, pushDevStateStore, repoRootFinder) {
|
|
56
|
+
constructor(startUpdateCommand, finishUpdateCommand, startUpsertPrCommand, finishUpsertPrCommand, cleanupCommand, syncMainCommand, landPrCommand, checkPrCommand, reviewUpsertPrCommand, reapWorktreeCommand, buildCommand, awaitReviewsCommand, writeReviewCommand, writeReviewFixesCommand, awaitChecksCommand, pushDevCommand, finishPushDevCommand, humanPostPrCommand, upsertHotfixPrCommand, pushDevStateStore, repoRootFinder) {
|
|
55
57
|
this.startUpdateCommand = startUpdateCommand;
|
|
56
58
|
this.finishUpdateCommand = finishUpdateCommand;
|
|
57
59
|
this.startUpsertPrCommand = startUpsertPrCommand;
|
|
@@ -70,6 +72,7 @@ let PrGateApp = class PrGateApp {
|
|
|
70
72
|
this.pushDevCommand = pushDevCommand;
|
|
71
73
|
this.finishPushDevCommand = finishPushDevCommand;
|
|
72
74
|
this.humanPostPrCommand = humanPostPrCommand;
|
|
75
|
+
this.upsertHotfixPrCommand = upsertHotfixPrCommand;
|
|
73
76
|
this.pushDevStateStore = pushDevStateStore;
|
|
74
77
|
this.repoRootFinder = repoRootFinder;
|
|
75
78
|
}
|
|
@@ -164,6 +167,14 @@ let PrGateApp = class PrGateApp {
|
|
|
164
167
|
this.assertNoResolveInProgress('wp-human-post-pr');
|
|
165
168
|
return this.humanPostPrCommand.run();
|
|
166
169
|
}
|
|
170
|
+
/**
|
|
171
|
+
* `wp-upsert-hotfix-pr`: the one command for a `/hotfix/` branch — `hotfix-ci` gate, no merge from
|
|
172
|
+
* main, one fast-forward push, upsert the bannered PR, never auto-merge (issue #1057).
|
|
173
|
+
*/
|
|
174
|
+
upsertHotfixPr() {
|
|
175
|
+
this.assertNoResolveInProgress('wp-upsert-hotfix-pr');
|
|
176
|
+
return this.upsertHotfixPrCommand.run();
|
|
177
|
+
}
|
|
167
178
|
/**
|
|
168
179
|
* `wp-cleanup`: reap what is provably merged AND every zero-commit husk, then report the rest with
|
|
169
180
|
* the exact flags that take it. `options` carries what argv said — see CleanupOptions.
|
|
@@ -226,6 +237,7 @@ exports.PrGateApp = PrGateApp = tslib_1.__decorate([
|
|
|
226
237
|
push_dev_command_1.PushDevCommand,
|
|
227
238
|
finish_push_dev_command_1.FinishPushDevCommand,
|
|
228
239
|
human_post_pr_command_1.HumanPostPrCommand,
|
|
240
|
+
upsert_hotfix_pr_command_1.UpsertHotfixPrCommand,
|
|
229
241
|
push_dev_state_1.PushDevStateStore,
|
|
230
242
|
rules_config_2.RepoRootFinder])
|
|
231
243
|
], PrGateApp);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pr-gate-app.js","sourceRoot":"","sources":["../../../../../../packages/tooling/pr-gate/src/scripts/pr-gate-app.ts"],"names":[],"mappings":";;;;AAAA,0DAAyD;AACzD,yCAA2D;AAC3D,0EAAqE;AACrE,4EAAuE;AACvE,gFAA0E;AAC1E,kFAA4E;AAC5E,gEAA4D;AAE5D,oEAA+D;AAC/D,gEAA0E;AAC1E,kEAA6D;AAC7D,kFAAmG;AACnG,4EAAuE;AACvE,4DAAsE;AACtE,4EAAuE;AACvE,0EAAmH;AACnH,sFAAyG;AACzG,0EAAyF;AACzF,kEAA6E;AAC7E,gFAAgG;AAChG,4EAAsE;AACtE,8DAA8D;AAC9D,0DAAyD;AAEzD;;;;;GAKG;AAGI,IAAM,SAAS,GAAf,MAAM,SAAS;IAEG;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IApBrB,YACqB,kBAAsC,EACtC,mBAAwC,EACxC,oBAA0C,EAC1C,qBAA4C,EAC5C,cAA8B,EAC9B,eAAgC,EAChC,aAA4B,EAC5B,cAA8B,EAC9B,qBAA4C,EAC5C,mBAAwC,EACxC,YAA0B,EAC1B,mBAAwC,EACxC,kBAAsC,EACtC,uBAAgD,EAChD,kBAAsC,EACtC,cAA8B,EAC9B,oBAA0C,EAC1C,kBAAsC,EACtC,iBAAoC,EACpC,cAA8B;QAnB9B,uBAAkB,GAAlB,kBAAkB,CAAoB;QACtC,wBAAmB,GAAnB,mBAAmB,CAAqB;QACxC,yBAAoB,GAApB,oBAAoB,CAAsB;QAC1C,0BAAqB,GAArB,qBAAqB,CAAuB;QAC5C,mBAAc,GAAd,cAAc,CAAgB;QAC9B,oBAAe,GAAf,eAAe,CAAiB;QAChC,kBAAa,GAAb,aAAa,CAAe;QAC5B,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oB;QACtB,0CAAkB;QACnB,kCAAiB;QACpB,6BAAc;GArB1C,SAAS,CA+KrB","sourcesContent":["import { DocumentDesign } from '@webpieces/rules-config';\nimport { injectable, bindingScopeValues } from 'inversify';\nimport { StartUpdateCommand } from './commands/start-update-command';\nimport { FinishUpdateCommand } from './commands/finish-update-command';\nimport { StartUpsertPrCommand } from './commands/start-upsert-pr-command';\nimport { FinishUpsertPrCommand } from './commands/finish-upsert-pr-command';\nimport { CleanupCommand } from './commands/cleanup-command';\nimport { CleanupOptions } from './commands/cleanup-options';\nimport { SyncMainCommand } from './commands/sync-main-command';\nimport { LandPrCommand, LandPrRequest } from './commands/land-pr-command';\nimport { CheckPrCommand } from './commands/check-pr-command';\nimport { ReviewUpsertPrCommand, ReviewUpsertPrOptions } from './commands/review-upsert-pr-command';\nimport { ReapWorktreeCommand } from './commands/reap-worktree-command';\nimport { BuildCommand, BuildOptions } from './commands/build-command';\nimport { AwaitReviewsCommand } from './commands/await-reviews-command';\nimport { ReviewBudgetCheckOptions, WriteReviewCommand, WriteReviewOptions } from './commands/write-review-command';\nimport { WriteReviewFixesCommand, WriteReviewFixesOptions } from './commands/write-review-fixes-command';\nimport { AwaitChecksCommand, AwaitChecksOptions } from './commands/await-checks-command';\nimport { PushDevCommand, PushDevOptions } from './commands/push-dev-command';\nimport { FinishPushDevCommand, FinishPushDevOptions } from './commands/finish-push-dev-command';\nimport { HumanPostPrCommand } from './commands/human-post-pr-command';\nimport { PushDevStateStore } from './workflow/push-dev-state';\nimport { RepoRootFinder } from '@webpieces/rules-config';\n\n/**\n * The pr-gate application root. `container.get(PrGateApp)` resolves the entire workflow DAG (the command\n * classes → the injected git/merge/dashboard services). `@DocumentDesign` marks it the\n * top-of-DAG the DI-design analyzer roots on, so `role:app` pr-gate draws its design. Each `bin/*`\n * entry resolves THIS and calls the matching command method.\n */\n@DocumentDesign()\n@injectable(bindingScopeValues.Singleton)\nexport class PrGateApp {\n constructor(\n private readonly startUpdateCommand: StartUpdateCommand,\n private readonly finishUpdateCommand: FinishUpdateCommand,\n private readonly startUpsertPrCommand: StartUpsertPrCommand,\n private readonly finishUpsertPrCommand: FinishUpsertPrCommand,\n private readonly cleanupCommand: CleanupCommand,\n private readonly syncMainCommand: SyncMainCommand,\n private readonly landPrCommand: LandPrCommand,\n private readonly checkPrCommand: CheckPrCommand,\n private readonly reviewUpsertPrCommand: ReviewUpsertPrCommand,\n private readonly reapWorktreeCommand: ReapWorktreeCommand,\n private readonly buildCommand: BuildCommand,\n private readonly awaitReviewsCommand: AwaitReviewsCommand,\n private readonly writeReviewCommand: WriteReviewCommand,\n private readonly writeReviewFixesCommand: WriteReviewFixesCommand,\n private readonly awaitChecksCommand: AwaitChecksCommand,\n private readonly pushDevCommand: PushDevCommand,\n private readonly finishPushDevCommand: FinishPushDevCommand,\n private readonly humanPostPrCommand: HumanPostPrCommand,\n private readonly pushDevStateStore: PushDevStateStore,\n private readonly repoRootFinder: RepoRootFinder,\n ) {}\n\n /**\n * Refuse `command` while a `wp-push-dev --resolve` is half-finished.\n *\n * Enforced HERE, at the one place every bin funnels through, rather than in each command: a resolve\n * parks the checkout on a throwaway branch, so every command below would act on a branch that is not\n * the one it thinks it is. Putting the check in nine constructors is nine chances to forget it in the\n * tenth. PushDevStateStore owns the blocked list AND renders the hint from it, so the two cannot drift.\n */\n private assertNoResolveInProgress(command: string): void {\n if (!this.pushDevStateStore.isBlockedDuringResolve(command)) return;\n this.pushDevStateStore.assertIdle(\n this.repoRootFinder.resolveRepoRoot(process.cwd()),\n command,\n );\n }\n\n /** `wp-push-dev`: publish a DISPOSABLE copy of this branch for the shared dev environment. No PR, no build. */\n pushDev(opts: PushDevOptions = new PushDevOptions()): Promise<void> {\n return this.pushDevCommand.run(opts);\n }\n\n /** `wp-finish-push-dev`: commit a resolved dev composition and publish it (conflict path only). */\n finishPushDev(opts: FinishPushDevOptions = new FinishPushDevOptions()): Promise<void> {\n return this.finishPushDevCommand.run(opts);\n }\n\n /**\n * INTERNAL (`wp-reap-worktree.js`, no `bin` entry): remove ONE named worktree and its branch.\n * `wp-land-pr` spawns it with cwd = the primary clone so the tree it just landed from can be\n * reaped by a process that is not standing in it.\n */\n reapWorktree(args: string[]): Promise<void> {\n return this.reapWorktreeCommand.run(args);\n }\n\n /**\n * `wp-build`: run this repo's ONE configured build (`commands.pr-gate.buildCommand`) — the same\n * command, resolved by the same resolver, that the PR gate's build stage runs. Not blocked during a\n * `wp-push-dev --resolve`: it mutates nothing and reads no branch state.\n */\n build(opts: BuildOptions): Promise<void> {\n return this.buildCommand.run(opts);\n }\n\n /**\n * `wp-await-reviews`: BLOCK until every reviewer verdict this branch owes has landed, then print\n * them. Not blocked during a `wp-push-dev --resolve`: it reads verdict files and mutates nothing.\n */\n awaitReviews(): Promise<void> {\n return this.awaitReviewsCommand.run();\n }\n\n /**\n * `wp-write-review`: a reviewer subagent submits ONE checklist verdict, with provenance (issue #863).\n * Not blocked during a `wp-push-dev --resolve`: it writes only this branch's review state.\n */\n writeReview(opts: WriteReviewOptions): Promise<void> {\n return this.writeReviewCommand.run(opts);\n }\n\n /** `wp-write-review --check`: may this checklist still be reviewed on this branch (issue #1051)? */\n checkReviewBudget(opts: ReviewBudgetCheckOptions): Promise<void> {\n return this.writeReviewCommand.check(opts);\n }\n\n /** `wp-write-review-fixes`: the coordinator records committed fixes without editing a reviewer verdict. */\n writeReviewFixes(opts: WriteReviewFixesOptions): Promise<void> {\n return this.writeReviewFixesCommand.run(opts);\n }\n\n /**\n * `wp-await-checks --pr <n>`: BLOCK until that PR's checks stop running, then print where they\n * landed. Read-only against GitHub, so it too is allowed during a resolve.\n */\n awaitChecks(opts: AwaitChecksOptions): Promise<void> {\n return this.awaitChecksCommand.run(opts);\n }\n\n /** `wp-start-update`: 3-point squash-update from main (no PR). */\n startUpdate(): Promise<void> {\n this.assertNoResolveInProgress('wp-start-update');\n return this.startUpdateCommand.run();\n }\n\n /** `wp-finish-update`: validate + finalize a resolved 3-point merge (no PR). */\n finishUpdate(): Promise<void> {\n this.assertNoResolveInProgress('wp-finish-update');\n return this.finishUpdateCommand.run();\n }\n\n /** `wp-start-upsert-pr`: update from main (3-point merge), hand off summary.json. No build gate, no push. */\n startUpsertPr(): Promise<void> {\n this.assertNoResolveInProgress('wp-start-upsert-pr');\n return this.startUpsertPrCommand.run();\n }\n\n /** `wp-finish-upsert-pr`: finalize merge, authoritative build gate, dashboard, create/update PR. */\n finishUpsertPr(): Promise<void> {\n this.assertNoResolveInProgress('wp-finish-upsert-pr');\n return this.finishUpsertPrCommand.run();\n }\n\n /** `wp-human-post-pr`: human-attested post with optional local build and no automated review. */\n humanPostPr(): Promise<void> {\n this.assertNoResolveInProgress('wp-human-post-pr');\n return this.humanPostPrCommand.run();\n }\n\n /**\n * `wp-cleanup`: reap what is provably merged AND every zero-commit husk, then report the rest with\n * the exact flags that take it. `options` carries what argv said — see CleanupOptions.\n */\n cleanup(options: CleanupOptions): Promise<void> {\n this.assertNoResolveInProgress('wp-cleanup');\n return this.cleanupCommand.run(options);\n }\n\n /**\n * `wp-sync-main`: go to main, fast-forward it, reap dead worktrees and branches, and sweep\n * the orphan directories a project move leaves behind. Replaces `git checkout main && git pull\n * origin main` outright — see SyncMainCommand for why the old pair must stop being accepted\n * rather than surviving beside this.\n */\n syncMain(): Promise<void> {\n this.assertNoResolveInProgress('wp-sync-main');\n return this.syncMainCommand.run();\n }\n\n /**\n * `wp-land-pr`: squash-merge a PR into main with the compact commit body — this branch's by default,\n * or the one `--pr <n>` names, which is how a coordinator finishes a gone agent's work.\n */\n landPr(request: LandPrRequest): Promise<void> {\n this.assertNoResolveInProgress('wp-land-pr');\n return this.landPrCommand.run(request);\n }\n\n /**\n * `wp-review-upsert-pr`: STAGE ② — validate the 3-point merge, run the build gate, extract this\n * branch's diff, and brief the reviewer subagents. Unlike the report-only command it replaces, this CAN\n * fail — before any reviewer is spawned, so a broken branch costs no reviewer tokens.\n */\n reviewUpsertPr(opts: ReviewUpsertPrOptions = new ReviewUpsertPrOptions()): Promise<void> {\n this.assertNoResolveInProgress('wp-review-upsert-pr');\n return this.reviewUpsertPrCommand.run(opts);\n }\n\n /** `wp-check-pr`: READ-ONLY CI check — verify the PR body carries a valid HMAC gate token for its head sha. */\n checkPr(): Promise<void> {\n return this.checkPrCommand.run();\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"pr-gate-app.js","sourceRoot":"","sources":["../../../../../../packages/tooling/pr-gate/src/scripts/pr-gate-app.ts"],"names":[],"mappings":";;;;AAAA,0DAAyD;AACzD,yCAA2D;AAC3D,0EAAqE;AACrE,4EAAuE;AACvE,gFAA0E;AAC1E,kFAA4E;AAC5E,gEAA4D;AAE5D,oEAA+D;AAC/D,gEAA0E;AAC1E,kEAA6D;AAC7D,kFAAmG;AACnG,4EAAuE;AACvE,4DAAsE;AACtE,4EAAuE;AACvE,0EAAmH;AACnH,sFAAyG;AACzG,0EAAyF;AACzF,kEAA6E;AAC7E,gFAAgG;AAChG,4EAAsE;AACtE,kFAA4E;AAC5E,8DAA8D;AAC9D,0DAAyD;AAEzD;;;;;GAKG;AAGI,IAAM,SAAS,GAAf,MAAM,SAAS;IAEG;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IArBrB,YACqB,kBAAsC,EACtC,mBAAwC,EACxC,oBAA0C,EAC1C,qBAA4C,EAC5C,cAA8B,EAC9B,eAAgC,EAChC,aAA4B,EAC5B,cAA8B,EAC9B,qBAA4C,EAC5C,mBAAwC,EACxC,YAA0B,EAC1B,mBAAwC,EACxC,kBAAsC,EACtC,uBAAgD,EAChD,kBAAsC,EACtC,cAA8B,EAC9B,oBAA0C,EAC1C,kBAAsC,EACtC,qBAA4C,EAC5C,iBAAoC,EACpC,cAA8B;QApB9B,uBAAkB,GAAlB,kBAAkB,CAAoB;QACtC,wBAAmB,GAAnB,mBAAmB,CAAqB;QACxC,yBAAoB,GAApB,oBAAoB,CAAsB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S;oBAAT,SAAS;IAFrB,IAAA,6BAAc,GAAE;IAChB,IAAA,sBAAU,EAAC,8BAAkB,CAAC,SAAS,CAAC;6CAGI,yCAAkB;QACjB,2CAAmB;QAClB,8CAAoB;QACnB,gDAAqB;QAC5B,gCAAc;QACb,mCAAe;QACjB,+BAAa;QACZ,iCAAc;QACP,gDAAqB;QACvB,2CAAmB;QAC1B,4BAAY;QACL,2CAAmB;QACpB,yCAAkB;QACb,oDAAuB;QAC5B,yCAAkB;QACtB,iCAAc;QACR,8CAAoB;QACtB,0CAAkB;QACf,gDAAqB;QACzB,kCAAiB;QACpB,6BAAc;GAtB1C,SAAS,CAyLrB","sourcesContent":["import { DocumentDesign } from '@webpieces/rules-config';\nimport { injectable, bindingScopeValues } from 'inversify';\nimport { StartUpdateCommand } from './commands/start-update-command';\nimport { FinishUpdateCommand } from './commands/finish-update-command';\nimport { StartUpsertPrCommand } from './commands/start-upsert-pr-command';\nimport { FinishUpsertPrCommand } from './commands/finish-upsert-pr-command';\nimport { CleanupCommand } from './commands/cleanup-command';\nimport { CleanupOptions } from './commands/cleanup-options';\nimport { SyncMainCommand } from './commands/sync-main-command';\nimport { LandPrCommand, LandPrRequest } from './commands/land-pr-command';\nimport { CheckPrCommand } from './commands/check-pr-command';\nimport { ReviewUpsertPrCommand, ReviewUpsertPrOptions } from './commands/review-upsert-pr-command';\nimport { ReapWorktreeCommand } from './commands/reap-worktree-command';\nimport { BuildCommand, BuildOptions } from './commands/build-command';\nimport { AwaitReviewsCommand } from './commands/await-reviews-command';\nimport { ReviewBudgetCheckOptions, WriteReviewCommand, WriteReviewOptions } from './commands/write-review-command';\nimport { WriteReviewFixesCommand, WriteReviewFixesOptions } from './commands/write-review-fixes-command';\nimport { AwaitChecksCommand, AwaitChecksOptions } from './commands/await-checks-command';\nimport { PushDevCommand, PushDevOptions } from './commands/push-dev-command';\nimport { FinishPushDevCommand, FinishPushDevOptions } from './commands/finish-push-dev-command';\nimport { HumanPostPrCommand } from './commands/human-post-pr-command';\nimport { UpsertHotfixPrCommand } from './commands/upsert-hotfix-pr-command';\nimport { PushDevStateStore } from './workflow/push-dev-state';\nimport { RepoRootFinder } from '@webpieces/rules-config';\n\n/**\n * The pr-gate application root. `container.get(PrGateApp)` resolves the entire workflow DAG (the command\n * classes → the injected git/merge/dashboard services). `@DocumentDesign` marks it the\n * top-of-DAG the DI-design analyzer roots on, so `role:app` pr-gate draws its design. Each `bin/*`\n * entry resolves THIS and calls the matching command method.\n */\n@DocumentDesign()\n@injectable(bindingScopeValues.Singleton)\nexport class PrGateApp {\n constructor(\n private readonly startUpdateCommand: StartUpdateCommand,\n private readonly finishUpdateCommand: FinishUpdateCommand,\n private readonly startUpsertPrCommand: StartUpsertPrCommand,\n private readonly finishUpsertPrCommand: FinishUpsertPrCommand,\n private readonly cleanupCommand: CleanupCommand,\n private readonly syncMainCommand: SyncMainCommand,\n private readonly landPrCommand: LandPrCommand,\n private readonly checkPrCommand: CheckPrCommand,\n private readonly reviewUpsertPrCommand: ReviewUpsertPrCommand,\n private readonly reapWorktreeCommand: ReapWorktreeCommand,\n private readonly buildCommand: BuildCommand,\n private readonly awaitReviewsCommand: AwaitReviewsCommand,\n private readonly writeReviewCommand: WriteReviewCommand,\n private readonly writeReviewFixesCommand: WriteReviewFixesCommand,\n private readonly awaitChecksCommand: AwaitChecksCommand,\n private readonly pushDevCommand: PushDevCommand,\n private readonly finishPushDevCommand: FinishPushDevCommand,\n private readonly humanPostPrCommand: HumanPostPrCommand,\n private readonly upsertHotfixPrCommand: UpsertHotfixPrCommand,\n private readonly pushDevStateStore: PushDevStateStore,\n private readonly repoRootFinder: RepoRootFinder,\n ) {}\n\n /**\n * Refuse `command` while a `wp-push-dev --resolve` is half-finished.\n *\n * Enforced HERE, at the one place every bin funnels through, rather than in each command: a resolve\n * parks the checkout on a throwaway branch, so every command below would act on a branch that is not\n * the one it thinks it is. Putting the check in nine constructors is nine chances to forget it in the\n * tenth. PushDevStateStore owns the blocked list AND renders the hint from it, so the two cannot drift.\n */\n private assertNoResolveInProgress(command: string): void {\n if (!this.pushDevStateStore.isBlockedDuringResolve(command)) return;\n this.pushDevStateStore.assertIdle(\n this.repoRootFinder.resolveRepoRoot(process.cwd()),\n command,\n );\n }\n\n /** `wp-push-dev`: publish a DISPOSABLE copy of this branch for the shared dev environment. No PR, no build. */\n pushDev(opts: PushDevOptions = new PushDevOptions()): Promise<void> {\n return this.pushDevCommand.run(opts);\n }\n\n /** `wp-finish-push-dev`: commit a resolved dev composition and publish it (conflict path only). */\n finishPushDev(opts: FinishPushDevOptions = new FinishPushDevOptions()): Promise<void> {\n return this.finishPushDevCommand.run(opts);\n }\n\n /**\n * INTERNAL (`wp-reap-worktree.js`, no `bin` entry): remove ONE named worktree and its branch.\n * `wp-land-pr` spawns it with cwd = the primary clone so the tree it just landed from can be\n * reaped by a process that is not standing in it.\n */\n reapWorktree(args: string[]): Promise<void> {\n return this.reapWorktreeCommand.run(args);\n }\n\n /**\n * `wp-build`: run this repo's ONE configured build (`commands.pr-gate.buildCommand`) — the same\n * command, resolved by the same resolver, that the PR gate's build stage runs. Not blocked during a\n * `wp-push-dev --resolve`: it mutates nothing and reads no branch state.\n */\n build(opts: BuildOptions): Promise<void> {\n return this.buildCommand.run(opts);\n }\n\n /**\n * `wp-await-reviews`: BLOCK until every reviewer verdict this branch owes has landed, then print\n * them. Not blocked during a `wp-push-dev --resolve`: it reads verdict files and mutates nothing.\n */\n awaitReviews(): Promise<void> {\n return this.awaitReviewsCommand.run();\n }\n\n /**\n * `wp-write-review`: a reviewer subagent submits ONE checklist verdict, with provenance (issue #863).\n * Not blocked during a `wp-push-dev --resolve`: it writes only this branch's review state.\n */\n writeReview(opts: WriteReviewOptions): Promise<void> {\n return this.writeReviewCommand.run(opts);\n }\n\n /** `wp-write-review --check`: may this checklist still be reviewed on this branch (issue #1051)? */\n checkReviewBudget(opts: ReviewBudgetCheckOptions): Promise<void> {\n return this.writeReviewCommand.check(opts);\n }\n\n /** `wp-write-review-fixes`: the coordinator records committed fixes without editing a reviewer verdict. */\n writeReviewFixes(opts: WriteReviewFixesOptions): Promise<void> {\n return this.writeReviewFixesCommand.run(opts);\n }\n\n /**\n * `wp-await-checks --pr <n>`: BLOCK until that PR's checks stop running, then print where they\n * landed. Read-only against GitHub, so it too is allowed during a resolve.\n */\n awaitChecks(opts: AwaitChecksOptions): Promise<void> {\n return this.awaitChecksCommand.run(opts);\n }\n\n /** `wp-start-update`: 3-point squash-update from main (no PR). */\n startUpdate(): Promise<void> {\n this.assertNoResolveInProgress('wp-start-update');\n return this.startUpdateCommand.run();\n }\n\n /** `wp-finish-update`: validate + finalize a resolved 3-point merge (no PR). */\n finishUpdate(): Promise<void> {\n this.assertNoResolveInProgress('wp-finish-update');\n return this.finishUpdateCommand.run();\n }\n\n /** `wp-start-upsert-pr`: update from main (3-point merge), hand off summary.json. No build gate, no push. */\n startUpsertPr(): Promise<void> {\n this.assertNoResolveInProgress('wp-start-upsert-pr');\n return this.startUpsertPrCommand.run();\n }\n\n /** `wp-finish-upsert-pr`: finalize merge, authoritative build gate, dashboard, create/update PR. */\n finishUpsertPr(): Promise<void> {\n this.assertNoResolveInProgress('wp-finish-upsert-pr');\n return this.finishUpsertPrCommand.run();\n }\n\n /** `wp-human-post-pr`: human-attested post with optional local build and no automated review. */\n humanPostPr(): Promise<void> {\n this.assertNoResolveInProgress('wp-human-post-pr');\n return this.humanPostPrCommand.run();\n }\n\n /**\n * `wp-upsert-hotfix-pr`: the one command for a `/hotfix/` branch — `hotfix-ci` gate, no merge from\n * main, one fast-forward push, upsert the bannered PR, never auto-merge (issue #1057).\n */\n upsertHotfixPr(): Promise<void> {\n this.assertNoResolveInProgress('wp-upsert-hotfix-pr');\n return this.upsertHotfixPrCommand.run();\n }\n\n /**\n * `wp-cleanup`: reap what is provably merged AND every zero-commit husk, then report the rest with\n * the exact flags that take it. `options` carries what argv said — see CleanupOptions.\n */\n cleanup(options: CleanupOptions): Promise<void> {\n this.assertNoResolveInProgress('wp-cleanup');\n return this.cleanupCommand.run(options);\n }\n\n /**\n * `wp-sync-main`: go to main, fast-forward it, reap dead worktrees and branches, and sweep\n * the orphan directories a project move leaves behind. Replaces `git checkout main && git pull\n * origin main` outright — see SyncMainCommand for why the old pair must stop being accepted\n * rather than surviving beside this.\n */\n syncMain(): Promise<void> {\n this.assertNoResolveInProgress('wp-sync-main');\n return this.syncMainCommand.run();\n }\n\n /**\n * `wp-land-pr`: squash-merge a PR into main with the compact commit body — this branch's by default,\n * or the one `--pr <n>` names, which is how a coordinator finishes a gone agent's work.\n */\n landPr(request: LandPrRequest): Promise<void> {\n this.assertNoResolveInProgress('wp-land-pr');\n return this.landPrCommand.run(request);\n }\n\n /**\n * `wp-review-upsert-pr`: STAGE ② — validate the 3-point merge, run the build gate, extract this\n * branch's diff, and brief the reviewer subagents. Unlike the report-only command it replaces, this CAN\n * fail — before any reviewer is spawned, so a broken branch costs no reviewer tokens.\n */\n reviewUpsertPr(opts: ReviewUpsertPrOptions = new ReviewUpsertPrOptions()): Promise<void> {\n this.assertNoResolveInProgress('wp-review-upsert-pr');\n return this.reviewUpsertPrCommand.run(opts);\n }\n\n /** `wp-check-pr`: READ-ONLY CI check — verify the PR body carries a valid HMAC gate token for its head sha. */\n checkPr(): Promise<void> {\n return this.checkPrCommand.run();\n }\n}\n"]}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { GatedPrPublisher } from './gated-pr-publisher';
|
|
2
|
+
import { GitExec } from './git-exec';
|
|
3
|
+
/**
|
|
4
|
+
* The gated publisher for a `/hotfix/` branch: the same body-before-push ordering, with a push that can
|
|
5
|
+
* NEVER rewrite the remote branch.
|
|
6
|
+
*
|
|
7
|
+
* The normal flow pushes with `--force-with-lease`, because its 3-point squash rewrites history on every
|
|
8
|
+
* update. A hotfix branch is never rewritten — it only ever grows by the fix commits added on top of the
|
|
9
|
+
* production sha — so its push is a plain fast-forward. If the remote branch has diverged (somebody else
|
|
10
|
+
* pushed to it), the push FAILS instead of overwriting their commits, and nothing is lost.
|
|
11
|
+
*
|
|
12
|
+
* The push runs as a CHILD PROCESS of `wp-upsert-hotfix-pr`, which the PreToolUse hook never sees, so
|
|
13
|
+
* `pr-creation-or-push-guard` keeps refusing every hand-typed `git push` exactly as before.
|
|
14
|
+
*/
|
|
15
|
+
export declare class HotfixPrPublisher extends GatedPrPublisher {
|
|
16
|
+
private readonly hotfixGit;
|
|
17
|
+
constructor(hotfixGit: GitExec);
|
|
18
|
+
/** Fast-forward-only push of HEAD to origin/<branch>, run in `cwd`. Throws on any failure. */
|
|
19
|
+
pushFastForward(cwd: string, branch: string): void;
|
|
20
|
+
protected push(baseBranch: string): void;
|
|
21
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.HotfixPrPublisher = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const rules_config_1 = require("@webpieces/rules-config");
|
|
6
|
+
const inversify_1 = require("inversify");
|
|
7
|
+
const gated_pr_publisher_1 = require("./gated-pr-publisher");
|
|
8
|
+
const git_exec_1 = require("./git-exec");
|
|
9
|
+
/**
|
|
10
|
+
* The gated publisher for a `/hotfix/` branch: the same body-before-push ordering, with a push that can
|
|
11
|
+
* NEVER rewrite the remote branch.
|
|
12
|
+
*
|
|
13
|
+
* The normal flow pushes with `--force-with-lease`, because its 3-point squash rewrites history on every
|
|
14
|
+
* update. A hotfix branch is never rewritten — it only ever grows by the fix commits added on top of the
|
|
15
|
+
* production sha — so its push is a plain fast-forward. If the remote branch has diverged (somebody else
|
|
16
|
+
* pushed to it), the push FAILS instead of overwriting their commits, and nothing is lost.
|
|
17
|
+
*
|
|
18
|
+
* The push runs as a CHILD PROCESS of `wp-upsert-hotfix-pr`, which the PreToolUse hook never sees, so
|
|
19
|
+
* `pr-creation-or-push-guard` keeps refusing every hand-typed `git push` exactly as before.
|
|
20
|
+
*/
|
|
21
|
+
let HotfixPrPublisher = class HotfixPrPublisher extends gated_pr_publisher_1.GatedPrPublisher {
|
|
22
|
+
hotfixGit;
|
|
23
|
+
constructor(hotfixGit) {
|
|
24
|
+
super(hotfixGit);
|
|
25
|
+
this.hotfixGit = hotfixGit;
|
|
26
|
+
}
|
|
27
|
+
/** Fast-forward-only push of HEAD to origin/<branch>, run in `cwd`. Throws on any failure. */
|
|
28
|
+
pushFastForward(cwd, branch) {
|
|
29
|
+
const out = this.hotfixGit.tryGit(['push', '-u', 'origin', `HEAD:${branch}`], cwd);
|
|
30
|
+
if (out.ok)
|
|
31
|
+
return;
|
|
32
|
+
throw new rules_config_1.CliExitError(1, `❌ git push of the hotfix branch '${branch}' failed (exit ${String(out.status)}). A hotfix push is\n` +
|
|
33
|
+
' fast-forward only — it never forces — so a remote branch that has diverged is refused rather\n' +
|
|
34
|
+
' than overwritten.\n' +
|
|
35
|
+
` git said: ${out.stderr === '' ? '(nothing)' : out.stderr}`);
|
|
36
|
+
}
|
|
37
|
+
push(baseBranch) {
|
|
38
|
+
this.pushFastForward(process.cwd(), baseBranch);
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
exports.HotfixPrPublisher = HotfixPrPublisher;
|
|
42
|
+
exports.HotfixPrPublisher = HotfixPrPublisher = tslib_1.__decorate([
|
|
43
|
+
(0, inversify_1.injectable)(inversify_1.bindingScopeValues.Singleton),
|
|
44
|
+
tslib_1.__metadata("design:paramtypes", [git_exec_1.GitExec])
|
|
45
|
+
], HotfixPrPublisher);
|
|
46
|
+
//# sourceMappingURL=hotfix-pr-publisher.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hotfix-pr-publisher.js","sourceRoot":"","sources":["../../../../../../../packages/tooling/pr-gate/src/scripts/workflow/hotfix-pr-publisher.ts"],"names":[],"mappings":";;;;AAAA,0DAAuD;AACvD,yCAA2D;AAC3D,6DAAwD;AACxD,yCAAqC;AAErC;;;;;;;;;;;GAWG;AAEI,IAAM,iBAAiB,GAAvB,MAAM,iBAAkB,SAAQ,qCAAgB;IACtB;IAA7B,YAA6B,SAAkB;QAC3C,KAAK,CAAC,SAAS,CAAC,CAAC;QADQ,cAAS,GAAT,SAAS,CAAS;IAE/C,CAAC;IAED,8FAA8F;IAC9F,eAAe,CAAC,GAAW,EAAE,MAAc;QACvC,MAAM,GAAG,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,MAAM,EAAE,CAAC,EAAE,GAAG,CAAC,CAAC;QACnF,IAAI,GAAG,CAAC,EAAE;YAAE,OAAO;QACnB,MAAM,IAAI,2BAAY,CAClB,CAAC,EACD,oCAAoC,MAAM,kBAAkB,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,uBAAuB;YACjG,mGAAmG;YACnG,wBAAwB;YACxB,gBAAgB,GAAG,CAAC,MAAM,KAAK,EAAE,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,GAAG,CAAC,MAAM,EAAE,CACrE,CAAC;IACN,CAAC;IAEkB,IAAI,CAAC,UAAkB;QACtC,IAAI,CAAC,eAAe,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,UAAU,CAAC,CAAC;IACpD,CAAC;CACJ,CAAA;AArBY,8CAAiB;4BAAjB,iBAAiB;IAD7B,IAAA,sBAAU,EAAC,8BAAkB,CAAC,SAAS,CAAC;6CAEG,kBAAO;GADtC,iBAAiB,CAqB7B","sourcesContent":["import { CliExitError } from '@webpieces/rules-config';\nimport { injectable, bindingScopeValues } from 'inversify';\nimport { GatedPrPublisher } from './gated-pr-publisher';\nimport { GitExec } from './git-exec';\n\n/**\n * The gated publisher for a `/hotfix/` branch: the same body-before-push ordering, with a push that can\n * NEVER rewrite the remote branch.\n *\n * The normal flow pushes with `--force-with-lease`, because its 3-point squash rewrites history on every\n * update. A hotfix branch is never rewritten — it only ever grows by the fix commits added on top of the\n * production sha — so its push is a plain fast-forward. If the remote branch has diverged (somebody else\n * pushed to it), the push FAILS instead of overwriting their commits, and nothing is lost.\n *\n * The push runs as a CHILD PROCESS of `wp-upsert-hotfix-pr`, which the PreToolUse hook never sees, so\n * `pr-creation-or-push-guard` keeps refusing every hand-typed `git push` exactly as before.\n */\n@injectable(bindingScopeValues.Singleton)\nexport class HotfixPrPublisher extends GatedPrPublisher {\n constructor(private readonly hotfixGit: GitExec) {\n super(hotfixGit);\n }\n\n /** Fast-forward-only push of HEAD to origin/<branch>, run in `cwd`. Throws on any failure. */\n pushFastForward(cwd: string, branch: string): void {\n const out = this.hotfixGit.tryGit(['push', '-u', 'origin', `HEAD:${branch}`], cwd);\n if (out.ok) return;\n throw new CliExitError(\n 1,\n `❌ git push of the hotfix branch '${branch}' failed (exit ${String(out.status)}). A hotfix push is\\n` +\n ' fast-forward only — it never forces — so a remote branch that has diverged is refused rather\\n' +\n ' than overwritten.\\n' +\n ` git said: ${out.stderr === '' ? '(nothing)' : out.stderr}`,\n );\n }\n\n protected override push(baseBranch: string): void {\n this.pushFastForward(process.cwd(), baseBranch);\n }\n}\n"]}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { BranchIdentity } from '@webpieces/rules-config';
|
|
2
|
+
/** The ONE command a `/hotfix/` branch publishes with (issue #1057). */
|
|
3
|
+
export declare const UPSERT_HOTFIX_PR_COMMAND = "pnpm wp-upsert-hotfix-pr";
|
|
4
|
+
/**
|
|
5
|
+
* Sends a `/hotfix/` branch out of the three-stage PR flow, BEFORE that flow touches anything.
|
|
6
|
+
*
|
|
7
|
+
* WHY it refuses rather than adapting the stages. Stage ① squash-updates the branch from main, and a
|
|
8
|
+
* hotfix branch is cut from the exact commit running in production so that it ships production plus the
|
|
9
|
+
* fix and nothing else. Merging main into it would ship every commit that has landed but has not been
|
|
10
|
+
* promoted yet — the one thing the branch exists to avoid. The review stage has nothing to do either: a
|
|
11
|
+
* hotfix runs no reviewers. So the whole start → review → finish split is the wrong shape, and each of the
|
|
12
|
+
* three stages names the single command that is the right one, `wp-upsert-hotfix-pr`.
|
|
13
|
+
*/
|
|
14
|
+
export declare class HotfixRedirect {
|
|
15
|
+
private readonly branchIdentity;
|
|
16
|
+
constructor(branchIdentity: BranchIdentity);
|
|
17
|
+
/** Throws when the current branch is a `/hotfix/` branch; returns silently otherwise. */
|
|
18
|
+
assertNotHotfix(command: string): void;
|
|
19
|
+
message(command: string, branch: string): string;
|
|
20
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.HotfixRedirect = exports.UPSERT_HOTFIX_PR_COMMAND = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const rules_config_1 = require("@webpieces/rules-config");
|
|
6
|
+
const inversify_1 = require("inversify");
|
|
7
|
+
const SEP = '━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n';
|
|
8
|
+
/** The ONE command a `/hotfix/` branch publishes with (issue #1057). */
|
|
9
|
+
exports.UPSERT_HOTFIX_PR_COMMAND = 'pnpm wp-upsert-hotfix-pr';
|
|
10
|
+
/**
|
|
11
|
+
* Sends a `/hotfix/` branch out of the three-stage PR flow, BEFORE that flow touches anything.
|
|
12
|
+
*
|
|
13
|
+
* WHY it refuses rather than adapting the stages. Stage ① squash-updates the branch from main, and a
|
|
14
|
+
* hotfix branch is cut from the exact commit running in production so that it ships production plus the
|
|
15
|
+
* fix and nothing else. Merging main into it would ship every commit that has landed but has not been
|
|
16
|
+
* promoted yet — the one thing the branch exists to avoid. The review stage has nothing to do either: a
|
|
17
|
+
* hotfix runs no reviewers. So the whole start → review → finish split is the wrong shape, and each of the
|
|
18
|
+
* three stages names the single command that is the right one, `wp-upsert-hotfix-pr`.
|
|
19
|
+
*/
|
|
20
|
+
let HotfixRedirect = class HotfixRedirect {
|
|
21
|
+
branchIdentity;
|
|
22
|
+
constructor(branchIdentity) {
|
|
23
|
+
this.branchIdentity = branchIdentity;
|
|
24
|
+
}
|
|
25
|
+
/** Throws when the current branch is a `/hotfix/` branch; returns silently otherwise. */
|
|
26
|
+
assertNotHotfix(command) {
|
|
27
|
+
const branch = this.branchIdentity.current();
|
|
28
|
+
if (!this.branchIdentity.isHotfix(branch))
|
|
29
|
+
return;
|
|
30
|
+
throw new rules_config_1.CliExitError(1, this.message(command, branch));
|
|
31
|
+
}
|
|
32
|
+
message(command, branch) {
|
|
33
|
+
return ('\n' +
|
|
34
|
+
SEP +
|
|
35
|
+
`⚠️ HOT FIX ⚠️ — ${command} does not run on a /hotfix/ branch\n` +
|
|
36
|
+
SEP +
|
|
37
|
+
'\n' +
|
|
38
|
+
`'${branch}' contains the /hotfix/ segment. Nothing was changed: no merge from main, no build, no push.\n\n` +
|
|
39
|
+
'A hotfix branch is cut from the commit running in production, so it must ship production plus the\n' +
|
|
40
|
+
'fix and nothing else. This flow would merge main into it and ship every unpromoted main commit too.\n\n' +
|
|
41
|
+
'Publish it with the one hotfix command instead:\n' +
|
|
42
|
+
` ${exports.UPSERT_HOTFIX_PR_COMMAND}\n\n` +
|
|
43
|
+
'It requires a clean tree and summary.json (it prints the path and schema when the file is missing),\n' +
|
|
44
|
+
'runs only hotfix-ci (build + test), never merges main or rewrites the branch, pushes once, and\n' +
|
|
45
|
+
'creates or updates the bannered PR to main without ever enabling auto-merge.\n');
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
exports.HotfixRedirect = HotfixRedirect;
|
|
49
|
+
exports.HotfixRedirect = HotfixRedirect = tslib_1.__decorate([
|
|
50
|
+
(0, inversify_1.injectable)(inversify_1.bindingScopeValues.Singleton),
|
|
51
|
+
tslib_1.__metadata("design:paramtypes", [rules_config_1.BranchIdentity])
|
|
52
|
+
], HotfixRedirect);
|
|
53
|
+
//# sourceMappingURL=hotfix-redirect.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hotfix-redirect.js","sourceRoot":"","sources":["../../../../../../../packages/tooling/pr-gate/src/scripts/workflow/hotfix-redirect.ts"],"names":[],"mappings":";;;;AAAA,0DAAuE;AACvE,yCAA2D;AAE3D,MAAM,GAAG,GAAG,0DAA0D,CAAC;AAEvE,wEAAwE;AAC3D,QAAA,wBAAwB,GAAG,0BAA0B,CAAC;AAEnE;;;;;;;;;GASG;AAEI,IAAM,cAAc,GAApB,MAAM,cAAc;IACM;IAA7B,YAA6B,cAA8B;QAA9B,mBAAc,GAAd,cAAc,CAAgB;IAAG,CAAC;IAE/D,yFAAyF;IACzF,eAAe,CAAC,OAAe;QAC3B,MAAM,MAAM,GAAG,IAAI,CAAC,cAAc,CAAC,OAAO,EAAE,CAAC;QAC7C,IAAI,CAAC,IAAI,CAAC,cAAc,CAAC,QAAQ,CAAC,MAAM,CAAC;YAAE,OAAO;QAClD,MAAM,IAAI,2BAAY,CAAC,CAAC,EAAE,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC,CAAC;IAC7D,CAAC;IAED,OAAO,CAAC,OAAe,EAAE,MAAc;QACnC,OAAO,CACH,IAAI;YACJ,GAAG;YACH,mBAAmB,OAAO,sCAAsC;YAChE,GAAG;YACH,IAAI;YACJ,IAAI,MAAM,kGAAkG;YAC5G,qGAAqG;YACrG,yGAAyG;YACzG,mDAAmD;YACnD,KAAK,gCAAwB,MAAM;YACnC,uGAAuG;YACvG,kGAAkG;YAClG,gFAAgF,CACnF,CAAC;IACN,CAAC;CACJ,CAAA;AA3BY,wCAAc;yBAAd,cAAc;IAD1B,IAAA,sBAAU,EAAC,8BAAkB,CAAC,SAAS,CAAC;6CAEQ,6BAAc;GADlD,cAAc,CA2B1B","sourcesContent":["import { BranchIdentity, CliExitError } from '@webpieces/rules-config';\nimport { injectable, bindingScopeValues } from 'inversify';\n\nconst SEP = '━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\\n';\n\n/** The ONE command a `/hotfix/` branch publishes with (issue #1057). */\nexport const UPSERT_HOTFIX_PR_COMMAND = 'pnpm wp-upsert-hotfix-pr';\n\n/**\n * Sends a `/hotfix/` branch out of the three-stage PR flow, BEFORE that flow touches anything.\n *\n * WHY it refuses rather than adapting the stages. Stage ① squash-updates the branch from main, and a\n * hotfix branch is cut from the exact commit running in production so that it ships production plus the\n * fix and nothing else. Merging main into it would ship every commit that has landed but has not been\n * promoted yet — the one thing the branch exists to avoid. The review stage has nothing to do either: a\n * hotfix runs no reviewers. So the whole start → review → finish split is the wrong shape, and each of the\n * three stages names the single command that is the right one, `wp-upsert-hotfix-pr`.\n */\n@injectable(bindingScopeValues.Singleton)\nexport class HotfixRedirect {\n constructor(private readonly branchIdentity: BranchIdentity) {}\n\n /** Throws when the current branch is a `/hotfix/` branch; returns silently otherwise. */\n assertNotHotfix(command: string): void {\n const branch = this.branchIdentity.current();\n if (!this.branchIdentity.isHotfix(branch)) return;\n throw new CliExitError(1, this.message(command, branch));\n }\n\n message(command: string, branch: string): string {\n return (\n '\\n' +\n SEP +\n `⚠️ HOT FIX ⚠️ — ${command} does not run on a /hotfix/ branch\\n` +\n SEP +\n '\\n' +\n `'${branch}' contains the /hotfix/ segment. Nothing was changed: no merge from main, no build, no push.\\n\\n` +\n 'A hotfix branch is cut from the commit running in production, so it must ship production plus the\\n' +\n 'fix and nothing else. This flow would merge main into it and ship every unpromoted main commit too.\\n\\n' +\n 'Publish it with the one hotfix command instead:\\n' +\n ` ${UPSERT_HOTFIX_PR_COMMAND}\\n\\n` +\n 'It requires a clean tree and summary.json (it prints the path and schema when the file is missing),\\n' +\n 'runs only hotfix-ci (build + test), never merges main or rewrites the branch, pushes once, and\\n' +\n 'creates or updates the bannered PR to main without ever enabling auto-merge.\\n'\n );\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"push-dev-state.js","sourceRoot":"","sources":["../../../../../../../packages/tooling/pr-gate/src/scripts/workflow/push-dev-state.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iCAAkB,4DAA4D,KAAK,CAAC,cAAc,QAAQ;YAC/G,eAAe,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAC7C,CAAC;IACN,CAAC;IAED,gFAAgF;IACxE,kBAAkB;QACtB,OAAO,sBAAsB,CAAC,GAAG,CAAC,CAAC,CAAS,EAAU,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACzF,CAAC;IAED,uFAAuF;IACvF,sBAAsB,CAAC,OAAe;QAClC,OAAO,sBAAsB,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;IACpD,CAAC;CACJ,CAAA;AArGY,8CAAiB;4BAAjB,iBAAiB;IAD7B,IAAA,sBAAU,EAAC,8BAAkB,CAAC,SAAS,CAAC;6CAEM,2BAAY;GAD9C,iBAAiB,CAqG7B","sourcesContent":["import * as fs from 'fs';\n\nimport {\n CliExitError,\n DotWebpieces,\n PUSH_DEV_STATE_FILE,\n WP_FINISH_PUSH_DEV,\n WP_PUSH_DEV,\n toError,\n} from '@webpieces/rules-config';\nimport { injectable, bindingScopeValues } from 'inversify';\n\nconst SEP = '━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\\n';\n\n/**\n * The persisted half of the `wp-push-dev --resolve` state machine.\n *\n * A single-shot wrapper is IMPOSSIBLE here and that is why this file exists: `git merge` halts on\n * conflict with markers in the working tree and a non-zero exit, and a human or an AI has to edit files\n * before anything can be committed. So the command must be able to stop, hand the tree over, and be\n * resumed by a second command that knows exactly where it left off.\n *\n * Data-only (per CLAUDE.md) — the behaviour lives in {@link PushDevStateStore}.\n */\nexport class PushDevState {\n /** The branch to return to when the resolve finishes or aborts. NEVER written to by this flow. */\n originalBranch: string;\n /** The local throwaway branch the merges happen on. Deleted on finish and on abort. */\n tmpBranch: string;\n /** `<namespace>/<originalBranch>` — the remote copy this resolve republishes. */\n targetRef: string;\n /** The copy refs still to merge, in the order CI composes them. */\n queue: string[];\n /** The ref currently mid-merge (conflicted), or '' when nothing is halted. */\n current: string;\n\n // eslint-disable-next-line @typescript-eslint/max-params\n constructor(\n originalBranch: string,\n tmpBranch: string,\n targetRef: string,\n queue: string[],\n current = '',\n ) {\n this.originalBranch = originalBranch;\n this.tmpBranch = tmpBranch;\n this.targetRef = targetRef;\n this.queue = queue;\n this.current = current;\n }\n}\n\n// The wp-* commands that must REFUSE while a resolve is half-finished, and the ONE place that list is\n// written. The blocked-list sentence below RENDERS ITSELF from this array — the same lesson\n// merge-in-progress-guard already learned the hard way: a hand-written \"don't run other commands\"\n// survives every edit to the actual enforcement and ends up forbidding things the flow requires.\n//\n// Why these and not everything: each one either rewrites the current branch (the two starts), pushes it\n// (the finishes), or deletes branches (cleanup) — and during a resolve the checkout is a throwaway\n// branch, not the feature branch any of them think they are acting on.\nconst BLOCKED_DURING_RESOLVE: readonly string[] = [\n 'wp-start-update',\n 'wp-finish-update',\n 'wp-start-upsert-pr',\n 'wp-review-upsert-pr',\n 'wp-finish-upsert-pr',\n 'wp-human-post-pr',\n 'wp-land-pr',\n 'wp-cleanup',\n];\n\n/**\n * Reads, writes and clears the resolve state file, and refuses the other `wp-*` commands while it\n * exists.\n *\n * LOCAL scope, deliberately: a resolve halts one worktree's checkout on a throwaway branch, and another\n * worktree has no reason to care. Sharing it would block a colleague's PR flow on state that says\n * nothing about their tree.\n */\n@injectable(bindingScopeValues.Singleton)\nexport class PushDevStateStore {\n constructor(private readonly dotWebpieces: DotWebpieces) {}\n\n path(repoRoot: string): string {\n return this.dotWebpieces.localFile(repoRoot, PUSH_DEV_STATE_FILE);\n }\n\n exists(repoRoot: string): boolean {\n return fs.existsSync(this.path(repoRoot));\n }\n\n /** The in-flight resolve, or null when none is. A corrupt file reads as null rather than crashing. */\n read(repoRoot: string): PushDevState | null {\n const file = this.path(repoRoot);\n if (!fs.existsSync(file)) return null;\n // webpieces-disable no-unmanaged-exceptions -- a truncated/hand-edited state file must degrade to \"no resolve in progress\" (recoverable via --abort or a fresh --resolve), never crash every wp-* command in the tree\n // eslint-disable-next-line @webpieces/no-unmanaged-exceptions\n try {\n // webpieces-disable no-any-unknown -- JSON.parse is untyped until narrowed on the next line\n const raw = JSON.parse(fs.readFileSync(file, 'utf8')) as Partial<PushDevState>;\n if (typeof raw.originalBranch !== 'string' || typeof raw.tmpBranch !== 'string')\n return null;\n return new PushDevState(\n raw.originalBranch,\n raw.tmpBranch,\n raw.targetRef ?? '',\n Array.isArray(raw.queue) ? raw.queue : [],\n raw.current ?? '',\n );\n // The parse error carries nothing a caller could act on: the ONLY meaningful reading of an\n // unparseable state file is \"no resolve in progress\", which --abort and a fresh --resolve both\n // recover from.\n } catch (err: unknown) {\n const error = toError(err);\n void error;\n return null;\n }\n }\n\n write(repoRoot: string, state: PushDevState): void {\n fs.mkdirSync(this.dotWebpieces.local(repoRoot), { recursive: true });\n fs.writeFileSync(this.path(repoRoot), JSON.stringify(state, null, 2) + '\\n', 'utf8');\n }\n\n clear(repoRoot: string): void {\n const file = this.path(repoRoot);\n if (fs.existsSync(file)) fs.rmSync(file);\n }\n\n /** The read that MUST find a resolve — used by `wp-finish-push-dev`, whose whole job is resuming one. */\n require(repoRoot: string): PushDevState {\n const state = this.read(repoRoot);\n if (state !== null) return state;\n throw new CliExitError(\n 2,\n '\\n' +\n SEP +\n '⛔ No dev-deploy resolve is in progress\\n' +\n SEP +\n '\\n' +\n `${WP_FINISH_PUSH_DEV} resumes a resolve that \\`${WP_PUSH_DEV} --resolve\\` started, and there is no\\n` +\n `state file at:\\n ${this.path(repoRoot)}\\n\\n` +\n 'If you meant to publish your branch to the shared dev server, that is the one-command form:\\n' +\n ` ${WP_PUSH_DEV}\\n`,\n );\n }\n\n /**\n * Refuse `attempted` while a resolve is half-finished. Called from the app root for every command in\n * {@link BLOCKED_DURING_RESOLVE}, so no individual command has to remember to ask.\n */\n assertIdle(repoRoot: string, attempted: string): void {\n const state = this.read(repoRoot);\n if (state === null) return;\n throw new CliExitError(\n 2,\n '\\n' +\n SEP +\n `⛔ A dev-deploy resolve is in progress — \\`pnpm ${attempted}\\` is blocked\\n` +\n SEP +\n '\\n' +\n `You are standing on the throwaway branch \\`${state.tmpBranch}\\`, not on \\`${state.originalBranch}\\`,\\n` +\n `so ${this.blockedCommandList()} would all act on the wrong branch.\\n` +\n 'That is the whole list; nothing else is blocked.\\n\\n' +\n 'EXPECTED of you right now, and NOT blocked: read the conflicted files and edit them until every\\n' +\n 'conflict marker is gone. Then finish or bail out:\\n' +\n ` ${WP_FINISH_PUSH_DEV} ← commit the resolution, resume the queue, publish the copy\\n` +\n ` ${WP_FINISH_PUSH_DEV} --abort ← throw the resolution away and go back to \\`${state.originalBranch}\\`\\n\\n` +\n `State file: ${this.path(repoRoot)}\\n`,\n );\n }\n\n // Rendered from BLOCKED_DURING_RESOLVE, never hand-written — see that constant.\n private blockedCommandList(): string {\n return BLOCKED_DURING_RESOLVE.map((c: string): string => `\\`pnpm ${c}\\``).join(', ');\n }\n\n /** Is `command` one of the ones that must refuse mid-resolve? Used by the app root. */\n isBlockedDuringResolve(command: string): boolean {\n return BLOCKED_DURING_RESOLVE.includes(command);\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"push-dev-state.js","sourceRoot":"","sources":["../../../../../../../packages/tooling/pr-gate/src/scripts/workflow/push-dev-state.ts"],"names":[],"mappings":";;;;AAAA,+CAAyB;AAEzB,0DAOiC;AACjC,yCAA2D;AAE3D,MAAM,GAAG,GAAG,0DAA0D,CAAC;AAEvE;;;;;;;;;GASG;AACH,MAAa,YAAY;IACrB,kGAAkG;IAClG,cAAc,CAAS;IACvB,uFAAuF;IACvF,SAAS,CAAS;IAClB,iFAAiF;IACjF,SAAS,CAAS;IAClB,mEAAmE;IACnE,KAAK,CAAW;IAChB,8EAA8E;IAC9E,OAAO,CAAS;IAEhB,yDAAyD;IACzD,YACI,cAAsB,EACtB,SAAiB,EACjB,SAAiB,EACjB,KAAe,EACf,OAAO,GAAG,E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CAAC;IACpD,CAAC;CACJ,CAAA;AArGY,8CAAiB;4BAAjB,iBAAiB;IAD7B,IAAA,sBAAU,EAAC,8BAAkB,CAAC,SAAS,CAAC;6CAEM,2BAAY;GAD9C,iBAAiB,CAqG7B","sourcesContent":["import * as fs from 'fs';\n\nimport {\n CliExitError,\n DotWebpieces,\n PUSH_DEV_STATE_FILE,\n WP_FINISH_PUSH_DEV,\n WP_PUSH_DEV,\n toError,\n} from '@webpieces/rules-config';\nimport { injectable, bindingScopeValues } from 'inversify';\n\nconst SEP = '━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\\n';\n\n/**\n * The persisted half of the `wp-push-dev --resolve` state machine.\n *\n * A single-shot wrapper is IMPOSSIBLE here and that is why this file exists: `git merge` halts on\n * conflict with markers in the working tree and a non-zero exit, and a human or an AI has to edit files\n * before anything can be committed. So the command must be able to stop, hand the tree over, and be\n * resumed by a second command that knows exactly where it left off.\n *\n * Data-only (per CLAUDE.md) — the behaviour lives in {@link PushDevStateStore}.\n */\nexport class PushDevState {\n /** The branch to return to when the resolve finishes or aborts. NEVER written to by this flow. */\n originalBranch: string;\n /** The local throwaway branch the merges happen on. Deleted on finish and on abort. */\n tmpBranch: string;\n /** `<namespace>/<originalBranch>` — the remote copy this resolve republishes. */\n targetRef: string;\n /** The copy refs still to merge, in the order CI composes them. */\n queue: string[];\n /** The ref currently mid-merge (conflicted), or '' when nothing is halted. */\n current: string;\n\n // eslint-disable-next-line @typescript-eslint/max-params\n constructor(\n originalBranch: string,\n tmpBranch: string,\n targetRef: string,\n queue: string[],\n current = '',\n ) {\n this.originalBranch = originalBranch;\n this.tmpBranch = tmpBranch;\n this.targetRef = targetRef;\n this.queue = queue;\n this.current = current;\n }\n}\n\n// The wp-* commands that must REFUSE while a resolve is half-finished, and the ONE place that list is\n// written. The blocked-list sentence below RENDERS ITSELF from this array — the same lesson\n// merge-in-progress-guard already learned the hard way: a hand-written \"don't run other commands\"\n// survives every edit to the actual enforcement and ends up forbidding things the flow requires.\n//\n// Why these and not everything: each one either rewrites the current branch (the two starts), pushes it\n// (the finishes), or deletes branches (cleanup) — and during a resolve the checkout is a throwaway\n// branch, not the feature branch any of them think they are acting on.\nconst BLOCKED_DURING_RESOLVE: readonly string[] = [\n 'wp-start-update',\n 'wp-finish-update',\n 'wp-start-upsert-pr',\n 'wp-review-upsert-pr',\n 'wp-finish-upsert-pr',\n 'wp-human-post-pr',\n 'wp-upsert-hotfix-pr',\n 'wp-land-pr',\n 'wp-cleanup',\n];\n\n/**\n * Reads, writes and clears the resolve state file, and refuses the other `wp-*` commands while it\n * exists.\n *\n * LOCAL scope, deliberately: a resolve halts one worktree's checkout on a throwaway branch, and another\n * worktree has no reason to care. Sharing it would block a colleague's PR flow on state that says\n * nothing about their tree.\n */\n@injectable(bindingScopeValues.Singleton)\nexport class PushDevStateStore {\n constructor(private readonly dotWebpieces: DotWebpieces) {}\n\n path(repoRoot: string): string {\n return this.dotWebpieces.localFile(repoRoot, PUSH_DEV_STATE_FILE);\n }\n\n exists(repoRoot: string): boolean {\n return fs.existsSync(this.path(repoRoot));\n }\n\n /** The in-flight resolve, or null when none is. A corrupt file reads as null rather than crashing. */\n read(repoRoot: string): PushDevState | null {\n const file = this.path(repoRoot);\n if (!fs.existsSync(file)) return null;\n // webpieces-disable no-unmanaged-exceptions -- a truncated/hand-edited state file must degrade to \"no resolve in progress\" (recoverable via --abort or a fresh --resolve), never crash every wp-* command in the tree\n // eslint-disable-next-line @webpieces/no-unmanaged-exceptions\n try {\n // webpieces-disable no-any-unknown -- JSON.parse is untyped until narrowed on the next line\n const raw = JSON.parse(fs.readFileSync(file, 'utf8')) as Partial<PushDevState>;\n if (typeof raw.originalBranch !== 'string' || typeof raw.tmpBranch !== 'string')\n return null;\n return new PushDevState(\n raw.originalBranch,\n raw.tmpBranch,\n raw.targetRef ?? '',\n Array.isArray(raw.queue) ? raw.queue : [],\n raw.current ?? '',\n );\n // The parse error carries nothing a caller could act on: the ONLY meaningful reading of an\n // unparseable state file is \"no resolve in progress\", which --abort and a fresh --resolve both\n // recover from.\n } catch (err: unknown) {\n const error = toError(err);\n void error;\n return null;\n }\n }\n\n write(repoRoot: string, state: PushDevState): void {\n fs.mkdirSync(this.dotWebpieces.local(repoRoot), { recursive: true });\n fs.writeFileSync(this.path(repoRoot), JSON.stringify(state, null, 2) + '\\n', 'utf8');\n }\n\n clear(repoRoot: string): void {\n const file = this.path(repoRoot);\n if (fs.existsSync(file)) fs.rmSync(file);\n }\n\n /** The read that MUST find a resolve — used by `wp-finish-push-dev`, whose whole job is resuming one. */\n require(repoRoot: string): PushDevState {\n const state = this.read(repoRoot);\n if (state !== null) return state;\n throw new CliExitError(\n 2,\n '\\n' +\n SEP +\n '⛔ No dev-deploy resolve is in progress\\n' +\n SEP +\n '\\n' +\n `${WP_FINISH_PUSH_DEV} resumes a resolve that \\`${WP_PUSH_DEV} --resolve\\` started, and there is no\\n` +\n `state file at:\\n ${this.path(repoRoot)}\\n\\n` +\n 'If you meant to publish your branch to the shared dev server, that is the one-command form:\\n' +\n ` ${WP_PUSH_DEV}\\n`,\n );\n }\n\n /**\n * Refuse `attempted` while a resolve is half-finished. Called from the app root for every command in\n * {@link BLOCKED_DURING_RESOLVE}, so no individual command has to remember to ask.\n */\n assertIdle(repoRoot: string, attempted: string): void {\n const state = this.read(repoRoot);\n if (state === null) return;\n throw new CliExitError(\n 2,\n '\\n' +\n SEP +\n `⛔ A dev-deploy resolve is in progress — \\`pnpm ${attempted}\\` is blocked\\n` +\n SEP +\n '\\n' +\n `You are standing on the throwaway branch \\`${state.tmpBranch}\\`, not on \\`${state.originalBranch}\\`,\\n` +\n `so ${this.blockedCommandList()} would all act on the wrong branch.\\n` +\n 'That is the whole list; nothing else is blocked.\\n\\n' +\n 'EXPECTED of you right now, and NOT blocked: read the conflicted files and edit them until every\\n' +\n 'conflict marker is gone. Then finish or bail out:\\n' +\n ` ${WP_FINISH_PUSH_DEV} ← commit the resolution, resume the queue, publish the copy\\n` +\n ` ${WP_FINISH_PUSH_DEV} --abort ← throw the resolution away and go back to \\`${state.originalBranch}\\`\\n\\n` +\n `State file: ${this.path(repoRoot)}\\n`,\n );\n }\n\n // Rendered from BLOCKED_DURING_RESOLVE, never hand-written — see that constant.\n private blockedCommandList(): string {\n return BLOCKED_DURING_RESOLVE.map((c: string): string => `\\`pnpm ${c}\\``).join(', ');\n }\n\n /** Is `command` one of the ones that must refuse mid-resolve? Used by the app root. */\n isBlockedDuringResolve(command: string): boolean {\n return BLOCKED_DURING_RESOLVE.includes(command);\n }\n}\n"]}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
require("reflect-metadata");
|
|
5
|
+
const inversify_1 = require("inversify");
|
|
6
|
+
const rules_config_1 = require("@webpieces/rules-config");
|
|
7
|
+
const pr_gate_app_1 = require("./pr-gate-app");
|
|
8
|
+
// Composition root for `wp-upsert-hotfix-pr` (issue #1057): publish a /hotfix/ branch in one command.
|
|
9
|
+
(0, rules_config_1.runMain)(async () => {
|
|
10
|
+
const container = new inversify_1.Container({ autobind: true });
|
|
11
|
+
container
|
|
12
|
+
.get(rules_config_1.CliArgs)
|
|
13
|
+
.assertNoArgs(new rules_config_1.CliUsage('wp-upsert-hotfix-pr', 'Publish the current /hotfix/ branch: hotfix-ci gate (build + test), no merge from main, one\n' +
|
|
14
|
+
'fast-forward push, then create or update the audit-bannered PR to main. Never auto-merges.'));
|
|
15
|
+
await container.get(pr_gate_app_1.PrGateApp).upsertHotfixPr();
|
|
16
|
+
});
|
|
17
|
+
//# sourceMappingURL=wp-upsert-hotfix-pr.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wp-upsert-hotfix-pr.js","sourceRoot":"","sources":["../../../../../../packages/tooling/pr-gate/src/scripts/wp-upsert-hotfix-pr.ts"],"names":[],"mappings":";;;AACA,4BAA0B;AAC1B,yCAAsC;AACtC,0DAAqE;AACrE,+CAA0C;AAE1C,sGAAsG;AACtG,IAAA,sBAAO,EAAC,KAAK,IAAmB,EAAE;IAC9B,MAAM,SAAS,GAAG,IAAI,qBAAS,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC;IACpD,SAAS;SACJ,GAAG,CAAC,sBAAO,CAAC;SACZ,YAAY,CACT,IAAI,uBAAQ,CACR,qBAAqB,EACrB,+FAA+F;QAC3F,4FAA4F,CACnG,CACJ,CAAC;IACN,MAAM,SAAS,CAAC,GAAG,CAAC,uBAAS,CAAC,CAAC,cAAc,EAAE,CAAC;AACpD,CAAC,CAAC,CAAC","sourcesContent":["#!/usr/bin/env node\nimport 'reflect-metadata';\nimport { Container } from 'inversify';\nimport { CliArgs, CliUsage, runMain } from '@webpieces/rules-config';\nimport { PrGateApp } from './pr-gate-app';\n\n// Composition root for `wp-upsert-hotfix-pr` (issue #1057): publish a /hotfix/ branch in one command.\nrunMain(async (): Promise<void> => {\n const container = new Container({ autobind: true });\n container\n .get(CliArgs)\n .assertNoArgs(\n new CliUsage(\n 'wp-upsert-hotfix-pr',\n 'Publish the current /hotfix/ branch: hotfix-ci gate (build + test), no merge from main, one\\n' +\n 'fast-forward push, then create or update the audit-bannered PR to main. Never auto-merges.',\n ),\n );\n await container.get(PrGateApp).upsertHotfixPr();\n});\n"]}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { BranchIdentity, PrSummary, ReviewJsonService } from '@webpieces/rules-config';
|
|
2
|
-
import { AiBranchName } from './git-readAiBranchName';
|
|
3
|
-
import { BuildAffected } from './build-affected';
|
|
4
|
-
import { BuildArtifactGate } from './build-artifact-gate';
|
|
5
|
-
import { ChecklistScan, ChecklistScanner } from './checklist-scanner';
|
|
6
|
-
import { DiffMaterializer } from './diff-materializer';
|
|
7
|
-
import { GitExec } from './git-exec';
|
|
8
|
-
import { MergeEnd } from './merge-end';
|
|
9
|
-
import { MergeState } from './merge-state';
|
|
10
|
-
import { PrContextWriter } from './pr-context-writer';
|
|
11
|
-
import { ProvenanceEnforcer, ProvenanceReport } from './provenance-enforcer';
|
|
12
|
-
export declare class HotfixFinishState {
|
|
13
|
-
readonly featureName: string;
|
|
14
|
-
readonly currentBranch: string;
|
|
15
|
-
readonly review: PrSummary;
|
|
16
|
-
readonly scan: ChecklistScan;
|
|
17
|
-
readonly provenance: ProvenanceReport;
|
|
18
|
-
constructor(featureName: string, currentBranch: string, review: PrSummary, scan: ChecklistScan, provenance: ProvenanceReport);
|
|
19
|
-
}
|
|
20
|
-
/** Validates and builds the emergency flow before FinishUpsertPrCommand publishes anything. */
|
|
21
|
-
export declare class HotfixFinishPreparer {
|
|
22
|
-
private readonly branchIdentity;
|
|
23
|
-
private readonly aiBranchName;
|
|
24
|
-
private readonly gitExec;
|
|
25
|
-
private readonly reviewJsonService;
|
|
26
|
-
private readonly buildAffected;
|
|
27
|
-
private readonly buildArtifactGate;
|
|
28
|
-
private readonly mergeState;
|
|
29
|
-
private readonly mergeEnd;
|
|
30
|
-
private readonly checklistScanner;
|
|
31
|
-
private readonly materializer;
|
|
32
|
-
private readonly prContextWriter;
|
|
33
|
-
private readonly provenanceEnforcer;
|
|
34
|
-
constructor(branchIdentity: BranchIdentity, aiBranchName: AiBranchName, gitExec: GitExec, reviewJsonService: ReviewJsonService, buildAffected: BuildAffected, buildArtifactGate: BuildArtifactGate, mergeState: MergeState, mergeEnd: MergeEnd, checklistScanner: ChecklistScanner, materializer: DiffMaterializer, prContextWriter: PrContextWriter, provenanceEnforcer: ProvenanceEnforcer);
|
|
35
|
-
prepare(repoRoot: string): Promise<HotfixFinishState>;
|
|
36
|
-
private finalizeMerge;
|
|
37
|
-
private gitOut;
|
|
38
|
-
}
|
|
@@ -1,114 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.HotfixFinishPreparer = exports.HotfixFinishState = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const child_process_1 = require("child_process");
|
|
6
|
-
const rules_config_1 = require("@webpieces/rules-config");
|
|
7
|
-
const inversify_1 = require("inversify");
|
|
8
|
-
const git_readAiBranchName_1 = require("./git-readAiBranchName");
|
|
9
|
-
const build_affected_1 = require("./build-affected");
|
|
10
|
-
const build_artifact_gate_1 = require("./build-artifact-gate");
|
|
11
|
-
const build_gate_log_1 = require("./build-gate-log");
|
|
12
|
-
const checklist_scanner_1 = require("./checklist-scanner");
|
|
13
|
-
const diff_materializer_1 = require("./diff-materializer");
|
|
14
|
-
const git_exec_1 = require("./git-exec");
|
|
15
|
-
const merge_start_1 = require("./merge-start");
|
|
16
|
-
const merge_end_1 = require("./merge-end");
|
|
17
|
-
const merge_state_1 = require("./merge-state");
|
|
18
|
-
const pr_context_writer_1 = require("./pr-context-writer");
|
|
19
|
-
const provenance_enforcer_1 = require("./provenance-enforcer");
|
|
20
|
-
class HotfixFinishState {
|
|
21
|
-
featureName;
|
|
22
|
-
currentBranch;
|
|
23
|
-
review;
|
|
24
|
-
scan;
|
|
25
|
-
provenance;
|
|
26
|
-
constructor(featureName, currentBranch, review, scan, provenance) {
|
|
27
|
-
this.featureName = featureName;
|
|
28
|
-
this.currentBranch = currentBranch;
|
|
29
|
-
this.review = review;
|
|
30
|
-
this.scan = scan;
|
|
31
|
-
this.provenance = provenance;
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
exports.HotfixFinishState = HotfixFinishState;
|
|
35
|
-
/** Validates and builds the emergency flow before FinishUpsertPrCommand publishes anything. */
|
|
36
|
-
let HotfixFinishPreparer = class HotfixFinishPreparer {
|
|
37
|
-
branchIdentity;
|
|
38
|
-
aiBranchName;
|
|
39
|
-
gitExec;
|
|
40
|
-
reviewJsonService;
|
|
41
|
-
buildAffected;
|
|
42
|
-
buildArtifactGate;
|
|
43
|
-
mergeState;
|
|
44
|
-
mergeEnd;
|
|
45
|
-
checklistScanner;
|
|
46
|
-
materializer;
|
|
47
|
-
prContextWriter;
|
|
48
|
-
provenanceEnforcer;
|
|
49
|
-
constructor(branchIdentity, aiBranchName, gitExec, reviewJsonService, buildAffected, buildArtifactGate, mergeState, mergeEnd, checklistScanner, materializer, prContextWriter, provenanceEnforcer) {
|
|
50
|
-
this.branchIdentity = branchIdentity;
|
|
51
|
-
this.aiBranchName = aiBranchName;
|
|
52
|
-
this.gitExec = gitExec;
|
|
53
|
-
this.reviewJsonService = reviewJsonService;
|
|
54
|
-
this.buildAffected = buildAffected;
|
|
55
|
-
this.buildArtifactGate = buildArtifactGate;
|
|
56
|
-
this.mergeState = mergeState;
|
|
57
|
-
this.mergeEnd = mergeEnd;
|
|
58
|
-
this.checklistScanner = checklistScanner;
|
|
59
|
-
this.materializer = materializer;
|
|
60
|
-
this.prContextWriter = prContextWriter;
|
|
61
|
-
this.provenanceEnforcer = provenanceEnforcer;
|
|
62
|
-
}
|
|
63
|
-
async prepare(repoRoot) {
|
|
64
|
-
await this.finalizeMerge(repoRoot);
|
|
65
|
-
this.gitExec.assertCleanTree(repoRoot);
|
|
66
|
-
const featureName = this.aiBranchName.getFeatureName();
|
|
67
|
-
const review = this.reviewJsonService.loadSummaryJson((0, rules_config_1.summaryJsonPath)(repoRoot, featureName), []);
|
|
68
|
-
const headBefore = this.gitOut(repoRoot, ['rev-parse', 'HEAD']);
|
|
69
|
-
await this.buildAffected.runBuildGate(repoRoot, new build_affected_1.BuildGateOptions('🛠️ Hotfix build gate (build + test only)', 'pnpm wp-finish-upsert-pr', 'Hotfix build failed — no PR created/updated.', build_gate_log_1.FINISH_STAGE));
|
|
70
|
-
this.buildArtifactGate.assertBuildLeftNothingUncommitted(repoRoot);
|
|
71
|
-
this.gitExec.assertCleanTree(repoRoot);
|
|
72
|
-
if (headBefore === '' || this.gitOut(repoRoot, ['rev-parse', 'HEAD']) !== headBefore) {
|
|
73
|
-
throw new rules_config_1.InformAiError('Hotfix HEAD changed while compilation/tests were running. Re-run pnpm wp-finish-upsert-pr so the build receipt covers the exact commit pushed.');
|
|
74
|
-
}
|
|
75
|
-
const config = (0, rules_config_1.loadAndValidate)(repoRoot).prGate;
|
|
76
|
-
const scan = this.checklistScanner.scan(repoRoot, config.checklists, new checklist_scanner_1.ChecklistScanOptions(config.maxReviewerRounds, false, ''));
|
|
77
|
-
if (!scan.basis.unresolved) {
|
|
78
|
-
this.materializer.materialize(repoRoot, featureName, scan.basis, scan.changedFiles, config.reviewDiffExclude);
|
|
79
|
-
this.prContextWriter.ensure(repoRoot, featureName, scan.basis, 'stage3-hotfix', scan.changedFiles, this.materializer.diffDirFor(repoRoot, featureName));
|
|
80
|
-
}
|
|
81
|
-
const currentBranch = this.branchIdentity.current();
|
|
82
|
-
const provenance = this.provenanceEnforcer.enforce([], currentBranch, repoRoot, config);
|
|
83
|
-
return new HotfixFinishState(featureName, currentBranch, review, scan, provenance);
|
|
84
|
-
}
|
|
85
|
-
async finalizeMerge(repoRoot) {
|
|
86
|
-
const home = this.mergeState.mergeDirFor(repoRoot, this.aiBranchName.getFeatureName());
|
|
87
|
-
const activeDir = this.mergeState.findActiveMergeRunDir(home);
|
|
88
|
-
const marker = activeDir ? this.mergeState.readMergeMarker(activeDir) : null;
|
|
89
|
-
if (!activeDir || !marker || marker.validated)
|
|
90
|
-
return;
|
|
91
|
-
await this.mergeEnd.mergeEnd(repoRoot, 'wp-finish-upsert-pr', activeDir, new merge_start_1.MergeContext(marker.currentBranch, marker.squashBranch, marker.backupBranch, marker.prNumber), new merge_end_1.MergeEndOptions(marker.conflictedFiles, false));
|
|
92
|
-
}
|
|
93
|
-
gitOut(repoRoot, args) {
|
|
94
|
-
const result = (0, child_process_1.spawnSync)('git', args, { cwd: repoRoot, encoding: 'utf8' });
|
|
95
|
-
return result.status === 0 ? (result.stdout ?? '').trim() : '';
|
|
96
|
-
}
|
|
97
|
-
};
|
|
98
|
-
exports.HotfixFinishPreparer = HotfixFinishPreparer;
|
|
99
|
-
exports.HotfixFinishPreparer = HotfixFinishPreparer = tslib_1.__decorate([
|
|
100
|
-
(0, inversify_1.injectable)(inversify_1.bindingScopeValues.Singleton),
|
|
101
|
-
tslib_1.__metadata("design:paramtypes", [rules_config_1.BranchIdentity,
|
|
102
|
-
git_readAiBranchName_1.AiBranchName,
|
|
103
|
-
git_exec_1.GitExec,
|
|
104
|
-
rules_config_1.ReviewJsonService,
|
|
105
|
-
build_affected_1.BuildAffected,
|
|
106
|
-
build_artifact_gate_1.BuildArtifactGate,
|
|
107
|
-
merge_state_1.MergeState,
|
|
108
|
-
merge_end_1.MergeEnd,
|
|
109
|
-
checklist_scanner_1.ChecklistScanner,
|
|
110
|
-
diff_materializer_1.DiffMaterializer,
|
|
111
|
-
pr_context_writer_1.PrContextWriter,
|
|
112
|
-
provenance_enforcer_1.ProvenanceEnforcer])
|
|
113
|
-
], HotfixFinishPreparer);
|
|
114
|
-
//# sourceMappingURL=hotfix-finish-preparer.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"hotfix-finish-preparer.js","sourceRoot":"","sources":["../../../../../../../packages/tooling/pr-gate/src/scripts/workflow/hotfix-finish-preparer.ts"],"names":[],"mappings":";;;;AAAA,iDAA0C;AAC1C,0DAAwI;AACxI,yCAA2D;AAC3D,iEAAsD;AACtD,qDAAmE;AACnE,+DAA0D;AAC1D,qDAAgD;AAChD,2DAA4F;AAC5F,2DAAuD;AACvD,yCAAqC;AACrC,+CAA6C;AAC7C,2CAAwD;AACxD,+CAA2C;AAC3C,2DAAsD;AACtD,+DAA6E;AAE7E,MAAa,iBAAiB;IAEb;IACA;IACA;IACA;IACA;IALb,YACa,WAAmB,EACnB,aAAqB,EACrB,MAAiB,EACjB,IAAmB,EACnB,UAA4B;QAJ5B,gBAAW,GAAX,WAAW,CAAQ;QACnB,kBAAa,GAAb,aAAa,CAAQ;QACrB,WAAM,GAAN,MAAM,CAAW;QACjB,SAAI,GAAJ,IAAI,CAAe;QACnB,e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IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;IACnE,CAAC;CACJ,CAAA;AAnDY,oDAAoB;+BAApB,oBAAoB;IADhC,IAAA,sBAAU,EAAC,8BAAkB,CAAC,SAAS,CAAC;6CAGA,6BAAc;QAChB,mCAAY;QACjB,kBAAO;QACG,gCAAiB;QACrB,8BAAa;QACT,uCAAiB;QACxB,wBAAU;QACZ,oBAAQ;QACA,oCAAgB;QACpB,oCAAgB;QACb,mCAAe;QACZ,wCAAkB;GAblD,oBAAoB,CAmDhC","sourcesContent":["import { spawnSync } from 'child_process';\nimport { BranchIdentity, InformAiError, PrSummary, ReviewJsonService, loadAndValidate, summaryJsonPath } from '@webpieces/rules-config';\nimport { injectable, bindingScopeValues } from 'inversify';\nimport { AiBranchName } from './git-readAiBranchName';\nimport { BuildAffected, BuildGateOptions } from './build-affected';\nimport { BuildArtifactGate } from './build-artifact-gate';\nimport { FINISH_STAGE } from './build-gate-log';\nimport { ChecklistScan, ChecklistScanOptions, ChecklistScanner } from './checklist-scanner';\nimport { DiffMaterializer } from './diff-materializer';\nimport { GitExec } from './git-exec';\nimport { MergeContext } from './merge-start';\nimport { MergeEnd, MergeEndOptions } from './merge-end';\nimport { MergeState } from './merge-state';\nimport { PrContextWriter } from './pr-context-writer';\nimport { ProvenanceEnforcer, ProvenanceReport } from './provenance-enforcer';\n\nexport class HotfixFinishState {\n constructor(\n readonly featureName: string,\n readonly currentBranch: string,\n readonly review: PrSummary,\n readonly scan: ChecklistScan,\n readonly provenance: ProvenanceReport,\n ) {}\n}\n\n/** Validates and builds the emergency flow before FinishUpsertPrCommand publishes anything. */\n@injectable(bindingScopeValues.Singleton)\nexport class HotfixFinishPreparer {\n constructor(\n private readonly branchIdentity: BranchIdentity,\n private readonly aiBranchName: AiBranchName,\n private readonly gitExec: GitExec,\n private readonly reviewJsonService: ReviewJsonService,\n private readonly buildAffected: BuildAffected,\n private readonly buildArtifactGate: BuildArtifactGate,\n private readonly mergeState: MergeState,\n private readonly mergeEnd: MergeEnd,\n private readonly checklistScanner: ChecklistScanner,\n private readonly materializer: DiffMaterializer,\n private readonly prContextWriter: PrContextWriter,\n private readonly provenanceEnforcer: ProvenanceEnforcer,\n ) {}\n\n async prepare(repoRoot: string): Promise<HotfixFinishState> {\n await this.finalizeMerge(repoRoot);\n this.gitExec.assertCleanTree(repoRoot);\n const featureName = this.aiBranchName.getFeatureName();\n const review = this.reviewJsonService.loadSummaryJson(summaryJsonPath(repoRoot, featureName), []);\n const headBefore = this.gitOut(repoRoot, ['rev-parse', 'HEAD']);\n await this.buildAffected.runBuildGate(repoRoot, new BuildGateOptions('🛠️ Hotfix build gate (build + test only)', 'pnpm wp-finish-upsert-pr', 'Hotfix build failed — no PR created/updated.', FINISH_STAGE));\n this.buildArtifactGate.assertBuildLeftNothingUncommitted(repoRoot);\n this.gitExec.assertCleanTree(repoRoot);\n if (headBefore === '' || this.gitOut(repoRoot, ['rev-parse', 'HEAD']) !== headBefore) {\n throw new InformAiError('Hotfix HEAD changed while compilation/tests were running. Re-run pnpm wp-finish-upsert-pr so the build receipt covers the exact commit pushed.');\n }\n const config = loadAndValidate(repoRoot).prGate;\n const scan = this.checklistScanner.scan(repoRoot, config.checklists, new ChecklistScanOptions(config.maxReviewerRounds, false, ''));\n if (!scan.basis.unresolved) {\n this.materializer.materialize(repoRoot, featureName, scan.basis, scan.changedFiles, config.reviewDiffExclude);\n this.prContextWriter.ensure(repoRoot, featureName, scan.basis, 'stage3-hotfix', scan.changedFiles, this.materializer.diffDirFor(repoRoot, featureName));\n }\n const currentBranch = this.branchIdentity.current();\n const provenance = this.provenanceEnforcer.enforce([], currentBranch, repoRoot, config);\n return new HotfixFinishState(featureName, currentBranch, review, scan, provenance);\n }\n\n private async finalizeMerge(repoRoot: string): Promise<void> {\n const home = this.mergeState.mergeDirFor(repoRoot, this.aiBranchName.getFeatureName());\n const activeDir = this.mergeState.findActiveMergeRunDir(home);\n const marker = activeDir ? this.mergeState.readMergeMarker(activeDir) : null;\n if (!activeDir || !marker || marker.validated) return;\n await this.mergeEnd.mergeEnd(repoRoot, 'wp-finish-upsert-pr', activeDir, new MergeContext(marker.currentBranch, marker.squashBranch, marker.backupBranch, marker.prNumber), new MergeEndOptions(marker.conflictedFiles, false));\n }\n\n private gitOut(repoRoot: string, args: string[]): string {\n const result = spawnSync('git', args, { cwd: repoRoot, encoding: 'utf8' });\n return result.status === 0 ? (result.stdout ?? '').trim() : '';\n }\n}\n"]}
|