dependency-cruiser 11.14.2 → 11.15.0
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": "11.
|
|
3
|
+
"version": "11.15.0",
|
|
4
4
|
"description": "Validate and visualize dependencies. With your rules. JavaScript, TypeScript, CoffeeScript. ES6, CommonJS, AMD.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"static analysis",
|
|
@@ -104,6 +104,7 @@
|
|
|
104
104
|
"lint:types:tsc": "tsc --project types/tsconfig.json",
|
|
105
105
|
"lint:types:lint": "eslint --no-ignore --config types/.eslintrc.json types/*.d.ts",
|
|
106
106
|
"lint:types:fix": "eslint --no-ignore --config types/.eslintrc.json --fix types/*.d.ts",
|
|
107
|
+
"prepare": "husky install",
|
|
107
108
|
"scm:push": "run-p --aggregate-output scm:push:*",
|
|
108
109
|
"scm:push:bitbucket-mirror": "run-p --aggregate-output scm:push:bitbucket-mirror:*",
|
|
109
110
|
"scm:push:bitbucket-mirror:commits": "git push bitbucket-mirror",
|
|
@@ -134,7 +135,7 @@
|
|
|
134
135
|
"test:watch": "mocha --watch --watch-extensions=json --reporter=min test/\\*\\*/\\*.spec.js",
|
|
135
136
|
"update-dependencies": "npm-run-all upem:update upem:install build:clean build lint:fix depcruise test:cover",
|
|
136
137
|
"upem:install": "npm install",
|
|
137
|
-
"upem:update": "npm outdated --json | upem",
|
|
138
|
+
"upem:update": "npm outdated --json --long | upem | pbcopy && pbpaste",
|
|
138
139
|
"version": "npm-run-all build depcruise:graph:doc scm:stage"
|
|
139
140
|
},
|
|
140
141
|
"dependencies": {
|
|
@@ -152,9 +153,11 @@
|
|
|
152
153
|
"glob": "7.2.0",
|
|
153
154
|
"handlebars": "4.7.7",
|
|
154
155
|
"indent-string": "^4.0.0",
|
|
156
|
+
"interpret": "^2.2.0",
|
|
155
157
|
"json5": "2.2.1",
|
|
156
158
|
"lodash": "4.17.21",
|
|
157
159
|
"prompts": "2.4.2",
|
|
160
|
+
"rechoir": "^0.8.0",
|
|
158
161
|
"safe-regex": "2.1.1",
|
|
159
162
|
"semver": "^7.3.7",
|
|
160
163
|
"semver-try-require": "^5.0.2",
|
|
@@ -167,12 +170,12 @@
|
|
|
167
170
|
"@babel/core": "7.18.10",
|
|
168
171
|
"@babel/plugin-transform-modules-commonjs": "7.18.6",
|
|
169
172
|
"@babel/preset-typescript": "7.18.6",
|
|
170
|
-
"@swc/core": "1.2.
|
|
171
|
-
"@types/lodash": "4.14.
|
|
172
|
-
"@types/node": "18.7.
|
|
173
|
+
"@swc/core": "1.2.241",
|
|
174
|
+
"@types/lodash": "4.14.184",
|
|
175
|
+
"@types/node": "18.7.8",
|
|
173
176
|
"@types/prompts": "2.0.14",
|
|
174
|
-
"@typescript-eslint/eslint-plugin": "5.33.
|
|
175
|
-
"@typescript-eslint/parser": "5.33.
|
|
177
|
+
"@typescript-eslint/eslint-plugin": "5.33.1",
|
|
178
|
+
"@typescript-eslint/parser": "5.33.1",
|
|
176
179
|
"@vue/compiler-sfc": "3.2.37",
|
|
177
180
|
"c8": "7.12.0",
|
|
178
181
|
"chai": "4.3.6",
|
|
@@ -187,7 +190,7 @@
|
|
|
187
190
|
"eslint-plugin-node": "11.1.0",
|
|
188
191
|
"eslint-plugin-security": "1.5.0",
|
|
189
192
|
"eslint-plugin-unicorn": "^43.0.1",
|
|
190
|
-
"husky": "
|
|
193
|
+
"husky": "8.0.1",
|
|
191
194
|
"intercept-stdout": "0.1.2",
|
|
192
195
|
"lint-staged": "12.3.4",
|
|
193
196
|
"mocha": "10.0.0",
|
|
@@ -199,8 +202,8 @@
|
|
|
199
202
|
"svelte": "3.49.0",
|
|
200
203
|
"symlink-dir": "5.0.1",
|
|
201
204
|
"typescript": "4.7.4",
|
|
202
|
-
"upem": "7.0
|
|
203
|
-
"vue-template-compiler": "2.7.
|
|
205
|
+
"upem": "7.2.0",
|
|
206
|
+
"vue-template-compiler": "2.7.9",
|
|
204
207
|
"yarn": "1.22.19"
|
|
205
208
|
},
|
|
206
209
|
"upem": {
|
|
@@ -208,12 +211,12 @@
|
|
|
208
211
|
{
|
|
209
212
|
"package": "chalk",
|
|
210
213
|
"policy": "wanted",
|
|
211
|
-
"because": "version 5 only exports
|
|
214
|
+
"because": "version 5 only exports esm - and we use cjs and don't transpile"
|
|
212
215
|
},
|
|
213
216
|
{
|
|
214
217
|
"package": "figures",
|
|
215
218
|
"policy": "wanted",
|
|
216
|
-
"because": "version 4 only exports
|
|
219
|
+
"because": "version 4 only exports esm - and we use cjs and don't transpile"
|
|
217
220
|
},
|
|
218
221
|
{
|
|
219
222
|
"package": "glob",
|
|
@@ -221,14 +224,14 @@
|
|
|
221
224
|
"because": "from version 7.2.1 behavior on windows changes - in a potentially breaking fashion. Wait with upgrading until we're majoring or from when there's a vuln in 7.2.0"
|
|
222
225
|
},
|
|
223
226
|
{
|
|
224
|
-
"package": "
|
|
227
|
+
"package": "indent-string",
|
|
225
228
|
"policy": "wanted",
|
|
226
|
-
"because": "
|
|
229
|
+
"because": "version 5 only exports esm - and we use cjs and don't transpile"
|
|
227
230
|
},
|
|
228
231
|
{
|
|
229
|
-
"package": "
|
|
232
|
+
"package": "interpret",
|
|
230
233
|
"policy": "wanted",
|
|
231
|
-
"because": "
|
|
234
|
+
"because": "we want to keep interpret ~similar to what webpack-cli uses (which is ^2.2.0)"
|
|
232
235
|
},
|
|
233
236
|
{
|
|
234
237
|
"package": "lint-staged",
|
|
@@ -238,12 +241,17 @@
|
|
|
238
241
|
{
|
|
239
242
|
"package": "normalize-newline",
|
|
240
243
|
"policy": "wanted",
|
|
241
|
-
"because": "version 4 only exports
|
|
244
|
+
"because": "version 4 only exports esm - and we use cjs and don't transpile (this only used in unit tests - but one of'em is a cjs one ...)"
|
|
245
|
+
},
|
|
246
|
+
{
|
|
247
|
+
"package": "rechoir",
|
|
248
|
+
"policy": "wanted",
|
|
249
|
+
"because": "we want to keep rechoir ~similar to what webpack-cli uses (which is ^0.7.0, but ^0.8.0 is similar enough and more recent anyway)"
|
|
242
250
|
},
|
|
243
251
|
{
|
|
244
252
|
"package": "wrap-ansi",
|
|
245
253
|
"policy": "wanted",
|
|
246
|
-
"because": "version 8 only exports
|
|
254
|
+
"because": "version 8 only exports esm - and we use cjs and don't transpile"
|
|
247
255
|
}
|
|
248
256
|
]
|
|
249
257
|
},
|
|
@@ -278,11 +286,6 @@
|
|
|
278
286
|
"vue-template-compiler": ">=2.0.0 <3.0.0",
|
|
279
287
|
"@vue/compiler-sfc": ">=3.0.0 <4.0.0"
|
|
280
288
|
},
|
|
281
|
-
"husky": {
|
|
282
|
-
"hooks": {
|
|
283
|
-
"pre-commit": "lint-staged"
|
|
284
|
-
}
|
|
285
|
-
},
|
|
286
289
|
"lint-staged": {
|
|
287
290
|
"{src,config}/**/*.js": [
|
|
288
291
|
"eslint --fix"
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const
|
|
2
|
-
const
|
|
1
|
+
const { readFileSync, readdirSync, accessSync, statSync, R_OK } = require("fs");
|
|
2
|
+
const { join } = require("path");
|
|
3
3
|
const has = require("lodash/has");
|
|
4
4
|
const get = require("lodash/get");
|
|
5
5
|
const { DEFAULT_CONFIG_FILE_NAME } = require("../defaults");
|
|
@@ -9,7 +9,7 @@ const LIKELY_TEST_FOLDERS = ["test", "spec", "tests", "specs", "bdd"];
|
|
|
9
9
|
const LIKELY_PACKAGES_FOLDERS = ["packages"];
|
|
10
10
|
const TSCONFIG_CANDIDATE_PATTERN = /.*tsconfig.*\.json$/gi;
|
|
11
11
|
const JSCONFIG_CANDIDATE_PATTERN = /.*jsconfig.*\.json$/gi;
|
|
12
|
-
const WEBPACK_CANDIDATE_PATTERN = /.*webpack.*\.c?js
|
|
12
|
+
const WEBPACK_CANDIDATE_PATTERN = /.*webpack.*\.(c?js|json5?|ts|ya?ml)$/gi;
|
|
13
13
|
const BABEL_CONFIG_CANDIDATE_PATTERN = /^\.babelrc$|.*babel.*\.json/gi;
|
|
14
14
|
|
|
15
15
|
/**
|
|
@@ -17,11 +17,11 @@ const BABEL_CONFIG_CANDIDATE_PATTERN = /^\.babelrc$|.*babel.*\.json/gi;
|
|
|
17
17
|
*
|
|
18
18
|
* @param {string} pManifestFileName - the file name where the package manifest (package.json) lives
|
|
19
19
|
* @returns {any} - the contents of said manifest as a javascript object
|
|
20
|
-
* @throws ENOENT when the manifest wasn't found
|
|
21
|
-
* @throws SyntaxError when the manifest's json is invalid
|
|
20
|
+
* @throws {ENOENT} when the manifest wasn't found
|
|
21
|
+
* @throws {SyntaxError} when the manifest's json is invalid
|
|
22
22
|
*/
|
|
23
23
|
function readManifest(pManifestFileName = "./package.json") {
|
|
24
|
-
return JSON.parse(
|
|
24
|
+
return JSON.parse(readFileSync(pManifestFileName, "utf8"));
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
/*
|
|
@@ -30,7 +30,7 @@ function readManifest(pManifestFileName = "./package.json") {
|
|
|
30
30
|
*/
|
|
31
31
|
function fileExists(pFile) {
|
|
32
32
|
try {
|
|
33
|
-
|
|
33
|
+
accessSync(pFile, R_OK);
|
|
34
34
|
} catch (pError) {
|
|
35
35
|
return false;
|
|
36
36
|
}
|
|
@@ -61,21 +61,17 @@ function isTypeModule() {
|
|
|
61
61
|
}
|
|
62
62
|
|
|
63
63
|
function getFolderNames(pFolderName) {
|
|
64
|
-
return
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
fs.statSync(path.join(pFolderName, pFileName)).isDirectory()
|
|
68
|
-
);
|
|
64
|
+
return readdirSync(pFolderName, "utf8").filter((pFileName) =>
|
|
65
|
+
statSync(join(pFolderName, pFileName)).isDirectory()
|
|
66
|
+
);
|
|
69
67
|
}
|
|
70
68
|
|
|
71
69
|
function getMatchingFileNames(pPattern, pFolderName = process.cwd()) {
|
|
72
|
-
return
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
(
|
|
76
|
-
|
|
77
|
-
pFileName.match(pPattern)
|
|
78
|
-
);
|
|
70
|
+
return readdirSync(pFolderName, "utf8").filter(
|
|
71
|
+
(pFileName) =>
|
|
72
|
+
statSync(join(pFolderName, pFileName)).isFile() &&
|
|
73
|
+
pFileName.match(pPattern)
|
|
74
|
+
);
|
|
79
75
|
}
|
|
80
76
|
|
|
81
77
|
function isLikelyMonoRepo(pFolderNames = getFolderNames(process.cwd())) {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
const { extname } = require("path");
|
|
1
2
|
const makeAbsolute = require("./make-absolute");
|
|
2
3
|
|
|
3
4
|
function pryConfigFromTheConfig(
|
|
@@ -22,6 +23,52 @@ function pryConfigFromTheConfig(
|
|
|
22
23
|
return lReturnValue;
|
|
23
24
|
}
|
|
24
25
|
|
|
26
|
+
function suggestModules(pSuggestionList, pWebpackConfigFilename) {
|
|
27
|
+
let lReturnValue = "";
|
|
28
|
+
let lSuggestionList = pSuggestionList;
|
|
29
|
+
|
|
30
|
+
if (pSuggestionList && typeof pSuggestionList === "string") {
|
|
31
|
+
lSuggestionList = [pSuggestionList];
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
if (Array.isArray(lSuggestionList) && lSuggestionList.length > 0) {
|
|
35
|
+
lReturnValue = lSuggestionList.reduce(
|
|
36
|
+
(pAll, pCurrent) =>
|
|
37
|
+
(pAll += ` - ${pCurrent.module || pCurrent}\n`),
|
|
38
|
+
`\n Some npm modules that might fix that problem (one of which you'll` +
|
|
39
|
+
`\n need so '${pWebpackConfigFilename}' works with webpack anyway):\n`
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
return lReturnValue;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function tryRegisterNonNative(pWebpackConfigFilename) {
|
|
46
|
+
const lConfigExtension = extname(pWebpackConfigFilename);
|
|
47
|
+
|
|
48
|
+
if (lConfigExtension === ".mjs") {
|
|
49
|
+
throw new Error(
|
|
50
|
+
`dependency-cruiser currently does not support webpack configurations in` +
|
|
51
|
+
`\n ES Module format (like '${pWebpackConfigFilename}').\n`
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
const interpret = require("interpret");
|
|
56
|
+
const rechoir = require("rechoir");
|
|
57
|
+
|
|
58
|
+
try {
|
|
59
|
+
rechoir.prepare(interpret.extensions, pWebpackConfigFilename);
|
|
60
|
+
} catch (pError) {
|
|
61
|
+
throw new Error(
|
|
62
|
+
`${pError.message}` +
|
|
63
|
+
`\n${suggestModules(
|
|
64
|
+
// eslint-disable-next-line security/detect-object-injection
|
|
65
|
+
interpret.extensions[lConfigExtension],
|
|
66
|
+
pWebpackConfigFilename
|
|
67
|
+
)}`
|
|
68
|
+
);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
25
72
|
/**
|
|
26
73
|
* Reads the file with name `pWebpackConfigFilename` and (applying the
|
|
27
74
|
* environment `pEnvironment` and the arguments `pArguments` (which can
|
|
@@ -35,16 +82,23 @@ function pryConfigFromTheConfig(
|
|
|
35
82
|
* @throws {Error} when the webpack config isn't usable (e.g. because it
|
|
36
83
|
* doesn't exist, or because it's invalid)
|
|
37
84
|
*/
|
|
85
|
+
// eslint-disable-next-line max-lines-per-function, complexity
|
|
38
86
|
module.exports = function extractWebpackResolveConfig(
|
|
39
87
|
pWebpackConfigFilename,
|
|
40
88
|
pEnvironment,
|
|
41
89
|
pArguments
|
|
42
90
|
) {
|
|
43
91
|
let lReturnValue = {};
|
|
92
|
+
const lNativelySupportedExtensions = [".js", ".cjs", ".json", ".node"];
|
|
93
|
+
const lWebpackConfigFilename = makeAbsolute(pWebpackConfigFilename);
|
|
94
|
+
|
|
95
|
+
if (!lNativelySupportedExtensions.includes(extname(pWebpackConfigFilename))) {
|
|
96
|
+
tryRegisterNonNative(pWebpackConfigFilename);
|
|
97
|
+
}
|
|
44
98
|
|
|
45
99
|
try {
|
|
46
100
|
/* eslint node/global-require:0, security/detect-non-literal-require:0, import/no-dynamic-require:0 */
|
|
47
|
-
const lWebpackConfigModule = require(
|
|
101
|
+
const lWebpackConfigModule = require(lWebpackConfigFilename);
|
|
48
102
|
const lWebpackConfig = pryConfigFromTheConfig(
|
|
49
103
|
lWebpackConfigModule,
|
|
50
104
|
pEnvironment,
|