dependency-cruiser 17.3.2 → 17.3.3-beta-2

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.
Files changed (232) hide show
  1. package/bin/depcruise-baseline.mjs +43 -43
  2. package/bin/depcruise-fmt.mjs +89 -89
  3. package/bin/dependency-cruise.mjs +171 -171
  4. package/configs/plugins/3d-reporter-plugin.mjs +36 -36
  5. package/configs/plugins/stats-reporter-plugin.mjs +51 -51
  6. package/configs/recommended-strict.cjs +5 -5
  7. package/configs/recommended-warn-only.cjs +5 -5
  8. package/configs/recommended.cjs +22 -22
  9. package/configs/rules/no-circular.cjs +10 -10
  10. package/configs/rules/no-deprecated-core.cjs +10 -10
  11. package/configs/rules/no-duplicate-dependency-types.cjs +17 -17
  12. package/configs/rules/no-non-package-json.cjs +11 -11
  13. package/configs/rules/no-orphans.cjs +18 -18
  14. package/configs/rules/not-to-deprecated.cjs +10 -10
  15. package/configs/rules/not-to-unresolvable.cjs +10 -10
  16. package/package.json +170 -170
  17. package/src/cache/cache.mjs +139 -139
  18. package/src/cache/content-strategy.mjs +88 -88
  19. package/src/cache/find-content-changes.mjs +58 -58
  20. package/src/cache/helpers.mjs +52 -52
  21. package/src/cache/metadata-strategy.mjs +83 -83
  22. package/src/cache/options-compatible.mjs +56 -109
  23. package/src/cli/assert-node-environment-suitable.mjs +7 -7
  24. package/src/cli/defaults.mjs +5 -5
  25. package/src/cli/format-meta-info.mjs +22 -22
  26. package/src/cli/format.mjs +28 -28
  27. package/src/cli/index.mjs +145 -145
  28. package/src/cli/init-config/build-config.mjs +94 -94
  29. package/src/cli/init-config/environment-helpers.mjs +77 -77
  30. package/src/cli/init-config/find-extensions.mjs +27 -27
  31. package/src/cli/init-config/get-user-input.mjs +151 -151
  32. package/src/cli/init-config/index.mjs +88 -88
  33. package/src/cli/init-config/normalize-init-options.mjs +47 -47
  34. package/src/cli/init-config/utl.mjs +4 -4
  35. package/src/cli/init-config/validators.mjs +10 -10
  36. package/src/cli/init-config/write-config.mjs +21 -21
  37. package/src/cli/init-config/write-run-scripts-to-manifest.mjs +103 -107
  38. package/src/cli/listeners/cli-feedback.mjs +49 -49
  39. package/src/cli/listeners/ndjson.mjs +66 -66
  40. package/src/cli/listeners/performance-log/format-helpers.mjs +63 -63
  41. package/src/cli/listeners/performance-log/handlers.mjs +56 -56
  42. package/src/cli/listeners/performance-log/index.mjs +37 -37
  43. package/src/cli/normalize-cli-options.mjs +182 -182
  44. package/src/cli/tools/wrap-stream-in-html.mjs +37 -37
  45. package/src/cli/utl/assert-file-existence.mjs +7 -7
  46. package/src/cli/utl/io.mjs +28 -31
  47. package/src/config-utl/extract-babel-config.mjs +69 -69
  48. package/src/config-utl/extract-depcruise-config/index.mjs +54 -54
  49. package/src/config-utl/extract-depcruise-config/merge-configs.mjs +63 -63
  50. package/src/config-utl/extract-depcruise-config/read-config.mjs +9 -9
  51. package/src/config-utl/extract-depcruise-options.mjs +9 -9
  52. package/src/config-utl/extract-known-violations.mjs +49 -49
  53. package/src/config-utl/extract-ts-config.mjs +46 -48
  54. package/src/config-utl/extract-webpack-resolve-config.mjs +88 -88
  55. package/src/config-utl/make-absolute.mjs +5 -5
  56. package/src/enrich/add-validations.mjs +13 -13
  57. package/src/enrich/derive/circular.mjs +49 -49
  58. package/src/enrich/derive/dependents.mjs +27 -27
  59. package/src/enrich/derive/folders/aggregate-to-folders.mjs +104 -104
  60. package/src/enrich/derive/folders/index.mjs +19 -19
  61. package/src/enrich/derive/folders/utl.mjs +18 -18
  62. package/src/enrich/derive/metrics/get-module-metrics.mjs +27 -27
  63. package/src/enrich/derive/metrics/index.mjs +8 -8
  64. package/src/enrich/derive/module-utl.mjs +18 -18
  65. package/src/enrich/derive/orphan/index.mjs +18 -18
  66. package/src/enrich/derive/orphan/is-orphan.mjs +9 -9
  67. package/src/enrich/derive/reachable.mjs +165 -168
  68. package/src/enrich/enrich-modules.mjs +25 -25
  69. package/src/enrich/index.mjs +15 -15
  70. package/src/enrich/soften-known-violations.mjs +90 -90
  71. package/src/enrich/summarize/add-rule-set-used.mjs +13 -13
  72. package/src/enrich/summarize/get-stats.mjs +17 -17
  73. package/src/enrich/summarize/index.mjs +18 -18
  74. package/src/enrich/summarize/is-same-violation.mjs +30 -30
  75. package/src/enrich/summarize/summarize-folders.mjs +35 -35
  76. package/src/enrich/summarize/summarize-modules.mjs +97 -97
  77. package/src/enrich/summarize/summarize-options.mjs +71 -71
  78. package/src/extract/acorn/estree-helpers.mjs +66 -66
  79. package/src/extract/acorn/extract-amd-deps.mjs +63 -64
  80. package/src/extract/acorn/extract-cjs-deps.mjs +83 -83
  81. package/src/extract/acorn/extract-es6-deps.mjs +54 -54
  82. package/src/extract/acorn/extract-stats.mjs +4 -4
  83. package/src/extract/acorn/extract.mjs +28 -28
  84. package/src/extract/acorn/parse.mjs +37 -37
  85. package/src/extract/clear-caches.mjs +7 -7
  86. package/src/extract/extract-dependencies.mjs +109 -109
  87. package/src/extract/extract-stats.mjs +21 -21
  88. package/src/extract/gather-initial-sources.mjs +64 -64
  89. package/src/extract/helpers.mjs +73 -71
  90. package/src/extract/index.mjs +120 -120
  91. package/src/extract/resolve/determine-dependency-types.mjs +166 -169
  92. package/src/extract/resolve/external-module-helpers.mjs +76 -76
  93. package/src/extract/resolve/get-manifest.mjs +79 -79
  94. package/src/extract/resolve/index.mjs +175 -164
  95. package/src/extract/resolve/is-built-in.mjs +22 -24
  96. package/src/extract/resolve/merge-manifests.mjs +43 -43
  97. package/src/extract/resolve/module-classifiers.mjs +229 -229
  98. package/src/extract/resolve/resolve-amd.mjs +44 -44
  99. package/src/extract/resolve/resolve-cjs.mjs +40 -40
  100. package/src/extract/resolve/resolve-helpers.mjs +20 -20
  101. package/src/extract/resolve/resolve.mjs +26 -26
  102. package/src/extract/swc/dependency-visitor.mjs +211 -211
  103. package/src/extract/swc/extract-swc-deps.mjs +4 -4
  104. package/src/extract/swc/extract.mjs +7 -7
  105. package/src/extract/swc/parse.mjs +12 -12
  106. package/src/extract/transpile/babel-wrap.mjs +9 -9
  107. package/src/extract/transpile/coffeescript-wrap.mjs +21 -21
  108. package/src/extract/transpile/index.mjs +47 -47
  109. package/src/extract/transpile/javascript-wrap.mjs +6 -6
  110. package/src/extract/transpile/livescript-wrap.mjs +5 -5
  111. package/src/extract/transpile/meta.mjs +80 -80
  112. package/src/extract/transpile/svelte-preprocess.mjs +73 -73
  113. package/src/extract/transpile/svelte-wrap.mjs +19 -19
  114. package/src/extract/transpile/try-import-available.mjs +26 -27
  115. package/src/extract/transpile/typescript-wrap.mjs +39 -39
  116. package/src/extract/transpile/vue-template-wrap.cjs +43 -43
  117. package/src/extract/tsc/extract-stats.mjs +4 -4
  118. package/src/extract/tsc/extract-typescript-deps.mjs +429 -398
  119. package/src/extract/tsc/extract.mjs +22 -22
  120. package/src/extract/tsc/parse.mjs +21 -21
  121. package/src/graph-utl/add-focus.mjs +35 -35
  122. package/src/graph-utl/compare.mjs +24 -24
  123. package/src/graph-utl/consolidate-module-dependencies.mjs +35 -35
  124. package/src/graph-utl/consolidate-modules.mjs +33 -33
  125. package/src/graph-utl/consolidate-to-folder.mjs +13 -13
  126. package/src/graph-utl/consolidate-to-pattern.mjs +34 -34
  127. package/src/graph-utl/filter-bank.mjs +74 -69
  128. package/src/graph-utl/indexed-module-graph.mjs +227 -225
  129. package/src/graph-utl/match-facade.mjs +3 -3
  130. package/src/graph-utl/rule-set.mjs +20 -20
  131. package/src/graph-utl/strip-self-transitions.mjs +6 -6
  132. package/src/main/cruise.mjs +81 -81
  133. package/src/main/files-and-dirs/normalize.mjs +7 -7
  134. package/src/main/format.mjs +11 -14
  135. package/src/main/helpers.mjs +25 -25
  136. package/src/main/index.mjs +8 -8
  137. package/src/main/options/assert-validity.mjs +100 -100
  138. package/src/main/options/defaults.mjs +11 -11
  139. package/src/main/options/normalize.mjs +158 -160
  140. package/src/main/report-wrap.mjs +37 -37
  141. package/src/main/resolve-options/normalize.mjs +127 -128
  142. package/src/main/rule-set/assert-validity.mjs +67 -73
  143. package/src/main/rule-set/normalize.mjs +81 -79
  144. package/src/meta.cjs +15 -16
  145. package/src/report/anon/anonymize-path-element.mjs +20 -34
  146. package/src/report/anon/anonymize-path.mjs +11 -11
  147. package/src/report/anon/index.mjs +119 -119
  148. package/src/report/anon/random-string.mjs +23 -23
  149. package/src/report/azure-devops.mjs +75 -99
  150. package/src/report/baseline.mjs +9 -9
  151. package/src/report/csv.mjs +13 -13
  152. package/src/report/d2.mjs +105 -105
  153. package/src/report/dot/default-theme.mjs +152 -152
  154. package/src/report/dot/index.mjs +146 -146
  155. package/src/report/dot/module-utl.mjs +72 -72
  156. package/src/report/dot/prepare-custom-level.mjs +20 -20
  157. package/src/report/dot/prepare-flat-level.mjs +11 -11
  158. package/src/report/dot/prepare-folder-level.mjs +12 -13
  159. package/src/report/dot/theming.mjs +73 -73
  160. package/src/report/dot-webpage/dot-module.mjs +36 -36
  161. package/src/report/dot-webpage/svg-in-html-snippets/script.cjs +208 -210
  162. package/src/report/dot-webpage/svg-in-html-snippets/style.css +51 -51
  163. package/src/report/dot-webpage/wrap-in-html.mjs +7 -7
  164. package/src/report/error-html/index.mjs +49 -49
  165. package/src/report/error-html/utl.mjs +99 -99
  166. package/src/report/error-long.mjs +1 -1
  167. package/src/report/error.mjs +93 -93
  168. package/src/report/html/index.mjs +48 -48
  169. package/src/report/identity.mjs +4 -4
  170. package/src/report/index.mjs +33 -33
  171. package/src/report/json.mjs +4 -4
  172. package/src/report/markdown.mjs +120 -120
  173. package/src/report/mermaid.mjs +111 -111
  174. package/src/report/metrics.mjs +185 -185
  175. package/src/report/null.mjs +4 -4
  176. package/src/report/plugins.mjs +41 -41
  177. package/src/report/teamcity.mjs +150 -150
  178. package/src/report/text.mjs +42 -42
  179. package/src/report/utl/dependency-to-incidence-transformer.mjs +32 -32
  180. package/src/report/utl/index.mjs +53 -53
  181. package/src/schema/configuration.validate.mjs +1 -0
  182. package/src/schema/cruise-result.validate.mjs +1 -0
  183. package/src/schema/utl.mjs +6 -0
  184. package/src/utl/array-util.mjs +25 -25
  185. package/src/utl/bus.mjs +12 -12
  186. package/src/utl/extract-root-module-name.cjs +8 -8
  187. package/src/utl/find-all-files.mjs +54 -54
  188. package/src/utl/get-extension.mjs +2 -2
  189. package/src/utl/object-util.mjs +21 -22
  190. package/src/utl/path-to-posix.mjs +5 -5
  191. package/src/utl/regex-util.mjs +20 -20
  192. package/src/utl/try-import.mjs +42 -41
  193. package/src/utl/try-require.cjs +23 -23
  194. package/src/utl/wrap-and-indent.mjs +33 -33
  195. package/src/validate/index.mjs +65 -65
  196. package/src/validate/match-dependency-rule.mjs +47 -47
  197. package/src/validate/match-folder-dependency-rule.mjs +27 -27
  198. package/src/validate/match-module-rule-helpers.mjs +76 -76
  199. package/src/validate/match-module-rule.mjs +12 -12
  200. package/src/validate/matchers.mjs +162 -162
  201. package/src/validate/rule-classifiers.mjs +9 -9
  202. package/src/validate/violates-required-rule.mjs +23 -23
  203. package/types/cache-options.d.mts +27 -27
  204. package/types/config-utl/extract-babel-config.d.mts +1 -1
  205. package/types/config-utl/extract-depcruise-config.d.mts +3 -3
  206. package/types/config-utl/extract-depcruise-options.d.mts +1 -1
  207. package/types/config-utl/extract-ts-config.d.mts +1 -1
  208. package/types/config-utl/extract-webpack-resolve-config.d.mts +3 -3
  209. package/types/configuration.d.mts +10 -10
  210. package/types/cruise-result.d.mts +414 -414
  211. package/types/dependency-cruiser.d.mts +52 -52
  212. package/types/filter-types.d.mts +45 -45
  213. package/types/options.d.mts +430 -430
  214. package/types/plugins/3d-reporter-plugin.d.mts +9 -9
  215. package/types/plugins/mermaid-reporter-plugin.d.mts +10 -10
  216. package/types/plugins/stats-reporter-plugin.d.mts +9 -9
  217. package/types/reporter-options.d.mts +196 -196
  218. package/types/resolve-options.d.mts +23 -23
  219. package/types/restrictions.d.mts +174 -174
  220. package/types/rule-set.d.mts +132 -132
  221. package/types/rule-summary.d.mts +14 -14
  222. package/types/shared-types.d.mts +89 -89
  223. package/types/strict-filter-types.d.mts +52 -52
  224. package/types/strict-options.d.mts +34 -34
  225. package/types/strict-restrictions.d.mts +25 -25
  226. package/types/strict-rule-set.d.mts +36 -36
  227. package/types/violations.d.mts +40 -40
  228. package/src/schema/README.md +0 -5
  229. package/src/schema/baseline-violations.schema.mjs +0 -1
  230. package/src/schema/configuration.schema.mjs +0 -1
  231. package/src/schema/cruise-result.schema.mjs +0 -1
  232. package/types/README.md +0 -1
