@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.
Files changed (52) hide show
  1. package/package.json +8 -8
  2. package/src/scripts/commands/build-push-dev-command.d.ts +61 -0
  3. package/src/scripts/commands/build-push-dev-command.js +159 -0
  4. package/src/scripts/commands/build-push-dev-command.js.map +1 -0
  5. package/src/scripts/commands/finish-push-dev-command.d.ts +73 -17
  6. package/src/scripts/commands/finish-push-dev-command.js +187 -31
  7. package/src/scripts/commands/finish-push-dev-command.js.map +1 -1
  8. package/src/scripts/commands/start-push-dev-command.d.ts +43 -0
  9. package/src/scripts/commands/start-push-dev-command.js +111 -0
  10. package/src/scripts/commands/start-push-dev-command.js.map +1 -0
  11. package/src/scripts/pr-gate-app.d.ts +18 -18
  12. package/src/scripts/pr-gate-app.js +27 -26
  13. package/src/scripts/pr-gate-app.js.map +1 -1
  14. package/src/scripts/pr-gate-cli-app.d.ts +2 -2
  15. package/src/scripts/pr-gate-cli-app.js +20 -29
  16. package/src/scripts/pr-gate-cli-app.js.map +1 -1
  17. package/src/scripts/workflow/build-gate-log.js +2 -2
  18. package/src/scripts/workflow/build-gate-log.js.map +1 -1
  19. package/src/scripts/workflow/dev-build.js +2 -2
  20. package/src/scripts/workflow/dev-build.js.map +1 -1
  21. package/src/scripts/workflow/dev-copy-on-main.d.ts +1 -1
  22. package/src/scripts/workflow/dev-copy-on-main.js +1 -1
  23. package/src/scripts/workflow/dev-copy-on-main.js.map +1 -1
  24. package/src/scripts/workflow/dev-deploy-refs.d.ts +4 -17
  25. package/src/scripts/workflow/dev-deploy-refs.js +5 -21
  26. package/src/scripts/workflow/dev-deploy-refs.js.map +1 -1
  27. package/src/scripts/workflow/dev-resolve-runner.d.ts +43 -73
  28. package/src/scripts/workflow/dev-resolve-runner.js +117 -181
  29. package/src/scripts/workflow/dev-resolve-runner.js.map +1 -1
  30. package/src/scripts/workflow/main-freshness.d.ts +16 -0
  31. package/src/scripts/workflow/main-freshness.js +33 -0
  32. package/src/scripts/workflow/main-freshness.js.map +1 -0
  33. package/src/scripts/workflow/push-dev-state.d.ts +12 -35
  34. package/src/scripts/workflow/push-dev-state.js +31 -62
  35. package/src/scripts/workflow/push-dev-state.js.map +1 -1
  36. package/src/scripts/workflow/verified-dev-copy.d.ts +46 -0
  37. package/src/scripts/workflow/verified-dev-copy.js +89 -0
  38. package/src/scripts/workflow/verified-dev-copy.js.map +1 -0
  39. package/src/scripts/{wp-build-dev.js → wp-build-push-dev.js} +2 -2
  40. package/src/scripts/wp-build-push-dev.js.map +1 -0
  41. package/src/scripts/{wp-push-dev.js → wp-start-push-dev.js} +2 -2
  42. package/src/scripts/wp-start-push-dev.js.map +1 -0
  43. package/src/scripts/commands/build-dev-command.d.ts +0 -27
  44. package/src/scripts/commands/build-dev-command.js +0 -99
  45. package/src/scripts/commands/build-dev-command.js.map +0 -1
  46. package/src/scripts/commands/push-dev-command.d.ts +0 -140
  47. package/src/scripts/commands/push-dev-command.js +0 -356
  48. package/src/scripts/commands/push-dev-command.js.map +0 -1
  49. package/src/scripts/wp-build-dev.js.map +0 -1
  50. package/src/scripts/wp-push-dev.js.map +0 -1
  51. /package/src/scripts/{wp-build-dev.d.ts → wp-build-push-dev.d.ts} +0 -0
  52. /package/src/scripts/{wp-push-dev.d.ts → wp-start-push-dev.d.ts} +0 -0
@@ -4,58 +4,214 @@ exports.FinishPushDevCommand = exports.FinishPushDevOptions = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const rules_config_1 = require("@webpieces/rules-config");
6
6
  const inversify_1 = require("inversify");
7
- const push_dev_state_1 = require("../workflow/push-dev-state");
8
- const dev_resolve_runner_1 = require("../workflow/dev-resolve-runner");
9
- /** What `wp-finish-push-dev` was asked to do. Data-only (per CLAUDE.md). */
7
+ const git_exec_1 = require("../workflow/git-exec");
8
+ const dev_deploy_refs_1 = require("../workflow/dev-deploy-refs");
9
+ const dev_deploy_watch_hints_1 = require("../workflow/dev-deploy-watch-hints");
10
+ const dev_copy_on_main_1 = require("../workflow/dev-copy-on-main");
11
+ const verified_dev_copy_1 = require("../workflow/verified-dev-copy");
12
+ const SEP = '━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n';
13
+ /**
14
+ * Which of `wp-finish-push-dev`'s modes was asked for. Data-only (per CLAUDE.md) with plain assigned
15
+ * fields — the bin sets what argv carried and nothing else.
16
+ */
10
17
  class FinishPushDevOptions {
11
- /** Throw the whole resolve away and restore the original checkout. */
12
- abort = false;
13
- constructor(abort = false) {
14
- this.abort = abort;
15
- }
18
+ /** Delete the remote copy and push the rebuild marker — the rollback. */
19
+ remove = false;
20
+ /** List the live copies and stop. */
21
+ list = false;
16
22
  }
17
23
  exports.FinishPushDevOptions = FinishPushDevOptions;
18
24
  /**
19
- * `wp-finish-push-dev` — stage ② of the dev-deploy flow, needed ONLY when a merge stopped.
25
+ * `wp-finish-push-dev` — stage ③ of the dev-deploy flow (#1403): publish the copy `wp-build-push-dev`
26
+ * verified as `<namespace>/<branch>`, so a shared dev environment can build it, without landing anything
27
+ * on `main` and without opening a PR. Also `--list` (the pool) and `--remove` (the rollback).
20
28
  *
21
- * It mirrors `wp-start-update` → `wp-finish-update` on purpose: the repo already has a two-phase
22
- * start/finish idiom for exactly this shape ("the tool merges, you resolve, the tool commits"), and a
23
- * `--continue` idiom invented here would be a second vocabulary for one concept. A clean `wp-push-dev
24
- * --resolve` finalizes itself and this command is never needed.
29
+ * WHY THIS COMMAND HAS TO EXIST AT ALL: `pr-creation-or-push-guard` blocks every `git push`, no
30
+ * exceptions, by design. Without a gated command there is no legal way for an AI to get a branch onto a
31
+ * dev server.
25
32
  *
26
- * The command owns the commit because the AI cannot make it: `redirect-how-to-merge-main` blocks
27
- * `git merge --continue` and `merge-in-progress-guard` blocks `git commit`. Editing the conflicted files
28
- * and `git add`-ing them is the AI's whole job, and neither is blocked.
33
+ * IT PUBLISHES ONLY WHAT WAS VERIFIED: stage ② records the feature head it built and the copy it made; this
34
+ * refuses when HEAD has moved since (a new commit nobody built), exactly as `wp-finish-upsert-pr` trusts
35
+ * only the sha stage ② of the PR flow verified.
36
+ *
37
+ * IT FORCE-PUSHES, leased against the copy sha stage ② saw. Stage ① rewrites the branch on almost every
38
+ * publish, so the new copy is rarely a fast-forward of the old one, and the push event's `before` is then
39
+ * the previous copy — which is what a consumer's dev CI needs to apply only the difference (#1403).
29
40
  */
