dependency-cruiser 16.6.0 → 16.7.0-beta-1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/cache/cache.mjs +3 -4
- package/src/cache/content-strategy.mjs +5 -7
- package/src/cache/find-content-changes.mjs +11 -5
- package/src/cache/helpers.mjs +8 -8
- package/src/cache/metadata-strategy.mjs +6 -8
- package/src/cache/options-compatible.mjs +2 -1
- package/src/cli/init-config/build-config.mjs +13 -9
- package/src/cli/init-config/config-template.mjs +11 -0
- package/src/cli/init-config/index.mjs +10 -6
- package/src/cli/init-config/normalize-init-options.mjs +10 -6
- package/src/config-utl/extract-depcruise-options.mjs +8 -4
- package/src/config-utl/extract-known-violations.mjs +2 -2
- package/src/enrich/summarize/summarize-options.mjs +2 -0
- package/src/extract/extract-dependencies.mjs +14 -9
- package/src/extract/extract-stats.mjs +9 -4
- package/src/extract/gather-initial-sources.mjs +7 -5
- package/src/extract/index.mjs +9 -4
- package/src/extract/resolve/determine-dependency-types.mjs +20 -13
- package/src/extract/resolve/index.mjs +11 -5
- package/src/extract/resolve/module-classifiers.mjs +7 -2
- package/src/extract/swc/parse.mjs +8 -4
- package/src/extract/tsc/extract-typescript-deps.mjs +85 -13
- package/src/extract/tsc/extract.mjs +2 -1
- package/src/graph-utl/consolidate-module-dependencies.mjs +8 -4
- package/src/graph-utl/filter-bank.mjs +8 -3
- package/src/graph-utl/indexed-module-graph.mjs +7 -11
- package/src/graph-utl/rule-set.mjs +9 -5
- package/src/main/options/assert-validity.mjs +6 -2
- package/src/main/options/defaults.mjs +1 -0
- package/src/main/options/normalize.mjs +23 -13
- package/src/main/report-wrap.mjs +12 -7
- package/src/main/resolve-options/normalize.mjs +9 -4
- package/src/main/rule-set/assert-validity.mjs +5 -2
- package/src/main/rule-set/normalize.mjs +18 -8
- package/src/meta.cjs +1 -1
- package/src/schema/baseline-violations.schema.mjs +1 -1
- package/src/schema/configuration.schema.mjs +1 -1
- package/src/schema/cruise-result.schema.mjs +1 -1
- package/src/validate/index.mjs +6 -2
- package/src/validate/match-dependency-rule.mjs +8 -4
- package/src/validate/match-module-rule-helpers.mjs +15 -9
- package/src/validate/match-module-rule.mjs +8 -5
- package/types/options.d.mts +5 -0
- package/types/shared-types.d.mts +3 -0
package/package.json
CHANGED
package/src/cache/cache.mjs
CHANGED
|
@@ -13,10 +13,9 @@ import { scannableExtensions } from "#extract/transpile/meta.mjs";
|
|
|
13
13
|
import { bus } from "#utl/bus.mjs";
|
|
14
14
|
|
|
15
15
|
/**
|
|
16
|
-
* @
|
|
17
|
-
* @
|
|
18
|
-
* @
|
|
19
|
-
* @typedef {import("../../types/cache-options.mjs").cacheStrategyType} cacheStrategyType
|
|
16
|
+
* @import { IRevisionData, ICruiseResult } from "../../types/dependency-cruiser.mjs";
|
|
17
|
+
* @import { IStrictCruiseOptions } from "../../types/strict-options.mjs";
|
|
18
|
+
* @import { cacheStrategyType } from "../../types/cache-options.mjs";
|
|
20
19
|
*/
|
|
21
20
|
|
|
22
21
|
const CACHE_FILE_NAME = "cache.json";
|
|
@@ -10,11 +10,9 @@ import {
|
|
|
10
10
|
} from "./helpers.mjs";
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
|
-
* @
|
|
14
|
-
* @
|
|
15
|
-
* @
|
|
16
|
-
* @typedef {import("../../types/dependency-cruiser.mjs").ICruiseResult} ICruiseResult
|
|
17
|
-
* @typedef {import("../../types/strict-options.mjs").IStrictCruiseOptions} IStrictCruiseOptions
|
|
13
|
+
* @import { IModule, IRevisionChange, IRevisionData, ICruiseResult } from "../../types/dependency-cruiser.mjs"
|
|
14
|
+
* @import { IStrictCruiseOptions } from "../../types/strict-options.mjs"
|
|
15
|
+
* @import { changeType, getSHA } from "watskeburt"
|
|
18
16
|
*/
|
|
19
17
|
|
|
20
18
|
/**
|
|
@@ -56,10 +54,10 @@ export default class ContentStrategy {
|
|
|
56
54
|
* @param {IStrictCruiseOptions} pCruiseOptions
|
|
57
55
|
* @param {Object} pOptions
|
|
58
56
|
* @param {Set<string>} pOptions.extensions
|
|
59
|
-
* @param {Set<
|
|
57
|
+
* @param {Set<changeType>=} pOptions.interestingChangeTypes?
|
|
60
58
|
* @param {string=} pOptions.baseDir
|
|
61
59
|
* @param {typeof findContentChanges=} pOptions.diffListFn
|
|
62
|
-
* @param {typeof
|
|
60
|
+
* @param {typeof getSHA=} pOptions.checksumFn
|
|
63
61
|
* @returns {IRevisionData}
|
|
64
62
|
*/
|
|
65
63
|
getRevisionData(pDirectory, pCachedCruiseResult, pCruiseOptions, pOptions) {
|
|
@@ -11,10 +11,16 @@ import {
|
|
|
11
11
|
import { bus } from "#utl/bus.mjs";
|
|
12
12
|
import findAllFiles from "#utl/find-all-files.mjs";
|
|
13
13
|
|
|
14
|
+
/**
|
|
15
|
+
* @import { IModule, IRevisionChange } from "../../types/dependency-cruiser.mjs"
|
|
16
|
+
* @import { ICruiseResult } from "../../types/cruise-result.mjs"
|
|
17
|
+
* @import { IStrictExcludeType, IStrictIncludeOnlyType } from "../../types/strict-filter-types.mjs"
|
|
18
|
+
*/
|
|
19
|
+
|
|
14
20
|
/**
|
|
15
21
|
* @param {Set<string>} pFileSet
|
|
16
22
|
* @param {typeof getFileHashSync} pFileHashFunction
|
|
17
|
-
* @returns {(pModule:
|
|
23
|
+
* @returns {(pModule:IModule) => IRevisionChange}
|
|
18
24
|
*/
|
|
19
25
|
function diffCachedModuleAgainstFileSet(
|
|
20
26
|
pFileSet,
|
|
@@ -63,13 +69,13 @@ function diffCachedModuleAgainstFileSet(
|
|
|
63
69
|
- there is a cache, but it doesn't contain checksums => same as before, except
|
|
64
70
|
all files will be marked as 'modified'
|
|
65
71
|
* @param {string} pDirectory
|
|
66
|
-
* @param {
|
|
72
|
+
* @param {ICruiseResult} pCachedCruiseResult
|
|
67
73
|
* @param {Object} pOptions
|
|
68
74
|
* @param {Set<string>} pOptions.extensions
|
|
69
75
|
* @param {string} pOptions.baseDir
|
|
70
|
-
* @param {
|
|
71
|
-
* @param {
|
|
72
|
-
* @returns {
|
|
76
|
+
* @param {IStrictExcludeType} pOptions.exclude
|
|
77
|
+
* @param {IStrictIncludeOnlyType=} pOptions.includeOnly
|
|
78
|
+
* @returns {IRevisionChange[]}
|
|
73
79
|
*/
|
|
74
80
|
export default function findContentChanges(
|
|
75
81
|
pDirectory,
|
package/src/cache/helpers.mjs
CHANGED
|
@@ -6,10 +6,10 @@ import memoize from "memoize";
|
|
|
6
6
|
import { filenameMatchesPattern } from "#graph-utl/match-facade.mjs";
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
|
-
* @
|
|
10
|
-
* @
|
|
11
|
-
* @
|
|
12
|
-
* @
|
|
9
|
+
* @import { IModule, IRevisionChange, } from "../../types/dependency-cruiser.mjs"
|
|
10
|
+
* @import { IExcludeType } from "../../types/filter-types.mjs"
|
|
11
|
+
* @import { IStrictIncludeOnlyType } from "../../types/strict-filter-types.mjs"
|
|
12
|
+
* @import { changeType, IChange } from "watskeburt"
|
|
13
13
|
*/
|
|
14
14
|
|
|
15
15
|
/**
|
|
@@ -35,7 +35,7 @@ function _getFileHashSync(pFileName) {
|
|
|
35
35
|
export const getFileHashSync = memoize(_getFileHashSync);
|
|
36
36
|
|
|
37
37
|
/**
|
|
38
|
-
* @param {
|
|
38
|
+
* @param {IChange} pChange
|
|
39
39
|
* @return {IRevisionChange}
|
|
40
40
|
*/
|
|
41
41
|
export function addCheckSumToChangeSync(pChange) {
|
|
@@ -80,7 +80,7 @@ export function hasInterestingExtension(pExtensions) {
|
|
|
80
80
|
|
|
81
81
|
/**
|
|
82
82
|
* @param {Set<string>} pExtensions
|
|
83
|
-
* @returns {(pChange:
|
|
83
|
+
* @returns {(pChange: IChange) => boolean}
|
|
84
84
|
*/
|
|
85
85
|
export function changeHasInterestingExtension(pExtensions) {
|
|
86
86
|
return (pChange) => {
|
|
@@ -106,8 +106,8 @@ const DEFAULT_INTERESTING_CHANGE_TYPES = new Set([
|
|
|
106
106
|
]);
|
|
107
107
|
|
|
108
108
|
/**
|
|
109
|
-
* @param {Set<
|
|
110
|
-
* @returns {(pChange:
|
|
109
|
+
* @param {Set<changeType>=} pInterestingChangeTypes
|
|
110
|
+
* @returns {(pChange: IChange) => boolean}
|
|
111
111
|
*/
|
|
112
112
|
export function isInterestingChangeType(pInterestingChangeTypes) {
|
|
113
113
|
return (pChange) =>
|
|
@@ -12,20 +12,18 @@ import {
|
|
|
12
12
|
import { bus } from "#utl/bus.mjs";
|
|
13
13
|
|
|
14
14
|
/**
|
|
15
|
-
* @
|
|
16
|
-
* @
|
|
17
|
-
* @
|
|
18
|
-
* @typedef {import("../../types/dependency-cruiser.mjs").ICruiseResult} ICruiseResult
|
|
19
|
-
* @typedef {import("../../types/strict-options.mjs").IStrictCruiseOptions} IStrictCruiseOptions
|
|
15
|
+
* @import {IModule, IRevisionChange, IRevisionData, ICruiseResult } from "../../types/dependency-cruiser.mjs"
|
|
16
|
+
* @import { IStrictCruiseOptions } from "../../types/strict-options.mjs"
|
|
17
|
+
* @import { changeType, IChange } from "watskeburt"
|
|
20
18
|
*/
|
|
21
19
|
|
|
22
20
|
export default class MetaDataStrategy {
|
|
23
21
|
/**
|
|
24
22
|
* @param {string} _pDirectory
|
|
25
|
-
* @param {
|
|
23
|
+
* @param {ICruiseResult} _pCachedCruiseResult
|
|
26
24
|
* @param {Object} pOptions
|
|
27
25
|
* @param {Set<string>} pOptions.extensions
|
|
28
|
-
* @param {Set<
|
|
26
|
+
* @param {Set<changeType>=} pOptions.interestingChangeTypes
|
|
29
27
|
* @param {typeof getSHA=} pOptions.shaRetrievalFn
|
|
30
28
|
* @param {typeof list=} pOptions.diffListFn
|
|
31
29
|
* @param {typeof addCheckSumToChangeSync=} pOptions.checksumFn
|
|
@@ -47,7 +45,7 @@ export default class MetaDataStrategy {
|
|
|
47
45
|
bus.debug("cache: - getting sha");
|
|
48
46
|
const lSHA = await lOptions.shaRetrievalFn();
|
|
49
47
|
bus.debug("cache: - getting diff");
|
|
50
|
-
const lDiff = /** @type {
|
|
48
|
+
const lDiff = /** @type {IChange[]} */ (
|
|
51
49
|
await lOptions.diffListFn({ oldRevision: lSHA })
|
|
52
50
|
);
|
|
53
51
|
const lChanges = lDiff
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { isDeepStrictEqual } from "node:util";
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
|
-
* @
|
|
5
|
+
* @import { IStrictCruiseOptions } from "../../types/strict-options.mjs"
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
/*
|
|
@@ -105,6 +105,7 @@ export function optionsAreCompatible(pOldOptions, pNewOptions) {
|
|
|
105
105
|
pOldOptions.preserveSymlinks === pNewOptions.preserveSymlinks &&
|
|
106
106
|
pOldOptions.combinedDependencies === pNewOptions.combinedDependencies &&
|
|
107
107
|
pOldOptions.experimentalStats === pNewOptions.experimentalStats &&
|
|
108
|
+
pOldOptions.detectJSDocImports === pNewOptions.detectJSDocImports &&
|
|
108
109
|
metricsIsCompatible(pOldOptions.metrics, pNewOptions.metrics) &&
|
|
109
110
|
// includeOnly suffers from a backwards compatibility disease
|
|
110
111
|
includeOnlyIsCompatible(pOldOptions.includeOnly, pNewOptions.includeOnly) &&
|
|
@@ -2,6 +2,10 @@
|
|
|
2
2
|
import { folderNameArrayToRE } from "./utl.mjs";
|
|
3
3
|
import configTemplate from "./config-template.mjs";
|
|
4
4
|
|
|
5
|
+
/**
|
|
6
|
+
* @import { IInitConfig } from "./types.js";
|
|
7
|
+
*/
|
|
8
|
+
|
|
5
9
|
/**
|
|
6
10
|
* @param {string} pString
|
|
7
11
|
* @returns {string}
|
|
@@ -22,7 +26,7 @@ function extensionsToString(pExtensions) {
|
|
|
22
26
|
}
|
|
23
27
|
|
|
24
28
|
/**
|
|
25
|
-
* @param {
|
|
29
|
+
* @param {IInitConfig} pInitOptions
|
|
26
30
|
* @returns {string}
|
|
27
31
|
*/
|
|
28
32
|
function buildNotToTestRule(pInitOptions) {
|
|
@@ -49,7 +53,7 @@ function buildNotToTestRule(pInitOptions) {
|
|
|
49
53
|
}
|
|
50
54
|
|
|
51
55
|
/**
|
|
52
|
-
* @param {
|
|
56
|
+
* @param {IInitConfig} pInitOptions
|
|
53
57
|
* @returns {string}
|
|
54
58
|
*/
|
|
55
59
|
function buildTsPreCompilationDepsAttribute(pInitOptions) {
|
|
@@ -59,7 +63,7 @@ function buildTsPreCompilationDepsAttribute(pInitOptions) {
|
|
|
59
63
|
}
|
|
60
64
|
|
|
61
65
|
/**
|
|
62
|
-
* @param {
|
|
66
|
+
* @param {IInitConfig} pInitOptions
|
|
63
67
|
* @returns {string}
|
|
64
68
|
*/
|
|
65
69
|
function buildCombinedDependenciesAttribute(pInitOptions) {
|
|
@@ -69,7 +73,7 @@ function buildCombinedDependenciesAttribute(pInitOptions) {
|
|
|
69
73
|
}
|
|
70
74
|
|
|
71
75
|
/**
|
|
72
|
-
* @param {
|
|
76
|
+
* @param {IInitConfig} pInitOptions
|
|
73
77
|
* @returns {string}
|
|
74
78
|
*/
|
|
75
79
|
function buildTsOrJsConfigAttribute(pInitOptions) {
|
|
@@ -89,7 +93,7 @@ function buildTsOrJsConfigAttribute(pInitOptions) {
|
|
|
89
93
|
}
|
|
90
94
|
|
|
91
95
|
/**
|
|
92
|
-
* @param {
|
|
96
|
+
* @param {IInitConfig} pInitOptions
|
|
93
97
|
* @returns {string}
|
|
94
98
|
*/
|
|
95
99
|
function buildWebpackConfigAttribute(pInitOptions) {
|
|
@@ -107,7 +111,7 @@ function buildWebpackConfigAttribute(pInitOptions) {
|
|
|
107
111
|
}
|
|
108
112
|
|
|
109
113
|
/**
|
|
110
|
-
* @param {
|
|
114
|
+
* @param {IInitConfig} pInitOptions
|
|
111
115
|
* @returns {string}
|
|
112
116
|
*/
|
|
113
117
|
function buildBabelConfigAttribute(pInitOptions) {
|
|
@@ -121,7 +125,7 @@ function buildBabelConfigAttribute(pInitOptions) {
|
|
|
121
125
|
}
|
|
122
126
|
|
|
123
127
|
/**
|
|
124
|
-
* @param {
|
|
128
|
+
* @param {IInitConfig} pInitOptions
|
|
125
129
|
* @returns {string}
|
|
126
130
|
*/
|
|
127
131
|
function buildExtensionsAttribute(pInitOptions) {
|
|
@@ -131,7 +135,7 @@ function buildExtensionsAttribute(pInitOptions) {
|
|
|
131
135
|
}
|
|
132
136
|
|
|
133
137
|
/**
|
|
134
|
-
* @param {
|
|
138
|
+
* @param {IInitConfig} pInitOptions
|
|
135
139
|
* @returns {string}
|
|
136
140
|
*/
|
|
137
141
|
function buildMainFieldsAttribute(pInitOptions) {
|
|
@@ -149,7 +153,7 @@ function buildMainFieldsAttribute(pInitOptions) {
|
|
|
149
153
|
* Creates a .dependency-cruiser config with a set of basic validations
|
|
150
154
|
* to the current directory.
|
|
151
155
|
*
|
|
152
|
-
* @param {
|
|
156
|
+
* @param {IInitConfig} pInitOptions ('Normalized') options that influence the shape of
|
|
153
157
|
* the configuration
|
|
154
158
|
* @returns {string} the configuration as a string
|
|
155
159
|
*/
|
|
@@ -228,6 +228,17 @@ module.exports = {
|
|
|
228
228
|
|
|
229
229
|
// moduleSystems: ['cjs', 'es6'],
|
|
230
230
|
|
|
231
|
+
/*
|
|
232
|
+
false: don't look at JSDoc imports
|
|
233
|
+
true: dependency-cruiser will detect dependencies in JSDoc-style
|
|
234
|
+
import statements. Implies "parser": "tsc", so the dependency-cruiser
|
|
235
|
+
will use the typescript parser for JavaScript files.
|
|
236
|
+
|
|
237
|
+
For this to work the typescript compiler will need to be installed in the
|
|
238
|
+
same spot as you're running dependency-cruiser from.
|
|
239
|
+
*/
|
|
240
|
+
// detectJSDocImports: true,
|
|
241
|
+
|
|
231
242
|
/* prefix for links in html and svg output (e.g. 'https://github.com/you/yourrepo/blob/main/'
|
|
232
243
|
to open it on your online repo or \`vscode://file/$\{process.cwd()}/\` to
|
|
233
244
|
open it in visual studio code),
|
|
@@ -20,17 +20,21 @@ import {
|
|
|
20
20
|
} from "./environment-helpers.mjs";
|
|
21
21
|
import { writeRunScriptsToManifest } from "./write-run-scripts-to-manifest.mjs";
|
|
22
22
|
|
|
23
|
+
/**
|
|
24
|
+
* @import { IInitConfig, IPartialInitConfig, OneShotConfigIDType } from "./types.js";
|
|
25
|
+
*/
|
|
26
|
+
|
|
23
27
|
const PACKAGE_MANIFEST = `./${_PACKAGE_MANIFEST}`;
|
|
24
28
|
|
|
25
29
|
/**
|
|
26
30
|
* Create a initialization configuration based on guessed defaults
|
|
27
31
|
* (e.g. a tsconfig exists => use it and assume typescript is used)
|
|
28
32
|
*
|
|
29
|
-
* @param {
|
|
30
|
-
* @return {
|
|
33
|
+
* @param {OneShotConfigIDType} pOneShotConfigId
|
|
34
|
+
* @return {IPartialInitConfig} an initialization configuration
|
|
31
35
|
*/
|
|
32
36
|
function getOneShotConfig(pOneShotConfigId) {
|
|
33
|
-
/** @type {
|
|
37
|
+
/** @type {IPartialInitConfig} */
|
|
34
38
|
const lBaseConfig = {
|
|
35
39
|
isMonoRepo: isLikelyMonoRepo(),
|
|
36
40
|
isTypeModule: isTypeModule(),
|
|
@@ -46,7 +50,7 @@ function getOneShotConfig(pOneShotConfigId) {
|
|
|
46
50
|
babelConfig: getBabelConfigCandidates().shift(),
|
|
47
51
|
specifyResolutionExtensions: true,
|
|
48
52
|
};
|
|
49
|
-
/** @type {Map<
|
|
53
|
+
/** @type {Map<OneShotConfigIDType, IPartialInitConfig>} */
|
|
50
54
|
const lOneShotConfigs = new Map([
|
|
51
55
|
["yes", lBaseConfig],
|
|
52
56
|
[
|
|
@@ -63,7 +67,7 @@ function getOneShotConfig(pOneShotConfigId) {
|
|
|
63
67
|
|
|
64
68
|
/**
|
|
65
69
|
*
|
|
66
|
-
* @param {
|
|
70
|
+
* @param {IInitConfig} pNormalizedInitConfig
|
|
67
71
|
*/
|
|
68
72
|
function manifestIsUpdatable(pNormalizedInitConfig) {
|
|
69
73
|
return (
|
|
@@ -73,7 +77,7 @@ function manifestIsUpdatable(pNormalizedInitConfig) {
|
|
|
73
77
|
}
|
|
74
78
|
|
|
75
79
|
/**
|
|
76
|
-
* @param {boolean|
|
|
80
|
+
* @param {boolean|OneShotConfigIDType} pInit
|
|
77
81
|
* @param {string=} pConfigFileName
|
|
78
82
|
* @param {{stdout: NodeJS.WritableStream, stderr: NodeJS.WritableStream}=} pStreams
|
|
79
83
|
*/
|
|
@@ -8,7 +8,11 @@ import findExtensions from "./find-extensions.mjs";
|
|
|
8
8
|
import meta from "#meta.cjs";
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
|
-
* @
|
|
11
|
+
* @import { IInitConfig, IPartialInitConfig } from "./types.js";
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* @param {IInitConfig} pInitOptions
|
|
12
16
|
* @param {string[]} pExtensions
|
|
13
17
|
* @returns {boolean}
|
|
14
18
|
*/
|
|
@@ -25,7 +29,7 @@ function usesTypeScript(pInitOptions, pExtensions) {
|
|
|
25
29
|
}
|
|
26
30
|
|
|
27
31
|
/**
|
|
28
|
-
* @param {
|
|
32
|
+
* @param {IInitConfig} pInitOptions
|
|
29
33
|
* @returns {string[]}
|
|
30
34
|
*/
|
|
31
35
|
function getExtensions(pInitOptions) {
|
|
@@ -38,8 +42,8 @@ function getExtensions(pInitOptions) {
|
|
|
38
42
|
}
|
|
39
43
|
|
|
40
44
|
/**
|
|
41
|
-
* @param {
|
|
42
|
-
* @return {
|
|
45
|
+
* @param {IPartialInitConfig} pInitOptions
|
|
46
|
+
* @return {IPartialInitConfig}
|
|
43
47
|
*/
|
|
44
48
|
function populate(pInitOptions) {
|
|
45
49
|
const lReturnValue = {
|
|
@@ -66,8 +70,8 @@ function populate(pInitOptions) {
|
|
|
66
70
|
|
|
67
71
|
/**
|
|
68
72
|
*
|
|
69
|
-
* @param {
|
|
70
|
-
* @return {
|
|
73
|
+
* @param {IPartialInitConfig} pInitOptions
|
|
74
|
+
* @return {IInitConfig}
|
|
71
75
|
*/
|
|
72
76
|
export default function normalizeInitOptions(pInitOptions) {
|
|
73
77
|
let lReturnValue = populate(pInitOptions);
|
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
import extractDepcruiseConfig from "./extract-depcruise-config/index.mjs";
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
5
|
-
* @
|
|
6
|
-
|
|
4
|
+
* @import { IConfiguration } from "../../types/configuration.mjs";
|
|
5
|
+
* @import { ICruiseOptions } from "../../types/options.mjs";
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* @param {IConfiguration} pConfiguration
|
|
10
|
+
* @returns {ICruiseOptions}
|
|
7
11
|
*/
|
|
8
12
|
function configuration2options(pConfiguration) {
|
|
9
13
|
/* c8 ignore next 1 */
|
|
@@ -20,7 +24,7 @@ function configuration2options(pConfiguration) {
|
|
|
20
24
|
/**
|
|
21
25
|
*
|
|
22
26
|
* @param {string} pConfigFileName
|
|
23
|
-
* @returns {Promise<
|
|
27
|
+
* @returns {Promise<ICruiseOptions>}
|
|
24
28
|
*/
|
|
25
29
|
export default async function extractDepcruiseOptions(pConfigFileName) {
|
|
26
30
|
const lReturnValue = await extractDepcruiseConfig(pConfigFileName);
|
|
@@ -3,8 +3,8 @@ import json5 from "json5";
|
|
|
3
3
|
import makeAbsolute from "./make-absolute.mjs";
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
|
-
* @
|
|
7
|
-
* @
|
|
6
|
+
* @import { IViolation } from "../../types/violations.mjs"
|
|
7
|
+
* @import { DependencyType } from "../../types/shared-types.mjs"
|
|
8
8
|
*
|
|
9
9
|
* @typedef {IViolation & {cycle: Array<{name: string, dependencyTypes: Array<DependencyType>}>} | {cycle: Array<DependencyType>}} IMaybeOldFormatViolation
|
|
10
10
|
*/
|
|
@@ -4,6 +4,7 @@ const SHAREABLE_OPTIONS = [
|
|
|
4
4
|
"cache",
|
|
5
5
|
"collapse",
|
|
6
6
|
"combinedDependencies",
|
|
7
|
+
"detectJSDocImports",
|
|
7
8
|
"doNotFollow",
|
|
8
9
|
"enhancedResolveOptions",
|
|
9
10
|
"exclude",
|
|
@@ -20,6 +21,7 @@ const SHAREABLE_OPTIONS = [
|
|
|
20
21
|
"moduleSystems",
|
|
21
22
|
"outputTo",
|
|
22
23
|
"outputType",
|
|
24
|
+
"parser",
|
|
23
25
|
"prefix",
|
|
24
26
|
"preserveSymlinks",
|
|
25
27
|
"reaches",
|
|
@@ -15,6 +15,11 @@ import {
|
|
|
15
15
|
} from "./helpers.mjs";
|
|
16
16
|
import { uniqBy, intersects } from "#utl/array-util.mjs";
|
|
17
17
|
|
|
18
|
+
/**
|
|
19
|
+
* @import { IDependency } from "../../types/cruise-result.mjs";
|
|
20
|
+
* @import { IResolveOptions, IStrictCruiseOptions, ITranspileOptions } from "../../types/dependency-cruiser.mjs";
|
|
21
|
+
*/
|
|
22
|
+
|
|
18
23
|
function extractWithTsc(pCruiseOptions, pFileName, pTranspileOptions) {
|
|
19
24
|
let lDependencies = tscExtract(pCruiseOptions, pFileName, pTranspileOptions);
|
|
20
25
|
|
|
@@ -30,7 +35,7 @@ function extractWithTsc(pCruiseOptions, pFileName, pTranspileOptions) {
|
|
|
30
35
|
/**
|
|
31
36
|
* @param {IStrictCruiseOptions} pCruiseOptions
|
|
32
37
|
* @param {string} pFileName
|
|
33
|
-
* @returns {(IStrictCruiseOptions, string, any) =>
|
|
38
|
+
* @returns {(IStrictCruiseOptions, string, any) => IDependency[]}
|
|
34
39
|
*/
|
|
35
40
|
function determineExtractionFunction(pCruiseOptions, pFileName) {
|
|
36
41
|
let lExtractionFunction = acornExtract;
|
|
@@ -45,13 +50,13 @@ function determineExtractionFunction(pCruiseOptions, pFileName) {
|
|
|
45
50
|
}
|
|
46
51
|
|
|
47
52
|
/**
|
|
48
|
-
* @param {
|
|
53
|
+
* @param {IStrictCruiseOptions} pCruiseOptions
|
|
49
54
|
* @param {string} pFileName
|
|
50
55
|
* @param {any} pTranspileOptions
|
|
51
|
-
* @returns {
|
|
56
|
+
* @returns {IDependency[]}
|
|
52
57
|
*/
|
|
53
58
|
function extractDependencies(pCruiseOptions, pFileName, pTranspileOptions) {
|
|
54
|
-
/** @type
|
|
59
|
+
/** @type IDependency[] */
|
|
55
60
|
let lDependencies = [];
|
|
56
61
|
|
|
57
62
|
if (!pCruiseOptions.extraExtensionsToScan.includes(extname(pFileName))) {
|
|
@@ -114,7 +119,7 @@ function matchesPattern(pFullPathToFile, pPattern) {
|
|
|
114
119
|
|
|
115
120
|
/**
|
|
116
121
|
*
|
|
117
|
-
* @param {
|
|
122
|
+
* @param {IDependency} pDependency
|
|
118
123
|
* @returns {string}
|
|
119
124
|
*/
|
|
120
125
|
function getDependencyUniqueKey({ module, moduleSystem, dependencyTypes }) {
|
|
@@ -143,12 +148,12 @@ function compareDeps(pLeft, pRight) {
|
|
|
143
148
|
*
|
|
144
149
|
*
|
|
145
150
|
* @param {string} pFileName path to the file
|
|
146
|
-
* @param {
|
|
147
|
-
* @param {
|
|
148
|
-
* @param {
|
|
151
|
+
* @param {IStrictCruiseOptions} pCruiseOptions cruise options
|
|
152
|
+
* @param {IResolveOptions} pResolveOptions webpack 'enhanced-resolve' options
|
|
153
|
+
* @param {ITranspileOptions} pTranspileOptions an object with tsconfig ('typescript project') options
|
|
149
154
|
* ('flattened' so there's no need for file access on any
|
|
150
155
|
* 'extends' option in there)
|
|
151
|
-
* @return {
|
|
156
|
+
* @return {IDependency[]} an array of dependency objects (see above)
|
|
152
157
|
*/
|
|
153
158
|
export default function getDependencies(
|
|
154
159
|
pFileName,
|
|
@@ -4,10 +4,15 @@ import {
|
|
|
4
4
|
} from "./tsc/extract.mjs";
|
|
5
5
|
import { getStats as acornStats } from "./acorn/extract.mjs";
|
|
6
6
|
|
|
7
|
+
/**
|
|
8
|
+
* @import { IStrictCruiseOptions, ITranspileOptions } from "../../types/dependency-cruiser.mjs";
|
|
9
|
+
* @import { IDependency } from "../../types/cruise-result.mjs";
|
|
10
|
+
*/
|
|
11
|
+
|
|
7
12
|
/**
|
|
8
13
|
* @param {IStrictCruiseOptions} pCruiseOptions
|
|
9
14
|
* @param {string} pFileName
|
|
10
|
-
* @returns {(IStrictCruiseOptions, string, any) =>
|
|
15
|
+
* @returns {(IStrictCruiseOptions, string, any) => IDependency[]}
|
|
11
16
|
*/
|
|
12
17
|
function determineExtractionFunction(pCruiseOptions, pFileName) {
|
|
13
18
|
let lExtractionFunction = acornStats;
|
|
@@ -23,11 +28,11 @@ function determineExtractionFunction(pCruiseOptions, pFileName) {
|
|
|
23
28
|
* Returns some stats for the module in pFileName
|
|
24
29
|
*
|
|
25
30
|
* @param {string} pFileName path to the file
|
|
26
|
-
* @param {
|
|
27
|
-
* @param {
|
|
31
|
+
* @param {IStrictCruiseOptions} pCruiseOptions cruise options
|
|
32
|
+
* @param {ITranspileOptions} pTranspileOptions an object with tsconfig ('typescript project') options
|
|
28
33
|
* ('flattened' so there's no need for file access on any
|
|
29
34
|
* 'extends' option in there)
|
|
30
|
-
* @return {
|
|
35
|
+
* @return {IDependency[]} an array of dependency objects (see above)
|
|
31
36
|
*/
|
|
32
37
|
export default function extractStats(
|
|
33
38
|
pFileName,
|
|
@@ -8,8 +8,11 @@ import getExtension from "#utl/get-extension.mjs";
|
|
|
8
8
|
import pathToPosix from "#utl/path-to-posix.mjs";
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
|
-
*
|
|
12
|
-
|
|
11
|
+
* @import {IStrictCruiseOptions} from "../../types/options.mjs";
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* @param {IStrictCruiseOptions} pOptions
|
|
13
16
|
* @returns {string[]}
|
|
14
17
|
*/
|
|
15
18
|
function getScannableExtensions(pOptions) {
|
|
@@ -37,9 +40,8 @@ function shouldNotBeExcluded(pFullPathToFile, pOptions) {
|
|
|
37
40
|
}
|
|
38
41
|
|
|
39
42
|
/**
|
|
40
|
-
*
|
|
41
43
|
* @param {string} pDirectoryName
|
|
42
|
-
* @param
|
|
44
|
+
* @param {IStrictCruiseOptions} pOptions options that
|
|
43
45
|
* @returns {string[]}
|
|
44
46
|
*/
|
|
45
47
|
function gatherScannableFilesFromDirectory(pDirectoryName, pOptions) {
|
|
@@ -90,7 +92,7 @@ function expandGlob(pBaseDirectory, pScannedGlob) {
|
|
|
90
92
|
*
|
|
91
93
|
* @param {string[]} pFileDirectoryAndGlobArray globs and/ or paths to files or
|
|
92
94
|
* directories to be gathered
|
|
93
|
-
* @param {
|
|
95
|
+
* @param {IStrictCruiseOptions} pOptions options that
|
|
94
96
|
* influence what needs to be gathered/ scanned
|
|
95
97
|
* notably useful attributes:
|
|
96
98
|
* - exclude - regexp of what to exclude
|
package/src/extract/index.mjs
CHANGED
|
@@ -4,6 +4,11 @@ import gatherInitialSources from "./gather-initial-sources.mjs";
|
|
|
4
4
|
import clearCaches from "./clear-caches.mjs";
|
|
5
5
|
import { bus } from "#utl/bus.mjs";
|
|
6
6
|
|
|
7
|
+
/**
|
|
8
|
+
* @import {IStrictCruiseOptions} from "../../types/options.mjs";
|
|
9
|
+
* @import { IModule, IResolveOptions, ITranspileOptions } from "../../types/dependency-cruiser.mjs";
|
|
10
|
+
*/
|
|
11
|
+
|
|
7
12
|
/* eslint max-params:0 , max-lines-per-function:0*/
|
|
8
13
|
function extractRecursive(
|
|
9
14
|
pFileName,
|
|
@@ -142,10 +147,10 @@ function filterExcludedDynamicDependencies(pModule, pExclude) {
|
|
|
142
147
|
* returns an array of all the modules it finds that way.
|
|
143
148
|
*
|
|
144
149
|
* @param {string[]} pFileDirectoryArray
|
|
145
|
-
* @param {
|
|
146
|
-
* @param {
|
|
147
|
-
* @param {
|
|
148
|
-
* @returns {Partial<
|
|
150
|
+
* @param {IStrictCruiseOptions} pCruiseOptions
|
|
151
|
+
* @param {IResolveOptions} pResolveOptions
|
|
152
|
+
* @param {ITranspileOptions} pTranspileOptions
|
|
153
|
+
* @returns {Partial<IModule[]>}
|
|
149
154
|
*/
|
|
150
155
|
export default function extract(
|
|
151
156
|
pFileDirectoryArray,
|