@webpieces/pr-gate 0.4.983 → 0.4.985

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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 +49 -0
  22. package/src/scripts/workflow/dev-copy-on-main.js +99 -0
  23. package/src/scripts/workflow/dev-copy-on-main.js.map +1 -0
  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 -124
  47. package/src/scripts/commands/push-dev-command.js +0 -318
  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
@@ -1 +1 @@
1
- {"version":3,"file":"dev-build.js","sourceRoot":"","sources":["../../../../../../../packages/tooling/pr-gate/src/scripts/workflow/dev-build.ts"],"names":[],"mappings":";;;;AAAA,0DAAkF;AAClF,yCAA2D;AAE3D,qDAAmE;AACnE,qDAAmD;AACnD,uDAAkD;AAElD,MAAM,GAAG,GAAG,0DAA0D,CAAC;AAEvE,uGAAuG;AAC1F,QAAA,yBAAyB,GAAG,4DAA4D,CAAC;AAEtG;;;;;;;;;;;;;GAaG;AAEI,IAAM,QAAQ,GAAd,MAAM,QAAQ;IAEI;IACA;IAFrB,YACqB,aAA4B,EAC5B,IAAmB;QADnB,kBAAa,GAAb,aAAa,CAAe;QAC5B,SAAI,GAAJ,IAAI,CAAe;IACrC,CAAC;IAEJ,4GAA4G;IAC5G,OAAO,CAAC,QAAgB;QACpB,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,eAAe,CAAC,QAAQ,CAAC,CAAC;QACvD,IAAI,UAAU,KAAK,SAAS,IAAI,UAAU,CAAC,IAAI,EAAE,KAAK,EAAE;YAAE,OAAO,UAAU,CAAC;QAC5E,MAAM,IAAI,2BAAY,CAAC,CAAC,EACpB,IAAI,GAAG,GAAG,GAAG,wDAAwD,GAAG,GAAG,GAAG,IAAI;cAChF,GAAG,0BAAW,qEAAqE,2BAAY,IAAI;cACnG,6FAA6F;cAC7F,6CAA6C;cAC7C,kGAAkG;cAClG,2CAA2C;cAC3C,oCAAoC,iCAAyB,OAAO,CAAC,CAAC;IAChF,CAAC;IAED;;;;OAIG;IACH,GAAG,CAAC,QAAgB,EAAE,YAAoB;QACtC,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;QACvC,OAAO,IAAI,CAAC,aAAa,CAAC,gBAAgB,CAAC,QAAQ,EAAE,OAAO,EAAE,IAAI,iCAAgB,CAC9E,iDAAiD,EACjD,YAAY,EACZ,2CAA2C,EAC3C,gCAAe,CAClB,CAAC,CAAC;IACP,CAAC;CACJ,CAAA;AAlCY,4BAAQ;mBAAR,QAAQ;IADpB,IAAA,sBAAU,EAAC,8BAAkB,CAAC,SAAS,CAAC;6CAGD,8BAAa;QACtB,+BAAa;GAH/B,QAAQ,CAkCpB","sourcesContent":["import { CliExitError, WP_BUILD_DEV, WP_PUSH_DEV } from '@webpieces/rules-config';\nimport { injectable, bindingScopeValues } from 'inversify';\n\nimport { BuildAffected, BuildGateOptions } from './build-affected';\nimport { DEV_BUILD_STAGE } from './build-gate-log';\nimport { DevDeployRefs } from './dev-deploy-refs';\n\nconst SEP = '━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\\n';\n\n/** The example printed when the key is missing. An example, never a fallback: nothing ever RUNS it. */\nexport const EXAMPLE_DEV_BUILD_COMMAND = 'pnpm nx affected --target=ci --base=origin/dev --head=HEAD';\n\n/**\n * The dev-scoped build (#1397): `commands.push-dev.buildCommand`, run through the SAME build gate as\n * `wp-build` and the PR gate (`BuildAffected.runBuildGateWith`) — one log-file capture, one heartbeat, one\n * ledger row pair, one failure rendering. Only the command and the log name (`build-dev.log`) differ.\n *\n * WHY A SECOND COMMAND AND NOT `commands.pr-gate.buildCommand`: the PR gate builds what this branch\n * changes against `main`. Before a dev publish the question is different — does this copy build once it is\n * merged with what is ALREADY on `dev` — and the cheap way to answer it builds only what differs from\n * `origin/dev`. The two are different builds, so they are two keys.\n *\n * NO DEFAULT, deliberately (`.claude/rules/no-rule-defaults.md`): which build vouches for a dev publish is\n * the consumer's decision. Missing ⇒ the command refuses before it touches anything, naming the key and\n * printing the entry to paste.\n */\n@injectable(bindingScopeValues.Singleton)\nexport class DevBuild {\n constructor(\n private readonly buildAffected: BuildAffected,\n private readonly refs: DevDeployRefs,\n ) {}\n\n /** The configured command, or the refusal naming the key. Called BEFORE any git write, so it fails fast. */\n command(repoRoot: string): string {\n const configured = this.refs.devBuildCommand(repoRoot);\n if (configured !== undefined && configured.trim() !== '') return configured;\n throw new CliExitError(2,\n '\\n' + SEP + '⛔ `commands.push-dev.buildCommand` is not configured\\n' + SEP + '\\n'\n + `${WP_PUSH_DEV} builds your copy merged with origin/dev before it publishes, and ${WP_BUILD_DEV}\\n`\n + 'runs that build on its own. WHICH build is this repo\\'s decision, so there is no default.\\n'\n + 'Nothing was merged, built or published.\\n\\n'\n + 'Add this to webpieces.config.json, inside \"commands\", choosing a command that builds only what\\n'\n + 'differs from origin/dev in this repo:\\n\\n'\n + ` \"push-dev\": { \"buildCommand\": \"${EXAMPLE_DEV_BUILD_COMMAND}\" }\\n`);\n }\n\n /**\n * Run the dev build on the CURRENT checkout. Throws CliExitError on a red build, with the `FullLog :`\n * pointer, exactly like `wp-build`. `rerunCommand` is what the failure text tells the reader to run\n * after fixing it.\n */\n run(repoRoot: string, rerunCommand: string): Promise<void> {\n const command = this.command(repoRoot);\n return this.buildAffected.runBuildGateWith(repoRoot, command, new BuildGateOptions(\n '🛠️ dev build (commands.push-dev.buildCommand)',\n rerunCommand,\n 'Dev build failed — nothing was published.',\n DEV_BUILD_STAGE,\n ));\n }\n}\n"]}
1
+ {"version":3,"file":"dev-build.js","sourceRoot":"","sources":["../../../../../../../packages/tooling/pr-gate/src/scripts/workflow/dev-build.ts"],"names":[],"mappings":";;;;AAAA,0DAA0E;AAC1E,yCAA2D;AAE3D,qDAAmE;AACnE,qDAAmD;AACnD,uDAAkD;AAElD,MAAM,GAAG,GAAG,0DAA0D,CAAC;AAEvE,uGAAuG;AAC1F,QAAA,yBAAyB,GAAG,4DAA4D,CAAC;AAEtG;;;;;;;;;;;;;GAaG;AAEI,IAAM,QAAQ,GAAd,MAAM,QAAQ;IAEI;IACA;IAFrB,YACqB,aAA4B,EAC5B,IAAmB;QADnB,kBAAa,GAAb,aAAa,CAAe;QAC5B,SAAI,GAAJ,IAAI,CAAe;IACrC,CAAC;IAEJ,4GAA4G;IAC5G,OAAO,CAAC,QAAgB;QACpB,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,eAAe,CAAC,QAAQ,CAAC,CAAC;QACvD,IAAI,UAAU,KAAK,SAAS,IAAI,UAAU,CAAC,IAAI,EAAE,KAAK,EAAE;YAAE,OAAO,UAAU,CAAC;QAC5E,MAAM,IAAI,2BAAY,CAAC,CAAC,EACpB,IAAI,GAAG,GAAG,GAAG,wDAAwD,GAAG,GAAG,GAAG,IAAI;cAChF,GAAG,gCAAiB,oFAAoF;cACxG,iEAAiE;cACjE,6CAA6C;cAC7C,kGAAkG;cAClG,2CAA2C;cAC3C,oCAAoC,iCAAyB,OAAO,CAAC,CAAC;IAChF,CAAC;IAED;;;;OAIG;IACH,GAAG,CAAC,QAAgB,EAAE,YAAoB;QACtC,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;QACvC,OAAO,IAAI,CAAC,aAAa,CAAC,gBAAgB,CAAC,QAAQ,EAAE,OAAO,EAAE,IAAI,iCAAgB,CAC9E,iDAAiD,EACjD,YAAY,EACZ,2CAA2C,EAC3C,gCAAe,CAClB,CAAC,CAAC;IACP,CAAC;CACJ,CAAA;AAlCY,4BAAQ;mBAAR,QAAQ;IADpB,IAAA,sBAAU,EAAC,8BAAkB,CAAC,SAAS,CAAC;6CAGD,8BAAa;QACtB,+BAAa;GAH/B,QAAQ,CAkCpB","sourcesContent":["import { CliExitError, WP_BUILD_PUSH_DEV } from '@webpieces/rules-config';\nimport { injectable, bindingScopeValues } from 'inversify';\n\nimport { BuildAffected, BuildGateOptions } from './build-affected';\nimport { DEV_BUILD_STAGE } from './build-gate-log';\nimport { DevDeployRefs } from './dev-deploy-refs';\n\nconst SEP = '━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\\n';\n\n/** The example printed when the key is missing. An example, never a fallback: nothing ever RUNS it. */\nexport const EXAMPLE_DEV_BUILD_COMMAND = 'pnpm nx affected --target=ci --base=origin/dev --head=HEAD';\n\n/**\n * The dev-scoped build (#1397): `commands.push-dev.buildCommand`, run through the SAME build gate as\n * `wp-build` and the PR gate (`BuildAffected.runBuildGateWith`) — one log-file capture, one heartbeat, one\n * ledger row pair, one failure rendering. Only the command and the log name (`build-dev.log`) differ.\n *\n * WHY A SECOND COMMAND AND NOT `commands.pr-gate.buildCommand`: the PR gate builds what this branch\n * changes against `main`. Before a dev publish the question is different — does this copy build once it is\n * merged with what is ALREADY on `dev` — and the cheap way to answer it builds only what differs from\n * `origin/dev`. The two are different builds, so they are two keys.\n *\n * NO DEFAULT, deliberately (`.claude/rules/no-rule-defaults.md`): which build vouches for a dev publish is\n * the consumer's decision. Missing ⇒ the command refuses before it touches anything, naming the key and\n * printing the entry to paste.\n */\n@injectable(bindingScopeValues.Singleton)\nexport class DevBuild {\n constructor(\n private readonly buildAffected: BuildAffected,\n private readonly refs: DevDeployRefs,\n ) {}\n\n /** The configured command, or the refusal naming the key. Called BEFORE any git write, so it fails fast. */\n command(repoRoot: string): string {\n const configured = this.refs.devBuildCommand(repoRoot);\n if (configured !== undefined && configured.trim() !== '') return configured;\n throw new CliExitError(2,\n '\\n' + SEP + '⛔ `commands.push-dev.buildCommand` is not configured\\n' + SEP + '\\n'\n + `${WP_BUILD_PUSH_DEV} builds your copy merged with origin/dev before wp-finish-push-dev publishes it.\\n`\n + 'WHICH build is this repo\\'s decision, so there is no default.\\n'\n + 'Nothing was merged, built or published.\\n\\n'\n + 'Add this to webpieces.config.json, inside \"commands\", choosing a command that builds only what\\n'\n + 'differs from origin/dev in this repo:\\n\\n'\n + ` \"push-dev\": { \"buildCommand\": \"${EXAMPLE_DEV_BUILD_COMMAND}\" }\\n`);\n }\n\n /**\n * Run the dev build on the CURRENT checkout. Throws CliExitError on a red build, with the `FullLog :`\n * pointer, exactly like `wp-build`. `rerunCommand` is what the failure text tells the reader to run\n * after fixing it.\n */\n run(repoRoot: string, rerunCommand: string): Promise<void> {\n const command = this.command(repoRoot);\n return this.buildAffected.runBuildGateWith(repoRoot, command, new BuildGateOptions(\n '🛠️ dev build (commands.push-dev.buildCommand)',\n rerunCommand,\n 'Dev build failed — nothing was published.',\n DEV_BUILD_STAGE,\n ));\n }\n}\n"]}
@@ -0,0 +1,49 @@
1
+ import { NativeProcessApi } from '@webpieces/tooling-common';
2
+ import { GitExec } from './git-exec';
3
+ /**
4
+ * How much of one dev copy is already on `origin/main`. Data-only per CLAUDE.md.
5
+ *
6
+ * `changed` is every file the copy changes relative to its merge-base with `origin/main`; `landed` is the
7
+ * subset whose content on `origin/main` is now identical to the copy's.
8
+ */
9
+ export declare class DevCopyLanding {
10
+ readonly changed: string[];
11
+ readonly landed: string[];
12
+ constructor(changed: string[], landed: string[]);
13
+ /** Every file the copy changes already has the copy's content on main — removing it takes nothing off dev. */
14
+ fullyOnMain(): boolean;
15
+ /** Some, but not all, of the copy's files are already on main. */
16
+ partlyOnMain(): boolean;
17
+ }
18
+ /** The merged PR a copy's branch landed through, for the refusal message. Data-only. */
19
+ export declare class MergedPr {
20
+ readonly num: string;
21
+ readonly mergedAt: string;
22
+ constructor(num: string, mergedAt: string);
23
+ }
24
+ /**
25
+ * Answers "is this dev copy already on `origin/main`?" for `wp-finish-push-dev --remove` (#1401).
26
+ *
27
+ * WHY: developers ran `--remove` after their PR landed, as a "done, clean up" habit. On a repo that composes
28
+ * `dev` = `origin/main` + every copy, that remove takes nothing off dev (main keeps the change there) and
29
+ * still triggers a full recompose that can redeploy every service. Only rolling back a copy that broke dev is
30
+ * a real reason to remove.
31
+ *
32
+ * HOW: a pure content check, no GitHub dependency. The files the copy changes since its merge-base with
33
+ * `origin/main` (`git diff A...B`), minus the files where `origin/main` and the copy still differ
34
+ * (`git diff A B`), are the files already landed. Both refs must already be fetched. `--no-renames` so a
35
+ * rename counts both its old and new path rather than hiding the deletion.
36
+ */
37
+ export declare class DevCopyOnMain {
38
+ private readonly gitExec;
39
+ private readonly processes;
40
+ constructor(gitExec: GitExec, processes: NativeProcessApi);
41
+ landing(repoRoot: string, copyRef: string): Promise<DevCopyLanding>;
42
+ /**
43
+ * The merged PR whose head was `branch`, or null. It only decorates the refusal message, so a `gh` that
44
+ * is missing, unauthenticated or offline yields null rather than an error: the content check above has
45
+ * already decided.
46
+ */
47
+ mergedPr(repoRoot: string, branch: string): Promise<MergedPr | null>;
48
+ private names;
49
+ }
@@ -0,0 +1,99 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DevCopyOnMain = exports.MergedPr = exports.DevCopyLanding = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const tooling_common_1 = require("@webpieces/tooling-common");
6
+ const inversify_1 = require("inversify");
7
+ const git_exec_1 = require("./git-exec");
8
+ const MAIN_REF = 'refs/remotes/origin/main';
9
+ /**
10
+ * How much of one dev copy is already on `origin/main`. Data-only per CLAUDE.md.
11
+ *
12
+ * `changed` is every file the copy changes relative to its merge-base with `origin/main`; `landed` is the
13
+ * subset whose content on `origin/main` is now identical to the copy's.
14
+ */
15
+ class DevCopyLanding {
16
+ changed;
17
+ landed;
18
+ constructor(changed, landed) {
19
+ this.changed = changed;
20
+ this.landed = landed;
21
+ }
22
+ /** Every file the copy changes already has the copy's content on main — removing it takes nothing off dev. */
23
+ fullyOnMain() {
24
+ return this.landed.length === this.changed.length;
25
+ }
26
+ /** Some, but not all, of the copy's files are already on main. */
27
+ partlyOnMain() {
28
+ return this.landed.length > 0 && !this.fullyOnMain();
29
+ }
30
+ }
31
+ exports.DevCopyLanding = DevCopyLanding;
32
+ /** The merged PR a copy's branch landed through, for the refusal message. Data-only. */
33
+ class MergedPr {
34
+ num;
35
+ mergedAt;
36
+ constructor(num, mergedAt) {
37
+ this.num = num;
38
+ this.mergedAt = mergedAt;
39
+ }
40
+ }
41
+ exports.MergedPr = MergedPr;
42
+ // `<number> <mergedAt>` as the --jq below prints it; an empty list prints `null null`, which does not match.
43
+ const PR_LINE = /^(\d+) (\S+)$/;
44
+ /**
45
+ * Answers "is this dev copy already on `origin/main`?" for `wp-finish-push-dev --remove` (#1401).
46
+ *
47
+ * WHY: developers ran `--remove` after their PR landed, as a "done, clean up" habit. On a repo that composes
48
+ * `dev` = `origin/main` + every copy, that remove takes nothing off dev (main keeps the change there) and
49
+ * still triggers a full recompose that can redeploy every service. Only rolling back a copy that broke dev is
50
+ * a real reason to remove.
51
+ *
52
+ * HOW: a pure content check, no GitHub dependency. The files the copy changes since its merge-base with
53
+ * `origin/main` (`git diff A...B`), minus the files where `origin/main` and the copy still differ
54
+ * (`git diff A B`), are the files already landed. Both refs must already be fetched. `--no-renames` so a
55
+ * rename counts both its old and new path rather than hiding the deletion.
56
+ */
57
+ let DevCopyOnMain = class DevCopyOnMain {
58
+ gitExec;
59
+ processes;
60
+ constructor(gitExec, processes) {
61
+ this.gitExec = gitExec;
62
+ this.processes = processes;
63
+ }
64
+ async landing(repoRoot, copyRef) {
65
+ const copy = `refs/remotes/origin/${copyRef}`;
66
+ const changed = await this.names(repoRoot, [`${MAIN_REF}...${copy}`], `Failed to list the files ${copyRef} changes since its merge-base with origin/main (git diff ${MAIN_REF}...${copy}). Nothing was removed.`);
67
+ const stillDiffer = new Set(await this.names(repoRoot, [MAIN_REF, copy], `Failed to compare ${copyRef} with origin/main (git diff ${MAIN_REF} ${copy}). Nothing was removed.`));
68
+ const landed = changed.filter((f) => !stillDiffer.has(f));
69
+ return new DevCopyLanding(changed, landed);
70
+ }
71
+ /**
72
+ * The merged PR whose head was `branch`, or null. It only decorates the refusal message, so a `gh` that
73
+ * is missing, unauthenticated or offline yields null rather than an error: the content check above has
74
+ * already decided.
75
+ */
76
+ async mergedPr(repoRoot, branch) {
77
+ const result = await this.processes.run('gh', [
78
+ 'pr', 'list', '--head', branch, '--state', 'merged', '--limit', '1',
79
+ '--json', 'number,mergedAt', '--jq', '.[0] | "\\(.number) \\(.mergedAt)"',
80
+ ], repoRoot);
81
+ if (!result.ok)
82
+ return null;
83
+ const match = PR_LINE.exec(result.stdout.trim());
84
+ if (match === null)
85
+ return null;
86
+ return new MergedPr(match[1], match[2]);
87
+ }
88
+ async names(repoRoot, revs, failMsg) {
89
+ const out = await this.gitExec.gitQuery(['-C', repoRoot, 'diff', '--name-only', '--no-renames', ...revs], repoRoot, failMsg);
90
+ return out.split('\n').map((l) => l.trim()).filter((l) => l !== '');
91
+ }
92
+ };
93
+ exports.DevCopyOnMain = DevCopyOnMain;
94
+ exports.DevCopyOnMain = DevCopyOnMain = tslib_1.__decorate([
95
+ (0, inversify_1.injectable)(inversify_1.bindingScopeValues.Singleton),
96
+ tslib_1.__metadata("design:paramtypes", [git_exec_1.GitExec,
97
+ tooling_common_1.NativeProcessApi])
98
+ ], DevCopyOnMain);
99
+ //# sourceMappingURL=dev-copy-on-main.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dev-copy-on-main.js","sourceRoot":"","sources":["../../../../../../../packages/tooling/pr-gate/src/scripts/workflow/dev-copy-on-main.ts"],"names":[],"mappings":";;;;AAAA,8DAA6D;AAC7D,yCAA2D;AAE3D,yCAAqC;AAErC,MAAM,QAAQ,GAAG,0BAA0B,CAAC;AAE5C;;;;;GAKG;AACH,MAAa,cAAc;IAEV;IACA;IAFb,YACa,OAAiB,EACjB,MAAgB;QADhB,YAAO,GAAP,OAAO,CAAU;QACjB,WAAM,GAAN,MAAM,CAAU;IAC1B,CAAC;IAEJ,8GAA8G;IAC9G,WAAW;QACP,OAAO,IAAI,CAAC,MAAM,CAAC,MAAM,KAAK,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC;IACtD,CAAC;IAED,kEAAkE;IAClE,YAAY;QACR,OAAO,IAAI,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC;IACzD,CAAC;CACJ;AAfD,wCAeC;AAED,wFAAwF;AACxF,MAAa,QAAQ;IAEJ;IACA;IAFb,YACa,GAAW,EACX,QAAgB;QADhB,QAAG,GAAH,GAAG,CAAQ;QACX,aAAQ,GAAR,QAAQ,CAAQ;IAC1B,CAAC;CACP;AALD,4BAKC;AAED,6GAA6G;AAC7G,MAAM,OAAO,GAAG,eAAe,CAAC;AAEhC;;;;;;;;;;;;GAYG;AAEI,IAAM,aAAa,GAAnB,MAAM,aAAa;IAED;IACA;IAFrB,YACqB,OAAgB,EAChB,SAA2B;QAD3B,YAAO,GAAP,OAAO,CAAS;QAChB,cAAS,GAAT,SAAS,CAAkB;IAC7C,CAAC;IAEJ,KAAK,CAAC,OAAO,CAAC,QAAgB,EAAE,OAAe;QAC3C,MAAM,IAAI,GAAG,uBAAuB,OAAO,EAAE,CAAC;QAC9C,MAAM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CAAC,KAAK,CAAC,QAAgB,EAAE,IAAc,EAAE,OAAe;QACjE,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,aAAa,EAAE,cAAc,EAAE,GAAG,IAAI,CAAC,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC;QAC7H,OAAO,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,CAAS,EAAU,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAS,EAAW,EAAE,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC;IACzG,CAAC;CACJ,CAAA;AApCY,sCAAa;wBAAb,aAAa;IADzB,IAAA,sBAAU,EAAC,8BAAkB,CAAC,SAAS,CAAC;6CAGP,kBAAO;QACL,iCAAgB;GAHvC,aAAa,CAoCzB","sourcesContent":["import { NativeProcessApi } from '@webpieces/tooling-common';\nimport { injectable, bindingScopeValues } from 'inversify';\n\nimport { GitExec } from './git-exec';\n\nconst MAIN_REF = 'refs/remotes/origin/main';\n\n/**\n * How much of one dev copy is already on `origin/main`. Data-only per CLAUDE.md.\n *\n * `changed` is every file the copy changes relative to its merge-base with `origin/main`; `landed` is the\n * subset whose content on `origin/main` is now identical to the copy's.\n */\nexport class DevCopyLanding {\n constructor(\n readonly changed: string[],\n readonly landed: string[],\n ) {}\n\n /** Every file the copy changes already has the copy's content on main — removing it takes nothing off dev. */\n fullyOnMain(): boolean {\n return this.landed.length === this.changed.length;\n }\n\n /** Some, but not all, of the copy's files are already on main. */\n partlyOnMain(): boolean {\n return this.landed.length > 0 && !this.fullyOnMain();\n }\n}\n\n/** The merged PR a copy's branch landed through, for the refusal message. Data-only. */\nexport class MergedPr {\n constructor(\n readonly num: string,\n readonly mergedAt: string,\n ) {}\n}\n\n// `<number> <mergedAt>` as the --jq below prints it; an empty list prints `null null`, which does not match.\nconst PR_LINE = /^(\\d+) (\\S+)$/;\n\n/**\n * Answers \"is this dev copy already on `origin/main`?\" for `wp-finish-push-dev --remove` (#1401).\n *\n * WHY: developers ran `--remove` after their PR landed, as a \"done, clean up\" habit. On a repo that composes\n * `dev` = `origin/main` + every copy, that remove takes nothing off dev (main keeps the change there) and\n * still triggers a full recompose that can redeploy every service. Only rolling back a copy that broke dev is\n * a real reason to remove.\n *\n * HOW: a pure content check, no GitHub dependency. The files the copy changes since its merge-base with\n * `origin/main` (`git diff A...B`), minus the files where `origin/main` and the copy still differ\n * (`git diff A B`), are the files already landed. Both refs must already be fetched. `--no-renames` so a\n * rename counts both its old and new path rather than hiding the deletion.\n */\n@injectable(bindingScopeValues.Singleton)\nexport class DevCopyOnMain {\n constructor(\n private readonly gitExec: GitExec,\n private readonly processes: NativeProcessApi,\n ) {}\n\n async landing(repoRoot: string, copyRef: string): Promise<DevCopyLanding> {\n const copy = `refs/remotes/origin/${copyRef}`;\n const changed = await this.names(repoRoot, [`${MAIN_REF}...${copy}`],\n `Failed to list the files ${copyRef} changes since its merge-base with origin/main (git diff ${MAIN_REF}...${copy}). Nothing was removed.`);\n const stillDiffer = new Set(await this.names(repoRoot, [MAIN_REF, copy],\n `Failed to compare ${copyRef} with origin/main (git diff ${MAIN_REF} ${copy}). Nothing was removed.`));\n const landed = changed.filter((f: string): boolean => !stillDiffer.has(f));\n return new DevCopyLanding(changed, landed);\n }\n\n /**\n * The merged PR whose head was `branch`, or null. It only decorates the refusal message, so a `gh` that\n * is missing, unauthenticated or offline yields null rather than an error: the content check above has\n * already decided.\n */\n async mergedPr(repoRoot: string, branch: string): Promise<MergedPr | null> {\n const result = await this.processes.run('gh', [\n 'pr', 'list', '--head', branch, '--state', 'merged', '--limit', '1',\n '--json', 'number,mergedAt', '--jq', '.[0] | \"\\\\(.number) \\\\(.mergedAt)\"',\n ], repoRoot);\n if (!result.ok) return null;\n const match = PR_LINE.exec(result.stdout.trim());\n if (match === null) return null;\n return new MergedPr(match[1], match[2]);\n }\n\n private async names(repoRoot: string, revs: string[], failMsg: string): Promise<string[]> {\n const out = await this.gitExec.gitQuery(['-C', repoRoot, 'diff', '--name-only', '--no-renames', ...revs], repoRoot, failMsg);\n return out.split('\\n').map((l: string): string => l.trim()).filter((l: string): boolean => l !== '');\n }\n}\n"]}
@@ -2,8 +2,7 @@ import { DevDeployConfig } from '@webpieces/rules-config';
2
2
  import { GitExec } from './git-exec';