30
41
  let FinishPushDevCommand = class FinishPushDevCommand {
31
42
  repoRootFinder;
32
- store;
33
- runner;
34
- constructor(repoRootFinder, store, runner) {
43
+ gitExec;
44
+ refs;
45
+ verified;
46
+ watchHints;
47
+ copyOnMain;
48
+ constructor(repoRootFinder, gitExec, refs, verified, watchHints, copyOnMain) {
35
49
  this.repoRootFinder = repoRootFinder;
36
- this.store = store;
37
- this.runner = runner;
50
+ this.gitExec = gitExec;
51
+ this.refs = refs;
52
+ this.verified = verified;
53
+ this.watchHints = watchHints;
54
+ this.copyOnMain = copyOnMain;
38
55
  }
39
56
  async run(opts) {
40
57
  const repoRoot = this.repoRootFinder.resolveRepoRoot(process.cwd());
58
+ // Refresh the AI-facing workflow doc so it is present + current for any failure message to cite.
41
59
  (0, rules_config_1.writeTemplate)(repoRoot, 'webpieces.git-workflow.md');
42
- // Refuses with the one-command publish form when nothing is in flight, so a mistaken call here
43
- // does not read as "the flow is broken".
44
- const state = this.store.require(repoRoot);
45
- if (opts.abort) {
46
- await this.runner.abort(repoRoot, state);
60
+ const cfg = this.refs.config(repoRoot);
61
+ if (opts.list) {
62
+ await this.list(repoRoot, cfg);
63
+ return;
64
+ }
65
+ const branch = this.refs.currentBranch(repoRoot);
66
+ this.refs.assertPushable(cfg, branch);
67
+ const targetRef = cfg.copyRefFor(branch);
68
+ if (opts.remove) {
69
+ await this.remove(repoRoot, cfg, branch, targetRef);
47
70
  return;
48
71
  }
49
- // Refuses (and re-prints the unresolved files) before committing anything, then resumes the
50
- // queue — a LATER ref can conflict too, so this may legitimately stop again.
51
- await this.runner.resume(repoRoot, state);
72
+ await this.publish(repoRoot, cfg, branch);
73
+ }
74
+ /** The publish: the verified copy, force-pushed with a lease, then the watch hints. */
75
+ async publish(repoRoot, cfg, branch) {
76
+ const record = this.verified.read(repoRoot);
77
+ if (record === null || record.branch !== branch)
78
+ this.refuseUnverified(branch);
79
+ const head = await this.refs.headSha(repoRoot, 'HEAD');
80
+ if (head !== record.headSha)
81
+ this.refuseMoved(branch, record, head);
82
+ const lease = record.leaseSha === '' ? [] : [`--force-with-lease=refs/heads/${record.targetRef}:${record.leaseSha}`];
83
+ await this.gitExec.runGitChecked(['-C', repoRoot, 'push', ...lease, 'origin', `${record.copySha}:refs/heads/${record.targetRef}`], `Failed to publish the dev copy ${record.targetRef}`);
84
+ await this.gitExec.tryGit(['-C', repoRoot, 'update-ref', '-d', this.verified.keepRef(branch)], repoRoot);
85
+ this.verified.clear(repoRoot);
86
+ process.stdout.write('\n' + SEP + `✅ Published ${record.targetRef}\n` + SEP + '\n'
87
+ + (record.copySha === record.headSha
88
+ ? 'The copy is your branch exactly as it is.\n'
89
+ : 'The copy is your branch plus ONE commit recording the files resolved against dev.\n')
90
+ + `Your CI picks it up on its next \`${cfg.devBranch}\` run.\n`
91
+ + ` ${rules_config_1.WP_FINISH_PUSH_DEV} --list ← what else is in the pool\n`
92
+ + ` ${rules_config_1.WP_FINISH_PUSH_DEV} --remove ← take this branch back out\n`
93
+ + this.watchHints.render(cfg, record.targetRef, record.copySha));
94
+ }
95
+ refuseUnverified(branch) {
96
+ throw new rules_config_1.CliExitError(2, '\n' + SEP + `⛔ \`${branch}\` has not been verified against dev — nothing was published\n` + SEP + '\n'
97
+ + 'This command publishes only the copy `wp-build-push-dev` checked against dev and built. Run the\n'
98
+ + 'stages before it:\n'
99
+ + ` ${rules_config_1.WP_START_PUSH_DEV} ← bring the branch up to date with main (only if it is behind)\n`
100
+ + ` ${rules_config_1.WP_BUILD_PUSH_DEV} ← merge dev into a throwaway, pnpm install, run the dev build\n`
101
+ + ` ${rules_config_1.WP_FINISH_PUSH_DEV} ← then this\n`);
102
+ }
103
+ refuseMoved(branch, record, head) {
104
+ throw new rules_config_1.CliExitError(2, '\n' + SEP + `⛔ \`${branch}\` moved after it was verified — nothing was published\n` + SEP + '\n'
105
+ + `wp-build-push-dev verified ${record.headSha.slice(0, 8)}, but HEAD is now ${head.slice(0, 8)}. The new commit was\n`
106
+ + 'never checked against dev or built, so it is not published. Verify it, then publish:\n'
107
+ + ` ${rules_config_1.WP_BUILD_PUSH_DEV}\n ${rules_config_1.WP_FINISH_PUSH_DEV}\n`);
108
+ }
109
+ /** `--list`: exactly the live copies, straight from the remote — never a cached local view. */
110
+ async list(repoRoot, cfg) {
111
+ const copies = await this.refs.liveCopies(repoRoot, cfg);
112
+ if (copies.length === 0) {
113
+ process.stdout.write(`\nNo dev copies published — nothing matches \`${cfg.copyRefGlob()}\` on origin.\n`
114
+ + `Publish this branch's with: ${rules_config_1.WP_START_PUSH_DEV} → ${rules_config_1.WP_BUILD_PUSH_DEV} → ${rules_config_1.WP_FINISH_PUSH_DEV}\n`);
115
+ return;
116
+ }
117
+ let out = '\n' + SEP + `📋 ${String(copies.length)} dev cop${copies.length === 1 ? 'y' : 'ies'} on origin\n` + SEP + '\n';
118
+ for (const copy of copies)
119
+ out += ` ${copy.sha.slice(0, 8)} ${copy.ref}\n`;
120
+ out += `\nYour CI composes \`${cfg.devBranch}\` from origin/main plus every ref above.\n`
121
+ + `Remove yours with: ${rules_config_1.WP_FINISH_PUSH_DEV} --remove (deletes your copy, then pushes the content-free\n`
122
+ + `\`${cfg.removeMarkerRefFor('<your-branch>')}\` marker your dev workflow triggers on and deletes)\n`;
123
+ process.stdout.write(out);
124
+ }
125
+ /**
126
+ * `--remove`: delete the remote copy, then push the `<removeNamespace>/<branch>` marker (#1395). This
127
+ * IS the rollback — nothing else has to be undone.
128
+ *
129
+ * WHY A MARKER AS WELL AS THE DELETION: a deletion can only be heard by a workflow's `on: delete:`,
130
+ * which GitHub cannot filter by branch, so every branch deletion in the repo started a dev-deploy run.
131
+ * A PUSH to `<removeNamespace>/**` is filterable. The deletion stays, unchanged, so a consumer whose
132
+ * workflow still listens on `delete:` keeps working through the rollout window; the marker is purely
133
+ * additive at the transport level.
134
+ *
135
+ * ALREADY ON MAIN (#1401): before anything is deleted, the copy is compared with `origin/main`. When
136
+ * every file it changes already has the copy's content on main, removing it takes nothing off dev —
137
+ * main keeps the change there — and would only force a pointless full recompose, so it is REFUSED
138
+ * ({@link refuseLanded}). When only some files are, the rest is still a real rollback: it warns, naming
139
+ * the landed files, and removes.
140
+ *
141
+ * ORDER: `origin/main` and the copy are fetched BEFORE anything is deleted, so a network failure there
142
+ * leaves the pool exactly as it was. The marker push is the last step, and the only one that can fail with the
143
+ * copy already gone — that is the state {@link markerPushFailed} names.
144
+ */
145
+ async remove(repoRoot, cfg, branch, targetRef) {
146
+ if (await this.refs.remoteSha(repoRoot, targetRef) === '') {
147
+ process.stdout.write(`\nNothing to remove — \`${targetRef}\` is not published.\n`
148
+ + `List what IS published with: ${rules_config_1.WP_FINISH_PUSH_DEV} --list\n`);
149
+ return;
150
+ }
151
+ const markerRef = cfg.removeMarkerRefFor(branch);
152
+ const mainTip = await this.refs.freshMainTip(repoRoot);
153
+ await this.refs.fetchCopies(repoRoot, [targetRef]);
154
+ const landing = await this.copyOnMain.landing(repoRoot, targetRef);
155
+ if (landing.fullyOnMain()) {
156
+ this.refuseLanded(targetRef, await this.copyOnMain.mergedPr(repoRoot, branch));
157
+ }
158
+ if (landing.partlyOnMain())
159
+ process.stdout.write(this.partlyLandedWarning(targetRef, landing));
160
+ await this.gitExec.runGitChecked(['-C', repoRoot, 'push', 'origin', '--delete', `refs/heads/${targetRef}`], `Failed to delete the dev copy ${targetRef}`);
161
+ // --force: the marker carries no content, so whatever an earlier, never-deleted marker pointed at
162
+ // is worthless — and refusing a non-fast-forward here would strand the rollback half-done.
163
+ const pushed = await this.gitExec.tryGit(['-C', repoRoot, 'push', '--force', 'origin', `${mainTip}:refs/heads/${markerRef}`], repoRoot);
164
+ if (!pushed.ok)
165
+ this.markerPushFailed(cfg, branch, targetRef, markerRef, pushed.stderr);
166
+ process.stdout.write('\n' + SEP + `🗑️ Removed ${targetRef}\n` + SEP + '\n'
167
+ + `Pushed the marker \`${markerRef}\` (at origin/main ${mainTip.slice(0, 8)}) — your dev workflow triggers\n`
168
+ + `on it, deletes it, and takes \`${branch}\` back out of \`${cfg.devBranch}\`. Your branch and any PR on it\n`
169
+ + 'are untouched.\n');
170
+ }
171
+ /**
172
+ * `--remove` of a copy whose every change is already on `origin/main`. Nothing was deleted and no marker
173
+ * was pushed. There is deliberately no override: a remove cannot take back what main already holds, so
174
+ * refusing never blocks a real rollback — that is a revert PR.
175
+ */
176
+ refuseLanded(targetRef, pr) {
177
+ const landedVia = pr === null ? '' : ` (PR #${pr.num} landed ${pr.mergedAt})`;
178
+ throw new rules_config_1.CliExitError(2, '\n' + SEP + `⛔ \`${targetRef}\` is already on origin/main — nothing was removed\n` + SEP + '\n'
179
+ + `\`${targetRef}\` is already on origin/main${landedVia}, so removing the copy\n`
180
+ + 'would not take anything off dev — main keeps it there. The nightly reset deletes the copy.\n'
181
+ + 'Nothing was removed, and no rebuild marker was pushed.\n\n'
182
+ + 'If that code is what broke dev, it is on main now: the fix is a revert PR against main, not a remove.\n');
183
+ }
184
+ /** Some of the copy's files are already on main: the remove proceeds, and says what it does NOT take off. */
185
+ partlyLandedWarning(targetRef, landing) {
186
+ return '\n' + SEP + `⚠️ Part of \`${targetRef}\` is already on origin/main\n` + SEP + '\n'
187
+ + `${String(landing.landed.length)} of the ${String(landing.changed.length)} files this copy changes already have the copy's content on\n`
188
+ + 'origin/main. Removing the copy does NOT take these off dev — main keeps them there:\n'
189
+ + landing.landed.map((f) => ` ${f}`).join('\n') + '\n'
190
+ + 'Only the rest of the copy is being removed. If one of the files above broke dev, the fix is a revert PR.\n';
191
+ }
192
+ /**
193
+ * The one half-done state `--remove` can leave: the copy is deleted, the rebuild signal is not sent.
194
+ * Said out loud because it is invisible otherwise — `--list` already looks right, while the deployed
195
+ * `dev` still runs the removed branch until something else triggers a composition.
196
+ */
197
+ markerPushFailed(cfg, branch, targetRef, markerRef, stderr) {
198
+ throw new rules_config_1.CliExitError(1, '\n' + SEP + `⛔ Removed \`${targetRef}\`, but pushing the rebuild marker \`${markerRef}\` FAILED\n` + SEP + '\n'
199
+ + `Your copy is already GONE from origin, but \`${cfg.devBranch}\` was NOT rebuilt: the deployed dev server\n`
200
+ + `still runs \`${branch}\` until the next composition run.\n\n`
201
+ + 'git said:\n' + (stderr === '' ? ' (no output)' : stderr.split('\n').map((l) => ` ${l}`).join('\n')) + '\n\n'
202
+ + 'Once the cause above is fixed (network, auth, a branch-protection rule on the marker namespace),\n'
203
+ + 're-publish and remove again; the second remove pushes the marker:\n\n'
204
+ + ` ${rules_config_1.WP_START_PUSH_DEV}\n ${rules_config_1.WP_BUILD_PUSH_DEV}\n ${rules_config_1.WP_FINISH_PUSH_DEV}\n ${rules_config_1.WP_FINISH_PUSH_DEV} --remove\n`);
52
205
  }
53
206
  };
54
207
  exports.FinishPushDevCommand = FinishPushDevCommand;
55
208
  exports.FinishPushDevCommand = FinishPushDevCommand = tslib_1.__decorate([
56
209
  (0, inversify_1.injectable)(inversify_1.bindingScopeValues.Singleton),
57
210
  tslib_1.__metadata("design:paramtypes", [rules_config_1.RepoRootFinder,
58
- push_dev_state_1.PushDevStateStore,
59
- dev_resolve_runner_1.DevResolveRunner])
211
+ git_exec_1.GitExec,
212
+ dev_deploy_refs_1.DevDeployRefs,
213
+ verified_dev_copy_1.VerifiedDevCopyStore,
214
+ dev_deploy_watch_hints_1.DevDeployWatchHints,
215
+ dev_copy_on_main_1.DevCopyOnMain])
60
216
  ], FinishPushDevCommand);
