dependency-cruiser 17.3.10 → 17.4.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/package.json +2 -2
- package/src/analyze/summarize/summarize-modules.mjs +2 -0
- package/src/cli/init-config/build-config.mjs +1 -1
- package/src/cli/init-config/check-and-warn-inconsistencies.mjs +111 -0
- package/src/cli/init-config/get-user-input.mjs +1 -1
- package/src/cli/init-config/index.mjs +6 -1
- package/src/cli/init-config/normalize-init-options.mjs +1 -1
- package/src/cli/init-config/types.d.mts +114 -0
- package/src/cli/init-config/write-run-scripts-to-manifest.mjs +1 -1
- package/src/extract/transpile/meta.mjs +32 -10
- package/src/meta.cjs +1 -1
- package/src/report/error-html/error-html-template.mjs +25 -0
- package/src/report/error-html/index.mjs +23 -10
- package/src/report/error-html/utl.mjs +9 -8
- package/src/report/error.mjs +20 -9
- package/src/report/markdown.mjs +8 -5
- package/src/report/utl/index.mjs +60 -0
- package/src/schema/configuration.validate.mjs +1 -1
- package/src/schema/cruise-result.validate.mjs +1 -1
- package/src/utl/try-import.mjs +0 -1
- package/types/reporter-options.d.mts +47 -2
- package/types/violations.d.mts +14 -2
package/src/report/markdown.mjs
CHANGED
|
@@ -22,6 +22,8 @@ const REPORT_DEFAULTS = {
|
|
|
22
22
|
detailsHeader: "### :fire: All violations",
|
|
23
23
|
collapseDetails: true,
|
|
24
24
|
collapsedMessage: "Violations found - click to expand",
|
|
25
|
+
showExternalModulesUnresolved: false,
|
|
26
|
+
showAliasedModulesUnresolved: false,
|
|
25
27
|
noViolationsMessage:
|
|
26
28
|
":revolving_hearts: No violations found. Get gummy bears to celebrate.",
|
|
27
29
|
|
|
@@ -84,20 +86,21 @@ function formatRulesSummary(pCruiseResult, pIncludeIgnoredInSummary) {
|
|
|
84
86
|
/**
|
|
85
87
|
*
|
|
86
88
|
* @param {import("../../types/cruise-result.mjs").IViolation[]} pViolations
|
|
87
|
-
* @param {
|
|
89
|
+
* @param {object} pOptions
|
|
88
90
|
* @return {string}
|
|
89
91
|
*/
|
|
90
|
-
function formatViolations(pViolations,
|
|
92
|
+
function formatViolations(pViolations, pOptions) {
|
|
91
93
|
const lTableHead = "|violated rule|module|to|\n|:---|:---|:---|\n";
|
|
92
94
|
|
|
93
95
|
return pViolations
|
|
94
96
|
.filter(
|
|
95
97
|
(pViolation) =>
|
|
96
|
-
pViolation.rule.severity !== "ignore" ||
|
|
98
|
+
pViolation.rule.severity !== "ignore" ||
|
|
99
|
+
pOptions.includeIgnoredInDetails,
|
|
97
100
|
)
|
|
98
101
|
.reduce((pAll, pViolation) => {
|
|
99
102
|
const lFromExtras = determineFromExtras(pViolation);
|
|
100
|
-
const lTo = determineTo(pViolation);
|
|
103
|
+
const lTo = determineTo(pViolation, pOptions);
|
|
101
104
|
|
|
102
105
|
return `${pAll}|${severity2Icon(pViolation.rule.severity)} _${
|
|
103
106
|
pViolation.rule.name
|
|
@@ -116,7 +119,7 @@ function details(pResults, pOptions) {
|
|
|
116
119
|
}
|
|
117
120
|
lReturnValue += `${formatViolations(
|
|
118
121
|
pResults.summary.violations,
|
|
119
|
-
pOptions
|
|
122
|
+
pOptions,
|
|
120
123
|
)}\n\n`;
|
|
121
124
|
if (pOptions.collapseDetails) {
|
|
122
125
|
lReturnValue += "</details>\n\n";
|
package/src/report/utl/index.mjs
CHANGED
|
@@ -14,9 +14,11 @@ export function formatViolation(
|
|
|
14
14
|
pViolation,
|
|
15
15
|
pViolationType2Formatter,
|
|
16
16
|
pDefaultFormatter,
|
|
17
|
+
pOptions,
|
|
17
18
|
) {
|
|
18
19
|
return (pViolationType2Formatter[pViolation.type] || pDefaultFormatter)(
|
|
19
20
|
pViolation,
|
|
21
|
+
pOptions,
|
|
20
22
|
);
|
|
21
23
|
}
|
|
22
24
|
|
|
@@ -105,3 +107,61 @@ export function getURLForModule(pModule, pPrefix, pSuffix) {
|
|
|
105
107
|
}
|
|
106
108
|
return pModule.source;
|
|
107
109
|
}
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
*
|
|
113
|
+
* @param {import("../../../types/shared-types.mjs").DependencyType[]} pDependencyTypes
|
|
114
|
+
* @returns {string}
|
|
115
|
+
*/
|
|
116
|
+
export function getOneLetterDependencyType(pDependencyTypes) {
|
|
117
|
+
if (pDependencyTypes) {
|
|
118
|
+
if (
|
|
119
|
+
pDependencyTypes.some((pDependencyType) =>
|
|
120
|
+
pDependencyType.startsWith("npm"),
|
|
121
|
+
)
|
|
122
|
+
) {
|
|
123
|
+
return "n";
|
|
124
|
+
}
|
|
125
|
+
if (pDependencyTypes.includes("aliased-subpath-import")) {
|
|
126
|
+
return "#";
|
|
127
|
+
}
|
|
128
|
+
if (pDependencyTypes.includes("aliased")) {
|
|
129
|
+
return "@";
|
|
130
|
+
}
|
|
131
|
+
if (pDependencyTypes.includes("core")) {
|
|
132
|
+
return "c";
|
|
133
|
+
}
|
|
134
|
+
if (pDependencyTypes.includes("export")) {
|
|
135
|
+
return "x";
|
|
136
|
+
}
|
|
137
|
+
if (pDependencyTypes.includes("local")) {
|
|
138
|
+
return ".";
|
|
139
|
+
}
|
|
140
|
+
if (
|
|
141
|
+
pDependencyTypes.some((pDependencyType) =>
|
|
142
|
+
pDependencyType.startsWith("type-"),
|
|
143
|
+
)
|
|
144
|
+
) {
|
|
145
|
+
return "T";
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
return "";
|
|
150
|
+
}
|
|
151
|
+
export function formatDependencyTo(pViolation, pOptions) {
|
|
152
|
+
if (pViolation.unresolvedTo) {
|
|
153
|
+
const lDependencyTypes = pViolation?.dependencyTypes ?? [];
|
|
154
|
+
const lShowUnresolvedExternal =
|
|
155
|
+
pOptions?.showExternalModulesUnresolved &&
|
|
156
|
+
lDependencyTypes.some((pDependencyType) =>
|
|
157
|
+
pDependencyType.startsWith("npm"),
|
|
158
|
+
);
|
|
159
|
+
const lShowUnresolvedAliased =
|
|
160
|
+
pOptions?.showAliasedModulesUnresolved &&
|
|
161
|
+
lDependencyTypes.includes("aliased");
|
|
162
|
+
return lShowUnresolvedExternal || lShowUnresolvedAliased
|
|
163
|
+
? pViolation.unresolvedTo
|
|
164
|
+
: pViolation.to;
|
|
165
|
+
}
|
|
166
|
+
return pViolation.to;
|
|
167
|
+
}
|