@codependix/boundaries 0.0.10 → 0.0.11
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/CHANGELOG.md +16 -0
- package/README.md +143 -95
- package/dist/src/index.d.ts +330 -28
- package/dist/src/index.js +275 -90
- package/package.json +3 -3
package/dist/src/index.d.ts
CHANGED
|
@@ -42,7 +42,11 @@ export declare class BoundariesService {
|
|
|
42
42
|
private readonly cyclesService;
|
|
43
43
|
private readonly selectorService;
|
|
44
44
|
constructor(cyclesService: BoundaryCyclesService, selectorService: BoundarySelectorService);
|
|
45
|
-
/**
|
|
45
|
+
/**
|
|
46
|
+
* Turns one condemned edge into the violation reported for it, charged to
|
|
47
|
+
* the project owning the edge's source alone: the dependency is written in
|
|
48
|
+
* the source, so that is the project a fix belongs to.
|
|
49
|
+
*/
|
|
46
50
|
private buildAccessViolation;
|
|
47
51
|
/**
|
|
48
52
|
* The sentence a violation is reported as.
|
|
@@ -54,6 +58,15 @@ export declare class BoundariesService {
|
|
|
54
58
|
* configured half says why it matters.
|
|
55
59
|
*/
|
|
56
60
|
private buildMessage;
|
|
61
|
+
/**
|
|
62
|
+
* The projects owning the given nodes, sorted and deduplicated.
|
|
63
|
+
*
|
|
64
|
+
* A node's own `project` where it carries one — every node in an Nx-level
|
|
65
|
+
* graph is its own project — and the graph's `scope` otherwise, which is
|
|
66
|
+
* the project a file- or NestJS-level graph was built for. Never the
|
|
67
|
+
* workspace: a finding charged to no project could fail no project.
|
|
68
|
+
*/
|
|
69
|
+
private chargeProjects;
|
|
57
70
|
/**
|
|
58
71
|
* Reports every edge an `allow` or `forbid` rule condemns.
|
|
59
72
|
*
|
|
@@ -63,7 +76,11 @@ export declare class BoundariesService {
|
|
|
63
76
|
* does not.
|
|
64
77
|
*/
|
|
65
78
|
private evaluateAccessRule;
|
|
66
|
-
/**
|
|
79
|
+
/**
|
|
80
|
+
* Reports every cycle an `acyclic` rule's selected nodes still form, each
|
|
81
|
+
* charged to every project owning a node on it: no one project on a cycle
|
|
82
|
+
* can break it alone, so it fails every one of them.
|
|
83
|
+
*/
|
|
67
84
|
private evaluateAcyclicRule;
|
|
68
85
|
/** Indexes a graph's nodes by identifier, so an edge can look its ends up. */
|
|
69
86
|
private indexNodes;
|
|
@@ -133,6 +150,12 @@ export declare const BOUNDARY_LEVEL_ORDER: readonly ["nxProjects", "nestjsModule
|
|
|
133
150
|
* be repacked at the call site.
|
|
134
151
|
*/
|
|
135
152
|
export declare interface BoundaryCheckContext {
|
|
153
|
+
/**
|
|
154
|
+
* The projects every level's graph is built over: `selectedProjects` and
|
|
155
|
+
* everything they depend on, or `selectedProjects` alone under
|
|
156
|
+
* `--no-dependencies` — see `RunContextService.resolveBuildProjects`.
|
|
157
|
+
*/
|
|
158
|
+
readonly buildProjects: NxProject[];
|
|
136
159
|
readonly configuration: ResolvedCodependixConfiguration;
|
|
137
160
|
/**
|
|
138
161
|
* The graph types this run judges.
|
|
@@ -148,7 +171,8 @@ export declare interface BoundaryCheckContext {
|
|
|
148
171
|
/** Every project the graph knows, apart from the workspace root. */
|
|
149
172
|
readonly projects: NxProject[];
|
|
150
173
|
/**
|
|
151
|
-
* The projects the run was narrowed to
|
|
174
|
+
* The projects the run was narrowed to: a finding fails the run only when
|
|
175
|
+
* it is charged to one of these.
|
|
152
176
|
*
|
|
153
177
|
* Identical to `projects` unless `--projects` or `--tags` named a
|
|
154
178
|
* selection, so the gate judges the whole workspace by default and a
|
|
@@ -158,10 +182,26 @@ export declare interface BoundaryCheckContext {
|
|
|
158
182
|
readonly workingDirectory: string;
|
|
159
183
|
}
|
|
160
184
|
|
|
161
|
-
/**
|
|
185
|
+
/**
|
|
186
|
+
* One graph that could not be built, charged to the project(s) it was being
|
|
187
|
+
* built for.
|
|
188
|
+
*
|
|
189
|
+
* A container that cannot boot fails its own project, since that container
|
|
190
|
+
* really cannot boot — but the class it failed on often lives in a
|
|
191
|
+
* dependency, so `ownerProject` names that dependency when the stack shows it.
|
|
192
|
+
*/
|
|
162
193
|
export declare interface BoundaryCheckFailure {
|
|
194
|
+
/** The raised error's message. */
|
|
163
195
|
readonly error: string;
|
|
164
|
-
readonly
|
|
196
|
+
readonly level: CodependixBoundaryLevel;
|
|
197
|
+
/**
|
|
198
|
+
* The project owning the first stack frame inside the root of a project
|
|
199
|
+
* the charged ones depend on, when that is not a charged project. Absent when no frame resolves to a
|
|
200
|
+
* project: a guessed owner would blame a project that did nothing wrong.
|
|
201
|
+
*/
|
|
202
|
+
readonly ownerProject?: string | undefined;
|
|
203
|
+
/** The projects this failure is charged to, sorted. */
|
|
204
|
+
readonly projects: readonly string[];
|
|
165
205
|
}
|
|
166
206
|
|
|
167
207
|
/** Wires rule evaluation together with the four graph builders it judges. */
|
|
@@ -169,7 +209,7 @@ export declare class BoundaryCheckModule {
|
|
|
169
209
|
}
|
|
170
210
|
|
|
171
211
|
/**
|
|
172
|
-
* What one `--check boundaries` pass found.
|
|
212
|
+
* What one `--check boundaries` pass found, each finding judged.
|
|
173
213
|
*
|
|
174
214
|
* Failures are carried beside violations rather than thrown, for the same
|
|
175
215
|
* reason every export pass carries them: a NestJS project that cannot boot
|
|
@@ -178,8 +218,8 @@ export declare class BoundaryCheckModule {
|
|
|
178
218
|
* has.
|
|
179
219
|
*/
|
|
180
220
|
export declare interface BoundaryCheckOutcome {
|
|
181
|
-
readonly failures: BoundaryCheckFailure[];
|
|
182
|
-
readonly violations: BoundaryViolation[];
|
|
221
|
+
readonly failures: JudgedBoundaryFinding<BoundaryCheckFailure>[];
|
|
222
|
+
readonly violations: JudgedBoundaryFinding<BoundaryViolation>[];
|
|
183
223
|
}
|
|
184
224
|
|
|
185
225
|
/**
|
|
@@ -198,15 +238,14 @@ export declare interface BoundaryCheckOutcome {
|
|
|
198
238
|
*/
|
|
199
239
|
export declare class BoundaryCheckService {
|
|
200
240
|
private readonly boundariesService;
|
|
241
|
+
private readonly boundaryFailureService;
|
|
201
242
|
private readonly boundaryGraphService;
|
|
202
243
|
private readonly moduleGraphService;
|
|
203
244
|
private readonly nestjsProjectService;
|
|
204
245
|
private readonly pythonService;
|
|
205
246
|
private readonly typescriptService;
|
|
206
247
|
private readonly workspaceGraphService;
|
|
207
|
-
constructor(boundariesService: BoundariesService, boundaryGraphService: BoundaryGraphService, moduleGraphService: ModuleGraphService, nestjsProjectService: NestjsProjectService, pythonService: PythonService, typescriptService: TypescriptService, workspaceGraphService: WorkspaceGraphService);
|
|
208
|
-
/** Turns a raised error into a `BoundaryCheckFailure` for the given project. */
|
|
209
|
-
private collectProjectFailure;
|
|
248
|
+
constructor(boundariesService: BoundariesService, boundaryFailureService: BoundaryFailureService, boundaryGraphService: BoundaryGraphService, moduleGraphService: ModuleGraphService, nestjsProjectService: NestjsProjectService, pythonService: PythonService, typescriptService: TypescriptService, workspaceGraphService: WorkspaceGraphService);
|
|
210
249
|
/**
|
|
211
250
|
* The `CodependixGraphType` each boundary level is judged under.
|
|
212
251
|
*
|
|
@@ -217,6 +256,13 @@ export declare class BoundaryCheckService {
|
|
|
217
256
|
* both levels together.
|
|
218
257
|
*/
|
|
219
258
|
private graphTypeForLevel;
|
|
259
|
+
/**
|
|
260
|
+
* Judges every charged finding: it fails the run when one of its projects
|
|
261
|
+
* is judged, and is a note against the dependency it lives in otherwise.
|
|
262
|
+
*/
|
|
263
|
+
private judge;
|
|
264
|
+
/** `"fail"` when any charged project is judged, and `"note"` otherwise. */
|
|
265
|
+
private resolveVerdict;
|
|
220
266
|
/**
|
|
221
267
|
* Resolves one level's declared rules out of the nested boundaries shape.
|
|
222
268
|
*
|
|
@@ -227,7 +273,7 @@ export declare class BoundaryCheckService {
|
|
|
227
273
|
*/
|
|
228
274
|
private rulesForLevel;
|
|
229
275
|
/**
|
|
230
|
-
*
|
|
276
|
+
* Builds one level's findings, whichever of the four builders it needs.
|
|
231
277
|
*
|
|
232
278
|
* A record keyed by level rather than a switch: the record type requires
|
|
233
279
|
* every `CodependixBoundaryLevel` to have an entry, so a fifth level added
|
|
@@ -236,17 +282,24 @@ export declare class BoundaryCheckService {
|
|
|
236
282
|
private runLevel;
|
|
237
283
|
/** Judges every `framework:nestjs` project's module graph. */
|
|
238
284
|
private runNestjsLevel;
|
|
239
|
-
/**
|
|
285
|
+
/**
|
|
286
|
+
* Judges the whole-workspace Nx project graph, drawn over the build set so
|
|
287
|
+
* no edge from a judged project into a dependency is dropped.
|
|
288
|
+
*
|
|
289
|
+
* A graph that cannot be built is charged to every judged project, since
|
|
290
|
+
* none of them could be judged at this level.
|
|
291
|
+
*/
|
|
240
292
|
private runNxLevel;
|
|
241
293
|
/**
|
|
242
|
-
* Judges every project at one level, isolating each
|
|
294
|
+
* Judges every project in the build set at one level, isolating each
|
|
295
|
+
* project's failure.
|
|
243
296
|
*
|
|
244
297
|
* The three per-project levels differ only in how a project is discovered
|
|
245
298
|
* and how its graph is built, so the loop around them is written once: a
|
|
246
|
-
* project that raises is collected as a failure
|
|
247
|
-
* still judged. `buildGraph` may be asynchronous because
|
|
248
|
-
* is — booting a container is the one graph this tool
|
|
249
|
-
* synchronously.
|
|
299
|
+
* project that raises is collected as a failure charged to it, and every
|
|
300
|
+
* other project is still judged. `buildGraph` may be asynchronous because
|
|
301
|
+
* the NestJS level's is — booting a container is the one graph this tool
|
|
302
|
+
* cannot build synchronously.
|
|
250
303
|
*/
|
|
251
304
|
private runProjectLevel;
|
|
252
305
|
/** Judges every `language:python` project's file-level import graph. */
|
|
@@ -339,6 +392,64 @@ export declare interface BoundaryEdge {
|
|
|
339
392
|
readonly target: string;
|
|
340
393
|
}
|
|
341
394
|
|
|
395
|
+
/**
|
|
396
|
+
* Turns an error a graph builder raised into the failure a run reports.
|
|
397
|
+
*
|
|
398
|
+
* The failure is charged to the project whose graph was being built — a
|
|
399
|
+
* container that cannot boot fails that project, whichever class broke it.
|
|
400
|
+
* What the message alone cannot say is whose class that was: NestJS
|
|
401
|
+
* containers are booted by `import()`, and a module that fails evaluation in
|
|
402
|
+
* a dependency rethrows the same error into every project importing it. The
|
|
403
|
+
* stack still holds the frame that threw, so the first frame inside the root
|
|
404
|
+
* of a project the charged ones depend on names the project that owns the
|
|
405
|
+
* failing code.
|
|
406
|
+
*
|
|
407
|
+
* Only their dependency closure: when codependix runs from source, its own
|
|
408
|
+
* packages are workspace projects too, and an error it raises itself would
|
|
409
|
+
* otherwise blame whichever of them threw.
|
|
410
|
+
*/
|
|
411
|
+
export declare class BoundaryFailureService {
|
|
412
|
+
private readonly neighborhoodService;
|
|
413
|
+
constructor(neighborhoodService: NeighborhoodService);
|
|
414
|
+
/**
|
|
415
|
+
* The project whose root holds a file, the innermost when roots nest — or
|
|
416
|
+
* nothing for a file no project holds, or one inside `node_modules`.
|
|
417
|
+
*/
|
|
418
|
+
private findProjectHolding;
|
|
419
|
+
/**
|
|
420
|
+
* The location one stack line names, without its line and column — or
|
|
421
|
+
* nothing for a line that is not a frame, or a frame naming no position.
|
|
422
|
+
*
|
|
423
|
+
* String operations rather than a regular expression: a stack is library
|
|
424
|
+
* input, and every single-pattern reading of both frame shapes backtracks
|
|
425
|
+
* in polynomial time on a crafted line.
|
|
426
|
+
*/
|
|
427
|
+
private readFrameLocation;
|
|
428
|
+
/**
|
|
429
|
+
* The absolute file path one stack line names, or nothing for a line that
|
|
430
|
+
* is not a frame or names no file — a `node:` internal, say.
|
|
431
|
+
*/
|
|
432
|
+
private readFramePath;
|
|
433
|
+
/**
|
|
434
|
+
* The project owning the first stack frame inside the root of a project
|
|
435
|
+
* the charged ones transitively depend on, themselves included.
|
|
436
|
+
*
|
|
437
|
+
* The first such frame rather than any: frames below it are whatever was
|
|
438
|
+
* importing the failing module, which is every project that depends on it.
|
|
439
|
+
* A frame in any other project is skipped — that project is not something
|
|
440
|
+
* the charged ones are built from, so it cannot be what broke them.
|
|
441
|
+
*/
|
|
442
|
+
private resolveOwnerProject;
|
|
443
|
+
/**
|
|
444
|
+
* Collects one graph's failure, charged to the projects it was built for.
|
|
445
|
+
*
|
|
446
|
+
* `ownerProject` is set only when the stack resolves to a project that is
|
|
447
|
+
* not already charged: naming the charged project a second time says
|
|
448
|
+
* nothing, and naming a guess would blame a project that did nothing wrong.
|
|
449
|
+
*/
|
|
450
|
+
collect(args: CollectFailureArguments): BoundaryCheckFailure;
|
|
451
|
+
}
|
|
452
|
+
|
|
342
453
|
/**
|
|
343
454
|
* One built graph, reduced to what rule evaluation needs.
|
|
344
455
|
*
|
|
@@ -419,6 +530,12 @@ export declare class BoundaryGraphService {
|
|
|
419
530
|
buildTypescriptImportGraph(graph: TypescriptImportGraph): BoundaryGraph;
|
|
420
531
|
}
|
|
421
532
|
|
|
533
|
+
/** What every level found, charged but not yet judged. */
|
|
534
|
+
export declare interface BoundaryLevelOutcome {
|
|
535
|
+
readonly failures: BoundaryCheckFailure[];
|
|
536
|
+
readonly violations: BoundaryViolation[];
|
|
537
|
+
}
|
|
538
|
+
|
|
422
539
|
/**
|
|
423
540
|
* One node in a graph, with whatever a level knows about it.
|
|
424
541
|
*
|
|
@@ -438,6 +555,86 @@ export declare interface BoundaryNode {
|
|
|
438
555
|
readonly tags?: readonly string[] | undefined;
|
|
439
556
|
}
|
|
440
557
|
|
|
558
|
+
/**
|
|
559
|
+
* Reports what a boundary pass found — as lines, as the JSON object under the
|
|
560
|
+
* `boundaries` key, and as the Markdown section of a combined document.
|
|
561
|
+
*
|
|
562
|
+
* Kept apart from `BoundaryReportService`, which renders rule violations
|
|
563
|
+
* alone: a pass's container failures and verdicts are only known to the check
|
|
564
|
+
* that judged them, and every wording that says whom a finding is charged to
|
|
565
|
+
* still comes from `BoundaryReportService.describeCharge`.
|
|
566
|
+
*/
|
|
567
|
+
export declare class BoundaryOutcomeReportService {
|
|
568
|
+
private readonly boundaryReportService;
|
|
569
|
+
constructor(boundaryReportService: BoundaryReportService);
|
|
570
|
+
/** One bullet: the verdict in bold, then the line the log prints. */
|
|
571
|
+
private renderBullet;
|
|
572
|
+
/** One failure as the line the log and the Markdown report both print. */
|
|
573
|
+
private renderFailure;
|
|
574
|
+
/** The bullets of every finding charged to one project, violations first. */
|
|
575
|
+
private renderProjectGroup;
|
|
576
|
+
/** One violation as the line the log and the Markdown report both print. */
|
|
577
|
+
private renderViolation;
|
|
578
|
+
/**
|
|
579
|
+
* Reduces a pass's judged findings to the object `--format json` prints.
|
|
580
|
+
*
|
|
581
|
+
* Maps field by field rather than spreading: a violation's `scope` is where
|
|
582
|
+
* it was found, not whose it is, and the report names the charged projects
|
|
583
|
+
* instead. A cycle absent from an access rule is `null` and an absent owner
|
|
584
|
+
* is left out, so the same key never means two things.
|
|
585
|
+
*/
|
|
586
|
+
buildReport(args: BoundaryReportArguments): BoundaryReport;
|
|
587
|
+
/**
|
|
588
|
+
* One line per failure: its level, whom it is charged to, and the error —
|
|
589
|
+
* then the project owning the code it broke on, when that is another
|
|
590
|
+
* project. A note says which dependency it lives in instead.
|
|
591
|
+
*/
|
|
592
|
+
renderFailures(failures: readonly JudgedBoundaryFinding<BoundaryCheckFailure>[]): string[];
|
|
593
|
+
/**
|
|
594
|
+
* Renders a report as the Markdown a combined document carries: the judged
|
|
595
|
+
* projects, then every finding listed under each project it is charged to,
|
|
596
|
+
* a note marked as not failing under the dependency it lives in.
|
|
597
|
+
*
|
|
598
|
+
* A run judging no project at all — a workspace holding nothing but its
|
|
599
|
+
* root, since an unmatched selection is refused before the run — says
|
|
600
|
+
* "none" rather than printing an empty list.
|
|
601
|
+
*/
|
|
602
|
+
renderMarkdown(report: BoundaryReport): string;
|
|
603
|
+
}
|
|
604
|
+
|
|
605
|
+
/**
|
|
606
|
+
* One boundary pass's findings as `--format json` prints them, under the
|
|
607
|
+
* `boundaries` key.
|
|
608
|
+
*
|
|
609
|
+
* Every finding carries its verdict, so a reader can tell a finding that
|
|
610
|
+
* failed the run from a note about a dependency without re-deriving it from
|
|
611
|
+
* `judgedProjects`.
|
|
612
|
+
*/
|
|
613
|
+
export declare interface BoundaryReport {
|
|
614
|
+
/** Every container that could not boot, charged and judged. */
|
|
615
|
+
readonly failures: BoundaryReportFailure[];
|
|
616
|
+
/** The projects the run judged, sorted — what a finding must be charged to to fail. */
|
|
617
|
+
readonly judgedProjects: string[];
|
|
618
|
+
/** Every edge or cycle that broke a declared rule, charged and judged. */
|
|
619
|
+
readonly violations: BoundaryReportViolation[];
|
|
620
|
+
}
|
|
621
|
+
|
|
622
|
+
/** Arguments accepted when building a run's `BoundaryReport`. */
|
|
623
|
+
export declare interface BoundaryReportArguments {
|
|
624
|
+
readonly judgedProjects: readonly string[];
|
|
625
|
+
readonly outcome: BoundaryCheckOutcome;
|
|
626
|
+
}
|
|
627
|
+
|
|
628
|
+
/** One container failure in a `BoundaryReport`. */
|
|
629
|
+
export declare interface BoundaryReportFailure {
|
|
630
|
+
readonly error: string;
|
|
631
|
+
readonly level: CodependixBoundaryLevel;
|
|
632
|
+
/** Present only when the failing code belongs to another project. */
|
|
633
|
+
readonly ownerProject?: string;
|
|
634
|
+
readonly projects: readonly string[];
|
|
635
|
+
readonly verdict: BoundaryVerdict;
|
|
636
|
+
}
|
|
637
|
+
|
|
441
638
|
/**
|
|
442
639
|
* Renders violations into the lines a run prints.
|
|
443
640
|
*
|
|
@@ -450,6 +647,24 @@ export declare interface BoundaryNode {
|
|
|
450
647
|
*/
|
|
451
648
|
export declare class BoundaryReportService {
|
|
452
649
|
constructor();
|
|
650
|
+
/**
|
|
651
|
+
* Who a finding is charged to, as the lines and the Markdown report word it.
|
|
652
|
+
*
|
|
653
|
+
* The one place that wording lives: a violation and a failure are both
|
|
654
|
+
* reported as a note when they live only in a dependency, and a reader who
|
|
655
|
+
* sees the phrase in one report should find it unchanged in the other.
|
|
656
|
+
* Says "in dependency" because the finding is real, and inherited, but it is
|
|
657
|
+
* not theirs to fix and it did not fail their run.
|
|
658
|
+
*/
|
|
659
|
+
describeCharge(args: {
|
|
660
|
+
isNote: boolean;
|
|
661
|
+
projects: readonly string[];
|
|
662
|
+
}): string;
|
|
663
|
+
/**
|
|
664
|
+
* One line per note — a violation charged only to a dependency of the
|
|
665
|
+
* projects a run judges — marked as not failing.
|
|
666
|
+
*/
|
|
667
|
+
renderNotes(violations: readonly BoundaryViolation[]): string[];
|
|
453
668
|
/**
|
|
454
669
|
* One line summarizing what a run found.
|
|
455
670
|
*
|
|
@@ -459,16 +674,31 @@ export declare class BoundaryReportService {
|
|
|
459
674
|
*/
|
|
460
675
|
renderSummary(violations: readonly BoundaryViolation[]): string;
|
|
461
676
|
/**
|
|
462
|
-
* One line per violation, each naming its level and
|
|
463
|
-
* own sentence.
|
|
677
|
+
* One line per violation, each naming its level and the projects it is
|
|
678
|
+
* charged to before the rule's own sentence.
|
|
464
679
|
*
|
|
465
|
-
* The level and
|
|
466
|
-
* rule evaluated at file level fails once per project, and a bare pair
|
|
467
|
-
* file paths does not say whose files they are.
|
|
680
|
+
* The level and projects lead because the message cannot carry them: the
|
|
681
|
+
* same rule evaluated at file level fails once per project, and a bare pair
|
|
682
|
+
* of file paths does not say whose files they are. Charged projects rather
|
|
683
|
+
* than the graph's scope, so an Nx-level finding names the projects that
|
|
684
|
+
* own it rather than the workspace it was found in.
|
|
468
685
|
*/
|
|
469
686
|
renderViolations(violations: readonly BoundaryViolation[]): string[];
|
|
470
687
|
}
|
|
471
688
|
|
|
689
|
+
/** One rule violation in a `BoundaryReport`. */
|
|
690
|
+
export declare interface BoundaryReportViolation {
|
|
691
|
+
/** The whole cycle for an `acyclic` rule, and `null` for an access rule. */
|
|
692
|
+
readonly cycle: null | readonly string[];
|
|
693
|
+
readonly level: CodependixBoundaryLevel;
|
|
694
|
+
readonly message: string;
|
|
695
|
+
readonly projects: readonly string[];
|
|
696
|
+
readonly rule: string;
|
|
697
|
+
readonly source: string;
|
|
698
|
+
readonly target: string;
|
|
699
|
+
readonly verdict: BoundaryVerdict;
|
|
700
|
+
}
|
|
701
|
+
|
|
472
702
|
/**
|
|
473
703
|
* Decides which nodes a rule's selector claims.
|
|
474
704
|
*
|
|
@@ -517,6 +747,16 @@ export declare class BoundarySelectorService {
|
|
|
517
747
|
selectIds(nodes: readonly BoundaryNode[], selector: CodependixBoundarySelector | undefined): Set<string>;
|
|
518
748
|
}
|
|
519
749
|
|
|
750
|
+
/**
|
|
751
|
+
* Whether a finding fails the run, or is reported as a note against the
|
|
752
|
+
* dependency it lives in.
|
|
753
|
+
*
|
|
754
|
+
* `"fail"` when a charged project is one the run judges; `"note"` when every
|
|
755
|
+
* charged project is only in the build set — a dependency the judged
|
|
756
|
+
* projects are built from, whose finding they inherit but cannot fix.
|
|
757
|
+
*/
|
|
758
|
+
export declare type BoundaryVerdict = "fail" | "note";
|
|
759
|
+
|
|
520
760
|
/** One edge, or one cycle, breaking one declared rule. */
|
|
521
761
|
export declare interface BoundaryViolation {
|
|
522
762
|
/**
|
|
@@ -529,6 +769,14 @@ export declare interface BoundaryViolation {
|
|
|
529
769
|
readonly level: CodependixBoundaryLevel;
|
|
530
770
|
/** The sentence reported, whether the rule's own or the generated one. */
|
|
531
771
|
readonly message: string;
|
|
772
|
+
/**
|
|
773
|
+
* The projects this violation is charged to, sorted: an access rule's
|
|
774
|
+
* edge source's project, or every project owning a node on a cycle.
|
|
775
|
+
*
|
|
776
|
+
* What decides whether it fails a run — it does when any of these is a
|
|
777
|
+
* project the run judges — see `BoundaryCheckService.run`.
|
|
778
|
+
*/
|
|
779
|
+
readonly projects: readonly string[];
|
|
532
780
|
/** The `name` of the rule that reported it. */
|
|
533
781
|
readonly rule: string;
|
|
534
782
|
readonly scope: string;
|
|
@@ -547,6 +795,21 @@ export declare interface BoundaryViolation {
|
|
|
547
795
|
*/
|
|
548
796
|
declare type CodependixBoundaryLevel = "nestjsModules" | "nxProjects" | "python" | "typescript";
|
|
549
797
|
|
|
798
|
+
/** Arguments accepted when collecting one graph's failure. */
|
|
799
|
+
export declare interface CollectFailureArguments {
|
|
800
|
+
readonly error: unknown;
|
|
801
|
+
/**
|
|
802
|
+
* The whole Nx project graph, rather than the build set, so an owner is
|
|
803
|
+
* still found in a dependency `--no-dependencies` left out of the build.
|
|
804
|
+
*/
|
|
805
|
+
readonly graph: NxProjectGraph;
|
|
806
|
+
readonly level: CodependixBoundaryLevel;
|
|
807
|
+
/** The projects the failing graph was being built for. */
|
|
808
|
+
readonly projects: readonly string[];
|
|
809
|
+
/** Every project the workspace knows, for resolving the failure's owner. */
|
|
810
|
+
readonly workspaceProjects: readonly NxProject[];
|
|
811
|
+
}
|
|
812
|
+
|
|
550
813
|
/** How a cycle's nodes are joined when one is reported. */
|
|
551
814
|
export declare const CYCLE_SEPARATOR = " \u2192 ";
|
|
552
815
|
|
|
@@ -607,6 +870,16 @@ export declare interface FindCyclesArguments {
|
|
|
607
870
|
* at the call site.
|
|
608
871
|
*/
|
|
609
872
|
export declare interface GraphRunContext {
|
|
873
|
+
/**
|
|
874
|
+
* The projects every boundary graph is built over: `selectedProjects`'
|
|
875
|
+
* dependency closure in the Nx project graph, or `selectedProjects` alone
|
|
876
|
+
* under `--no-dependencies`.
|
|
877
|
+
*
|
|
878
|
+
* Wider than what is judged, so a finding a selected project inherits from
|
|
879
|
+
* a dependency is still found — and reported as a note against that
|
|
880
|
+
* dependency rather than failing the run. Exports never read this.
|
|
881
|
+
*/
|
|
882
|
+
buildProjects: NxProject[];
|
|
610
883
|
configuration: ResolvedCodependixConfiguration;
|
|
611
884
|
/**
|
|
612
885
|
* The graph types this run builds, checks, and writes.
|
|
@@ -633,7 +906,8 @@ export declare interface GraphRunContext {
|
|
|
633
906
|
/** Every project the graph knows, apart from the workspace root. */
|
|
634
907
|
projects: NxProject[];
|
|
635
908
|
/**
|
|
636
|
-
* The projects `--projects` and `--tags` narrowed the run to
|
|
909
|
+
* The projects `--projects` and `--tags` narrowed the run to — the set the
|
|
910
|
+
* boundary gate judges, and the set the Workspace Graph is drawn over.
|
|
637
911
|
*
|
|
638
912
|
* Identical to `projects` when a run named neither, which is what keeps the
|
|
639
913
|
* Workspace Graph whole and the boundary gate judging every project by
|
|
@@ -644,6 +918,11 @@ export declare interface GraphRunContext {
|
|
|
644
918
|
workingDirectory: string;
|
|
645
919
|
}
|
|
646
920
|
|
|
921
|
+
/** A violation or failure, with the verdict the run reached on it. */
|
|
922
|
+
export declare type JudgedBoundaryFinding<Finding> = Finding & {
|
|
923
|
+
readonly verdict: BoundaryVerdict;
|
|
924
|
+
};
|
|
925
|
+
|
|
647
926
|
/** Arguments accepted when judging one graph level against its rules. */
|
|
648
927
|
export declare interface LevelCheckArguments {
|
|
649
928
|
readonly context: BoundaryCheckContext;
|
|
@@ -681,6 +960,18 @@ export declare class RunContextService {
|
|
|
681
960
|
* `undefined` for the ones naming none.
|
|
682
961
|
*/
|
|
683
962
|
private loadProjectConfigurations;
|
|
963
|
+
/**
|
|
964
|
+
* Widens the selected projects to the set every boundary graph is built
|
|
965
|
+
* over: their dependency closure, or the selection alone under
|
|
966
|
+
* `--no-dependencies`.
|
|
967
|
+
*
|
|
968
|
+
* Only the selection is judged. The rest of the closure is built so a
|
|
969
|
+
* finding the selected projects inherit from a dependency can be reported
|
|
970
|
+
* against it as a note, and so an Nx edge leaving the selection is still
|
|
971
|
+
* drawn. With no selection every project is selected, and the closure of
|
|
972
|
+
* every project is every project.
|
|
973
|
+
*/
|
|
974
|
+
private resolveBuildProjects;
|
|
684
975
|
/**
|
|
685
976
|
* Reads the three graph-type toggle flags into the set of graph types this
|
|
686
977
|
* run builds, checks, and writes.
|
|
@@ -699,6 +990,15 @@ export declare class RunContextService {
|
|
|
699
990
|
* resolve underneath it too.
|
|
700
991
|
*/
|
|
701
992
|
private resolveProjectGraphPath;
|
|
993
|
+
/**
|
|
994
|
+
* Resolves the two project sets a run acts on: the selection it judges,
|
|
995
|
+
* and the build set every boundary graph is drawn over.
|
|
996
|
+
*
|
|
997
|
+
* A `--projects`/`--tags` selection matching no project is refused here,
|
|
998
|
+
* before any pass runs — see `emptySelectionError`. No selection at all
|
|
999
|
+
* selects every project, so only a named one can come back empty.
|
|
1000
|
+
*/
|
|
1001
|
+
private resolveProjectSets;
|
|
702
1002
|
/**
|
|
703
1003
|
* Narrows every project to the set `--projects` and `--tags` named.
|
|
704
1004
|
*
|
|
@@ -725,11 +1025,13 @@ export declare class RunContextService {
|
|
|
725
1025
|
}
|
|
726
1026
|
|
|
727
1027
|
/**
|
|
728
|
-
* The scope
|
|
729
|
-
*
|
|
1028
|
+
* The `scope` of the whole-workspace Nx graph — what the graph covers, not
|
|
1029
|
+
* who a finding in it is charged to.
|
|
730
1030
|
*
|
|
731
|
-
* The Nx level is
|
|
732
|
-
* project, so
|
|
1031
|
+
* The Nx level is built once for the repository rather than once per
|
|
1032
|
+
* project, so its graph has no one project to name. Each finding in it is
|
|
1033
|
+
* charged to the projects owning its nodes instead — see
|
|
1034
|
+
* `BoundariesService.chargeProjects`.
|
|
733
1035
|
*/
|
|
734
1036
|
export declare const WORKSPACE_SCOPE = "workspace";
|
|
735
1037
|
|