Skip to content

Commit

Permalink
chore(publish): try to automatically open the web browser (denoland#2…
Browse files Browse the repository at this point in the history
  • Loading branch information
bartlomieju committed Jan 31, 2024
1 parent b91ae88 commit 163491f
Show file tree
Hide file tree
Showing 3 changed files with 134 additions and 2 deletions.
128 changes: 128 additions & 0 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
7 changes: 5 additions & 2 deletions cli/tools/registry/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand All @@ -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);

Expand Down Expand Up @@ -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(
&registry_api_url,
Expand Down

0 comments on commit 163491f

Please sign in to comment.