diff --git a/cli/tools/registry/api.rs b/cli/tools/registry/api.rs index 672cdc02c1..b8eb6c18e3 100644 --- a/cli/tools/registry/api.rs +++ b/cli/tools/registry/api.rs @@ -53,6 +53,8 @@ pub struct PublishingTask { pub struct ApiError { pub code: String, pub message: String, + #[serde(flatten)] + pub data: serde_json::Value, #[serde(skip)] pub x_deno_ray: Option, } @@ -97,6 +99,7 @@ pub async fn parse_response( code: "unknown".to_string(), message: format!("{}: {}", status, text), x_deno_ray, + data: serde_json::json!({}), }; return Err(err); } @@ -107,6 +110,7 @@ pub async fn parse_response( code: "unknown".to_string(), message: format!("Failed to parse response: {}, response: '{}'", err, text), x_deno_ray, + data: serde_json::json!({}), }) } diff --git a/cli/tools/registry/mod.rs b/cli/tools/registry/mod.rs index 789ee131f1..ee1174e1c3 100644 --- a/cli/tools/registry/mod.rs +++ b/cli/tools/registry/mod.rs @@ -555,15 +555,29 @@ async fn publish_package( let res = api::parse_response::(response).await; let mut task = match res { Ok(task) => task, - Err(err) if err.code == "duplicateVersionPublish" => { + Err(mut err) if err.code == "duplicateVersionPublish" => { + let task = serde_json::from_value::( + err.data.get_mut("task").unwrap().take(), + ) + .unwrap(); + if task.status == "success" { + println!( + "{} @{}/{}@{}", + colors::green("Skipping, already published"), + package.scope, + package.package, + package.version + ); + return Ok(()); + } println!( "{} @{}/{}@{}", - colors::yellow("Skipping, already published"), + colors::yellow("Already uploaded, waiting for publishing"), package.scope, package.package, package.version ); - return Ok(()); + task } Err(err) => { return Err(err).with_context(|| {