@webpieces/pr-gate 0.4.984 → 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 +8 -8
- package/src/scripts/commands/build-push-dev-command.d.ts +61 -0
- package/src/scripts/commands/build-push-dev-command.js +159 -0
- package/src/scripts/commands/build-push-dev-command.js.map +1 -0
- package/src/scripts/commands/finish-push-dev-command.d.ts +73 -17
- package/src/scripts/commands/finish-push-dev-command.js +187 -31
- package/src/scripts/commands/finish-push-dev-command.js.map +1 -1
- package/src/scripts/commands/start-push-dev-command.d.ts +43 -0
- package/src/scripts/commands/start-push-dev-command.js +111 -0
- package/src/scripts/commands/start-push-dev-command.js.map +1 -0
- package/src/scripts/pr-gate-app.d.ts +18 -18
- package/src/scripts/pr-gate-app.js +27 -26
- package/src/scripts/pr-gate-app.js.map +1 -1
- package/src/scripts/pr-gate-cli-app.d.ts +2 -2
- package/src/scripts/pr-gate-cli-app.js +20 -29
- package/src/scripts/pr-gate-cli-app.js.map +1 -1
- package/src/scripts/workflow/build-gate-log.js +2 -2
- package/src/scripts/workflow/build-gate-log.js.map +1 -1
- package/src/scripts/workflow/dev-build.js +2 -2
- package/src/scripts/workflow/dev-build.js.map +1 -1
- package/src/scripts/workflow/dev-copy-on-main.d.ts +1 -1
- package/src/scripts/workflow/dev-copy-on-main.js +1 -1
- package/src/scripts/workflow/dev-copy-on-main.js.map +1 -1
- package/src/scripts/workflow/dev-deploy-refs.d.ts +4 -17
- package/src/scripts/workflow/dev-deploy-refs.js +5 -21
- package/src/scripts/workflow/dev-deploy-refs.js.map +1 -1
- package/src/scripts/workflow/dev-resolve-runner.d.ts +43 -73
- package/src/scripts/workflow/dev-resolve-runner.js +117 -181
- package/src/scripts/workflow/dev-resolve-runner.js.map +1 -1
- package/src/scripts/workflow/main-freshness.d.ts +16 -0
- package/src/scripts/workflow/main-freshness.js +33 -0
- package/src/scripts/workflow/main-freshness.js.map +1 -0
- package/src/scripts/workflow/push-dev-state.d.ts +12 -35
- package/src/scripts/workflow/push-dev-state.js +31 -62
- package/src/scripts/workflow/push-dev-state.js.map +1 -1
- package/src/scripts/workflow/verified-dev-copy.d.ts +46 -0
- package/src/scripts/workflow/verified-dev-copy.js +89 -0
- package/src/scripts/workflow/verified-dev-copy.js.map +1 -0
- package/src/scripts/{wp-build-dev.js → wp-build-push-dev.js} +2 -2
- package/src/scripts/wp-build-push-dev.js.map +1 -0
- package/src/scripts/{wp-push-dev.js → wp-start-push-dev.js} +2 -2
- package/src/scripts/wp-start-push-dev.js.map +1 -0
- package/src/scripts/commands/build-dev-command.d.ts +0 -27
- package/src/scripts/commands/build-dev-command.js +0 -99
- package/src/scripts/commands/build-dev-command.js.map +0 -1
- package/src/scripts/commands/push-dev-command.d.ts +0 -140
- package/src/scripts/commands/push-dev-command.js +0 -356
- package/src/scripts/commands/push-dev-command.js.map +0 -1
- package/src/scripts/wp-build-dev.js.map +0 -1
- package/src/scripts/wp-push-dev.js.map +0 -1
- /package/src/scripts/{wp-build-dev.d.ts → wp-build-push-dev.d.ts} +0 -0
- /package/src/scripts/{wp-push-dev.d.ts → wp-start-push-dev.d.ts} +0 -0
|
@@ -15,12 +15,12 @@ const check_pr_command_1 = require("./commands/check-pr-command");
|
|
|
15
15
|
const review_upsert_pr_command_1 = require("./commands/review-upsert-pr-command");
|
|
16
16
|
const reap_worktree_command_1 = require("./commands/reap-worktree-command");
|
|
17
17
|
const build_command_1 = require("./commands/build-command");
|
|
18
|
-
const build_dev_command_1 = require("./commands/build-dev-command");
|
|
19
18
|
const await_reviews_command_1 = require("./commands/await-reviews-command");
|
|
20
19
|
const write_review_command_1 = require("./commands/write-review-command");
|
|
21
20
|
const write_review_fixes_command_1 = require("./commands/write-review-fixes-command");
|
|
22
21
|
const await_checks_command_1 = require("./commands/await-checks-command");
|
|
23
|
-
const
|
|
22
|
+
const start_push_dev_command_1 = require("./commands/start-push-dev-command");
|
|
23
|
+
const build_push_dev_command_1 = require("./commands/build-push-dev-command");
|
|
24
24
|
const finish_push_dev_command_1 = require("./commands/finish-push-dev-command");
|
|
25
25
|
const human_post_pr_command_1 = require("./commands/human-post-pr-command");
|
|
26
26
|
const upsert_hotfix_pr_command_1 = require("./commands/upsert-hotfix-pr-command");
|
|
@@ -44,18 +44,18 @@ let PrGateApp = class PrGateApp {
|
|
|
44
44
|
reviewUpsertPrCommand;
|
|
45
45
|
reapWorktreeCommand;
|
|
46
46
|
buildCommand;
|
|
47
|
-
buildDevCommand;
|
|
48
47
|
awaitReviewsCommand;
|
|
49
48
|
writeReviewCommand;
|
|
50
49
|
writeReviewFixesCommand;
|
|
51
50
|
awaitChecksCommand;
|
|
52
|
-
|
|
51
|
+
startPushDevCommand;
|
|
52
|
+
buildPushDevCommand;
|
|
53
53
|
finishPushDevCommand;
|
|
54
54
|
humanPostPrCommand;
|
|
55
55
|
upsertHotfixPrCommand;
|
|
56
56
|
pushDevStateStore;
|
|
57
57
|
repoRootFinder;
|
|
58
|
-
constructor(startUpdateCommand, finishUpdateCommand, startUpsertPrCommand, finishUpsertPrCommand, cleanupCommand, syncMainCommand, landPrCommand, checkPrCommand, reviewUpsertPrCommand, reapWorktreeCommand, buildCommand,
|
|
58
|
+
constructor(startUpdateCommand, finishUpdateCommand, startUpsertPrCommand, finishUpsertPrCommand, cleanupCommand, syncMainCommand, landPrCommand, checkPrCommand, reviewUpsertPrCommand, reapWorktreeCommand, buildCommand, awaitReviewsCommand, writeReviewCommand, writeReviewFixesCommand, awaitChecksCommand, startPushDevCommand, buildPushDevCommand, finishPushDevCommand, humanPostPrCommand, upsertHotfixPrCommand, pushDevStateStore, repoRootFinder) {
|
|
59
59
|
this.startUpdateCommand = startUpdateCommand;
|
|
60
60
|
this.finishUpdateCommand = finishUpdateCommand;
|
|
61
61
|
this.startUpsertPrCommand = startUpsertPrCommand;
|
|
@@ -67,12 +67,12 @@ let PrGateApp = class PrGateApp {
|
|
|
67
67
|
this.reviewUpsertPrCommand = reviewUpsertPrCommand;
|
|
68
68
|
this.reapWorktreeCommand = reapWorktreeCommand;
|
|
69
69
|
this.buildCommand = buildCommand;
|
|
70
|
-
this.buildDevCommand = buildDevCommand;
|
|
71
70
|
this.awaitReviewsCommand = awaitReviewsCommand;
|
|
72
71
|
this.writeReviewCommand = writeReviewCommand;
|
|
73
72
|
this.writeReviewFixesCommand = writeReviewFixesCommand;
|
|
74
73
|
this.awaitChecksCommand = awaitChecksCommand;
|
|
75
|
-
this.
|
|
74
|
+
this.startPushDevCommand = startPushDevCommand;
|
|
75
|
+
this.buildPushDevCommand = buildPushDevCommand;
|
|
76
76
|
this.finishPushDevCommand = finishPushDevCommand;
|
|
77
77
|
this.humanPostPrCommand = humanPostPrCommand;
|
|
78
78
|
this.upsertHotfixPrCommand = upsertHotfixPrCommand;
|
|
@@ -80,7 +80,7 @@ let PrGateApp = class PrGateApp {
|
|
|
80
80
|
this.repoRootFinder = repoRootFinder;
|
|
81
81
|
}
|
|
82
82
|
/**
|
|
83
|
-
* Refuse `command` while a `wp-push-dev
|
|
83
|
+
* Refuse `command` while a `wp-build-push-dev` conflict resolution is half-finished.
|
|
84
84
|
*
|
|
85
85
|
* Enforced HERE, at the one place every bin funnels through, rather than in each command: a resolve
|
|
86
86
|
* parks the checkout on a throwaway branch, so every command below would act on a branch that is not
|
|
@@ -92,12 +92,22 @@ let PrGateApp = class PrGateApp {
|
|
|
92
92
|
return;
|
|
93
93
|
this.pushDevStateStore.assertIdle(this.repoRootFinder.resolveRepoRoot(process.cwd()), command);
|
|
94
94
|
}
|
|
95
|
-
/** `wp-push-dev`:
|
|
96
|
-
|
|
97
|
-
|
|
95
|
+
/** `wp-start-push-dev`: dev-deploy stage ① — 3-point merge from main, ONLY if the branch is behind it. */
|
|
96
|
+
startPushDev() {
|
|
97
|
+
this.assertNoResolveInProgress('wp-start-push-dev');
|
|
98
|
+
return this.startPushDevCommand.run();
|
|
98
99
|
}
|
|
99
|
-
/**
|
|
100
|
+
/**
|
|
101
|
+
* `wp-build-push-dev`: dev-deploy stage ② — check the branch against dev on a throwaway merge,
|
|
102
|
+
* `pnpm install`, run the dev build, record the copy. NOT blocked during a resolve: re-running it is
|
|
103
|
+
* how a resolve continues, and `--abort` is how it ends.
|
|
104
|
+
*/
|
|
105
|
+
buildPushDev(opts = new build_push_dev_command_1.BuildPushDevOptions()) {
|
|
106
|
+
return this.buildPushDevCommand.run(opts);
|
|
107
|
+
}
|
|
108
|
+
/** `wp-finish-push-dev`: dev-deploy stage ③ — publish the verified DISPOSABLE copy; `--list`, `--remove`. No PR. */
|
|
100
109
|
finishPushDev(opts = new finish_push_dev_command_1.FinishPushDevOptions()) {
|
|
110
|
+
this.assertNoResolveInProgress('wp-finish-push-dev');
|
|
101
111
|
return this.finishPushDevCommand.run(opts);
|
|
102
112
|
}
|
|
103
113
|
/**
|
|
@@ -111,30 +121,21 @@ let PrGateApp = class PrGateApp {
|
|
|
111
121
|
/**
|
|
112
122
|
* `wp-build`: run this repo's ONE configured build (`commands.pr-gate.buildCommand`) — the same
|
|
113
123
|
* command, resolved by the same resolver, that the PR gate's build stage runs. Not blocked during a
|
|
114
|
-
*
|
|
124
|
+
* dev-deploy resolve: it mutates nothing and reads no branch state.
|
|
115
125
|
*/
|
|
116
126
|
build(opts) {
|
|
117
127
|
return this.buildCommand.run(opts);
|
|
118
128
|
}
|
|
119
|
-
/**
|
|
120
|
-
* `wp-build-dev`: merge `origin/<devBranch>` into a throwaway, run `commands.push-dev.buildCommand` on
|
|
121
|
-
* it, and go back — the check `wp-push-dev` runs before publishing, without the publish (#1397).
|
|
122
|
-
* Blocked during a resolve: it parks the checkout on a throwaway of its own.
|
|
123
|
-
*/
|
|
124
|
-
buildDev() {
|
|
125
|
-
this.assertNoResolveInProgress('wp-build-dev');
|
|
126
|
-
return this.buildDevCommand.run();
|
|
127
|
-
}
|
|
128
129
|
/**
|
|
129
130
|
* `wp-await-reviews`: BLOCK until every reviewer verdict this branch owes has landed, then print
|
|
130
|
-
* them. Not blocked during a
|
|
131
|
+
* them. Not blocked during a dev-deploy resolve: it reads verdict files and mutates nothing.
|
|
131
132
|
*/
|
|
132
133
|
awaitReviews() {
|
|
133
134
|
return this.awaitReviewsCommand.run();
|
|
134
135
|
}
|
|
135
136
|
/**
|
|
136
137
|
* `wp-write-review`: a reviewer subagent submits ONE checklist verdict, with provenance (issue #863).
|
|
137
|
-
* Not blocked during a
|
|
138
|
+
* Not blocked during a dev-deploy resolve: it writes only this branch's review state.
|
|
138
139
|
*/
|
|
139
140
|
writeReview(opts) {
|
|
140
141
|
return this.writeReviewCommand.run(opts);
|
|
@@ -242,12 +243,12 @@ exports.PrGateApp = PrGateApp = tslib_1.__decorate([
|
|
|
242
243
|
review_upsert_pr_command_1.ReviewUpsertPrCommand,
|
|
243
244
|
reap_worktree_command_1.ReapWorktreeCommand,
|
|
244
245
|
build_command_1.BuildCommand,
|
|
245
|
-
build_dev_command_1.BuildDevCommand,
|
|
246
246
|
await_reviews_command_1.AwaitReviewsCommand,
|
|
247
247
|
write_review_command_1.WriteReviewCommand,
|
|
248
248
|
write_review_fixes_command_1.WriteReviewFixesCommand,
|
|
249
249
|
await_checks_command_1.AwaitChecksCommand,
|
|
250
|
-
|
|
250
|
+
start_push_dev_command_1.StartPushDevCommand,
|
|
251
|
+
build_push_dev_command_1.BuildPushDevCommand,
|
|
251
252
|
finish_push_dev_command_1.FinishPushDevCommand,
|
|
252
253
|
human_post_pr_command_1.HumanPostPrCommand,
|
|
253
254
|
upsert_hotfix_pr_command_1.UpsertHotfixPrCommand,
|
|
@@ -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,k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B;QACb,oDAAuB;QAC5B,yCAAkB;QACtB,iCAAc;QACR,8CAAoB;QACtB,0CAAkB;QACf,gDAAqB;QACzB,kCAAiB;QACpB,6BAAc;GAvB1C,SAAS,CAoMrB","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 } from './commands/review-upsert-pr-command';\nimport { ReapWorktreeCommand } from './commands/reap-worktree-command';\nimport { BuildCommand, BuildOptions } from './commands/build-command';\nimport { BuildDevCommand } from './commands/build-dev-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 buildDevCommand: BuildDevCommand,\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`: check this branch against dev, build it, and publish a DISPOSABLE copy of it. No PR. */\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-build-dev`: merge `origin/<devBranch>` into a throwaway, run `commands.push-dev.buildCommand` on\n * it, and go back — the check `wp-push-dev` runs before publishing, without the publish (#1397).\n * Blocked during a resolve: it parks the checkout on a throwaway of its own.\n */\n buildDev(): Promise<void> {\n this.assertNoResolveInProgress('wp-build-dev');\n return this.buildDevCommand.run();\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(): Promise<void> {\n this.assertNoResolveInProgress('wp-review-upsert-pr');\n return this.reviewUpsertPrCommand.run();\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,kFAA4E;AAC5E,4EAAuE;AACvE,4DAAsE;AACtE,4EAAuE;AACvE,0EAAmH;AACnH,sFAAyG;AACzG,0EAAyF;AACzF,8EAAwE;AACxE,8EAA6F;AAC7F,gFAAgG;AAChG,4EAAsE;AACtE,kFAA4E;AAC5E,8DAA8D;AAC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qMrB","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 } 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 { StartPushDevCommand } from './commands/start-push-dev-command';\nimport { BuildPushDevCommand, BuildPushDevOptions } from './commands/build-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 startPushDevCommand: StartPushDevCommand,\n private readonly buildPushDevCommand: BuildPushDevCommand,\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-build-push-dev` conflict resolution 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-start-push-dev`: dev-deploy stage ① — 3-point merge from main, ONLY if the branch is behind it. */\n startPushDev(): Promise<void> {\n this.assertNoResolveInProgress('wp-start-push-dev');\n return this.startPushDevCommand.run();\n }\n\n /**\n * `wp-build-push-dev`: dev-deploy stage ② — check the branch against dev on a throwaway merge,\n * `pnpm install`, run the dev build, record the copy. NOT blocked during a resolve: re-running it is\n * how a resolve continues, and `--abort` is how it ends.\n */\n buildPushDev(opts: BuildPushDevOptions = new BuildPushDevOptions()): Promise<void> {\n return this.buildPushDevCommand.run(opts);\n }\n\n /** `wp-finish-push-dev`: dev-deploy stage ③ — publish the verified DISPOSABLE copy; `--list`, `--remove`. No PR. */\n finishPushDev(opts: FinishPushDevOptions = new FinishPushDevOptions()): Promise<void> {\n this.assertNoResolveInProgress('wp-finish-push-dev');\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 * dev-deploy 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 dev-deploy 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 dev-deploy 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(): Promise<void> {\n this.assertNoResolveInProgress('wp-review-upsert-pr');\n return this.reviewUpsertPrCommand.run();\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"]}
|
|
@@ -19,7 +19,6 @@ export declare class PrGateCliApp {
|
|
|
19
19
|
private parse;
|
|
20
20
|
private noArgs;
|
|
21
21
|
private buildUsage;
|
|
22
|
-
private buildDevUsage;
|
|
23
22
|
private finishUpsertUsage;
|
|
24
23
|
private humanPostUsage;
|
|
25
24
|
private hotfixUsage;
|
|
@@ -31,7 +30,8 @@ export declare class PrGateCliApp {
|
|
|
31
30
|
private reviewUpsertUsage;
|
|
32
31
|
private awaitReviewsUsage;
|
|
33
32
|
private landUsage;
|
|
34
|
-
private
|
|
33
|
+
private startPushDevUsage;
|
|
34
|
+
private buildPushDevUsage;
|
|
35
35
|
private finishPushDevUsage;
|
|
36
36
|
private awaitChecksUsage;
|
|
37
37
|
private writeReviewUsage;
|
|
@@ -9,9 +9,9 @@ const inversify_1 = require("inversify");
|
|
|
9
9
|
const await_checks_command_1 = require("./commands/await-checks-command");
|
|
10
10
|
const build_command_1 = require("./commands/build-command");
|
|
11
11
|
const cleanup_options_1 = require("./commands/cleanup-options");
|
|
12
|
+
const build_push_dev_command_1 = require("./commands/build-push-dev-command");
|
|
12
13
|
const finish_push_dev_command_1 = require("./commands/finish-push-dev-command");
|
|
13
14
|
const land_pr_command_1 = require("./commands/land-pr-command");
|
|
14
|
-
const push_dev_command_1 = require("./commands/push-dev-command");
|
|
15
15
|
const write_review_command_1 = require("./commands/write-review-command");
|
|
16
16
|
const write_review_fixes_command_1 = require("./commands/write-review-fixes-command");
|
|
17
17
|
const pr_gate_app_1 = require("./pr-gate-app");
|
|
@@ -22,9 +22,7 @@ const FILE = '--file';
|
|
|
22
22
|
const FORCE = '--force';
|
|
23
23
|
const LIST = '--list';
|
|
24
24
|
const PR = '--pr';
|
|
25
|
-
const REBASE_RESOLUTION = '--rebase-resolution';
|
|
26
25
|
const REMOVE = '--remove';
|
|
27
|
-
const RESOLVE = '--resolve';
|
|
28
26
|
/** Stable application boundary for every published `wp-*` command. */
|
|
29
27
|
let PrGateCliApp = class PrGateCliApp {
|
|
30
28
|
app;
|
|
@@ -119,10 +117,6 @@ let PrGateCliApp = class PrGateCliApp {
|
|
|
119
117
|
await this.app.build(new build_command_1.BuildOptions(args.has(FORCE)));
|
|
120
118
|
return true;
|
|
121
119
|
}
|
|
122
|
-
if (binName === 'wp-build-dev') {
|
|
123
|
-
await this.noArgs(invocation, this.buildDevUsage(), () => this.app.buildDev());
|
|
124
|
-
return true;
|
|
125
|
-
}
|
|
126
120
|
if (binName === 'wp-cleanup') {
|
|
127
121
|
const args = this.parse(invocation, this.cleanupUsage.declare());
|
|
128
122
|
await this.app.cleanup(new cleanup_options_1.CleanupOptions(new cleanup_options_1.DeleteSelection(cleanup_options_1.FLAG_DELETE_BRANCHES, args.has(cleanup_options_1.FLAG_DELETE_BRANCHES), args.value(cleanup_options_1.FLAG_DELETE_BRANCHES)), new cleanup_options_1.DeleteSelection(cleanup_options_1.FLAG_DELETE_WORKTREES, args.has(cleanup_options_1.FLAG_DELETE_WORKTREES), args.value(cleanup_options_1.FLAG_DELETE_WORKTREES)), args.has(cleanup_options_1.FLAG_REPORT), args.has(cleanup_options_1.FLAG_INTERACTIVE), args.has(cleanup_options_1.FLAG_IGNORE_STALE_LOCKS)));
|
|
@@ -133,21 +127,21 @@ let PrGateCliApp = class PrGateCliApp {
|
|
|
133
127
|
await this.app.landPr(new land_pr_command_1.LandPrRequest(args.has(PR), args.value(PR)));
|
|
134
128
|
return true;
|
|
135
129
|
}
|
|
136
|
-
if (binName === 'wp-push-dev') {
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
opts.resolve = args.has(RESOLVE);
|
|
144
|
-
opts.resolveTarget = args.value(RESOLVE);
|
|
145
|
-
await this.app.pushDev(opts);
|
|
130
|
+
if (binName === 'wp-start-push-dev') {
|
|
131
|
+
await this.noArgs(invocation, this.startPushDevUsage(), () => this.app.startPushDev());
|
|
132
|
+
return true;
|
|
133
|
+
}
|
|
134
|
+
if (binName === 'wp-build-push-dev') {
|
|
135
|
+
const args = this.parse(invocation, this.buildPushDevUsage());
|
|
136
|
+
await this.app.buildPushDev(new build_push_dev_command_1.BuildPushDevOptions(args.has(ABORT)));
|
|
146
137
|
return true;
|
|
147
138
|
}
|
|
148
139
|
if (binName === 'wp-finish-push-dev') {
|
|
149
140
|
const args = this.parse(invocation, this.finishPushDevUsage());
|
|
150
|
-
|
|
141
|
+
const opts = new finish_push_dev_command_1.FinishPushDevOptions();
|
|
142
|
+
opts.list = args.has(LIST);
|
|
143
|
+
opts.remove = args.has(REMOVE);
|
|
144
|
+
await this.app.finishPushDev(opts);
|
|
151
145
|
return true;
|
|
152
146
|
}
|
|
153
147
|
if (binName === 'wp-await-checks') {
|
|
@@ -188,9 +182,6 @@ let PrGateCliApp = class PrGateCliApp {
|
|
|
188
182
|
new rules_config_1.CliFlag(FORCE, 'Build even though this machine is already at its concurrent-build limit.'),
|
|
189
183
|
]);
|
|
190
184
|
}
|
|
191
|
-
buildDevUsage() {
|
|
192
|
-
return new rules_config_1.CliUsage('wp-build-dev', 'Merge origin/dev into a throwaway branch and run commands.push-dev.buildCommand on it — wp-push-dev`s pre-publish check, without publishing.');
|
|
193
|
-
}
|
|
194
185
|
finishUpsertUsage() {
|
|
195
186
|
return new rules_config_1.CliUsage('wp-finish-upsert-pr', 'Finalize the merge, run the authoritative build gate, render the dashboard, and create/update the PR.');
|
|
196
187
|
}
|
|
@@ -224,19 +215,19 @@ let PrGateCliApp = class PrGateCliApp {
|
|
|
224
215
|
landUsage() {
|
|
225
216
|
return new rules_config_1.CliUsage('wp-land-pr', 'Squash-merge a PR into main with its description as the commit body.', [new rules_config_1.CliFlag(PR, 'The PR number to land.', true)]);
|
|
226
217
|
}
|
|
227
|
-
|
|
228
|
-
return new rules_config_1.CliUsage('wp-push-dev', '
|
|
218
|
+
startPushDevUsage() {
|
|
219
|
+
return new rules_config_1.CliUsage('wp-start-push-dev', 'Dev-deploy stage 1: 3-point merge this branch from origin/main, only if it is behind it.');
|
|
220
|
+
}
|
|
221
|
+
buildPushDevUsage() {
|
|
222
|
+
return new rules_config_1.CliUsage('wp-build-push-dev', 'Dev-deploy stage 2: merge origin/dev into a throwaway branch, pnpm install, run commands.push-dev.buildCommand, and record the copy to publish. Re-run it to continue after resolving a conflict.', [new rules_config_1.CliFlag(ABORT, 'Throw a conflict resolution in progress away.')]);
|
|
223
|
+
}
|
|
224
|
+
finishPushDevUsage() {
|
|
225
|
+
return new rules_config_1.CliUsage('wp-finish-push-dev', 'Dev-deploy stage 3: publish the copy wp-build-push-dev verified as a disposable dev copy.', [
|
|
229
226
|
new rules_config_1.CliFlag(LIST, 'List published dev copies.'),
|
|
230
227
|
new rules_config_1.CliFlag(REMOVE, "Delete this branch's dev copy, then push the <removeNamespace>/<branch> marker"
|
|
231
228
|
+ ' (default dev-remove) that triggers the dev rebuild.'),
|
|
232
|
-
new rules_config_1.CliFlag(RESOLVE, 'Compose other published copies, optionally one named branch.', true),
|
|
233
|
-
new rules_config_1.CliFlag(REBASE_RESOLUTION, 'Replay an existing resolution onto new commits.'),
|
|
234
|
-
new rules_config_1.CliFlag(FORCE, 'Discard the published resolution and overwrite it.'),
|
|
235
229
|
]);
|
|
236
230
|
}
|
|
237
|
-
finishPushDevUsage() {
|
|
238
|
-
return new rules_config_1.CliUsage('wp-finish-push-dev', 'Commit a resolved dev merge, run the dev build when publishing, and publish the copy.', [new rules_config_1.CliFlag(ABORT, 'Throw the resolve away without publishing.')]);
|
|
239
|
-
}
|
|
240
231
|
awaitChecksUsage() {
|
|
241
232
|
return new rules_config_1.CliUsage('wp-await-checks', 'Block until checks on one PR stop running.', [
|
|
242
233
|
new rules_config_1.CliFlag(PR, 'REQUIRED. The PR number to wait on.', true),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pr-gate-cli-app.js","sourceRoot":"","sources":["../../../../../../packages/tooling/pr-gate/src/scripts/pr-gate-cli-app.ts"],"names":[],"mappings":";;;;AAAA,mDAA6B;AAE7B,0DAAqI;AACrI,iEAA6D;AAC7D,yCAA2D;AAE3D,0EAAkE;AAClE,4DAAwD;AACxD,gEASoC;AACpC,gFAA0E;AAC1E,gEAA2D;AAC3D,kEAA6D;AAC7D,0EAIyC;AACzC,sFAG+C;AAC/C,+CAA0C;AAG1C,MAAM,KAAK,GAAG,SAAS,CAAC;AACxB,MAAM,KAAK,GAAG,SAAS,CAAC;AACxB,MAAM,SAAS,GAAG,aAAa,CAAC;AAChC,MAAM,IAAI,GAAG,QAAQ,CAAC;AACtB,MAAM,KAAK,GAAG,SAAS,CAAC;AACxB,MAAM,IAAI,GAAG,QAAQ,CAAC;AACtB,MAAM,EAAE,GAAG,MAAM,CAAC;AAClB,MAAM,iBAAiB,GAAG,qBAAqB,CAAC;AAChD,MAAM,MAAM,GAAG,UAAU,CA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I,CAAC,CAAC,CAC9D,CAAC;IACN,CAAC;CACJ,CAAA;AArXY,oCAAY;uBAAZ,YAAY;IADxB,IAAA,sBAAU,EAAC,8BAAkB,CAAC,SAAS,CAAC;6CAGX,uBAAS;QACA,8BAAY;QACR,uCAAgB;QACX,kDAAqB;GALxD,YAAY,CAqXxB","sourcesContent":["import * as path from 'path';\n\nimport { CliArgs, CliArgSet, CliExitError, CliFlag, CliUsage, RuleFailError, renderRuleFailForHuman } from '@webpieces/rules-config';\nimport { toError } from '@webpieces/tooling-common/to-error';\nimport { bindingScopeValues, injectable } from 'inversify';\n\nimport { AwaitChecksArgs } from './commands/await-checks-command';\nimport { BuildOptions } from './commands/build-command';\nimport {\n CleanupOptions,\n CleanupUsage,\n DeleteSelection,\n FLAG_DELETE_BRANCHES,\n FLAG_DELETE_WORKTREES,\n FLAG_IGNORE_STALE_LOCKS,\n FLAG_INTERACTIVE,\n FLAG_REPORT,\n} from './commands/cleanup-options';\nimport { FinishPushDevOptions } from './commands/finish-push-dev-command';\nimport { LandPrRequest } from './commands/land-pr-command';\nimport { PushDevOptions } from './commands/push-dev-command';\nimport {\n ReviewBudgetCheckOptions,\n WriteReviewInput,\n WriteReviewOptions,\n} from './commands/write-review-command';\nimport {\n WriteReviewFixesInput,\n WriteReviewFixesOptions,\n} from './commands/write-review-fixes-command';\nimport { PrGateApp } from './pr-gate-app';\nimport { PrGateCliInvocation } from './pr-gate-cli-invocation';\n\nconst ABORT = '--abort';\nconst CHECK = '--check';\nconst CHECKLIST = '--checklist';\nconst FILE = '--file';\nconst FORCE = '--force';\nconst LIST = '--list';\nconst PR = '--pr';\nconst REBASE_RESOLUTION = '--rebase-resolution';\nconst REMOVE = '--remove';\nconst RESOLVE = '--resolve';\n\n/** Stable application boundary for every published `wp-*` command. */\n@injectable(bindingScopeValues.Singleton)\nexport class PrGateCliApp {\n constructor(\n private readonly app: PrGateApp,\n private readonly cleanupUsage: CleanupUsage,\n private readonly writeReviewInput: WriteReviewInput,\n private readonly writeReviewFixesInput: WriteReviewFixesInput,\n ) {}\n\n async run(invocation: PrGateCliInvocation): Promise<void> {\n // eslint-disable-next-line @webpieces/no-unmanaged-exceptions\n try {\n await this.dispatch(path.basename(invocation.binName), invocation);\n } catch (err: unknown) {\n const error = toError(err);\n if (err instanceof CliExitError) {\n if (err.message !== '') {\n (err.exitCode === 0 ? invocation.stdout : invocation.stderr).write(\n err.message + '\\n',\n );\n }\n invocation.processExit.exit(err.exitCode);\n return;\n }\n const message =\n err instanceof RuleFailError ? renderRuleFailForHuman(err) : error.message;\n invocation.stderr.write(message + '\\n');\n invocation.processExit.exit(1);\n }\n }\n\n private async dispatch(binName: string, invocation: PrGateCliInvocation): Promise<void> {\n if (await this.dispatchUpdateCommand(binName, invocation)) return;\n if (await this.dispatchPrCommand(binName, invocation)) return;\n if (await this.dispatchRepoCommand(binName, invocation)) return;\n if (await this.dispatchReviewCommand(binName, invocation)) return;\n throw new CliExitError(2, `Unknown PR-gate command: ${binName}`);\n }\n\n private async dispatchUpdateCommand(\n binName: string,\n invocation: PrGateCliInvocation,\n ): Promise<boolean> {\n if (binName === 'wp-finish-upsert-pr') {\n await this.noArgs(\n invocation,\n this.finishUpsertUsage(),\n (): Promise<void> => this.app.finishUpsertPr(),\n );\n return true;\n }\n if (binName === 'wp-start-upsert-pr') {\n await this.noArgs(\n invocation,\n this.startUpsertUsage(),\n (): Promise<void> => this.app.startUpsertPr(),\n );\n return true;\n }\n if (binName === 'wp-start-update') {\n await this.noArgs(\n invocation,\n this.startUpdateUsage(),\n (): Promise<void> => this.app.startUpdate(),\n );\n return true;\n }\n if (binName === 'wp-finish-update') {\n await this.noArgs(\n invocation,\n this.finishUpdateUsage(),\n (): Promise<void> => this.app.finishUpdate(),\n );\n return true;\n }\n if (binName === 'wp-sync-main') {\n await this.noArgs(\n invocation,\n this.syncMainUsage(),\n (): Promise<void> => this.app.syncMain(),\n );\n return true;\n }\n return false;\n }\n\n private async dispatchPrCommand(\n binName: string,\n invocation: PrGateCliInvocation,\n ): Promise<boolean> {\n if (binName === 'wp-human-post-pr') {\n await this.noArgs(\n invocation,\n this.humanPostUsage(),\n (): Promise<void> => this.app.humanPostPr(),\n );\n return true;\n }\n if (binName === 'wp-upsert-hotfix-pr') {\n await this.noArgs(\n invocation,\n this.hotfixUsage(),\n (): Promise<void> => this.app.upsertHotfixPr(),\n );\n return true;\n }\n if (binName === 'wp-check-pr') {\n await this.noArgs(\n invocation,\n this.checkPrUsage(),\n (): Promise<void> => this.app.checkPr(),\n );\n return true;\n }\n if (binName === 'wp-review-upsert-pr') {\n await this.noArgs(\n invocation,\n this.reviewUpsertUsage(),\n (): Promise<void> => this.app.reviewUpsertPr(),\n );\n return true;\n }\n if (binName === 'wp-await-reviews') {\n await this.noArgs(\n invocation,\n this.awaitReviewsUsage(),\n (): Promise<void> => this.app.awaitReviews(),\n );\n return true;\n }\n return false;\n }\n\n private async dispatchRepoCommand(\n binName: string,\n invocation: PrGateCliInvocation,\n ): Promise<boolean> {\n if (binName === 'wp-build') {\n const args = this.parse(invocation, this.buildUsage());\n await this.app.build(new BuildOptions(args.has(FORCE)));\n return true;\n }\n if (binName === 'wp-build-dev') {\n await this.noArgs(invocation, this.buildDevUsage(), (): Promise<void> => this.app.buildDev());\n return true;\n }\n if (binName === 'wp-cleanup') {\n const args = this.parse(invocation, this.cleanupUsage.declare());\n await this.app.cleanup(\n new CleanupOptions(\n new DeleteSelection(\n FLAG_DELETE_BRANCHES,\n args.has(FLAG_DELETE_BRANCHES),\n args.value(FLAG_DELETE_BRANCHES),\n ),\n new DeleteSelection(\n FLAG_DELETE_WORKTREES,\n args.has(FLAG_DELETE_WORKTREES),\n args.value(FLAG_DELETE_WORKTREES),\n ),\n args.has(FLAG_REPORT),\n args.has(FLAG_INTERACTIVE),\n args.has(FLAG_IGNORE_STALE_LOCKS),\n ),\n );\n return true;\n }\n if (binName === 'wp-land-pr') {\n const args = this.parse(invocation, this.landUsage());\n await this.app.landPr(new LandPrRequest(args.has(PR), args.value(PR)));\n return true;\n }\n if (binName === 'wp-push-dev') {\n const args = this.parse(invocation, this.pushDevUsage());\n const opts = new PushDevOptions();\n opts.list = args.has(LIST);\n opts.remove = args.has(REMOVE);\n opts.force = args.has(FORCE);\n opts.rebaseResolution = args.has(REBASE_RESOLUTION);\n opts.resolve = args.has(RESOLVE);\n opts.resolveTarget = args.value(RESOLVE);\n await this.app.pushDev(opts);\n return true;\n }\n if (binName === 'wp-finish-push-dev') {\n const args = this.parse(invocation, this.finishPushDevUsage());\n await this.app.finishPushDev(new FinishPushDevOptions(args.has(ABORT)));\n return true;\n }\n if (binName === 'wp-await-checks') {\n const args = this.parse(invocation, this.awaitChecksUsage());\n await this.app.awaitChecks(new AwaitChecksArgs().parse(args.value(PR)));\n return true;\n }\n return false;\n }\n\n private async dispatchReviewCommand(\n binName: string,\n invocation: PrGateCliInvocation,\n ): Promise<boolean> {\n if (binName === 'wp-write-review') {\n const args = this.parse(invocation, this.writeReviewUsage());\n if (args.has(CHECK)) {\n await this.app.checkReviewBudget(\n new ReviewBudgetCheckOptions(args.value(CHECKLIST), invocation.cwd),\n );\n return true;\n }\n const json = this.writeReviewInput.read(args.value(FILE), invocation.stdin);\n await this.app.writeReview(\n new WriteReviewOptions(args.value(CHECKLIST), json, invocation.cwd),\n );\n return true;\n }\n if (binName === 'wp-write-review-fixes') {\n const args = this.parse(invocation, this.writeReviewFixesUsage());\n const json = this.writeReviewFixesInput.read(args.value(FILE), invocation.stdin);\n await this.app.writeReviewFixes(new WriteReviewFixesOptions(json, invocation.cwd));\n return true;\n }\n return false;\n }\n\n private parse(invocation: PrGateCliInvocation, usage: CliUsage): CliArgSet {\n return new CliArgs().parseArgs(invocation.argv, usage);\n }\n\n private async noArgs(\n invocation: PrGateCliInvocation,\n usage: CliUsage,\n action: () => Promise<void>,\n ): Promise<void> {\n this.parse(invocation, usage);\n await action();\n }\n\n private buildUsage(): CliUsage {\n return new CliUsage(\n 'wp-build',\n 'Run this repo`s configured build (commands.pr-gate.buildCommand) — the same command the PR gate runs.',\n [\n new CliFlag(\n FORCE,\n 'Build even though this machine is already at its concurrent-build limit.',\n ),\n ],\n );\n }\n\n private buildDevUsage(): CliUsage {\n return new CliUsage(\n 'wp-build-dev',\n 'Merge origin/dev into a throwaway branch and run commands.push-dev.buildCommand on it — wp-push-dev`s pre-publish check, without publishing.',\n );\n }\n\n private finishUpsertUsage(): CliUsage {\n return new CliUsage(\n 'wp-finish-upsert-pr',\n 'Finalize the merge, run the authoritative build gate, render the dashboard, and create/update the PR.',\n );\n }\n private humanPostUsage(): CliUsage {\n return new CliUsage(\n 'wp-human-post-pr',\n 'Interactively attest that a human is posting the current clean, current-main feature branch.',\n );\n }\n private hotfixUsage(): CliUsage {\n return new CliUsage(\n 'wp-upsert-hotfix-pr',\n 'Publish the current /hotfix/ branch through the hotfix gate.',\n );\n }\n private startUpsertUsage(): CliUsage {\n return new CliUsage(\n 'wp-start-upsert-pr',\n 'Update from main and hand off the PR review stage.',\n );\n }\n private startUpdateUsage(): CliUsage {\n return new CliUsage(\n 'wp-start-update',\n '3-point squash-update this feature branch from main (no PR).',\n );\n }\n private finishUpdateUsage(): CliUsage {\n return new CliUsage(\n 'wp-finish-update',\n 'Validate + finalize a resolved 3-point merge (no PR).',\n );\n }\n private syncMainUsage(): CliUsage {\n return new CliUsage(\n 'wp-sync-main',\n 'Go to main, fast-forward it, reap dead worktrees and branches, and sweep orphan directories.',\n );\n }\n private checkPrUsage(): CliUsage {\n return new CliUsage(\n 'wp-check-pr',\n 'CI check: verify this PR was created through the webpieces gated flow (valid gate token).',\n );\n }\n private reviewUpsertUsage(): CliUsage {\n return new CliUsage(\n 'wp-review-upsert-pr',\n 'Validate the merge, build, extract the diff, and brief required reviewers.',\n );\n }\n private awaitReviewsUsage(): CliUsage {\n return new CliUsage('wp-await-reviews', 'Block until every reviewer verdict has landed.');\n }\n\n private landUsage(): CliUsage {\n return new CliUsage(\n 'wp-land-pr',\n 'Squash-merge a PR into main with its description as the commit body.',\n [new CliFlag(PR, 'The PR number to land.', true)],\n );\n }\n\n private pushDevUsage(): CliUsage {\n return new CliUsage(\n 'wp-push-dev',\n 'Check this branch against origin/dev (throwaway merge + commands.push-dev.buildCommand), then publish a disposable copy of it for shared dev.',\n [\n new CliFlag(LIST, 'List published dev copies.'),\n new CliFlag(\n REMOVE,\n \"Delete this branch's dev copy, then push the <removeNamespace>/<branch> marker\"\n + ' (default dev-remove) that triggers the dev rebuild.',\n ),\n new CliFlag(\n RESOLVE,\n 'Compose other published copies, optionally one named branch.',\n true,\n ),\n new CliFlag(REBASE_RESOLUTION, 'Replay an existing resolution onto new commits.'),\n new CliFlag(FORCE, 'Discard the published resolution and overwrite it.'),\n ],\n );\n }\n\n private finishPushDevUsage(): CliUsage {\n return new CliUsage(\n 'wp-finish-push-dev',\n 'Commit a resolved dev merge, run the dev build when publishing, and publish the copy.',\n [new CliFlag(ABORT, 'Throw the resolve away without publishing.')],\n );\n }\n\n private awaitChecksUsage(): CliUsage {\n return new CliUsage('wp-await-checks', 'Block until checks on one PR stop running.', [\n new CliFlag(PR, 'REQUIRED. The PR number to wait on.', true),\n ]);\n }\n\n private writeReviewUsage(): CliUsage {\n return new CliUsage('wp-write-review', 'Submit one reviewer verdict for one checklist.', [\n new CliFlag(CHECKLIST, 'REQUIRED. The checklist id.', true),\n new CliFlag(FILE, 'The verdict JSON file. Omit to read stdin.', true),\n new CliFlag(CHECK, 'Only check whether this checklist may still be reviewed.'),\n ]);\n }\n\n private writeReviewFixesUsage(): CliUsage {\n return new CliUsage(\n 'wp-write-review-fixes',\n 'Record the coordinator response to red findings.',\n [new CliFlag(FILE, 'JSON file. Omit to read stdin.', true)],\n );\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"pr-gate-cli-app.js","sourceRoot":"","sources":["../../../../../../packages/tooling/pr-gate/src/scripts/pr-gate-cli-app.ts"],"names":[],"mappings":";;;;AAAA,mDAA6B;AAE7B,0DAAqI;AACrI,iEAA6D;A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,CAAA;AA1WY,oCAAY;uBAAZ,YAAY;IADxB,IAAA,sBAAU,EAAC,8BAAkB,CAAC,SAAS,CAAC;6CAGX,uBAAS;QACA,8BAAY;QACR,uCAAgB;QACX,kDAAqB;GALxD,YAAY,CA0WxB","sourcesContent":["import * as path from 'path';\n\nimport { CliArgs, CliArgSet, CliExitError, CliFlag, CliUsage, RuleFailError, renderRuleFailForHuman } from '@webpieces/rules-config';\nimport { toError } from '@webpieces/tooling-common/to-error';\nimport { bindingScopeValues, injectable } from 'inversify';\n\nimport { AwaitChecksArgs } from './commands/await-checks-command';\nimport { BuildOptions } from './commands/build-command';\nimport {\n CleanupOptions,\n CleanupUsage,\n DeleteSelection,\n FLAG_DELETE_BRANCHES,\n FLAG_DELETE_WORKTREES,\n FLAG_IGNORE_STALE_LOCKS,\n FLAG_INTERACTIVE,\n FLAG_REPORT,\n} from './commands/cleanup-options';\nimport { BuildPushDevOptions } from './commands/build-push-dev-command';\nimport { FinishPushDevOptions } from './commands/finish-push-dev-command';\nimport { LandPrRequest } from './commands/land-pr-command';\nimport {\n ReviewBudgetCheckOptions,\n WriteReviewInput,\n WriteReviewOptions,\n} from './commands/write-review-command';\nimport {\n WriteReviewFixesInput,\n WriteReviewFixesOptions,\n} from './commands/write-review-fixes-command';\nimport { PrGateApp } from './pr-gate-app';\nimport { PrGateCliInvocation } from './pr-gate-cli-invocation';\n\nconst ABORT = '--abort';\nconst CHECK = '--check';\nconst CHECKLIST = '--checklist';\nconst FILE = '--file';\nconst FORCE = '--force';\nconst LIST = '--list';\nconst PR = '--pr';\nconst REMOVE = '--remove';\n\n/** Stable application boundary for every published `wp-*` command. */\n@injectable(bindingScopeValues.Singleton)\nexport class PrGateCliApp {\n constructor(\n private readonly app: PrGateApp,\n private readonly cleanupUsage: CleanupUsage,\n private readonly writeReviewInput: WriteReviewInput,\n private readonly writeReviewFixesInput: WriteReviewFixesInput,\n ) {}\n\n async run(invocation: PrGateCliInvocation): Promise<void> {\n // eslint-disable-next-line @webpieces/no-unmanaged-exceptions\n try {\n await this.dispatch(path.basename(invocation.binName), invocation);\n } catch (err: unknown) {\n const error = toError(err);\n if (err instanceof CliExitError) {\n if (err.message !== '') {\n (err.exitCode === 0 ? invocation.stdout : invocation.stderr).write(\n err.message + '\\n',\n );\n }\n invocation.processExit.exit(err.exitCode);\n return;\n }\n const message =\n err instanceof RuleFailError ? renderRuleFailForHuman(err) : error.message;\n invocation.stderr.write(message + '\\n');\n invocation.processExit.exit(1);\n }\n }\n\n private async dispatch(binName: string, invocation: PrGateCliInvocation): Promise<void> {\n if (await this.dispatchUpdateCommand(binName, invocation)) return;\n if (await this.dispatchPrCommand(binName, invocation)) return;\n if (await this.dispatchRepoCommand(binName, invocation)) return;\n if (await this.dispatchReviewCommand(binName, invocation)) return;\n throw new CliExitError(2, `Unknown PR-gate command: ${binName}`);\n }\n\n private async dispatchUpdateCommand(\n binName: string,\n invocation: PrGateCliInvocation,\n ): Promise<boolean> {\n if (binName === 'wp-finish-upsert-pr') {\n await this.noArgs(\n invocation,\n this.finishUpsertUsage(),\n (): Promise<void> => this.app.finishUpsertPr(),\n );\n return true;\n }\n if (binName === 'wp-start-upsert-pr') {\n await this.noArgs(\n invocation,\n this.startUpsertUsage(),\n (): Promise<void> => this.app.startUpsertPr(),\n );\n return true;\n }\n if (binName === 'wp-start-update') {\n await this.noArgs(\n invocation,\n this.startUpdateUsage(),\n (): Promise<void> => this.app.startUpdate(),\n );\n return true;\n }\n if (binName === 'wp-finish-update') {\n await this.noArgs(\n invocation,\n this.finishUpdateUsage(),\n (): Promise<void> => this.app.finishUpdate(),\n );\n return true;\n }\n if (binName === 'wp-sync-main') {\n await this.noArgs(\n invocation,\n this.syncMainUsage(),\n (): Promise<void> => this.app.syncMain(),\n );\n return true;\n }\n return false;\n }\n\n private async dispatchPrCommand(\n binName: string,\n invocation: PrGateCliInvocation,\n ): Promise<boolean> {\n if (binName === 'wp-human-post-pr') {\n await this.noArgs(\n invocation,\n this.humanPostUsage(),\n (): Promise<void> => this.app.humanPostPr(),\n );\n return true;\n }\n if (binName === 'wp-upsert-hotfix-pr') {\n await this.noArgs(\n invocation,\n this.hotfixUsage(),\n (): Promise<void> => this.app.upsertHotfixPr(),\n );\n return true;\n }\n if (binName === 'wp-check-pr') {\n await this.noArgs(\n invocation,\n this.checkPrUsage(),\n (): Promise<void> => this.app.checkPr(),\n );\n return true;\n }\n if (binName === 'wp-review-upsert-pr') {\n await this.noArgs(\n invocation,\n this.reviewUpsertUsage(),\n (): Promise<void> => this.app.reviewUpsertPr(),\n );\n return true;\n }\n if (binName === 'wp-await-reviews') {\n await this.noArgs(\n invocation,\n this.awaitReviewsUsage(),\n (): Promise<void> => this.app.awaitReviews(),\n );\n return true;\n }\n return false;\n }\n\n private async dispatchRepoCommand(\n binName: string,\n invocation: PrGateCliInvocation,\n ): Promise<boolean> {\n if (binName === 'wp-build') {\n const args = this.parse(invocation, this.buildUsage());\n await this.app.build(new BuildOptions(args.has(FORCE)));\n return true;\n }\n if (binName === 'wp-cleanup') {\n const args = this.parse(invocation, this.cleanupUsage.declare());\n await this.app.cleanup(\n new CleanupOptions(\n new DeleteSelection(\n FLAG_DELETE_BRANCHES,\n args.has(FLAG_DELETE_BRANCHES),\n args.value(FLAG_DELETE_BRANCHES),\n ),\n new DeleteSelection(\n FLAG_DELETE_WORKTREES,\n args.has(FLAG_DELETE_WORKTREES),\n args.value(FLAG_DELETE_WORKTREES),\n ),\n args.has(FLAG_REPORT),\n args.has(FLAG_INTERACTIVE),\n args.has(FLAG_IGNORE_STALE_LOCKS),\n ),\n );\n return true;\n }\n if (binName === 'wp-land-pr') {\n const args = this.parse(invocation, this.landUsage());\n await this.app.landPr(new LandPrRequest(args.has(PR), args.value(PR)));\n return true;\n }\n if (binName === 'wp-start-push-dev') {\n await this.noArgs(invocation, this.startPushDevUsage(), (): Promise<void> => this.app.startPushDev());\n return true;\n }\n if (binName === 'wp-build-push-dev') {\n const args = this.parse(invocation, this.buildPushDevUsage());\n await this.app.buildPushDev(new BuildPushDevOptions(args.has(ABORT)));\n return true;\n }\n if (binName === 'wp-finish-push-dev') {\n const args = this.parse(invocation, this.finishPushDevUsage());\n const opts = new FinishPushDevOptions();\n opts.list = args.has(LIST);\n opts.remove = args.has(REMOVE);\n await this.app.finishPushDev(opts);\n return true;\n }\n if (binName === 'wp-await-checks') {\n const args = this.parse(invocation, this.awaitChecksUsage());\n await this.app.awaitChecks(new AwaitChecksArgs().parse(args.value(PR)));\n return true;\n }\n return false;\n }\n\n private async dispatchReviewCommand(\n binName: string,\n invocation: PrGateCliInvocation,\n ): Promise<boolean> {\n if (binName === 'wp-write-review') {\n const args = this.parse(invocation, this.writeReviewUsage());\n if (args.has(CHECK)) {\n await this.app.checkReviewBudget(\n new ReviewBudgetCheckOptions(args.value(CHECKLIST), invocation.cwd),\n );\n return true;\n }\n const json = this.writeReviewInput.read(args.value(FILE), invocation.stdin);\n await this.app.writeReview(\n new WriteReviewOptions(args.value(CHECKLIST), json, invocation.cwd),\n );\n return true;\n }\n if (binName === 'wp-write-review-fixes') {\n const args = this.parse(invocation, this.writeReviewFixesUsage());\n const json = this.writeReviewFixesInput.read(args.value(FILE), invocation.stdin);\n await this.app.writeReviewFixes(new WriteReviewFixesOptions(json, invocation.cwd));\n return true;\n }\n return false;\n }\n\n private parse(invocation: PrGateCliInvocation, usage: CliUsage): CliArgSet {\n return new CliArgs().parseArgs(invocation.argv, usage);\n }\n\n private async noArgs(\n invocation: PrGateCliInvocation,\n usage: CliUsage,\n action: () => Promise<void>,\n ): Promise<void> {\n this.parse(invocation, usage);\n await action();\n }\n\n private buildUsage(): CliUsage {\n return new CliUsage(\n 'wp-build',\n 'Run this repo`s configured build (commands.pr-gate.buildCommand) — the same command the PR gate runs.',\n [\n new CliFlag(\n FORCE,\n 'Build even though this machine is already at its concurrent-build limit.',\n ),\n ],\n );\n }\n\n private finishUpsertUsage(): CliUsage {\n return new CliUsage(\n 'wp-finish-upsert-pr',\n 'Finalize the merge, run the authoritative build gate, render the dashboard, and create/update the PR.',\n );\n }\n private humanPostUsage(): CliUsage {\n return new CliUsage(\n 'wp-human-post-pr',\n 'Interactively attest that a human is posting the current clean, current-main feature branch.',\n );\n }\n private hotfixUsage(): CliUsage {\n return new CliUsage(\n 'wp-upsert-hotfix-pr',\n 'Publish the current /hotfix/ branch through the hotfix gate.',\n );\n }\n private startUpsertUsage(): CliUsage {\n return new CliUsage(\n 'wp-start-upsert-pr',\n 'Update from main and hand off the PR review stage.',\n );\n }\n private startUpdateUsage(): CliUsage {\n return new CliUsage(\n 'wp-start-update',\n '3-point squash-update this feature branch from main (no PR).',\n );\n }\n private finishUpdateUsage(): CliUsage {\n return new CliUsage(\n 'wp-finish-update',\n 'Validate + finalize a resolved 3-point merge (no PR).',\n );\n }\n private syncMainUsage(): CliUsage {\n return new CliUsage(\n 'wp-sync-main',\n 'Go to main, fast-forward it, reap dead worktrees and branches, and sweep orphan directories.',\n );\n }\n private checkPrUsage(): CliUsage {\n return new CliUsage(\n 'wp-check-pr',\n 'CI check: verify this PR was created through the webpieces gated flow (valid gate token).',\n );\n }\n private reviewUpsertUsage(): CliUsage {\n return new CliUsage(\n 'wp-review-upsert-pr',\n 'Validate the merge, build, extract the diff, and brief required reviewers.',\n );\n }\n private awaitReviewsUsage(): CliUsage {\n return new CliUsage('wp-await-reviews', 'Block until every reviewer verdict has landed.');\n }\n\n private landUsage(): CliUsage {\n return new CliUsage(\n 'wp-land-pr',\n 'Squash-merge a PR into main with its description as the commit body.',\n [new CliFlag(PR, 'The PR number to land.', true)],\n );\n }\n\n private startPushDevUsage(): CliUsage {\n return new CliUsage(\n 'wp-start-push-dev',\n 'Dev-deploy stage 1: 3-point merge this branch from origin/main, only if it is behind it.',\n );\n }\n\n private buildPushDevUsage(): CliUsage {\n return new CliUsage(\n 'wp-build-push-dev',\n 'Dev-deploy stage 2: merge origin/dev into a throwaway branch, pnpm install, run commands.push-dev.buildCommand, and record the copy to publish. Re-run it to continue after resolving a conflict.',\n [new CliFlag(ABORT, 'Throw a conflict resolution in progress away.')],\n );\n }\n\n private finishPushDevUsage(): CliUsage {\n return new CliUsage(\n 'wp-finish-push-dev',\n 'Dev-deploy stage 3: publish the copy wp-build-push-dev verified as a disposable dev copy.',\n [\n new CliFlag(LIST, 'List published dev copies.'),\n new CliFlag(\n REMOVE,\n \"Delete this branch's dev copy, then push the <removeNamespace>/<branch> marker\"\n + ' (default dev-remove) that triggers the dev rebuild.',\n ),\n ],\n );\n }\n\n private awaitChecksUsage(): CliUsage {\n return new CliUsage('wp-await-checks', 'Block until checks on one PR stop running.', [\n new CliFlag(PR, 'REQUIRED. The PR number to wait on.', true),\n ]);\n }\n\n private writeReviewUsage(): CliUsage {\n return new CliUsage('wp-write-review', 'Submit one reviewer verdict for one checklist.', [\n new CliFlag(CHECKLIST, 'REQUIRED. The checklist id.', true),\n new CliFlag(FILE, 'The verdict JSON file. Omit to read stdin.', true),\n new CliFlag(CHECK, 'Only check whether this checklist may still be reviewed.'),\n ]);\n }\n\n private writeReviewFixesUsage(): CliUsage {\n return new CliUsage(\n 'wp-write-review-fixes',\n 'Record the coordinator response to red findings.',\n [new CliFlag(FILE, 'JSON file. Omit to read stdin.', true)],\n );\n }\n}\n"]}
|
|
@@ -48,8 +48,8 @@ exports.REVIEW_STAGE = 'review';
|
|
|
48
48
|
exports.FINISH_STAGE = 'finish';
|
|
49
49
|
// `wp-build`, which is not a stage of the PR flow but runs the SAME gate (BuildAffected.runBuildGate).
|
|
50
50
|
exports.BUILD_STAGE = 'build';
|
|
51
|
-
// `wp-build-dev`
|
|
52
|
-
//
|
|
51
|
+
// `wp-build-push-dev`'s build of the merge with dev (#1397, #1403): the SAME gate, running
|
|
52
|
+
// `commands.push-dev.buildCommand` instead.
|
|
53
53
|
exports.DEV_BUILD_STAGE = 'build-dev';
|
|
54
54
|
/** The fixed log names — see BuildGateLog.fileNameFor for why only the two ad-hoc builds get one. */
|
|
55
55
|
exports.BUILD_LOG_NAME = 'build.log';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build-gate-log.js","sourceRoot":"","sources":["../../../../../../../packages/tooling/pr-gate/src/scripts/workflow/build-gate-log.ts"],"names":[],"mappings":";;;;AAAA,+CAAyB;AACzB,0DAA2D;AAC3D,8DAA8G;AAC9G,yCAA2D;AAE3D,mDAA8C;AAC9C,yDAAoD;AACpD,6DAAwD;AAExD,0GAA0G;AAC1G,yGAAyG;AACzG,2GAA2G;AAC3G,mGAAmG;AACnG,kGAAkG;AAClG,EAAE;AACF,uGAAuG;AACvG,kGAAkG;AAClG,EAAE;AACF,0GAA0G;AAC1G,sGAAsG;AACtG,wGAAwG;AACxG,2GAA2G;AAC3G,2GAA2G;AAC3G,wGAAwG;AACxG,qGAAqG;AACrG,EAAE;AACF,sIAAsI;AACtI,kHAAkH;AAClH,0GAA0G;AAC1G,kGAAkG;AAClG,EAAE;AACF,uGAAuG;AACvG,0GAA0G;AAC1G,uGAAuG;AAEvG;uEACuE;AAC1D,QAAA,YAAY,GAAG,MAAM,CAAC;AAEnC;;sCAEsC;AACzB,QAAA,kBAAkB,GAAG,EAAE,CAAC;AAErC;;GAEG;AACU,QAAA,YAAY,GAAG,QAAQ,CAAC;AACxB,QAAA,YAAY,GAAG,QAAQ,CAAC;AACrC,uGAAuG;AAC1F,QAAA,WAAW,GAAG,OAAO,CAAC;AACnC,2GAA2G;AAC3G,oDAAoD;AACvC,QAAA,eAAe,GAAG,WAAW,CAAC;AAE3C,qGAAqG;AACxF,QAAA,cAAc,GAAG,WAAW,CAAC;AAC7B,QAAA,kBAAkB,GAAG,eAAe,CAAC;AAElD;;;;;;;GAOG;AACH,MAAa,iBAAiB;IAIL;IACA;IACA;IALb,QAAQ,GAAkB,IAAI,CAAC;IAEvC,YACqB,KAAkB,EAClB,OAAe,EACf,WAAmB;QAFnB,UAAK,GAAL,KAAK,CAAa;QAClB,YAAO,GAAP,OAAO,CAAQ;QACf,gBAAW,GAAX,WAAW,CAAQ;IACrC,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ED,wGAAwG;IAChG,IAAI,CAAC,KAAa;QACtB,OAAO,KAAK,CAAC,OAAO,CAAC,mBAAmB,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC;IAC3E,CAAC;IAED,qGAAqG;IACrG,8DAA8D;IACtD,KAAK,CAAC,MAAM,CAAC,QAAgB,EAAE,IAAc;QACjD,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,QAAQ,EAAE,GAAG,IAAI,CAAC,CAAC,CAAC;QAC7D,IAAI,CAAC,MAAM,CAAC,EAAE;YAAE,OAAO,EAAE,CAAC;QAC1B,OAAO,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;IAChC,CAAC;CACJ,CAAA;AA9IY,oCAAY;uBAAZ,YAAY;IADxB,IAAA,sBAAU,EAAC,8BAAkB,CAAC,SAAS,CAAC;6CAGT,2BAAW;QACJ,iCAAc;QACvB,8BAAa;QACP,iCAAgB;GALvC,YAAY,CA8IxB","sourcesContent":["import * as fs from 'fs';\nimport { BuildTermination } from '@webpieces/rules-config';\nimport { gitCheckout, GitProcessApi, NativeProcessApi, ShellTerminationDto } from '@webpieces/tooling-common';\nimport { injectable, bindingScopeValues } from 'inversify';\n\nimport { GateLogFile } from './gate-log-file';\nimport { StageOutputLog } from './stage-output-log';\nimport { BuildLogFollower } from './build-log-follower';\n\n// ─── Why ───────────────────────────────────────────────────────────────────────────────────────────────\n// The build gate already builds everything. When the output only ever went to the CONSOLE, an agent that\n// wanted a different slice of it re-ran the WHOLE BUILD to get it: one measured session spent 23.9 minutes\n// across nine `nx affected` runs, five of them with NO code change in between — `| tail -50`, then\n// `> /tmp/file`, then `| grep`, then `| sed -n '1100,1230p'`. ~19 minutes spent re-reading a log.\n//\n// So the build's output is not streamed; it is REDIRECTED, in full, to a file whose path the caller is\n// handed on completion. Reading a different slice is then a `grep` of a FILE, not a second build.\n//\n// ─── Why a redirect and not `tee` ──────────────────────────────────────────────────────────────────────\n// An earlier cut of this used `cmd 2>&1 | tee log`, to keep the terminal byte-identical. That is what\n// makes the transcript expensive in the first place — an AI caller carries every line of it in context.\n// The redirect keeps the console to a handful of lines (a heartbeat, then a pointer at the file), which is\n// the entire productivity claim. Losing `tee` also deletes the `$?`-into-a-side-file dance it needed: in a\n// pipeline the shell reports TEE's status, which is 0 whether the build passed or failed, so the status\n// had to be smuggled out through a side file. With no pipe, the child's own exit code IS the answer.\n//\n// ─── Why async (a child that does not block, not a synchronous spawn) ──────────────────────────────────────────────────────────────\n// A synchronous spawn blocks the event loop for the length of the build, so NOTHING can print while it runs — and\n// a silent terminal for 3–7 minutes is indistinguishable from a hang. The heartbeat is the reason this is\n// async, and it is why `run` returns a Promise and `BuildAffected.runBuildGate` is async with it.\n//\n// It is also the reason the heartbeat goes through `StageOutputLog.say` rather than `process.stdout` —\n// stage ② and stage ③ capture their own console output to a file, and a heartbeat captured into a file is\n// a heartbeat nobody can see. The 600-second watchdog that kills a silent command does not read files.\n\n/** How often the heartbeat reports the log's size. Hardcoded: a knob here would be a knob the PR gate's\n * own build never receives, and the two must stay the same command. */\nexport const HEARTBEAT_MS = 10_000;\n\n/** How many trailing log lines the failure message echoes, so the immediate cause is visible without a\n * second command. Small on purpose — the FULL log is one grep away and the message must not become the\n * transcript it exists to replace. */\nexport const FAILURE_TAIL_LINES = 20;\n\n/**\n * Which stage's gate is being captured. The value decides the log FILENAME.\n */\nexport const REVIEW_STAGE = 'review';\nexport const FINISH_STAGE = 'finish';\n// `wp-build`, which is not a stage of the PR flow but runs the SAME gate (BuildAffected.runBuildGate).\nexport const BUILD_STAGE = 'build';\n// `wp-build-dev` and the pre-publish build of `wp-push-dev` / `wp-finish-push-dev` (#1397): the SAME gate,\n// running `commands.push-dev.buildCommand` instead.\nexport const DEV_BUILD_STAGE = 'build-dev';\n\n/** The fixed log names — see BuildGateLog.fileNameFor for why only the two ad-hoc builds get one. */\nexport const BUILD_LOG_NAME = 'build.log';\nexport const DEV_BUILD_LOG_NAME = 'build-dev.log';\n\n/**\n * The heartbeat's state: the line count reported on the PREVIOUS tick, so a tick that has not moved can\n * say so. Stateful per RUN, which is why it is constructed per run rather than injected.\n *\n * `still` is the load-bearing word. A build that is linking, or waiting on a cold nx cache, produces no\n * output for minutes; without `still` the caller sees the same number twice and cannot tell a stalled\n * BUILD from a stalled REPORTER.\n */\nexport class BuildLogHeartbeat {\n private previous: number | null = null;\n\n constructor(\n private readonly files: GateLogFile,\n private readonly logPath: string,\n private readonly displayPath: string,\n ) {}\n\n /** One heartbeat line — `<path> size <n> lines`, plus ` still` when <n> has not moved. */\n tick(): string {\n const count = this.files.lineCount(this.logPath);\n const still = this.previous !== null && count === this.previous ? ' still' : '';\n this.previous = count;\n return `${this.displayPath} size ${count} lines${still}`;\n }\n}\n\n/**\n * Captures the build gate's full output to a file, reports progress while it runs, and renders the\n * pointer the caller is handed instead of a rebuild instruction.\n *\n * WHERE the file goes, how the previous run is kept, and what the pointer reads like are `GateLogFile`'s\n * — one mechanism, shared with the stage console log, so there is a single answer to \"where is it?\".\n *\n * ─── One directory, two naming schemes, one rule each ──────────────────────────────────────────────────\n * Every build log sits in `<tree>/.webpieces/logs/` (GateLogFile.logsPath — inside the checkout the\n * command ran in, a linked worktree's own root included; issue #1393).\n * • `wp-build` (BUILD_STAGE) writes ONE fixed name, `build.log`. History comes from the rotation.\n * • stage ② and stage ③ write `build-gate-<stage>-<branch>-<shortSha>.log`, because those two gates CAN\n * run against one commit and a failure message from one must not be pointing at a file the other\n * overwrote.\n * Nobody needs to type either name: the absolute path is printed as the FIRST line of the build, before\n * it starts, and again in the closing pointer.\n *\n * ─── Concurrency ───────────────────────────────────────────────────────────────────────────────────────\n * The DIRECTORY is per checkout — a linked worktree writes under its own root — so \"N agents in N\n * worktrees\" is safe by construction rather than by naming. The residual case is two builds in the SAME\n * worktree at once, which is already unsupported: both would be driving one git index.\n */\n@injectable(bindingScopeValues.Singleton)\nexport class BuildGateLog {\n constructor(\n private readonly files: GateLogFile,\n private readonly stageConsole: StageOutputLog,\n private readonly git: GitProcessApi,\n private readonly processes: NativeProcessApi,\n ) {}\n\n /** Absolute path of the log for `stage` at the current HEAD, creating its directory. */\n pathFor(repoRoot: string, stage: string): Promise<string> {\n return this.resolvePath(repoRoot, stage);\n }\n\n /** The same path, and '' when no log has been WRITTEN there yet. Used by finish's skip path. */\n async existingLogFor(repoRoot: string, stage: string): Promise<string> {\n const file = await this.resolvePath(repoRoot, stage);\n return fs.existsSync(file) ? file : '';\n }\n\n /** `build.log` for `wp-build`; `build-dev.log` for the dev build; `build-gate-<stage>-<branch>-<shortSha>.log` for the PR-flow stages. */\n async fileNameFor(repoRoot: string, stage: string): Promise<string> {\n if (stage === BUILD_STAGE) return BUILD_LOG_NAME;\n // Fixed, like build.log: the dev build runs on a THROWAWAY branch whose name and sha say nothing\n // to the reader, and history comes from the same rotation.\n if (stage === DEV_BUILD_STAGE) return DEV_BUILD_LOG_NAME;\n const branch = this.slug(gitCheckout.branch(repoRoot) ?? '');\n const sha = this.slug(await this.gitOut(repoRoot, ['rev-parse', '--short', 'HEAD']));\n return `build-gate-${this.slug(stage)}-${branch === '' ? 'nobranch' : branch}-${sha === '' ? 'nosha' : sha}.log`;\n }\n\n /**\n * Run `buildCommand` with its stdout AND stderr redirected in full to `logPath`, printing a heartbeat\n * every HEARTBEAT_MS so the caller can see it is alive. Returns the BUILD's raw termination facts.\n * Nothing is truncated. Ordinary AI-facing callers do not stream; the explicitly human-attested\n * PR escape hatch may wrap this with runStreaming(), which follows the same durable file live.\n */\n async run(repoRoot: string, buildCommand: string, logPath: string): Promise<BuildTermination> {\n this.files.rotate(logPath);\n const fd = fs.openSync(logPath, 'w');\n const heartbeat = new BuildLogHeartbeat(\n this.files,\n logPath,\n this.files.displayPath(repoRoot, logPath),\n );\n const timer = setInterval((): void => {\n this.stageConsole.say(`${heartbeat.tick()}\\n`);\n }, HEARTBEAT_MS);\n // webpieces-disable no-unmanaged-exceptions -- chokepoint: the timer and the fd MUST be released\n // whatever the child does, and the exit code is returned rather than thrown so runBuildGate owns\n // the one CliExitError.\n // eslint-disable-next-line @webpieces/no-unmanaged-exceptions\n try {\n return this.recordTermination(await this.processes.runShellToFile(buildCommand, repoRoot, fd), fd);\n } finally {\n clearInterval(timer);\n fs.closeSync(fd);\n }\n }\n\n /** Human-only variant: preserve the durable log and follow its appended bytes live. */\n runStreaming(\n repoRoot: string,\n buildCommand: string,\n logPath: string,\n ): Promise<BuildTermination> {\n // run() synchronously rotates and opens the file before reaching its first await, so the follower\n // cannot accidentally replay the previous build that was at this path.\n const completion = this.run(repoRoot, buildCommand, logPath);\n const follower = new BuildLogFollower(logPath, this.stageConsole);\n follower.start();\n return completion.finally((): void => follower.stop());\n }\n\n /** The `FullLog : <path>` line printed before the build starts — see GateLogFile.startLine. */\n startLine(logPath: string): string {\n return this.files.startLine(logPath);\n }\n\n /**\n * The success summary: the caller is told WHERE the full output is, not handed the output.\n */\n successMessage(logPath: string): string {\n return `\\nBuild success\\n${this.files.pointer(logPath)}`;\n }\n\n /**\n * The ENTIRE message the caller gets on a failed build. It names the log, echoes the last\n * FAILURE_TAIL_LINES lines so the immediate cause needs no second command, and forbids the rebuild\n * this whole file exists to prevent.\n *\n * The last sentence is not filler. If the log holds no visible failure then something upstream is wrong\n * (a runner that died without printing, a truncated redirect), and the worst possible response is an\n * agent guessing or rebuilding — so it is told to surface the contradiction to the human and stop.\n */\n failureMessage(buildCommand: string, logPath: string, termination: BuildTermination): string {\n return (\n `\\nBuild Failed: ${buildCommand}\\n${this.files.pointer(logPath)}\\n` +\n `${this.terminationRecord(termination)}\\n` +\n `Last ${FAILURE_TAIL_LINES} lines of that log:\\n${this.files.tail(logPath, FAILURE_TAIL_LINES)}\\n` +\n `Read that FILE for the failures. Do NOT re-run the build to see them.\\n` +\n `If you do not see failures in that log, report that to the user and stop.\\n`\n );\n }\n\n // The child's close code AND signal. A command that never starts (a shell that is missing, a cwd that\n // vanished) fails CLOSED to 1 — calling a build that never ran green is the one outcome that must be\n // impossible — and the reason is APPENDED TO THE LOG, so the failure message's pointer still leads to\n // it rather than to an empty file.\n private recordTermination(ended: ShellTerminationDto, fd: number): BuildTermination {\n if (ended.startError !== null) {\n fs.writeSync(fd, `\\nThe build command could not be started: ${ended.startError}\\n`);\n return new BuildTermination(1, null);\n }\n const termination = new BuildTermination(ended.code, ended.signal);\n if (ended.code === null || ended.signal !== null)\n fs.writeSync(fd, `\\n${this.terminationRecord(termination)}\\n`);\n return termination;\n }\n\n /** One stable, human-readable spelling shared by the FullLog and the immediate failure output. */\n private terminationRecord(termination: BuildTermination): string {\n const code = termination.code === null ? 'null' : String(termination.code);\n const signal = termination.signal === null ? 'none' : termination.signal;\n return `Build process termination: exit code ${code}; signal ${signal}.`;\n }\n\n private async resolvePath(repoRoot: string, stage: string): Promise<string> {\n return this.files.logsPath(repoRoot, await this.fileNameFor(repoRoot, stage));\n }\n\n // Anything that is not a filename-safe character becomes '-', so `dean/feat` cannot create directories.\n private slug(value: string): string {\n return value.replace(/[^A-Za-z0-9._-]+/g, '-').replace(/^-+|-+$/g, '');\n }\n\n // One local git read. Fails SOFT to '' — a missing branch/sha degrades the FILENAME, and degrading a\n // filename may never be the reason a build gate does not run.\n private async gitOut(repoRoot: string, args: string[]): Promise<string> {\n const result = await this.git.run(['-C', repoRoot, ...args]);\n if (!result.ok) return '';\n return result.stdout.trim();\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"build-gate-log.js","sourceRoot":"","sources":["../../../../../../../packages/tooling/pr-gate/src/scripts/workflow/build-gate-log.ts"],"names":[],"mappings":";;;;AAAA,+CAAyB;AACzB,0DAA2D;AAC3D,8DAA8G;AAC9G,yCAA2D;AAE3D,mDAA8C;AAC9C,yDAAoD;AACpD,6DAAwD;AAExD,0GAA0G;AAC1G,yGAAyG;AACzG,2GAA2G;AAC3G,mGAAmG;AACnG,kGAAkG;AAClG,EAAE;AACF,uGAAuG;A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,CAAC,CAAC,CAAC;QAC7D,IAAI,CAAC,MAAM,CAAC,EAAE;YAAE,OAAO,EAAE,CAAC;QAC1B,OAAO,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;IAChC,CAAC;CACJ,CAAA;AA9IY,oCAAY;uBAAZ,YAAY;IADxB,IAAA,sBAAU,EAAC,8BAAkB,CAAC,SAAS,CAAC;6CAGT,2BAAW;QACJ,iCAAc;QACvB,8BAAa;QACP,iCAAgB;GALvC,YAAY,CA8IxB","sourcesContent":["import * as fs from 'fs';\nimport { BuildTermination } from '@webpieces/rules-config';\nimport { gitCheckout, GitProcessApi, NativeProcessApi, ShellTerminationDto } from '@webpieces/tooling-common';\nimport { injectable, bindingScopeValues } from 'inversify';\n\nimport { GateLogFile } from './gate-log-file';\nimport { StageOutputLog } from './stage-output-log';\nimport { BuildLogFollower } from './build-log-follower';\n\n// ─── Why ───────────────────────────────────────────────────────────────────────────────────────────────\n// The build gate already builds everything. When the output only ever went to the CONSOLE, an agent that\n// wanted a different slice of it re-ran the WHOLE BUILD to get it: one measured session spent 23.9 minutes\n// across nine `nx affected` runs, five of them with NO code change in between — `| tail -50`, then\n// `> /tmp/file`, then `| grep`, then `| sed -n '1100,1230p'`. ~19 minutes spent re-reading a log.\n//\n// So the build's output is not streamed; it is REDIRECTED, in full, to a file whose path the caller is\n// handed on completion. Reading a different slice is then a `grep` of a FILE, not a second build.\n//\n// ─── Why a redirect and not `tee` ──────────────────────────────────────────────────────────────────────\n// An earlier cut of this used `cmd 2>&1 | tee log`, to keep the terminal byte-identical. That is what\n// makes the transcript expensive in the first place — an AI caller carries every line of it in context.\n// The redirect keeps the console to a handful of lines (a heartbeat, then a pointer at the file), which is\n// the entire productivity claim. Losing `tee` also deletes the `$?`-into-a-side-file dance it needed: in a\n// pipeline the shell reports TEE's status, which is 0 whether the build passed or failed, so the status\n// had to be smuggled out through a side file. With no pipe, the child's own exit code IS the answer.\n//\n// ─── Why async (a child that does not block, not a synchronous spawn) ──────────────────────────────────────────────────────────────\n// A synchronous spawn blocks the event loop for the length of the build, so NOTHING can print while it runs — and\n// a silent terminal for 3–7 minutes is indistinguishable from a hang. The heartbeat is the reason this is\n// async, and it is why `run` returns a Promise and `BuildAffected.runBuildGate` is async with it.\n//\n// It is also the reason the heartbeat goes through `StageOutputLog.say` rather than `process.stdout` —\n// stage ② and stage ③ capture their own console output to a file, and a heartbeat captured into a file is\n// a heartbeat nobody can see. The 600-second watchdog that kills a silent command does not read files.\n\n/** How often the heartbeat reports the log's size. Hardcoded: a knob here would be a knob the PR gate's\n * own build never receives, and the two must stay the same command. */\nexport const HEARTBEAT_MS = 10_000;\n\n/** How many trailing log lines the failure message echoes, so the immediate cause is visible without a\n * second command. Small on purpose — the FULL log is one grep away and the message must not become the\n * transcript it exists to replace. */\nexport const FAILURE_TAIL_LINES = 20;\n\n/**\n * Which stage's gate is being captured. The value decides the log FILENAME.\n */\nexport const REVIEW_STAGE = 'review';\nexport const FINISH_STAGE = 'finish';\n// `wp-build`, which is not a stage of the PR flow but runs the SAME gate (BuildAffected.runBuildGate).\nexport const BUILD_STAGE = 'build';\n// `wp-build-push-dev`'s build of the merge with dev (#1397, #1403): the SAME gate, running\n// `commands.push-dev.buildCommand` instead.\nexport const DEV_BUILD_STAGE = 'build-dev';\n\n/** The fixed log names — see BuildGateLog.fileNameFor for why only the two ad-hoc builds get one. */\nexport const BUILD_LOG_NAME = 'build.log';\nexport const DEV_BUILD_LOG_NAME = 'build-dev.log';\n\n/**\n * The heartbeat's state: the line count reported on the PREVIOUS tick, so a tick that has not moved can\n * say so. Stateful per RUN, which is why it is constructed per run rather than injected.\n *\n * `still` is the load-bearing word. A build that is linking, or waiting on a cold nx cache, produces no\n * output for minutes; without `still` the caller sees the same number twice and cannot tell a stalled\n * BUILD from a stalled REPORTER.\n */\nexport class BuildLogHeartbeat {\n private previous: number | null = null;\n\n constructor(\n private readonly files: GateLogFile,\n private readonly logPath: string,\n private readonly displayPath: string,\n ) {}\n\n /** One heartbeat line — `<path> size <n> lines`, plus ` still` when <n> has not moved. */\n tick(): string {\n const count = this.files.lineCount(this.logPath);\n const still = this.previous !== null && count === this.previous ? ' still' : '';\n this.previous = count;\n return `${this.displayPath} size ${count} lines${still}`;\n }\n}\n\n/**\n * Captures the build gate's full output to a file, reports progress while it runs, and renders the\n * pointer the caller is handed instead of a rebuild instruction.\n *\n * WHERE the file goes, how the previous run is kept, and what the pointer reads like are `GateLogFile`'s\n * — one mechanism, shared with the stage console log, so there is a single answer to \"where is it?\".\n *\n * ─── One directory, two naming schemes, one rule each ──────────────────────────────────────────────────\n * Every build log sits in `<tree>/.webpieces/logs/` (GateLogFile.logsPath — inside the checkout the\n * command ran in, a linked worktree's own root included; issue #1393).\n * • `wp-build` (BUILD_STAGE) writes ONE fixed name, `build.log`. History comes from the rotation.\n * • stage ② and stage ③ write `build-gate-<stage>-<branch>-<shortSha>.log`, because those two gates CAN\n * run against one commit and a failure message from one must not be pointing at a file the other\n * overwrote.\n * Nobody needs to type either name: the absolute path is printed as the FIRST line of the build, before\n * it starts, and again in the closing pointer.\n *\n * ─── Concurrency ───────────────────────────────────────────────────────────────────────────────────────\n * The DIRECTORY is per checkout — a linked worktree writes under its own root — so \"N agents in N\n * worktrees\" is safe by construction rather than by naming. The residual case is two builds in the SAME\n * worktree at once, which is already unsupported: both would be driving one git index.\n */\n@injectable(bindingScopeValues.Singleton)\nexport class BuildGateLog {\n constructor(\n private readonly files: GateLogFile,\n private readonly stageConsole: StageOutputLog,\n private readonly git: GitProcessApi,\n private readonly processes: NativeProcessApi,\n ) {}\n\n /** Absolute path of the log for `stage` at the current HEAD, creating its directory. */\n pathFor(repoRoot: string, stage: string): Promise<string> {\n return this.resolvePath(repoRoot, stage);\n }\n\n /** The same path, and '' when no log has been WRITTEN there yet. Used by finish's skip path. */\n async existingLogFor(repoRoot: string, stage: string): Promise<string> {\n const file = await this.resolvePath(repoRoot, stage);\n return fs.existsSync(file) ? file : '';\n }\n\n /** `build.log` for `wp-build`; `build-dev.log` for the dev build; `build-gate-<stage>-<branch>-<shortSha>.log` for the PR-flow stages. */\n async fileNameFor(repoRoot: string, stage: string): Promise<string> {\n if (stage === BUILD_STAGE) return BUILD_LOG_NAME;\n // Fixed, like build.log: the dev build runs on a THROWAWAY branch whose name and sha say nothing\n // to the reader, and history comes from the same rotation.\n if (stage === DEV_BUILD_STAGE) return DEV_BUILD_LOG_NAME;\n const branch = this.slug(gitCheckout.branch(repoRoot) ?? '');\n const sha = this.slug(await this.gitOut(repoRoot, ['rev-parse', '--short', 'HEAD']));\n return `build-gate-${this.slug(stage)}-${branch === '' ? 'nobranch' : branch}-${sha === '' ? 'nosha' : sha}.log`;\n }\n\n /**\n * Run `buildCommand` with its stdout AND stderr redirected in full to `logPath`, printing a heartbeat\n * every HEARTBEAT_MS so the caller can see it is alive. Returns the BUILD's raw termination facts.\n * Nothing is truncated. Ordinary AI-facing callers do not stream; the explicitly human-attested\n * PR escape hatch may wrap this with runStreaming(), which follows the same durable file live.\n */\n async run(repoRoot: string, buildCommand: string, logPath: string): Promise<BuildTermination> {\n this.files.rotate(logPath);\n const fd = fs.openSync(logPath, 'w');\n const heartbeat = new BuildLogHeartbeat(\n this.files,\n logPath,\n this.files.displayPath(repoRoot, logPath),\n );\n const timer = setInterval((): void => {\n this.stageConsole.say(`${heartbeat.tick()}\\n`);\n }, HEARTBEAT_MS);\n // webpieces-disable no-unmanaged-exceptions -- chokepoint: the timer and the fd MUST be released\n // whatever the child does, and the exit code is returned rather than thrown so runBuildGate owns\n // the one CliExitError.\n // eslint-disable-next-line @webpieces/no-unmanaged-exceptions\n try {\n return this.recordTermination(await this.processes.runShellToFile(buildCommand, repoRoot, fd), fd);\n } finally {\n clearInterval(timer);\n fs.closeSync(fd);\n }\n }\n\n /** Human-only variant: preserve the durable log and follow its appended bytes live. */\n runStreaming(\n repoRoot: string,\n buildCommand: string,\n logPath: string,\n ): Promise<BuildTermination> {\n // run() synchronously rotates and opens the file before reaching its first await, so the follower\n // cannot accidentally replay the previous build that was at this path.\n const completion = this.run(repoRoot, buildCommand, logPath);\n const follower = new BuildLogFollower(logPath, this.stageConsole);\n follower.start();\n return completion.finally((): void => follower.stop());\n }\n\n /** The `FullLog : <path>` line printed before the build starts — see GateLogFile.startLine. */\n startLine(logPath: string): string {\n return this.files.startLine(logPath);\n }\n\n /**\n * The success summary: the caller is told WHERE the full output is, not handed the output.\n */\n successMessage(logPath: string): string {\n return `\\nBuild success\\n${this.files.pointer(logPath)}`;\n }\n\n /**\n * The ENTIRE message the caller gets on a failed build. It names the log, echoes the last\n * FAILURE_TAIL_LINES lines so the immediate cause needs no second command, and forbids the rebuild\n * this whole file exists to prevent.\n *\n * The last sentence is not filler. If the log holds no visible failure then something upstream is wrong\n * (a runner that died without printing, a truncated redirect), and the worst possible response is an\n * agent guessing or rebuilding — so it is told to surface the contradiction to the human and stop.\n */\n failureMessage(buildCommand: string, logPath: string, termination: BuildTermination): string {\n return (\n `\\nBuild Failed: ${buildCommand}\\n${this.files.pointer(logPath)}\\n` +\n `${this.terminationRecord(termination)}\\n` +\n `Last ${FAILURE_TAIL_LINES} lines of that log:\\n${this.files.tail(logPath, FAILURE_TAIL_LINES)}\\n` +\n `Read that FILE for the failures. Do NOT re-run the build to see them.\\n` +\n `If you do not see failures in that log, report that to the user and stop.\\n`\n );\n }\n\n // The child's close code AND signal. A command that never starts (a shell that is missing, a cwd that\n // vanished) fails CLOSED to 1 — calling a build that never ran green is the one outcome that must be\n // impossible — and the reason is APPENDED TO THE LOG, so the failure message's pointer still leads to\n // it rather than to an empty file.\n private recordTermination(ended: ShellTerminationDto, fd: number): BuildTermination {\n if (ended.startError !== null) {\n fs.writeSync(fd, `\\nThe build command could not be started: ${ended.startError}\\n`);\n return new BuildTermination(1, null);\n }\n const termination = new BuildTermination(ended.code, ended.signal);\n if (ended.code === null || ended.signal !== null)\n fs.writeSync(fd, `\\n${this.terminationRecord(termination)}\\n`);\n return termination;\n }\n\n /** One stable, human-readable spelling shared by the FullLog and the immediate failure output. */\n private terminationRecord(termination: BuildTermination): string {\n const code = termination.code === null ? 'null' : String(termination.code);\n const signal = termination.signal === null ? 'none' : termination.signal;\n return `Build process termination: exit code ${code}; signal ${signal}.`;\n }\n\n private async resolvePath(repoRoot: string, stage: string): Promise<string> {\n return this.files.logsPath(repoRoot, await this.fileNameFor(repoRoot, stage));\n }\n\n // Anything that is not a filename-safe character becomes '-', so `dean/feat` cannot create directories.\n private slug(value: string): string {\n return value.replace(/[^A-Za-z0-9._-]+/g, '-').replace(/^-+|-+$/g, '');\n }\n\n // One local git read. Fails SOFT to '' — a missing branch/sha degrades the FILENAME, and degrading a\n // filename may never be the reason a build gate does not run.\n private async gitOut(repoRoot: string, args: string[]): Promise<string> {\n const result = await this.git.run(['-C', repoRoot, ...args]);\n if (!result.ok) return '';\n return result.stdout.trim();\n }\n}\n"]}
|
|
@@ -37,8 +37,8 @@ let DevBuild = class DevBuild {
|
|
|
37
37
|
if (configured !== undefined && configured.trim() !== '')
|
|
38
38
|
return configured;
|
|
39
39
|
throw new rules_config_1.CliExitError(2, '\n' + SEP + '⛔ `commands.push-dev.buildCommand` is not configured\n' + SEP + '\n'
|
|
40
|
-
+ `${rules_config_1.
|
|
41
|
-
+ '
|
|
40
|
+
+ `${rules_config_1.WP_BUILD_PUSH_DEV} builds your copy merged with origin/dev before wp-finish-push-dev publishes it.\n`
|
|
41
|
+
+ 'WHICH build is this repo\'s decision, so there is no default.\n'
|
|
42
42
|
+ 'Nothing was merged, built or published.\n\n'
|
|
43
43
|
+ 'Add this to webpieces.config.json, inside "commands", choosing a command that builds only what\n'
|
|
44
44
|
+ 'differs from origin/dev in this repo:\n\n'
|