@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
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MainFreshness = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const inversify_1 = require("inversify");
6
+ const git_exec_1 = require("./git-exec");
7
+ /**
8
+ * "Does this branch already contain the latest `origin/main`?" — the question both ends of the dev-deploy
9
+ * flow ask (#1403). `wp-start-push-dev` asks it to decide whether to run the 3-point merge at all (it runs
10
+ * ONLY when the branch is behind), and `wp-build-push-dev` asks it to refuse a copy built from a stale
11
+ * fork point: such a copy builds against a `node_modules` missing whatever main added since, while dev
12
+ * already contains it.
13
+ *
14
+ * Always FETCHES first. A local `origin/main` from last week answers "contains main" confidently and
15
+ * wrongly, which is the exact staleness this check exists to catch.
16
+ */
17
+ let MainFreshness = class MainFreshness {
18
+ gitExec;
19
+ constructor(gitExec) {
20
+ this.gitExec = gitExec;
21
+ }
22
+ async containsLatestMain(repoRoot) {
23
+ await this.gitExec.runGitChecked(['-C', repoRoot, 'fetch', 'origin', '+refs/heads/main:refs/remotes/origin/main'], 'Failed to fetch origin/main to check whether this branch is up to date with it');
24
+ const contains = await this.gitExec.tryGit(['-C', repoRoot, 'merge-base', '--is-ancestor', 'refs/remotes/origin/main', 'HEAD'], repoRoot);
25
+ return contains.ok;
26
+ }
27
+ };
28
+ exports.MainFreshness = MainFreshness;
29
+ exports.MainFreshness = MainFreshness = tslib_1.__decorate([
30
+ (0, inversify_1.injectable)(inversify_1.bindingScopeValues.Singleton),
31
+ tslib_1.__metadata("design:paramtypes", [git_exec_1.GitExec])
32
+ ], MainFreshness);
33
+ //# sourceMappingURL=main-freshness.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"main-freshness.js","sourceRoot":"","sources":["../../../../../../../packages/tooling/pr-gate/src/scripts/workflow/main-freshness.ts"],"names":[],"mappings":";;;;AAAA,yCAA2D;AAE3D,yCAAqC;AAErC;;;;;;;;;GASG;AAEI,IAAM,aAAa,GAAnB,MAAM,aAAa;IACO;IAA7B,YAA6B,OAAgB;QAAhB,YAAO,GAAP,OAAO,CAAS;IAAG,CAAC;IAEjD,KAAK,CAAC,kBAAkB,CAAC,QAAgB;QACrC,MAAM,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,QAAQ,EAAE,2CAA2C,CAAC,EAC7G,gFAAgF,CAAC,CAAC;QACtF,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,MAAM,CACtC,CAAC,IAAI,EAAE,QAAQ,EAAE,YAAY,EAAE,eAAe,EAAE,0BAA0B,EAAE,MAAM,CAAC,EAAE,QAAQ,CAAC,CAAC;QACnG,OAAO,QAAQ,CAAC,EAAE,CAAC;IACvB,CAAC;CACJ,CAAA;AAVY,sCAAa;wBAAb,aAAa;IADzB,IAAA,sBAAU,EAAC,8BAAkB,CAAC,SAAS,CAAC;6CAEC,kBAAO;GADpC,aAAa,CAUzB","sourcesContent":["import { injectable, bindingScopeValues } from 'inversify';\n\nimport { GitExec } from './git-exec';\n\n/**\n * \"Does this branch already contain the latest `origin/main`?\" — the question both ends of the dev-deploy\n * flow ask (#1403). `wp-start-push-dev` asks it to decide whether to run the 3-point merge at all (it runs\n * ONLY when the branch is behind), and `wp-build-push-dev` asks it to refuse a copy built from a stale\n * fork point: such a copy builds against a `node_modules` missing whatever main added since, while dev\n * already contains it.\n *\n * Always FETCHES first. A local `origin/main` from last week answers \"contains main\" confidently and\n * wrongly, which is the exact staleness this check exists to catch.\n */\n@injectable(bindingScopeValues.Singleton)\nexport class MainFreshness {\n constructor(private readonly gitExec: GitExec) {}\n\n async containsLatestMain(repoRoot: string): Promise<boolean> {\n await this.gitExec.runGitChecked(['-C', repoRoot, 'fetch', 'origin', '+refs/heads/main:refs/remotes/origin/main'],\n 'Failed to fetch origin/main to check whether this branch is up to date with it');\n const contains = await this.gitExec.tryGit(\n ['-C', repoRoot, 'merge-base', '--is-ancestor', 'refs/remotes/origin/main', 'HEAD'], repoRoot);\n return contains.ok;\n }\n}\n"]}
@@ -1,53 +1,30 @@
1
1
  import { DotWebpieces } from '@webpieces/tooling-common';
2
2
  /**
3
- * WHICH flow a resolve is part of — it decides what the finish publishes (#1397).
3
+ * The persisted half of `wp-build-push-dev`'s conflict halt (#1403).
4
4
  *
5
- * - `PREBUILD` — plain `wp-push-dev`: `origin/<devBranch>` is merged into a throwaway, the dev build runs
6
- * on the merged tree, and what is published is the feature head PLUS one commit recording the resolved
7
- * files. The merge itself is never published.
8
- * - `COMPOSE` — `wp-push-dev --resolve`: the other copies are merged into a throwaway, and what is
9
- * published is the existing copy PLUS one commit recording the resolved files — never a merge parent,
10
- * so no other copy becomes an ancestor of this one and a later `--remove` of it really takes it off dev.
11
- * - `REPLAY` — `wp-push-dev --rebase-resolution`: the published copy is merged into the new local head
12
- * and that merge IS what is published, so the copy's own resolution survives the new commits.
13
- */
14
- export declare enum DevResolveMode {
15
- PREBUILD = "prebuild",
16
- COMPOSE = "compose",
17
- REPLAY = "replay"
18
- }
19
- /**
20
- * The persisted half of the `wp-push-dev --resolve` state machine.
21
- *
22
- * A single-shot wrapper is IMPOSSIBLE here and that is why this file exists: `git merge` halts on
5
+ * A single-shot command is IMPOSSIBLE here and that is why this file exists: `git merge` halts on
23
6
  * conflict with markers in the working tree and a non-zero exit, and a human or an AI has to edit files
24
7
  * before anything can be committed. So the command must be able to stop, hand the tree over, and be
25
- * resumed by a second command that knows exactly where it left off.
8
+ * resumed — by a re-run of itself — knowing exactly where it left off.
26
9
  *
27
10
  * Data-only (per CLAUDE.md) — the behaviour lives in {@link PushDevStateStore}.
28
11
  */
29
12
  export declare class PushDevState {
30
- /** The branch to return to when the resolve finishes or aborts. NEVER written to by this flow. */
13
+ /** The branch to return to when the check finishes or aborts. NEVER written to by this flow. */
31
14
  originalBranch: string;
32
- /** The local throwaway branch the merges happen on. Deleted on finish and on abort. */
15
+ /** The local throwaway branch the dev merge happens on. Deleted on finish and on abort. */
33
16
  tmpBranch: string;
34
- /** `<namespace>/<originalBranch>` — the remote copy this resolve republishes. */
17
+ /** `<namespace>/<originalBranch>` — the remote copy `wp-finish-push-dev` will publish. */
35
18
  targetRef: string;
36
- /** The copy refs still to merge, in the order CI composes them. */
37
- queue: string[];
38
- /** The ref currently mid-merge (conflicted), or '' when nothing is halted. */
39
- current: string;
40
- /** What the finish publishes — see DevResolveMode. */
41
- mode: DevResolveMode;
42
- /** The sha the published copy is built ON: the feature head (PREBUILD) or the published copy (COMPOSE). */
19
+ /** The composed dev branch merged into the throwaway, e.g. `dev`. */
20
+ devBranch: string;
21
+ /** The feature head the copy is built ON, pinned when the check started. */
43
22
  baseSha: string;
44
23
  /** Every path that conflicted and was resolved; the recorded resolution carries exactly these. */
45
24
  resolvedPaths: string[];
46
- /** The remote copy's sha when the flow started ('' = not published yet) — the push's lease. */
25
+ /** The remote copy's sha when the check started ('' = not published yet) — the publish's lease. */
47
26
  leaseSha: string;
48
- /** `--force` was given: overwrite the copy without a lease. */
49
- force: boolean;
50
- constructor(originalBranch: string, tmpBranch: string, targetRef: string, queue: string[], current?: string);
27
+ constructor(originalBranch: string, tmpBranch: string, targetRef: string, devBranch: string);
51
28
  }
