dependency-cruiser 12.1.0 → 12.2.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/README.md +1 -1
- package/configs/plugins/3d-reporter-plugin.js +3 -3
- package/configs/plugins/stats-reporter-plugin.js +3 -3
- package/package.json +26 -29
- package/src/cache/cache.js +4 -4
- package/src/cache/revision-data.js +13 -6
- package/src/cache/utl.js +1 -0
- package/src/cli/format.js +2 -2
- package/src/cli/index.js +9 -10
- package/src/cli/init-config/build-config.js +2 -2
- package/src/cli/init-config/environment-helpers.js +6 -3
- package/src/cli/init-config/get-user-input.js +2 -2
- package/src/cli/init-config/index.js +15 -8
- package/src/cli/init-config/{inquirer-validators.js → validators.js} +1 -9
- package/src/cli/init-config/write-config.js +1 -1
- package/src/cli/listeners/performance-log/format-helpers.js +75 -15
- package/src/cli/listeners/performance-log/handlers.js +32 -14
- package/src/cli/listeners/performance-log/index.js +6 -0
- package/src/config-utl/extract-depcruise-config/index.js +12 -9
- package/src/config-utl/extract-depcruise-config/read-config.js +1 -1
- package/src/config-utl/extract-webpack-resolve-config.js +1 -2
- package/src/config-utl/make-absolute.js +1 -1
- package/src/enrich/add-validations.js +1 -1
- package/src/enrich/derive/circular/get-cycle.js +3 -4
- package/src/enrich/derive/folders/index.js +3 -3
- package/src/enrich/derive/orphan/index.js +3 -2
- package/src/enrich/derive/orphan/is-orphan.js +1 -1
- package/src/enrich/derive/reachable/index.js +1 -1
- package/src/enrich/index.js +3 -3
- package/src/enrich/summarize/index.js +1 -1
- package/src/extract/ast-extractors/swc-dependency-visitor.js +1 -1
- package/src/extract/gather-initial-sources.js +1 -1
- package/src/extract/get-dependencies.js +14 -21
- package/src/extract/index.js +4 -4
- package/src/extract/resolve/determine-dependency-types.js +6 -6
- package/src/extract/resolve/index.js +2 -2
- package/src/graph-utl/add-focus.js +1 -1
- package/src/graph-utl/consolidate-module-dependencies.js +6 -4
- package/src/graph-utl/consolidate-modules.js +1 -1
- package/src/graph-utl/consolidate-to-folder.js +3 -2
- package/src/graph-utl/rule-set.js +3 -3
- package/src/main/index.js +4 -4
- package/src/main/options/normalize.js +6 -6
- package/src/main/options/validate.js +2 -2
- package/src/main/report-wrap.js +6 -6
- package/src/main/resolve-options/normalize.js +4 -4
- package/src/main/rule-set/normalize.js +1 -1
- package/src/meta.js +1 -1
- package/src/report/anon/index.js +1 -1
- package/src/report/baseline.js +12 -10
- package/src/report/csv.js +7 -5
- package/src/report/dot/index.js +12 -10
- package/src/report/dot/module-utl.js +2 -2
- package/src/report/dot/prepare-custom-level.js +6 -1
- package/src/report/dot/prepare-flat-level.js +1 -1
- package/src/report/dot/prepare-folder-level.js +6 -1
- package/src/report/error-html/index.js +7 -5
- package/src/report/error-html/utl.js +5 -5
- package/src/report/error.js +10 -8
- package/src/report/html/index.js +7 -5
- package/src/report/identity.js +7 -5
- package/src/report/json.js +7 -5
- package/src/report/markdown.js +9 -7
- package/src/report/mermaid.js +14 -11
- package/src/report/metrics.js +7 -8
- package/src/report/{plugins/index.js → plugins.js} +5 -2
- package/src/report/teamcity.js +5 -5
- package/src/report/text.js +7 -5
- package/src/report/utl/dependency-to-incidence-transformer.js +3 -2
- package/src/report/utl/index.js +4 -5
- package/src/validate/match-dependency-rule.js +2 -2
- package/types/README.md +1 -0
- package/types/init-config.d.ts +8 -11
|
@@ -1,9 +1,13 @@
|
|
|
1
|
-
const
|
|
2
|
-
|
|
1
|
+
const {
|
|
2
|
+
formatTime,
|
|
3
|
+
formatPerfLine,
|
|
4
|
+
formatHeader,
|
|
5
|
+
formatMemory,
|
|
6
|
+
} = require("./format-helpers");
|
|
3
7
|
|
|
4
8
|
function getHeader(pLevel, pMaxLevel) {
|
|
5
9
|
if (pLevel <= pMaxLevel) {
|
|
6
|
-
return
|
|
10
|
+
return formatHeader();
|
|
7
11
|
}
|
|
8
12
|
return "";
|
|
9
13
|
}
|
|
@@ -13,14 +17,29 @@ function getProgressLine(pMessage, pState, pLevel, pMaxLevel) {
|
|
|
13
17
|
|
|
14
18
|
if (pLevel <= pMaxLevel) {
|
|
15
19
|
const lTime = process.uptime();
|
|
20
|
+
const { user, system } = process.cpuUsage();
|
|
21
|
+
const { rss, heapTotal, heapUsed, external } = process.memoryUsage();
|
|
22
|
+
const lStats = {
|
|
23
|
+
elapsedTime: lTime - pState.previousTime,
|
|
24
|
+
elapsedUser: user - pState.previousUserUsage,
|
|
25
|
+
elapsedSystem: system - pState.previousSystemUsage,
|
|
26
|
+
deltaRss: rss - pState.previousRss,
|
|
27
|
+
deltaHeapUsed: heapUsed - pState.previousHeapUsed,
|
|
28
|
+
deltaHeapTotal: heapTotal - pState.previousHeapTotal,
|
|
29
|
+
deltaExternal: external - pState.previousExternal,
|
|
30
|
+
message: pState.previousMessage,
|
|
31
|
+
};
|
|
16
32
|
|
|
17
|
-
lReturnValue = formatPerfLine(
|
|
18
|
-
lTime,
|
|
19
|
-
pState.previousTime,
|
|
20
|
-
pState.previousMessage
|
|
21
|
-
);
|
|
22
33
|
pState.previousMessage = pMessage;
|
|
23
34
|
pState.previousTime = lTime;
|
|
35
|
+
pState.previousUserUsage = user;
|
|
36
|
+
pState.previousSystemUsage = system;
|
|
37
|
+
pState.previousRss = rss;
|
|
38
|
+
pState.previousHeapTotal = heapTotal;
|
|
39
|
+
pState.previousHeapUsed = heapUsed;
|
|
40
|
+
pState.previousExternal = external;
|
|
41
|
+
|
|
42
|
+
lReturnValue = formatPerfLine(lStats);
|
|
24
43
|
}
|
|
25
44
|
return lReturnValue;
|
|
26
45
|
}
|
|
@@ -28,12 +47,11 @@ function getProgressLine(pMessage, pState, pLevel, pMaxLevel) {
|
|
|
28
47
|
function getEndText(pState, pLevel, pMaxLevel) {
|
|
29
48
|
if (pLevel <= pMaxLevel) {
|
|
30
49
|
const lTime = process.uptime();
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
lTime
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
);
|
|
50
|
+
const { heapUsed } = process.memoryUsage();
|
|
51
|
+
pState.previousMessage = `really done (${formatTime(
|
|
52
|
+
lTime
|
|
53
|
+
).trim()}, ${formatMemory(heapUsed).trim()})`;
|
|
54
|
+
return getProgressLine("", pState, pLevel, pMaxLevel);
|
|
37
55
|
}
|
|
38
56
|
return "";
|
|
39
57
|
}
|
|
@@ -32,6 +32,12 @@ module.exports = function setUpPerformanceLogListener(
|
|
|
32
32
|
let lState = {
|
|
33
33
|
previousMessage: "start of node process",
|
|
34
34
|
previousTime: 0,
|
|
35
|
+
previousUserUsage: 0,
|
|
36
|
+
previousSystemUsage: 0,
|
|
37
|
+
previousRss: 0,
|
|
38
|
+
previousHeapTotal: 0,
|
|
39
|
+
previousHeapUsed: 0,
|
|
40
|
+
previousExternal: 0,
|
|
35
41
|
};
|
|
36
42
|
|
|
37
43
|
pEventEmitter.on("start", getHeaderWriter(pStream, pMaxLevel));
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
const path = require("path");
|
|
2
|
+
const cloneDeep = require("lodash/cloneDeep");
|
|
2
3
|
const has = require("lodash/has");
|
|
3
4
|
const resolve = require("../../extract/resolve/resolve");
|
|
4
5
|
const normalizeResolveOptions = require("../../main/resolve-options/normalize");
|
|
@@ -7,29 +8,31 @@ const mergeConfigs = require("./merge-configs");
|
|
|
7
8
|
|
|
8
9
|
/* eslint no-use-before-define: 0 */
|
|
9
10
|
function processExtends(pReturnValue, pAlreadyVisited, pBaseDirectory) {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
let lReturnValue = cloneDeep(pReturnValue);
|
|
12
|
+
|
|
13
|
+
if (typeof lReturnValue.extends === "string") {
|
|
14
|
+
lReturnValue = mergeConfigs(
|
|
15
|
+
lReturnValue,
|
|
13
16
|
extractDepcruiseConfig(
|
|
14
|
-
|
|
17
|
+
lReturnValue.extends,
|
|
15
18
|
pAlreadyVisited,
|
|
16
19
|
pBaseDirectory
|
|
17
20
|
)
|
|
18
21
|
);
|
|
19
22
|
}
|
|
20
23
|
|
|
21
|
-
if (Array.isArray(
|
|
22
|
-
|
|
24
|
+
if (Array.isArray(lReturnValue.extends)) {
|
|
25
|
+
lReturnValue = lReturnValue.extends.reduce(
|
|
23
26
|
(pAll, pExtends) =>
|
|
24
27
|
mergeConfigs(
|
|
25
28
|
pAll,
|
|
26
29
|
extractDepcruiseConfig(pExtends, pAlreadyVisited, pBaseDirectory)
|
|
27
30
|
),
|
|
28
|
-
|
|
31
|
+
lReturnValue
|
|
29
32
|
);
|
|
30
33
|
}
|
|
31
|
-
Reflect.deleteProperty(
|
|
32
|
-
return
|
|
34
|
+
Reflect.deleteProperty(lReturnValue, "extends");
|
|
35
|
+
return lReturnValue;
|
|
33
36
|
}
|
|
34
37
|
|
|
35
38
|
/**
|
|
@@ -2,7 +2,7 @@ const fs = require("fs");
|
|
|
2
2
|
const path = require("path");
|
|
3
3
|
const json5 = require("json5");
|
|
4
4
|
|
|
5
|
-
module.exports = (pConfigFileName)
|
|
5
|
+
module.exports = function readConfig(pConfigFileName) {
|
|
6
6
|
if ([".js", ".cjs", ""].includes(path.extname(pConfigFileName))) {
|
|
7
7
|
/* eslint node/global-require:0, security/detect-non-literal-require:0, import/no-dynamic-require:0 */
|
|
8
8
|
return require(pConfigFileName);
|
|
@@ -33,8 +33,7 @@ function suggestModules(pSuggestionList, pWebpackConfigFilename) {
|
|
|
33
33
|
|
|
34
34
|
if (Array.isArray(lSuggestionList) && lSuggestionList.length > 0) {
|
|
35
35
|
lReturnValue = lSuggestionList.reduce(
|
|
36
|
-
(pAll, pCurrent) =>
|
|
37
|
-
(pAll += ` - ${pCurrent.module || pCurrent}\n`),
|
|
36
|
+
(pAll, pCurrent) => `${pAll} - ${pCurrent.module || pCurrent}\n`,
|
|
38
37
|
`\n Some npm modules that might fix that problem (one of which you'll` +
|
|
39
38
|
`\n need so '${pWebpackConfigFilename}' works with webpack anyway):\n`
|
|
40
39
|
);
|
|
@@ -20,7 +20,7 @@ function addDependencyViolations(pModule, pDependency, pRuleSet, pValidate) {
|
|
|
20
20
|
* of them added whether or not it is
|
|
21
21
|
* valid and if not which rules were violated
|
|
22
22
|
*/
|
|
23
|
-
module.exports = (pModules, pRuleSet, pValidate)
|
|
23
|
+
module.exports = function addValidations(pModules, pRuleSet, pValidate) {
|
|
24
24
|
return pModules.map((pModule) => ({
|
|
25
25
|
...pModule,
|
|
26
26
|
...(pValidate ? validate.module(pRuleSet, pModule) : { valid: true }),
|
|
@@ -38,11 +38,10 @@ function getCycle(
|
|
|
38
38
|
{ pDependencyName, pFindNodeByName },
|
|
39
39
|
pVisited
|
|
40
40
|
) {
|
|
41
|
-
|
|
42
|
-
|
|
41
|
+
let lVisited = pVisited || new Set();
|
|
43
42
|
const lCurrentNode = pFindNodeByName(pGraph, pCurrentSource);
|
|
44
43
|
const lDependencies = lCurrentNode.dependencies.filter(
|
|
45
|
-
(pDependency) => !
|
|
44
|
+
(pDependency) => !lVisited.has(pDependency[pDependencyName])
|
|
46
45
|
);
|
|
47
46
|
const lMatch = lDependencies.find(
|
|
48
47
|
(pDependency) => pDependency[pDependencyName] === pInitialSource
|
|
@@ -57,7 +56,7 @@ function getCycle(
|
|
|
57
56
|
pInitialSource,
|
|
58
57
|
pDependency[pDependencyName],
|
|
59
58
|
{ pDependencyName, pFindNodeByName },
|
|
60
|
-
|
|
59
|
+
lVisited.add(pDependency[pDependencyName])
|
|
61
60
|
);
|
|
62
61
|
|
|
63
62
|
if (lCycle.length > 0 && !lCycle.includes(pCurrentSource)) {
|
|
@@ -4,7 +4,7 @@ const aggregateToFolders = require("./aggregate-to-folders");
|
|
|
4
4
|
/**
|
|
5
5
|
*
|
|
6
6
|
* @param {*} pFolder
|
|
7
|
-
* @param {import('
|
|
7
|
+
* @param {import('../../../..').IOptions} pOptions
|
|
8
8
|
* @returns
|
|
9
9
|
*/
|
|
10
10
|
function validateFolderDependency(pFolder, pOptions) {
|
|
@@ -29,8 +29,8 @@ function addFolderDependencyViolations(pOptions) {
|
|
|
29
29
|
|
|
30
30
|
/**
|
|
31
31
|
*
|
|
32
|
-
* @param {import('
|
|
33
|
-
* @param {import('
|
|
32
|
+
* @param {import('../../../..').IModule[]} pModules
|
|
33
|
+
* @param {import('../../../..').IOptions} pOptions
|
|
34
34
|
* @returns {any}
|
|
35
35
|
*/
|
|
36
36
|
module.exports = function deriveFolderMetrics(pModules, pOptions) {
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
const isOrphan = require("./is-orphan");
|
|
2
2
|
|
|
3
|
-
module.exports = (pModules)
|
|
4
|
-
pModules.map((pModule) => ({
|
|
3
|
+
module.exports = function deriveOrphans(pModules) {
|
|
4
|
+
return pModules.map((pModule) => ({
|
|
5
5
|
...pModule,
|
|
6
6
|
orphan: isOrphan(pModule, pModules),
|
|
7
7
|
}));
|
|
8
|
+
};
|
|
@@ -169,7 +169,7 @@ function addReachabilityToGraph(pGraph, pReachableRule) {
|
|
|
169
169
|
});
|
|
170
170
|
}
|
|
171
171
|
|
|
172
|
-
module.exports = (pGraph, pRuleSet)
|
|
172
|
+
module.exports = function deriveReachables(pGraph, pRuleSet) {
|
|
173
173
|
const lReachableRules = pRuleSet ? getReachableRules(pRuleSet) : [];
|
|
174
174
|
|
|
175
175
|
return lReachableRules.reduce(
|
package/src/enrich/index.js
CHANGED
|
@@ -11,10 +11,10 @@ const clearCaches = require("./clear-caches");
|
|
|
11
11
|
* used in the cruise, so consumers of the cruise result (reporters, depcruise-fmt,
|
|
12
12
|
* caching) can use that.
|
|
13
13
|
*
|
|
14
|
-
* @param {import("
|
|
15
|
-
* @param {import("
|
|
14
|
+
* @param {import("../..").IModule[]} pModules
|
|
15
|
+
* @param {import("../..").ICruiseOptions} pOptions
|
|
16
16
|
* @param {string[]} pFileAndDirectoryArray
|
|
17
|
-
* @returns {import("
|
|
17
|
+
* @returns {import("../..").ICruiseResult}
|
|
18
18
|
*/
|
|
19
19
|
module.exports = function enrich(pModules, pOptions, pFileAndDirectoryArray) {
|
|
20
20
|
clearCaches();
|
|
@@ -17,7 +17,7 @@ const {
|
|
|
17
17
|
* @param {import("../../../types/options").IStrictCruiseOptions} pOptions -
|
|
18
18
|
* @param {string[]} pFileDirectoryArray -
|
|
19
19
|
* the files/ directories originally passed to be cruised
|
|
20
|
-
* @param {import("
|
|
20
|
+
* @param {import("../../..").IFolder[]} pFolders -
|
|
21
21
|
* the pModules collapsed to folders, with their own metrics & deps
|
|
22
22
|
*
|
|
23
23
|
* @returns {import("../../../types/cruise-result").ISummary} -
|
|
@@ -66,7 +66,7 @@ function extractExoticMemberCallExpression(pNode, pExoticRequireStrings) {
|
|
|
66
66
|
pNode.callee.property.value === pThing.property &&
|
|
67
67
|
argumentsAreUsable(pNode.arguments)
|
|
68
68
|
) {
|
|
69
|
-
|
|
69
|
+
return pAll.concat({
|
|
70
70
|
module: pryStringsFromArguments(pNode.arguments),
|
|
71
71
|
moduleSystem: "cjs",
|
|
72
72
|
exoticallyRequired: true,
|
|
@@ -85,7 +85,7 @@ function gatherScannableFilesFromDirectory(pDirectoryName, pOptions) {
|
|
|
85
85
|
*
|
|
86
86
|
* @param {string[]} pFileAndDirectoryArray globs and/ or paths to files or
|
|
87
87
|
* directories to be gathered
|
|
88
|
-
* @param {import('
|
|
88
|
+
* @param {import('../..').IStrictCruiseOptions} pOptions options that
|
|
89
89
|
* influence what needs to be gathered/ scanned
|
|
90
90
|
* notably useful attributes:
|
|
91
91
|
* - exclude - regexp of what to exclude
|
|
@@ -78,37 +78,31 @@ function extractFromJavaScriptAST(pOptions, pFileName, pTranspileOptions) {
|
|
|
78
78
|
return lDependencies;
|
|
79
79
|
}
|
|
80
80
|
|
|
81
|
-
function extractWithSwc(
|
|
82
|
-
|
|
81
|
+
function extractWithSwc(pCruiseOptions, pFileName) {
|
|
82
|
+
return extractFromSwcAST(pCruiseOptions, pFileName).filter((pDep) =>
|
|
83
83
|
pCruiseOptions.moduleSystems.includes(pDep.moduleSystem)
|
|
84
84
|
);
|
|
85
|
-
return pDependencies;
|
|
86
85
|
}
|
|
87
86
|
|
|
88
|
-
function extractWithTsc(
|
|
89
|
-
|
|
90
|
-
pCruiseOptions,
|
|
91
|
-
pFileName,
|
|
92
|
-
pTranspileOptions
|
|
93
|
-
) {
|
|
94
|
-
pDependencies = extractFromTypeScriptAST(
|
|
87
|
+
function extractWithTsc(pCruiseOptions, pFileName, pTranspileOptions) {
|
|
88
|
+
let lDependencies = extractFromTypeScriptAST(
|
|
95
89
|
pCruiseOptions,
|
|
96
90
|
pFileName,
|
|
97
91
|
pTranspileOptions
|
|
98
92
|
).filter((pDep) => pCruiseOptions.moduleSystems.includes(pDep.moduleSystem));
|
|
99
93
|
|
|
100
94
|
if (pCruiseOptions.tsPreCompilationDeps === "specify") {
|
|
101
|
-
|
|
102
|
-
|
|
95
|
+
lDependencies = detectPreCompilationNess(
|
|
96
|
+
lDependencies,
|
|
103
97
|
extractFromJavaScriptAST(pCruiseOptions, pFileName, pTranspileOptions)
|
|
104
98
|
);
|
|
105
99
|
}
|
|
106
|
-
return
|
|
100
|
+
return lDependencies;
|
|
107
101
|
}
|
|
108
102
|
|
|
109
103
|
/**
|
|
110
104
|
*
|
|
111
|
-
* @param {import('
|
|
105
|
+
* @param {import('../..').IStrictCruiseOptions} pCruiseOptions
|
|
112
106
|
* @param {string} pFileName
|
|
113
107
|
* @param {any} pTranspileOptions
|
|
114
108
|
* @returns {import('../../types/cruise-result').IDependency[]}
|
|
@@ -119,10 +113,9 @@ function extractDependencies(pCruiseOptions, pFileName, pTranspileOptions) {
|
|
|
119
113
|
|
|
120
114
|
if (!pCruiseOptions.extraExtensionsToScan.includes(path.extname(pFileName))) {
|
|
121
115
|
if (shouldUseSwc(pCruiseOptions, pFileName)) {
|
|
122
|
-
lDependencies = extractWithSwc(
|
|
116
|
+
lDependencies = extractWithSwc(pCruiseOptions, pFileName);
|
|
123
117
|
} else if (shouldUseTsc(pCruiseOptions, pFileName)) {
|
|
124
118
|
lDependencies = extractWithTsc(
|
|
125
|
-
lDependencies,
|
|
126
119
|
pCruiseOptions,
|
|
127
120
|
pFileName,
|
|
128
121
|
pTranspileOptions
|
|
@@ -181,7 +174,7 @@ function matchesPattern(pFullPathToFile, pPattern) {
|
|
|
181
174
|
|
|
182
175
|
/**
|
|
183
176
|
*
|
|
184
|
-
* @param {import("
|
|
177
|
+
* @param {import("../..").IDependency} pDependency
|
|
185
178
|
* @returns {string}
|
|
186
179
|
*/
|
|
187
180
|
function getDependencyUniqueKey(pDependency) {
|
|
@@ -208,12 +201,12 @@ function compareDeps(pLeft, pRight) {
|
|
|
208
201
|
*
|
|
209
202
|
*
|
|
210
203
|
* @param {string} pFileName path to the file
|
|
211
|
-
* @param {import("
|
|
212
|
-
* @param {import("
|
|
213
|
-
* @param {import("
|
|
204
|
+
* @param {import("../..").IStrictCruiseOptions} pCruiseOptions cruise options
|
|
205
|
+
* @param {import("../..").IResolveOptions} pResolveOptions webpack 'enhanced-resolve' options
|
|
206
|
+
* @param {import("../..").ITranspileOptions} pTranspileOptions an object with tsconfig ('typescript project') options
|
|
214
207
|
* ('flattened' so there's no need for file access on any
|
|
215
208
|
* 'extends' option in there)
|
|
216
|
-
* @return {import("
|
|
209
|
+
* @return {import("../..").IDependency[]} an array of dependency objects (see above)
|
|
217
210
|
*/
|
|
218
211
|
module.exports = function getDependencies(
|
|
219
212
|
pFileName,
|
package/src/extract/index.js
CHANGED
|
@@ -141,10 +141,10 @@ function filterExcludedDynamicDependencies(pModule, pExclude) {
|
|
|
141
141
|
* returns an array of all the modules it finds that way.
|
|
142
142
|
*
|
|
143
143
|
* @param {string[]} pFileDirectoryArray
|
|
144
|
-
* @param {import("
|
|
145
|
-
* @param {import("
|
|
146
|
-
* @param {import("
|
|
147
|
-
* @returns {Partial<import("
|
|
144
|
+
* @param {import("../..").IStrictCruiseOptions} pCruiseOptions
|
|
145
|
+
* @param {import("../..").IResolveOptions} pResolveOptions
|
|
146
|
+
* @param {import("../..").ITranspileOptions} pTranspileOptions
|
|
147
|
+
* @returns {Partial<import("../..").IModule[]>}
|
|
148
148
|
*/
|
|
149
149
|
module.exports = function extract(
|
|
150
150
|
pFileDirectoryArray,
|
|
@@ -96,7 +96,7 @@ function dependencyIsBundled(pModule, pPackageDeps) {
|
|
|
96
96
|
* @param {string} pModuleName
|
|
97
97
|
* @param {string} pPackageDeps
|
|
98
98
|
* @param {string} pFileDirectory
|
|
99
|
-
* @param {import("
|
|
99
|
+
* @param {import("../../..").IResolveOptions} pResolveOptions
|
|
100
100
|
* @returns {import("../../../types/shared-types").DependencyType[]}
|
|
101
101
|
*/
|
|
102
102
|
function determineNodeModuleDependencyTypes(
|
|
@@ -133,7 +133,7 @@ function determineNodeModuleDependencyTypes(
|
|
|
133
133
|
* @param {string} pModuleName
|
|
134
134
|
* @param {any} pPackageDeps
|
|
135
135
|
* @param {string} pFileDirectory
|
|
136
|
-
* @param {import("
|
|
136
|
+
* @param {import("../../..").IResolveOptions} pResolveOptions
|
|
137
137
|
* @param {string} pBaseDirectory
|
|
138
138
|
* @returns {import("../../../types/shared-types").DependencyType[]}
|
|
139
139
|
*/
|
|
@@ -185,7 +185,7 @@ module.exports = function determineDependencyTypes(
|
|
|
185
185
|
) {
|
|
186
186
|
/** @type {import("../../../types/shared-types").DependencyType[]}*/
|
|
187
187
|
let lReturnValue = ["undetermined"];
|
|
188
|
-
|
|
188
|
+
const lResolveOptions = pResolveOptions || {};
|
|
189
189
|
|
|
190
190
|
if (pDependency.couldNotResolve) {
|
|
191
191
|
lReturnValue = ["unknown"];
|
|
@@ -201,7 +201,7 @@ module.exports = function determineDependencyTypes(
|
|
|
201
201
|
} else if (
|
|
202
202
|
isExternalModule(
|
|
203
203
|
pDependency.resolved,
|
|
204
|
-
|
|
204
|
+
lResolveOptions.modules,
|
|
205
205
|
pBaseDirectory
|
|
206
206
|
)
|
|
207
207
|
) {
|
|
@@ -210,10 +210,10 @@ module.exports = function determineDependencyTypes(
|
|
|
210
210
|
pModuleName,
|
|
211
211
|
pManifest,
|
|
212
212
|
pFileDirectory,
|
|
213
|
-
|
|
213
|
+
lResolveOptions,
|
|
214
214
|
pBaseDirectory
|
|
215
215
|
);
|
|
216
|
-
} else if (isAliassy(pModuleName, pDependency.resolved,
|
|
216
|
+
} else if (isAliassy(pModuleName, pDependency.resolved, lResolveOptions)) {
|
|
217
217
|
lReturnValue = ["aliased"];
|
|
218
218
|
}
|
|
219
219
|
|
|
@@ -11,10 +11,10 @@ const getManifest = require("./get-manifest");
|
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
13
|
*
|
|
14
|
-
* @param {import("
|
|
14
|
+
* @param {import("../../..").IModule} pModule
|
|
15
15
|
* @param {string} pBaseDirectory
|
|
16
16
|
* @param {string} pFileDirectory
|
|
17
|
-
* @param {import("
|
|
17
|
+
* @param {import("../../..").IResolveOptions} pResolveOptions
|
|
18
18
|
* @returns {any}
|
|
19
19
|
*/
|
|
20
20
|
function resolveModule(
|
|
@@ -23,7 +23,7 @@ function scrub(pModuleNamesSet) {
|
|
|
23
23
|
}
|
|
24
24
|
/**
|
|
25
25
|
*
|
|
26
|
-
* @param {import("
|
|
26
|
+
* @param {import("../..").IModule[]} pModules
|
|
27
27
|
* @param {import("../../types/strict-filter-types").IStrictFocusType} pFilter
|
|
28
28
|
* @returns
|
|
29
29
|
*/
|
|
@@ -47,7 +47,9 @@ function consolidateDependencies(pDependencies) {
|
|
|
47
47
|
return lReturnValue;
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
-
module.exports = (pModule)
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
50
|
+
module.exports = function consolidateModuleDependencies(pModule) {
|
|
51
|
+
return {
|
|
52
|
+
...pModule,
|
|
53
|
+
dependencies: consolidateDependencies(pModule.dependencies),
|
|
54
|
+
};
|
|
55
|
+
};
|
|
@@ -17,7 +17,8 @@ function squashModuleToDirectory(pModule) {
|
|
|
17
17
|
};
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
-
module.exports = (pModules)
|
|
21
|
-
consolidateModules(pModules.map(squashModuleToDirectory)).map(
|
|
20
|
+
module.exports = function consolidateToFolder(pModules) {
|
|
21
|
+
return consolidateModules(pModules.map(squashModuleToDirectory)).map(
|
|
22
22
|
consolidateModuleDependencies
|
|
23
23
|
);
|
|
24
|
+
};
|
|
@@ -7,7 +7,7 @@ const has = require("lodash/has");
|
|
|
7
7
|
*
|
|
8
8
|
* (this thing probably belongs in a model-like folder and not in utl)
|
|
9
9
|
*
|
|
10
|
-
* @param {import("
|
|
10
|
+
* @param {import("../..").IFlattenedRuleSet} pRuleSet - The rule set to search in
|
|
11
11
|
* @param {string} pName - The rule name to look for
|
|
12
12
|
* @return {import("../../types/rule-set").IForbiddenRuleType|undefined} - a rule (or 'undefined' if nothing found)
|
|
13
13
|
*/
|
|
@@ -23,7 +23,7 @@ function findRuleByName(pRuleSet, pName) {
|
|
|
23
23
|
*
|
|
24
24
|
* Returns false in all other cases
|
|
25
25
|
*
|
|
26
|
-
* @param {import('
|
|
26
|
+
* @param {import('../..').IFlattenedRuleSet} pRuleSet
|
|
27
27
|
* @return {boolean}
|
|
28
28
|
*/
|
|
29
29
|
function ruleSetHasLicenseRule(pRuleSet) {
|
|
@@ -38,7 +38,7 @@ function ruleSetHasLicenseRule(pRuleSet) {
|
|
|
38
38
|
}
|
|
39
39
|
/**
|
|
40
40
|
*
|
|
41
|
-
* @param {import('
|
|
41
|
+
* @param {import('../..').IFlattenedRuleSet} pRuleSet
|
|
42
42
|
* @return {boolean}
|
|
43
43
|
*/
|
|
44
44
|
function ruleSetHasDeprecationRule(pRuleSet) {
|
package/src/main/index.js
CHANGED
|
@@ -31,7 +31,7 @@ function validateResultAgainstSchema(pResult) {
|
|
|
31
31
|
);
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
|
-
/** @type {import("
|
|
34
|
+
/** @type {import("../..").format} */
|
|
35
35
|
function format(pResult, pFormatOptions = {}) {
|
|
36
36
|
const lFormatOptions = normalizeFormatOptions(pFormatOptions);
|
|
37
37
|
validateFormatOptions(lFormatOptions);
|
|
@@ -47,7 +47,7 @@ function c(pComplete, pTotal = TOTAL_STEPS) {
|
|
|
47
47
|
return { complete: pComplete / pTotal };
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
-
/** @type {import("
|
|
50
|
+
/** @type {import("../..").futureCruise} */
|
|
51
51
|
// eslint-disable-next-line max-lines-per-function, complexity, max-statements
|
|
52
52
|
function futureCruise(
|
|
53
53
|
pFileAndDirectoryArray,
|
|
@@ -124,8 +124,8 @@ function futureCruise(
|
|
|
124
124
|
}
|
|
125
125
|
|
|
126
126
|
// see [api.md](../../doc/api.md) and/ or the
|
|
127
|
-
// [type definition](
|
|
128
|
-
/** @type {import("
|
|
127
|
+
// [type definition](../...d.ts) for details
|
|
128
|
+
/** @type {import("../..").cruise} */
|
|
129
129
|
function cruise(pFileAndDirectoryArray, pOptions, pResolveOptions, pTSConfig) {
|
|
130
130
|
return futureCruise(pFileAndDirectoryArray, pOptions, pResolveOptions, {
|
|
131
131
|
tsConfig: pTSConfig,
|
|
@@ -68,7 +68,7 @@ function normalizeCollapse(pCollapse) {
|
|
|
68
68
|
}
|
|
69
69
|
|
|
70
70
|
function normalizeFocusDepth(pFormatOptions) {
|
|
71
|
-
/** @type {import("
|
|
71
|
+
/** @type {import("../../..").IFormatOptions}*/
|
|
72
72
|
let lFormatOptions = clone(pFormatOptions);
|
|
73
73
|
if (has(lFormatOptions, "focusDepth")) {
|
|
74
74
|
if (has(lFormatOptions, "focus")) {
|
|
@@ -84,7 +84,7 @@ function normalizeFocusDepth(pFormatOptions) {
|
|
|
84
84
|
|
|
85
85
|
/**
|
|
86
86
|
*
|
|
87
|
-
* @param {import("
|
|
87
|
+
* @param {import("../../..").IForbiddenRuleType} pRule
|
|
88
88
|
* @returns {boolean}
|
|
89
89
|
*/
|
|
90
90
|
function hasMetricsRule(pRule) {
|
|
@@ -98,7 +98,7 @@ function hasMetricsRule(pRule) {
|
|
|
98
98
|
|
|
99
99
|
/**
|
|
100
100
|
*
|
|
101
|
-
* @param {import("
|
|
101
|
+
* @param {import("../../..").IFlattenedRuleSet} pRuleSet
|
|
102
102
|
* @returns {boolean}
|
|
103
103
|
*/
|
|
104
104
|
function ruleSetHasMetricsRule(pRuleSet) {
|
|
@@ -111,7 +111,7 @@ function ruleSetHasMetricsRule(pRuleSet) {
|
|
|
111
111
|
|
|
112
112
|
/**
|
|
113
113
|
*
|
|
114
|
-
* @param {import('
|
|
114
|
+
* @param {import('../../..').ICruiseOptions} pOptions
|
|
115
115
|
* @returns Boolean
|
|
116
116
|
*/
|
|
117
117
|
function reporterShowsMetrics(pOptions) {
|
|
@@ -127,7 +127,7 @@ function reporterShowsMetrics(pOptions) {
|
|
|
127
127
|
/**
|
|
128
128
|
* Determines whether (instability) metrics should be calculated
|
|
129
129
|
*
|
|
130
|
-
* @param {import('
|
|
130
|
+
* @param {import('../../..').ICruiseOptions} pOptions
|
|
131
131
|
* @returns Boolean
|
|
132
132
|
*/
|
|
133
133
|
function shouldCalculateMetrics(pOptions) {
|
|
@@ -192,7 +192,7 @@ function normalizeCruiseOptions(pOptions, pFileAndDirectoryArray = []) {
|
|
|
192
192
|
|
|
193
193
|
/**
|
|
194
194
|
*
|
|
195
|
-
* @param {import("
|
|
195
|
+
* @param {import("../../..").IFormatOptions} pFormatOptions
|
|
196
196
|
* @returns {import("../../../types/strict-options").IStrictFormatOptions}
|
|
197
197
|
*/
|
|
198
198
|
function normalizeFormatOptions(pFormatOptions) {
|
|
@@ -74,7 +74,7 @@ function validatePathsSafety(pFilterOption) {
|
|
|
74
74
|
*
|
|
75
75
|
* @param {any} pOptions
|
|
76
76
|
* @throws {Error}
|
|
77
|
-
* @returns {import("
|
|
77
|
+
* @returns {import("../../..").ICruiseOptions}
|
|
78
78
|
*/
|
|
79
79
|
function validateCruiseOptions(pOptions) {
|
|
80
80
|
let lReturnValue = {};
|
|
@@ -110,7 +110,7 @@ function validateCruiseOptions(pOptions) {
|
|
|
110
110
|
|
|
111
111
|
/**
|
|
112
112
|
*
|
|
113
|
-
* @param {import("
|
|
113
|
+
* @param {import("../../..").IFormatOptions} pFormatOptions
|
|
114
114
|
* @throws {Error}
|
|
115
115
|
*/
|
|
116
116
|
function validateFormatOptions(pFormatOptions) {
|