-
Notifications
You must be signed in to change notification settings - Fork 2
/
.dependency-cruiser.js
76 lines (70 loc) · 2 KB
/
.dependency-cruiser.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
// @ts-check
// workspaces must be defined in layer order
const workspaces = ["apps", "integrations", "libraries", "core", "incubations"];
const workspacesMayStillDependOn = {
incubations: ["^core/test/", "^core/build/"],
core: ["^libraries/validate/", "^libraries/result/"],
integrations: ["^apps/.*?-server/.*.graphql"],
};
/**
* @type {import("dependency-cruiser").IForbiddenRuleType[]}
*/
const forbidden = [];
for (let i = 0; i < workspaces.length; i++) {
const higher = workspaces.slice(0, i);
const ws = workspaces[i];
if (higher.length) {
const mayStillDependOn = workspacesMayStillDependOn[ws];
forbidden.push({
name: `forbidden-dependencies-for-${ws}`,
comment:
`${ws} may not depend on ${higher.join(", ")}` +
(mayStillDependOn ? ` (except ${mayStillDependOn.join(", ")})` : ""),
severity: "error",
from: { path: wsPath(ws) },
to: {
path: higher.map(wsPath),
pathNot: mayStillDependOn ? mayStillDependOn : undefined,
},
});
}
}
/**
* @type {import("dependency-cruiser").IConfiguration}
*/
const config = {
forbidden,
options: {
tsPreCompilationDeps: true,
exclude: ["node_modules", ".*/dist/.*"],
reporterOptions: {
archi: {
theme: {
graph: {
ranksep: false,
},
},
filters: {
includeOnly: { path: workspaces.map(wsPath) },
exclude: {
// Reason for hiding these:
// - incubations: about-to-be 3rd party packages, so not relevant to architecture.
// - core: used by almost every single package, so it's more distracting than informative to show these.
path: ["core", "incubations"].map(wsPath),
},
focus: {},
reaches: {},
},
collapsePattern: workspaces.map((ws) => `^${ws}/.*?/`),
},
},
},
};
/**
* @param {string} workspace
* @returns {string}
*/
function wsPath(workspace) {
return `^${workspace}/`;
}
module.exports = config;