dependency-cruiser 16.3.6 → 16.3.7

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.6",
3
+ "version": "16.3.7",
4
4
  "description": "Validate and visualize dependencies. With your rules. JavaScript, TypeScript, CoffeeScript. ES6, CommonJS, AMD.",
5
5
  "keywords": [
6
6
  "static analysis",
@@ -143,7 +143,7 @@
143
143
  "acorn-jsx-walk": "2.0.0",
144
144
  "acorn-loose": "8.4.0",
145
145
  "acorn-walk": "8.3.3",
146
- "ajv": "8.16.0",
146
+ "ajv": "8.17.1",
147
147
  "commander": "12.1.0",
148
148
  "enhanced-resolve": "5.17.0",
149
149
  "ignore": "5.3.1",
@@ -160,8 +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.1.0",
164
- "wrap-ansi": "9.0.0"
163
+ "watskeburt": "4.1.0"
165
164
  },
166
165
  "overrides": {
167
166
  "semver": "^7.6.2",
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.6",
4
+ version: "16.3.7",
5
5
  engines: {
6
6
  node: "^18.17||>=20",
7
7
  },
@@ -44,11 +44,11 @@ function formatReachabilityViolation(pViolation) {
44
44
  }
45
45
 
46
46
  function formatInstabilityViolation(pViolation) {
47
- return `${formatDependencyViolation(pViolation)}${EOL}${wrapAndIndent(
48
- pc.dim(
47
+ return `${formatDependencyViolation(pViolation)}${EOL}${pc.dim(
48
+ wrapAndIndent(
49
49
  `instability: ${formatPercentage(pViolation.metrics.from.instability)} → ${formatPercentage(pViolation.metrics.to.instability)}`,
50
+ EXTRA_PATH_INFORMATION_INDENT,
50
51
  ),
51
- EXTRA_PATH_INFORMATION_INDENT,
52
52
  )}`;
53
53
  }
54
54
 
@@ -72,7 +72,7 @@ function formatViolation(pViolation) {
72
72
  )} ${pViolation.rule.name}: ${lFormattedViolators}` +
73
73
  `${
74
74
  pViolation.comment
75
- ? `${EOL}${wrapAndIndent(pc.dim(pViolation.comment))}${EOL}`
75
+ ? `${EOL}${pc.dim(wrapAndIndent(pViolation.comment))}${EOL}`
76
76
  : ""
77
77
  }`
78
78
  );
@@ -1,5 +1,3 @@
1
- import wrapAnsi from "wrap-ansi";
2
-
3
1
  const DEFAULT_INDENT = 4;
4
2
 
5
3
  function indentString(pString, pCount) {
@@ -8,9 +6,51 @@ function indentString(pString, pCount) {
8
6
  return pString.replace(lRegex, " ".repeat(pCount));
9
7
  }
10
8
 
11
- export default function wrapAndIndent(pString, pCount = DEFAULT_INDENT) {
12
- const lDogmaticMaxConsoleWidth = 78;
13
- const lMaxWidth = lDogmaticMaxConsoleWidth - pCount;
9
+ /**
10
+ * @param {string} pLine
11
+ * @param {number} pMaxWidth
12
+ */
13
+ function splitLine(pLine, pMaxWidth) {
14
+ const lWords = pLine.split(" ");
15
+ const lWrappedLines = [];
16
+ let lCurrentLine = "";
17
+ let lCurrentWidth = 0;
18
+
19
+ for (const lWord of lWords) {
20
+ if (lCurrentWidth + lWord.length > pMaxWidth) {
21
+ lWrappedLines.push(lCurrentLine.trimEnd());
22
+ lCurrentLine = "";
23
+ lCurrentWidth = 0;
24
+ }
25
+
26
+ if (lCurrentLine) {
27
+ lCurrentLine += " ";
28
+ lCurrentWidth += 1;
29
+ }
30
+
31
+ lCurrentLine += lWord;
32
+ lCurrentWidth += lWord.length;
33
+ }
34
+
35
+ lWrappedLines.push(lCurrentLine.trimEnd());
36
+
37
+ return lWrappedLines.join("\n");
38
+ }
39
+
40
+ /**
41
+ * @param {string} pString - the string to wrap
42
+ * @param {number} pMaxWidth - the maximum width of the wrapped string
43
+ */
44
+ function wrapString(pString, pMaxWidth) {
45
+ return pString
46
+ .split(/\r?\n/)
47
+ .map((pLine) => splitLine(pLine, pMaxWidth))
48
+ .join("\n");
49
+ }
50
+
51
+ export default function wrapAndIndent(pString, pIndent = DEFAULT_INDENT) {
52
+ const lMaxConsoleWidth = 78;
53
+ const lMaxWidth = lMaxConsoleWidth - pIndent;
14
54
 
15
- return indentString(wrapAnsi(pString, lMaxWidth), pCount);
55
+ return indentString(wrapString(pString, lMaxWidth), pIndent);
16
56
  }