@@ -69,12 +69,13 @@ pub struct NpmPackageLockfileInfo {
69
69
pub integrity : Option < String > ,
70
70
pub dependencies : Vec < NpmPackageDependencyLockfileInfo > ,
71
71
pub optional_dependencies : Vec < NpmPackageDependencyLockfileInfo > ,
72
+ pub optional_peer_dependencies : Vec < NpmPackageDependencyLockfileInfo > ,
72
73
pub os : Vec < SmallStackString > ,
73
74
pub cpu : Vec < SmallStackString > ,
74
75
pub tarball : Option < StackString > ,
75
76
pub deprecated : bool ,
76
- pub scripts : bool ,
77
- pub bin : bool ,
77
+ pub has_scripts : bool ,
78
+ pub has_bin : bool ,
78
79
}
79
80
80
81
#[ derive( Debug , Clone , PartialEq , Eq ) ]
@@ -91,16 +92,18 @@ pub struct NpmPackageInfo {
91
92
pub dependencies : BTreeMap < StackString , StackString > ,
92
93
#[ serde( default ) ]
93
94
pub optional_dependencies : BTreeMap < StackString , StackString > ,
95
+ #[ serde( default ) ]
96
+ pub optional_peer_dependencies : BTreeMap < StackString , StackString > ,
94
97
pub os : Vec < SmallStackString > ,
95
98
pub cpu : Vec < SmallStackString > ,
96
99
#[ serde( skip_serializing_if = "Option::is_none" ) ]
97
100
pub tarball : Option < StackString > ,
98
101
#[ serde( default , skip_serializing_if = "is_false" ) ]
99
102
pub deprecated : bool ,
100
103
#[ serde( default , skip_serializing_if = "is_false" ) ]
101
- pub scripts : bool ,
104
+ pub has_scripts : bool ,
102
105
#[ serde( default , skip_serializing_if = "is_false" ) ]
103
- pub bin : bool ,
106
+ pub has_bin : bool ,
104
107
}
105
108
106
109
fn is_false ( value : & bool ) -> bool {
@@ -302,6 +305,8 @@ impl LockfileContent {
302
305
pub dependencies : Vec < StackString > ,
303
306
#[ serde( default ) ]
304
307
pub optional_dependencies : Vec < StackString > ,
308
+ #[ serde( default , skip_serializing_if = "Vec::is_empty" ) ]
309
+ pub optional_peer_dependencies : Vec < StackString > ,
305
310
#[ serde( default ) ]
306
311
pub os : Vec < SmallStackString > ,
307
312
#[ serde( default ) ]
@@ -311,9 +316,9 @@ impl LockfileContent {
311
316
#[ serde( default , skip_serializing_if = "is_false" ) ]
312
317
pub deprecated : bool ,
313
318
#[ serde( default , skip_serializing_if = "is_false" ) ]
314
- pub scripts : bool ,
319
+ pub has_scripts : bool ,
315
320
#[ serde( default , skip_serializing_if = "is_false" ) ]
316
- pub bin : bool ,
321
+ pub has_bin : bool ,
317
322
}
318
323
319
324
#[ derive( Debug , Deserialize ) ]
@@ -373,6 +378,8 @@ impl LockfileContent {
373
378
BTreeMap :: new ( ) ;
374
379
let mut optional_dependencies =
375
380
BTreeMap :: < StackString , StackString > :: new ( ) ;
381
+ let mut optional_peer_dependencies =
382
+ BTreeMap :: < StackString , StackString > :: new ( ) ;
376
383
377
384
for dep in value. dependencies . into_iter ( ) {
378
385
handle_dep ( dep, & version_by_dep_name, & mut dependencies) ?;
@@ -384,6 +391,14 @@ impl LockfileContent {
384
391
& mut optional_dependencies,
385
392
) ?;
386
393
}
394
+ for dep in value. optional_peer_dependencies . into_iter ( ) {
395
+ handle_dep (
396
+ dep,
397
+ & version_by_dep_name,
398
+ & mut optional_peer_dependencies,
399
+ ) ?;
400
+ }
401
+
387
402
npm. insert (
388
403
key,
389
404
NpmPackageInfo {
@@ -393,9 +408,10 @@ impl LockfileContent {
393
408
os : value. os ,
394
409
tarball : value. tarball ,
395
410
optional_dependencies,
411
+ optional_peer_dependencies,
396
412
deprecated : value. deprecated ,
397
- scripts : value. scripts ,
398
- bin : value. bin ,
413
+ has_scripts : value. has_scripts ,
414
+ has_bin : value. has_bin ,
399
415
} ,
400
416
) ;
401
417
}
@@ -909,18 +925,24 @@ impl Lockfile {
909
925
. into_iter ( )
910
926
. map ( |dep| ( dep. name , dep. id ) )
911
927
. collect :: < BTreeMap < StackString , StackString > > ( ) ;
928
+ let optional_peer_dependencies = package_info
929
+ . optional_peer_dependencies
930
+ . into_iter ( )
931
+ . map ( |dep| ( dep. name , dep. id ) )
932
+ . collect :: < BTreeMap < StackString , StackString > > ( ) ;
912
933
913
934
let entry = self . content . packages . npm . entry ( package_info. serialized_id ) ;
914
935
let package_info = NpmPackageInfo {
915
936
integrity : package_info. integrity ,
916
937
dependencies,
917
938
optional_dependencies,
939
+ optional_peer_dependencies,
918
940
os : package_info. os ,
919
941
cpu : package_info. cpu ,
920
942
tarball : package_info. tarball ,
921
943
deprecated : package_info. deprecated ,
922
- scripts : package_info. scripts ,
923
- bin : package_info. bin ,
944
+ has_scripts : package_info. has_scripts ,
945
+ has_bin : package_info. has_bin ,
924
946
} ;
925
947
match entry {
926
948
BTreeMapEntry :: Vacant ( entry) => {
@@ -1286,12 +1308,13 @@ mod tests {
1286
1308
integrity : Some ( "sha512-MqBkQh/OHTS2egovRtLk45wEyNXwF+cokD+1YPf9u5VfJiRdAiRwB2froX5Co9Rh20xs4siNPm8naNotSD6RBw==" . to_string ( ) ) ,
1287
1309
dependencies : vec ! [ ] ,
1288
1310
optional_dependencies : vec ! [ ] ,
1311
+ optional_peer_dependencies : vec ! [ ] ,
1289
1312
os : vec ! [ ] ,
1290
1313
cpu : vec ! [ ] ,
1291
1314
tarball : None ,
1292
1315
deprecated : false ,
1293
- scripts : false ,
1294
- bin : false ,
1316
+ has_scripts : false ,
1317
+ has_bin : false ,
1295
1318
} ;
1296
1319
lockfile. insert_npm_package ( npm_package) ;
1297
1320
assert ! ( !lockfile. has_content_changed) ;
@@ -1302,12 +1325,13 @@ mod tests {
1302
1325
integrity : Some ( "sha512-1fygroTLlHu66zi26VoTDv8yRgm0Fccecssto+MhsZ0D/DGW2sm8E8AjW7NU5VVTRt5GxbeZ5qBuJr+HyLYkjQ==" . to_string ( ) ) ,
1303
1326
dependencies : vec ! [ ] ,
1304
1327
optional_dependencies : vec ! [ ] ,
1328
+ optional_peer_dependencies : vec ! [ ] ,
1305
1329
os : vec ! [ ] ,
1306
1330
cpu : vec ! [ ] ,
1307
1331
tarball : None ,
1308
1332
deprecated : false ,
1309
- scripts : false ,
1310
- bin : false ,
1333
+ has_scripts : false ,
1334
+ has_bin : false ,
1311
1335
} ;
1312
1336
lockfile. insert_npm_package ( npm_package) ;
1313
1337
assert ! ( lockfile. has_content_changed) ;
@@ -1318,12 +1342,13 @@ mod tests {
1318
1342
integrity : Some ( "sha512-R0XvVJ9WusLiqTCEiGCmICCMplcCkIwwR11mOSD9CR5u+IXYdiseeEuXCVAjS54zqwkLcPNnmU4OeJ6tUrWhDw==" . to_string ( ) ) ,
1319
1343
dependencies : vec ! [ ] ,
1320
1344
optional_dependencies : vec ! [ ] ,
1345
+ optional_peer_dependencies : vec ! [ ] ,
1321
1346
os : vec ! [ ] ,
1322
1347
cpu : vec ! [ ] ,
1323
1348
tarball : None ,
1324
1349
deprecated : false ,
1325
- scripts : false ,
1326
- bin : false ,
1350
+ has_scripts : false ,
1351
+ has_bin : false ,
1327
1352
} ;
1328
1353
// Not present in lockfile yet, should be inserted
1329
1354
lockfile. insert_npm_package ( npm_package. clone ( ) ) ;
@@ -1339,12 +1364,13 @@ mod tests {
1339
1364
integrity : Some ( "sha512-foobar" . to_string ( ) ) ,
1340
1365
dependencies : vec ! [ ] ,
1341
1366
optional_dependencies : vec ! [ ] ,
1367
+ optional_peer_dependencies : vec ! [ ] ,
1342
1368
os : vec ! [ ] ,
1343
1369
cpu : vec ! [ ] ,
1344
1370
tarball : None ,
1345
1371
deprecated : false ,
1346
- scripts : false ,
1347
- bin : false ,
1372
+ has_scripts : false ,
1373
+ has_bin : false ,
1348
1374
} ;
1349
1375
// Now present in lockfile, should be changed due to different integrity
1350
1376
lockfile. insert_npm_package ( npm_package) ;
0 commit comments