dependency-cruiser 10.4.0-beta-1 → 10.4.0-beta-2
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 +9 -9
- package/src/enrich/soften-known-violations.js +9 -6
- package/src/enrich/summarize/is-same-violation.js +18 -0
- package/src/enrich/summarize/summarize-modules.js +6 -3
- package/src/extract/ast-extractors/extract-typescript-deps.js +1 -1
- package/src/extract/get-dependencies.js +4 -14
- package/src/extract/resolve/determine-dependency-types.js +3 -7
- package/src/extract/resolve/index.js +46 -13
- package/src/extract/resolve/module-classifiers.js +0 -6
- package/src/extract/resolve/resolve-amd.js +11 -38
- package/src/extract/resolve/resolve-cjs.js +7 -35
- package/src/meta.js +1 -1
- package/src/schema/cruise-result.schema.js +1 -0
- package/types/cruise-result.d.ts +4 -0
- package/src/enrich/summarize/de-duplicate-violations.js +0 -18
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dependency-cruiser",
|
|
3
|
-
"version": "10.4.0-beta-
|
|
3
|
+
"version": "10.4.0-beta-2",
|
|
4
4
|
"description": "Validate and visualize dependencies. With your rules. JavaScript, TypeScript, CoffeeScript. ES6, CommonJS, AMD.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"static analysis",
|
|
@@ -139,10 +139,10 @@
|
|
|
139
139
|
"ajv": "8.6.3",
|
|
140
140
|
"chalk": "4.1.2",
|
|
141
141
|
"commander": "8.2.0",
|
|
142
|
-
"enhanced-resolve": "5.8.
|
|
142
|
+
"enhanced-resolve": "5.8.3",
|
|
143
143
|
"figures": "^3.2.0",
|
|
144
144
|
"get-stream": "^6.0.1",
|
|
145
|
-
"glob": "7.
|
|
145
|
+
"glob": "7.2.0",
|
|
146
146
|
"handlebars": "4.7.7",
|
|
147
147
|
"indent-string": "^4.0.0",
|
|
148
148
|
"inquirer": "8.1.5",
|
|
@@ -159,13 +159,13 @@
|
|
|
159
159
|
"@babel/core": "7.15.5",
|
|
160
160
|
"@babel/plugin-transform-modules-commonjs": "7.15.4",
|
|
161
161
|
"@babel/preset-typescript": "7.15.0",
|
|
162
|
-
"@swc/core": "1.2.
|
|
163
|
-
"@typescript-eslint/eslint-plugin": "4.31.
|
|
164
|
-
"@typescript-eslint/parser": "4.31.
|
|
162
|
+
"@swc/core": "1.2.91",
|
|
163
|
+
"@typescript-eslint/eslint-plugin": "4.31.2",
|
|
164
|
+
"@typescript-eslint/parser": "4.31.2",
|
|
165
165
|
"c8": "7.9.0",
|
|
166
166
|
"chai": "4.3.4",
|
|
167
167
|
"chai-json-schema": "1.5.1",
|
|
168
|
-
"coffeescript": "2.
|
|
168
|
+
"coffeescript": "2.6.0",
|
|
169
169
|
"eslint": "7.32.0",
|
|
170
170
|
"eslint-config-moving-meadow": "2.0.9",
|
|
171
171
|
"eslint-config-prettier": "8.3.0",
|
|
@@ -178,12 +178,12 @@
|
|
|
178
178
|
"husky": "^4.3.8",
|
|
179
179
|
"intercept-stdout": "0.1.2",
|
|
180
180
|
"lint-staged": "11.1.2",
|
|
181
|
-
"mocha": "9.1.
|
|
181
|
+
"mocha": "9.1.2",
|
|
182
182
|
"normalize-newline": "4.1.0",
|
|
183
183
|
"npm-run-all": "4.1.5",
|
|
184
184
|
"prettier": "2.4.1",
|
|
185
185
|
"shx": "0.3.3",
|
|
186
|
-
"svelte": "3.
|
|
186
|
+
"svelte": "3.43.0",
|
|
187
187
|
"symlink-dir": "5.0.1",
|
|
188
188
|
"typescript": "4.4.3",
|
|
189
189
|
"upem": "^7.0.0",
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
const bus = require("../utl/bus");
|
|
2
2
|
const busLogLevels = require("../utl/bus-log-levels");
|
|
3
|
+
const isSameViolation = require("./summarize/is-same-violation");
|
|
3
4
|
|
|
4
5
|
function softenModuleViolation(
|
|
5
6
|
pRule,
|
|
@@ -26,11 +27,8 @@ function softenDependencyViolation(
|
|
|
26
27
|
) {
|
|
27
28
|
return {
|
|
28
29
|
...pViolationKey.rule,
|
|
29
|
-
severity: pKnownDependencyViolations.some(
|
|
30
|
-
(pKnownError)
|
|
31
|
-
pKnownError.from === pViolationKey.from &&
|
|
32
|
-
pKnownError.to === pViolationKey.to &&
|
|
33
|
-
pKnownError.rule.name === pViolationKey.rule.name
|
|
30
|
+
severity: pKnownDependencyViolations.some((pKnownError) =>
|
|
31
|
+
isSameViolation(pKnownError, pViolationKey)
|
|
34
32
|
)
|
|
35
33
|
? pSoftenedSeverity
|
|
36
34
|
: pViolationKey.rule.severity,
|
|
@@ -48,7 +46,12 @@ function softenDependencyViolations(
|
|
|
48
46
|
...pDependency,
|
|
49
47
|
rules: pDependency.rules.map((pRule) =>
|
|
50
48
|
softenDependencyViolation(
|
|
51
|
-
{
|
|
49
|
+
{
|
|
50
|
+
rule: pRule,
|
|
51
|
+
from: pModuleSource,
|
|
52
|
+
to: pDependency.resolved,
|
|
53
|
+
cycle: pDependency.cycle,
|
|
54
|
+
},
|
|
52
55
|
pKnownDependencyViolations,
|
|
53
56
|
pSoftenedSeverity
|
|
54
57
|
)
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
module.exports = function isSameViolation(pLeftViolation, pRightViolation) {
|
|
2
|
+
let lReturnValue = false;
|
|
3
|
+
|
|
4
|
+
if (pLeftViolation.rule.name === pRightViolation.rule.name) {
|
|
5
|
+
if (pRightViolation.cycle && pLeftViolation.cycle) {
|
|
6
|
+
lReturnValue =
|
|
7
|
+
pLeftViolation.cycle.length === pRightViolation.cycle.length &&
|
|
8
|
+
pLeftViolation.cycle.every((pModule) =>
|
|
9
|
+
pRightViolation.cycle.includes(pModule)
|
|
10
|
+
);
|
|
11
|
+
} else {
|
|
12
|
+
lReturnValue =
|
|
13
|
+
pLeftViolation.from === pRightViolation.from &&
|
|
14
|
+
pLeftViolation.to === pRightViolation.to;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
return lReturnValue;
|
|
18
|
+
};
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
const _flattenDeep = require("lodash/flattenDeep");
|
|
2
2
|
const _get = require("lodash/get");
|
|
3
|
+
const _uniqWith = require("lodash/uniqWith");
|
|
3
4
|
const { findRuleByName } = require("../../graph-utl/rule-set");
|
|
4
5
|
const compare = require("../../graph-utl/compare");
|
|
5
|
-
const
|
|
6
|
+
const isSameViolation = require("./is-same-violation");
|
|
6
7
|
|
|
7
8
|
function cutNonTransgressions(pSourceEntry) {
|
|
8
9
|
return {
|
|
@@ -23,6 +24,7 @@ function extractMetaData(pViolations) {
|
|
|
23
24
|
error: 0,
|
|
24
25
|
warn: 0,
|
|
25
26
|
info: 0,
|
|
27
|
+
ignore: 0,
|
|
26
28
|
}
|
|
27
29
|
);
|
|
28
30
|
}
|
|
@@ -128,10 +130,11 @@ function extractModuleViolations(pModules, pRuleSet) {
|
|
|
128
130
|
}
|
|
129
131
|
|
|
130
132
|
module.exports = function summarizeModules(pModules, pRuleSet) {
|
|
131
|
-
const lViolations =
|
|
133
|
+
const lViolations = _uniqWith(
|
|
132
134
|
extractDependencyViolations(pModules, pRuleSet)
|
|
133
135
|
.concat(extractModuleViolations(pModules, pRuleSet))
|
|
134
|
-
.sort(compare.violations)
|
|
136
|
+
.sort(compare.violations),
|
|
137
|
+
isSameViolation
|
|
135
138
|
);
|
|
136
139
|
|
|
137
140
|
return {
|
|
@@ -162,8 +162,8 @@ function addResolutionAttributes(pOptions, pFileName, pResolveOptions) {
|
|
|
162
162
|
);
|
|
163
163
|
|
|
164
164
|
return {
|
|
165
|
-
...lResolved,
|
|
166
165
|
...pDependency,
|
|
166
|
+
...lResolved,
|
|
167
167
|
followable: lResolved.followable && !lMatchesDoNotFollow,
|
|
168
168
|
matchesDoNotFollow: lMatchesDoNotFollow,
|
|
169
169
|
};
|
|
@@ -196,22 +196,12 @@ function compareDeps(pLeft, pRight) {
|
|
|
196
196
|
*
|
|
197
197
|
*
|
|
198
198
|
* @param {string} pFileName path to the file
|
|
199
|
-
* @param {
|
|
200
|
-
*
|
|
201
|
-
* base for all files
|
|
202
|
-
* Default: the current working directory
|
|
203
|
-
* - moduleSystems - an array of module systems to
|
|
204
|
-
* consider.
|
|
205
|
-
* Default: ["cjs", "es6", "amd"]
|
|
206
|
-
* - exclude - a regular expression string
|
|
207
|
-
* with a pattern of modules to exclude
|
|
208
|
-
* (e.g. "(node_modules)"). Default: none
|
|
209
|
-
* - preserveSymlinks - don't resolve symlinks.
|
|
210
|
-
* @param {object} pResolveOptions an object with webpack 'enhanced-resolve' options
|
|
199
|
+
* @param {import("../../../types/dependency-cruiser").ICruiseOptions} pCruiseOptions cruise options
|
|
200
|
+
* @param {import("../../types/resolve-options").IResolveOptions} pResolveOptions webpack 'enhanced-resolve' options
|
|
211
201
|
* @param {any} pTranspileOptions an object with tsconfig ('typescript project') options
|
|
212
202
|
* ('flattened' so there's no need for file access on any
|
|
213
203
|
* 'extends' option in there)
|
|
214
|
-
* @return {
|
|
204
|
+
* @return {import("../../types/dependency-cruiser").IDependency[]} an array of dependency objects (see above)
|
|
215
205
|
*/
|
|
216
206
|
module.exports = function getDependencies(
|
|
217
207
|
pFileName,
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
const path = require("path");
|
|
2
|
+
const { builtinModules } = require("module");
|
|
2
3
|
const _has = require("lodash/has");
|
|
3
4
|
const {
|
|
4
5
|
isRelativeModuleName,
|
|
5
|
-
isCore,
|
|
6
6
|
isExternalModule,
|
|
7
7
|
isAliassy,
|
|
8
8
|
} = require("./module-classifiers");
|
|
@@ -167,7 +167,7 @@ module.exports = function determineDependencyTypes(
|
|
|
167
167
|
|
|
168
168
|
if (pDependency.couldNotResolve) {
|
|
169
169
|
lReturnValue = ["unknown"];
|
|
170
|
-
} else if (
|
|
170
|
+
} else if (builtinModules.includes(pModuleName)) {
|
|
171
171
|
// this 'isCore' business seems duplicate (it's already in
|
|
172
172
|
// the passed object as `coreModule`- determined by the resolve-AMD or
|
|
173
173
|
// resolve-commonJS module). I want to deprecate the `coreModule`
|
|
@@ -195,11 +195,7 @@ module.exports = function determineDependencyTypes(
|
|
|
195
195
|
lReturnValue = ["aliased"];
|
|
196
196
|
}
|
|
197
197
|
|
|
198
|
-
|
|
199
|
-
lReturnValue.push("type-only");
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
return lReturnValue;
|
|
198
|
+
return lReturnValue.concat(pDependency.dependencyTypes || []);
|
|
203
199
|
};
|
|
204
200
|
|
|
205
201
|
/* eslint security/detect-object-injection: 0*/
|
|
@@ -7,6 +7,8 @@ const { isRelativeModuleName } = require("./module-classifiers");
|
|
|
7
7
|
const resolveAMD = require("./resolve-amd");
|
|
8
8
|
const resolveCommonJS = require("./resolve-cjs");
|
|
9
9
|
const resolveHelpers = require("./resolve-helpers");
|
|
10
|
+
const determineDependencyTypes = require("./determine-dependency-types");
|
|
11
|
+
const getManifest = require("./get-manifest");
|
|
10
12
|
|
|
11
13
|
function resolveModule(
|
|
12
14
|
pModule,
|
|
@@ -16,20 +18,20 @@ function resolveModule(
|
|
|
16
18
|
) {
|
|
17
19
|
let lReturnValue = null;
|
|
18
20
|
|
|
19
|
-
const
|
|
21
|
+
const lStrippedModuleName = resolveHelpers.stripToModuleName(pModule.module);
|
|
20
22
|
if (
|
|
21
|
-
isRelativeModuleName(
|
|
23
|
+
isRelativeModuleName(lStrippedModuleName) ||
|
|
22
24
|
["cjs", "es6", "tsd"].includes(pModule.moduleSystem)
|
|
23
25
|
) {
|
|
24
26
|
lReturnValue = resolveCommonJS(
|
|
25
|
-
|
|
27
|
+
lStrippedModuleName,
|
|
26
28
|
pBaseDirectory,
|
|
27
29
|
pFileDirectory,
|
|
28
30
|
pResolveOptions
|
|
29
31
|
);
|
|
30
32
|
} else {
|
|
31
33
|
lReturnValue = resolveAMD(
|
|
32
|
-
|
|
34
|
+
lStrippedModuleName,
|
|
33
35
|
pBaseDirectory,
|
|
34
36
|
pFileDirectory,
|
|
35
37
|
pResolveOptions
|
|
@@ -48,7 +50,7 @@ function isTypeScriptishExtension(pModuleName) {
|
|
|
48
50
|
function resolveYarnVirtual(pPath) {
|
|
49
51
|
const pnpAPI = get(monkeyPatchedModule, "findPnpApi", () => false)(pPath);
|
|
50
52
|
|
|
51
|
-
// the pnp api only works in plug'n play
|
|
53
|
+
// the pnp api only works in plug'n play environments, and resolveVirtual
|
|
52
54
|
// only under yarn(berry). As we can't run a 'regular' nodejs environment
|
|
53
55
|
// and a yarn(berry) one at the same time, ignore in the test coverage and
|
|
54
56
|
// cover it in a separate integration test.
|
|
@@ -72,7 +74,7 @@ function resolveWithRetry(
|
|
|
72
74
|
pFileDirectory,
|
|
73
75
|
pResolveOptions
|
|
74
76
|
);
|
|
75
|
-
const
|
|
77
|
+
const lStrippedModuleName = resolveHelpers.stripToModuleName(pModule.module);
|
|
76
78
|
|
|
77
79
|
// when we feed the typescript compiler an import with an explicit .js(x) extension
|
|
78
80
|
// and the .js(x) file does not exist, it tries files with the .ts, .tsx or
|
|
@@ -87,8 +89,14 @@ function resolveWithRetry(
|
|
|
87
89
|
//
|
|
88
90
|
// This should eventually probably land in either enhanced_resolve or in a
|
|
89
91
|
// plugin/ extension for it (tsconfig-paths-webpack-plugin?)
|
|
90
|
-
if (
|
|
91
|
-
|
|
92
|
+
if (
|
|
93
|
+
lReturnValue.couldNotResolve &&
|
|
94
|
+
canBeResolvedToTsVariant(lStrippedModuleName)
|
|
95
|
+
) {
|
|
96
|
+
const lModuleWithOutExtension = lStrippedModuleName.replace(
|
|
97
|
+
/\.js(x)?$/g,
|
|
98
|
+
""
|
|
99
|
+
);
|
|
92
100
|
|
|
93
101
|
const lReturnValueCandidate = resolveModule(
|
|
94
102
|
{ ...pModule, module: lModuleWithOutExtension },
|
|
@@ -106,14 +114,13 @@ function resolveWithRetry(
|
|
|
106
114
|
/**
|
|
107
115
|
* resolves the module name of the pDependency to a file on disk.
|
|
108
116
|
*
|
|
109
|
-
* @param {import("../../../types/cruise-result").
|
|
110
|
-
* according to which this is a dependency
|
|
117
|
+
* @param {Partial <import("../../../types/cruise-result").IDependency>} pDependency
|
|
111
118
|
* @param {string} pBaseDirectory the directory to consider as base (or 'root')
|
|
112
119
|
* for resolved files.
|
|
113
120
|
* @param {string} pFileDirectory the directory of the file the dependency was
|
|
114
121
|
* detected in
|
|
115
122
|
* @param {import(../../../types/resolve-options").IResolveOptions} pResolveOptions
|
|
116
|
-
* @return {
|
|
123
|
+
* @return {Partial <import("../../../types/cruise-result").IDependency>} an object with as attributes:
|
|
117
124
|
* - resolved: a string representing the pDependency
|
|
118
125
|
* resolved to a file on disk (or the pDependency
|
|
119
126
|
* name itself when it could not be resolved)
|
|
@@ -128,18 +135,44 @@ function resolveWithRetry(
|
|
|
128
135
|
* - dependencyTypes: an array of dependencyTypes
|
|
129
136
|
*
|
|
130
137
|
*/
|
|
138
|
+
// eslint-disable-next-line max-lines-per-function
|
|
131
139
|
module.exports = function resolve(
|
|
132
|
-
|
|
140
|
+
pDependency,
|
|
133
141
|
pBaseDirectory,
|
|
134
142
|
pFileDirectory,
|
|
135
143
|
pResolveOptions
|
|
136
144
|
) {
|
|
137
145
|
let lResolvedModule = resolveWithRetry(
|
|
138
|
-
|
|
146
|
+
pDependency,
|
|
139
147
|
pBaseDirectory,
|
|
140
148
|
pFileDirectory,
|
|
141
149
|
pResolveOptions
|
|
142
150
|
);
|
|
151
|
+
const lStrippedModuleName = resolveHelpers.stripToModuleName(
|
|
152
|
+
pDependency.module
|
|
153
|
+
);
|
|
154
|
+
|
|
155
|
+
lResolvedModule = {
|
|
156
|
+
...lResolvedModule,
|
|
157
|
+
...resolveHelpers.addLicenseAttribute(
|
|
158
|
+
lStrippedModuleName,
|
|
159
|
+
lResolvedModule.resolved,
|
|
160
|
+
{ baseDirectory: pBaseDirectory, fileDirectory: pFileDirectory },
|
|
161
|
+
pResolveOptions
|
|
162
|
+
),
|
|
163
|
+
dependencyTypes: determineDependencyTypes(
|
|
164
|
+
{ ...pDependency, ...lResolvedModule },
|
|
165
|
+
lStrippedModuleName,
|
|
166
|
+
getManifest(
|
|
167
|
+
pFileDirectory,
|
|
168
|
+
pBaseDirectory,
|
|
169
|
+
pResolveOptions.combinedDependencies
|
|
170
|
+
),
|
|
171
|
+
pFileDirectory,
|
|
172
|
+
pResolveOptions,
|
|
173
|
+
pBaseDirectory
|
|
174
|
+
),
|
|
175
|
+
};
|
|
143
176
|
|
|
144
177
|
if (
|
|
145
178
|
!pResolveOptions.symlinks &&
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
const { builtinModules } = require("module");
|
|
2
1
|
const path = require("path");
|
|
3
2
|
const getExtension = require("../utl/get-extension");
|
|
4
3
|
|
|
@@ -19,10 +18,6 @@ function isRelativeModuleName(pModuleName) {
|
|
|
19
18
|
);
|
|
20
19
|
}
|
|
21
20
|
|
|
22
|
-
function isCore(pModuleName) {
|
|
23
|
-
return builtinModules.includes(pModuleName);
|
|
24
|
-
}
|
|
25
|
-
|
|
26
21
|
function isExternalModule(
|
|
27
22
|
pResolvedModuleName,
|
|
28
23
|
pModuleFolderNames = ["node_modules"],
|
|
@@ -124,7 +119,6 @@ function isAliassy(pModuleName, pResolvedModuleName, pResolveOptions) {
|
|
|
124
119
|
module.exports = {
|
|
125
120
|
isScoped,
|
|
126
121
|
isRelativeModuleName,
|
|
127
|
-
isCore,
|
|
128
122
|
isExternalModule,
|
|
129
123
|
isFollowable,
|
|
130
124
|
isAliassy,
|
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
const fs = require("fs");
|
|
2
2
|
const path = require("path");
|
|
3
|
+
const { builtinModules } = require("module");
|
|
3
4
|
const memoize = require("lodash/memoize");
|
|
4
5
|
const pathToPosix = require("../utl/path-to-posix");
|
|
5
|
-
const determineDependencyTypes = require("./determine-dependency-types");
|
|
6
|
-
const { isCore } = require("./module-classifiers");
|
|
7
|
-
const getManifest = require("./get-manifest");
|
|
8
|
-
const resolveHelpers = require("./resolve-helpers");
|
|
9
6
|
|
|
10
7
|
const fileExists = memoize((pFile) => {
|
|
11
8
|
try {
|
|
@@ -27,7 +24,7 @@ function guessPath(pBaseDirectory, pFileDirectory, pStrippedModuleName) {
|
|
|
27
24
|
}
|
|
28
25
|
|
|
29
26
|
function guessLikelyPath(pBaseDirectory, pFileDirectory, pStrippedModuleName) {
|
|
30
|
-
|
|
27
|
+
return (
|
|
31
28
|
[".js", ""]
|
|
32
29
|
.map((pExtension) =>
|
|
33
30
|
guessPath(
|
|
@@ -36,16 +33,14 @@ function guessLikelyPath(pBaseDirectory, pFileDirectory, pStrippedModuleName) {
|
|
|
36
33
|
`${pStrippedModuleName}${pExtension}`
|
|
37
34
|
)
|
|
38
35
|
)
|
|
39
|
-
.find(fileExists) || pStrippedModuleName
|
|
40
|
-
|
|
41
|
-
return lReturnValue;
|
|
36
|
+
.find(fileExists) || pStrippedModuleName
|
|
37
|
+
);
|
|
42
38
|
}
|
|
43
39
|
|
|
44
40
|
module.exports = function resolveAMD(
|
|
45
|
-
|
|
41
|
+
pStrippedModuleName,
|
|
46
42
|
pBaseDirectory,
|
|
47
|
-
pFileDirectory
|
|
48
|
-
pResolveOptions
|
|
43
|
+
pFileDirectory
|
|
49
44
|
) {
|
|
50
45
|
// lookups:
|
|
51
46
|
// - [x] could be relative in the end (implemented)
|
|
@@ -53,41 +48,19 @@ module.exports = function resolveAMD(
|
|
|
53
48
|
// - [ ] maybe use mrjoelkemp/module-lookup-amd ?
|
|
54
49
|
// - [ ] or https://github.com/jaredhanson/amd-resolve ?
|
|
55
50
|
// - [x] funky plugins (json!wappie, ./screeching-cat!sabertooth)
|
|
56
|
-
const lModuleName = resolveHelpers.stripToModuleName(pRawModuleName);
|
|
57
51
|
const lResolvedPath = guessLikelyPath(
|
|
58
52
|
pBaseDirectory,
|
|
59
53
|
pFileDirectory,
|
|
60
|
-
|
|
54
|
+
pStrippedModuleName
|
|
61
55
|
);
|
|
62
56
|
|
|
63
|
-
|
|
57
|
+
return {
|
|
64
58
|
resolved: lResolvedPath,
|
|
65
|
-
coreModule:
|
|
59
|
+
coreModule: builtinModules.includes(pStrippedModuleName),
|
|
66
60
|
followable: fileExists(lResolvedPath) && lResolvedPath.endsWith(".js"),
|
|
67
61
|
couldNotResolve:
|
|
68
|
-
!
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
return {
|
|
72
|
-
...lReturnValue,
|
|
73
|
-
...resolveHelpers.addLicenseAttribute(
|
|
74
|
-
lModuleName,
|
|
75
|
-
pBaseDirectory,
|
|
76
|
-
pResolveOptions,
|
|
77
|
-
lReturnValue.resolved
|
|
78
|
-
),
|
|
79
|
-
dependencyTypes: determineDependencyTypes(
|
|
80
|
-
lReturnValue,
|
|
81
|
-
lModuleName,
|
|
82
|
-
getManifest(
|
|
83
|
-
pFileDirectory,
|
|
84
|
-
pBaseDirectory,
|
|
85
|
-
pResolveOptions.combinedDependencies
|
|
86
|
-
),
|
|
87
|
-
pFileDirectory,
|
|
88
|
-
pResolveOptions,
|
|
89
|
-
pBaseDirectory
|
|
90
|
-
),
|
|
62
|
+
!builtinModules.includes(pStrippedModuleName) &&
|
|
63
|
+
!fileExists(lResolvedPath),
|
|
91
64
|
};
|
|
92
65
|
};
|
|
93
66
|
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
const path = require("path");
|
|
2
|
+
const { builtinModules } = require("module");
|
|
2
3
|
const pathToPosix = require("../utl/path-to-posix");
|
|
3
|
-
const
|
|
4
|
-
const { isCore, isFollowable } = require("./module-classifiers");
|
|
5
|
-
const getManifest = require("./get-manifest");
|
|
6
|
-
const resolveHelpers = require("./resolve-helpers");
|
|
4
|
+
const { isFollowable } = require("./module-classifiers");
|
|
7
5
|
const resolve = require("./resolve");
|
|
8
6
|
|
|
9
7
|
function addResolutionAttributes(
|
|
@@ -14,7 +12,7 @@ function addResolutionAttributes(
|
|
|
14
12
|
) {
|
|
15
13
|
let lReturnValue = {};
|
|
16
14
|
|
|
17
|
-
if (
|
|
15
|
+
if (builtinModules.includes(pModuleName)) {
|
|
18
16
|
lReturnValue.coreModule = true;
|
|
19
17
|
} else {
|
|
20
18
|
try {
|
|
@@ -39,47 +37,21 @@ function addResolutionAttributes(
|
|
|
39
37
|
* resolves both CommonJS and ES6
|
|
40
38
|
*/
|
|
41
39
|
module.exports = function resolveCommonJS(
|
|
42
|
-
|
|
40
|
+
pStrippedModuleName,
|
|
43
41
|
pBaseDirectory,
|
|
44
42
|
pFileDirectory,
|
|
45
43
|
pResolveOptions
|
|
46
44
|
) {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
pFileDirectory,
|
|
50
|
-
pBaseDirectory,
|
|
51
|
-
pResolveOptions.combinedDependencies
|
|
52
|
-
);
|
|
53
|
-
|
|
54
|
-
let lReturnValue = {
|
|
55
|
-
resolved: lModuleName,
|
|
45
|
+
return {
|
|
46
|
+
resolved: pStrippedModuleName,
|
|
56
47
|
coreModule: false,
|
|
57
48
|
followable: false,
|
|
58
49
|
couldNotResolve: false,
|
|
59
|
-
dependencyTypes: ["undetermined"],
|
|
60
50
|
...addResolutionAttributes(
|
|
61
51
|
pBaseDirectory,
|
|
62
|
-
|
|
52
|
+
pStrippedModuleName,
|
|
63
53
|
pFileDirectory,
|
|
64
54
|
pResolveOptions
|
|
65
55
|
),
|
|
66
56
|
};
|
|
67
|
-
|
|
68
|
-
return {
|
|
69
|
-
...lReturnValue,
|
|
70
|
-
...resolveHelpers.addLicenseAttribute(
|
|
71
|
-
lModuleName,
|
|
72
|
-
lReturnValue.resolved,
|
|
73
|
-
{ baseDirectory: pBaseDirectory, fileDirectory: pFileDirectory },
|
|
74
|
-
pResolveOptions
|
|
75
|
-
),
|
|
76
|
-
dependencyTypes: determineDependencyTypes(
|
|
77
|
-
lReturnValue,
|
|
78
|
-
lModuleName,
|
|
79
|
-
lManifest,
|
|
80
|
-
pFileDirectory,
|
|
81
|
-
pResolveOptions,
|
|
82
|
-
pBaseDirectory
|
|
83
|
-
),
|
|
84
|
-
};
|
|
85
57
|
};
|
package/src/meta.js
CHANGED
|
@@ -174,6 +174,7 @@ module.exports = {
|
|
|
174
174
|
error: { type: "number" },
|
|
175
175
|
warn: { type: "number" },
|
|
176
176
|
info: { type: "number" },
|
|
177
|
+
ignore: { type: "number" },
|
|
177
178
|
totalCruised: { type: "number" },
|
|
178
179
|
totalDependenciesCruised: { type: "number" },
|
|
179
180
|
ruleSetUsed: { $ref: "#/definitions/RuleSetType" },
|
package/types/cruise-result.d.ts
CHANGED
|
@@ -278,6 +278,10 @@ export interface ISummary {
|
|
|
278
278
|
* the number of errors in the dependencies
|
|
279
279
|
*/
|
|
280
280
|
error: number;
|
|
281
|
+
/**
|
|
282
|
+
* the number of ignored notices in the dependencies
|
|
283
|
+
*/
|
|
284
|
+
ignore: number;
|
|
281
285
|
/**
|
|
282
286
|
* the number of informational level notices in the dependencies
|
|
283
287
|
*/
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
const _difference = require("lodash/difference");
|
|
2
|
-
const _uniqWith = require("lodash/uniqWith");
|
|
3
|
-
|
|
4
|
-
function violationIsEqual(pLeftViolation, pRightViolation) {
|
|
5
|
-
if (
|
|
6
|
-
pLeftViolation.rule.name === pRightViolation.rule.name &&
|
|
7
|
-
pLeftViolation.cycle
|
|
8
|
-
) {
|
|
9
|
-
return (
|
|
10
|
-
_difference(pLeftViolation.cycle, pRightViolation.cycle).length === 0
|
|
11
|
-
);
|
|
12
|
-
}
|
|
13
|
-
return false;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
module.exports = function deDuplicateViolations(pViolations) {
|
|
17
|
-
return _uniqWith(pViolations, violationIsEqual);
|
|
18
|
-
};
|