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:
parent
bca0fe1cde
commit
d347e73f5a
3 changed files with 13 additions and 6 deletions
14
cli/jsr.rs
14
cli/jsr.rs
|
@ -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;
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -1,5 +1,8 @@
|
||||||
{
|
{
|
||||||
"versions": {
|
"versions": {
|
||||||
|
"2.0.0": {
|
||||||
|
"yanked": true
|
||||||
|
},
|
||||||
"1.0.0": {},
|
"1.0.0": {},
|
||||||
"0.2.0": {}
|
"0.2.0": {}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue