@@ -29,7 +29,12 @@ export const parseNpmLockV2Project = async (
29
29
pkgLockContent : string ,
30
30
options : ProjectParseOptions ,
31
31
) : Promise < DepGraph > => {
32
- const { includeDevDeps, strictOutOfSync, includeOptionalDeps } = options ;
32
+ const {
33
+ includeDevDeps,
34
+ strictOutOfSync,
35
+ includeOptionalDeps,
36
+ pruneNpmStrictOutOfSync,
37
+ } = options ;
33
38
34
39
const pkgJson : PackageJsonBase = parsePkgJson ( pkgJsonContent ) ;
35
40
const pkgs = extractPkgsFromNpmLockV2 ( pkgLockContent ) ;
@@ -38,6 +43,7 @@ export const parseNpmLockV2Project = async (
38
43
includeDevDeps,
39
44
includeOptionalDeps,
40
45
strictOutOfSync,
46
+ pruneNpmStrictOutOfSync,
41
47
} ) ;
42
48
43
49
return depgraph ;
@@ -48,8 +54,12 @@ export const buildDepGraphNpmLockV2 = async (
48
54
pkgJson : PackageJsonBase ,
49
55
options : DepGraphBuildOptions ,
50
56
) : Promise < DepGraph > => {
51
- const { includeDevDeps, strictOutOfSync, includeOptionalDeps } = options ;
52
-
57
+ const {
58
+ includeDevDeps,
59
+ strictOutOfSync,
60
+ includeOptionalDeps,
61
+ pruneNpmStrictOutOfSync,
62
+ } = options ;
53
63
const depGraphBuilder = new DepGraphBuilder (
54
64
{ name : 'npm' } ,
55
65
{ name : pkgJson . name as string , version : pkgJson . version } ,
@@ -101,6 +111,7 @@ export const buildDepGraphNpmLockV2 = async (
101
111
[ ] ,
102
112
pkgKeysByName ,
103
113
pkgJson . overrides ,
114
+ pruneNpmStrictOutOfSync ,
104
115
) ;
105
116
return depGraphBuilder . build ( ) ;
106
117
} ;
@@ -123,6 +134,7 @@ const dfsVisit = async (
123
134
ancestry : Ancestry [ ] ,
124
135
pkgKeysByName : Map < string , string [ ] > ,
125
136
overrides : Overrides | undefined ,
137
+ pruneNpmStrictOutOfSync ?: boolean ,
126
138
) : Promise < void > => {
127
139
visitedMap . add ( node . id ) ;
128
140
@@ -149,6 +161,7 @@ const dfsVisit = async (
149
161
] ,
150
162
pkgKeysByName ,
151
163
overrides ,
164
+ pruneNpmStrictOutOfSync ,
152
165
) ;
153
166
154
167
if ( ! visitedMap . has ( childNode . id ) ) {
@@ -189,6 +202,7 @@ const getChildNode = (
189
202
ancestry : Ancestry [ ] ,
190
203
pkgKeysByName : Map < string , string [ ] > ,
191
204
overrides ?: Overrides ,
205
+ pruneNpmStrictOutOfSync ?: boolean ,
192
206
) => {
193
207
let version = depInfo . version ;
194
208
@@ -210,6 +224,7 @@ const getChildNode = (
210
224
ancestry ,
211
225
pkgs ,
212
226
pkgKeysByName ,
227
+ pruneNpmStrictOutOfSync ,
213
228
) ;
214
229
215
230
if ( ! childNodeKey ) {
@@ -292,6 +307,7 @@ export const getChildNodeKey = (
292
307
ancestry : { name : string ; key : string ; inBundle : boolean } [ ] ,
293
308
pkgs : Record < string , NpmLockPkg > ,
294
309
pkgKeysByName : Map < string , string [ ] > ,
310
+ pruneNpmStrictOutOfSync ?: boolean ,
295
311
) : string | undefined => {
296
312
// This is a list of all our possible options for the childKey
297
313
const candidateKeys = pkgKeysByName . get ( name ) ;
@@ -306,8 +322,10 @@ export const getChildNodeKey = (
306
322
if (
307
323
semver . validRange ( version ) &&
308
324
pkgs [ candidateKeys [ 0 ] ] . version &&
309
- ! semver . satisfies ( pkgs [ candidateKeys [ 0 ] ] . version , version )
325
+ ! semver . satisfies ( pkgs [ candidateKeys [ 0 ] ] . version , version ) &&
326
+ pruneNpmStrictOutOfSync
310
327
) {
328
+ //TODO: Add some logs to monitor
311
329
return undefined ;
312
330
}
313
331
return candidateKeys [ 0 ] ;
0 commit comments