mirror of
https://github.com/pesde-pkg/pesde.git
synced 2024-12-12 02:50:37 +00:00
feat: return all targets from version endpoint
This commit is contained in:
parent
07ee4b9617
commit
e14f350336
5 changed files with 307 additions and 247 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -4,4 +4,4 @@
|
|||
cobertura.xml
|
||||
tarpaulin-report.html
|
||||
build_rs_cov.profraw
|
||||
registry/cache
|
||||
registry/data
|
515
Cargo.lock
generated
515
Cargo.lock
generated
File diff suppressed because it is too large
Load diff
|
@ -46,7 +46,7 @@ uninlined_format_args = "warn"
|
|||
serde = { version = "1.0.204", features = ["derive"] }
|
||||
toml = "0.8.19"
|
||||
serde_with = "3.9.0"
|
||||
gix = { version = "0.64.0", default-features = false, features = ["blocking-http-transport-reqwest-rust-tls", "revparse-regex", "credentials"] }
|
||||
gix = { version = "0.66.0", default-features = false, features = ["blocking-http-transport-reqwest-rust-tls", "revparse-regex", "credentials"] }
|
||||
semver = { version = "1.0.23", features = ["serde"] }
|
||||
reqwest = { version = "0.12.5", default-features = false, features = ["rustls-tls", "blocking"] }
|
||||
tar = "0.4.41"
|
||||
|
@ -82,10 +82,6 @@ indicatif = { version = "0.17.8", optional = true }
|
|||
indicatif-log-bridge = { version = "0.2.2", optional = true }
|
||||
inquire = { version = "0.7.5", optional = true }
|
||||
|
||||
# TODO: remove this when a release with https://github.com/Byron/gitoxide/commit/aab78f102113330f96c3140c472aaab0912bc553 is available
|
||||
[patch.crates-io]
|
||||
gix-worktree-state = { git = "https://github.com/daimond113/gitoxide", rev = "0447211a773f4da62b9bb9e7db73d047e09aed66" }
|
||||
|
||||
[target.'cfg(target_os = "windows")'.dependencies]
|
||||
winreg = { version = "0.52.0", optional = true }
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ url = "2.5.2"
|
|||
futures = "0.3.30"
|
||||
|
||||
git2 = "0.19.0"
|
||||
gix = { version = "0.64.0", default-features = false, features = ["blocking-http-transport-reqwest-rust-tls", "credentials"] }
|
||||
gix = { version = "0.66.0", default-features = false, features = ["blocking-http-transport-reqwest-rust-tls", "credentials"] }
|
||||
|
||||
serde = "1.0.206"
|
||||
serde_json = "1.0.124"
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
use std::collections::BTreeSet;
|
||||
|
||||
use actix_web::{
|
||||
http::header::{ACCEPT, LOCATION},
|
||||
web, HttpRequest, HttpResponse, Responder,
|
||||
|
@ -82,7 +80,7 @@ pub async fn get_package_version(
|
|||
}
|
||||
};
|
||||
|
||||
let Some((v_id, entry)) = ({
|
||||
let Some((v_id, entry, targets)) = ({
|
||||
let version = match version {
|
||||
VersionRequest::Latest => match entries.keys().map(|k| k.version()).max() {
|
||||
Some(latest) => latest.clone(),
|
||||
|
@ -91,16 +89,23 @@ pub async fn get_package_version(
|
|||
VersionRequest::Specific(version) => version,
|
||||
};
|
||||
|
||||
let mut versions = entries
|
||||
.into_iter()
|
||||
let versions = entries
|
||||
.iter()
|
||||
.filter(|(v_id, _)| *v_id.version() == version);
|
||||
|
||||
match target {
|
||||
TargetRequest::Any => versions.min_by_key(|(v_id, _)| *v_id.target()),
|
||||
TargetRequest::Specific(kind) => {
|
||||
versions.find(|(_, entry)| entry.target.kind() == kind)
|
||||
}
|
||||
TargetRequest::Any => versions.clone().min_by_key(|(v_id, _)| *v_id.target()),
|
||||
TargetRequest::Specific(kind) => versions
|
||||
.clone()
|
||||
.find(|(_, entry)| entry.target.kind() == kind),
|
||||
}
|
||||
.map(|(v_id, entry)| {
|
||||
(
|
||||
v_id,
|
||||
entry,
|
||||
versions.map(|(_, entry)| (&entry.target).into()).collect(),
|
||||
)
|
||||
})
|
||||
}) else {
|
||||
return Ok(HttpResponse::NotFound().finish());
|
||||
};
|
||||
|
@ -119,7 +124,7 @@ pub async fn get_package_version(
|
|||
let object_url = GetObject::new(
|
||||
&app_state.s3_bucket,
|
||||
Some(&app_state.s3_credentials),
|
||||
&s3_name(&name, &v_id, readme),
|
||||
&s3_name(&name, v_id, readme),
|
||||
)
|
||||
.sign(S3_SIGN_DURATION);
|
||||
|
||||
|
@ -131,7 +136,7 @@ pub async fn get_package_version(
|
|||
Ok(HttpResponse::Ok().json(PackageResponse {
|
||||
name: name.to_string(),
|
||||
version: v_id.version().to_string(),
|
||||
targets: BTreeSet::from([entry.target.into()]),
|
||||
targets,
|
||||
description: entry.description.clone().unwrap_or_default(),
|
||||
published_at: entry.published_at,
|
||||
license: entry.license.clone().unwrap_or_default(),
|
||||
|
|
Loading…
Reference in a new issue