Skip to content

Commit 3e46d16

Browse files
committed
rename to optionalPeers
1 parent a55a866 commit 3e46d16

File tree

6 files changed

+31
-38
lines changed

6 files changed

+31
-38
lines changed

src/graphs.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ struct LockfileNpmGraphPackage {
7777
integrity: Option<String>,
7878
dependencies: BTreeMap<StackString, LockfileNpmPackageId>,
7979
optional_dependencies: BTreeMap<StackString, LockfileNpmPackageId>,
80-
optional_peer_dependencies: BTreeMap<StackString, LockfileNpmPackageId>,
80+
optional_peers: BTreeMap<StackString, LockfileNpmPackageId>,
8181
os: Vec<SmallStackString>,
8282
cpu: Vec<SmallStackString>,
8383
tarball: Option<StackString>,
@@ -184,8 +184,8 @@ impl LockfilePackageGraph {
184184
deprecated: package.deprecated,
185185
has_scripts: package.has_scripts,
186186
has_bin: package.has_bin,
187-
optional_peer_dependencies: package
188-
.optional_peer_dependencies
187+
optional_peers: package
188+
.optional_peers
189189
.iter()
190190
.map(|(name, dep_id)| {
191191
(name.clone(), LockfileNpmPackageId(dep_id.clone()))
@@ -397,8 +397,8 @@ impl LockfilePackageGraph {
397397
deprecated: package.deprecated,
398398
has_scripts: package.has_scripts,
399399
has_bin: package.has_bin,
400-
optional_peer_dependencies: package
401-
.optional_peer_dependencies
400+
optional_peers: package
401+
.optional_peers
402402
.into_iter()
403403
.map(|(name, id)| (name, id.0))
404404
.collect(),

src/lib.rs

+14-18
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ pub struct NpmPackageLockfileInfo {
6969
pub integrity: Option<String>,
7070
pub dependencies: Vec<NpmPackageDependencyLockfileInfo>,
7171
pub optional_dependencies: Vec<NpmPackageDependencyLockfileInfo>,
72-
pub optional_peer_dependencies: Vec<NpmPackageDependencyLockfileInfo>,
72+
pub optional_peers: Vec<NpmPackageDependencyLockfileInfo>,
7373
pub os: Vec<SmallStackString>,
7474
pub cpu: Vec<SmallStackString>,
7575
pub tarball: Option<StackString>,
@@ -93,7 +93,7 @@ pub struct NpmPackageInfo {
9393
#[serde(default)]
9494
pub optional_dependencies: BTreeMap<StackString, StackString>,
9595
#[serde(default)]
96-
pub optional_peer_dependencies: BTreeMap<StackString, StackString>,
96+
pub optional_peers: BTreeMap<StackString, StackString>,
9797
pub os: Vec<SmallStackString>,
9898
pub cpu: Vec<SmallStackString>,
9999
#[serde(skip_serializing_if = "Option::is_none")]
@@ -306,7 +306,7 @@ impl LockfileContent {
306306
#[serde(default)]
307307
pub optional_dependencies: Vec<StackString>,
308308
#[serde(default, skip_serializing_if = "Vec::is_empty")]
309-
pub optional_peer_dependencies: Vec<StackString>,
309+
pub optional_peers: Vec<StackString>,
310310
#[serde(default)]
311311
pub os: Vec<SmallStackString>,
312312
#[serde(default)]
@@ -378,7 +378,7 @@ impl LockfileContent {
378378
BTreeMap::new();
379379
let mut optional_dependencies =
380380
BTreeMap::<StackString, StackString>::new();
381-
let mut optional_peer_dependencies =
381+
let mut optional_peers =
382382
BTreeMap::<StackString, StackString>::new();
383383

384384
for dep in value.dependencies.into_iter() {
@@ -391,12 +391,8 @@ impl LockfileContent {
391391
&mut optional_dependencies,
392392
)?;
393393
}
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-
)?;
394+
for dep in value.optional_peers.into_iter() {
395+
handle_dep(dep, &version_by_dep_name, &mut optional_peers)?;
400396
}
401397

402398
npm.insert(
@@ -408,7 +404,7 @@ impl LockfileContent {
408404
os: value.os,
409405
tarball: value.tarball,
410406
optional_dependencies,
411-
optional_peer_dependencies,
407+
optional_peers,
412408
deprecated: value.deprecated,
413409
has_scripts: value.has_scripts,
414410
has_bin: value.has_bin,
@@ -925,8 +921,8 @@ impl Lockfile {
925921
.into_iter()
926922
.map(|dep| (dep.name, dep.id))
927923
.collect::<BTreeMap<StackString, StackString>>();
928-
let optional_peer_dependencies = package_info
929-
.optional_peer_dependencies
924+
let optional_peers = package_info
925+
.optional_peers
930926
.into_iter()
931927
.map(|dep| (dep.name, dep.id))
932928
.collect::<BTreeMap<StackString, StackString>>();
@@ -936,7 +932,7 @@ impl Lockfile {
936932
integrity: package_info.integrity,
937933
dependencies,
938934
optional_dependencies,
939-
optional_peer_dependencies,
935+
optional_peers,
940936
os: package_info.os,
941937
cpu: package_info.cpu,
942938
tarball: package_info.tarball,
@@ -1308,7 +1304,7 @@ mod tests {
13081304
integrity: Some("sha512-MqBkQh/OHTS2egovRtLk45wEyNXwF+cokD+1YPf9u5VfJiRdAiRwB2froX5Co9Rh20xs4siNPm8naNotSD6RBw==".to_string()),
13091305
dependencies: vec![],
13101306
optional_dependencies: vec![],
1311-
optional_peer_dependencies: vec![],
1307+
optional_peers: vec![],
13121308
os: vec![],
13131309
cpu: vec![],
13141310
tarball: None,
@@ -1325,7 +1321,7 @@ mod tests {
13251321
integrity: Some("sha512-1fygroTLlHu66zi26VoTDv8yRgm0Fccecssto+MhsZ0D/DGW2sm8E8AjW7NU5VVTRt5GxbeZ5qBuJr+HyLYkjQ==".to_string()),
13261322
dependencies: vec![],
13271323
optional_dependencies: vec![],
1328-
optional_peer_dependencies: vec![],
1324+
optional_peers: vec![],
13291325
os: vec![],
13301326
cpu: vec![],
13311327
tarball: None,
@@ -1342,7 +1338,7 @@ mod tests {
13421338
integrity: Some("sha512-R0XvVJ9WusLiqTCEiGCmICCMplcCkIwwR11mOSD9CR5u+IXYdiseeEuXCVAjS54zqwkLcPNnmU4OeJ6tUrWhDw==".to_string()),
13431339
dependencies: vec![],
13441340
optional_dependencies: vec![],
1345-
optional_peer_dependencies: vec![],
1341+
optional_peers: vec![],
13461342
os: vec![],
13471343
cpu: vec![],
13481344
tarball: None,
@@ -1364,7 +1360,7 @@ mod tests {
13641360
integrity: Some("sha512-foobar".to_string()),
13651361
dependencies: vec![],
13661362
optional_dependencies: vec![],
1367-
optional_peer_dependencies: vec![],
1363+
optional_peers: vec![],
13681364
os: vec![],
13691365
cpu: vec![],
13701366
tarball: None,

src/printer.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ struct SerializedNpmPkg<'a> {
3737
#[serde(skip_serializing_if = "Vec::is_empty")]
3838
optional_dependencies: Vec<Cow<'a, str>>,
3939
#[serde(skip_serializing_if = "Vec::is_empty")]
40-
optional_peer_dependencies: Vec<Cow<'a, str>>,
40+
optional_peers: Vec<Cow<'a, str>>,
4141
#[serde(skip_serializing_if = "Vec::is_empty")]
4242
os: Vec<SmallStackString>,
4343
#[serde(skip_serializing_if = "Vec::is_empty")]
@@ -269,8 +269,8 @@ pub fn print_v5_content(content: &LockfileContent) -> String {
269269
handle_deps(&value.dependencies, &pkg_had_multiple_versions);
270270
let optional_dependencies =
271271
handle_deps(&value.optional_dependencies, &pkg_had_multiple_versions);
272-
let optional_peer_dependencies = handle_deps(
273-
&value.optional_peer_dependencies,
272+
let optional_peers = handle_deps(
273+
&value.optional_peers,
274274
&pkg_had_multiple_versions,
275275
);
276276
(
@@ -279,7 +279,7 @@ pub fn print_v5_content(content: &LockfileContent) -> String {
279279
integrity: value.integrity.as_deref(),
280280
dependencies,
281281
optional_dependencies,
282-
optional_peer_dependencies,
282+
optional_peers,
283283
os: value.os.clone(),
284284
cpu: value.cpu.clone(),
285285
tarball: value.tarball.as_deref(),

src/transforms.rs

+6-9
Original file line numberDiff line numberDiff line change
@@ -296,14 +296,11 @@ pub async fn transform4_to_5(
296296
value.insert("optionalDependencies".into(), new_optional_deps.into());
297297
}
298298
let mut new_optional_peer_deps = Vec::new();
299-
if !result.optional_peer_dependencies.is_empty() {
300-
for (key, value) in result.optional_peer_dependencies {
299+
if !result.optional_peers.is_empty() {
300+
for (key, value) in result.optional_peers {
301301
new_optional_peer_deps.push(format!("{}@{}", key, value));
302302
}
303-
value.insert(
304-
"optionalPeerDependencies".into(),
305-
new_optional_peer_deps.into(),
306-
);
303+
value.insert("optionalPeers".into(), new_optional_peer_deps.into());
307304
}
308305

309306
if existing_deps.is_empty() {
@@ -348,7 +345,7 @@ pub async fn transform4_to_5(
348345
pub struct Lockfile5NpmInfo {
349346
pub tarball_url: Option<String>,
350347
pub optional_dependencies: BTreeMap<String, String>,
351-
pub optional_peer_dependencies: BTreeMap<String, String>,
348+
pub optional_peers: BTreeMap<String, String>,
352349
pub cpu: Vec<String>,
353350
pub os: Vec<String>,
354351
pub deprecated: bool,
@@ -615,7 +612,7 @@ mod test {
615612
(
616613
617614
Lockfile5NpmInfo {
618-
optional_peer_dependencies: [("package-z", "1.0.0")]
615+
optional_peers: [("package-z", "1.0.0")]
619616
.into_iter()
620617
.map(|(k, v)| (k.to_string(), v.to_string()))
621618
.collect(),
@@ -700,7 +697,7 @@ mod test {
700697
},
701698
702699
"integrity": "sha512-foobar",
703-
"optionalPeerDependencies": ["[email protected]"],
700+
"optionalPeers": ["[email protected]"],
704701
},
705702
706703
"integrity": "sha512-foobar",

tests/registry_data/@[email protected]

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@
55
"optionalDependencies": { "othername": "npm:@b/[email protected]" },
66
"hasBin": true,
77
"hasScripts": true,
8-
"optionalPeerDependencies": { "optionalpeerdep": "npm:@z/[email protected]" }
8+
"optionalPeers": { "optionalpeerdep": "npm:@z/[email protected]" }
99
}

tests/specs/transforms/upgrades_v3_npm_dep_different_key_name.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
"optionalDependencies": [
2828
"othername@npm:@b/[email protected]"
2929
],
30-
"optionalPeerDependencies": [
30+
"optionalPeers": [
3131
"optionalpeerdep@npm:@z/[email protected]"
3232
],
3333
"os": [

0 commit comments

Comments
 (0)