nestjs-doctor 0.5.0 → 0.6.0
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 +181 -9
- package/dist/api/index.d.mts +259 -13
- package/dist/api/index.mjs +12 -7
- package/dist/cli/index.mjs +13 -8
- package/dist/{init-DDx6OGsF.mjs → init-B8Ap8Ubr.mjs} +1 -1
- package/dist/list-rules-Cr6UPDHN.mjs +2 -0
- package/dist/{setup-CN4uKQl2.mjs → setup-BDqj6-K4.mjs} +3 -3
- package/package.json +11 -8
package/README.md
CHANGED
|
@@ -66,6 +66,113 @@ Use `NestJS Doctor: Scan Project` from the command palette to trigger a full sca
|
|
|
66
66
|
|
|
67
67
|
---
|
|
68
68
|
|
|
69
|
+
## GitHub Action
|
|
70
|
+
|
|
71
|
+
Reviews every pull request and reports **only what the change introduced**, not
|
|
72
|
+
your existing backlog. Posts a sticky summary comment, inline review comments on
|
|
73
|
+
the changed lines, and a commit status with the score.
|
|
74
|
+
|
|
75
|
+
```yaml
|
|
76
|
+
# .github/workflows/nestjs-doctor.yml
|
|
77
|
+
name: NestJS Doctor
|
|
78
|
+
|
|
79
|
+
on:
|
|
80
|
+
pull_request:
|
|
81
|
+
push:
|
|
82
|
+
branches: [main]
|
|
83
|
+
|
|
84
|
+
permissions:
|
|
85
|
+
contents: read
|
|
86
|
+
pull-requests: write
|
|
87
|
+
statuses: write
|
|
88
|
+
|
|
89
|
+
jobs:
|
|
90
|
+
doctor:
|
|
91
|
+
runs-on: ubuntu-latest
|
|
92
|
+
steps:
|
|
93
|
+
- uses: actions/checkout@v4
|
|
94
|
+
with:
|
|
95
|
+
fetch-depth: 0 # required for `scope: changed`
|
|
96
|
+
- uses: RoloBits/nestjs-doctor@v1
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
`fetch-depth: 0` matters. `scope: changed` compares against the **merge base**
|
|
100
|
+
of your branch and its target, which a shallow checkout can't resolve — the
|
|
101
|
+
action falls back to the base branch tip, or, if it can't reach that either, to
|
|
102
|
+
reporting every finding in the changed files. It says which happened in the
|
|
103
|
+
comment.
|
|
104
|
+
|
|
105
|
+
### Inputs
|
|
106
|
+
|
|
107
|
+
| Input | Default | Description |
|
|
108
|
+
|-------|---------|-------------|
|
|
109
|
+
| `directory` | `.` | Project directory to scan |
|
|
110
|
+
| `scope` | `changed` | `changed` (only what the pull request introduced), `files` (everything in the changed files), `lines` (only the changed lines), `full` (the whole project) |
|
|
111
|
+
| `blocking` | `none` | Severity that fails the workflow: `none`, `warning`, `error` |
|
|
112
|
+
| `min-score` | — | Fail when the project's score drops below this |
|
|
113
|
+
| `config` | — | Path to a config file |
|
|
114
|
+
| `comment` | `true` | Sticky pull request summary comment |
|
|
115
|
+
| `review-comments` | `true` | Inline review comments on changed lines |
|
|
116
|
+
| `commit-status` | `true` | Commit status with the score |
|
|
117
|
+
| `sarif` | `false` | Also write a SARIF report |
|
|
118
|
+
| `sarif-file` | `nestjs-doctor.sarif` | Where the SARIF report goes |
|
|
119
|
+
| `silence-missing-baseline-warning` | `false` | Hide the degraded-scope warning |
|
|
120
|
+
| `github-token` | `${{ github.token }}` | Token used to comment and set the status |
|
|
121
|
+
| `node-version` | `22` | Node.js version |
|
|
122
|
+
| `version` | `latest` | nestjs-doctor version to run |
|
|
123
|
+
|
|
124
|
+
### Failing the build
|
|
125
|
+
|
|
126
|
+
Out of the box the action **never fails** — it comments and sets a status, and
|
|
127
|
+
you decide what to do about it. Enforcement is opt-in through two independent
|
|
128
|
+
gates, and either one failing fails the run.
|
|
129
|
+
|
|
130
|
+
```yaml
|
|
131
|
+
- uses: RoloBits/nestjs-doctor@v1
|
|
132
|
+
with:
|
|
133
|
+
blocking: error # any error the change introduced fails the run
|
|
134
|
+
min-score: 80 # …and so does a project score below 80
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
`blocking` gates on the findings **actually reported**, so with the default
|
|
138
|
+
`scope: changed` it fires only on what the pull request introduced — your
|
|
139
|
+
existing backlog cannot fail somebody else's pull request. `none` (the default)
|
|
140
|
+
never fails, `warning` fails on any error or warning, `error` on errors only.
|
|
141
|
+
|
|
142
|
+
`min-score` gates on the **whole project**, always, whatever the scope. That is
|
|
143
|
+
deliberate — narrowing a report must not make a codebase look healthier than it
|
|
144
|
+
is — but it does mean a high enough threshold can fail a pull request for debt
|
|
145
|
+
it did not create. Use `blocking` on its own to gate purely on the change.
|
|
146
|
+
|
|
147
|
+
### Outputs
|
|
148
|
+
|
|
149
|
+
`score`, `label`, `total-issues`, `fixed-issues`, `error-count`,
|
|
150
|
+
`warning-count`, `affected-files`, `report-file`, `sarif-file`.
|
|
151
|
+
|
|
152
|
+
Pushes to the default branch always scan the whole project and never fail the
|
|
153
|
+
run — they are a health snapshot, surfaced through the job summary and the
|
|
154
|
+
commit status, so `main` doesn't go red on pre-existing findings.
|
|
155
|
+
|
|
156
|
+
### Code scanning
|
|
157
|
+
|
|
158
|
+
Turn on `sarif` to send findings to the repository's Security tab:
|
|
159
|
+
|
|
160
|
+
```yaml
|
|
161
|
+
- uses: RoloBits/nestjs-doctor@v1
|
|
162
|
+
id: doctor
|
|
163
|
+
with:
|
|
164
|
+
scope: full
|
|
165
|
+
sarif: "true"
|
|
166
|
+
- uses: github/codeql-action/upload-sarif@v3
|
|
167
|
+
if: always() && steps.doctor.outputs.sarif-file != ''
|
|
168
|
+
with:
|
|
169
|
+
sarif_file: ${{ steps.doctor.outputs.sarif-file }}
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
Add `security-events: write` to the job's `permissions`.
|
|
173
|
+
|
|
174
|
+
---
|
|
175
|
+
|
|
69
176
|
## CI
|
|
70
177
|
|
|
71
178
|
Pin it as a devDependency:
|
|
@@ -90,19 +197,84 @@ Or wire it into `package.json`:
|
|
|
90
197
|
}
|
|
91
198
|
```
|
|
92
199
|
|
|
93
|
-
Exit codes: `1` if
|
|
200
|
+
Exit codes: `1` if a gate fails, `2` for bad input.
|
|
94
201
|
|
|
95
202
|
```
|
|
96
203
|
Usage: nestjs-doctor [directory] [options]
|
|
97
204
|
|
|
98
|
-
--verbose
|
|
99
|
-
--score
|
|
100
|
-
--json
|
|
101
|
-
--
|
|
102
|
-
--
|
|
103
|
-
--
|
|
104
|
-
--
|
|
105
|
-
|
|
205
|
+
--verbose Show file paths and line numbers per diagnostic
|
|
206
|
+
--score Output only the numeric score (for CI)
|
|
207
|
+
--json JSON output (for tooling)
|
|
208
|
+
--format <f> console (default), json, sarif, gitlab, markdown, github
|
|
209
|
+
--output <path> Write the formatted output to a file instead of stdout
|
|
210
|
+
--json-compact Emit JSON-based formats without indentation
|
|
211
|
+
--scope <s> full (default), files, lines, changed
|
|
212
|
+
--base <ref> Git ref to compare against (auto-detected)
|
|
213
|
+
--staged Scope to the staged files, for pre-commit hooks
|
|
214
|
+
--changed-files-from Path to a newline-separated list of changed files
|
|
215
|
+
--blocking <level> Severity that fails the run: none, warning, error
|
|
216
|
+
--min-score <n> Minimum passing score (0-100)
|
|
217
|
+
--report Generate an interactive HTML report (--graph also works)
|
|
218
|
+
--config <p> Path to config file
|
|
219
|
+
--list-rules List every built-in rule and exit
|
|
220
|
+
--init Set up the /nestjs-doctor skill for AI coding agents
|
|
221
|
+
-h, --help Show help
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
### Scoping to a change
|
|
225
|
+
|
|
226
|
+
The whole project is always analysed — cross-file rules like
|
|
227
|
+
`no-circular-module-deps` and `no-unused-providers` need it — so `--scope` only
|
|
228
|
+
narrows what gets **reported**.
|
|
229
|
+
|
|
230
|
+
| Scope | Reports |
|
|
231
|
+
|-------|---------|
|
|
232
|
+
| `full` | Every finding in the project (the default) |
|
|
233
|
+
| `files` | Findings in files the change touched |
|
|
234
|
+
| `lines` | Findings on the lines the change touched |
|
|
235
|
+
| `changed` | Findings the change introduced, measured against the base revision |
|
|
236
|
+
|
|
237
|
+
```bash
|
|
238
|
+
# What did this branch introduce?
|
|
239
|
+
npx nestjs-doctor . --scope changed --base origin/main
|
|
240
|
+
|
|
241
|
+
# Pre-commit hook: only what you are about to commit
|
|
242
|
+
npx nestjs-doctor . --staged --blocking error
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
`changed` scans the base revision in a temporary git worktree and subtracts the
|
|
246
|
+
findings that were already there. Findings are matched on rule, file, message,
|
|
247
|
+
and source text rather than line number, so unrelated edits above a finding
|
|
248
|
+
don't make it look new. If the base can't be reached the scan degrades to
|
|
249
|
+
`files` and warns rather than reporting a delta it never measured.
|
|
250
|
+
|
|
251
|
+
**The score always reflects the whole project**, whatever the scope — narrowing
|
|
252
|
+
the report can't make a codebase look healthier than it is. `--min-score` gates
|
|
253
|
+
on that project score; `--blocking` gates on the reported findings.
|
|
254
|
+
|
|
255
|
+
### Blocking
|
|
256
|
+
|
|
257
|
+
| Level | Fails the run when |
|
|
258
|
+
|-------|--------------------|
|
|
259
|
+
| `none` | Never — advisory only |
|
|
260
|
+
| `warning` | Any error or warning is reported |
|
|
261
|
+
| `error` | Any error is reported |
|
|
262
|
+
|
|
263
|
+
The default preserves long-standing behaviour: `error` for the console report,
|
|
264
|
+
`none` for `--json` and `--score`, which historically only failed on
|
|
265
|
+
`--min-score`. Pass `--blocking` explicitly to make both paths behave the same.
|
|
266
|
+
|
|
267
|
+
### Other CI systems
|
|
268
|
+
|
|
269
|
+
```bash
|
|
270
|
+
# GitLab Code Quality widget
|
|
271
|
+
npx nestjs-doctor . --format gitlab --output gl-code-quality-report.json
|
|
272
|
+
|
|
273
|
+
# SARIF, for any code-scanning backend
|
|
274
|
+
npx nestjs-doctor . --format sarif --output nestjs-doctor.sarif
|
|
275
|
+
|
|
276
|
+
# A markdown body to post as a merge request comment
|
|
277
|
+
npx nestjs-doctor . --format markdown --output comment.md
|
|
106
278
|
```
|
|
107
279
|
|
|
108
280
|
---
|
package/dist/api/index.d.mts
CHANGED
|
@@ -313,6 +313,30 @@ interface EndpointGraph {
|
|
|
313
313
|
endpoints: EndpointNode[];
|
|
314
314
|
}
|
|
315
315
|
//#endregion
|
|
316
|
+
//#region src/common/scope.d.ts
|
|
317
|
+
/**
|
|
318
|
+
* How much of a scan gets reported: everything, the changed files, the changed
|
|
319
|
+
* lines, or what the change introduced. Every mode analyses the whole project.
|
|
320
|
+
*/
|
|
321
|
+
type ScopeMode = "full" | "files" | "lines" | "changed";
|
|
322
|
+
declare const SCOPE_MODES: ScopeMode[];
|
|
323
|
+
declare function isScopeMode(value: string): value is ScopeMode;
|
|
324
|
+
/** Scope metadata attached to a result so consumers can see what was reported. */
|
|
325
|
+
interface ScopeInfo {
|
|
326
|
+
/** Present in `changed` mode: whether the base revision could be scanned. */
|
|
327
|
+
baselineAvailable?: boolean;
|
|
328
|
+
baseRef?: string;
|
|
329
|
+
/** Files the scope narrowed to, not the change's total file count. */
|
|
330
|
+
changedFiles?: number;
|
|
331
|
+
/** Files the change touched before filtering, when the caller knows it. */
|
|
332
|
+
changedFilesTotal?: number;
|
|
333
|
+
/** Set when the requested mode could not be honoured. */
|
|
334
|
+
degradedFrom?: ScopeMode;
|
|
335
|
+
/** Present in `changed` mode: findings the change resolved. */
|
|
336
|
+
fixed?: number;
|
|
337
|
+
mode: ScopeMode;
|
|
338
|
+
}
|
|
339
|
+
//#endregion
|
|
316
340
|
//#region src/common/result.d.ts
|
|
317
341
|
interface Score {
|
|
318
342
|
label: string;
|
|
@@ -344,6 +368,8 @@ interface DiagnoseResult {
|
|
|
344
368
|
project: ProjectInfo;
|
|
345
369
|
ruleErrors: RuleErrorInfo[];
|
|
346
370
|
schema?: SerializedSchemaGraph;
|
|
371
|
+
/** What `diagnostics` and `summary` cover. Absent when nothing was narrowed. */
|
|
372
|
+
scope?: ScopeInfo;
|
|
347
373
|
score: Score;
|
|
348
374
|
summary: DiagnoseSummary;
|
|
349
375
|
}
|
|
@@ -372,18 +398,6 @@ declare class ValidationError extends NestjsDoctorError {
|
|
|
372
398
|
constructor(message: string);
|
|
373
399
|
}
|
|
374
400
|
//#endregion
|
|
375
|
-
//#region src/engine/graph/endpoint-graph.d.ts
|
|
376
|
-
declare function buildEndpointGraph(project: Project, files: string[], providers: Map<string, ProviderInfo>): EndpointGraph;
|
|
377
|
-
/**
|
|
378
|
-
* Layer 2: traces method-level call chains for a specific endpoint.
|
|
379
|
-
* Returns the full recursive call tree through injected dependencies.
|
|
380
|
-
*/
|
|
381
|
-
declare function traceEndpointCalls(endpoint: EndpointNode, providers: Map<string, ProviderInfo>, project: Project): MethodCallNode[];
|
|
382
|
-
declare function updateEndpointGraphForFile(graph: EndpointGraph, project: Project, filePath: string, providers: Map<string, ProviderInfo>): void;
|
|
383
|
-
//#endregion
|
|
384
|
-
//#region src/engine/rules/index.d.ts
|
|
385
|
-
declare function getRules(): AnyRule[];
|
|
386
|
-
//#endregion
|
|
387
401
|
//#region src/engine/config/scan-config.d.ts
|
|
388
402
|
interface ScanConfig {
|
|
389
403
|
combinedRules: AnyRule[];
|
|
@@ -400,6 +414,132 @@ interface MonorepoInfo {
|
|
|
400
414
|
projects: Map<string, string>;
|
|
401
415
|
}
|
|
402
416
|
//#endregion
|
|
417
|
+
//#region src/engine/git.d.ts
|
|
418
|
+
/** A contiguous run of lines on the new side of a diff hunk. */
|
|
419
|
+
interface LineRange {
|
|
420
|
+
end: number;
|
|
421
|
+
start: number;
|
|
422
|
+
}
|
|
423
|
+
interface GitRepo {
|
|
424
|
+
/** Scanned directory relative to {@link root}, posix, `""` at the root. */
|
|
425
|
+
prefix: string;
|
|
426
|
+
/** Absolute path of the repository root, as git reports it. */
|
|
427
|
+
root: string;
|
|
428
|
+
/** Absolute path of the directory being scanned, as the caller gave it. */
|
|
429
|
+
targetPath: string;
|
|
430
|
+
}
|
|
431
|
+
/** Resolves the repository that contains `targetPath`, or `null` if there is none. */
|
|
432
|
+
declare function findGitRepo(targetPath: string): GitRepo | null;
|
|
433
|
+
/**
|
|
434
|
+
* Picks the ref to compare against: explicit, then `GITHUB_BASE_REF`, then the
|
|
435
|
+
* remote's default branch, then conventional names. `null` if none resolve.
|
|
436
|
+
*/
|
|
437
|
+
declare function resolveBaseRef(repo: GitRepo, explicit?: string): string | null;
|
|
438
|
+
/** Files added, modified, or renamed between the merge base of `base` and HEAD. */
|
|
439
|
+
declare function getChangedFiles(repo: GitRepo, base: string): string[] | null;
|
|
440
|
+
/** Files staged in the index — the set a pre-commit hook should look at. */
|
|
441
|
+
declare function getStagedFiles(repo: GitRepo): string[] | null;
|
|
442
|
+
/** New-side line ranges introduced between the merge base of `base` and HEAD. */
|
|
443
|
+
declare function getChangedLineRanges(repo: GitRepo, base: string): Map<string, LineRange[]> | null;
|
|
444
|
+
interface BaseCheckout {
|
|
445
|
+
/** Removes the temporary worktree. Safe to call more than once. */
|
|
446
|
+
cleanup(): void;
|
|
447
|
+
/** Absolute path mirroring the scanned directory at the base revision. */
|
|
448
|
+
targetPath: string;
|
|
449
|
+
}
|
|
450
|
+
/**
|
|
451
|
+
* Checks the base revision out into a detached worktree under the OS temp
|
|
452
|
+
* directory. `null` when the base is unreachable.
|
|
453
|
+
*/
|
|
454
|
+
declare function checkoutBase(repo: GitRepo, base: string): BaseCheckout | null;
|
|
455
|
+
//#endregion
|
|
456
|
+
//#region src/engine/scope.d.ts
|
|
457
|
+
interface ScopeOptions {
|
|
458
|
+
/** Git ref to compare against. Auto-detected when omitted. */
|
|
459
|
+
base?: string;
|
|
460
|
+
/** Path to a newline-separated list of changed files (CI hand-off). */
|
|
461
|
+
changedFilesFrom?: string;
|
|
462
|
+
mode: ScopeMode;
|
|
463
|
+
/** Compare against the index instead of a ref. */
|
|
464
|
+
staged?: boolean;
|
|
465
|
+
targetPath: string;
|
|
466
|
+
}
|
|
467
|
+
interface ResolvedScope {
|
|
468
|
+
baseRef: string | null;
|
|
469
|
+
/** Absolute paths of the changed files, or `null` in `full` mode. */
|
|
470
|
+
files: Set<string> | null;
|
|
471
|
+
lineRanges: Map<string, LineRange[]> | null;
|
|
472
|
+
/** The mode actually in force — may be a degraded `requestedMode`. */
|
|
473
|
+
mode: ScopeMode;
|
|
474
|
+
repo: GitRepo | null;
|
|
475
|
+
requestedMode: ScopeMode;
|
|
476
|
+
warnings: string[];
|
|
477
|
+
}
|
|
478
|
+
/**
|
|
479
|
+
* Works out which files, and lines, the reported set narrows to. Every failure
|
|
480
|
+
* path degrades to a wider scope with a warning.
|
|
481
|
+
*/
|
|
482
|
+
declare function resolveScope(options: ScopeOptions): ResolvedScope;
|
|
483
|
+
/** Narrows a diagnostic set to the resolved scope. `changed` is applied by the caller. */
|
|
484
|
+
declare function applyScope(diagnostics: Diagnostic[], scope: ResolvedScope): Diagnostic[];
|
|
485
|
+
/** Builds the {@link ScopeInfo} recorded on a result. */
|
|
486
|
+
declare function buildScopeInfo(scope: ResolvedScope, extra?: {
|
|
487
|
+
baselineAvailable?: boolean;
|
|
488
|
+
fixed?: number;
|
|
489
|
+
}): ScopeInfo | undefined;
|
|
490
|
+
//#endregion
|
|
491
|
+
//#region src/engine/baseline.d.ts
|
|
492
|
+
interface BaselineDelta {
|
|
493
|
+
/** False when the base could not be checked out — callers should degrade. */
|
|
494
|
+
available: boolean;
|
|
495
|
+
/** Findings the change resolved. */
|
|
496
|
+
fixed: number;
|
|
497
|
+
/** Findings with no counterpart at the base. */
|
|
498
|
+
introduced: Diagnostic[];
|
|
499
|
+
warnings: string[];
|
|
500
|
+
}
|
|
501
|
+
/**
|
|
502
|
+
* Which of HEAD's findings the change introduced. `available: false` when the
|
|
503
|
+
* base revision cannot be materialised.
|
|
504
|
+
*/
|
|
505
|
+
declare function computeBaselineDelta(headDiagnostics: Diagnostic[], scope: ResolvedScope, targetPath: string, scanConfig: ScanConfig, monorepo?: MonorepoInfo): Promise<BaselineDelta>;
|
|
506
|
+
//#endregion
|
|
507
|
+
//#region src/engine/fingerprint.d.ts
|
|
508
|
+
/** Path of `filePath` relative to `targetPath`, always with forward slashes. */
|
|
509
|
+
declare function toRelativePath(targetPath: string, filePath: string): string;
|
|
510
|
+
/**
|
|
511
|
+
* Stable identity for a diagnostic: rule, path, message, and the anchor line's
|
|
512
|
+
* text. Excludes line and column, which shift under unrelated edits.
|
|
513
|
+
*/
|
|
514
|
+
declare function diagnosticIdentity(diagnostic: Diagnostic, targetPath: string): string;
|
|
515
|
+
/** Hex digest of {@link diagnosticIdentity} — the form reporters emit. */
|
|
516
|
+
declare function fingerprint(diagnostic: Diagnostic, targetPath: string): string;
|
|
517
|
+
/** Counts identities, so repeated findings subtract one at a time. */
|
|
518
|
+
declare function countIdentities(diagnostics: Diagnostic[], targetPath: string): Map<string, number>;
|
|
519
|
+
interface DiagnosticDelta {
|
|
520
|
+
/** Findings present at the base that are gone at HEAD. */
|
|
521
|
+
fixed: number;
|
|
522
|
+
/** Findings at HEAD with no counterpart at the base. */
|
|
523
|
+
introduced: Diagnostic[];
|
|
524
|
+
}
|
|
525
|
+
/**
|
|
526
|
+
* Subtracts the base revision's findings from HEAD's. Each side's identities
|
|
527
|
+
* are computed against its own root.
|
|
528
|
+
*/
|
|
529
|
+
declare function diffDiagnostics(head: Diagnostic[], base: Diagnostic[], targetPath: string, baseTargetPath: string): DiagnosticDelta;
|
|
530
|
+
//#endregion
|
|
531
|
+
//#region src/engine/graph/endpoint-graph.d.ts
|
|
532
|
+
declare function buildEndpointGraph(project: Project, files: string[], providers: Map<string, ProviderInfo>): EndpointGraph;
|
|
533
|
+
/**
|
|
534
|
+
* Layer 2: traces method-level call chains for a specific endpoint.
|
|
535
|
+
* Returns the full recursive call tree through injected dependencies.
|
|
536
|
+
*/
|
|
537
|
+
declare function traceEndpointCalls(endpoint: EndpointNode, providers: Map<string, ProviderInfo>, project: Project): MethodCallNode[];
|
|
538
|
+
declare function updateEndpointGraphForFile(graph: EndpointGraph, project: Project, filePath: string, providers: Map<string, ProviderInfo>): void;
|
|
539
|
+
//#endregion
|
|
540
|
+
//#region src/engine/rules/index.d.ts
|
|
541
|
+
declare function getRules(): AnyRule[];
|
|
542
|
+
//#endregion
|
|
403
543
|
//#region src/engine/analysis-context.d.ts
|
|
404
544
|
interface AnalysisContext {
|
|
405
545
|
astProject: Project;
|
|
@@ -462,6 +602,11 @@ interface MonorepoEngineResult {
|
|
|
462
602
|
moduleGraphs: Map<string, ModuleGraph>;
|
|
463
603
|
result: MonorepoResult;
|
|
464
604
|
}
|
|
605
|
+
/**
|
|
606
|
+
* Replaces a result's diagnostics and recomputes the summary. The score is
|
|
607
|
+
* carried over: it measures the project, not the reported subset.
|
|
608
|
+
*/
|
|
609
|
+
declare function withScopedDiagnostics(result: DiagnoseResult, diagnostics: Diagnostic[], scope: ScopeInfo | undefined): DiagnoseResult;
|
|
465
610
|
declare function buildResult(context: AnalysisContext, rawOutput: RawDiagnosticOutput, customRuleWarnings?: string[]): EngineResult;
|
|
466
611
|
//#endregion
|
|
467
612
|
//#region src/engine/scanner.d.ts
|
|
@@ -480,6 +625,107 @@ declare function autoScan(targetPath: string, options?: {
|
|
|
480
625
|
//#region src/engine/schema/extract.d.ts
|
|
481
626
|
declare function extractSchema(project: Project, files: string[], orm: string | null, targetPath: string): SchemaGraph;
|
|
482
627
|
//#endregion
|
|
628
|
+
//#region src/formatters/gitlab-report.d.ts
|
|
629
|
+
interface CodeQualityIssue {
|
|
630
|
+
check_name: string;
|
|
631
|
+
description: string;
|
|
632
|
+
fingerprint: string;
|
|
633
|
+
location: {
|
|
634
|
+
lines: {
|
|
635
|
+
begin: number;
|
|
636
|
+
};
|
|
637
|
+
path: string;
|
|
638
|
+
};
|
|
639
|
+
severity: string;
|
|
640
|
+
}
|
|
641
|
+
/** Renders a result in the CodeClimate subset GitLab's Code Quality reads. */
|
|
642
|
+
declare function buildCodeQualityReport(result: DiagnoseResult, targetPath: string): CodeQualityIssue[];
|
|
643
|
+
//#endregion
|
|
644
|
+
//#region src/formatters/markdown-report.d.ts
|
|
645
|
+
/** Lets a CI job find and rewrite its own comment instead of stacking new ones. */
|
|
646
|
+
declare const MARKDOWN_COMMENT_MARKER = "<!-- nestjs-doctor:summary -->";
|
|
647
|
+
interface MarkdownReportOptions {
|
|
648
|
+
commitSha?: string;
|
|
649
|
+
monorepo?: MonorepoResult;
|
|
650
|
+
runUrl?: string;
|
|
651
|
+
scope?: ScopeInfo;
|
|
652
|
+
targetPath: string;
|
|
653
|
+
version: string;
|
|
654
|
+
warnings?: string[];
|
|
655
|
+
}
|
|
656
|
+
/** Renders a result as the markdown a CI job posts. */
|
|
657
|
+
declare function buildMarkdownReport(result: DiagnoseResult, options: MarkdownReportOptions): string;
|
|
658
|
+
//#endregion
|
|
659
|
+
//#region src/formatters/sarif-report.d.ts
|
|
660
|
+
type SarifLevel = "error" | "warning" | "note";
|
|
661
|
+
interface SarifRule {
|
|
662
|
+
fullDescription: {
|
|
663
|
+
text: string;
|
|
664
|
+
};
|
|
665
|
+
help: {
|
|
666
|
+
markdown: string;
|
|
667
|
+
text: string;
|
|
668
|
+
};
|
|
669
|
+
helpUri: string;
|
|
670
|
+
id: string;
|
|
671
|
+
name: string;
|
|
672
|
+
properties: {
|
|
673
|
+
problem: {
|
|
674
|
+
severity: string;
|
|
675
|
+
};
|
|
676
|
+
tags: string[];
|
|
677
|
+
};
|
|
678
|
+
shortDescription: {
|
|
679
|
+
text: string;
|
|
680
|
+
};
|
|
681
|
+
}
|
|
682
|
+
interface SarifResult {
|
|
683
|
+
level: SarifLevel;
|
|
684
|
+
locations: {
|
|
685
|
+
physicalLocation: {
|
|
686
|
+
artifactLocation: {
|
|
687
|
+
uri: string;
|
|
688
|
+
uriBaseId: string;
|
|
689
|
+
};
|
|
690
|
+
region: {
|
|
691
|
+
startColumn?: number;
|
|
692
|
+
startLine: number;
|
|
693
|
+
};
|
|
694
|
+
};
|
|
695
|
+
}[];
|
|
696
|
+
message: {
|
|
697
|
+
text: string;
|
|
698
|
+
};
|
|
699
|
+
partialFingerprints: Record<string, string>;
|
|
700
|
+
ruleId: string;
|
|
701
|
+
ruleIndex: number;
|
|
702
|
+
}
|
|
703
|
+
interface SarifLog {
|
|
704
|
+
$schema: string;
|
|
705
|
+
runs: {
|
|
706
|
+
columnKind: string;
|
|
707
|
+
originalUriBaseIds: Record<string, {
|
|
708
|
+
uri: string;
|
|
709
|
+
}>;
|
|
710
|
+
results: SarifResult[];
|
|
711
|
+
tool: {
|
|
712
|
+
driver: {
|
|
713
|
+
informationUri: string;
|
|
714
|
+
name: string;
|
|
715
|
+
rules: SarifRule[];
|
|
716
|
+
semanticVersion: string;
|
|
717
|
+
version: string;
|
|
718
|
+
};
|
|
719
|
+
};
|
|
720
|
+
}[];
|
|
721
|
+
version: string;
|
|
722
|
+
}
|
|
723
|
+
/**
|
|
724
|
+
* Renders a result as a SARIF 2.1.0 log, with an explicit `partialFingerprints`
|
|
725
|
+
* on every result.
|
|
726
|
+
*/
|
|
727
|
+
declare function buildSarifLog(result: DiagnoseResult, targetPath: string, version: string): SarifLog;
|
|
728
|
+
//#endregion
|
|
483
729
|
//#region src/api/index.d.ts
|
|
484
730
|
/**
|
|
485
731
|
* Scans a single NestJS project and returns a health diagnostic result.
|
|
@@ -507,4 +753,4 @@ declare function diagnoseMonorepo(path: string, options?: {
|
|
|
507
753
|
config?: string;
|
|
508
754
|
}): Promise<MonorepoResult>;
|
|
509
755
|
//#endregion
|
|
510
|
-
export { type AnalysisContext, type AnyRule, type AutoScanResult, type BaseDiagnostic, type Category, type CodeDiagnostic, type CodeRuleContext, type CodeRuleContext as RuleContext, ConfigurationError, type DependencyType, type DiagnoseResult, type DiagnoseSummary, type Diagnostic, type EndpointGraph, type EndpointNode, type MethodCallNode, type MethodDependencyNode, type MonorepoResult, type NestjsDoctorConfig, NestjsDoctorError, type ProjectInfo, type ProjectRule, type ProjectRuleContext, type RawDiagnosticOutput, type Rule, type RuleErrorInfo, type RuleMeta, type ScanConfig, ScanError, type SchemaColumn, type SchemaDiagnostic, type SchemaEntity, type SchemaGraph, type SchemaRelation, type SchemaRule, type SchemaRuleContext, type Score, type SerializedSchemaGraph, type Severity, type SubProjectResult, ValidationError, autoScan, buildAnalysisContext, buildEndpointGraph, buildResult, checkAllFiles, checkFile, checkProject, checkSchema, diagnose, diagnoseMonorepo, extractSchema, getRules, isCodeDiagnostic, isSchemaDiagnostic, prepareAnalysis, resolveScanConfig, traceEndpointCalls, updateEndpointGraphForFile, updateFile, updateModuleGraphForFile, updateProvidersForFile };
|
|
756
|
+
export { type AnalysisContext, type AnyRule, type AutoScanResult, type BaseCheckout, type BaseDiagnostic, type BaselineDelta, type Category, type CodeDiagnostic, type CodeQualityIssue, type CodeRuleContext, type CodeRuleContext as RuleContext, ConfigurationError, type DependencyType, type DiagnoseResult, type DiagnoseSummary, type Diagnostic, type DiagnosticDelta, type EndpointGraph, type EndpointNode, type GitRepo, type LineRange, MARKDOWN_COMMENT_MARKER, type MarkdownReportOptions, type MethodCallNode, type MethodDependencyNode, type MonorepoResult, type NestjsDoctorConfig, NestjsDoctorError, type ProjectInfo, type ProjectRule, type ProjectRuleContext, type RawDiagnosticOutput, type ResolvedScope, type Rule, type RuleErrorInfo, type RuleMeta, SCOPE_MODES, type SarifLog, type ScanConfig, ScanError, type SchemaColumn, type SchemaDiagnostic, type SchemaEntity, type SchemaGraph, type SchemaRelation, type SchemaRule, type SchemaRuleContext, type ScopeInfo, type ScopeMode, type ScopeOptions, type Score, type SerializedSchemaGraph, type Severity, type SubProjectResult, ValidationError, applyScope, autoScan, buildAnalysisContext, buildCodeQualityReport, buildEndpointGraph, buildMarkdownReport, buildResult, buildSarifLog, buildScopeInfo, checkAllFiles, checkFile, checkProject, checkSchema, checkoutBase, computeBaselineDelta, countIdentities, diagnose, diagnoseMonorepo, diagnosticIdentity, diffDiagnostics, extractSchema, findGitRepo, fingerprint, getChangedFiles, getChangedLineRanges, getRules, getStagedFiles, isCodeDiagnostic, isSchemaDiagnostic, isScopeMode, prepareAnalysis, resolveBaseRef, resolveScanConfig, resolveScope, toRelativePath, traceEndpointCalls, updateEndpointGraphForFile, updateFile, updateModuleGraphForFile, updateProvidersForFile, withScopedDiagnostics };
|