dependency-cruiser 12.1.1 → 12.3.0-beta-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/README.md +1 -1
- package/configs/plugins/3d-reporter-plugin.js +3 -3
- package/configs/plugins/stats-reporter-plugin.js +3 -3
- package/package.json +18 -21
- package/src/cache/cache.js +4 -4
- package/src/cache/revision-data.js +13 -6
- package/src/cache/utl.js +1 -0
- package/src/cli/format.js +2 -2
- package/src/cli/index.js +9 -10
- package/src/cli/init-config/build-config.js +25 -3
- package/src/cli/init-config/config.js.template.js +1 -1
- package/src/cli/init-config/environment-helpers.js +39 -5
- package/src/cli/init-config/find-extensions.js +114 -0
- package/src/cli/init-config/get-user-input.js +10 -9
- package/src/cli/init-config/index.js +19 -11
- package/src/cli/init-config/normalize-init-options.js +12 -5
- package/{types/init-config.d.ts → src/cli/init-config/types.d.ts} +20 -11
- package/src/cli/init-config/{inquirer-validators.js → validators.js} +1 -9
- package/src/cli/init-config/write-config.js +1 -1
- package/src/cli/init-config/write-run-scripts-to-manifest.js +1 -1
- package/src/cli/listeners/performance-log/format-helpers.js +75 -15
- package/src/cli/listeners/performance-log/handlers.js +32 -14
- package/src/cli/listeners/performance-log/index.js +6 -0
- package/src/config-utl/extract-depcruise-config/index.js +12 -9
- package/src/config-utl/extract-depcruise-config/read-config.js +1 -1
- package/src/config-utl/extract-webpack-resolve-config.js +1 -2
- package/src/config-utl/make-absolute.js +1 -1
- package/src/enrich/add-validations.js +1 -1
- package/src/enrich/derive/circular/get-cycle.js +3 -4
- package/src/enrich/derive/folders/index.js +3 -3
- package/src/enrich/derive/orphan/index.js +3 -2
- package/src/enrich/derive/orphan/is-orphan.js +1 -1
- package/src/enrich/derive/reachable/index.js +1 -1
- package/src/enrich/index.js +3 -3
- package/src/enrich/summarize/index.js +1 -1
- package/src/extract/ast-extractors/swc-dependency-visitor.js +1 -1
- package/src/extract/gather-initial-sources.js +3 -3
- package/src/extract/get-dependencies.js +14 -21
- package/src/extract/index.js +4 -4
- package/src/extract/parse/to-javascript-ast.js +1 -1
- package/src/extract/parse/to-typescript-ast.js +1 -1
- package/src/extract/resolve/determine-dependency-types.js +6 -6
- package/src/extract/resolve/index.js +3 -3
- package/src/extract/resolve/module-classifiers.js +1 -1
- package/src/extract/resolve/resolve-amd.js +1 -1
- package/src/extract/resolve/resolve-cjs.js +1 -1
- package/src/extract/resolve/resolve.js +1 -1
- package/src/extract/transpile/svelte-preprocess.js +25 -5
- package/src/graph-utl/add-focus.js +1 -1
- package/src/graph-utl/consolidate-module-dependencies.js +6 -4
- package/src/graph-utl/consolidate-modules.js +1 -1
- package/src/graph-utl/consolidate-to-folder.js +3 -2
- package/src/graph-utl/rule-set.js +3 -3
- package/src/main/index.js +4 -4
- package/src/main/options/normalize.js +6 -6
- package/src/main/options/validate.js +2 -2
- package/src/main/report-wrap.js +6 -6
- package/src/main/resolve-options/normalize.js +4 -4
- package/src/main/rule-set/normalize.js +1 -1
- package/src/meta.js +1 -1
- package/src/report/anon/index.js +1 -1
- package/src/report/baseline.js +12 -10
- package/src/report/csv.js +7 -5
- package/src/report/dot/index.js +12 -10
- package/src/report/dot/module-utl.js +2 -2
- package/src/report/dot/prepare-custom-level.js +6 -1
- package/src/report/dot/prepare-flat-level.js +1 -1
- package/src/report/dot/prepare-folder-level.js +6 -1
- package/src/report/error-html/index.js +7 -5
- package/src/report/error-html/utl.js +5 -5
- package/src/report/error.js +10 -8
- package/src/report/html/index.js +7 -5
- package/src/report/identity.js +7 -5
- package/src/report/json.js +7 -5
- package/src/report/markdown.js +9 -7
- package/src/report/mermaid.js +25 -12
- package/src/report/metrics.js +7 -8
- package/src/report/plugins.js +1 -1
- package/src/report/teamcity.js +5 -5
- package/src/report/text.js +7 -5
- package/src/report/utl/dependency-to-incidence-transformer.js +3 -2
- package/src/report/utl/index.js +4 -5
- package/src/{extract/utl → utl}/get-extension.js +0 -0
- package/src/{extract/utl → utl}/path-to-posix.js +0 -0
- package/src/validate/match-dependency-rule.js +2 -2
- package/types/README.md +1 -0
package/README.md
CHANGED
|
@@ -154,7 +154,7 @@ You've come to the right place :-) :
|
|
|
154
154
|
|
|
155
155
|
## Build status
|
|
156
156
|
|
|
157
|
-
[](https://github.com/sverweij/dependency-cruiser/actions/workflows/ci.yml)
|
|
158
158
|
[](https://gitlab.com/sverweij/dependency-cruiser/builds)
|
|
159
159
|
[](https://codeclimate.com/github/sverweij/dependency-cruiser/maintainability)
|
|
160
160
|
[](https://codeclimate.com/github/sverweij/dependency-cruiser/test_coverage)
|
|
@@ -81,7 +81,7 @@ function formatDependency(pFrom, pTo) {
|
|
|
81
81
|
|
|
82
82
|
/**
|
|
83
83
|
*
|
|
84
|
-
* @param {import('
|
|
84
|
+
* @param {import('../..').ICruiseResult} pCruiseResult
|
|
85
85
|
*/
|
|
86
86
|
function render3DThing(pCruiseResult) {
|
|
87
87
|
const lNodes = pCruiseResult.modules.map((pModule) => {
|
|
@@ -114,10 +114,10 @@ function render3DThing(pCruiseResult) {
|
|
|
114
114
|
/**
|
|
115
115
|
* Sample plugin: 3d representation
|
|
116
116
|
*
|
|
117
|
-
* @param {import('
|
|
117
|
+
* @param {import('../..').ICruiseResult} pCruiseResult -
|
|
118
118
|
* the output of a dependency-cruise adhering to dependency-cruiser's
|
|
119
119
|
* cruise result schema
|
|
120
|
-
* @return {import('
|
|
120
|
+
* @return {import('../..').IReporterOutput} -
|
|
121
121
|
* output: a string
|
|
122
122
|
* exitCode: 0
|
|
123
123
|
*/
|
|
@@ -33,7 +33,7 @@ function doMagic(pCruiseResult) {
|
|
|
33
33
|
* returns an object with some stats from the ICruiseResult pCruiseResult it
|
|
34
34
|
* got passed
|
|
35
35
|
*
|
|
36
|
-
* @param {import('
|
|
36
|
+
* @param {import('../..').ICruiseResult} pCruiseResult - a result from a cruise.
|
|
37
37
|
* @return {string} an object with some stats
|
|
38
38
|
*/
|
|
39
39
|
function samplePluginReporter(pCruiseResult) {
|
|
@@ -65,10 +65,10 @@ function samplePluginReporter(pCruiseResult) {
|
|
|
65
65
|
/**
|
|
66
66
|
* Sample plugin
|
|
67
67
|
*
|
|
68
|
-
* @param {import('
|
|
68
|
+
* @param {import('../..').ICruiseResult} pCruiseResult -
|
|
69
69
|
* the output of a dependency-cruise adhering to dependency-cruiser's
|
|
70
70
|
* cruise result schema
|
|
71
|
-
* @return {import('
|
|
71
|
+
* @return {import('../..').IReporterOutput} -
|
|
72
72
|
* output: some stats on modules and dependencies in json format
|
|
73
73
|
* exitCode: 0
|
|
74
74
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dependency-cruiser",
|
|
3
|
-
"version": "12.
|
|
3
|
+
"version": "12.3.0-beta-1",
|
|
4
4
|
"description": "Validate and visualize dependencies. With your rules. JavaScript, TypeScript, CoffeeScript. ES6, CommonJS, AMD.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"static analysis",
|
|
@@ -87,12 +87,14 @@
|
|
|
87
87
|
"depcruise:graph:doc:samples": "sh tools/generate-samples.sh",
|
|
88
88
|
"depcruise:graph:dot": "node ./bin/dependency-cruise.js bin src --config --output-type dot | dot -T svg > tmp_deps.svg",
|
|
89
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
|
+
"depcruise:graph:mermaid": "node ./bin/dependency-cruise.js bin src --include-only ^src/ --config --collapse 2 --output-type mermaid",
|
|
91
|
+
"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)\"",
|
|
90
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",
|
|
91
93
|
"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",
|
|
92
94
|
"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",
|
|
93
95
|
"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",
|
|
94
96
|
"depcruise:report:view": "node ./bin/dependency-cruise.js src bin test configs types --output-type err-html --config configs/.dependency-cruiser-show-metrics-config.json --output-to - | browser",
|
|
95
|
-
"depcruise:focus": "node ./bin/dependency-cruise.js src bin test configs types tools --progress --config
|
|
97
|
+
"depcruise:focus": "node ./bin/dependency-cruise.js src bin test configs types tools --progress --config --output-type text --focus",
|
|
96
98
|
"depcruise:reaches": "node ./bin/dependency-cruise.js src bin test configs types tools --progress --config configs/.dependency-cruiser-unlimited.json --output-type text --reaches",
|
|
97
99
|
"format": "prettier --loglevel warn --write \"src/**/*.js\" \"configs/**/*.js\" \"tools/**/*.mjs\" \"bin/*\" \"types/*.d.ts\" \"test/**/*.spec.{cjs,js}\" \"test/**/*.{spec,utl}.mjs\"",
|
|
98
100
|
"format:check": "prettier --loglevel warn --check \"src/**/*.js\" \"configs/**/*.js\" \"tools/**/*.mjs\" \"bin/*\" \"types/*.d.ts\" \"test/**/*.spec.{cjs,js}\" \"test/**/*.{spec,utl}.mjs\"",
|
|
@@ -116,11 +118,11 @@
|
|
|
116
118
|
"scm:push:gitlab-mirror:commits": "git push gitlab-mirror",
|
|
117
119
|
"scm:push:gitlab-mirror:tags": "git push --tags gitlab-mirror",
|
|
118
120
|
"scm:stage": "git add .",
|
|
119
|
-
"test": "mocha",
|
|
120
|
-
"test:i": "mocha --grep \"^\\[[I]\\]\"",
|
|
121
|
-
"test:u": "mocha --grep \"^\\[[U]\\]\"",
|
|
122
|
-
"test:e": "mocha --grep \"^\\[[E]\\]\"",
|
|
123
|
-
"test:cover": "c8 --check-coverage --statements 99.9 --branches 99.7 --functions 100 --lines 99.9 --exclude \"{bin,configs/*.js,configs/rules,configs/plugins/3d-*.js,configs/plugins/stats-*.js,doc,docs,coverage,test,tools,webpack.conf.js,tmp*,src/**/*.template.js,src/cli/tools/svg-in-html-snippets/script.snippet.js,src/cli/init-config/get-user-input.js,src/cli/listeners/*/index.js}\" --reporter text-summary --reporter html --reporter json-summary mocha",
|
|
121
|
+
"test": "LANG=en_US.UTF-8 mocha",
|
|
122
|
+
"test:i": "LANG=en_US.UTF-8 mocha --grep \"^\\[[I]\\]\"",
|
|
123
|
+
"test:u": "LANG=en_US.UTF-8 mocha --grep \"^\\[[U]\\]\"",
|
|
124
|
+
"test:e": "LANG=en_US.UTF-8 mocha --grep \"^\\[[E]\\]\"",
|
|
125
|
+
"test:cover": "LANG=en_US.UTF-8 c8 --check-coverage --statements 99.9 --branches 99.7 --functions 100 --lines 99.9 --exclude \"{bin,configs/*.js,configs/rules,configs/plugins/3d-*.js,configs/plugins/stats-*.js,doc,docs,coverage,test,tools,webpack.conf.js,tmp*,src/**/*.template.js,src/cli/tools/svg-in-html-snippets/script.snippet.js,src/cli/init-config/get-user-input.js,src/cli/listeners/*/index.js}\" --reporter text-summary --reporter html --reporter json-summary mocha",
|
|
124
126
|
"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)\"",
|
|
125
127
|
"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",
|
|
126
128
|
"test:yarn-pnp:pack": "npm pack",
|
|
@@ -154,7 +156,7 @@
|
|
|
154
156
|
"glob": "7.2.0",
|
|
155
157
|
"handlebars": "4.7.7",
|
|
156
158
|
"indent-string": "^4.0.0",
|
|
157
|
-
"interpret": "^
|
|
159
|
+
"interpret": "^3.1.0",
|
|
158
160
|
"is-installed-globally": "0.4.0",
|
|
159
161
|
"json5": "2.2.2",
|
|
160
162
|
"lodash": "4.17.21",
|
|
@@ -169,15 +171,15 @@
|
|
|
169
171
|
"wrap-ansi": "^7.0.0"
|
|
170
172
|
},
|
|
171
173
|
"devDependencies": {
|
|
172
|
-
"@babel/core": "7.20.
|
|
173
|
-
"@babel/plugin-transform-modules-commonjs": "7.
|
|
174
|
+
"@babel/core": "7.20.7",
|
|
175
|
+
"@babel/plugin-transform-modules-commonjs": "7.20.11",
|
|
174
176
|
"@babel/preset-typescript": "7.18.6",
|
|
175
|
-
"@swc/core": "1.3.
|
|
177
|
+
"@swc/core": "1.3.24",
|
|
176
178
|
"@types/lodash": "4.14.191",
|
|
177
179
|
"@types/node": "18.11.17",
|
|
178
180
|
"@types/prompts": "2.4.2",
|
|
179
|
-
"@typescript-eslint/eslint-plugin": "5.
|
|
180
|
-
"@typescript-eslint/parser": "5.
|
|
181
|
+
"@typescript-eslint/eslint-plugin": "5.47.0",
|
|
182
|
+
"@typescript-eslint/parser": "5.47.0",
|
|
181
183
|
"@vue/compiler-sfc": "3.2.45",
|
|
182
184
|
"c8": "7.12.0",
|
|
183
185
|
"chai": "4.3.7",
|
|
@@ -195,7 +197,7 @@
|
|
|
195
197
|
"eslint-plugin-unicorn": "^45.0.0",
|
|
196
198
|
"husky": "8.0.2",
|
|
197
199
|
"intercept-stdout": "0.1.2",
|
|
198
|
-
"lint-staged": "
|
|
200
|
+
"lint-staged": "13.1.0",
|
|
199
201
|
"mocha": "10.2.0",
|
|
200
202
|
"normalize-newline": "^3.0.0",
|
|
201
203
|
"npm-run-all": "4.1.5",
|
|
@@ -234,12 +236,7 @@
|
|
|
234
236
|
{
|
|
235
237
|
"package": "interpret",
|
|
236
238
|
"policy": "wanted",
|
|
237
|
-
"because": "we want to keep interpret ~similar to what webpack-cli uses (which is ^
|
|
238
|
-
},
|
|
239
|
-
{
|
|
240
|
-
"package": "lint-staged",
|
|
241
|
-
"policy": "pin",
|
|
242
|
-
"because": "12.3.5 fails with SyntaxError: Unexpected token o in JSON at position 1"
|
|
239
|
+
"because": "we want to keep interpret ~similar to what webpack-cli uses (which is ^3.1.0 since 2022-11-15)"
|
|
243
240
|
},
|
|
244
241
|
{
|
|
245
242
|
"package": "normalize-newline",
|
|
@@ -249,7 +246,7 @@
|
|
|
249
246
|
{
|
|
250
247
|
"package": "rechoir",
|
|
251
248
|
"policy": "wanted",
|
|
252
|
-
"because": "we want to keep rechoir ~similar to what webpack-cli uses (which is ^0.
|
|
249
|
+
"because": "we want to keep rechoir ~similar to what webpack-cli uses (which is ^0.8.0 since 2022-11-15))"
|
|
253
250
|
},
|
|
254
251
|
{
|
|
255
252
|
"package": "wrap-ansi",
|
package/src/cache/cache.js
CHANGED
|
@@ -21,7 +21,7 @@ function writeCache(pCacheFolder, pCruiseResult) {
|
|
|
21
21
|
/**
|
|
22
22
|
*
|
|
23
23
|
* @param {string} pCacheFolder
|
|
24
|
-
* @returns {import("
|
|
24
|
+
* @returns {import("../..").ICruiseResult}
|
|
25
25
|
*/
|
|
26
26
|
function readCache(pCacheFolder) {
|
|
27
27
|
try {
|
|
@@ -36,11 +36,11 @@ function readCache(pCacheFolder) {
|
|
|
36
36
|
/**
|
|
37
37
|
*
|
|
38
38
|
* @param {import("../../types/strict-options").IStrictCruiseOptions} pOptions
|
|
39
|
-
* @param {import("
|
|
40
|
-
* @returns
|
|
39
|
+
* @param {import("../..").IRevisionData} pRevisionData
|
|
40
|
+
* @returns {boolean}
|
|
41
41
|
*/
|
|
42
42
|
function canServeFromCache(pOptions, pRevisionData) {
|
|
43
|
-
/** @type {import("
|
|
43
|
+
/** @type {import("../..").ICruiseResult} */
|
|
44
44
|
const lCachedResults = readCache(pOptions.cache);
|
|
45
45
|
|
|
46
46
|
return (
|
|
@@ -36,10 +36,18 @@ function isInterestingChangeType(pInterestingChangeTypes) {
|
|
|
36
36
|
return (pChange) => pInterestingChangeTypes.has(pChange.changeType);
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
+
/**
|
|
40
|
+
* @param {string} pString
|
|
41
|
+
* @returns {string}
|
|
42
|
+
*/
|
|
39
43
|
function hash(pString) {
|
|
40
44
|
return createHash("sha1").update(pString).digest("base64");
|
|
41
45
|
}
|
|
42
46
|
|
|
47
|
+
/**
|
|
48
|
+
* @param {import("fs").PathOrFileDescriptor} pFileName
|
|
49
|
+
* @returns {string}
|
|
50
|
+
*/
|
|
43
51
|
function getFileHash(pFileName) {
|
|
44
52
|
try {
|
|
45
53
|
return hash(readFileSync(pFileName, "utf8"));
|
|
@@ -50,7 +58,7 @@ function getFileHash(pFileName) {
|
|
|
50
58
|
|
|
51
59
|
/**
|
|
52
60
|
* @param {import("watskeburt").IChange} pChange
|
|
53
|
-
* @param {import("
|
|
61
|
+
* @param {import("../..").IRevisionChange}
|
|
54
62
|
*/
|
|
55
63
|
function addChecksum(pChange) {
|
|
56
64
|
return {
|
|
@@ -66,8 +74,8 @@ function addChecksum(pChange) {
|
|
|
66
74
|
* @param {Object} pOptions
|
|
67
75
|
* @param {() => string} pOptions.shaRetrievalFn
|
|
68
76
|
* @param {(pString:string) => Array<import("watskeburt").IChange>} pOptions.diffListFn
|
|
69
|
-
* @param {(import("watskeburt").IChange) => import("
|
|
70
|
-
* @returns {import("
|
|
77
|
+
* @param {(import("watskeburt").IChange) => import("../..").IRevisionChange} pOptions.checkSumFn
|
|
78
|
+
* @returns {import("../..").IRevisionData}
|
|
71
79
|
*/
|
|
72
80
|
function getRevisionData(
|
|
73
81
|
pExtensions,
|
|
@@ -100,9 +108,8 @@ function getRevisionData(
|
|
|
100
108
|
}
|
|
101
109
|
|
|
102
110
|
/**
|
|
103
|
-
*
|
|
104
|
-
* @param {import("
|
|
105
|
-
* @param {import("../../types/cruise-result").IRevisionData} pNewRevisionData
|
|
111
|
+
* @param {import("../..").IRevisionData} pExistingRevisionData
|
|
112
|
+
* @param {import("../..").IRevisionData} pNewRevisionData
|
|
106
113
|
* @returns {boolean}
|
|
107
114
|
*/
|
|
108
115
|
function revisionDataEqual(pExistingRevisionData, pNewRevisionData) {
|
package/src/cache/utl.js
CHANGED
package/src/cli/format.js
CHANGED
|
@@ -7,10 +7,10 @@ const io = require("./utl/io");
|
|
|
7
7
|
/**
|
|
8
8
|
*
|
|
9
9
|
* @param {string} pResultFile the name of the file with cruise results
|
|
10
|
-
* @param {import("
|
|
10
|
+
* @param {import("../..").IFormatOptions} pOptions
|
|
11
11
|
* @returns {Number} an exitCode
|
|
12
12
|
*/
|
|
13
|
-
module.exports = async (pResultFile, pOptions)
|
|
13
|
+
module.exports = async function format(pResultFile, pOptions) {
|
|
14
14
|
const lOptions = normalizeOptions(pOptions);
|
|
15
15
|
|
|
16
16
|
if (pResultFile !== "-") {
|
package/src/cli/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const path = require("path");
|
|
2
2
|
const glob = require("glob");
|
|
3
|
-
const
|
|
3
|
+
const cloneDeep = require("lodash/cloneDeep");
|
|
4
4
|
const set = require("lodash/set");
|
|
5
5
|
const isInstalledGlobally = require("is-installed-globally");
|
|
6
6
|
const { red, yellow, bold } = require("chalk");
|
|
@@ -42,7 +42,7 @@ function addKnownViolations(pCruiseOptions) {
|
|
|
42
42
|
|
|
43
43
|
// Check against json schema is already done in src/main/options/validate
|
|
44
44
|
// so here we can just concentrate on the io
|
|
45
|
-
let lCruiseOptions =
|
|
45
|
+
let lCruiseOptions = cloneDeep(pCruiseOptions);
|
|
46
46
|
set(lCruiseOptions, "ruleSet.options.knownViolations", lKnownViolations);
|
|
47
47
|
return lCruiseOptions;
|
|
48
48
|
}
|
|
@@ -119,7 +119,6 @@ function runCruise(pFileDirectoryArray, pCruiseOptions) {
|
|
|
119
119
|
bus.emit("progress", "cli: writing results");
|
|
120
120
|
bus.emit("write-start");
|
|
121
121
|
io.write(lCruiseOptions.outputTo, lReportingResult.output);
|
|
122
|
-
bus.emit("end");
|
|
123
122
|
|
|
124
123
|
return lReportingResult.exitCode;
|
|
125
124
|
}
|
|
@@ -127,11 +126,11 @@ function runCruise(pFileDirectoryArray, pCruiseOptions) {
|
|
|
127
126
|
/**
|
|
128
127
|
*
|
|
129
128
|
* @param {string[]} pFileDirectoryArray
|
|
130
|
-
* @param {import("../../types/options").ICruiseOptions}
|
|
129
|
+
* @param {import("../../types/options").ICruiseOptions} lCruiseOptions
|
|
131
130
|
* @returns {number}
|
|
132
131
|
*/
|
|
133
132
|
module.exports = function executeCli(pFileDirectoryArray, pCruiseOptions) {
|
|
134
|
-
|
|
133
|
+
let lCruiseOptions = pCruiseOptions || {};
|
|
135
134
|
let lExitCode = 0;
|
|
136
135
|
|
|
137
136
|
try {
|
|
@@ -150,9 +149,9 @@ module.exports = function executeCli(pFileDirectoryArray, pCruiseOptions) {
|
|
|
150
149
|
);
|
|
151
150
|
}
|
|
152
151
|
/* c8 ignore stop */
|
|
153
|
-
if (
|
|
152
|
+
if (lCruiseOptions.info === true) {
|
|
154
153
|
process.stdout.write(formatMetaInfo());
|
|
155
|
-
} else if (
|
|
154
|
+
} else if (lCruiseOptions.init) {
|
|
156
155
|
// requiring init-config took ~100ms (most of it taken up by requiring
|
|
157
156
|
// inquirer, measured on a 2.6GHz quad core i7 with flash storage on
|
|
158
157
|
// macOS 10.15.7). Only requiring it when '--init' is necessary speeds up
|
|
@@ -161,15 +160,15 @@ module.exports = function executeCli(pFileDirectoryArray, pCruiseOptions) {
|
|
|
161
160
|
// holds.
|
|
162
161
|
// eslint-disable-next-line node/global-require
|
|
163
162
|
const initConfig = require("./init-config");
|
|
164
|
-
initConfig(
|
|
163
|
+
initConfig(lCruiseOptions.init);
|
|
165
164
|
} else {
|
|
166
|
-
lExitCode = runCruise(pFileDirectoryArray,
|
|
165
|
+
lExitCode = runCruise(pFileDirectoryArray, lCruiseOptions);
|
|
167
166
|
}
|
|
168
167
|
} catch (pError) {
|
|
169
168
|
process.stderr.write(`\n ${red("ERROR")}: ${pError.message}\n`);
|
|
170
169
|
bus.emit("end");
|
|
171
170
|
lExitCode = 1;
|
|
172
171
|
}
|
|
173
|
-
|
|
172
|
+
bus.emit("end");
|
|
174
173
|
return lExitCode;
|
|
175
174
|
};
|
|
@@ -1,17 +1,36 @@
|
|
|
1
|
+
// @ts-check
|
|
1
2
|
const Handlebars = require("handlebars/runtime");
|
|
2
|
-
|
|
3
3
|
const { folderNameArrayToRE } = require("./utl");
|
|
4
4
|
|
|
5
5
|
/* eslint import/no-unassigned-import: 0 */
|
|
6
6
|
require("./config.js.template");
|
|
7
7
|
|
|
8
|
+
/**
|
|
9
|
+
* @param {string} pString
|
|
10
|
+
* @returns {string}
|
|
11
|
+
*/
|
|
12
|
+
function quote(pString) {
|
|
13
|
+
return `"${pString}"`;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* @param {string[]=} pExtensions
|
|
18
|
+
* @returns {string}
|
|
19
|
+
*/
|
|
20
|
+
function extensionsToString(pExtensions) {
|
|
21
|
+
if (pExtensions) {
|
|
22
|
+
return `[${pExtensions.map(quote).join(", ")}]`;
|
|
23
|
+
}
|
|
24
|
+
return "";
|
|
25
|
+
}
|
|
26
|
+
|
|
8
27
|
/**
|
|
9
28
|
* Creates a .dependency-cruiser config with a set of basic validations
|
|
10
29
|
* to the current directory.
|
|
11
30
|
*
|
|
12
|
-
* @
|
|
13
|
-
* @param {any} pNormalizedInitOptions Options that influence the shape of
|
|
31
|
+
* @param {import("./types").IInitConfig} pNormalizedInitOptions Options that influence the shape of
|
|
14
32
|
* the configuration
|
|
33
|
+
* @returns {string} the configuration as a string
|
|
15
34
|
*/
|
|
16
35
|
|
|
17
36
|
module.exports = function buildConfig(pNormalizedInitOptions) {
|
|
@@ -22,5 +41,8 @@ module.exports = function buildConfig(pNormalizedInitOptions) {
|
|
|
22
41
|
pNormalizedInitOptions.sourceLocation
|
|
23
42
|
),
|
|
24
43
|
testLocationRE: folderNameArrayToRE(pNormalizedInitOptions.testLocation),
|
|
44
|
+
resolutionExtensionsAsString: extensionsToString(
|
|
45
|
+
pNormalizedInitOptions.resolutionExtensions
|
|
46
|
+
),
|
|
25
47
|
});
|
|
26
48
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var Handlebars=require("handlebars/runtime"),template=Handlebars.template,templates=Handlebars.templates=Handlebars.templates||{};templates["config.js.template.hbs"]=template({1:function(e,n,t,o,s){var i,r=null!=n?n:e.nullContext||{},a=e.hooks.helperMissing,l="function",c=e.escapeExpression,e=e.lookupProperty||function(e,n){if(Object.prototype.hasOwnProperty.call(e,n))return e[n]};return" 'extends': '"+c(typeof(i=null!=(i=e(t,"preset")||(null!=n?e(n,"preset"):n))?i:a)==l?i.call(r,{name:"preset",hash:{},data:s,loc:{start:{line:4,column:14},end:{line:4,column:24}}}):i)+"',\n /*\n the '"+c(typeof(i=null!=(i=e(t,"preset")||(null!=n?e(n,"preset"):n))?i:a)==l?i.call(r,{name:"preset",hash:{},data:s,loc:{start:{line:6,column:10},end:{line:6,column:20}}}):i)+"' preset\n contains these rules:\n no-circular - flags all circular dependencies\n no-orphans - flags orphan modules (except typescript .d.ts files)\n no-deprecated-core - flags dependencies on deprecated node 'core' modules\n no-deprecated-npm - flags dependencies on deprecated npm modules\n no-non-package-json - flags (npm) dependencies that don't occur in package.json\n not-to-unresolvable - flags dependencies that can't be resolved`\n no-duplicate-dep-types - flags dependencies that occur more than once in package.json\n\n If you need to, you can override these rules. E.g. to ignore the\n no-duplicate-dep-types rule, you can set its severity to \"ignore\" by\n adding this to the 'forbidden' section:\n {\n name: 'no-duplicate-dep-types',\n severity: 'ignore'\n }\n\n Also, by default, the preset does not follow any external modules (things in\n node_modules or in yarn's plug'n'play magic). If you want to have that\n differently, just override it the options.doNotFollow key.\n */\n forbidden: [\n"},3:function(e,n,t,o,s){return" forbidden: [\n /* rules from the 'recommended' preset: */\n {\n name: 'no-circular',\n severity: 'warn',\n comment:\n 'This dependency is part of a circular relationship. You might want to revise ' +\n 'your solution (i.e. use dependency inversion, make sure the modules have a single responsibility) ',\n from: {},\n to: {\n circular: true\n }\n },\n {\n name: 'no-orphans',\n comment:\n \"This is an orphan module - it's likely not used (anymore?). Either use it or \" +\n \"remove it. If it's logical this module is an orphan (i.e. it's a config file), \" +\n \"add an exception for it in your dependency-cruiser configuration. By default \" +\n \"this rule does not scrutinize dot-files (e.g. .eslintrc.js), TypeScript declaration \" +\n \"files (.d.ts), tsconfig.json and some of the babel and webpack configs.\",\n severity: 'warn',\n from: {\n orphan: true,\n pathNot: [\n '(^|/)\\\\.[^/]+\\\\.(js|cjs|mjs|ts|json)$', // dot files\n '\\\\.d\\\\.ts$', // TypeScript declaration files\n '(^|/)tsconfig\\\\.json$', // TypeScript config\n '(^|/)(babel|webpack)\\\\.config\\\\.(js|cjs|mjs|ts|json)$' // other configs\n ]\n },\n to: {},\n },\n {\n name: 'no-deprecated-core',\n comment:\n 'A module depends on a node core module that has been deprecated. Find an alternative - these are ' +\n \"bound to exist - node doesn't deprecate lightly.\",\n severity: 'warn',\n from: {},\n to: {\n dependencyTypes: [\n 'core'\n ],\n path: [\n '^(v8\\/tools\\/codemap)$',\n '^(v8\\/tools\\/consarray)$',\n '^(v8\\/tools\\/csvparser)$',\n '^(v8\\/tools\\/logreader)$',\n '^(v8\\/tools\\/profile_view)$',\n '^(v8\\/tools\\/profile)$',\n '^(v8\\/tools\\/SourceMap)$',\n '^(v8\\/tools\\/splaytree)$',\n '^(v8\\/tools\\/tickprocessor-driver)$',\n '^(v8\\/tools\\/tickprocessor)$',\n '^(node-inspect\\/lib\\/_inspect)$',\n '^(node-inspect\\/lib\\/internal\\/inspect_client)$',\n '^(node-inspect\\/lib\\/internal\\/inspect_repl)$',\n '^(async_hooks)$',\n '^(punycode)$',\n '^(domain)$',\n '^(constants)$',\n '^(sys)$',\n '^(_linklist)$',\n '^(_stream_wrap)$'\n ],\n }\n },\n {\n name: 'not-to-deprecated',\n comment:\n 'This module uses a (version of an) npm module that has been deprecated. Either upgrade to a later ' +\n 'version of that module, or find an alternative. Deprecated modules are a security risk.',\n severity: 'warn',\n from: {},\n to: {\n dependencyTypes: [\n 'deprecated'\n ]\n }\n },\n {\n name: 'no-non-package-json',\n severity: 'error',\n comment:\n \"This module depends on an npm package that isn't in the 'dependencies' section of your package.json. \" +\n \"That's problematic as the package either (1) won't be available on live (2 - worse) will be \" +\n \"available on live with an non-guaranteed version. Fix it by adding the package to the dependencies \" +\n \"in your package.json.\",\n from: {},\n to: {\n dependencyTypes: [\n 'npm-no-pkg',\n 'npm-unknown'\n ]\n }\n },\n {\n name: 'not-to-unresolvable',\n comment:\n \"This module depends on a module that cannot be found ('resolved to disk'). If it's an npm \" +\n 'module: add it to your package.json. In all other cases you likely already know what to do.',\n severity: 'error',\n from: {},\n to: {\n couldNotResolve: true\n }\n },\n {\n name: 'no-duplicate-dep-types',\n comment:\n \"Likely this module depends on an external ('npm') package that occurs more than once \" +\n \"in your package.json i.e. bot as a devDependencies and in dependencies. This will cause \" +\n \"maintenance problems later on.\",\n severity: 'warn',\n from: {},\n to: {\n moreThanOneDependencyType: true,\n // as it's pretty common to have a type import be a type only import \n // _and_ (e.g.) a devDependency - don't consider type-only dependency\n // types for this rule\n dependencyTypesNot: [\"type-only\"]\n }\n },\n\n /* rules you might want to tweak for your specific situation: */\n"},5:function(e,n,t,o,s){var i,r=null!=n?n:e.nullContext||{},a=e.hooks.helperMissing,l="function",c=e.escapeExpression,e=e.lookupProperty||function(e,n){if(Object.prototype.hasOwnProperty.call(e,n))return e[n]};return" {\n name: 'not-to-test',\n comment:\n \"This module depends on code within a folder that should only contain tests. As tests don't \" +\n \"implement functionality this is odd. Either you're writing a test outside the test folder \" +\n \"or there's something in the test folder that isn't a test.\",\n severity: 'error',\n from: {\n pathNot: '"+c(typeof(i=null!=(i=e(t,"testLocationRE")||(null!=n?e(n,"testLocationRE"):n))?i:a)==l?i.call(r,{name:"testLocationRE",hash:{},data:s,loc:{start:{line:166,column:18},end:{line:166,column:36}}}):i)+"'\n },\n to: {\n path: '"+c(typeof(i=null!=(i=e(t,"testLocationRE")||(null!=n?e(n,"testLocationRE"):n))?i:a)==l?i.call(r,{name:"testLocationRE",hash:{},data:s,loc:{start:{line:169,column:15},end:{line:169,column:33}}}):i)+"'\n }\n },\n"},7:function(e,n,t,o,s){return" tsPreCompilationDeps: true,\n"},9:function(e,n,t,o,s){return" // tsPreCompilationDeps: false,\n"},11:function(e,n,t,o,s){return" combinedDependencies: true,\n"},13:function(e,n,t,o,s){return" // combinedDependencies: false,\n"},15:function(e,n,t,o,s){var i=e.lookupProperty||function(e,n){if(Object.prototype.hasOwnProperty.call(e,n))return e[n]};return" tsConfig: {\n fileName: '"+e.escapeExpression("function"==typeof(t=null!=(t=i(t,"tsConfig")||(null!=n?i(n,"tsConfig"):n))?t:e.hooks.helperMissing)?t.call(null!=n?n:e.nullContext||{},{name:"tsConfig",hash:{},data:s,loc:{start:{line:316,column:17},end:{line:316,column:29}}}):t)+"'\n },\n"},17:function(e,n,t,o,s){var i=e.lookupProperty||function(e,n){if(Object.prototype.hasOwnProperty.call(e,n))return e[n]};return null!=(t=i(t,"if").call(null!=n?n:e.nullContext||{},null!=n?i(n,"useJsConfig"):n,{name:"if",hash:{},fn:e.program(18,s,0),inverse:e.program(20,s,0),data:s,loc:{start:{line:319,column:6},end:{line:327,column:13}}}))?t:""},18:function(e,n,t,o,s){var i=e.lookupProperty||function(e,n){if(Object.prototype.hasOwnProperty.call(e,n))return e[n]};return" tsConfig: {\n fileName: '"+e.escapeExpression("function"==typeof(t=null!=(t=i(t,"jsConfig")||(null!=n?i(n,"jsConfig"):n))?t:e.hooks.helperMissing)?t.call(null!=n?n:e.nullContext||{},{name:"jsConfig",hash:{},data:s,loc:{start:{line:321,column:17},end:{line:321,column:29}}}):t)+"'\n },\n"},20:function(e,n,t,o,s){return" // tsConfig: {\n // fileName: './tsconfig.json'\n // },\n"},22:function(e,n,t,o,s){var i=e.lookupProperty||function(e,n){if(Object.prototype.hasOwnProperty.call(e,n))return e[n]};return" webpackConfig: {\n fileName: '"+e.escapeExpression("function"==typeof(t=null!=(t=i(t,"webpackConfig")||(null!=n?i(n,"webpackConfig"):n))?t:e.hooks.helperMissing)?t.call(null!=n?n:e.nullContext||{},{name:"webpackConfig",hash:{},data:s,loc:{start:{line:342,column:17},end:{line:342,column:34}}}):t)+"',\n // env: {},\n // args: {},\n },\n"},24:function(e,n,t,o,s){return" // webpackConfig: {\n // fileName: './webpack.config.js',\n // env: {},\n // args: {},\n // },\n"},26:function(e,n,t,o,s){var i=e.lookupProperty||function(e,n){if(Object.prototype.hasOwnProperty.call(e,n))return e[n]};return" babelConfig: {\n fileName: '"+e.escapeExpression("function"==typeof(t=null!=(t=i(t,"babelConfig")||(null!=n?i(n,"babelConfig"):n))?t:e.hooks.helperMissing)?t.call(null!=n?n:e.nullContext||{},{name:"babelConfig",hash:{},data:s,loc:{start:{line:362,column:17},end:{line:362,column:32}}}):t)+"'\n },\n"},28:function(e,n,t,o,s){return" // babelConfig: {\n // fileName: './.babelrc'\n // },\n"},compiler:[8,">= 4.3.0"],main:function(e,n,t,o,s){var i=null!=n?n:e.nullContext||{},r=e.hooks.helperMissing,a="function",l=e.escapeExpression,c=e.lookupProperty||function(e,n){if(Object.prototype.hasOwnProperty.call(e,n))return e[n]},p="/** @type {import('dependency-cruiser').IConfiguration} */\nmodule.exports = {\n"+(null!=(h=c(t,"if").call(i,null!=n?c(n,"preset"):n,{name:"if",hash:{},fn:e.program(1,s,0),inverse:e.program(3,s,0),data:s,loc:{start:{line:3,column:0},end:{line:156,column:7}}}))?h:""),d=null!=(d=c(t,"hasTestsOutsideSource")||(null!=n?c(n,"hasTestsOutsideSource"):n))?d:r,u={name:"hasTestsOutsideSource",hash:{},fn:e.program(5,s,0),inverse:e.noop,data:s,loc:{start:{line:157,column:4},end:{line:172,column:30}}},h=typeof d==a?d.call(i,u):d;return null!=(h=c(t,"hasTestsOutsideSource")?h:e.hooks.blockHelperMissing.call(n,h,u))&&(p+=h),p+" {\n name: 'not-to-spec',\n comment:\n 'This module depends on a spec (test) file. The sole responsibility of a spec file is to test code. ' +\n \"If there's something in a spec that's of use to other modules, it doesn't have that single \" +\n 'responsibility anymore. Factor it out into (e.g.) a separate utility/ helper or a mock.',\n severity: 'error',\n from: {},\n to: {\n path: '\\\\.(spec|test)\\\\.(js|mjs|cjs|ts|ls|coffee|litcoffee|coffee\\\\.md)$'\n }\n },\n {\n name: 'not-to-dev-dep',\n severity: 'error',\n comment:\n \"This module depends on an npm package from the 'devDependencies' section of your \" +\n 'package.json. It looks like something that ships to production, though. To prevent problems ' +\n \"with npm packages that aren't there on production declare it (only!) in the 'dependencies'\" +\n 'section of your package.json. If this module is development only - add it to the ' +\n 'from.pathNot re of the not-to-dev-dep rule in the dependency-cruiser configuration',\n from: {\n path: '"+l(typeof(d=null!=(d=c(t,"sourceLocationRE")||(null!=n?c(n,"sourceLocationRE"):n))?d:r)==a?d.call(i,{name:"sourceLocationRE",hash:{},data:s,loc:{start:{line:195,column:15},end:{line:195,column:35}}}):d)+"',\n pathNot: '\\\\.(spec|test)\\\\.(js|mjs|cjs|ts|ls|coffee|litcoffee|coffee\\\\.md)$'\n },\n to: {\n dependencyTypes: [\n 'npm-dev'\n ]\n }\n },\n {\n name: 'optional-deps-used',\n severity: 'info',\n comment:\n \"This module depends on an npm package that is declared as an optional dependency \" +\n \"in your package.json. As this makes sense in limited situations only, it's flagged here. \" +\n \"If you're using an optional dependency here by design - add an exception to your\" +\n \"dependency-cruiser configuration.\",\n from: {},\n to: {\n dependencyTypes: [\n 'npm-optional'\n ]\n }\n },\n {\n name: 'peer-deps-used',\n comment:\n \"This module depends on an npm package that is declared as a peer dependency \" +\n \"in your package.json. This makes sense if your package is e.g. a plugin, but in \" +\n \"other cases - maybe not so much. If the use of a peer dependency is intentional \" +\n \"add an exception to your dependency-cruiser configuration.\",\n severity: 'warn',\n from: {},\n to: {\n dependencyTypes: [\n 'npm-peer'\n ]\n }\n }\n ],\n options: {\n\n /* conditions specifying which files not to follow further when encountered:\n - path: a regular expression to match\n - dependencyTypes: see https://github.com/sverweij/dependency-cruiser/blob/master/doc/rules-reference.md#dependencytypes-and-dependencytypesnot\n for a complete list\n */\n doNotFollow: {\n path: 'node_modules'\n },\n\n /* conditions specifying which dependencies to exclude\n - path: a regular expression to match\n - dynamic: a boolean indicating whether to ignore dynamic (true) or static (false) dependencies.\n leave out if you want to exclude neither (recommended!)\n */\n // exclude : {\n // path: '',\n // dynamic: true\n // },\n\n /* pattern specifying which files to include (regular expression)\n dependency-cruiser will skip everything not matching this pattern\n */\n // includeOnly : '',\n\n /* dependency-cruiser will include modules matching against the focus\n regular expression in its output, as well as their neighbours (direct\n dependencies and dependents)\n */\n // focus : '',\n\n /* list of module systems to cruise */\n // moduleSystems: ['amd', 'cjs', 'es6', 'tsd'],\n\n /* prefix for links in html and svg output (e.g. 'https://github.com/you/yourrepo/blob/develop/'\n to open it on your online repo or `vscode://file/${process.cwd()}/` to \n open it in visual studio code),\n */\n // prefix: '',\n\n /* false (the default): ignore dependencies that only exist before typescript-to-javascript compilation\n true: also detect dependencies that only exist before typescript-to-javascript compilation\n \"specify\": for each dependency identify whether it only exists before compilation or also after\n */\n"+(null!=(h=c(t,"if").call(i,null!=n?c(n,"tsPreCompilationDeps"):n,{name:"if",hash:{},fn:e.program(7,s,0),inverse:e.program(9,s,0),data:s,loc:{start:{line:280,column:4},end:{line:284,column:11}}}))?h:"")+' \n /* \n list of extensions to scan that aren\'t javascript or compile-to-javascript. \n Empty by default. Only put extensions in here that you want to take into\n account that are _not_ parsable. \n */\n // extraExtensionsToScan: [".json", ".jpg", ".png", ".svg", ".webp"],\n\n /* if true combines the package.jsons found from the module up to the base\n folder the cruise is initiated from. Useful for how (some) mono-repos\n manage dependencies & dependency definitions.\n */\n'+(null!=(h=c(t,"if").call(i,null!=n?c(n,"combinedDependencies"):n,{name:"if",hash:{},fn:e.program(11,s,0),inverse:e.program(13,s,0),data:s,loc:{start:{line:297,column:4},end:{line:301,column:11}}}))?h:"")+"\n /* if true leave symlinks untouched, otherwise use the realpath */\n // preserveSymlinks: false,\n\n /* TypeScript project file ('tsconfig.json') to use for\n (1) compilation and\n (2) resolution (e.g. with the paths property)\n\n The (optional) fileName attribute specifies which file to take (relative to\n dependency-cruiser's current working directory). When not provided\n defaults to './tsconfig.json'.\n */\n"+(null!=(h=c(t,"if").call(i,null!=n?c(n,"useTsConfig"):n,{name:"if",hash:{},fn:e.program(15,s,0),inverse:e.program(17,s,0),data:s,loc:{start:{line:314,column:4},end:{line:328,column:11}}}))?h:"")+"\n /* Webpack configuration to use to get resolve options from.\n\n The (optional) fileName attribute specifies which file to take (relative\n to dependency-cruiser's current working directory. When not provided defaults\n to './webpack.conf.js'.\n\n The (optional) `env` and `args` attributes contain the parameters to be passed if\n your webpack config is a function and takes them (see webpack documentation\n for details)\n */\n"+(null!=(h=c(t,"if").call(i,null!=n?c(n,"useWebpackConfig"):n,{name:"if",hash:{},fn:e.program(22,s,0),inverse:e.program(24,s,0),data:s,loc:{start:{line:340,column:4},end:{line:352,column:11}}}))?h:"")+"\n /* Babel config ('.babelrc', '.babelrc.json', '.babelrc.json5', ...) to use\n for compilation (and whatever other naughty things babel plugins do to\n source code). This feature is well tested and usable, but might change\n behavior a bit over time (e.g. more precise results for used module \n systems) without dependency-cruiser getting a major version bump.\n */\n"+(null!=(h=c(t,"if").call(i,null!=n?c(n,"useBabelConfig"):n,{name:"if",hash:{},fn:e.program(26,s,0),inverse:e.program(28,s,0),data:s,loc:{start:{line:360,column:4},end:{line:368,column:11}}}))?h:"")+'\n /* List of strings you have in use in addition to cjs/ es6 requires\n & imports to declare module dependencies. Use this e.g. if you\'ve\n re-declared require, use a require-wrapper or use window.require as\n a hack.\n */\n // exoticRequireStrings: [],\n /* options to pass on to enhanced-resolve, the package dependency-cruiser\n uses to resolve module references to disk. You can set most of these\n options in a webpack.conf.js - this section is here for those\n projects that don\'t have a separate webpack config file.\n\n Note: settings in webpack.conf.js override the ones specified here.\n */\n enhancedResolveOptions: {\n /* List of strings to consider as \'exports\' fields in package.json. Use\n [\'exports\'] when you use packages that use such a field and your environment\n supports it (e.g. node ^12.19 || >=14.7 or recent versions of webpack).\n\n If you have an `exportsFields` attribute in your webpack config, that one\n will have precedence over the one specified here.\n */ \n exportsFields: ["exports"],\n /* List of conditions to check for in the exports field. e.g. use [\'imports\']\n if you\'re only interested in exposed es6 modules, [\'require\'] for commonjs,\n or all conditions at once `([\'import\', \'require\', \'node\', \'default\']`)\n if anything goes for you. Only works when the \'exportsFields\' array is\n non-empty.\n\n If you have a \'conditionNames\' attribute in your webpack config, that one will\n have precedence over the one specified here.\n */\n conditionNames: ["import", "require", "node", "default"]\n /*\n The extensions, by default are the same as the ones dependency-cruiser\n can access (run `npx depcruise --info` to see which ones that are in\n _your_ environment. If that list is larger than what you need (e.g. \n it contains .js, .jsx, .ts, .tsx, .cts, .mts - but you don\'t use \n TypeScript you can pass just the extensions you actually use (e.g. \n [".js", ".jsx"]). This can speed up the most expensive step in \n dependency cruising (module resolution) quite a bit.\n */\n // extensions: [".js", ".jsx", ".ts", ".tsx", ".d.ts"]\n },\n reporterOptions: {\n dot: {\n /* pattern of modules that can be consolidated in the detailed\n graphical dependency graph. The default pattern in this configuration\n collapses everything in node_modules to one folder deep so you see\n the external modules, but not the innards your app depends upon.\n */\n collapsePattern: \'node_modules/[^/]+\',\n\n /* Options to tweak the appearance of your graph.See\n https://github.com/sverweij/dependency-cruiser/blob/master/doc/options-reference.md#reporteroptions\n for details and some examples. If you don\'t specify a theme\n don\'t worry - dependency-cruiser will fall back to the default one.\n */\n // theme: {\n // graph: {\n // /* use splines: "ortho" for straight lines. Be aware though\n // graphviz might take a long time calculating ortho(gonal)\n // routings.\n // */\n // splines: "true"\n // },\n // modules: [\n // {\n // criteria: { matchesFocus: true },\n // attributes: {\n // fillcolor: "lime",\n // penwidth: 2,\n // },\n // },\n // {\n // criteria: { matchesFocus: false },\n // attributes: {\n // fillcolor: "lightgrey",\n // },\n // },\n // {\n // criteria: { matchesReaches: true },\n // attributes: {\n // fillcolor: "lime",\n // penwidth: 2,\n // },\n // },\n // {\n // criteria: { matchesReaches: false },\n // attributes: {\n // fillcolor: "lightgrey",\n // },\n // },\n // {\n // criteria: { source: "^src/model" },\n // attributes: { fillcolor: "#ccccff" }\n // },\n // {\n // criteria: { source: "^src/view" },\n // attributes: { fillcolor: "#ccffcc" }\n // },\n // ],\n // dependencies: [\n // {\n // criteria: { "rules[0].severity": "error" },\n // attributes: { fontcolor: "red", color: "red" }\n // },\n // {\n // criteria: { "rules[0].severity": "warn" },\n // attributes: { fontcolor: "orange", color: "orange" }\n // },\n // {\n // criteria: { "rules[0].severity": "info" },\n // attributes: { fontcolor: "blue", color: "blue" }\n // },\n // {\n // criteria: { resolved: "^src/model" },\n // attributes: { color: "#0000ff77" }\n // },\n // {\n // criteria: { resolved: "^src/view" },\n // attributes: { color: "#00770077" }\n // }\n // ]\n // }\n },\n archi: {\n /* pattern of modules that can be consolidated in the high level\n graphical dependency graph. If you use the high level graphical\n dependency graph reporter (`archi`) you probably want to tweak\n this collapsePattern to your situation.\n */\n collapsePattern: \'^(packages|src|lib|app|bin|test(s?)|spec(s?))/[^/]+|node_modules/[^/]+\',\n\n /* Options to tweak the appearance of your graph.See\n https://github.com/sverweij/dependency-cruiser/blob/master/doc/options-reference.md#reporteroptions\n for details and some examples. If you don\'t specify a theme\n for \'archi\' dependency-cruiser will use the one specified in the\n dot section (see above), if any, and otherwise use the default one.\n */\n // theme: {\n // },\n },\n "text": {\n "highlightFocused": true\n },\n }\n }\n};\n// generated: dependency-cruiser@'+l(typeof(d=null!=(d=c(t,"version")||(null!=n?c(n,"version"):n))?d:r)==a?d.call(i,{name:"version",hash:{},data:s,loc:{start:{line:518,column:33},end:{line:518,column:44}}}):d)+" on "+l(typeof(d=null!=(d=c(t,"date")||(null!=n?c(n,"date"):n))?d:r)==a?d.call(i,{name:"date",hash:{},data:s,loc:{start:{line:518,column:48},end:{line:518,column:56}}}):d)+"\n"},useData:!0});
|
|
1
|
+
var Handlebars=require("handlebars/runtime"),template=Handlebars.template,templates=Handlebars.templates=Handlebars.templates||{};templates["config.js.template.hbs"]=template({1:function(e,n,t,o,s){var i,r=null!=n?n:e.nullContext||{},a=e.hooks.helperMissing,l="function",c=e.escapeExpression,e=e.lookupProperty||function(e,n){if(Object.prototype.hasOwnProperty.call(e,n))return e[n]};return" 'extends': '"+c(typeof(i=null!=(i=e(t,"preset")||(null!=n?e(n,"preset"):n))?i:a)==l?i.call(r,{name:"preset",hash:{},data:s,loc:{start:{line:4,column:14},end:{line:4,column:24}}}):i)+"',\n /*\n the '"+c(typeof(i=null!=(i=e(t,"preset")||(null!=n?e(n,"preset"):n))?i:a)==l?i.call(r,{name:"preset",hash:{},data:s,loc:{start:{line:6,column:10},end:{line:6,column:20}}}):i)+"' preset\n contains these rules:\n no-circular - flags all circular dependencies\n no-orphans - flags orphan modules (except typescript .d.ts files)\n no-deprecated-core - flags dependencies on deprecated node 'core' modules\n no-deprecated-npm - flags dependencies on deprecated npm modules\n no-non-package-json - flags (npm) dependencies that don't occur in package.json\n not-to-unresolvable - flags dependencies that can't be resolved`\n no-duplicate-dep-types - flags dependencies that occur more than once in package.json\n\n If you need to, you can override these rules. E.g. to ignore the\n no-duplicate-dep-types rule, you can set its severity to \"ignore\" by\n adding this to the 'forbidden' section:\n {\n name: 'no-duplicate-dep-types',\n severity: 'ignore'\n }\n\n Also, by default, the preset does not follow any external modules (things in\n node_modules or in yarn's plug'n'play magic). If you want to have that\n differently, just override it the options.doNotFollow key.\n */\n forbidden: [\n"},3:function(e,n,t,o,s){return" forbidden: [\n /* rules from the 'recommended' preset: */\n {\n name: 'no-circular',\n severity: 'warn',\n comment:\n 'This dependency is part of a circular relationship. You might want to revise ' +\n 'your solution (i.e. use dependency inversion, make sure the modules have a single responsibility) ',\n from: {},\n to: {\n circular: true\n }\n },\n {\n name: 'no-orphans',\n comment:\n \"This is an orphan module - it's likely not used (anymore?). Either use it or \" +\n \"remove it. If it's logical this module is an orphan (i.e. it's a config file), \" +\n \"add an exception for it in your dependency-cruiser configuration. By default \" +\n \"this rule does not scrutinize dot-files (e.g. .eslintrc.js), TypeScript declaration \" +\n \"files (.d.ts), tsconfig.json and some of the babel and webpack configs.\",\n severity: 'warn',\n from: {\n orphan: true,\n pathNot: [\n '(^|/)\\\\.[^/]+\\\\.(js|cjs|mjs|ts|json)$', // dot files\n '\\\\.d\\\\.ts$', // TypeScript declaration files\n '(^|/)tsconfig\\\\.json$', // TypeScript config\n '(^|/)(babel|webpack)\\\\.config\\\\.(js|cjs|mjs|ts|json)$' // other configs\n ]\n },\n to: {},\n },\n {\n name: 'no-deprecated-core',\n comment:\n 'A module depends on a node core module that has been deprecated. Find an alternative - these are ' +\n \"bound to exist - node doesn't deprecate lightly.\",\n severity: 'warn',\n from: {},\n to: {\n dependencyTypes: [\n 'core'\n ],\n path: [\n '^(v8\\/tools\\/codemap)$',\n '^(v8\\/tools\\/consarray)$',\n '^(v8\\/tools\\/csvparser)$',\n '^(v8\\/tools\\/logreader)$',\n '^(v8\\/tools\\/profile_view)$',\n '^(v8\\/tools\\/profile)$',\n '^(v8\\/tools\\/SourceMap)$',\n '^(v8\\/tools\\/splaytree)$',\n '^(v8\\/tools\\/tickprocessor-driver)$',\n '^(v8\\/tools\\/tickprocessor)$',\n '^(node-inspect\\/lib\\/_inspect)$',\n '^(node-inspect\\/lib\\/internal\\/inspect_client)$',\n '^(node-inspect\\/lib\\/internal\\/inspect_repl)$',\n '^(async_hooks)$',\n '^(punycode)$',\n '^(domain)$',\n '^(constants)$',\n '^(sys)$',\n '^(_linklist)$',\n '^(_stream_wrap)$'\n ],\n }\n },\n {\n name: 'not-to-deprecated',\n comment:\n 'This module uses a (version of an) npm module that has been deprecated. Either upgrade to a later ' +\n 'version of that module, or find an alternative. Deprecated modules are a security risk.',\n severity: 'warn',\n from: {},\n to: {\n dependencyTypes: [\n 'deprecated'\n ]\n }\n },\n {\n name: 'no-non-package-json',\n severity: 'error',\n comment:\n \"This module depends on an npm package that isn't in the 'dependencies' section of your package.json. \" +\n \"That's problematic as the package either (1) won't be available on live (2 - worse) will be \" +\n \"available on live with an non-guaranteed version. Fix it by adding the package to the dependencies \" +\n \"in your package.json.\",\n from: {},\n to: {\n dependencyTypes: [\n 'npm-no-pkg',\n 'npm-unknown'\n ]\n }\n },\n {\n name: 'not-to-unresolvable',\n comment:\n \"This module depends on a module that cannot be found ('resolved to disk'). If it's an npm \" +\n 'module: add it to your package.json. In all other cases you likely already know what to do.',\n severity: 'error',\n from: {},\n to: {\n couldNotResolve: true\n }\n },\n {\n name: 'no-duplicate-dep-types',\n comment:\n \"Likely this module depends on an external ('npm') package that occurs more than once \" +\n \"in your package.json i.e. bot as a devDependencies and in dependencies. This will cause \" +\n \"maintenance problems later on.\",\n severity: 'warn',\n from: {},\n to: {\n moreThanOneDependencyType: true,\n // as it's pretty common to have a type import be a type only import \n // _and_ (e.g.) a devDependency - don't consider type-only dependency\n // types for this rule\n dependencyTypesNot: [\"type-only\"]\n }\n },\n\n /* rules you might want to tweak for your specific situation: */\n"},5:function(e,n,t,o,s){var i,r=null!=n?n:e.nullContext||{},a=e.hooks.helperMissing,l="function",c=e.escapeExpression,e=e.lookupProperty||function(e,n){if(Object.prototype.hasOwnProperty.call(e,n))return e[n]};return" {\n name: 'not-to-test',\n comment:\n \"This module depends on code within a folder that should only contain tests. As tests don't \" +\n \"implement functionality this is odd. Either you're writing a test outside the test folder \" +\n \"or there's something in the test folder that isn't a test.\",\n severity: 'error',\n from: {\n pathNot: '"+c(typeof(i=null!=(i=e(t,"testLocationRE")||(null!=n?e(n,"testLocationRE"):n))?i:a)==l?i.call(r,{name:"testLocationRE",hash:{},data:s,loc:{start:{line:166,column:18},end:{line:166,column:36}}}):i)+"'\n },\n to: {\n path: '"+c(typeof(i=null!=(i=e(t,"testLocationRE")||(null!=n?e(n,"testLocationRE"):n))?i:a)==l?i.call(r,{name:"testLocationRE",hash:{},data:s,loc:{start:{line:169,column:15},end:{line:169,column:33}}}):i)+"'\n }\n },\n"},7:function(e,n,t,o,s){return" tsPreCompilationDeps: true,\n"},9:function(e,n,t,o,s){return" // tsPreCompilationDeps: false,\n"},11:function(e,n,t,o,s){return" combinedDependencies: true,\n"},13:function(e,n,t,o,s){return" // combinedDependencies: false,\n"},15:function(e,n,t,o,s){var i=e.lookupProperty||function(e,n){if(Object.prototype.hasOwnProperty.call(e,n))return e[n]};return" tsConfig: {\n fileName: '"+e.escapeExpression("function"==typeof(t=null!=(t=i(t,"tsConfig")||(null!=n?i(n,"tsConfig"):n))?t:e.hooks.helperMissing)?t.call(null!=n?n:e.nullContext||{},{name:"tsConfig",hash:{},data:s,loc:{start:{line:316,column:17},end:{line:316,column:29}}}):t)+"'\n },\n"},17:function(e,n,t,o,s){var i=e.lookupProperty||function(e,n){if(Object.prototype.hasOwnProperty.call(e,n))return e[n]};return null!=(t=i(t,"if").call(null!=n?n:e.nullContext||{},null!=n?i(n,"useJsConfig"):n,{name:"if",hash:{},fn:e.program(18,s,0),inverse:e.program(20,s,0),data:s,loc:{start:{line:319,column:6},end:{line:327,column:13}}}))?t:""},18:function(e,n,t,o,s){var i=e.lookupProperty||function(e,n){if(Object.prototype.hasOwnProperty.call(e,n))return e[n]};return" tsConfig: {\n fileName: '"+e.escapeExpression("function"==typeof(t=null!=(t=i(t,"jsConfig")||(null!=n?i(n,"jsConfig"):n))?t:e.hooks.helperMissing)?t.call(null!=n?n:e.nullContext||{},{name:"jsConfig",hash:{},data:s,loc:{start:{line:321,column:17},end:{line:321,column:29}}}):t)+"'\n },\n"},20:function(e,n,t,o,s){return" // tsConfig: {\n // fileName: './tsconfig.json'\n // },\n"},22:function(e,n,t,o,s){var i=e.lookupProperty||function(e,n){if(Object.prototype.hasOwnProperty.call(e,n))return e[n]};return" webpackConfig: {\n fileName: '"+e.escapeExpression("function"==typeof(t=null!=(t=i(t,"webpackConfig")||(null!=n?i(n,"webpackConfig"):n))?t:e.hooks.helperMissing)?t.call(null!=n?n:e.nullContext||{},{name:"webpackConfig",hash:{},data:s,loc:{start:{line:342,column:17},end:{line:342,column:34}}}):t)+"',\n // env: {},\n // args: {},\n },\n"},24:function(e,n,t,o,s){return" // webpackConfig: {\n // fileName: './webpack.config.js',\n // env: {},\n // args: {},\n // },\n"},26:function(e,n,t,o,s){var i=e.lookupProperty||function(e,n){if(Object.prototype.hasOwnProperty.call(e,n))return e[n]};return" babelConfig: {\n fileName: '"+e.escapeExpression("function"==typeof(t=null!=(t=i(t,"babelConfig")||(null!=n?i(n,"babelConfig"):n))?t:e.hooks.helperMissing)?t.call(null!=n?n:e.nullContext||{},{name:"babelConfig",hash:{},data:s,loc:{start:{line:362,column:17},end:{line:362,column:32}}}):t)+"'\n },\n"},28:function(e,n,t,o,s){return" // babelConfig: {\n // fileName: './.babelrc'\n // },\n"},30:function(e,n,t,o,s){var i=e.lookupProperty||function(e,n){if(Object.prototype.hasOwnProperty.call(e,n))return e[n]};return" extensions: "+(null!=(i="function"==typeof(t=null!=(t=i(t,"resolutionExtensionsAsString")||(null!=n?i(n,"resolutionExtensionsAsString"):n))?t:e.hooks.helperMissing)?t.call(null!=n?n:e.nullContext||{},{name:"resolutionExtensionsAsString",hash:{},data:s,loc:{start:{line:412,column:18},end:{line:412,column:52}}}):t)?i:"")+",\n"},32:function(e,n,t,o,s){return' // extensions: [".js", ".jsx", ".ts", ".tsx", ".d.ts"]\n'},compiler:[8,">= 4.3.0"],main:function(e,n,t,o,s){var i=null!=n?n:e.nullContext||{},r=e.hooks.helperMissing,a="function",l=e.escapeExpression,c=e.lookupProperty||function(e,n){if(Object.prototype.hasOwnProperty.call(e,n))return e[n]},p="/** @type {import('dependency-cruiser').IConfiguration} */\nmodule.exports = {\n"+(null!=(h=c(t,"if").call(i,null!=n?c(n,"preset"):n,{name:"if",hash:{},fn:e.program(1,s,0),inverse:e.program(3,s,0),data:s,loc:{start:{line:3,column:0},end:{line:156,column:7}}}))?h:""),u=null!=(u=c(t,"hasTestsOutsideSource")||(null!=n?c(n,"hasTestsOutsideSource"):n))?u:r,d={name:"hasTestsOutsideSource",hash:{},fn:e.program(5,s,0),inverse:e.noop,data:s,loc:{start:{line:157,column:4},end:{line:172,column:30}}},h=typeof u==a?u.call(i,d):u;return null!=(h=c(t,"hasTestsOutsideSource")?h:e.hooks.blockHelperMissing.call(n,h,d))&&(p+=h),p+" {\n name: 'not-to-spec',\n comment:\n 'This module depends on a spec (test) file. The sole responsibility of a spec file is to test code. ' +\n \"If there's something in a spec that's of use to other modules, it doesn't have that single \" +\n 'responsibility anymore. Factor it out into (e.g.) a separate utility/ helper or a mock.',\n severity: 'error',\n from: {},\n to: {\n path: '\\\\.(spec|test)\\\\.(js|mjs|cjs|ts|ls|coffee|litcoffee|coffee\\\\.md)$'\n }\n },\n {\n name: 'not-to-dev-dep',\n severity: 'error',\n comment:\n \"This module depends on an npm package from the 'devDependencies' section of your \" +\n 'package.json. It looks like something that ships to production, though. To prevent problems ' +\n \"with npm packages that aren't there on production declare it (only!) in the 'dependencies'\" +\n 'section of your package.json. If this module is development only - add it to the ' +\n 'from.pathNot re of the not-to-dev-dep rule in the dependency-cruiser configuration',\n from: {\n path: '"+l(typeof(u=null!=(u=c(t,"sourceLocationRE")||(null!=n?c(n,"sourceLocationRE"):n))?u:r)==a?u.call(i,{name:"sourceLocationRE",hash:{},data:s,loc:{start:{line:195,column:15},end:{line:195,column:35}}}):u)+"',\n pathNot: '\\\\.(spec|test)\\\\.(js|mjs|cjs|ts|ls|coffee|litcoffee|coffee\\\\.md)$'\n },\n to: {\n dependencyTypes: [\n 'npm-dev'\n ]\n }\n },\n {\n name: 'optional-deps-used',\n severity: 'info',\n comment:\n \"This module depends on an npm package that is declared as an optional dependency \" +\n \"in your package.json. As this makes sense in limited situations only, it's flagged here. \" +\n \"If you're using an optional dependency here by design - add an exception to your\" +\n \"dependency-cruiser configuration.\",\n from: {},\n to: {\n dependencyTypes: [\n 'npm-optional'\n ]\n }\n },\n {\n name: 'peer-deps-used',\n comment:\n \"This module depends on an npm package that is declared as a peer dependency \" +\n \"in your package.json. This makes sense if your package is e.g. a plugin, but in \" +\n \"other cases - maybe not so much. If the use of a peer dependency is intentional \" +\n \"add an exception to your dependency-cruiser configuration.\",\n severity: 'warn',\n from: {},\n to: {\n dependencyTypes: [\n 'npm-peer'\n ]\n }\n }\n ],\n options: {\n\n /* conditions specifying which files not to follow further when encountered:\n - path: a regular expression to match\n - dependencyTypes: see https://github.com/sverweij/dependency-cruiser/blob/master/doc/rules-reference.md#dependencytypes-and-dependencytypesnot\n for a complete list\n */\n doNotFollow: {\n path: 'node_modules'\n },\n\n /* conditions specifying which dependencies to exclude\n - path: a regular expression to match\n - dynamic: a boolean indicating whether to ignore dynamic (true) or static (false) dependencies.\n leave out if you want to exclude neither (recommended!)\n */\n // exclude : {\n // path: '',\n // dynamic: true\n // },\n\n /* pattern specifying which files to include (regular expression)\n dependency-cruiser will skip everything not matching this pattern\n */\n // includeOnly : '',\n\n /* dependency-cruiser will include modules matching against the focus\n regular expression in its output, as well as their neighbours (direct\n dependencies and dependents)\n */\n // focus : '',\n\n /* list of module systems to cruise */\n // moduleSystems: ['amd', 'cjs', 'es6', 'tsd'],\n\n /* prefix for links in html and svg output (e.g. 'https://github.com/you/yourrepo/blob/develop/'\n to open it on your online repo or `vscode://file/${process.cwd()}/` to \n open it in visual studio code),\n */\n // prefix: '',\n\n /* false (the default): ignore dependencies that only exist before typescript-to-javascript compilation\n true: also detect dependencies that only exist before typescript-to-javascript compilation\n \"specify\": for each dependency identify whether it only exists before compilation or also after\n */\n"+(null!=(h=c(t,"if").call(i,null!=n?c(n,"tsPreCompilationDeps"):n,{name:"if",hash:{},fn:e.program(7,s,0),inverse:e.program(9,s,0),data:s,loc:{start:{line:280,column:4},end:{line:284,column:11}}}))?h:"")+' \n /* \n list of extensions to scan that aren\'t javascript or compile-to-javascript. \n Empty by default. Only put extensions in here that you want to take into\n account that are _not_ parsable. \n */\n // extraExtensionsToScan: [".json", ".jpg", ".png", ".svg", ".webp"],\n\n /* if true combines the package.jsons found from the module up to the base\n folder the cruise is initiated from. Useful for how (some) mono-repos\n manage dependencies & dependency definitions.\n */\n'+(null!=(h=c(t,"if").call(i,null!=n?c(n,"combinedDependencies"):n,{name:"if",hash:{},fn:e.program(11,s,0),inverse:e.program(13,s,0),data:s,loc:{start:{line:297,column:4},end:{line:301,column:11}}}))?h:"")+"\n /* if true leave symlinks untouched, otherwise use the realpath */\n // preserveSymlinks: false,\n\n /* TypeScript project file ('tsconfig.json') to use for\n (1) compilation and\n (2) resolution (e.g. with the paths property)\n\n The (optional) fileName attribute specifies which file to take (relative to\n dependency-cruiser's current working directory). When not provided\n defaults to './tsconfig.json'.\n */\n"+(null!=(h=c(t,"if").call(i,null!=n?c(n,"useTsConfig"):n,{name:"if",hash:{},fn:e.program(15,s,0),inverse:e.program(17,s,0),data:s,loc:{start:{line:314,column:4},end:{line:328,column:11}}}))?h:"")+"\n /* Webpack configuration to use to get resolve options from.\n\n The (optional) fileName attribute specifies which file to take (relative\n to dependency-cruiser's current working directory. When not provided defaults\n to './webpack.conf.js'.\n\n The (optional) `env` and `args` attributes contain the parameters to be passed if\n your webpack config is a function and takes them (see webpack documentation\n for details)\n */\n"+(null!=(h=c(t,"if").call(i,null!=n?c(n,"useWebpackConfig"):n,{name:"if",hash:{},fn:e.program(22,s,0),inverse:e.program(24,s,0),data:s,loc:{start:{line:340,column:4},end:{line:352,column:11}}}))?h:"")+"\n /* Babel config ('.babelrc', '.babelrc.json', '.babelrc.json5', ...) to use\n for compilation (and whatever other naughty things babel plugins do to\n source code). This feature is well tested and usable, but might change\n behavior a bit over time (e.g. more precise results for used module \n systems) without dependency-cruiser getting a major version bump.\n */\n"+(null!=(h=c(t,"if").call(i,null!=n?c(n,"useBabelConfig"):n,{name:"if",hash:{},fn:e.program(26,s,0),inverse:e.program(28,s,0),data:s,loc:{start:{line:360,column:4},end:{line:368,column:11}}}))?h:"")+"\n /* List of strings you have in use in addition to cjs/ es6 requires\n & imports to declare module dependencies. Use this e.g. if you've\n re-declared require, use a require-wrapper or use window.require as\n a hack.\n */\n // exoticRequireStrings: [],\n /* options to pass on to enhanced-resolve, the package dependency-cruiser\n uses to resolve module references to disk. You can set most of these\n options in a webpack.conf.js - this section is here for those\n projects that don't have a separate webpack config file.\n\n Note: settings in webpack.conf.js override the ones specified here.\n */\n enhancedResolveOptions: {\n /* List of strings to consider as 'exports' fields in package.json. Use\n ['exports'] when you use packages that use such a field and your environment\n supports it (e.g. node ^12.19 || >=14.7 or recent versions of webpack).\n\n If you have an `exportsFields` attribute in your webpack config, that one\n will have precedence over the one specified here.\n */ \n exportsFields: [\"exports\"],\n /* List of conditions to check for in the exports field. e.g. use ['imports']\n if you're only interested in exposed es6 modules, ['require'] for commonjs,\n or all conditions at once `(['import', 'require', 'node', 'default']`)\n if anything goes for you. Only works when the 'exportsFields' array is\n non-empty.\n\n If you have a 'conditionNames' attribute in your webpack config, that one will\n have precedence over the one specified here.\n */\n conditionNames: [\"import\", \"require\", \"node\", \"default\"],\n /*\n The extensions, by default are the same as the ones dependency-cruiser\n can access (run `npx depcruise --info` to see which ones that are in\n _your_ environment. If that list is larger than what you need (e.g. \n it contains .js, .jsx, .ts, .tsx, .cts, .mts - but you don't use \n TypeScript you can pass just the extensions you actually use (e.g. \n [\".js\", \".jsx\"]). This can speed up the most expensive step in \n dependency cruising (module resolution) quite a bit.\n */\n"+(null!=(h=c(t,"if").call(i,null!=n?c(n,"specifyResolutionExtensions"):n,{name:"if",hash:{},fn:e.program(30,s,0),inverse:e.program(32,s,0),data:s,loc:{start:{line:411,column:6},end:{line:415,column:13}}}))?h:"")+' },\n reporterOptions: {\n dot: {\n /* pattern of modules that can be consolidated in the detailed\n graphical dependency graph. The default pattern in this configuration\n collapses everything in node_modules to one folder deep so you see\n the external modules, but not the innards your app depends upon.\n */\n collapsePattern: \'node_modules/[^/]+\',\n\n /* Options to tweak the appearance of your graph.See\n https://github.com/sverweij/dependency-cruiser/blob/master/doc/options-reference.md#reporteroptions\n for details and some examples. If you don\'t specify a theme\n don\'t worry - dependency-cruiser will fall back to the default one.\n */\n // theme: {\n // graph: {\n // /* use splines: "ortho" for straight lines. Be aware though\n // graphviz might take a long time calculating ortho(gonal)\n // routings.\n // */\n // splines: "true"\n // },\n // modules: [\n // {\n // criteria: { matchesFocus: true },\n // attributes: {\n // fillcolor: "lime",\n // penwidth: 2,\n // },\n // },\n // {\n // criteria: { matchesFocus: false },\n // attributes: {\n // fillcolor: "lightgrey",\n // },\n // },\n // {\n // criteria: { matchesReaches: true },\n // attributes: {\n // fillcolor: "lime",\n // penwidth: 2,\n // },\n // },\n // {\n // criteria: { matchesReaches: false },\n // attributes: {\n // fillcolor: "lightgrey",\n // },\n // },\n // {\n // criteria: { source: "^src/model" },\n // attributes: { fillcolor: "#ccccff" }\n // },\n // {\n // criteria: { source: "^src/view" },\n // attributes: { fillcolor: "#ccffcc" }\n // },\n // ],\n // dependencies: [\n // {\n // criteria: { "rules[0].severity": "error" },\n // attributes: { fontcolor: "red", color: "red" }\n // },\n // {\n // criteria: { "rules[0].severity": "warn" },\n // attributes: { fontcolor: "orange", color: "orange" }\n // },\n // {\n // criteria: { "rules[0].severity": "info" },\n // attributes: { fontcolor: "blue", color: "blue" }\n // },\n // {\n // criteria: { resolved: "^src/model" },\n // attributes: { color: "#0000ff77" }\n // },\n // {\n // criteria: { resolved: "^src/view" },\n // attributes: { color: "#00770077" }\n // }\n // ]\n // }\n },\n archi: {\n /* pattern of modules that can be consolidated in the high level\n graphical dependency graph. If you use the high level graphical\n dependency graph reporter (`archi`) you probably want to tweak\n this collapsePattern to your situation.\n */\n collapsePattern: \'^(packages|src|lib|app|bin|test(s?)|spec(s?))/[^/]+|node_modules/[^/]+\',\n\n /* Options to tweak the appearance of your graph.See\n https://github.com/sverweij/dependency-cruiser/blob/master/doc/options-reference.md#reporteroptions\n for details and some examples. If you don\'t specify a theme\n for \'archi\' dependency-cruiser will use the one specified in the\n dot section (see above), if any, and otherwise use the default one.\n */\n // theme: {\n // },\n },\n "text": {\n "highlightFocused": true\n },\n }\n }\n};\n// generated: dependency-cruiser@'+l(typeof(u=null!=(u=c(t,"version")||(null!=n?c(n,"version"):n))?u:r)==a?u.call(i,{name:"version",hash:{},data:s,loc:{start:{line:522,column:33},end:{line:522,column:44}}}):u)+" on "+l(typeof(u=null!=(u=c(t,"date")||(null!=n?c(n,"date"):n))?u:r)==a?u.call(i,{name:"date",hash:{},data:s,loc:{start:{line:522,column:48},end:{line:522,column:56}}}):u)+"\n"},useData:!0});
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
// @ts-check
|
|
1
2
|
const { readFileSync, readdirSync, accessSync, statSync, R_OK } = require("fs");
|
|
2
3
|
const { join } = require("path");
|
|
3
4
|
const has = require("lodash/has");
|
|
@@ -15,8 +16,8 @@ const BABEL_CONFIG_CANDIDATE_PATTERN = /^\.babelrc$|.*babel.*\.json/gi;
|
|
|
15
16
|
/**
|
|
16
17
|
* Read the package manifest ('package.json') and return it as a javascript object
|
|
17
18
|
*
|
|
18
|
-
* @param {
|
|
19
|
-
* @returns {any} - the contents of said manifest as a javascript object
|
|
19
|
+
* @param {import("fs").PathOrFileDescriptor} pManifestFileName - the file name where the package manifest (package.json) lives
|
|
20
|
+
* @returns {Record<string,any>} - the contents of said manifest as a javascript object
|
|
20
21
|
* @throws {ENOENT} when the manifest wasn't found
|
|
21
22
|
* @throws {SyntaxError} when the manifest's json is invalid
|
|
22
23
|
*/
|
|
@@ -24,9 +25,12 @@ function readManifest(pManifestFileName = "./package.json") {
|
|
|
24
25
|
return JSON.parse(readFileSync(pManifestFileName, "utf8"));
|
|
25
26
|
}
|
|
26
27
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
28
|
+
/**
|
|
29
|
+
* We could have used utl.fileExists - but that one is cached.
|
|
30
|
+
* Not typically what we want for this util.
|
|
31
|
+
*
|
|
32
|
+
* @param {import("fs").PathLike} pFile
|
|
33
|
+
* @returns {boolean}
|
|
30
34
|
*/
|
|
31
35
|
function fileExists(pFile) {
|
|
32
36
|
try {
|
|
@@ -37,6 +41,9 @@ function fileExists(pFile) {
|
|
|
37
41
|
return true;
|
|
38
42
|
}
|
|
39
43
|
|
|
44
|
+
/**
|
|
45
|
+
* @returns {boolean}
|
|
46
|
+
*/
|
|
40
47
|
function babelIsConfiguredInManifest() {
|
|
41
48
|
let lReturnValue = false;
|
|
42
49
|
|
|
@@ -48,6 +55,9 @@ function babelIsConfiguredInManifest() {
|
|
|
48
55
|
return lReturnValue;
|
|
49
56
|
}
|
|
50
57
|
|
|
58
|
+
/**
|
|
59
|
+
* @returns {boolean}
|
|
60
|
+
*/
|
|
51
61
|
function isTypeModule() {
|
|
52
62
|
let lReturnValue = false;
|
|
53
63
|
|
|
@@ -60,12 +70,21 @@ function isTypeModule() {
|
|
|
60
70
|
return lReturnValue;
|
|
61
71
|
}
|
|
62
72
|
|
|
73
|
+
/**
|
|
74
|
+
* @param {string} pFolderName
|
|
75
|
+
* @returns {string[]} Array of folder names
|
|
76
|
+
*/
|
|
63
77
|
function getFolderNames(pFolderName) {
|
|
64
78
|
return readdirSync(pFolderName, "utf8").filter((pFileName) =>
|
|
65
79
|
statSync(join(pFolderName, pFileName)).isDirectory()
|
|
66
80
|
);
|
|
67
81
|
}
|
|
68
82
|
|
|
83
|
+
/**
|
|
84
|
+
* @param {RegExp} pPattern
|
|
85
|
+
* @param {string=} pFolderName
|
|
86
|
+
* @returns {string[]}
|
|
87
|
+
*/
|
|
69
88
|
function getMatchingFileNames(pPattern, pFolderName = process.cwd()) {
|
|
70
89
|
return readdirSync(pFolderName, "utf8").filter(
|
|
71
90
|
(pFileName) =>
|
|
@@ -74,6 +93,10 @@ function getMatchingFileNames(pPattern, pFolderName = process.cwd()) {
|
|
|
74
93
|
);
|
|
75
94
|
}
|
|
76
95
|
|
|
96
|
+
/**
|
|
97
|
+
* @param {string[]} pFolderNames
|
|
98
|
+
* @returns {boolean}
|
|
99
|
+
*/
|
|
77
100
|
function isLikelyMonoRepo(pFolderNames = getFolderNames(process.cwd())) {
|
|
78
101
|
return pFolderNames.includes("packages");
|
|
79
102
|
}
|
|
@@ -92,6 +115,10 @@ function getFolderCandidates(pCandidateFolderArray) {
|
|
|
92
115
|
};
|
|
93
116
|
}
|
|
94
117
|
|
|
118
|
+
/**
|
|
119
|
+
* @param {string[]|string} pLocations
|
|
120
|
+
* @returns {string[]}
|
|
121
|
+
*/
|
|
95
122
|
function toSourceLocationArray(pLocations) {
|
|
96
123
|
if (!Array.isArray(pLocations)) {
|
|
97
124
|
return pLocations.split(",").map((pFolder) => pFolder.trim());
|
|
@@ -99,6 +126,9 @@ function toSourceLocationArray(pLocations) {
|
|
|
99
126
|
return pLocations;
|
|
100
127
|
}
|
|
101
128
|
|
|
129
|
+
/**
|
|
130
|
+
* @returns {string[]}
|
|
131
|
+
*/
|
|
102
132
|
function getManifestFilesWithABabelConfig() {
|
|
103
133
|
return babelIsConfiguredInManifest() ? ["package.json"] : [];
|
|
104
134
|
}
|
|
@@ -129,6 +159,10 @@ const getTestFolderCandidates = getFolderCandidates(LIKELY_TEST_FOLDERS);
|
|
|
129
159
|
const getMonoRepoPackagesCandidates = getFolderCandidates(
|
|
130
160
|
LIKELY_PACKAGES_FOLDERS
|
|
131
161
|
);
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* @returns {string}
|
|
165
|
+
*/
|
|
132
166
|
function getDefaultConfigFileName() {
|
|
133
167
|
return isTypeModule() ? ".dependency-cruiser.cjs" : DEFAULT_CONFIG_FILE_NAME;
|
|
134
168
|
}
|