dependency-cruiser 16.3.5 → 16.3.6

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dependency-cruiser",
3
- "version": "16.3.5",
3
+ "version": "16.3.6",
4
4
  "description": "Validate and visualize dependencies. With your rules. JavaScript, TypeScript, CoffeeScript. ES6, CommonJS, AMD.",
5
5
  "keywords": [
6
6
  "static analysis",
@@ -138,13 +138,12 @@
138
138
  "README.md"
139
139
  ],
140
140
  "dependencies": {
141
- "acorn": "8.12.0",
141
+ "acorn": "8.12.1",
142
142
  "acorn-jsx": "5.3.2",
143
143
  "acorn-jsx-walk": "2.0.0",
144
144
  "acorn-loose": "8.4.0",
145
145
  "acorn-walk": "8.3.3",
146
146
  "ajv": "8.16.0",
147
- "chalk": "5.3.0",
148
147
  "commander": "12.1.0",
149
148
  "enhanced-resolve": "5.17.0",
150
149
  "ignore": "5.3.1",
@@ -153,6 +152,7 @@
153
152
  "json5": "2.2.3",
154
153
  "lodash": "4.17.21",
155
154
  "memoize": "10.0.0",
155
+ "picocolors": "1.0.1",
156
156
  "picomatch": "4.0.2",
157
157
  "prompts": "2.4.2",
158
158
  "rechoir": "^0.8.0",
@@ -160,7 +160,7 @@
160
160
  "semver": "^7.6.2",
161
161
  "teamcity-service-messages": "0.1.14",
162
162
  "tsconfig-paths-webpack-plugin": "4.1.0",
163
- "watskeburt": "4.0.2",
163
+ "watskeburt": "4.1.0",
164
164
  "wrap-ansi": "9.0.0"
165
165
  },
