@webpieces/pr-gate 0.3.354 → 0.3.356
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +7 -2
- package/src/dashboard/dashboard.d.ts +12 -3
- package/src/dashboard/dashboard.js +136 -129
- package/src/dashboard/dashboard.js.map +1 -1
- package/src/index.d.ts +2 -1
- package/src/index.js +4 -4
- package/src/index.js.map +1 -1
- package/src/scripts/commands/finish-update-command.d.ts +10 -0
- package/src/scripts/commands/finish-update-command.js +51 -0
- package/src/scripts/commands/finish-update-command.js.map +1 -0
- package/src/scripts/commands/finish-upsert-pr-command.d.ts +22 -0
- package/src/scripts/commands/finish-upsert-pr-command.js +131 -0
- package/src/scripts/commands/finish-upsert-pr-command.js.map +1 -0
- package/src/scripts/commands/start-update-command.d.ts +9 -0
- package/src/scripts/commands/start-update-command.js +67 -0
- package/src/scripts/commands/start-update-command.js.map +1 -0
- package/src/scripts/commands/start-upsert-pr-command.d.ts +15 -0
- package/src/scripts/commands/start-upsert-pr-command.js +73 -0
- package/src/scripts/commands/start-upsert-pr-command.js.map +1 -0
- package/src/scripts/git-finishUpsertPr.d.ts +1 -1
- package/src/scripts/git-finishUpsertPr.js +11 -109
- package/src/scripts/git-finishUpsertPr.js.map +1 -1
- package/src/scripts/git-gatherInfo.d.ts +15 -1
- package/src/scripts/git-gatherInfo.js +79 -61
- package/src/scripts/git-gatherInfo.js.map +1 -1
- package/src/scripts/pr-gate-app.d.ts +25 -0
- package/src/scripts/pr-gate-app.js +56 -0
- package/src/scripts/pr-gate-app.js.map +1 -0
- package/src/scripts/workflow/branch-naming.d.ts +11 -8
- package/src/scripts/workflow/branch-naming.js +30 -21
- package/src/scripts/workflow/branch-naming.js.map +1 -1
- package/src/scripts/workflow/build-affected.d.ts +21 -30
- package/src/scripts/workflow/build-affected.js +57 -63
- package/src/scripts/workflow/build-affected.js.map +1 -1
- package/src/scripts/workflow/cleanTmp.d.ts +6 -1
- package/src/scripts/workflow/cleanTmp.js +83 -78
- package/src/scripts/workflow/cleanTmp.js.map +1 -1
- package/src/scripts/workflow/git-exec.d.ts +32 -28
- package/src/scripts/workflow/git-exec.js +92 -85
- package/src/scripts/workflow/git-exec.js.map +1 -1
- package/src/scripts/workflow/git-findForkPoint.d.ts +12 -3
- package/src/scripts/workflow/git-findForkPoint.js +116 -107
- package/src/scripts/workflow/git-findForkPoint.js.map +1 -1
- package/src/scripts/workflow/git-readAiBranchName.d.ts +7 -2
- package/src/scripts/workflow/git-readAiBranchName.js +24 -15
- package/src/scripts/workflow/git-readAiBranchName.js.map +1 -1
- package/src/scripts/workflow/merge-end.d.ts +21 -6
- package/src/scripts/workflow/merge-end.js +147 -133
- package/src/scripts/workflow/merge-end.js.map +1 -1
- package/src/scripts/workflow/merge-start.d.ts +22 -1
- package/src/scripts/workflow/merge-start.js +180 -186
- package/src/scripts/workflow/merge-start.js.map +1 -1
- package/src/scripts/workflow/merge-state.d.ts +26 -23
- package/src/scripts/workflow/merge-state.js +131 -137
- package/src/scripts/workflow/merge-state.js.map +1 -1
- package/src/scripts/workflow/open-pr-check.d.ts +7 -1
- package/src/scripts/workflow/open-pr-check.js +34 -23
- package/src/scripts/workflow/open-pr-check.js.map +1 -1
- package/src/scripts/workflow/run-update.d.ts +13 -1
- package/src/scripts/workflow/run-update.js +59 -28
- package/src/scripts/workflow/run-update.js.map +1 -1
- package/src/scripts/wp-finish-update.d.ts +1 -1
- package/src/scripts/wp-finish-update.js +11 -30
- package/src/scripts/wp-finish-update.js.map +1 -1
- package/src/scripts/wp-start-update.d.ts +1 -2
- package/src/scripts/wp-start-update.js +11 -51
- package/src/scripts/wp-start-update.js.map +1 -1
- package/src/scripts/wp-start-upsert-pr.d.ts +1 -1
- package/src/scripts/wp-start-upsert-pr.js +11 -47
- 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
|
|
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
|
-
|
|
29
|
-
|
|
30
|
-
|
|
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
|
-
|
|
33
|
-
//
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
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('
|
|
51
|
+
process.stderr.write('📍 Gathering Merge Context\n');
|
|
78
52
|
process.stderr.write(SEP);
|
|
79
53
|
process.stderr.write('\n');
|
|
80
|
-
process.stderr.write('
|
|
81
|
-
|
|
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
|
-
|
|
74
|
+
process.stderr.write('\n');
|
|
75
|
+
return new GatherInfoResult(false, hashes);
|
|
85
76
|
}
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
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":"
|
|
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;AA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AI,CAAC,CAAC;QAC3B,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,0BAA0B,MAAM,CAAC,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
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
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.
|
|
25
|
-
|
|
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
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
return
|
|
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
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
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
|
|
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;;;;AAE7F,0DAA2D;AAC3D,yCAAuC;AAEvC,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;AAIM,IAAM,YAAY,GAAlB,MAAM,YAAY;IACrB;qGACiG;IACjG,cAAc,CAAC,MAAc;QACzB,OAAO,IAAI,CAAC,eAAe,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC;IAC7C,CAAC;IAED;;;0GAGsG;IACtG,kBAAkB,CAAC,MAAc,EAAE,CAAS;QACxC,OAAO,GAAG,MAAM,WAAW,CAAC,EAAE,CAAC;IACnC,CAAC;IAEO,eAAe,CAAC,MAAc;QAClC,MAAM,aAAa,GAAG,MAAM,CAAC,OAAO,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC;QACpD,MAAM,KAAK,GAAG,aAAa,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC;QACjD,IAAI,KAAK,IAAI,KAAK,CAAC,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC;YAC3B,OAAO,IAAI,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC;QAC5D,CAAC;QACD,OAAO,IAAI,UAAU,CAAC,aAAa,EAAE,CAAC,CAAC,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
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
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
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
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
|
+
}
|