@webpieces/pr-gate 0.3.354 → 0.3.355

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 (70) hide show
  1. package/package.json +7 -2
  2. package/src/dashboard/dashboard.d.ts +12 -3
  3. package/src/dashboard/dashboard.js +136 -129
  4. package/src/dashboard/dashboard.js.map +1 -1
  5. package/src/index.d.ts +2 -1
  6. package/src/index.js +4 -4
  7. package/src/index.js.map +1 -1
  8. package/src/scripts/commands/finish-update-command.d.ts +10 -0
  9. package/src/scripts/commands/finish-update-command.js +51 -0
  10. package/src/scripts/commands/finish-update-command.js.map +1 -0
  11. package/src/scripts/commands/finish-upsert-pr-command.d.ts +22 -0
  12. package/src/scripts/commands/finish-upsert-pr-command.js +131 -0
  13. package/src/scripts/commands/finish-upsert-pr-command.js.map +1 -0
  14. package/src/scripts/commands/start-update-command.d.ts +9 -0
  15. package/src/scripts/commands/start-update-command.js +67 -0
  16. package/src/scripts/commands/start-update-command.js.map +1 -0
  17. package/src/scripts/commands/start-upsert-pr-command.d.ts +15 -0
  18. package/src/scripts/commands/start-upsert-pr-command.js +73 -0
  19. package/src/scripts/commands/start-upsert-pr-command.js.map +1 -0
  20. package/src/scripts/git-finishUpsertPr.d.ts +1 -1
  21. package/src/scripts/git-finishUpsertPr.js +11 -109
  22. package/src/scripts/git-finishUpsertPr.js.map +1 -1
  23. package/src/scripts/git-gatherInfo.d.ts +15 -1
  24. package/src/scripts/git-gatherInfo.js +79 -61
  25. package/src/scripts/git-gatherInfo.js.map +1 -1
  26. package/src/scripts/pr-gate-app.d.ts +25 -0
  27. package/src/scripts/pr-gate-app.js +56 -0
  28. package/src/scripts/pr-gate-app.js.map +1 -0
  29. package/src/scripts/workflow/branch-naming.d.ts +11 -8
  30. package/src/scripts/workflow/branch-naming.js +30 -21
  31. package/src/scripts/workflow/branch-naming.js.map +1 -1
  32. package/src/scripts/workflow/build-affected.d.ts +21 -30
  33. package/src/scripts/workflow/build-affected.js +57 -63
  34. package/src/scripts/workflow/build-affected.js.map +1 -1
  35. package/src/scripts/workflow/cleanTmp.d.ts +6 -1
  36. package/src/scripts/workflow/cleanTmp.js +83 -78
  37. package/src/scripts/workflow/cleanTmp.js.map +1 -1
  38. package/src/scripts/workflow/git-exec.d.ts +32 -28
  39. package/src/scripts/workflow/git-exec.js +92 -85
  40. package/src/scripts/workflow/git-exec.js.map +1 -1
  41. package/src/scripts/workflow/git-findForkPoint.d.ts +12 -3
  42. package/src/scripts/workflow/git-findForkPoint.js +116 -107
  43. package/src/scripts/workflow/git-findForkPoint.js.map +1 -1
  44. package/src/scripts/workflow/git-readAiBranchName.d.ts +7 -2
  45. package/src/scripts/workflow/git-readAiBranchName.js +24 -15
  46. package/src/scripts/workflow/git-readAiBranchName.js.map +1 -1
  47. package/src/scripts/workflow/merge-end.d.ts +21 -6
  48. package/src/scripts/workflow/merge-end.js +147 -133
  49. package/src/scripts/workflow/merge-end.js.map +1 -1
  50. package/src/scripts/workflow/merge-start.d.ts +22 -1
  51. package/src/scripts/workflow/merge-start.js +180 -186
  52. package/src/scripts/workflow/merge-start.js.map +1 -1
  53. package/src/scripts/workflow/merge-state.d.ts +26 -23
  54. package/src/scripts/workflow/merge-state.js +131 -137
  55. package/src/scripts/workflow/merge-state.js.map +1 -1
  56. package/src/scripts/workflow/open-pr-check.d.ts +7 -1
  57. package/src/scripts/workflow/open-pr-check.js +34 -23
  58. package/src/scripts/workflow/open-pr-check.js.map +1 -1
  59. package/src/scripts/workflow/run-update.d.ts +13 -1
  60. package/src/scripts/workflow/run-update.js +59 -28
  61. package/src/scripts/workflow/run-update.js.map +1 -1
  62. package/src/scripts/wp-finish-update.d.ts +1 -1
  63. package/src/scripts/wp-finish-update.js +11 -30
  64. package/src/scripts/wp-finish-update.js.map +1 -1
  65. package/src/scripts/wp-start-update.d.ts +1 -2
  66. package/src/scripts/wp-start-update.js +11 -51
  67. package/src/scripts/wp-start-update.js.map +1 -1
  68. package/src/scripts/wp-start-upsert-pr.d.ts +1 -1
  69. package/src/scripts/wp-start-upsert-pr.js +11 -47
  70. package/src/scripts/wp-start-upsert-pr.js.map +1 -1
@@ -1,12 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.GatherInfoResult = void 0;
4
- exports.gatherInfo = gatherInfo;
3
+ exports.GatherInfo = exports.GatherInfoResult = void 0;
5
4
  const tslib_1 = require("tslib");
6
5
  const child_process_1 = require("child_process");
7
6
  const fs = tslib_1.__importStar(require("fs"));
8
7
  const path = tslib_1.__importStar(require("path"));
9
8
  const rules_config_1 = require("@webpieces/rules-config");
9
+ const core_context_1 = require("@webpieces/core-context");
10
+ const inversify_1 = require("inversify");
10
11
  const git_readAiBranchName_1 = require("./workflow/git-readAiBranchName");
11
12
  const git_findForkPoint_1 = require("./workflow/git-findForkPoint");
12
13
  const merge_state_1 = require("./workflow/merge-state");
@@ -14,8 +15,7 @@ const git_exec_1 = require("./workflow/git-exec");
14
15
  const SEP = '━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n';
15
16
  // Result of gathering merge context: whether the branch is already even with main (fork point == main
16
17
  // HEAD, so there is nothing to merge) plus the 3 hash points. A class (not an object literal) per the
17
- // codebase's data-structure convention. gatherInfo RETURNS this instead of calling process.exit — a
18
- // library function must never exit the process (see CliExitError / runMain).
18
+ // codebase's data-structure convention. gatherInfo RETURNS this instead of calling process.exit.
19
19
  class GatherInfoResult {
20
20
  alreadyUpToDate;
21
21
  hashes;
@@ -25,68 +25,86 @@ class GatherInfoResult {
25
25
  }
26
26
  }
27
27
  exports.GatherInfoResult = GatherInfoResult;