3
3
  /**
4
4
  * One live copy in the dev namespace: the remote ref and the sha it points at. Data-only per CLAUDE.md —
5
- * `--list` prints it and the clobber guard compares against `sha`, and neither should be re-parsing
6
- * `ls-remote` output.
5
+ * `--list` prints it, and should not be re-parsing `ls-remote` output.
7
6
  */
8
7
  export declare class DevCopy {
9
8
  /** The full ref name WITHOUT `refs/heads/`, e.g. `dev-include/dean/ONE-2275`. */
@@ -14,8 +13,8 @@ export declare class DevCopy {
14
13
  constructor(ref: string, sha: string, sourceBranch: string);
15
14
  }
16
15
  /**
17
- * Ref derivation and preconditions for the dev-deploy flow — the half of `wp-push-dev` that decides WHICH
18
- * refs are in play, kept out of the commands so both `wp-push-dev` and `wp-finish-push-dev` answer those
16
+ * Ref derivation and preconditions for the dev-deploy flow — the half that decides WHICH refs are in play,
17
+ * kept out of the commands so `wp-start-push-dev`, `wp-build-push-dev` and `wp-finish-push-dev` answer those
19
18
  * questions identically.
20
19
  *
21
20
  * THE INVARIANT THIS FILE EXISTS TO PROTECT: the feature branch is the PR head, so it must never acquire
@@ -50,12 +49,7 @@ export declare class DevDeployRefs {
50
49
  */
51
50
  assertPushable(cfg: DevDeployConfig, branch: string): void;
52
51
  /**
53
- * Every live copy in the namespace, sorted by ref name.
54
- *
55
- * The sort is not cosmetic: `--resolve` with no argument queues these in exactly this order, and the
56
- * consumer's CI composes `dev` in the same order, so what a developer resolves locally is the
57
- * composition CI will actually build. A different order can produce a different (still valid) merge
58
- * result, which would make the local resolution a guess about CI rather than a rehearsal of it.
52
+ * Every live copy in the namespace, sorted by ref name — what `wp-finish-push-dev --list` prints.
59
53
  */
60
54
  liveCopies(repoRoot: string, cfg: DevDeployConfig): Promise<DevCopy[]>;
61
55
  /**
@@ -83,12 +77,5 @@ export declare class DevDeployRefs {
83
77
  * stale refs rehearses a composition CI will not build.
84
78
  */
85
79
  fetchCopies(repoRoot: string, refs: string[]): Promise<void>;
86
- /**
87
- * The subject of every commit `origin/<ref>` has that `HEAD` does not — the clobber signal. Empty =
88
- * safe to publish. Subjects rather than a count, because a commit this flow wrote itself (a recorded
89
- * conflict resolution, see DevResolveRunner) is re-derived by the next publish's check against dev and
90
- * is therefore safe to replace, while anything else on the copy is somebody's work.
91
- */
92
- subjectsOnlyOnRemote(repoRoot: string, ref: string): Promise<string[]>;
93
80
  private refusal;
94
81
  }
