dependency-cruiser 18.1.0 → 18.1.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/configs/plugins/3d-reporter-plugin.mjs +1 -1
- package/configs/plugins/stats-reporter-plugin.mjs +2 -2
- package/package.json +3 -3
- package/src/analyze/add-validations.mjs +1 -1
- package/src/analyze/derive/folders/utl.mjs +2 -2
- package/src/analyze/summarize/summarize-modules.mjs +1 -1
- package/src/cache/cache.mjs +4 -4
- package/src/cache/helpers.mjs +2 -2
- package/src/cli/format-meta-info.mjs +3 -3
- package/src/cli/index.mjs +2 -2
- package/src/cli/init-config/check-and-warn-inconsistencies.mjs +3 -3
- package/src/cli/init-config/environment-helpers.mjs +4 -4
- package/src/cli/init-config/get-user-input.mjs +1 -1
- package/src/cli/init-config/index.mjs +1 -1
- package/src/cli/init-config/normalize-init-options.mjs +3 -3
- package/src/cli/init-config/validators.mjs +1 -1
- package/src/cli/init-config/write-run-scripts-to-manifest.mjs +2 -2
- package/src/cli/listeners/ndjson.mjs +1 -1
- package/src/cli/listeners/performance-log/index.mjs +1 -1
- package/src/cli/normalize-cli-options.mjs +6 -4
- package/src/cli/utl/assert-file-existence.mjs +1 -1
- package/src/config-utl/extract-babel-config.mjs +3 -1
- package/src/config-utl/extract-depcruise-config/index.mjs +1 -1
- package/src/config-utl/extract-depcruise-config/merge-configs.mjs +5 -3
- package/src/config-utl/extract-ts-config.mjs +1 -1
- package/src/config-utl/extract-webpack-resolve-config.mjs +2 -2
- package/src/extract/acorn/extract.mjs +1 -1
- package/src/extract/acorn/parse.mjs +2 -2
- package/src/extract/extract-dependencies.mjs +1 -1
- package/src/extract/extract-stats.mjs +1 -1
- package/src/extract/gather-initial-sources.mjs +1 -1
- package/src/extract/helpers.mjs +1 -1
- package/src/extract/index.mjs +1 -1
- package/src/extract/resolve/determine-dependency-types.mjs +3 -2
- package/src/extract/resolve/external-module-helpers.mjs +8 -8
- package/src/extract/resolve/get-manifest.mjs +7 -7
- package/src/extract/resolve/index.mjs +2 -1
- package/src/extract/resolve/merge-manifests.mjs +2 -2
- package/src/extract/resolve/module-classifiers.mjs +1 -1
- package/src/extract/resolve/resolve-amd.mjs +1 -1
- package/src/extract/resolve/resolve-cjs.mjs +2 -2
- package/src/extract/resolve/resolve-helpers.mjs +1 -1
- package/src/extract/resolve/resolve.mjs +2 -2
- package/src/extract/swc/dependency-visitor.mjs +1 -0
- package/src/extract/swc/parse.mjs +2 -2
- package/src/extract/transpile/index.mjs +1 -1
- package/src/extract/transpile/meta.mjs +1 -1
- package/src/extract/transpile/try-import-available.mjs +1 -1
- package/src/extract/transpile/typescript-wrap.mjs +1 -1
- package/src/extract/tsc/extract-typescript-deps.mjs +1 -1
- package/src/extract/tsc/parse.mjs +3 -3
- package/src/graph-utl/add-focus.mjs +1 -1
- package/src/graph-utl/consolidate-to-pattern.mjs +1 -0
- package/src/graph-utl/indexed-module-graph.mjs +6 -6
- package/src/graph-utl/module-graph-with-dependency-set.mjs +1 -1
- package/src/graph-utl/rule-set.mjs +3 -3
- package/src/main/cruise.mjs +1 -1
- package/src/main/helpers.mjs +1 -1
- package/src/main/options/normalize.mjs +2 -2
- package/src/main/resolve-options/normalize.mjs +2 -2
- package/src/main/rule-set/assert-validity.mjs +1 -1
- package/src/main/rule-set/normalize.mjs +1 -1
- package/src/meta.cjs +1 -1
- package/src/report/anon/anonymize-path-element.mjs +1 -1
- package/src/report/anon/index.mjs +1 -1
- package/src/report/anon/random-string.mjs +1 -1
- package/src/report/azure-devops.mjs +2 -2
- package/src/report/baseline.mjs +1 -1
- package/src/report/d2.mjs +3 -3
- package/src/report/dot/index.mjs +1 -1
- package/src/report/dot/module-utl.mjs +2 -2
- package/src/report/dot/theming.mjs +12 -6
- package/src/report/dot-webpage/svg-in-html-snippets/script.cjs +7 -7
- package/src/report/error.mjs +1 -1
- package/src/report/html/index.mjs +2 -2
- package/src/report/index.mjs +1 -0
- package/src/report/markdown.mjs +3 -3
- package/src/report/mermaid.mjs +3 -3
- package/src/report/metrics.mjs +2 -2
- package/src/report/plugins.mjs +2 -1
- package/src/report/teamcity.mjs +2 -2
- package/src/report/utl/dependency-to-incidence-transformer.mjs +1 -1
- package/src/report/utl/index.mjs +1 -1
- package/src/utl/array-util.mjs +1 -1
- package/src/utl/find-all-files.mjs +1 -1
- package/src/utl/get-extension.mjs +1 -1
- package/src/utl/path-to-posix.mjs +1 -1
- package/src/utl/regex-util.mjs +3 -1
- package/src/utl/try-import.mjs +1 -1
- package/src/utl/try-require.cjs +3 -3
- package/src/validate/index.mjs +2 -2
- package/types/config-utl/extract-babel-config.d.mts +1 -1
- package/types/config-utl/extract-depcruise-config.d.mts +1 -1
- package/types/config-utl/extract-depcruise-options.d.mts +1 -1
- package/types/config-utl/extract-ts-config.d.mts +1 -1
- package/types/config-utl/extract-webpack-resolve-config.d.mts +1 -1
- package/types/plugins/3d-reporter-plugin.d.mts +1 -1
- package/types/plugins/mermaid-reporter-plugin.d.mts +1 -1
- package/types/plugins/stats-reporter-plugin.d.mts +1 -1
|
@@ -30,14 +30,14 @@ const PACKAGE_JSON_CACHE = new Map();
|
|
|
30
30
|
* non-commonJS and are still using node_modules) e.g. '../node_modules/oldash/fp'
|
|
31
31
|
*
|
|
32
32
|
* @param {string} pModule a module name
|
|
33
|
-
* @
|
|
33
|
+
* @returns {string} the module name root
|
|
34
34
|
*/
|
|
35
35
|
export function getPackageRoot(pModule) {
|
|
36
36
|
if (!pModule || isRelativeModuleName(pModule)) {
|
|
37
37
|
return pModule;
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
|
|
40
|
+
const lPathElements = pModule.split("/");
|
|
41
41
|
|
|
42
42
|
if (isScoped(pModule)) {
|
|
43
43
|
// '@imdoingweirdvoodoo'
|
|
@@ -69,7 +69,7 @@ export function getPackageRoot(pModule) {
|
|
|
69
69
|
* @param {string} pModuleName The name of the module to get the package.json of
|
|
70
70
|
* @param {string} pFileDirectory The folder the module resides in. Defaults to the current working directory
|
|
71
71
|
* @param {any} pResolveOptions options for the resolver
|
|
72
|
-
* @
|
|
72
|
+
* @returns {Record<string, any>} The package.json as a javascript object, or
|
|
73
73
|
* null if either module or package.json could
|
|
74
74
|
* not be found
|
|
75
75
|
*/
|
|
@@ -104,7 +104,7 @@ export function getPackageJson(pModuleName, pFileDirectory, pResolveOptions) {
|
|
|
104
104
|
"manifest-resolution",
|
|
105
105
|
);
|
|
106
106
|
lReturnValue = JSON.parse(readFileSync(lPackageJsonFilename, "utf8"));
|
|
107
|
-
} catch
|
|
107
|
+
} catch {
|
|
108
108
|
// left empty on purpose
|
|
109
109
|
}
|
|
110
110
|
PACKAGE_JSON_CACHE.set(lCacheKey, lReturnValue);
|
|
@@ -117,7 +117,7 @@ export function getPackageJson(pModuleName, pFileDirectory, pResolveOptions) {
|
|
|
117
117
|
* @param {string} pModuleName The name of the module to get the deprecation status of
|
|
118
118
|
* @param {string} pFileDirectory The folder the module resides in.
|
|
119
119
|
* @param {any} pResolveOptions options for the resolver
|
|
120
|
-
* @
|
|
120
|
+
* @returns {boolean} true when deprecated, false in all other cases
|
|
121
121
|
*/
|
|
122
122
|
export function dependencyIsDeprecated(
|
|
123
123
|
pModuleName,
|
|
@@ -125,7 +125,7 @@ export function dependencyIsDeprecated(
|
|
|
125
125
|
pResolveOptions,
|
|
126
126
|
) {
|
|
127
127
|
let lReturnValue = false;
|
|
128
|
-
|
|
128
|
+
const lPackageJson = getPackageJson(
|
|
129
129
|
pModuleName,
|
|
130
130
|
pFileDirectory,
|
|
131
131
|
pResolveOptions,
|
|
@@ -144,12 +144,12 @@ export function dependencyIsDeprecated(
|
|
|
144
144
|
* @param {string} pModuleName The name of the module to get the license of
|
|
145
145
|
* @param {string} pFileDirectory The folder the module resides in.
|
|
146
146
|
* @param {any} pResolveOptions options for the resolver
|
|
147
|
-
* @
|
|
147
|
+
* @returns {string} The module's license string, or '' in case
|
|
148
148
|
* there is no package.json or no license field
|
|
149
149
|
*/
|
|
150
150
|
export function getLicense(pModuleName, pFileDirectory, pResolveOptions) {
|
|
151
151
|
let lReturnValue = "";
|
|
152
|
-
|
|
152
|
+
const lPackageJson = getPackageJson(
|
|
153
153
|
pModuleName,
|
|
154
154
|
pFileDirectory,
|
|
155
155
|
pResolveOptions,
|
|
@@ -14,7 +14,7 @@ const COMBINED_MANIFEST_CACHE = new Map();
|
|
|
14
14
|
*
|
|
15
15
|
* @param {string} pFileDirectory the folder relative to which to find
|
|
16
16
|
* the package.json
|
|
17
|
-
* @
|
|
17
|
+
* @returns {any} the contents of the package.json as a javascript
|
|
18
18
|
* object or null if the package.json could not be
|
|
19
19
|
* found or is invalid
|
|
20
20
|
*/
|
|
@@ -34,10 +34,10 @@ function getSingleManifest(pFileDirectory) {
|
|
|
34
34
|
|
|
35
35
|
try {
|
|
36
36
|
lReturnValue = JSON.parse(lPackageContent);
|
|
37
|
-
} catch
|
|
37
|
+
} catch {
|
|
38
38
|
// left empty on purpose
|
|
39
39
|
}
|
|
40
|
-
} catch
|
|
40
|
+
} catch {
|
|
41
41
|
const lNextDirectory = dirname(pFileDirectory);
|
|
42
42
|
|
|
43
43
|
if (lNextDirectory !== pFileDirectory) {
|
|
@@ -60,17 +60,17 @@ function maybeReadPackage(pFileDirectory) {
|
|
|
60
60
|
|
|
61
61
|
try {
|
|
62
62
|
lReturnValue = JSON.parse(lPackageContent);
|
|
63
|
-
} catch
|
|
63
|
+
} catch {
|
|
64
64
|
// left empty on purpose
|
|
65
65
|
}
|
|
66
|
-
} catch
|
|
66
|
+
} catch {
|
|
67
67
|
// left empty on purpose
|
|
68
68
|
}
|
|
69
69
|
return lReturnValue;
|
|
70
70
|
}
|
|
71
71
|
|
|
72
72
|
function getIntermediatePaths(pFileDirectory, pBaseDirectory) {
|
|
73
|
-
|
|
73
|
+
const lReturnValue = [];
|
|
74
74
|
let lIntermediate = pFileDirectory;
|
|
75
75
|
|
|
76
76
|
while (
|
|
@@ -133,7 +133,7 @@ function getCombinedManifests(pFileDirectory, pBaseDirectory) {
|
|
|
133
133
|
* @param {string} pBaseDirectory the directory to consider as base (or 'root')
|
|
134
134
|
* @param {Boolean} pCombinedDependencies whether to stop (false) or continue
|
|
135
135
|
* searching until the 'root'
|
|
136
|
-
* @
|
|
136
|
+
* @returns {any} the contents of a package.json as a javascript
|
|
137
137
|
* object or null if a package.json could not be
|
|
138
138
|
* found or is invalid
|
|
139
139
|
*/
|
|
@@ -30,6 +30,7 @@ function resolveModule(
|
|
|
30
30
|
pFileDirectory,
|
|
31
31
|
pResolveOptions,
|
|
32
32
|
) {
|
|
33
|
+
/* oxlint-disable-next-line no-useless-assignment */
|
|
33
34
|
let lReturnValue = null;
|
|
34
35
|
|
|
35
36
|
const lStrippedModuleName = stripToModuleName(pModule.module);
|
|
@@ -178,7 +179,7 @@ function resolveWithRetry(
|
|
|
178
179
|
* detected in
|
|
179
180
|
* @param {IResolveOptions} pResolveOptions
|
|
180
181
|
* @param {any} pTranspileOptions
|
|
181
|
-
* @
|
|
182
|
+
* @returns {Partial <IDependency>}
|
|
182
183
|
*
|
|
183
184
|
*
|
|
184
185
|
*/
|
|
@@ -2,7 +2,7 @@ import { uniq } from "#utl/array-util.mjs";
|
|
|
2
2
|
|
|
3
3
|
/* eslint-disable security/detect-object-injection */
|
|
4
4
|
function normalizeManifestKeys(pManifest) {
|
|
5
|
-
|
|
5
|
+
const lReturnValue = pManifest;
|
|
6
6
|
|
|
7
7
|
if (pManifest.bundleDependencies) {
|
|
8
8
|
pManifest.bundledDependencies = structuredClone(
|
|
@@ -60,7 +60,7 @@ function isAnArrayKey(pKey) {
|
|
|
60
60
|
* source being perused (e.g. ./packages/sub/package.json)
|
|
61
61
|
* @param {any} pFurtherManifest the contents of a package.json further away
|
|
62
62
|
* (e.g. ./package.json)
|
|
63
|
-
* @
|
|
63
|
+
* @returns {any} the combined dependency-keys within those manifests
|
|
64
64
|
*/
|
|
65
65
|
export default function mergeManifests(pClosestManifest, pFurtherManifest) {
|
|
66
66
|
return getJointUniqueDependencyKeys(
|
|
@@ -54,7 +54,7 @@ export function isExternalModule(
|
|
|
54
54
|
}
|
|
55
55
|
|
|
56
56
|
function determineFollowableExtensions(pResolveOptions) {
|
|
57
|
-
|
|
57
|
+
const lReturnValue = new Set(pResolveOptions.extensions);
|
|
58
58
|
|
|
59
59
|
// we could include things like pictures, movies, html, xml etc in
|
|
60
60
|
// lKnownUnfollowables as well. Ijavascript-like sources you don't
|
|
@@ -10,7 +10,7 @@ function addResolutionAttributes(
|
|
|
10
10
|
pFileDirectory,
|
|
11
11
|
pResolveOptions,
|
|
12
12
|
) {
|
|
13
|
-
|
|
13
|
+
const lReturnValue = {};
|
|
14
14
|
|
|
15
15
|
if (isBuiltin(pModuleName, pResolveOptions)) {
|
|
16
16
|
lReturnValue.coreModule = true;
|
|
@@ -26,7 +26,7 @@ function addResolutionAttributes(
|
|
|
26
26
|
lReturnValue.resolved,
|
|
27
27
|
pResolveOptions,
|
|
28
28
|
);
|
|
29
|
-
} catch
|
|
29
|
+
} catch {
|
|
30
30
|
lReturnValue.couldNotResolve = true;
|
|
31
31
|
}
|
|
32
32
|
}
|
|
@@ -5,9 +5,9 @@ import pathToPosix from "#utl/path-to-posix.mjs";
|
|
|
5
5
|
/** @import {IResolveOptions} from "../../../types/resolve-options.mjs" */
|
|
6
6
|
|
|
7
7
|
/** @type {Map<string, enhancedResolve.Resolver>} */
|
|
8
|
-
|
|
8
|
+
const gResolvers = new Map();
|
|
9
9
|
/** @type {Set<string>} */
|
|
10
|
-
|
|
10
|
+
const gInitialized = new Set();
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
13
|
* Initializes a resolver for the given caching context if not already done
|
|
@@ -32,7 +32,7 @@ export function getASTFromSource(pSource) {
|
|
|
32
32
|
* return the result from a cache
|
|
33
33
|
*
|
|
34
34
|
* @param {string} pFileName - the name of the file to compile
|
|
35
|
-
* @
|
|
35
|
+
* @returns {ModuleItem[]} - an (swc) AST
|
|
36
36
|
*/
|
|
37
37
|
export function getASTCached(pFileName) {
|
|
38
38
|
if (CACHE.has(pFileName)) {
|
|
@@ -49,7 +49,7 @@ export function clearCache() {
|
|
|
49
49
|
}
|
|
50
50
|
|
|
51
51
|
/**
|
|
52
|
-
* @
|
|
52
|
+
* @returns {boolean} - true if the swc compiler is available,
|
|
53
53
|
* false in all other cases
|
|
54
54
|
*/
|
|
55
55
|
// @ts-expect-error dfdfd
|
|
@@ -89,7 +89,7 @@ export function getWrapper(pExtension, pTranspilerOptions) {
|
|
|
89
89
|
* @param {{ extension:string; source:string; filename:string; }} pFileRecord Record with source code, an extension and a filename
|
|
90
90
|
* @param {any} pTranspilerOptions (optional) object with options influencing
|
|
91
91
|
* the underlying transpiler behavior.
|
|
92
|
-
* @
|
|
92
|
+
* @returns {string} the transpiled version of the file (or the file
|
|
93
93
|
* itself when the function could not find a
|
|
94
94
|
* transpiler matching pExtension
|
|
95
95
|
*/
|
|
@@ -155,7 +155,7 @@ export const scannableExtensions = Array.from(
|
|
|
155
155
|
* - the version (range) supported
|
|
156
156
|
* - whether or not it is available in the current environment
|
|
157
157
|
*
|
|
158
|
-
* @
|
|
158
|
+
* @returns {IAvailableTranspiler[]} an array of supported transpilers
|
|
159
159
|
*/
|
|
160
160
|
export function getAvailableTranspilers() {
|
|
161
161
|
return ["javascript"]
|
|
@@ -38,7 +38,7 @@ export default function tryImportAvailable(pModuleName, pSemanticVersion) {
|
|
|
38
38
|
// of course we'd love to use something like import.meta.resolve, but
|
|
39
39
|
// that's _experimental_, so ¯\_(ツ)_/¯
|
|
40
40
|
return Boolean(require.resolve(pModuleName));
|
|
41
|
-
} catch
|
|
41
|
+
} catch {
|
|
42
42
|
return false;
|
|
43
43
|
}
|
|
44
44
|
}
|
|
@@ -18,7 +18,7 @@ const CACHE = new Map();
|
|
|
18
18
|
* @param {object} pFileRecord Record with source code, an extension and a filename
|
|
19
19
|
* @param {any} [pTranspileOptions] options for the transpiler(s) - a tsconfig or
|
|
20
20
|
* a babel config
|
|
21
|
-
* @
|
|
21
|
+
* @returns {object} - a (typescript) AST
|
|
22
22
|
*/
|
|
23
23
|
export function getASTFromSource(pFileRecord, pTranspileOptions) {
|
|
24
24
|
let lSource = pFileRecord.source;
|
|
@@ -42,7 +42,7 @@ export function getASTFromSource(pFileRecord, pTranspileOptions) {
|
|
|
42
42
|
* @param {string} pFileName - the name of the file to compile
|
|
43
43
|
* @param {any} [pTranspileOptions] options for the transpiler(s) - a tsconfig or
|
|
44
44
|
* a babel config
|
|
45
|
-
* @
|
|
45
|
+
* @returns {object} - a (typescript) AST
|
|
46
46
|
*/
|
|
47
47
|
export function getASTCached(pFileName, pTranspileOptions) {
|
|
48
48
|
if (CACHE.has(pFileName)) {
|
|
@@ -61,7 +61,7 @@ export function getASTCached(pFileName, pTranspileOptions) {
|
|
|
61
61
|
}
|
|
62
62
|
|
|
63
63
|
/**
|
|
64
|
-
* @
|
|
64
|
+
* @returns {boolean} - true if the typescript compiler is available,
|
|
65
65
|
* false in all other cases
|
|
66
66
|
*/
|
|
67
67
|
export const isAvailable = () => typescript !== false;
|
|
@@ -34,7 +34,7 @@ export default function addFocus(pModules, pFilter) {
|
|
|
34
34
|
({ source }) => source,
|
|
35
35
|
);
|
|
36
36
|
let lReachableModuleNamesArray = [];
|
|
37
|
-
|
|
37
|
+
const lIndexedModules = new IndexedModuleGraph(pModules);
|
|
38
38
|
|
|
39
39
|
for (const lFocusedModule of lFocusedModuleNames) {
|
|
40
40
|
lReachableModuleNamesArray = lReachableModuleNamesArray
|
|
@@ -16,6 +16,7 @@ function squashDependencyToPattern(pCollapsePattern) {
|
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
function determineConsolidatedness(pConsolidated, pCollapseMatch, pSource) {
|
|
19
|
+
/* oxlint-disable-next-line no-useless-assignment */
|
|
19
20
|
let lReturnValue = false;
|
|
20
21
|
|
|
21
22
|
// if it was already established it's consolidated (e.g. from an earlier
|
|
@@ -43,7 +43,7 @@ export default class IndexedModuleGraph {
|
|
|
43
43
|
|
|
44
44
|
/**
|
|
45
45
|
* @param {string} pName
|
|
46
|
-
* @
|
|
46
|
+
* @returns {IVertex}
|
|
47
47
|
*/
|
|
48
48
|
findVertexByName(pName) {
|
|
49
49
|
return this.#indexedGraph.get(pName);
|
|
@@ -71,7 +71,7 @@ export default class IndexedModuleGraph {
|
|
|
71
71
|
const lModule = this.#indexedGraph.get(pName);
|
|
72
72
|
|
|
73
73
|
if (lModule && (!pMaxDepth || pDepth <= pMaxDepth)) {
|
|
74
|
-
|
|
74
|
+
const lDependents = lModule.dependents || [];
|
|
75
75
|
const lVisited = pVisited.add(pName);
|
|
76
76
|
|
|
77
77
|
// @TODO this works for modules, but not for folders yet
|
|
@@ -115,7 +115,7 @@ export default class IndexedModuleGraph {
|
|
|
115
115
|
const lModule = this.#indexedGraph.get(pName);
|
|
116
116
|
|
|
117
117
|
if (lModule && (!pMaxDepth || pDepth <= pMaxDepth)) {
|
|
118
|
-
|
|
118
|
+
const lDependencies = lModule.dependencies;
|
|
119
119
|
const lVisited = pVisited.add(pName);
|
|
120
120
|
|
|
121
121
|
if (lDependencies.length > 0) {
|
|
@@ -169,7 +169,7 @@ export default class IndexedModuleGraph {
|
|
|
169
169
|
if (lDependency.name === pTo) {
|
|
170
170
|
return [this.#geldEdge(lDependency)];
|
|
171
171
|
}
|
|
172
|
-
|
|
172
|
+
const lCandidatePath = this.getPath(lDependency.name, pTo, pVisited);
|
|
173
173
|
|
|
174
174
|
if (lCandidatePath.length > 0) {
|
|
175
175
|
return [this.#geldEdge(lDependency)].concat(lCandidatePath);
|
|
@@ -187,7 +187,7 @@ export default class IndexedModuleGraph {
|
|
|
187
187
|
* @param {string} pInitialSource The 'source' attribute of the node to be tested (source uniquely identifying a node)
|
|
188
188
|
* @param {IEdge} pCurrentDependency The 'to' node to be traversed as a dependency object of the previous 'from' traversed
|
|
189
189
|
* @param {Set<string>=} pVisited Technical parameter - best to leave out of direct calls
|
|
190
|
-
* @
|
|
190
|
+
* @returns {Array<IMiniDependency>} see description above
|
|
191
191
|
*/
|
|
192
192
|
#getCycle(pInitialSource, pCurrentDependency, pVisited) {
|
|
193
193
|
const lVisited = pVisited || new Set();
|
|
@@ -239,7 +239,7 @@ export default class IndexedModuleGraph {
|
|
|
239
239
|
* (source uniquely identifying a node)
|
|
240
240
|
* @param {string} pCurrentSource The 'source' attribute of the 'to' node to
|
|
241
241
|
* be traversed
|
|
242
|
-
* @
|
|
242
|
+
* @returns {Array<IMiniDependency>} see description above
|
|
243
243
|
*/
|
|
244
244
|
getCycle(pInitialSource, pCurrentSource) {
|
|
245
245
|
/** @type {IVertex} */
|
|
@@ -3,7 +3,7 @@ export default class ModuleGraphWithDependencySet {
|
|
|
3
3
|
#modulesWithDependencySet;
|
|
4
4
|
/**
|
|
5
5
|
* Creates a module graph optimized for querying dependents
|
|
6
|
-
* @
|
|
6
|
+
* @class
|
|
7
7
|
* @param {import("../../types/dependency-cruiser.mjs").IModule[]} pModules
|
|
8
8
|
*/
|
|
9
9
|
constructor(pModules) {
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
*
|
|
12
12
|
* @param {IFlattenedRuleSet} pRuleSet - The rule set to search in
|
|
13
13
|
* @param {string} pName - The rule name to look for
|
|
14
|
-
* @
|
|
14
|
+
* @returns {IForbiddenRuleType|undefined} - a rule (or 'undefined' if nothing found)
|
|
15
15
|
*/
|
|
16
16
|
export function findRuleByName(pRuleSet, pName) {
|
|
17
17
|
const lNamedRules = (pRuleSet?.forbidden ?? []).concat(
|
|
@@ -34,7 +34,7 @@ function ruleHasALicenseLikeAttribute(pRule) {
|
|
|
34
34
|
* Returns false in all other cases
|
|
35
35
|
*
|
|
36
36
|
* @param {IFlattenedRuleSet} pRuleSet
|
|
37
|
-
* @
|
|
37
|
+
* @returns {boolean}
|
|
38
38
|
*/
|
|
39
39
|
export function ruleSetHasLicenseRule(pRuleSet) {
|
|
40
40
|
return (
|
|
@@ -45,7 +45,7 @@ export function ruleSetHasLicenseRule(pRuleSet) {
|
|
|
45
45
|
|
|
46
46
|
/**
|
|
47
47
|
* @param {IFlattenedRuleSet} pRuleSet
|
|
48
|
-
* @
|
|
48
|
+
* @returns {boolean}
|
|
49
49
|
*/
|
|
50
50
|
export function ruleSetHasDeprecationRule(pRuleSet) {
|
|
51
51
|
return (
|
package/src/main/cruise.mjs
CHANGED
|
@@ -22,7 +22,7 @@ export default async function cruise(
|
|
|
22
22
|
bus.summary("startup: parse options", c(1));
|
|
23
23
|
const lCruiseOptionsValid = assertCruiseOptionsValid(pCruiseOptions);
|
|
24
24
|
/** @type {import("../../types/strict-options.mjs").IStrictCruiseOptions} */
|
|
25
|
-
|
|
25
|
+
const lCruiseOptions = normalizeCruiseOptions(
|
|
26
26
|
lCruiseOptionsValid,
|
|
27
27
|
pFileAndDirectoryArray,
|
|
28
28
|
);
|
package/src/main/helpers.mjs
CHANGED
|
@@ -25,7 +25,7 @@ export function normalizeREProperties(
|
|
|
25
25
|
pPropertyContainer,
|
|
26
26
|
pREProperties = RE_PROPERTIES,
|
|
27
27
|
) {
|
|
28
|
-
|
|
28
|
+
const lPropertyContainer = structuredClone(pPropertyContainer);
|
|
29
29
|
|
|
30
30
|
for (const lProperty of pREProperties) {
|
|
31
31
|
// lProperty can be nested properties, so we use _.has and _.get
|
|
@@ -45,7 +45,7 @@ function normalizeReporterOptions(pReporterOptions) {
|
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
function normalizeFilterOptions(pOptions, pFilterOptionKeys) {
|
|
48
|
-
|
|
48
|
+
const lReturnValue = { ...pOptions };
|
|
49
49
|
|
|
50
50
|
for (const lFilterOptionKey of pFilterOptionKeys) {
|
|
51
51
|
if (pOptions[lFilterOptionKey]) {
|
|
@@ -74,7 +74,7 @@ function normalizeCollapse(pCollapse) {
|
|
|
74
74
|
|
|
75
75
|
function normalizeFocusDepth(pFormatOptions) {
|
|
76
76
|
/** @type {IFormatOptions}*/
|
|
77
|
-
|
|
77
|
+
const lFormatOptions = structuredClone(pFormatOptions);
|
|
78
78
|
if (Object.hasOwn(lFormatOptions, "focusDepth")) {
|
|
79
79
|
if (lFormatOptions?.focus) {
|
|
80
80
|
lFormatOptions.focus.depth = Number.parseInt(
|
|
@@ -37,7 +37,7 @@ const DEFAULT_RESOLVE_OPTIONS = {
|
|
|
37
37
|
|
|
38
38
|
function omit(pObject, pProperty) {
|
|
39
39
|
const lObject = structuredClone(pObject);
|
|
40
|
-
|
|
40
|
+
/* oxlint-disable-next-line no-dynamic-delete */
|
|
41
41
|
delete lObject[pProperty];
|
|
42
42
|
return lObject;
|
|
43
43
|
}
|
|
@@ -71,7 +71,7 @@ async function compileResolveOptions(
|
|
|
71
71
|
pTSConfig,
|
|
72
72
|
pResolveOptionsFromDCConfig,
|
|
73
73
|
) {
|
|
74
|
-
|
|
74
|
+
const lResolveOptions = {};
|
|
75
75
|
|
|
76
76
|
// There's a performance impact of ~1 ms per resolve even when there
|
|
77
77
|
// are 0 paths in the tsconfig, so not loading it when not necessary
|
|
@@ -76,7 +76,7 @@ function assertRuleSafety(pRule) {
|
|
|
76
76
|
* Throws an Error in all other cases.
|
|
77
77
|
*
|
|
78
78
|
* @param {IConfiguration} pConfiguration The configuration to validate
|
|
79
|
-
* @
|
|
79
|
+
* @returns {IConfiguration} The configuration as passed
|
|
80
80
|
* @throws {Error} An error with the reason for the error as a message
|
|
81
81
|
*/
|
|
82
82
|
export default function assertRuleSetValid(pConfiguration) {
|
|
@@ -111,7 +111,7 @@ function normalizeRule(pRule) {
|
|
|
111
111
|
* - severity (default 'warn')
|
|
112
112
|
*
|
|
113
113
|
* @param {IFlattenedRuleSet} pRuleSet
|
|
114
|
-
* @
|
|
114
|
+
* @returns {IStrictRuleSet}
|
|
115
115
|
*/
|
|
116
116
|
export default function normalizeRuleSet(pRuleSet) {
|
|
117
117
|
bus.debug("startup: parse rule set: normalize");
|
package/src/meta.cjs
CHANGED
|
@@ -37,7 +37,7 @@ function replaceFromWordList(pPathElement, pWordList, pCached) {
|
|
|
37
37
|
* @param {string[]} pWordList words to pick from
|
|
38
38
|
* @param {RegExp} pWhiteListRE pattern not to anonymize
|
|
39
39
|
* @param {boolean} pCached caches the replaced value, with pPathElement as the key
|
|
40
|
-
* @
|
|
40
|
+
* @returns {string} the path element, anonymized if it isn't whitelisted
|
|
41
41
|
*/
|
|
42
42
|
export function anonymizePathElement(
|
|
43
43
|
pPathElement,
|
|
@@ -179,7 +179,7 @@ function sanitizeWordList(pWordList) {
|
|
|
179
179
|
*/
|
|
180
180
|
export default function reportAnonymous(pResults, pAnonymousReporterOptions) {
|
|
181
181
|
/** @type {{wordlist?: String[]}} */
|
|
182
|
-
|
|
182
|
+
const lAnonymousReporterOptions = pAnonymousReporterOptions || {};
|
|
183
183
|
if (!lAnonymousReporterOptions.wordlist) {
|
|
184
184
|
lAnonymousReporterOptions.wordlist =
|
|
185
185
|
pResults?.summary?.optionsUsed?.reporterOptions?.anon?.wordlist ?? [];
|
|
@@ -51,7 +51,7 @@ function getRandomChar(pChar) {
|
|
|
51
51
|
* pulp2slurp => jgyb3guyow
|
|
52
52
|
*
|
|
53
53
|
* @param {string} pString - any string
|
|
54
|
-
* @
|
|
54
|
+
* @returns {string} - a random string with above specs
|
|
55
55
|
*/
|
|
56
56
|
export default function getRandomString(pString) {
|
|
57
57
|
return Array.from(pString).map(getRandomChar).join("");
|
|
@@ -80,7 +80,7 @@ function formatViolation(pViolation) {
|
|
|
80
80
|
reachability: formatReachabilityViolation,
|
|
81
81
|
instability: formatInstabilityViolation,
|
|
82
82
|
};
|
|
83
|
-
|
|
83
|
+
const lFormattedViolators = _formatViolation(
|
|
84
84
|
pViolation,
|
|
85
85
|
lViolationType2Formatter,
|
|
86
86
|
formatDependencyViolation,
|
|
@@ -133,7 +133,7 @@ function formatIgnoreWarning(pNumberOfIgnored) {
|
|
|
133
133
|
* @returns {string}
|
|
134
134
|
*/
|
|
135
135
|
function formatResultMessage(pSummary) {
|
|
136
|
-
|
|
136
|
+
const lStatSummary = `${pSummary.totalCruised} modules, ${
|
|
137
137
|
pSummary?.totalDependenciesCruised ?? 0
|
|
138
138
|
} dependencies cruised`;
|
|
139
139
|
|
package/src/report/baseline.mjs
CHANGED
|
@@ -7,7 +7,7 @@ const EOL = "\n";
|
|
|
7
7
|
* @param {import('../../types/dependency-cruiser').ICruiseResult} pCruiseResult -
|
|
8
8
|
* the output of a dependency-cruise adhering to dependency-cruiser's
|
|
9
9
|
* cruise result schema
|
|
10
|
-
* @
|
|
10
|
+
* @returns {import('../../types/dependency-cruiser').IReporterOutput} -
|
|
11
11
|
* output: some stats on modules and dependencies in json format
|
|
12
12
|
* exitCode: 0
|
|
13
13
|
*/
|
package/src/report/d2.mjs
CHANGED
|
@@ -32,7 +32,7 @@ function getMaxSeverity(pRules) {
|
|
|
32
32
|
|
|
33
33
|
/**
|
|
34
34
|
* @param {string} pSource
|
|
35
|
-
* @
|
|
35
|
+
* @returns {string}
|
|
36
36
|
*/
|
|
37
37
|
function getVertexName(pSource) {
|
|
38
38
|
const lFolderName = dirname(pSource)
|
|
@@ -117,7 +117,7 @@ function getDependencyAttributes(pDependency) {
|
|
|
117
117
|
|
|
118
118
|
/**
|
|
119
119
|
* @param {import('../../types/cruise-result').ICruiseResult} pCruiseResult
|
|
120
|
-
* @
|
|
120
|
+
* @returns {string}
|
|
121
121
|
*/
|
|
122
122
|
function renderD2Source(pCruiseResult) {
|
|
123
123
|
const lVertices = pCruiseResult.modules
|
|
@@ -153,7 +153,7 @@ function renderD2Source(pCruiseResult) {
|
|
|
153
153
|
* d2 reporter
|
|
154
154
|
*
|
|
155
155
|
* @param {import('../../types/dependency-cruiser').ICruiseResult} pCruiseResult
|
|
156
|
-
* @
|
|
156
|
+
* @returns {import('../../types/dependency-cruiser').IReporterOutput}
|
|
157
157
|
*/
|
|
158
158
|
export default function d2(pCruiseResult) {
|
|
159
159
|
return {
|
package/src/report/dot/index.mjs
CHANGED
|
@@ -57,8 +57,8 @@ function makeInstabilityString(pModule, pShowMetrics = false) {
|
|
|
57
57
|
export function folderify(pShowMetrics) {
|
|
58
58
|
/** @param {import("../../../types/cruise-result").IModule} pModule*/
|
|
59
59
|
return (pModule) => {
|
|
60
|
-
|
|
61
|
-
|
|
60
|
+
const lAdditions = {};
|
|
61
|
+
const lDirectoryName = dirname(pModule.source);
|
|
62
62
|
|
|
63
63
|
if (lDirectoryName !== ".") {
|
|
64
64
|
lAdditions.folder = lDirectoryName;
|