@@ -1,34 +1,34 @@
1
1
  import {
2
- aggregateViolations,
3
- determineTo,
4
- determineFromExtras,
2
+ aggregateViolations,
3
+ determineTo,
4
+ determineFromExtras,
5
5
  } from "./error-html/utl.mjs";
6
6
  import meta from "#meta.cjs";
7
7
 
8
8
  const REPORT_DEFAULTS = {
9
- showTitle: true,
10
- title: "## Forbidden dependency check - results",
11
-
12
- showSummary: true,
13
- showSummaryHeader: true,
14
- summaryHeader: "### :chart_with_upwards_trend: Summary",
15
- showStatsSummary: true,
16
- showRulesSummary: true,
17
- includeIgnoredInSummary: true,
18
-
19
- showDetails: true,
20
- includeIgnoredInDetails: true,
21
- showDetailsHeader: true,
22
- detailsHeader: "### :fire: All violations",
23
- collapseDetails: true,
24
- collapsedMessage: "Violations found - click to expand",
25
- noViolationsMessage:
26
- ":revolving_hearts: No violations found. Get gummy bears to celebrate.",
27
-
28
- showFooter: true,
29
- footer: `---\n[dependency-cruiser@${
30
- meta.version
31
- }](https://www.github.com/sverweij/dependency-cruiser) / ${new Date().toISOString()}`,
9
+ showTitle: true,
10
+ title: "## Forbidden dependency check - results",
11
+
12
+ showSummary: true,
13
+ showSummaryHeader: true,
14
+ summaryHeader: "### :chart_with_upwards_trend: Summary",
15
+ showStatsSummary: true,
16
+ showRulesSummary: true,
17
+ includeIgnoredInSummary: true,
18
+
19
+ showDetails: true,
20
+ includeIgnoredInDetails: true,
21
+ showDetailsHeader: true,
22
+ detailsHeader: "### :fire: All violations",
23
+ collapseDetails: true,
24
+ collapsedMessage: "Violations found - click to expand",
25
+ noViolationsMessage:
26
+ ":revolving_hearts: No violations found. Get gummy bears to celebrate.",
27
+
28
+ showFooter: true,
29
+ footer: `---\n[dependency-cruiser@${
30
+ meta.version
31
+ }](https://www.github.com/sverweij/dependency-cruiser) / ${new Date().toISOString()}`,
32
32
  };
