@webpieces/pr-gate 0.4.980 → 0.4.982
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 +6 -6
- package/src/scripts/commands/build-command.d.ts +2 -2
- package/src/scripts/commands/build-command.js +2 -2
- package/src/scripts/commands/build-command.js.map +1 -1
- package/src/scripts/commands/push-dev-command.d.ts +20 -1
- package/src/scripts/commands/push-dev-command.js +42 -4
- package/src/scripts/commands/push-dev-command.js.map +1 -1
- package/src/scripts/pr-gate-cli-app.js +2 -1
- package/src/scripts/pr-gate-cli-app.js.map +1 -1
- package/src/scripts/workflow/build-affected.js +6 -1
- package/src/scripts/workflow/build-affected.js.map +1 -1
- package/src/scripts/workflow/build-gate-log.d.ts +14 -11
- package/src/scripts/workflow/build-gate-log.js +17 -17
- package/src/scripts/workflow/build-gate-log.js.map +1 -1
- package/src/scripts/workflow/cleanTmp.d.ts +3 -3
- package/src/scripts/workflow/cleanTmp.js +6 -6
- package/src/scripts/workflow/cleanTmp.js.map +1 -1
- package/src/scripts/workflow/dev-deploy-refs.d.ts +10 -1
- package/src/scripts/workflow/dev-deploy-refs.js +13 -1
- package/src/scripts/workflow/dev-deploy-refs.js.map +1 -1
- package/src/scripts/workflow/gate-log-file.d.ts +11 -10
- package/src/scripts/workflow/gate-log-file.js +22 -18
- package/src/scripts/workflow/gate-log-file.js.map +1 -1
- package/src/scripts/workflow/stage-output-log.js +5 -0
- package/src/scripts/workflow/stage-output-log.js.map +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webpieces/pr-gate",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.982",
|
|
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",
|
|
@@ -16,18 +16,18 @@
|
|
|
16
16
|
},
|
|
17
17
|
"dependencies": {
|
|
18
18
|
"@inversifyjs/binding-decorators": "1.1.5",
|
|
19
|
-
"@webpieces/hook-runtime": "0.4.
|
|
20
|
-
"@webpieces/rules-config": "0.4.
|
|
19
|
+
"@webpieces/hook-runtime": "0.4.982",
|
|
20
|
+
"@webpieces/rules-config": "0.4.982",
|
|
21
21
|
"inversify": "7.10.4",
|
|
22
22
|
"reflect-metadata": "0.2.2",
|
|
23
|
-
"@webpieces/tooling-common": "0.4.
|
|
24
|
-
"@webpieces/repo-workflow-core": "0.4.
|
|
23
|
+
"@webpieces/tooling-common": "0.4.982",
|
|
24
|
+
"@webpieces/repo-workflow-core": "0.4.982"
|
|
25
25
|
},
|
|
26
26
|
"publishConfig": {
|
|
27
27
|
"access": "public"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
|
-
"@webpieces/tooling-testkit": "0.4.
|
|
30
|
+
"@webpieces/tooling-testkit": "0.4.982"
|
|
31
31
|
},
|
|
32
32
|
"types": "./src/index.d.ts",
|
|
33
33
|
"bin": {
|
|
@@ -44,8 +44,8 @@ export declare class BuildOptions {
|
|
|
44
44
|
*
|
|
45
45
|
* ─── The output goes to a FILE, unconditionally ────────────────────────────────────────────────────
|
|
46
46
|
* Every caller of the gate captures, and there is no flag or config key that selects otherwise. That is
|
|
47
|
-
* the reason this bin is worth running: the build's full stdout+stderr land in `.webpieces/build.log`
|
|
48
|
-
* (previous run kept as
|
|
47
|
+
* the reason this bin is worth running: the build's full stdout+stderr land in `.webpieces/logs/build.log`
|
|
48
|
+
* (previous run kept as `build.log.bak` beside it), and the console gets the pointer FIRST, a heartbeat, then the pointer again at
|
|
49
49
|
* that file. A measured session burned ~19 minutes re-running `nx affected` five times with no code
|
|
50
50
|
* change in between, purely to see a different slice of output that had scrolled past. Reading a
|
|
51
51
|
* different slice must cost a `grep`, not a build — see BuildGateLog.
|
|
@@ -58,8 +58,8 @@ exports.BuildOptions = BuildOptions;
|
|
|
58
58
|
*
|
|
59
59
|
* ─── The output goes to a FILE, unconditionally ────────────────────────────────────────────────────
|
|
60
60
|
* Every caller of the gate captures, and there is no flag or config key that selects otherwise. That is
|
|
61
|
-
* the reason this bin is worth running: the build's full stdout+stderr land in `.webpieces/build.log`
|
|
62
|
-
* (previous run kept as
|
|
61
|
+
* the reason this bin is worth running: the build's full stdout+stderr land in `.webpieces/logs/build.log`
|
|
62
|
+
* (previous run kept as `build.log.bak` beside it), and the console gets the pointer FIRST, a heartbeat, then the pointer again at
|
|
63
63
|
* that file. A measured session burned ~19 minutes re-running `nx affected` five times with no code
|
|
64
64
|
* change in between, purely to see a different slice of output that had scrolled past. Reading a
|
|
65
65
|
* different slice must cost a `grep`, not a build — see BuildGateLog.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build-command.js","sourceRoot":"","sources":["../../../../../../../packages/tooling/pr-gate/src/scripts/commands/build-command.ts"],"names":[],"mappings":";;;;AAAA,0DAOiC;AACjC,yCAA2D;AAE3D,+DAA6E;AAC7E,+DAAyD;AAEzD,yFAAyF;AAC5E,QAAA,0BAA0B,GAAG,4BAA4B,CAAC;AAEvE;;;;;;;GAOG;AACH,MAAa,YAAY;IACrB,KAAK,CAAU;IAEf,qGAAqG;IACrG,kGAAkG;IAClG,kGAAkG;IAClG,8FAA8F;IAC9F,yDAAyD;IACzD,YAAY,KAAc;QACtB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACvB,CAAC;CACJ;AAXD,oCAWC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AAEI,IAAM,YAAY,GAAlB,MAAM,YAAY;IAEA;IACA;IACA;IACA;IAJrB,YACqB,aAA4B,EAC5B,cAA8B,EAC9B,SAAoB,EACpB,UAA6B;QAH7B,kBAAa,GAAb,aAAa,CAAe;QAC5B,mBAAc,GAAd,cAAc,CAAgB;QAC9B,cAAS,GAAT,SAAS,CAAW;QACpB,eAAU,GAAV,UAAU,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EACvF,SAAS,EACT,SAAS,EACT;YACI,IAAI,qBAAM,CACN,gFAAgF;gBAC5E,qFAAqF;gBACrF,+EAA+E,EACnF,IAAI,CACP;YACD,IAAI,qBAAM,CACN,qFAAqF;gBACjF,2EAA2E,CAClF;YACD,IAAI,qBAAM,CACN,uEAAuE;gBACnE,0EAA0E,CACjF;YACD,IAAI,qBAAM,CACN,wEAAwE;gBACpE,iFAAiF,CACxF;YACD,IAAI,qBAAM,CACN,iFAAiF;gBAC7E,mCAAmC,CAC1C;SACJ,CACJ,CAAC;IACN,CAAC;IAED,gGAAgG;IAChG,oGAAoG;IAC5F,QAAQ,CAAC,IAA6B;QAC1C,OAAO,IAAI;aACN,GAAG,CAAC,CAAC,KAAmB,EAAU,EAAE;YACjC,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,KAAK,CAAC,SAAS,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC;YAC3E,OAAO,CACH,OAAO,KAAK,CAAC,IAAI,UAAU,KAAK,CAAC,IAAI,IAAI,SAAS,IAAI;gBACtD,UAAU,KAAK,CAAC,MAAM,IAAI,GAAG,OAAO,KAAK,CAAC,EAAE,QAAQ,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG;gBACxE,eAAe,MAAM,CAAC,GAAG,CAAC,GAAG,CAChC,CAAC;QACN,CAAC,CAAC;aACD,IAAI,CAAC,IAAI,CAAC,CAAC;IACpB,CAAC;CACJ,CAAA;AAnGY,oCAAY;uBAAZ,YAAY;IADxB,IAAA,sBAAU,EAAC,8BAAkB,CAAC,SAAS,CAAC;6CAGD,8BAAa;QACZ,6BAAc;QACnB,wBAAS;QACR,gCAAiB;GALzC,YAAY,CAmGxB","sourcesContent":["import {\n BuildsLog,\n HomeConfigService,\n Option,\n RepoRootFinder,\n RuleFailError,\n RunningBuild,\n} from '@webpieces/rules-config';\nimport { injectable, bindingScopeValues } from 'inversify';\n\nimport { BuildAffected, BuildGateOptions } from '../workflow/build-affected';\nimport { BUILD_STAGE } from '../workflow/build-gate-log';\n\n/** The rule name the refusal is reported under, so it is greppable from a transcript. */\nexport const TOO_MANY_CONCURRENT_BUILDS = 'too-many-concurrent-builds';\n\n/**\n * What `wp-build` was asked to do. Data-only (a class, per CLAUDE.md), with exactly one field so far.\n *\n * `force` SKIPS THE CONCURRENCY CHECK AND NOTHING ELSE. It does not touch the command, and it must never\n * grow a field that does: `wp-build` runs `commands.pr-gate.buildCommand` verbatim, and a flag that\n * changed the command would make it a different build from the one the PR gate runs — which is the exact\n * drift this bin exists to delete.\n */\nexport class BuildOptions {\n force: boolean;\n\n // REQUIRED, no default. `new BuildOptions()` and `new BuildOptions(false)` would be two spellings of\n // one decision, and the bare form would keep compiling unchanged if this class ever grew a second\n // field — silently meaning \"not forced\" at a call site that was never revisited. That is the same\n // argument HomeConfig's constructor makes about its own four required parameters; a defaulted\n // parameter is exactly the shim this repo does not ship.\n constructor(force: boolean) {\n this.force = force;\n }\n}\n\n/**\n * `wp-build` — run THE project's build, and nothing else.\n *\n * ─── Why this bin exists ───────────────────────────────────────────────────────────────────────────\n * The correct verification command has lived in `commands.pr-gate.buildCommand` all along, and NOTHING\n * SURFACED IT. So every repo hand-composed its own verify chain, and those chains drifted: one sibling\n * repo's `ci:local` was `prettier --check .` (whole repo) + `wp-ci` (whole monorepo) +\n * `nx affected -t test` with NO `--base` (whole repo again) — three whole-world passes on an inner\n * loop, none of them the command the gate runs. `wp-build` closes that by making the configured value\n * the only thing anyone has to type.\n *\n * ─── It composes NOTHING, deliberately ─────────────────────────────────────────────────────────────\n * This command runs `commands.pr-gate.buildCommand` VERBATIM and adds no leg of its own — no format\n * check, no lint pass, no extra test run. Composition is exactly what drifted. Anything that must run\n * on every build belongs INSIDE `buildCommand`, where the PR gate runs it too; a leg added here would\n * be a leg the gate never sees, which is the same defect one level in.\n *\n * ─── ONE resolver, and ONE gate ────────────────────────────────────────────────────────────────────\n * `BuildAffected.runBuildGate` is the single code path that resolves the command\n * (`resolveBuildCommand`), announces it, runs it, captures its output to a log file, and renders the\n * failure. `wp-build` calls THAT — it does not re-read the config key and does not hand-write a second\n * failure string. A second reader is a second thing that can drift, and a second failure message is a\n * second thing that can teach a command the gate does not run; drift is the entire reason this bin\n * exists, so reproducing it one level in would be self-defeating.\n *\n * Only `BuildGateOptions` differs from stage ② and stage ③ — the label, the command to re-run, the\n * headline, and the log-file stage id.\n *\n * ─── The output goes to a FILE, unconditionally ────────────────────────────────────────────────────\n * Every caller of the gate captures, and there is no flag or config key that selects otherwise. That is\n * the reason this bin is worth running: the build's full stdout+stderr land in `.webpieces/build.log`\n * (previous run kept as `.webpieces/build.log.bak`), and the console gets a heartbeat plus a pointer at\n * that file. A measured session burned ~19 minutes re-running `nx affected` five times with no code\n * change in between, purely to see a different slice of output that had scrolled past. Reading a\n * different slice must cost a `grep`, not a build — see BuildGateLog.\n */\n@injectable(bindingScopeValues.Singleton)\nexport class BuildCommand {\n constructor(\n private readonly buildAffected: BuildAffected,\n private readonly repoRootFinder: RepoRootFinder,\n private readonly buildsLog: BuildsLog,\n private readonly homeConfig: HomeConfigService,\n ) {}\n\n run(opts: BuildOptions): Promise<void> {\n return this.runGate(opts, false);\n }\n\n /** Human-terminal form used by wp-human-post-pr; build.log remains complete while output is live. */\n runStreaming(opts: BuildOptions): Promise<void> {\n return this.runGate(opts, true);\n }\n\n private runGate(opts: BuildOptions, stream: boolean): Promise<void> {\n const repoRoot = this.repoRootFinder.resolveRepoRoot(process.cwd());\n if (!opts.force) this.assertMachineHasRoom();\n // runBuildGate announces the resolved command, runs it, and throws CliExitError on failure so\n // runMain owns the exit — the same three things it does for stage ② and stage ③. It also writes\n // this build's START/DONE pair to the ledger the check above just read.\n const gateOptions = new BuildGateOptions(\n '🛠️ wp-build',\n 'pnpm wp-build',\n 'Build failed.',\n BUILD_STAGE,\n );\n return stream\n ? this.buildAffected.runBuildGateStreaming(repoRoot, gateOptions)\n : this.buildAffected.runBuildGate(repoRoot, gateOptions);\n }\n\n /**\n * Refuse when this MACHINE is already running `maxConcurrentBuilds` builds.\n *\n * ─── WHY ONLY HERE, AND NEVER ON THE GATE STAGES ─────────────────────────────────────────────────\n * `wp-review-upsert-pr` and `wp-finish-upsert-pr` are the SANCTIONED path, and a refusal there wedges\n * a PR that has nowhere else to go. So they always run — and their builds still write ledger rows, so\n * they count toward what refuses an ad-hoc `wp-build`. The asymmetry is the whole design: the thing\n * that gets throttled is the extra build, not the one the process needs.\n *\n * The cures are `Option`s handed to `RuleFailError`, which `runMain` renders through\n * `formatFixOptions`. They are never numbered by hand in the message — the framework owns\n * \"Fix Option N:\", and a hand-numbered list in a string literal is an automatic review reject.\n */\n private assertMachineHasRoom(): void {\n const live = this.buildsLog.running();\n const max = this.homeConfig.load().maxConcurrentBuilds;\n if (live.length < max) return;\n throw new RuleFailError(\n TOO_MANY_CONCURRENT_BUILDS,\n `This machine is already running ${String(live.length)} build(s), and the limit is ` +\n `${String(max)}. Starting another makes all of them slower — CPU contention between agents ` +\n `building at once was measured at ~3.2x total test time.\\n\\n${this.describe(live)}`,\n undefined,\n undefined,\n [\n new Option(\n 'Re-use the gate you should be running anyway: `pnpm wp-start-upsert-pr` then\\n' +\n '`pnpm wp-review-upsert-pr`. Stage ② runs the SAME `commands.pr-gate.buildCommand`\\n' +\n 'this would have run, so its green is the same evidence — and it posts the PR.',\n true,\n ),\n new Option(\n 'Wait for one of the builds above to finish and run `pnpm wp-build` again. A build\\n' +\n 'that has already died leaves no row: the count only holds live processes.',\n ),\n new Option(\n 'Verify only what you are editing instead of the whole affected set:\\n' +\n '`pnpm exec vitest run <one spec file>`, or `pnpm nx run <project>:test`.',\n ),\n new Option(\n 'Raise the limit for THIS machine, if it genuinely has the cores: put\\n' +\n '`{\"experimental\": {\"maxConcurrentBuilds\": <n>}}` in `~/.webpieces/config.json`.',\n ),\n new Option(\n 'If you are really stuck and cannot use a gate and really really need wp-build\\n' +\n 'then use `pnpm wp-build --force`.',\n ),\n ],\n );\n }\n\n // One line per live build: which repo, which worktree, on what branch, and how long it has been\n // going. Age is what tells a reader whether to wait thirty seconds or go and look at a stuck agent.\n private describe(live: readonly RunningBuild[]): string {\n return live\n .map((build: RunningBuild): string => {\n const age = Math.max(0, Math.round((Date.now() - build.startedMs) / 1000));\n return (\n ` • ${build.repo} [tree=${build.tree || 'primary'}] ` +\n `branch=${build.branch || '?'} by=${build.by} pid=${String(build.pid)} ` +\n `running for ${String(age)}s`\n );\n })\n .join('\\n');\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"build-command.js","sourceRoot":"","sources":["../../../../../../../packages/tooling/pr-gate/src/scripts/commands/build-command.ts"],"names":[],"mappings":";;;;AAAA,0DAOiC;AACjC,yCAA2D;AAE3D,+DAA6E;AAC7E,+DAAyD;AAEzD,yFAAyF;AAC5E,QAAA,0BAA0B,GAAG,4BAA4B,CAAC;AAEvE;;;;;;;GAOG;AACH,MAAa,YAAY;IACrB,KAAK,CAAU;IAEf,qGAAqG;IACrG,kGAAkG;IAClG,kGAAkG;IAClG,8FAA8F;IAC9F,yDAAyD;IACzD,YAAY,KAAc;QACtB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACvB,CAAC;CACJ;AAXD,oCAWC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AAEI,IAAM,YAAY,GAAlB,MAAM,YAAY;IAEA;IACA;IACA;IACA;IAJrB,YACqB,aAA4B,EAC5B,cAA8B,EAC9B,SAAoB,EACpB,UAA6B;QAH7B,kBAAa,GAAb,aAAa,CAAe;QAC5B,mBAAc,GAAd,cAAc,CAAgB;QAC9B,cAAS,GAAT,SAAS,CAAW;QACpB,eAAU,GAAV,UAAU,CAAmB;IAC/C,CAAC;IAEJ,GAAG,CAAC,IAAkB;QAClB,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IACrC,CA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AAM,CACN,qFAAqF;gBACjF,2EAA2E,CAClF;YACD,IAAI,qBAAM,CACN,uEAAuE;gBACnE,0EAA0E,CACjF;YACD,IAAI,qBAAM,CACN,wEAAwE;gBACpE,iFAAiF,CACxF;YACD,IAAI,qBAAM,CACN,iFAAiF;gBAC7E,mCAAmC,CAC1C;SACJ,CACJ,CAAC;IACN,CAAC;IAED,gGAAgG;IAChG,oGAAoG;IAC5F,QAAQ,CAAC,IAA6B;QAC1C,OAAO,IAAI;aACN,GAAG,CAAC,CAAC,KAAmB,EAAU,EAAE;YACjC,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,KAAK,CAAC,SAAS,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC;YAC3E,OAAO,CACH,OAAO,KAAK,CAAC,IAAI,UAAU,KAAK,CAAC,IAAI,IAAI,SAAS,IAAI;gBACtD,UAAU,KAAK,CAAC,MAAM,IAAI,GAAG,OAAO,KAAK,CAAC,EAAE,QAAQ,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG;gBACxE,eAAe,MAAM,CAAC,GAAG,CAAC,GAAG,CAChC,CAAC;QACN,CAAC,CAAC;aACD,IAAI,CAAC,IAAI,CAAC,CAAC;IACpB,CAAC;CACJ,CAAA;AAnGY,oCAAY;uBAAZ,YAAY;IADxB,IAAA,sBAAU,EAAC,8BAAkB,CAAC,SAAS,CAAC;6CAGD,8BAAa;QACZ,6BAAc;QACnB,wBAAS;QACR,gCAAiB;GALzC,YAAY,CAmGxB","sourcesContent":["import {\n BuildsLog,\n HomeConfigService,\n Option,\n RepoRootFinder,\n RuleFailError,\n RunningBuild,\n} from '@webpieces/rules-config';\nimport { injectable, bindingScopeValues } from 'inversify';\n\nimport { BuildAffected, BuildGateOptions } from '../workflow/build-affected';\nimport { BUILD_STAGE } from '../workflow/build-gate-log';\n\n/** The rule name the refusal is reported under, so it is greppable from a transcript. */\nexport const TOO_MANY_CONCURRENT_BUILDS = 'too-many-concurrent-builds';\n\n/**\n * What `wp-build` was asked to do. Data-only (a class, per CLAUDE.md), with exactly one field so far.\n *\n * `force` SKIPS THE CONCURRENCY CHECK AND NOTHING ELSE. It does not touch the command, and it must never\n * grow a field that does: `wp-build` runs `commands.pr-gate.buildCommand` verbatim, and a flag that\n * changed the command would make it a different build from the one the PR gate runs — which is the exact\n * drift this bin exists to delete.\n */\nexport class BuildOptions {\n force: boolean;\n\n // REQUIRED, no default. `new BuildOptions()` and `new BuildOptions(false)` would be two spellings of\n // one decision, and the bare form would keep compiling unchanged if this class ever grew a second\n // field — silently meaning \"not forced\" at a call site that was never revisited. That is the same\n // argument HomeConfig's constructor makes about its own four required parameters; a defaulted\n // parameter is exactly the shim this repo does not ship.\n constructor(force: boolean) {\n this.force = force;\n }\n}\n\n/**\n * `wp-build` — run THE project's build, and nothing else.\n *\n * ─── Why this bin exists ───────────────────────────────────────────────────────────────────────────\n * The correct verification command has lived in `commands.pr-gate.buildCommand` all along, and NOTHING\n * SURFACED IT. So every repo hand-composed its own verify chain, and those chains drifted: one sibling\n * repo's `ci:local` was `prettier --check .` (whole repo) + `wp-ci` (whole monorepo) +\n * `nx affected -t test` with NO `--base` (whole repo again) — three whole-world passes on an inner\n * loop, none of them the command the gate runs. `wp-build` closes that by making the configured value\n * the only thing anyone has to type.\n *\n * ─── It composes NOTHING, deliberately ─────────────────────────────────────────────────────────────\n * This command runs `commands.pr-gate.buildCommand` VERBATIM and adds no leg of its own — no format\n * check, no lint pass, no extra test run. Composition is exactly what drifted. Anything that must run\n * on every build belongs INSIDE `buildCommand`, where the PR gate runs it too; a leg added here would\n * be a leg the gate never sees, which is the same defect one level in.\n *\n * ─── ONE resolver, and ONE gate ────────────────────────────────────────────────────────────────────\n * `BuildAffected.runBuildGate` is the single code path that resolves the command\n * (`resolveBuildCommand`), announces it, runs it, captures its output to a log file, and renders the\n * failure. `wp-build` calls THAT — it does not re-read the config key and does not hand-write a second\n * failure string. A second reader is a second thing that can drift, and a second failure message is a\n * second thing that can teach a command the gate does not run; drift is the entire reason this bin\n * exists, so reproducing it one level in would be self-defeating.\n *\n * Only `BuildGateOptions` differs from stage ② and stage ③ — the label, the command to re-run, the\n * headline, and the log-file stage id.\n *\n * ─── The output goes to a FILE, unconditionally ────────────────────────────────────────────────────\n * Every caller of the gate captures, and there is no flag or config key that selects otherwise. That is\n * the reason this bin is worth running: the build's full stdout+stderr land in `.webpieces/logs/build.log`\n * (previous run kept as `build.log.bak` beside it), and the console gets the pointer FIRST, a heartbeat, then the pointer again at\n * that file. A measured session burned ~19 minutes re-running `nx affected` five times with no code\n * change in between, purely to see a different slice of output that had scrolled past. Reading a\n * different slice must cost a `grep`, not a build — see BuildGateLog.\n */\n@injectable(bindingScopeValues.Singleton)\nexport class BuildCommand {\n constructor(\n private readonly buildAffected: BuildAffected,\n private readonly repoRootFinder: RepoRootFinder,\n private readonly buildsLog: BuildsLog,\n private readonly homeConfig: HomeConfigService,\n ) {}\n\n run(opts: BuildOptions): Promise<void> {\n return this.runGate(opts, false);\n }\n\n /** Human-terminal form used by wp-human-post-pr; build.log remains complete while output is live. */\n runStreaming(opts: BuildOptions): Promise<void> {\n return this.runGate(opts, true);\n }\n\n private runGate(opts: BuildOptions, stream: boolean): Promise<void> {\n const repoRoot = this.repoRootFinder.resolveRepoRoot(process.cwd());\n if (!opts.force) this.assertMachineHasRoom();\n // runBuildGate announces the resolved command, runs it, and throws CliExitError on failure so\n // runMain owns the exit — the same three things it does for stage ② and stage ③. It also writes\n // this build's START/DONE pair to the ledger the check above just read.\n const gateOptions = new BuildGateOptions(\n '🛠️ wp-build',\n 'pnpm wp-build',\n 'Build failed.',\n BUILD_STAGE,\n );\n return stream\n ? this.buildAffected.runBuildGateStreaming(repoRoot, gateOptions)\n : this.buildAffected.runBuildGate(repoRoot, gateOptions);\n }\n\n /**\n * Refuse when this MACHINE is already running `maxConcurrentBuilds` builds.\n *\n * ─── WHY ONLY HERE, AND NEVER ON THE GATE STAGES ─────────────────────────────────────────────────\n * `wp-review-upsert-pr` and `wp-finish-upsert-pr` are the SANCTIONED path, and a refusal there wedges\n * a PR that has nowhere else to go. So they always run — and their builds still write ledger rows, so\n * they count toward what refuses an ad-hoc `wp-build`. The asymmetry is the whole design: the thing\n * that gets throttled is the extra build, not the one the process needs.\n *\n * The cures are `Option`s handed to `RuleFailError`, which `runMain` renders through\n * `formatFixOptions`. They are never numbered by hand in the message — the framework owns\n * \"Fix Option N:\", and a hand-numbered list in a string literal is an automatic review reject.\n */\n private assertMachineHasRoom(): void {\n const live = this.buildsLog.running();\n const max = this.homeConfig.load().maxConcurrentBuilds;\n if (live.length < max) return;\n throw new RuleFailError(\n TOO_MANY_CONCURRENT_BUILDS,\n `This machine is already running ${String(live.length)} build(s), and the limit is ` +\n `${String(max)}. Starting another makes all of them slower — CPU contention between agents ` +\n `building at once was measured at ~3.2x total test time.\\n\\n${this.describe(live)}`,\n undefined,\n undefined,\n [\n new Option(\n 'Re-use the gate you should be running anyway: `pnpm wp-start-upsert-pr` then\\n' +\n '`pnpm wp-review-upsert-pr`. Stage ② runs the SAME `commands.pr-gate.buildCommand`\\n' +\n 'this would have run, so its green is the same evidence — and it posts the PR.',\n true,\n ),\n new Option(\n 'Wait for one of the builds above to finish and run `pnpm wp-build` again. A build\\n' +\n 'that has already died leaves no row: the count only holds live processes.',\n ),\n new Option(\n 'Verify only what you are editing instead of the whole affected set:\\n' +\n '`pnpm exec vitest run <one spec file>`, or `pnpm nx run <project>:test`.',\n ),\n new Option(\n 'Raise the limit for THIS machine, if it genuinely has the cores: put\\n' +\n '`{\"experimental\": {\"maxConcurrentBuilds\": <n>}}` in `~/.webpieces/config.json`.',\n ),\n new Option(\n 'If you are really stuck and cannot use a gate and really really need wp-build\\n' +\n 'then use `pnpm wp-build --force`.',\n ),\n ],\n );\n }\n\n // One line per live build: which repo, which worktree, on what branch, and how long it has been\n // going. Age is what tells a reader whether to wait thirty seconds or go and look at a stuck agent.\n private describe(live: readonly RunningBuild[]): string {\n return live\n .map((build: RunningBuild): string => {\n const age = Math.max(0, Math.round((Date.now() - build.startedMs) / 1000));\n return (\n ` • ${build.repo} [tree=${build.tree || 'primary'}] ` +\n `branch=${build.branch || '?'} by=${build.by} pid=${String(build.pid)} ` +\n `running for ${String(age)}s`\n );\n })\n .join('\\n');\n }\n}\n"]}
|
|
@@ -51,8 +51,27 @@ export declare class PushDevCommand {
|
|
|
51
51
|
run(opts: PushDevOptions): Promise<void>;
|
|
52
52
|
/** `--list`: exactly the live copies, straight from the remote — never a cached local view. */
|
|
53
53
|
private list;
|
|
54
|
-
/**
|
|
54
|
+
/**
|
|
55
|
+
* `--remove`: delete the remote copy, then push the `<removeNamespace>/<branch>` marker (#1395). This
|
|
56
|
+
* IS the rollback — nothing else has to be undone.
|
|
57
|
+
*
|
|
58
|
+
* WHY A MARKER AS WELL AS THE DELETION: a deletion can only be heard by a workflow's `on: delete:`,
|
|
59
|
+
* which GitHub cannot filter by branch, so every branch deletion in the repo started a dev-deploy run.
|
|
60
|
+
* A PUSH to `<removeNamespace>/**` is filterable. The deletion stays, unchanged, so a consumer whose
|
|
61
|
+
* workflow still listens on `delete:` keeps working through the rollout window; the marker is purely
|
|
62
|
+
* additive at the transport level.
|
|
63
|
+
*
|
|
64
|
+
* ORDER: `origin/main` is fetched BEFORE anything is deleted, so a network failure there leaves the
|
|
65
|
+
* pool exactly as it was. The marker push is the last step, and the only one that can fail with the
|
|
66
|
+
* copy already gone — that is the state {@link markerPushFailed} names.
|
|
67
|
+
*/
|
|
55
68
|
private remove;
|
|
69
|
+
/**
|
|
70
|
+
* The one half-done state `--remove` can leave: the copy is deleted, the rebuild signal is not sent.
|
|
71
|
+
* Said out loud because it is invisible otherwise — `--list` already looks right, while the deployed
|
|
72
|
+
* `dev` still runs the removed branch until something else triggers a composition.
|
|
73
|
+
*/
|
|
74
|
+
private markerPushFailed;
|
|
56
75
|
/**
|
|
57
76
|
* The ordinary path: publish HEAD as `<namespace>/<branch>`.
|
|
58
77
|
*
|
|
@@ -102,20 +102,58 @@ let PushDevCommand = class PushDevCommand {
|
|
|
102
102
|
for (const copy of copies)
|
|
103
103
|
out += ` ${copy.sha.slice(0, 8)} ${copy.ref}\n`;
|
|
104
104
|
out += `\nYour CI composes \`${cfg.devBranch}\` from origin/main plus every ref above, on every run.\n`
|
|
105
|
-
+ `Remove yours with: ${rules_config_1.WP_PUSH_DEV} --remove\n
|
|
105
|
+
+ `Remove yours with: ${rules_config_1.WP_PUSH_DEV} --remove (deletes your copy, then pushes the content-free\n`
|
|
106
|
+
+ `\`${cfg.removeMarkerRefFor('<your-branch>')}\` marker your dev workflow triggers on and deletes)\n`;
|
|
106
107
|
process.stdout.write(out);
|
|
107
108
|
}
|
|
108
|
-
/**
|
|
109
|
+
/**
|
|
110
|
+
* `--remove`: delete the remote copy, then push the `<removeNamespace>/<branch>` marker (#1395). This
|
|
111
|
+
* IS the rollback — nothing else has to be undone.
|
|
112
|
+
*
|
|
113
|
+
* WHY A MARKER AS WELL AS THE DELETION: a deletion can only be heard by a workflow's `on: delete:`,
|
|
114
|
+
* which GitHub cannot filter by branch, so every branch deletion in the repo started a dev-deploy run.
|
|
115
|
+
* A PUSH to `<removeNamespace>/**` is filterable. The deletion stays, unchanged, so a consumer whose
|
|
116
|
+
* workflow still listens on `delete:` keeps working through the rollout window; the marker is purely
|
|
117
|
+
* additive at the transport level.
|
|
118
|
+
*
|
|
119
|
+
* ORDER: `origin/main` is fetched BEFORE anything is deleted, so a network failure there leaves the
|
|
120
|
+
* pool exactly as it was. The marker push is the last step, and the only one that can fail with the
|
|
121
|
+
* copy already gone — that is the state {@link markerPushFailed} names.
|
|
122
|
+
*/
|
|
109
123
|
async remove(repoRoot, cfg, branch, targetRef) {
|
|
110
124
|
if (await this.refs.remoteSha(repoRoot, targetRef) === '') {
|
|
111
125
|
process.stdout.write(`\nNothing to remove — \`${targetRef}\` is not published.\n`
|
|
112
126
|
+ `List what IS published with: ${rules_config_1.WP_PUSH_DEV} --list\n`);
|
|
113
127
|
return;
|
|
114
128
|
}
|
|
129
|
+
const markerRef = cfg.removeMarkerRefFor(branch);
|
|
130
|
+
const mainTip = await this.refs.freshMainTip(repoRoot);
|
|
115
131
|
await this.gitExec.runGitChecked(['-C', repoRoot, 'push', 'origin', '--delete', `refs/heads/${targetRef}`], `Failed to delete the dev copy ${targetRef}`);
|
|
132
|
+
// --force: the marker carries no content, so whatever an earlier, never-deleted marker pointed at
|
|
133
|
+
// is worthless — and refusing a non-fast-forward here would strand the rollback half-done.
|
|
134
|
+
const pushed = await this.gitExec.tryGit(['-C', repoRoot, 'push', '--force', 'origin', `${mainTip}:refs/heads/${markerRef}`], repoRoot);
|
|
135
|
+
if (!pushed.ok)
|
|
136
|
+
this.markerPushFailed(cfg, branch, targetRef, markerRef, pushed.stderr);
|
|
116
137
|
process.stdout.write('\n' + SEP + `🗑️ Removed ${targetRef}\n` + SEP + '\n'
|
|
117
|
-
+
|
|
118
|
-
+
|
|
138
|
+
+ `Pushed the marker \`${markerRef}\` (at origin/main ${mainTip.slice(0, 8)}) — your dev workflow triggers\n`
|
|
139
|
+
+ `on it, deletes it, and rebuilds \`${cfg.devBranch}\` without \`${branch}\`. Your branch and any PR on it\n`
|
|
140
|
+
+ 'are untouched.\n');
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* The one half-done state `--remove` can leave: the copy is deleted, the rebuild signal is not sent.
|
|
144
|
+
* Said out loud because it is invisible otherwise — `--list` already looks right, while the deployed
|
|
145
|
+
* `dev` still runs the removed branch until something else triggers a composition.
|
|
146
|
+
*/
|
|
147
|
+
markerPushFailed(cfg, branch, targetRef, markerRef, stderr) {
|
|
148
|
+
throw new rules_config_1.CliExitError(1, '\n' + SEP + `⛔ Removed \`${targetRef}\`, but pushing the rebuild marker \`${markerRef}\` FAILED\n` + SEP + '\n'
|
|
149
|
+
+ `Your copy is already GONE from origin, but \`${cfg.devBranch}\` was NOT rebuilt: the deployed dev server\n`
|
|
150
|
+
+ `still runs \`${branch}\` until the next composition run.\n\n`
|
|
151
|
+
+ 'git said:\n' + (stderr === '' ? ' (no output)' : stderr.split('\n').map((l) => ` ${l}`).join('\n')) + '\n\n'
|
|
152
|
+
+ 'Any later composition run drops your branch on its own, because the copy no longer exists — the next\n'
|
|
153
|
+
+ `\`${rules_config_1.WP_PUSH_DEV}\` by anyone, or a push to main if your workflow composes on that. To force one now,\n`
|
|
154
|
+
+ 'once the cause above is fixed (network, auth, a branch-protection rule on the marker namespace),\n'
|
|
155
|
+
+ 're-publish and remove again; the second remove pushes the marker:\n\n'
|
|
156
|
+
+ ` ${rules_config_1.WP_PUSH_DEV}\n ${rules_config_1.WP_PUSH_DEV} --remove\n`);
|
|
119
157
|
}
|
|
120
158
|
/**
|
|
121
159
|
* The ordinary path: publish HEAD as `<namespace>/<branch>`.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"push-dev-command.js","sourceRoot":"","sources":["../../../../../../../packages/tooling/pr-gate/src/scripts/commands/push-dev-command.ts"],"names":[],"mappings":";;;;AAAA,0DAOiC;AACjC,yCAA2D;AAE3D,mDAA+C;AAC/C,iEAAqE;AACrE,+DAA6E;AAC7E,uEAAkE;AAClE,+EAAyE;AAEzE,MAAM,GAAG,GAAG,0DAA0D,CAAC;AAEvE;;;GAGG;AACH,MAAa,cAAc;IACvB,6CAA6C;IAC7C,MAAM,GAAG,KAAK,CAAC;IACf,sFAAsF;IACtF,IAAI,GAAG,KAAK,CAAC;IACb,qFAAqF;IACrF,KAAK,GAAG,KAAK,CAAC;IACd,uFAAuF;IACvF,gBAAgB,GAAG,KAAK,CAAC;IACzB,gGAAgG;IAChG,OAAO,GAAG,KAAK,CAAC;IAChB,sFAAsF;IACtF,aAAa,GAAG,EAAE,CAAC;CACtB;AAbD,wCAaC;AAED;;;;;;;;;;;;;;;;;GAiBG;AAEI,IAAM,cAAc,GAApB,MAAM,cAAc;IA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kB,gDAAgD,KAAK,CAAC,cAAc,MAAM,CAAC,CAAC;IAC7G,CAAC;CACJ,CAAA;AAnNY,wCAAc;yBAAd,cAAc;IAD1B,IAAA,sBAAU,EAAC,8BAAkB,CAAC,SAAS,CAAC;6CAGA,6BAAc;QACrB,kBAAO;QACV,+BAAa;QACZ,kCAAiB;QAChB,qCAAgB;QACZ,4CAAmB;GAP3C,cAAc,CAmN1B","sourcesContent":["import {\n CliExitError,\n DevDeployConfig,\n RepoRootFinder,\n WP_FINISH_PUSH_DEV,\n WP_PUSH_DEV,\n writeTemplate,\n} from '@webpieces/rules-config';\nimport { injectable, bindingScopeValues } from 'inversify';\n\nimport { GitExec } from '../workflow/git-exec';\nimport { DevCopy, DevDeployRefs } from '../workflow/dev-deploy-refs';\nimport { PushDevState, PushDevStateStore } from '../workflow/push-dev-state';\nimport { DevResolveRunner } from '../workflow/dev-resolve-runner';\nimport { DevDeployWatchHints } from '../workflow/dev-deploy-watch-hints';\n\nconst SEP = '━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\\n';\n\n/**\n * Which of `wp-push-dev`'s modes was asked for. Data-only (per CLAUDE.md) with plain assigned fields\n * rather than a seven-argument constructor — the bin sets what argv carried and nothing else.\n */\nexport class PushDevOptions {\n /** Delete the remote copy — the rollback. */\n remove = false;\n /** List the live copies and stop. The one mode that needs no branch preconditions. */\n list = false;\n /** Discard a conflict resolution already published on the copy, and overwrite it. */\n force = false;\n /** Replay that resolution on top of the new local commits instead of discarding it. */\n rebaseResolution = false;\n /** Compose the other copies onto this one so the shared environment can build them together. */\n resolve = false;\n /** With `--resolve`: merge ONLY this developer's branch. Empty ⇒ every other copy. */\n resolveTarget = '';\n}\n\n/**\n * `wp-push-dev` — publish a DISPOSABLE copy of this branch so a shared dev environment can build it,\n * without landing anything on `main` and without opening a PR.\n *\n * WHY THIS COMMAND HAS TO EXIST AT ALL: `pr-creation-or-push-guard` blocks every `git push`, no\n * exceptions, by design. Its own fix-hint offers \"ask a human to run the push\" for out-of-band cases —\n * which is the right answer for a genuine exception and the wrong one for a routine daily action. Without\n * a gated command there is simply no legal way for an AI to get a branch onto a dev server, so the\n * feature was undoable rather than merely awkward.\n *\n * WHY THERE IS NO BUILD, deliberately unlike `wp-start-upsert-pr`: the shared environment's CI builds the\n * COMPOSED tree (main + every listed branch). A local build here proves the branch compiles against\n * `main` alone, which is not the question — it would be both slower and reassuring about the wrong thing.\n * The gate that matters runs on the composition, in CI, where it belongs.\n *\n * WHAT IT NEVER DOES: touch the feature branch. See DevDeployRefs for the invariant and why the copy\n * exists to hold conflict resolutions that must not reach the PR.\n */\n@injectable(bindingScopeValues.Singleton)\nexport class PushDevCommand {\n constructor(\n private readonly repoRootFinder: RepoRootFinder,\n private readonly gitExec: GitExec,\n private readonly refs: DevDeployRefs,\n private readonly store: PushDevStateStore,\n private readonly runner: DevResolveRunner,\n private readonly watchHints: DevDeployWatchHints,\n ) {}\n\n async run(opts: PushDevOptions): Promise<void> {\n const repoRoot = this.repoRootFinder.resolveRepoRoot(process.cwd());\n // Refresh the AI-facing workflow doc so it is present + current for any failure message to cite —\n // same reason every other wp-* command opens this way.\n writeTemplate(repoRoot, 'webpieces.git-workflow.md');\n const cfg = this.refs.config(repoRoot);\n\n // A resolve already in flight owns the checkout; starting a second one would strand the first.\n this.assertNoResolveInProgress(repoRoot);\n\n if (opts.list) {\n await this.list(repoRoot, cfg);\n return;\n }\n\n const branch = this.refs.currentBranch(repoRoot);\n this.refs.assertPushable(cfg, branch);\n const targetRef = cfg.copyRefFor(branch);\n\n if (opts.remove) {\n await this.remove(repoRoot, cfg, branch, targetRef);\n return;\n }\n // Every remaining mode commits or merges, so the tree must be the AI's committed work and nothing\n // else. The tooling never commits for you.\n await this.gitExec.assertCleanTree(repoRoot);\n\n if (opts.resolve) {\n await this.startResolve(repoRoot, cfg, branch, targetRef, opts.resolveTarget);\n return;\n }\n await this.publish(repoRoot, cfg, branch, targetRef, opts);\n }\n\n /** `--list`: exactly the live copies, straight from the remote — never a cached local view. */\n private async list(repoRoot: string, cfg: DevDeployConfig): Promise<void> {\n const copies = await this.refs.liveCopies(repoRoot, cfg);\n if (copies.length === 0) {\n process.stdout.write(\n `\\nNo dev copies published — nothing matches \\`${cfg.copyRefGlob()}\\` on origin.\\n`\n + `Publish this branch's with: ${WP_PUSH_DEV}\\n`);\n return;\n }\n let out = '\\n' + SEP + `📋 ${String(copies.length)} dev cop${copies.length === 1 ? 'y' : 'ies'} on origin\\n` + SEP + '\\n';\n for (const copy of copies) out += ` ${copy.sha.slice(0, 8)} ${copy.ref}\\n`;\n out += `\\nYour CI composes \\`${cfg.devBranch}\\` from origin/main plus every ref above, on every run.\\n`\n + `Remove yours with: ${WP_PUSH_DEV} --remove\\n`;\n process.stdout.write(out);\n }\n\n /** `--remove`: delete the remote copy. This IS the rollback — nothing else has to be undone. */\n private async remove(repoRoot: string, cfg: DevDeployConfig, branch: string, targetRef: string): Promise<void> {\n if (await this.refs.remoteSha(repoRoot, targetRef) === '') {\n process.stdout.write(\n `\\nNothing to remove — \\`${targetRef}\\` is not published.\\n`\n + `List what IS published with: ${WP_PUSH_DEV} --list\\n`);\n return;\n }\n await this.gitExec.runGitChecked(['-C', repoRoot, 'push', 'origin', '--delete', `refs/heads/${targetRef}`],\n `Failed to delete the dev copy ${targetRef}`);\n process.stdout.write(\n '\\n' + SEP + `🗑️ Removed ${targetRef}\\n` + SEP + '\\n'\n + `\\`${branch}\\` will drop out of \\`${cfg.devBranch}\\` on its next composition run. Your branch and any\\n`\n + 'PR on it are untouched.\\n');\n }\n\n /**\n * The ordinary path: publish HEAD as `<namespace>/<branch>`.\n *\n * THE CLOBBER GUARD is the whole of the interesting logic here. If the remote copy holds commits the\n * local branch does not, somebody (quite possibly this developer, days ago) resolved a real conflict\n * over there. A silent force-push destroys work that cost a human a genuine merge resolution, so the\n * default is refusal with two named ways forward — never a \"use --force\" one-liner, which is how a\n * warning becomes a reflex.\n */\n private async publish(repoRoot: string, cfg: DevDeployConfig, branch: string, targetRef: string, opts: PushDevOptions): Promise<void> {\n const remoteSha = await this.refs.remoteSha(repoRoot, targetRef);\n if (remoteSha !== '') {\n await this.refs.fetchCopies(repoRoot, [targetRef]);\n const ahead = await this.refs.commitsOnlyOnRemote(repoRoot, targetRef);\n if (ahead > 0 && opts.rebaseResolution) {\n await this.rebaseResolution(repoRoot, branch, targetRef);\n return;\n }\n if (ahead > 0 && !opts.force) this.refuseClobber(cfg, branch, targetRef, ahead);\n }\n await this.gitExec.runGitChecked(\n ['-C', repoRoot, 'push', ...this.pushSafety(targetRef, remoteSha, opts.force),\n 'origin', `HEAD:refs/heads/${targetRef}`],\n `Failed to publish the dev copy ${targetRef}`);\n // Read AFTER the push, so the sha in the watch hints is provably the one that is now published.\n const published = await this.refs.headSha(repoRoot);\n process.stdout.write(\n '\\n' + SEP + `✅ Published ${targetRef}\\n` + SEP + '\\n'\n + `\\`${branch}\\` is now in the pool your CI composes \\`${cfg.devBranch}\\` from — it will be picked up on\\n`\n + 'the next composition run. No PR was opened and nothing landed on main.\\n\\n'\n + ` ${WP_PUSH_DEV} --list ← what else is in the pool\\n`\n + ` ${WP_PUSH_DEV} --remove ← take this branch back out\\n`\n + this.watchHints.render(cfg, targetRef, published));\n }\n\n /**\n * `--rebase-resolution`: keep the published resolution, replay it on top of the new commits.\n *\n * Implemented as a resolve whose BASE is the local HEAD and whose queue is the copy itself, so a\n * replay that conflicts again lands in exactly the same halt/`wp-finish-push-dev` state machine as\n * any other conflict, rather than inventing a second way to be stuck.\n */\n private async rebaseResolution(repoRoot: string, branch: string, targetRef: string): Promise<void> {\n const state = new PushDevState(branch, this.runner.tmpBranchFor(branch), targetRef, [targetRef]);\n process.stdout.write(\n '\\n' + SEP + `♻️ Replaying the published resolution onto \\`${branch}\\`\\n` + SEP + '\\n'\n + `Merging \\`${targetRef}\\` (which holds the resolution) into your new commits on a throwaway branch.\\n`\n + `Your feature branch \\`${branch}\\` is not touched.\\n\\n`);\n await this.runner.start(repoRoot, state, 'HEAD', [targetRef]);\n }\n\n /**\n * `--resolve`: compose the other copies onto this one, so what is published is what CI will build.\n *\n * With no argument the queue is EVERY other copy, in the same sorted order CI composes them — the\n * local resolution is then a rehearsal of the real composition, not a guess at it. With an argument\n * (the branch a CI conflict message names) it is just that one.\n */\n private async startResolve(repoRoot: string, cfg: DevDeployConfig, branch: string, targetRef: string, only: string): Promise<void> {\n if (await this.refs.remoteSha(repoRoot, targetRef) === '') {\n throw new CliExitError(2,\n '\\n' + SEP + `⛔ \\`${targetRef}\\` is not published yet\\n` + SEP + '\\n'\n + 'There is nothing to compose against. Publish your copy first, then resolve:\\n'\n + ` ${WP_PUSH_DEV}\\n ${WP_PUSH_DEV} --resolve\\n`);\n }\n const queue = await this.resolveQueue(repoRoot, cfg, targetRef, only);\n if (queue.length === 0) {\n process.stdout.write(\n `\\nNothing to compose — \\`${targetRef}\\` is the only copy in \\`${cfg.copyRefGlob()}\\`.\\n`\n + `Your CI will merge it onto origin/main by itself; there is no other branch to conflict with.\\n`);\n return;\n }\n const state = new PushDevState(branch, this.runner.tmpBranchFor(branch), targetRef, queue);\n process.stdout.write(this.runner.announce(cfg, state));\n await this.runner.start(repoRoot, state, `refs/remotes/origin/${targetRef}`, [targetRef, ...queue]);\n }\n\n // The refs to merge: one named copy, or every copy that is not mine. A named branch is accepted with\n // or without the namespace prefix, because the CI message that names it may print either.\n private async resolveQueue(repoRoot: string, cfg: DevDeployConfig, targetRef: string, only: string): Promise<string[]> {\n const copies = await this.refs.liveCopies(repoRoot, cfg);\n if (only === '') {\n return copies.filter((c: DevCopy): boolean => c.ref !== targetRef).map((c: DevCopy): string => c.ref);\n }\n const wanted = only.startsWith(`${cfg.branchNamespace}/`) ? only : cfg.copyRefFor(only);\n if (wanted === targetRef) {\n throw new CliExitError(2, `\\n⛔ \\`${only}\\` is your own copy — there is nothing to compose it with.\\n`);\n }\n if (!copies.some((c: DevCopy): boolean => c.ref === wanted)) {\n throw new CliExitError(2,\n '\\n' + SEP + `⛔ No published copy \\`${wanted}\\`\\n` + SEP + '\\n'\n + `Live copies (${WP_PUSH_DEV} --list):\\n`\n + copies.map((c: DevCopy): string => ` ${c.ref}`).join('\\n') + '\\n');\n }\n return [wanted];\n }\n\n /**\n * `--force-with-lease` pinned to the sha we just inspected, so the clobber guard's verdict cannot go\n * stale between the check and the push. Plain `--force` only when the caller explicitly asked to\n * discard, and no force at all for a brand-new copy.\n */\n private pushSafety(targetRef: string, remoteSha: string, force: boolean): string[] {\n if (remoteSha === '') return [];\n if (force) return ['--force'];\n return [`--force-with-lease=refs/heads/${targetRef}:${remoteSha}`];\n }\n\n private refuseClobber(cfg: DevDeployConfig, branch: string, targetRef: string, ahead: number): never {\n throw new CliExitError(2,\n '\\n' + SEP + `⛔ \\`${targetRef}\\` holds ${String(ahead)} commit(s) your branch does not\\n` + SEP + '\\n'\n + 'That is what a CONFLICT RESOLUTION looks like: somebody composed this copy against another\\n'\n + `developer's branch so \\`${cfg.devBranch}\\` could build, and that work exists ONLY on the copy —\\n`\n + 'by design, because it must never reach your feature branch or your PR.\\n\\n'\n + 'Publishing now would force-push over it and destroy it, so this command refuses. Pick one:\\n\\n'\n + ` ${WP_PUSH_DEV} --rebase-resolution\\n`\n + ' Replay that resolution on top of your new commits. Keeps the work; may ask you to\\n'\n + ' re-resolve the parts your new commits actually changed.\\n\\n'\n + ` ${WP_PUSH_DEV} --force\\n`\n + ' Discard it and publish your branch as-is. The composition breaks again until someone\\n'\n + ` re-resolves it with \\`${WP_PUSH_DEV} --resolve\\`.\\n\\n`\n + `See what is on the copy: git log --oneline ${branch}..refs/remotes/origin/${targetRef}\\n`);\n }\n\n // A half-finished resolve owns the checkout — it is parked on a throwaway branch, so \"the current\n // branch\" is not the feature branch this command would otherwise act on.\n private assertNoResolveInProgress(repoRoot: string): void {\n const state = this.store.read(repoRoot);\n if (state === null) return;\n throw new CliExitError(2,\n '\\n' + SEP + '⛔ A dev-deploy resolve is already in progress\\n' + SEP + '\\n'\n + `You are on the throwaway branch \\`${state.tmpBranch}\\`, mid-composition. Finish it or bail out:\\n`\n + ` ${WP_FINISH_PUSH_DEV} ← commit the resolution, resume the queue, publish\\n`\n + ` ${WP_FINISH_PUSH_DEV} --abort ← throw it away and go back to \\`${state.originalBranch}\\`\\n`);\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"push-dev-command.js","sourceRoot":"","sources":["../../../../../../../packages/tooling/pr-gate/src/scripts/commands/push-dev-command.ts"],"names":[],"mappings":";;;;AAAA,0DAOiC;AACjC,yCAA2D;AAE3D,mDAA+C;AAC/C,iEAAqE;AACrE,+DAA6E;AAC7E,uEAAkE;AAClE,+EAAyE;AAEzE,MAAM,GAAG,GAAG,0DAA0D,CAAC;AAEvE;;;GAGG;AACH,MAAa,cAAc;IACvB,6CAA6C;IAC7C,MAAM,GAAG,KAAK,CAAC;IACf,sFAAsF;IACtF,IAAI,GAAG,KAAK,CAAC;IACb,qFAAqF;IACrF,KAAK,GAAG,KAAK,CAAC;IACd,uFAAuF;IACvF,gBAAgB,GAAG,KAAK,CAAC;IACzB,gGAAgG;IAChG,OAAO,GAAG,KAAK,CAAC;IAChB,sFAAsF;IACtF,aAAa,GAAG,EAAE,CAAC;CACtB;AAbD,wCAaC;AAED;;;;;;;;;;;;;;;;;GAiBG;AAEI,IAAM,cAAc,GAApB,MAAM,cAAc;IAEF;IACA;IACA;IACA;IACA;IACA;IANrB,YACqB,cAA8B,EAC9B,OAAgB,EAChB,IAAmB,EACnB,KAAwB,EACxB,MAAwB,EACxB,UAA+B;QAL/B,mBAAc,GAAd,cAAc,CAAgB;QAC9B,YAAO,GAAP,OAAO,CAAS;QAChB,SAAI,GAAJ,IAAI,CAAe;QACnB,UAAK,GAAL,KAAK,CAAmB;QACxB,WAAM,GAAN,MAAM,CAAkB;QACxB,eAAU,GAAV,UAAU,CAAqB;IACjD,CAAC;IAEJ,KAAK,CAAC,GAAG,CAAC,IAAoB;QAC1B,MAAM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3C,cAAc,CA2P1B","sourcesContent":["import {\n CliExitError,\n DevDeployConfig,\n RepoRootFinder,\n WP_FINISH_PUSH_DEV,\n WP_PUSH_DEV,\n writeTemplate,\n} from '@webpieces/rules-config';\nimport { injectable, bindingScopeValues } from 'inversify';\n\nimport { GitExec } from '../workflow/git-exec';\nimport { DevCopy, DevDeployRefs } from '../workflow/dev-deploy-refs';\nimport { PushDevState, PushDevStateStore } from '../workflow/push-dev-state';\nimport { DevResolveRunner } from '../workflow/dev-resolve-runner';\nimport { DevDeployWatchHints } from '../workflow/dev-deploy-watch-hints';\n\nconst SEP = '━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\\n';\n\n/**\n * Which of `wp-push-dev`'s modes was asked for. Data-only (per CLAUDE.md) with plain assigned fields\n * rather than a seven-argument constructor — the bin sets what argv carried and nothing else.\n */\nexport class PushDevOptions {\n /** Delete the remote copy — the rollback. */\n remove = false;\n /** List the live copies and stop. The one mode that needs no branch preconditions. */\n list = false;\n /** Discard a conflict resolution already published on the copy, and overwrite it. */\n force = false;\n /** Replay that resolution on top of the new local commits instead of discarding it. */\n rebaseResolution = false;\n /** Compose the other copies onto this one so the shared environment can build them together. */\n resolve = false;\n /** With `--resolve`: merge ONLY this developer's branch. Empty ⇒ every other copy. */\n resolveTarget = '';\n}\n\n/**\n * `wp-push-dev` — publish a DISPOSABLE copy of this branch so a shared dev environment can build it,\n * without landing anything on `main` and without opening a PR.\n *\n * WHY THIS COMMAND HAS TO EXIST AT ALL: `pr-creation-or-push-guard` blocks every `git push`, no\n * exceptions, by design. Its own fix-hint offers \"ask a human to run the push\" for out-of-band cases —\n * which is the right answer for a genuine exception and the wrong one for a routine daily action. Without\n * a gated command there is simply no legal way for an AI to get a branch onto a dev server, so the\n * feature was undoable rather than merely awkward.\n *\n * WHY THERE IS NO BUILD, deliberately unlike `wp-start-upsert-pr`: the shared environment's CI builds the\n * COMPOSED tree (main + every listed branch). A local build here proves the branch compiles against\n * `main` alone, which is not the question — it would be both slower and reassuring about the wrong thing.\n * The gate that matters runs on the composition, in CI, where it belongs.\n *\n * WHAT IT NEVER DOES: touch the feature branch. See DevDeployRefs for the invariant and why the copy\n * exists to hold conflict resolutions that must not reach the PR.\n */\n@injectable(bindingScopeValues.Singleton)\nexport class PushDevCommand {\n constructor(\n private readonly repoRootFinder: RepoRootFinder,\n private readonly gitExec: GitExec,\n private readonly refs: DevDeployRefs,\n private readonly store: PushDevStateStore,\n private readonly runner: DevResolveRunner,\n private readonly watchHints: DevDeployWatchHints,\n ) {}\n\n async run(opts: PushDevOptions): Promise<void> {\n const repoRoot = this.repoRootFinder.resolveRepoRoot(process.cwd());\n // Refresh the AI-facing workflow doc so it is present + current for any failure message to cite —\n // same reason every other wp-* command opens this way.\n writeTemplate(repoRoot, 'webpieces.git-workflow.md');\n const cfg = this.refs.config(repoRoot);\n\n // A resolve already in flight owns the checkout; starting a second one would strand the first.\n this.assertNoResolveInProgress(repoRoot);\n\n if (opts.list) {\n await this.list(repoRoot, cfg);\n return;\n }\n\n const branch = this.refs.currentBranch(repoRoot);\n this.refs.assertPushable(cfg, branch);\n const targetRef = cfg.copyRefFor(branch);\n\n if (opts.remove) {\n await this.remove(repoRoot, cfg, branch, targetRef);\n return;\n }\n // Every remaining mode commits or merges, so the tree must be the AI's committed work and nothing\n // else. The tooling never commits for you.\n await this.gitExec.assertCleanTree(repoRoot);\n\n if (opts.resolve) {\n await this.startResolve(repoRoot, cfg, branch, targetRef, opts.resolveTarget);\n return;\n }\n await this.publish(repoRoot, cfg, branch, targetRef, opts);\n }\n\n /** `--list`: exactly the live copies, straight from the remote — never a cached local view. */\n private async list(repoRoot: string, cfg: DevDeployConfig): Promise<void> {\n const copies = await this.refs.liveCopies(repoRoot, cfg);\n if (copies.length === 0) {\n process.stdout.write(\n `\\nNo dev copies published — nothing matches \\`${cfg.copyRefGlob()}\\` on origin.\\n`\n + `Publish this branch's with: ${WP_PUSH_DEV}\\n`);\n return;\n }\n let out = '\\n' + SEP + `📋 ${String(copies.length)} dev cop${copies.length === 1 ? 'y' : 'ies'} on origin\\n` + SEP + '\\n';\n for (const copy of copies) out += ` ${copy.sha.slice(0, 8)} ${copy.ref}\\n`;\n out += `\\nYour CI composes \\`${cfg.devBranch}\\` from origin/main plus every ref above, on every run.\\n`\n + `Remove yours with: ${WP_PUSH_DEV} --remove (deletes your copy, then pushes the content-free\\n`\n + `\\`${cfg.removeMarkerRefFor('<your-branch>')}\\` marker your dev workflow triggers on and deletes)\\n`;\n process.stdout.write(out);\n }\n\n /**\n * `--remove`: delete the remote copy, then push the `<removeNamespace>/<branch>` marker (#1395). This\n * IS the rollback — nothing else has to be undone.\n *\n * WHY A MARKER AS WELL AS THE DELETION: a deletion can only be heard by a workflow's `on: delete:`,\n * which GitHub cannot filter by branch, so every branch deletion in the repo started a dev-deploy run.\n * A PUSH to `<removeNamespace>/**` is filterable. The deletion stays, unchanged, so a consumer whose\n * workflow still listens on `delete:` keeps working through the rollout window; the marker is purely\n * additive at the transport level.\n *\n * ORDER: `origin/main` is fetched BEFORE anything is deleted, so a network failure there leaves the\n * pool exactly as it was. The marker push is the last step, and the only one that can fail with the\n * copy already gone — that is the state {@link markerPushFailed} names.\n */\n private async remove(repoRoot: string, cfg: DevDeployConfig, branch: string, targetRef: string): Promise<void> {\n if (await this.refs.remoteSha(repoRoot, targetRef) === '') {\n process.stdout.write(\n `\\nNothing to remove — \\`${targetRef}\\` is not published.\\n`\n + `List what IS published with: ${WP_PUSH_DEV} --list\\n`);\n return;\n }\n const markerRef = cfg.removeMarkerRefFor(branch);\n const mainTip = await this.refs.freshMainTip(repoRoot);\n await this.gitExec.runGitChecked(['-C', repoRoot, 'push', 'origin', '--delete', `refs/heads/${targetRef}`],\n `Failed to delete the dev copy ${targetRef}`);\n // --force: the marker carries no content, so whatever an earlier, never-deleted marker pointed at\n // is worthless — and refusing a non-fast-forward here would strand the rollback half-done.\n const pushed = await this.gitExec.tryGit(\n ['-C', repoRoot, 'push', '--force', 'origin', `${mainTip}:refs/heads/${markerRef}`], repoRoot);\n if (!pushed.ok) this.markerPushFailed(cfg, branch, targetRef, markerRef, pushed.stderr);\n process.stdout.write(\n '\\n' + SEP + `🗑️ Removed ${targetRef}\\n` + SEP + '\\n'\n + `Pushed the marker \\`${markerRef}\\` (at origin/main ${mainTip.slice(0, 8)}) — your dev workflow triggers\\n`\n + `on it, deletes it, and rebuilds \\`${cfg.devBranch}\\` without \\`${branch}\\`. Your branch and any PR on it\\n`\n + 'are untouched.\\n');\n }\n\n /**\n * The one half-done state `--remove` can leave: the copy is deleted, the rebuild signal is not sent.\n * Said out loud because it is invisible otherwise — `--list` already looks right, while the deployed\n * `dev` still runs the removed branch until something else triggers a composition.\n */\n private markerPushFailed(cfg: DevDeployConfig, branch: string, targetRef: string, markerRef: string, stderr: string): never {\n throw new CliExitError(1,\n '\\n' + SEP + `⛔ Removed \\`${targetRef}\\`, but pushing the rebuild marker \\`${markerRef}\\` FAILED\\n` + SEP + '\\n'\n + `Your copy is already GONE from origin, but \\`${cfg.devBranch}\\` was NOT rebuilt: the deployed dev server\\n`\n + `still runs \\`${branch}\\` until the next composition run.\\n\\n`\n + 'git said:\\n' + (stderr === '' ? ' (no output)' : stderr.split('\\n').map((l: string): string => ` ${l}`).join('\\n')) + '\\n\\n'\n + 'Any later composition run drops your branch on its own, because the copy no longer exists — the next\\n'\n + `\\`${WP_PUSH_DEV}\\` by anyone, or a push to main if your workflow composes on that. To force one now,\\n`\n + 'once the cause above is fixed (network, auth, a branch-protection rule on the marker namespace),\\n'\n + 're-publish and remove again; the second remove pushes the marker:\\n\\n'\n + ` ${WP_PUSH_DEV}\\n ${WP_PUSH_DEV} --remove\\n`);\n }\n\n /**\n * The ordinary path: publish HEAD as `<namespace>/<branch>`.\n *\n * THE CLOBBER GUARD is the whole of the interesting logic here. If the remote copy holds commits the\n * local branch does not, somebody (quite possibly this developer, days ago) resolved a real conflict\n * over there. A silent force-push destroys work that cost a human a genuine merge resolution, so the\n * default is refusal with two named ways forward — never a \"use --force\" one-liner, which is how a\n * warning becomes a reflex.\n */\n private async publish(repoRoot: string, cfg: DevDeployConfig, branch: string, targetRef: string, opts: PushDevOptions): Promise<void> {\n const remoteSha = await this.refs.remoteSha(repoRoot, targetRef);\n if (remoteSha !== '') {\n await this.refs.fetchCopies(repoRoot, [targetRef]);\n const ahead = await this.refs.commitsOnlyOnRemote(repoRoot, targetRef);\n if (ahead > 0 && opts.rebaseResolution) {\n await this.rebaseResolution(repoRoot, branch, targetRef);\n return;\n }\n if (ahead > 0 && !opts.force) this.refuseClobber(cfg, branch, targetRef, ahead);\n }\n await this.gitExec.runGitChecked(\n ['-C', repoRoot, 'push', ...this.pushSafety(targetRef, remoteSha, opts.force),\n 'origin', `HEAD:refs/heads/${targetRef}`],\n `Failed to publish the dev copy ${targetRef}`);\n // Read AFTER the push, so the sha in the watch hints is provably the one that is now published.\n const published = await this.refs.headSha(repoRoot);\n process.stdout.write(\n '\\n' + SEP + `✅ Published ${targetRef}\\n` + SEP + '\\n'\n + `\\`${branch}\\` is now in the pool your CI composes \\`${cfg.devBranch}\\` from — it will be picked up on\\n`\n + 'the next composition run. No PR was opened and nothing landed on main.\\n\\n'\n + ` ${WP_PUSH_DEV} --list ← what else is in the pool\\n`\n + ` ${WP_PUSH_DEV} --remove ← take this branch back out\\n`\n + this.watchHints.render(cfg, targetRef, published));\n }\n\n /**\n * `--rebase-resolution`: keep the published resolution, replay it on top of the new commits.\n *\n * Implemented as a resolve whose BASE is the local HEAD and whose queue is the copy itself, so a\n * replay that conflicts again lands in exactly the same halt/`wp-finish-push-dev` state machine as\n * any other conflict, rather than inventing a second way to be stuck.\n */\n private async rebaseResolution(repoRoot: string, branch: string, targetRef: string): Promise<void> {\n const state = new PushDevState(branch, this.runner.tmpBranchFor(branch), targetRef, [targetRef]);\n process.stdout.write(\n '\\n' + SEP + `♻️ Replaying the published resolution onto \\`${branch}\\`\\n` + SEP + '\\n'\n + `Merging \\`${targetRef}\\` (which holds the resolution) into your new commits on a throwaway branch.\\n`\n + `Your feature branch \\`${branch}\\` is not touched.\\n\\n`);\n await this.runner.start(repoRoot, state, 'HEAD', [targetRef]);\n }\n\n /**\n * `--resolve`: compose the other copies onto this one, so what is published is what CI will build.\n *\n * With no argument the queue is EVERY other copy, in the same sorted order CI composes them — the\n * local resolution is then a rehearsal of the real composition, not a guess at it. With an argument\n * (the branch a CI conflict message names) it is just that one.\n */\n private async startResolve(repoRoot: string, cfg: DevDeployConfig, branch: string, targetRef: string, only: string): Promise<void> {\n if (await this.refs.remoteSha(repoRoot, targetRef) === '') {\n throw new CliExitError(2,\n '\\n' + SEP + `⛔ \\`${targetRef}\\` is not published yet\\n` + SEP + '\\n'\n + 'There is nothing to compose against. Publish your copy first, then resolve:\\n'\n + ` ${WP_PUSH_DEV}\\n ${WP_PUSH_DEV} --resolve\\n`);\n }\n const queue = await this.resolveQueue(repoRoot, cfg, targetRef, only);\n if (queue.length === 0) {\n process.stdout.write(\n `\\nNothing to compose — \\`${targetRef}\\` is the only copy in \\`${cfg.copyRefGlob()}\\`.\\n`\n + `Your CI will merge it onto origin/main by itself; there is no other branch to conflict with.\\n`);\n return;\n }\n const state = new PushDevState(branch, this.runner.tmpBranchFor(branch), targetRef, queue);\n process.stdout.write(this.runner.announce(cfg, state));\n await this.runner.start(repoRoot, state, `refs/remotes/origin/${targetRef}`, [targetRef, ...queue]);\n }\n\n // The refs to merge: one named copy, or every copy that is not mine. A named branch is accepted with\n // or without the namespace prefix, because the CI message that names it may print either.\n private async resolveQueue(repoRoot: string, cfg: DevDeployConfig, targetRef: string, only: string): Promise<string[]> {\n const copies = await this.refs.liveCopies(repoRoot, cfg);\n if (only === '') {\n return copies.filter((c: DevCopy): boolean => c.ref !== targetRef).map((c: DevCopy): string => c.ref);\n }\n const wanted = only.startsWith(`${cfg.branchNamespace}/`) ? only : cfg.copyRefFor(only);\n if (wanted === targetRef) {\n throw new CliExitError(2, `\\n⛔ \\`${only}\\` is your own copy — there is nothing to compose it with.\\n`);\n }\n if (!copies.some((c: DevCopy): boolean => c.ref === wanted)) {\n throw new CliExitError(2,\n '\\n' + SEP + `⛔ No published copy \\`${wanted}\\`\\n` + SEP + '\\n'\n + `Live copies (${WP_PUSH_DEV} --list):\\n`\n + copies.map((c: DevCopy): string => ` ${c.ref}`).join('\\n') + '\\n');\n }\n return [wanted];\n }\n\n /**\n * `--force-with-lease` pinned to the sha we just inspected, so the clobber guard's verdict cannot go\n * stale between the check and the push. Plain `--force` only when the caller explicitly asked to\n * discard, and no force at all for a brand-new copy.\n */\n private pushSafety(targetRef: string, remoteSha: string, force: boolean): string[] {\n if (remoteSha === '') return [];\n if (force) return ['--force'];\n return [`--force-with-lease=refs/heads/${targetRef}:${remoteSha}`];\n }\n\n private refuseClobber(cfg: DevDeployConfig, branch: string, targetRef: string, ahead: number): never {\n throw new CliExitError(2,\n '\\n' + SEP + `⛔ \\`${targetRef}\\` holds ${String(ahead)} commit(s) your branch does not\\n` + SEP + '\\n'\n + 'That is what a CONFLICT RESOLUTION looks like: somebody composed this copy against another\\n'\n + `developer's branch so \\`${cfg.devBranch}\\` could build, and that work exists ONLY on the copy —\\n`\n + 'by design, because it must never reach your feature branch or your PR.\\n\\n'\n + 'Publishing now would force-push over it and destroy it, so this command refuses. Pick one:\\n\\n'\n + ` ${WP_PUSH_DEV} --rebase-resolution\\n`\n + ' Replay that resolution on top of your new commits. Keeps the work; may ask you to\\n'\n + ' re-resolve the parts your new commits actually changed.\\n\\n'\n + ` ${WP_PUSH_DEV} --force\\n`\n + ' Discard it and publish your branch as-is. The composition breaks again until someone\\n'\n + ` re-resolves it with \\`${WP_PUSH_DEV} --resolve\\`.\\n\\n`\n + `See what is on the copy: git log --oneline ${branch}..refs/remotes/origin/${targetRef}\\n`);\n }\n\n // A half-finished resolve owns the checkout — it is parked on a throwaway branch, so \"the current\n // branch\" is not the feature branch this command would otherwise act on.\n private assertNoResolveInProgress(repoRoot: string): void {\n const state = this.store.read(repoRoot);\n if (state === null) return;\n throw new CliExitError(2,\n '\\n' + SEP + '⛔ A dev-deploy resolve is already in progress\\n' + SEP + '\\n'\n + `You are on the throwaway branch \\`${state.tmpBranch}\\`, mid-composition. Finish it or bail out:\\n`\n + ` ${WP_FINISH_PUSH_DEV} ← commit the resolution, resume the queue, publish\\n`\n + ` ${WP_FINISH_PUSH_DEV} --abort ← throw it away and go back to \\`${state.originalBranch}\\`\\n`);\n }\n}\n"]}
|
|
@@ -220,7 +220,8 @@ let PrGateCliApp = class PrGateCliApp {
|
|
|
220
220
|
pushDevUsage() {
|
|
221
221
|
return new rules_config_1.CliUsage('wp-push-dev', 'Publish a disposable copy of this branch for shared dev.', [
|
|
222
222
|
new rules_config_1.CliFlag(LIST, 'List published dev copies.'),
|
|
223
|
-
new rules_config_1.CliFlag(REMOVE, "Delete this branch's dev copy
|
|
223
|
+
new rules_config_1.CliFlag(REMOVE, "Delete this branch's dev copy, then push the <removeNamespace>/<branch> marker"
|
|
224
|
+
+ ' (default dev-remove) that triggers the dev rebuild.'),
|
|
224
225
|
new rules_config_1.CliFlag(RESOLVE, 'Compose other published copies, optionally one named branch.', true),
|
|
225
226
|
new rules_config_1.CliFlag(REBASE_RESOLUTION, 'Replay an existing resolution onto new commits.'),
|
|
226
227
|
new rules_config_1.CliFlag(FORCE, 'Discard the published resolution and overwrite it.'),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pr-gate-cli-app.js","sourceRoot":"","sources":["../../../../../../packages/tooling/pr-gate/src/scripts/pr-gate-cli-app.ts"],"names":[],"mappings":";;;;AAAA,mDAA6B;AAE7B,0DAAqI;AACrI,iEAA6D;AAC7D,yCAA2D;AAE3D,0EAAkE;AAClE,4DAAwD;AACxD,gEASoC;AACpC,gFAA0E;AAC1E,gEAA2D;AAC3D,kEAA6D;AAC7D,0EAIyC;AACzC,sFAG+C;AAC/C,+CAA0C;AAG1C,MAAM,KAAK,GAAG,SAAS,CAAC;AACx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CACJ,CAAA;AAtWY,oCAAY;uBAAZ,YAAY;IADxB,IAAA,sBAAU,EAAC,8BAAkB,CAAC,SAAS,CAAC;6CAGX,uBAAS;QACA,8BAAY;QACR,uCAAgB;QACX,kDAAqB;GALxD,YAAY,CAsWxB","sourcesContent":["import * as path from 'path';\n\nimport { CliArgs, CliArgSet, CliExitError, CliFlag, CliUsage, RuleFailError, renderRuleFailForHuman } from '@webpieces/rules-config';\nimport { toError } from '@webpieces/tooling-common/to-error';\nimport { bindingScopeValues, injectable } from 'inversify';\n\nimport { AwaitChecksArgs } from './commands/await-checks-command';\nimport { BuildOptions } from './commands/build-command';\nimport {\n CleanupOptions,\n CleanupUsage,\n DeleteSelection,\n FLAG_DELETE_BRANCHES,\n FLAG_DELETE_WORKTREES,\n FLAG_IGNORE_STALE_LOCKS,\n FLAG_INTERACTIVE,\n FLAG_REPORT,\n} from './commands/cleanup-options';\nimport { FinishPushDevOptions } from './commands/finish-push-dev-command';\nimport { LandPrRequest } from './commands/land-pr-command';\nimport { PushDevOptions } from './commands/push-dev-command';\nimport {\n ReviewBudgetCheckOptions,\n WriteReviewInput,\n WriteReviewOptions,\n} from './commands/write-review-command';\nimport {\n WriteReviewFixesInput,\n WriteReviewFixesOptions,\n} from './commands/write-review-fixes-command';\nimport { PrGateApp } from './pr-gate-app';\nimport { PrGateCliInvocation } from './pr-gate-cli-invocation';\n\nconst ABORT = '--abort';\nconst CHECK = '--check';\nconst CHECKLIST = '--checklist';\nconst FILE = '--file';\nconst FORCE = '--force';\nconst LIST = '--list';\nconst PR = '--pr';\nconst REBASE_RESOLUTION = '--rebase-resolution';\nconst REMOVE = '--remove';\nconst RESOLVE = '--resolve';\n\n/** Stable application boundary for every published `wp-*` command. */\n@injectable(bindingScopeValues.Singleton)\nexport class PrGateCliApp {\n constructor(\n private readonly app: PrGateApp,\n private readonly cleanupUsage: CleanupUsage,\n private readonly writeReviewInput: WriteReviewInput,\n private readonly writeReviewFixesInput: WriteReviewFixesInput,\n ) {}\n\n async run(invocation: PrGateCliInvocation): Promise<void> {\n // eslint-disable-next-line @webpieces/no-unmanaged-exceptions\n try {\n await this.dispatch(path.basename(invocation.binName), invocation);\n } catch (err: unknown) {\n const error = toError(err);\n if (err instanceof CliExitError) {\n if (err.message !== '') {\n (err.exitCode === 0 ? invocation.stdout : invocation.stderr).write(\n err.message + '\\n',\n );\n }\n invocation.processExit.exit(err.exitCode);\n return;\n }\n const message =\n err instanceof RuleFailError ? renderRuleFailForHuman(err) : error.message;\n invocation.stderr.write(message + '\\n');\n invocation.processExit.exit(1);\n }\n }\n\n private async dispatch(binName: string, invocation: PrGateCliInvocation): Promise<void> {\n if (await this.dispatchUpdateCommand(binName, invocation)) return;\n if (await this.dispatchPrCommand(binName, invocation)) return;\n if (await this.dispatchRepoCommand(binName, invocation)) return;\n if (await this.dispatchReviewCommand(binName, invocation)) return;\n throw new CliExitError(2, `Unknown PR-gate command: ${binName}`);\n }\n\n private async dispatchUpdateCommand(\n binName: string,\n invocation: PrGateCliInvocation,\n ): Promise<boolean> {\n if (binName === 'wp-finish-upsert-pr') {\n await this.noArgs(\n invocation,\n this.finishUpsertUsage(),\n (): Promise<void> => this.app.finishUpsertPr(),\n );\n return true;\n }\n if (binName === 'wp-start-upsert-pr') {\n await this.noArgs(\n invocation,\n this.startUpsertUsage(),\n (): Promise<void> => this.app.startUpsertPr(),\n );\n return true;\n }\n if (binName === 'wp-start-update') {\n await this.noArgs(\n invocation,\n this.startUpdateUsage(),\n (): Promise<void> => this.app.startUpdate(),\n );\n return true;\n }\n if (binName === 'wp-finish-update') {\n await this.noArgs(\n invocation,\n this.finishUpdateUsage(),\n (): Promise<void> => this.app.finishUpdate(),\n );\n return true;\n }\n if (binName === 'wp-sync-main') {\n await this.noArgs(\n invocation,\n this.syncMainUsage(),\n (): Promise<void> => this.app.syncMain(),\n );\n return true;\n }\n return false;\n }\n\n private async dispatchPrCommand(\n binName: string,\n invocation: PrGateCliInvocation,\n ): Promise<boolean> {\n if (binName === 'wp-human-post-pr') {\n await this.noArgs(\n invocation,\n this.humanPostUsage(),\n (): Promise<void> => this.app.humanPostPr(),\n );\n return true;\n }\n if (binName === 'wp-upsert-hotfix-pr') {\n await this.noArgs(\n invocation,\n this.hotfixUsage(),\n (): Promise<void> => this.app.upsertHotfixPr(),\n );\n return true;\n }\n if (binName === 'wp-check-pr') {\n await this.noArgs(\n invocation,\n this.checkPrUsage(),\n (): Promise<void> => this.app.checkPr(),\n );\n return true;\n }\n if (binName === 'wp-review-upsert-pr') {\n await this.noArgs(\n invocation,\n this.reviewUpsertUsage(),\n (): Promise<void> => this.app.reviewUpsertPr(),\n );\n return true;\n }\n if (binName === 'wp-await-reviews') {\n await this.noArgs(\n invocation,\n this.awaitReviewsUsage(),\n (): Promise<void> => this.app.awaitReviews(),\n );\n return true;\n }\n return false;\n }\n\n private async dispatchRepoCommand(\n binName: string,\n invocation: PrGateCliInvocation,\n ): Promise<boolean> {\n if (binName === 'wp-build') {\n const args = this.parse(invocation, this.buildUsage());\n await this.app.build(new BuildOptions(args.has(FORCE)));\n return true;\n }\n if (binName === 'wp-cleanup') {\n const args = this.parse(invocation, this.cleanupUsage.declare());\n await this.app.cleanup(\n new CleanupOptions(\n new DeleteSelection(\n FLAG_DELETE_BRANCHES,\n args.has(FLAG_DELETE_BRANCHES),\n args.value(FLAG_DELETE_BRANCHES),\n ),\n new DeleteSelection(\n FLAG_DELETE_WORKTREES,\n args.has(FLAG_DELETE_WORKTREES),\n args.value(FLAG_DELETE_WORKTREES),\n ),\n args.has(FLAG_REPORT),\n args.has(FLAG_INTERACTIVE),\n args.has(FLAG_IGNORE_STALE_LOCKS),\n ),\n );\n return true;\n }\n if (binName === 'wp-land-pr') {\n const args = this.parse(invocation, this.landUsage());\n await this.app.landPr(new LandPrRequest(args.has(PR), args.value(PR)));\n return true;\n }\n if (binName === 'wp-push-dev') {\n const args = this.parse(invocation, this.pushDevUsage());\n const opts = new PushDevOptions();\n opts.list = args.has(LIST);\n opts.remove = args.has(REMOVE);\n opts.force = args.has(FORCE);\n opts.rebaseResolution = args.has(REBASE_RESOLUTION);\n opts.resolve = args.has(RESOLVE);\n opts.resolveTarget = args.value(RESOLVE);\n await this.app.pushDev(opts);\n return true;\n }\n if (binName === 'wp-finish-push-dev') {\n const args = this.parse(invocation, this.finishPushDevUsage());\n await this.app.finishPushDev(new FinishPushDevOptions(args.has(ABORT)));\n return true;\n }\n if (binName === 'wp-await-checks') {\n const args = this.parse(invocation, this.awaitChecksUsage());\n await this.app.awaitChecks(new AwaitChecksArgs().parse(args.value(PR)));\n return true;\n }\n return false;\n }\n\n private async dispatchReviewCommand(\n binName: string,\n invocation: PrGateCliInvocation,\n ): Promise<boolean> {\n if (binName === 'wp-write-review') {\n const args = this.parse(invocation, this.writeReviewUsage());\n if (args.has(CHECK)) {\n await this.app.checkReviewBudget(\n new ReviewBudgetCheckOptions(args.value(CHECKLIST), invocation.cwd),\n );\n return true;\n }\n const json = this.writeReviewInput.read(args.value(FILE), invocation.stdin);\n await this.app.writeReview(\n new WriteReviewOptions(args.value(CHECKLIST), json, invocation.cwd),\n );\n return true;\n }\n if (binName === 'wp-write-review-fixes') {\n const args = this.parse(invocation, this.writeReviewFixesUsage());\n const json = this.writeReviewFixesInput.read(args.value(FILE), invocation.stdin);\n await this.app.writeReviewFixes(new WriteReviewFixesOptions(json, invocation.cwd));\n return true;\n }\n return false;\n }\n\n private parse(invocation: PrGateCliInvocation, usage: CliUsage): CliArgSet {\n return new CliArgs().parseArgs(invocation.argv, usage);\n }\n\n private async noArgs(\n invocation: PrGateCliInvocation,\n usage: CliUsage,\n action: () => Promise<void>,\n ): Promise<void> {\n this.parse(invocation, usage);\n await action();\n }\n\n private buildUsage(): CliUsage {\n return new CliUsage(\n 'wp-build',\n 'Run this repo`s configured build (commands.pr-gate.buildCommand) — the same command the PR gate runs.',\n [\n new CliFlag(\n FORCE,\n 'Build even though this machine is already at its concurrent-build limit.',\n ),\n ],\n );\n }\n\n private finishUpsertUsage(): CliUsage {\n return new CliUsage(\n 'wp-finish-upsert-pr',\n 'Finalize the merge, run the authoritative build gate, render the dashboard, and create/update the PR.',\n );\n }\n private humanPostUsage(): CliUsage {\n return new CliUsage(\n 'wp-human-post-pr',\n 'Interactively attest that a human is posting the current clean, current-main feature branch.',\n );\n }\n private hotfixUsage(): CliUsage {\n return new CliUsage(\n 'wp-upsert-hotfix-pr',\n 'Publish the current /hotfix/ branch through the hotfix gate.',\n );\n }\n private startUpsertUsage(): CliUsage {\n return new CliUsage(\n 'wp-start-upsert-pr',\n 'Update from main and hand off the PR review stage.',\n );\n }\n private startUpdateUsage(): CliUsage {\n return new CliUsage(\n 'wp-start-update',\n '3-point squash-update this feature branch from main (no PR).',\n );\n }\n private finishUpdateUsage(): CliUsage {\n return new CliUsage(\n 'wp-finish-update',\n 'Validate + finalize a resolved 3-point merge (no PR).',\n );\n }\n private syncMainUsage(): CliUsage {\n return new CliUsage(\n 'wp-sync-main',\n 'Go to main, fast-forward it, reap dead worktrees and branches, and sweep orphan directories.',\n );\n }\n private checkPrUsage(): CliUsage {\n return new CliUsage(\n 'wp-check-pr',\n 'CI check: verify this PR was created through the webpieces gated flow (valid gate token).',\n );\n }\n private reviewUpsertUsage(): CliUsage {\n return new CliUsage(\n 'wp-review-upsert-pr',\n 'Validate the merge, build, extract the diff, and brief required reviewers.',\n );\n }\n private awaitReviewsUsage(): CliUsage {\n return new CliUsage('wp-await-reviews', 'Block until every reviewer verdict has landed.');\n }\n\n private landUsage(): CliUsage {\n return new CliUsage(\n 'wp-land-pr',\n 'Squash-merge a PR into main with its description as the commit body.',\n [new CliFlag(PR, 'The PR number to land.', true)],\n );\n }\n\n private pushDevUsage(): CliUsage {\n return new CliUsage(\n 'wp-push-dev',\n 'Publish a disposable copy of this branch for shared dev.',\n [\n new CliFlag(LIST, 'List published dev copies.'),\n new CliFlag(REMOVE, \"Delete this branch's dev copy.\"),\n new CliFlag(\n RESOLVE,\n 'Compose other published copies, optionally one named branch.',\n true,\n ),\n new CliFlag(REBASE_RESOLUTION, 'Replay an existing resolution onto new commits.'),\n new CliFlag(FORCE, 'Discard the published resolution and overwrite it.'),\n ],\n );\n }\n\n private finishPushDevUsage(): CliUsage {\n return new CliUsage(\n 'wp-finish-push-dev',\n 'Commit a resolved dev composition and publish it.',\n [new CliFlag(ABORT, 'Throw the resolve away without publishing.')],\n );\n }\n\n private awaitChecksUsage(): CliUsage {\n return new CliUsage('wp-await-checks', 'Block until checks on one PR stop running.', [\n new CliFlag(PR, 'REQUIRED. The PR number to wait on.', true),\n ]);\n }\n\n private writeReviewUsage(): CliUsage {\n return new CliUsage('wp-write-review', 'Submit one reviewer verdict for one checklist.', [\n new CliFlag(CHECKLIST, 'REQUIRED. The checklist id.', true),\n new CliFlag(FILE, 'The verdict JSON file. Omit to read stdin.', true),\n new CliFlag(CHECK, 'Only check whether this checklist may still be reviewed.'),\n ]);\n }\n\n private writeReviewFixesUsage(): CliUsage {\n return new CliUsage(\n 'wp-write-review-fixes',\n 'Record the coordinator response to red findings.',\n [new CliFlag(FILE, 'JSON file. Omit to read stdin.', true)],\n );\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"pr-gate-cli-app.js","sourceRoot":"","sources":["../../../../../../packages/tooling/pr-gate/src/scripts/pr-gate-cli-app.ts"],"names":[],"mappings":";;;;AAAA,mDAA6B;AAE7B,0DAAqI;AACrI,iEAA6D;AAC7D,yCAA2D;AAE3D,0EAAkE;AAClE,4DAAwD;AACxD,gEASoC;AACpC,gFAA0E;AAC1E,gEAA2D;AAC3D,kEAA6D;AAC7D,0EAIyC;AACzC,sFAG+C;AAC/C,+CAA0C;AAG1C,MAAM,KAAK,GAAG,SAAS,CAAC;AACxB,MAAM,KAAK,GAAG,SAAS,CAAC;AACxB,MAAM,SAAS,GAAG,aAAa,CAAC;AAChC,MAAM,IAAI,GAAG,QAAQ,CAAC;AACtB,MAAM,KAAK,GAAG,SAAS,CAAC;AACxB,MAAM,IAAI,GAAG,QAAQ,C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0WxB","sourcesContent":["import * as path from 'path';\n\nimport { CliArgs, CliArgSet, CliExitError, CliFlag, CliUsage, RuleFailError, renderRuleFailForHuman } from '@webpieces/rules-config';\nimport { toError } from '@webpieces/tooling-common/to-error';\nimport { bindingScopeValues, injectable } from 'inversify';\n\nimport { AwaitChecksArgs } from './commands/await-checks-command';\nimport { BuildOptions } from './commands/build-command';\nimport {\n CleanupOptions,\n CleanupUsage,\n DeleteSelection,\n FLAG_DELETE_BRANCHES,\n FLAG_DELETE_WORKTREES,\n FLAG_IGNORE_STALE_LOCKS,\n FLAG_INTERACTIVE,\n FLAG_REPORT,\n} from './commands/cleanup-options';\nimport { FinishPushDevOptions } from './commands/finish-push-dev-command';\nimport { LandPrRequest } from './commands/land-pr-command';\nimport { PushDevOptions } from './commands/push-dev-command';\nimport {\n ReviewBudgetCheckOptions,\n WriteReviewInput,\n WriteReviewOptions,\n} from './commands/write-review-command';\nimport {\n WriteReviewFixesInput,\n WriteReviewFixesOptions,\n} from './commands/write-review-fixes-command';\nimport { PrGateApp } from './pr-gate-app';\nimport { PrGateCliInvocation } from './pr-gate-cli-invocation';\n\nconst ABORT = '--abort';\nconst CHECK = '--check';\nconst CHECKLIST = '--checklist';\nconst FILE = '--file';\nconst FORCE = '--force';\nconst LIST = '--list';\nconst PR = '--pr';\nconst REBASE_RESOLUTION = '--rebase-resolution';\nconst REMOVE = '--remove';\nconst RESOLVE = '--resolve';\n\n/** Stable application boundary for every published `wp-*` command. */\n@injectable(bindingScopeValues.Singleton)\nexport class PrGateCliApp {\n constructor(\n private readonly app: PrGateApp,\n private readonly cleanupUsage: CleanupUsage,\n private readonly writeReviewInput: WriteReviewInput,\n private readonly writeReviewFixesInput: WriteReviewFixesInput,\n ) {}\n\n async run(invocation: PrGateCliInvocation): Promise<void> {\n // eslint-disable-next-line @webpieces/no-unmanaged-exceptions\n try {\n await this.dispatch(path.basename(invocation.binName), invocation);\n } catch (err: unknown) {\n const error = toError(err);\n if (err instanceof CliExitError) {\n if (err.message !== '') {\n (err.exitCode === 0 ? invocation.stdout : invocation.stderr).write(\n err.message + '\\n',\n );\n }\n invocation.processExit.exit(err.exitCode);\n return;\n }\n const message =\n err instanceof RuleFailError ? renderRuleFailForHuman(err) : error.message;\n invocation.stderr.write(message + '\\n');\n invocation.processExit.exit(1);\n }\n }\n\n private async dispatch(binName: string, invocation: PrGateCliInvocation): Promise<void> {\n if (await this.dispatchUpdateCommand(binName, invocation)) return;\n if (await this.dispatchPrCommand(binName, invocation)) return;\n if (await this.dispatchRepoCommand(binName, invocation)) return;\n if (await this.dispatchReviewCommand(binName, invocation)) return;\n throw new CliExitError(2, `Unknown PR-gate command: ${binName}`);\n }\n\n private async dispatchUpdateCommand(\n binName: string,\n invocation: PrGateCliInvocation,\n ): Promise<boolean> {\n if (binName === 'wp-finish-upsert-pr') {\n await this.noArgs(\n invocation,\n this.finishUpsertUsage(),\n (): Promise<void> => this.app.finishUpsertPr(),\n );\n return true;\n }\n if (binName === 'wp-start-upsert-pr') {\n await this.noArgs(\n invocation,\n this.startUpsertUsage(),\n (): Promise<void> => this.app.startUpsertPr(),\n );\n return true;\n }\n if (binName === 'wp-start-update') {\n await this.noArgs(\n invocation,\n this.startUpdateUsage(),\n (): Promise<void> => this.app.startUpdate(),\n );\n return true;\n }\n if (binName === 'wp-finish-update') {\n await this.noArgs(\n invocation,\n this.finishUpdateUsage(),\n (): Promise<void> => this.app.finishUpdate(),\n );\n return true;\n }\n if (binName === 'wp-sync-main') {\n await this.noArgs(\n invocation,\n this.syncMainUsage(),\n (): Promise<void> => this.app.syncMain(),\n );\n return true;\n }\n return false;\n }\n\n private async dispatchPrCommand(\n binName: string,\n invocation: PrGateCliInvocation,\n ): Promise<boolean> {\n if (binName === 'wp-human-post-pr') {\n await this.noArgs(\n invocation,\n this.humanPostUsage(),\n (): Promise<void> => this.app.humanPostPr(),\n );\n return true;\n }\n if (binName === 'wp-upsert-hotfix-pr') {\n await this.noArgs(\n invocation,\n this.hotfixUsage(),\n (): Promise<void> => this.app.upsertHotfixPr(),\n );\n return true;\n }\n if (binName === 'wp-check-pr') {\n await this.noArgs(\n invocation,\n this.checkPrUsage(),\n (): Promise<void> => this.app.checkPr(),\n );\n return true;\n }\n if (binName === 'wp-review-upsert-pr') {\n await this.noArgs(\n invocation,\n this.reviewUpsertUsage(),\n (): Promise<void> => this.app.reviewUpsertPr(),\n );\n return true;\n }\n if (binName === 'wp-await-reviews') {\n await this.noArgs(\n invocation,\n this.awaitReviewsUsage(),\n (): Promise<void> => this.app.awaitReviews(),\n );\n return true;\n }\n return false;\n }\n\n private async dispatchRepoCommand(\n binName: string,\n invocation: PrGateCliInvocation,\n ): Promise<boolean> {\n if (binName === 'wp-build') {\n const args = this.parse(invocation, this.buildUsage());\n await this.app.build(new BuildOptions(args.has(FORCE)));\n return true;\n }\n if (binName === 'wp-cleanup') {\n const args = this.parse(invocation, this.cleanupUsage.declare());\n await this.app.cleanup(\n new CleanupOptions(\n new DeleteSelection(\n FLAG_DELETE_BRANCHES,\n args.has(FLAG_DELETE_BRANCHES),\n args.value(FLAG_DELETE_BRANCHES),\n ),\n new DeleteSelection(\n FLAG_DELETE_WORKTREES,\n args.has(FLAG_DELETE_WORKTREES),\n args.value(FLAG_DELETE_WORKTREES),\n ),\n args.has(FLAG_REPORT),\n args.has(FLAG_INTERACTIVE),\n args.has(FLAG_IGNORE_STALE_LOCKS),\n ),\n );\n return true;\n }\n if (binName === 'wp-land-pr') {\n const args = this.parse(invocation, this.landUsage());\n await this.app.landPr(new LandPrRequest(args.has(PR), args.value(PR)));\n return true;\n }\n if (binName === 'wp-push-dev') {\n const args = this.parse(invocation, this.pushDevUsage());\n const opts = new PushDevOptions();\n opts.list = args.has(LIST);\n opts.remove = args.has(REMOVE);\n opts.force = args.has(FORCE);\n opts.rebaseResolution = args.has(REBASE_RESOLUTION);\n opts.resolve = args.has(RESOLVE);\n opts.resolveTarget = args.value(RESOLVE);\n await this.app.pushDev(opts);\n return true;\n }\n if (binName === 'wp-finish-push-dev') {\n const args = this.parse(invocation, this.finishPushDevUsage());\n await this.app.finishPushDev(new FinishPushDevOptions(args.has(ABORT)));\n return true;\n }\n if (binName === 'wp-await-checks') {\n const args = this.parse(invocation, this.awaitChecksUsage());\n await this.app.awaitChecks(new AwaitChecksArgs().parse(args.value(PR)));\n return true;\n }\n return false;\n }\n\n private async dispatchReviewCommand(\n binName: string,\n invocation: PrGateCliInvocation,\n ): Promise<boolean> {\n if (binName === 'wp-write-review') {\n const args = this.parse(invocation, this.writeReviewUsage());\n if (args.has(CHECK)) {\n await this.app.checkReviewBudget(\n new ReviewBudgetCheckOptions(args.value(CHECKLIST), invocation.cwd),\n );\n return true;\n }\n const json = this.writeReviewInput.read(args.value(FILE), invocation.stdin);\n await this.app.writeReview(\n new WriteReviewOptions(args.value(CHECKLIST), json, invocation.cwd),\n );\n return true;\n }\n if (binName === 'wp-write-review-fixes') {\n const args = this.parse(invocation, this.writeReviewFixesUsage());\n const json = this.writeReviewFixesInput.read(args.value(FILE), invocation.stdin);\n await this.app.writeReviewFixes(new WriteReviewFixesOptions(json, invocation.cwd));\n return true;\n }\n return false;\n }\n\n private parse(invocation: PrGateCliInvocation, usage: CliUsage): CliArgSet {\n return new CliArgs().parseArgs(invocation.argv, usage);\n }\n\n private async noArgs(\n invocation: PrGateCliInvocation,\n usage: CliUsage,\n action: () => Promise<void>,\n ): Promise<void> {\n this.parse(invocation, usage);\n await action();\n }\n\n private buildUsage(): CliUsage {\n return new CliUsage(\n 'wp-build',\n 'Run this repo`s configured build (commands.pr-gate.buildCommand) — the same command the PR gate runs.',\n [\n new CliFlag(\n FORCE,\n 'Build even though this machine is already at its concurrent-build limit.',\n ),\n ],\n );\n }\n\n private finishUpsertUsage(): CliUsage {\n return new CliUsage(\n 'wp-finish-upsert-pr',\n 'Finalize the merge, run the authoritative build gate, render the dashboard, and create/update the PR.',\n );\n }\n private humanPostUsage(): CliUsage {\n return new CliUsage(\n 'wp-human-post-pr',\n 'Interactively attest that a human is posting the current clean, current-main feature branch.',\n );\n }\n private hotfixUsage(): CliUsage {\n return new CliUsage(\n 'wp-upsert-hotfix-pr',\n 'Publish the current /hotfix/ branch through the hotfix gate.',\n );\n }\n private startUpsertUsage(): CliUsage {\n return new CliUsage(\n 'wp-start-upsert-pr',\n 'Update from main and hand off the PR review stage.',\n );\n }\n private startUpdateUsage(): CliUsage {\n return new CliUsage(\n 'wp-start-update',\n '3-point squash-update this feature branch from main (no PR).',\n );\n }\n private finishUpdateUsage(): CliUsage {\n return new CliUsage(\n 'wp-finish-update',\n 'Validate + finalize a resolved 3-point merge (no PR).',\n );\n }\n private syncMainUsage(): CliUsage {\n return new CliUsage(\n 'wp-sync-main',\n 'Go to main, fast-forward it, reap dead worktrees and branches, and sweep orphan directories.',\n );\n }\n private checkPrUsage(): CliUsage {\n return new CliUsage(\n 'wp-check-pr',\n 'CI check: verify this PR was created through the webpieces gated flow (valid gate token).',\n );\n }\n private reviewUpsertUsage(): CliUsage {\n return new CliUsage(\n 'wp-review-upsert-pr',\n 'Validate the merge, build, extract the diff, and brief required reviewers.',\n );\n }\n private awaitReviewsUsage(): CliUsage {\n return new CliUsage('wp-await-reviews', 'Block until every reviewer verdict has landed.');\n }\n\n private landUsage(): CliUsage {\n return new CliUsage(\n 'wp-land-pr',\n 'Squash-merge a PR into main with its description as the commit body.',\n [new CliFlag(PR, 'The PR number to land.', true)],\n );\n }\n\n private pushDevUsage(): CliUsage {\n return new CliUsage(\n 'wp-push-dev',\n 'Publish a disposable copy of this branch for shared dev.',\n [\n new CliFlag(LIST, 'List published dev copies.'),\n new CliFlag(\n REMOVE,\n \"Delete this branch's dev copy, then push the <removeNamespace>/<branch> marker\"\n + ' (default dev-remove) that triggers the dev rebuild.',\n ),\n new CliFlag(\n RESOLVE,\n 'Compose other published copies, optionally one named branch.',\n true,\n ),\n new CliFlag(REBASE_RESOLUTION, 'Replay an existing resolution onto new commits.'),\n new CliFlag(FORCE, 'Discard the published resolution and overwrite it.'),\n ],\n );\n }\n\n private finishPushDevUsage(): CliUsage {\n return new CliUsage(\n 'wp-finish-push-dev',\n 'Commit a resolved dev composition and publish it.',\n [new CliFlag(ABORT, 'Throw the resolve away without publishing.')],\n );\n }\n\n private awaitChecksUsage(): CliUsage {\n return new CliUsage('wp-await-checks', 'Block until checks on one PR stop running.', [\n new CliFlag(PR, 'REQUIRED. The PR number to wait on.', true),\n ]);\n }\n\n private writeReviewUsage(): CliUsage {\n return new CliUsage('wp-write-review', 'Submit one reviewer verdict for one checklist.', [\n new CliFlag(CHECKLIST, 'REQUIRED. The checklist id.', true),\n new CliFlag(FILE, 'The verdict JSON file. Omit to read stdin.', true),\n new CliFlag(CHECK, 'Only check whether this checklist may still be reviewed.'),\n ]);\n }\n\n private writeReviewFixesUsage(): CliUsage {\n return new CliUsage(\n 'wp-write-review-fixes',\n 'Record the coordinator response to red findings.',\n [new CliFlag(FILE, 'JSON file. Omit to read stdin.', true)],\n );\n }\n}\n"]}
|
|
@@ -88,8 +88,13 @@ let BuildAffected = class BuildAffected {
|
|
|
88
88
|
// `say`, so it survives a stage that is capturing its own console (see StageOutputLog): the
|
|
89
89
|
// command being run and the result of running it are exactly what a caller watching a long build
|
|
90
90
|
// needs to see live.
|
|
91
|
-
|
|
91
|
+
//
|
|
92
|
+
// The log's path goes out FIRST, before the command line and before any work (issue #1393): for
|
|
93
|
+
// `wp-build` it is the very first line on stdout, so a caller that backgrounds the build, or whose
|
|
94
|
+
// harness captures the console into a file of its own, already knows which file to read.
|
|
92
95
|
const logPath = await this.buildLog.pathFor(repoRoot, opts.stage);
|
|
96
|
+
this.stageConsole.say(this.buildLog.startLine(logPath));
|
|
97
|
+
this.stageConsole.say(`\n${opts.label}: ${buildCommand}\n`);
|
|
93
98
|
const ticket = this.buildsLog.start(opts.stage, repoRoot);
|
|
94
99
|
let termination = new rules_config_1.BuildTermination(1, null);
|
|
95
100
|
// webpieces-disable no-unmanaged-exceptions -- chokepoint: the DONE row must be written whether the
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build-affected.js","sourceRoot":"","sources":["../../../../../../../packages/tooling/pr-gate/src/scripts/workflow/build-affected.ts"],"names":[],"mappings":";;;;AAAA,0DAAkJ;AAClJ,sEAA+D;AAC/D,yCAA2D;AAC3D,qDAAgD;AAChD,yDAAoD;AAEpD,iGAAiG;AACjG,8FAA8F;AAC9F,iGAAiG;AACjG,oFAAoF;AACpF,oGAAoG;AACpG,iEAAiE;AAEjE;;;;GAIG;AACH,MAAa,gBAAgB;IACzB,KAAK,CAAS,CAAC,sCAAsC;IACrD,YAAY,CAAS,CAAC,gDAAgD;IACtE,eAAe,CAAS,CAAC,gCAAgC;IACzD,qGAAqG;IACrG,uGAAuG;IACvG,KAAK,CAAS;IAEd,YAAY,KAAa,EAAE,YAAoB,EAAE,eAAuB,EAAE,KAAa;QACnF,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;QACjC,IAAI,CAAC,eAAe,GAAG,eAAe,CAAC;QACvC,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACvB,CAAC;CACJ;AAdD,4CAcC;AAED,qGAAqG;AAE9F,IAAM,aAAa,GAAnB,MAAM,aAAa;IAED;IACA;IACA;IACA;IAJrB,YACqB,QAAsB,EACtB,SAAoB,EACpB,YAA4B,EAC5B,cAA8B;QAH9B,aAAQ,GAAR,QAAQ,CAAc;QACtB,cAAS,GAAT,SAAS,CAAW;QACpB,iBAAY,GAAZ,YAAY,CAAgB;QAC5B,mBAAc,GAAd,cAAc,CAAgB;IAChD,CAAC;IAEJ;;;OAGG;IACH,mBAAmB,CAAC,QAAgB;QAChC,IAAI,IAAI,CAAC,cAAc,CAAC,QAAQ,EAAE;YAAE,OAAO,mCAAoB,CAAC;QAChE,MAAM,UAAU,GAAG,IAAA,8BAAe,EAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,YAAY,CAAC;QACjE,OAAO,UAAU,KAAK,S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AE,OAAO,CAAC;gBACnE,CAAC,CAAC,MAAM,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,QAAQ,EAAE,YAAY,EAAE,OAAO,CAAC,CAAC;QACnE,CAAC;gBAAS,CAAC;YACP,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;QAC/C,CAAC;QACD,MAAM,SAAS,GACX,WAAW,CAAC,IAAI,KAAK,IAAI,IAAI,WAAW,CAAC,MAAM,KAAK,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,IAAI,CAAC;QACpF,IAAI,SAAS,KAAK,CAAC,EAAE,CAAC;YAClB,MAAM,IAAI,2BAAY,CAClB,SAAS,EACT,IAAI,CAAC,WAAW,CAAC,IAAI,EAAE,YAAY,EAAE,OAAO,EAAE,WAAW,CAAC,CAC7D,CAAC;QACN,CAAC;QACD,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC,CAAC;IACjE,CAAC;IAED;;;;;;;OAOG;IACK,WAAW,CACf,IAAsB,EACtB,YAAoB,EACpB,OAAe,EACf,WAA6B;QAE7B,OAAO,CACH,OAAO,IAAI,CAAC,eAAe,IAAI;YAC/B,IAAI,CAAC,QAAQ,CAAC,cAAc,CAAC,YAAY,EAAE,OAAO,EAAE,WAAW,CAAC;YAChE,wCAAwC,IAAI,CAAC,YAAY,KAAK,CACjE,CAAC;IACN,CAAC;CACJ,CAAA;AAlGY,sCAAa;wBAAb,aAAa;IADzB,IAAA,sBAAU,EAAC,8BAAkB,CAAC,SAAS,CAAC;6CAGN,6BAAY;QACX,wBAAS;QACN,iCAAc;QACZ,mCAAc;GAL1C,aAAa,CAkGzB","sourcesContent":["import { loadAndValidate, CliExitError, DEFAULT_BUILD_COMMAND, BuildsLog, BuildTermination, HOTFIX_BUILD_COMMAND } from '@webpieces/rules-config';\nimport { BranchIdentity } from '@webpieces/repo-workflow-core';\nimport { injectable, bindingScopeValues } from 'inversify';\nimport { BuildGateLog } from './build-gate-log';\nimport { StageOutputLog } from './stage-output-log';\n\n// Single source of truth for RUNNING the build gate. `wp-start-upsert-pr` runs NO build; stage ②\n// (`wp-review-upsert-pr`) runs it authoritatively before any reviewer is spawned, and stage ③\n// (`wp-finish-upsert-pr`) re-runs it only when HEAD has moved since. nx `affected` only rebuilds\n// changed projects. The fallback command itself lives in @webpieces/rules-config as\n// DEFAULT_BUILD_COMMAND — whole-repo-build-guard prints the same string, and one definition is what\n// keeps the refusal message naming the build that actually runs.\n\n/**\n * The caller-supplied framing for the build gate (label, re-run command, failure headline, stage id). Kept\n * as a parameter object so runBuildGate stays agnostic of who invokes it. A class (not an object literal)\n * per the codebase's data-structure convention.\n */\nexport class BuildGateOptions {\n label: string; // section header shown above the gate\n rerunCommand: string; // command the AI re-runs after fixing the build\n failureHeadline: string; // first line printed on failure\n // WHICH stage's gate this is — REVIEW_STAGE, FINISH_STAGE or BUILD_STAGE. Required, with no default:\n // it decides the captured log's filename, and a default would silently make two stages share one file.\n stage: string;\n\n constructor(label: string, rerunCommand: string, failureHeadline: string, stage: string) {\n this.label = label;\n this.rerunCommand = rerunCommand;\n this.failureHeadline = failureHeadline;\n this.stage = stage;\n }\n}\n\n/** Runs the authoritative nx-affected build gate for wp-review-upsert-pr and wp-finish-upsert-pr. */\n@injectable(bindingScopeValues.Singleton)\nexport class BuildAffected {\n constructor(\n private readonly buildLog: BuildGateLog,\n private readonly buildsLog: BuildsLog,\n private readonly stageConsole: StageOutputLog,\n private readonly branchIdentity: BranchIdentity,\n ) {}\n\n /**\n * Resolve the exact build command this gate will run: the project's configured\n * PrGateConfig.buildCommand, or the default affected-ci command when none is set.\n */\n resolveBuildCommand(repoRoot: string): string {\n if (this.branchIdentity.isHotfix()) return HOTFIX_BUILD_COMMAND;\n const configured = loadAndValidate(repoRoot).prGate.buildCommand;\n return configured !== undefined && configured.trim() !== ''\n ? configured\n : DEFAULT_BUILD_COMMAND;\n }\n\n /**\n * Run the configured build gate with consistent framing, throwing CliExitError(buildCode) on\n * failure so the bin's main()/runMain owns the exit. THE single source of truth for running a build:\n * wp-build, wp-review-upsert-pr and wp-finish-upsert-pr all call THIS (only the BuildGateOptions\n * differ), and there is no other way to reach the spawn.\n *\n * ─── EVERY BUILD ON THIS MACHINE IS LEDGERED FROM HERE ───────────────────────────────────────────\n * A START row goes into `~/.webpieces/builds.log` before the spawn and a DONE row after it, in a\n * `finally` so a throw on the failure path still closes the pair. `opts.stage` — `build` | `review` |\n * `finish` — IS the caller id the row records; there is deliberately no second `caller` field, since\n * two spellings of one fact is the shim `.claude/rules/no-backwards-compat.md` rejects.\n *\n * The ledger is best-effort by construction (see BuildsLog): it can never throw, so no build can die\n * because a log file was busy.\n */\n async runBuildGate(repoRoot: string, opts: BuildGateOptions): Promise<void> {\n return this.run(repoRoot, opts, false);\n }\n\n /** The human escape hatch uses the same gate but follows build.log on the terminal while it runs. */\n async runBuildGateStreaming(repoRoot: string, opts: BuildGateOptions): Promise<void> {\n return this.run(repoRoot, opts, true);\n }\n\n private async run(repoRoot: string, opts: BuildGateOptions, stream: boolean): Promise<void> {\n const buildCommand = this.resolveBuildCommand(repoRoot);\n // TWO lines on the happy path — the command, then the result. The old framing spent a banner and a\n // paragraph explaining how to reproduce a build that was about to pass anyway; that explanation is\n // only useful when the build FAILS, so it now lives solely on the failure path below.\n //\n // `say`, so it survives a stage that is capturing its own console (see StageOutputLog): the\n // command being run and the result of running it are exactly what a caller watching a long build\n // needs to see live.\n this.stageConsole.say(`\\n${opts.label}: ${buildCommand}\\n`);\n const logPath = await this.buildLog.pathFor(repoRoot, opts.stage);\n const ticket = this.buildsLog.start(opts.stage, repoRoot);\n let termination = new BuildTermination(1, null);\n // webpieces-disable no-unmanaged-exceptions -- chokepoint: the DONE row must be written whether the\n // build passed, failed, or the spawn itself blew up; the throw is re-raised untouched below\n // eslint-disable-next-line @webpieces/no-unmanaged-exceptions\n try {\n termination = stream\n ? await this.buildLog.runStreaming(repoRoot, buildCommand, logPath)\n : await this.buildLog.run(repoRoot, buildCommand, logPath);\n } finally {\n this.buildsLog.finish(ticket, termination);\n }\n const buildCode =\n termination.code === null || termination.signal !== null ? 1 : termination.code;\n if (buildCode !== 0) {\n throw new CliExitError(\n buildCode,\n this.failureText(opts, buildCommand, logPath, termination),\n );\n }\n this.stageConsole.say(this.buildLog.successMessage(logPath));\n }\n\n /**\n * The failure text: this gate's own headline, then the pointer at the log the build already wrote.\n *\n * There is no second, streamed variant any more. Capturing used to be behind an EXPERIMENTAL\n * machine-local opt-in, which meant the refusal an agent read depended on a file almost nobody had —\n * and the un-captured branch's advice was \"run the build again yourself\", which is the single most\n * expensive thing an agent can be told. Reading a FILE is now the only answer this gate gives.\n */\n private failureText(\n opts: BuildGateOptions,\n buildCommand: string,\n logPath: string,\n termination: BuildTermination,\n ): string {\n return (\n `\\n❌ ${opts.failureHeadline}\\n` +\n this.buildLog.failureMessage(buildCommand, logPath, termination) +\n `Fix what that log shows, then re-run ${opts.rerunCommand}.\\n`\n );\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"build-affected.js","sourceRoot":"","sources":["../../../../../../../packages/tooling/pr-gate/src/scripts/workflow/build-affected.ts"],"names":[],"mappings":";;;;AAAA,0DAAkJ;AAClJ,sEAA+D;AAC/D,yCAA2D;AAC3D,qDAAgD;AAChD,yDAAoD;AAEpD,iGAAiG;AACjG,8FAA8F;AAC9F,iGAAiG;AACjG,oFAAoF;AACpF,oGAAoG;AACpG,iEAAiE;AAEjE;;;;GAIG;AACH,MAAa,gBAAgB;IACzB,KAAK,CAAS,CAAC,sCAAsC;IACrD,YAAY,CAAS,CAAC,gDAAgD;IACtE,eAAe,CAAS,CAAC,gCAAgC;IACzD,qGAAqG;IACrG,uGAAuG;IACvG,KAAK,CAAS;IAEd,YAAY,KAAa,EAAE,YAAoB,EAAE,eAAuB,EAAE,KAAa;QACnF,IAAI,CAAC,K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F,IAAI,SAAS,KAAK,CAAC,EAAE,CAAC;YAClB,MAAM,IAAI,2BAAY,CAClB,SAAS,EACT,IAAI,CAAC,WAAW,CAAC,IAAI,EAAE,YAAY,EAAE,OAAO,EAAE,WAAW,CAAC,CAC7D,CAAC;QACN,CAAC;QACD,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC,CAAC;IACjE,CAAC;IAED;;;;;;;OAOG;IACK,WAAW,CACf,IAAsB,EACtB,YAAoB,EACpB,OAAe,EACf,WAA6B;QAE7B,OAAO,CACH,OAAO,IAAI,CAAC,eAAe,IAAI;YAC/B,IAAI,CAAC,QAAQ,CAAC,cAAc,CAAC,YAAY,EAAE,OAAO,EAAE,WAAW,CAAC;YAChE,wCAAwC,IAAI,CAAC,YAAY,KAAK,CACjE,CAAC;IACN,CAAC;CACJ,CAAA;AAvGY,sCAAa;wBAAb,aAAa;IADzB,IAAA,sBAAU,EAAC,8BAAkB,CAAC,SAAS,CAAC;6CAGN,6BAAY;QACX,wBAAS;QACN,iCAAc;QACZ,mCAAc;GAL1C,aAAa,CAuGzB","sourcesContent":["import { loadAndValidate, CliExitError, DEFAULT_BUILD_COMMAND, BuildsLog, BuildTermination, HOTFIX_BUILD_COMMAND } from '@webpieces/rules-config';\nimport { BranchIdentity } from '@webpieces/repo-workflow-core';\nimport { injectable, bindingScopeValues } from 'inversify';\nimport { BuildGateLog } from './build-gate-log';\nimport { StageOutputLog } from './stage-output-log';\n\n// Single source of truth for RUNNING the build gate. `wp-start-upsert-pr` runs NO build; stage ②\n// (`wp-review-upsert-pr`) runs it authoritatively before any reviewer is spawned, and stage ③\n// (`wp-finish-upsert-pr`) re-runs it only when HEAD has moved since. nx `affected` only rebuilds\n// changed projects. The fallback command itself lives in @webpieces/rules-config as\n// DEFAULT_BUILD_COMMAND — whole-repo-build-guard prints the same string, and one definition is what\n// keeps the refusal message naming the build that actually runs.\n\n/**\n * The caller-supplied framing for the build gate (label, re-run command, failure headline, stage id). Kept\n * as a parameter object so runBuildGate stays agnostic of who invokes it. A class (not an object literal)\n * per the codebase's data-structure convention.\n */\nexport class BuildGateOptions {\n label: string; // section header shown above the gate\n rerunCommand: string; // command the AI re-runs after fixing the build\n failureHeadline: string; // first line printed on failure\n // WHICH stage's gate this is — REVIEW_STAGE, FINISH_STAGE or BUILD_STAGE. Required, with no default:\n // it decides the captured log's filename, and a default would silently make two stages share one file.\n stage: string;\n\n constructor(label: string, rerunCommand: string, failureHeadline: string, stage: string) {\n this.label = label;\n this.rerunCommand = rerunCommand;\n this.failureHeadline = failureHeadline;\n this.stage = stage;\n }\n}\n\n/** Runs the authoritative nx-affected build gate for wp-review-upsert-pr and wp-finish-upsert-pr. */\n@injectable(bindingScopeValues.Singleton)\nexport class BuildAffected {\n constructor(\n private readonly buildLog: BuildGateLog,\n private readonly buildsLog: BuildsLog,\n private readonly stageConsole: StageOutputLog,\n private readonly branchIdentity: BranchIdentity,\n ) {}\n\n /**\n * Resolve the exact build command this gate will run: the project's configured\n * PrGateConfig.buildCommand, or the default affected-ci command when none is set.\n */\n resolveBuildCommand(repoRoot: string): string {\n if (this.branchIdentity.isHotfix()) return HOTFIX_BUILD_COMMAND;\n const configured = loadAndValidate(repoRoot).prGate.buildCommand;\n return configured !== undefined && configured.trim() !== ''\n ? configured\n : DEFAULT_BUILD_COMMAND;\n }\n\n /**\n * Run the configured build gate with consistent framing, throwing CliExitError(buildCode) on\n * failure so the bin's main()/runMain owns the exit. THE single source of truth for running a build:\n * wp-build, wp-review-upsert-pr and wp-finish-upsert-pr all call THIS (only the BuildGateOptions\n * differ), and there is no other way to reach the spawn.\n *\n * ─── EVERY BUILD ON THIS MACHINE IS LEDGERED FROM HERE ───────────────────────────────────────────\n * A START row goes into `~/.webpieces/builds.log` before the spawn and a DONE row after it, in a\n * `finally` so a throw on the failure path still closes the pair. `opts.stage` — `build` | `review` |\n * `finish` — IS the caller id the row records; there is deliberately no second `caller` field, since\n * two spellings of one fact is the shim `.claude/rules/no-backwards-compat.md` rejects.\n *\n * The ledger is best-effort by construction (see BuildsLog): it can never throw, so no build can die\n * because a log file was busy.\n */\n async runBuildGate(repoRoot: string, opts: BuildGateOptions): Promise<void> {\n return this.run(repoRoot, opts, false);\n }\n\n /** The human escape hatch uses the same gate but follows build.log on the terminal while it runs. */\n async runBuildGateStreaming(repoRoot: string, opts: BuildGateOptions): Promise<void> {\n return this.run(repoRoot, opts, true);\n }\n\n private async run(repoRoot: string, opts: BuildGateOptions, stream: boolean): Promise<void> {\n const buildCommand = this.resolveBuildCommand(repoRoot);\n // TWO lines on the happy path — the command, then the result. The old framing spent a banner and a\n // paragraph explaining how to reproduce a build that was about to pass anyway; that explanation is\n // only useful when the build FAILS, so it now lives solely on the failure path below.\n //\n // `say`, so it survives a stage that is capturing its own console (see StageOutputLog): the\n // command being run and the result of running it are exactly what a caller watching a long build\n // needs to see live.\n //\n // The log's path goes out FIRST, before the command line and before any work (issue #1393): for\n // `wp-build` it is the very first line on stdout, so a caller that backgrounds the build, or whose\n // harness captures the console into a file of its own, already knows which file to read.\n const logPath = await this.buildLog.pathFor(repoRoot, opts.stage);\n this.stageConsole.say(this.buildLog.startLine(logPath));\n this.stageConsole.say(`\\n${opts.label}: ${buildCommand}\\n`);\n const ticket = this.buildsLog.start(opts.stage, repoRoot);\n let termination = new BuildTermination(1, null);\n // webpieces-disable no-unmanaged-exceptions -- chokepoint: the DONE row must be written whether the\n // build passed, failed, or the spawn itself blew up; the throw is re-raised untouched below\n // eslint-disable-next-line @webpieces/no-unmanaged-exceptions\n try {\n termination = stream\n ? await this.buildLog.runStreaming(repoRoot, buildCommand, logPath)\n : await this.buildLog.run(repoRoot, buildCommand, logPath);\n } finally {\n this.buildsLog.finish(ticket, termination);\n }\n const buildCode =\n termination.code === null || termination.signal !== null ? 1 : termination.code;\n if (buildCode !== 0) {\n throw new CliExitError(\n buildCode,\n this.failureText(opts, buildCommand, logPath, termination),\n );\n }\n this.stageConsole.say(this.buildLog.successMessage(logPath));\n }\n\n /**\n * The failure text: this gate's own headline, then the pointer at the log the build already wrote.\n *\n * There is no second, streamed variant any more. Capturing used to be behind an EXPERIMENTAL\n * machine-local opt-in, which meant the refusal an agent read depended on a file almost nobody had —\n * and the un-captured branch's advice was \"run the build again yourself\", which is the single most\n * expensive thing an agent can be told. Reading a FILE is now the only answer this gate gives.\n */\n private failureText(\n opts: BuildGateOptions,\n buildCommand: string,\n logPath: string,\n termination: BuildTermination,\n ): string {\n return (\n `\\n❌ ${opts.failureHeadline}\\n` +\n this.buildLog.failureMessage(buildCommand, logPath, termination) +\n `Fix what that log shows, then re-run ${opts.rerunCommand}.\\n`\n );\n }\n}\n"]}
|
|
@@ -41,19 +41,20 @@ export declare class BuildLogHeartbeat {
|
|
|
41
41
|
* WHERE the file goes, how the previous run is kept, and what the pointer reads like are `GateLogFile`'s
|
|
42
42
|
* — one mechanism, shared with the stage console log, so there is a single answer to "where is it?".
|
|
43
43
|
*
|
|
44
|
-
* ───
|
|
45
|
-
*
|
|
46
|
-
*
|
|
47
|
-
*
|
|
48
|
-
* • stage ② and stage ③ write `
|
|
49
|
-
*
|
|
50
|
-
*
|
|
44
|
+
* ─── One directory, two naming schemes, one rule each ──────────────────────────────────────────────────
|
|
45
|
+
* Every build log sits in `<tree>/.webpieces/logs/` (GateLogFile.logsPath — inside the checkout the
|
|
46
|
+
* command ran in, a linked worktree's own root included; issue #1393).
|
|
47
|
+
* • `wp-build` (BUILD_STAGE) writes ONE fixed name, `build.log`. History comes from the rotation.
|
|
48
|
+
* • stage ② and stage ③ write `build-gate-<stage>-<branch>-<shortSha>.log`, because those two gates CAN
|
|
49
|
+
* run against one commit and a failure message from one must not be pointing at a file the other
|
|
50
|
+
* overwrote.
|
|
51
|
+
* Nobody needs to type either name: the absolute path is printed as the FIRST line of the build, before
|
|
52
|
+
* it starts, and again in the closing pointer.
|
|
51
53
|
*
|
|
52
54
|
* ─── Concurrency ───────────────────────────────────────────────────────────────────────────────────────
|
|
53
|
-
* The DIRECTORY is
|
|
54
|
-
*
|
|
55
|
-
*
|
|
56
|
-
* driving one git index.
|
|
55
|
+
* The DIRECTORY is per checkout — a linked worktree writes under its own root — so "N agents in N
|
|
56
|
+
* worktrees" is safe by construction rather than by naming. The residual case is two builds in the SAME
|
|
57
|
+
* worktree at once, which is already unsupported: both would be driving one git index.
|
|
57
58
|
*/
|
|
58
59
|
export declare class BuildGateLog {
|
|
59
60
|
private readonly files;
|
|
@@ -76,6 +77,8 @@ export declare class BuildGateLog {
|
|
|
76
77
|
run(repoRoot: string, buildCommand: string, logPath: string): Promise<BuildTermination>;
|
|
77
78
|
/** Human-only variant: preserve the durable log and follow its appended bytes live. */
|
|
78
79
|
runStreaming(repoRoot: string, buildCommand: string, logPath: string): Promise<BuildTermination>;
|
|
80
|
+
/** The `FullLog : <path>` line printed before the build starts — see GateLogFile.startLine. */
|
|
81
|
+
startLine(logPath: string): string;
|
|
79
82
|
/**
|
|
80
83
|
* The success summary: the caller is told WHERE the full output is, not handed the output.
|
|
81
84
|
*/
|