dependency-cruiser 13.1.2 → 13.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +12 -14
- package/src/cli/init-config/build-config.mjs +156 -18
- package/src/cli/init-config/config-template.mjs +443 -0
- package/src/meta.js +1 -1
- package/src/report/dot/index.mjs +128 -32
- package/src/report/error-html/error-html-template.mjs +212 -0
- package/src/report/error-html/index.mjs +160 -16
- package/src/report/error-html/utl.mjs +6 -6
- package/src/report/html/html-template.mjs +184 -0
- package/src/report/html/index.mjs +92 -7
- package/types/options.d.ts +2 -1
- package/src/cli/init-config/config.js.template.js +0 -1
- package/src/report/dot/dot.template.js +0 -1
- package/src/report/error-html/error-html.template.js +0 -1
- package/src/report/html/html.template.js +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dependency-cruiser",
|
|
3
|
-
"version": "13.1.
|
|
3
|
+
"version": "13.1.4",
|
|
4
4
|
"description": "Validate and visualize dependencies. With your rules. JavaScript, TypeScript, CoffeeScript. ES6, CommonJS, AMD.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"static analysis",
|
|
@@ -159,7 +159,6 @@
|
|
|
159
159
|
"enhanced-resolve": "5.15.0",
|
|
160
160
|
"figures": "5.0.0",
|
|
161
161
|
"glob": "10.3.3",
|
|
162
|
-
"handlebars": "4.7.8",
|
|
163
162
|
"ignore": "5.2.4",
|
|
164
163
|
"indent-string": "5.0.0",
|
|
165
164
|
"interpret": "^3.1.1",
|
|
@@ -177,36 +176,35 @@
|
|
|
177
176
|
"wrap-ansi": "8.1.0"
|
|
178
177
|
},
|
|
179
178
|
"devDependencies": {
|
|
180
|
-
"@babel/core": "7.22.
|
|
179
|
+
"@babel/core": "7.22.10",
|
|
181
180
|
"@babel/plugin-transform-modules-commonjs": "7.22.5",
|
|
182
181
|
"@babel/preset-typescript": "7.22.5",
|
|
183
|
-
"@swc/core": "1.3.
|
|
184
|
-
"@types/lodash": "4.14.
|
|
185
|
-
"@types/node": "20.
|
|
182
|
+
"@swc/core": "1.3.78",
|
|
183
|
+
"@types/lodash": "4.14.197",
|
|
184
|
+
"@types/node": "20.5.1",
|
|
186
185
|
"@types/prompts": "2.4.4",
|
|
187
|
-
"@typescript-eslint/eslint-plugin": "6.
|
|
188
|
-
"@typescript-eslint/parser": "6.
|
|
186
|
+
"@typescript-eslint/eslint-plugin": "6.4.0",
|
|
187
|
+
"@typescript-eslint/parser": "6.4.0",
|
|
189
188
|
"@vue/compiler-sfc": "3.3.4",
|
|
190
189
|
"c8": "8.0.1",
|
|
191
|
-
"chai": "4.3.7",
|
|
192
190
|
"coffeescript": "2.7.0",
|
|
193
|
-
"eslint": "8.
|
|
191
|
+
"eslint": "8.47.0",
|
|
194
192
|
"eslint-config-moving-meadow": "4.0.2",
|
|
195
|
-
"eslint-config-prettier": "
|
|
193
|
+
"eslint-config-prettier": "9.0.0",
|
|
196
194
|
"eslint-plugin-budapestian": "5.0.1",
|
|
197
195
|
"eslint-plugin-eslint-comments": "3.2.0",
|
|
198
|
-
"eslint-plugin-import": "2.28.
|
|
196
|
+
"eslint-plugin-import": "2.28.1",
|
|
199
197
|
"eslint-plugin-mocha": "10.1.0",
|
|
200
198
|
"eslint-plugin-node": "11.1.0",
|
|
201
199
|
"eslint-plugin-security": "1.7.1",
|
|
202
200
|
"eslint-plugin-unicorn": "^48.0.1",
|
|
203
201
|
"husky": "8.0.3",
|
|
204
202
|
"intercept-stdout": "0.1.2",
|
|
205
|
-
"lint-staged": "
|
|
203
|
+
"lint-staged": "14.0.0",
|
|
206
204
|
"mocha": "10.2.0",
|
|
207
205
|
"normalize-newline": "4.1.0",
|
|
208
206
|
"npm-run-all": "4.1.5",
|
|
209
|
-
"prettier": "3.0.
|
|
207
|
+
"prettier": "3.0.2",
|
|
210
208
|
"proxyquire": "2.1.3",
|
|
211
209
|
"shx": "0.3.4",
|
|
212
210
|
"svelte": "3.59.1",
|
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
// @ts-check
|
|
2
|
-
import Handlebars from "handlebars/runtime.js";
|
|
3
2
|
import { folderNameArrayToRE } from "./utl.mjs";
|
|
4
|
-
|
|
5
|
-
/* eslint import/no-unassigned-import: 0 */
|
|
6
|
-
await import("./config.js.template.js");
|
|
3
|
+
import configTemplate from "./config-template.mjs";
|
|
7
4
|
|
|
8
5
|
/**
|
|
9
6
|
* @param {string} pString
|
|
@@ -24,25 +21,166 @@ function extensionsToString(pExtensions) {
|
|
|
24
21
|
return "";
|
|
25
22
|
}
|
|
26
23
|
|
|
24
|
+
/**
|
|
25
|
+
* @param {import("./types.js").IInitConfig} pInitOptions
|
|
26
|
+
* @returns {string}
|
|
27
|
+
*/
|
|
28
|
+
function buildNotToTestRule(pInitOptions) {
|
|
29
|
+
const lNotToTestRule = `{
|
|
30
|
+
name: 'not-to-test',
|
|
31
|
+
comment:
|
|
32
|
+
"This module depends on code within a folder that should only contain tests. As tests don't " +
|
|
33
|
+
"implement functionality this is odd. Either you're writing a test outside the test folder " +
|
|
34
|
+
"or there's something in the test folder that isn't a test.",
|
|
35
|
+
severity: 'error',
|
|
36
|
+
from: {
|
|
37
|
+
pathNot: '{{testLocationRE}}'
|
|
38
|
+
},
|
|
39
|
+
to: {
|
|
40
|
+
path: '{{testLocationRE}}'
|
|
41
|
+
}
|
|
42
|
+
},`;
|
|
43
|
+
return pInitOptions.hasTestsOutsideSource
|
|
44
|
+
? lNotToTestRule.replace(
|
|
45
|
+
/{{testLocationRE}}/g,
|
|
46
|
+
folderNameArrayToRE(pInitOptions?.testLocation ?? []),
|
|
47
|
+
)
|
|
48
|
+
: "";
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* @param {import("./types.js").IInitConfig} pInitOptions
|
|
53
|
+
* @returns {string}
|
|
54
|
+
*/
|
|
55
|
+
function buildTsPreCompilationDepsAttribute(pInitOptions) {
|
|
56
|
+
return pInitOptions.tsPreCompilationDeps
|
|
57
|
+
? "tsPreCompilationDeps: true,"
|
|
58
|
+
: "// tsPreCompilationDeps: false,";
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* @param {import("./types.js").IInitConfig} pInitOptions
|
|
63
|
+
* @returns {string}
|
|
64
|
+
*/
|
|
65
|
+
function buildCombinedDependenciesAttribute(pInitOptions) {
|
|
66
|
+
return pInitOptions.combinedDependencies
|
|
67
|
+
? "combinedDependencies: true,"
|
|
68
|
+
: "// combinedDependencies: false,";
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* @param {import("./types.js").IInitConfig} pInitOptions
|
|
73
|
+
* @returns {string}
|
|
74
|
+
*/
|
|
75
|
+
function buildTsOrJsConfigAttribute(pInitOptions) {
|
|
76
|
+
if (pInitOptions.useTsConfig) {
|
|
77
|
+
return `tsConfig: {
|
|
78
|
+
fileName: '${pInitOptions.tsConfig}'
|
|
79
|
+
},`;
|
|
80
|
+
}
|
|
81
|
+
if (pInitOptions.useJsConfig) {
|
|
82
|
+
return `tsConfig: {
|
|
83
|
+
fileName: '${pInitOptions.jsConfig}'
|
|
84
|
+
},`;
|
|
85
|
+
}
|
|
86
|
+
return `// tsConfig: {
|
|
87
|
+
// fileName: 'tsconfig.json'
|
|
88
|
+
// },`;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* @param {import("./types.js").IInitConfig} pInitOptions
|
|
93
|
+
* @returns {string}
|
|
94
|
+
*/
|
|
95
|
+
function buildWebpackConfigAttribute(pInitOptions) {
|
|
96
|
+
return pInitOptions.webpackConfig
|
|
97
|
+
? `webpackConfig: {
|
|
98
|
+
fileName: '${pInitOptions.webpackConfig}',
|
|
99
|
+
// env: {},
|
|
100
|
+
// arguments: {}
|
|
101
|
+
},`
|
|
102
|
+
: `// webpackConfig: {
|
|
103
|
+
// fileName: 'webpack.config.js',
|
|
104
|
+
// env: {},
|
|
105
|
+
// arguments: {}
|
|
106
|
+
// },`;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* @param {import("./types.js").IInitConfig} pInitOptions
|
|
111
|
+
* @returns {string}
|
|
112
|
+
*/
|
|
113
|
+
function buildBabelConfigAttribute(pInitOptions) {
|
|
114
|
+
return pInitOptions.babelConfig
|
|
115
|
+
? `babelConfig: {
|
|
116
|
+
fileName: '${pInitOptions.babelConfig}'
|
|
117
|
+
},`
|
|
118
|
+
: `// babelConfig: {
|
|
119
|
+
// fileName: '.babelrc',
|
|
120
|
+
// },`;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* @param {import("./types.js").IInitConfig} pInitOptions
|
|
125
|
+
* @returns {string}
|
|
126
|
+
*/
|
|
127
|
+
function buildExtensionsAttribute(pInitOptions) {
|
|
128
|
+
return pInitOptions.specifyResolutionExtensions
|
|
129
|
+
? `extensions: ${extensionsToString(pInitOptions.resolutionExtensions)},`
|
|
130
|
+
: `// extensions: [".js", ".jsx", ".ts", ".tsx", ".d.ts"],`;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* @param {import("./types.js").IInitConfig} pInitOptions
|
|
135
|
+
* @returns {string}
|
|
136
|
+
*/
|
|
137
|
+
function buildMainFieldsAttribute(pInitOptions) {
|
|
138
|
+
return pInitOptions.usesTypeScript
|
|
139
|
+
? `mainFields: ["main", "types", "typings"],`
|
|
140
|
+
: `// mainFields: ["main", "types", "typings"],`;
|
|
141
|
+
}
|
|
142
|
+
|
|
27
143
|
/**
|
|
28
144
|
* Creates a .dependency-cruiser config with a set of basic validations
|
|
29
145
|
* to the current directory.
|
|
30
146
|
*
|
|
31
|
-
* @param {import("./types.js").IInitConfig}
|
|
147
|
+
* @param {import("./types.js").IInitConfig} pInitOptions ('Normalized') options that influence the shape of
|
|
32
148
|
* the configuration
|
|
33
149
|
* @returns {string} the configuration as a string
|
|
34
150
|
*/
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
151
|
+
export default function buildConfig(pInitOptions) {
|
|
152
|
+
return configTemplate
|
|
153
|
+
.replace(
|
|
154
|
+
/{{sourceLocationRE}}/g,
|
|
155
|
+
folderNameArrayToRE(pInitOptions.sourceLocation),
|
|
156
|
+
)
|
|
157
|
+
.replace(
|
|
158
|
+
/{{resolutionExtensionsAsString}}/g,
|
|
159
|
+
extensionsToString(pInitOptions.resolutionExtensions),
|
|
160
|
+
)
|
|
161
|
+
.replace("{{notToTestRule}}", buildNotToTestRule(pInitOptions))
|
|
162
|
+
.replace(
|
|
163
|
+
"{{tsPreCompilationDepsAttribute}}",
|
|
164
|
+
buildTsPreCompilationDepsAttribute(pInitOptions),
|
|
165
|
+
)
|
|
166
|
+
.replace(
|
|
167
|
+
"{{combinedDependenciesAttribute}}",
|
|
168
|
+
buildCombinedDependenciesAttribute(pInitOptions),
|
|
169
|
+
)
|
|
170
|
+
.replace(
|
|
171
|
+
"{{tsOrJsConfigAttribute}}",
|
|
172
|
+
buildTsOrJsConfigAttribute(pInitOptions),
|
|
173
|
+
)
|
|
174
|
+
.replace(
|
|
175
|
+
"{{webpackConfigAttribute}}",
|
|
176
|
+
buildWebpackConfigAttribute(pInitOptions),
|
|
177
|
+
)
|
|
178
|
+
.replace(
|
|
179
|
+
"{{babelConfigAttribute}}",
|
|
180
|
+
buildBabelConfigAttribute(pInitOptions),
|
|
181
|
+
)
|
|
182
|
+
.replace("{{extensionsAttribute}}", buildExtensionsAttribute(pInitOptions))
|
|
183
|
+
.replace("{{mainFieldsAttribute}}", buildMainFieldsAttribute(pInitOptions))
|
|
184
|
+
.replace("{{version}}", pInitOptions.version)
|
|
185
|
+
.replace("{{date}}", pInitOptions.date);
|
|
48
186
|
}
|