@@ -2,13 +2,12 @@ use std::{future::Future, io::Write};
22
33use serde:: { Deserialize , Serialize } ;
44use zpm_parsers:: JsonDocument ;
5- use zpm_semver:: { Version , VersionRc } ;
6- use zpm_utils:: { DataType , Hash64 , Path , ToFileString , ToHumanString , Unit , is_terminal} ;
7- use zpm_utils:: eco_vec;
5+ use zpm_semver:: { Range , VersionRc } ;
6+ use zpm_utils:: { DataType , FromFileString , Hash64 , Path , ToFileString , ToHumanString , Unit , is_terminal} ;
87
98use crate :: errors:: Error ;
109
11- pub const CACHE_VERSION : usize = 1 ;
10+ pub const CACHE_VERSION : usize = 2 ;
1211
1312#[ derive( Serialize , Deserialize ) ]
1413#[ serde( rename_all = "camelCase" ) ]
@@ -26,18 +25,17 @@ fn get_npm_registry_server() -> String {
2625impl CacheKey {
2726 pub fn to_npm_url ( & self ) -> Option < String > {
2827 if self . version . rc . as_ref ( ) . map_or ( true , |rc| !rc. starts_with ( & [ VersionRc :: String ( "git" . into ( ) ) ] ) ) {
29- // Older RC versions (<6.0.0-rc.9) are not available in npm
30- let first_npm_release = Version :: new_from_components (
31- 6 ,
32- 0 ,
33- 0 ,
34- Some ( eco_vec ! [ VersionRc :: String ( "rc" . into( ) ) , VersionRc :: Number ( 9 ) ] ) ,
35- ) ;
36-
37- if self . version >= first_npm_release {
28+ // zpm is available on npm since 6.0.0-rc.9
29+ if Range :: from_file_string ( ">=6.0.0-rc.9" ) . unwrap ( ) . check_ignore_rc ( & self . version ) {
3830 let registry = get_npm_registry_server ( ) ;
3931 return Some ( format ! ( "{}/@yarnpkg/yarn-{}/-/yarn-{}-{}.tgz" , registry, self . platform, self . platform, self . version. to_file_string( ) ) ) ;
4032 }
33+
34+ // berry has been published to npm since 2.4.1
35+ if Range :: from_file_string ( ">=2.4.1 <6.0.0-0" ) . unwrap ( ) . check_ignore_rc ( & self . version ) {
36+ let registry = get_npm_registry_server ( ) ;
37+ return Some ( format ! ( "{}/@yarnpkg/cli-bin/-/cli-bin-{}.tgz" , registry, self . version. to_file_string( ) ) ) ;
38+ }
4139 }
4240
4341 None
0 commit comments