52
29
  /**
53
30
  * Reads, writes and clears the resolve state file, and refuses the other `wp-*` commands while it
@@ -66,7 +43,7 @@ export declare class PushDevStateStore {
66
43
  read(repoRoot: string): PushDevState | null;
67
44
  write(repoRoot: string, state: PushDevState): void;
68
45
  clear(repoRoot: string): void;
69
- /** The read that MUST find a resolve — used by `wp-finish-push-dev`, whose whole job is resuming one. */
46
+ /** The read that MUST find a resolve — used by `wp-build-push-dev --abort`, whose whole job is ending one. */
70
47
  require(repoRoot: string): PushDevState;
71
48
  /**
72
49
  * Refuse `attempted` while a resolve is half-finished. Called from the app root for every command in
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PushDevStateStore = exports.PushDevState = exports.DevResolveMode = void 0;
3
+ exports.PushDevStateStore = exports.PushDevState = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const fs = tslib_1.__importStar(require("fs"));
6
6
  const rules_config_1 = require("@webpieces/rules-config");
@@ -9,75 +9,50 @@ const to_error_1 = require("@webpieces/tooling-common/to-error");
9
9
  const inversify_1 = require("inversify");
10
10
  const SEP = '━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n';
11
11
  /**
12
- * WHICH flow a resolve is part of — it decides what the finish publishes (#1397).
12
+ * The persisted half of `wp-build-push-dev`'s conflict halt (#1403).
13
13
  *
14
- * - `PREBUILD` — plain `wp-push-dev`: `origin/<devBranch>` is merged into a throwaway, the dev build runs
15
- * on the merged tree, and what is published is the feature head PLUS one commit recording the resolved
16
- * files. The merge itself is never published.
17
- * - `COMPOSE` — `wp-push-dev --resolve`: the other copies are merged into a throwaway, and what is
18
- * published is the existing copy PLUS one commit recording the resolved files — never a merge parent,
19
- * so no other copy becomes an ancestor of this one and a later `--remove` of it really takes it off dev.
20
- * - `REPLAY` — `wp-push-dev --rebase-resolution`: the published copy is merged into the new local head
21
- * and that merge IS what is published, so the copy's own resolution survives the new commits.
22
- */
23
- var DevResolveMode;
24
- (function (DevResolveMode) {
25
- DevResolveMode["PREBUILD"] = "prebuild";
26
- DevResolveMode["COMPOSE"] = "compose";
27
- DevResolveMode["REPLAY"] = "replay";
28
- })(DevResolveMode || (exports.DevResolveMode = DevResolveMode = {}));
29
- /**
30
- * The persisted half of the `wp-push-dev --resolve` state machine.
31
- *
32
- * A single-shot wrapper is IMPOSSIBLE here and that is why this file exists: `git merge` halts on
14
+ * A single-shot command is IMPOSSIBLE here and that is why this file exists: `git merge` halts on
33
15
  * conflict with markers in the working tree and a non-zero exit, and a human or an AI has to edit files
34
16
  * before anything can be committed. So the command must be able to stop, hand the tree over, and be
35
- * resumed by a second command that knows exactly where it left off.
17
+ * resumed — by a re-run of itself — knowing exactly where it left off.
36
18
  *
37
19
  * Data-only (per CLAUDE.md) — the behaviour lives in {@link PushDevStateStore}.
38
20
  */
