dependency-cruiser 16.4.1 → 16.4.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 (37) hide show
  1. package/package.json +4 -4
  2. package/src/enrich/add-validations.mjs +3 -3
  3. package/src/enrich/derive/folders/index.mjs +2 -2
  4. package/src/enrich/derive/reachable.mjs +6 -3
  5. package/src/enrich/summarize/index.mjs +2 -2
  6. package/src/enrich/summarize/summarize-modules.mjs +2 -2
  7. package/src/extract/acorn/extract.mjs +3 -3
  8. package/src/extract/acorn/parse.mjs +0 -6
  9. package/src/extract/clear-caches.mjs +6 -6
  10. package/src/extract/swc/extract.mjs +3 -5
  11. package/src/extract/swc/parse.mjs +14 -22
  12. package/src/extract/tsc/extract.mjs +4 -4
  13. package/src/extract/tsc/parse.mjs +14 -22
  14. package/src/graph-utl/compare.mjs +10 -14
  15. package/src/graph-utl/consolidate-module-dependencies.mjs +2 -2
  16. package/src/graph-utl/consolidate-modules.mjs +2 -2
  17. package/src/main/options/assert-validity.mjs +2 -2
  18. package/src/main/report-wrap.mjs +4 -4
  19. package/src/meta.cjs +1 -1
  20. package/src/report/dot/index.mjs +6 -12
  21. package/src/report/dot/module-utl.mjs +5 -35
  22. package/src/report/dot/prepare-custom-level.mjs +8 -7
  23. package/src/report/dot/prepare-flat-level.mjs +8 -7
  24. package/src/report/dot/prepare-folder-level.mjs +9 -7
  25. package/src/report/dot/theming.mjs +20 -6
  26. package/src/report/error-html/utl.mjs +2 -11
  27. package/src/report/index.mjs +2 -7
  28. package/src/report/markdown.mjs +5 -3
  29. package/src/utl/regex-util.mjs +2 -7
  30. package/src/validate/index.mjs +14 -17
  31. package/src/validate/match-dependency-rule.mjs +34 -25
  32. package/src/validate/match-folder-dependency-rule.mjs +3 -3
  33. package/src/validate/match-module-rule-helpers.mjs +132 -0
  34. package/src/validate/match-module-rule.mjs +6 -130
  35. package/src/validate/matchers.mjs +22 -38
  36. package/src/validate/rule-classifiers.mjs +0 -2
  37. package/src/validate/violates-required-rule.mjs +8 -4
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dependency-cruiser",
3
- "version": "16.4.1",
3
+ "version": "16.4.2",
4
4
  "description": "Validate and visualize dependencies. With your rules. JavaScript, TypeScript, CoffeeScript. ES6, CommonJS, AMD.",
