dependency-cruiser 12.7.0 → 12.7.1-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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dependency-cruiser",
3
- "version": "12.7.0",
3
+ "version": "12.7.1-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",
@@ -85,11 +85,8 @@
85
85
  "depcruise:graph:doc:fmt-schema": "cd tools/schema && node ../../bin/dependency-cruise.js . --config --output-type dot | dot -T svg | tee ../overview.svg | node ../../bin/wrap-stream-in-html.js > ../../docs/schema-overview.html && cd -",
86
86
  "depcruise:graph:doc:fmt-types": "cd types && node ../bin/dependency-cruise.js . --ts-pre-compilation-deps --config --output-type dot | dot -T svg > overview.svg && cd -",
87
87
  "depcruise:graph:doc:samples": "sh tools/generate-samples.sh",
88
- "depcruise:graph:dot": "node ./bin/dependency-cruise.js bin src --config --output-type dot | dot -T svg > tmp_deps.svg",
89
- "depcruise:graph:fdp": "node ./bin/dependency-cruise.js bin src --config --output-type dot | fdp -GK=0.1 -Gsplines=true -T svg > tmp_deps.svg",
90
88
  "depcruise:graph:mermaid": "node ./bin/dependency-cruise.js bin src --include-only ^src/ --config --collapse 2 --output-type mermaid",
91
89
  "depcruise:graph:mermaid:diff": "node ./bin/dependency-cruise.js bin src test types tools --config configs/.dependency-cruiser-unlimited.json --output-type mermaid --reaches \"$(watskeburt $SHA)\"",
92
- "depcruise:graph:osage": "node ./bin/dependency-cruise.js bin src --config --output-type dot | osage -Gpack=32 -GpackMode=array2 -T svg > tmp_deps.svg",
93
90
  "depcruise:graph:view": "node ./bin/dependency-cruise.js bin src --prefix vscode://file/$(pwd)/ --config configs/.dependency-cruiser-show-metrics-config.json --output-type dot --progress cli-feedback --highlight \"$(watskeburt develop)\" | dot -T svg | node ./bin/wrap-stream-in-html.js | browser",
94
91
  "depcruise:graph:view:diff": "node ./bin/dependency-cruise.js bin src test --prefix vscode://file/$(pwd)/ --config configs/.dependency-cruiser-unlimited.json --output-type dot --progress cli-feedback --reaches \"$(watskeburt develop)\" | dot -T svg | node ./bin/wrap-stream-in-html.js | browser",
95
92
  "depcruise:report": "node ./bin/dependency-cruise.js src bin test configs types --output-type err-html --config configs/.dependency-cruiser-show-metrics-config.json --output-to dependency-violations.html",
@@ -100,7 +97,7 @@
100
97
  "format:check": "prettier --loglevel warn --check \"src/**/*.js\" \"configs/**/*.js\" \"tools/**/*.mjs\" \"bin/*\" \"types/*.d.ts\" \"test/**/*.spec.{cjs,js}\" \"test/**/*.{spec,utl}.mjs\"",
101
98
  "lint": "npm-run-all --parallel --aggregate-output lint:eslint format:check lint:types",
102
99
  "lint:eslint": "eslint bin/dependency-cruise.js bin src test configs tools/**/*.mjs --cache --cache-location node_modules/.cache/eslint/",
103
- "lint:eslint:fix": "eslint --fix bin src test configs tools/**/*.mjs --cache --cache-location node_modules/.cache/eslint/",
100
+ "lint:eslint:fix": "eslint --fix bin src test configs tools/**/*.mjs --cache --cache-location node_modules/.cache/eslint/",
104
101
  "lint:fix": "npm-run-all lint:eslint:fix format lint:types:fix",
105
102
  "lint:types": "npm-run-all lint:types:tsc lint:types:lint",
106
103
  "lint:types:tsc": "tsc --project types/tsconfig.json",
@@ -122,7 +119,7 @@
122
119
  "test:i": "LANG=en_US.UTF-8 mocha --grep \"^\\[[I]\\]\"",
123
120
  "test:u": "LANG=en_US.UTF-8 mocha --grep \"^\\[[U]\\]\"",
124
121
  "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,src/cli/listeners/{cli-feedback,ndjson}.js}\" --reporter text-summary --reporter html --reporter json-summary mocha",
122
+ "test:cover": "LANG=en_US.UTF-8 c8 mocha",
126
123
  "test:glob": "set -f && test \"`bin/dependency-cruise.js test/extract/__mocks__/gather-globbing/packages/**/src/**/*.js | grep \"no dependency violations found\"`\" = \"✔ no dependency violations found (6 modules, 0 dependencies cruised)\"",
127
124
  "test:yarn-pnp": "npm-run-all test:yarn-pnp:cleanup test:yarn-pnp:pack test:yarn-pnp:copy test:yarn-pnp:install test:yarn-pnp:version test:yarn-pnp:run test:yarn-pnp:test test:yarn-pnp:cleanup",
128
125
  "test:yarn-pnp:pack": "npm pack",
@@ -256,23 +253,6 @@
256
253
  }
257
254
  ]
258
255
  },
