From f73a4a422abf09a1bb7c49091efdfc3e0e5e3db1 Mon Sep 17 00:00:00 2001 From: Miles Johnson Date: Tue, 14 Nov 2023 12:12:04 -0800 Subject: [PATCH 1/3] Fix prefix. --- CHANGELOG.md | 6 ++++++ Cargo.lock | 4 ++-- crates/node-depman/Cargo.toml | 2 +- crates/node-depman/src/proto.rs | 23 +++++++++++++++-------- crates/node-depman/tests/versions_test.rs | 2 +- crates/node/Cargo.toml | 2 +- 6 files changed, 26 insertions(+), 13 deletions(-) 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..1cc9b05 100644 --- a/crates/node-depman/tests/versions_test.rs +++ b/crates/node-depman/tests/versions_test.rs @@ -165,7 +165,7 @@ 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", 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 From 6d5c69f63007a596c5c61b110188ad6d2ffc2228 Mon Sep 17 00:00:00 2001 From: Miles Johnson Date: Tue, 14 Nov 2023 12:55:08 -0800 Subject: [PATCH 2/3] Fix tests. --- crates/node-depman/tests/versions_test.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/node-depman/tests/versions_test.rs b/crates/node-depman/tests/versions_test.rs index 1cc9b05..e618855 100644 --- a/crates/node-depman/tests/versions_test.rs +++ b/crates/node-depman/tests/versions_test.rs @@ -167,7 +167,7 @@ mod yarn { generate_resolve_versions_tests!("yarn-test", { "1" => "1.22.21", "2" => "2.4.3", - "3" => "3.6.4", + "3" => "3.7.0", "berry" => "4.0.1", }); From 06cd22bb3a4d48dee98936e20cac258082ed9efb Mon Sep 17 00:00:00 2001 From: Miles Johnson Date: Tue, 14 Nov 2023 13:28:31 -0800 Subject: [PATCH 3/3] Fix tests. --- crates/node-depman/tests/versions_test.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/node-depman/tests/versions_test.rs b/crates/node-depman/tests/versions_test.rs index e618855..f2a5527 100644 --- a/crates/node-depman/tests/versions_test.rs +++ b/crates/node-depman/tests/versions_test.rs @@ -168,7 +168,7 @@ mod yarn { "1" => "1.22.21", "2" => "2.4.3", "3" => "3.7.0", - "berry" => "4.0.1", + "berry" => "4.0.2", }); #[test]