@@ -11,8 +11,7 @@ const MAIN = 'main';
11
11
  const DETACHED = 'HEAD';
12
12
  /**
13
13
  * One live copy in the dev namespace: the remote ref and the sha it points at. Data-only per CLAUDE.md —
14
- * `--list` prints it and the clobber guard compares against `sha`, and neither should be re-parsing
15
- * `ls-remote` output.
14
+ * `--list` prints it, and should not be re-parsing `ls-remote` output.
16
15
  */
17
16
  class DevCopy {
18
17
  /** The full ref name WITHOUT `refs/heads/`, e.g. `dev-include/dean/ONE-2275`. */
@@ -28,8 +27,8 @@ class DevCopy {
28
27
  }
29
28
  exports.DevCopy = DevCopy;
30
29
  /**
31
- * Ref derivation and preconditions for the dev-deploy flow — the half of `wp-push-dev` that decides WHICH
32
- * refs are in play, kept out of the commands so both `wp-push-dev` and `wp-finish-push-dev` answer those
30
+ * Ref derivation and preconditions for the dev-deploy flow — the half that decides WHICH refs are in play,
31
+ * kept out of the commands so `wp-start-push-dev`, `wp-build-push-dev` and `wp-finish-push-dev` answer those
33
32
  * questions identically.
34
33
  *
35
34
  * THE INVARIANT THIS FILE EXISTS TO PROTECT: the feature branch is the PR head, so it must never acquire
@@ -92,12 +91,7 @@ let DevDeployRefs = class DevDeployRefs {
92
91
  }
93
92
  }
94
93
  /**
95
- * Every live copy in the namespace, sorted by ref name.
96
- *
97
- * The sort is not cosmetic: `--resolve` with no argument queues these in exactly this order, and the
98
- * consumer's CI composes `dev` in the same order, so what a developer resolves locally is the
99
- * composition CI will actually build. A different order can produce a different (still valid) merge
100
- * result, which would make the local resolution a guess about CI rather than a rehearsal of it.
94
+ * Every live copy in the namespace, sorted by ref name — what `wp-finish-push-dev --list` prints.
101
95
  */
102
96
  async liveCopies(repoRoot, cfg) {
103
97
  const out = await this.gitExec.gitQuery(['ls-remote', '--heads', 'origin', cfg.copyRefGlob()], repoRoot, `Failed to list the dev copies (git ls-remote --heads origin '${cfg.copyRefGlob()}').`);
@@ -156,18 +150,8 @@ let DevDeployRefs = class DevDeployRefs {
156
150
  const specs = refs.map((r) => `+refs/heads/${r}:refs/remotes/origin/${r}`);
157
151
  await this.gitExec.runGitChecked(['-C', repoRoot, 'fetch', 'origin', ...specs], 'Failed to fetch the dev copy refs from origin');
158
152
  }
159
- /**
160
- * The subject of every commit `origin/<ref>` has that `HEAD` does not — the clobber signal. Empty =
161
- * safe to publish. Subjects rather than a count, because a commit this flow wrote itself (a recorded
162
- * conflict resolution, see DevResolveRunner) is re-derived by the next publish's check against dev and
163
- * is therefore safe to replace, while anything else on the copy is somebody's work.
164
- */
165
- async subjectsOnlyOnRemote(repoRoot, ref) {
166
- const out = await this.gitExec.gitQuery(['log', '--format=%s', `HEAD..refs/remotes/origin/${ref}`], repoRoot, `Failed to compare HEAD against origin/${ref} (git log HEAD..origin/${ref}).`);
167
- return out.split('\n').filter((l) => l.trim() !== '');
168
- }
169
153
  refusal(headline, body) {
170
- return '\n' + SEP + `⛔ ${headline}\n` + SEP + '\n' + body + `\nRun \`${rules_config_1.WP_PUSH_DEV} --help\` for the full command.\n`;
154
+ return '\n' + SEP + `⛔ ${headline}\n` + SEP + '\n' + body + '\nRun `pnpm wp-finish-push-dev --help` for the full command.\n';
171
155
  }
172
156
  };
173
157
  exports.DevDeployRefs = DevDeployRefs;
@@ -1 +1 @@
1
- {"version":3,"file":"dev-deploy-refs.js","sourceRoot":"","sources":["../../../../../../../packages/tooling/pr-gate/src/scripts/workflow/dev-deploy-refs.ts"],"names":[],"mappings":";;;;AAAA,0DAAsG;AACtG,yCAA2D;AAC3D,8DAAwD;AAExD,yCAAqC;AAErC,MAAM,GAAG,GAAG,0DAA0D,CAAC;AACvE,MAAM,IAAI,GAAG,MAAM,CAAC;AACpB,MAAM,QAAQ,GAAG,MAAM,CAAC;AAExB;;;;GAIG;AACH,MAAa,OAAO;IAChB,iFAAiF;IACjF,GAAG,CAAS;IACZ,GAAG,CAAS;IACZ,uFAAuF;IACvF,YAAY,CAAS;IAErB,YAAY,GAAW,EAAE,GAAW,EAAE,YAAoB;QACtD,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QACf,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QACf,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;IACrC,CAAC;CACJ;AAZD,0BAYC;AAED;;;;;;;;;;GAUG;AAEI,IAAM,aAAa,GAAnB,MAAM,aAAa;IACO;IAA7B,YAA6B,OAAgB;QAAhB,YAAO,GAAP,OAAO,CAAS;IAAG,CAAC;IAEjD,4GAA4G;IAC5G,MAAM,CAAC,QAAgB;QACnB,OAAO,IAAA,8BAAe,EAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,SAAS,CAAC;IACtD,CAAC;IAED;;;;OAIG;IACH,eAAe,CAAC,QAAgB;QAC5B,OAAO,IAAA,8BAAe,EAAC,QAAQ,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,YAAY,CAAC;IACnE,CAAC;IAED,0GAA0G;IAC1G,aAAa,CAAC,QAAgB;QAC1B,OAAO,4BAAW,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC;IAC/C,CAAC;IAED;;;;;;;;;;OAUG;IACH,cAAc,CAAC,GAAoB,EAAE,MAAc;QAC/C,IAAI,MAAM,KAAK,QAAQ,IAAI,MAAM,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F,MAAM,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,QAAQ,EAAE,GAAG,KAAK,CAAC,EAC1E,+CAA+C,CAAC,CAAC;IACzD,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,oBAAoB,CAAC,QAAgB,EAAE,GAAW;QACpD,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,KAAK,EAAE,aAAa,EAAE,6BAA6B,GAAG,EAAE,CAAC,EAAE,QAAQ,EACxG,yCAAyC,GAAG,0BAA0B,GAAG,IAAI,CAAC,CAAC;QACnF,OAAO,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC,CAAS,EAAW,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC;IAC3E,CAAC;IAEO,OAAO,CAAC,QAAgB,EAAE,IAAY;QAC1C,OAAO,IAAI,GAAG,GAAG,GAAG,KAAK,QAAQ,IAAI,GAAG,GAAG,GAAG,IAAI,GAAG,IAAI,GAAG,WAAW,0BAAW,mCAAmC,CAAC;IAC1H,CAAC;CACJ,CAAA;AArJY,sCAAa;wBAAb,aAAa;IADzB,IAAA,sBAAU,EAAC,8BAAkB,CAAC,SAAS,CAAC;6CAEC,kBAAO;GADpC,aAAa,CAqJzB","sourcesContent":["import { CliExitError, DevDeployConfig, loadAndValidate, WP_PUSH_DEV } from '@webpieces/rules-config';\nimport { injectable, bindingScopeValues } from 'inversify';\nimport { gitCheckout } from '@webpieces/tooling-common';\n\nimport { GitExec } from './git-exec';\n\nconst SEP = '━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\\n';\nconst MAIN = 'main';\nconst DETACHED = 'HEAD';\n\n/**\n * One live copy in the dev namespace: the remote ref and the sha it points at. Data-only per CLAUDE.md —\n * `--list` prints it and the clobber guard compares against `sha`, and neither should be re-parsing\n * `ls-remote` output.\n */\nexport class DevCopy {\n /** The full ref name WITHOUT `refs/heads/`, e.g. `dev-include/dean/ONE-2275`. */\n ref: string;\n sha: string;\n /** The feature branch this is a copy OF — `ref` with the namespace prefix stripped. */\n sourceBranch: string;\n\n constructor(ref: string, sha: string, sourceBranch: string) {\n this.ref = ref;\n this.sha = sha;\n this.sourceBranch = sourceBranch;\n }\n}\n\n/**\n * Ref derivation and preconditions for the dev-deploy flow — the half of `wp-push-dev` that decides WHICH\n * refs are in play, kept out of the commands so both `wp-push-dev` and `wp-finish-push-dev` answer those\n * questions identically.\n *\n * THE INVARIANT THIS FILE EXISTS TO PROTECT: the feature branch is the PR head, so it must never acquire\n * another developer's commits — landing that PR would ship their unreviewed work to production. Every\n * write this flow performs therefore targets either the `<namespace>/<feature>` copy or a local throwaway\n * branch, and NOTHING here ever moves `<feature>` itself. That is why a conflict resolution needs the copy\n * to live in: it is the only place the resolution can be recorded without contaminating the PR.\n */\n@injectable(bindingScopeValues.Singleton)\nexport class DevDeployRefs {\n constructor(private readonly gitExec: GitExec) {}\n\n /** The `pr-gate.devDeploy` block — `dev-include` / `dev` / `dev-remove` unless the consumer overrode it. */\n config(repoRoot: string): DevDeployConfig {\n return loadAndValidate(repoRoot).prGate.devDeploy;\n }\n\n /**\n * `commands.push-dev.buildCommand`, or `undefined` when the consumer has not configured it. There is\n * no default (#1397, `.claude/rules/no-rule-defaults.md`); DevBuild turns `undefined` into the refusal\n * that names the key.\n */\n devBuildCommand(repoRoot: string): string | undefined {\n return loadAndValidate(repoRoot).commands.pushDev.buildCommand;\n }\n\n /** The checked-out branch name, or `'HEAD'` on a detached HEAD (which {@link assertPushable} refuses). */\n currentBranch(repoRoot: string): string {\n return gitCheckout.requireBranch(repoRoot);\n }\n\n /**\n * Refuse every branch that must never be the SOURCE of a dev copy, before anything is fetched or\n * pushed.\n *\n * `main` and the composed dev branch are refused for the same reason from opposite ends: `main` is the\n * trunk (whatever is on it already deploys, so copying it is meaningless), and the dev branch is a\n * BUILD ARTIFACT that CI recomputes from `origin/main` on every run — copying it would publish a\n * composition of everyone's work under one developer's name, and it would be wiped on the next CI run\n * anyway. A branch already inside the namespace is refused because publishing a copy of a copy nests\n * the prefix (`dev-include/dev-include/…`) and nothing would ever clean it up.\n */\n assertPushable(cfg: DevDeployConfig, branch: string): void {\n if (branch === DETACHED || branch === '') {\n throw new CliExitError(2, this.refusal(\n 'Detached HEAD',\n 'There is no branch name to derive the dev copy from. Check out your feature branch first:\\n'\n + ' git checkout <your-feature-branch>\\n'));\n }\n if (branch === MAIN) {\n throw new CliExitError(2, this.refusal(\n `Refusing to publish a dev copy of \\`${MAIN}\\``,\n `\\`${MAIN}\\` is the trunk — whatever is on it already deploys, so a dev copy of it means nothing.\\n`\n + 'Check out the feature branch you actually want on the dev server and re-run.\\n'));\n }\n if (branch === cfg.devBranch) {\n throw new CliExitError(2, this.refusal(\n `Refusing to publish a dev copy of \\`${cfg.devBranch}\\``,\n `\\`${cfg.devBranch}\\` is a BUILD ARTIFACT, not a source branch: your CI resets it to origin/${MAIN},\\n`\n + `merges every \\`${cfg.copyRefGlob()}\\` ref into it, and force-pushes — every run. Copying it would\\n`\n + \"publish a composition of everybody's work under your branch's name, and the next CI run would\\n\"\n + 'wipe it. Check out your own feature branch and re-run.\\n'));\n }\n if (branch === cfg.branchNamespace || branch.startsWith(`${cfg.branchNamespace}/`)) {\n throw new CliExitError(2, this.refusal(\n `Refusing to publish a dev copy of a dev copy (\\`${branch}\\`)`,\n `\\`${cfg.branchNamespace}/\\` holds the disposable copies this command WRITES; you are standing on one.\\n`\n + `Publishing from here would nest the prefix (\\`${cfg.branchNamespace}/${branch}\\`) and nothing ever\\n`\n + 'cleans that up. Check out the real feature branch and re-run.\\n'));\n }\n }\n\n /**\n * Every live copy in the namespace, sorted by ref name.\n *\n * The sort is not cosmetic: `--resolve` with no argument queues these in exactly this order, and the\n * consumer's CI composes `dev` in the same order, so what a developer resolves locally is the\n * composition CI will actually build. A different order can produce a different (still valid) merge\n * result, which would make the local resolution a guess about CI rather than a rehearsal of it.\n */\n async liveCopies(repoRoot: string, cfg: DevDeployConfig): Promise<DevCopy[]> {\n const out = await this.gitExec.gitQuery(['ls-remote', '--heads', 'origin', cfg.copyRefGlob()], repoRoot,\n `Failed to list the dev copies (git ls-remote --heads origin '${cfg.copyRefGlob()}').`);\n const copies: DevCopy[] = [];\n for (const line of out.split('\\n')) {\n if (line.trim() === '') continue;\n const fields = line.split(/\\s+/);\n const sha = fields[0];\n const ref = fields[1];\n if (sha === undefined || ref === undefined || !ref.startsWith('refs/heads/')) continue;\n const shortRef = ref.slice('refs/heads/'.length);\n copies.push(new DevCopy(shortRef, sha, shortRef.slice(cfg.branchNamespace.length + 1)));\n }\n return copies.sort((a: DevCopy, b: DevCopy): number => (a.ref < b.ref ? -1 : a.ref > b.ref ? 1 : 0));\n }\n\n /**\n * The sha of a local ref (default HEAD).\n *\n * Read AFTER a push so the watch hints quote the sha that is provably published. Quoting the copy\n * REF instead would be a moving target — it advances the next time anybody publishes — and the whole\n * value of the \"did my code land in dev\" check is that it is a claim about one specific commit.\n */\n headSha(repoRoot: string, ref = 'HEAD'): Promise<string> {\n return this.gitExec.gitQuery(['-C', repoRoot, 'rev-parse', ref], repoRoot,\n `Failed to read the sha of ${ref} (git rev-parse).`);\n }\n\n /**\n * Fetch `origin/main` and return its sha — what the `--remove` marker points at (#1395).\n *\n * The marker carries no content, so any sha the remote already has would do; `main`'s tip is chosen\n * because it is guaranteed to exist on origin (the push sends no objects) and it is what the\n * consumer's workflow composes from anyway. Fetched rather than read from the local tracking ref, so a\n * clone that has not fetched in weeks does not point the marker at an arbitrarily old commit.\n */\n async freshMainTip(repoRoot: string): Promise<string> {\n await this.gitExec.runGitChecked(['-C', repoRoot, 'fetch', 'origin', `+refs/heads/${MAIN}:refs/remotes/origin/${MAIN}`],\n `Failed to fetch origin/${MAIN}, which the --remove marker points at. Nothing was removed`);\n return this.headSha(repoRoot, `refs/remotes/origin/${MAIN}`);\n }\n\n /** The remote sha of one copy, or '' when that copy does not exist yet. */\n async remoteSha(repoRoot: string, ref: string): Promise<string> {\n const out = await this.gitExec.gitQuery(['ls-remote', '--heads', 'origin', ref], repoRoot,\n `Failed to look up origin/${ref} (git ls-remote).`);\n const line = out.split('\\n').find((l: string): boolean => l.trim() !== '');\n if (line === undefined) return '';\n return line.split(/\\s+/)[0] ?? '';\n }\n\n /**\n * Fetch the named copy refs into `refs/remotes/origin/<ref>` so the local merges below run against\n * fresh state. A no-op for an empty list, and a hard failure otherwise: a resolve queued against\n * stale refs rehearses a composition CI will not build.\n */\n async fetchCopies(repoRoot: string, refs: string[]): Promise<void> {\n if (refs.length === 0) return;\n const specs = refs.map((r: string): string => `+refs/heads/${r}:refs/remotes/origin/${r}`);\n await this.gitExec.runGitChecked(['-C', repoRoot, 'fetch', 'origin', ...specs],\n 'Failed to fetch the dev copy refs from origin');\n }\n\n /**\n * The subject of every commit `origin/<ref>` has that `HEAD` does not — the clobber signal. Empty =\n * safe to publish. Subjects rather than a count, because a commit this flow wrote itself (a recorded\n * conflict resolution, see DevResolveRunner) is re-derived by the next publish's check against dev and\n * is therefore safe to replace, while anything else on the copy is somebody's work.\n */\n async subjectsOnlyOnRemote(repoRoot: string, ref: string): Promise<string[]> {\n const out = await this.gitExec.gitQuery(['log', '--format=%s', `HEAD..refs/remotes/origin/${ref}`], repoRoot,\n `Failed to compare HEAD against origin/${ref} (git log HEAD..origin/${ref}).`);\n return out.split('\\n').filter((l: string): boolean => l.trim() !== '');\n }\n\n private refusal(headline: string, body: string): string {\n return '\\n' + SEP + `⛔ ${headline}\\n` + SEP + '\\n' + body + `\\nRun \\`${WP_PUSH_DEV} --help\\` for the full command.\\n`;\n }\n}\n"]}
1
+ {"version":3,"file":"dev-deploy-refs.js","sourceRoot":"","sources":["../../../../../../../packages/tooling/pr-gate/src/scripts/workflow/dev-deploy-refs.ts"],"names":[],"mappings":";;;;AAAA,0DAAyF;AAC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EO,OAAO,CAAC,QAAgB,EAAE,IAAY;QAC1C,OAAO,IAAI,GAAG,GAAG,GAAG,KAAK,QAAQ,IAAI,GAAG,GAAG,GAAG,IAAI,GAAG,IAAI,GAAG,gEAAgE,CAAC;IACjI,CAAC;CACJ,CAAA;AApIY,sCAAa;wBAAb,aAAa;IADzB,IAAA,sBAAU,EAAC,8BAAkB,CAAC,SAAS,CAAC;6CAEC,kBAAO;GADpC,aAAa,CAoIzB","sourcesContent":["import { CliExitError, DevDeployConfig, loadAndValidate } from '@webpieces/rules-config';\nimport { injectable, bindingScopeValues } from 'inversify';\nimport { gitCheckout } from '@webpieces/tooling-common';\n\nimport { GitExec } from './git-exec';\n\nconst SEP = '━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\\n';\nconst MAIN = 'main';\nconst DETACHED = 'HEAD';\n\n/**\n * One live copy in the dev namespace: the remote ref and the sha it points at. Data-only per CLAUDE.md —\n * `--list` prints it, and should not be re-parsing `ls-remote` output.\n */\nexport class DevCopy {\n /** The full ref name WITHOUT `refs/heads/`, e.g. `dev-include/dean/ONE-2275`. */\n ref: string;\n sha: string;\n /** The feature branch this is a copy OF — `ref` with the namespace prefix stripped. */\n sourceBranch: string;\n\n constructor(ref: string, sha: string, sourceBranch: string) {\n this.ref = ref;\n this.sha = sha;\n this.sourceBranch = sourceBranch;\n }\n}\n\n/**\n * Ref derivation and preconditions for the dev-deploy flow — the half that decides WHICH refs are in play,\n * kept out of the commands so `wp-start-push-dev`, `wp-build-push-dev` and `wp-finish-push-dev` answer those\n * questions identically.\n *\n * THE INVARIANT THIS FILE EXISTS TO PROTECT: the feature branch is the PR head, so it must never acquire\n * another developer's commits — landing that PR would ship their unreviewed work to production. Every\n * write this flow performs therefore targets either the `<namespace>/<feature>` copy or a local throwaway\n * branch, and NOTHING here ever moves `<feature>` itself. That is why a conflict resolution needs the copy\n * to live in: it is the only place the resolution can be recorded without contaminating the PR.\n */\n@injectable(bindingScopeValues.Singleton)\nexport class DevDeployRefs {\n constructor(private readonly gitExec: GitExec) {}\n\n /** The `pr-gate.devDeploy` block — `dev-include` / `dev` / `dev-remove` unless the consumer overrode it. */\n config(repoRoot: string): DevDeployConfig {\n return loadAndValidate(repoRoot).prGate.devDeploy;\n }\n\n /**\n * `commands.push-dev.buildCommand`, or `undefined` when the consumer has not configured it. There is\n * no default (#1397, `.claude/rules/no-rule-defaults.md`); DevBuild turns `undefined` into the refusal\n * that names the key.\n */\n devBuildCommand(repoRoot: string): string | undefined {\n return loadAndValidate(repoRoot).commands.pushDev.buildCommand;\n }\n\n /** The checked-out branch name, or `'HEAD'` on a detached HEAD (which {@link assertPushable} refuses). */\n currentBranch(repoRoot: string): string {\n return gitCheckout.requireBranch(repoRoot);\n }\n\n /**\n * Refuse every branch that must never be the SOURCE of a dev copy, before anything is fetched or\n * pushed.\n *\n * `main` and the composed dev branch are refused for the same reason from opposite ends: `main` is the\n * trunk (whatever is on it already deploys, so copying it is meaningless), and the dev branch is a\n * BUILD ARTIFACT that CI recomputes from `origin/main` on every run — copying it would publish a\n * composition of everyone's work under one developer's name, and it would be wiped on the next CI run\n * anyway. A branch already inside the namespace is refused because publishing a copy of a copy nests\n * the prefix (`dev-include/dev-include/…`) and nothing would ever clean it up.\n */\n assertPushable(cfg: DevDeployConfig, branch: string): void {\n if (branch === DETACHED || branch === '') {\n throw new CliExitError(2, this.refusal(\n 'Detached HEAD',\n 'There is no branch name to derive the dev copy from. Check out your feature branch first:\\n'\n + ' git checkout <your-feature-branch>\\n'));\n }\n if (branch === MAIN) {\n throw new CliExitError(2, this.refusal(\n `Refusing to publish a dev copy of \\`${MAIN}\\``,\n `\\`${MAIN}\\` is the trunk — whatever is on it already deploys, so a dev copy of it means nothing.\\n`\n + 'Check out the feature branch you actually want on the dev server and re-run.\\n'));\n }\n if (branch === cfg.devBranch) {\n throw new CliExitError(2, this.refusal(\n `Refusing to publish a dev copy of \\`${cfg.devBranch}\\``,\n `\\`${cfg.devBranch}\\` is a BUILD ARTIFACT, not a source branch: your CI resets it to origin/${MAIN},\\n`\n + `merges every \\`${cfg.copyRefGlob()}\\` ref into it, and force-pushes — every run. Copying it would\\n`\n + \"publish a composition of everybody's work under your branch's name, and the next CI run would\\n\"\n + 'wipe it. Check out your own feature branch and re-run.\\n'));\n }\n if (branch === cfg.branchNamespace || branch.startsWith(`${cfg.branchNamespace}/`)) {\n throw new CliExitError(2, this.refusal(\n `Refusing to publish a dev copy of a dev copy (\\`${branch}\\`)`,\n `\\`${cfg.branchNamespace}/\\` holds the disposable copies this command WRITES; you are standing on one.\\n`\n + `Publishing from here would nest the prefix (\\`${cfg.branchNamespace}/${branch}\\`) and nothing ever\\n`\n + 'cleans that up. Check out the real feature branch and re-run.\\n'));\n }\n }\n\n /**\n * Every live copy in the namespace, sorted by ref name — what `wp-finish-push-dev --list` prints.\n */\n async liveCopies(repoRoot: string, cfg: DevDeployConfig): Promise<DevCopy[]> {\n const out = await this.gitExec.gitQuery(['ls-remote', '--heads', 'origin', cfg.copyRefGlob()], repoRoot,\n `Failed to list the dev copies (git ls-remote --heads origin '${cfg.copyRefGlob()}').`);\n const copies: DevCopy[] = [];\n for (const line of out.split('\\n')) {\n if (line.trim() === '') continue;\n const fields = line.split(/\\s+/);\n const sha = fields[0];\n const ref = fields[1];\n if (sha === undefined || ref === undefined || !ref.startsWith('refs/heads/')) continue;\n const shortRef = ref.slice('refs/heads/'.length);\n copies.push(new DevCopy(shortRef, sha, shortRef.slice(cfg.branchNamespace.length + 1)));\n }\n return copies.sort((a: DevCopy, b: DevCopy): number => (a.ref < b.ref ? -1 : a.ref > b.ref ? 1 : 0));\n }\n\n /**\n * The sha of a local ref (default HEAD).\n *\n * Read AFTER a push so the watch hints quote the sha that is provably published. Quoting the copy\n * REF instead would be a moving target — it advances the next time anybody publishes — and the whole\n * value of the \"did my code land in dev\" check is that it is a claim about one specific commit.\n */\n headSha(repoRoot: string, ref = 'HEAD'): Promise<string> {\n return this.gitExec.gitQuery(['-C', repoRoot, 'rev-parse', ref], repoRoot,\n `Failed to read the sha of ${ref} (git rev-parse).`);\n }\n\n /**\n * Fetch `origin/main` and return its sha — what the `--remove` marker points at (#1395).\n *\n * The marker carries no content, so any sha the remote already has would do; `main`'s tip is chosen\n * because it is guaranteed to exist on origin (the push sends no objects) and it is what the\n * consumer's workflow composes from anyway. Fetched rather than read from the local tracking ref, so a\n * clone that has not fetched in weeks does not point the marker at an arbitrarily old commit.\n */\n async freshMainTip(repoRoot: string): Promise<string> {\n await this.gitExec.runGitChecked(['-C', repoRoot, 'fetch', 'origin', `+refs/heads/${MAIN}:refs/remotes/origin/${MAIN}`],\n `Failed to fetch origin/${MAIN}, which the --remove marker points at. Nothing was removed`);\n return this.headSha(repoRoot, `refs/remotes/origin/${MAIN}`);\n }\n\n /** The remote sha of one copy, or '' when that copy does not exist yet. */\n async remoteSha(repoRoot: string, ref: string): Promise<string> {\n const out = await this.gitExec.gitQuery(['ls-remote', '--heads', 'origin', ref], repoRoot,\n `Failed to look up origin/${ref} (git ls-remote).`);\n const line = out.split('\\n').find((l: string): boolean => l.trim() !== '');\n if (line === undefined) return '';\n return line.split(/\\s+/)[0] ?? '';\n }\n\n /**\n * Fetch the named copy refs into `refs/remotes/origin/<ref>` so the local merges below run against\n * fresh state. A no-op for an empty list, and a hard failure otherwise: a resolve queued against\n * stale refs rehearses a composition CI will not build.\n */\n async fetchCopies(repoRoot: string, refs: string[]): Promise<void> {\n if (refs.length === 0) return;\n const specs = refs.map((r: string): string => `+refs/heads/${r}:refs/remotes/origin/${r}`);\n await this.gitExec.runGitChecked(['-C', repoRoot, 'fetch', 'origin', ...specs],\n 'Failed to fetch the dev copy refs from origin');\n }\n\n private refusal(headline: string, body: string): string {\n return '\\n' + SEP + `⛔ ${headline}\\n` + SEP + '\\n' + body + '\\nRun `pnpm wp-finish-push-dev --help` for the full command.\\n';\n }\n}\n"]}
@@ -1,121 +1,91 @@
1
1
  import { DevDeployConfig } from '@webpieces/rules-config';
2
+ import { NativeProcessApi } from '@webpieces/tooling-common';
2
3
  import { GitExec } from './git-exec';
3
4
  import { DevDeployRefs } from './dev-deploy-refs';
4
5
  import { PushDevState, PushDevStateStore } from './push-dev-state';
5
- import { DevDeployWatchHints } from './dev-deploy-watch-hints';
6
6
  import { DevBuild } from './dev-build';
7
+ import { VerifiedDevCopyStore } from './verified-dev-copy';
7
8
  /**
8
9
  * The subject prefix of the ONE commit this flow writes onto a copy: the recorded conflict resolution.
9
- * The clobber guard reads it — a remote-only commit with this subject is re-derived by the next publish's
10
- * check against dev, so replacing it destroys nothing; any other remote-only commit is somebody's work.
11
10
  */
12
11
  export declare const RESOLUTION_SUBJECT = "Dev-deploy: conflict resolution for";
13
12
  /**
14
- * The queue-draining engine behind `wp-push-dev` (its pre-publish check against dev, #1397),
15
- * `wp-push-dev --resolve`, `--rebase-resolution`, and `wp-finish-push-dev`.
13
+ * The engine behind `wp-build-push-dev` (#1403): merge `origin/<devBranch>` into a THROWAWAY branch, stop
14
+ * on a conflict, `pnpm install`, run the dev build, and record the copy `wp-finish-push-dev` publishes.
16
15
  *
17
- * ONE class owns every git WRITE in the resolve flow, and that is a hard requirement rather than tidiness:
16
+ * ONE class owns every git WRITE of the check, and that is a hard requirement rather than tidiness:
18
17
  * `redirect-how-to-merge-main` blocks `git merge` in every form INCLUDING `--continue`, and
19
- * `pr-creation-or-push-guard` blocks every `git push`. So an AI cannot be told "now run `git commit`" or
18
+ * `merge-in-progress-guard` blocks `git commit`. So an AI cannot be told "now run `git commit`" or
20
19
  * "`git merge --continue`" — those instructions are unrunnable by the only party reading them. The command
21
- * owns the merges, the commit and the push (as child processes the hooks never see); the AI's entire job is
22
- * editing the conflicted files and `git add`-ing them, neither of which is blocked.
20
+ * owns the merge and the commits (as child processes the hooks never see); the AI's entire job is editing
21
+ * the conflicted files and `git add`-ing them, neither of which is blocked.
22
+ *
23
+ * It NEVER writes to the feature branch: every merge lands on a throwaway that is deleted at the end, so no
24
+ * other developer's commits can reach the PR head even if the check is abandoned halfway.
23
25
  */
24
26
  export declare class DevResolveRunner {
25
27
  private readonly gitExec;
26
28
  private readonly refs;
27
29
  private readonly store;
28
- private readonly watchHints;
30
+ private readonly verified;
29
31
  private readonly devBuild;
30
- constructor(gitExec: GitExec, refs: DevDeployRefs, store: PushDevStateStore, watchHints: DevDeployWatchHints, devBuild: DevBuild);
31
- /**
32
- * Start a resolve: park on a throwaway branch at the current copy, then drain the queue.
33
- *
34
- * The checkout is `-B <tmp> <base>` and NEVER the feature branch, which is the cardinal constraint made
35
- * mechanical — every merge below lands on a branch that is deleted at the end, so no other developer's
36
- * commits can reach the PR head even if the resolve is abandoned halfway.
37
- *
38
- * `base` differs between the callers and the difference IS the semantics. A plain publish starts at the
39
- * LOCAL HEAD and merges `origin/<devBranch>` in (does this copy merge and build against what is already
40
- * on dev?). `--resolve` starts at the published copy and merges the other copies in (compose what CI
41
- * will build). `--rebase-resolution` starts at the LOCAL HEAD and merges the published copy in (replay
42
- * an existing resolution on top of the new commits, instead of force-pushing over it). What is finally
43
- * PUBLISHED is the state's DevResolveMode's decision — see finalize.
44
- *
45
- * `fetchRefs` is passed separately from the queue because `--rebase-resolution` merges a ref that is
46
- * also its push destination, so "everything to fetch" and "everything to merge" are not the same list.
47
- */
48
- start(repoRoot: string, state: PushDevState, base: string, fetchRefs: string[]): Promise<void>;
32
+ private readonly processes;
33
+ constructor(gitExec: GitExec, refs: DevDeployRefs, store: PushDevStateStore, verified: VerifiedDevCopyStore, devBuild: DevBuild, processes: NativeProcessApi);
49
34
  /**
50
- * Resume after the human/AI has resolved the halted merge: commit it, then keep draining.
51
- *
52
- * REFETCHES the remaining queue first. A resolution session can run long, and queuing against refs
53
- * fetched an hour ago rehearses a composition CI will not build — the one freshness gap the sibling
54
- * update flow is still known to have (only its stage ① ever fetches).
35
+ * Start the check: park on a throwaway branch at the feature head, merge `origin/<devBranch>` into it,
36
+ * and either halt on a conflict or go straight on to install, build and record.
55
37
  */
38
+ start(repoRoot: string, state: PushDevState): Promise<void>;
39
+ /** Resume after the conflicted files were resolved and `git add`-ed: commit the merge, then finish. */
56
40
  resume(repoRoot: string, state: PushDevState): Promise<void>;
57
41
  /**
58
- * Throw the whole resolve away: undo any halted merge, go back to the original branch, delete the
59
- * throwaway branch and the state file. Nothing published, nothing on the feature branch.
42
+ * Throw the whole check away: undo any halted merge, go back to the original branch, delete the
43
+ * throwaway branch and the state file. Nothing verified, nothing on the feature branch.
60
44
  */
61
45
  abort(repoRoot: string, state: PushDevState): Promise<void>;
62
- /**
63
- * Merge queued refs until one conflicts (HALT, hand the tree over) or the queue empties (PUBLISH).
64
- *
65
- * A LATER ref can conflict too, which is why this is a loop resumed from a state file rather than a
66
- * single pass: `wp-finish-push-dev` can legitimately stop again on the next ref in the queue.
67
- */
68
- private drain;
69
46
  /** Stop with the conflicted files listed and the ONE command that continues. Exit 2 = "your turn". */
70
47
  private halt;
71
48
  /**
72
- * Queue empty. What happens next is the mode's (see DevResolveMode):
49
+ * The merge is complete. Install and build the MERGED tree, then turn the throwaway into the copy and
50
+ * record it for `wp-finish-push-dev`.
73
51
  *
74
- * - PREBUILD runs the dev build on the MERGED tree first, so a red build stops before anything is
75
- * published.
76
- * - PREBUILD and COMPOSE then publish the BASE plus the recorded resolution — never the merge. REPLAY
77
- * publishes the merge, as it always has.
52
+ * `pnpm install` runs AFTER the merge, never before: other copies already on dev can add workspace
53
+ * packages main does not have yet, so the feature branch's `node_modules` does not link the merged
54
+ * tree (#1403 — a 30-commits-behind branch failed six minutes into its build on exactly that).
78
55
  */
79
- private finalize;
56
+ private finish;
57
+ private install;
80
58
  /**
81
- * Run the dev build on the merged throwaway. On a red build, put the checkout back first — the fix
82
- * belongs on the feature branch, and a developer left parked on a throwaway would make the next
83
- * `wp-*` command act on the wrong branch — then let the build's own failure (with its `FullLog :`
84
- * pointer) reach the top-level handler unchanged.
59
+ * Run one step on the throwaway. On a failure, put the checkout back first — the fix belongs on the
60
+ * feature branch, and a developer left parked on a throwaway would make the next `wp-*` command act on
61
+ * the wrong branch — then let the step's own failure (a build's carries its `FullLog :` pointer) reach
62
+ * the top-level handler unchanged.
85
63
  */
86
- private buildOrRestore;
64
+ private onThrowaway;
87
65
  /**
88
- * Turn the throwaway into what gets PUBLISHED: the base sha plus, when anything conflicted, ONE commit
89
- * that sets each resolved file to its resolved content.
66
+ * Turn the throwaway into the copy: the base sha plus, when anything conflicted, ONE commit that sets
67
+ * each resolved file to its resolved content.
90
68
  *
91
- * This is issue #1397's option (a): the merge is used for the conflict check and the build only, and
92
- * is never published. Publishing it would make every other copy an ancestor of this one, so a later
93
- * `--remove` of that copy would leave its commits on dev through ours. The resolution commit has
94
- * exactly one parent, the base, so the only thing it can carry of anybody else's work is the text of
95
- * the hunks that were resolved — content, never history.
69
+ * The merge is used for the conflict check and the build only, and is never published. Publishing it
70
+ * would make every other copy an ancestor of this one, so a later `--remove` of that copy would leave
71
+ * its commits on dev through ours. The resolution commit has exactly one parent, the base, so the only
72
+ * thing it can carry of anybody else's work is the text of the hunks that were resolved — content,
73
+ * never history.
96
74
  */
97
75
  private recordResolution;
98
- /** Back to the original branch; the throwaway and the state file are gone. */
76
+ /** Back to the original branch; any halted merge, the throwaway and the state file are gone. */
99
77
  private restore;
100
- /**
101
- * PREBUILD leases against the sha the clobber guard inspected (plain `--force` only when asked); the
102
- * other two modes overwrite the copy they themselves started from, as they always have.
103
- */
104
- private pushSafety;
105
- private buildStep;
106
- private publishedBanner;
78
+ private verifiedBanner;
107
79
  /** Conflicted (unmerged-in-index) paths. Empty once every one has been resolved and `git add`ed. */
108
80
  private unmergedPaths;
109
81
  private assertNoUnmergedPaths;
110
82
  /**
111
- * The name of the throwaway branch for a resolve of `branch`.
83
+ * The name of the throwaway branch for a check of `branch`.
112
84
  *
113
85
  * Suffixed rather than prefixed, matching the existing `<feature>Squash` / `<feature>PreMerge<n>`
114
86
  * convention — and deliberately NOT inside the dev namespace, which holds REMOTE copies only.
115
87
  */
116
88
  tmpBranchFor(branch: string): string;
117
- /** The banner `--resolve` prints before the first merge, so the queue is visible before it halts. */
89
+ /** The banner `wp-build-push-dev` prints before its check against dev. */
118
90
  announce(cfg: DevDeployConfig, state: PushDevState): string;
119
- /** The banner plain `wp-push-dev` prints before its check against dev (#1397). */
120
- announcePrebuild(cfg: DevDeployConfig, state: PushDevState): string;
121
91
  }