nestjs-doctor 0.4.11 → 0.4.13

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/README.md CHANGED
@@ -1,3 +1,7 @@
1
+ <p align="center">
2
+ <img src="https://nestjs.doctor/logo.png" width="120" alt="nestjs-doctor logo" />
3
+ </p>
4
+
1
5
  <p align="center">
2
6
  <h1 align="center">nestjs-doctor</h1>
3
7
  </p>
@@ -114,6 +114,55 @@ function extractArrayPropertyNames(obj, propertyName) {
114
114
  return text;
115
115
  });
116
116
  }
117
+ function updateModuleGraphForFile(graph, project, filePath) {
118
+ for (const [name, node] of graph.modules) if (node.filePath === filePath) {
119
+ graph.modules.delete(name);
120
+ graph.edges.delete(name);
121
+ for (const provider of node.providers) if (graph.providerToModule.get(provider) === node) graph.providerToModule.delete(provider);
122
+ for (const edgeSet of graph.edges.values()) edgeSet.delete(name);
123
+ }
124
+ const sourceFile = project.getSourceFile(filePath);
125
+ if (!sourceFile) return;
126
+ const newModules = [];
127
+ for (const cls of sourceFile.getClasses()) {
128
+ const moduleDecorator = cls.getDecorator("Module");
129
+ if (!moduleDecorator) continue;
130
+ const name = cls.getName() ?? "AnonymousModule";
131
+ const args = moduleDecorator.getArguments()[0];
132
+ const node = {
133
+ name,
134
+ filePath,
135
+ classDeclaration: cls,
136
+ imports: [],
137
+ exports: [],
138
+ providers: [],
139
+ controllers: []
140
+ };
141
+ if (args && args.getKind() === ts_morph.SyntaxKind.ObjectLiteralExpression) {
142
+ const obj = args.asKind(ts_morph.SyntaxKind.ObjectLiteralExpression);
143
+ if (obj) {
144
+ node.imports = extractArrayPropertyNames(obj, "imports");
145
+ node.exports = extractArrayPropertyNames(obj, "exports");
146
+ node.providers = extractArrayPropertyNames(obj, "providers");
147
+ node.controllers = extractArrayPropertyNames(obj, "controllers");
148
+ }
149
+ }
150
+ graph.modules.set(name, node);
151
+ newModules.push(node);
152
+ }
153
+ for (const node of newModules) {
154
+ const importSet = /* @__PURE__ */ new Set();
155
+ for (const imp of node.imports) if (graph.modules.has(imp)) importSet.add(imp);
156
+ graph.edges.set(node.name, importSet);
157
+ for (const provider of node.providers) graph.providerToModule.set(provider, node);
158
+ }
159
+ for (const [name, node] of graph.modules) {
160
+ if (node.filePath === filePath) continue;
161
+ const importSet = /* @__PURE__ */ new Set();
162
+ for (const imp of node.imports) if (graph.modules.has(imp)) importSet.add(imp);
163
+ graph.edges.set(name, importSet);
164
+ }
165
+ }
117
166
  function findCircularDeps(graph) {
118
167
  const cycles = [];
119
168
  const visited = /* @__PURE__ */ new Set();
@@ -176,50 +225,78 @@ function isProjectRule(rule) {
176
225
 
177
226
  //#endregion
178
227
  //#region src/engine/rule-runner.ts
179
- function runRules(project, files, rules, options) {
180
- const diagnostics = [];
181
- const errors = [];
228
+ function separateRules(rules) {
182
229
  const fileRules = [];
183
230
  const projectRules = [];
184
231
  for (const rule of rules) if (isProjectRule(rule)) projectRules.push(rule);
185
232
  else fileRules.push(rule);
186
- for (const filePath of files) {
187
- const sourceFile = project.getSourceFile(filePath);
188
- if (!sourceFile) continue;
189
- const allLines = sourceFile.getFullText().split("\n");
190
- for (const rule of fileRules) {
191
- const context = {
192
- sourceFile,
193
- filePath,
194
- report(partial) {
195
- const sourceLines = [];
196
- const start = Math.max(0, partial.line - 6);
197
- const end = Math.min(allLines.length, partial.line + 5);
198
- for (let i = start; i < end; i++) sourceLines.push({
199
- line: i + 1,
200
- text: allLines[i]
201
- });
202
- diagnostics.push({
203
- ...partial,
204
- rule: rule.meta.id,
205
- category: rule.meta.category,
206
- scope: "file",
207
- severity: rule.meta.severity,
208
- sourceLines
209
- });
210
- }
211
- };
212
- try {
213
- rule.check(context);
214
- } catch (error) {
215
- errors.push({
216
- ruleId: rule.meta.id,
217
- error
233
+ return {
234
+ fileRules,
235
+ projectRules
236
+ };
237
+ }
238
+ function runFileRulesOnFile(project, filePath, rules) {
239
+ const diagnostics = [];
240
+ const errors = [];
241
+ const sourceFile = project.getSourceFile(filePath);
242
+ if (!sourceFile) return {
243
+ diagnostics,
244
+ errors
245
+ };
246
+ const allLines = sourceFile.getFullText().split("\n");
247
+ for (const rule of rules) {
248
+ const context = {
249
+ sourceFile,
250
+ filePath,
251
+ report(partial) {
252
+ const sourceLines = [];
253
+ const start = Math.max(0, partial.line - 6);
254
+ const end = Math.min(allLines.length, partial.line + 5);
255
+ for (let i = start; i < end; i++) sourceLines.push({
256
+ line: i + 1,
257
+ text: allLines[i]
258
+ });
259
+ diagnostics.push({
260
+ ...partial,
261
+ rule: rule.meta.id,
262
+ category: rule.meta.category,
263
+ scope: "file",
264
+ severity: rule.meta.severity,
265
+ sourceLines
218
266
  });
219
267
  }
268
+ };
269
+ try {
270
+ rule.check(context);
271
+ } catch (error) {
272
+ errors.push({
273
+ ruleId: rule.meta.id,
274
+ error
275
+ });
220
276
  }
221
277
  }
222
- for (const rule of projectRules) {
278
+ return {
279
+ diagnostics,
280
+ errors
281
+ };
282
+ }
283
+ function runFileRules(project, files, rules) {
284
+ const diagnostics = [];
285
+ const errors = [];
286
+ for (const filePath of files) {
287
+ const result = runFileRulesOnFile(project, filePath, rules);
288
+ diagnostics.push(...result.diagnostics);
289
+ errors.push(...result.errors);
290
+ }
291
+ return {
292
+ diagnostics,
293
+ errors
294
+ };
295
+ }
296
+ function runProjectRules(project, files, rules, options) {
297
+ const diagnostics = [];
298
+ const errors = [];
299
+ for (const rule of rules) {
223
300
  const context = {
224
301
  project,
225
302
  files,
@@ -250,6 +327,15 @@ function runRules(project, files, rules, options) {
250
327
  errors
251
328
  };
252
329
  }
330
+ function runRules(project, files, rules, options) {
331
+ const { fileRules, projectRules } = separateRules(rules);
332
+ const fileResult = runFileRules(project, files, fileRules);
333
+ const projectResult = runProjectRules(project, files, projectRules, options);
334
+ return {
335
+ diagnostics: [...fileResult.diagnostics, ...projectResult.diagnostics],
336
+ errors: [...fileResult.errors, ...projectResult.errors]
337
+ };
338
+ }
253
339
 
254
340
  //#endregion
255
341
  //#region src/engine/type-resolver.ts
@@ -284,6 +370,32 @@ function resolveProviders(project, files) {
284
370
  }
285
371
  return providers;
286
372
  }
373
+ function updateProvidersForFile(providers, project, filePath) {
374
+ for (const [name, info] of providers) if (info.filePath === filePath) providers.delete(name);
375
+ const sourceFile = project.getSourceFile(filePath);
376
+ if (!sourceFile) return;
377
+ for (const cls of sourceFile.getClasses()) {
378
+ if (!cls.getDecorator("Injectable")) continue;
379
+ const name = cls.getName();
380
+ if (!name) continue;
381
+ const ctor = cls.getConstructors()[0];
382
+ const dependencies = ctor ? ctor.getParameters().map((p) => {
383
+ const typeNode = p.getTypeNode();
384
+ return extractSimpleTypeName(typeNode ? typeNode.getText() : p.getType().getText());
385
+ }) : [];
386
+ const publicMethodCount = cls.getMethods().filter((m) => {
387
+ const scope = m.getScope();
388
+ return !scope || scope === "public";
389
+ }).length;
390
+ providers.set(name, {
391
+ name,
392
+ filePath,
393
+ classDeclaration: cls,
394
+ dependencies,
395
+ publicMethodCount
396
+ });
397
+ }
398
+ }
287
399
  function extractSimpleTypeName(typeText) {
288
400
  const importMatch = typeText.match(IMPORT_TYPE_REGEX);
289
401
  if (importMatch) return importMatch[1];
@@ -2228,11 +2340,11 @@ async function collectFiles(targetPath, config = {}) {
2228
2340
  })).sort();
2229
2341
  }
2230
2342
  async function collectMonorepoFiles(targetPath, monorepo, config = {}) {
2343
+ const entries = await Promise.all([...monorepo.projects.entries()].map(async ([name, root]) => {
2344
+ return [name, await collectFiles((0, node_path.join)(targetPath, root), config)];
2345
+ }));
2231
2346
  const result = /* @__PURE__ */ new Map();
2232
- for (const [name, root] of monorepo.projects) {
2233
- const files = await collectFiles((0, node_path.join)(targetPath, root), config);
2234
- result.set(name, files);
2235
- }
2347
+ for (const [name, files] of entries) result.set(name, files);
2236
2348
  return result;
2237
2349
  }
2238
2350
 
@@ -2451,28 +2563,82 @@ function formatRuleError(error) {
2451
2563
  if (error instanceof Error) return error.message;
2452
2564
  return String(error);
2453
2565
  }
2454
- async function scan(targetPath, options = {}) {
2455
- const startTime = node_perf_hooks.performance.now();
2566
+ async function prepareScan(targetPath, options = {}) {
2456
2567
  const config = await loadConfig(targetPath, options.config);
2457
- const { rules: customRules, warnings: customRuleWarnings } = await resolveCustomRules(config, targetPath);
2568
+ const [{ rules: customRules, warnings: customRuleWarnings }, files] = await Promise.all([resolveCustomRules(config, targetPath), collectFiles(targetPath, config)]);
2458
2569
  const combinedRules = mergeRules(allRules, customRules, customRuleWarnings);
2459
- const project = await detectProject(targetPath);
2460
- const files = await collectFiles(targetPath, config);
2461
2570
  const astProject = createAstParser(files);
2462
2571
  const moduleGraph = buildModuleGraph(astProject, files);
2463
2572
  const providers = resolveProviders(astProject, files);
2464
- const { diagnostics: rawDiagnostics, errors } = runRules(astProject, files, filterRules(config, combinedRules), {
2465
- moduleGraph,
2466
- providers,
2467
- config
2468
- });
2469
- const diagnostics = filterIgnoredDiagnostics(rawDiagnostics, config, targetPath);
2470
- const score = calculateScore(diagnostics, files.length);
2573
+ const { fileRules, projectRules } = separateRules(filterRules(config, combinedRules));
2574
+ return {
2575
+ context: {
2576
+ astProject,
2577
+ config,
2578
+ fileRules,
2579
+ files,
2580
+ moduleGraph,
2581
+ projectRules,
2582
+ providers,
2583
+ targetPath
2584
+ },
2585
+ customRuleWarnings
2586
+ };
2587
+ }
2588
+ function updateFile(context, filePath) {
2589
+ const existing = context.astProject.getSourceFile(filePath);
2590
+ if (existing) context.astProject.removeSourceFile(existing);
2591
+ context.astProject.addSourceFileAtPath(filePath);
2592
+ if (!context.files.includes(filePath)) context.files.push(filePath);
2593
+ updateModuleGraphForFile(context.moduleGraph, context.astProject, filePath);
2594
+ updateProvidersForFile(context.providers, context.astProject, filePath);
2595
+ }
2596
+ function scanFile(context, filePath) {
2597
+ const { diagnostics: rawDiagnostics, errors } = runFileRules(context.astProject, [filePath], context.fileRules);
2598
+ return {
2599
+ diagnostics: filterIgnoredDiagnostics(rawDiagnostics, context.config, context.targetPath),
2600
+ errors: errors.map((e) => ({
2601
+ ruleId: e.ruleId,
2602
+ error: formatRuleError(e.error)
2603
+ }))
2604
+ };
2605
+ }
2606
+ function scanAllFiles(context) {
2607
+ const { diagnostics: rawDiagnostics, errors } = runFileRules(context.astProject, context.files, context.fileRules);
2608
+ return {
2609
+ diagnostics: filterIgnoredDiagnostics(rawDiagnostics, context.config, context.targetPath),
2610
+ errors: errors.map((e) => ({
2611
+ ruleId: e.ruleId,
2612
+ error: formatRuleError(e.error)
2613
+ }))
2614
+ };
2615
+ }
2616
+ function scanProject(context) {
2617
+ const options = {
2618
+ moduleGraph: context.moduleGraph,
2619
+ providers: context.providers,
2620
+ config: context.config
2621
+ };
2622
+ const { diagnostics: rawDiagnostics, errors } = runProjectRules(context.astProject, context.files, context.projectRules, options);
2623
+ return {
2624
+ diagnostics: filterIgnoredDiagnostics(rawDiagnostics, context.config, context.targetPath),
2625
+ errors: errors.map((e) => ({
2626
+ ruleId: e.ruleId,
2627
+ error: formatRuleError(e.error)
2628
+ }))
2629
+ };
2630
+ }
2631
+ async function scan(targetPath, options = {}) {
2632
+ const startTime = node_perf_hooks.performance.now();
2633
+ const { context, customRuleWarnings } = await prepareScan(targetPath, options);
2634
+ const projectPromise = detectProject(targetPath);
2635
+ const fileResult = scanAllFiles(context);
2636
+ const projectResult = scanProject(context);
2637
+ const diagnostics = [...fileResult.diagnostics, ...projectResult.diagnostics];
2638
+ const ruleErrors = [...fileResult.errors, ...projectResult.errors];
2639
+ const project = await projectPromise;
2640
+ const score = calculateScore(diagnostics, context.files.length);
2471
2641
  const summary = buildSummary(diagnostics);
2472
- const ruleErrors = errors.map((e) => ({
2473
- ruleId: e.ruleId,
2474
- error: formatRuleError(e.error)
2475
- }));
2476
2642
  const elapsedMs = node_perf_hooks.performance.now() - startTime;
2477
2643
  return {
2478
2644
  result: {
@@ -2480,17 +2646,17 @@ async function scan(targetPath, options = {}) {
2480
2646
  diagnostics,
2481
2647
  project: {
2482
2648
  ...project,
2483
- fileCount: files.length,
2484
- moduleCount: moduleGraph.modules.size
2649
+ fileCount: context.files.length,
2650
+ moduleCount: context.moduleGraph.modules.size
2485
2651
  },
2486
2652
  summary,
2487
2653
  ruleErrors,
2488
2654
  elapsedMs
2489
2655
  },
2490
- moduleGraph,
2656
+ moduleGraph: context.moduleGraph,
2491
2657
  customRuleWarnings,
2492
- files,
2493
- providers
2658
+ files: context.files,
2659
+ providers: context.providers
2494
2660
  };
2495
2661
  }
2496
2662
  function filterRules(config, rules) {
@@ -2527,16 +2693,9 @@ async function scanMonorepo(targetPath, options = {}) {
2527
2693
  const { rules: customRules, warnings: customRuleWarnings } = await resolveCustomRules(rootConfig, targetPath);
2528
2694
  const combinedRules = mergeRules(allRules, customRules, customRuleWarnings);
2529
2695
  const filesByProject = await collectMonorepoFiles(targetPath, monorepo, rootConfig);
2530
- const subProjects = [];
2531
- const allDiagnostics = [];
2532
- const allRuleErrors = [];
2533
- const moduleGraphs = /* @__PURE__ */ new Map();
2534
- let totalFiles = 0;
2535
- for (const [name, files] of filesByProject) {
2536
- if (files.length === 0) continue;
2696
+ const subProjectEntries = await Promise.all([...filesByProject.entries()].filter(([, files]) => files.length > 0).map(async ([name, files]) => {
2537
2697
  const projectPath = (0, node_path.join)(targetPath, monorepo.projects.get(name));
2538
- const project = await detectProject(projectPath);
2539
- const projectConfig = await loadConfigWithFallback(projectPath, rootConfig);
2698
+ const [project, projectConfig] = await Promise.all([detectProject(projectPath), loadConfigWithFallback(projectPath, rootConfig)]);
2540
2699
  const astProject = createAstParser(files);
2541
2700
  const moduleGraph = buildModuleGraph(astProject, files);
2542
2701
  const providers = resolveProviders(astProject, files);
@@ -2552,26 +2711,39 @@ async function scanMonorepo(targetPath, options = {}) {
2552
2711
  ruleId: e.ruleId,
2553
2712
  error: formatRuleError(e.error)
2554
2713
  }));
2555
- const result = {
2556
- score,
2557
- diagnostics,
2558
- project: {
2559
- ...project,
2560
- fileCount: files.length,
2561
- moduleCount: moduleGraph.modules.size
2714
+ return {
2715
+ name,
2716
+ result: {
2717
+ score,
2718
+ diagnostics,
2719
+ project: {
2720
+ ...project,
2721
+ fileCount: files.length,
2722
+ moduleCount: moduleGraph.modules.size
2723
+ },
2724
+ summary,
2725
+ ruleErrors,
2726
+ elapsedMs: 0
2562
2727
  },
2563
- summary,
2564
- ruleErrors,
2565
- elapsedMs: 0
2728
+ moduleGraph,
2729
+ diagnostics,
2730
+ ruleErrors
2566
2731
  };
2732
+ }));
2733
+ const subProjects = [];
2734
+ const allDiagnostics = [];
2735
+ const allRuleErrors = [];
2736
+ const moduleGraphs = /* @__PURE__ */ new Map();
2737
+ let totalFiles = 0;
2738
+ for (const entry of subProjectEntries) {
2567
2739
  subProjects.push({
2568
- name,
2569
- result
2740
+ name: entry.name,
2741
+ result: entry.result
2570
2742
  });
2571
- moduleGraphs.set(name, moduleGraph);
2572
- allDiagnostics.push(...diagnostics);
2573
- allRuleErrors.push(...ruleErrors);
2574
- totalFiles += files.length;
2743
+ moduleGraphs.set(entry.name, entry.moduleGraph);
2744
+ allDiagnostics.push(...entry.diagnostics);
2745
+ allRuleErrors.push(...entry.ruleErrors);
2746
+ totalFiles += entry.result.project.fileCount;
2575
2747
  }
2576
2748
  const combinedScore = calculateScore(allDiagnostics, totalFiles);
2577
2749
  const combinedSummary = buildSummary(allDiagnostics);
@@ -2702,4 +2874,11 @@ exports.ScanError = ScanError;
2702
2874
  exports.ValidationError = ValidationError;
2703
2875
  exports.diagnose = diagnose;
2704
2876
  exports.diagnoseMonorepo = diagnoseMonorepo;
2705
- exports.getRules = getRules;
2877
+ exports.getRules = getRules;
2878
+ exports.prepareScan = prepareScan;
2879
+ exports.scanAllFiles = scanAllFiles;
2880
+ exports.scanFile = scanFile;
2881
+ exports.scanProject = scanProject;
2882
+ exports.updateFile = updateFile;
2883
+ exports.updateModuleGraphForFile = updateModuleGraphForFile;
2884
+ exports.updateProvidersForFile = updateProvidersForFile;
@@ -8,6 +8,7 @@ interface ProviderInfo {
8
8
  name: string;
9
9
  publicMethodCount: number;
10
10
  }
11
+ declare function updateProvidersForFile(providers: Map<string, ProviderInfo>, project: Project, filePath: string): void;
11
12
  //#endregion
12
13
  //#region src/engine/module-graph.d.ts
13
14
  interface ModuleNode {
@@ -24,6 +25,7 @@ interface ModuleGraph {
24
25
  modules: Map<string, ModuleNode>;
25
26
  providerToModule: Map<string, ModuleNode>;
26
27
  }
28
+ declare function updateModuleGraphForFile(graph: ModuleGraph, project: Project, filePath: string): void;
27
29
  //#endregion
28
30
  //#region src/types/diagnostic.d.ts
29
31
  type Severity = "error" | "warning" | "info";
@@ -97,23 +99,6 @@ interface ProjectRule {
97
99
  }
98
100
  type AnyRule = Rule | ProjectRule;
99
101
  //#endregion
100
- //#region src/rules/index.d.ts
101
- declare function getRules(): AnyRule[];
102
- //#endregion
103
- //#region src/types/errors.d.ts
104
- declare class NestjsDoctorError extends Error {
105
- constructor(message: string);
106
- }
107
- declare class ConfigurationError extends NestjsDoctorError {
108
- constructor(message: string);
109
- }
110
- declare class ScanError extends NestjsDoctorError {
111
- constructor(message: string);
112
- }
113
- declare class ValidationError extends NestjsDoctorError {
114
- constructor(message: string);
115
- }
116
- //#endregion
117
102
  //#region src/types/result.d.ts
118
103
  interface Score {
119
104
  label: string;
@@ -157,6 +142,55 @@ interface MonorepoResult {
157
142
  subProjects: SubProjectResult[];
158
143
  }
159
144
  //#endregion
145
+ //#region src/core/scanner.d.ts
146
+ interface ScanOptions {
147
+ config?: string;
148
+ }
149
+ interface ScanContext {
150
+ astProject: Project;
151
+ config: NestjsDoctorConfig;
152
+ fileRules: Rule[];
153
+ files: string[];
154
+ moduleGraph: ModuleGraph;
155
+ projectRules: ProjectRule[];
156
+ providers: Map<string, ProviderInfo>;
157
+ targetPath: string;
158
+ }
159
+ declare function prepareScan(targetPath: string, options?: ScanOptions): Promise<{
160
+ context: ScanContext;
161
+ customRuleWarnings: string[];
162
+ }>;
163
+ declare function updateFile(context: ScanContext, filePath: string): void;
164
+ declare function scanFile(context: ScanContext, filePath: string): {
165
+ diagnostics: Diagnostic[];
166
+ errors: RuleErrorInfo[];
167
+ };
168
+ declare function scanAllFiles(context: ScanContext): {
169
+ diagnostics: Diagnostic[];
170
+ errors: RuleErrorInfo[];
171
+ };
172
+ declare function scanProject(context: ScanContext): {
173
+ diagnostics: Diagnostic[];
174
+ errors: RuleErrorInfo[];
175
+ };
176
+ //#endregion
177
+ //#region src/rules/index.d.ts
178
+ declare function getRules(): AnyRule[];
179
+ //#endregion
180
+ //#region src/types/errors.d.ts
181
+ declare class NestjsDoctorError extends Error {
182
+ constructor(message: string);
183
+ }
184
+ declare class ConfigurationError extends NestjsDoctorError {
185
+ constructor(message: string);
186
+ }
187
+ declare class ScanError extends NestjsDoctorError {
188
+ constructor(message: string);
189
+ }
190
+ declare class ValidationError extends NestjsDoctorError {
191
+ constructor(message: string);
192
+ }
193
+ //#endregion
160
194
  //#region src/api/index.d.ts
161
195
  /**
162
196
  * Scans a single NestJS project and returns a health diagnostic result.
@@ -184,5 +218,5 @@ declare function diagnoseMonorepo(path: string, options?: {
184
218
  config?: string;
185
219
  }): Promise<MonorepoResult>;
186
220
  //#endregion
187
- export { type AnyRule, type Category, ConfigurationError, type DiagnoseResult, type DiagnoseSummary, type Diagnostic, type MonorepoResult, type NestjsDoctorConfig, NestjsDoctorError, type ProjectInfo, type ProjectRule, type ProjectRuleContext, type Rule, type RuleContext, type RuleErrorInfo, type RuleMeta, ScanError, type Score, type Severity, type SubProjectResult, ValidationError, diagnose, diagnoseMonorepo, getRules };
221
+ export { type AnyRule, type Category, ConfigurationError, type DiagnoseResult, type DiagnoseSummary, type Diagnostic, type MonorepoResult, type NestjsDoctorConfig, NestjsDoctorError, type ProjectInfo, type ProjectRule, type ProjectRuleContext, type Rule, type RuleContext, type RuleErrorInfo, type RuleMeta, type ScanContext, ScanError, type Score, type Severity, type SubProjectResult, ValidationError, diagnose, diagnoseMonorepo, getRules, prepareScan, scanAllFiles, scanFile, scanProject, updateFile, updateModuleGraphForFile, updateProvidersForFile };
188
222
  //# sourceMappingURL=index.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.cts","names":[],"sources":["../../src/engine/type-resolver.ts","../../src/engine/module-graph.ts","../../src/types/diagnostic.ts","../../src/types/config.ts","../../src/rules/types.ts","../../src/rules/index.ts","../../src/types/errors.ts","../../src/types/result.ts","../../src/api/index.ts"],"mappings":";;;UAKiB,YAAA;EAChB,gBAAA,EAAkB,gBAAA;EAClB,YAAA;EACA,QAAA;EACA,IAAA;EACA,iBAAA;AAAA;;;UCAgB,UAAA;EAChB,gBAAA,EAAkB,gBAAA;EAClB,WAAA;EACA,OAAA;EACA,QAAA;EACA,OAAA;EACA,IAAA;EACA,SAAA;AAAA;AAAA,UAGgB,WAAA;EAChB,KAAA,EAAO,GAAA,SAAY,GAAA;EACnB,OAAA,EAAS,GAAA,SAAY,UAAA;EACrB,gBAAA,EAAkB,GAAA,SAAY,UAAA;AAAA;;;KCrBnB,QAAA;AAAA,KACA,QAAA;AAAA,UAMK,UAAA;EAChB,IAAA;EACA,IAAA;AAAA;AAAA,UAGgB,UAAA;EAChB,QAAA,EAAU,QAAA;EACV,MAAA;EACA,QAAA;EACA,IAAA;EACA,IAAA;EACA,OAAA;EACA,IAAA;EACA,KAAA,GAAQ,SAAA;EACR,QAAA,EAAU,QAAA;EACV,WAAA,GAAc,UAAA;AAAA;;;UCtBE,YAAA;EAChB,OAAA;EACA,QAAA,GAAW,QAAA;AAAA;AAAA,UAGK,wBAAA;EAChB,KAAA;EACA,KAAA;AAAA;AAAA,UAGgB,kBAAA;EAChB,UAAA,GAAa,OAAA,CAAQ,MAAA,CAAO,QAAA;EAC5B,cAAA;EACA,OAAA;EACA,MAAA,GAAS,wBAAA;EACT,OAAA;EACA,QAAA;EACA,KAAA,GAAQ,MAAA,SAAe,YAAA;AAAA;;;KCbZ,SAAA;AAAA,UAEK,QAAA;EAChB,QAAA,EAAU,QAAA;EACV,WAAA;EACA,IAAA;EACA,EAAA;EACA,KAAA,G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A,UAGO,gBAAA;EAChB,IAAA;EACA,MAAA,EAAQ,cAAA;AAAA;AAAA,UAGQ,cAAA;EAChB,QAAA,EAAU,cAAA;EACV,SAAA;EACA,UAAA;EACA,WAAA,EAAa,gBAAA;AAAA;;;;;;;;;;;iBCiBQ,QAAA,CACrB,IAAA,UACA,OAAA;EAAW,MAAA;AAAA,IAAsB,OAAA,CAFJ,cAAA;;APtD9B;;;;;;;;;;iBO0EsB,gBAAA,CACrB,IAAA,UACA,OAAA;EAAW,MAAA;AAAA,IAAsB,OAAA,CAFI,cAAA"}
1
+ {"version":3,"file":"index.d.cts","names":[],"sources":["../../src/engine/type-resolver.ts","../../src/engine/module-graph.ts","../../src/types/diagnostic.ts","../../src/types/config.ts","../../src/rules/types.ts","../../src/types/result.ts","../../src/core/scanner.ts","../../src/rules/index.ts","../../src/types/errors.ts","../../src/api/index.ts"],"mappings":";;;UAKiB,YAAA;EAChB,gBAAA,EAAkB,gBAAA;EAClB,YAAA;EACA,QAAA;EACA,IAAA;EACA,iBAAA;AAAA;AAAA,iBAuDe,sBAAA,CACf,SAAA,EAAW,GAAA,SAAY,YAAA,GACvB,OAAA,EAAS,OAAA,EACT,QAAA;;;UC1DgB,UAAA;EAChB,gBAAA,EAAkB,gBAAA;EAClB,WAAA;EACA,OAAA;EACA,QAAA;EACA,OAAA;EACA,IAAA;EACA,SAAA;AAAA;AAAA,UAGgB,WAAA;EAChB,KAAA,EAAO,GAAA,SAAY,GAAA;EACnB,OAAA,EAAS,GAAA,SAAY,UAAA;EACrB,gBAAA,EAAkB,GAAA,SAAY,UAAA;AAAA;AAAA,iBAuGf,wBAAA,CACf,KAAA,EAAO,WAAA,EACP,OAAA,EAAS,OAAA,EACT,QAAA;;;KC/HW,QAAA;AAAA,KACA,QAAA;AAAA,UAMK,UAAA;EAChB,IAAA;EACA,IAAA;AAAA;AAAA,UAGgB,UAAA;EAChB,QAAA,EAAU,QAAA;EACV,MAAA;EACA,QAAA;EACA,IAAA;EACA,IAA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;cAC3B,OAAA;AAAA;AAAA,cAMA,SAAA,SAAkB,iBAAA;cAClB,OAAA;AAAA;AAAA,cAMA,eAAA,SAAwB,iBAAA;cACxB,OAAA;AAAA;;;;;;;;AR2Cb;;;iBSSsB,QAAA,CACrB,IAAA,UACA,OAAA;EAAW,MAAA;AAAA,IAAsB,OAAA,CAFJ,cAAA;;;;;;;;;;;;iBAoBR,gBAAA,CACrB,IAAA,UACA,OAAA;EAAW,MAAA;AAAA,IAAsB,OAAA,CAFI,cAAA"}
@@ -8,6 +8,7 @@ interface ProviderInfo {
8
8
  name: string;
9
9
  publicMethodCount: number;
10
10
  }
11
+ declare function updateProvidersForFile(providers: Map<string, ProviderInfo>, project: Project, filePath: string): void;
11
12
  //#endregion
12
13
  //#region src/engine/module-graph.d.ts
13
14
  interface ModuleNode {
@@ -24,6 +25,7 @@ interface ModuleGraph {
24
25
  modules: Map<string, ModuleNode>;
25
26
  providerToModule: Map<string, ModuleNode>;
26
27
  }
28
+ declare function updateModuleGraphForFile(graph: ModuleGraph, project: Project, filePath: string): void;
27
29
  //#endregion
28
30
  //#region src/types/diagnostic.d.ts
29
31
  type Severity = "error" | "warning" | "info";
@@ -97,23 +99,6 @@ interface ProjectRule {
97
99
  }
98
100
  type AnyRule = Rule | ProjectRule;
99
101
  //#endregion
100
- //#region src/rules/index.d.ts
101
- declare function getRules(): AnyRule[];
102
- //#endregion
103
- //#region src/types/errors.d.ts
104
- declare class NestjsDoctorError extends Error {
105
- constructor(message: string);
106
- }
107
- declare class ConfigurationError extends NestjsDoctorError {
108
- constructor(message: string);
109
- }
110
- declare class ScanError extends NestjsDoctorError {
111
- constructor(message: string);
112
- }
113
- declare class ValidationError extends NestjsDoctorError {
114
- constructor(message: string);
115
- }
116
- //#endregion
117
102
  //#region src/types/result.d.ts
118
103
  interface Score {
119
104
  label: string;
@@ -157,6 +142,55 @@ interface MonorepoResult {
157
142
  subProjects: SubProjectResult[];
158
143
  }
159
144
  //#endregion
145
+ //#region src/core/scanner.d.ts
146
+ interface ScanOptions {
147
+ config?: string;
148
+ }
149
+ interface ScanContext {
150
+ astProject: Project;
151
+ config: NestjsDoctorConfig;
152
+ fileRules: Rule[];
153
+ files: string[];
154
+ moduleGraph: ModuleGraph;
155
+ projectRules: ProjectRule[];
156
+ providers: Map<string, ProviderInfo>;
157
+ targetPath: string;
158
+ }
159
+ declare function prepareScan(targetPath: string, options?: ScanOptions): Promise<{
160
+ context: ScanContext;
161
+ customRuleWarnings: string[];
162
+ }>;
163
+ declare function updateFile(context: ScanContext, filePath: string): void;
164
+ declare function scanFile(context: ScanContext, filePath: string): {
165
+ diagnostics: Diagnostic[];
166
+ errors: RuleErrorInfo[];
167
+ };
168
+ declare function scanAllFiles(context: ScanContext): {
169
+ diagnostics: Diagnostic[];
170
+ errors: RuleErrorInfo[];
171
+ };
172
+ declare function scanProject(context: ScanContext): {
173
+ diagnostics: Diagnostic[];
174
+ errors: RuleErrorInfo[];
175
+ };
176
+ //#endregion
177
+ //#region src/rules/index.d.ts
178
+ declare function getRules(): AnyRule[];
179
+ //#endregion
180
+ //#region src/types/errors.d.ts
181
+ declare class NestjsDoctorError extends Error {
182
+ constructor(message: string);
183
+ }
184
+ declare class ConfigurationError extends NestjsDoctorError {
185
+ constructor(message: string);
186
+ }
187
+ declare class ScanError extends NestjsDoctorError {
188
+ constructor(message: string);
189
+ }
190
+ declare class ValidationError extends NestjsDoctorError {
191
+ constructor(message: string);
192
+ }
193
+ //#endregion
160
194
  //#region src/api/index.d.ts
161
195
  /**
162
196
  * Scans a single NestJS project and returns a health diagnostic result.
@@ -184,5 +218,5 @@ declare function diagnoseMonorepo(path: string, options?: {
184
218
  config?: string;
185
219
  }): Promise<MonorepoResult>;
186
220
  //#endregion
187
- export { type AnyRule, type Category, ConfigurationError, type DiagnoseResult, type DiagnoseSummary, type Diagnostic, type MonorepoResult, type NestjsDoctorConfig, NestjsDoctorError, type ProjectInfo, type ProjectRule, type ProjectRuleContext, type Rule, type RuleContext, type RuleErrorInfo, type RuleMeta, ScanError, type Score, type Severity, type SubProjectResult, ValidationError, diagnose, diagnoseMonorepo, getRules };
221
+ export { type AnyRule, type Category, ConfigurationError, type DiagnoseResult, type DiagnoseSummary, type Diagnostic, type MonorepoResult, type NestjsDoctorConfig, NestjsDoctorError, type ProjectInfo, type ProjectRule, type ProjectRuleContext, type Rule, type RuleContext, type RuleErrorInfo, type RuleMeta, type ScanContext, ScanError, type Score, type Severity, type SubProjectResult, ValidationError, diagnose, diagnoseMonorepo, getRules, prepareScan, scanAllFiles, scanFile, scanProject, updateFile, updateModuleGraphForFile, updateProvidersForFile };
188
222
  //# sourceMappingURL=index.d.mts.map