28
- function validateCleanTree(currentBranch, repoRoot) {
29
- if (currentBranch === 'main') {
30
- throw new rules_config_1.CliExitError(1, '❌ Error: Already on main branch. No need to update from main.');
28
+ /** Gathers the 3-point merge context (fetch main, find fork point, write hashes) for merge-start. */
29
+ let GatherInfo = class GatherInfo {
30
+ aiBranchName;
31
+ forkPoint;
32
+ mergeState;
33
+ gitExec;
34
+ constructor(aiBranchName, forkPoint, mergeState, gitExec) {
35
+ this.aiBranchName = aiBranchName;
36
+ this.forkPoint = forkPoint;
37
+ this.mergeState = mergeState;
38
+ this.gitExec = gitExec;
31
39
  }
32
- process.stderr.write(`Current branch: ${currentBranch}\n`);
33
- // Require a fully-committed tree (tracked AND untracked). The old check used `git diff-index`,
34
- // which is tracked-only, so a stale untracked dir slipped through and was later swept into the
35
- // squash commit by `git add -A`. assertCleanTree uses `git status --porcelain` (untracked-aware,
36
- // gitignore-respecting) and aborts with instructions — the tooling never commits your work for you.
37
- (0, git_exec_1.assertCleanTree)(repoRoot);
38
- }
39
- function printHashPoints(hashes, currentBranch, mergeDir) {
40
- process.stderr.write('📍 The 3 Hash Points:\n');
41
- process.stderr.write(` 1. Fork point (A): ${hashes.hashForkPoint}\n`);
42
- process.stderr.write(` (where ${currentBranch} diverged from main)\n`);
43
- process.stderr.write('\n');
44
- process.stderr.write(` 2. Feature HEAD (B): ${hashes.hashFeatureHead}\n`);
45
- process.stderr.write(` (tip of ${currentBranch})\n`);
46
- process.stderr.write('\n');
47
- process.stderr.write(` 3. Main HEAD (C): ${hashes.hashMainHead}\n`);
48
- process.stderr.write(' (current origin/main)\n');
49
- process.stderr.write('\n');
50
- process.stderr.write(`Merge directory: ${mergeDir}\n`);
51
- process.stderr.write('\n');
52
- }
53
- // Gather the 3-point merge context for the current feature branch (fetches main, finds the fork
54
- // point, writes updatemain-hashes.json) and RETURN whether the branch is already even with main.
55
- // NEVER calls process.exit: it is called as a library (from merge-start). Callers decide what to
56
- // do with an up-to-date branch.
57
- async function gatherInfo() {
58
- const currentBranch = (0, child_process_1.execSync)('git branch --show-current', { encoding: 'utf8' }).trim();
59
- const featureName = (0, git_readAiBranchName_1.getFeatureName)();
60
- const repoRoot = (0, child_process_1.execSync)('git rev-parse --show-toplevel', { encoding: 'utf8' }).trim();
61
- const mergeDir = (0, merge_state_1.mergeDirFor)(repoRoot, featureName);
62
- fs.mkdirSync(mergeDir, { recursive: true });
63
- validateCleanTree(currentBranch, repoRoot);
64
- process.stderr.write('\n');
65
- process.stderr.write(SEP);
66
- process.stderr.write('📍 Gathering Merge Context\n');
67
- process.stderr.write(SEP);
68
- process.stderr.write('\n');
69
- process.stderr.write('Fetching latest changes from origin/main...\n');
70
- (0, child_process_1.spawnSync)('git', ['fetch', 'origin', 'main'], { stdio: 'inherit' });
71
- await (0, git_findForkPoint_1.findForkPoint)('merge');
72
- const hashesFile = path.join(mergeDir, 'updatemain-hashes.json');
73
- const hashes = JSON.parse(fs.readFileSync(hashesFile, 'utf8'));
74
- printHashPoints(hashes, currentBranch, mergeDir);
75
- if (hashes.hashForkPoint === hashes.hashMainHead) {
40
+ // Gather the 3-point merge context for the current feature branch and RETURN whether the branch is
41
+ // already even with main. NEVER calls process.exit: it is called as a library (from merge-start).
42
+ async gatherInfo() {
43
+ const currentBranch = (0, child_process_1.execSync)('git branch --show-current', { encoding: 'utf8' }).trim();
44
+ const featureName = this.aiBranchName.getFeatureName();
45
+ const repoRoot = (0, child_process_1.execSync)('git rev-parse --show-toplevel', { encoding: 'utf8' }).trim();
46
+ const mergeDir = this.mergeState.mergeDirFor(repoRoot, featureName);
47
+ fs.mkdirSync(mergeDir, { recursive: true });
48
+ this.validateCleanTree(currentBranch, repoRoot);
49
+ process.stderr.write('\n');
76
50
  process.stderr.write(SEP);
77
- process.stderr.write(' Already up to date with main!\n');
51
+ process.stderr.write('📍 Gathering Merge Context\n');
78
52
  process.stderr.write(SEP);
79
53
  process.stderr.write('\n');
80
- process.stderr.write('Your branch has not diverged from main.\n');
81
- process.stderr.write('There are no new changes from main to merge.\n');
54
+ process.stderr.write('Fetching latest changes from origin/main...\n');
55
+ (0, child_process_1.spawnSync)('git', ['fetch', 'origin', 'main'], { stdio: 'inherit' });
56
+ await this.forkPoint.findForkPoint('merge');
57
+ const hashesFile = path.join(mergeDir, 'updatemain-hashes.json');
58
+ const hashes = JSON.parse(fs.readFileSync(hashesFile, 'utf8'));
59
+ this.printHashPoints(hashes, currentBranch, mergeDir);
60
+ if (hashes.hashForkPoint === hashes.hashMainHead) {
61
+ process.stderr.write(SEP);
62
+ process.stderr.write('✅ Already up to date with main!\n');
63
+ process.stderr.write(SEP);
64
+ process.stderr.write('\n');
65
+ process.stderr.write('Your branch has not diverged from main.\n');
66
+ process.stderr.write('There are no new changes from main to merge.\n');
67
+ process.stderr.write('\n');
68
+ process.stderr.write(SEP);
69
+ return new GatherInfoResult(true, hashes);
70
+ }
71
+ process.stderr.write('Main has advanced. Merge will be needed.\n');
82
72
  process.stderr.write('\n');
83
73
  process.stderr.write(SEP);
84
- return new GatherInfoResult(true, hashes);
74
+ process.stderr.write('\n');
75
+ return new GatherInfoResult(false, hashes);
85
76
  }
86
- process.stderr.write('Main has advanced. Merge will be needed.\n');
87
- process.stderr.write('\n');
88
- process.stderr.write(SEP);
89
- process.stderr.write('\n');
90
- return new GatherInfoResult(false, hashes);
91
- }
77
+ validateCleanTree(currentBranch, repoRoot) {
78
+ if (currentBranch === 'main') {
79
+ throw new rules_config_1.CliExitError(1, '❌ Error: Already on main branch. No need to update from main.');
80
+ }
81
+ process.stderr.write(`Current branch: ${currentBranch}\n`);
82
+ // Require a fully-committed tree (tracked AND untracked). assertCleanTree uses
83
+ // `git status --porcelain` (untracked-aware, gitignore-respecting) and aborts with instructions.
84
+ this.gitExec.assertCleanTree(repoRoot);
85
+ }
86
+ printHashPoints(hashes, currentBranch, mergeDir) {
87
+ process.stderr.write('📍 The 3 Hash Points:\n');
88
+ process.stderr.write(` 1. Fork point (A): ${hashes.hashForkPoint}\n`);
89
+ process.stderr.write(` (where ${currentBranch} diverged from main)\n`);
90
+ process.stderr.write('\n');
91
+ process.stderr.write(` 2. Feature HEAD (B): ${hashes.hashFeatureHead}\n`);
92
+ process.stderr.write(` (tip of ${currentBranch})\n`);
93
+ process.stderr.write('\n');
94
+ process.stderr.write(` 3. Main HEAD (C): ${hashes.hashMainHead}\n`);
95
+ process.stderr.write(' (current origin/main)\n');
96
+ process.stderr.write('\n');
97
+ process.stderr.write(`Merge directory: ${mergeDir}\n`);
98
+ process.stderr.write('\n');
99
+ }
100
+ };
101
+ exports.GatherInfo = GatherInfo;
102
+ exports.GatherInfo = GatherInfo = tslib_1.__decorate([
103
+ (0, core_context_1.provideSingleton)(),
104
+ (0, inversify_1.injectable)(),
105
+ tslib_1.__metadata("design:paramtypes", [git_readAiBranchName_1.AiBranchName,
106
+ git_findForkPoint_1.ForkPoint,
107
+ merge_state_1.MergeState,
108
+ git_exec_1.GitExec])
109
+ ], GatherInfo);
92
110
  //# sourceMappingURL=git-gatherInfo.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"git-gatherInfo.js","sourceRoot":"","sources":["../../../../../../packages/tooling/pr-gate/src/scripts/git-gatherInfo.ts"],"names":[],"mappings":";;;AA8DA,gCAyCC;;AAvGD,iDAAoD;AACpD,+CAAyB;AACzB,mDAA6B;AAC7B,0DAAuD;AACvD,0EAAiE;AACjE,oEAA6D;AAC7D,wDAAqD;AACrD,kDAAsD;AAEtD,MAAM,GAAG,GAAG,0DAA0D,CAAC;AAQvE,sGAAsG;AACtG,sGAAsG;AACtG,oGAAoG;AACpG,6EAA6E;AAC7E,MAAa,gBAAgB;IACzB,eAAe,CAAU;IACzB,MAAM,CAAa;IAEnB,YAAY,eAAwB,EAAE,MAAkB;QACpD,IAAI,CAAC,eAAe,GAAG,eAAe,CAAC;QACvC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACzB,CAAC;CACJ;AARD,4CAQC;AAED,SAAS,iBAAiB,CAAC,aAAqB,EAAE,QAAgB;IAC9D,IAAI,aAAa,KAAK,MAAM,EAAE,CAAC;QAC3B,MAAM,IAAI,2BAAY,CAAC,CAAC,EAAE,+DAA+D,CAAC,CAAC;IAC/F,CAAC;IACD,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,mBAAmB,aAAa,IAAI,CAAC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CAAC,aAAa,KAAK,MAAM,CAAC,YAAY,EAAE,CAAC;QAC/C,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAC1B,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,mCAAmC,CAAC,CAAC;QAC1D,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAC1B,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QAC3B,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,2CAA2C,CAAC,CAAC;QAClE,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,gDAAgD,CAAC,CAAC;QACvE,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QAC3B,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAC1B,OAAO,IAAI,gBAAgB,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;IAC9C,CAAC;IAED,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,4CAA4C,CAAC,CAAC;IACnE,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAC3B,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAC1B,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAC3B,OAAO,IAAI,gBAAgB,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;AAC/C,CAAC","sourcesContent":["import { execSync, spawnSync } from 'child_process';\nimport * as fs from 'fs';\nimport * as path from 'path';\nimport { CliExitError } from '@webpieces/rules-config';\nimport { getFeatureName } from './workflow/git-readAiBranchName';\nimport { findForkPoint } from './workflow/git-findForkPoint';\nimport { mergeDirFor } from './workflow/merge-state';\nimport { assertCleanTree } from './workflow/git-exec';\n\nconst SEP = '━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\\n';\n\ninterface HashPoints {\n hashForkPoint: string;\n hashFeatureHead: string;\n hashMainHead: string;\n}\n\n// Result of gathering merge context: whether the branch is already even with main (fork point == main\n// HEAD, so there is nothing to merge) plus the 3 hash points. A class (not an object literal) per the\n// codebase's data-structure convention. gatherInfo RETURNS this instead of calling process.exit — a\n// library function must never exit the process (see CliExitError / runMain).\nexport class GatherInfoResult {\n alreadyUpToDate: boolean;\n hashes: HashPoints;\n\n constructor(alreadyUpToDate: boolean, hashes: HashPoints) {\n this.alreadyUpToDate = alreadyUpToDate;\n this.hashes = hashes;\n }\n}\n\nfunction validateCleanTree(currentBranch: string, repoRoot: string): void {\n if (currentBranch === 'main') {\n throw new CliExitError(1, '❌ Error: Already on main branch. No need to update from main.');\n }\n process.stderr.write(`Current branch: ${currentBranch}\\n`);\n // Require a fully-committed tree (tracked AND untracked). The old check used `git diff-index`,\n // which is tracked-only, so a stale untracked dir slipped through and was later swept into the\n // squash commit by `git add -A`. assertCleanTree uses `git status --porcelain` (untracked-aware,\n // gitignore-respecting) and aborts with instructions — the tooling never commits your work for you.\n assertCleanTree(repoRoot);\n}\n\nfunction printHashPoints(hashes: HashPoints, currentBranch: string, mergeDir: string): void {\n process.stderr.write('📍 The 3 Hash Points:\\n');\n process.stderr.write(` 1. Fork point (A): ${hashes.hashForkPoint}\\n`);\n process.stderr.write(` (where ${currentBranch} diverged from main)\\n`);\n process.stderr.write('\\n');\n process.stderr.write(` 2. Feature HEAD (B): ${hashes.hashFeatureHead}\\n`);\n process.stderr.write(` (tip of ${currentBranch})\\n`);\n process.stderr.write('\\n');\n process.stderr.write(` 3. Main HEAD (C): ${hashes.hashMainHead}\\n`);\n process.stderr.write(' (current origin/main)\\n');\n process.stderr.write('\\n');\n process.stderr.write(`Merge directory: ${mergeDir}\\n`);\n process.stderr.write('\\n');\n}\n\n// Gather the 3-point merge context for the current feature branch (fetches main, finds the fork\n// point, writes updatemain-hashes.json) and RETURN whether the branch is already even with main.\n// NEVER calls process.exit: it is called as a library (from merge-start). Callers decide what to\n// do with an up-to-date branch.\nexport async function gatherInfo(): Promise<GatherInfoResult> {\n const currentBranch = execSync('git branch --show-current', { encoding: 'utf8' }).trim();\n const featureName = getFeatureName();\n const repoRoot = execSync('git rev-parse --show-toplevel', { encoding: 'utf8' }).trim();\n const mergeDir = mergeDirFor(repoRoot, featureName);\n fs.mkdirSync(mergeDir, { recursive: true });\n\n validateCleanTree(currentBranch, repoRoot);\n\n process.stderr.write('\\n');\n process.stderr.write(SEP);\n process.stderr.write('📍 Gathering Merge Context\\n');\n process.stderr.write(SEP);\n process.stderr.write('\\n');\n process.stderr.write('Fetching latest changes from origin/main...\\n');\n spawnSync('git', ['fetch', 'origin', 'main'], { stdio: 'inherit' });\n\n await findForkPoint('merge');\n\n const hashesFile = path.join(mergeDir, 'updatemain-hashes.json');\n const hashes = JSON.parse(fs.readFileSync(hashesFile, 'utf8')) as HashPoints;\n\n printHashPoints(hashes, currentBranch, mergeDir);\n\n if (hashes.hashForkPoint === hashes.hashMainHead) {\n process.stderr.write(SEP);\n process.stderr.write('✅ Already up to date with main!\\n');\n process.stderr.write(SEP);\n process.stderr.write('\\n');\n process.stderr.write('Your branch has not diverged from main.\\n');\n process.stderr.write('There are no new changes from main to merge.\\n');\n process.stderr.write('\\n');\n process.stderr.write(SEP);\n return new GatherInfoResult(true, hashes);\n }\n\n process.stderr.write('Main has advanced. Merge will be needed.\\n');\n process.stderr.write('\\n');\n process.stderr.write(SEP);\n process.stderr.write('\\n');\n return new GatherInfoResult(false, hashes);\n}\n"]}
1
+ {"version":3,"file":"git-gatherInfo.js","sourceRoot":"","sources":["../../../../../../packages/tooling/pr-gate/src/scripts/git-gatherInfo.ts"],"names":[],"mappings":";;;;AAAA,iDAAoD;AACpD,+CAAyB;AACzB,mDAA6B;AAC7B,0DAAuD;AACvD,0DAA2D;AAC3D,yCAAuC;AACvC,0EAA+D;AAC/D,oEAAyD;AACzD,wDAAoD;AACpD,kDAA8C;AAE9C,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eAAe,IAAI,CAAC,CAAC;QAC3E,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,gBAAgB,aAAa,KAAK,CAAC,CAAC;QACzD,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QAC3B,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,0BAA0B,MAAM,CAAC,YAAY,IAAI,CAAC,CAAC;QACxE,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,8BAA8B,CAAC,CAAC;QACrD,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QAC3B,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,oBAAoB,QAAQ,IAAI,CAAC,CAAC;QACvD,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAC/B,CAAC;CACJ,CAAA;AA7EY,gCAAU;qBAAV,UAAU;IAFtB,IAAA,+BAAgB,GAAE;IAClB,IAAA,sBAAU,GAAE;6CAG0B,mCAAY;QACf,6BAAS;QACR,wBAAU;QACb,kBAAO;GAL5B,UAAU,CA6EtB","sourcesContent":["import { execSync, spawnSync } from 'child_process';\nimport * as fs from 'fs';\nimport * as path from 'path';\nimport { CliExitError } from '@webpieces/rules-config';\nimport { provideSingleton } from '@webpieces/core-context';\nimport { injectable } from 'inversify';\nimport { AiBranchName } from './workflow/git-readAiBranchName';\nimport { ForkPoint } from './workflow/git-findForkPoint';\nimport { MergeState } from './workflow/merge-state';\nimport { GitExec } from './workflow/git-exec';\n\nconst SEP = '━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\\n';\n\ninterface HashPoints {\n hashForkPoint: string;\n hashFeatureHead: string;\n hashMainHead: string;\n}\n\n// Result of gathering merge context: whether the branch is already even with main (fork point == main\n// HEAD, so there is nothing to merge) plus the 3 hash points. A class (not an object literal) per the\n// codebase's data-structure convention. gatherInfo RETURNS this instead of calling process.exit.\nexport class GatherInfoResult {\n alreadyUpToDate: boolean;\n hashes: HashPoints;\n\n constructor(alreadyUpToDate: boolean, hashes: HashPoints) {\n this.alreadyUpToDate = alreadyUpToDate;\n this.hashes = hashes;\n }\n}\n\n/** Gathers the 3-point merge context (fetch main, find fork point, write hashes) for merge-start. */\n@provideSingleton()\n@injectable()\nexport class GatherInfo {\n constructor(\n private readonly aiBranchName: AiBranchName,\n private readonly forkPoint: ForkPoint,\n private readonly mergeState: MergeState,\n private readonly gitExec: GitExec,\n ) {}\n\n // Gather the 3-point merge context for the current feature branch and RETURN whether the branch is\n // already even with main. NEVER calls process.exit: it is called as a library (from merge-start).\n async gatherInfo(): Promise<GatherInfoResult> {\n const currentBranch = execSync('git branch --show-current', { encoding: 'utf8' }).trim();\n const featureName = this.aiBranchName.getFeatureName();\n const repoRoot = execSync('git rev-parse --show-toplevel', { encoding: 'utf8' }).trim();\n const mergeDir = this.mergeState.mergeDirFor(repoRoot, featureName);\n fs.mkdirSync(mergeDir, { recursive: true });\n\n this.validateCleanTree(currentBranch, repoRoot);\n\n process.stderr.write('\\n');\n process.stderr.write(SEP);\n process.stderr.write('📍 Gathering Merge Context\\n');\n process.stderr.write(SEP);\n process.stderr.write('\\n');\n process.stderr.write('Fetching latest changes from origin/main...\\n');\n spawnSync('git', ['fetch', 'origin', 'main'], { stdio: 'inherit' });\n\n await this.forkPoint.findForkPoint('merge');\n\n const hashesFile = path.join(mergeDir, 'updatemain-hashes.json');\n const hashes = JSON.parse(fs.readFileSync(hashesFile, 'utf8')) as HashPoints;\n\n this.printHashPoints(hashes, currentBranch, mergeDir);\n\n if (hashes.hashForkPoint === hashes.hashMainHead) {\n process.stderr.write(SEP);\n process.stderr.write('✅ Already up to date with main!\\n');\n process.stderr.write(SEP);\n process.stderr.write('\\n');\n process.stderr.write('Your branch has not diverged from main.\\n');\n process.stderr.write('There are no new changes from main to merge.\\n');\n process.stderr.write('\\n');\n process.stderr.write(SEP);\n return new GatherInfoResult(true, hashes);\n }\n\n process.stderr.write('Main has advanced. Merge will be needed.\\n');\n process.stderr.write('\\n');\n process.stderr.write(SEP);\n process.stderr.write('\\n');\n return new GatherInfoResult(false, hashes);\n }\n\n private validateCleanTree(currentBranch: string, repoRoot: string): void {\n if (currentBranch === 'main') {\n throw new CliExitError(1, '❌ Error: Already on main branch. No need to update from main.');\n }\n process.stderr.write(`Current branch: ${currentBranch}\\n`);\n // Require a fully-committed tree (tracked AND untracked). assertCleanTree uses\n // `git status --porcelain` (untracked-aware, gitignore-respecting) and aborts with instructions.\n this.gitExec.assertCleanTree(repoRoot);\n }\n\n private printHashPoints(hashes: HashPoints, currentBranch: string, mergeDir: string): void {\n process.stderr.write('📍 The 3 Hash Points:\\n');\n process.stderr.write(` 1. Fork point (A): ${hashes.hashForkPoint}\\n`);\n process.stderr.write(` (where ${currentBranch} diverged from main)\\n`);\n process.stderr.write('\\n');\n process.stderr.write(` 2. Feature HEAD (B): ${hashes.hashFeatureHead}\\n`);\n process.stderr.write(` (tip of ${currentBranch})\\n`);\n process.stderr.write('\\n');\n process.stderr.write(` 3. Main HEAD (C): ${hashes.hashMainHead}\\n`);\n process.stderr.write(' (current origin/main)\\n');\n process.stderr.write('\\n');\n process.stderr.write(`Merge directory: ${mergeDir}\\n`);\n process.stderr.write('\\n');\n }\n}\n"]}
@@ -0,0 +1,25 @@
1
+ import { StartUpdateCommand } from './commands/start-update-command';
2
+ import { FinishUpdateCommand } from './commands/finish-update-command';
3
+ import { StartUpsertPrCommand } from './commands/start-upsert-pr-command';
4
+ import { FinishUpsertPrCommand } from './commands/finish-upsert-pr-command';
5
+ /**
6
+ * The pr-gate application root. `container.get(PrGateApp)` resolves the entire workflow DAG (the 4
7
+ * command classes → the injected git/merge/dashboard services). `@DocumentDesign` marks it the
8
+ * top-of-DAG the DI-design analyzer roots on, so `role:app` pr-gate draws its design. Each `bin/*`
9
+ * entry resolves THIS and calls the matching command method.
10
+ */
11
+ export declare class PrGateApp {
12
+ private readonly startUpdateCommand;
13
+ private readonly finishUpdateCommand;
14
+ private readonly startUpsertPrCommand;
15
+ private readonly finishUpsertPrCommand;
16
+ constructor(startUpdateCommand: StartUpdateCommand, finishUpdateCommand: FinishUpdateCommand, startUpsertPrCommand: StartUpsertPrCommand, finishUpsertPrCommand: FinishUpsertPrCommand);
17
+ /** `wp-start-update`: 3-point squash-update from main (no PR). */
18
+ startUpdate(): Promise<void>;
19
+ /** `wp-finish-update`: validate + finalize a resolved 3-point merge (no PR). */
20
+ finishUpdate(): Promise<void>;
21
+ /** `wp-start-upsert-pr`: update from main, push, advisory build gate, hand off review.json. */
22
+ startUpsertPr(): Promise<void>;
23
+ /** `wp-finish-upsert-pr`: finalize merge, authoritative build gate, dashboard, create/update PR. */
24
+ finishUpsertPr(): Promise<void>;
25
+ }
@@ -0,0 +1,56 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PrGateApp = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const core_util_1 = require("@webpieces/core-util");
6
+ const core_context_1 = require("@webpieces/core-context");
7
+ const inversify_1 = require("inversify");
8
+ const start_update_command_1 = require("./commands/start-update-command");
9
+ const finish_update_command_1 = require("./commands/finish-update-command");
10
+ const start_upsert_pr_command_1 = require("./commands/start-upsert-pr-command");
11
+ const finish_upsert_pr_command_1 = require("./commands/finish-upsert-pr-command");
12
+ /**
13
+ * The pr-gate application root. `container.get(PrGateApp)` resolves the entire workflow DAG (the 4
14
+ * command classes → the injected git/merge/dashboard services). `@DocumentDesign` marks it the
15
+ * top-of-DAG the DI-design analyzer roots on, so `role:app` pr-gate draws its design. Each `bin/*`
16
+ * entry resolves THIS and calls the matching command method.
17
+ */
18
+ let PrGateApp = class PrGateApp {
19
+ startUpdateCommand;
20
+ finishUpdateCommand;
21
+ startUpsertPrCommand;
22
+ finishUpsertPrCommand;
23
+ constructor(startUpdateCommand, finishUpdateCommand, startUpsertPrCommand, finishUpsertPrCommand) {
24
+ this.startUpdateCommand = startUpdateCommand;
25
+ this.finishUpdateCommand = finishUpdateCommand;
26
+ this.startUpsertPrCommand = startUpsertPrCommand;
27
+ this.finishUpsertPrCommand = finishUpsertPrCommand;
28
+ }
29
+ /** `wp-start-update`: 3-point squash-update from main (no PR). */
30
+ startUpdate() {
31
+ return this.startUpdateCommand.run();
32
+ }
33
+ /** `wp-finish-update`: validate + finalize a resolved 3-point merge (no PR). */
34
+ finishUpdate() {
35
+ return this.finishUpdateCommand.run();
36
+ }
37
+ /** `wp-start-upsert-pr`: update from main, push, advisory build gate, hand off review.json. */
38
+ startUpsertPr() {
39
+ return this.startUpsertPrCommand.run();
40
+ }
41
+ /** `wp-finish-upsert-pr`: finalize merge, authoritative build gate, dashboard, create/update PR. */
42
+ finishUpsertPr() {
43
+ return this.finishUpsertPrCommand.run();
44
+ }
45
+ };
46
+ exports.PrGateApp = PrGateApp;
47
+ exports.PrGateApp = PrGateApp = tslib_1.__decorate([
48
+ (0, core_util_1.DocumentDesign)(),
49
+ (0, core_context_1.provideSingleton)(),
50
+ (0, inversify_1.injectable)(),
51
+ tslib_1.__metadata("design:paramtypes", [start_update_command_1.StartUpdateCommand,
52
+ finish_update_command_1.FinishUpdateCommand,
53
+ start_upsert_pr_command_1.StartUpsertPrCommand,
54
+ finish_upsert_pr_command_1.FinishUpsertPrCommand])
55
+ ], PrGateApp);
56
+ //# sourceMappingURL=pr-gate-app.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pr-gate-app.js","sourceRoot":"","sources":["../../../../../../packages/tooling/pr-gate/src/scripts/pr-gate-app.ts"],"names":[],"mappings":";;;;AAAA,oDAAsD;AACtD,0DAA2D;AAC3D,yCAAuC;AACvC,0EAAqE;AACrE,4EAAuE;AACvE,gFAA0E;AAC1E,kFAA4E;AAE5E;;;;;GAKG;AAII,IAAM,SAAS,GAAf,MAAM,SAAS;IAEG;IACA;IACA;IACA;IAJrB,YACqB,kBAAsC,EACtC,mBAAwC,EACxC,oBAA0C,EAC1C,qBAA4C;QAH5C,uBAAkB,GAAlB,kBAAkB,CAAoB;QACtC,wBAAmB,GAAnB,mBAAmB,CAAqB;QACxC,yBAAoB,GAApB,oBAAoB,CAAsB;QAC1C,0BAAqB,GAArB,qBAAqB,CAAuB;IAC9D,CAAC;IAEJ,kEAAkE;IAClE,WAAW;QACP,OAAO,IAAI,CAAC,kBAAkB,CAAC,GAAG,EAAE,CAAC;IACzC,CAAC;IAED,gFAAgF;IAChF,YAAY;QACR,OAAO,IAAI,CAAC,mBAAmB,CAAC,GAAG,EAAE,CAAC;IAC1C,CAAC;IAED,+FAA+F;IAC/F,aAAa;QACT,OAAO,IAAI,CAAC,oBAAoB,CAAC,GAAG,EAAE,CAAC;IAC3C,CAAC;IAED,oGAAoG;IACpG,cAAc;QACV,OAAO,IAAI,CAAC,qBAAqB,CAAC,GAAG,EAAE,CAAC;IAC5C,CAAC;CACJ,CAAA;AA3BY,8BAAS;oBAAT,SAAS;IAHrB,IAAA,0BAAc,GAAE;IAChB,IAAA,+BAAgB,GAAE;IAClB,IAAA,sBAAU,GAAE;6CAGgC,yCAAkB;QACjB,2CAAmB;QAClB,8CAAoB;QACnB,gDAAqB;GALxD,SAAS,CA2BrB","sourcesContent":["import { DocumentDesign } from '@webpieces/core-util';\nimport { provideSingleton } from '@webpieces/core-context';\nimport { injectable } from 'inversify';\nimport { StartUpdateCommand } from './commands/start-update-command';\nimport { FinishUpdateCommand } from './commands/finish-update-command';\nimport { StartUpsertPrCommand } from './commands/start-upsert-pr-command';\nimport { FinishUpsertPrCommand } from './commands/finish-upsert-pr-command';\n\n/**\n * The pr-gate application root. `container.get(PrGateApp)` resolves the entire workflow DAG (the 4\n * command classes → the injected git/merge/dashboard services). `@DocumentDesign` marks it the\n * top-of-DAG the DI-design analyzer roots on, so `role:app` pr-gate draws its design. Each `bin/*`\n * entry resolves THIS and calls the matching command method.\n */\n@DocumentDesign()\n@provideSingleton()\n@injectable()\nexport class PrGateApp {\n constructor(\n private readonly startUpdateCommand: StartUpdateCommand,\n private readonly finishUpdateCommand: FinishUpdateCommand,\n private readonly startUpsertPrCommand: StartUpsertPrCommand,\n private readonly finishUpsertPrCommand: FinishUpsertPrCommand,\n ) {}\n\n /** `wp-start-update`: 3-point squash-update from main (no PR). */\n startUpdate(): Promise<void> {\n return this.startUpdateCommand.run();\n }\n\n /** `wp-finish-update`: validate + finalize a resolved 3-point merge (no PR). */\n finishUpdate(): Promise<void> {\n return this.finishUpdateCommand.run();\n }\n\n /** `wp-start-upsert-pr`: update from main, push, advisory build gate, hand off review.json. */\n startUpsertPr(): Promise<void> {\n return this.startUpsertPrCommand.run();\n }\n\n /** `wp-finish-upsert-pr`: finalize merge, authoritative build gate, dashboard, create/update PR. */\n finishUpsertPr(): Promise<void> {\n return this.finishUpsertPrCommand.run();\n }\n}\n"]}
@@ -1,8 +1,11 @@
1
- /** Stable base identity (remote / PR / feature-name slug source): trailing `Squash` and the
2
- * generation marker stripped. `base` `base`, `basewp2` `base`, `basewp2Squash` `base`. */
3
- export declare function baseBranchName(branch: string): string;
4
- /** Pre-merge snapshot name for slot `n`, ALWAYS numbered from 1: `<branch>PreMerge1`,
5
- * `<branch>PreMerge2`, The same `n` also names the paired conflict-context folder
6
- * (`merge-info/<slug>/merge-<n>/`, see merge-state.mergeRunDirFor), so the branch and its context
7
- * share one number. Clean syncs delete their snapshot at finalize; only conflict syncs leave one. */
8
- export declare function preMergeBackupName(branch: string, n: number): string;
1
+ export declare class BranchNaming {
2
+ /** Stable base identity (remote / PR / feature-name slug source): trailing `Squash` and the
3
+ * generation marker stripped. `base` `base`, `basewp2` → `base`, `basewp2Squash` → `base`. */
4
+ baseBranchName(branch: string): string;
5
+ /** Pre-merge snapshot name for slot `n`, ALWAYS numbered from 1: `<branch>PreMerge1`,
6
+ * `<branch>PreMerge2`, … The same `n` also names the paired conflict-context folder
7
+ * (`merge-info/<slug>/merge-<n>/`, see merge-state.mergeRunDirFor), so the branch and its context
8
+ * share one number. Clean syncs delete their snapshot at finalize; only conflict syncs leave one. */
9
+ preMergeBackupName(branch: string, n: number): string;
10
+ private parseGeneration;
11
+ }
@@ -21,8 +21,10 @@
21
21
  // names that naturally end in digits, e.g. `deanhiller/upgrade-webpieces-0.3.213`. The tool no longer
22
22
  // PRODUCES `wpN`; the branch-creation-guard still reserves the suffix during the transition.
23
23
  Object.defineProperty(exports, "__esModule", { value: true });
24
- exports.baseBranchName = baseBranchName;
25
- exports.preMergeBackupName = preMergeBackupName;
24
+ exports.BranchNaming = void 0;
25
+ const tslib_1 = require("tslib");
26
+ const core_context_1 = require("@webpieces/core-context");
27
+ const inversify_1 = require("inversify");
26
28
  const GENERATION_RE = /^(.*)wp(\d+)$/;
27
29
  class Generation {
28
30
  base;
@@ -32,24 +34,31 @@ class Generation {
32
34
  this.gen = gen;
33
35
  }
34
36
  }
35
- function parseGeneration(branch) {
36
- const withoutSquash = branch.replace(/Squash$/, '');
37
- const match = withoutSquash.match(GENERATION_RE);
38
- if (match && match[1] !== '') {
39
- return new Generation(match[1], parseInt(match[2], 10));
37
+ let BranchNaming = class BranchNaming {
38
+ /** Stable base identity (remote / PR / feature-name slug source): trailing `Squash` and the
39
+ * generation marker stripped. `base` → `base`, `basewp2` → `base`, `basewp2Squash` → `base`. */
40
+ baseBranchName(branch) {
41
+ return this.parseGeneration(branch).base;
40
42
  }
41
- return new Generation(withoutSquash, 1);
42
- }
43
- /** Stable base identity (remote / PR / feature-name slug source): trailing `Squash` and the
44
- * generation marker stripped. `base` `base`, `basewp2` `base`, `basewp2Squash` `base`. */
45
- function baseBranchName(branch) {
46
- return parseGeneration(branch).base;
47
- }
48
- /** Pre-merge snapshot name for slot `n`, ALWAYS numbered from 1: `<branch>PreMerge1`,
49
- * `<branch>PreMerge2`, The same `n` also names the paired conflict-context folder
50
- * (`merge-info/<slug>/merge-<n>/`, see merge-state.mergeRunDirFor), so the branch and its context
51
- * share one number. Clean syncs delete their snapshot at finalize; only conflict syncs leave one. */
52
- function preMergeBackupName(branch, n) {
53
- return `${branch}PreMerge${n}`;
54
- }
43
+ /** Pre-merge snapshot name for slot `n`, ALWAYS numbered from 1: `<branch>PreMerge1`,
44
+ * `<branch>PreMerge2`, … The same `n` also names the paired conflict-context folder
45
+ * (`merge-info/<slug>/merge-<n>/`, see merge-state.mergeRunDirFor), so the branch and its context
46
+ * share one number. Clean syncs delete their snapshot at finalize; only conflict syncs leave one. */
47
+ preMergeBackupName(branch, n) {
48
+ return `${branch}PreMerge${n}`;
49
+ }
50
+ parseGeneration(branch) {
51
+ const withoutSquash = branch.replace(/Squash$/, '');
52
+ const match = withoutSquash.match(GENERATION_RE);
53
+ if (match && match[1] !== '') {
54
+ return new Generation(match[1], parseInt(match[2], 10));
55
+ }
56
+ return new Generation(withoutSquash, 1);
57
+ }
58
+ };
59
+ exports.BranchNaming = BranchNaming;
60
+ exports.BranchNaming = BranchNaming = tslib_1.__decorate([
61
+ (0, core_context_1.provideSingleton)(),
62
+ (0, inversify_1.injectable)()
63
+ ], BranchNaming);
55
64
  //# sourceMappingURL=branch-naming.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"branch-naming.js","sourceRoot":"","sources":["../../../../../../../packages/tooling/pr-gate/src/scripts/workflow/branch-naming.ts"],"names":[],"mappings":";AAAA,6CAA6C;AAC7C,EAAE;AACF,sGAAsG;AACtG,oGAAoG;AACpG,gGAAgG;AAChG,kGAAkG;AAClG,oGAAoG;AACpG,iGAAiG;AACjG,EAAE;AACF,oGAAoG;AACpG,sGAAsG;AACtG,oGAAoG;AACpG,sGAAsG;AACtG,kGAAkG;AAClG,EAAE;AACF,sGAAsG;AACtG,iGAAiG;AACjG,iGAAiG;AACjG,oGAAoG;AACpG,sGAAsG;AACtG,6FAA6F;;AAyB7F,wCAEC;AAMD,gDAEC;AAjCD,MAAM,aAAa,GAAG,eAAe,CAAC;AAEtC,MAAM,UAAU;IACZ,IAAI,CAAS;IACb,GAAG,CAAS;IAEZ,YAAY,IAAY,EAAE,GAAW;QACjC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;IACnB,CAAC;CACJ;AAED,SAAS,eAAe,CAAC,MAAc;IACnC,MAAM,aAAa,GAAG,MAAM,CAAC,OAAO,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC;IACpD,MAAM,KAAK,GAAG,aAAa,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC;IACjD,IAAI,KAAK,IAAI,KAAK,CAAC,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC;QAC3B,OAAO,IAAI,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC;IAC5D,CAAC;IACD,OAAO,IAAI,UAAU,CAAC,aAAa,EAAE,CAAC,CAAC,CAAC;AAC5C,CAAC;AAED;iGACiG;AACjG,SAAgB,cAAc,CAAC,MAAc;IACzC,OAAO,eAAe,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC;AACxC,CAAC;AAED;;;sGAGsG;AACtG,SAAgB,kBAAkB,CAAC,MAAc,EAAE,CAAS;IACxD,OAAO,GAAG,MAAM,WAAW,CAAC,EAAE,CAAC;AACnC,CAAC","sourcesContent":["// Branch-naming for the squash-merge scheme.\n//\n// A feature branch has ONE stable name that never changes: it is the local branch, the remote branch,\n// AND the single PR head — all identical, so \"which branch is my PR on?\" is never ambiguous. A sync\n// (re-merge from main) happens on a transient `<branch>Squash` branch and, when it finishes, is\n// force-pushed and RENAMED BACK to the same feature name (see merge-end.finalizeBranch). No `wpN`\n// generation number survives a sync — the old scheme numbered the LOCAL branch up (base → basewp2 →\n// basewp3) while the remote/PR stayed on `base`, which read as \"the PR moved\" when it never did.\n//\n// The pre-merge safety snapshot is a NUMBERED trail — `<branch>PreMerge1`, `<branch>PreMerge2`, … —\n// paired with a durable audit folder `merge-<n>/` of the SAME number (see merge-state). The number is\n// chosen MONOTONICALLY from the existing `merge-<n>/` dirs (merge-state.nextMergeSlotNumber), never\n// recycled. A CLEAN sync deletes its snapshot branch at finalize (no undo point needed) but KEEPS its\n// `merge-<n>/` audit record; a CONFLICT sync keeps both the snapshot branch and its `merge-<n>/`.\n//\n// `baseBranchName` still strips a trailing `Squash` (the transient temp-branch suffix) AND a trailing\n// `wp<digits>` — the latter only for BACKWARD COMPATIBILITY, so a consumer sitting on a leftover\n// `…wp5` branch from the old scheme still resolves to its stable name during the transition. The\n// generation marker `wp<N>` is a literal `wp` prefix (NOT a bare number) so it never mangles branch\n// names that naturally end in digits, e.g. `deanhiller/upgrade-webpieces-0.3.213`. The tool no longer\n// PRODUCES `wpN`; the branch-creation-guard still reserves the suffix during the transition.\n\nconst GENERATION_RE = /^(.*)wp(\\d+)$/;\n\nclass Generation {\n base: string;\n gen: number;\n\n constructor(base: string, gen: number) {\n this.base = base;\n this.gen = gen;\n }\n}\n\nfunction parseGeneration(branch: string): Generation {\n const withoutSquash = branch.replace(/Squash$/, '');\n const match = withoutSquash.match(GENERATION_RE);\n if (match && match[1] !== '') {\n return new Generation(match[1], parseInt(match[2], 10));\n }\n return new Generation(withoutSquash, 1);\n}\n\n/** Stable base identity (remote / PR / feature-name slug source): trailing `Squash` and the\n * generation marker stripped. `base` → `base`, `basewp2` → `base`, `basewp2Squash` → `base`. */\nexport function baseBranchName(branch: string): string {\n return parseGeneration(branch).base;\n}\n\n/** Pre-merge snapshot name for slot `n`, ALWAYS numbered from 1: `<branch>PreMerge1`,\n * `<branch>PreMerge2`, … The same `n` also names the paired conflict-context folder\n * (`merge-info/<slug>/merge-<n>/`, see merge-state.mergeRunDirFor), so the branch and its context\n * share one number. Clean syncs delete their snapshot at finalize; only conflict syncs leave one. */\nexport function preMergeBackupName(branch: string, n: number): string {\n return `${branch}PreMerge${n}`;\n}\n"]}
1
+ {"version":3,"file":"branch-naming.js","sourceRoot":"","sources":["../../../../../../../packages/tooling/pr-gate/src/scripts/workflow/branch-naming.ts"],"names":[],"mappings":";AAAA,6CAA6C;AAC7C,EA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,CAAC;IAC5C,CAAC;CACJ,CAAA;AAvBY,oCAAY;uBAAZ,YAAY;IAFxB,IAAA,+BAAgB,GAAE;IAClB,IAAA,sBAAU,GAAE;GACA,YAAY,CAuBxB","sourcesContent":["// Branch-naming for the squash-merge scheme.\n//\n// A feature branch has ONE stable name that never changes: it is the local branch, the remote branch,\n// AND the single PR head — all identical, so \"which branch is my PR on?\" is never ambiguous. A sync\n// (re-merge from main) happens on a transient `<branch>Squash` branch and, when it finishes, is\n// force-pushed and RENAMED BACK to the same feature name (see merge-end.finalizeBranch). No `wpN`\n// generation number survives a sync — the old scheme numbered the LOCAL branch up (base → basewp2 →\n// basewp3) while the remote/PR stayed on `base`, which read as \"the PR moved\" when it never did.\n//\n// The pre-merge safety snapshot is a NUMBERED trail — `<branch>PreMerge1`, `<branch>PreMerge2`, … —\n// paired with a durable audit folder `merge-<n>/` of the SAME number (see merge-state). The number is\n// chosen MONOTONICALLY from the existing `merge-<n>/` dirs (merge-state.nextMergeSlotNumber), never\n// recycled. A CLEAN sync deletes its snapshot branch at finalize (no undo point needed) but KEEPS its\n// `merge-<n>/` audit record; a CONFLICT sync keeps both the snapshot branch and its `merge-<n>/`.\n//\n// `baseBranchName` still strips a trailing `Squash` (the transient temp-branch suffix) AND a trailing\n// `wp<digits>` — the latter only for BACKWARD COMPATIBILITY, so a consumer sitting on a leftover\n// `…wp5` branch from the old scheme still resolves to its stable name during the transition. The\n// generation marker `wp<N>` is a literal `wp` prefix (NOT a bare number) so it never mangles branch\n// names that naturally end in digits, e.g. `deanhiller/upgrade-webpieces-0.3.213`. The tool no longer\n// PRODUCES `wpN`; the branch-creation-guard still reserves the suffix during the transition.\n\nimport { provideSingleton } from '@webpieces/core-context';\nimport { injectable } from 'inversify';\n\nconst GENERATION_RE = /^(.*)wp(\\d+)$/;\n\nclass Generation {\n base: string;\n gen: number;\n\n constructor(base: string, gen: number) {\n this.base = base;\n this.gen = gen;\n }\n}\n\n@provideSingleton()\n@injectable()\nexport class BranchNaming {\n /** Stable base identity (remote / PR / feature-name slug source): trailing `Squash` and the\n * generation marker stripped. `base` → `base`, `basewp2` → `base`, `basewp2Squash` → `base`. */\n baseBranchName(branch: string): string {\n return this.parseGeneration(branch).base;\n }\n\n /** Pre-merge snapshot name for slot `n`, ALWAYS numbered from 1: `<branch>PreMerge1`,\n * `<branch>PreMerge2`, … The same `n` also names the paired conflict-context folder\n * (`merge-info/<slug>/merge-<n>/`, see merge-state.mergeRunDirFor), so the branch and its context\n * share one number. Clean syncs delete their snapshot at finalize; only conflict syncs leave one. */\n preMergeBackupName(branch: string, n: number): string {\n return `${branch}PreMerge${n}`;\n }\n\n private parseGeneration(branch: string): Generation {\n const withoutSquash = branch.replace(/Squash$/, '');\n const match = withoutSquash.match(GENERATION_RE);\n if (match && match[1] !== '') {\n return new Generation(match[1], parseInt(match[2], 10));\n }\n return new Generation(withoutSquash, 1);\n }\n}\n"]}
@@ -1,28 +1,8 @@
1
1
  export declare const DEFAULT_BUILD_COMMAND = "pnpm nx affected --target=ci --base=$(git merge-base origin/main HEAD)";
2
2
  /**
3
- * Resolve the exact build command this gate will run for a repo: the project's configured
4
- * PrGateConfig.buildCommand, or the default affected-ci command when none is set. Callers
5
- * print this so the AI knows precisely which command to run locally to get the gate passing.
6
- */
7
- export declare function resolveBuildCommand(repoRoot: string): string;
8
- /**
9
- * Run the build gate. Returns the process exit code (0 = pass). `buildCommand` overrides
10
- * the default (sourced from PrGateConfig.buildCommand by callers); empty/undefined uses the
11
- * default affected-ci command.
12
- */
13
- export declare function runBuildAffected(repoRoot: string, buildCommand?: string): number;
14
- /**
15
- * Run the build gate using the project's configured command (PrGateConfig.buildCommand). The
16
- * finish-upsert-pr gate and wp-start-upsert-pr both call THIS so they provably build with the same
17
- * command — the resolution the AI validates is built exactly as the PR command builds it.
18
- * Returns the exit code; callers print their own re-run hint.
19
- */
20
- export declare function runConfiguredBuildGate(repoRoot: string): number;
21
- /**
22
- * The two facts that differ between the wp-start (advisory) and wp-finish (authoritative) build
23
- * gates. Everything else — resolve command, run it, print the re-run hint, exit non-zero on failure
24
- * — is identical, so it lives once in runBuildGate and the difference is passed in here. A class (not
25
- * an object literal) per the codebase's data-structure convention.
3
+ * The two facts that differ between the wp-start (advisory) and wp-finish (authoritative) build gates.
4
+ * Everything else is identical, so it lives once in runBuildGate and the difference is passed in here.
5
+ * A class (not an object literal) per the codebase's data-structure convention.
26
6
  */
27
7
  export declare class BuildGateOptions {
28
8
  label: string;
@@ -30,10 +10,21 @@ export declare class BuildGateOptions {
30
10
  failureHeadline: string;
31
11
  constructor(label: string, rerunCommand: string, failureHeadline: string);
32
12
  }
33
- /**
34
- * Run the configured build gate with consistent framing, throwing CliExitError(buildCode) on failure
35
- * so the bin's main()/runMain owns the exit. Single source of truth: wp-start-upsert-pr and
36
- * wp-finish-upsert-pr both call THIS (only the BuildGateOptions differ) so a fix to the gate flow is
37
- * made once, not in two near-identical copies.
38
- */
39
- export declare function runBuildGate(repoRoot: string, opts: BuildGateOptions): void;
13
+ /** Runs the nx-affected build gate the same way for the advisory and authoritative PR gates. */
14
+ export declare class BuildAffected {
15
+ /**
16
+ * Resolve the exact build command this gate will run: the project's configured
17
+ * PrGateConfig.buildCommand, or the default affected-ci command when none is set.
18
+ */
19
+ resolveBuildCommand(repoRoot: string): string;
20
+ /** Run the build gate. Returns the process exit code (0 = pass). */
21
+ runBuildAffected(repoRoot: string, buildCommand?: string): number;
22
+ /** Run the build gate using the project's configured command (PrGateConfig.buildCommand). */
23
+ runConfiguredBuildGate(repoRoot: string): number;
24
+ /**
25
+ * Run the configured build gate with consistent framing, throwing CliExitError(buildCode) on
26
+ * failure so the bin's main()/runMain owns the exit. Single source of truth: wp-start-upsert-pr and
27
+ * wp-finish-upsert-pr both call THIS (only the BuildGateOptions differ).
28
+ */
29
+ runBuildGate(repoRoot: string, opts: BuildGateOptions): void;
30
+ }