166
166
  "overrides": {
@@ -1,9 +1,9 @@
1
- import chalk from "chalk";
1
+ import pc from "picocolors";
2
2
 
3
3
  import { getAvailableTranspilers, allExtensions } from "#main/index.mjs";
4
4
 
5
5
  function bool2Symbol(pBool) {
6
- return pBool ? chalk.green("✔") : chalk.red("x");
6
+ return pBool ? pc.green("✔") : pc.red("x");
7
7
  }
8
8
 
9
9
  function formatTranspilers() {
@@ -28,7 +28,7 @@ export default function formatMetaInfo() {
28
28
  return `
29
29
  Supported:
30
30
 
31
- If you need a supported, but not enabled transpiler ('${chalk.red(
31
+ If you need a supported, but not enabled transpiler ('${pc.red(
32
32
  "x",
33
33
  )}' below), just install
34
34
  it in the same folder dependency-cruiser is installed. E.g. 'npm i livescript'
package/src/cli/index.mjs CHANGED
@@ -2,7 +2,7 @@ import { join } from "node:path";
2
2
  import picomatch from "picomatch";
3
3
  import set from "lodash/set.js";
4
4
  import isInstalledGlobally from "is-installed-globally";
5
- import chalk from "chalk";
5
+ import pc from "picocolors";
6
6
 
7
7
  import assertFileExistence from "./utl/assert-file-existence.mjs";
8
8
  import normalizeCliOptions from "./normalize-cli-options.mjs";
@@ -159,11 +159,13 @@ export default async function executeCli(
159
159
  /* c8 ignore start */
160
160
  if (isInstalledGlobally) {
161
161
  lStreams.stderr.write(
162
- `\n ${chalk.yellow(
162
+ `\n ${pc.yellow(
163
163
  "WARNING",
164
164
  )}: You're running a globally installed dependency-cruiser.\n\n` +
165
- ` We recommend to ${chalk.bold.italic.underline(
166
- "install and run it as a local devDependency",
165
+ ` We recommend to ${pc.bold(
166
+ pc.italic(
167
+ pc.underline("install and run it as a local devDependency"),
168
+ ),
167
169
  )} in\n` +
168
170
  ` your project instead. There it has your project's environment and\n` +
169
171
  ` transpilers at its disposal. That will ensure it can find e.g.\n` +
@@ -183,7 +185,7 @@ export default async function executeCli(
183
185
  lExitCode = await runCruise(pFileDirectoryArray, lCruiseOptions);
184
186
  }
185
187
  } catch (pError) {
186
- lStreams.stderr.write(`\n ${chalk.red("ERROR")}: ${pError.message}\n`);
188
+ lStreams.stderr.write(`\n ${pc.red("ERROR")}: ${pError.message}\n`);
187
189
  bus.emit("end");
188
190
  lExitCode = 1;
189
191
  }
@@ -1,5 +1,5 @@
1
1
  import { writeFileSync } from "node:fs";
2
- import chalk from "chalk";
2
+ import pc from "picocolors";
3
3
  import {
4
4
  fileExists,
5
5
  getDefaultConfigFileName,
@@ -29,7 +29,7 @@ export default function writeConfig(
29
29
  try {
30
30
  writeFileSync(pFileName, pConfig);
31
31
  pOutStream.write(
32
- `\n ${chalk.green("✔")} Successfully created '${pFileName}'\n\n`,
32
+ `\n ${pc.green("✔")} Successfully created '${pFileName}'\n\n`,
33
33
  );
34
34
  /* c8 ignore start */
35
35
  } catch (pError) {
@@ -2,7 +2,7 @@
2
2
  /* eslint-disable security/detect-object-injection */
3
3
  import { writeFileSync } from "node:fs";
4
4
  import { EOL } from "node:os";
5
- import chalk from "chalk";
5
+ import pc from "picocolors";
6
6
  import { PACKAGE_MANIFEST as _PACKAGE_MANIFEST } from "../defaults.mjs";
7
7
  import { readManifest } from "./environment-helpers.mjs";
8
8
  import { folderNameArrayToRE } from "./utl.mjs";
@@ -126,16 +126,14 @@ export function addRunScriptsToManifest(pManifest, pAdditionalRunScripts) {
126
126
  }
127
127
 
128
128
  function getSuccessMessage(pDestinationManifestFileName) {
129
- const lExplanationIndent = 6;
130
-
131
129
  return EXPERIMENTAL_SCRIPT_DOC.reduce(
132
130
  (pAll, pScript) => {
133
131
  return `${pAll}${
134
- `\n ${chalk.green("►")} ${pScript.headline}` +
132
+ `\n ${pc.green("►")} ${pScript.headline}` +
135
133
  `\n${pScript.description}\n\n`
136
134
  }`;
137
135
  },
138
- ` ${chalk.green("✔")} Run scripts added to '${pDestinationManifestFileName}':\n`,
136
+ ` ${pc.green("✔")} Run scripts added to '${pDestinationManifestFileName}':\n`,
139
137
  );
140
138
  }
141
139
 
@@ -1,4 +1,4 @@
1
- import chalk from "chalk";
1
+ import pc from "picocolors";
2
2
  import { SUMMARY } from "#utl/bus.mjs";
3
3
 
4
4
  const FULL_ON = 100;
@@ -17,7 +17,7 @@ function getPercentageBar(pPercentage, pParameters) {
17
17
  const lBlocks = Math.floor(lParameters.barSize * lPercentage);
18
18
  const lBlanks = lParameters.barSize - lBlocks;
19
19
 
20
- return `${chalk.green(lParameters.block.repeat(lBlocks))}${chalk.green(
20
+ return `${pc.green(lParameters.block.repeat(lBlocks))}${pc.green(
21
21
  lParameters.blank.repeat(lBlanks),
22
22
  )} ${Math.round(FULL_ON * lPercentage)}%`;
23
23
  }
@@ -1,4 +1,4 @@
1
- import chalk from "chalk";
1
+ import pc from "picocolors";
2
2
  import { INFO } from "#utl/bus.mjs";
3
3
 
4
4
  const MS_PER_SECOND = 1000;
@@ -43,7 +43,7 @@ export function formatDividerLine() {
43
43
  }
44
44
 
45
45
  export function formatHeader() {
46
- return chalk
46
+ return pc
47
47
  .bold(
48
48
  `${
49
49
  pad("∆ rss") +
@@ -59,7 +59,7 @@ export function formatHeader() {
59
59
  }
60
60
 
61
61
  function formatMessage(pMessage, pLevel) {
62
- return pLevel >= INFO ? chalk.dim(pMessage) : pMessage;
62
+ return pLevel >= INFO ? pc.dim(pMessage) : pMessage;
63
63
  }
64
64
 
65
65
  export function formatTime(
@@ -81,7 +81,7 @@ export function formatMemory(pBytes, pLevel) {
81
81
  );
82
82
 
83
83
  return formatMessage(
84
- (pBytes < 0 ? chalk.blue(lReturnValue) : lReturnValue).concat(" "),
84
+ (pBytes < 0 ? pc.blue(lReturnValue) : lReturnValue).concat(" "),
85
85
  pLevel,
86
86
  );
87
87
  }
@@ -1,4 +1,3 @@
1
- import flattenDeep from "lodash/flattenDeep.js";
2
1
  import uniqWith from "lodash/uniqWith.js";
3
2
  import isSameViolation from "./is-same-violation.mjs";
4
3
  import { findRuleByName } from "#graph-utl/rule-set.mjs";
@@ -72,18 +71,17 @@ function toDependencyViolationSummary(pRule, pModule, pDependency, pRuleSet) {
72
71
  * @return {any} an array of violations
73
72
  */
74
73
  function extractDependencyViolations(pModules, pRuleSet) {
75
- return flattenDeep(
76
- pModules
77
- .map(cutNonTransgressions)
78
- .filter((pModule) => pModule.dependencies.length > 0)
79
- .map((pModule) =>
80
- pModule.dependencies.map((pDependency) =>
81
- pDependency.rules.map((pRule) =>
82
- toDependencyViolationSummary(pRule, pModule, pDependency, pRuleSet),
83
- ),
74
+ return pModules
75
+ .map(cutNonTransgressions)
76
+ .filter((pModule) => pModule.dependencies.length > 0)
77
+ .map((pModule) =>
78
+ pModule.dependencies.map((pDependency) =>
79
+ pDependency.rules.map((pRule) =>
80
+ toDependencyViolationSummary(pRule, pModule, pDependency, pRuleSet),
84
81
  ),
85
82
  ),
86
- );
83
+ )
84
+ .flat(Infinity);
87
85
  }
88
86
 
89
87
  function toModuleViolationSummary(pRule, pModule, pRuleSet) {
@@ -1,5 +1,4 @@
1
1
  const { EOL } = require("node:os");
2
- const isEmpty = require("lodash/isEmpty");
3
2
  const tryRequire = require("#utl/try-require.cjs");
4
3
  const meta = require("#meta.cjs");
5
4
 
@@ -29,6 +28,12 @@ function getVueTemplateCompiler() {
29
28
  return { lCompiler, lIsVue3 };
30
29
  }
31
30
 
31
+ function isEmpty(pObject) {
32
+ return (
33
+ Object.entries(pObject).length === 0 && !pObject?.length && !pObject?.size
34
+ );
35
+ }
36
+
32
37
  const { lCompiler: vueTemplateCompiler, lIsVue3: isVue3 } =
33
38
  getVueTemplateCompiler();
34
39
 
@@ -1,4 +1,3 @@
1
- import reject from "lodash/reject.js";
2
1
  import compare from "./compare.mjs";
3
2
  import { uniq } from "#utl/array-util.mjs";
4
3
 
@@ -42,9 +41,10 @@ function consolidateDependencies(pDependencies) {
42
41
  lReturnValue.push(
43
42
  mergeDependencies(lDependencies[0].resolved, lDependencies),
44
43
  );
45
- lDependencies = reject(lDependencies, {
46
- resolved: lDependencies[0].resolved,
47
- });
44
+ lDependencies = lDependencies.filter(
45
+ // eslint-disable-next-line no-loop-func
46
+ (pDependency) => pDependency.resolved !== lDependencies[0].resolved,
47
+ );
48
48
  }
49
49
 
50
50
  return lReturnValue;
@@ -1,4 +1,3 @@
1
- import _reject from "lodash/reject.js";
2
1
  import uniqBy from "lodash/uniqBy.js";
3
2
  import compare from "./compare.mjs";
4
3
 
@@ -39,7 +38,10 @@ export default function consolidateModules(pModules) {
39
38
 
40
39
  while (lModules.length > 0) {
41
40
  lReturnValue.push(mergeModules(lModules[0].source, lModules));
42
- lModules = _reject(lModules, { source: lModules[0].source });
41
+ lModules = lModules.filter(
42
+ // eslint-disable-next-line no-loop-func
43
+ (pModule) => pModule.source !== lModules[0].source,
44
+ );
43
45
  }
44
46
  return lReturnValue;
45
47
  }
@@ -1,10 +1,33 @@
1
- import merge from "lodash/merge.js";
1
+ /* eslint-disable security/detect-object-injection */
2
2
  import safeRegex from "safe-regex";
3
3
  import report 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;
7
7
 
8
+ function isObject(pObject) {
9
+ return (
10
+ typeof pObject === "object" && !Array.isArray(pObject) && pObject !== null
11
+ );
12
+ }
13
+ function deepMerge(pTarget, pSource) {
14
+ const lOutput = structuredClone(pTarget);
15
+
16
+ for (const lKey in pSource) {
17
+ if (isObject(pSource[lKey])) {
18
+ if (lKey in pTarget) {
19
+ lOutput[lKey] = deepMerge(pTarget[lKey], pSource[lKey]);
20
+ } else {
21
+ Object.assign(lOutput, { [lKey]: pSource[lKey] });
22
+ }
23
+ } else {
24
+ Object.assign(lOutput, { [lKey]: pSource[lKey] });
25
+ }
26
+ }
27
+
28
+ return lOutput;
29
+ }
30
+
8
31
  function assertModuleSystemsValid(pModuleSystems) {
9
32
  if (
10
33
  Boolean(pModuleSystems) &&
@@ -102,7 +125,7 @@ export function assertCruiseOptionsValid(pOptions) {
102
125
  if (pOptions?.ruleSet?.options) {
103
126
  lReturnValue = assertCruiseOptionsValid(pOptions.ruleSet.options);
104
127
  }
105
- return merge({}, lReturnValue, pOptions);
128
+ return deepMerge(lReturnValue, pOptions);
106
129
  }
107
130
  return lReturnValue;
108
131
  }
@@ -1,6 +1,5 @@
1
1
  import fs from "node:fs";
2
2
  import enhancedResolve from "enhanced-resolve";
3
- import omit from "lodash/omit.js";
4
3
  import { scannableExtensions } from "#extract/transpile/meta.mjs";
5
4
  import {
6
5
  ruleSetHasDeprecationRule,
@@ -32,6 +31,13 @@ const DEFAULT_RESOLVE_OPTIONS = {
32
31
  exportsFields: [],
33
32
  };
34
33
 
34
+ function omit(pObject, pProperty) {
35
+ const lObject = structuredClone(pObject);
36
+ // eslint-disable-next-line security/detect-object-injection
37
+ delete lObject[pProperty];
38
+ return lObject;
39
+ }
40
+
35
41
  /**
36
42
  *
37
43
  * @param {Number} pCacheDuration
package/src/meta.cjs CHANGED
@@ -1,7 +1,7 @@
1
1
  /* generated - don't edit */
2
2
 
3
3
  module.exports = {
4
- version: "16.3.5",
4
+ version: "16.3.6",
5
5
  engines: {
6
6
  node: "^18.17||>=20",
7
7
  },
@@ -1,5 +1,5 @@
1
1
  import { EOL } from "node:os";
2
- import chalk from "chalk";
2
+ import pc from "picocolors";
3
3
  import {
4
4
  formatPercentage,
5
5
  formatViolation as _formatViolation,
@@ -7,11 +7,11 @@ import {
7
7
  import { findRuleByName } from "#graph-utl/rule-set.mjs";
8
8
  import wrapAndIndent from "#utl/wrap-and-indent.mjs";
9
9
 
10
- const SEVERITY2CHALK = new Map([
11
- ["error", chalk.red],
12
- ["warn", chalk.yellow],
13
- ["info", chalk.cyan],
14
- ["ignore", chalk.gray],
10
+ const SEVERITY2COLOR_FN = new Map([
11
+ ["error", pc.red],
12
+ ["warn", pc.yellow],
13
+ ["info", pc.cyan],
14
+ ["ignore", pc.gray],
15
15
  ]);
16
16
 
17
17
  const EXTRA_PATH_INFORMATION_INDENT = 6;
@@ -26,26 +26,26 @@ function formatMiniDependency(pMiniDependency) {
26
26
  }
27
27
 
28
28
  function formatModuleViolation(pViolation) {
29
- return chalk.bold(pViolation.from);
29
+ return pc.bold(pViolation.from);
30
30
  }
31
31
 
32
32
  function formatDependencyViolation(pViolation) {
33
- return `${chalk.bold(pViolation.from)} → ${chalk.bold(pViolation.to)}`;
33
+ return `${pc.bold(pViolation.from)} → ${pc.bold(pViolation.to)}`;
34
34
  }
35
35
 
36
36
  function formatCycleViolation(pViolation) {
37
- return `${chalk.bold(pViolation.from)} → ${formatMiniDependency(pViolation.cycle)}`;
37
+ return `${pc.bold(pViolation.from)} → ${formatMiniDependency(pViolation.cycle)}`;
38
38
  }
39
39
 
40
40
  function formatReachabilityViolation(pViolation) {
41
- return `${chalk.bold(pViolation.from)} → ${chalk.bold(
41
+ return `${pc.bold(pViolation.from)} → ${pc.bold(
42
42
  pViolation.to,
43
43
  )}${formatMiniDependency(pViolation.via)}`;
44
44
  }
45
45
 
46
46
  function formatInstabilityViolation(pViolation) {
47
47
  return `${formatDependencyViolation(pViolation)}${EOL}${wrapAndIndent(
48
- chalk.dim(
48
+ pc.dim(
49
49
  `instability: ${formatPercentage(pViolation.metrics.from.instability)} → ${formatPercentage(pViolation.metrics.to.instability)}`,
50
50
  ),
51
51
  EXTRA_PATH_INFORMATION_INDENT,
@@ -67,12 +67,12 @@ function formatViolation(pViolation) {
67
67
  );
68
68
 
69
69
  return (
70
- `${SEVERITY2CHALK.get(pViolation.rule.severity)(
70
+ `${SEVERITY2COLOR_FN.get(pViolation.rule.severity)(
71
71
  pViolation.rule.severity,
72
72
  )} ${pViolation.rule.name}: ${lFormattedViolators}` +
73
73
  `${
74
74
  pViolation.comment
75
- ? `${EOL}${wrapAndIndent(chalk.dim(pViolation.comment))}${EOL}`
75
+ ? `${EOL}${wrapAndIndent(pc.dim(pViolation.comment))}${EOL}`
76
76
  : ""
77
77
  }`
78
78
  );
@@ -93,7 +93,7 @@ function formatSummary(pSummary) {
93
93
  pSummary.totalCruised
94
94
  } modules, ${pSummary.totalDependenciesCruised} dependencies cruised.${EOL}`;
95
95
 
96
- return pSummary.error > 0 ? chalk.red(lMessage) : lMessage;
96
+ return pSummary.error > 0 ? pc.red(lMessage) : lMessage;
97
97
  }
98
98
 
99
99
  function addExplanation(pRuleSet, pLong) {
@@ -107,7 +107,7 @@ function addExplanation(pRuleSet, pLong) {
107
107
 
108
108
  function formatIgnoreWarning(pNumberOfIgnoredViolations) {
109
109
  if (pNumberOfIgnoredViolations > 0) {
110
- return chalk.yellow(
110
+ return pc.yellow(
111
111
  `‼ ${pNumberOfIgnoredViolations} known violations ignored. Run with --no-ignore-known to see them.${EOL}`,
112
112
  );
113
113
  }
@@ -120,7 +120,7 @@ function report(pResults, pLong) {
120
120
  );
121
121
 
122
122
  if (lNonIgnorableViolations.length === 0) {
123
- return `${EOL}${chalk.green("✔")} no dependency violations found (${
123
+ return `${EOL}${pc.green("✔")} no dependency violations found (${
124
124
  pResults.summary.totalCruised
125
125
  } modules, ${
126
126
  pResults.summary.totalDependenciesCruised
@@ -1,5 +1,5 @@
1
1
  import { EOL } from "node:os";
2
- import chalk from "chalk";
2
+ import pc from "picocolors";
3
3
  import { formatNumber, formatPercentage } from "./utl/index.mjs";
4
4
 
5
5
  /**
@@ -224,7 +224,7 @@ function formatToTextData(pData, pMetaData) {
224
224
  * @returns {string}
225
225
  */
226
226
  function formatToTextTable(pData, pMetaData) {
227
- return [chalk.bold(formatToTextHeader(pMetaData))]
227
+ return [pc.bold(formatToTextHeader(pMetaData))]
228
228
  .concat(formatToTextDemarcationLine(pMetaData))
229
229
  .concat(formatToTextData(pData, pMetaData))
230
230
  .join(EOL)
@@ -1,4 +1,4 @@
1
- import chalk from "chalk";
1
+ import pc from "picocolors";
2
2
 
3
3
  const DEFAULT_OPTIONS = {
4
4
  highlightFocused: false,
@@ -36,7 +36,7 @@ function toFlatDependencies(pModules, pModulesInFocus, pHighlightFocused) {
36
36
  }
37
37
 
38
38
  function stringifyModule(pModule) {
39
- return pModule.highlight ? chalk.underline(pModule.name) : pModule.name;
39
+ return pModule.highlight ? pc.underline(pModule.name) : pModule.name;
40
40
  }
41
41
 
42
42
  function stringify(pFlatDependency) {