diff --git a/CHANGELOG.md b/CHANGELOG.md index 110a82f..bffd9bb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +## 0.5.1 + +#### 🐞 Fixes + +- Fixed Yarn >= v1.22.20 not unpacking correctly. + ## 0.5.0 #### 💥 Breaking diff --git a/Cargo.lock b/Cargo.lock index 37341ae..057e943 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1850,7 +1850,7 @@ dependencies = [ [[package]] name = "node_depman_plugin" -version = "0.5.0" +version = "0.5.1" dependencies = [ "extism-pdk", "node_common", @@ -1865,7 +1865,7 @@ dependencies = [ [[package]] name = "node_plugin" -version = "0.5.0" +version = "0.5.1" dependencies = [ "extism-pdk", "node_common", diff --git a/crates/node-depman/Cargo.toml b/crates/node-depman/Cargo.toml index 4870a36..5bc0e51 100644 --- a/crates/node-depman/Cargo.toml +++ b/crates/node-depman/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "node_depman_plugin" -version = "0.5.0" +version = "0.5.1" edition = "2021" license = "MIT" publish = false diff --git a/crates/node-depman/src/proto.rs b/crates/node-depman/src/proto.rs index 988a8a8..c963f84 100644 --- a/crates/node-depman/src/proto.rs +++ b/crates/node-depman/src/proto.rs @@ -209,6 +209,20 @@ pub fn resolve_version( Ok(Json(output)) } +fn get_archive_prefix(manager: &PackageManager, spec: &VersionSpec) -> String { + if manager.is_yarn_classic(spec.to_unresolved_spec()) { + if let VersionSpec::Version(version) = spec { + // Prefix changed to "package" in v1.22.20 + // https://github.com/yarnpkg/yarn/releases/tag/v1.22.20 + if version.minor <= 22 && version.patch <= 19 { + return format!("yarn-v{version}"); + } + } + } + + "package".into() +} + #[plugin_fn] pub fn download_prebuilt( Json(input): Json, @@ -225,13 +239,6 @@ pub fn download_prebuilt( let package_name = manager.get_package_name(version.to_unresolved_spec()); - // Derive values based on package manager - let archive_prefix = if manager.is_yarn_classic(version.to_unresolved_spec()) { - format!("yarn-v{version}") - } else { - "package".into() - }; - let package_without_scope = if package_name.contains('/') { package_name.split('/').nth(1).unwrap() } else { @@ -239,7 +246,7 @@ pub fn download_prebuilt( }; Ok(Json(DownloadPrebuiltOutput { - archive_prefix: Some(archive_prefix), + archive_prefix: Some(get_archive_prefix(&manager, &version)), download_url: format!( "https://registry.npmjs.org/{package_name}/-/{package_without_scope}-{version}.tgz", ), diff --git a/crates/node-depman/tests/versions_test.rs b/crates/node-depman/tests/versions_test.rs index 00ab8c7..f2a5527 100644 --- a/crates/node-depman/tests/versions_test.rs +++ b/crates/node-depman/tests/versions_test.rs @@ -165,10 +165,10 @@ mod yarn { use super::*; generate_resolve_versions_tests!("yarn-test", { - "1" => "1.22.19", + "1" => "1.22.21", "2" => "2.4.3", - "3" => "3.6.4", - "berry" => "4.0.1", + "3" => "3.7.0", + "berry" => "4.0.2", }); #[test] diff --git a/crates/node/Cargo.toml b/crates/node/Cargo.toml index 0dd9bee..d1ed529 100644 --- a/crates/node/Cargo.toml +++ b/crates/node/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "node_plugin" -version = "0.5.0" +version = "0.5.1" edition = "2021" license = "MIT" publish = false