1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-12-25 00:29:09 -05:00

fix(jsr): exclude yanked versions from 'deno add' and completions (#23113)

This commit is contained in:
Nayeem Rahman 2024-03-28 19:02:07 +00:00 committed by GitHub
parent bca0fe1cde
commit d347e73f5a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 13 additions and 6 deletions

View file

@ -207,14 +207,18 @@ impl JsrFetchResolver {
let maybe_get_nv = || async { let maybe_get_nv = || async {
let name = req.name.clone(); let name = req.name.clone();
let package_info = self.package_info(&name).await?; let package_info = self.package_info(&name).await?;
// Find the first matching version of the package which is cached. // Find the first matching version of the package.
let mut versions = package_info.versions.keys().collect::<Vec<_>>(); let mut versions = package_info.versions.iter().collect::<Vec<_>>();
versions.sort(); versions.sort_by_key(|(v, _)| *v);
let version = versions let version = versions
.into_iter() .into_iter()
.rev() .rev()
.find(|v| req.version_req.tag().is_none() && req.version_req.matches(v)) .find(|(v, i)| {
.cloned()?; !i.yanked
&& req.version_req.tag().is_none()
&& req.version_req.matches(v)
})
.map(|(v, _)| v.clone())?;
Some(PackageNv { name, version }) Some(PackageNv { name, version })
}; };
let nv = maybe_get_nv().await; let nv = maybe_get_nv().await;

View file

@ -119,7 +119,7 @@ impl NpmFetchResolver {
let maybe_get_nv = || async { let maybe_get_nv = || async {
let name = req.name.clone(); let name = req.name.clone();
let package_info = self.package_info(&name).await?; let package_info = self.package_info(&name).await?;
// Find the first matching version of the package which is cached. // Find the first matching version of the package.
let mut versions = package_info.versions.keys().collect::<Vec<_>>(); let mut versions = package_info.versions.keys().collect::<Vec<_>>();
versions.sort(); versions.sort();
let version = versions let version = versions

View file

@ -1,5 +1,8 @@
{ {
"versions": { "versions": {
"2.0.0": {
"yanked": true
},
"1.0.0": {}, "1.0.0": {},
"0.2.0": {} "0.2.0": {}
} }