@webpieces/pr-gate 0.3.348 → 0.3.350
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
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webpieces/pr-gate",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.350",
|
|
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",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"directory": "packages/tooling/pr-gate"
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@webpieces/rules-config": "0.3.
|
|
24
|
+
"@webpieces/rules-config": "0.3.350"
|
|
25
25
|
},
|
|
26
26
|
"publishConfig": {
|
|
27
27
|
"access": "public"
|
|
@@ -9,8 +9,9 @@ exports.ensurePushed = ensurePushed;
|
|
|
9
9
|
const child_process_1 = require("child_process");
|
|
10
10
|
const rules_config_1 = require("@webpieces/rules-config");
|
|
11
11
|
const SEP = '━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n';
|
|
12
|
-
// The AI-facing doc the failure messages point at (generated under
|
|
13
|
-
|
|
12
|
+
// The AI-facing doc the failure messages point at (generated under `.webpieces/instruct-ai`, at the
|
|
13
|
+
// REPO ROOT — resolved absolute so the AI opens it regardless of the cwd it reads the message from).
|
|
14
|
+
const GIT_WORKFLOW_DOC_NAME = 'webpieces.git-workflow.md';
|
|
14
15
|
// Run a read-only git query from the repo root; abort if git itself errors. Kept `cwd`-explicit (not
|
|
15
16
|
// process.cwd()) because `git ls-files --others` is scoped to the cwd subtree — running from a subdir
|
|
16
17
|
// would miss untracked files elsewhere in the repo.
|
|
@@ -48,7 +49,7 @@ function assertCleanTree(cwd) {
|
|
|
48
49
|
'changes, and either commit or delete any untracked files, then re-run.\n\n' +
|
|
49
50
|
'Working tree (git status --porcelain):\n' +
|
|
50
51
|
dirty + '\n\n' +
|
|
51
|
-
`See ${
|
|
52
|
+
`See ${new rules_config_1.RepoRootFinder().docPathFrom(cwd, GIT_WORKFLOW_DOC_NAME)} for the full merge + PR process.\n` +
|
|
52
53
|
SEP);
|
|
53
54
|
}
|
|
54
55
|
/**
|
|
@@ -66,7 +67,7 @@ function assertNoUntracked(cwd) {
|
|
|
66
67
|
'The tooling will not sweep untracked files into the squash commit. Commit\n' +
|
|
67
68
|
'or delete these, then re-run:\n\n' +
|
|
68
69
|
untracked + '\n\n' +
|
|
69
|
-
`See ${
|
|
70
|
+
`See ${new rules_config_1.RepoRootFinder().docPathFrom(cwd, GIT_WORKFLOW_DOC_NAME)} for the full merge + PR process.\n` +
|
|
70
71
|
SEP);
|
|
71
72
|
}
|
|
72
73
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"git-exec.js","sourceRoot":"","sources":["../../../../../../../packages/tooling/pr-gate/src/scripts/workflow/git-exec.ts"],"names":[],"mappings":";;AAqBA,4CAEC;AAGD,wCAEC;AASD,0CAcC;AAOD,8CAaC;AAOD,sCAKC;AAOD,oCAOC;AAjGD,iDAA0C;AAC1C,
|
|
1
|
+
{"version":3,"file":"git-exec.js","sourceRoot":"","sources":["../../../../../../../packages/tooling/pr-gate/src/scripts/workflow/git-exec.ts"],"names":[],"mappings":";;AAqBA,4CAEC;AAGD,wCAEC;AASD,0CAcC;AAOD,8CAaC;AAOD,sCAKC;AAOD,oCAOC;AAjGD,iDAA0C;AAC1C,0DAAuE;AAEvE,MAAM,GAAG,GAAG,0DAA0D,CAAC;AACvE,oGAAoG;AACpG,qGAAqG;AACrG,MAAM,qBAAqB,GAAG,2BAA2B,CAAC;AAE1D,qGAAqG;AACrG,sGAAsG;AACtG,oDAAoD;AACpD,SAAS,QAAQ,CAAC,IAAc,EAAE,GA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'child_process';\nimport { CliExitError, RepoRootFinder } from '@webpieces/rules-config';\n\nconst SEP = '━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\\n';\n// The AI-facing doc the failure messages point at (generated under `.webpieces/instruct-ai`, at the\n// REPO ROOT — resolved absolute so the AI opens it regardless of the cwd it reads the message from).\nconst GIT_WORKFLOW_DOC_NAME = 'webpieces.git-workflow.md';\n\n// Run a read-only git query from the repo root; abort if git itself errors. Kept `cwd`-explicit (not\n// process.cwd()) because `git ls-files --others` is scoped to the cwd subtree — running from a subdir\n// would miss untracked files elsewhere in the repo.\nfunction gitQuery(args: string[], cwd: string, failMsg: string): string {\n const out = spawnSync('git', args, { encoding: 'utf8', cwd });\n if (out.status !== 0) {\n throw new CliExitError(1, `❌ ${failMsg}`);\n }\n return out.stdout.trim();\n}\n\n// Tracked changes (staged + unstaged) AND untracked files, EXCLUDING gitignored paths — so `.webpieces/`\n// tooling artifacts never count. Empty string = fully committed. Exported for unit testing.\nexport function uncommittedFiles(cwd: string): string {\n return gitQuery(['status', '--porcelain'], cwd, 'Failed to run `git status --porcelain` to check the working tree.');\n}\n\n// Untracked files only (respects .gitignore). Empty string = none. Exported for unit testing.\nexport function untrackedFiles(cwd: string): string {\n return gitQuery(['ls-files', '--others', '--exclude-standard'], cwd, 'Failed to list untracked files (git ls-files --others).');\n}\n\n/**\n * Precondition for every PR/merge entry point: the working tree must be fully committed. The webpieces\n * tooling deliberately does NOT `git add`/`commit` the developer's work for them — a blanket `git add\n * -A` once swept a stale untracked directory into a squash commit, and building the working tree while\n * pushing HEAD let an uncommitted fix pass the build gate yet push a stale commit. Aborts with\n * instructions if anything is uncommitted (tracked or untracked, excluding gitignored).\n */\nexport function assertCleanTree(cwd: string): void {\n const dirty = uncommittedFiles(cwd);\n if (dirty === '') return;\n throw new CliExitError(1,\n '\\n' + SEP +\n '❌ ERROR: You have uncommitted or untracked changes\\n' +\n SEP + '\\n' +\n 'The webpieces PR tooling will NOT commit your work for you. Commit your\\n' +\n 'changes, and either commit or delete any untracked files, then re-run.\\n\\n' +\n 'Working tree (git status --porcelain):\\n' +\n dirty + '\\n\\n' +\n `See ${new RepoRootFinder().docPathFrom(cwd, GIT_WORKFLOW_DOC_NAME)} for the full merge + PR process.\\n` +\n SEP,\n );\n}\n\n/**\n * Narrower guard for the merge-resolve commit point, where tracked resolutions are legitimately in the\n * tree but untracked files must NOT be swept into the squash commit (replaces the old blanket `git add\n * -A`). Lists any untracked files and aborts so the AI commits or deletes them explicitly.\n */\nexport function assertNoUntracked(cwd: string): void {\n const untracked = untrackedFiles(cwd);\n if (untracked === '') return;\n throw new CliExitError(1,\n '\\n' + SEP +\n '❌ ERROR: Untracked files present during merge finalize\\n' +\n SEP + '\\n' +\n 'The tooling will not sweep untracked files into the squash commit. Commit\\n' +\n 'or delete these, then re-run:\\n\\n' +\n untracked + '\\n\\n' +\n `See ${new RepoRootFinder().docPathFrom(cwd, GIT_WORKFLOW_DOC_NAME)} for the full merge + PR process.\\n` +\n SEP,\n );\n}\n\n/**\n * Run a git command that is expected to succeed; abort the process with a clear message\n * if it fails. Used for fetch/pull/checkout/commit where silently continuing on failure\n * would operate on stale or wrong state.\n */\nexport function runGitChecked(args: string[], errMsg: string): void {\n const result = spawnSync('git', args, { stdio: 'inherit' });\n if (result.status !== 0) {\n throw new CliExitError(1, `❌ ${errMsg} (git ${args.join(' ')} exited ${String(result.status)})`);\n }\n}\n\n/**\n * Push HEAD to origin/<currentBranch>. Single source of truth shared by wp-start-upsert-pr and\n * wp-finish-upsert-pr (they pushed with identical copy-pasted logic). Uses --force-with-lease for an\n * existing remote branch (the 3-point squash rewrites history) and -u for a brand-new branch.\n */\nexport function ensurePushed(currentBranch: string): void {\n const remoteExists = spawnSync('git', ['ls-remote', '--exit-code', '--heads', 'origin', currentBranch]).status === 0;\n if (remoteExists) {\n runGitChecked(['push', '--force-with-lease', 'origin', `HEAD:${currentBranch}`], 'Failed to push branch');\n } else {\n runGitChecked(['push', '-u', 'origin', `HEAD:${currentBranch}`], 'Failed to push new branch');\n }\n}\n"]}
|