@webpieces/pr-gate 0.4.981 → 0.4.983

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (34) hide show
  1. package/package.json +7 -6
  2. package/src/scripts/commands/build-dev-command.d.ts +27 -0
  3. package/src/scripts/commands/build-dev-command.js +99 -0
  4. package/src/scripts/commands/build-dev-command.js.map +1 -0
  5. package/src/scripts/commands/push-dev-command.d.ts +51 -18
  6. package/src/scripts/commands/push-dev-command.js +97 -34
  7. package/src/scripts/commands/push-dev-command.js.map +1 -1
  8. package/src/scripts/pr-gate-app.d.ts +10 -2
  9. package/src/scripts/pr-gate-app.js +15 -2
  10. package/src/scripts/pr-gate-app.js.map +1 -1
  11. package/src/scripts/pr-gate-cli-app.d.ts +1 -0
  12. package/src/scripts/pr-gate-cli-app.js +11 -3
  13. package/src/scripts/pr-gate-cli-app.js.map +1 -1
  14. package/src/scripts/workflow/build-affected.d.ts +7 -0
  15. package/src/scripts/workflow/build-affected.js +12 -4
  16. package/src/scripts/workflow/build-affected.js.map +1 -1
  17. package/src/scripts/workflow/build-gate-log.d.ts +4 -2
  18. package/src/scripts/workflow/build-gate-log.js +11 -3
  19. package/src/scripts/workflow/build-gate-log.js.map +1 -1
  20. package/src/scripts/workflow/dev-build.d.ts +31 -0
  21. package/src/scripts/workflow/dev-build.js +63 -0
  22. package/src/scripts/workflow/dev-build.js.map +1 -0
  23. package/src/scripts/workflow/dev-deploy-refs.d.ts +23 -3
  24. package/src/scripts/workflow/dev-deploy-refs.js +30 -6
  25. package/src/scripts/workflow/dev-deploy-refs.js.map +1 -1
  26. package/src/scripts/workflow/dev-resolve-runner.d.ts +55 -8
  27. package/src/scripts/workflow/dev-resolve-runner.js +150 -22
  28. package/src/scripts/workflow/dev-resolve-runner.js.map +1 -1
  29. package/src/scripts/workflow/push-dev-state.d.ts +27 -0
  30. package/src/scripts/workflow/push-dev-state.js +41 -3
  31. package/src/scripts/workflow/push-dev-state.js.map +1 -1
  32. package/src/scripts/wp-build-dev.d.ts +2 -0
  33. package/src/scripts/wp-build-dev.js +13 -0
  34. package/src/scripts/wp-build-dev.js.map +1 -0