33
33
 
34
34
  /**
@@ -36,13 +36,13 @@ const REPORT_DEFAULTS = {
36
36
  * @returns {string}
37
37
  */
38
38
  function severity2Icon(pSeverity) {
39
- const lSeverity2IconMap = new Map([
40
- ["error", ":exclamation:"],
41
- ["info", ":grey_exclamation:"],
42
- ["ignore", ":see_no_evil:"],
43
- ]);
39
+ const lSeverity2IconMap = new Map([
40
+ ["error", ":exclamation:"],
41
+ ["info", ":grey_exclamation:"],
42
+ ["ignore", ":see_no_evil:"],
43
+ ]);
44
44
 
45
- return lSeverity2IconMap.get(pSeverity) || ":warning:";
45
+ return lSeverity2IconMap.get(pSeverity) || ":warning:";
46
46
  }
47
47
 
48
48
  /**
@@ -50,9 +50,9 @@ function severity2Icon(pSeverity) {
50
50
  * @return {string}
51
51
  */
52
52
  function formatStatsSummary(pSummary) {
53
- const lSpacerLength = 4;
54
- const lSpacer = " ".repeat(lSpacerLength);
55
- return `**${pSummary.totalCruised}** modules${lSpacer}**${pSummary.totalDependenciesCruised}** dependencies${lSpacer}**${pSummary.error}** errors${lSpacer}**${pSummary.warn}** warnings${lSpacer}**${pSummary.info}** informational${lSpacer}**${pSummary.ignore}** ignored\n`;
53
+ const lSpacerLength = 4;
54
+ const lSpacer = " ".repeat(lSpacerLength);
55
+ return `**${pSummary.totalCruised}** modules${lSpacer}**${pSummary.totalDependenciesCruised}** dependencies${lSpacer}**${pSummary.error}** errors${lSpacer}**${pSummary.warn}** warnings${lSpacer}**${pSummary.info}** informational${lSpacer}**${pSummary.ignore}** ignored\n`;
56
56
  }