61
217
  //# sourceMappingURL=finish-push-dev-command.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"finish-push-dev-command.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AAC;6CAGA,6BAAc;QACvB,kCAAiB;QAChB,qCAAgB;GAJpC,oBAAoB,CAsBhC","sourcesContent":["import { RepoRootFinder, writeTemplate } from '@webpieces/rules-config';\nimport { injectable, bindingScopeValues } from 'inversify';\n\nimport { PushDevStateStore } from '../workflow/push-dev-state';\nimport { DevResolveRunner } from '../workflow/dev-resolve-runner';\n\n/** What `wp-finish-push-dev` was asked to do. Data-only (per CLAUDE.md). */\nexport class FinishPushDevOptions {\n /** Throw the whole resolve away and restore the original checkout. */\n abort = false;\n\n constructor(abort = false) {\n this.abort = abort;\n }\n}\n\n/**\n * `wp-finish-push-dev` — stage ② of the dev-deploy flow, needed ONLY when a merge stopped.\n *\n * It mirrors `wp-start-update` → `wp-finish-update` on purpose: the repo already has a two-phase\n * start/finish idiom for exactly this shape (\"the tool merges, you resolve, the tool commits\"), and a\n * `--continue` idiom invented here would be a second vocabulary for one concept. A clean `wp-push-dev\n * --resolve` finalizes itself and this command is never needed.\n *\n * The command owns the commit because the AI cannot make it: `redirect-how-to-merge-main` blocks\n * `git merge --continue` and `merge-in-progress-guard` blocks `git commit`. Editing the conflicted files\n * and `git add`-ing them is the AI's whole job, and neither is blocked.\n */\n@injectable(bindingScopeValues.Singleton)\nexport class FinishPushDevCommand {\n constructor(\n private readonly repoRootFinder: RepoRootFinder,\n private readonly store: PushDevStateStore,\n private readonly runner: DevResolveRunner,\n ) {}\n\n async run(opts: FinishPushDevOptions): Promise<void> {\n const repoRoot = this.repoRootFinder.resolveRepoRoot(process.cwd());\n writeTemplate(repoRoot, 'webpieces.git-workflow.md');\n // Refuses with the one-command publish form when nothing is in flight, so a mistaken call here\n // does not read as \"the flow is broken\".\n const state = this.store.require(repoRoot);\n\n if (opts.abort) {\n await this.runner.abort(repoRoot, state);\n return;\n }\n // Refuses (and re-prints the unresolved files) before committing anything, then resumes the\n // queue — a LATER ref can conflict too, so this may legitimately stop again.\n await this.runner.resume(repoRoot, state);\n }\n}\n"]}
