From 163491f2378febc846190f64b60f199bd8e5ede8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartek=20Iwa=C5=84czuk?= Date: Wed, 31 Jan 2024 22:38:57 +0100 Subject: chore(publish): try to automatically open the web browser (#22208) --- cli/Cargo.toml | 1 + cli/tools/registry/mod.rs | 7 +++++-- 2 files changed, 6 insertions(+), 2 deletions(-) (limited to 'cli') diff --git a/cli/Cargo.toml b/cli/Cargo.toml index fba54c85b..89d677f9d 100644 --- a/cli/Cargo.toml +++ b/cli/Cargo.toml @@ -135,6 +135,7 @@ typed-arena = "=2.0.1" unicode-width = "0.1" uuid = { workspace = true, features = ["serde"] } walkdir = "=2.3.2" +webbrowser = "0.8.12" zeromq = { version = "=0.3.4", default-features = false, features = ["tcp-transport", "tokio-runtime"] } zstd.workspace = true diff --git a/cli/tools/registry/mod.rs b/cli/tools/registry/mod.rs index 574166348..cc2488a10 100644 --- a/cli/tools/registry/mod.rs +++ b/cli/tools/registry/mod.rs @@ -208,9 +208,10 @@ async fn get_auth_headers( .await .context("Failed to create interactive authorization")?; + let auth_url = format!("{}?code={}", auth.verification_url, auth.code); print!( "Visit {} to authorize publishing of", - colors::cyan(format!("{}?code={}", auth.verification_url, auth.code)) + colors::cyan(&auth_url) ); if packages.len() > 1 { println!(" {} packages", packages.len()); @@ -220,6 +221,7 @@ async fn get_auth_headers( ring_bell(); println!("{}", colors::gray("Waiting...")); + let _ = webbrowser::open(&auth_url); let interval = std::time::Duration::from_secs(auth.poll_interval); @@ -410,9 +412,10 @@ async fn ensure_scopes_and_packages_exist( "'@{}/{}' doesn't exist yet. Visit {} to create the package", &package.scope, &package.package, - colors::cyan_with_underline(create_package_url) + colors::cyan_with_underline(&create_package_url) ); println!("{}", colors::gray("Waiting...")); + let _ = webbrowser::open(&create_package_url); let package_api_url = api::get_package_api_url( ®istry_api_url, -- cgit v1.2.3