57
57
 
58
58
  /**
@@ -61,24 +61,24 @@ function formatStatsSummary(pSummary) {
61
61
  * @return {string}
62
62
  */
63
63
  function formatRulesSummary(pCruiseResult, pIncludeIgnoredInSummary) {
64
- const lTableHead =
65
- "|rule|violations|ignored|explanation\n|:---|:---:|:---:|:---|\n";
66
-
67
- return aggregateViolations(
68
- pCruiseResult.summary.violations,
69
- pCruiseResult.summary.ruleSetUsed,
70
- )
71
- .filter(
72
- (pRule) =>
73
- pRule.count > 0 || (pIncludeIgnoredInSummary && pRule.ignoredCount > 0),
74
- )
75
- .reduce(
76
- (pAll, pRule) =>
77
- `${pAll}|${severity2Icon(pRule.severity)} _${pRule.name}_|**${
78
- pRule.count
79
- }**|**${pRule.ignoredCount}**|${pRule.comment}|\n`,
80
- lTableHead,
81
- );
64
+ const lTableHead =
65
+ "|rule|violations|ignored|explanation\n|:---|:---:|:---:|:---|\n";
66
+
67
+ return aggregateViolations(
68
+ pCruiseResult.summary.violations,
69
+ pCruiseResult.summary.ruleSetUsed,
70
+ )
71
+ .filter(
72
+ (pRule) =>
73
+ pRule.count > 0 || (pIncludeIgnoredInSummary && pRule.ignoredCount > 0),
74
+ )
75
+ .reduce(
76
+ (pAll, pRule) =>
77
+ `${pAll}|${severity2Icon(pRule.severity)} _${pRule.name}_|**${
78
+ pRule.count
79
+ }**|**${pRule.ignoredCount}**|${pRule.comment}|\n`,
80
+ lTableHead,
81
+ );
82
82
  }
83
83
 
84
84
  /**
@@ -88,60 +88,60 @@ function formatRulesSummary(pCruiseResult, pIncludeIgnoredInSummary) {
88
88
  * @return {string}
89
89
  */
90
90
  function formatViolations(pViolations, pIncludeIgnoredInDetails) {
91
- const lTableHead = "|violated rule|module|to|\n|:---|:---|:---|\n";
92
-
93
- return pViolations
94
- .filter(
95
- (pViolation) =>
96
- pViolation.rule.severity !== "ignore" || pIncludeIgnoredInDetails,
97
- )
98
- .reduce((pAll, pViolation) => {
99
- const lFromExtras = determineFromExtras(pViolation);
100
- const lTo = determineTo(pViolation);
101
-
102
- return `${pAll}|${severity2Icon(pViolation.rule.severity)} _${
103
- pViolation.rule.name
104
- }_|${pViolation.from}${lFromExtras}|${lTo}|\n`;
105
- }, lTableHead);
91
+ const lTableHead = "|violated rule|module|to|\n|:---|:---|:---|\n";
92
+
93
+ return pViolations
94
+ .filter(
95
+ (pViolation) =>
96
+ pViolation.rule.severity !== "ignore" || pIncludeIgnoredInDetails,
97
+ )
98
+ .reduce((pAll, pViolation) => {
99
+ const lFromExtras = determineFromExtras(pViolation);
100
+ const lTo = determineTo(pViolation);
101
+
102
+ return `${pAll}|${severity2Icon(pViolation.rule.severity)} _${
103
+ pViolation.rule.name
104
+ }_|${pViolation.from}${lFromExtras}|${lTo}|\n`;
105
+ }, lTableHead);
106
106
  }
107
107
 
108
108
  function details(pResults, pOptions) {
109
- let lReturnValue = "";
110
- if (pResults.summary.violations.length > 0) {
111
- if (pOptions.showDetailsHeader) {
112
- lReturnValue += `${pOptions.detailsHeader}\n\n`;
113
- }
114
- if (pOptions.collapseDetails) {
115
- lReturnValue += `<details><summary>${pOptions.collapsedMessage}</summary>\n\n`;
116
- }
117
- lReturnValue += `${formatViolations(
118
- pResults.summary.violations,
119
- pOptions.includeIgnoredInDetails,
120
- )}\n\n`;
121
- if (pOptions.collapseDetails) {
122
- lReturnValue += "</details>\n\n";
123
- }
124
- } else {
125
- lReturnValue += `${pOptions.noViolationsMessage}\n\n`;
126
- }
127
- return lReturnValue;
109
+ let lReturnValue = "";
110
+ if (pResults.summary.violations.length > 0) {
111
+ if (pOptions.showDetailsHeader) {
112
+ lReturnValue += `${pOptions.detailsHeader}\n\n`;
113
+ }
114
+ if (pOptions.collapseDetails) {
115
+ lReturnValue += `<details><summary>${pOptions.collapsedMessage}</summary>\n\n`;
116
+ }
117
+ lReturnValue += `${formatViolations(
118
+ pResults.summary.violations,
119
+ pOptions.includeIgnoredInDetails,
120
+ )}\n\n`;
121
+ if (pOptions.collapseDetails) {
122
+ lReturnValue += "</details>\n\n";
123
+ }
124
+ } else {
125
+ lReturnValue += `${pOptions.noViolationsMessage}\n\n`;
126
+ }
127
+ return lReturnValue;
128
128
  }
129
129
 
130
130
  function summary(pResults, pOptions) {
131
- let lReturnValue = "";
132
-
133
- if (pOptions.showSummaryHeader) {
134
- lReturnValue += `${pOptions.summaryHeader}\n\n`;
135
- }
136
- lReturnValue += `${formatStatsSummary(pResults.summary)}\n\n`;
137
-
138
- if (pResults.summary.violations.length > 0 && pOptions.showRulesSummary) {
139
- lReturnValue += `${formatRulesSummary(
140
- pResults,
141
- pOptions.includeIgnoredInSummary,
142
- )}\n\n`;
143
- }
144
- return lReturnValue;
131
+ let lReturnValue = "";
132
+
133
+ if (pOptions.showSummaryHeader) {
134
+ lReturnValue += `${pOptions.summaryHeader}\n\n`;
135
+ }
136
+ lReturnValue += `${formatStatsSummary(pResults.summary)}\n\n`;
137
+
138
+ if (pResults.summary.violations.length > 0 && pOptions.showRulesSummary) {
139
+ lReturnValue += `${formatRulesSummary(
140
+ pResults,
141
+ pOptions.includeIgnoredInSummary,
142
+ )}\n\n`;
143
+ }
144
+ return lReturnValue;
145
145
  }
