dependency-cruiser 13.1.1 → 13.1.3

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": "13.1.1",
3
+ "version": "13.1.3",
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,7 @@
159
159
  "enhanced-resolve": "5.15.0",
160
160
  "figures": "5.0.0",
161
161
  "glob": "10.3.3",
162
- "handlebars": "4.7.7",
162
+ "handlebars": "4.7.8",
163
163
  "ignore": "5.2.4",
164
164
  "indent-string": "5.0.0",
165
165
  "interpret": "^3.1.1",
@@ -173,41 +173,39 @@
173
173
  "semver-try-require": "6.2.3",
174
174
  "teamcity-service-messages": "0.1.14",
175
175
  "tsconfig-paths-webpack-plugin": "4.1.0",
176
- "watskeburt": "0.11.6",
176
+ "watskeburt": "0.12.1",
177
177
  "wrap-ansi": "8.1.0"
178
178
  },
179
179
  "devDependencies": {
180
- "@babel/core": "7.22.9",
180
+ "@babel/core": "7.22.10",
181
181
  "@babel/plugin-transform-modules-commonjs": "7.22.5",
182
182
  "@babel/preset-typescript": "7.22.5",
183
- "@swc/core": "1.3.69",
184
- "@types/lodash": "4.14.195",
185
- "@types/node": "20.4.2",
183
+ "@swc/core": "1.3.76",
184
+ "@types/lodash": "4.14.197",
185
+ "@types/node": "20.4.10",
186
186
  "@types/prompts": "2.4.4",
187
- "@typescript-eslint/eslint-plugin": "6.0.0",
188
- "@typescript-eslint/parser": "6.0.0",
187
+ "@typescript-eslint/eslint-plugin": "6.3.0",
188
+ "@typescript-eslint/parser": "6.3.0",
189
189
  "@vue/compiler-sfc": "3.3.4",
190
- "c8": "8.0.0",
191
- "chai": "4.3.7",
192
- "chai-json-schema": "1.5.1",
190
+ "c8": "8.0.1",
193
191
  "coffeescript": "2.7.0",
194
- "eslint": "8.45.0",
192
+ "eslint": "8.47.0",
195
193
  "eslint-config-moving-meadow": "4.0.2",
196
- "eslint-config-prettier": "8.8.0",
194
+ "eslint-config-prettier": "9.0.0",
197
195
  "eslint-plugin-budapestian": "5.0.1",
198
196
  "eslint-plugin-eslint-comments": "3.2.0",
199
- "eslint-plugin-import": "2.27.5",
197
+ "eslint-plugin-import": "2.28.0",
200
198
  "eslint-plugin-mocha": "10.1.0",
201
199
  "eslint-plugin-node": "11.1.0",
202
200
  "eslint-plugin-security": "1.7.1",
203
- "eslint-plugin-unicorn": "^47.0.0",
201
+ "eslint-plugin-unicorn": "^48.0.1",
204
202
  "husky": "8.0.3",
205
203
  "intercept-stdout": "0.1.2",
206
- "lint-staged": "13.2.3",
204
+ "lint-staged": "13.3.0",
207
205
  "mocha": "10.2.0",
208
206
  "normalize-newline": "4.1.0",
209
207
  "npm-run-all": "4.1.5",
210
- "prettier": "3.0.0",
208
+ "prettier": "3.0.1",
211
209
  "proxyquire": "2.1.3",
212
210
  "shx": "0.3.4",
213
211
  "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"],`
140
+ : `// mainFields: ["main", "types"],`;
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} pNormalizedInitOptions Options that influence the shape of
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
- export default function buildConfig(pNormalizedInitOptions) {
37
- return Handlebars.templates["config.js.template.hbs"]({
38
- ...pNormalizedInitOptions,
39
-
40
- sourceLocationRE: folderNameArrayToRE(
41
- pNormalizedInitOptions.sourceLocation
42
- ),
43
- testLocationRE: folderNameArrayToRE(pNormalizedInitOptions.testLocation),
44
- resolutionExtensionsAsString: extensionsToString(
45
- pNormalizedInitOptions.resolutionExtensions
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
  }