diff --git a/crates/turborepo-lockfiles/fixtures/pnpm-v9.yaml b/crates/turborepo-lockfiles/fixtures/pnpm-v9.yaml new file mode 100644 index 0000000000000..862f8c8080e4b --- /dev/null +++ b/crates/turborepo-lockfiles/fixtures/pnpm-v9.yaml @@ -0,0 +1,125 @@ +lockfileVersion: "9.0" + +settings: + autoInstallPeers: true + excludeLinksFromLockfile: false + +importers: + .: + devDependencies: + turbo: + specifier: canary + version: 1.13.3-canary.1 + + apps/apps-a: + dependencies: + pkg-a: + specifier: workspace:* + version: link:../../packages/pkg-a + tooling-config: + specifier: workspace:* + version: link:../../packages/tooling-config + + apps/apps-b: + dependencies: + tooling-config: + specifier: workspace:* + version: link:../../packages/tooling-config + + packages/pkg-a: + dependencies: + tooling-config: + specifier: workspace:* + version: link:../tooling-config + + packages/pkg-b: + dependencies: + tooling-config: + specifier: workspace:* + version: link:../tooling-config + + packages/tooling-config: {} + +packages: + turbo-darwin-64@1.13.3-canary.1: + resolution: + { + integrity: sha512-1xfKCf/d7mD7oGT1qBnD5pYsZfI43Wftlo/N0GTpBLDjKhfJifBvng9ns5grhs79wNiIdDxYYGt6pHOUzc+6YQ==, + } + cpu: [x64] + os: [darwin] + + turbo-darwin-arm64@1.13.3-canary.1: + resolution: + { + integrity: sha512-uNK9QnlDJBLuaR7l4/68AoKByQ+q+rT9OyvizzUV2KZ8r2u/Sv+f3GiV48qxtG1duYlWLlLnDGuEnUPKEq0WZg==, + } + cpu: [arm64] + os: [darwin] + + turbo-linux-64@1.13.3-canary.1: + resolution: + { + integrity: sha512-D/RRtqHch0I5q/Pod7mgLPGrvjcDpvBe95yp5hNy59+ZSyKHlkDrm/pQaA/+6mdjHEQB8eIL/18nrKx/B5qduA==, + } + cpu: [x64] + os: [linux] + + turbo-linux-arm64@1.13.3-canary.1: + resolution: + { + integrity: sha512-FXwgkadDZr6mPLN7lmlc0ESRZFfXDONEKTQbDV9h4n/7I0HOehMM0CrWZsptoekKEKFEqQDxZo5QXFDZON0cww==, + } + cpu: [arm64] + os: [linux] + + turbo-windows-64@1.13.3-canary.1: + resolution: + { + integrity: sha512-ce6TENLbCeFAWVrJtLMOjv7FkPCpfSNvczFpaolbOB9omPW3uO4hXMbpqk14hgsU8OsmMt61rLzI38L0miJuEw==, + } + cpu: [x64] + os: [win32] + + turbo-windows-arm64@1.13.3-canary.1: + resolution: + { + integrity: sha512-7sm8tZRqcmWo/D3Mb513/diVZuFC6rwz/ZaW8IGsEcLrUdqq6qSRlW6e7ZsfOMR7cO6geeGhuFsJg8ILOETTgw==, + } + cpu: [arm64] + os: [win32] + + turbo@1.13.3-canary.1: + resolution: + { + integrity: sha512-bxOFjIhBxwWiExjUyTV2KOP6P28M5TOHUaM6YKRR2oPtKoQpIGUmYP+DCxG+icjaLXviUJRHU4YxzEOaL9Bf6A==, + } + hasBin: true + +snapshots: + turbo-darwin-64@1.13.3-canary.1: + optional: true + + turbo-darwin-arm64@1.13.3-canary.1: + optional: true + + turbo-linux-64@1.13.3-canary.1: + optional: true + + turbo-linux-arm64@1.13.3-canary.1: + optional: true + + turbo-windows-64@1.13.3-canary.1: + optional: true + + turbo-windows-arm64@1.13.3-canary.1: + optional: true + + turbo@1.13.3-canary.1: + optionalDependencies: + turbo-darwin-64: 1.13.3-canary.1 + turbo-darwin-arm64: 1.13.3-canary.1 + turbo-linux-64: 1.13.3-canary.1 + turbo-linux-arm64: 1.13.3-canary.1 + turbo-windows-64: 1.13.3-canary.1 + turbo-windows-arm64: 1.13.3-canary.1 diff --git a/crates/turborepo-lockfiles/src/pnpm/data.rs b/crates/turborepo-lockfiles/src/pnpm/data.rs index 618f8d7f24f3c..9ff2cfd07184f 100644 --- a/crates/turborepo-lockfiles/src/pnpm/data.rs +++ b/crates/turborepo-lockfiles/src/pnpm/data.rs @@ -187,7 +187,7 @@ impl PnpmLockfile { SupportedLockfileVersion::V5 | SupportedLockfileVersion::V6 => { self.packages.as_ref().map(|pkgs| pkgs.contains_key(key)) } - SupportedLockfileVersion::V7 => { + SupportedLockfileVersion::V7AndV9 => { self.snapshots.as_ref().map(|snaps| snaps.contains_key(key)) } } @@ -221,7 +221,7 @@ impl PnpmLockfile { return SupportedLockfileVersion::V5; } match self.lockfile_version.version.as_str() { - "7.0" => SupportedLockfileVersion::V7, + "7.0" | "9.0" => SupportedLockfileVersion::V7AndV9, _ => SupportedLockfileVersion::V6, } } @@ -230,7 +230,7 @@ impl PnpmLockfile { match self.version() { SupportedLockfileVersion::V5 => format!("/{name}/{version}"), SupportedLockfileVersion::V6 => format!("/{name}@{version}"), - SupportedLockfileVersion::V7 => format!("{name}@{version}"), + SupportedLockfileVersion::V7AndV9 => format!("{name}@{version}"), } } @@ -298,7 +298,7 @@ impl PnpmLockfile { let patch_key = format!("{}@{}", dp.name, dp.version); if let Some(patch) = patches.get(&patch_key).filter(|patch| { // In V7 patch hash isn't included in packages key, so no need to check - matches!(self.version(), SupportedLockfileVersion::V7) + matches!(self.version(), SupportedLockfileVersion::V7AndV9) || dp.patch_hash() == Some(&patch.hash) }) { pruned_patches.insert(patch_key, patch.clone()); @@ -604,6 +604,7 @@ mod tests { const PNPM_V7: &[u8] = include_bytes!("../../fixtures/pnpm-v7.yaml").as_slice(); const PNPM_V7_PEER: &[u8] = include_bytes!("../../fixtures/pnpm-v7-peer.yaml").as_slice(); const PNPM_V7_PATCH: &[u8] = include_bytes!("../../fixtures/pnpm-v7-patch.yaml").as_slice(); + const PNPM_V9: &[u8] = include_bytes!("../../fixtures/pnpm-v9.yaml").as_slice(); use super::*; use crate::{Lockfile, Package}; @@ -615,6 +616,7 @@ mod tests { #[test_case(PNPM_V7)] #[test_case(PNPM_V7_PEER)] #[test_case(PNPM_V7_PATCH)] + #[test_case(PNPM_V9)] fn test_roundtrip(fixture: &[u8]) { let lockfile = PnpmLockfile::from_bytes(fixture).unwrap(); let serialized_lockfile = serde_yaml::to_string(&lockfile).unwrap(); @@ -856,6 +858,17 @@ mod tests { })) ; "v7 peer 2" )] + #[test_case( + PNPM_V9, + "", + "turbo", + "canary", + Ok(Some(crate::Package { + key: "turbo@1.13.3-canary.1".into(), + version: "1.13.3-canary.1".into(), + })) + ; "v9" + )] fn test_resolve_package( lockfile: &[u8], workspace_path: &str, diff --git a/crates/turborepo-lockfiles/src/pnpm/dep_path.rs b/crates/turborepo-lockfiles/src/pnpm/dep_path.rs index 39312fa9fcf42..02089dbd3d820 100644 --- a/crates/turborepo-lockfiles/src/pnpm/dep_path.rs +++ b/crates/turborepo-lockfiles/src/pnpm/dep_path.rs @@ -32,7 +32,7 @@ impl<'a> DepPath<'a> { input: &'a str, ) -> Result> { let (_, dep_path) = match version { - SupportedLockfileVersion::V7 => parse_dep_path_v7(input), + SupportedLockfileVersion::V7AndV9 => parse_dep_path_v7(input), SupportedLockfileVersion::V5 | SupportedLockfileVersion::V6 => parse_dep_path(input), } .map_err(|e| e.to_owned()) diff --git a/crates/turborepo-lockfiles/src/pnpm/mod.rs b/crates/turborepo-lockfiles/src/pnpm/mod.rs index f824896fb9e76..235cf01135941 100644 --- a/crates/turborepo-lockfiles/src/pnpm/mod.rs +++ b/crates/turborepo-lockfiles/src/pnpm/mod.rs @@ -33,7 +33,10 @@ enum VersionFormat { enum SupportedLockfileVersion { V5, V6, - V7, + // As of pnpm@9.0.0-rc.0 the lockfile version will now match the pnpm version + // Lockfile version 7.0 and 9.0 are both the same version + // See https://github.com/pnpm/pnpm/pull/7861 + V7AndV9, } pub fn pnpm_subgraph(