dependency-cruiser 16.3.2 → 16.3.4
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/configs/plugins/3d-reporter-plugin.mjs +4 -7
- package/package.json +12 -14
- package/src/cache/helpers.mjs +0 -1
- package/src/cli/format-meta-info.mjs +2 -3
- package/src/cli/init-config/config-template.mjs +19 -32
- package/src/cli/init-config/write-config.mjs +1 -4
- package/src/cli/init-config/write-run-scripts-to-manifest.mjs +21 -13
- package/src/cli/listeners/cli-feedback.mjs +2 -3
- package/src/config-utl/extract-babel-config.mjs +1 -1
- package/src/config-utl/extract-ts-config.mjs +1 -1
- package/src/enrich/summarize/summarize-options.mjs +1 -0
- package/src/extract/swc/dependency-visitor.mjs +1 -1
- package/src/extract/swc/parse.mjs +1 -1
- package/src/extract/transpile/babel-wrap.mjs +1 -1
- package/src/extract/transpile/coffeescript-wrap.mjs +1 -1
- package/src/extract/transpile/livescript-wrap.mjs +1 -1
- package/src/extract/transpile/svelte-wrap.mjs +1 -1
- package/src/extract/transpile/typescript-wrap.mjs +1 -1
- package/src/extract/transpile/vue-template-wrap.cjs +1 -1
- package/src/extract/tsc/extract-typescript-deps.mjs +1 -1
- package/src/extract/tsc/parse.mjs +1 -1
- package/src/meta.cjs +1 -1
- package/src/report/error.mjs +8 -19
- package/src/report/text.mjs +1 -4
- package/src/schema/baseline-violations.schema.mjs +1 -1
- package/src/schema/configuration.schema.mjs +1 -1
- package/src/schema/cruise-result.schema.mjs +1 -1
- package/src/utl/extract-root-module-name.cjs +23 -0
- package/src/utl/try-import.mjs +67 -0
- package/src/utl/try-require.cjs +51 -0
- package/src/utl/wrap-and-indent.mjs +9 -4
- package/src/cli/init-config/types.d.ts +0 -101
- package/src/extract/transpile/meta.d.ts +0 -21
- package/src/main/index.d.ts +0 -4
- package/src/validate/index.d.ts +0 -61
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import * as path from "node:path";
|
|
2
|
-
import figures from "figures";
|
|
3
2
|
|
|
4
3
|
const TEMPLATE = `
|
|
5
4
|
<html>
|
|
@@ -74,9 +73,7 @@ function formatFileName(pFileName) {
|
|
|
74
73
|
return `${path.dirname(pFileName)}/<b>${path.basename(pFileName)}</b>`;
|
|
75
74
|
}
|
|
76
75
|
function formatDependency(pFrom, pTo) {
|
|
77
|
-
return `${formatFileName(pFrom)}
|
|
78
|
-
pTo
|
|
79
|
-
)}`;
|
|
76
|
+
return `${formatFileName(pFrom)} →</br>${formatFileName(pTo)}`;
|
|
80
77
|
}
|
|
81
78
|
|
|
82
79
|
/**
|
|
@@ -100,14 +97,14 @@ function render3DThing(pCruiseResult) {
|
|
|
100
97
|
source: pCurrentModule.source,
|
|
101
98
|
target: pDependency.resolved,
|
|
102
99
|
label: formatDependency(pCurrentModule.source, pDependency.resolved),
|
|
103
|
-
}))
|
|
100
|
+
})),
|
|
104
101
|
),
|
|
105
|
-
[]
|
|
102
|
+
[],
|
|
106
103
|
);
|
|
107
104
|
|
|
108
105
|
return TEMPLATE.replace(/@@NODES@@/g, JSON.stringify(lNodes)).replace(
|
|
109
106
|
/@@LINKS@@/g,
|
|
110
|
-
JSON.stringify(lLinks)
|
|
107
|
+
JSON.stringify(lLinks),
|
|
111
108
|
);
|
|
112
109
|
}
|
|
113
110
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dependency-cruiser",
|
|
3
|
-
"version": "16.3.
|
|
3
|
+
"version": "16.3.4",
|
|
4
4
|
"description": "Validate and visualize dependencies. With your rules. JavaScript, TypeScript, CoffeeScript. ES6, CommonJS, AMD.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"static analysis",
|
|
@@ -59,6 +59,7 @@
|
|
|
59
59
|
"electrovir (https://github.com/electrovir)",
|
|
60
60
|
"fusheng (https://github.com/lin-hun)"
|
|
61
61
|
],
|
|
62
|
+
"type": "module",
|
|
62
63
|
"license": "MIT",
|
|
63
64
|
"repository": {
|
|
64
65
|
"type": "git",
|
|
@@ -127,6 +128,7 @@
|
|
|
127
128
|
"configs/plugins/",
|
|
128
129
|
"src",
|
|
129
130
|
"!src/**/*.json",
|
|
131
|
+
"!src/**/*.ts",
|
|
130
132
|
"!src/**/*.md",
|
|
131
133
|
"!**/*.DS_Store",
|
|
132
134
|
"types/**/*.d.mts",
|
|
@@ -135,18 +137,16 @@
|
|
|
135
137
|
"README.md"
|
|
136
138
|
],
|
|
137
139
|
"dependencies": {
|
|
138
|
-
"acorn": "8.
|
|
140
|
+
"acorn": "8.12.0",
|
|
139
141
|
"acorn-jsx": "5.3.2",
|
|
140
142
|
"acorn-jsx-walk": "2.0.0",
|
|
141
143
|
"acorn-loose": "8.4.0",
|
|
142
|
-
"acorn-walk": "8.3.
|
|
143
|
-
"ajv": "8.
|
|
144
|
+
"acorn-walk": "8.3.3",
|
|
145
|
+
"ajv": "8.16.0",
|
|
144
146
|
"chalk": "5.3.0",
|
|
145
|
-
"commander": "12.
|
|
146
|
-
"enhanced-resolve": "5.
|
|
147
|
-
"figures": "6.1.0",
|
|
147
|
+
"commander": "12.1.0",
|
|
148
|
+
"enhanced-resolve": "5.17.0",
|
|
148
149
|
"ignore": "5.3.1",
|
|
149
|
-
"indent-string": "5.0.0",
|
|
150
150
|
"interpret": "^3.1.1",
|
|
151
151
|
"is-installed-globally": "1.0.0",
|
|
152
152
|
"json5": "2.2.3",
|
|
@@ -156,19 +156,18 @@
|
|
|
156
156
|
"prompts": "2.4.2",
|
|
157
157
|
"rechoir": "^0.8.0",
|
|
158
158
|
"safe-regex": "2.1.1",
|
|
159
|
-
"semver": "^7.6.
|
|
160
|
-
"semver-try-require": "7.0.0",
|
|
159
|
+
"semver": "^7.6.2",
|
|
161
160
|
"teamcity-service-messages": "0.1.14",
|
|
162
161
|
"tsconfig-paths-webpack-plugin": "4.1.0",
|
|
163
162
|
"watskeburt": "4.0.2",
|
|
164
163
|
"wrap-ansi": "9.0.0"
|
|
165
164
|
},
|
|
166
165
|
"overrides": {
|
|
167
|
-
"semver": "^7.6.
|
|
166
|
+
"semver": "^7.6.2",
|
|
168
167
|
"postcss": "^8.4.31"
|
|
169
168
|
},
|
|
170
169
|
"resolutions": {
|
|
171
|
-
"semver": "^7.6.
|
|
170
|
+
"semver": "^7.6.2",
|
|
172
171
|
"postcss": "^8.4.31"
|
|
173
172
|
},
|
|
174
173
|
"engines": {
|
|
@@ -176,6 +175,5 @@
|
|
|
176
175
|
},
|
|
177
176
|
"scripts": {
|
|
178
177
|
"test": "echo for test, build and static analysis scripts: see the github repository"
|
|
179
|
-
}
|
|
180
|
-
"type": "module"
|
|
178
|
+
}
|
|
181
179
|
}
|
package/src/cache/helpers.mjs
CHANGED
|
@@ -3,7 +3,6 @@ import { createHash } from "node:crypto";
|
|
|
3
3
|
import { readFileSync } from "node:fs";
|
|
4
4
|
import { extname } from "node:path";
|
|
5
5
|
import memoize from "memoize";
|
|
6
|
-
// @ts-expect-error ts(2307) - the ts compiler is not privy to the existence of #imports in package.json
|
|
7
6
|
import { filenameMatchesPattern } from "#graph-utl/match-facade.mjs";
|
|
8
7
|
|
|
9
8
|
/**
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import chalk from "chalk";
|
|
2
|
-
import figures from "figures";
|
|
3
2
|
|
|
4
3
|
import { getAvailableTranspilers, allExtensions } from "#main/index.mjs";
|
|
5
4
|
|
|
6
5
|
function bool2Symbol(pBool) {
|
|
7
|
-
return pBool ? chalk.green(
|
|
6
|
+
return pBool ? chalk.green("✔") : chalk.red("x");
|
|
8
7
|
}
|
|
9
8
|
|
|
10
9
|
function formatTranspilers() {
|
|
@@ -30,7 +29,7 @@ export default function formatMetaInfo() {
|
|
|
30
29
|
Supported:
|
|
31
30
|
|
|
32
31
|
If you need a supported, but not enabled transpiler ('${chalk.red(
|
|
33
|
-
|
|
32
|
+
"x",
|
|
34
33
|
)}' below), just install
|
|
35
34
|
it in the same folder dependency-cruiser is installed. E.g. 'npm i livescript'
|
|
36
35
|
will enable livescript support if it's installed in your project folder.
|
|
@@ -136,7 +136,7 @@ module.exports = {
|
|
|
136
136
|
severity: 'error',
|
|
137
137
|
from: {},
|
|
138
138
|
to: {
|
|
139
|
-
path: '[.](?:spec|test)[.](?:js|mjs|cjs|jsx|ts|mts|cts|tsx
|
|
139
|
+
path: '[.](?:spec|test)[.](?:js|mjs|cjs|jsx|ts|mts|cts|tsx)$'
|
|
140
140
|
}
|
|
141
141
|
},
|
|
142
142
|
{
|
|
@@ -150,7 +150,7 @@ module.exports = {
|
|
|
150
150
|
'from.pathNot re of the not-to-dev-dep rule in the dependency-cruiser configuration',
|
|
151
151
|
from: {
|
|
152
152
|
path: '{{sourceLocationRE}}',
|
|
153
|
-
pathNot: '[.](?:spec|test)[.](?:js|mjs|cjs|jsx|ts|mts|cts|tsx
|
|
153
|
+
pathNot: '[.](?:spec|test)[.](?:js|mjs|cjs|jsx|ts|mts|cts|tsx)$'
|
|
154
154
|
},
|
|
155
155
|
to: {
|
|
156
156
|
dependencyTypes: [
|
|
@@ -216,12 +216,6 @@ module.exports = {
|
|
|
216
216
|
*/
|
|
217
217
|
// includeOnly : [''],
|
|
218
218
|
|
|
219
|
-
/* dependency-cruiser will include modules matching against the focus
|
|
220
|
-
regular expression in its output, as well as their direct neighbours
|
|
221
|
-
(dependencies and dependents)
|
|
222
|
-
*/
|
|
223
|
-
// focus : '',
|
|
224
|
-
|
|
225
219
|
/* List of module systems to cruise.
|
|
226
220
|
When left out dependency-cruiser will fall back to the list of _all_
|
|
227
221
|
module systems it knows of. It's the default because it's the safe option
|
|
@@ -234,7 +228,7 @@ module.exports = {
|
|
|
234
228
|
|
|
235
229
|
// moduleSystems: ['cjs', 'es6'],
|
|
236
230
|
|
|
237
|
-
/* prefix for links in html and svg output (e.g. 'https://github.com/you/yourrepo/blob/
|
|
231
|
+
/* prefix for links in html and svg output (e.g. 'https://github.com/you/yourrepo/blob/main/'
|
|
238
232
|
to open it on your online repo or \`vscode://file/$\{process.cwd()}/\` to
|
|
239
233
|
open it in visual studio code),
|
|
240
234
|
*/
|
|
@@ -277,15 +271,14 @@ module.exports = {
|
|
|
277
271
|
to dependency-cruiser's current working directory. When not provided defaults
|
|
278
272
|
to './webpack.conf.js'.
|
|
279
273
|
|
|
280
|
-
The (optional) \`env\` and \`arguments\` attributes contain the parameters
|
|
281
|
-
your webpack config is a function and takes them (see
|
|
282
|
-
|
|
274
|
+
The (optional) \`env\` and \`arguments\` attributes contain the parameters
|
|
275
|
+
to be passed if your webpack config is a function and takes them (see
|
|
276
|
+
webpack documentation for details)
|
|
283
277
|
*/
|
|
284
278
|
{{webpackConfigAttribute}}
|
|
285
279
|
|
|
286
280
|
/* Babel config ('.babelrc', '.babelrc.json', '.babelrc.json5', ...) to use
|
|
287
|
-
for compilation
|
|
288
|
-
source code).
|
|
281
|
+
for compilation
|
|
289
282
|
*/
|
|
290
283
|
{{babelConfigAttribute}}
|
|
291
284
|
|
|
@@ -313,10 +306,9 @@ module.exports = {
|
|
|
313
306
|
/*
|
|
314
307
|
The extensions, by default are the same as the ones dependency-cruiser
|
|
315
308
|
can access (run \`npx depcruise --info\` to see which ones that are in
|
|
316
|
-
_your_ environment. If that list is larger than you need you can pass
|
|
309
|
+
_your_ environment). If that list is larger than you need you can pass
|
|
317
310
|
the extensions you actually use (e.g. [".js", ".jsx"]). This can speed
|
|
318
|
-
up the most expensive step
|
|
319
|
-
quite a bit.
|
|
311
|
+
up module resolution, which is the most expensive step.
|
|
320
312
|
*/
|
|
321
313
|
{{extensionsAttribute}}
|
|
322
314
|
/* What to consider a 'main' field in package.json */
|
|
@@ -324,10 +316,10 @@ module.exports = {
|
|
|
324
316
|
/*
|
|
325
317
|
A list of alias fields in package.jsons
|
|
326
318
|
See [this specification](https://github.com/defunctzombie/package-browser-field-spec) and
|
|
327
|
-
the [resolve.alias](https://webpack.js.org/configuration/resolve/#resolvealiasfields)
|
|
328
|
-
documentation
|
|
319
|
+
the webpack [resolve.alias](https://webpack.js.org/configuration/resolve/#resolvealiasfields)
|
|
320
|
+
documentation
|
|
329
321
|
|
|
330
|
-
Defaults to an empty array (don't use
|
|
322
|
+
Defaults to an empty array (= don't use alias fields).
|
|
331
323
|
*/
|
|
332
324
|
// aliasFields: ["browser"],
|
|
333
325
|
},
|
|
@@ -336,21 +328,19 @@ module.exports = {
|
|
|
336
328
|
/* pattern of modules that can be consolidated in the detailed
|
|
337
329
|
graphical dependency graph. The default pattern in this configuration
|
|
338
330
|
collapses everything in node_modules to one folder deep so you see
|
|
339
|
-
the external modules, but
|
|
331
|
+
the external modules, but their innards.
|
|
340
332
|
*/
|
|
341
333
|
collapsePattern: 'node_modules/(?:@[^/]+/[^/]+|[^/]+)',
|
|
342
334
|
|
|
343
335
|
/* Options to tweak the appearance of your graph.See
|
|
344
336
|
https://github.com/sverweij/dependency-cruiser/blob/main/doc/options-reference.md#reporteroptions
|
|
345
337
|
for details and some examples. If you don't specify a theme
|
|
346
|
-
|
|
338
|
+
dependency-cruiser falls back to a built-in one.
|
|
347
339
|
*/
|
|
348
340
|
// theme: {
|
|
349
341
|
// graph: {
|
|
350
|
-
// /* splines: "ortho"
|
|
351
|
-
//
|
|
352
|
-
// splines: "true" will give you bezier curves which are faster
|
|
353
|
-
// but might not look as nice
|
|
342
|
+
// /* splines: "ortho" gives straight lines, but is slow on big graphs
|
|
343
|
+
// splines: "true" gives bezier curves (fast, not as nice as ortho)
|
|
354
344
|
// */
|
|
355
345
|
// splines: "true"
|
|
356
346
|
// },
|
|
@@ -364,14 +354,11 @@ module.exports = {
|
|
|
364
354
|
*/
|
|
365
355
|
collapsePattern: '^(?:packages|src|lib(s?)|app(s?)|bin|test(s?)|spec(s?))/[^/]+|node_modules/(?:@[^/]+/[^/]+|[^/]+)',
|
|
366
356
|
|
|
367
|
-
/* Options to tweak the appearance of your graph.
|
|
368
|
-
|
|
369
|
-
for details and some examples. If you don't specify a theme
|
|
370
|
-
for 'archi' dependency-cruiser will use the one specified in the
|
|
357
|
+
/* Options to tweak the appearance of your graph. If you don't specify a
|
|
358
|
+
theme for 'archi' dependency-cruiser will use the one specified in the
|
|
371
359
|
dot section above and otherwise use the default one.
|
|
372
360
|
*/
|
|
373
|
-
// theme: {
|
|
374
|
-
// },
|
|
361
|
+
// theme: { },
|
|
375
362
|
},
|
|
376
363
|
"text": {
|
|
377
364
|
"highlightFocused": true
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { writeFileSync } from "node:fs";
|
|
2
|
-
import figures from "figures";
|
|
3
2
|
import chalk from "chalk";
|
|
4
3
|
import {
|
|
5
4
|
fileExists,
|
|
@@ -30,9 +29,7 @@ export default function writeConfig(
|
|
|
30
29
|
try {
|
|
31
30
|
writeFileSync(pFileName, pConfig);
|
|
32
31
|
pOutStream.write(
|
|
33
|
-
`\n ${chalk.green(
|
|
34
|
-
figures.tick,
|
|
35
|
-
)} Successfully created '${pFileName}'\n\n`,
|
|
32
|
+
`\n ${chalk.green("✔")} Successfully created '${pFileName}'\n\n`,
|
|
36
33
|
);
|
|
37
34
|
/* c8 ignore start */
|
|
38
35
|
} catch (pError) {
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
+
/* eslint-disable prefer-template */
|
|
1
2
|
/* eslint-disable security/detect-object-injection */
|
|
2
3
|
import { writeFileSync } from "node:fs";
|
|
3
|
-
import
|
|
4
|
+
import { EOL } from "node:os";
|
|
4
5
|
import chalk from "chalk";
|
|
5
6
|
import { PACKAGE_MANIFEST as _PACKAGE_MANIFEST } from "../defaults.mjs";
|
|
6
7
|
import { readManifest } from "./environment-helpers.mjs";
|
|
7
8
|
import { folderNameArrayToRE } from "./utl.mjs";
|
|
8
|
-
import wrapAndIndent from "#utl/wrap-and-indent.mjs";
|
|
9
9
|
|
|
10
10
|
const PACKAGE_MANIFEST = `./${_PACKAGE_MANIFEST}`;
|
|
11
11
|
|
|
@@ -14,37 +14,47 @@ const EXPERIMENTAL_SCRIPT_DOC = [
|
|
|
14
14
|
name: "depcruise",
|
|
15
15
|
headline: "npm run depcruise",
|
|
16
16
|
description:
|
|
17
|
-
"validates against the rules in .dependency-cruiser.js and writes the
|
|
17
|
+
" validates against the rules in .dependency-cruiser.js and writes the" +
|
|
18
|
+
EOL +
|
|
19
|
+
" outcome to stdout",
|
|
18
20
|
},
|
|
19
21
|
{
|
|
20
22
|
name: "depcruise:html",
|
|
21
23
|
headline: "npm run depcruise:html",
|
|
22
24
|
description:
|
|
23
|
-
"validates against the rules in .dependency-cruiser.js and writes it to
|
|
25
|
+
" validates against the rules in .dependency-cruiser.js and writes it to" +
|
|
26
|
+
EOL +
|
|
27
|
+
" 'dependency-violation-report.html' with a friendly layout",
|
|
24
28
|
},
|
|
25
29
|
{
|
|
26
30
|
name: "depcruise:graph",
|
|
27
31
|
headline: "npm run depcruise:graph",
|
|
28
32
|
description:
|
|
29
|
-
"writes a detailed internal graph of your app to 'dependency-graph.html'",
|
|
33
|
+
" writes a detailed internal graph of your app to 'dependency-graph.html'",
|
|
30
34
|
},
|
|
31
35
|
{
|
|
32
36
|
name: "depcruise:graph:dev",
|
|
33
37
|
headline: "npm run depcruise:graph:dev",
|
|
34
38
|
description:
|
|
35
|
-
"opens a detailed internal graph of your app in your default browser
|
|
39
|
+
" opens a detailed internal graph of your app in your default browser" +
|
|
40
|
+
EOL +
|
|
41
|
+
" (uses the 'browser' command line program)",
|
|
36
42
|
},
|
|
37
43
|
{
|
|
38
44
|
name: "depcruise:graph:archi",
|
|
39
45
|
headline: "depcruise:graph:archi",
|
|
40
46
|
description:
|
|
41
|
-
"writes a high-level internal graph of your app to
|
|
47
|
+
" writes a high-level internal graph of your app to" +
|
|
48
|
+
EOL +
|
|
49
|
+
" 'high-level-dependency-graph.html",
|
|
42
50
|
},
|
|
43
51
|
{
|
|
44
52
|
name: "depcruise:focus",
|
|
45
53
|
headline: "npm run depcruise:focus <regex>",
|
|
46
54
|
description:
|
|
47
|
-
"writes all dependencies to and from modules matching the given <regex>
|
|
55
|
+
" writes all dependencies to and from modules matching the given <regex>" +
|
|
56
|
+
EOL +
|
|
57
|
+
" to stdout - in simple text",
|
|
48
58
|
},
|
|
49
59
|
// {
|
|
50
60
|
// name: "depcruise:text",
|
|
@@ -121,13 +131,11 @@ function getSuccessMessage(pDestinationManifestFileName) {
|
|
|
121
131
|
return EXPERIMENTAL_SCRIPT_DOC.reduce(
|
|
122
132
|
(pAll, pScript) => {
|
|
123
133
|
return `${pAll}${
|
|
124
|
-
`\n ${chalk.green(
|
|
125
|
-
`\n${
|
|
134
|
+
`\n ${chalk.green("►")} ${pScript.headline}` +
|
|
135
|
+
`\n${pScript.description}\n\n`
|
|
126
136
|
}`;
|
|
127
137
|
},
|
|
128
|
-
` ${chalk.green(
|
|
129
|
-
figures.tick,
|
|
130
|
-
)} Run scripts added to '${pDestinationManifestFileName}':\n`,
|
|
138
|
+
` ${chalk.green("✔")} Run scripts added to '${pDestinationManifestFileName}':\n`,
|
|
131
139
|
);
|
|
132
140
|
}
|
|
133
141
|
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import chalk from "chalk";
|
|
2
|
-
import figures from "figures";
|
|
3
2
|
import { SUMMARY } from "#utl/bus.mjs";
|
|
4
3
|
|
|
5
4
|
const FULL_ON = 100;
|
|
@@ -7,8 +6,8 @@ const FULL_ON = 100;
|
|
|
7
6
|
function normalizeParameters(pParameters) {
|
|
8
7
|
return {
|
|
9
8
|
barSize: 10,
|
|
10
|
-
block:
|
|
11
|
-
blank:
|
|
9
|
+
block: "■",
|
|
10
|
+
blank: "□",
|
|
12
11
|
...(pParameters || {}),
|
|
13
12
|
};
|
|
14
13
|
}
|
|
@@ -2,8 +2,8 @@ import { readFile } from "node:fs/promises";
|
|
|
2
2
|
|
|
3
3
|
import { extname } from "node:path";
|
|
4
4
|
import json5 from "json5";
|
|
5
|
-
import tryImport from "semver-try-require";
|
|
6
5
|
import makeAbsolute from "./make-absolute.mjs";
|
|
6
|
+
import tryImport from "#utl/try-import.mjs";
|
|
7
7
|
import meta from "#meta.cjs";
|
|
8
8
|
|
|
9
9
|
async function getJSConfig(pBabelConfigFileName) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { readFileSync } from "node:fs";
|
|
2
|
-
import tryImport from "semver-try-require";
|
|
3
2
|
import memoize, { memoizeClear } from "memoize";
|
|
4
3
|
import transpile from "../transpile/index.mjs";
|
|
4
|
+
import tryImport from "#utl/try-import.mjs";
|
|
5
5
|
import meta from "#meta.cjs";
|
|
6
6
|
import getExtension from "#utl/get-extension.mjs";
|
|
7
7
|
|
package/src/meta.cjs
CHANGED
package/src/report/error.mjs
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { EOL } from "node:os";
|
|
2
2
|
import chalk from "chalk";
|
|
3
|
-
import figures from "figures";
|
|
4
3
|
import {
|
|
5
4
|
formatPercentage,
|
|
6
5
|
formatViolation as _formatViolation,
|
|
@@ -20,9 +19,7 @@ const EXTRA_PATH_INFORMATION_INDENT = 6;
|
|
|
20
19
|
function formatMiniDependency(pMiniDependency) {
|
|
21
20
|
return EOL.concat(
|
|
22
21
|
wrapAndIndent(
|
|
23
|
-
pMiniDependency
|
|
24
|
-
.map(({ name }) => name)
|
|
25
|
-
.join(` ${figures.arrowRight} ${EOL}`),
|
|
22
|
+
pMiniDependency.map(({ name }) => name).join(` → ${EOL}`),
|
|
26
23
|
EXTRA_PATH_INFORMATION_INDENT,
|
|
27
24
|
),
|
|
28
25
|
);
|
|
@@ -33,19 +30,15 @@ function formatModuleViolation(pViolation) {
|
|
|
33
30
|
}
|
|
34
31
|
|
|
35
32
|
function formatDependencyViolation(pViolation) {
|
|
36
|
-
return `${chalk.bold(pViolation.from)}
|
|
37
|
-
pViolation.to,
|
|
38
|
-
)}`;
|
|
33
|
+
return `${chalk.bold(pViolation.from)} → ${chalk.bold(pViolation.to)}`;
|
|
39
34
|
}
|
|
40
35
|
|
|
41
36
|
function formatCycleViolation(pViolation) {
|
|
42
|
-
return `${chalk.bold(pViolation.from)} ${
|
|
43
|
-
figures.arrowRight
|
|
44
|
-
} ${formatMiniDependency(pViolation.cycle)}`;
|
|
37
|
+
return `${chalk.bold(pViolation.from)} → ${formatMiniDependency(pViolation.cycle)}`;
|
|
45
38
|
}
|
|
46
39
|
|
|
47
40
|
function formatReachabilityViolation(pViolation) {
|
|
48
|
-
return `${chalk.bold(pViolation.from)}
|
|
41
|
+
return `${chalk.bold(pViolation.from)} → ${chalk.bold(
|
|
49
42
|
pViolation.to,
|
|
50
43
|
)}${formatMiniDependency(pViolation.via)}`;
|
|
51
44
|
}
|
|
@@ -53,9 +46,7 @@ function formatReachabilityViolation(pViolation) {
|
|
|
53
46
|
function formatInstabilityViolation(pViolation) {
|
|
54
47
|
return `${formatDependencyViolation(pViolation)}${EOL}${wrapAndIndent(
|
|
55
48
|
chalk.dim(
|
|
56
|
-
`instability: ${formatPercentage(pViolation.metrics.from.instability)} ${
|
|
57
|
-
figures.arrowRight
|
|
58
|
-
} ${formatPercentage(pViolation.metrics.to.instability)}`,
|
|
49
|
+
`instability: ${formatPercentage(pViolation.metrics.from.instability)} → ${formatPercentage(pViolation.metrics.to.instability)}`,
|
|
59
50
|
),
|
|
60
51
|
EXTRA_PATH_INFORMATION_INDENT,
|
|
61
52
|
)}`;
|
|
@@ -96,7 +87,7 @@ function sumMeta(pMeta) {
|
|
|
96
87
|
}
|
|
97
88
|
|
|
98
89
|
function formatSummary(pSummary) {
|
|
99
|
-
let lMessage = `${EOL}
|
|
90
|
+
let lMessage = `${EOL}x ${sumMeta(
|
|
100
91
|
pSummary,
|
|
101
92
|
)} dependency violations (${formatMeta(pSummary)}). ${
|
|
102
93
|
pSummary.totalCruised
|
|
@@ -117,7 +108,7 @@ function addExplanation(pRuleSet, pLong) {
|
|
|
117
108
|
function formatIgnoreWarning(pNumberOfIgnoredViolations) {
|
|
118
109
|
if (pNumberOfIgnoredViolations > 0) {
|
|
119
110
|
return chalk.yellow(
|
|
120
|
-
|
|
111
|
+
`‼ ${pNumberOfIgnoredViolations} known violations ignored. Run with --no-ignore-known to see them.${EOL}`,
|
|
121
112
|
);
|
|
122
113
|
}
|
|
123
114
|
return "";
|
|
@@ -129,9 +120,7 @@ function report(pResults, pLong) {
|
|
|
129
120
|
);
|
|
130
121
|
|
|
131
122
|
if (lNonIgnorableViolations.length === 0) {
|
|
132
|
-
return `${EOL}${chalk.green(
|
|
133
|
-
figures.tick,
|
|
134
|
-
)} no dependency violations found (${
|
|
123
|
+
return `${EOL}${chalk.green("✔")} no dependency violations found (${
|
|
135
124
|
pResults.summary.totalCruised
|
|
136
125
|
} modules, ${
|
|
137
126
|
pResults.summary.totalDependenciesCruised
|
package/src/report/text.mjs
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import figures from "figures";
|
|
2
1
|
import chalk from "chalk";
|
|
3
2
|
|
|
4
3
|
const DEFAULT_OPTIONS = {
|
|
@@ -41,9 +40,7 @@ function stringifyModule(pModule) {
|
|
|
41
40
|
}
|
|
42
41
|
|
|
43
42
|
function stringify(pFlatDependency) {
|
|
44
|
-
return `${stringifyModule(pFlatDependency.from)} ${
|
|
45
|
-
figures.arrowRight
|
|
46
|
-
} ${stringifyModule(pFlatDependency.to)}`;
|
|
43
|
+
return `${stringifyModule(pFlatDependency.from)} → ${stringifyModule(pFlatDependency.to)}`;
|
|
47
44
|
}
|
|
48
45
|
|
|
49
46
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
/* generated - don't edit */export default
|
|
1
|
+
/* generated - don't edit */export default{title:"dependency-cruiser baseline ('known errors') format",$schema:"http://json-schema.org/draft-07/schema#",$id:"https://dependency-cruiser.js.org/schema/baseline-violations.schema.json",$ref:"#/definitions/ViolationsType",definitions:{ViolationsType:{type:"array",items:{$ref:"#/definitions/ViolationType"}},ViolationType:{type:"object",required:["from","to","rule"],additionalProperties:false,properties:{from:{type:"string"},to:{type:"string"},type:{$ref:"#/definitions/ViolationTypeType"},rule:{$ref:"#/definitions/RuleSummaryType"},cycle:{type:"array",items:{$ref:"#/definitions/MiniDependency"}},via:{type:"array",items:{$ref:"#/definitions/MiniDependency"}},metrics:{type:"object",required:["from","to"],additionalProperties:false,properties:{from:{type:"object",required:["instability"],additionalProperties:false,properties:{instability:{type:"number"}}},to:{type:"object",required:["instability"],additionalProperties:false,properties:{instability:{type:"number"}}}}},comment:{type:"string"}}},RuleSummaryType:{type:"object",required:["name","severity"],additionalProperties:false,properties:{name:{type:"string"},severity:{$ref:"#/definitions/SeverityType"}}},SeverityType:{type:"string",enum:["error","warn","info","ignore"]},ViolationTypeType:{type:"string",enum:["dependency","module","reachability","cycle","instability","folder"]},MiniDependency:{type:"object",required:["name","dependencyTypes"],additionalProperties:false,properties:{name:{type:"string"},dependencyTypes:{type:"array",items:{$ref:"#/definitions/DependencyTypeType"}}}},DependencyTypeType:{type:"string",enum:["aliased-subpath-import","aliased-tsconfig-base-url","aliased-tsconfig-paths","aliased-tsconfig","aliased-webpack","aliased-workspace","aliased","amd-define","amd-require","amd-exotic-require","core","deprecated","dynamic-import","exotic-require","export","import-equals","import","local","localmodule","npm-bundled","npm-dev","npm-no-pkg","npm-optional","npm-peer","npm-unknown","npm","pre-compilation-only","require","triple-slash-amd-dependency","triple-slash-directive","triple-slash-file-reference","triple-slash-type-reference","type-import","type-only","undetermined","unknown"]}}};
|