@@ -1 +1 @@
1
- {"version":3,"file":"push-dev-state.js","sourceRoot":"","sources":["../../../../../../../packages/tooling/pr-gate/src/scripts/workflow/push-dev-state.ts"],"names":[],"mappings":";;;;AAAA,+CAAyB;AAEzB,0DAA6G;AAC7G,8DAAyD;AACzD,iEAA6D;AAC7D,yCAA2D;AAE3D,MAAM,GAAG,GAAG,0DAA0D,CAAC;AAEvE;;;;;;;;;GASG;AACH,MAAa,YAAY;IACrB,kGAAkG;IAClG,cAAc,CAAS;IACvB,uFAAuF;IACvF,SAAS,CAAS;IAClB,iFAAiF;IACjF,SAAS,CAAS;IAClB,mEAAmE;IACnE,KAAK,CAAW;IAChB,8EAA8E;IAC9E,OAAO,CAAS;IAEhB,yDAAyD;IACzD,YACI,cAAsB,EACtB,SAAiB,EACjB,SAAiB,EACjB,KAAe,EACf,OAAO,GAAG,EAAE;QAEZ,IAAI,CAAC,cAAc,GAAG,cAAc,CAAC;QACrC,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IAC3B,CAAC;CACJ;AA1BD,oCA0BC;AAED,sGAAsG;AACtG,4FAA4F;AAC5F,kGAAkG;AAClG,iGAAiG;AACjG,EAAE;AACF,wGAAwG;AACxG,mGAAmG;AACnG,uEAAuE;AACvE,MAAM,sBAAsB,GAAsB;IAC9C,iBAAiB;IACjB,kBAAkB;IAClB,oBAAoB;IACpB,qBAAqB;IACrB,qBAAqB;IACrB,kBAAkB;IAClB,qBAAqB;IACrB,YAAY;IACZ,YAAY;CACf,CAAC;AAEF;;;;;;;GAOG;AAEI,IAAM,iBAAiB,GAAvB,MAAM,iBAAiB;I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A,GAAG;YACH,kDAAkD,SAAS,iBAAiB;YAC5E,GAAG;YACH,IAAI;YACJ,8CAA8C,KAAK,CAAC,SAAS,gBAAgB,KAAK,CAAC,cAAc,OAAO;YACxG,MAAM,IAAI,CAAC,kBAAkB,EAAE,uCAAuC;YACtE,sDAAsD;YACtD,mGAAmG;YACnG,qDAAqD;YACrD,KAAK,iCAAkB,2EAA2E;YAClG,KAAK,iCAAkB,4DAA4D,KAAK,CAAC,cAAc,QAAQ;YAC/G,eAAe,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAC7C,CAAC;IACN,CAAC;IAED,gFAAgF;IACxE,kBAAkB;QACtB,OAAO,sBAAsB,CAAC,GAAG,CAAC,CAAC,CAAS,EAAU,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACzF,CAAC;IAED,uFAAuF;IACvF,sBAAsB,CAAC,OAAe;QAClC,OAAO,sBAAsB,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;IACpD,CAAC;CACJ,CAAA;AArGY,8CAAiB;4BAAjB,iBAAiB;IAD7B,IAAA,sBAAU,EAAC,8BAAkB,CAAC,SAAS,CAAC;6CAEM,6BAAY;GAD9C,iBAAiB,CAqG7B","sourcesContent":["import * as fs from 'fs';\n\nimport { CliExitError, PUSH_DEV_STATE_FILE, WP_FINISH_PUSH_DEV, WP_PUSH_DEV } from '@webpieces/rules-config';\nimport { DotWebpieces } from '@webpieces/tooling-common';\nimport { toError } from '@webpieces/tooling-common/to-error';\nimport { injectable, bindingScopeValues } from 'inversify';\n\nconst SEP = '━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\\n';\n\n/**\n * The persisted half of the `wp-push-dev --resolve` state machine.\n *\n * A single-shot wrapper is IMPOSSIBLE here and that is why this file exists: `git merge` halts on\n * conflict with markers in the working tree and a non-zero exit, and a human or an AI has to edit files\n * before anything can be committed. So the command must be able to stop, hand the tree over, and be\n * resumed by a second command that knows exactly where it left off.\n *\n * Data-only (per CLAUDE.md) — the behaviour lives in {@link PushDevStateStore}.\n */\nexport class PushDevState {\n /** The branch to return to when the resolve finishes or aborts. NEVER written to by this flow. */\n originalBranch: string;\n /** The local throwaway branch the merges happen on. Deleted on finish and on abort. */\n tmpBranch: string;\n /** `<namespace>/<originalBranch>` — the remote copy this resolve republishes. */\n targetRef: string;\n /** The copy refs still to merge, in the order CI composes them. */\n queue: string[];\n /** The ref currently mid-merge (conflicted), or '' when nothing is halted. */\n current: string;\n\n // eslint-disable-next-line @typescript-eslint/max-params\n constructor(\n originalBranch: string,\n tmpBranch: string,\n targetRef: string,\n queue: string[],\n current = '',\n ) {\n this.originalBranch = originalBranch;\n this.tmpBranch = tmpBranch;\n this.targetRef = targetRef;\n this.queue = queue;\n this.current = current;\n }\n}\n\n// The wp-* commands that must REFUSE while a resolve is half-finished, and the ONE place that list is\n// written. The blocked-list sentence below RENDERS ITSELF from this array — the same lesson\n// merge-in-progress-guard already learned the hard way: a hand-written \"don't run other commands\"\n// survives every edit to the actual enforcement and ends up forbidding things the flow requires.\n//\n// Why these and not everything: each one either rewrites the current branch (the two starts), pushes it\n// (the finishes), or deletes branches (cleanup) — and during a resolve the checkout is a throwaway\n// branch, not the feature branch any of them think they are acting on.\nconst BLOCKED_DURING_RESOLVE: readonly string[] = [\n 'wp-start-update',\n 'wp-finish-update',\n 'wp-start-upsert-pr',\n 'wp-review-upsert-pr',\n 'wp-finish-upsert-pr',\n 'wp-human-post-pr',\n 'wp-upsert-hotfix-pr',\n 'wp-land-pr',\n 'wp-cleanup',\n];\n\n/**\n * Reads, writes and clears the resolve state file, and refuses the other `wp-*` commands while it\n * exists.\n *\n * LOCAL scope, deliberately: a resolve halts one worktree's checkout on a throwaway branch, and another\n * worktree has no reason to care. Sharing it would block a colleague's PR flow on state that says\n * nothing about their tree.\n */\n@injectable(bindingScopeValues.Singleton)\nexport class PushDevStateStore {\n constructor(private readonly dotWebpieces: DotWebpieces) {}\n\n path(repoRoot: string): string {\n return this.dotWebpieces.localFile(repoRoot, PUSH_DEV_STATE_FILE);\n }\n\n exists(repoRoot: string): boolean {\n return fs.existsSync(this.path(repoRoot));\n }\n\n /** The in-flight resolve, or null when none is. A corrupt file reads as null rather than crashing. */\n read(repoRoot: string): PushDevState | null {\n const file = this.path(repoRoot);\n if (!fs.existsSync(file)) return null;\n // webpieces-disable no-unmanaged-exceptions -- a truncated/hand-edited state file must degrade to \"no resolve in progress\" (recoverable via --abort or a fresh --resolve), never crash every wp-* command in the tree\n // eslint-disable-next-line @webpieces/no-unmanaged-exceptions\n try {\n // webpieces-disable no-any-unknown -- JSON.parse is untyped until narrowed on the next line\n const raw = JSON.parse(fs.readFileSync(file, 'utf8')) as Partial<PushDevState>;\n if (typeof raw.originalBranch !== 'string' || typeof raw.tmpBranch !== 'string')\n return null;\n return new PushDevState(\n raw.originalBranch,\n raw.tmpBranch,\n raw.targetRef ?? '',\n Array.isArray(raw.queue) ? raw.queue : [],\n raw.current ?? '',\n );\n // The parse error carries nothing a caller could act on: the ONLY meaningful reading of an\n // unparseable state file is \"no resolve in progress\", which --abort and a fresh --resolve both\n // recover from.\n } catch (err: unknown) {\n const error = toError(err);\n void error;\n return null;\n }\n }\n\n write(repoRoot: string, state: PushDevState): void {\n fs.mkdirSync(this.dotWebpieces.local(repoRoot), { recursive: true });\n fs.writeFileSync(this.path(repoRoot), JSON.stringify(state, null, 2) + '\\n', 'utf8');\n }\n\n clear(repoRoot: string): void {\n const file = this.path(repoRoot);\n if (fs.existsSync(file)) fs.rmSync(file);\n }\n\n /** The read that MUST find a resolve — used by `wp-finish-push-dev`, whose whole job is resuming one. */\n require(repoRoot: string): PushDevState {\n const state = this.read(repoRoot);\n if (state !== null) return state;\n throw new CliExitError(\n 2,\n '\\n' +\n SEP +\n '⛔ No dev-deploy resolve is in progress\\n' +\n SEP +\n '\\n' +\n `${WP_FINISH_PUSH_DEV} resumes a resolve that \\`${WP_PUSH_DEV} --resolve\\` started, and there is no\\n` +\n `state file at:\\n ${this.path(repoRoot)}\\n\\n` +\n 'If you meant to publish your branch to the shared dev server, that is the one-command form:\\n' +\n ` ${WP_PUSH_DEV}\\n`,\n );\n }\n\n /**\n * Refuse `attempted` while a resolve is half-finished. Called from the app root for every command in\n * {@link BLOCKED_DURING_RESOLVE}, so no individual command has to remember to ask.\n */\n assertIdle(repoRoot: string, attempted: string): void {\n const state = this.read(repoRoot);\n if (state === null) return;\n throw new CliExitError(\n 2,\n '\\n' +\n SEP +\n `⛔ A dev-deploy resolve is in progress — \\`pnpm ${attempted}\\` is blocked\\n` +\n SEP +\n '\\n' +\n `You are standing on the throwaway branch \\`${state.tmpBranch}\\`, not on \\`${state.originalBranch}\\`,\\n` +\n `so ${this.blockedCommandList()} would all act on the wrong branch.\\n` +\n 'That is the whole list; nothing else is blocked.\\n\\n' +\n 'EXPECTED of you right now, and NOT blocked: read the conflicted files and edit them until every\\n' +\n 'conflict marker is gone. Then finish or bail out:\\n' +\n ` ${WP_FINISH_PUSH_DEV} ← commit the resolution, resume the queue, publish the copy\\n` +\n ` ${WP_FINISH_PUSH_DEV} --abort ← throw the resolution away and go back to \\`${state.originalBranch}\\`\\n\\n` +\n `State file: ${this.path(repoRoot)}\\n`,\n );\n }\n\n // Rendered from BLOCKED_DURING_RESOLVE, never hand-written — see that constant.\n private blockedCommandList(): string {\n return BLOCKED_DURING_RESOLVE.map((c: string): string => `\\`pnpm ${c}\\``).join(', ');\n }\n\n /** Is `command` one of the ones that must refuse mid-resolve? Used by the app root. */\n isBlockedDuringResolve(command: string): boolean {\n return BLOCKED_DURING_RESOLVE.includes(command);\n }\n}\n"]}
1
+ {"version":3,"file":"push-dev-state.js","sourceRoot":"","sources":["../../../../../../../packages/tooling/pr-gate/src/scripts/workflow/push-dev-state.ts"],"names":[],"mappings":";;;;AAAA,+CAAyB;AAEzB,0DAA6G;AAC7G,8DAAyD;AACzD,iEAA6D;AAC7D,yCAA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ACxE,kBAAkB;QACtB,OAAO,sBAAsB,CAAC,GAAG,CAAC,CAAC,CAAS,EAAU,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACzF,CAAC;IAED,uFAAuF;IACvF,sBAAsB,CAAC,OAAe;QAClC,OAAO,sBAAsB,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;IACpD,CAAC;CACJ,CAAA;AA7GY,8CAAiB;4BAAjB,iBAAiB;IAD7B,IAAA,sBAAU,EAAC,8BAAkB,CAAC,SAAS,CAAC;6CAEM,6BAAY;GAD9C,iBAAiB,CA6G7B","sourcesContent":["import * as fs from 'fs';\n\nimport { CliExitError, PUSH_DEV_STATE_FILE, WP_FINISH_PUSH_DEV, WP_PUSH_DEV } from '@webpieces/rules-config';\nimport { DotWebpieces } from '@webpieces/tooling-common';\nimport { toError } from '@webpieces/tooling-common/to-error';\nimport { injectable, bindingScopeValues } from 'inversify';\n\nconst SEP = '━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\\n';\n\n/**\n * WHICH flow a resolve is part of — it decides what the finish publishes (#1397).\n *\n * - `PREBUILD` — plain `wp-push-dev`: `origin/<devBranch>` is merged into a throwaway, the dev build runs\n * on the merged tree, and what is published is the feature head PLUS one commit recording the resolved\n * files. The merge itself is never published.\n * - `COMPOSE` — `wp-push-dev --resolve`: the other copies are merged into a throwaway, and what is\n * published is the existing copy PLUS one commit recording the resolved files — never a merge parent,\n * so no other copy becomes an ancestor of this one and a later `--remove` of it really takes it off dev.\n * - `REPLAY` — `wp-push-dev --rebase-resolution`: the published copy is merged into the new local head\n * and that merge IS what is published, so the copy's own resolution survives the new commits.\n */\nexport enum DevResolveMode {\n PREBUILD = 'prebuild',\n COMPOSE = 'compose',\n REPLAY = 'replay',\n}\n\n/**\n * The persisted half of the `wp-push-dev --resolve` state machine.\n *\n * A single-shot wrapper is IMPOSSIBLE here and that is why this file exists: `git merge` halts on\n * conflict with markers in the working tree and a non-zero exit, and a human or an AI has to edit files\n * before anything can be committed. So the command must be able to stop, hand the tree over, and be\n * resumed by a second command that knows exactly where it left off.\n *\n * Data-only (per CLAUDE.md) — the behaviour lives in {@link PushDevStateStore}.\n */\nexport class PushDevState {\n /** The branch to return to when the resolve finishes or aborts. NEVER written to by this flow. */\n originalBranch: string;\n /** The local throwaway branch the merges happen on. Deleted on finish and on abort. */\n tmpBranch: string;\n /** `<namespace>/<originalBranch>` — the remote copy this resolve republishes. */\n targetRef: string;\n /** The copy refs still to merge, in the order CI composes them. */\n queue: string[];\n /** The ref currently mid-merge (conflicted), or '' when nothing is halted. */\n current: string;\n /** What the finish publishes — see DevResolveMode. */\n mode: DevResolveMode = DevResolveMode.COMPOSE;\n /** The sha the published copy is built ON: the feature head (PREBUILD) or the published copy (COMPOSE). */\n baseSha = '';\n /** Every path that conflicted and was resolved; the recorded resolution carries exactly these. */\n resolvedPaths: string[] = [];\n /** The remote copy's sha when the flow started ('' = not published yet) — the push's lease. */\n leaseSha = '';\n /** `--force` was given: overwrite the copy without a lease. */\n force = false;\n\n // eslint-disable-next-line @typescript-eslint/max-params\n constructor(\n originalBranch: string,\n tmpBranch: string,\n targetRef: string,\n queue: string[],\n current = '',\n ) {\n this.originalBranch = originalBranch;\n this.tmpBranch = tmpBranch;\n this.targetRef = targetRef;\n this.queue = queue;\n this.current = current;\n }\n}\n\n// The wp-* commands that must REFUSE while a resolve is half-finished, and the ONE place that list is\n// written. The blocked-list sentence below RENDERS ITSELF from this array — the same lesson\n// merge-in-progress-guard already learned the hard way: a hand-written \"don't run other commands\"\n// survives every edit to the actual enforcement and ends up forbidding things the flow requires.\n//\n// Why these and not everything: each one either rewrites the current branch (the two starts), pushes it\n// (the finishes), deletes branches (cleanup), or parks the checkout on a throwaway of its own\n// (wp-build-dev) — and during a resolve the checkout is a throwaway\n// branch, not the feature branch any of them think they are acting on.\nconst BLOCKED_DURING_RESOLVE: readonly string[] = [\n 'wp-build-dev',\n 'wp-start-update',\n 'wp-finish-update',\n 'wp-start-upsert-pr',\n 'wp-review-upsert-pr',\n 'wp-finish-upsert-pr',\n 'wp-human-post-pr',\n 'wp-upsert-hotfix-pr',\n 'wp-land-pr',\n 'wp-cleanup',\n];\n\n/**\n * Reads, writes and clears the resolve state file, and refuses the other `wp-*` commands while it\n * exists.\n *\n * LOCAL scope, deliberately: a resolve halts one worktree's checkout on a throwaway branch, and another\n * worktree has no reason to care. Sharing it would block a colleague's PR flow on state that says\n * nothing about their tree.\n */\n@injectable(bindingScopeValues.Singleton)\nexport class PushDevStateStore {\n constructor(private readonly dotWebpieces: DotWebpieces) {}\n\n path(repoRoot: string): string {\n return this.dotWebpieces.localFile(repoRoot, PUSH_DEV_STATE_FILE);\n }\n\n exists(repoRoot: string): boolean {\n return fs.existsSync(this.path(repoRoot));\n }\n\n /** The in-flight resolve, or null when none is. A corrupt file reads as null rather than crashing. */\n read(repoRoot: string): PushDevState | null {\n const file = this.path(repoRoot);\n if (!fs.existsSync(file)) return null;\n // webpieces-disable no-unmanaged-exceptions -- a truncated/hand-edited state file must degrade to \"no resolve in progress\" (recoverable via --abort or a fresh --resolve), never crash every wp-* command in the tree\n // eslint-disable-next-line @webpieces/no-unmanaged-exceptions\n try {\n // webpieces-disable no-any-unknown -- JSON.parse is untyped until narrowed on the next line\n const raw = JSON.parse(fs.readFileSync(file, 'utf8')) as Partial<PushDevState>;\n if (typeof raw.originalBranch !== 'string' || typeof raw.tmpBranch !== 'string')\n return null;\n const state = new PushDevState(\n raw.originalBranch,\n raw.tmpBranch,\n raw.targetRef ?? '',\n Array.isArray(raw.queue) ? raw.queue : [],\n raw.current ?? '',\n );\n state.mode = Object.values(DevResolveMode).includes(raw.mode as DevResolveMode)\n ? (raw.mode as DevResolveMode)\n : DevResolveMode.COMPOSE;\n state.baseSha = typeof raw.baseSha === 'string' ? raw.baseSha : '';\n state.resolvedPaths = Array.isArray(raw.resolvedPaths) ? raw.resolvedPaths : [];\n state.leaseSha = typeof raw.leaseSha === 'string' ? raw.leaseSha : '';\n state.force = raw.force === true;\n return state;\n // The parse error carries nothing a caller could act on: the ONLY meaningful reading of an\n // unparseable state file is \"no resolve in progress\", which --abort and a fresh --resolve both\n // recover from.\n } catch (err: unknown) {\n const error = toError(err);\n void error;\n return null;\n }\n }\n\n write(repoRoot: string, state: PushDevState): void {\n fs.mkdirSync(this.dotWebpieces.local(repoRoot), { recursive: true });\n fs.writeFileSync(this.path(repoRoot), JSON.stringify(state, null, 2) + '\\n', 'utf8');\n }\n\n clear(repoRoot: string): void {\n const file = this.path(repoRoot);\n if (fs.existsSync(file)) fs.rmSync(file);\n }\n\n /** The read that MUST find a resolve — used by `wp-finish-push-dev`, whose whole job is resuming one. */\n require(repoRoot: string): PushDevState {\n const state = this.read(repoRoot);\n if (state !== null) return state;\n throw new CliExitError(\n 2,\n '\\n' +\n SEP +\n '⛔ No dev-deploy resolve is in progress\\n' +\n SEP +\n '\\n' +\n `${WP_FINISH_PUSH_DEV} resumes a resolve that \\`${WP_PUSH_DEV} --resolve\\` started, and there is no\\n` +\n `state file at:\\n ${this.path(repoRoot)}\\n\\n` +\n 'If you meant to publish your branch to the shared dev server, that is the one-command form:\\n' +\n ` ${WP_PUSH_DEV}\\n`,\n );\n }\n\n /**\n * Refuse `attempted` while a resolve is half-finished. Called from the app root for every command in\n * {@link BLOCKED_DURING_RESOLVE}, so no individual command has to remember to ask.\n */\n assertIdle(repoRoot: string, attempted: string): void {\n const state = this.read(repoRoot);\n if (state === null) return;\n throw new CliExitError(\n 2,\n '\\n' +\n SEP +\n `⛔ A dev-deploy resolve is in progress — \\`pnpm ${attempted}\\` is blocked\\n` +\n SEP +\n '\\n' +\n `You are standing on the throwaway branch \\`${state.tmpBranch}\\`, not on \\`${state.originalBranch}\\`,\\n` +\n `so ${this.blockedCommandList()} would all act on the wrong branch.\\n` +\n 'That is the whole list; nothing else is blocked.\\n\\n' +\n 'EXPECTED of you right now, and NOT blocked: read the conflicted files and edit them until every\\n' +\n 'conflict marker is gone. Then finish or bail out:\\n' +\n ` ${WP_FINISH_PUSH_DEV} ← commit the resolution, resume the queue, publish the copy\\n` +\n ` ${WP_FINISH_PUSH_DEV} --abort ← throw the resolution away and go back to \\`${state.originalBranch}\\`\\n\\n` +\n `State file: ${this.path(repoRoot)}\\n`,\n );\n }\n\n // Rendered from BLOCKED_DURING_RESOLVE, never hand-written — see that constant.\n private blockedCommandList(): string {\n return BLOCKED_DURING_RESOLVE.map((c: string): string => `\\`pnpm ${c}\\``).join(', ');\n }\n\n /** Is `command` one of the ones that must refuse mid-resolve? Used by the app root. */\n isBlockedDuringResolve(command: string): boolean {\n return BLOCKED_DURING_RESOLVE.includes(command);\n }\n}\n"]}
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ import 'reflect-metadata';
@@ -0,0 +1,13 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ require("reflect-metadata");
5
+ const rules_config_1 = require("@webpieces/rules-config");
6
+ const pr_gate_container_1 = require("./pr-gate-container");
7
+ const pr_gate_cli_app_1 = require("./pr-gate-cli-app");
8
+ const pr_gate_cli_invocation_1 = require("./pr-gate-cli-invocation");
9
+ const container = new pr_gate_container_1.PrGateContainer().create();
10
+ (0, rules_config_1.runMain)(() => container
11
+ .get(pr_gate_cli_app_1.PrGateCliApp)
12
+ .run(container.get(pr_gate_cli_invocation_1.PrGateCliInvocationFactory).fromProcess('wp-build-dev')));
13
+ //# sourceMappingURL=wp-build-dev.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wp-build-dev.js","sourceRoot":"","sources":["../../../../../../packages/tooling/pr-gate/src/scripts/wp-build-dev.ts"],"names":[],"mappings":";;;AACA,4BAA0B;AAC1B,0DAAkD;AAClD,2DAAsD;AACtD,uDAAiD;AACjD,qEAAsE;AAEtE,MAAM,SAAS,GAAG,IAAI,mCAAe,EAAE,CAAC,MAAM,EAAE,CAAC;AACjD,IAAA,sBAAO,EACH,GAAkB,EAAE,CAChB,SAAS;KACJ,GAAG,CAAC,8BAAY,CAAC;KACjB,GAAG,CAAC,SAAS,CAAC,GAAG,CAAC,mDAA0B,CAAC,CAAC,WAAW,CAAC,cAAc,CAAC,CAAC,CACtF,CAAC","sourcesContent":["#!/usr/bin/env node\nimport 'reflect-metadata';\nimport { runMain } from '@webpieces/rules-config';\nimport { PrGateContainer } from './pr-gate-container';\nimport { PrGateCliApp } from './pr-gate-cli-app';\nimport { PrGateCliInvocationFactory } from './pr-gate-cli-invocation';\n\nconst container = new PrGateContainer().create();\nrunMain(\n (): Promise<void> =>\n container\n .get(PrGateCliApp)\n .run(container.get(PrGateCliInvocationFactory).fromProcess('wp-build-dev')),\n);\n"]}