@webpieces/pr-gate 0.4.421 → 0.4.423
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 +4 -3
- package/src/scripts/commands/cleanup-command.d.ts +22 -0
- package/src/scripts/commands/cleanup-command.js +74 -0
- package/src/scripts/commands/cleanup-command.js.map +1 -0
- package/src/scripts/pr-gate-app.d.ts +5 -1
- package/src/scripts/pr-gate-app.js +10 -2
- package/src/scripts/pr-gate-app.js.map +1 -1
- package/src/scripts/wp-cleanup.d.ts +2 -0
- package/src/scripts/wp-cleanup.js +16 -0
- package/src/scripts/wp-cleanup.js.map +1 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webpieces/pr-gate",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.423",
|
|
4
4
|
"description": "Gated PR system: 3-point squash-merge, merge validation gate, and red/yellow/green PR dashboard. Standalone scripts, no Nx dependency required.",
|
|
5
5
|
"type": "commonjs",
|
|
6
6
|
"main": "./src/index.js",
|
|
@@ -8,7 +8,8 @@
|
|
|
8
8
|
"wp-finish-upsert-pr": "./src/scripts/git-finishUpsertPr.js",
|
|
9
9
|
"wp-start-upsert-pr": "./src/scripts/wp-start-upsert-pr.js",
|
|
10
10
|
"wp-start-update": "./src/scripts/wp-start-update.js",
|
|
11
|
-
"wp-finish-update": "./src/scripts/wp-finish-update.js"
|
|
11
|
+
"wp-finish-update": "./src/scripts/wp-finish-update.js",
|
|
12
|
+
"wp-cleanup": "./src/scripts/wp-cleanup.js"
|
|
12
13
|
},
|
|
13
14
|
"files": [
|
|
14
15
|
"src/**/*"
|
|
@@ -21,7 +22,7 @@
|
|
|
21
22
|
"directory": "packages/tooling/pr-gate"
|
|
22
23
|
},
|
|
23
24
|
"dependencies": {
|
|
24
|
-
"@webpieces/rules-config": "0.4.
|
|
25
|
+
"@webpieces/rules-config": "0.4.423",
|
|
25
26
|
"@inversifyjs/binding-decorators": "1.1.5",
|
|
26
27
|
"inversify": "7.10.4",
|
|
27
28
|
"reflect-metadata": "0.2.2"
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { BranchReaper, RepoRootFinder } from '@webpieces/rules-config';
|
|
2
|
+
/**
|
|
3
|
+
* wp-cleanup: delete the local branches whose PR is already merged (or that hold no commits).
|
|
4
|
+
*
|
|
5
|
+
* WHY a named command instead of the `git branch -D a b c` the guards used to print: an AI agent
|
|
6
|
+
* reads a raw `-D` as destructive, so it asks permission and stops — which is exactly why branches
|
|
7
|
+
* piled up despite the tooling knowing precisely which ones were dead. `pnpm wp-cleanup` is one
|
|
8
|
+
* boring, allowlistable verb whose safety is a property of the command itself rather than of the
|
|
9
|
+
* agent's judgement about a git flag.
|
|
10
|
+
*
|
|
11
|
+
* All the danger lives in the verdicts, not here — see BranchReaper for why every deleted branch is
|
|
12
|
+
* provably dead and recoverable by hash.
|
|
13
|
+
*/
|
|
14
|
+
export declare class CleanupCommand {
|
|
15
|
+
private readonly repoRootFinder;
|
|
16
|
+
private readonly branchReaper;
|
|
17
|
+
constructor(repoRootFinder: RepoRootFinder, branchReaper: BranchReaper);
|
|
18
|
+
run(): Promise<void>;
|
|
19
|
+
private report;
|
|
20
|
+
private reapedLine;
|
|
21
|
+
private sparedBlock;
|
|
22
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CleanupCommand = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const rules_config_1 = require("@webpieces/rules-config");
|
|
6
|
+
const inversify_1 = require("inversify");
|
|
7
|
+
const SEP = '━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n';
|
|
8
|
+
/**
|
|
9
|
+
* wp-cleanup: delete the local branches whose PR is already merged (or that hold no commits).
|
|
10
|
+
*
|
|
11
|
+
* WHY a named command instead of the `git branch -D a b c` the guards used to print: an AI agent
|
|
12
|
+
* reads a raw `-D` as destructive, so it asks permission and stops — which is exactly why branches
|
|
13
|
+
* piled up despite the tooling knowing precisely which ones were dead. `pnpm wp-cleanup` is one
|
|
14
|
+
* boring, allowlistable verb whose safety is a property of the command itself rather than of the
|
|
15
|
+
* agent's judgement about a git flag.
|
|
16
|
+
*
|
|
17
|
+
* All the danger lives in the verdicts, not here — see BranchReaper for why every deleted branch is
|
|
18
|
+
* provably dead and recoverable by hash.
|
|
19
|
+
*/
|
|
20
|
+
let CleanupCommand = class CleanupCommand {
|
|
21
|
+
repoRootFinder;
|
|
22
|
+
branchReaper;
|
|
23
|
+
constructor(repoRootFinder, branchReaper) {
|
|
24
|
+
this.repoRootFinder = repoRootFinder;
|
|
25
|
+
this.branchReaper = branchReaper;
|
|
26
|
+
}
|
|
27
|
+
run() {
|
|
28
|
+
const repoRoot = this.repoRootFinder.resolveRepoRoot(process.cwd());
|
|
29
|
+
// No cache argument: wp-cleanup recomputes the verdicts itself. The file on disk is allowed to
|
|
30
|
+
// go stale, and stale evidence is fine for BLOCKING but never for DELETING.
|
|
31
|
+
const result = this.branchReaper.reap(repoRoot, 'wp-cleanup');
|
|
32
|
+
process.stdout.write(this.report(result));
|
|
33
|
+
return Promise.resolve();
|
|
34
|
+
}
|
|
35
|
+
report(result) {
|
|
36
|
+
if (result.reaped.length === 0 && result.failed.length === 0) {
|
|
37
|
+
return '\n✅ Nothing to clean up — no local branch is provably dead.\n' + this.sparedBlock(result.spared);
|
|
38
|
+
}
|
|
39
|
+
let out = '\n' + SEP + `🧹 Cleaned up ${String(result.reaped.length)} dead local branch(es)\n` + SEP + '\n';
|
|
40
|
+
for (const entry of result.reaped)
|
|
41
|
+
out += this.reapedLine(entry);
|
|
42
|
+
if (result.failed.length > 0) {
|
|
43
|
+
out += `\n⚠️ ${String(result.failed.length)} branch(es) could not be deleted:\n`;
|
|
44
|
+
for (const entry of result.failed)
|
|
45
|
+
out += ` ✗ ${entry.branch} — ${entry.error}\n`;
|
|
46
|
+
}
|
|
47
|
+
// Printed even on success: a deletion the human cannot undo is a deletion they have to trust
|
|
48
|
+
// blindly, and the whole argument for auto-cleanup is that they never have to.
|
|
49
|
+
out += '\nEvery deletion is logged with its pre-delete SHA in .webpieces/hooks/branch-mutations.log —\n'
|
|
50
|
+
+ 'recover any of them with the `recover=` command on its line.\n';
|
|
51
|
+
return out + this.sparedBlock(result.spared);
|
|
52
|
+
}
|
|
53
|
+
reapedLine(entry) {
|
|
54
|
+
const sha = entry.sha !== '' ? ` (was ${entry.sha.slice(0, 8)})` : '';
|
|
55
|
+
return ` ✓ ${entry.branch}${sha} — ${entry.reason}\n`;
|
|
56
|
+
}
|
|
57
|
+
// The branches we refused to touch, with reasons. Silence here would read as "there was nothing
|
|
58
|
+
// else", when these are precisely the ones only a human can rule on.
|
|
59
|
+
sparedBlock(spared) {
|
|
60
|
+
if (spared.length === 0)
|
|
61
|
+
return '';
|
|
62
|
+
let out = `\nSpared ${String(spared.length)} branch(es) — a human decides on these:\n`;
|
|
63
|
+
for (const entry of spared)
|
|
64
|
+
out += ` • ${entry.branch} — ${entry.reason}\n`;
|
|
65
|
+
return out;
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
exports.CleanupCommand = CleanupCommand;
|
|
69
|
+
exports.CleanupCommand = CleanupCommand = tslib_1.__decorate([
|
|
70
|
+
(0, inversify_1.injectable)(inversify_1.bindingScopeValues.Singleton),
|
|
71
|
+
tslib_1.__metadata("design:paramtypes", [rules_config_1.RepoRootFinder,
|
|
72
|
+
rules_config_1.BranchReaper])
|
|
73
|
+
], CleanupCommand);
|
|
74
|
+
//# sourceMappingURL=cleanup-command.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cleanup-command.js","sourceRoot":"","sources":["../../../../../../../packages/tooling/pr-gate/src/scripts/commands/cleanup-command.ts"],"names":[],"mappings":";;;;AAAA,0DAMi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bindingScopeValues } from 'inversify';\n\nconst SEP = '━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\\n';\n\n/**\n * wp-cleanup: delete the local branches whose PR is already merged (or that hold no commits).\n *\n * WHY a named command instead of the `git branch -D a b c` the guards used to print: an AI agent\n * reads a raw `-D` as destructive, so it asks permission and stops — which is exactly why branches\n * piled up despite the tooling knowing precisely which ones were dead. `pnpm wp-cleanup` is one\n * boring, allowlistable verb whose safety is a property of the command itself rather than of the\n * agent's judgement about a git flag.\n *\n * All the danger lives in the verdicts, not here — see BranchReaper for why every deleted branch is\n * provably dead and recoverable by hash.\n */\n@injectable(bindingScopeValues.Singleton)\nexport class CleanupCommand {\n constructor(\n private readonly repoRootFinder: RepoRootFinder,\n private readonly branchReaper: BranchReaper,\n ) {}\n\n run(): Promise<void> {\n const repoRoot = this.repoRootFinder.resolveRepoRoot(process.cwd());\n // No cache argument: wp-cleanup recomputes the verdicts itself. The file on disk is allowed to\n // go stale, and stale evidence is fine for BLOCKING but never for DELETING.\n const result = this.branchReaper.reap(repoRoot, 'wp-cleanup');\n process.stdout.write(this.report(result));\n return Promise.resolve();\n }\n\n private report(result: ReapResult): string {\n if (result.reaped.length === 0 && result.failed.length === 0) {\n return '\\n✅ Nothing to clean up — no local branch is provably dead.\\n' + this.sparedBlock(result.spared);\n }\n\n let out = '\\n' + SEP + `🧹 Cleaned up ${String(result.reaped.length)} dead local branch(es)\\n` + SEP + '\\n';\n for (const entry of result.reaped) out += this.reapedLine(entry);\n\n if (result.failed.length > 0) {\n out += `\\n⚠️ ${String(result.failed.length)} branch(es) could not be deleted:\\n`;\n for (const entry of result.failed) out += ` ✗ ${entry.branch} — ${entry.error}\\n`;\n }\n\n // Printed even on success: a deletion the human cannot undo is a deletion they have to trust\n // blindly, and the whole argument for auto-cleanup is that they never have to.\n out += '\\nEvery deletion is logged with its pre-delete SHA in .webpieces/hooks/branch-mutations.log —\\n'\n + 'recover any of them with the `recover=` command on its line.\\n';\n return out + this.sparedBlock(result.spared);\n }\n\n private reapedLine(entry: ReapedBranch): string {\n const sha = entry.sha !== '' ? ` (was ${entry.sha.slice(0, 8)})` : '';\n return ` ✓ ${entry.branch}${sha} — ${entry.reason}\\n`;\n }\n\n // The branches we refused to touch, with reasons. Silence here would read as \"there was nothing\n // else\", when these are precisely the ones only a human can rule on.\n private sparedBlock(spared: DeletableBranch[]): string {\n if (spared.length === 0) return '';\n let out = `\\nSpared ${String(spared.length)} branch(es) — a human decides on these:\\n`;\n for (const entry of spared) out += ` • ${entry.branch} — ${entry.reason}\\n`;\n return out;\n }\n}\n"]}
|
|
@@ -2,6 +2,7 @@ import { StartUpdateCommand } from './commands/start-update-command';
|
|
|
2
2
|
import { FinishUpdateCommand } from './commands/finish-update-command';
|
|
3
3
|
import { StartUpsertPrCommand } from './commands/start-upsert-pr-command';
|
|
4
4
|
import { FinishUpsertPrCommand } from './commands/finish-upsert-pr-command';
|
|
5
|
+
import { CleanupCommand } from './commands/cleanup-command';
|
|
5
6
|
/**
|
|
6
7
|
* The pr-gate application root. `container.get(PrGateApp)` resolves the entire workflow DAG (the 4
|
|
7
8
|
* command classes → the injected git/merge/dashboard services). `@DocumentDesign` marks it the
|
|
@@ -13,7 +14,8 @@ export declare class PrGateApp {
|
|
|
13
14
|
private readonly finishUpdateCommand;
|
|
14
15
|
private readonly startUpsertPrCommand;
|
|
15
16
|
private readonly finishUpsertPrCommand;
|
|
16
|
-
|
|
17
|
+
private readonly cleanupCommand;
|
|
18
|
+
constructor(startUpdateCommand: StartUpdateCommand, finishUpdateCommand: FinishUpdateCommand, startUpsertPrCommand: StartUpsertPrCommand, finishUpsertPrCommand: FinishUpsertPrCommand, cleanupCommand: CleanupCommand);
|
|
17
19
|
/** `wp-start-update`: 3-point squash-update from main (no PR). */
|
|
18
20
|
startUpdate(): Promise<void>;
|
|
19
21
|
/** `wp-finish-update`: validate + finalize a resolved 3-point merge (no PR). */
|
|
@@ -22,4 +24,6 @@ export declare class PrGateApp {
|
|
|
22
24
|
startUpsertPr(): Promise<void>;
|
|
23
25
|
/** `wp-finish-upsert-pr`: finalize merge, authoritative build gate, dashboard, create/update PR. */
|
|
24
26
|
finishUpsertPr(): Promise<void>;
|
|
27
|
+
/** `wp-cleanup`: delete local branches whose PR is already merged (or that hold no commits). */
|
|
28
|
+
cleanup(): Promise<void>;
|
|
25
29
|
}
|
|
@@ -8,6 +8,7 @@ const start_update_command_1 = require("./commands/start-update-command");
|
|
|
8
8
|
const finish_update_command_1 = require("./commands/finish-update-command");
|
|
9
9
|
const start_upsert_pr_command_1 = require("./commands/start-upsert-pr-command");
|
|
10
10
|
const finish_upsert_pr_command_1 = require("./commands/finish-upsert-pr-command");
|
|
11
|
+
const cleanup_command_1 = require("./commands/cleanup-command");
|
|
11
12
|
/**
|
|
12
13
|
* The pr-gate application root. `container.get(PrGateApp)` resolves the entire workflow DAG (the 4
|
|
13
14
|
* command classes → the injected git/merge/dashboard services). `@DocumentDesign` marks it the
|
|
@@ -19,11 +20,13 @@ let PrGateApp = class PrGateApp {
|
|
|
19
20
|
finishUpdateCommand;
|
|
20
21
|
startUpsertPrCommand;
|
|
21
22
|
finishUpsertPrCommand;
|
|
22
|
-
|
|
23
|
+
cleanupCommand;
|
|
24
|
+
constructor(startUpdateCommand, finishUpdateCommand, startUpsertPrCommand, finishUpsertPrCommand, cleanupCommand) {
|
|
23
25
|
this.startUpdateCommand = startUpdateCommand;
|
|
24
26
|
this.finishUpdateCommand = finishUpdateCommand;
|
|
25
27
|
this.startUpsertPrCommand = startUpsertPrCommand;
|
|
26
28
|
this.finishUpsertPrCommand = finishUpsertPrCommand;
|
|
29
|
+
this.cleanupCommand = cleanupCommand;
|
|
27
30
|
}
|
|
28
31
|
/** `wp-start-update`: 3-point squash-update from main (no PR). */
|
|
29
32
|
startUpdate() {
|
|
@@ -41,6 +44,10 @@ let PrGateApp = class PrGateApp {
|
|
|
41
44
|
finishUpsertPr() {
|
|
42
45
|
return this.finishUpsertPrCommand.run();
|
|
43
46
|
}
|
|
47
|
+
/** `wp-cleanup`: delete local branches whose PR is already merged (or that hold no commits). */
|
|
48
|
+
cleanup() {
|
|
49
|
+
return this.cleanupCommand.run();
|
|
50
|
+
}
|
|
44
51
|
};
|
|
45
52
|
exports.PrGateApp = PrGateApp;
|
|
46
53
|
exports.PrGateApp = PrGateApp = tslib_1.__decorate([
|
|
@@ -49,6 +56,7 @@ exports.PrGateApp = PrGateApp = tslib_1.__decorate([
|
|
|
49
56
|
tslib_1.__metadata("design:paramtypes", [start_update_command_1.StartUpdateCommand,
|
|
50
57
|
finish_update_command_1.FinishUpdateCommand,
|
|
51
58
|
start_upsert_pr_command_1.StartUpsertPrCommand,
|
|
52
|
-
finish_upsert_pr_command_1.FinishUpsertPrCommand
|
|
59
|
+
finish_upsert_pr_command_1.FinishUpsertPrCommand,
|
|
60
|
+
cleanup_command_1.CleanupCommand])
|
|
53
61
|
], PrGateApp);
|
|
54
62
|
//# sourceMappingURL=pr-gate-app.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pr-gate-app.js","sourceRoot":"","sources":["../../../../../../packages/tooling/pr-gate/src/scripts/pr-gate-app.ts"],"names":[],"mappings":";;;;AAAA,0DAAyD;AACzD,yCAA2D;AAC3D,0EAAqE;AACrE,4EAAuE;AACvE,gFAA0E;AAC1E,kFAA4E;
|
|
1
|
+
{"version":3,"file":"pr-gate-app.js","sourceRoot":"","sources":["../../../../../../packages/tooling/pr-gate/src/scripts/pr-gate-app.ts"],"names":[],"mappings":";;;;AAAA,0DAAyD;AACzD,yCAA2D;AAC3D,0EAAqE;AACrE,4EAAuE;AACvE,gFAA0E;AAC1E,kFAA4E;AAC5E,gEAA4D;AAE5D;;;;;GAKG;AAGI,IAAM,SAAS,GAAf,MAAM,SAAS;IAEG;IACA;IACA;IACA;IACA;IALrB,YACqB,kBAAsC,EACtC,mBAAwC,EACxC,oBAA0C,EAC1C,qBAA4C,EAC5C,cAA8B;QAJ9B,uBAAkB,GAAlB,kBAAkB,CAAoB;QACtC,wBAAmB,GAAnB,mBAAmB,CAAqB;QACxC,yBAAoB,GAApB,oBAAoB,CAAsB;QAC1C,0BAAqB,GAArB,qBAAqB,CAAuB;QAC5C,mBAAc,GAAd,cAAc,CAAgB;IAChD,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;IAED,gGAAgG;IAChG,OAAO;QACH,OAAO,IAAI,CAAC,cAAc,CAAC,GAAG,EAAE,CAAC;IACrC,CAAC;CACJ,CAAA;AAjCY,8BAAS;oBAAT,SAAS;IAFrB,IAAA,6BAAc,GAAE;IAChB,IAAA,sBAAU,EAAC,8BAAkB,CAAC,SAAS,CAAC;6CAGI,yCAAkB;QACjB,2CAAmB;QAClB,8CAAoB;QACnB,gDAAqB;QAC5B,gCAAc;GAN1C,SAAS,CAiCrB","sourcesContent":["import { DocumentDesign } from '@webpieces/rules-config';\nimport { injectable, bindingScopeValues } 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';\nimport { CleanupCommand } from './commands/cleanup-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@injectable(bindingScopeValues.Singleton)\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 private readonly cleanupCommand: CleanupCommand,\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 /** `wp-cleanup`: delete local branches whose PR is already merged (or that hold no commits). */\n cleanup(): Promise<void> {\n return this.cleanupCommand.run();\n }\n}\n"]}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
require("reflect-metadata");
|
|
5
|
+
const inversify_1 = require("inversify");
|
|
6
|
+
const rules_config_1 = require("@webpieces/rules-config");
|
|
7
|
+
const pr_gate_app_1 = require("./pr-gate-app");
|
|
8
|
+
// Composition root: build the container and resolve the app so inversify constructs the whole DAG.
|
|
9
|
+
(0, rules_config_1.runMain)(async () => {
|
|
10
|
+
// autobind self-binds every @injectable(Singleton) tooling class (replaces the buildProviderModule registry scan)
|
|
11
|
+
const container = new inversify_1.Container({ autobind: true });
|
|
12
|
+
// Reject `--help`/bogus flags BEFORE the app touches git — an ignored flag must never start the flow.
|
|
13
|
+
container.get(rules_config_1.CliArgs).assertNoArgs(new rules_config_1.CliUsage('wp-cleanup', 'Delete local branches whose PR is already merged (or that hold no commits).'));
|
|
14
|
+
await container.get(pr_gate_app_1.PrGateApp).cleanup();
|
|
15
|
+
});
|
|
16
|
+
//# sourceMappingURL=wp-cleanup.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wp-cleanup.js","sourceRoot":"","sources":["../../../../../../packages/tooling/pr-gate/src/scripts/wp-cleanup.ts"],"names":[],"mappings":";;;AACA,4BAA0B;AAC1B,yCAAsC;AACtC,0DAAqE;AACrE,+CAA0C;AAE1C,mGAAmG;AACnG,IAAA,sBAAO,EAAC,KAAK,IAAmB,EAAE;IAC9B,kHAAkH;IAClH,MAAM,SAAS,GAAG,IAAI,qBAAS,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC;IACpD,sGAAsG;IACtG,SAAS,CAAC,GAAG,CAAC,sBAAO,CAAC,CAAC,YAAY,CAAC,IAAI,uBAAQ,CAC5C,YAAY,EAAE,6EAA6E,CAAC,CAAC,CAAC;IAClG,MAAM,SAAS,CAAC,GAAG,CAAC,uBAAS,CAAC,CAAC,OAAO,EAAE,CAAC;AAC7C,CAAC,CAAC,CAAC","sourcesContent":["#!/usr/bin/env node\nimport 'reflect-metadata';\nimport { Container } from 'inversify';\nimport { runMain, CliArgs, CliUsage } from '@webpieces/rules-config';\nimport { PrGateApp } from './pr-gate-app';\n\n// Composition root: build the container and resolve the app so inversify constructs the whole DAG.\nrunMain(async (): Promise<void> => {\n // autobind self-binds every @injectable(Singleton) tooling class (replaces the buildProviderModule registry scan)\n const container = new Container({ autobind: true });\n // Reject `--help`/bogus flags BEFORE the app touches git — an ignored flag must never start the flow.\n container.get(CliArgs).assertNoArgs(new CliUsage(\n 'wp-cleanup', 'Delete local branches whose PR is already merged (or that hold no commits).'));\n await container.get(PrGateApp).cleanup();\n});\n"]}
|