Skip to content

Commit

Permalink
Merge pull request #5292 from wasmerio/bugfix/read-readme-content
Browse files Browse the repository at this point in the history
Pass readme content instead of readme file name
  • Loading branch information
syrusakbary authored Dec 12, 2024
2 parents a798795 + 8186c40 commit 7dee3cb
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 63 deletions.
52 changes: 7 additions & 45 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion lib/cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,6 @@ url = "2.3.1"
libc.workspace = true
parking_lot = "0.12"
dialoguer = "0.11.0"
tldextract = "0.6.0"
hex = "0.4.3"
flate2 = "1.0.25"
cargo_metadata = "0.15.2"
Expand Down
22 changes: 6 additions & 16 deletions lib/cli/src/commands/auth/login/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,25 +55,15 @@ impl Login {
return Ok(AuthorizationState::TokenSuccess(token.clone()));
}

let registry_host = env.registry_endpoint()?;
let registry_tld = tldextract::TldExtractor::new(tldextract::TldOption::default())
.extract(registry_host.as_str())
.map_err(|e| {
std::io::Error::new(
std::io::ErrorKind::Other,
format!("Invalid registry for login {}: {e}", registry_host),
)
})?;

let login_prompt = match (
registry_tld.domain.as_deref(),
registry_tld.suffix.as_deref(),
) {
(Some(d), Some(s)) => {
format!("Please paste the login token from https://{d}.{s}/settings/access-tokens")
let public_url = env.registry_public_url()?;

let login_prompt = match public_url.domain() {
Some(d) => {
format!("Please paste the login token from https://{d}/settings/access-tokens")
}
_ => "Please paste the login token".to_string(),
};

#[cfg(test)]
{
Ok(AuthorizationState::TokenSuccess(login_prompt))
Expand Down
14 changes: 13 additions & 1 deletion lib/cli/src/commands/package/tag.rs
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,18 @@ impl PackageTag {
None
};

let maybe_readme_content = match maybe_readme {
Some(readme) => {
let readme_path = self.package_path.join(&readme);
if readme_path.exists() {
Some(tokio::fs::read_to_string(readme_path).await?)
} else {
None
}
}
None => None,
};

let r = wasmer_backend_api::query::tag_package_release(
client,
maybe_description.as_deref(),
Expand All @@ -211,7 +223,7 @@ impl PackageTag {
None,
package_release_id,
private,
maybe_readme.as_deref(),
maybe_readme_content.as_deref(),
maybe_repository.as_deref(),
&version,
);
Expand Down

0 comments on commit 7dee3cb

Please sign in to comment.