146
146
 
147
147
  /**
@@ -150,26 +150,26 @@ function summary(pResults, pOptions) {
150
150
  * @returns {string}
151
151
  */
152
152
  function report(pResults, pOptions) {
153
- const lOptions = { ...REPORT_DEFAULTS, ...(pOptions || {}) };
154
- let lReturnValue = "";
153
+ const lOptions = { ...REPORT_DEFAULTS, ...(pOptions || {}) };
154
+ let lReturnValue = "";
155
155
 
156
- if (lOptions.showTitle) {
157
- lReturnValue += `${lOptions.title}\n\n`;
158
- }
156
+ if (lOptions.showTitle) {
157
+ lReturnValue += `${lOptions.title}\n\n`;
158
+ }
159
159
 
160
- if (lOptions.showSummary) {
161
- lReturnValue += summary(pResults, lOptions);
162
- }
160
+ if (lOptions.showSummary) {
161
+ lReturnValue += summary(pResults, lOptions);
162
+ }
163
163
 
164
- if (lOptions.showDetails) {
165
- lReturnValue += details(pResults, lOptions);
166
- }
164
+ if (lOptions.showDetails) {
165
+ lReturnValue += details(pResults, lOptions);
166
+ }
167
167
 
168
- if (lOptions.showFooter) {
169
- lReturnValue += `${lOptions.footer}\n\n`;
170
- }
168
+ if (lOptions.showFooter) {
169
+ lReturnValue += `${lOptions.footer}\n\n`;
170
+ }
171
171
 
172
- return lReturnValue;
172
+ return lReturnValue;
173
173
  }
174
174
 
175
175
  /**
@@ -180,8 +180,8 @@ function report(pResults, pOptions) {
180
180
  * @returns {import("../../types/dependency-cruiser.js").IReporterOutput}
181
181
  */
182
182
  export default function markdown(pResults, pOptions) {
183
- return {
184
- output: report(pResults, pOptions),
185
- exitCode: 0,
186
- };
183
+ return {
184
+ output: report(pResults, pOptions),
185
+ exitCode: 0,
186
+ };
187
187
  }
@@ -1,61 +1,61 @@
1
1
  /* eslint-disable security/detect-object-injection */
2
2
  const ACORN_DUMMY_VALUE = "✖";
3
3
  const REPORT_DEFAULTS = {
4
- minify: true,
4
+ minify: true,
5
5
  };
6
6
 
7
7
  const renderNode = (pNode, pText) =>
8
- `${pNode}["${pText.length > 0 ? pText : " "}"]`;
8
+ `${pNode}["${pText.length > 0 ? pText : " "}"]`;
9
9
 
10
10
  const renderEdge = (pFrom, pTo) => `${pFrom.node}-->${pTo.node}`;
11
11
 
12
12
  const renderEdges = (pEdges) =>
13
- pEdges.map((pEdge) => renderEdge(pEdge.from, pEdge.to)).join("\n");
13
+ pEdges.map((pEdge) => renderEdge(pEdge.from, pEdge.to)).join("\n");
14
14
 
15
15
  /**
16
16
  * @param {import('../../types/dependency-cruiser').ICruiseResult} pCruiseResult
17
17
  * @param {Map<string, string>} pNamesHashMap
18
18
  */
19
19
  function convertEdgeSources(pCruiseResult, pNamesHashMap) {
20
- return pCruiseResult.modules.flatMap((pModule) => {
21
- const lFromNode = pNamesHashMap.get(pModule.source);
22
- const lFrom = {
23
- node: lFromNode,
24
- text: pModule.source.split("/").slice(-1)[0],
25
- };
26
-
27
- return pModule.dependencies.map((pDependency) => {
28
- const lToNode = pNamesHashMap.get(pDependency.resolved);
29
- return {
30
- from: lFrom,
31
- to: {
32
- node: lToNode,
33
- text: pDependency.resolved.split("/").slice(-1)[0],
34
- },
35
- };
36
- });
37
- });
20
+ return pCruiseResult.modules.flatMap((pModule) => {
21
+ const lFromNode = pNamesHashMap.get(pModule.source);
22
+ const lFrom = {
23
+ node: lFromNode,
24
+ text: pModule.source.split("/").slice(-1)[0],
25
+ };
26
+
27
+ return pModule.dependencies.map((pDependency) => {
28
+ const lToNode = pNamesHashMap.get(pDependency.resolved);
29
+ return {
30
+ from: lFrom,
31
+ to: {
32
+ node: lToNode,
33
+ text: pDependency.resolved.split("/").slice(-1)[0],
34
+ },
35
+ };
36
+ });
37
+ });
38
38
  }
39
39
 
40
40
  const indent = (pDepth, pMinify) => (pMinify ? "" : " ".repeat(pDepth));
41
41
 
42
42
  const renderSubgraph = (pNode, pText, pChildren, pIndent) =>
43
- `${pIndent}subgraph ${renderNode(pNode, pText)}
43
+ `${pIndent}subgraph ${renderNode(pNode, pText)}
44
44
  ${pChildren}
45
45
  ${pIndent}end`;
46
46
 
47
47
  function renderSubgraphs(pSource, pOptions, pDepth = 0) {
48
- return Object.keys(pSource)
49
- .map((pName) => {
50
- const lIndent = indent(pDepth, pOptions.minify);
51
- const source = pSource[pName];
52
- const children = renderSubgraphs(source.children, pOptions, pDepth + 1);
53
- if (children === "")
54
- return `${lIndent}${renderNode(source.node, source.text)}`;
55
-
56
- return renderSubgraph(source.node, source.text, children, lIndent);
57
- })
58
- .join("\n");
48
+ return Object.keys(pSource)
49
+ .map((pName) => {
50
+ const lIndent = indent(pDepth, pOptions.minify);
51
+ const source = pSource[pName];
52
+ const children = renderSubgraphs(source.children, pOptions, pDepth + 1);
53
+ if (children === "")
54
+ return `${lIndent}${renderNode(source.node, source.text)}`;
55
+
56
+ return renderSubgraph(source.node, source.text, children, lIndent);
57
+ })
58
+ .join("\n");
59
59
  }
60
60
 
61
61
  /**
@@ -63,25 +63,25 @@ function renderSubgraphs(pSource, pOptions, pDepth = 0) {
63
63
  * @param {Map<string, string>} pNamesHashMap
64
64
  */
65
65
  function convertSubgraphSources(pCruiseResult, pNamesHashMap) {
66
- let lTree = {};
67
-
68
- for (const lModule of pCruiseResult.modules) {
69
- const lPaths = lModule.source.split("/");
70
-
71
- lPaths.reduce((pChildren, pCurrentPath, pIndex) => {
72
- if (!pChildren[pCurrentPath]) {
73
- const node = lPaths.slice(0, pIndex + 1).join("/");
74
- pChildren[pCurrentPath] = {
75
- node: pNamesHashMap.get(node),
76
- text: pCurrentPath,
77
- children: {},
78
- };
79
- }
80
- return pChildren[pCurrentPath].children;
81
- }, lTree);
82
- }
83
-
84
- return lTree;
66
+ let lTree = {};
67
+
68
+ for (const lModule of pCruiseResult.modules) {
69
+ const lPaths = lModule.source.split("/");
70
+
71
+ lPaths.reduce((pChildren, pCurrentPath, pIndex) => {
72
+ if (!pChildren[pCurrentPath]) {
73
+ const node = lPaths.slice(0, pIndex + 1).join("/");
74
+ pChildren[pCurrentPath] = {
75
+ node: pNamesHashMap.get(node),
76
+ text: pCurrentPath,
77
+ children: {},
78
+ };
79
+ }
80
+ return pChildren[pCurrentPath].children;
81
+ }, lTree);
82
+ }
83
+
84
+ return lTree;
85
85
  }
86
86
 
87
87
  /**
@@ -89,27 +89,27 @@ function convertSubgraphSources(pCruiseResult, pNamesHashMap) {
89
89
  * @param {Map<string, string>} pNamesHashMap
90
90
  */
91
91
  function focusHighlights(pModules, pNamesHashMap) {
92
- const lHighLightStyle = "fill:lime,color:black";
93
-
94
- return pModules
95
- .filter(
96
- (pModule) =>
97
- pModule.matchesFocus ||
98
- pModule.matchesReaches ||
99
- pModule.matchesHighlight,
100
- )
101
- .reduce((pAll, pModule) => {
102
- const lSource = pNamesHashMap.get(pModule.source);
103
- return `${pAll}\nstyle ${lSource} ${lHighLightStyle}`;
104
- }, "");
92
+ const lHighLightStyle = "fill:lime,color:black";
93
+
94
+ return pModules
95
+ .filter(
96
+ (pModule) =>
97
+ pModule.matchesFocus ||
98
+ pModule.matchesReaches ||
99
+ pModule.matchesHighlight,
100
+ )
101
+ .reduce((pAll, pModule) => {
102
+ const lSource = pNamesHashMap.get(pModule.source);
103
+ return `${pAll}\nstyle ${lSource} ${lHighLightStyle}`;
104
+ }, "");
105
105
  }
106
106
 
107
107
  const hashToReadableNodeName = (pNode) =>
108
- pNode
109
- .replace(ACORN_DUMMY_VALUE, "__unknown__")
110
- .replace(/^\.$|^\.\//g, "__currentPath__")
111
- .replace(/^\.{2}$|^\.{2}\//g, "__prevPath__")
112
- .replace(/[[\]/.@~-]/g, "_");
108
+ pNode
109
+ .replace(ACORN_DUMMY_VALUE, "__unknown__")
110
+ .replace(/^\.$|^\.\//g, "__currentPath__")
111
+ .replace(/^\.{2}$|^\.{2}\//g, "__prevPath__")
112
+ .replace(/[[\]/.@~-]/g, "_");
113
113
 
114
114
  /**
115
115
  * @param {import("../../types/cruise-result").IModule[]} pModules
@@ -117,38 +117,38 @@ const hashToReadableNodeName = (pNode) =>
117
117
  * @return {Map<string, string>}
118
118
  */
119
119
  function hashModuleNames(pModules, pMinify) {
120
- const lBase = 36;
121
- const lNamesHashMap = new Map();
122
- let lCount = 0;
123
-
124
- for (const lModule of pModules) {
125
- const lPaths = lModule.source.split("/");
126
-
127
- for (let lIndex = 0; lIndex < lPaths.length; lIndex += 1) {
128
- const lName = lPaths.slice(0, lIndex + 1).join("/");
129
- if (!lNamesHashMap.has(lName)) {
130
- // eslint-disable-next-line max-depth
131
- if (pMinify) {
132
- // toUpperCase because otherwise we generate e.g. o-->a and x-->a
133
- // which are ambiguous in mermaid (o--> and x--> are edge shapes
134
- // whereas e.g. a--> is node 'a' + the arrow shape -->). The only
135
- // collision within alphanums are 'o' and 'x', so upper casing
136
- // saves us...
137
- // ref: https://mermaid.js.org/syntax/flowchart.html#new-arrow-types
138
- // another way to solve this would be to place a space between the
139
- // node name and the edge shape (x --> a) - however, this would make
140
- // for a larger output, running into the mermaid max source size
141
- // earlier
142
- lNamesHashMap.set(lName, lCount.toString(lBase).toUpperCase());
143
- lCount += 1;
144
- } else {
145
- lNamesHashMap.set(lName, hashToReadableNodeName(lName));
146
- }
147
- }
148
- }
149
- }
150
-
151
- return lNamesHashMap;
120
+ const lBase = 36;
121
+ const lNamesHashMap = new Map();
122
+ let lCount = 0;
123
+
124
+ for (const lModule of pModules) {
125
+ const lPaths = lModule.source.split("/");
126
+
127
+ for (let lIndex = 0; lIndex < lPaths.length; lIndex += 1) {
128
+ const lName = lPaths.slice(0, lIndex + 1).join("/");
129
+ if (!lNamesHashMap.has(lName)) {
130
+ // eslint-disable-next-line max-depth
131
+ if (pMinify) {
132
+ // toUpperCase because otherwise we generate e.g. o-->a and x-->a
133
+ // which are ambiguous in mermaid (o--> and x--> are edge shapes
134
+ // whereas e.g. a--> is node 'a' + the arrow shape -->). The only
135
+ // collision within alphanums are 'o' and 'x', so upper casing
136
+ // saves us...
137
+ // ref: https://mermaid.js.org/syntax/flowchart.html#new-arrow-types
138
+ // another way to solve this would be to place a space between the
139
+ // node name and the edge shape (x --> a) - however, this would make
140
+ // for a larger output, running into the mermaid max source size
141
+ // earlier
142
+ lNamesHashMap.set(lName, lCount.toString(lBase).toUpperCase());
143
+ lCount += 1;
144
+ } else {
145
+ lNamesHashMap.set(lName, hashToReadableNodeName(lName));
146
+ }
147
+ }
148
+ }
149
+ }
150
+
151
+ return lNamesHashMap;
152
152
  }
153
153
 
154
154
  /**
@@ -156,12 +156,12 @@ function hashModuleNames(pModules, pMinify) {
156
156
  * @param {import("../../types/reporter-options").IMermaidReporterOptions} pOptions
157
157
  */
158
158
  function renderMermaidSource(pCruiseResult, pOptions) {
159
- const lOptions = { ...REPORT_DEFAULTS, ...(pOptions || {}) };
160
- const lNamesHashMap = hashModuleNames(pCruiseResult.modules, lOptions.minify);
161
- const lSubgraphs = convertSubgraphSources(pCruiseResult, lNamesHashMap);
162
- const lEdges = convertEdgeSources(pCruiseResult, lNamesHashMap);
159
+ const lOptions = { ...REPORT_DEFAULTS, ...(pOptions || {}) };
160
+ const lNamesHashMap = hashModuleNames(pCruiseResult.modules, lOptions.minify);
161
+ const lSubgraphs = convertSubgraphSources(pCruiseResult, lNamesHashMap);
162
+ const lEdges = convertEdgeSources(pCruiseResult, lNamesHashMap);
163
163
 
164
- return `flowchart LR
164
+ return `flowchart LR
165
165
 
166
166
  ${renderSubgraphs(lSubgraphs, lOptions)}
167
167
  ${renderEdges(lEdges)}
@@ -176,8 +176,8 @@ ${focusHighlights(pCruiseResult.modules, lNamesHashMap)}`;
176
176
  * @return {import('../../types/dependency-cruiser').IReporterOutput}
177
177
  */
178
178
  export default function mermaid(pCruiseResult, pOptions) {
179
- return {
180
- output: renderMermaidSource(pCruiseResult, pOptions),
181
- exitCode: 0,
182
- };
179
+ return {
180
+ output: renderMermaidSource(pCruiseResult, pOptions),
181
+ exitCode: 0,
182
+ };
183
183
  }