diff --git a/crates/turborepo-lockfiles/fixtures/berry.lock b/crates/turborepo-lockfiles/fixtures/berry.lock index f4436e4aeb2f6..2ae79f564e51e 100644 --- a/crates/turborepo-lockfiles/fixtures/berry.lock +++ b/crates/turborepo-lockfiles/fixtures/berry.lock @@ -1263,6 +1263,7 @@ eslint-config-turbo@latest: debug: ^3.2.7 dependenciesMeta: debug@4.3.4: + built: false unplugged: true peerDependenciesMeta: eslint: diff --git a/crates/turborepo-lockfiles/src/berry/mod.rs b/crates/turborepo-lockfiles/src/berry/mod.rs index ae6a886159cfa..586eddfda9774 100644 --- a/crates/turborepo-lockfiles/src/berry/mod.rs +++ b/crates/turborepo-lockfiles/src/berry/mod.rs @@ -96,6 +96,7 @@ struct BerryPackage { #[derive(Debug, Deserialize, PartialEq, Eq, Hash, PartialOrd, Ord, Clone, Copy)] struct DependencyMeta { + built: Option, optional: Option, unplugged: Option, } diff --git a/crates/turborepo-lockfiles/src/berry/ser.rs b/crates/turborepo-lockfiles/src/berry/ser.rs index 20a15c6ecb545..35327bf1d598c 100644 --- a/crates/turborepo-lockfiles/src/berry/ser.rs +++ b/crates/turborepo-lockfiles/src/berry/ser.rs @@ -147,27 +147,34 @@ where let mut string = String::new(); let mut first = true; - let mut add_line = |dependency: &str, field: &str| { + let mut add_line = |dependency: &str, settings: &[(Option, &str)]| { if !first { string.push('\n'); } - string.push_str(&format!( - " {}:\n {}: true", - wrap_string(dependency), - wrap_string(field) - )); + string.push_str(&format!(" {}:\n", wrap_string(dependency))); + + for (i, (setting, field)) in settings.iter().enumerate() { + if let Some(value) = setting { + string.push_str(&format!(" {}: {}", wrap_string(field), value)); + if i < settings.len() - 1 { + string.push('\n'); + } + } + } first = false; }; for (dependency, meta) in metadata { let dependency = dependency.as_ref(); - if meta.optional.unwrap_or_default() { - add_line(dependency, "optional"); - } - if meta.unplugged.unwrap_or_default() { - add_line(dependency, "unplugged"); + let settings = [ + (meta.built, "built"), + (meta.optional, "optional"), + (meta.unplugged, "unplugged"), + ]; + if settings.iter().any(|&(setting, _)| setting.is_some()) { + add_line(dependency, &settings); } }