1
+ {"version":3,"file":"finish-push-dev-command.js","sourceRoot":"","sources":["../../../../../../../packages/tooling/pr-gate/src/scripts/commands/finish-push-dev-command.ts"],"names":[],"mappings":";;;;AAAA,0DAQiC;AACjC,yCAA2D;AAE3D,mDAA+C;AAC/C,iEAA4D;AAC5D,+EAAyE;AACzE,mEAAuF;AACvF,qEAAsF;AAEtF,MAAM,GAAG,GAAG,0DAA0D,CAAC;AAEvE;;;GAGG;AACH,MAAa,oBAAoB;IAC7B,yEAAyE;IACzE,MAAM,GAAG,KAAK,CAAC;IACf,qCAAqC;IACrC,IAAI,GAAG,KAAK,CAAC;CAChB;AALD,oDAKC;AAED;;;;;;;;;;;;;;;;GAgBG;AAEI,IAAM,oBAAoB,GAA1B,MAAM,oBAAoB;IAER;IACA;IACA;IACA;IACA;IACA;IANrB,YACqB,cAA8B,EAC9B,OAAgB,EAChB,IAAmB,EACnB,QAA8B,EAC9B,UAA+B,EAC/B,UAAyB;QALzB,mBAAc,GAAd,cAAc,CAAgB;QAC9B,YAAO,GAAP,OAAO,CAAS;QAChB,SAAI,GAAJ,IAAI,CAAe;QACnB,aAAQ,GAAR,QAAQ,CAAsB;QAC9B,eAAU,GAAV,UAAU,CAAqB;QAC/B,eAAU,GAAV,UAAU,CAAe;IAC3C,CAAC;IAEJ,KAAK,CAAC,GAAG,CAAC,IAA0B;QAChC,MAAM,QAAQ,GAAG,IAAI,CAAC,cAAc,CAAC,eAAe,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC;QACpE,iGAAiG;QACjG,IAAA,4BAAa,EAAC,QAAQ,EAAE,2BAA2B,CAAC,CAAC;QACrD,MAAM,GAAG,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;QAEvC,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC;YACZ,MAAM,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC;YAC/B,OAAO;QACX,CAAC;QACD,MAAM,MAAM,GAAG,IAAI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,\n} from '@webpieces/rules-config';\nimport { injectable, bindingScopeValues } from 'inversify';\n\nimport { GitExec } from '../workflow/git-exec';\nimport { DevDeployRefs } from '../workflow/dev-deploy-refs';\nimport { DevDeployWatchHints } from '../workflow/dev-deploy-watch-hints';\nimport { DevCopyLanding, DevCopyOnMain, MergedPr } from '../workflow/dev-copy-on-main';\nimport { VerifiedDevCopy, VerifiedDevCopyStore } from '../workflow/verified-dev-copy';\n\nconst SEP = '━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\\n';\n\n/**\n * Which of `wp-finish-push-dev`'s modes was asked for. Data-only (per CLAUDE.md) with plain assigned\n * fields — the bin sets what argv carried and nothing else.\n */\nexport class FinishPushDevOptions {\n /** Delete the remote copy and push the rebuild marker — the rollback. */\n remove = false;\n /** List the live copies and stop. */\n list = false;\n}\n\n/**\n * `wp-finish-push-dev` — stage ③ of the dev-deploy flow (#1403): publish the copy `wp-build-push-dev`\n * verified as `<namespace>/<branch>`, so a shared dev environment can build it, without landing anything\n * on `main` and without opening a PR. Also `--list` (the pool) and `--remove` (the rollback).\n *\n * WHY THIS COMMAND HAS TO EXIST AT ALL: `pr-creation-or-push-guard` blocks every `git push`, no\n * exceptions, by design. Without a gated command there is no legal way for an AI to get a branch onto a\n * dev server.\n *\n * IT PUBLISHES ONLY WHAT WAS VERIFIED: stage ② records the feature head it built and the copy it made; this\n * refuses when HEAD has moved since (a new commit nobody built), exactly as `wp-finish-upsert-pr` trusts\n * only the sha stage ② of the PR flow verified.\n *\n * IT FORCE-PUSHES, leased against the copy sha stage ② saw. Stage ① rewrites the branch on almost every\n * publish, so the new copy is rarely a fast-forward of the old one, and the push event's `before` is then\n * the previous copy — which is what a consumer's dev CI needs to apply only the difference (#1403).\n */\n@injectable(bindingScopeValues.Singleton)\nexport class FinishPushDevCommand {\n constructor(\n private readonly repoRootFinder: RepoRootFinder,\n private readonly gitExec: GitExec,\n private readonly refs: DevDeployRefs,\n private readonly verified: VerifiedDevCopyStore,\n private readonly watchHints: DevDeployWatchHints,\n private readonly copyOnMain: DevCopyOnMain,\n ) {}\n\n async run(opts: FinishPushDevOptions): Promise<void> {\n const repoRoot = this.repoRootFinder.resolveRepoRoot(process.cwd());\n // Refresh the AI-facing workflow doc so it is present + current for any failure message to cite.\n writeTemplate(repoRoot, 'webpieces.git-workflow.md');\n const cfg = this.refs.config(repoRoot);\n\n if (opts.list) {\n await this.list(repoRoot, cfg);\n return;\n }\n const branch = this.refs.currentBranch(repoRoot);\n this.refs.assertPushable(cfg, branch);\n const targetRef = cfg.copyRefFor(branch);\n if (opts.remove) {\n await this.remove(repoRoot, cfg, branch, targetRef);\n return;\n }\n await this.publish(repoRoot, cfg, branch);\n }\n\n /** The publish: the verified copy, force-pushed with a lease, then the watch hints. */\n private async publish(repoRoot: string, cfg: DevDeployConfig, branch: string): Promise<void> {\n const record = this.verified.read(repoRoot);\n if (record === null || record.branch !== branch) this.refuseUnverified(branch);\n const head = await this.refs.headSha(repoRoot, 'HEAD');\n if (head !== record.headSha) this.refuseMoved(branch, record, head);\n const lease = record.leaseSha === '' ? [] : [`--force-with-lease=refs/heads/${record.targetRef}:${record.leaseSha}`];\n await this.gitExec.runGitChecked(\n ['-C', repoRoot, 'push', ...lease, 'origin', `${record.copySha}:refs/heads/${record.targetRef}`],\n `Failed to publish the dev copy ${record.targetRef}`);\n await this.gitExec.tryGit(['-C', repoRoot, 'update-ref', '-d', this.verified.keepRef(branch)], repoRoot);\n this.verified.clear(repoRoot);\n process.stdout.write(\n '\\n' + SEP + `✅ Published ${record.targetRef}\\n` + SEP + '\\n'\n + (record.copySha === record.headSha\n ? 'The copy is your branch exactly as it is.\\n'\n : 'The copy is your branch plus ONE commit recording the files resolved against dev.\\n')\n + `Your CI picks it up on its next \\`${cfg.devBranch}\\` run.\\n`\n + ` ${WP_FINISH_PUSH_DEV} --list ← what else is in the pool\\n`\n + ` ${WP_FINISH_PUSH_DEV} --remove ← take this branch back out\\n`\n + this.watchHints.render(cfg, record.targetRef, record.copySha));\n }\n\n private refuseUnverified(branch: string): never {\n throw new CliExitError(2,\n '\\n' + SEP + `⛔ \\`${branch}\\` has not been verified against dev — nothing was published\\n` + SEP + '\\n'\n + 'This command publishes only the copy `wp-build-push-dev` checked against dev and built. Run the\\n'\n + 'stages before it:\\n'\n + ` ${WP_START_PUSH_DEV} ← bring the branch up to date with main (only if it is behind)\\n`\n + ` ${WP_BUILD_PUSH_DEV} ← merge dev into a throwaway, pnpm install, run the dev build\\n`\n + ` ${WP_FINISH_PUSH_DEV} ← then this\\n`);\n }\n\n private refuseMoved(branch: string, record: VerifiedDevCopy, head: string): never {\n throw new CliExitError(2,\n '\\n' + SEP + `⛔ \\`${branch}\\` moved after it was verified — nothing was published\\n` + SEP + '\\n'\n + `wp-build-push-dev verified ${record.headSha.slice(0, 8)}, but HEAD is now ${head.slice(0, 8)}. The new commit was\\n`\n + 'never checked against dev or built, so it is not published. Verify it, then publish:\\n'\n + ` ${WP_BUILD_PUSH_DEV}\\n ${WP_FINISH_PUSH_DEV}\\n`);\n }\n\n /** `--list`: exactly the live copies, straight from the remote — never a cached local view. */\n private async list(repoRoot: string, cfg: DevDeployConfig): Promise<void> {\n const copies = await this.refs.liveCopies(repoRoot, cfg);\n if (copies.length === 0) {\n process.stdout.write(\n `\\nNo dev copies published — nothing matches \\`${cfg.copyRefGlob()}\\` on origin.\\n`\n + `Publish this branch's with: ${WP_START_PUSH_DEV} → ${WP_BUILD_PUSH_DEV} → ${WP_FINISH_PUSH_DEV}\\n`);\n return;\n }\n let out = '\\n' + SEP + `📋 ${String(copies.length)} dev cop${copies.length === 1 ? 'y' : 'ies'} on origin\\n` + SEP + '\\n';\n for (const copy of copies) out += ` ${copy.sha.slice(0, 8)} ${copy.ref}\\n`;\n out += `\\nYour CI composes \\`${cfg.devBranch}\\` from origin/main plus every ref above.\\n`\n + `Remove yours with: ${WP_FINISH_PUSH_DEV} --remove (deletes your copy, then pushes the content-free\\n`\n + `\\`${cfg.removeMarkerRefFor('<your-branch>')}\\` marker your dev workflow triggers on and deletes)\\n`;\n process.stdout.write(out);\n }\n\n /**\n * `--remove`: delete the remote copy, then push the `<removeNamespace>/<branch>` marker (#1395). This\n * IS the rollback — nothing else has to be undone.\n *\n * WHY A MARKER AS WELL AS THE DELETION: a deletion can only be heard by a workflow's `on: delete:`,\n * which GitHub cannot filter by branch, so every branch deletion in the repo started a dev-deploy run.\n * A PUSH to `<removeNamespace>/**` is filterable. The deletion stays, unchanged, so a consumer whose\n * workflow still listens on `delete:` keeps working through the rollout window; the marker is purely\n * additive at the transport level.\n *\n * ALREADY ON MAIN (#1401): before anything is deleted, the copy is compared with `origin/main`. When\n * every file it changes already has the copy's content on main, removing it takes nothing off dev —\n * main keeps the change there — and would only force a pointless full recompose, so it is REFUSED\n * ({@link refuseLanded}). When only some files are, the rest is still a real rollback: it warns, naming\n * the landed files, and removes.\n *\n * ORDER: `origin/main` and the copy are fetched BEFORE anything is deleted, so a network failure there\n * leaves the pool exactly as it was. The marker push is the last step, and the only one that can fail with the\n * copy already gone — that is the state {@link markerPushFailed} names.\n */\n private async remove(repoRoot: string, cfg: DevDeployConfig, branch: string, targetRef: string): Promise<void> {\n if (await this.refs.remoteSha(repoRoot, targetRef) === '') {\n process.stdout.write(\n `\\nNothing to remove — \\`${targetRef}\\` is not published.\\n`\n + `List what IS published with: ${WP_FINISH_PUSH_DEV} --list\\n`);\n return;\n }\n const markerRef = cfg.removeMarkerRefFor(branch);\n const mainTip = await this.refs.freshMainTip(repoRoot);\n await this.refs.fetchCopies(repoRoot, [targetRef]);\n const landing = await this.copyOnMain.landing(repoRoot, targetRef);\n if (landing.fullyOnMain()) {\n this.refuseLanded(targetRef, await this.copyOnMain.mergedPr(repoRoot, branch));\n }\n if (landing.partlyOnMain()) process.stdout.write(this.partlyLandedWarning(targetRef, landing));\n await this.gitExec.runGitChecked(['-C', repoRoot, 'push', 'origin', '--delete', `refs/heads/${targetRef}`],\n `Failed to delete the dev copy ${targetRef}`);\n // --force: the marker carries no content, so whatever an earlier, never-deleted marker pointed at\n // is worthless — and refusing a non-fast-forward here would strand the rollback half-done.\n const pushed = await this.gitExec.tryGit(\n ['-C', repoRoot, 'push', '--force', 'origin', `${mainTip}:refs/heads/${markerRef}`], repoRoot);\n if (!pushed.ok) this.markerPushFailed(cfg, branch, targetRef, markerRef, pushed.stderr);\n process.stdout.write(\n '\\n' + SEP + `🗑️ Removed ${targetRef}\\n` + SEP + '\\n'\n + `Pushed the marker \\`${markerRef}\\` (at origin/main ${mainTip.slice(0, 8)}) — your dev workflow triggers\\n`\n + `on it, deletes it, and takes \\`${branch}\\` back out of \\`${cfg.devBranch}\\`. Your branch and any PR on it\\n`\n + 'are untouched.\\n');\n }\n\n /**\n * `--remove` of a copy whose every change is already on `origin/main`. Nothing was deleted and no marker\n * was pushed. There is deliberately no override: a remove cannot take back what main already holds, so\n * refusing never blocks a real rollback — that is a revert PR.\n */\n private refuseLanded(targetRef: string, pr: MergedPr | null): never {\n const landedVia = pr === null ? '' : ` (PR #${pr.num} landed ${pr.mergedAt})`;\n throw new CliExitError(2,\n '\\n' + SEP + `⛔ \\`${targetRef}\\` is already on origin/main — nothing was removed\\n` + SEP + '\\n'\n + `\\`${targetRef}\\` is already on origin/main${landedVia}, so removing the copy\\n`\n + 'would not take anything off dev — main keeps it there. The nightly reset deletes the copy.\\n'\n + 'Nothing was removed, and no rebuild marker was pushed.\\n\\n'\n + 'If that code is what broke dev, it is on main now: the fix is a revert PR against main, not a remove.\\n');\n }\n\n /** Some of the copy's files are already on main: the remove proceeds, and says what it does NOT take off. */\n private partlyLandedWarning(targetRef: string, landing: DevCopyLanding): string {\n return '\\n' + SEP + `⚠️ Part of \\`${targetRef}\\` is already on origin/main\\n` + SEP + '\\n'\n + `${String(landing.landed.length)} of the ${String(landing.changed.length)} files this copy changes already have the copy's content on\\n`\n + 'origin/main. Removing the copy does NOT take these off dev — main keeps them there:\\n'\n + landing.landed.map((f: string): string => ` ${f}`).join('\\n') + '\\n'\n + 'Only the rest of the copy is being removed. If one of the files above broke dev, the fix is a revert PR.\\n';\n }\n\n /**\n * The one half-done state `--remove` can leave: the copy is deleted, the rebuild signal is not sent.\n * Said out loud because it is invisible otherwise — `--list` already looks right, while the deployed\n * `dev` still runs the removed branch until something else triggers a composition.\n */\n private markerPushFailed(cfg: DevDeployConfig, branch: string, targetRef: string, markerRef: string, stderr: string): never {\n throw new CliExitError(1,\n '\\n' + SEP + `⛔ Removed \\`${targetRef}\\`, but pushing the rebuild marker \\`${markerRef}\\` FAILED\\n` + SEP + '\\n'\n + `Your copy is already GONE from origin, but \\`${cfg.devBranch}\\` was NOT rebuilt: the deployed dev server\\n`\n + `still runs \\`${branch}\\` until the next composition run.\\n\\n`\n + 'git said:\\n' + (stderr === '' ? ' (no output)' : stderr.split('\\n').map((l: string): string => ` ${l}`).join('\\n')) + '\\n\\n'\n + 'Once the cause above is fixed (network, auth, a branch-protection rule on the marker namespace),\\n'\n + 're-publish and remove again; the second remove pushes the marker:\\n\\n'\n + ` ${WP_START_PUSH_DEV}\\n ${WP_BUILD_PUSH_DEV}\\n ${WP_FINISH_PUSH_DEV}\\n ${WP_FINISH_PUSH_DEV} --remove\\n`);\n }\n}\n"]}
@@ -0,0 +1,43 @@
1
+ import { RepoRootFinder } from '@webpieces/rules-config';
2
+ import { DevDeployRefs } from '../workflow/dev-deploy-refs';
3
+ import { MainFreshness } from '../workflow/main-freshness';
4
+ import { OpenPrCheck } from '../workflow/open-pr-check';
5
+ import { RunUpdate } from '../workflow/run-update';
6
+ import { HotfixRedirect } from '../workflow/hotfix-redirect';
7
+ import { AiBranchName } from '../workflow/git-readAiBranchName';
8
+ import { MergeState } from '../workflow/merge-state';
9
+ /**
10
+ * `wp-start-push-dev` — stage ① of the dev-deploy flow (#1403): bring the branch up to date with
11
+ * `origin/main`, ONLY if it is behind, then hand off to `wp-build-push-dev`.
12
+ *
13
+ * WHY: a branch forked from an old main was published to dev, built against a `node_modules` missing a
14
+ * workspace package main had added since, and failed six minutes into its build (monorepo-nx #2042, 30
15
+ * commits behind). Every dev copy is therefore based on the latest main.
16
+ *
17
+ * It adds NO merge logic: it runs the same 3-point squash-update `wp-start-update` and
18
+ * `wp-start-upsert-pr` run (RunUpdate), so rewriting the branch is expected. Which of those two it
19
+ * behaves like is decided by whether a PR is open, the same way the two flows are chosen:
20
+ *
21
+ * - no PR — like `wp-start-update`: a clean update pushes the rewrite to `origin/<feature>` when that
22
+ * branch exists, since no later stage of this flow pushes the feature branch.
23
+ * - a PR open — like `wp-start-upsert-pr`: the rewrite stays local, because the PR head is only ever pushed
24
+ * by the reviewed PR flow. The dev copy is published from it regardless.
25
+ *
26
+ * A conflict is resolved on the developer's own branch with `/wp-merge`; `wp-build-push-dev` then
27
+ * validates and finalizes it before doing anything else.
28
+ */
29
+ export declare class StartPushDevCommand {
30
+ private readonly repoRootFinder;
31
+ private readonly refs;
32
+ private readonly mainFreshness;
33
+ private readonly openPrCheck;
34
+ private readonly runUpdate;
35
+ private readonly hotfixRedirect;
36
+ private readonly aiBranchName;
37
+ private readonly mergeState;
38
+ constructor(repoRootFinder: RepoRootFinder, refs: DevDeployRefs, mainFreshness: MainFreshness, openPrCheck: OpenPrCheck, runUpdate: RunUpdate, hotfixRedirect: HotfixRedirect, aiBranchName: AiBranchName, mergeState: MergeState);
39
+ run(): Promise<void>;
40
+ private updateFromMain;
41
+ private next;
42
+ private mainMergeInFlight;
43
+ }
@@ -0,0 +1,111 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.StartPushDevCommand = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const rules_config_1 = require("@webpieces/rules-config");
6
+ const inversify_1 = require("inversify");
7
+ const dev_deploy_refs_1 = require("../workflow/dev-deploy-refs");
8
+ const main_freshness_1 = require("../workflow/main-freshness");
9
+ const open_pr_check_1 = require("../workflow/open-pr-check");
10
+ const run_update_1 = require("../workflow/run-update");
11
+ const hotfix_redirect_1 = require("../workflow/hotfix-redirect");
12
+ const git_readAiBranchName_1 = require("../workflow/git-readAiBranchName");
13
+ const merge_state_1 = require("../workflow/merge-state");
14
+ const SEP = '━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n';
15
+ /**
16
+ * `wp-start-push-dev` — stage ① of the dev-deploy flow (#1403): bring the branch up to date with
17
+ * `origin/main`, ONLY if it is behind, then hand off to `wp-build-push-dev`.
18
+ *
19
+ * WHY: a branch forked from an old main was published to dev, built against a `node_modules` missing a
20
+ * workspace package main had added since, and failed six minutes into its build (monorepo-nx #2042, 30
21
+ * commits behind). Every dev copy is therefore based on the latest main.
22
+ *
23
+ * It adds NO merge logic: it runs the same 3-point squash-update `wp-start-update` and
24
+ * `wp-start-upsert-pr` run (RunUpdate), so rewriting the branch is expected. Which of those two it
25
+ * behaves like is decided by whether a PR is open, the same way the two flows are chosen:
26
+ *
27
+ * - no PR — like `wp-start-update`: a clean update pushes the rewrite to `origin/<feature>` when that
28
+ * branch exists, since no later stage of this flow pushes the feature branch.
29
+ * - a PR open — like `wp-start-upsert-pr`: the rewrite stays local, because the PR head is only ever pushed
30
+ * by the reviewed PR flow. The dev copy is published from it regardless.
31
+ *
32
+ * A conflict is resolved on the developer's own branch with `/wp-merge`; `wp-build-push-dev` then
33
+ * validates and finalizes it before doing anything else.
34
+ */
35
+ let StartPushDevCommand = class StartPushDevCommand {
36
+ repoRootFinder;
37
+ refs;
38
+ mainFreshness;
39
+ openPrCheck;
40
+ runUpdate;
41
+ hotfixRedirect;
42
+ aiBranchName;
43
+ mergeState;
44
+ constructor(repoRootFinder, refs, mainFreshness, openPrCheck, runUpdate, hotfixRedirect, aiBranchName, mergeState) {
45
+ this.repoRootFinder = repoRootFinder;
46
+ this.refs = refs;
47
+ this.mainFreshness = mainFreshness;
48
+ this.openPrCheck = openPrCheck;
49
+ this.runUpdate = runUpdate;
50
+ this.hotfixRedirect = hotfixRedirect;
51
+ this.aiBranchName = aiBranchName;
52
+ this.mergeState = mergeState;
53
+ }
54
+ async run() {
55
+ // FIRST: a /hotfix/ branch is cut from the production sha and must never take main (issue #1057).
56
+ this.hotfixRedirect.assertNotHotfix('wp-start-push-dev');
57
+ const repoRoot = this.repoRootFinder.resolveRepoRoot(process.cwd());
58
+ // Refresh the AI-facing workflow doc so it is present + current for any failure message to cite.
59
+ (0, rules_config_1.writeTemplate)(repoRoot, 'webpieces.git-workflow.md');
60
+ const mergeInFlight = await this.mainMergeInFlight(repoRoot);
61
+ if (!mergeInFlight) {
62
+ const branch = this.refs.currentBranch(repoRoot);
63
+ this.refs.assertPushable(this.refs.config(repoRoot), branch);
64
+ if (await this.mainFreshness.containsLatestMain(repoRoot)) {
65
+ process.stdout.write('\n' + SEP + `✅ \`${branch}\` already contains origin/main — nothing to merge\n` + SEP + '\n'
66
+ + 'Your branch was not touched.\n\n'
67
+ + this.next());
68
+ return;
69
+ }
70
+ }
71
+ await this.updateFromMain(repoRoot);
72
+ }
73
+ // The 3-point merge, exactly as the other two flows run it; only the push decision is ours (see class).
74
+ async updateFromMain(repoRoot) {
75
+ const branch = this.refs.currentBranch(repoRoot);
76
+ const openPr = await this.openPrCheck.openPrForBranch(repoRoot, branch);
77
+ process.stdout.write('\n' + SEP + '① Updating branch from main\n' + SEP + '\n');
78
+ const outcome = await this.runUpdate.runUpdateFromMain(repoRoot, 'wp-start-push-dev', 'wp-build-push-dev', openPr === '');
79
+ if (outcome === 'conflict' || outcome === 'unvalidatedResume') {
80
+ throw new rules_config_1.CliExitError(2, '\n⏸️ Conflicts with main — resolve them on your branch with /wp-merge, then run\n'
81
+ + ` ${rules_config_1.WP_BUILD_PUSH_DEV} (it validates and finalizes the merge first, then checks against dev).\n`);
82
+ }
83
+ const prNote = openPr === ''
84
+ ? ''
85
+ : `PR #${openPr} is open, so the update was NOT pushed to it — the PR flow does that push, reviewed.\n`;
86
+ process.stdout.write('\n✅ Updated from main.\n' + prNote + '\n' + this.next());
87
+ }
88
+ next() {
89
+ return `▶ NEXT run: ${rules_config_1.WP_BUILD_PUSH_DEV}\n`
90
+ + ' It merges origin/dev into a throwaway branch, runs pnpm install and the dev build on it, and\n'
91
+ + ' records the copy wp-finish-push-dev publishes.\n';
92
+ }
93
+ // A 3-point merge already started (and stopped on a conflict) by any start command.
94
+ async mainMergeInFlight(repoRoot) {
95
+ const home = this.mergeState.mergeDirFor(repoRoot, await this.aiBranchName.getFeatureName());
96
+ return this.mergeState.findActiveMergeRunDir(home) !== null;
97
+ }
98
+ };
99
+ exports.StartPushDevCommand = StartPushDevCommand;
100
+ exports.StartPushDevCommand = StartPushDevCommand = tslib_1.__decorate([
101
+ (0, inversify_1.injectable)(inversify_1.bindingScopeValues.Singleton),
102
+ tslib_1.__metadata("design:paramtypes", [rules_config_1.RepoRootFinder,
103
+ dev_deploy_refs_1.DevDeployRefs,
104
+ main_freshness_1.MainFreshness,
105
+ open_pr_check_1.OpenPrCheck,
106
+ run_update_1.RunUpdate,
107
+ hotfix_redirect_1.HotfixRedirect,
108
+ git_readAiBranchName_1.AiBranchName,
109
+ merge_state_1.MergeState])
110
+ ], StartPushDevCommand);
111
+ //# sourceMappingURL=start-push-dev-command.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"start-push-dev-command.js","sourceRoot":"","sources":["../../../../../../../packages/tooling/pr-gate/src/scripts/commands/start-push-dev-command.ts"],"names":[],"mappings":";;;;AAAA,0DAAyG;AACzG,yCAA2D;AAE3D,iEAA4D;AAC5D,+DAA2D;AAC3D,6DAAwD;AACxD,uDAAmD;AACnD,iEAA6D;AAC7D,2EAAgE;AAChE,yDAAqD;AAErD,MAAM,GAAG,GAAG,0DAA0D,CAAC;AAEvE;;;;;;;;;;;;;;;;;;;GAmBG;AAEI,IAAM,mBAAmB,GAAzB,MAAM,mBAAmB;IAEP;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IARrB,YACqB,cAA8B,EAC9B,IAAmB,EACnB,aAA4B,EAC5B,WAA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U,CAAC,qBAAqB,CAAC,IAAI,CAAC,KAAK,IAAI,CAAC;IAChE,CAAC;CACJ,CAAA;AA9DY,kDAAmB;8BAAnB,mBAAmB;IAD/B,IAAA,sBAAU,EAAC,8BAAkB,CAAC,SAAS,CAAC;6CAGA,6BAAc;QACxB,+BAAa;QACJ,8BAAa;QACf,2BAAW;QACb,sBAAS;QACJ,gCAAc;QAChB,mCAAY;QACd,wBAAU;GATlC,mBAAmB,CA8D/B","sourcesContent":["import { CliExitError, RepoRootFinder, WP_BUILD_PUSH_DEV, writeTemplate } from '@webpieces/rules-config';\nimport { injectable, bindingScopeValues } from 'inversify';\n\nimport { DevDeployRefs } from '../workflow/dev-deploy-refs';\nimport { MainFreshness } from '../workflow/main-freshness';\nimport { OpenPrCheck } from '../workflow/open-pr-check';\nimport { RunUpdate } from '../workflow/run-update';\nimport { HotfixRedirect } from '../workflow/hotfix-redirect';\nimport { AiBranchName } from '../workflow/git-readAiBranchName';\nimport { MergeState } from '../workflow/merge-state';\n\nconst SEP = '━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\\n';\n\n/**\n * `wp-start-push-dev` — stage ① of the dev-deploy flow (#1403): bring the branch up to date with\n * `origin/main`, ONLY if it is behind, then hand off to `wp-build-push-dev`.\n *\n * WHY: a branch forked from an old main was published to dev, built against a `node_modules` missing a\n * workspace package main had added since, and failed six minutes into its build (monorepo-nx #2042, 30\n * commits behind). Every dev copy is therefore based on the latest main.\n *\n * It adds NO merge logic: it runs the same 3-point squash-update `wp-start-update` and\n * `wp-start-upsert-pr` run (RunUpdate), so rewriting the branch is expected. Which of those two it\n * behaves like is decided by whether a PR is open, the same way the two flows are chosen:\n *\n * - no PR — like `wp-start-update`: a clean update pushes the rewrite to `origin/<feature>` when that\n * branch exists, since no later stage of this flow pushes the feature branch.\n * - a PR open — like `wp-start-upsert-pr`: the rewrite stays local, because the PR head is only ever pushed\n * by the reviewed PR flow. The dev copy is published from it regardless.\n *\n * A conflict is resolved on the developer's own branch with `/wp-merge`; `wp-build-push-dev` then\n * validates and finalizes it before doing anything else.\n */\n@injectable(bindingScopeValues.Singleton)\nexport class StartPushDevCommand {\n constructor(\n private readonly repoRootFinder: RepoRootFinder,\n private readonly refs: DevDeployRefs,\n private readonly mainFreshness: MainFreshness,\n private readonly openPrCheck: OpenPrCheck,\n private readonly runUpdate: RunUpdate,\n private readonly hotfixRedirect: HotfixRedirect,\n private readonly aiBranchName: AiBranchName,\n private readonly mergeState: MergeState,\n ) {}\n\n async run(): Promise<void> {\n // FIRST: a /hotfix/ branch is cut from the production sha and must never take main (issue #1057).\n this.hotfixRedirect.assertNotHotfix('wp-start-push-dev');\n const repoRoot = this.repoRootFinder.resolveRepoRoot(process.cwd());\n // Refresh the AI-facing workflow doc so it is present + current for any failure message to cite.\n writeTemplate(repoRoot, 'webpieces.git-workflow.md');\n\n const mergeInFlight = await this.mainMergeInFlight(repoRoot);\n if (!mergeInFlight) {\n const branch = this.refs.currentBranch(repoRoot);\n this.refs.assertPushable(this.refs.config(repoRoot), branch);\n if (await this.mainFreshness.containsLatestMain(repoRoot)) {\n process.stdout.write(\n '\\n' + SEP + `✅ \\`${branch}\\` already contains origin/main — nothing to merge\\n` + SEP + '\\n'\n + 'Your branch was not touched.\\n\\n'\n + this.next());\n return;\n }\n }\n await this.updateFromMain(repoRoot);\n }\n\n // The 3-point merge, exactly as the other two flows run it; only the push decision is ours (see class).\n private async updateFromMain(repoRoot: string): Promise<void> {\n const branch = this.refs.currentBranch(repoRoot);\n const openPr = await this.openPrCheck.openPrForBranch(repoRoot, branch);\n process.stdout.write('\\n' + SEP + '① Updating branch from main\\n' + SEP + '\\n');\n const outcome = await this.runUpdate.runUpdateFromMain(repoRoot, 'wp-start-push-dev', 'wp-build-push-dev', openPr === '');\n if (outcome === 'conflict' || outcome === 'unvalidatedResume') {\n throw new CliExitError(2,\n '\\n⏸️ Conflicts with main — resolve them on your branch with /wp-merge, then run\\n'\n + ` ${WP_BUILD_PUSH_DEV} (it validates and finalizes the merge first, then checks against dev).\\n`);\n }\n const prNote = openPr === ''\n ? ''\n : `PR #${openPr} is open, so the update was NOT pushed to it — the PR flow does that push, reviewed.\\n`;\n process.stdout.write('\\n✅ Updated from main.\\n' + prNote + '\\n' + this.next());\n }\n\n private next(): string {\n return `▶ NEXT run: ${WP_BUILD_PUSH_DEV}\\n`\n + ' It merges origin/dev into a throwaway branch, runs pnpm install and the dev build on it, and\\n'\n + ' records the copy wp-finish-push-dev publishes.\\n';\n }\n\n // A 3-point merge already started (and stopped on a conflict) by any start command.\n private async mainMergeInFlight(repoRoot: string): Promise<boolean> {\n const home = this.mergeState.mergeDirFor(repoRoot, await this.aiBranchName.getFeatureName());\n return this.mergeState.findActiveMergeRunDir(home) !== null;\n }\n}\n"]}
@@ -10,12 +10,12 @@ import { CheckPrCommand } from './commands/check-pr-command';
10
10
  import { ReviewUpsertPrCommand } from './commands/review-upsert-pr-command';
