dependency-cruiser 12.7.0 → 12.7.1
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 +14 -53
- package/src/extract/resolve/index.js +30 -6
- package/src/meta.js +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dependency-cruiser",
|
|
3
|
-
"version": "12.7.
|
|
3
|
+
"version": "12.7.1",
|
|
4
4
|
"description": "Validate and visualize dependencies. With your rules. JavaScript, TypeScript, CoffeeScript. ES6, CommonJS, AMD.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"static analysis",
|
|
@@ -85,11 +85,8 @@
|
|
|
85
85
|
"depcruise:graph:doc:fmt-schema": "cd tools/schema && node ../../bin/dependency-cruise.js . --config --output-type dot | dot -T svg | tee ../overview.svg | node ../../bin/wrap-stream-in-html.js > ../../docs/schema-overview.html && cd -",
|
|
86
86
|
"depcruise:graph:doc:fmt-types": "cd types && node ../bin/dependency-cruise.js . --ts-pre-compilation-deps --config --output-type dot | dot -T svg > overview.svg && cd -",
|
|
87
87
|
"depcruise:graph:doc:samples": "sh tools/generate-samples.sh",
|
|
88
|
-
"depcruise:graph:dot": "node ./bin/dependency-cruise.js bin src --config --output-type dot | dot -T svg > tmp_deps.svg",
|
|
89
|
-
"depcruise:graph:fdp": "node ./bin/dependency-cruise.js bin src --config --output-type dot | fdp -GK=0.1 -Gsplines=true -T svg > tmp_deps.svg",
|
|
90
88
|
"depcruise:graph:mermaid": "node ./bin/dependency-cruise.js bin src --include-only ^src/ --config --collapse 2 --output-type mermaid",
|
|
91
89
|
"depcruise:graph:mermaid:diff": "node ./bin/dependency-cruise.js bin src test types tools --config configs/.dependency-cruiser-unlimited.json --output-type mermaid --reaches \"$(watskeburt $SHA)\"",
|
|
92
|
-
"depcruise:graph:osage": "node ./bin/dependency-cruise.js bin src --config --output-type dot | osage -Gpack=32 -GpackMode=array2 -T svg > tmp_deps.svg",
|
|
93
90
|
"depcruise:graph:view": "node ./bin/dependency-cruise.js bin src --prefix vscode://file/$(pwd)/ --config configs/.dependency-cruiser-show-metrics-config.json --output-type dot --progress cli-feedback --highlight \"$(watskeburt develop)\" | dot -T svg | node ./bin/wrap-stream-in-html.js | browser",
|
|
94
91
|
"depcruise:graph:view:diff": "node ./bin/dependency-cruise.js bin src test --prefix vscode://file/$(pwd)/ --config configs/.dependency-cruiser-unlimited.json --output-type dot --progress cli-feedback --reaches \"$(watskeburt develop)\" | dot -T svg | node ./bin/wrap-stream-in-html.js | browser",
|
|
95
92
|
"depcruise:report": "node ./bin/dependency-cruise.js src bin test configs types --output-type err-html --config configs/.dependency-cruiser-show-metrics-config.json --output-to dependency-violations.html",
|
|
@@ -100,7 +97,8 @@
|
|
|
100
97
|
"format:check": "prettier --loglevel warn --check \"src/**/*.js\" \"configs/**/*.js\" \"tools/**/*.mjs\" \"bin/*\" \"types/*.d.ts\" \"test/**/*.spec.{cjs,js}\" \"test/**/*.{spec,utl}.mjs\"",
|
|
101
98
|
"lint": "npm-run-all --parallel --aggregate-output lint:eslint format:check lint:types",
|
|
102
99
|
"lint:eslint": "eslint bin/dependency-cruise.js bin src test configs tools/**/*.mjs --cache --cache-location node_modules/.cache/eslint/",
|
|
103
|
-
"lint:eslint:fix": "eslint --fix bin src test configs
|
|
100
|
+
"lint:eslint:fix": "eslint --fix bin src test configs tools/**/*.mjs --cache --cache-location node_modules/.cache/eslint/",
|
|
101
|
+
"lint:eslint:clear-caches": "rm -rf node_modules/.cache/eslint/",
|
|
104
102
|
"lint:fix": "npm-run-all lint:eslint:fix format lint:types:fix",
|
|
105
103
|
"lint:types": "npm-run-all lint:types:tsc lint:types:lint",
|
|
106
104
|
"lint:types:tsc": "tsc --project types/tsconfig.json",
|
|
@@ -122,7 +120,7 @@
|
|
|
122
120
|
"test:i": "LANG=en_US.UTF-8 mocha --grep \"^\\[[I]\\]\"",
|
|
123
121
|
"test:u": "LANG=en_US.UTF-8 mocha --grep \"^\\[[U]\\]\"",
|
|
124
122
|
"test:e": "LANG=en_US.UTF-8 mocha --grep \"^\\[[E]\\]\"",
|
|
125
|
-
"test:cover": "LANG=en_US.UTF-8 c8
|
|
123
|
+
"test:cover": "LANG=en_US.UTF-8 c8 mocha",
|
|
126
124
|
"test:glob": "set -f && test \"`bin/dependency-cruise.js test/extract/__mocks__/gather-globbing/packages/**/src/**/*.js | grep \"no dependency violations found\"`\" = \"✔ no dependency violations found (6 modules, 0 dependencies cruised)\"",
|
|
127
125
|
"test:yarn-pnp": "npm-run-all test:yarn-pnp:cleanup test:yarn-pnp:pack test:yarn-pnp:copy test:yarn-pnp:install test:yarn-pnp:version test:yarn-pnp:run test:yarn-pnp:test test:yarn-pnp:cleanup",
|
|
128
126
|
"test:yarn-pnp:pack": "npm pack",
|
|
@@ -135,7 +133,7 @@
|
|
|
135
133
|
"test:load": "hyperfine --warmup 3 --runs 30 \"bin/dependency-cruise.js src bin test configs types tools --ignore-known --validate --no-cache --no-progress\"",
|
|
136
134
|
"test:load:short": "hyperfine --warmup 1 --runs 5 \"bin/dependency-cruise.js src bin test configs types tools --ignore-known --validate --no-cache --no-progress\"",
|
|
137
135
|
"test:watch": "mocha --watch --watch-extensions=json --reporter=min test/\\*\\*/\\*.spec.js",
|
|
138
|
-
"update-dependencies": "npm-run-all upem:update upem:install build:clean build lint:fix depcruise test:cover",
|
|
136
|
+
"update-dependencies": "npm-run-all upem:update upem:install build:clean build lint:eslint:clear-caches lint:fix depcruise test:cover",
|
|
139
137
|
"upem-outdated": "npm outdated --json --long | upem --dry-run",
|
|
140
138
|
"upem:install": "npm install",
|
|
141
139
|
"upem:update": "npm outdated --json --long | upem | pbcopy && pbpaste",
|
|
@@ -175,13 +173,13 @@
|
|
|
175
173
|
"@babel/core": "7.20.12",
|
|
176
174
|
"@babel/plugin-transform-modules-commonjs": "7.20.11",
|
|
177
175
|
"@babel/preset-typescript": "7.18.6",
|
|
178
|
-
"@swc/core": "1.3.
|
|
176
|
+
"@swc/core": "1.3.34",
|
|
179
177
|
"@types/lodash": "4.14.191",
|
|
180
|
-
"@types/node": "18.
|
|
178
|
+
"@types/node": "18.13.0",
|
|
181
179
|
"@types/prompts": "2.4.2",
|
|
182
|
-
"@typescript-eslint/eslint-plugin": "5.
|
|
183
|
-
"@typescript-eslint/parser": "5.
|
|
184
|
-
"@vue/compiler-sfc": "3.2.
|
|
180
|
+
"@typescript-eslint/eslint-plugin": "5.51.0",
|
|
181
|
+
"@typescript-eslint/parser": "5.51.0",
|
|
182
|
+
"@vue/compiler-sfc": "3.2.47",
|
|
185
183
|
"c8": "7.12.0",
|
|
186
184
|
"chai": "4.3.7",
|
|
187
185
|
"chai-json-schema": "1.5.1",
|
|
@@ -194,19 +192,19 @@
|
|
|
194
192
|
"eslint-plugin-import": "2.27.5",
|
|
195
193
|
"eslint-plugin-mocha": "10.1.0",
|
|
196
194
|
"eslint-plugin-node": "11.1.0",
|
|
197
|
-
"eslint-plugin-security": "1.7.
|
|
195
|
+
"eslint-plugin-security": "1.7.1",
|
|
198
196
|
"eslint-plugin-unicorn": "^45.0.0",
|
|
199
197
|
"husky": "8.0.3",
|
|
200
198
|
"intercept-stdout": "0.1.2",
|
|
201
|
-
"lint-staged": "13.1.
|
|
199
|
+
"lint-staged": "13.1.1",
|
|
202
200
|
"mocha": "10.2.0",
|
|
203
201
|
"normalize-newline": "^3.0.0",
|
|
204
202
|
"npm-run-all": "4.1.5",
|
|
205
|
-
"prettier": "2.8.
|
|
203
|
+
"prettier": "2.8.4",
|
|
206
204
|
"proxyquire": "2.1.3",
|
|
207
205
|
"shx": "0.3.4",
|
|
208
206
|
"svelte": "3.55.1",
|
|
209
|
-
"symlink-dir": "5.1.
|
|
207
|
+
"symlink-dir": "5.1.1",
|
|
210
208
|
"typescript": "4.9.5",
|
|
211
209
|
"upem": "7.3.1",
|
|
212
210
|
"vue-template-compiler": "2.7.14",
|
|
@@ -256,23 +254,6 @@
|
|
|
256
254
|
}
|
|
257
255
|
]
|
|
258
256
|
},
|
|
259
|
-
"eslintIgnore": [
|
|
260
|
-
".pnp.cjs",
|
|
261
|
-
".yarn",
|
|
262
|
-
"node_modules",
|
|
263
|
-
"coverage",
|
|
264
|
-
"tmp",
|
|
265
|
-
"src/**/*.schema.js",
|
|
266
|
-
"src/**/*.template.js",
|
|
267
|
-
"src/cli/tools/svg-in-html-snippets/script.snippet.js",
|
|
268
|
-
"test/integration/**",
|
|
269
|
-
"test/*/__fixtures__/**",
|
|
270
|
-
"test/*/*/__fixtures__/**",
|
|
271
|
-
"test/*/*/*/__fixtures__/**",
|
|
272
|
-
"test/*/__mocks__/**",
|
|
273
|
-
"test/*/*/__mocks__/**",
|
|
274
|
-
"types/**"
|
|
275
|
-
],
|
|
276
257
|
"engines": {
|
|
277
258
|
"node": "^14||^16||>=18"
|
|
278
259
|
},
|
|
@@ -286,25 +267,5 @@
|
|
|
286
267
|
"typescript": ">=2.0.0 <5.0.0",
|
|
287
268
|
"vue-template-compiler": ">=2.0.0 <3.0.0",
|
|
288
269
|
"@vue/compiler-sfc": ">=3.0.0 <4.0.0"
|
|
289
|
-
},
|
|
290
|
-
"lint-staged": {
|
|
291
|
-
"{src,config}/**/*.js": [
|
|
292
|
-
"eslint --fix"
|
|
293
|
-
],
|
|
294
|
-
"{tools,src,config}/**/*.{mjs,js,json}": [
|
|
295
|
-
"prettier --write"
|
|
296
|
-
],
|
|
297
|
-
"bin/*": [
|
|
298
|
-
"eslint --fix",
|
|
299
|
-
"prettier --write"
|
|
300
|
-
],
|
|
301
|
-
"test/**/*.{utl,spec}.{mjs,cjs}": [
|
|
302
|
-
"eslint --fix",
|
|
303
|
-
"prettier --write"
|
|
304
|
-
],
|
|
305
|
-
"types/**/*.d.ts": [
|
|
306
|
-
"eslint --config types/.eslintrc.json --fix",
|
|
307
|
-
"prettier --write"
|
|
308
|
-
]
|
|
309
270
|
}
|
|
310
271
|
}
|
|
@@ -47,7 +47,7 @@ function resolveModule(
|
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
function canBeResolvedToTsVariant(pModuleName) {
|
|
50
|
-
return [".js", ".jsx"].includes(path.extname(pModuleName));
|
|
50
|
+
return [".js", ".jsx", ".mjs", ".cjs"].includes(path.extname(pModuleName));
|
|
51
51
|
}
|
|
52
52
|
|
|
53
53
|
function isTypeScriptIshExtension(pModuleName) {
|
|
@@ -68,6 +68,23 @@ function resolveYarnVirtual(pPath) {
|
|
|
68
68
|
return pPath;
|
|
69
69
|
}
|
|
70
70
|
|
|
71
|
+
/**
|
|
72
|
+
*
|
|
73
|
+
* @param {string} pJavaScriptExtension
|
|
74
|
+
* @returns {string}
|
|
75
|
+
*/
|
|
76
|
+
function getTypeScriptExtensionsToTry(pJavaScriptExtension) {
|
|
77
|
+
const lJS2TSMap = {
|
|
78
|
+
".js": [".ts", ".tsx", ".d.ts"],
|
|
79
|
+
".jsx": [".ts", ".tsx", ".d.ts"],
|
|
80
|
+
".cjs": [".cts", ".d.cts"],
|
|
81
|
+
".mjs": [".mts", ".d.mts"],
|
|
82
|
+
};
|
|
83
|
+
// eslint-disable-next-line security/detect-object-injection
|
|
84
|
+
return lJS2TSMap[pJavaScriptExtension] ?? [];
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
// eslint-disable-next-line max-lines-per-function
|
|
71
88
|
function resolveWithRetry(
|
|
72
89
|
pModule,
|
|
73
90
|
pBaseDirectory,
|
|
@@ -90,7 +107,11 @@ function resolveWithRetry(
|
|
|
90
107
|
// This behavior is very specific:
|
|
91
108
|
// - tsc only (doesn't work in ts-node for instance)
|
|
92
109
|
// - until TypeScript 4.6 only for the .js and .jsx extensions
|
|
93
|
-
// - since TypeScript 4.7 also for .cjs and .mjs (=> .cts, .mts) extensions
|
|
110
|
+
// - since TypeScript 4.7 also for .cjs and .mjs (=> .cts, .mts) extensions,
|
|
111
|
+
// which work subtly different;
|
|
112
|
+
// .cjs resolves to .cts or .d.cts (in that order)
|
|
113
|
+
// .mjs resolves to .mts or .d.mts (in that order)
|
|
114
|
+
// ref: https://www.typescriptlang.org/docs/handbook/esm-node.html#new-file-extensions
|
|
94
115
|
//
|
|
95
116
|
// Hence also this oddly specific looking check & retry.
|
|
96
117
|
//
|
|
@@ -100,16 +121,19 @@ function resolveWithRetry(
|
|
|
100
121
|
lReturnValue.couldNotResolve &&
|
|
101
122
|
canBeResolvedToTsVariant(lStrippedModuleName)
|
|
102
123
|
) {
|
|
103
|
-
const
|
|
104
|
-
/\.(js|jsx|mjs
|
|
124
|
+
const lModuleWithoutExtension = lStrippedModuleName.replace(
|
|
125
|
+
/\.(js|jsx|cjs|mjs)$/g,
|
|
105
126
|
""
|
|
106
127
|
);
|
|
128
|
+
const lExtensionsToTry = getTypeScriptExtensionsToTry(
|
|
129
|
+
path.extname(lStrippedModuleName)
|
|
130
|
+
);
|
|
107
131
|
|
|
108
132
|
const lReturnValueCandidate = resolveModule(
|
|
109
|
-
{ ...pModule, module:
|
|
133
|
+
{ ...pModule, module: lModuleWithoutExtension },
|
|
110
134
|
pBaseDirectory,
|
|
111
135
|
pFileDirectory,
|
|
112
|
-
pResolveOptions
|
|
136
|
+
{ ...pResolveOptions, extensions: lExtensionsToTry }
|
|
113
137
|
);
|
|
114
138
|
|
|
115
139
|
if (isTypeScriptIshExtension(lReturnValueCandidate.resolved)) {
|