259
- "eslintIgnore": [
260
- ".pnp.cjs",
261
- ".yarn",
262
- "node_modules",
263
- "coverage",
264
- "tmp",
265
- "src/**/*.schema.js",
266
- "src/**/*.template.js",
267
- "src/cli/tools/svg-in-html-snippets/script.snippet.js",
268
- "test/integration/**",
269
- "test/*/__fixtures__/**",
270
- "test/*/*/__fixtures__/**",
271
- "test/*/*/*/__fixtures__/**",
272
- "test/*/__mocks__/**",
273
- "test/*/*/__mocks__/**",
274
- "types/**"
275
- ],
276
256
  "engines": {
277
257
  "node": "^14||^16||>=18"
278
258
  },
@@ -286,25 +266,5 @@
286
266
  "typescript": ">=2.0.0 <5.0.0",
287
267
  "vue-template-compiler": ">=2.0.0 <3.0.0",
288
268
  "@vue/compiler-sfc": ">=3.0.0 <4.0.0"
289
- },
290
- "lint-staged": {
291
- "{src,config}/**/*.js": [
292
- "eslint --fix"
293
- ],
294
- "{tools,src,config}/**/*.{mjs,js,json}": [
295
- "prettier --write"
296
- ],
297
- "bin/*": [
298
- "eslint --fix",
299
- "prettier --write"
300
- ],
301
- "test/**/*.{utl,spec}.{mjs,cjs}": [
302
- "eslint --fix",
303
- "prettier --write"
304
- ],
305
- "types/**/*.d.ts": [
306
- "eslint --config types/.eslintrc.json --fix",
307
- "prettier --write"
308
- ]
309
269
  }
310
270
  }
@@ -47,7 +47,7 @@ function resolveModule(
47
47
  }
48
48
 
49
49
  function canBeResolvedToTsVariant(pModuleName) {
50
- return [".js", ".jsx"].includes(path.extname(pModuleName));
50
+ return [".js", ".jsx", ".mjs", ".cjs"].includes(path.extname(pModuleName));
51
51
  }
52
52
 
53
53
  function isTypeScriptIshExtension(pModuleName) {
@@ -68,6 +68,23 @@ function resolveYarnVirtual(pPath) {
68
68
  return pPath;
69
69
  }
70
70
 
71
+ /**
72
+ *
73
+ * @param {string} pJavaScriptExtension
74
+ * @returns {string}
75
+ */
76
+ function getTypeScriptExtensionsToTry(pJavaScriptExtension) {
77
+ const lJS2TSMap = {
78
+ ".js": [".ts", ".tsx", ".d.ts"],
79
+ ".jsx": [".ts", ".tsx", ".d.ts"],
80
+ ".cjs": [".cts", ".d.cts"],
81
+ ".mjs": [".mts", ".d.mts"],
82
+ };
83
+ // eslint-disable-next-line security/detect-object-injection
84
+ return lJS2TSMap[pJavaScriptExtension] ?? [];
85
+ }
86
+
87
+ // eslint-disable-next-line max-lines-per-function
71
88
  function resolveWithRetry(
72
89
  pModule,
73
90
  pBaseDirectory,
@@ -90,7 +107,11 @@ function resolveWithRetry(
90
107
  // This behavior is very specific:
91
108
  // - tsc only (doesn't work in ts-node for instance)
92
109
  // - until TypeScript 4.6 only for the .js and .jsx extensions
93
- // - since TypeScript 4.7 also for .cjs and .mjs (=> .cts, .mts) extensions
110
+ // - since TypeScript 4.7 also for .cjs and .mjs (=> .cts, .mts) extensions,
111
+ // which work subtly different;
112
+ // .cjs resolves to .cts or .d.cts (in that order)
113
+ // .mjs resolves to .mts or .d.mts (in that order)
114
+ // ref: https://www.typescriptlang.org/docs/handbook/esm-node.html#new-file-extensions
94
115
  //
95
116
  // Hence also this oddly specific looking check & retry.
96
117
  //
@@ -100,16 +121,19 @@ function resolveWithRetry(
100
121
  lReturnValue.couldNotResolve &&
101
122
  canBeResolvedToTsVariant(lStrippedModuleName)
102
123
  ) {
103
- const lModuleWithOutExtension = lStrippedModuleName.replace(
104
- /\.(js|jsx|mjs|cjs)$/g,
124
+ const lModuleWithoutExtension = lStrippedModuleName.replace(
125
+ /\.(js|jsx|cjs|mjs)$/g,
105
126
  ""
106
127
  );
128
+ const lExtensionsToTry = getTypeScriptExtensionsToTry(
129
+ path.extname(lStrippedModuleName)
130
+ );
107
131
 
108
132
  const lReturnValueCandidate = resolveModule(
109
- { ...pModule, module: lModuleWithOutExtension },
133
+ { ...pModule, module: lModuleWithoutExtension },
110
134
  pBaseDirectory,
111
135
  pFileDirectory,
112
- pResolveOptions
136
+ { ...pResolveOptions, extensions: lExtensionsToTry }
113
137
  );
114
138
 
115
139
  if (isTypeScriptIshExtension(lReturnValueCandidate.resolved)) {
package/src/meta.js CHANGED
@@ -1,7 +1,7 @@
1
1
  /* generated - don't edit */
2
2
 
3
3
  module.exports = {
4
- version: "12.7.0",
4
+ version: "12.7.1-beta-1",
5
5
  engines: {
6
6
  node: "^14||^16||>=18",
7
7
  },