5
5
  "keywords": [
6
6
  "static analysis",
@@ -143,16 +143,16 @@
143
143
  "acorn-jsx": "^5.3.2",
144
144
  "acorn-jsx-walk": "^2.0.0",
145
145
  "acorn-loose": "^8.4.0",
146
- "acorn-walk": "^8.3.3",
146
+ "acorn-walk": "^8.3.4",
147
147
  "ajv": "^8.17.1",
148
148
  "commander": "^12.1.0",
149
149
  "enhanced-resolve": "^5.17.1",
150
- "ignore": "^5.3.2",
150
+ "ignore": "^6.0.2",
151
151
  "interpret": "^3.1.1",
152
152
  "is-installed-globally": "^1.0.0",
153
153
  "json5": "^2.2.3",
154
154
  "memoize": "^10.0.0",
155
- "picocolors": "^1.0.1",
155
+ "picocolors": "^1.1.0",
156
156
  "picomatch": "^4.0.2",
157
157
  "prompts": "^2.4.2",
158
158
  "rechoir": "^0.8.0",
@@ -1,10 +1,10 @@
1
- import validate from "#validate/index.mjs";
1
+ import { validateDependency, validateModule } from "#validate/index.mjs";
2
2
 
3
3
  function addDependencyViolations(pModule, pDependency, pRuleSet, pValidate) {
4
4
  return {
5
5
  ...pDependency,
6
6
  ...(pValidate
7
- ? validate.dependency(pRuleSet, pModule, pDependency)
7
+ ? validateDependency(pRuleSet, pModule, pDependency)
8
8
  : { valid: true }),
9
9
  };
10
10
  }
@@ -24,7 +24,7 @@ function addDependencyViolations(pModule, pDependency, pRuleSet, pValidate) {
24
24
  export default function addValidations(pModules, pRuleSet, pValidate) {
25
25
  return pModules.map((pModule) => ({
26
26
  ...pModule,
27
- ...(pValidate ? validate.module(pRuleSet, pModule) : { valid: true }),
27
+ ...(pValidate ? validateModule(pRuleSet, pModule) : { valid: true }),
28
28
  dependencies: pModule.dependencies.map((pDependency) =>
29
29
  addDependencyViolations(pModule, pDependency, pRuleSet, pValidate),
30
30
  ),
@@ -1,5 +1,5 @@
1
1
  import aggregateToFolders from "./aggregate-to-folders.mjs";
2
- import validate from "#validate/index.mjs";
2
+ import { validateFolder } from "#validate/index.mjs";
3
3
 
4
4
  /**
5
5
  * @param {import("../../../../types/dependency-cruiser.js").IFolder} pFolder
@@ -9,7 +9,7 @@ import validate from "#validate/index.mjs";
9
9
  function validateFolderDependency(pFolder, pOptions) {
10
10
  return (pDependency) => ({
11
11
  ...pDependency,
12
- ...validate.folder(pOptions.ruleSet || {}, pFolder, pDependency),
12
+ ...validateFolder(pOptions.ruleSet || {}, pFolder, pDependency),
13
13
  });
14
14
  }
15
15
 
@@ -1,5 +1,8 @@
1
1
  /* eslint-disable security/detect-object-injection, no-inline-comments */
2
- import matchers from "#validate/matchers.mjs";
2
+ import {
3
+ matchToModulePath,
4
+ matchToModulePathNot,
5
+ } from "#validate/matchers.mjs";
3
6
  import IndexedModuleGraph from "#graph-utl/indexed-module-graph.mjs";
4
7
  import { extractGroups } from "#utl/regex-util.mjs";
5
8
 
@@ -25,8 +28,8 @@ function isModuleInRuleTo(pRule, pModuleTo, pModuleFrom) {
25
28
  : [];
26
29
 
27
30
  return (
28
- matchers.toModulePath(pRule, pModuleTo, lGroups) &&
29
- matchers.toModulePathNot(pRule, pModuleTo, lGroups)
31
+ matchToModulePath(pRule, pModuleTo, lGroups) &&
32
+ matchToModulePathNot(pRule, pModuleTo, lGroups)
30
33
  );
31
34
  }
32
35
 
@@ -7,7 +7,7 @@ import {
7
7
  getModulesCruised,
8
8
  getDependenciesCruised,
9
9
  } from "./get-stats.mjs";
10
- import compare from "#graph-utl/compare.mjs";
10
+ import { compareViolations } from "#graph-utl/compare.mjs";
11
11
 
12
12
  /**
13
13
  *
@@ -31,7 +31,7 @@ export default function summarize(
31
31
  ) {
32
32
  const lViolations = summarizeModules(pModules, pOptions.ruleSet)
33
33
  .concat(summarizeFolders(pFolders || [], pOptions.ruleSet))
34
- .sort(compare.violations);
34
+ .sort(compareViolations);
35
35
 
36
36
  return {
37
37
  violations: lViolations,
@@ -1,6 +1,6 @@
1
1
  import isSameViolation from "./is-same-violation.mjs";
2
2
  import { findRuleByName } from "#graph-utl/rule-set.mjs";
3
- import compare from "#graph-utl/compare.mjs";
3
+ import { compareViolations } from "#graph-utl/compare.mjs";
4
4
  import { uniqWith } from "#utl/array-util.mjs";
5
5
 
6
6
  function cutNonTransgressions(pModule) {
@@ -135,7 +135,7 @@ export default function summarizeModules(pModules, pRuleSet) {
135
135
  return uniqWith(
136
136
  extractDependencyViolations(pModules, pRuleSet)
137
137
  .concat(extractModuleViolations(pModules, pRuleSet))
138
- .sort(compare.violations),
138
+ .sort(compareViolations),
139
139
  isSameViolation,
140
140
  );
141
141
  }
@@ -2,7 +2,7 @@ import { join } from "node:path";
2
2
  import extractES6Deps from "./extract-es6-deps.mjs";
3
3
  import extractCommonJSDeps from "./extract-cjs-deps.mjs";
4
4
  import extractAMDDeps from "./extract-amd-deps.mjs";
5
- import parse from "./parse.mjs";
5
+ import { getASTCached } from "./parse.mjs";
6
6
  import extractStats from "./extract-stats.mjs";
7
7
 
8
8
  export function extract(
@@ -11,7 +11,7 @@ export function extract(
11
11
  pTranspileOptions,
12
12
  ) {
13
13
  let lDependencies = [];
14
- const lAST = parse.getASTCached(join(baseDir, pFileName), pTranspileOptions);
14
+ const lAST = getASTCached(join(baseDir, pFileName), pTranspileOptions);
15
15
 
16
16
  if (moduleSystems.includes("cjs")) {
17
17
  extractCommonJSDeps(lAST, lDependencies, "cjs", exoticRequireStrings);
@@ -27,6 +27,6 @@ export function extract(
27
27
  }
28
28
 
29
29
  export function getStats({ baseDir }, pFileName, pTranspileOptions) {
30
- const lAST = parse.getASTCached(join(baseDir, pFileName), pTranspileOptions);
30
+ const lAST = getASTCached(join(baseDir, pFileName), pTranspileOptions);
31
31
  return extractStats(lAST);
32
32
  }
@@ -92,9 +92,3 @@ export const getASTCached = memoize(getAST);
92
92
  export function clearCache() {
93
93
  memoizeClear(getASTCached);
94
94
  }
95
-
96
- export default {
97
- getASTFromSource,
98
- getASTCached,
99
- clearCache,
100
- };
@@ -1,15 +1,15 @@
1
- import tscParse from "./tsc/parse.mjs";
2
- import acornParse from "./acorn/parse.mjs";
3
- import swcParse from "./swc/parse.mjs";
1
+ import { clearCache as tscClearCache } from "./tsc/parse.mjs";
2
+ import { clearCache as acornClearCache } from "./acorn/parse.mjs";
3
+ import { clearCache as swcClearCache } from "./swc/parse.mjs";
4
4
  import { clearCache as externalModuleHelpers_clearCache } from "./resolve/external-module-helpers.mjs";
5
5
  import { clearCache as getManifest_clearCache } from "./resolve/get-manifest.mjs";
6
6
  import { clearCache as resolveAMD_clearCache } from "./resolve/resolve-amd.mjs";
7
7
  import { clearCache as resolve_clearCache } from "./resolve/resolve.mjs";
8
8
 
9
9
  export default function clearCaches() {
10
- tscParse.clearCache();
11
- acornParse.clearCache();
12
- swcParse.clearCache();
10
+ tscClearCache();
11
+ acornClearCache();
12
+ swcClearCache();
13
13
  externalModuleHelpers_clearCache();
14
14
  getManifest_clearCache();
15
15
  resolveAMD_clearCache();
@@ -1,12 +1,10 @@
1
1
  import { join } from "node:path/posix";
2
2
  import { isTypeScriptCompatible } from "../helpers.mjs";
3
3
  import extractSwcDeps from "./extract-swc-deps.mjs";
4
- import parse from "./parse.mjs";
4
+ import { getASTCached, isAvailable } from "./parse.mjs";
5
5
 
6
6
  export function shouldUse({ parser }, pFileName) {
7
- return (
8
- parser === "swc" && parse.isAvailable() && isTypeScriptCompatible(pFileName)
9
- );
7
+ return parser === "swc" && isAvailable() && isTypeScriptCompatible(pFileName);
10
8
  }
11
9
 
12
10
  export function extract(
@@ -14,7 +12,7 @@ export function extract(
14
12
  pFileName,
15
13
  ) {
16
14
  return extractSwcDeps(
17
- parse.getASTCached(join(baseDir, pFileName)),
15
+ getASTCached(join(baseDir, pFileName)),
18
16
  exoticRequireStrings,
19
17
  ).filter(({ moduleSystem }) => moduleSystems.includes(moduleSystem));
20
18
  }
@@ -26,31 +26,23 @@ function getAST(pFileName) {
26
26
  return swc.parseFileSync(pFileName, SWC_PARSE_OPTIONS);
27
27
  }
28
28
 
29
+ /**
30
+ * Compiles the file identified by pFileName into an (swc)
31
+ * AST and returns it. Subsequent calls for the same file name will
32
+ * return the result from a cache
33
+ *
34
+ * @param {string} pFileName - the name of the file to compile
35
+ * @return {import('@swc/core').ModuleItem[]} - an (swc) AST
36
+ */
29
37
  export const getASTCached = memoize(getAST);
30
38
 
31
39
  export function clearCache() {
32
40
  memoizeClear(getASTCached);
33
41
  }
34
42
 
35
- export default {
36
- getASTFromSource,
37
-
38
- /**
39
- * @return {boolean} - true if the swc compiler is available,
40
- * false in all other cases
41
- */
42
- // @ts-expect-error dfdfd
43
- isAvailable: () => swc !== false,
44
-
45
- /**
46
- * Compiles the file identified by pFileName into an (swc)
47
- * AST and returns it. Subsequent calls for the same file name will
48
- * return the result from a cache
49
- *
50
- * @param {string} pFileName - the name of the file to compile
51
- * @return {import('@swc/core').ModuleItem[]} - an (swc) AST
52
- */
53
- getASTCached,
54
-
55
- clearCache,
56
- };
43
+ /**
44
+ * @return {boolean} - true if the swc compiler is available,
45
+ * false in all other cases
46
+ */
47
+ // @ts-expect-error dfdfd
48
+ export const isAvailable = () => swc !== false;
@@ -1,13 +1,13 @@
1
1
  import { join } from "node:path";
2
2
  import { isTypeScriptCompatible } from "../helpers.mjs";
3
3
  import extractTypeScriptDeps from "./extract-typescript-deps.mjs";
4
- import parse from "./parse.mjs";
4
+ import { getASTCached, isAvailable } from "./parse.mjs";
5
5
  import extractStats from "./extract-stats.mjs";
6
6
 
7
7
  export function shouldUse({ tsPreCompilationDeps, parser }, pFileName) {
8
8
  return (
9
9
  (tsPreCompilationDeps || parser === "tsc") &&
10
- parse.isAvailable() &&
10
+ isAvailable() &&
11
11
  isTypeScriptCompatible(pFileName)
12
12
  );
13
13
  }
@@ -18,12 +18,12 @@ export function extract(
18
18
  pTranspileOptions,
19
19
  ) {
20
20
  return extractTypeScriptDeps(
21
- parse.getASTCached(join(baseDir, pFileName), pTranspileOptions),
21
+ getASTCached(join(baseDir, pFileName), pTranspileOptions),
22
22
  exoticRequireStrings,
23
23
  ).filter(({ moduleSystem }) => moduleSystems.includes(moduleSystem));
24
24
  }
25
25
 
26
26
  export function getStats({ baseDir }, pFileName, pTranspileOptions) {
27
- const lAST = parse.getASTCached(join(baseDir, pFileName), pTranspileOptions);
27
+ const lAST = getASTCached(join(baseDir, pFileName), pTranspileOptions);
28
28
  return extractStats(lAST);
29
29
  }
@@ -53,30 +53,22 @@ function getAST(pFileName, pTranspileOptions) {
53
53
  );
54
54
  }
55
55
 
56
+ /**
57
+ * Compiles the file identified by pFileName into a (typescript)
58
+ * AST and returns it. Subsequent calls for the same file name will
59
+ * return the result from a cache
60
+ *
61
+ * @param {string} pFileName - the name of the file to compile
62
+ * @return {object} - a (typescript) AST
63
+ */
56
64
  export const getASTCached = memoize(getAST);
57
65
 
66
+ /**
67
+ * @return {boolean} - true if the typescript compiler is available,
68
+ * false in all other cases
69
+ */
70
+ export const isAvailable = () => typescript !== false;
71
+
58
72
  export function clearCache() {
59
73
  memoizeClear(getASTCached);
60
74
  }
61
-
62
- export default {
63
- getASTFromSource,
64
-
65
- /**
66
- * @return {boolean} - true if the typescript compiler is available,
67
- * false in all other cases
68
- */
69
- isAvailable: () => typescript !== false,
70
-
71
- /**
72
- * Compiles the file identified by pFileName into a (typescript)
73
- * AST and returns it. Subsequent calls for the same file name will
74
- * return the result from a cache
75
- *
76
- * @param {string} pFileName - the name of the file to compile
77
- * @return {object} - a (typescript) AST
78
- */
79
- getASTCached,
80
-
81
- clearCache,
82
- };
@@ -10,35 +10,31 @@ function severity2number(pSeverity) {
10
10
  return lSeverity2Number.get(pSeverity) || -1;
11
11
  }
12
12
 
13
- export function severities(pFirstSeverity, pSecondSeverity) {
13
+ export function compareSeverities(pFirstSeverity, pSecondSeverity) {
14
14
  return Math.sign(
15
- severity2number(pFirstSeverity) - severity2number(pSecondSeverity)
15
+ severity2number(pFirstSeverity) - severity2number(pSecondSeverity),
16
16
  );
17
17
  }
18
18
 
19
- export function violations(pFirstViolation, pSecondViolation) {
19
+ export function compareViolations(pFirstViolation, pSecondViolation) {
20
20
  return (
21
- severities(pFirstViolation.rule.severity, pSecondViolation.rule.severity) ||
21
+ compareSeverities(
22
+ pFirstViolation.rule.severity,
23
+ pSecondViolation.rule.severity,
24
+ ) ||
22
25
  pFirstViolation.rule.name.localeCompare(pSecondViolation.rule.name) ||
23
26
  pFirstViolation.from.localeCompare(pSecondViolation.from) ||
24
27
  pFirstViolation.to.localeCompare(pSecondViolation.to)
25
28
  );
26
29
  }
27
30
 
28
- export function rules(pLeftRule, pRightRule) {
31
+ export function compareRules(pLeftRule, pRightRule) {
29
32
  return (
30
- severities(pLeftRule.severity, pRightRule.severity) ||
33
+ compareSeverities(pLeftRule.severity, pRightRule.severity) ||
31
34
  pLeftRule.name.localeCompare(pRightRule.name)
32
35
  );
33
36
  }
34
37
 
35
- export function modules(pLeftModule, pRightModule) {
38
+ export function compareModules(pLeftModule, pRightModule) {
36
39
  return pLeftModule.source > pRightModule.source ? 1 : -1;
37
40
  }
38
-
39
- export default {
40
- modules,
41
- rules,
42
- severities,
43
- violations,
44
- };
@@ -1,4 +1,4 @@
1
- import compare from "./compare.mjs";
1
+ import { compareRules } from "./compare.mjs";
2
2
  import { uniq } from "#utl/array-util.mjs";
3
3
 
4
4
  function mergeDependency(pLeftDependency, pRightDependency) {
@@ -10,7 +10,7 @@ function mergeDependency(pLeftDependency, pRightDependency) {
10
10
  ),
11
11
  rules: pLeftDependency.rules
12
12
  .concat(pRightDependency?.rules ?? [])
13
- .sort(compare.rules),
13
+ .sort(compareRules),
14
14
  valid: pLeftDependency.valid && pRightDependency.valid,
15
15
  };
16
16
  }
@@ -1,4 +1,4 @@
1
- import compare from "./compare.mjs";
1
+ import { compareRules } from "./compare.mjs";
2
2
  import { uniqBy } from "#utl/array-util.mjs";
3
3
 
4
4
  function mergeModule(pLeftModule, pRightModule) {
@@ -11,7 +11,7 @@ function mergeModule(pLeftModule, pRightModule) {
11
11
  ),
12
12
  rules: pLeftModule.rules
13
13
  .concat(pRightModule?.rules ?? [])
14
- .sort(compare.rules),
14
+ .sort(compareRules),
15
15
  valid: pLeftModule.valid && pRightModule.valid,
16
16
  consolidated:
17
17
  Boolean(pLeftModule.consolidated) || Boolean(pRightModule.consolidated),
@@ -1,6 +1,6 @@
1
1
  /* eslint-disable security/detect-object-injection */
2
2
  import safeRegex from "safe-regex";
3
- import report from "#report/index.mjs";
3
+ import { getAvailableReporters } from "#report/index.mjs";
4
4
 
5
5
  const MODULE_SYSTEM_LIST_RE = /^(?:(?:cjs|amd|es6|tsd)(?:,|$)){1,4}/gi;
6
6
  const VALID_DEPTH_RE = /^\d{1,2}$/g;
@@ -53,7 +53,7 @@ function assertRegExpSafety(pPattern) {
53
53
  function assertOutputTypeValid(pOutputType) {
54
54
  if (
55
55
  Boolean(pOutputType) &&
56
- !report.getAvailableReporters().includes(pOutputType) &&
56
+ !getAvailableReporters().includes(pOutputType) &&
57
57
  !pOutputType.startsWith("plugin:")
58
58
  ) {
59
59
  throw new Error(`'${pOutputType}' is not a valid output type.\n`);
@@ -1,8 +1,8 @@
1
- import report from "#report/index.mjs";
1
+ import { getReporter } from "#report/index.mjs";
2
2
  import summarize from "#enrich/summarize/index.mjs";
3
3
  import { applyFilters } from "#graph-utl/filter-bank.mjs";
4
4
  import consolidateToPattern from "#graph-utl/consolidate-to-pattern.mjs";
5
- import compare from "#graph-utl/compare.mjs";
5
+ import { compareModules } from "#graph-utl/compare.mjs";
6
6
  import stripSelfTransitions from "#graph-utl/strip-self-transitions.mjs";
7
7
 
8
8
  /**
@@ -16,7 +16,7 @@ function reSummarizeResults(pResult, pFormatOptions) {
16
16
 
17
17
  if (Object.hasOwn(pFormatOptions, "collapse")) {
18
18
  lModules = consolidateToPattern(lModules, pFormatOptions.collapse)
19
- .sort(compare.modules)
19
+ .sort(compareModules)
20
20
  .map(stripSelfTransitions);
21
21
  }
22
22
  return {
@@ -49,7 +49,7 @@ function getReporterSection(pOutputType) {
49
49
  * @returns {import("../../types/dependency-cruiser.js").IReporterOutput}
50
50
  */
51
51
  export default async function reportWrap(pResult, pFormatOptions) {
52
- const lReportFunction = await report.getReporter(pFormatOptions.outputType);
52
+ const lReportFunction = await getReporter(pFormatOptions.outputType);
53
53
  const lReportOptions =
54
54
  pResult.summary.optionsUsed?.reporterOptions?.[
55
55
  getReporterSection(pFormatOptions.outputType)
package/src/meta.cjs CHANGED
@@ -1,7 +1,7 @@
1
1
  /* generated - don't edit */
2
2
 
3
3
  module.exports = {
4
- version: "16.4.1",
4
+ version: "16.4.2",
5
5
  engines: {
6
6
  node: "^18.17||>=20",
7
7
  },
@@ -1,6 +1,6 @@
1
1
  /* eslint-disable prefer-template */
2
- import theming from "./theming.mjs";
3
- import moduleUtl from "./module-utl.mjs";
2
+ import { normalizeTheme } from "./theming.mjs";
3
+ import { attributizeObject } from "./module-utl.mjs";
4
4
  import prepareFolderLevel from "./prepare-folder-level.mjs";
5
5
  import prepareCustomLevel from "./prepare-custom-level.mjs";
6
6
  import prepareFlatLevel from "./prepare-flat-level.mjs";
@@ -25,21 +25,15 @@ const GRANULARITY2REPORTER_OPTIONS = new Map([
25
25
  ]);
26
26
 
27
27
  function buildGraphAttributes(pGraph) {
28
- return Boolean(pGraph)
29
- ? ` ${moduleUtl.attributizeObject(pGraph || {})}`
30
- : "";
28
+ return Boolean(pGraph) ? ` ${attributizeObject(pGraph || {})}` : "";
31
29
  }
32
30
 
33
31
  function buildNodeAttributes(pNode) {
34
- return Boolean(pNode)
35
- ? ` node [${moduleUtl.attributizeObject(pNode || {})}]`
36
- : "";
32
+ return Boolean(pNode) ? ` node [${attributizeObject(pNode || {})}]` : "";
37
33
  }
38
34
 
39
35
  function buildEdgeAttributes(pEdge) {
40
- return Boolean(pEdge)
41
- ? ` edge [${moduleUtl.attributizeObject(pEdge || {})}]`
42
- : "";
36
+ return Boolean(pEdge) ? ` edge [${attributizeObject(pEdge || {})}]` : "";
43
37
  }
44
38
 
45
39
  function buildGeneralAttributes(pTheme) {
@@ -120,7 +114,7 @@ function report(
120
114
  pGranularity,
121
115
  { theme, collapsePattern, filters, showMetrics },
122
116
  ) {
123
- const lTheme = theming.normalizeTheme(theme);
117
+ const lTheme = normalizeTheme(theme);
124
118
  const lResults = filters
125
119
  ? {
126
120
  ...pResults,
@@ -1,8 +1,7 @@
1
1
  import { basename, sep, dirname } from "node:path/posix";
2
2
  import { formatPercentage, getURLForModule } from "../utl/index.mjs";
3
- import theming from "./theming.mjs";
4
3
 
5
- function attributizeObject(pObject) {
4
+ export function attributizeObject(pObject) {
6
5
  return (
7
6
  Object.keys(pObject)
8
7
  // eslint-disable-next-line security/detect-object-injection
@@ -11,7 +10,7 @@ function attributizeObject(pObject) {
11
10
  );
12
11
  }
13
12
 
14
- function extractFirstTransgression(pModule) {
13
+ export function extractFirstTransgression(pModule) {
15
14
  return {
16
15
  ...(pModule?.rules?.[0]
17
16
  ? { ...pModule, tooltip: pModule.rules[0].name }
@@ -27,26 +26,6 @@ function extractFirstTransgression(pModule) {
27
26
  };
28
27
  }
29
28
 
30
- function applyTheme(pTheme) {
31
- return (pModule) => ({
32
- ...pModule,
33
- dependencies: pModule.dependencies
34
- .map((pDependency) => ({
35
- ...pDependency,
36
- themeAttrs: attributizeObject(
37
- theming.determineAttributes(pDependency, pTheme.dependencies),
38
- ),
39
- }))
40
- .map((pDependency) => ({
41
- ...pDependency,
42
- hasExtraAttributes: Boolean(pDependency.rule || pDependency.themeAttrs),
43
- })),
44
- themeAttrs: attributizeObject(
45
- theming.determineAttributes(pModule, pTheme.modules),
46
- ),
47
- });
48
- }
49
-
50
29
  function toFullPath(pAll, pCurrent) {
51
30
  return `${pAll}${pCurrent}${sep}`;
52
31
  }
@@ -75,7 +54,7 @@ function makeInstabilityString(pModule, pShowMetrics = false) {
75
54
  return lInstabilityString;
76
55
  }
77
56
 
78
- function folderify(pShowMetrics) {
57
+ export function folderify(pShowMetrics) {
79
58
  /** @param {import("../../../types/cruise-result").IModule} pModule*/
80
59
  return (pModule) => {
81
60
  let lAdditions = {};
@@ -103,7 +82,7 @@ function folderify(pShowMetrics) {
103
82
  * @param {string} pPrefix
104
83
  * @returns {URL?: string}
105
84
  */
106
- function addURL(pPrefix) {
85
+ export function addURL(pPrefix) {
107
86
  return (pModule) => {
108
87
  if (pModule.couldNotResolve) {
109
88
  return pModule;
@@ -122,19 +101,10 @@ function makeLabel(pModule, pShowMetrics) {
122
101
  )}</B>${makeInstabilityString(pModule, pShowMetrics)}>`;
123
102
  }
124
103
 
125
- function flatLabel(pShowMetrics) {
104
+ export function flatLabel(pShowMetrics) {
126
105
  return (pModule) => ({
127
106
  ...pModule,
128
107
  label: makeLabel(pModule, pShowMetrics),
129
108
  tooltip: basename(pModule.source),
130
109
  });
131
110
  }
132
-
133
- export default {
134
- folderify,
135
- applyTheme,
136
- extractFirstTransgression,
137
- attributizeObject,
138
- addURL,
139
- flatLabel,
140
- };
@@ -1,6 +1,7 @@
1
- import moduleUtl from "./module-utl.mjs";
1
+ import { folderify, addURL, extractFirstTransgression } from "./module-utl.mjs";
2
+ import { applyTheme } from "./theming.mjs";
2
3
  import consolidateToPattern from "#graph-utl/consolidate-to-pattern.mjs";
3
- import compare from "#graph-utl/compare.mjs";
4
+ import { compareModules } from "#graph-utl/compare.mjs";
4
5
  import stripSelfTransitions from "#graph-utl/strip-self-transitions.mjs";
5
6
 
6
7
  export default function prepareCustomLevel(
@@ -14,10 +15,10 @@ export default function prepareCustomLevel(
14
15
  ? consolidateToPattern(pResults.modules, pCollapsePattern)
15
16
  : pResults.modules
16
17
  )
17
- .sort(compare.modules)
18
- .map(moduleUtl.folderify(pShowMetrics))
19
- .map(moduleUtl.extractFirstTransgression)
18
+ .sort(compareModules)
19
+ .map(folderify(pShowMetrics))
20
+ .map(extractFirstTransgression)
20
21
  .map(stripSelfTransitions)
21
- .map(moduleUtl.applyTheme(pTheme))
22
- .map(moduleUtl.addURL(pResults.summary.optionsUsed?.prefix ?? ""));
22
+ .map(applyTheme(pTheme))
23
+ .map(addURL(pResults.summary.optionsUsed?.prefix ?? ""));
23
24
  }
@@ -1,11 +1,12 @@
1
- import moduleUtl from "./module-utl.mjs";
2
- import compare from "#graph-utl/compare.mjs";
1
+ import { flatLabel, extractFirstTransgression, addURL } from "./module-utl.mjs";
2
+ import { applyTheme } from "./theming.mjs";
3
+ import { compareModules } from "#graph-utl/compare.mjs";
3
4
 
4
5
  export default function prepareFlatLevel(pResults, pTheme, _, pShowMetrics) {
5
6
  return pResults.modules
6
- .sort(compare.modules)
7
- .map(moduleUtl.flatLabel(pShowMetrics))
8
- .map(moduleUtl.extractFirstTransgression)
9
- .map(moduleUtl.applyTheme(pTheme))
10
- .map(moduleUtl.addURL(pResults.summary.optionsUsed?.prefix ?? ""));
7
+ .sort(compareModules)
8
+ .map(flatLabel(pShowMetrics))
9
+ .map(extractFirstTransgression)
10
+ .map(applyTheme(pTheme))
11
+ .map(addURL(pResults.summary.optionsUsed?.prefix ?? ""));
11
12
  }