dependency-cruiser 16.3.5 → 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 +5 -6
- package/src/cli/format-meta-info.mjs +3 -3
- package/src/cli/index.mjs +7 -5
- package/src/cli/init-config/write-config.mjs +2 -2
- package/src/cli/init-config/write-run-scripts-to-manifest.mjs +3 -5
- package/src/cli/listeners/cli-feedback.mjs +2 -2
- package/src/cli/listeners/performance-log/format-helpers.mjs +4 -4
- package/src/enrich/summarize/summarize-modules.mjs +9 -11
- package/src/extract/transpile/vue-template-wrap.cjs +6 -1
- package/src/graph-utl/consolidate-module-dependencies.mjs +4 -4
- package/src/graph-utl/consolidate-modules.mjs +4 -2
- package/src/main/options/assert-validity.mjs +25 -2
- package/src/main/resolve-options/normalize.mjs +7 -1
- package/src/meta.cjs +1 -1
- package/src/report/error.mjs +18 -18
- package/src/report/metrics.mjs +2 -2
- package/src/report/text.mjs +2 -2
- package/src/utl/wrap-and-indent.mjs +46 -6
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dependency-cruiser",
|
|
3
|
-
"version": "16.3.
|
|
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",
|
|
@@ -138,13 +138,12 @@
|
|
|
138
138
|
"README.md"
|
|
139
139
|
],
|
|
140
140
|
"dependencies": {
|
|
141
|
-
"acorn": "8.12.
|
|
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
|
-
"ajv": "8.
|
|
147
|
-
"chalk": "5.3.0",
|
|
146
|
+
"ajv": "8.17.1",
|
|
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,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.0
|
|
164
|
-
"wrap-ansi": "9.0.0"
|
|
163
|
+
"watskeburt": "4.1.0"
|
|
165
164
|
},
|
|
166
165
|
"overrides": {
|
|
167
166
|
"semver": "^7.6.2",
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import
|
|
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 ?
|
|
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 ('${
|
|
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
|
|
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 ${
|
|
162
|
+
`\n ${pc.yellow(
|
|
163
163
|
"WARNING",
|
|
164
164
|
)}: You're running a globally installed dependency-cruiser.\n\n` +
|
|
165
|
-
` We recommend to ${
|
|
166
|
-
|
|
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 ${
|
|
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
|
|
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 ${
|
|
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
|
|
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 ${
|
|
132
|
+
`\n ${pc.green("►")} ${pScript.headline}` +
|
|
135
133
|
`\n${pScript.description}\n\n`
|
|
136
134
|
}`;
|
|
137
135
|
},
|
|
138
|
-
` ${
|
|
136
|
+
` ${pc.green("✔")} Run scripts added to '${pDestinationManifestFileName}':\n`,
|
|
139
137
|
);
|
|
140
138
|
}
|
|
141
139
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
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 `${
|
|
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
|
|
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
|
|
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 ?
|
|
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 ?
|
|
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
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
.map((
|
|
80
|
-
|
|
81
|
-
|
|
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 =
|
|
46
|
-
|
|
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 =
|
|
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
|
-
|
|
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
|
|
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
package/src/report/error.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { EOL } from "node:os";
|
|
2
|
-
import
|
|
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
|
|
11
|
-
["error",
|
|
12
|
-
["warn",
|
|
13
|
-
["info",
|
|
14
|
-
["ignore",
|
|
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,29 +26,29 @@ function formatMiniDependency(pMiniDependency) {
|
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
function formatModuleViolation(pViolation) {
|
|
29
|
-
return
|
|
29
|
+
return pc.bold(pViolation.from);
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
function formatDependencyViolation(pViolation) {
|
|
33
|
-
return `${
|
|
33
|
+
return `${pc.bold(pViolation.from)} → ${pc.bold(pViolation.to)}`;
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
function formatCycleViolation(pViolation) {
|
|
37
|
-
return `${
|
|
37
|
+
return `${pc.bold(pViolation.from)} → ${formatMiniDependency(pViolation.cycle)}`;
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
function formatReachabilityViolation(pViolation) {
|
|
41
|
-
return `${
|
|
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
|
-
return `${formatDependencyViolation(pViolation)}${EOL}${
|
|
48
|
-
|
|
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
|
|
|
@@ -67,12 +67,12 @@ function formatViolation(pViolation) {
|
|
|
67
67
|
);
|
|
68
68
|
|
|
69
69
|
return (
|
|
70
|
-
`${
|
|
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}${
|
|
75
|
+
? `${EOL}${pc.dim(wrapAndIndent(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 ?
|
|
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
|
|
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}${
|
|
123
|
+
return `${EOL}${pc.green("✔")} no dependency violations found (${
|
|
124
124
|
pResults.summary.totalCruised
|
|
125
125
|
} modules, ${
|
|
126
126
|
pResults.summary.totalDependenciesCruised
|
package/src/report/metrics.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { EOL } from "node:os";
|
|
2
|
-
import
|
|
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 [
|
|
227
|
+
return [pc.bold(formatToTextHeader(pMetaData))]
|
|
228
228
|
.concat(formatToTextDemarcationLine(pMetaData))
|
|
229
229
|
.concat(formatToTextData(pData, pMetaData))
|
|
230
230
|
.join(EOL)
|
package/src/report/text.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
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 ?
|
|
39
|
+
return pModule.highlight ? pc.underline(pModule.name) : pModule.name;
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
function stringify(pFlatDependency) {
|
|
@@ -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
|
-
|
|
12
|
-
|
|
13
|
-
|
|
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(
|
|
55
|
+
return indentString(wrapString(pString, lMaxWidth), pIndent);
|
|
16
56
|
}
|