39
21
  class PushDevState {
40
- /** The branch to return to when the resolve finishes or aborts. NEVER written to by this flow. */
22
+ /** The branch to return to when the check finishes or aborts. NEVER written to by this flow. */
41
23
  originalBranch;
42
- /** The local throwaway branch the merges happen on. Deleted on finish and on abort. */
24
+ /** The local throwaway branch the dev merge happens on. Deleted on finish and on abort. */
43
25
  tmpBranch;
44
- /** `<namespace>/<originalBranch>` — the remote copy this resolve republishes. */
26
+ /** `<namespace>/<originalBranch>` — the remote copy `wp-finish-push-dev` will publish. */
45
27
  targetRef;
46
- /** The copy refs still to merge, in the order CI composes them. */
47
- queue;
48
- /** The ref currently mid-merge (conflicted), or '' when nothing is halted. */
49
- current;
50
- /** What the finish publishes — see DevResolveMode. */
51
- mode = DevResolveMode.COMPOSE;
52
- /** The sha the published copy is built ON: the feature head (PREBUILD) or the published copy (COMPOSE). */
28
+ /** The composed dev branch merged into the throwaway, e.g. `dev`. */
29
+ devBranch;
30
+ /** The feature head the copy is built ON, pinned when the check started. */
53
31
  baseSha = '';
54
32
  /** Every path that conflicted and was resolved; the recorded resolution carries exactly these. */
55
33
  resolvedPaths = [];
56
- /** The remote copy's sha when the flow started ('' = not published yet) — the push's lease. */
34
+ /** The remote copy's sha when the check started ('' = not published yet) — the publish's lease. */
57
35
  leaseSha = '';
58
- /** `--force` was given: overwrite the copy without a lease. */
59
- force = false;
60
- // eslint-disable-next-line @typescript-eslint/max-params
61
- constructor(originalBranch, tmpBranch, targetRef, queue, current = '') {
36
+ constructor(originalBranch, tmpBranch, targetRef, devBranch) {
62
37
  this.originalBranch = originalBranch;
63
38
  this.tmpBranch = tmpBranch;
64
39
  this.targetRef = targetRef;
65
- this.queue = queue;
66
- this.current = current;
40
+ this.devBranch = devBranch;
67
41
  }
68
42
  }
69
43
  exports.PushDevState = PushDevState;
70
- // The wp-* commands that must REFUSE while a resolve is half-finished, and the ONE place that list is
71
- // written. The blocked-list sentence below RENDERS ITSELF from this array — the same lesson
44
+ // The wp-* commands that must REFUSE while a dev conflict is half-resolved, and the ONE place that list
45
+ // is written. The blocked-list sentence below RENDERS ITSELF from this array — the same lesson
72
46
  // merge-in-progress-guard already learned the hard way: a hand-written "don't run other commands"
73
47
  // survives every edit to the actual enforcement and ends up forbidding things the flow requires.
74
48
  //
75
- // Why these and not everything: each one either rewrites the current branch (the two starts), pushes it
76
- // (the finishes), deletes branches (cleanup), or parks the checkout on a throwaway of its own
77
- // (wp-build-dev) — and during a resolve the checkout is a throwaway
78
- // branch, not the feature branch any of them think they are acting on.
49
+ // Why these and not everything: each one either rewrites the current branch (the starts), pushes it or a
50
+ // copy of it (the finishes), or deletes branches (cleanup) — and during a resolve the checkout is a
51
+ // throwaway branch, not the feature branch any of them think they are acting on. `wp-build-push-dev`
52
+ // itself is NOT here: re-running it is how the resolve continues.
79
53
  const BLOCKED_DURING_RESOLVE = [
80
- 'wp-build-dev',
54
+ 'wp-start-push-dev',
55
+ 'wp-finish-push-dev',
81
56
  'wp-start-update',
82
57
  'wp-finish-update',
83
58
  'wp-start-upsert-pr',
@@ -112,25 +87,21 @@ let PushDevStateStore = class PushDevStateStore {
112
87
  const file = this.path(repoRoot);
113
88
  if (!fs.existsSync(file))
114
89
  return null;
115
- // webpieces-disable no-unmanaged-exceptions -- a truncated/hand-edited state file must degrade to "no resolve in progress" (recoverable via --abort or a fresh --resolve), never crash every wp-* command in the tree
90
+ // webpieces-disable no-unmanaged-exceptions -- a truncated/hand-edited state file must degrade to "no resolve in progress", never crash every wp-* command in the tree
116
91
  // eslint-disable-next-line @webpieces/no-unmanaged-exceptions
117
92
  try {
118
93
  // webpieces-disable no-any-unknown -- JSON.parse is untyped until narrowed on the next line
119
94
  const raw = JSON.parse(fs.readFileSync(file, 'utf8'));
120
95
  if (typeof raw.originalBranch !== 'string' || typeof raw.tmpBranch !== 'string')
121
96
  return null;
122
- const state = new PushDevState(raw.originalBranch, raw.tmpBranch, raw.targetRef ?? '', Array.isArray(raw.queue) ? raw.queue : [], raw.current ?? '');
123
- state.mode = Object.values(DevResolveMode).includes(raw.mode)
124
- ? raw.mode
125
- : DevResolveMode.COMPOSE;
97
+ const state = new PushDevState(raw.originalBranch, raw.tmpBranch, typeof raw.targetRef === 'string' ? raw.targetRef : '', typeof raw.devBranch === 'string' ? raw.devBranch : '');
126
98
  state.baseSha = typeof raw.baseSha === 'string' ? raw.baseSha : '';
127
99
  state.resolvedPaths = Array.isArray(raw.resolvedPaths) ? raw.resolvedPaths : [];
128
100
  state.leaseSha = typeof raw.leaseSha === 'string' ? raw.leaseSha : '';
129
- state.force = raw.force === true;
130
101
  return state;
131
102
  // The parse error carries nothing a caller could act on: the ONLY meaningful reading of an
132
- // unparseable state file is "no resolve in progress", which --abort and a fresh --resolve both
133
- // recover from.
103
+ // unparseable state file is "no resolve in progress".
104
+ // webpieces-disable catch-must-propagate -- an unparseable state file means no resolve is in progress; the parse error carries nothing a caller could act on
134
105
  }
135
106
  catch (err) {
136
107
  const error = (0, to_error_1.toError)(err);
@@ -147,7 +118,7 @@ let PushDevStateStore = class PushDevStateStore {
147
118
  if (fs.existsSync(file))
148
119
  fs.rmSync(file);
149
120
  }
150
- /** The read that MUST find a resolve — used by `wp-finish-push-dev`, whose whole job is resuming one. */
121
+ /** The read that MUST find a resolve — used by `wp-build-push-dev --abort`, whose whole job is ending one. */
151
122
  require(repoRoot) {
152
123
  const state = this.read(repoRoot);
153
124
  if (state !== null)
@@ -157,10 +128,8 @@ let PushDevStateStore = class PushDevStateStore {
157
128
  '⛔ No dev-deploy resolve is in progress\n' +
158
129
  SEP +
159
130
  '\n' +
160
- `${rules_config_1.WP_FINISH_PUSH_DEV} resumes a resolve that \`${rules_config_1.WP_PUSH_DEV} --resolve\` started, and there is no\n` +
161
- `state file at:\n ${this.path(repoRoot)}\n\n` +
162
- 'If you meant to publish your branch to the shared dev server, that is the one-command form:\n' +
163
- ` ${rules_config_1.WP_PUSH_DEV}\n`);
131
+ `\`${rules_config_1.WP_BUILD_PUSH_DEV} --abort\` throws away a conflict resolution that \`${rules_config_1.WP_BUILD_PUSH_DEV}\` stopped on,\n` +
132
+ `and there is no state file at:\n ${this.path(repoRoot)}\n\nThere is nothing to abort.\n`);
164
133
  }
165
134
  /**
166
135
  * Refuse `attempted` while a resolve is half-finished. Called from the app root for every command in
@@ -179,9 +148,9 @@ let PushDevStateStore = class PushDevStateStore {
179
148
  `so ${this.blockedCommandList()} would all act on the wrong branch.\n` +
180
149
  'That is the whole list; nothing else is blocked.\n\n' +
181
150
  'EXPECTED of you right now, and NOT blocked: read the conflicted files and edit them until every\n' +
182
- 'conflict marker is gone. Then finish or bail out:\n' +
183
- ` ${rules_config_1.WP_FINISH_PUSH_DEV} ← commit the resolution, resume the queue, publish the copy\n` +
184
- ` ${rules_config_1.WP_FINISH_PUSH_DEV} --abort ← throw the resolution away and go back to \`${state.originalBranch}\`\n\n` +
151
+ 'conflict marker is gone, and `git add` each one. Then continue or bail out:\n' +
152
+ ` ${rules_config_1.WP_BUILD_PUSH_DEV} ← commit the resolution, pnpm install, run the dev build\n` +
153
+ ` ${rules_config_1.WP_BUILD_PUSH_DEV} --abort ← throw the resolution away and go back to \`${state.originalBranch}\`\n\n` +
185
154
  `State file: ${this.path(repoRoot)}\n`);
186
155
  }
187
156
  // Rendered from BLOCKED_DURING_RESOLVE, never hand-written — see that constant.
@@ -1 +1 @@
1
- {"version":3,"file":"push-dev-state.js","sourceRoot":"","sources":["../../../../../../../packages/tooling/pr-gate/src/scripts/workflow/push-dev-state.ts"],"names":[],"mappings":";;;;AAAA,+CAAyB;AAEzB,0DAA6G;AAC7G,8DAAyD;AACzD,iEAA6D;AAC7D,yCAA2D;AAE3D,MAAM,GAAG,GAAG,0DAA0D,CAAC;AAEvE;;;;;;;;;;;GAWG;AACH,IAAY,cAIX;AAJD,WAAY,cAAc;IACtB,uCAAqB,CAAA;IACrB,qCAAmB,CAAA;IACnB,mCAAiB,CAAA;AACrB,CAAC,EAJW,cAAc,8BAAd,cAAc,QAIzB;AAED;;;;;;;;;GASG;AACH,MAAa,YAAY;IACrB,kGAAkG;IAClG,cAAc,CAAS;IACvB,uFAAuF;IACvF,SAAS,CAAS;IAClB,iFAAiF;IACjF,SAAS,CAAS;IAClB,mEAAmE;IACnE,KAAK,CAAW;IAChB,8EAA8E;IAC9E,OAAO,CAAS;IAChB,sDAAsD;IACtD,IAAI,GAAmB,cAAc,CAAC,OAAO,CAAC;IAC9C,2GAA2G;IAC3G,OAAO,GAAG,EAAE,CAAC;IACb,kGAAkG;IAClG,aAA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AC,QAAQ,CAAC,MAAM;YAC9C,+FAA+F;YAC/F,KAAK,0BAAW,IAAI,CAC3B,CAAC;IACN,CAAC;IAED;;;OAGG;IACH,UAAU,CAAC,QAAgB,EAAE,SAAiB;QAC1C,MAAM,KAAK,GAAG,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAClC,IAAI,KAAK,KAAK,IAAI;YAAE,OAAO;QAC3B,MAAM,IAAI,2BAAY,CAClB,CAAC,EACD,IAAI;YACA,GAAG;YACH,kDAAkD,SAAS,iBAAiB;YAC5E,GAAG;YACH,IAAI;YACJ,8CAA8C,KAAK,CAAC,SAAS,gBAAgB,KAAK,CAAC,cAAc,OAAO;YACxG,MAAM,IAAI,CAAC,kBAAkB,EAAE,uCAAuC;YACtE,sDAAsD;YACtD,mGAAmG;YACnG,qDAAqD;YACrD,KAAK,iCAAkB,2EAA2E;YAClG,KAAK,iCAAkB,4DAA4D,KAAK,CAAC,cAAc,QAAQ;YAC/G,eAAe,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAC7C,CAAC;IACN,CAAC;IAED,gFAAgF;IACxE,kBAAkB;QACtB,OAAO,sBAAsB,CAAC,GAAG,CAAC,CAAC,CAAS,EAAU,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACzF,CAAC;IAED,uFAAuF;IACvF,sBAAsB,CAAC,OAAe;QAClC,OAAO,sBAAsB,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;IACpD,CAAC;CACJ,CAAA;AA7GY,8CAAiB;4BAAjB,iBAAiB;IAD7B,IAAA,sBAAU,EAAC,8BAAkB,CAAC,SAAS,CAAC;6CAEM,6BAAY;GAD9C,iBAAiB,CA6G7B","sourcesContent":["import * as fs from 'fs';\n\nimport { CliExitError, PUSH_DEV_STATE_FILE, WP_FINISH_PUSH_DEV, WP_PUSH_DEV } from '@webpieces/rules-config';\nimport { DotWebpieces } from '@webpieces/tooling-common';\nimport { toError } from '@webpieces/tooling-common/to-error';\nimport { injectable, bindingScopeValues } from 'inversify';\n\nconst SEP = '━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\\n';\n\n/**\n * WHICH flow a resolve is part of — it decides what the finish publishes (#1397).\n *\n * - `PREBUILD` — plain `wp-push-dev`: `origin/<devBranch>` is merged into a throwaway, the dev build runs\n * on the merged tree, and what is published is the feature head PLUS one commit recording the resolved\n * files. The merge itself is never published.\n * - `COMPOSE` — `wp-push-dev --resolve`: the other copies are merged into a throwaway, and what is\n * published is the existing copy PLUS one commit recording the resolved files — never a merge parent,\n * so no other copy becomes an ancestor of this one and a later `--remove` of it really takes it off dev.\n * - `REPLAY` — `wp-push-dev --rebase-resolution`: the published copy is merged into the new local head\n * and that merge IS what is published, so the copy's own resolution survives the new commits.\n */\nexport enum DevResolveMode {\n PREBUILD = 'prebuild',\n COMPOSE = 'compose',\n REPLAY = 'replay',\n}\n\n/**\n * The persisted half of the `wp-push-dev --resolve` state machine.\n *\n * A single-shot wrapper is IMPOSSIBLE here and that is why this file exists: `git merge` halts on\n * conflict with markers in the working tree and a non-zero exit, and a human or an AI has to edit files\n * before anything can be committed. So the command must be able to stop, hand the tree over, and be\n * resumed by a second command that knows exactly where it left off.\n *\n * Data-only (per CLAUDE.md) — the behaviour lives in {@link PushDevStateStore}.\n */\nexport class PushDevState {\n /** The branch to return to when the resolve finishes or aborts. NEVER written to by this flow. */\n originalBranch: string;\n /** The local throwaway branch the merges happen on. Deleted on finish and on abort. */\n tmpBranch: string;\n /** `<namespace>/<originalBranch>` — the remote copy this resolve republishes. */\n targetRef: string;\n /** The copy refs still to merge, in the order CI composes them. */\n queue: string[];\n /** The ref currently mid-merge (conflicted), or '' when nothing is halted. */\n current: string;\n /** What the finish publishes — see DevResolveMode. */\n mode: DevResolveMode = DevResolveMode.COMPOSE;\n /** The sha the published copy is built ON: the feature head (PREBUILD) or the published copy (COMPOSE). */\n baseSha = '';\n /** Every path that conflicted and was resolved; the recorded resolution carries exactly these. */\n resolvedPaths: string[] = [];\n /** The remote copy's sha when the flow started ('' = not published yet) — the push's lease. */\n leaseSha = '';\n /** `--force` was given: overwrite the copy without a lease. */\n force = false;\n\n // eslint-disable-next-line @typescript-eslint/max-params\n constructor(\n originalBranch: string,\n tmpBranch: string,\n targetRef: string,\n queue: string[],\n current = '',\n ) {\n this.originalBranch = originalBranch;\n this.tmpBranch = tmpBranch;\n this.targetRef = targetRef;\n this.queue = queue;\n this.current = current;\n }\n}\n\n// The wp-* commands that must REFUSE while a resolve is half-finished, and the ONE place that list is\n// written. The blocked-list sentence below RENDERS ITSELF from this array — the same lesson\n// merge-in-progress-guard already learned the hard way: a hand-written \"don't run other commands\"\n// survives every edit to the actual enforcement and ends up forbidding things the flow requires.\n//\n// Why these and not everything: each one either rewrites the current branch (the two starts), pushes it\n// (the finishes), deletes branches (cleanup), or parks the checkout on a throwaway of its own\n// (wp-build-dev) — and during a resolve the checkout is a throwaway\n// branch, not the feature branch any of them think they are acting on.\nconst BLOCKED_DURING_RESOLVE: readonly string[] = [\n 'wp-build-dev',\n 'wp-start-update',\n 'wp-finish-update',\n 'wp-start-upsert-pr',\n 'wp-review-upsert-pr',\n 'wp-finish-upsert-pr',\n 'wp-human-post-pr',\n 'wp-upsert-hotfix-pr',\n 'wp-land-pr',\n 'wp-cleanup',\n];\n\n/**\n * Reads, writes and clears the resolve state file, and refuses the other `wp-*` commands while it\n * exists.\n *\n * LOCAL scope, deliberately: a resolve halts one worktree's checkout on a throwaway branch, and another\n * worktree has no reason to care. Sharing it would block a colleague's PR flow on state that says\n * nothing about their tree.\n */\n@injectable(bindingScopeValues.Singleton)\nexport class PushDevStateStore {\n constructor(private readonly dotWebpieces: DotWebpieces) {}\n\n path(repoRoot: string): string {\n return this.dotWebpieces.localFile(repoRoot, PUSH_DEV_STATE_FILE);\n }\n\n exists(repoRoot: string): boolean {\n return fs.existsSync(this.path(repoRoot));\n }\n\n /** The in-flight resolve, or null when none is. A corrupt file reads as null rather than crashing. */\n read(repoRoot: string): PushDevState | null {\n const file = this.path(repoRoot);\n if (!fs.existsSync(file)) return null;\n // webpieces-disable no-unmanaged-exceptions -- a truncated/hand-edited state file must degrade to \"no resolve in progress\" (recoverable via --abort or a fresh --resolve), never crash every wp-* command in the tree\n // eslint-disable-next-line @webpieces/no-unmanaged-exceptions\n try {\n // webpieces-disable no-any-unknown -- JSON.parse is untyped until narrowed on the next line\n const raw = JSON.parse(fs.readFileSync(file, 'utf8')) as Partial<PushDevState>;\n if (typeof raw.originalBranch !== 'string' || typeof raw.tmpBranch !== 'string')\n return null;\n const state = new PushDevState(\n raw.originalBranch,\n raw.tmpBranch,\n raw.targetRef ?? '',\n Array.isArray(raw.queue) ? raw.queue : [],\n raw.current ?? '',\n );\n state.mode = Object.values(DevResolveMode).includes(raw.mode as DevResolveMode)\n ? (raw.mode as DevResolveMode)\n : DevResolveMode.COMPOSE;\n state.baseSha = typeof raw.baseSha === 'string' ? raw.baseSha : '';\n state.resolvedPaths = Array.isArray(raw.resolvedPaths) ? raw.resolvedPaths : [];\n state.leaseSha = typeof raw.leaseSha === 'string' ? raw.leaseSha : '';\n state.force = raw.force === true;\n return state;\n // The parse error carries nothing a caller could act on: the ONLY meaningful reading of an\n // unparseable state file is \"no resolve in progress\", which --abort and a fresh --resolve both\n // recover from.\n } catch (err: unknown) {\n const error = toError(err);\n void error;\n return null;\n }\n }\n\n write(repoRoot: string, state: PushDevState): void {\n fs.mkdirSync(this.dotWebpieces.local(repoRoot), { recursive: true });\n fs.writeFileSync(this.path(repoRoot), JSON.stringify(state, null, 2) + '\\n', 'utf8');\n }\n\n clear(repoRoot: string): void {\n const file = this.path(repoRoot);\n if (fs.existsSync(file)) fs.rmSync(file);\n }\n\n /** The read that MUST find a resolve — used by `wp-finish-push-dev`, whose whole job is resuming one. */\n require(repoRoot: string): PushDevState {\n const state = this.read(repoRoot);\n if (state !== null) return state;\n throw new CliExitError(\n 2,\n '\\n' +\n SEP +\n '⛔ No dev-deploy resolve is in progress\\n' +\n SEP +\n '\\n' +\n `${WP_FINISH_PUSH_DEV} resumes a resolve that \\`${WP_PUSH_DEV} --resolve\\` started, and there is no\\n` +\n `state file at:\\n ${this.path(repoRoot)}\\n\\n` +\n 'If you meant to publish your branch to the shared dev server, that is the one-command form:\\n' +\n ` ${WP_PUSH_DEV}\\n`,\n );\n }\n\n /**\n * Refuse `attempted` while a resolve is half-finished. Called from the app root for every command in\n * {@link BLOCKED_DURING_RESOLVE}, so no individual command has to remember to ask.\n */\n assertIdle(repoRoot: string, attempted: string): void {\n const state = this.read(repoRoot);\n if (state === null) return;\n throw new CliExitError(\n 2,\n '\\n' +\n SEP +\n `⛔ A dev-deploy resolve is in progress — \\`pnpm ${attempted}\\` is blocked\\n` +\n SEP +\n '\\n' +\n `You are standing on the throwaway branch \\`${state.tmpBranch}\\`, not on \\`${state.originalBranch}\\`,\\n` +\n `so ${this.blockedCommandList()} would all act on the wrong branch.\\n` +\n 'That is the whole list; nothing else is blocked.\\n\\n' +\n 'EXPECTED of you right now, and NOT blocked: read the conflicted files and edit them until every\\n' +\n 'conflict marker is gone. Then finish or bail out:\\n' +\n ` ${WP_FINISH_PUSH_DEV} ← commit the resolution, resume the queue, publish the copy\\n` +\n ` ${WP_FINISH_PUSH_DEV} --abort ← throw the resolution away and go back to \\`${state.originalBranch}\\`\\n\\n` +\n `State file: ${this.path(repoRoot)}\\n`,\n );\n }\n\n // Rendered from BLOCKED_DURING_RESOLVE, never hand-written — see that constant.\n private blockedCommandList(): string {\n return BLOCKED_DURING_RESOLVE.map((c: string): string => `\\`pnpm ${c}\\``).join(', ');\n }\n\n /** Is `command` one of the ones that must refuse mid-resolve? Used by the app root. */\n isBlockedDuringResolve(command: string): boolean {\n return BLOCKED_DURING_RESOLVE.includes(command);\n }\n}\n"]}
1
+ {"version":3,"file":"push-dev-state.js","sourceRoot":"","sources":["../../../../../../../packages/tooling/pr-gate/src/scrip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B,kBAAkB;YAChH,qCAAqC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,kCAAkC,CACjG,CAAC;IACN,CAAC;IAED;;;OAGG;IACH,UAAU,CAAC,QAAgB,EAAE,SAAiB;QAC1C,MAAM,KAAK,GAAG,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAClC,IAAI,KAAK,KAAK,IAAI;YAAE,OAAO;QAC3B,MAAM,IAAI,2BAAY,CAClB,CAAC,EACD,IAAI;YACA,GAAG;YACH,kDAAkD,SAAS,iBAAiB;YAC5E,GAAG;YACH,IAAI;YACJ,8CAA8C,KAAK,CAAC,SAAS,gBAAgB,KAAK,CAAC,cAAc,OAAO;YACxG,MAAM,IAAI,CAAC,kBAAkB,EAAE,uCAAuC;YACtE,sDAAsD;YACtD,mGAAmG;YACnG,+EAA+E;YAC/E,KAAK,gCAAiB,wEAAwE;YAC9F,KAAK,gCAAiB,4DAA4D,KAAK,CAAC,cAAc,QAAQ;YAC9G,eAAe,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAC7C,CAAC;IACN,CAAC;IAED,gFAAgF;IACxE,kBAAkB;QACtB,OAAO,sBAAsB,CAAC,GAAG,CAAC,CAAC,CAAS,EAAU,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACzF,CAAC;IAED,uFAAuF;IACvF,sBAAsB,CAAC,OAAe;QAClC,OAAO,sBAAsB,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;IACpD,CAAC;CACJ,CAAA;AAtGY,8CAAiB;4BAAjB,iBAAiB;IAD7B,IAAA,sBAAU,EAAC,8BAAkB,CAAC,SAAS,CAAC;6CAEM,6BAAY;GAD9C,iBAAiB,CAsG7B","sourcesContent":["import * as fs from 'fs';\n\nimport { CliExitError, PUSH_DEV_STATE_FILE, WP_BUILD_PUSH_DEV } from '@webpieces/rules-config';\nimport { DotWebpieces } from '@webpieces/tooling-common';\nimport { toError } from '@webpieces/tooling-common/to-error';\nimport { injectable, bindingScopeValues } from 'inversify';\n\nconst SEP = '━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\\n';\n\n/**\n * The persisted half of `wp-build-push-dev`'s conflict halt (#1403).\n *\n * A single-shot command is IMPOSSIBLE here and that is why this file exists: `git merge` halts on\n * conflict with markers in the working tree and a non-zero exit, and a human or an AI has to edit files\n * before anything can be committed. So the command must be able to stop, hand the tree over, and be\n * resumed — by a re-run of itself — knowing exactly where it left off.\n *\n * Data-only (per CLAUDE.md) — the behaviour lives in {@link PushDevStateStore}.\n */\nexport class PushDevState {\n /** The branch to return to when the check finishes or aborts. NEVER written to by this flow. */\n originalBranch: string;\n /** The local throwaway branch the dev merge happens on. Deleted on finish and on abort. */\n tmpBranch: string;\n /** `<namespace>/<originalBranch>` — the remote copy `wp-finish-push-dev` will publish. */\n targetRef: string;\n /** The composed dev branch merged into the throwaway, e.g. `dev`. */\n devBranch: string;\n /** The feature head the copy is built ON, pinned when the check started. */\n baseSha = '';\n /** Every path that conflicted and was resolved; the recorded resolution carries exactly these. */\n resolvedPaths: string[] = [];\n /** The remote copy's sha when the check started ('' = not published yet) — the publish's lease. */\n leaseSha = '';\n\n constructor(originalBranch: string, tmpBranch: string, targetRef: string, devBranch: string) {\n this.originalBranch = originalBranch;\n this.tmpBranch = tmpBranch;\n this.targetRef = targetRef;\n this.devBranch = devBranch;\n }\n}\n\n// The wp-* commands that must REFUSE while a dev conflict is half-resolved, and the ONE place that list\n// is written. The blocked-list sentence below RENDERS ITSELF from this array — the same lesson\n// merge-in-progress-guard already learned the hard way: a hand-written \"don't run other commands\"\n// survives every edit to the actual enforcement and ends up forbidding things the flow requires.\n//\n// Why these and not everything: each one either rewrites the current branch (the starts), pushes it or a\n// copy of it (the finishes), or deletes branches (cleanup) — and during a resolve the checkout is a\n// throwaway branch, not the feature branch any of them think they are acting on. `wp-build-push-dev`\n// itself is NOT here: re-running it is how the resolve continues.\nconst BLOCKED_DURING_RESOLVE: readonly string[] = [\n 'wp-start-push-dev',\n 'wp-finish-push-dev',\n 'wp-start-update',\n 'wp-finish-update',\n 'wp-start-upsert-pr',\n 'wp-review-upsert-pr',\n 'wp-finish-upsert-pr',\n 'wp-human-post-pr',\n 'wp-upsert-hotfix-pr',\n 'wp-land-pr',\n 'wp-cleanup',\n];\n\n/**\n * Reads, writes and clears the resolve state file, and refuses the other `wp-*` commands while it\n * exists.\n *\n * LOCAL scope, deliberately: a resolve halts one worktree's checkout on a throwaway branch, and another\n * worktree has no reason to care. Sharing it would block a colleague's PR flow on state that says\n * nothing about their tree.\n */\n@injectable(bindingScopeValues.Singleton)\nexport class PushDevStateStore {\n constructor(private readonly dotWebpieces: DotWebpieces) {}\n\n path(repoRoot: string): string {\n return this.dotWebpieces.localFile(repoRoot, PUSH_DEV_STATE_FILE);\n }\n\n exists(repoRoot: string): boolean {\n return fs.existsSync(this.path(repoRoot));\n }\n\n /** The in-flight resolve, or null when none is. A corrupt file reads as null rather than crashing. */\n read(repoRoot: string): PushDevState | null {\n const file = this.path(repoRoot);\n if (!fs.existsSync(file)) return null;\n // webpieces-disable no-unmanaged-exceptions -- a truncated/hand-edited state file must degrade to \"no resolve in progress\", never crash every wp-* command in the tree\n // eslint-disable-next-line @webpieces/no-unmanaged-exceptions\n try {\n // webpieces-disable no-any-unknown -- JSON.parse is untyped until narrowed on the next line\n const raw = JSON.parse(fs.readFileSync(file, 'utf8')) as Partial<PushDevState>;\n if (typeof raw.originalBranch !== 'string' || typeof raw.tmpBranch !== 'string')\n return null;\n const state = new PushDevState(\n raw.originalBranch,\n raw.tmpBranch,\n typeof raw.targetRef === 'string' ? raw.targetRef : '',\n typeof raw.devBranch === 'string' ? raw.devBranch : '',\n );\n state.baseSha = typeof raw.baseSha === 'string' ? raw.baseSha : '';\n state.resolvedPaths = Array.isArray(raw.resolvedPaths) ? raw.resolvedPaths : [];\n state.leaseSha = typeof raw.leaseSha === 'string' ? raw.leaseSha : '';\n return state;\n // The parse error carries nothing a caller could act on: the ONLY meaningful reading of an\n // unparseable state file is \"no resolve in progress\".\n // webpieces-disable catch-must-propagate -- an unparseable state file means no resolve is in progress; the parse error carries nothing a caller could act on\n } catch (err: unknown) {\n const error = toError(err);\n void error;\n return null;\n }\n }\n\n write(repoRoot: string, state: PushDevState): void {\n fs.mkdirSync(this.dotWebpieces.local(repoRoot), { recursive: true });\n fs.writeFileSync(this.path(repoRoot), JSON.stringify(state, null, 2) + '\\n', 'utf8');\n }\n\n clear(repoRoot: string): void {\n const file = this.path(repoRoot);\n if (fs.existsSync(file)) fs.rmSync(file);\n }\n\n /** The read that MUST find a resolve — used by `wp-build-push-dev --abort`, whose whole job is ending one. */\n require(repoRoot: string): PushDevState {\n const state = this.read(repoRoot);\n if (state !== null) return state;\n throw new CliExitError(\n 2,\n '\\n' +\n SEP +\n '⛔ No dev-deploy resolve is in progress\\n' +\n SEP +\n '\\n' +\n `\\`${WP_BUILD_PUSH_DEV} --abort\\` throws away a conflict resolution that \\`${WP_BUILD_PUSH_DEV}\\` stopped on,\\n` +\n `and there is no state file at:\\n ${this.path(repoRoot)}\\n\\nThere is nothing to abort.\\n`,\n );\n }\n\n /**\n * Refuse `attempted` while a resolve is half-finished. Called from the app root for every command in\n * {@link BLOCKED_DURING_RESOLVE}, so no individual command has to remember to ask.\n */\n assertIdle(repoRoot: string, attempted: string): void {\n const state = this.read(repoRoot);\n if (state === null) return;\n throw new CliExitError(\n 2,\n '\\n' +\n SEP +\n `⛔ A dev-deploy resolve is in progress — \\`pnpm ${attempted}\\` is blocked\\n` +\n SEP +\n '\\n' +\n `You are standing on the throwaway branch \\`${state.tmpBranch}\\`, not on \\`${state.originalBranch}\\`,\\n` +\n `so ${this.blockedCommandList()} would all act on the wrong branch.\\n` +\n 'That is the whole list; nothing else is blocked.\\n\\n' +\n 'EXPECTED of you right now, and NOT blocked: read the conflicted files and edit them until every\\n' +\n 'conflict marker is gone, and `git add` each one. Then continue or bail out:\\n' +\n ` ${WP_BUILD_PUSH_DEV} ← commit the resolution, pnpm install, run the dev build\\n` +\n ` ${WP_BUILD_PUSH_DEV} --abort ← throw the resolution away and go back to \\`${state.originalBranch}\\`\\n\\n` +\n `State file: ${this.path(repoRoot)}\\n`,\n );\n }\n\n // Rendered from BLOCKED_DURING_RESOLVE, never hand-written — see that constant.\n private blockedCommandList(): string {\n return BLOCKED_DURING_RESOLVE.map((c: string): string => `\\`pnpm ${c}\\``).join(', ');\n }\n\n /** Is `command` one of the ones that must refuse mid-resolve? Used by the app root. */\n isBlockedDuringResolve(command: string): boolean {\n return BLOCKED_DURING_RESOLVE.includes(command);\n }\n}\n"]}
@@ -0,0 +1,46 @@
1
+ import { DotWebpieces } from '@webpieces/tooling-common';
2
+ /** The local state file stage ② writes and stage ③ consumes. LOCAL scope: one worktree's verification. */
3
+ export declare const PUSH_DEV_VERIFIED_FILE = "push-dev-verified.json";
4
+ /**
5
+ * What `wp-build-push-dev` (stage ②) verified, for `wp-finish-push-dev` (stage ③) to publish (#1403).
6
+ *
7
+ * The same hand-off the PR flow makes between `wp-review-upsert-pr` and `wp-finish-upsert-pr`: stage ②
8
+ * records the sha it built, and stage ③ refuses when HEAD moved since — so what is published is exactly
9
+ * what was checked against dev and built, never a later commit nobody built.
10
+ *
11
+ * Data-only (per CLAUDE.md) — the behaviour lives in {@link VerifiedDevCopyStore}.
12
+ */
13
+ export declare class VerifiedDevCopy {
14
+ /** The feature branch that was verified. */
15
+ branch: string;
16
+ /** The feature head the copy is built on. Stage ③ refuses when HEAD is no longer this. */
17
+ headSha: string;
18
+ /** What stage ③ publishes: `headSha`, or `headSha` plus ONE commit recording the resolved files. */
19
+ copySha: string;
20
+ /** `<namespace>/<branch>` — where stage ③ publishes. */
21
+ targetRef: string;
22
+ /** The remote copy's sha when stage ② ran ('' = not published yet) — stage ③'s push lease. */
23
+ leaseSha: string;
24
+ /** The `origin/<devBranch>` sha the copy was merged with and built against; '' when dev did not exist. */
25
+ devSha: string;
26
+ constructor(branch: string, headSha: string, copySha: string, targetRef: string, leaseSha: string, devSha: string);
27
+ }
28
+ /**
29
+ * Reads, writes and clears the stage-② record. A missing or unreadable record reads as null, which stage ③
30
+ * turns into "run `pnpm wp-build-push-dev` first".
31
+ */
32
+ export declare class VerifiedDevCopyStore {
33
+ private readonly dotWebpieces;
34
+ constructor(dotWebpieces: DotWebpieces);
35
+ path(repoRoot: string): string;
36
+ /**
37
+ * The local ref that keeps the verified copy reachable between stage ② and stage ③. When something
38
+ * conflicted, the copy is a commit on top of the feature head that no branch points at; without a ref
39
+ * holding it, `git gc` could collect it before it is published. Outside `refs/heads/`, so it is never
40
+ * mistaken for a branch (and never counts toward the branch cap or reaches `wp-cleanup`).
41
+ */
42
+ keepRef(branch: string): string;
43
+ read(repoRoot: string): VerifiedDevCopy | null;
44
+ write(repoRoot: string, record: VerifiedDevCopy): void;
45
+ clear(repoRoot: string): void;
46
+ }
@@ -0,0 +1,89 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.VerifiedDevCopyStore = exports.VerifiedDevCopy = exports.PUSH_DEV_VERIFIED_FILE = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const fs = tslib_1.__importStar(require("fs"));
6
+ const tooling_common_1 = require("@webpieces/tooling-common");
7
+ const inversify_1 = require("inversify");
8
+ /** The local state file stage ② writes and stage ③ consumes. LOCAL scope: one worktree's verification. */
9
+ exports.PUSH_DEV_VERIFIED_FILE = 'push-dev-verified.json';
10
+ /**
11
+ * What `wp-build-push-dev` (stage ②) verified, for `wp-finish-push-dev` (stage ③) to publish (#1403).
12
+ *
13
+ * The same hand-off the PR flow makes between `wp-review-upsert-pr` and `wp-finish-upsert-pr`: stage ②
14
+ * records the sha it built, and stage ③ refuses when HEAD moved since — so what is published is exactly
15
+ * what was checked against dev and built, never a later commit nobody built.
16
+ *
17
+ * Data-only (per CLAUDE.md) — the behaviour lives in {@link VerifiedDevCopyStore}.
18
+ */
19
+ class VerifiedDevCopy {
20
+ /** The feature branch that was verified. */
21
+ branch;
22
+ /** The feature head the copy is built on. Stage ③ refuses when HEAD is no longer this. */
23
+ headSha;
24
+ /** What stage ③ publishes: `headSha`, or `headSha` plus ONE commit recording the resolved files. */
25
+ copySha;
26
+ /** `<namespace>/<branch>` — where stage ③ publishes. */
27
+ targetRef;
28
+ /** The remote copy's sha when stage ② ran ('' = not published yet) — stage ③'s push lease. */
29
+ leaseSha;
30
+ /** The `origin/<devBranch>` sha the copy was merged with and built against; '' when dev did not exist. */
31
+ devSha;
32
+ constructor(branch, headSha, copySha, targetRef, leaseSha, devSha) {
33
+ this.branch = branch;
34
+ this.headSha = headSha;
35
+ this.copySha = copySha;
36
+ this.targetRef = targetRef;
37
+ this.leaseSha = leaseSha;
38
+ this.devSha = devSha;
39
+ }
40
+ }
41
+ exports.VerifiedDevCopy = VerifiedDevCopy;
42
+ /**
43
+ * Reads, writes and clears the stage-② record. A missing or unreadable record reads as null, which stage ③
44
+ * turns into "run `pnpm wp-build-push-dev` first".
45
+ */
46
+ let VerifiedDevCopyStore = class VerifiedDevCopyStore {
47
+ dotWebpieces;
48
+ constructor(dotWebpieces) {
49
+ this.dotWebpieces = dotWebpieces;
50
+ }
51
+ path(repoRoot) {
52
+ return this.dotWebpieces.localFile(repoRoot, exports.PUSH_DEV_VERIFIED_FILE);
53
+ }
54
+ /**
55
+ * The local ref that keeps the verified copy reachable between stage ② and stage ③. When something
56
+ * conflicted, the copy is a commit on top of the feature head that no branch points at; without a ref
57
+ * holding it, `git gc` could collect it before it is published. Outside `refs/heads/`, so it is never
58
+ * mistaken for a branch (and never counts toward the branch cap or reaches `wp-cleanup`).
59
+ */
60
+ keepRef(branch) {
61
+ return `refs/webpieces/push-dev/${branch}`;
62
+ }
63
+ read(repoRoot) {
64
+ const file = this.path(repoRoot);
65
+ if (!fs.existsSync(file))
66
+ return null;
67
+ // webpieces-disable no-any-unknown -- JSON.parse is untyped until narrowed on the next line
68
+ const raw = JSON.parse(fs.readFileSync(file, 'utf8'));
69
+ const fields = [raw.branch, raw.headSha, raw.copySha, raw.targetRef, raw.leaseSha, raw.devSha];
70
+ if (!fields.every((f) => typeof f === 'string'))
71
+ return null;
72
+ return new VerifiedDevCopy(raw.branch, raw.headSha, raw.copySha, raw.targetRef, raw.leaseSha, raw.devSha);
73
+ }
74
+ write(repoRoot, record) {
75
+ fs.mkdirSync(this.dotWebpieces.local(repoRoot), { recursive: true });
76
+ fs.writeFileSync(this.path(repoRoot), JSON.stringify(record, null, 2) + '\n', 'utf8');
77
+ }
78
+ clear(repoRoot) {
79
+ const file = this.path(repoRoot);
80
+ if (fs.existsSync(file))
81
+ fs.rmSync(file);
82
+ }
83
+ };
84
+ exports.VerifiedDevCopyStore = VerifiedDevCopyStore;
85
+ exports.VerifiedDevCopyStore = VerifiedDevCopyStore = tslib_1.__decorate([
86
+ (0, inversify_1.injectable)(inversify_1.bindingScopeValues.Singleton),
87
+ tslib_1.__metadata("design:paramtypes", [tooling_common_1.DotWebpieces])
88
+ ], VerifiedDevCopyStore);
89
+ //# sourceMappingURL=verified-dev-copy.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"verified-dev-copy.js","sourceRoot":"","sources":["../../../../../../../packages/tooling/pr-gate/src/scripts/workflow/verified-dev-copy.ts"],"names":[],"mappings":";;;;AAAA,+CAAyB;AAEzB,8DAAyD;AACzD,yCAA2D;AAE3D,0GAA0G;AAC7F,QAAA,sBAAsB,GAAG,wBAAwB,CAAC;AAE/D;;;;;;;;GAQG;AACH,MAAa,eAAe;IACxB,4CAA4C;IAC5C,MAAM,CAAS;IACf,0FAA0F;IAC1F,OAAO,CAAS;IAChB,oGAAoG;IACpG,OAAO,CAAS;IAChB,wDAAwD;IACxD,SAAS,CAAS;IAClB,8FAA8F;IAC9F,QAAQ,CAAS;IACjB,0GAA0G;IAC1G,MAAM,CAAS;IAEf,YAAY,MAAc,EAAE,OAAe,EAAE,OAAe,EAAE,SAAi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,CAAC;YAAE,OAAO,IAAI,CAAC;QAC1F,OAAO,IAAI,eAAe,CACtB,GAAG,CAAC,MAAgB,EAAE,GAAG,CAAC,OAAiB,EAAE,GAAG,CAAC,OAAiB,EAClE,GAAG,CAAC,SAAmB,EAAE,GAAG,CAAC,QAAkB,EAAE,GAAG,CAAC,MAAgB,CACxE,CAAC;IACN,CAAC;IAED,KAAK,CAAC,QAAgB,EAAE,MAAuB;QAC3C,EAAE,CAAC,SAAS,CAAC,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,QAAQ,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QACrE,EAAE,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,GAAG,IAAI,EAAE,MAAM,CAAC,CAAC;IAC1F,CAAC;IAED,KAAK,CAAC,QAAgB;QAClB,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QACjC,IAAI,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC;YAAE,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IAC7C,CAAC;CACJ,CAAA;AAvCY,oDAAoB;+BAApB,oBAAoB;IADhC,IAAA,sBAAU,EAAC,8BAAkB,CAAC,SAAS,CAAC;6CAEM,6BAAY;GAD9C,oBAAoB,CAuChC","sourcesContent":["import * as fs from 'fs';\n\nimport { DotWebpieces } from '@webpieces/tooling-common';\nimport { injectable, bindingScopeValues } from 'inversify';\n\n/** The local state file stage ② writes and stage ③ consumes. LOCAL scope: one worktree's verification. */\nexport const PUSH_DEV_VERIFIED_FILE = 'push-dev-verified.json';\n\n/**\n * What `wp-build-push-dev` (stage ②) verified, for `wp-finish-push-dev` (stage ③) to publish (#1403).\n *\n * The same hand-off the PR flow makes between `wp-review-upsert-pr` and `wp-finish-upsert-pr`: stage ②\n * records the sha it built, and stage ③ refuses when HEAD moved since — so what is published is exactly\n * what was checked against dev and built, never a later commit nobody built.\n *\n * Data-only (per CLAUDE.md) — the behaviour lives in {@link VerifiedDevCopyStore}.\n */\nexport class VerifiedDevCopy {\n /** The feature branch that was verified. */\n branch: string;\n /** The feature head the copy is built on. Stage ③ refuses when HEAD is no longer this. */\n headSha: string;\n /** What stage ③ publishes: `headSha`, or `headSha` plus ONE commit recording the resolved files. */\n copySha: string;\n /** `<namespace>/<branch>` — where stage ③ publishes. */\n targetRef: string;\n /** The remote copy's sha when stage ② ran ('' = not published yet) — stage ③'s push lease. */\n leaseSha: string;\n /** The `origin/<devBranch>` sha the copy was merged with and built against; '' when dev did not exist. */\n devSha: string;\n\n constructor(branch: string, headSha: string, copySha: string, targetRef: string, leaseSha: string, devSha: string) {\n this.branch = branch;\n this.headSha = headSha;\n this.copySha = copySha;\n this.targetRef = targetRef;\n this.leaseSha = leaseSha;\n this.devSha = devSha;\n }\n}\n\n/**\n * Reads, writes and clears the stage-② record. A missing or unreadable record reads as null, which stage ③\n * turns into \"run `pnpm wp-build-push-dev` first\".\n */\n@injectable(bindingScopeValues.Singleton)\nexport class VerifiedDevCopyStore {\n constructor(private readonly dotWebpieces: DotWebpieces) {}\n\n path(repoRoot: string): string {\n return this.dotWebpieces.localFile(repoRoot, PUSH_DEV_VERIFIED_FILE);\n }\n\n /**\n * The local ref that keeps the verified copy reachable between stage ② and stage ③. When something\n * conflicted, the copy is a commit on top of the feature head that no branch points at; without a ref\n * holding it, `git gc` could collect it before it is published. Outside `refs/heads/`, so it is never\n * mistaken for a branch (and never counts toward the branch cap or reaches `wp-cleanup`).\n */\n keepRef(branch: string): string {\n return `refs/webpieces/push-dev/${branch}`;\n }\n\n read(repoRoot: string): VerifiedDevCopy | null {\n const file = this.path(repoRoot);\n if (!fs.existsSync(file)) return null;\n // webpieces-disable no-any-unknown -- JSON.parse is untyped until narrowed on the next line\n const raw = JSON.parse(fs.readFileSync(file, 'utf8')) as Partial<VerifiedDevCopy>;\n const fields = [raw.branch, raw.headSha, raw.copySha, raw.targetRef, raw.leaseSha, raw.devSha];\n if (!fields.every((f: string | undefined): boolean => typeof f === 'string')) return null;\n return new VerifiedDevCopy(\n raw.branch as string, raw.headSha as string, raw.copySha as string,\n raw.targetRef as string, raw.leaseSha as string, raw.devSha as string,\n );\n }\n\n write(repoRoot: string, record: VerifiedDevCopy): void {\n fs.mkdirSync(this.dotWebpieces.local(repoRoot), { recursive: true });\n fs.writeFileSync(this.path(repoRoot), JSON.stringify(record, null, 2) + '\\n', 'utf8');\n }\n\n clear(repoRoot: string): void {\n const file = this.path(repoRoot);\n if (fs.existsSync(file)) fs.rmSync(file);\n }\n}\n"]}
@@ -9,5 +9,5 @@ const pr_gate_cli_invocation_1 = require("./pr-gate-cli-invocation");
9
9
  const container = new pr_gate_container_1.PrGateContainer().create();
10
10
  (0, rules_config_1.runMain)(() => container
11
11
  .get(pr_gate_cli_app_1.PrGateCliApp)
12
- .run(container.get(pr_gate_cli_invocation_1.PrGateCliInvocationFactory).fromProcess('wp-build-dev')));
13
- //# sourceMappingURL=wp-build-dev.js.map
12
+ .run(container.get(pr_gate_cli_invocation_1.PrGateCliInvocationFactory).fromProcess('wp-build-push-dev')));
13
+ //# sourceMappingURL=wp-build-push-dev.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wp-build-push-dev.js","sourceRoot":"","sources":["../../../../../../packages/tooling/pr-gate/src/scripts/wp-build-push-dev.ts"],"names":[],"mappings":";;;AACA,4BAA0B;AAC1B,0DAAkD;AAClD,2DAAsD;AACtD,uDAAiD;AACjD,qEAAsE;AAEtE,MAAM,SAAS,GAAG,IAAI,mCAAe,EAAE,CAAC,MAAM,EAAE,CAAC;AACjD,IAAA,sBAAO,EACH,GAAkB,EAAE,CAChB,SAAS;KACJ,GAAG,CAAC,8BAAY,CAAC;KACjB,GAAG,CAAC,SAAS,CAAC,GAAG,CAAC,mDAA0B,CAAC,CAAC,WAAW,CAAC,mBAAmB,CAAC,CAAC,CAC3F,CAAC","sourcesContent":["#!/usr/bin/env node\nimport 'reflect-metadata';\nimport { runMain } from '@webpieces/rules-config';\nimport { PrGateContainer } from './pr-gate-container';\nimport { PrGateCliApp } from './pr-gate-cli-app';\nimport { PrGateCliInvocationFactory } from './pr-gate-cli-invocation';\n\nconst container = new PrGateContainer().create();\nrunMain(\n (): Promise<void> =>\n container\n .get(PrGateCliApp)\n .run(container.get(PrGateCliInvocationFactory).fromProcess('wp-build-push-dev')),\n);\n"]}
@@ -9,5 +9,5 @@ const pr_gate_cli_invocation_1 = require("./pr-gate-cli-invocation");
9
9
  const container = new pr_gate_container_1.PrGateContainer().create();
10
10
  (0, rules_config_1.runMain)(() => container
11
11
  .get(pr_gate_cli_app_1.PrGateCliApp)
12
- .run(container.get(pr_gate_cli_invocation_1.PrGateCliInvocationFactory).fromProcess('wp-push-dev')));
13
- //# sourceMappingURL=wp-push-dev.js.map
12
+ .run(container.get(pr_gate_cli_invocation_1.PrGateCliInvocationFactory).fromProcess('wp-start-push-dev')));
13
+ //# sourceMappingURL=wp-start-push-dev.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wp-start-push-dev.js","sourceRoot":"","sources":["../../../../../../packages/tooling/pr-gate/src/scripts/wp-start-push-dev.ts"],"names":[],"mappings":";;;AACA,4BAA0B;AAC1B,0DAAkD;AAClD,2DAAsD;AACtD,uDAAiD;AACjD,qEAAsE;AAEtE,MAAM,SAAS,GAAG,IAAI,mCAAe,EAAE,CAAC,MAAM,EAAE,CAAC;AACjD,IAAA,sBAAO,EACH,GAAkB,EAAE,CAChB,SAAS;KACJ,GAAG,CAAC,8BAAY,CAAC;KACjB,GAAG,CAAC,SAAS,CAAC,GAAG,CAAC,mDAA0B,CAAC,CAAC,WAAW,CAAC,mBAAmB,CAAC,CAAC,CAC3F,CAAC","sourcesContent":["#!/usr/bin/env node\nimport 'reflect-metadata';\nimport { runMain } from '@webpieces/rules-config';\nimport { PrGateContainer } from './pr-gate-container';\nimport { PrGateCliApp } from './pr-gate-cli-app';\nimport { PrGateCliInvocationFactory } from './pr-gate-cli-invocation';\n\nconst container = new PrGateContainer().create();\nrunMain(\n (): Promise<void> =>\n container\n .get(PrGateCliApp)\n .run(container.get(PrGateCliInvocationFactory).fromProcess('wp-start-push-dev')),\n);\n"]}
@@ -1,27 +0,0 @@
1
- import { RepoRootFinder } from '@webpieces/rules-config';
2
- import { GitExec } from '../workflow/git-exec';
3
- import { DevDeployRefs } from '../workflow/dev-deploy-refs';
4
- import { DevBuild } from '../workflow/dev-build';
5
- /**
6
- * `wp-build-dev` — the check `wp-push-dev` runs before it publishes, WITHOUT the publish (#1397).
7
- *
8
- * It merges `origin/<devBranch>` into a throwaway branch and runs `commands.push-dev.buildCommand` on the
9
- * merged tree, then puts the checkout back. That is the cheap, honest form of the question a developer
10
- * wants answered before publishing: does this branch build once it meets what is already on dev? Built on
11
- * the feature branch itself, a `--base=origin/dev` build would also rebuild every project the OTHER copies
12
- * on dev touched, because they differ from the feature branch too.
13
- *
14
- * It RESOLVES NOTHING. A conflict aborts the throwaway merge and names the files; resolving them is
15
- * `wp-push-dev`'s job, because a resolution is only worth anything once it is recorded on the published
16
- * copy. The feature branch is never written to, by the same rule as every other dev-deploy command.
17
- */
18
- export declare class BuildDevCommand {
19
- private readonly repoRootFinder;
20
- private readonly gitExec;
21
- private readonly refs;
22
- private readonly devBuild;
23
- constructor(repoRootFinder: RepoRootFinder, gitExec: GitExec, refs: DevDeployRefs, devBuild: DevBuild);
24
- run(): Promise<void>;
25
- private refuseConflict;
26
- private restore;
27
- }