dependency-cruiser 10.4.0-beta-2 → 10.4.0-beta-3
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/extract/resolve/determine-dependency-types.js +2 -3
- package/src/extract/resolve/index.js +11 -11
- package/src/main/utl/normalize-re-properties.js +2 -0
- package/src/meta.js +1 -1
- package/src/schema/configuration.schema.js +2 -0
- package/src/schema/cruise-result.schema.js +2 -0
- package/src/validate/match-dependency-rule.js +2 -0
- package/src/validate/matchers.js +18 -0
- package/types/restrictions.d.ts +11 -4
package/package.json
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
const path = require("path");
|
|
2
|
-
const { builtinModules } = require("module");
|
|
3
2
|
const _has = require("lodash/has");
|
|
4
3
|
const {
|
|
5
4
|
isRelativeModuleName,
|
|
@@ -167,8 +166,8 @@ module.exports = function determineDependencyTypes(
|
|
|
167
166
|
|
|
168
167
|
if (pDependency.couldNotResolve) {
|
|
169
168
|
lReturnValue = ["unknown"];
|
|
170
|
-
} else if (
|
|
171
|
-
// this
|
|
169
|
+
} else if (pDependency.coreModule) {
|
|
170
|
+
// this business seems duplicate (it's already in
|
|
172
171
|
// the passed object as `coreModule`- determined by the resolve-AMD or
|
|
173
172
|
// resolve-commonJS module). I want to deprecate the `coreModule`
|
|
174
173
|
// attribute in favor of this one and determining it here will make
|
|
@@ -142,7 +142,7 @@ module.exports = function resolve(
|
|
|
142
142
|
pFileDirectory,
|
|
143
143
|
pResolveOptions
|
|
144
144
|
) {
|
|
145
|
-
let
|
|
145
|
+
let lResolvedDependency = resolveWithRetry(
|
|
146
146
|
pDependency,
|
|
147
147
|
pBaseDirectory,
|
|
148
148
|
pFileDirectory,
|
|
@@ -152,16 +152,16 @@ module.exports = function resolve(
|
|
|
152
152
|
pDependency.module
|
|
153
153
|
);
|
|
154
154
|
|
|
155
|
-
|
|
156
|
-
...
|
|
155
|
+
lResolvedDependency = {
|
|
156
|
+
...lResolvedDependency,
|
|
157
157
|
...resolveHelpers.addLicenseAttribute(
|
|
158
158
|
lStrippedModuleName,
|
|
159
|
-
|
|
159
|
+
lResolvedDependency.resolved,
|
|
160
160
|
{ baseDirectory: pBaseDirectory, fileDirectory: pFileDirectory },
|
|
161
161
|
pResolveOptions
|
|
162
162
|
),
|
|
163
163
|
dependencyTypes: determineDependencyTypes(
|
|
164
|
-
{ ...pDependency, ...
|
|
164
|
+
{ ...pDependency, ...lResolvedDependency },
|
|
165
165
|
lStrippedModuleName,
|
|
166
166
|
getManifest(
|
|
167
167
|
pFileDirectory,
|
|
@@ -176,11 +176,11 @@ module.exports = function resolve(
|
|
|
176
176
|
|
|
177
177
|
if (
|
|
178
178
|
!pResolveOptions.symlinks &&
|
|
179
|
-
!
|
|
180
|
-
!
|
|
179
|
+
!lResolvedDependency.coreModule &&
|
|
180
|
+
!lResolvedDependency.couldNotResolve
|
|
181
181
|
) {
|
|
182
182
|
try {
|
|
183
|
-
|
|
183
|
+
lResolvedDependency.resolved = pathToPosix(
|
|
184
184
|
path.relative(
|
|
185
185
|
pBaseDirectory,
|
|
186
186
|
fs.realpathSync(
|
|
@@ -192,15 +192,15 @@ module.exports = function resolve(
|
|
|
192
192
|
again corresponds with a real file on disk
|
|
193
193
|
*/
|
|
194
194
|
// eslint-disable-next-line no-control-regex
|
|
195
|
-
|
|
195
|
+
lResolvedDependency.resolved.replace(/\u0000#/g, "#")
|
|
196
196
|
)
|
|
197
197
|
)
|
|
198
198
|
)
|
|
199
199
|
)
|
|
200
200
|
);
|
|
201
201
|
} catch (pError) {
|
|
202
|
-
|
|
202
|
+
lResolvedDependency.couldNotResolve = true;
|
|
203
203
|
}
|
|
204
204
|
}
|
|
205
|
-
return
|
|
205
|
+
return lResolvedDependency;
|
|
206
206
|
};
|
package/src/meta.js
CHANGED
|
@@ -162,6 +162,8 @@ module.exports = {
|
|
|
162
162
|
moreThanOneDependencyType: { type: "boolean" },
|
|
163
163
|
license: { $ref: "#/definitions/REAsStringsType" },
|
|
164
164
|
licenseNot: { $ref: "#/definitions/REAsStringsType" },
|
|
165
|
+
via: { $ref: "#/definitions/REAsStringsType" },
|
|
166
|
+
viaNot: { $ref: "#/definitions/REAsStringsType" },
|
|
165
167
|
},
|
|
166
168
|
},
|
|
167
169
|
DependentsModuleRestrictionType: {
|
|
@@ -334,6 +334,8 @@ module.exports = {
|
|
|
334
334
|
moreThanOneDependencyType: { type: "boolean" },
|
|
335
335
|
license: { $ref: "#/definitions/REAsStringsType" },
|
|
336
336
|
licenseNot: { $ref: "#/definitions/REAsStringsType" },
|
|
337
|
+
via: { $ref: "#/definitions/REAsStringsType" },
|
|
338
|
+
viaNot: { $ref: "#/definitions/REAsStringsType" },
|
|
337
339
|
},
|
|
338
340
|
},
|
|
339
341
|
DependentsModuleRestrictionType: {
|
|
@@ -37,6 +37,8 @@ function match(pFrom, pTo) {
|
|
|
37
37
|
matchers.toLicenseNot(pRule, pTo) &&
|
|
38
38
|
matchers.toExoticRequire(pRule, pTo) &&
|
|
39
39
|
matchers.toExoticRequireNot(pRule, pTo) &&
|
|
40
|
+
matchers.toVia(pRule, pTo) &&
|
|
41
|
+
matchers.toViaNot(pRule, pTo) &&
|
|
40
42
|
// preCompilationOnly is not a mandatory attribute, but if the attribute
|
|
41
43
|
// is in the rule but not in the dependency there won't be a match
|
|
42
44
|
// anyway, so we can use the default propertyEquals method regardless
|
package/src/validate/matchers.js
CHANGED
|
@@ -100,6 +100,22 @@ function toExoticRequireNot(pRule, pDependency) {
|
|
|
100
100
|
);
|
|
101
101
|
}
|
|
102
102
|
|
|
103
|
+
function toViaNot(pRule, pDependency) {
|
|
104
|
+
return Boolean(
|
|
105
|
+
!pRule.to.viaNot ||
|
|
106
|
+
(pDependency.cycle &&
|
|
107
|
+
!pDependency.cycle.some((pVia) => pVia.match(pRule.to.viaNot)))
|
|
108
|
+
);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
function toVia(pRule, pDependency) {
|
|
112
|
+
return Boolean(
|
|
113
|
+
!pRule.to.via ||
|
|
114
|
+
(pDependency.cycle &&
|
|
115
|
+
pDependency.cycle.some((pVia) => pVia.match(pRule.to.via)))
|
|
116
|
+
);
|
|
117
|
+
}
|
|
118
|
+
|
|
103
119
|
module.exports = {
|
|
104
120
|
_replaceGroupPlaceholders,
|
|
105
121
|
fromPath,
|
|
@@ -115,4 +131,6 @@ module.exports = {
|
|
|
115
131
|
toLicenseNot,
|
|
116
132
|
toExoticRequire,
|
|
117
133
|
toExoticRequireNot,
|
|
134
|
+
toVia,
|
|
135
|
+
toViaNot,
|
|
118
136
|
};
|
package/types/restrictions.d.ts
CHANGED
|
@@ -34,11 +34,18 @@ export interface IToRestriction extends IBaseRestrictionType {
|
|
|
34
34
|
*/
|
|
35
35
|
circular?: boolean;
|
|
36
36
|
/**
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
*
|
|
37
|
+
* For circular dependencies - whether or not to match cycles that include include modules
|
|
38
|
+
* with this regular expression. E.g. to allow all cycles, except when they go through one
|
|
39
|
+
* specific module. Typically to temporarily disallow some cycles with a lower severity -
|
|
40
|
+
* setting up a rule with a viaNot that ignores them.
|
|
40
41
|
*/
|
|
41
|
-
|
|
42
|
+
via?: string | string[];
|
|
43
|
+
/**
|
|
44
|
+
* For circular dependencies - whether or not to match cycles that do NOT include modules
|
|
45
|
+
* with this regular expression. E.g. to disallow all cycles, except when they go through
|
|
46
|
+
* one specific module. Typically to temporarily allow some cycles until they're removed.
|
|
47
|
+
*/
|
|
48
|
+
viaNot?: string | string[];
|
|
42
49
|
/**
|
|
43
50
|
* Whether or not to match when the dependency is a dynamic one.
|
|
44
51
|
*/
|