11
11
  import { ReapWorktreeCommand } from './commands/reap-worktree-command';
12
12
  import { BuildCommand, BuildOptions } from './commands/build-command';
13
- import { BuildDevCommand } from './commands/build-dev-command';
14
13
  import { AwaitReviewsCommand } from './commands/await-reviews-command';
15
14
  import { ReviewBudgetCheckOptions, WriteReviewCommand, WriteReviewOptions } from './commands/write-review-command';
16
15
  import { WriteReviewFixesCommand, WriteReviewFixesOptions } from './commands/write-review-fixes-command';
17
16
  import { AwaitChecksCommand, AwaitChecksOptions } from './commands/await-checks-command';
18
- import { PushDevCommand, PushDevOptions } from './commands/push-dev-command';
17
+ import { StartPushDevCommand } from './commands/start-push-dev-command';
18
+ import { BuildPushDevCommand, BuildPushDevOptions } from './commands/build-push-dev-command';
19
19
  import { FinishPushDevCommand, FinishPushDevOptions } from './commands/finish-push-dev-command';
20
20
  import { HumanPostPrCommand } from './commands/human-post-pr-command';
21
21
  import { UpsertHotfixPrCommand } from './commands/upsert-hotfix-pr-command';
@@ -39,20 +39,20 @@ export declare class PrGateApp {
39
39
  private readonly reviewUpsertPrCommand;
40
40
  private readonly reapWorktreeCommand;
41
41
  private readonly buildCommand;
42
- private readonly buildDevCommand;
43
42
  private readonly awaitReviewsCommand;
44
43
  private readonly writeReviewCommand;
45
44
  private readonly writeReviewFixesCommand;
46
45
  private readonly awaitChecksCommand;
47
- private readonly pushDevCommand;
46
+ private readonly startPushDevCommand;
47
+ private readonly buildPushDevCommand;
48
48
  private readonly finishPushDevCommand;
49
49
  private readonly humanPostPrCommand;
50
50
  private readonly upsertHotfixPrCommand;
51
51
  private readonly pushDevStateStore;
52
52
  private readonly repoRootFinder;
53
- constructor(startUpdateCommand: StartUpdateCommand, finishUpdateCommand: FinishUpdateCommand, startUpsertPrCommand: StartUpsertPrCommand, finishUpsertPrCommand: FinishUpsertPrCommand, cleanupCommand: CleanupCommand, syncMainCommand: SyncMainCommand, landPrCommand: LandPrCommand, checkPrCommand: CheckPrCommand, reviewUpsertPrCommand: ReviewUpsertPrCommand, reapWorktreeCommand: ReapWorktreeCommand, buildCommand: BuildCommand, buildDevCommand: BuildDevCommand, awaitReviewsCommand: AwaitReviewsCommand, writeReviewCommand: WriteReviewCommand, writeReviewFixesCommand: WriteReviewFixesCommand, awaitChecksCommand: AwaitChecksCommand, pushDevCommand: PushDevCommand, finishPushDevCommand: FinishPushDevCommand, humanPostPrCommand: HumanPostPrCommand, upsertHotfixPrCommand: UpsertHotfixPrCommand, pushDevStateStore: PushDevStateStore, repoRootFinder: RepoRootFinder);
53
+ constructor(startUpdateCommand: StartUpdateCommand, finishUpdateCommand: FinishUpdateCommand, startUpsertPrCommand: StartUpsertPrCommand, finishUpsertPrCommand: FinishUpsertPrCommand, cleanupCommand: CleanupCommand, syncMainCommand: SyncMainCommand, landPrCommand: LandPrCommand, checkPrCommand: CheckPrCommand, reviewUpsertPrCommand: ReviewUpsertPrCommand, reapWorktreeCommand: ReapWorktreeCommand, buildCommand: BuildCommand, awaitReviewsCommand: AwaitReviewsCommand, writeReviewCommand: WriteReviewCommand, writeReviewFixesCommand: WriteReviewFixesCommand, awaitChecksCommand: AwaitChecksCommand, startPushDevCommand: StartPushDevCommand, buildPushDevCommand: BuildPushDevCommand, finishPushDevCommand: FinishPushDevCommand, humanPostPrCommand: HumanPostPrCommand, upsertHotfixPrCommand: UpsertHotfixPrCommand, pushDevStateStore: PushDevStateStore, repoRootFinder: RepoRootFinder);
54
54
  /**
55
- * Refuse `command` while a `wp-push-dev --resolve` is half-finished.
55
+ * Refuse `command` while a `wp-build-push-dev` conflict resolution is half-finished.
56
56
  *
57
57
  * Enforced HERE, at the one place every bin funnels through, rather than in each command: a resolve
58
58
  * parks the checkout on a throwaway branch, so every command below would act on a branch that is not
@@ -60,9 +60,15 @@ export declare class PrGateApp {
60
60
  * tenth. PushDevStateStore owns the blocked list AND renders the hint from it, so the two cannot drift.
61
61
  */
62
62
  private assertNoResolveInProgress;
63
- /** `wp-push-dev`: check this branch against dev, build it, and publish a DISPOSABLE copy of it. No PR. */
64
- pushDev(opts?: PushDevOptions): Promise<void>;
65
- /** `wp-finish-push-dev`: commit a resolved dev composition and publish it (conflict path only). */
63
+ /** `wp-start-push-dev`: dev-deploy stage ① — 3-point merge from main, ONLY if the branch is behind it. */
64
+ startPushDev(): Promise<void>;
65
+ /**
66
+ * `wp-build-push-dev`: dev-deploy stage ② — check the branch against dev on a throwaway merge,
67
+ * `pnpm install`, run the dev build, record the copy. NOT blocked during a resolve: re-running it is
68
+ * how a resolve continues, and `--abort` is how it ends.
69
+ */
70
+ buildPushDev(opts?: BuildPushDevOptions): Promise<void>;
71
+ /** `wp-finish-push-dev`: dev-deploy stage ③ — publish the verified DISPOSABLE copy; `--list`, `--remove`. No PR. */
66
72
  finishPushDev(opts?: FinishPushDevOptions): Promise<void>;
67
73
  /**
68
74
  * INTERNAL (`wp-reap-worktree.js`, no `bin` entry): remove ONE named worktree and its branch.
@@ -73,23 +79,17 @@ export declare class PrGateApp {
73
79
  /**
74
80
  * `wp-build`: run this repo's ONE configured build (`commands.pr-gate.buildCommand`) — the same
75
81
  * command, resolved by the same resolver, that the PR gate's build stage runs. Not blocked during a
76
- * `wp-push-dev --resolve`: it mutates nothing and reads no branch state.
82
+ * dev-deploy resolve: it mutates nothing and reads no branch state.
77
83
  */
78
84
  build(opts: BuildOptions): Promise<void>;
79
- /**
80
- * `wp-build-dev`: merge `origin/<devBranch>` into a throwaway, run `commands.push-dev.buildCommand` on
81
- * it, and go back — the check `wp-push-dev` runs before publishing, without the publish (#1397).
82
- * Blocked during a resolve: it parks the checkout on a throwaway of its own.
83
- */
84
- buildDev(): Promise<void>;
85
85
  /**
86
86
  * `wp-await-reviews`: BLOCK until every reviewer verdict this branch owes has landed, then print
87
- * them. Not blocked during a `wp-push-dev --resolve`: it reads verdict files and mutates nothing.
87
+ * them. Not blocked during a dev-deploy resolve: it reads verdict files and mutates nothing.
88
88
  */
89
89
  awaitReviews(): Promise<void>;
90
90
  /**
91
91
  * `wp-write-review`: a reviewer subagent submits ONE checklist verdict, with provenance (issue #863).
92
- * Not blocked during a `wp-push-dev --resolve`: it writes only this branch's review state.
92
+ * Not blocked during a dev-deploy resolve: it writes only this branch's review state.
93
93
  */
94
94
  writeReview(opts: WriteReviewOptions): Promise<void>;
95
95
  /** `wp-write-review --check`: may this checklist still be reviewed on this branch (issue #1051)? */