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): Better final messages for push, tag and publish #4662

Merged
merged 4 commits into from
May 10, 2024
Merged
Show file tree
Hide file tree
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
19 changes: 18 additions & 1 deletion lib/cli/src/commands/package/common/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use std::{
path::{Path, PathBuf},
};
use wasmer_api::WasmerClient;
use wasmer_config::package::{Manifest, PackageHash};
use wasmer_config::package::{Manifest, NamedPackageIdent, PackageHash};
use webc::wasmer_package::Package;

pub mod macros;
Expand Down Expand Up @@ -207,3 +207,20 @@ pub(super) async fn login_user(

api.client()
}

pub(super) fn make_package_url(client: &WasmerClient, pkg: &NamedPackageIdent) -> String {
let host = client.graphql_endpoint().domain().unwrap_or("wasmer.io");

// Our special cases..
let host = match host {
_ if host.contains("wasmer.wtf") => "wasmer.wtf",
_ if host.contains("wasmer.io") => "wasmer.io",
_ => host,
};

format!(
"https://{host}/{}@{}",
pkg.full_name(),
pkg.version_or_default().to_string().replace('=', "")
)
}
16 changes: 9 additions & 7 deletions lib/cli/src/commands/package/publish.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::{
commands::{
package::{
common::{macros::*, wait::*, *},
common::{wait::*, *},
push::PackagePush,
tag::PackageTag,
},
Expand Down Expand Up @@ -147,12 +147,14 @@ impl AsyncCliCommand for PackagePublish {
.publish(&client, &manifest_path, &manifest, false)
.await?;

if !self.quiet && !self.non_interactive {
eprintln!(
"{} You can now run your package with {}",
"𖥔".green().bold(),
format!("`{} run {ident}`", bin_name!()).bold()
);
match ident {
PackageIdent::Named(ref n) => {
let url = make_package_url(&client, n);
eprintln!("{} Package URL: {url}", "𖥔".yellow().bold());
}
PackageIdent::Hash(ref h) => {
eprintln!("{} Succesfully published package ({h})", "✔".green().bold());
}
}

Ok(ident)
Expand Down
51 changes: 22 additions & 29 deletions lib/cli/src/commands/package/push.rs
Original file line number Diff line number Diff line change
Expand Up @@ -226,38 +226,31 @@ impl AsyncCliCommand for PackagePush {

let (_, hash) = self.push(&client, &manifest, &manifest_path).await?;

if !self.quiet {
let bin_name = bin_name!();
if let Some(package) = &manifest.package {
if package.name.is_some() {
let mut manifest_path_dir = manifest_path.clone();
manifest_path_dir.pop();

eprintln!(
"You can now tag your package with `{}`",
format!(
"{bin_name} package tag {}{}",
hash,
if manifest_path_dir.canonicalize()? == std::env::current_dir()? {
String::new()
} else {
format!(" {}", manifest_path_dir.display())
}
)
.bold()
let bin_name = bin_name!();
if let Some(package) = &manifest.package {
if package.name.is_some() {
let mut manifest_path_dir = manifest_path.clone();
manifest_path_dir.pop();

eprintln!(
"{} You can now tag your package with `{}`",
"𖥔".yellow().bold(),
format!(
"{bin_name} package tag {}{}",
hash,
if manifest_path_dir.canonicalize()? == std::env::current_dir()? {
String::new()
} else {
format!(" {}", manifest_path_dir.display())
}
)
} else {
eprintln!(
"You can now run your package with `{}`",
format!("{bin_name} run {}", hash).bold()
);
}
.bold()
)
} else {
eprintln!(
"You can now run your package with `{}`",
format!("{bin_name} run {}", hash).bold()
);
eprintln!("{} Succesfully pushed package ({hash})", "✔".green().bold());
}
} else {
eprintln!("{} Succesfully pushed package ({hash})", "✔".green().bold());
}

Ok(())
Expand Down
13 changes: 8 additions & 5 deletions lib/cli/src/commands/package/tag.rs
Original file line number Diff line number Diff line change
Expand Up @@ -490,11 +490,14 @@ impl AsyncCliCommand for PackageTag {
.tag(&client, &manifest, &manifest_path, false, false)
.await?;

if !self.quiet {
eprintln!(
"You can now run your package with `{}`",
format!("{} run {id}", bin_name!()).bold()
);
match id {
PackageIdent::Named(ref n) => {
let url = make_package_url(&client, n);
eprintln!("{} Package URL: {url}", "𖥔".yellow().bold());
}
PackageIdent::Hash(ref h) => {
eprintln!("{} Succesfully tagged package ({h})", "✔".green().bold());
}
}

Ok(())
Expand Down
Loading