@webpieces/rules-config 0.3.357 → 0.3.358

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/rules-config",
3
- "version": "0.3.357",
3
+ "version": "0.3.358",
4
4
  "description": "Shared webpieces.config.json loader. Single source of truth for validation rule configuration consumed by @webpieces/ai-hook-rules, @webpieces/code-rules, and @webpieces/nx-webpieces-rules.",
5
5
  "type": "commonjs",
6
6
  "main": "./src/index.js",
@@ -14,8 +14,8 @@
14
14
  "README.md"
15
15
  ],
16
16
  "dependencies": {
17
- "@webpieces/core-context": "0.3.357",
18
- "@webpieces/core-util": "0.3.357",
17
+ "@webpieces/core-context": "0.3.358",
18
+ "@webpieces/core-util": "0.3.358",
19
19
  "@inversifyjs/binding-decorators": "1.1.5",
20
20
  "inversify": "7.10.4",
21
21
  "reflect-metadata": "0.2.2",
@@ -1,13 +1,10 @@
1
1
  /**
2
- * Shared git-diff + diff-scoping helpers for ALL rule validators (code-rules) and nx executors
3
- * (nx-webpieces-rules). Centralized here in rules-config because it is the one package both of
4
- * those depend on, and it already shells out to git (see skip-rule.ts).
2
+ * Shared git-diff + diff-scoping service for ALL rule validators (code-rules) and nx executors
3
+ * (nx-webpieces-rules). Centralized here in rules-config because it is the one package both depend on.
5
4
  *
6
- * Before this module these functions were copy-pasted ~15× (one private copy per validator + the
7
- * validate-ts-in-src executor). They are now defined once; every consumer imports from
8
- * `@webpieces/rules-config`. The two historical variants are preserved as parameters:
9
- * - `getChangedFiles(..., { tsOnly: false })` reproduces validate-dtos' all-files diff.
10
- * - `detectBase` replaces both the nested-try and the ref-loop spellings (identical behavior).
5
+ * `@provideSingleton` so it can be injected and appear in the rules-config DI design. Free-function
6
+ * delegators are kept temporarily so the many existing consumers stay green; they migrate to injecting
7
+ * {@link DiffScope} over follow-up PRs, then the delegators are removed.
11
8
  */
12
9
  /** A git diff range: the base ref to compare against and an optional head (else the working tree). */
13
10
  export declare class DiffRange {
@@ -18,48 +15,34 @@ export declare class DiffRange {
18
15
  export declare class ChangedFilesOptions {
19
16
  tsOnly?: boolean;
20
17
  }
21
- /**
22
- * Auto-detect the diff base: the merge-base of HEAD with origin/main, falling back to local main.
23
- * Returns null when neither ref resolves (e.g. shallow clone with no main) callers treat null as
24
- * "no base detected" and typically skip.
25
- */
18
+ export declare class DiffScope {
19
+ /** Auto-detect the diff base: merge-base of HEAD with origin/main, falling back to local main. */
20
+ detectBase(workspaceRoot: string): string | null;
21
+ /** Resolve the diff range a rule should compare against (honors nx's NX_BASE / NX_HEAD). */
22
+ resolveBase(workspaceRoot: string): DiffRange;
23
+ /**
24
+ * Changed files between base and head (or base→working-tree when head is omitted). Untracked files
25
+ * are unioned in for the working-tree case. `tsOnly` (default true) restricts to *.ts/*.tsx and
26
+ * drops test files. Deletions are excluded (`--diff-filter=d`).
27
+ */
28
+ getChangedFiles(workspaceRoot: string, base: string, head?: string, opts?: ChangedFilesOptions): string[];
29
+ /** Diff content for a single file (synthetic all-added diff for an untracked file with no head). */
30
+ getFileDiff(workspaceRoot: string, file: string, base: string, head?: string): string;
31
+ /** Added/changed line numbers (the `+` lines per hunk) — basis of NEW_AND_MODIFIED_CODE scoping. */
32
+ getChangedLineNumbers(diffContent: string): Set<number>;
33
+ /** Method names whose signature line is a `+` addition in the diff — the basis of "NEW" methods. */
34
+ findNewMethodSignaturesInDiff(diffContent: string): Set<string>;
35
+ /** True if any line in [startLine, endLine] is in the changedLines set. */
36
+ hasChangesInRange(startLine: number, endLine: number, changedLines: Set<number>): boolean;
37
+ /** True if a node (method/function) is newly added or has any changed line in its range. */
38
+ isNewOrModified(name: string, startLine: number, endLine: number, changedLines: Set<number>, newMethodNames: Set<string>): boolean;
39
+ private isTestFile;
40
+ }
26
41
  export declare function detectBase(workspaceRoot: string): string | null;
27
- /**
28
- * Resolve the diff range a rule should compare against. Honors nx's NX_BASE / NX_HEAD (set by
29
- * `nx affected --base=.. --head=..`); when NX_BASE is unset, auto-detects via detectBase. A returned
30
- * `base` of undefined means "could not determine a base" (caller should skip).
31
- */
32
42
  export declare function resolveBase(workspaceRoot: string): DiffRange;
33
- /**
34
- * Changed files between base and head (or base→working-tree when head is omitted). When head is
35
- * omitted, untracked files are unioned in too (matching `nx affected`). `tsOnly` (default true)
36
- * restricts to *.ts/*.tsx and drops test files; pass false for an all-files diff.
37
- *
38
- * Deletions are excluded (`--diff-filter=d`): every consumer reasons about a file's current
39
- * content or location, and a path that no longer exists can't violate anything. This also fixes
40
- * renames — without rename detection git reports a rename as delete+add, so filtering the delete
41
- * side leaves only the file's NEW path in the list.
42
- */
43
43
  export declare function getChangedFiles(workspaceRoot: string, base: string, head?: string, opts?: ChangedFilesOptions): string[];
44
- /**
45
- * Diff content for a single file. When the file is untracked (and no head is given) a synthetic
46
- * all-added diff is produced so new files count as fully-changed.
47
- */
48
44
  export declare function getFileDiff(workspaceRoot: string, file: string, base: string, head?: string): string;
49
- /**
50
- * Parse a unified diff and return the set of added/changed line numbers (the `+` lines per hunk).
51
- * This is the basis of NEW_AND_MODIFIED_CODE (line-level) scoping.
52
- */
53
45
  export declare function getChangedLineNumbers(diffContent: string): Set<number>;
54
- /**
55
- * Method names whose signature line is a `+` addition in the diff — the basis of "NEW" methods.
56
- */
57
46
  export declare function findNewMethodSignaturesInDiff(diffContent: string): Set<string>;
58
- /**
59
- * True if any line in [startLine, endLine] is in the changedLines set.
60
- */
61
47
  export declare function hasChangesInRange(startLine: number, endLine: number, changedLines: Set<number>): boolean;
62
- /**
63
- * True if a node (method/function) is newly added or has any changed line in its range.
64
- */
65
48
  export declare function isNewOrModified(name: string, startLine: number, endLine: number, changedLines: Set<number>, newMethodNames: Set<string>): boolean;
package/src/diff-scope.js CHANGED
@@ -1,17 +1,14 @@
1
1
  "use strict";
2
2
  /**
3
- * Shared git-diff + diff-scoping helpers for ALL rule validators (code-rules) and nx executors
4
- * (nx-webpieces-rules). Centralized here in rules-config because it is the one package both of
5
- * those depend on, and it already shells out to git (see skip-rule.ts).
3
+ * Shared git-diff + diff-scoping service for ALL rule validators (code-rules) and nx executors
4
+ * (nx-webpieces-rules). Centralized here in rules-config because it is the one package both depend on.
6
5
  *
7
- * Before this module these functions were copy-pasted ~15× (one private copy per validator + the
8
- * validate-ts-in-src executor). They are now defined once; every consumer imports from
9
- * `@webpieces/rules-config`. The two historical variants are preserved as parameters:
10
- * - `getChangedFiles(..., { tsOnly: false })` reproduces validate-dtos' all-files diff.
11
- * - `detectBase` replaces both the nested-try and the ref-loop spellings (identical behavior).
6
+ * `@provideSingleton` so it can be injected and appear in the rules-config DI design. Free-function
7
+ * delegators are kept temporarily so the many existing consumers stay green; they migrate to injecting
8
+ * {@link DiffScope} over follow-up PRs, then the delegators are removed.
12
9
  */
13
10
  Object.defineProperty(exports, "__esModule", { value: true });
14
- exports.ChangedFilesOptions = exports.DiffRange = void 0;
11
+ exports.DiffScope = exports.ChangedFilesOptions = exports.DiffRange = void 0;
15
12
  exports.detectBase = detectBase;
16
13
  exports.resolveBase = resolveBase;
17
14
  exports.getChangedFiles = getChangedFiles;
@@ -24,6 +21,8 @@ const tslib_1 = require("tslib");
24
21
  const child_process_1 = require("child_process");
25
22
  const fs = tslib_1.__importStar(require("fs"));
26
23
  const path = tslib_1.__importStar(require("path"));
24
+ const core_context_1 = require("@webpieces/core-context");
25
+ const inversify_1 = require("inversify");
27
26
  const to_error_1 = require("./to-error");
28
27
  /** A git diff range: the base ref to compare against and an optional head (else the working tree). */
29
28
  class DiffRange {
@@ -36,202 +35,216 @@ class ChangedFilesOptions {
36
35
  tsOnly;
37
36
  }
38
37
  exports.ChangedFilesOptions = ChangedFilesOptions;
39
- /**
40
- * A file is "a test file" (excluded from diff-scoped rules) when it is a .spec/.test file or lives
41
- * under a __tests__/ directory. Union of every per-validator filter so no consumer loses coverage.
42
- */
43
- function isTestFile(file) {
44
- return file.includes('.spec.ts') || file.includes('.test.ts') || file.includes('__tests__/');
45
- }
46
- /**
47
- * Auto-detect the diff base: the merge-base of HEAD with origin/main, falling back to local main.
48
- * Returns null when neither ref resolves (e.g. shallow clone with no main) — callers treat null as
49
- * "no base detected" and typically skip.
50
- */
51
- function detectBase(workspaceRoot) {
52
- for (const ref of ['origin/main', 'main']) {
53
- // eslint-disable-next-line @webpieces/no-unmanaged-exceptions
54
- try {
55
- const merged = (0, child_process_1.execSync)(`git merge-base HEAD ${ref}`, {
56
- cwd: workspaceRoot, encoding: 'utf-8', stdio: ['pipe', 'pipe', 'pipe'],
57
- }).trim();
58
- if (merged)
59
- return merged;
60
- }
61
- catch (err) {
62
- const error = (0, to_error_1.toError)(err);
63
- void error; // swallow — try the next ref
64
- }
65
- }
66
- return null;
67
- }
68
- /**
69
- * Resolve the diff range a rule should compare against. Honors nx's NX_BASE / NX_HEAD (set by
70
- * `nx affected --base=.. --head=..`); when NX_BASE is unset, auto-detects via detectBase. A returned
71
- * `base` of undefined means "could not determine a base" (caller should skip).
72
- */
73
- function resolveBase(workspaceRoot) {
74
- const range = new DiffRange();
75
- range.base = process.env['NX_BASE'];
76
- range.head = process.env['NX_HEAD'];
77
- if (!range.base) {
78
- range.base = detectBase(workspaceRoot) ?? undefined;
79
- }
80
- return range;
81
- }
82
- /**
83
- * Changed files between base and head (or base→working-tree when head is omitted). When head is
84
- * omitted, untracked files are unioned in too (matching `nx affected`). `tsOnly` (default true)
85
- * restricts to *.ts/*.tsx and drops test files; pass false for an all-files diff.
86
- *
87
- * Deletions are excluded (`--diff-filter=d`): every consumer reasons about a file's current
88
- * content or location, and a path that no longer exists can't violate anything. This also fixes
89
- * renames — without rename detection git reports a rename as delete+add, so filtering the delete
90
- * side leaves only the file's NEW path in the list.
91
- */
92
- // webpieces-disable max-lines-new-methods -- git command handling with untracked files needs several code paths
93
- function getChangedFiles(workspaceRoot, base, head, opts) {
94
- const tsOnly = opts?.tsOnly ?? true;
95
- const glob = tsOnly ? " -- '*.ts' '*.tsx'" : '';
96
- const keep = (f) => f.length > 0 && (!tsOnly || !isTestFile(f));
97
- // eslint-disable-next-line @webpieces/no-unmanaged-exceptions
98
- try {
99
- const diffTarget = head ? `${base} ${head}` : base;
100
- const output = (0, child_process_1.execSync)(`git diff --name-only --diff-filter=d ${diffTarget}${glob}`, {
101
- cwd: workspaceRoot,
102
- encoding: 'utf-8',
103
- });
104
- const changedFiles = output.trim().split('\n').filter(keep);
105
- // Working-tree comparison (no head): also include untracked files, as nx affected does.
106
- if (!head) {
38
+ let DiffScope = class DiffScope {
39
+ /** Auto-detect the diff base: merge-base of HEAD with origin/main, falling back to local main. */
40
+ detectBase(workspaceRoot) {
41
+ for (const ref of ['origin/main', 'main']) {
107
42
  // eslint-disable-next-line @webpieces/no-unmanaged-exceptions
108
43
  try {
109
- const untrackedOutput = (0, child_process_1.execSync)(`git ls-files --others --exclude-standard${glob}`, {
110
- cwd: workspaceRoot,
111
- encoding: 'utf-8',
112
- });
113
- const untrackedFiles = untrackedOutput.trim().split('\n').filter(keep);
114
- return Array.from(new Set([...changedFiles, ...untrackedFiles]));
44
+ const merged = (0, child_process_1.execSync)(`git merge-base HEAD ${ref}`, {
45
+ cwd: workspaceRoot, encoding: 'utf-8', stdio: ['pipe', 'pipe', 'pipe'],
46
+ }).trim();
47
+ if (merged)
48
+ return merged;
115
49
  }
116
50
  catch (err) {
117
51
  const error = (0, to_error_1.toError)(err);
118
- void error; // swallow — ls-files failure falls back to the tracked list
119
- return changedFiles;
52
+ void error; // swallow — try the next ref
120
53
  }
121
54
  }
122
- return changedFiles;
55
+ return null;
123
56
  }
124
- catch (err) {
125
- const error = (0, to_error_1.toError)(err);
126
- void error; // swallow — git diff failure returns an empty list
127
- return [];
57
+ /** Resolve the diff range a rule should compare against (honors nx's NX_BASE / NX_HEAD). */
58
+ resolveBase(workspaceRoot) {
59
+ const range = new DiffRange();
60
+ range.base = process.env['NX_BASE'];
61
+ range.head = process.env['NX_HEAD'];
62
+ if (!range.base) {
63
+ range.base = this.detectBase(workspaceRoot) ?? undefined;
64
+ }
65
+ return range;
128
66
  }
129
- }
130
- /**
131
- * Diff content for a single file. When the file is untracked (and no head is given) a synthetic
132
- * all-added diff is produced so new files count as fully-changed.
133
- */
134
- function getFileDiff(workspaceRoot, file, base, head) {
135
- // eslint-disable-next-line @webpieces/no-unmanaged-exceptions
136
- try {
137
- const diffTarget = head ? `${base} ${head}` : base;
138
- const diff = (0, child_process_1.execSync)(`git diff ${diffTarget} -- "${file}"`, {
139
- cwd: workspaceRoot,
140
- encoding: 'utf-8',
141
- });
142
- if (!diff && !head) {
143
- const fullPath = path.join(workspaceRoot, file);
144
- if (fs.existsSync(fullPath)) {
145
- const isUntracked = (0, child_process_1.execSync)(`git ls-files --others --exclude-standard "${file}"`, {
146
- cwd: workspaceRoot,
147
- encoding: 'utf-8',
148
- }).trim();
149
- if (isUntracked) {
150
- const content = fs.readFileSync(fullPath, 'utf-8');
151
- return content.split('\n').map((l) => `+${l}`).join('\n');
67
+ /**
68
+ * Changed files between base and head (or base→working-tree when head is omitted). Untracked files
69
+ * are unioned in for the working-tree case. `tsOnly` (default true) restricts to *.ts/*.tsx and
70
+ * drops test files. Deletions are excluded (`--diff-filter=d`).
71
+ */
72
+ // webpieces-disable max-lines-new-methods -- git command handling with untracked files needs several code paths
73
+ getChangedFiles(workspaceRoot, base, head, opts) {
74
+ const tsOnly = opts?.tsOnly ?? true;
75
+ const glob = tsOnly ? " -- '*.ts' '*.tsx'" : '';
76
+ const keep = (f) => f.length > 0 && (!tsOnly || !this.isTestFile(f));
77
+ // eslint-disable-next-line @webpieces/no-unmanaged-exceptions
78
+ try {
79
+ const diffTarget = head ? `${base} ${head}` : base;
80
+ const output = (0, child_process_1.execSync)(`git diff --name-only --diff-filter=d ${diffTarget}${glob}`, {
81
+ cwd: workspaceRoot,
82
+ encoding: 'utf-8',
83
+ });
84
+ const changedFiles = output.trim().split('\n').filter(keep);
85
+ // Working-tree comparison (no head): also include untracked files, as nx affected does.
86
+ if (!head) {
87
+ // eslint-disable-next-line @webpieces/no-unmanaged-exceptions
88
+ try {
89
+ const untrackedOutput = (0, child_process_1.execSync)(`git ls-files --others --exclude-standard${glob}`, {
90
+ cwd: workspaceRoot,
91
+ encoding: 'utf-8',
92
+ });
93
+ const untrackedFiles = untrackedOutput.trim().split('\n').filter(keep);
94
+ return Array.from(new Set([...changedFiles, ...untrackedFiles]));
95
+ }
96
+ catch (err) {
97
+ const error = (0, to_error_1.toError)(err);
98
+ void error; // swallow — ls-files failure falls back to the tracked list
99
+ return changedFiles;
152
100
  }
153
101
  }
102
+ return changedFiles;
154
103
  }
155
- return diff;
156
- }
157
- catch (err) {
158
- const error = (0, to_error_1.toError)(err);
159
- void error; // swallow — git diff failure returns no diff
160
- return '';
161
- }
162
- }
163
- /**
164
- * Parse a unified diff and return the set of added/changed line numbers (the `+` lines per hunk).
165
- * This is the basis of NEW_AND_MODIFIED_CODE (line-level) scoping.
166
- */
167
- function getChangedLineNumbers(diffContent) {
168
- const changedLines = new Set();
169
- const lines = diffContent.split('\n');
170
- let currentLine = 0;
171
- for (const line of lines) {
172
- const hunkMatch = line.match(/^@@ -\d+(?:,\d+)? \+(\d+)(?:,\d+)? @@/);
173
- if (hunkMatch) {
174
- currentLine = parseInt(hunkMatch[1], 10);
175
- continue;
104
+ catch (err) {
105
+ const error = (0, to_error_1.toError)(err);
106
+ void error; // swallow — git diff failure returns an empty list
107
+ return [];
176
108
  }
177
- if (line.startsWith('+') && !line.startsWith('+++')) {
178
- changedLines.add(currentLine);
179
- currentLine++;
109
+ }
110
+ /** Diff content for a single file (synthetic all-added diff for an untracked file with no head). */
111
+ getFileDiff(workspaceRoot, file, base, head) {
112
+ // eslint-disable-next-line @webpieces/no-unmanaged-exceptions
113
+ try {
114
+ const diffTarget = head ? `${base} ${head}` : base;
115
+ const diff = (0, child_process_1.execSync)(`git diff ${diffTarget} -- "${file}"`, {
116
+ cwd: workspaceRoot,
117
+ encoding: 'utf-8',
118
+ });
119
+ if (!diff && !head) {
120
+ const fullPath = path.join(workspaceRoot, file);
121
+ if (fs.existsSync(fullPath)) {
122
+ const isUntracked = (0, child_process_1.execSync)(`git ls-files --others --exclude-standard "${file}"`, {
123
+ cwd: workspaceRoot,
124
+ encoding: 'utf-8',
125
+ }).trim();
126
+ if (isUntracked) {
127
+ const content = fs.readFileSync(fullPath, 'utf-8');
128
+ return content.split('\n').map((l) => `+${l}`).join('\n');
129
+ }
130
+ }
131
+ }
132
+ return diff;
180
133
  }
181
- else if (line.startsWith('-') && !line.startsWith('---')) {
182
- // Deletions don't advance the new-file line counter.
134
+ catch (err) {
135
+ const error = (0, to_error_1.toError)(err);
136
+ void error; // swallow — git diff failure returns no diff
137
+ return '';
183
138
  }
184
- else {
185
- currentLine++;
139
+ }
140
+ /** Added/changed line numbers (the `+` lines per hunk) — basis of NEW_AND_MODIFIED_CODE scoping. */
141
+ getChangedLineNumbers(diffContent) {
142
+ const changedLines = new Set();
143
+ const lines = diffContent.split('\n');
144
+ let currentLine = 0;
145
+ for (const line of lines) {
146
+ const hunkMatch = line.match(/^@@ -\d+(?:,\d+)? \+(\d+)(?:,\d+)? @@/);
147
+ if (hunkMatch) {
148
+ currentLine = parseInt(hunkMatch[1], 10);
149
+ continue;
150
+ }
151
+ if (line.startsWith('+') && !line.startsWith('+++')) {
152
+ changedLines.add(currentLine);
153
+ currentLine++;
154
+ }
155
+ else if (line.startsWith('-') && !line.startsWith('---')) {
156
+ // Deletions don't advance the new-file line counter.
157
+ }
158
+ else {
159
+ currentLine++;
160
+ }
186
161
  }
162
+ return changedLines;
187
163
  }
188
- return changedLines;
189
- }
190
- /**
191
- * Method names whose signature line is a `+` addition in the diff — the basis of "NEW" methods.
192
- */
193
- function findNewMethodSignaturesInDiff(diffContent) {
194
- const newMethods = new Set();
195
- const lines = diffContent.split('\n');
196
- const patterns = [
197
- /^\+\s*(?:export\s+)?(?:async\s+)?function\s+(\w+)\s*\(/,
198
- /^\+\s*(?:export\s+)?(?:const|let)\s+(\w+)\s*=\s*(?:async\s*)?\(/,
199
- /^\+\s*(?:export\s+)?(?:const|let)\s+(\w+)\s*=\s*(?:async\s+)?function/,
200
- /^\+\s*(?:(?:public|private|protected)\s+)?(?:static\s+)?(?:async\s+)?(\w+)\s*\(/,
201
- ];
202
- for (const line of lines) {
203
- if (line.startsWith('+') && !line.startsWith('+++')) {
204
- for (const pattern of patterns) {
205
- const match = line.match(pattern);
206
- if (match) {
207
- const methodName = match[1];
208
- if (methodName && !['if', 'for', 'while', 'switch', 'catch', 'constructor'].includes(methodName)) {
209
- newMethods.add(methodName);
164
+ /** Method names whose signature line is a `+` addition in the diff — the basis of "NEW" methods. */
165
+ findNewMethodSignaturesInDiff(diffContent) {
166
+ const newMethods = new Set();
167
+ const lines = diffContent.split('\n');
168
+ const patterns = [
169
+ /^\+\s*(?:export\s+)?(?:async\s+)?function\s+(\w+)\s*\(/,
170
+ /^\+\s*(?:export\s+)?(?:const|let)\s+(\w+)\s*=\s*(?:async\s*)?\(/,
171
+ /^\+\s*(?:export\s+)?(?:const|let)\s+(\w+)\s*=\s*(?:async\s+)?function/,
172
+ /^\+\s*(?:(?:public|private|protected)\s+)?(?:static\s+)?(?:async\s+)?(\w+)\s*\(/,
173
+ ];
174
+ for (const line of lines) {
175
+ if (line.startsWith('+') && !line.startsWith('+++')) {
176
+ for (const pattern of patterns) {
177
+ const match = line.match(pattern);
178
+ if (match) {
179
+ const methodName = match[1];
180
+ if (methodName && !['if', 'for', 'while', 'switch', 'catch', 'constructor'].includes(methodName)) {
181
+ newMethods.add(methodName);
182
+ }
183
+ break;
210
184
  }
211
- break;
212
185
  }
213
186
  }
214
187
  }
188
+ return newMethods;
215
189
  }
216
- return newMethods;
217
- }
218
- /**
219
- * True if any line in [startLine, endLine] is in the changedLines set.
220
- */
221
- function hasChangesInRange(startLine, endLine, changedLines) {
222
- for (let line = startLine; line <= endLine; line++) {
223
- if (changedLines.has(line)) {
224
- return true;
190
+ /** True if any line in [startLine, endLine] is in the changedLines set. */
191
+ hasChangesInRange(startLine, endLine, changedLines) {
192
+ for (let line = startLine; line <= endLine; line++) {
193
+ if (changedLines.has(line)) {
194
+ return true;
195
+ }
225
196
  }
197
+ return false;
198
+ }
199
+ /** True if a node (method/function) is newly added or has any changed line in its range. */
200
+ isNewOrModified(name, startLine, endLine, changedLines, newMethodNames) {
201
+ if (newMethodNames.has(name))
202
+ return true;
203
+ return this.hasChangesInRange(startLine, endLine, changedLines);
204
+ }
205
+ // A file is "a test file" (excluded from diff-scoped rules) when it is a .spec/.test file or lives
206
+ // under a __tests__/ directory.
207
+ isTestFile(file) {
208
+ return file.includes('.spec.ts') || file.includes('.test.ts') || file.includes('__tests__/');
226
209
  }
227
- return false;
210
+ };
211
+ exports.DiffScope = DiffScope;
212
+ exports.DiffScope = DiffScope = tslib_1.__decorate([
213
+ (0, core_context_1.provideSingleton)(),
214
+ (0, inversify_1.injectable)()
215
+ ], DiffScope);
216
+ // Temporary migration delegators to DiffScope — removed once consumers inject it.
217
+ const diffScopeSvc = new DiffScope();
218
+ // webpieces-disable no-function-outside-class -- temporary back-compat delegator to DiffScope; removed once consumers inject it
219
+ function detectBase(workspaceRoot) {
220
+ return diffScopeSvc.detectBase(workspaceRoot);
228
221
  }
229
- /**
230
- * True if a node (method/function) is newly added or has any changed line in its range.
231
- */
222
+ // webpieces-disable no-function-outside-class -- temporary back-compat delegator to DiffScope; removed once consumers inject it
223
+ function resolveBase(workspaceRoot) {
224
+ return diffScopeSvc.resolveBase(workspaceRoot);
225
+ }
226
+ // webpieces-disable no-function-outside-class -- temporary back-compat delegator to DiffScope; removed once consumers inject it
227
+ function getChangedFiles(workspaceRoot, base, head, opts) {
228
+ return diffScopeSvc.getChangedFiles(workspaceRoot, base, head, opts);
229
+ }
230
+ // webpieces-disable no-function-outside-class -- temporary back-compat delegator to DiffScope; removed once consumers inject it
231
+ function getFileDiff(workspaceRoot, file, base, head) {
232
+ return diffScopeSvc.getFileDiff(workspaceRoot, file, base, head);
233
+ }
234
+ // webpieces-disable no-function-outside-class -- temporary back-compat delegator to DiffScope; removed once consumers inject it
235
+ function getChangedLineNumbers(diffContent) {
236
+ return diffScopeSvc.getChangedLineNumbers(diffContent);
237
+ }
238
+ // webpieces-disable no-function-outside-class -- temporary back-compat delegator to DiffScope; removed once consumers inject it
239
+ function findNewMethodSignaturesInDiff(diffContent) {
240
+ return diffScopeSvc.findNewMethodSignaturesInDiff(diffContent);
241
+ }
242
+ // webpieces-disable no-function-outside-class -- temporary back-compat delegator to DiffScope; removed once consumers inject it
243
+ function hasChangesInRange(startLine, endLine, changedLines) {
244
+ return diffScopeSvc.hasChangesInRange(startLine, endLine, changedLines);
245
+ }
246
+ // webpieces-disable no-function-outside-class -- temporary back-compat delegator to DiffScope; removed once consumers inject it
232
247
  function isNewOrModified(name, startLine, endLine, changedLines, newMethodNames) {
233
- if (newMethodNames.has(name))
234
- return true;
235
- return hasChangesInRange(startLine, endLine, changedLines);
248
+ return diffScopeSvc.isNewOrModified(name, startLine, endLine, changedLines, newMethodNames);
236
249
  }
237
250
  //# sourceMappingURL=diff-scope.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"diff-scope.js","sourceRoot":"","sources":["../../../../../packages/tooling/rules-config/src/diff-scope.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;GAUG;;;AAgCH,gCAcC;AAOD,kCAQC;AAaD,0CAyCC;AAMD,kCA8BC;AAMD,sDAuBC;AAKD,sEA2BC;AAKD,8CAOC;AAKD,0CASC;;AA5OD,iDAAyC;AACzC,+CAAyB;AACzB,mDAA6B;AAE7B,yCAAqC;AAErC,sGAAsG;AACtG,MAAa,SAAS;IAClB,IAAI,CAAU;IACd,IAAI,CAAU;CACjB;AAHD,8BAGC;AAED,yGAAyG;AACzG,MAAa,mBAAmB;IAC5B,MAAM,CAAW;CACpB;AAFD,kDAEC;AAED;;;GAGG;AACH,SAAS,UAAU,CAAC,IAAY;IAC5B,OAAO,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,IA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AAgB,eAAe,CAC3B,IAAY,EACZ,SAAiB,EACjB,OAAe,EACf,YAAyB,EACzB,cAA2B;IAE3B,IAAI,cAAc,CAAC,GAAG,CAAC,IAAI,CAAC;QAAE,OAAO,IAAI,CAAC;IAC1C,OAAO,iBAAiB,CAAC,SAAS,EAAE,OAAO,EAAE,YAAY,CAAC,CAAC;AAC/D,CAAC","sourcesContent":["/**\n * Shared git-diff + diff-scoping helpers for ALL rule validators (code-rules) and nx executors\n * (nx-webpieces-rules). Centralized here in rules-config because it is the one package both of\n * those depend on, and it already shells out to git (see skip-rule.ts).\n *\n * Before this module these functions were copy-pasted ~15× (one private copy per validator + the\n * validate-ts-in-src executor). They are now defined once; every consumer imports from\n * `@webpieces/rules-config`. The two historical variants are preserved as parameters:\n * - `getChangedFiles(..., { tsOnly: false })` reproduces validate-dtos' all-files diff.\n * - `detectBase` replaces both the nested-try and the ref-loop spellings (identical behavior).\n */\n\nimport { execSync } from 'child_process';\nimport * as fs from 'fs';\nimport * as path from 'path';\n\nimport { toError } from './to-error';\n\n/** A git diff range: the base ref to compare against and an optional head (else the working tree). */\nexport class DiffRange {\n base?: string;\n head?: string;\n}\n\n/** Options for getChangedFiles. `tsOnly` (default true) restricts to *.ts/*.tsx and drops test files. */\nexport class ChangedFilesOptions {\n tsOnly?: boolean;\n}\n\n/**\n * A file is \"a test file\" (excluded from diff-scoped rules) when it is a .spec/.test file or lives\n * under a __tests__/ directory. Union of every per-validator filter so no consumer loses coverage.\n */\nfunction isTestFile(file: string): boolean {\n return file.includes('.spec.ts') || file.includes('.test.ts') || file.includes('__tests__/');\n}\n\n/**\n * Auto-detect the diff base: the merge-base of HEAD with origin/main, falling back to local main.\n * Returns null when neither ref resolves (e.g. shallow clone with no main) — callers treat null as\n * \"no base detected\" and typically skip.\n */\nexport function detectBase(workspaceRoot: string): string | null {\n for (const ref of ['origin/main', 'main']) {\n // eslint-disable-next-line @webpieces/no-unmanaged-exceptions\n try {\n const merged = execSync(`git merge-base HEAD ${ref}`, {\n cwd: workspaceRoot, encoding: 'utf-8', stdio: ['pipe', 'pipe', 'pipe'],\n }).trim();\n if (merged) return merged;\n } catch (err: unknown) {\n const error = toError(err);\n void error; // swallow — try the next ref\n }\n }\n return null;\n}\n\n/**\n * Resolve the diff range a rule should compare against. Honors nx's NX_BASE / NX_HEAD (set by\n * `nx affected --base=.. --head=..`); when NX_BASE is unset, auto-detects via detectBase. A returned\n * `base` of undefined means \"could not determine a base\" (caller should skip).\n */\nexport function resolveBase(workspaceRoot: string): DiffRange {\n const range = new DiffRange();\n range.base = process.env['NX_BASE'];\n range.head = process.env['NX_HEAD'];\n if (!range.base) {\n range.base = detectBase(workspaceRoot) ?? undefined;\n }\n return range;\n}\n\n/**\n * Changed files between base and head (or base→working-tree when head is omitted). When head is\n * omitted, untracked files are unioned in too (matching `nx affected`). `tsOnly` (default true)\n * restricts to *.ts/*.tsx and drops test files; pass false for an all-files diff.\n *\n * Deletions are excluded (`--diff-filter=d`): every consumer reasons about a file's current\n * content or location, and a path that no longer exists can't violate anything. This also fixes\n * renames — without rename detection git reports a rename as delete+add, so filtering the delete\n * side leaves only the file's NEW path in the list.\n */\n// webpieces-disable max-lines-new-methods -- git command handling with untracked files needs several code paths\nexport function getChangedFiles(\n workspaceRoot: string,\n base: string,\n head?: string,\n opts?: ChangedFilesOptions,\n): string[] {\n const tsOnly = opts?.tsOnly ?? true;\n const glob = tsOnly ? \" -- '*.ts' '*.tsx'\" : '';\n const keep = (f: string): boolean => f.length > 0 && (!tsOnly || !isTestFile(f));\n // eslint-disable-next-line @webpieces/no-unmanaged-exceptions\n try {\n const diffTarget = head ? `${base} ${head}` : base;\n const output = execSync(`git diff --name-only --diff-filter=d ${diffTarget}${glob}`, {\n cwd: workspaceRoot,\n encoding: 'utf-8',\n });\n const changedFiles = output.trim().split('\\n').filter(keep);\n\n // Working-tree comparison (no head): also include untracked files, as nx affected does.\n if (!head) {\n // eslint-disable-next-line @webpieces/no-unmanaged-exceptions\n try {\n const untrackedOutput = execSync(`git ls-files --others --exclude-standard${glob}`, {\n cwd: workspaceRoot,\n encoding: 'utf-8',\n });\n const untrackedFiles = untrackedOutput.trim().split('\\n').filter(keep);\n return Array.from(new Set([...changedFiles, ...untrackedFiles]));\n } catch (err: unknown) {\n const error = toError(err);\n void error; // swallow — ls-files failure falls back to the tracked list\n return changedFiles;\n }\n }\n\n return changedFiles;\n } catch (err: unknown) {\n const error = toError(err);\n void error; // swallow — git diff failure returns an empty list\n return [];\n }\n}\n\n/**\n * Diff content for a single file. When the file is untracked (and no head is given) a synthetic\n * all-added diff is produced so new files count as fully-changed.\n */\nexport function getFileDiff(workspaceRoot: string, file: string, base: string, head?: string): string {\n // eslint-disable-next-line @webpieces/no-unmanaged-exceptions\n try {\n const diffTarget = head ? `${base} ${head}` : base;\n const diff = execSync(`git diff ${diffTarget} -- \"${file}\"`, {\n cwd: workspaceRoot,\n encoding: 'utf-8',\n });\n\n if (!diff && !head) {\n const fullPath = path.join(workspaceRoot, file);\n if (fs.existsSync(fullPath)) {\n const isUntracked = execSync(`git ls-files --others --exclude-standard \"${file}\"`, {\n cwd: workspaceRoot,\n encoding: 'utf-8',\n }).trim();\n\n if (isUntracked) {\n const content = fs.readFileSync(fullPath, 'utf-8');\n return content.split('\\n').map((l: string) => `+${l}`).join('\\n');\n }\n }\n }\n\n return diff;\n } catch (err: unknown) {\n const error = toError(err);\n void error; // swallow — git diff failure returns no diff\n return '';\n }\n}\n\n/**\n * Parse a unified diff and return the set of added/changed line numbers (the `+` lines per hunk).\n * This is the basis of NEW_AND_MODIFIED_CODE (line-level) scoping.\n */\nexport function getChangedLineNumbers(diffContent: string): Set<number> {\n const changedLines = new Set<number>();\n const lines = diffContent.split('\\n');\n let currentLine = 0;\n\n for (const line of lines) {\n const hunkMatch = line.match(/^@@ -\\d+(?:,\\d+)? \\+(\\d+)(?:,\\d+)? @@/);\n if (hunkMatch) {\n currentLine = parseInt(hunkMatch[1], 10);\n continue;\n }\n\n if (line.startsWith('+') && !line.startsWith('+++')) {\n changedLines.add(currentLine);\n currentLine++;\n } else if (line.startsWith('-') && !line.startsWith('---')) {\n // Deletions don't advance the new-file line counter.\n } else {\n currentLine++;\n }\n }\n\n return changedLines;\n}\n\n/**\n * Method names whose signature line is a `+` addition in the diff — the basis of \"NEW\" methods.\n */\nexport function findNewMethodSignaturesInDiff(diffContent: string): Set<string> {\n const newMethods = new Set<string>();\n const lines = diffContent.split('\\n');\n\n const patterns = [\n /^\\+\\s*(?:export\\s+)?(?:async\\s+)?function\\s+(\\w+)\\s*\\(/,\n /^\\+\\s*(?:export\\s+)?(?:const|let)\\s+(\\w+)\\s*=\\s*(?:async\\s*)?\\(/,\n /^\\+\\s*(?:export\\s+)?(?:const|let)\\s+(\\w+)\\s*=\\s*(?:async\\s+)?function/,\n /^\\+\\s*(?:(?:public|private|protected)\\s+)?(?:static\\s+)?(?:async\\s+)?(\\w+)\\s*\\(/,\n ];\n\n for (const line of lines) {\n if (line.startsWith('+') && !line.startsWith('+++')) {\n for (const pattern of patterns) {\n const match = line.match(pattern);\n if (match) {\n const methodName = match[1];\n if (methodName && !['if', 'for', 'while', 'switch', 'catch', 'constructor'].includes(methodName)) {\n newMethods.add(methodName);\n }\n break;\n }\n }\n }\n }\n\n return newMethods;\n}\n\n/**\n * True if any line in [startLine, endLine] is in the changedLines set.\n */\nexport function hasChangesInRange(startLine: number, endLine: number, changedLines: Set<number>): boolean {\n for (let line = startLine; line <= endLine; line++) {\n if (changedLines.has(line)) {\n return true;\n }\n }\n return false;\n}\n\n/**\n * True if a node (method/function) is newly added or has any changed line in its range.\n */\nexport function isNewOrModified(\n name: string,\n startLine: number,\n endLine: number,\n changedLines: Set<number>,\n newMethodNames: Set<string>,\n): boolean {\n if (newMethodNames.has(name)) return true;\n return hasChangesInRange(startLine, endLine, changedLines);\n}\n"]}
1
+ {"version":3,"file":"diff-scope.js","sourceRoot":"","sources":["../../../../../packages/tooling/rules-config/src/diff-scope.ts"],"names":[],"mappings":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EAAE,IAAa,EAAE,IAA0B;IAC1G,OAAO,YAAY,CAAC,eAAe,CAAC,aAAa,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;AACzE,CAAC;AAED,gIAAgI;AAChI,SAAgB,WAAW,CAAC,aAAqB,EAAE,IAAY,EAAE,IAAY,EAAE,IAAa;IACxF,OAAO,YAAY,CAAC,WAAW,CAAC,aAAa,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;AACrE,CAAC;AAED,gIAAgI;AAChI,SAAgB,qBAAqB,CAAC,WAAmB;IACrD,OAAO,YAAY,CAAC,qBAAqB,CAAC,WAAW,CAAC,CAAC;AAC3D,CAAC;AAED,gIAAgI;AAChI,SAAgB,6BAA6B,CAAC,WAAmB;IAC7D,OAAO,YAAY,CAAC,6BAA6B,CAAC,WAAW,CAAC,CAAC;AACnE,CAAC;AAED,gIAAgI;AAChI,SAAgB,iBAAiB,CAAC,SAAiB,EAAE,OAAe,EAAE,YAAyB;IAC3F,OAAO,YAAY,CAAC,iBAAiB,CAAC,SAAS,EAAE,OAAO,EAAE,YAAY,CAAC,CAAC;AAC5E,CAAC;AAED,gIAAgI;AAChI,SAAgB,eAAe,CAC3B,IAAY,EACZ,SAAiB,EACjB,OAAe,EACf,YAAyB,EACzB,cAA2B;IAE3B,OAAO,YAAY,CAAC,eAAe,CAAC,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,YAAY,EAAE,cAAc,CAAC,CAAC;AAChG,CAAC","sourcesContent":["/**\n * Shared git-diff + diff-scoping service for ALL rule validators (code-rules) and nx executors\n * (nx-webpieces-rules). Centralized here in rules-config because it is the one package both depend on.\n *\n * `@provideSingleton` so it can be injected and appear in the rules-config DI design. Free-function\n * delegators are kept temporarily so the many existing consumers stay green; they migrate to injecting\n * {@link DiffScope} over follow-up PRs, then the delegators are removed.\n */\n\nimport { execSync } from 'child_process';\nimport * as fs from 'fs';\nimport * as path from 'path';\nimport { provideSingleton } from '@webpieces/core-context';\nimport { injectable } from 'inversify';\n\nimport { toError } from './to-error';\n\n/** A git diff range: the base ref to compare against and an optional head (else the working tree). */\nexport class DiffRange {\n base?: string;\n head?: string;\n}\n\n/** Options for getChangedFiles. `tsOnly` (default true) restricts to *.ts/*.tsx and drops test files. */\nexport class ChangedFilesOptions {\n tsOnly?: boolean;\n}\n\n@provideSingleton()\n@injectable()\nexport class DiffScope {\n /** Auto-detect the diff base: merge-base of HEAD with origin/main, falling back to local main. */\n detectBase(workspaceRoot: string): string | null {\n for (const ref of ['origin/main', 'main']) {\n // eslint-disable-next-line @webpieces/no-unmanaged-exceptions\n try {\n const merged = execSync(`git merge-base HEAD ${ref}`, {\n cwd: workspaceRoot, encoding: 'utf-8', stdio: ['pipe', 'pipe', 'pipe'],\n }).trim();\n if (merged) return merged;\n } catch (err: unknown) {\n const error = toError(err);\n void error; // swallow — try the next ref\n }\n }\n return null;\n }\n\n /** Resolve the diff range a rule should compare against (honors nx's NX_BASE / NX_HEAD). */\n resolveBase(workspaceRoot: string): DiffRange {\n const range = new DiffRange();\n range.base = process.env['NX_BASE'];\n range.head = process.env['NX_HEAD'];\n if (!range.base) {\n range.base = this.detectBase(workspaceRoot) ?? undefined;\n }\n return range;\n }\n\n /**\n * Changed files between base and head (or base→working-tree when head is omitted). Untracked files\n * are unioned in for the working-tree case. `tsOnly` (default true) restricts to *.ts/*.tsx and\n * drops test files. Deletions are excluded (`--diff-filter=d`).\n */\n // webpieces-disable max-lines-new-methods -- git command handling with untracked files needs several code paths\n getChangedFiles(workspaceRoot: string, base: string, head?: string, opts?: ChangedFilesOptions): string[] {\n const tsOnly = opts?.tsOnly ?? true;\n const glob = tsOnly ? \" -- '*.ts' '*.tsx'\" : '';\n const keep = (f: string): boolean => f.length > 0 && (!tsOnly || !this.isTestFile(f));\n // eslint-disable-next-line @webpieces/no-unmanaged-exceptions\n try {\n const diffTarget = head ? `${base} ${head}` : base;\n const output = execSync(`git diff --name-only --diff-filter=d ${diffTarget}${glob}`, {\n cwd: workspaceRoot,\n encoding: 'utf-8',\n });\n const changedFiles = output.trim().split('\\n').filter(keep);\n\n // Working-tree comparison (no head): also include untracked files, as nx affected does.\n if (!head) {\n // eslint-disable-next-line @webpieces/no-unmanaged-exceptions\n try {\n const untrackedOutput = execSync(`git ls-files --others --exclude-standard${glob}`, {\n cwd: workspaceRoot,\n encoding: 'utf-8',\n });\n const untrackedFiles = untrackedOutput.trim().split('\\n').filter(keep);\n return Array.from(new Set([...changedFiles, ...untrackedFiles]));\n } catch (err: unknown) {\n const error = toError(err);\n void error; // swallow — ls-files failure falls back to the tracked list\n return changedFiles;\n }\n }\n\n return changedFiles;\n } catch (err: unknown) {\n const error = toError(err);\n void error; // swallow — git diff failure returns an empty list\n return [];\n }\n }\n\n /** Diff content for a single file (synthetic all-added diff for an untracked file with no head). */\n getFileDiff(workspaceRoot: string, file: string, base: string, head?: string): string {\n // eslint-disable-next-line @webpieces/no-unmanaged-exceptions\n try {\n const diffTarget = head ? `${base} ${head}` : base;\n const diff = execSync(`git diff ${diffTarget} -- \"${file}\"`, {\n cwd: workspaceRoot,\n encoding: 'utf-8',\n });\n\n if (!diff && !head) {\n const fullPath = path.join(workspaceRoot, file);\n if (fs.existsSync(fullPath)) {\n const isUntracked = execSync(`git ls-files --others --exclude-standard \"${file}\"`, {\n cwd: workspaceRoot,\n encoding: 'utf-8',\n }).trim();\n\n if (isUntracked) {\n const content = fs.readFileSync(fullPath, 'utf-8');\n return content.split('\\n').map((l: string) => `+${l}`).join('\\n');\n }\n }\n }\n\n return diff;\n } catch (err: unknown) {\n const error = toError(err);\n void error; // swallow — git diff failure returns no diff\n return '';\n }\n }\n\n /** Added/changed line numbers (the `+` lines per hunk) — basis of NEW_AND_MODIFIED_CODE scoping. */\n getChangedLineNumbers(diffContent: string): Set<number> {\n const changedLines = new Set<number>();\n const lines = diffContent.split('\\n');\n let currentLine = 0;\n\n for (const line of lines) {\n const hunkMatch = line.match(/^@@ -\\d+(?:,\\d+)? \\+(\\d+)(?:,\\d+)? @@/);\n if (hunkMatch) {\n currentLine = parseInt(hunkMatch[1], 10);\n continue;\n }\n\n if (line.startsWith('+') && !line.startsWith('+++')) {\n changedLines.add(currentLine);\n currentLine++;\n } else if (line.startsWith('-') && !line.startsWith('---')) {\n // Deletions don't advance the new-file line counter.\n } else {\n currentLine++;\n }\n }\n\n return changedLines;\n }\n\n /** Method names whose signature line is a `+` addition in the diff — the basis of \"NEW\" methods. */\n findNewMethodSignaturesInDiff(diffContent: string): Set<string> {\n const newMethods = new Set<string>();\n const lines = diffContent.split('\\n');\n\n const patterns = [\n /^\\+\\s*(?:export\\s+)?(?:async\\s+)?function\\s+(\\w+)\\s*\\(/,\n /^\\+\\s*(?:export\\s+)?(?:const|let)\\s+(\\w+)\\s*=\\s*(?:async\\s*)?\\(/,\n /^\\+\\s*(?:export\\s+)?(?:const|let)\\s+(\\w+)\\s*=\\s*(?:async\\s+)?function/,\n /^\\+\\s*(?:(?:public|private|protected)\\s+)?(?:static\\s+)?(?:async\\s+)?(\\w+)\\s*\\(/,\n ];\n\n for (const line of lines) {\n if (line.startsWith('+') && !line.startsWith('+++')) {\n for (const pattern of patterns) {\n const match = line.match(pattern);\n if (match) {\n const methodName = match[1];\n if (methodName && !['if', 'for', 'while', 'switch', 'catch', 'constructor'].includes(methodName)) {\n newMethods.add(methodName);\n }\n break;\n }\n }\n }\n }\n\n return newMethods;\n }\n\n /** True if any line in [startLine, endLine] is in the changedLines set. */\n hasChangesInRange(startLine: number, endLine: number, changedLines: Set<number>): boolean {\n for (let line = startLine; line <= endLine; line++) {\n if (changedLines.has(line)) {\n return true;\n }\n }\n return false;\n }\n\n /** True if a node (method/function) is newly added or has any changed line in its range. */\n isNewOrModified(\n name: string,\n startLine: number,\n endLine: number,\n changedLines: Set<number>,\n newMethodNames: Set<string>,\n ): boolean {\n if (newMethodNames.has(name)) return true;\n return this.hasChangesInRange(startLine, endLine, changedLines);\n }\n\n // A file is \"a test file\" (excluded from diff-scoped rules) when it is a .spec/.test file or lives\n // under a __tests__/ directory.\n private isTestFile(file: string): boolean {\n return file.includes('.spec.ts') || file.includes('.test.ts') || file.includes('__tests__/');\n }\n}\n\n// Temporary migration delegators to DiffScope — removed once consumers inject it.\nconst diffScopeSvc = new DiffScope();\n\n// webpieces-disable no-function-outside-class -- temporary back-compat delegator to DiffScope; removed once consumers inject it\nexport function detectBase(workspaceRoot: string): string | null {\n return diffScopeSvc.detectBase(workspaceRoot);\n}\n\n// webpieces-disable no-function-outside-class -- temporary back-compat delegator to DiffScope; removed once consumers inject it\nexport function resolveBase(workspaceRoot: string): DiffRange {\n return diffScopeSvc.resolveBase(workspaceRoot);\n}\n\n// webpieces-disable no-function-outside-class -- temporary back-compat delegator to DiffScope; removed once consumers inject it\nexport function getChangedFiles(workspaceRoot: string, base: string, head?: string, opts?: ChangedFilesOptions): string[] {\n return diffScopeSvc.getChangedFiles(workspaceRoot, base, head, opts);\n}\n\n// webpieces-disable no-function-outside-class -- temporary back-compat delegator to DiffScope; removed once consumers inject it\nexport function getFileDiff(workspaceRoot: string, file: string, base: string, head?: string): string {\n return diffScopeSvc.getFileDiff(workspaceRoot, file, base, head);\n}\n\n// webpieces-disable no-function-outside-class -- temporary back-compat delegator to DiffScope; removed once consumers inject it\nexport function getChangedLineNumbers(diffContent: string): Set<number> {\n return diffScopeSvc.getChangedLineNumbers(diffContent);\n}\n\n// webpieces-disable no-function-outside-class -- temporary back-compat delegator to DiffScope; removed once consumers inject it\nexport function findNewMethodSignaturesInDiff(diffContent: string): Set<string> {\n return diffScopeSvc.findNewMethodSignaturesInDiff(diffContent);\n}\n\n// webpieces-disable no-function-outside-class -- temporary back-compat delegator to DiffScope; removed once consumers inject it\nexport function hasChangesInRange(startLine: number, endLine: number, changedLines: Set<number>): boolean {\n return diffScopeSvc.hasChangesInRange(startLine, endLine, changedLines);\n}\n\n// webpieces-disable no-function-outside-class -- temporary back-compat delegator to DiffScope; removed once consumers inject it\nexport function isNewOrModified(\n name: string,\n startLine: number,\n endLine: number,\n changedLines: Set<number>,\n newMethodNames: Set<string>,\n): boolean {\n return diffScopeSvc.isNewOrModified(name, startLine, endLine, changedLines, newMethodNames);\n}\n"]}
package/src/index.d.ts CHANGED
@@ -20,7 +20,7 @@ export { FieldDef } from './field-def';
20
20
  export type { SchemaShape } from './field-def';
21
21
  export { shouldSkipRule, getCurrentBranch } from './skip-rule';
22
22
  export type { SkipRuleResult } from './skip-rule';
23
- export { detectBase, resolveBase, getChangedFiles, getFileDiff, getChangedLineNumbers, findNewMethodSignaturesInDiff, hasChangesInRange, isNewOrModified, } from './diff-scope';
23
+ export { detectBase, resolveBase, getChangedFiles, getFileDiff, getChangedLineNumbers, findNewMethodSignaturesInDiff, hasChangesInRange, isNewOrModified, DiffScope, DiffRange, ChangedFilesOptions, } from './diff-scope';
24
24
  export { AbstractRule } from './abstract-rule';
25
25
  export { WEBPIECES_DISABLE, RULE_NAMES, hasDisable, WEBPIECES_TMP_DIR, MERGE_INFO_DIR, PR_REVIEW_DIR, MERGE_IN_PROGRESS_FILE, MERGE_EXPLANATION_FILE, } from './constants';
26
26
  export { WebpiecesRulesConfig } from './WebpiecesRulesConfig';
package/src/index.js CHANGED
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.findNewMethodSignaturesInDiff = exports.getChangedLineNumbers = exports.getFileDiff = exports.getChangedFiles = exports.resolveBase = exports.detectBase = exports.getCurrentBranch = exports.shouldSkipRule = exports.FieldDef = exports.sectionForRule = exports.isHookGuard = exports.HOOK_GUARD_NAMES = exports.DEFAULT_MATCH_RULES = exports.renderMatchRuleMessage = exports.compileMatchRulePatterns = exports.isMatchRuleAllowedPath = exports.findMatchRuleViolations = exports.MatchRuleViolation = exports.MatchRuleConfig = exports.allRuleNames = exports.validateMatchRulesSection = exports.validateExcludePaths = exports.validateCommandsSection = exports.validateSectionPlacement = exports.validatePrGateSection = exports.validateWebpiecesConfig = exports.TemplateWriter = exports.writeTemplate = exports.writeTemplateIfMissing = exports.loadTemplate = exports.defaultRulesDir = exports.defaultRules = exports.isPathExcluded = exports.ExcludePaths = exports.RulesConfigDesign = exports.INSTRUCT_AI_DIR = exports.RepoRootFinder = exports.ConfigFile = exports.CONFIG_FILENAME = exports.findConfigFile = exports.ConfigLoader = exports.LoadedConfig = exports.loadAndValidate = exports.toError = exports.runMain = exports.CliExitError = exports.RuleFailError = exports.InformAiError = exports.ResolvedRuleConfig = exports.ResolvedConfig = void 0;
4
- exports.PROJECT_MODES = exports.MODIFIED_CODE_MODES = exports.INLINE_TYPE_MODES = exports.RETURN_TYPE_MODES = exports.FILE_LIMIT_MODES = exports.METHOD_LIMIT_MODES = exports.BaseRuleConfig = exports.ValidateTsInSrcConfig = exports.NoJsFilesConfig = exports.DiGraphConfig = exports.NxWiringConfig = exports.RuntimeArchitectureConfig = exports.NoFileImportCyclesConfig = exports.FeatureBranchGuardConfig = exports.RedirectHowToMergeMainConfig = exports.PrMergeGuardConfig = exports.MergeInProgressGuardConfig = exports.PrCreationOrPushGuardConfig = exports.BranchCreationGuardConfig = exports.RoleTagConfig = exports.FrameworkTagConfig = exports.InjectAnnotationNotNeededForConcreteClassConfig = exports.NoFunctionOutsideClassConfig = exports.NoProcessExitOutsideMainConfig = exports.NoSymbolDiTokensConfig = exports.AngularNoDirectApiInResolverConfig = exports.ThrowCauseRequiredConfig = exports.CatchErrorPatternConfig = exports.NoUnmanagedExceptionsConfig = exports.NoDestructureConfig = exports.PrismaConverterConfig = exports.PrismaValidateDtosConfig = exports.NoImplicitAnyConfig = exports.NoAnyUnknownConfig = exports.NoInlineTypeLiteralsConfig = exports.RequireReturnTypeConfig = exports.MaxFileLinesConfig = exports.MaxMethodLinesConfig = exports.WebpiecesRulesConfig = exports.MERGE_EXPLANATION_FILE = exports.MERGE_IN_PROGRESS_FILE = exports.PR_REVIEW_DIR = exports.MERGE_INFO_DIR = exports.WEBPIECES_TMP_DIR = exports.hasDisable = exports.RULE_NAMES = exports.WEBPIECES_DISABLE = exports.AbstractRule = exports.isNewOrModified = exports.hasChangesInRange = void 0;
5
- exports.DEFAULT_MERGE_COMPLETE_COMMAND = exports.DEFAULT_UPSERT_PR_COMMAND = exports.buildCommandsConfig = exports.CommandsConfig = exports.logBranchMutation = exports.branchMutationLogPath = exports.BranchMutationEvent = exports.squashRecoverySteps = exports.stampCleanMainSyncStatus = exports.computeMainSyncStatus = exports.finishedLock = exports.inProcessLock = exports.isRefreshInProgress = exports.isLockStale = exports.writeMainSyncLock = exports.readMainSyncLock = exports.writeMainSyncStatus = exports.readMainSyncStatus = exports.mainSyncLockPath = exports.mainSyncStatusPath = exports.DEFAULT_HANG_TIMEOUT_MINUTES = exports.MainSyncLock = exports.MainSyncStatus = exports.reviewJsonSchemaHint = exports.reviewJsonPath = exports.prDirFor = exports.loadReviewJson = exports.ReviewJson = exports.buildPrGateConfig = exports.defaultPrGateConfig = exports.defaultGates = exports.PrGateConfig = exports.GateDefinition = exports.VALIDATE_TS_MODES = exports.STRUCTURAL_MODES = exports.ON_OFF_MODES = exports.THROW_CAUSE_MODES = exports.DIRECT_API_RESOLVER_MODES = exports.PRISMA_CONVERTER_MODES = exports.PRISMA_DTOS_MODES = void 0;
4
+ exports.RETURN_TYPE_MODES = exports.FILE_LIMIT_MODES = exports.METHOD_LIMIT_MODES = exports.BaseRuleConfig = exports.ValidateTsInSrcConfig = exports.NoJsFilesConfig = exports.DiGraphConfig = exports.NxWiringConfig = exports.RuntimeArchitectureConfig = exports.NoFileImportCyclesConfig = exports.FeatureBranchGuardConfig = exports.RedirectHowToMergeMainConfig = exports.PrMergeGuardConfig = exports.MergeInProgressGuardConfig = exports.PrCreationOrPushGuardConfig = exports.BranchCreationGuardConfig = exports.RoleTagConfig = exports.FrameworkTagConfig = exports.InjectAnnotationNotNeededForConcreteClassConfig = exports.NoFunctionOutsideClassConfig = exports.NoProcessExitOutsideMainConfig = exports.NoSymbolDiTokensConfig = exports.AngularNoDirectApiInResolverConfig = exports.ThrowCauseRequiredConfig = exports.CatchErrorPatternConfig = exports.NoUnmanagedExceptionsConfig = exports.NoDestructureConfig = exports.PrismaConverterConfig = exports.PrismaValidateDtosConfig = exports.NoImplicitAnyConfig = exports.NoAnyUnknownConfig = exports.NoInlineTypeLiteralsConfig = exports.RequireReturnTypeConfig = exports.MaxFileLinesConfig = exports.MaxMethodLinesConfig = exports.WebpiecesRulesConfig = exports.MERGE_EXPLANATION_FILE = exports.MERGE_IN_PROGRESS_FILE = exports.PR_REVIEW_DIR = exports.MERGE_INFO_DIR = exports.WEBPIECES_TMP_DIR = exports.hasDisable = exports.RULE_NAMES = exports.WEBPIECES_DISABLE = exports.AbstractRule = exports.ChangedFilesOptions = exports.DiffRange = exports.DiffScope = exports.isNewOrModified = exports.hasChangesInRange = void 0;
5
+ exports.DEFAULT_MERGE_COMPLETE_COMMAND = exports.DEFAULT_UPSERT_PR_COMMAND = exports.buildCommandsConfig = exports.CommandsConfig = exports.logBranchMutation = exports.branchMutationLogPath = exports.BranchMutationEvent = exports.squashRecoverySteps = exports.stampCleanMainSyncStatus = exports.computeMainSyncStatus = exports.finishedLock = exports.inProcessLock = exports.isRefreshInProgress = exports.isLockStale = exports.writeMainSyncLock = exports.readMainSyncLock = exports.writeMainSyncStatus = exports.readMainSyncStatus = exports.mainSyncLockPath = exports.mainSyncStatusPath = exports.DEFAULT_HANG_TIMEOUT_MINUTES = exports.MainSyncLock = exports.MainSyncStatus = exports.reviewJsonSchemaHint = exports.reviewJsonPath = exports.prDirFor = exports.loadReviewJson = exports.ReviewJson = exports.buildPrGateConfig = exports.defaultPrGateConfig = exports.defaultGates = exports.PrGateConfig = exports.GateDefinition = exports.VALIDATE_TS_MODES = exports.STRUCTURAL_MODES = exports.ON_OFF_MODES = exports.THROW_CAUSE_MODES = exports.DIRECT_API_RESOLVER_MODES = exports.PRISMA_CONVERTER_MODES = exports.PRISMA_DTOS_MODES = exports.PROJECT_MODES = exports.MODIFIED_CODE_MODES = exports.INLINE_TYPE_MODES = void 0;
6
6
  var types_1 = require("./types");
7
7
  Object.defineProperty(exports, "ResolvedConfig", { enumerable: true, get: function () { return types_1.ResolvedConfig; } });
8
8
  Object.defineProperty(exports, "ResolvedRuleConfig", { enumerable: true, get: function () { return types_1.ResolvedRuleConfig; } });
@@ -75,6 +75,9 @@ Object.defineProperty(exports, "getChangedLineNumbers", { enumerable: true, get:
75
75
  Object.defineProperty(exports, "findNewMethodSignaturesInDiff", { enumerable: true, get: function () { return diff_scope_1.findNewMethodSignaturesInDiff; } });
76
76
  Object.defineProperty(exports, "hasChangesInRange", { enumerable: true, get: function () { return diff_scope_1.hasChangesInRange; } });
77
77
  Object.defineProperty(exports, "isNewOrModified", { enumerable: true, get: function () { return diff_scope_1.isNewOrModified; } });
78
+ Object.defineProperty(exports, "DiffScope", { enumerable: true, get: function () { return diff_scope_1.DiffScope; } });
79
+ Object.defineProperty(exports, "DiffRange", { enumerable: true, get: function () { return diff_scope_1.DiffRange; } });
80
+ Object.defineProperty(exports, "ChangedFilesOptions", { enumerable: true, get: function () { return diff_scope_1.ChangedFilesOptions; } });
78
81
  var abstract_rule_1 = require("./abstract-rule");
79
82
  Object.defineProperty(exports, "AbstractRule", { enumerable: true, get: function () { return abstract_rule_1.AbstractRule; } });
80
83
  var constants_1 = require("./constants");
package/src/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../packages/tooling/rules-config/src/index.ts"],"names":[],"mappings":";;;;;AAAA,iCAA0E;AAAjE,uGAAA,cAAc,OAAA;AAAE,2GAAA,kBAAkB,OAAA;AAC3C,qDAAkD;AAAzC,gHAAA,aAAa,OAAA;AACtB,qDAAkD;AAAzC,gHAAA,aAAa,OAAA;AACtB,mDAAgD;AAAvC,8GAAA,YAAY,OAAA;AACrB,uCAAqC;AAA5B,mGAAA,OAAO,OAAA;AAChB,uCAAqC;AAA5B,mGAAA,OAAO,OAAA;AAChB,6CAA4E;AAAnE,8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A;AAGvB,6DAI+B;AAH3B,0HAAA,mBAAmB,OAAA;AACnB,4HAAA,qBAAqB,OAAA;AACrB,wHAAA,iBAAiB,OAAA;AAErB,qDAK2B;AAJvB,iHAAA,cAAc,OAAA;AACd,sHAAA,mBAAmB,OAAA;AACnB,4HAAA,yBAAyB,OAAA;AACzB,iIAAA,8BAA8B,OAAA","sourcesContent":["export { ResolvedConfig, ResolvedRuleConfig, RuleOptions } from './types';\nexport { InformAiError } from './inform-ai-error';\nexport { RuleFailError } from './rule-fail-error';\nexport { CliExitError } from './cli-exit-error';\nexport { runMain } from './run-main';\nexport { toError } from './to-error';\nexport { loadAndValidate, LoadedConfig, ConfigLoader } from './load-config';\nexport { findConfigFile, CONFIG_FILENAME, ConfigFile } from './config-file';\nexport { RepoRootFinder, INSTRUCT_AI_DIR } from './repo-root';\nexport { RulesConfigDesign } from './rules-config-design';\nexport { ExcludePaths } from './exclude-hook-paths';\nexport { isPathExcluded } from './exclude-paths';\nexport { defaultRules, defaultRulesDir } from './default-rules';\nexport { loadTemplate, writeTemplateIfMissing, writeTemplate, TemplateWriter } from './load-template';\nexport { validateWebpiecesConfig, validatePrGateSection, validateSectionPlacement, validateCommandsSection, validateExcludePaths, validateMatchRulesSection, allRuleNames } from './validate-config';\nexport {\n MatchRuleConfig,\n MatchRuleViolation,\n findMatchRuleViolations,\n isMatchRuleAllowedPath,\n compileMatchRulePatterns,\n renderMatchRuleMessage,\n DEFAULT_MATCH_RULES,\n} from './match-rules-config';\nexport type { ConfigSection } from './sections';\nexport { HOOK_GUARD_NAMES, isHookGuard, sectionForRule } from './sections';\nexport { FieldDef } from './field-def';\nexport type { SchemaShape } from './field-def';\nexport { shouldSkipRule, getCurrentBranch } from './skip-rule';\nexport type { SkipRuleResult } from './skip-rule';\nexport {\n detectBase,\n resolveBase,\n getChangedFiles,\n getFileDiff,\n getChangedLineNumbers,\n findNewMethodSignaturesInDiff,\n hasChangesInRange,\n isNewOrModified,\n} from './diff-scope';\nexport { AbstractRule } from './abstract-rule';\nexport {\n WEBPIECES_DISABLE,\n RULE_NAMES,\n hasDisable,\n WEBPIECES_TMP_DIR,\n MERGE_INFO_DIR,\n PR_REVIEW_DIR,\n MERGE_IN_PROGRESS_FILE,\n MERGE_EXPLANATION_FILE,\n} from './constants';\nexport { WebpiecesRulesConfig } from './WebpiecesRulesConfig';\nexport {\n MaxMethodLinesConfig,\n MaxFileLinesConfig,\n RequireReturnTypeConfig,\n NoInlineTypeLiteralsConfig,\n NoAnyUnknownConfig,\n NoImplicitAnyConfig,\n PrismaValidateDtosConfig,\n PrismaConverterConfig,\n NoDestructureConfig,\n NoUnmanagedExceptionsConfig,\n CatchErrorPatternConfig,\n ThrowCauseRequiredConfig,\n AngularNoDirectApiInResolverConfig,\n NoSymbolDiTokensConfig,\n NoProcessExitOutsideMainConfig,\n NoFunctionOutsideClassConfig,\n InjectAnnotationNotNeededForConcreteClassConfig,\n FrameworkTagConfig,\n RoleTagConfig,\n BranchCreationGuardConfig,\n PrCreationOrPushGuardConfig,\n MergeInProgressGuardConfig,\n PrMergeGuardConfig,\n RedirectHowToMergeMainConfig,\n FeatureBranchGuardConfig,\n NoFileImportCyclesConfig,\n RuntimeArchitectureConfig,\n NxWiringConfig,\n DiGraphConfig,\n NoJsFilesConfig,\n ValidateTsInSrcConfig,\n BaseRuleConfig,\n} from './rule-configs';\n// Mode unions + their value arrays — the single source of truth shared with code-rules.\nexport {\n METHOD_LIMIT_MODES,\n FILE_LIMIT_MODES,\n RETURN_TYPE_MODES,\n INLINE_TYPE_MODES,\n MODIFIED_CODE_MODES,\n PROJECT_MODES,\n PRISMA_DTOS_MODES,\n PRISMA_CONVERTER_MODES,\n DIRECT_API_RESOLVER_MODES,\n THROW_CAUSE_MODES,\n ON_OFF_MODES,\n STRUCTURAL_MODES,\n VALIDATE_TS_MODES,\n} from './rule-configs';\nexport type {\n MethodLimitMode,\n FileLimitMode,\n ReturnTypeMode,\n InlineTypeMode,\n ModifiedCodeMode,\n ProjectMode,\n PrismaValidateDtosMode,\n PrismaConverterMode,\n DirectApiResolverMode,\n ThrowCauseMode,\n OnOffMode,\n StructuralMode,\n ValidateTsMode,\n} from './rule-configs';\nexport {\n GateDefinition,\n PrGateConfig,\n defaultGates,\n defaultPrGateConfig,\n buildPrGateConfig,\n} from './pr-gate-config';\nexport {\n ReviewJson,\n loadReviewJson,\n prDirFor,\n reviewJsonPath,\n reviewJsonSchemaHint,\n} from './review-json';\nexport {\n MainSyncStatus,\n MainSyncLock,\n DEFAULT_HANG_TIMEOUT_MINUTES,\n mainSyncStatusPath,\n mainSyncLockPath,\n readMainSyncStatus,\n writeMainSyncStatus,\n readMainSyncLock,\n writeMainSyncLock,\n isLockStale,\n isRefreshInProgress,\n inProcessLock,\n finishedLock,\n computeMainSyncStatus,\n stampCleanMainSyncStatus,\n squashRecoverySteps,\n} from './main-sync-status';\nexport type { MutationVerb, MutationPhase } from './branch-mutation-log';\nexport {\n BranchMutationEvent,\n branchMutationLogPath,\n logBranchMutation,\n} from './branch-mutation-log';\nexport {\n CommandsConfig,\n buildCommandsConfig,\n DEFAULT_UPSERT_PR_COMMAND,\n DEFAULT_MERGE_COMPLETE_COMMAND,\n} from './commands-config';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../packages/tooling/rules-config/src/index.ts"],"names":[],"mappings":";;;;;AAAA,iCAA0E;AAAjE,uGAAA,cAAc,OAAA;AAAE,2GAAA,kBAAkB,OAAA;AAC3C,qDAAkD;AAAzC,gHAAA,aAAa,OAAA;AACtB,qDAAkD;AAAzC,gHAAA,aAAa,OAAA;AACtB,mDAAgD;AAAvC,8GAAA,YAAY,OAAA;AACrB,uCAAqC;AAA5B,mGAAA,OAAO,OAAA;AAChB,uCAAqC;AAA5B,mGAAA,OAAO,OAAA;AAChB,6CAA4E;AAAnE,8GAAA,eAAe,OAAA;AAAE,2GAAA,YAAY,OAAA;AAAE,2GAAA,YAAY,OAAA;AACpD,6CAA4E;AAAnE,6GAA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AAH3B,0HAAA,mBAAmB,OAAA;AACnB,4HAAA,qBAAqB,OAAA;AACrB,wHAAA,iBAAiB,OAAA;AAErB,qDAK2B;AAJvB,iHAAA,cAAc,OAAA;AACd,sHAAA,mBAAmB,OAAA;AACnB,4HAAA,yBAAyB,OAAA;AACzB,iIAAA,8BAA8B,OAAA","sourcesContent":["export { ResolvedConfig, ResolvedRuleConfig, RuleOptions } from './types';\nexport { InformAiError } from './inform-ai-error';\nexport { RuleFailError } from './rule-fail-error';\nexport { CliExitError } from './cli-exit-error';\nexport { runMain } from './run-main';\nexport { toError } from './to-error';\nexport { loadAndValidate, LoadedConfig, ConfigLoader } from './load-config';\nexport { findConfigFile, CONFIG_FILENAME, ConfigFile } from './config-file';\nexport { RepoRootFinder, INSTRUCT_AI_DIR } from './repo-root';\nexport { RulesConfigDesign } from './rules-config-design';\nexport { ExcludePaths } from './exclude-hook-paths';\nexport { isPathExcluded } from './exclude-paths';\nexport { defaultRules, defaultRulesDir } from './default-rules';\nexport { loadTemplate, writeTemplateIfMissing, writeTemplate, TemplateWriter } from './load-template';\nexport { validateWebpiecesConfig, validatePrGateSection, validateSectionPlacement, validateCommandsSection, validateExcludePaths, validateMatchRulesSection, allRuleNames } from './validate-config';\nexport {\n MatchRuleConfig,\n MatchRuleViolation,\n findMatchRuleViolations,\n isMatchRuleAllowedPath,\n compileMatchRulePatterns,\n renderMatchRuleMessage,\n DEFAULT_MATCH_RULES,\n} from './match-rules-config';\nexport type { ConfigSection } from './sections';\nexport { HOOK_GUARD_NAMES, isHookGuard, sectionForRule } from './sections';\nexport { FieldDef } from './field-def';\nexport type { SchemaShape } from './field-def';\nexport { shouldSkipRule, getCurrentBranch } from './skip-rule';\nexport type { SkipRuleResult } from './skip-rule';\nexport {\n detectBase,\n resolveBase,\n getChangedFiles,\n getFileDiff,\n getChangedLineNumbers,\n findNewMethodSignaturesInDiff,\n hasChangesInRange,\n isNewOrModified,\n DiffScope,\n DiffRange,\n ChangedFilesOptions,\n} from './diff-scope';\nexport { AbstractRule } from './abstract-rule';\nexport {\n WEBPIECES_DISABLE,\n RULE_NAMES,\n hasDisable,\n WEBPIECES_TMP_DIR,\n MERGE_INFO_DIR,\n PR_REVIEW_DIR,\n MERGE_IN_PROGRESS_FILE,\n MERGE_EXPLANATION_FILE,\n} from './constants';\nexport { WebpiecesRulesConfig } from './WebpiecesRulesConfig';\nexport {\n MaxMethodLinesConfig,\n MaxFileLinesConfig,\n RequireReturnTypeConfig,\n NoInlineTypeLiteralsConfig,\n NoAnyUnknownConfig,\n NoImplicitAnyConfig,\n PrismaValidateDtosConfig,\n PrismaConverterConfig,\n NoDestructureConfig,\n NoUnmanagedExceptionsConfig,\n CatchErrorPatternConfig,\n ThrowCauseRequiredConfig,\n AngularNoDirectApiInResolverConfig,\n NoSymbolDiTokensConfig,\n NoProcessExitOutsideMainConfig,\n NoFunctionOutsideClassConfig,\n InjectAnnotationNotNeededForConcreteClassConfig,\n FrameworkTagConfig,\n RoleTagConfig,\n BranchCreationGuardConfig,\n PrCreationOrPushGuardConfig,\n MergeInProgressGuardConfig,\n PrMergeGuardConfig,\n RedirectHowToMergeMainConfig,\n FeatureBranchGuardConfig,\n NoFileImportCyclesConfig,\n RuntimeArchitectureConfig,\n NxWiringConfig,\n DiGraphConfig,\n NoJsFilesConfig,\n ValidateTsInSrcConfig,\n BaseRuleConfig,\n} from './rule-configs';\n// Mode unions + their value arrays — the single source of truth shared with code-rules.\nexport {\n METHOD_LIMIT_MODES,\n FILE_LIMIT_MODES,\n RETURN_TYPE_MODES,\n INLINE_TYPE_MODES,\n MODIFIED_CODE_MODES,\n PROJECT_MODES,\n PRISMA_DTOS_MODES,\n PRISMA_CONVERTER_MODES,\n DIRECT_API_RESOLVER_MODES,\n THROW_CAUSE_MODES,\n ON_OFF_MODES,\n STRUCTURAL_MODES,\n VALIDATE_TS_MODES,\n} from './rule-configs';\nexport type {\n MethodLimitMode,\n FileLimitMode,\n ReturnTypeMode,\n InlineTypeMode,\n ModifiedCodeMode,\n ProjectMode,\n PrismaValidateDtosMode,\n PrismaConverterMode,\n DirectApiResolverMode,\n ThrowCauseMode,\n OnOffMode,\n StructuralMode,\n ValidateTsMode,\n} from './rule-configs';\nexport {\n GateDefinition,\n PrGateConfig,\n defaultGates,\n defaultPrGateConfig,\n buildPrGateConfig,\n} from './pr-gate-config';\nexport {\n ReviewJson,\n loadReviewJson,\n prDirFor,\n reviewJsonPath,\n reviewJsonSchemaHint,\n} from './review-json';\nexport {\n MainSyncStatus,\n MainSyncLock,\n DEFAULT_HANG_TIMEOUT_MINUTES,\n mainSyncStatusPath,\n mainSyncLockPath,\n readMainSyncStatus,\n writeMainSyncStatus,\n readMainSyncLock,\n writeMainSyncLock,\n isLockStale,\n isRefreshInProgress,\n inProcessLock,\n finishedLock,\n computeMainSyncStatus,\n stampCleanMainSyncStatus,\n squashRecoverySteps,\n} from './main-sync-status';\nexport type { MutationVerb, MutationPhase } from './branch-mutation-log';\nexport {\n BranchMutationEvent,\n branchMutationLogPath,\n logBranchMutation,\n} from './branch-mutation-log';\nexport {\n CommandsConfig,\n buildCommandsConfig,\n DEFAULT_UPSERT_PR_COMMAND,\n DEFAULT_MERGE_COMPLETE_COMMAND,\n} from './commands-config';\n"]}
@@ -1,6 +1,7 @@
1
1
  import { RepoRootFinder } from './repo-root';
2
2
  import { ConfigLoader } from './load-config';
3
3
  import { TemplateWriter } from './load-template';
4
+ import { DiffScope } from './diff-scope';
4
5
  /**
5
6
  * DI-design root for @webpieces/rules-config (role:designed-lib).
6
7
  *
@@ -14,5 +15,6 @@ export declare class RulesConfigDesign {
14
15
  private readonly repoRootFinder;
15
16
  private readonly configLoader;
16
17
  private readonly templateWriter;
17
- constructor(repoRootFinder: RepoRootFinder, configLoader: ConfigLoader, templateWriter: TemplateWriter);
18
+ private readonly diffScope;
19
+ constructor(repoRootFinder: RepoRootFinder, configLoader: ConfigLoader, templateWriter: TemplateWriter, diffScope: DiffScope);
18
20
  }
@@ -8,6 +8,7 @@ const inversify_1 = require("inversify");
8
8
  const repo_root_1 = require("./repo-root");
9
9
  const load_config_1 = require("./load-config");
10
10
  const load_template_1 = require("./load-template");
11
+ const diff_scope_1 = require("./diff-scope");
11
12
  /**
12
13
  * DI-design root for @webpieces/rules-config (role:designed-lib).
13
14
  *
@@ -21,10 +22,12 @@ let RulesConfigDesign = class RulesConfigDesign {
21
22
  repoRootFinder;
22
23
  configLoader;
23
24
  templateWriter;
24
- constructor(repoRootFinder, configLoader, templateWriter) {
25
+ diffScope;
26
+ constructor(repoRootFinder, configLoader, templateWriter, diffScope) {
25
27
  this.repoRootFinder = repoRootFinder;
26
28
  this.configLoader = configLoader;
27
29
  this.templateWriter = templateWriter;
30
+ this.diffScope = diffScope;
28
31
  }
29
32
  };
30
33
  exports.RulesConfigDesign = RulesConfigDesign;
@@ -34,6 +37,7 @@ exports.RulesConfigDesign = RulesConfigDesign = tslib_1.__decorate([
34
37
  (0, inversify_1.injectable)(),
35
38
  tslib_1.__metadata("design:paramtypes", [repo_root_1.RepoRootFinder,
36
39
  load_config_1.ConfigLoader,
37
- load_template_1.TemplateWriter])
40
+ load_template_1.TemplateWriter,
41
+ diff_scope_1.DiffScope])
38
42
  ], RulesConfigDesign);
39
43
  //# sourceMappingURL=rules-config-design.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"rules-config-design.js","sourceRoot":"","sources":["../../../../../packages/tooling/rules-config/src/rules-config-design.ts"],"names":[],"mappings":";;;;AAAA,oDAAsD;AACtD,0DAA2D;AAC3D,yCAAuC;AAEvC,2CAA6C;AAC7C,+CAA6C;AAC7C,mDAAiD;AAEjD;;;;;;;;GAQG;AAII,IAAM,iBAAiB,GAAvB,MAAM,iBAAiB;IAEL;IACA;IACA;IAHrB,YACqB,cAA8B,EAC9B,YAA0B,EAC1B,cAA8B;QAF9B,mBAAc,GAAd,cAAc,CAAgB;QAC9B,iBAAY,GAAZ,YAAY,CAAc;QAC1B,mBAAc,GAAd,cAAc,CAAgB;IAChD,CAAC;CACP,CAAA;AANY,8CAAiB;4BAAjB,iBAAiB;IAH7B,IAAA,0BAAc,GAAE;IAChB,IAAA,+BAAgB,GAAE;IAClB,IAAA,sBAAU,GAAE;6CAG4B,0BAAc;QAChB,0BAAY;QACV,8BAAc;GAJ1C,iBAAiB,CAM7B","sourcesContent":["import { DocumentDesign } from '@webpieces/core-util';\nimport { provideSingleton } from '@webpieces/core-context';\nimport { injectable } from 'inversify';\n\nimport { RepoRootFinder } from './repo-root';\nimport { ConfigLoader } from './load-config';\nimport { TemplateWriter } from './load-template';\n\n/**\n * DI-design root for @webpieces/rules-config (role:designed-lib).\n *\n * `@DocumentDesign` marks the top of the DAG the DI-design analyzer roots on, so the library's design\n * (design.json / design.md / design.html) is generated. rules-config is the shared foundation whose\n * utilities are being migrated from free functions to injected `@provideSingleton` service classes; as\n * each service class lands (config loader, template writer, diff/git services, …) it is injected HERE\n * so it appears in the drawn design.\n */\n@DocumentDesign()\n@provideSingleton()\n@injectable()\nexport class RulesConfigDesign {\n constructor(\n private readonly repoRootFinder: RepoRootFinder,\n private readonly configLoader: ConfigLoader,\n private readonly templateWriter: TemplateWriter,\n ) {}\n}\n"]}
1
+ {"version":3,"file":"rules-config-design.js","sourceRoot":"","sources":["../../../../../packages/tooling/rules-config/src/rules-config-design.ts"],"names":[],"mappings":";;;;AAAA,oDAAsD;AACtD,0DAA2D;AAC3D,yCAAuC;AAEvC,2CAA6C;AAC7C,+CAA6C;AAC7C,mDAAiD;AACjD,6CAAyC;AAEzC;;;;;;;;GAQG;AAII,IAAM,iBAAiB,GAAvB,MAAM,iBAAiB;IAEL;IACA;IACA;IACA;IAJrB,YACqB,cAA8B,EAC9B,YAA0B,EAC1B,cAA8B,EAC9B,SAAoB;QAHpB,mBAAc,GAAd,cAAc,CAAgB;QAC9B,iBAAY,GAAZ,YAAY,CAAc;QAC1B,mBAAc,GAAd,cAAc,CAAgB;QAC9B,cAAS,GAAT,SAAS,CAAW;IACtC,CAAC;CACP,CAAA;AAPY,8CAAiB;4BAAjB,iBAAiB;IAH7B,IAAA,0BAAc,GAAE;IAChB,IAAA,+BAAgB,GAAE;IAClB,IAAA,sBAAU,GAAE;6CAG4B,0BAAc;QAChB,0BAAY;QACV,8BAAc;QACnB,sBAAS;GALhC,iBAAiB,CAO7B","sourcesContent":["import { DocumentDesign } from '@webpieces/core-util';\nimport { provideSingleton } from '@webpieces/core-context';\nimport { injectable } from 'inversify';\n\nimport { RepoRootFinder } from './repo-root';\nimport { ConfigLoader } from './load-config';\nimport { TemplateWriter } from './load-template';\nimport { DiffScope } from './diff-scope';\n\n/**\n * DI-design root for @webpieces/rules-config (role:designed-lib).\n *\n * `@DocumentDesign` marks the top of the DAG the DI-design analyzer roots on, so the library's design\n * (design.json / design.md / design.html) is generated. rules-config is the shared foundation whose\n * utilities are being migrated from free functions to injected `@provideSingleton` service classes; as\n * each service class lands (config loader, template writer, diff/git services, …) it is injected HERE\n * so it appears in the drawn design.\n */\n@DocumentDesign()\n@provideSingleton()\n@injectable()\nexport class RulesConfigDesign {\n constructor(\n private readonly repoRootFinder: RepoRootFinder,\n private readonly configLoader: ConfigLoader,\n private readonly templateWriter: TemplateWriter,\n private readonly diffScope: DiffScope,\n ) {}\n}\n"]}