Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(cli): Show exact version of package in "package download" command #4797

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 13 additions & 8 deletions lib/cli/src/commands/package/download.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ impl PackageDownload {

step_num += 1;

let (download_url, token) = match &self.package {
let (download_url, token, ident) = match &self.package {
PackageSource::Ident(PackageIdent::Named(id)) => {
let endpoint = self.env.registry_endpoint()?;
let version = id.version_or_default().to_string();
Expand All @@ -107,16 +107,18 @@ impl PackageDownload {
)
.with_context(|| {
format!(
"could not retrieve package information for package '{}' from registry '{}'",
full_name, endpoint,
)
"could not retrieve package information for package '{}' from registry '{}'",
full_name, endpoint,
)
})?;

let download_url = package
.pirita_url
.context("registry does provide a container download container download URL")?;

(download_url, token)
let ident = format!("{}@{}", package.package, package.version);

(download_url, token, ident)
}
PackageSource::Ident(PackageIdent::Hash(hash)) => {
let endpoint = self.env.registry_endpoint()?;
Expand All @@ -133,7 +135,9 @@ impl PackageDownload {
let pkg = rt.block_on(wasmer_api::query::get_package_release(&client, &hash.to_string()))?
.with_context(|| format!("Package with {hash} does not exist in the registry, or is not accessible"))?;

(pkg.webc_url, token)
let ident = hash.to_string();

(pkg.webc_url, token, ident)
}
PackageSource::Path(p) => bail!("cannot download a package from a local path: '{p}'"),
PackageSource::Url(url) => bail!("cannot download a package from a URL: '{}'", url),
Expand All @@ -156,11 +160,12 @@ impl PackageDownload {
};

pb.println(format!(
"{} {}Downloading package...",
"{} {}Downloading package {} ...",
style(format!("[{}/{}]", step_num, total_steps))
.bold()
.dim(),
DOWNLOADING_PACKAGE_EMOJI
DOWNLOADING_PACKAGE_EMOJI,
ident,
));

step_num += 1;
Expand Down
Loading