dependency-cruiser 12.2.0 → 12.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dependency-cruiser",
3
- "version": "12.2.0",
3
+ "version": "12.3.0",
4
4
  "description": "Validate and visualize dependencies. With your rules. JavaScript, TypeScript, CoffeeScript. ES6, CommonJS, AMD.",
5
5
  "keywords": [
6
6
  "static analysis",
@@ -94,7 +94,7 @@
94
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",
95
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",
96
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",
97
- "depcruise:focus": "node ./bin/dependency-cruise.js src bin test configs types tools --progress --config configs/.dependency-cruiser-show-metrics-config.json --output-type text --focus",
97
+ "depcruise:focus": "node ./bin/dependency-cruise.js src bin test configs types tools --progress --config --output-type text --focus",
98
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",
99
99
  "format": "prettier --loglevel warn --write \"src/**/*.js\" \"configs/**/*.js\" \"tools/**/*.mjs\" \"bin/*\" \"types/*.d.ts\" \"test/**/*.spec.{cjs,js}\" \"test/**/*.{spec,utl}.mjs\"",
100
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\"",
@@ -176,10 +176,10 @@
176
176
  "@babel/preset-typescript": "7.18.6",
177
177
  "@swc/core": "1.3.24",
178
178
  "@types/lodash": "4.14.191",
179
- "@types/node": "18.11.17",
179
+ "@types/node": "18.11.18",
180
180
  "@types/prompts": "2.4.2",
181
- "@typescript-eslint/eslint-plugin": "5.47.0",
182
- "@typescript-eslint/parser": "5.47.0",
181
+ "@typescript-eslint/eslint-plugin": "5.47.1",
182
+ "@typescript-eslint/parser": "5.47.1",
183
183
  "@vue/compiler-sfc": "3.2.45",
184
184
  "c8": "7.12.0",
185
185
  "chai": "4.3.7",
@@ -1,15 +1,34 @@
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
- * @param {import("../../../types/init-config").IInitConfig} pNormalizedInitOptions Options that influence the shape of
31
+ * @param {import("./types").IInitConfig} pNormalizedInitOptions Options that influence the shape of
13
32
  * the configuration
14
33
  * @returns {string} the configuration as a string
15
34
  */
@@ -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 {string} pManifestFileName - the file name where the package manifest (package.json) lives
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
  */
@@ -40,6 +41,9 @@ function fileExists(pFile) {
40
41
  return true;
41
42
  }
42
43
 
44
+ /**
45
+ * @returns {boolean}
46
+ */
43
47
  function babelIsConfiguredInManifest() {
44
48
  let lReturnValue = false;
45
49
 
@@ -51,6 +55,9 @@ function babelIsConfiguredInManifest() {
51
55
  return lReturnValue;
52
56
  }
53
57
 
58
+ /**
59
+ * @returns {boolean}
60
+ */
54
61
  function isTypeModule() {
55
62
  let lReturnValue = false;
56
63
 
@@ -63,12 +70,21 @@ function isTypeModule() {
63
70
  return lReturnValue;
64
71
  }
65
72
 
73
+ /**
74
+ * @param {string} pFolderName
75
+ * @returns {string[]} Array of folder names
76
+ */
66
77
  function getFolderNames(pFolderName) {
67
78
  return readdirSync(pFolderName, "utf8").filter((pFileName) =>
68
79
  statSync(join(pFolderName, pFileName)).isDirectory()
69
80
  );
70
81
  }
71
82
 
83
+ /**
84
+ * @param {RegExp} pPattern
85
+ * @param {string=} pFolderName
86
+ * @returns {string[]}
87
+ */
72
88
  function getMatchingFileNames(pPattern, pFolderName = process.cwd()) {
73
89
  return readdirSync(pFolderName, "utf8").filter(
74
90
  (pFileName) =>
@@ -77,6 +93,10 @@ function getMatchingFileNames(pPattern, pFolderName = process.cwd()) {
77
93
  );
78
94
  }
79
95
 
96
+ /**
97
+ * @param {string[]} pFolderNames
98
+ * @returns {boolean}
99
+ */
80
100
  function isLikelyMonoRepo(pFolderNames = getFolderNames(process.cwd())) {
81
101
  return pFolderNames.includes("packages");
82
102
  }
@@ -95,6 +115,10 @@ function getFolderCandidates(pCandidateFolderArray) {
95
115
  };
96
116
  }
97
117
 
118
+ /**
119
+ * @param {string[]|string} pLocations
120
+ * @returns {string[]}
121
+ */
98
122
  function toSourceLocationArray(pLocations) {
99
123
  if (!Array.isArray(pLocations)) {
100
124
  return pLocations.split(",").map((pFolder) => pFolder.trim());
@@ -102,6 +126,9 @@ function toSourceLocationArray(pLocations) {
102
126
  return pLocations;
103
127
  }
104
128
 
129
+ /**
130
+ * @returns {string[]}
131
+ */
105
132
  function getManifestFilesWithABabelConfig() {
106
133
  return babelIsConfiguredInManifest() ? ["package.json"] : [];
107
134
  }
@@ -132,6 +159,10 @@ const getTestFolderCandidates = getFolderCandidates(LIKELY_TEST_FOLDERS);
132
159
  const getMonoRepoPackagesCandidates = getFolderCandidates(
133
160
  LIKELY_PACKAGES_FOLDERS
134
161
  );
162
+
163
+ /**
164
+ * @returns {string}
165
+ */
135
166
  function getDefaultConfigFileName() {
136
167
  return isTypeModule() ? ".dependency-cruiser.cjs" : DEFAULT_CONFIG_FILE_NAME;
137
168
  }
@@ -0,0 +1,114 @@
1
+ // @ts-check
2
+ /* eslint-disable security/detect-object-injection */
3
+ const fs = require("fs");
4
+ const path = require("path");
5
+ const pathToPosix = require("../../utl/path-to-posix");
6
+ const getExtension = require("../../utl/get-extension.js");
7
+ const meta = require("../../extract/transpile/meta");
8
+
9
+ /**
10
+ * @param {string[]} pIgnorablePathElements
11
+ * @returns {(string) => boolean}
12
+ */
13
+ function notIgnorable(pIgnorablePathElements) {
14
+ return (pPath) => {
15
+ return !pIgnorablePathElements.includes(pPath);
16
+ };
17
+ }
18
+
19
+ /**
20
+ * @param {string} pFullPathToFile
21
+ * @param {string} pBaseDirectory
22
+ * @returns {boolean}
23
+ */
24
+ function fileIsDirectory(pFullPathToFile, pBaseDirectory) {
25
+ try {
26
+ const lStat = fs.statSync(path.join(pBaseDirectory, pFullPathToFile));
27
+ return lStat.isDirectory();
28
+ } catch (pError) {
29
+ return false;
30
+ }
31
+ }
32
+
33
+ /**
34
+ * @param {string} pDirectoryName
35
+ * @param {{baseDir: string; ignorablePathElements: string[]}} pOptions
36
+ * @returns {string[]}
37
+ */
38
+ function listAllModules(pDirectoryName, { baseDir, ignorablePathElements }) {
39
+ return fs
40
+ .readdirSync(path.join(baseDir, pDirectoryName))
41
+ .filter(notIgnorable(ignorablePathElements))
42
+ .map((pFileName) => path.join(pDirectoryName, pFileName))
43
+ .map((pFullPathToFile) => ({
44
+ fullPathToFile: pFullPathToFile,
45
+ isDirectory: fileIsDirectory(pFullPathToFile, baseDir),
46
+ }))
47
+ .reduce(
48
+ /**
49
+ * @param {string[]} pSum
50
+ * @param {{fullPathToFile: string; isDirectory: boolean}} pCurrentValue
51
+ * @returns {string[]}
52
+ */
53
+ (pSum, { fullPathToFile, isDirectory }) => {
54
+ if (isDirectory) {
55
+ return pSum.concat(
56
+ listAllModules(fullPathToFile, { baseDir, ignorablePathElements })
57
+ );
58
+ }
59
+ return pSum.concat(fullPathToFile);
60
+ },
61
+ []
62
+ )
63
+ .map((pFullPathToFile) => pathToPosix(pFullPathToFile));
64
+ }
65
+
66
+ /**
67
+ * @param {Record<string,number>} pAll
68
+ * @param {string} pExtension
69
+ */
70
+ function reduceToCounts(pAll, pExtension) {
71
+ if (pAll[pExtension]) {
72
+ pAll[pExtension] += 1;
73
+ } else {
74
+ pAll[pExtension] = 1;
75
+ }
76
+ return pAll;
77
+ }
78
+
79
+ function compareByCount(pCountsObject) {
80
+ return function compare(pLeft, pRight) {
81
+ return pCountsObject[pRight] - pCountsObject[pLeft];
82
+ };
83
+ }
84
+
85
+ /**
86
+ * @param {string[]} pDirectories
87
+ * @param {{baseDir?: string; ignorablePathElements?: string[], scannableExtensions?: string[]}=} pOptions
88
+ * @returns {string[]}
89
+ */
90
+ module.exports = function findExtensions(pDirectories, pOptions) {
91
+ const lOptions = {
92
+ baseDir: process.cwd(),
93
+ ignorablePathElements: [
94
+ ".git",
95
+ ".husky",
96
+ ".vscode",
97
+ "coverage",
98
+ "node_nodules",
99
+ "nyc",
100
+ ],
101
+ scannableExtensions: meta.scannableExtensions,
102
+ ...pOptions,
103
+ };
104
+
105
+ const lExtensionsWithCounts = pDirectories
106
+ .flatMap((pDirectory) =>
107
+ listAllModules(pDirectory, lOptions).map(getExtension).filter(Boolean)
108
+ )
109
+ .reduce(reduceToCounts, {});
110
+
111
+ return Object.keys(lExtensionsWithCounts)
112
+ .filter((pExtension) => lOptions.scannableExtensions.includes(pExtension))
113
+ .sort(compareByCount(lExtensionsWithCounts));
114
+ };
@@ -1,3 +1,4 @@
1
+ // @ts-check
1
2
  const prompts = require("prompts");
2
3
  const {
3
4
  isLikelyMonoRepo,
@@ -34,9 +35,9 @@ const QUESTIONS = [
34
35
  },
35
36
  {
36
37
  name: "sourceLocation",
37
- type: (_, pAnswers) => (pAnswers.isMonoRepo ? "text" : false),
38
+ type: (_, pAnswers) => (pAnswers.isMonoRepo ? "list" : false),
38
39
  message: "Mono repo it is! Where do your packages live?",
39
- initial: getMonoRepoPackagesCandidates(),
40
+ initial: getMonoRepoPackagesCandidates().join(", "),
40
41
  validate: validateLocation,
41
42
  },
42
43
  {
@@ -48,9 +49,9 @@ const QUESTIONS = [
48
49
  },
49
50
  {
50
51
  name: "sourceLocation",
51
- type: (_, pAnswers) => (pAnswers.isMonoRepo ? false : "text"),
52
+ type: (_, pAnswers) => (pAnswers.isMonoRepo ? false : "list"),
52
53
  message: "Where do your source files live?",
53
- initial: getSourceFolderCandidates(),
54
+ initial: getSourceFolderCandidates().join(", "),
54
55
  validate: validateLocation,
55
56
  },
56
57
  {
@@ -67,9 +68,9 @@ const QUESTIONS = [
67
68
  {
68
69
  name: "testLocation",
69
70
  type: (_, pAnswers) =>
70
- pAnswers.hasTestsOutsideSource && !pAnswers.isMonoRepo ? "text" : false,
71
+ pAnswers.hasTestsOutsideSource && !pAnswers.isMonoRepo ? "list" : false,
71
72
  message: "Where do your test files live?",
72
- initial: getTestFolderCandidates(),
73
+ initial: getTestFolderCandidates().join(", "),
73
74
  validate: validateLocation,
74
75
  },
75
76
  {
@@ -134,7 +135,7 @@ const QUESTIONS = [
134
135
  ];
135
136
 
136
137
  /**
137
- * @return {Promise<import("../../../types/init-config").IPartialInitConfig>}
138
+ * @return {Promise<import("./types").IPartialInitConfig>}
138
139
  */
139
140
  module.exports = function getUserInput() {
140
141
  return prompts(QUESTIONS);
@@ -27,11 +27,11 @@ const PACKAGE_MANIFEST = `./${$defaults.PACKAGE_MANIFEST}`;
27
27
  * Create a initialization configuration based on guessed defaults
28
28
  * (e.g. a tsconfig exists => use it and assume typescript is used)
29
29
  *
30
- * @param {import("../../../types/init-config").OneShotConfigIDType} pOneShotConfigId
31
- * @return {import("../../../types/init-config").IPartialInitConfig} an initialization configuration
30
+ * @param {import("./types").OneShotConfigIDType} pOneShotConfigId
31
+ * @return {import("./types").IPartialInitConfig} an initialization configuration
32
32
  */
33
33
  function getOneShotConfig(pOneShotConfigId) {
34
- /** @type {import("../../../types/init-config").IPartialInitConfig} */
34
+ /** @type {import("./types").IPartialInitConfig} */
35
35
  const lBaseConfig = {
36
36
  isMonoRepo: isLikelyMonoRepo(),
37
37
  combinedDependencies: false,
@@ -44,8 +44,9 @@ function getOneShotConfig(pOneShotConfigId) {
44
44
  webpackConfig: getWebpackConfigCandidates().shift(),
45
45
  useBabelConfig: hasBabelConfigCandidates(),
46
46
  babelConfig: getBabelConfigCandidates().shift(),
47
+ specifyResolutionExtensions: true,
47
48
  };
48
- /** @type {Record<import("../../../types/init-config").OneShotConfigIDType, import("../../../types/init-config").IPartialInitConfig>} */
49
+ /** @type {Record<import("./types").OneShotConfigIDType, import("./types").IPartialInitConfig>} */
49
50
  const lOneShotConfigs = {
50
51
  preset: {
51
52
  configType: "preset",
@@ -65,7 +66,7 @@ function getOneShotConfig(pOneShotConfigId) {
65
66
 
66
67
  /**
67
68
  *
68
- * @param {import("../../../types/init-config").IInitConfig} pNormalizedInitConfig
69
+ * @param {import("./types").IInitConfig} pNormalizedInitConfig
69
70
  */
70
71
  function manifestIsUpdatable(pNormalizedInitConfig) {
71
72
  return (
@@ -75,7 +76,7 @@ function manifestIsUpdatable(pNormalizedInitConfig) {
75
76
  }
76
77
 
77
78
  /**
78
- * @param {boolean|import("../../../types/init-config").OneShotConfigIDType} pInit
79
+ * @param {boolean|import("./types").OneShotConfigIDType} pInit
79
80
  */
80
81
  module.exports = function initConfig(pInit) {
81
82
  /* c8 ignore start */
@@ -6,14 +6,15 @@ const {
6
6
  hasTestsWithinSource,
7
7
  toSourceLocationArray,
8
8
  } = require("./environment-helpers");
9
+ const findExtensions = require("./find-extensions.js");
9
10
 
10
11
  /**
11
12
  *
12
- * @param {import("../../../types/init-config").IPartialInitConfig} pInitOptions
13
- * @return {import("../../../types/init-config").IPartialInitConfig}
13
+ * @param {import("./types").IPartialInitConfig} pInitOptions
14
+ * @return {import("./types").IPartialInitConfig}
14
15
  */
15
16
  function populate(pInitOptions) {
16
- return {
17
+ const lReturnValue = {
17
18
  version,
18
19
  date: new Date().toJSON(),
19
20
  configType: "self-contained",
@@ -27,12 +28,18 @@ function populate(pInitOptions) {
27
28
  pInitOptions.testLocation || getTestFolderCandidates()
28
29
  ),
29
30
  };
31
+ if (lReturnValue.specifyResolutionExtensions) {
32
+ lReturnValue.resolutionExtensions = findExtensions(
33
+ lReturnValue.sourceLocation.concat(lReturnValue.testLocation)
34
+ );
35
+ }
36
+ return lReturnValue;
30
37
  }
31
38
 
32
39
  /**
33
40
  *
34
- * @param {import("../../../types/init-config").IPartialInitConfig} pInitOptions
35
- * @return {import("../../../types/init-config").IInitConfig}
41
+ * @param {import("./types").IPartialInitConfig} pInitOptions
42
+ * @return {import("./types").IInitConfig}
36
43
  */
37
44
  module.exports = function normalizeInitOptions(pInitOptions) {
38
45
  let lReturnValue = populate(pInitOptions);
@@ -66,6 +66,18 @@ export interface IInitConfig {
66
66
  * An array of (relative) paths to folders to understand as test code
67
67
  */
68
68
  testLocation?: string[];
69
+ /**
70
+ * Whether or not to explicitly pass extensions to the resolver. When not
71
+ * set explicitly dependency-cruiser will pass it all extensions it knows
72
+ * to handle - which makes it more sure to catch everything, at the trade-off
73
+ * of potentially being slower if the number of extensions used in reality
74
+ * is (a lot) smaller.
75
+ */
76
+ specifyResolutionExtensions: boolean;
77
+ /**
78
+ * An array of extensions the resolver should use when resolving dependencies
79
+ */
80
+ resolutionExtensions?: string[];
69
81
  /**
70
82
  * Dependency-cruiser version used
71
83
  */
@@ -55,7 +55,7 @@ const EXPERIMENTAL_SCRIPT_DOC = [
55
55
 
56
56
  /**
57
57
  *
58
- * @param {import("../../../types/init-config").IInitConfig} pInitOptions
58
+ * @param {import("./types").IInitConfig} pInitOptions
59
59
  * @return {any} an bunch of key value pairs that can be plonked into a `scripts` attribute in a package.json
60
60
  */
61
61
  function compileRunScripts(pInitOptions) {
@@ -4,9 +4,9 @@ const glob = require("glob");
4
4
  const get = require("lodash/get");
5
5
  const filenameMatchesPattern =
6
6
  require("../graph-utl/match-facade").filenameMatchesPattern;
7
- const pathToPosix = require("./utl/path-to-posix");
7
+ const getExtension = require("../utl/get-extension");
8
+ const pathToPosix = require("../utl/path-to-posix");
8
9
  const transpileMeta = require("./transpile/meta");
9
- const getExtension = require("./utl/get-extension");
10
10
 
11
11
  /**
12
12
  *
@@ -4,7 +4,7 @@ const acornLoose = require("acorn-loose");
4
4
  const acornJsx = require("acorn-jsx");
5
5
  const memoize = require("lodash/memoize");
6
6
  const transpile = require("../transpile");
7
- const getExtension = require("../utl/get-extension");
7
+ const getExtension = require("../../utl/get-extension");
8
8
 
9
9
  /** @type acorn.Options */
10
10
  const ACORN_OPTIONS = {
@@ -3,7 +3,7 @@ const tryRequire = require("semver-try-require");
3
3
  const memoize = require("lodash/memoize");
4
4
  const { supportedTranspilers } = require("../../../src/meta.js");
5
5
  const transpile = require("../transpile");
6
- const getExtension = require("../utl/get-extension");
6
+ const getExtension = require("../../utl/get-extension");
7
7
 
8
8
  /** @type {import('typescript')} */
9
9
  const typescript = tryRequire("typescript", supportedTranspilers.typescript);
@@ -1,7 +1,7 @@
1
1
  const fs = require("fs");
2
2
  const path = require("path");
3
3
  const monkeyPatchedModule = require("module");
4
- const pathToPosix = require("../utl/path-to-posix");
4
+ const pathToPosix = require("../../utl/path-to-posix");
5
5
  const { isRelativeModuleName } = require("./module-classifiers");
6
6
  const resolveAMD = require("./resolve-amd");
7
7
  const resolveCommonJS = require("./resolve-cjs");
@@ -1,5 +1,5 @@
1
1
  const path = require("path");
2
- const getExtension = require("../utl/get-extension");
2
+ const getExtension = require("../../utl/get-extension");
3
3
 
4
4
  let gFollowableExtensionsCache = new Set();
5
5
  let gFollowableExtensionsCacheInitialized = false;
@@ -2,7 +2,7 @@ const fs = require("fs");
2
2
  const path = require("path");
3
3
  const { builtinModules } = require("module");
4
4
  const memoize = require("lodash/memoize");
5
- const pathToPosix = require("../utl/path-to-posix");
5
+ const pathToPosix = require("../../utl/path-to-posix");
6
6
 
7
7
  const fileExists = memoize((pFile) => {
8
8
  try {
@@ -1,6 +1,6 @@
1
1
  const path = require("path");
2
2
  const { builtinModules } = require("module");
3
- const pathToPosix = require("../utl/path-to-posix");
3
+ const pathToPosix = require("../../utl/path-to-posix");
4
4
  const { isFollowable } = require("./module-classifiers");
5
5
  const resolve = require("./resolve");
6
6
 
@@ -1,5 +1,5 @@
1
1
  const enhancedResolve = require("enhanced-resolve");
2
- const pathToPosix = require("../utl/path-to-posix");
2
+ const pathToPosix = require("../../utl/path-to-posix");
3
3
  const stripQueryParameters = require("../utl/strip-query-parameters");
4
4
 
5
5
  let gResolvers = {};
@@ -1,5 +1,4 @@
1
1
  /* eslint-disable no-magic-numbers, security/detect-object-injection */
2
-
3
2
  /*
4
3
  parseAttributes copied verbatim from
5
4
  https://github.com/sveltejs/svelte/blob/67dea941bb1e61f0912ebd2257666b899c1ccefa/src/compiler/preprocess/index.ts#L27
@@ -60,20 +59,41 @@ function getSourceReplacer(pTranspiler, pTranspilerOptions) {
60
59
  };
61
60
  }
62
61
 
62
+ function styleReplacer(pMatch, pAttributes) {
63
+ const lParsedAttributes = parseAttributes(pAttributes || "");
64
+
65
+ if (lParsedAttributes.lang === "css" || !pAttributes) {
66
+ return pMatch;
67
+ } else {
68
+ return "";
69
+ }
70
+ }
71
+
63
72
  module.exports = function preProcess(
64
73
  pSource,
65
74
  pTranspilerWrapper,
66
75
  pTranspilerOptions
67
76
  ) {
68
- // regex from
77
+ // regexes from
69
78
  // github.com/sveltejs/svelte/blob/67dea941bb1e61f0912ebd2257666b899c1ccefa/src/compiler/preprocess/index.ts#L165
70
79
  // eslint-disable-next-line security/detect-unsafe-regex, unicorn/no-unsafe-regex
71
80
  const lScriptRegex = /<script(\s[^]*?)?(?:>([^]*?)<\/script>|\/>)/gi;
81
+ // eslint-disable-next-line security/detect-unsafe-regex, unicorn/no-unsafe-regex
82
+ const lStyleRegex = /<style(\s[^]*?)?(?:>([^]*?)<\/style>|\/>)/gi;
72
83
 
73
84
  if (pTranspilerWrapper.isAvailable) {
74
- return pSource.replace(
75
- lScriptRegex,
76
- getSourceReplacer(pTranspilerWrapper.transpile, pTranspilerOptions)
85
+ return (
86
+ pSource
87
+ .replace(
88
+ lScriptRegex,
89
+ getSourceReplacer(pTranspilerWrapper.transpile, pTranspilerOptions)
90
+ )
91
+ // we don't regard styling in our dependency analysis, so we can remove
92
+ // styles that (our instance of) svelte doesn't have pre-processors
93
+ // installed for (e.g. sass/scss/postcss/sss/styl/stylus/...) and that
94
+ // can potentially get svelte compiler to error out (for an example see
95
+ // https://github.com/sverweij/dependency-cruiser/issues/713)
96
+ .replace(lStyleRegex, styleReplacer)
77
97
  );
78
98
  } else {
79
99
  return pSource;
package/src/meta.js CHANGED
@@ -1,7 +1,7 @@
1
1
  /* generated - don't edit */
2
2
 
3
3
  module.exports = {
4
- version: "12.2.0",
4
+ version: "12.3.0",
5
5
  engines: {
6
6
  node: "^14||^16||>=18",
7
7
  },
@@ -128,7 +128,17 @@ function hashModuleNames(pModules, pMinify) {
128
128
  const lName = lPaths.slice(0, lIndex + 1).join("/");
129
129
  if (!lNamesHashMap.has(lName)) {
130
130
  if (pMinify) {
131
- lNamesHashMap.set(lName, lCount.toString(lBase));
131
+ // toUpperCase because otherwise we generate e.g. o-->a and x-->a
132
+ // which are ambiguous in mermaid (o--> and x--> are edge shapes
133
+ // whereas e.g. a--> is node 'a' + the arrow shape -->). The only
134
+ // collision within alphanums are 'o' and 'x', so upper casing
135
+ // saves us...
136
+ // ref: https://mermaid.js.org/syntax/flowchart.html#new-arrow-types
137
+ // another way to solve this would be to place a space between the
138
+ // node name and the edge shape (x --> a) - however, this would make
139
+ // for a larger output, running into the mermaid max source size
140
+ // earlier
141
+ lNamesHashMap.set(lName, lCount.toString(lBase).toUpperCase());
132
142
  lCount += 1;
133
143
  } else {
134
144
  lNamesHashMap.set(lName, hashToReadableNodeName(lName));
File without changes
File without changes
@@ -26,11 +26,11 @@ export interface ICruiseResult {
26
26
  modules: IModule[];
27
27
  /**
28
28
  * A list of folders, as derived from the detected modules, with for each
29
- * "folder a bunch of metrics (adapted from 'Agile software development:
30
- * "principles, patterns, and practices' by Robert C Martin (ISBN 0-13-597444-5).
31
- * "Note: these metrics substitute 'components' and 'classes' from that book
32
- * "with 'folders' and 'modules'; the closest relatives that work for the most
33
- * "programming styles in JavaScript (and its derivative languages).
29
+ * folder a bunch of metrics (adapted from 'Agile software development:
30
+ * principles, patterns, and practices' by Robert C Martin (ISBN 0-13-597444-5).
31
+ * Note: these metrics substitute 'components' and 'classes' from that book
32
+ * with 'folders' and 'modules'; the closest relatives that work for the most
33
+ * programming styles in JavaScript (and its derivative languages).
34
34
  */
35
35
  folders?: IFolder[];
36
36
  /**
@@ -165,10 +165,10 @@ export interface IDependency {
165
165
  */
166
166
  preCompilationOnly?: boolean;
167
167
  /**
168
- * 'true' when the module included the module explicitly as type only with the '
169
- * type' keyword e.g. import type { IThingus } from 'thing' Dependency-cruiser
168
+ * 'true' when the module included the module explicitly as type only with the
169
+ * `type` keyword e.g. `import type { IThingus } from 'thing'`. Dependency-cruiser
170
170
  * will only specify this attribute for TypeScript and when the 'tsPreCompilationDeps'
171
- * option has either the value true or 'specify'.
171
+ * option has either the value `true` or `"specify"`.
172
172
  */
173
173
  typeOnly?: boolean;
174
174
  /**