@webpieces/pr-gate 0.4.511 → 0.4.513
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 +2 -2
- package/src/scripts/commands/finish-upsert-pr-command.js +1 -1
- package/src/scripts/commands/finish-upsert-pr-command.js.map +1 -1
- package/src/scripts/commands/review-upsert-pr-command.d.ts +3 -3
- package/src/scripts/commands/review-upsert-pr-command.js +14 -39
- package/src/scripts/commands/review-upsert-pr-command.js.map +1 -1
- package/src/scripts/commands/start-upsert-pr-command.d.ts +0 -1
- package/src/scripts/commands/start-upsert-pr-command.js +5 -17
- package/src/scripts/commands/start-upsert-pr-command.js.map +1 -1
- package/src/scripts/workflow/build-affected.d.ts +6 -1
- package/src/scripts/workflow/build-affected.js +10 -5
- package/src/scripts/workflow/build-affected.js.map +1 -1
- package/src/scripts/workflow/checklist-scanner.d.ts +15 -1
- package/src/scripts/workflow/checklist-scanner.js +19 -2
- package/src/scripts/workflow/checklist-scanner.js.map +1 -1
- package/src/scripts/workflow/diff-basis.d.ts +16 -1
- package/src/scripts/workflow/diff-basis.js +29 -3
- package/src/scripts/workflow/diff-basis.js.map +1 -1
- package/src/scripts/workflow/diff-materializer.d.ts +4 -1
- package/src/scripts/workflow/diff-materializer.js +11 -2
- package/src/scripts/workflow/diff-materializer.js.map +1 -1
- package/src/scripts/workflow/pr-context-writer.d.ts +4 -1
- package/src/scripts/workflow/pr-context-writer.js +17 -4
- package/src/scripts/workflow/pr-context-writer.js.map +1 -1
|
@@ -38,15 +38,28 @@ let PrContextWriter = class PrContextWriter {
|
|
|
38
38
|
* *.sql / Dockerfile / .env* file a checklist most wants to key on). `includeDeletions` is on for the
|
|
39
39
|
* same reason: a DELETED migration is exactly what a checklist wants to see.
|
|
40
40
|
*/
|
|
41
|
-
|
|
41
|
+
// eslint-disable-next-line @typescript-eslint/max-params
|
|
42
|
+
ensure(repoRoot, featureName, basis, stage, changedFiles, diffDir = '') {
|
|
42
43
|
if (basis.unresolved)
|
|
43
44
|
return new rules_config_1.ChecklistReviewContext();
|
|
45
|
+
// Reuse the caller's changed-file set when it has one. ChecklistScanner already computed exactly
|
|
46
|
+
// this list to do its matching, and recomputing it here was a second `git diff --name-only` per
|
|
47
|
+
// command for a list we were handed — and a second chance for the two to disagree.
|
|
48
|
+
const changed = changedFiles ?? this.changedFiles(repoRoot, basis);
|
|
49
|
+
const p = this.reviewJsonService.writePrContext(repoRoot, featureName, new rules_config_1.PrContext(basis.base, basis.headSha, [...changed], basis.dirty, basis.dirtyFiles, basis.diffCommand, diffDir, new Date().toISOString(), basis.hashMainHead), stage);
|
|
50
|
+
return new rules_config_1.ChecklistReviewContext(basis.base, p, basis.fileDiffCommand, diffDir, basis.dirty);
|
|
51
|
+
}
|
|
52
|
+
/** The context WITHOUT persisting it — for a caller that must write later (after materializing). */
|
|
53
|
+
contextFor(repoRoot, featureName, basis) {
|
|
54
|
+
if (basis.unresolved)
|
|
55
|
+
return new rules_config_1.ChecklistReviewContext();
|
|
56
|
+
return new rules_config_1.ChecklistReviewContext(basis.base, this.reviewJsonService.prContextPath(repoRoot, featureName), basis.fileDiffCommand, '', basis.dirty);
|
|
57
|
+
}
|
|
58
|
+
changedFiles(repoRoot, basis) {
|
|
44
59
|
const opts = new rules_config_1.ChangedFilesOptions();
|
|
45
60
|
opts.tsOnly = false;
|
|
46
61
|
opts.includeDeletions = true;
|
|
47
|
-
|
|
48
|
-
const p = this.reviewJsonService.writePrContext(repoRoot, featureName, new rules_config_1.PrContext(basis.base, basis.headSha, changed, basis.dirty, basis.dirtyFiles, basis.diffCommand, diffDir, new Date().toISOString()));
|
|
49
|
-
return new rules_config_1.ChecklistReviewContext(basis.base, p, basis.fileDiffCommand, diffDir, basis.dirty);
|
|
62
|
+
return this.diffScope.getChangedFiles(repoRoot, basis.base, undefined, opts);
|
|
50
63
|
}
|
|
51
64
|
};
|
|
52
65
|
exports.PrContextWriter = PrContextWriter;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pr-context-writer.js","sourceRoot":"","sources":["../../../../../../../packages/tooling/pr-gate/src/scripts/workflow/pr-context-writer.ts"],"names":[],"mappings":";;;;AAAA,0DAEiC;AACjC,yCAA2D;AAG3D;;;;;;;;;;;GAWG;AAEI,IAAM,eAAe,GAArB,MAAM,eAAe;IAEH;IACA;IAFrB,YACqB,SAAoB,EACpB,iBAAoC;QADpC,cAAS,GAAT,SAAS,CAAW;QACpB,sBAAiB,GAAjB,iBAAiB,CAAmB;IACtD,CAAC;IAEJ;;;;;;;;;;;;;;OAcG;IACH,MAAM,CAAC,QAAgB,EAAE,WAAmB,EAAE,KAAgB,EAAE,OAAO,GAAG,EAAE;
|
|
1
|
+
{"version":3,"file":"pr-context-writer.js","sourceRoot":"","sources":["../../../../../../../packages/tooling/pr-gate/src/scripts/workflow/pr-context-writer.ts"],"names":[],"mappings":";;;;AAAA,0DAEiC;AACjC,yCAA2D;AAG3D;;;;;;;;;;;GAWG;AAEI,IAAM,eAAe,GAArB,MAAM,eAAe;IAEH;IACA;IAFrB,YACqB,SAAoB,EACpB,iBAAoC;QADpC,cAAS,GAAT,SAAS,CAAW;QACpB,sBAAiB,GAAjB,iBAAiB,CAAmB;IACtD,CAAC;IAEJ;;;;;;;;;;;;;;OAcG;IACH,yDAAyD;IACzD,MAAM,CAAC,QAAgB,EAAE,WAAmB,EAAE,KAAgB,EAAE,KAAa,EAAE,YAAgC,EAAE,OAAO,GAAG,EAAE;QACzH,IAAI,KAAK,CAAC,UAAU;YAAE,OAAO,IAAI,qCAAsB,EAAE,CAAC;QAC1D,iGAAiG;QACjG,gGAAgG;QAChG,mFAAmF;QACnF,MAAM,OAAO,GAAG,YAAY,IAAI,IAAI,CAAC,YAAY,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;QACnE,MAAM,CAAC,GAAG,IAAI,CAAC,iBAAiB,CAAC,cAAc,CAAC,QAAQ,EAAE,WAAW,EAAE,IAAI,wBAAS,CAChF,KA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PrContext, ReviewJsonService,\n} from '@webpieces/rules-config';\nimport { injectable, bindingScopeValues } from 'inversify';\nimport { DiffBasis } from './diff-basis';\n\n/**\n * Writes `pr-context.json` (the 3-point base/head sha + the FULL changed-file set) and returns the context\n * every printed review instruction inlines.\n *\n * Extracted so `wp-start-upsert-pr` and `wp-review-upsert-pr` cannot diverge. It used to live only in wp-start,\n * which meant `wp-review-upsert-pr` — the command wp-start tells the AI to run FIRST — silently rendered its\n * reviewer blocks with NO `git diff` command and NO full-file-set path whenever wp-start had not run this\n * cycle. A reviewer handed filenames and no way to read the diff is exactly the failure this instruction\n * exists to prevent, and it failed silently, which is worse.\n *\n * `@injectable(bindingScopeValues.Singleton)` so it is injected by type and drawn in the DI design.\n */\n@injectable(bindingScopeValues.Singleton)\nexport class PrContextWriter {\n constructor(\n private readonly diffScope: DiffScope,\n private readonly reviewJsonService: ReviewJsonService,\n ) {}\n\n /**\n * Compute + persist the context against the {@link DiffBasis} the CALLER already resolved, so the range\n * a reviewer is told to diff is byte-identical to the one the pattern matching used. Returns an EMPTY\n * context when the basis has no fork point — callers must say so out loud rather than quietly omit the\n * lines it would have filled; see ChecklistInstructionsService.diffLines.\n *\n * Taking a DiffBasis rather than a bare `forkPoint: string` is the fix, not a refactor: with a lone sha\n * this method had no way to know whether the tree was dirty, so it recorded `head:'HEAD'` and every\n * downstream reader assembled a commit-to-commit command that shows nothing when work is uncommitted.\n *\n * Two things mirror ChecklistScanner deliberately: no head argument to `getChangedFiles` (so the working\n * tree and untracked files are included, not just commits), and `tsOnly:false` (the default drops every\n * *.sql / Dockerfile / .env* file a checklist most wants to key on). `includeDeletions` is on for the\n * same reason: a DELETED migration is exactly what a checklist wants to see.\n */\n // eslint-disable-next-line @typescript-eslint/max-params\n ensure(repoRoot: string, featureName: string, basis: DiffBasis, stage: string, changedFiles?: readonly string[], diffDir = ''): ChecklistReviewContext {\n if (basis.unresolved) return new ChecklistReviewContext();\n // Reuse the caller's changed-file set when it has one. ChecklistScanner already computed exactly\n // this list to do its matching, and recomputing it here was a second `git diff --name-only` per\n // command for a list we were handed — and a second chance for the two to disagree.\n const changed = changedFiles ?? this.changedFiles(repoRoot, basis);\n const p = this.reviewJsonService.writePrContext(repoRoot, featureName, new PrContext(\n basis.base, basis.headSha, [...changed],\n basis.dirty, basis.dirtyFiles, basis.diffCommand, diffDir, new Date().toISOString(),\n basis.hashMainHead,\n ), stage);\n return new ChecklistReviewContext(basis.base, p, basis.fileDiffCommand, diffDir, basis.dirty);\n }\n\n /** The context WITHOUT persisting it — for a caller that must write later (after materializing). */\n contextFor(repoRoot: string, featureName: string, basis: DiffBasis): ChecklistReviewContext {\n if (basis.unresolved) return new ChecklistReviewContext();\n return new ChecklistReviewContext(\n basis.base, this.reviewJsonService.prContextPath(repoRoot, featureName),\n basis.fileDiffCommand, '', basis.dirty);\n }\n\n private changedFiles(repoRoot: string, basis: DiffBasis): string[] {\n const opts = new ChangedFilesOptions();\n opts.tsOnly = false;\n opts.includeDeletions = true;\n return this.diffScope.getChangedFiles(repoRoot, basis.base, undefined, opts);\n }\n}\n"]}
|