@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.js
CHANGED
|
@@ -3,9 +3,10 @@ import n from "node:path";
|
|
|
3
3
|
import { PythonModule as r, PythonService as i, TypescriptModule as a, TypescriptService as o } from "@codependix/file-imports";
|
|
4
4
|
import { ModuleGraphModule as s, ModuleGraphService as c, NestjsProjectModule as l, NestjsProjectService as u } from "@codependix/nestjs-modules";
|
|
5
5
|
import { NeighborhoodModule as d, NeighborhoodService as f, WorkspaceGraphModule as p, WorkspaceGraphService as m } from "@codependix/nx-projects";
|
|
6
|
-
import {
|
|
6
|
+
import { fileURLToPath as h } from "node:url";
|
|
7
|
+
import { CODEPENDIX_GRAPH_TYPES as g, ConfigurationModule as _, ConfigurationService as v, InputError as y } from "@codependix/configuration";
|
|
7
8
|
//#region \0rolldown/runtime.js
|
|
8
|
-
var
|
|
9
|
+
var b = " → ", describeCycle = (e) => `${e.rule}: ${e.cycle.join(b)} is a cycle.`, describeDisallowedEdge = (e) => `${e.rule}: ${e.source} may not depend on ${e.target}, which the rule's allowed targets do not cover.`, describeForbiddenEdge = (e) => `${e.rule}: ${e.source} must not depend on ${e.target}.`;
|
|
9
10
|
//#endregion
|
|
10
11
|
//#region \0@oxc-project+runtime@0.151.0/helpers/esm/decorateMetadata.js
|
|
11
12
|
function __decorateMetadata(e, t) {
|
|
@@ -21,7 +22,7 @@ function __decorate(e, t, n, r) {
|
|
|
21
22
|
}
|
|
22
23
|
//#endregion
|
|
23
24
|
//#region packages/ic-suite/codependix/codependix-boundaries/src/modules/boundaries/boundary-cycles.service.ts
|
|
24
|
-
var
|
|
25
|
+
var x = class BoundaryCyclesService {
|
|
25
26
|
constructor() {}
|
|
26
27
|
buildAdjacency(e) {
|
|
27
28
|
let t = /* @__PURE__ */ new Map();
|
|
@@ -80,10 +81,10 @@ var y = class BoundaryCyclesService {
|
|
|
80
81
|
return n.cycles;
|
|
81
82
|
}
|
|
82
83
|
};
|
|
83
|
-
|
|
84
|
+
x = __decorate([e(), __decorateMetadata("design:paramtypes", [])], x);
|
|
84
85
|
//#endregion
|
|
85
86
|
//#region packages/ic-suite/codependix/codependix-boundaries/src/modules/boundaries/boundary-selector.service.ts
|
|
86
|
-
var
|
|
87
|
+
var S = class BoundarySelectorService {
|
|
87
88
|
constructor() {}
|
|
88
89
|
matchesGlobs(e, t) {
|
|
89
90
|
return t === void 0 || e !== void 0 && t.some((t) => n.matchesGlob(e, t));
|
|
@@ -98,29 +99,34 @@ var b = class BoundarySelectorService {
|
|
|
98
99
|
return t === void 0 ? new Set(e.map((e) => e.id)) : new Set(e.filter((e) => this.matches(e, t)).map((e) => e.id));
|
|
99
100
|
}
|
|
100
101
|
};
|
|
101
|
-
|
|
102
|
+
S = __decorate([e(), __decorateMetadata("design:paramtypes", [])], S);
|
|
102
103
|
//#endregion
|
|
103
104
|
//#region packages/ic-suite/codependix/codependix-boundaries/src/modules/boundaries/boundaries.service.ts
|
|
104
|
-
var
|
|
105
|
+
var C = class BoundariesService {
|
|
105
106
|
cyclesService;
|
|
106
107
|
selectorService;
|
|
107
108
|
constructor(e, t) {
|
|
108
109
|
this.cyclesService = e, this.selectorService = t;
|
|
109
110
|
}
|
|
110
111
|
buildAccessViolation(e) {
|
|
111
|
-
let { edge: t, graph: n,
|
|
112
|
+
let { edge: t, graph: n, nodes: r, rule: i } = e, a = i.kind === "forbid" ? describeForbiddenEdge : describeDisallowedEdge;
|
|
112
113
|
return {
|
|
113
114
|
cycle: void 0,
|
|
114
115
|
level: n.level,
|
|
115
116
|
message: this.buildMessage({
|
|
116
|
-
generated:
|
|
117
|
-
rule:
|
|
117
|
+
generated: a({
|
|
118
|
+
rule: i.name,
|
|
118
119
|
source: t.source,
|
|
119
120
|
target: t.target
|
|
120
121
|
}),
|
|
121
|
-
message:
|
|
122
|
+
message: i.message
|
|
123
|
+
}),
|
|
124
|
+
projects: this.chargeProjects({
|
|
125
|
+
graph: n,
|
|
126
|
+
ids: [t.source],
|
|
127
|
+
nodes: r
|
|
122
128
|
}),
|
|
123
|
-
rule:
|
|
129
|
+
rule: i.name,
|
|
124
130
|
scope: n.scope,
|
|
125
131
|
source: t.source,
|
|
126
132
|
target: t.target
|
|
@@ -129,6 +135,9 @@ var x = class BoundariesService {
|
|
|
129
135
|
buildMessage(e) {
|
|
130
136
|
return e.message === void 0 ? e.generated : `${e.generated} ${e.message}`;
|
|
131
137
|
}
|
|
138
|
+
chargeProjects(e) {
|
|
139
|
+
return [...new Set(e.ids.map((t) => this.resolveNode(e.nodes, t).project ?? e.graph.scope))].toSorted((e, t) => e.localeCompare(t));
|
|
140
|
+
}
|
|
132
141
|
evaluateAccessRule(e) {
|
|
133
142
|
let { graph: t, rule: n } = e, r = this.indexNodes(t), i = [];
|
|
134
143
|
for (let e of t.edges) {
|
|
@@ -142,16 +151,17 @@ var x = class BoundariesService {
|
|
|
142
151
|
this.selectorService.matches(o, n.to) === (n.kind === "forbid") && i.push(this.buildAccessViolation({
|
|
143
152
|
edge: e,
|
|
144
153
|
graph: t,
|
|
154
|
+
nodes: r,
|
|
145
155
|
rule: n
|
|
146
156
|
}));
|
|
147
157
|
}
|
|
148
158
|
return i;
|
|
149
159
|
}
|
|
150
160
|
evaluateAcyclicRule(e) {
|
|
151
|
-
let { graph: t, rule: n } = e, r = this.selectorService.selectIds(t.nodes, n.nodes);
|
|
161
|
+
let { graph: t, rule: n } = e, r = this.indexNodes(t), i = this.selectorService.selectIds(t.nodes, n.nodes);
|
|
152
162
|
return this.cyclesService.findCycles({
|
|
153
163
|
edges: t.edges,
|
|
154
|
-
nodeIds:
|
|
164
|
+
nodeIds: i
|
|
155
165
|
}).map((e) => ({
|
|
156
166
|
cycle: e.path,
|
|
157
167
|
level: t.level,
|
|
@@ -162,6 +172,11 @@ var x = class BoundariesService {
|
|
|
162
172
|
}),
|
|
163
173
|
message: n.message
|
|
164
174
|
}),
|
|
175
|
+
projects: this.chargeProjects({
|
|
176
|
+
graph: t,
|
|
177
|
+
ids: e.path,
|
|
178
|
+
nodes: r
|
|
179
|
+
}),
|
|
165
180
|
rule: n.name,
|
|
166
181
|
scope: t.scope,
|
|
167
182
|
source: e.source,
|
|
@@ -188,48 +203,99 @@ var x = class BoundariesService {
|
|
|
188
203
|
}));
|
|
189
204
|
}
|
|
190
205
|
};
|
|
191
|
-
|
|
206
|
+
C = __decorate([e(), __decorateMetadata("design:paramtypes", [x === void 0 ? Object : x, S === void 0 ? Object : S])], C);
|
|
192
207
|
//#endregion
|
|
193
208
|
//#region packages/ic-suite/codependix/codependix-boundaries/src/modules/boundaries/boundary-report.service.ts
|
|
194
|
-
var
|
|
209
|
+
var w = class BoundaryReportService {
|
|
195
210
|
constructor() {}
|
|
211
|
+
describeCharge(e) {
|
|
212
|
+
let t = e.projects.join(", ");
|
|
213
|
+
return e.isNote ? `in dependency ${t}, not failing` : t;
|
|
214
|
+
}
|
|
215
|
+
renderNotes(e) {
|
|
216
|
+
return e.map((e) => `${e.level} ${this.describeCharge({
|
|
217
|
+
isNote: !0,
|
|
218
|
+
projects: e.projects
|
|
219
|
+
})}: ${e.message}`);
|
|
220
|
+
}
|
|
196
221
|
renderSummary(e) {
|
|
197
222
|
if (e.length === 0) return "No boundary violations.";
|
|
198
223
|
let t = new Set(e.map((e) => e.rule)), n = e.length === 1 ? "violation" : "violations", r = t.size === 1 ? "rule" : "rules";
|
|
199
224
|
return `${e.length} boundary ${n} across ${t.size} ${r}.`;
|
|
200
225
|
}
|
|
201
226
|
renderViolations(e) {
|
|
202
|
-
return e.map((e) => `${e.level} ${
|
|
227
|
+
return e.map((e) => `${e.level} ${this.describeCharge({
|
|
228
|
+
isNote: !1,
|
|
229
|
+
projects: e.projects
|
|
230
|
+
})}: ${e.message}`);
|
|
203
231
|
}
|
|
204
232
|
};
|
|
205
|
-
|
|
233
|
+
w = __decorate([e(), __decorateMetadata("design:paramtypes", [])], w);
|
|
206
234
|
//#endregion
|
|
207
235
|
//#region packages/ic-suite/codependix/codependix-boundaries/src/modules/boundaries/boundaries.module.ts
|
|
208
|
-
var
|
|
209
|
-
|
|
236
|
+
var T = class BoundariesModule {};
|
|
237
|
+
T = __decorate([t({
|
|
210
238
|
controllers: [],
|
|
211
239
|
exports: [
|
|
240
|
+
C,
|
|
212
241
|
x,
|
|
213
|
-
|
|
214
|
-
S
|
|
215
|
-
b
|
|
242
|
+
w,
|
|
243
|
+
S
|
|
216
244
|
],
|
|
217
245
|
imports: [],
|
|
218
246
|
providers: [
|
|
247
|
+
C,
|
|
219
248
|
x,
|
|
220
|
-
|
|
221
|
-
S
|
|
222
|
-
b
|
|
249
|
+
w,
|
|
250
|
+
S
|
|
223
251
|
]
|
|
224
|
-
})],
|
|
252
|
+
})], T);
|
|
225
253
|
//#endregion
|
|
226
254
|
//#region packages/ic-suite/codependix/codependix-boundaries/src/modules/boundary-check/boundary-check.constants.ts
|
|
227
|
-
var
|
|
255
|
+
var E = "workspace", D = [
|
|
228
256
|
"nxProjects",
|
|
229
257
|
"nestjsModules",
|
|
230
258
|
"typescript",
|
|
231
259
|
"python"
|
|
232
|
-
],
|
|
260
|
+
], O = /^\d+$/u, k = `${n.sep}node_modules${n.sep}`, A = class BoundaryFailureService {
|
|
261
|
+
neighborhoodService;
|
|
262
|
+
constructor(e) {
|
|
263
|
+
this.neighborhoodService = e;
|
|
264
|
+
}
|
|
265
|
+
findProjectHolding(e, t) {
|
|
266
|
+
if (!e.includes(k)) return t.filter((t) => e.startsWith(`${t.absoluteRoot}${n.sep}`)).toSorted((e, t) => t.absoluteRoot.length - e.absoluteRoot.length)[0]?.name;
|
|
267
|
+
}
|
|
268
|
+
readFrameLocation(e) {
|
|
269
|
+
let t = e.trim();
|
|
270
|
+
if (!t.startsWith("at ")) return;
|
|
271
|
+
let n = t.slice(3), r = n.endsWith(")") ? n.slice(n.lastIndexOf("(") + 1, -1) : n, i = r.lastIndexOf(":"), a = r.lastIndexOf(":", i - 1);
|
|
272
|
+
return a > 0 && O.test(r.slice(a + 1, i)) && O.test(r.slice(i + 1)) ? r.slice(0, a) : void 0;
|
|
273
|
+
}
|
|
274
|
+
readFramePath(e) {
|
|
275
|
+
let t = this.readFrameLocation(e);
|
|
276
|
+
return t?.startsWith("file:") === !0 ? h(t) : t !== void 0 && n.isAbsolute(t) ? t : void 0;
|
|
277
|
+
}
|
|
278
|
+
resolveOwnerProject(e) {
|
|
279
|
+
let t = new Set(this.neighborhoodService.resolveDependencyClosure(e.graph, e.projects)), n = e.workspaceProjects.filter((e) => t.has(e.name)), r = e.error instanceof Error ? e.error.stack ?? "" : "";
|
|
280
|
+
for (let e of r.split("\n")) {
|
|
281
|
+
let t = this.readFramePath(e), r = t === void 0 ? void 0 : this.findProjectHolding(t, n);
|
|
282
|
+
if (r !== void 0) return r;
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
collect(e) {
|
|
286
|
+
let t = this.resolveOwnerProject(e);
|
|
287
|
+
return {
|
|
288
|
+
error: e.error instanceof Error ? e.error.message : String(e.error),
|
|
289
|
+
level: e.level,
|
|
290
|
+
...t !== void 0 && !e.projects.includes(t) && { ownerProject: t },
|
|
291
|
+
projects: e.projects
|
|
292
|
+
};
|
|
293
|
+
}
|
|
294
|
+
};
|
|
295
|
+
A = __decorate([e(), __decorateMetadata("design:paramtypes", [f === void 0 ? Object : f])], A);
|
|
296
|
+
//#endregion
|
|
297
|
+
//#region packages/ic-suite/codependix/codependix-boundaries/src/modules/boundary-check/boundary-graph.service.ts
|
|
298
|
+
var j = class BoundaryGraphService {
|
|
233
299
|
constructor() {}
|
|
234
300
|
buildFileNodes(e) {
|
|
235
301
|
return e.fileNames.map((t) => ({
|
|
@@ -290,25 +356,20 @@ var w = "workspace", T = [
|
|
|
290
356
|
};
|
|
291
357
|
}
|
|
292
358
|
};
|
|
293
|
-
|
|
359
|
+
j = __decorate([e(), __decorateMetadata("design:paramtypes", [])], j);
|
|
294
360
|
//#endregion
|
|
295
361
|
//#region packages/ic-suite/codependix/codependix-boundaries/src/modules/boundary-check/boundary-check.service.ts
|
|
296
|
-
var
|
|
362
|
+
var M = class BoundaryCheckService {
|
|
297
363
|
boundariesService;
|
|
364
|
+
boundaryFailureService;
|
|
298
365
|
boundaryGraphService;
|
|
299
366
|
moduleGraphService;
|
|
300
367
|
nestjsProjectService;
|
|
301
368
|
pythonService;
|
|
302
369
|
typescriptService;
|
|
303
370
|
workspaceGraphService;
|
|
304
|
-
constructor(e, t, n, r, i, a, o) {
|
|
305
|
-
this.boundariesService = e, this.
|
|
306
|
-
}
|
|
307
|
-
collectProjectFailure(e, t) {
|
|
308
|
-
return {
|
|
309
|
-
error: t instanceof Error ? t.message : String(t),
|
|
310
|
-
projectName: e
|
|
311
|
-
};
|
|
371
|
+
constructor(e, t, n, r, i, a, o, s) {
|
|
372
|
+
this.boundariesService = e, this.boundaryFailureService = t, this.boundaryGraphService = n, this.moduleGraphService = r, this.nestjsProjectService = i, this.pythonService = a, this.typescriptService = o, this.workspaceGraphService = s;
|
|
312
373
|
}
|
|
313
374
|
graphTypeForLevel(e) {
|
|
314
375
|
return {
|
|
@@ -318,6 +379,22 @@ var D = class BoundaryCheckService {
|
|
|
318
379
|
typescript: "fileImports"
|
|
319
380
|
}[e];
|
|
320
381
|
}
|
|
382
|
+
judge(e, t) {
|
|
383
|
+
let n = new Set(t.selectedProjects.map((e) => e.name));
|
|
384
|
+
return {
|
|
385
|
+
failures: e.failures.map((e) => ({
|
|
386
|
+
...e,
|
|
387
|
+
verdict: this.resolveVerdict(e.projects, n)
|
|
388
|
+
})),
|
|
389
|
+
violations: e.violations.map((e) => ({
|
|
390
|
+
...e,
|
|
391
|
+
verdict: this.resolveVerdict(e.projects, n)
|
|
392
|
+
}))
|
|
393
|
+
};
|
|
394
|
+
}
|
|
395
|
+
resolveVerdict(e, t) {
|
|
396
|
+
return e.some((e) => t.has(e)) ? "fail" : "note";
|
|
397
|
+
}
|
|
321
398
|
rulesForLevel(e, t) {
|
|
322
399
|
return {
|
|
323
400
|
nestjsModules: e.nestjsModules,
|
|
@@ -337,66 +414,78 @@ var D = class BoundaryCheckService {
|
|
|
337
414
|
async runNestjsLevel(e) {
|
|
338
415
|
return this.runProjectLevel({
|
|
339
416
|
buildGraph: async (e) => this.boundaryGraphService.buildNestjsGraph(this.moduleGraphService.buildGraph(await this.nestjsProjectService.exploreProject(e), e.name)),
|
|
340
|
-
|
|
341
|
-
|
|
417
|
+
levelArguments: e,
|
|
418
|
+
projects: this.nestjsProjectService.discoverProjects(e.context.buildProjects)
|
|
342
419
|
});
|
|
343
420
|
}
|
|
344
421
|
runNxLevel(e) {
|
|
345
|
-
let { context: t,
|
|
422
|
+
let { context: t, level: n, rules: r } = e;
|
|
346
423
|
try {
|
|
347
424
|
let e = this.boundaryGraphService.buildNxGraph({
|
|
348
|
-
projects: t.
|
|
349
|
-
scope:
|
|
425
|
+
projects: t.buildProjects,
|
|
426
|
+
scope: E,
|
|
350
427
|
workingDirectory: t.workingDirectory,
|
|
351
|
-
workspaceGraph: this.workspaceGraphService.buildWorkspaceGraph(t.graph, t.
|
|
428
|
+
workspaceGraph: this.workspaceGraphService.buildWorkspaceGraph(t.graph, t.buildProjects)
|
|
352
429
|
});
|
|
353
430
|
return {
|
|
354
431
|
failures: [],
|
|
355
432
|
violations: this.boundariesService.evaluate({
|
|
356
433
|
graph: e,
|
|
357
|
-
rules:
|
|
434
|
+
rules: r
|
|
358
435
|
})
|
|
359
436
|
};
|
|
360
437
|
} catch (e) {
|
|
361
438
|
return {
|
|
362
|
-
failures: [this.
|
|
439
|
+
failures: [this.boundaryFailureService.collect({
|
|
440
|
+
error: e,
|
|
441
|
+
graph: t.graph,
|
|
442
|
+
level: n,
|
|
443
|
+
projects: t.selectedProjects.map((e) => e.name),
|
|
444
|
+
workspaceProjects: t.projects
|
|
445
|
+
})],
|
|
363
446
|
violations: []
|
|
364
447
|
};
|
|
365
448
|
}
|
|
366
449
|
}
|
|
367
450
|
async runProjectLevel(e) {
|
|
368
|
-
let t = [],
|
|
369
|
-
for (let
|
|
370
|
-
let t = await e.buildGraph(
|
|
371
|
-
|
|
451
|
+
let { context: t, level: n, rules: r } = e.levelArguments, i = [], a = [];
|
|
452
|
+
for (let o of e.projects) try {
|
|
453
|
+
let t = await e.buildGraph(o);
|
|
454
|
+
a.push(...this.boundariesService.evaluate({
|
|
372
455
|
graph: t,
|
|
373
|
-
rules:
|
|
456
|
+
rules: r
|
|
374
457
|
}));
|
|
375
458
|
} catch (e) {
|
|
376
|
-
|
|
459
|
+
i.push(this.boundaryFailureService.collect({
|
|
460
|
+
error: e,
|
|
461
|
+
graph: t.graph,
|
|
462
|
+
level: n,
|
|
463
|
+
projects: [o.name],
|
|
464
|
+
workspaceProjects: t.projects
|
|
465
|
+
}));
|
|
377
466
|
}
|
|
378
467
|
return {
|
|
379
|
-
failures:
|
|
380
|
-
violations:
|
|
468
|
+
failures: i,
|
|
469
|
+
violations: a
|
|
381
470
|
};
|
|
382
471
|
}
|
|
383
472
|
async runPythonImportsLevel(e) {
|
|
384
473
|
return this.runProjectLevel({
|
|
385
474
|
buildGraph: (e) => this.boundaryGraphService.buildPythonImportGraph(this.pythonService.buildGraph(e)),
|
|
386
|
-
|
|
387
|
-
|
|
475
|
+
levelArguments: e,
|
|
476
|
+
projects: this.pythonService.discoverProjects(e.context.buildProjects)
|
|
388
477
|
});
|
|
389
478
|
}
|
|
390
479
|
async runTypescriptImportsLevel(e) {
|
|
391
480
|
return this.runProjectLevel({
|
|
392
481
|
buildGraph: (e) => this.boundaryGraphService.buildTypescriptImportGraph(this.typescriptService.buildGraph(this.typescriptService.buildProgram(e))),
|
|
393
|
-
|
|
394
|
-
|
|
482
|
+
levelArguments: e,
|
|
483
|
+
projects: this.typescriptService.discoverProjects(e.context.buildProjects)
|
|
395
484
|
});
|
|
396
485
|
}
|
|
397
486
|
async run(e) {
|
|
398
487
|
let { boundaries: t } = e.configuration, n = [];
|
|
399
|
-
for (let r of
|
|
488
|
+
for (let r of D) {
|
|
400
489
|
if (!e.enabledGraphTypes.has(this.graphTypeForLevel(r))) continue;
|
|
401
490
|
let i = this.rulesForLevel(t, r);
|
|
402
491
|
i.length > 0 && n.push(await this.runLevel({
|
|
@@ -405,44 +494,122 @@ var D = class BoundaryCheckService {
|
|
|
405
494
|
rules: i
|
|
406
495
|
}));
|
|
407
496
|
}
|
|
408
|
-
return {
|
|
497
|
+
return this.judge({
|
|
409
498
|
failures: n.flatMap((e) => e.failures),
|
|
410
499
|
violations: n.flatMap((e) => e.violations)
|
|
411
|
-
};
|
|
500
|
+
}, e);
|
|
412
501
|
}
|
|
413
502
|
};
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
503
|
+
M = __decorate([e(), __decorateMetadata("design:paramtypes", [
|
|
504
|
+
C === void 0 ? Object : C,
|
|
505
|
+
A === void 0 ? Object : A,
|
|
506
|
+
j === void 0 ? Object : j,
|
|
417
507
|
c === void 0 ? Object : c,
|
|
418
508
|
u === void 0 ? Object : u,
|
|
419
509
|
i === void 0 ? Object : i,
|
|
420
510
|
o === void 0 ? Object : o,
|
|
421
511
|
m === void 0 ? Object : m
|
|
422
|
-
])],
|
|
512
|
+
])], M);
|
|
513
|
+
//#endregion
|
|
514
|
+
//#region packages/ic-suite/codependix/codependix-boundaries/src/modules/boundary-check/boundary-outcome-report.service.ts
|
|
515
|
+
var N = class BoundaryOutcomeReportService {
|
|
516
|
+
boundaryReportService;
|
|
517
|
+
constructor(e) {
|
|
518
|
+
this.boundaryReportService = e;
|
|
519
|
+
}
|
|
520
|
+
renderBullet(e, t) {
|
|
521
|
+
return `- **${e}** ${t}`;
|
|
522
|
+
}
|
|
523
|
+
renderFailure(e) {
|
|
524
|
+
let t = this.boundaryReportService.describeCharge({
|
|
525
|
+
isNote: e.verdict === "note",
|
|
526
|
+
projects: e.projects
|
|
527
|
+
}), n = e.ownerProject === void 0 ? "" : ` (failed in code owned by ${e.ownerProject})`;
|
|
528
|
+
return `${e.level} ${t}: ${e.error}${n}`;
|
|
529
|
+
}
|
|
530
|
+
renderProjectGroup(e) {
|
|
531
|
+
let { project: t, report: n } = e, r = [...n.violations.filter((e) => e.projects.includes(t)).map((e) => this.renderBullet(e.verdict, this.renderViolation(e))), ...n.failures.filter((e) => e.projects.includes(t)).map((e) => this.renderBullet(e.verdict, this.renderFailure(e)))];
|
|
532
|
+
return [
|
|
533
|
+
`#### ${t}`,
|
|
534
|
+
"",
|
|
535
|
+
...r
|
|
536
|
+
].join("\n");
|
|
537
|
+
}
|
|
538
|
+
renderViolation(e) {
|
|
539
|
+
let t = this.boundaryReportService.describeCharge({
|
|
540
|
+
isNote: e.verdict === "note",
|
|
541
|
+
projects: e.projects
|
|
542
|
+
});
|
|
543
|
+
return `${e.level} ${t}: ${e.message}`;
|
|
544
|
+
}
|
|
545
|
+
buildReport(e) {
|
|
546
|
+
return {
|
|
547
|
+
failures: e.outcome.failures.map((e) => ({
|
|
548
|
+
error: e.error,
|
|
549
|
+
level: e.level,
|
|
550
|
+
...e.ownerProject !== void 0 && { ownerProject: e.ownerProject },
|
|
551
|
+
projects: e.projects,
|
|
552
|
+
verdict: e.verdict
|
|
553
|
+
})),
|
|
554
|
+
judgedProjects: [...e.judgedProjects].toSorted(),
|
|
555
|
+
violations: e.outcome.violations.map((e) => ({
|
|
556
|
+
cycle: e.cycle ?? null,
|
|
557
|
+
level: e.level,
|
|
558
|
+
message: e.message,
|
|
559
|
+
projects: e.projects,
|
|
560
|
+
rule: e.rule,
|
|
561
|
+
source: e.source,
|
|
562
|
+
target: e.target,
|
|
563
|
+
verdict: e.verdict
|
|
564
|
+
}))
|
|
565
|
+
};
|
|
566
|
+
}
|
|
567
|
+
renderFailures(e) {
|
|
568
|
+
return e.map((e) => this.renderFailure(e));
|
|
569
|
+
}
|
|
570
|
+
renderMarkdown(e) {
|
|
571
|
+
let t = `Judged projects: ${e.judgedProjects.length === 0 ? "none" : e.judgedProjects.join(", ")}.`, n = [.../* @__PURE__ */ new Set([...e.violations.flatMap((e) => e.projects), ...e.failures.flatMap((e) => e.projects)])].toSorted();
|
|
572
|
+
return n.length === 0 ? `${t}\n\nNo boundary findings.` : [t, ...n.map((t) => this.renderProjectGroup({
|
|
573
|
+
project: t,
|
|
574
|
+
report: e
|
|
575
|
+
}))].join("\n\n");
|
|
576
|
+
}
|
|
577
|
+
};
|
|
578
|
+
N = __decorate([e(), __decorateMetadata("design:paramtypes", [w === void 0 ? Object : w])], N);
|
|
423
579
|
//#endregion
|
|
424
580
|
//#region packages/ic-suite/codependix/codependix-boundaries/src/modules/boundary-check/boundary-check.module.ts
|
|
425
|
-
var
|
|
426
|
-
|
|
581
|
+
var P = class BoundaryCheckModule {};
|
|
582
|
+
P = __decorate([t({
|
|
427
583
|
controllers: [],
|
|
428
584
|
exports: [
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
585
|
+
T,
|
|
586
|
+
M,
|
|
587
|
+
A,
|
|
588
|
+
j,
|
|
589
|
+
N
|
|
432
590
|
],
|
|
433
591
|
imports: [
|
|
434
|
-
|
|
592
|
+
T,
|
|
435
593
|
s,
|
|
594
|
+
d,
|
|
436
595
|
l,
|
|
437
596
|
r,
|
|
438
597
|
a,
|
|
439
598
|
p
|
|
440
599
|
],
|
|
441
|
-
providers: [
|
|
442
|
-
|
|
600
|
+
providers: [
|
|
601
|
+
M,
|
|
602
|
+
A,
|
|
603
|
+
j,
|
|
604
|
+
N
|
|
605
|
+
]
|
|
606
|
+
})], P);
|
|
443
607
|
//#endregion
|
|
444
|
-
//#region packages/ic-suite/codependix/codependix-boundaries/src/modules/run-context/run-context.
|
|
445
|
-
var
|
|
608
|
+
//#region packages/ic-suite/codependix/codependix-boundaries/src/modules/run-context/run-context.constants.ts
|
|
609
|
+
var emptySelectionError = (e) => {
|
|
610
|
+
let t = [...e.projects.length > 0 ? [`--projects ${e.projects.join(",")}`] : [], ...e.tags.length > 0 ? [`--tags ${e.tags.join(",")}`] : []];
|
|
611
|
+
return new y(`${t.join(" and ")} matched no project, so there is nothing to judge or draw.`);
|
|
612
|
+
}, F = class RunContextService {
|
|
446
613
|
configurationService;
|
|
447
614
|
neighborhoodService;
|
|
448
615
|
constructor(e, t) {
|
|
@@ -452,12 +619,28 @@ var k = class RunContextService {
|
|
|
452
619
|
let t = await Promise.all(e.map(async (e) => [e.name, await this.configurationService.loadProjectConfiguration({ projectRoot: e.absoluteRoot })]));
|
|
453
620
|
return new Map(t);
|
|
454
621
|
}
|
|
622
|
+
resolveBuildProjects(e) {
|
|
623
|
+
if (!e.configuration.selection.dependencies) return e.selectedProjects;
|
|
624
|
+
let t = new Set(this.neighborhoodService.resolveDependencyClosure(e.graph, e.selectedProjects.map((e) => e.name)));
|
|
625
|
+
return e.projects.filter((e) => t.has(e.name));
|
|
626
|
+
}
|
|
455
627
|
resolveEnabledGraphTypes(e) {
|
|
456
|
-
return new Set(
|
|
628
|
+
return new Set(g.filter((t) => e[t] !== !1));
|
|
457
629
|
}
|
|
458
630
|
resolveProjectGraphPath(e, t) {
|
|
459
631
|
return e === void 0 ? void 0 : n.resolve(t, e);
|
|
460
632
|
}
|
|
633
|
+
resolveProjectSets(e) {
|
|
634
|
+
let { selection: t } = e.configuration, n = this.selectProjects(e);
|
|
635
|
+
if (n.length === 0 && t.projects.length + t.tags.length > 0) throw emptySelectionError(t);
|
|
636
|
+
return {
|
|
637
|
+
buildProjects: this.resolveBuildProjects({
|
|
638
|
+
...e,
|
|
639
|
+
selectedProjects: n
|
|
640
|
+
}),
|
|
641
|
+
selectedProjects: n
|
|
642
|
+
};
|
|
643
|
+
}
|
|
461
644
|
selectProjects(e) {
|
|
462
645
|
return e.projects.filter((t) => this.configurationService.isProjectSelected({
|
|
463
646
|
configuration: e.configuration,
|
|
@@ -475,35 +658,37 @@ var k = class RunContextService {
|
|
|
475
658
|
},
|
|
476
659
|
searchDirectory: r,
|
|
477
660
|
selection: {
|
|
661
|
+
dependencies: n.dependencies,
|
|
478
662
|
projects: n.projects,
|
|
479
663
|
tags: n.tags
|
|
480
664
|
}
|
|
481
665
|
}), a = await this.neighborhoodService.readProjectGraph(this.resolveProjectGraphPath(i.projectGraph, r)), o = this.neighborhoodService.readProjects(a, r), s = await this.loadProjectConfigurations(o);
|
|
482
666
|
return {
|
|
667
|
+
...this.resolveProjectSets({
|
|
668
|
+
configuration: i,
|
|
669
|
+
graph: a,
|
|
670
|
+
projects: o,
|
|
671
|
+
workingDirectory: r
|
|
672
|
+
}),
|
|
483
673
|
configuration: i,
|
|
484
674
|
enabledGraphTypes: this.resolveEnabledGraphTypes(n),
|
|
485
675
|
graph: a,
|
|
486
676
|
mode: t,
|
|
487
677
|
projectConfigurations: s,
|
|
488
678
|
projects: o,
|
|
489
|
-
selectedProjects: this.selectProjects({
|
|
490
|
-
configuration: i,
|
|
491
|
-
projects: o,
|
|
492
|
-
workingDirectory: r
|
|
493
|
-
}),
|
|
494
679
|
workingDirectory: r
|
|
495
680
|
};
|
|
496
681
|
}
|
|
497
682
|
};
|
|
498
|
-
|
|
683
|
+
F = __decorate([e(), __decorateMetadata("design:paramtypes", [v === void 0 ? Object : v, f === void 0 ? Object : f])], F);
|
|
499
684
|
//#endregion
|
|
500
685
|
//#region packages/ic-suite/codependix/codependix-boundaries/src/modules/run-context/run-context.module.ts
|
|
501
|
-
var
|
|
502
|
-
|
|
686
|
+
var I = class RunContextModule {};
|
|
687
|
+
I = __decorate([t({
|
|
503
688
|
controllers: [],
|
|
504
|
-
exports: [
|
|
505
|
-
imports: [
|
|
506
|
-
providers: [
|
|
507
|
-
})],
|
|
689
|
+
exports: [F],
|
|
690
|
+
imports: [_, d],
|
|
691
|
+
providers: [F]
|
|
692
|
+
})], I);
|
|
508
693
|
//#endregion
|
|
509
|
-
export {
|
|
694
|
+
export { D as BOUNDARY_LEVEL_ORDER, T as BoundariesModule, C as BoundariesService, P as BoundaryCheckModule, M as BoundaryCheckService, x as BoundaryCyclesService, A as BoundaryFailureService, j as BoundaryGraphService, N as BoundaryOutcomeReportService, w as BoundaryReportService, S as BoundarySelectorService, b as CYCLE_SEPARATOR, I as RunContextModule, F as RunContextService, E as WORKSPACE_SCOPE, describeCycle, describeDisallowedEdge, describeForbiddenEdge };
|
package/package.json
CHANGED
|
@@ -4,11 +4,11 @@
|
|
|
4
4
|
"url": "https://github.com/organizzolini/codebase/issues"
|
|
5
5
|
},
|
|
6
6
|
"dependencies": {
|
|
7
|
-
"@codependix/configuration": "0.0.
|
|
7
|
+
"@codependix/configuration": "0.0.12",
|
|
8
8
|
"@codependix/core": "0.0.10",
|
|
9
9
|
"@codependix/file-imports": "0.0.10",
|
|
10
10
|
"@codependix/nestjs-modules": "0.0.10",
|
|
11
|
-
"@codependix/nx-projects": "0.0.
|
|
11
|
+
"@codependix/nx-projects": "0.0.11",
|
|
12
12
|
"@nestjs/common": "^11.1.21 || ^12.0.1",
|
|
13
13
|
"reflect-metadata": "^0.2.2"
|
|
14
14
|
},
|
|
@@ -62,5 +62,5 @@
|
|
|
62
62
|
"strict": true
|
|
63
63
|
},
|
|
64
64
|
"types": "./dist/src/index.d.ts",
|
|
65
|
-
"version": "0.0.
|
|
65
|
+
"version": "0.0.11"
|
|
66
66
|
}
|