1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-12-22 07:14:47 -05:00

feat(upgrade): refresh output (#24911)

This commit updates the output of "deno upgrade" subcommand.
This commit is contained in:
Bartek Iwańczuk 2024-08-07 12:59:12 +01:00 committed by GitHub
parent fade3136ba
commit f150a9c2d9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -238,14 +238,18 @@ fn get_minor_version(version: &str) -> &str {
fn print_release_notes(current_version: &str, new_version: &str) { fn print_release_notes(current_version: &str, new_version: &str) {
if get_minor_version(current_version) != get_minor_version(new_version) { if get_minor_version(current_version) != get_minor_version(new_version) {
log::info!( log::info!(
"{}{}", "Release notes:\n\n {}\n",
"Release notes: https://github.com/denoland/deno/releases/tag/v", colors::bold(format!(
"https://github.com/denoland/deno/releases/tag/v{}",
&new_version, &new_version,
))
); );
log::info!( log::info!(
"{}{}", "Blog post:\n\n {}\n",
"Blog post: https://deno.com/blog/v", colors::bold(format!(
"https://deno.com/blog/v{}",
get_minor_version(new_version) get_minor_version(new_version)
))
); );
} }
} }
@ -479,10 +483,10 @@ pub async fn upgrade(
} }
None => { None => {
let release_channel = if upgrade_flags.canary { let release_channel = if upgrade_flags.canary {
log::info!("Looking up latest canary version"); log::info!("{}", colors::gray("Looking up latest canary version"));
ReleaseChannel::Canary ReleaseChannel::Canary
} else { } else {
log::info!("Looking up latest version"); log::info!("{}", colors::gray("Looking up latest version"));
ReleaseChannel::Stable ReleaseChannel::Stable
}; };
@ -509,16 +513,22 @@ pub async fn upgrade(
&& current_is_most_recent && current_is_most_recent
{ {
log::info!( log::info!(
"Local deno version {} is the most recent release", "{}",
colors::green(format!(
"\nLocal deno version {} is the most recent release\n",
if upgrade_flags.canary { if upgrade_flags.canary {
crate::version::GIT_COMMIT_HASH crate::version::GIT_COMMIT_HASH
} else { } else {
crate::version::deno() crate::version::deno()
} }
))
); );
return Ok(()); return Ok(());
} else { } else {
log::info!("Found latest version {}", latest_version); log::info!(
"{}",
colors::bold(format!("\nFound latest version {}\n", latest_version))
);
latest_version latest_version
} }
} }
@ -540,7 +550,10 @@ pub async fn upgrade(
.await .await
.with_context(|| format!("Failed downloading {download_url}. The version you requested may not have been built for the current architecture."))?; .with_context(|| format!("Failed downloading {download_url}. The version you requested may not have been built for the current architecture."))?;
log::info!("Deno is upgrading to version {}", &install_version); log::info!(
"{}",
colors::gray(format!("Deno is upgrading to version {}", &install_version))
);
let temp_dir = tempfile::TempDir::new()?; let temp_dir = tempfile::TempDir::new()?;
let new_exe_path = unpack_into_dir( let new_exe_path = unpack_into_dir(
@ -589,7 +602,13 @@ pub async fn upgrade(
return Err(err.into()); return Err(err.into());
} }
} }
log::info!("Upgraded successfully"); log::info!(
"{}",
colors::green(format!(
"\nUpgraded successfully to Deno v{}\n",
install_version
))
);
if !upgrade_flags.canary { if !upgrade_flags.canary {
print_release_notes(version::deno(), &install_version); print_release_notes(version::deno(), &install_version);
} }
@ -670,7 +689,7 @@ async fn download_package(
client: &HttpClient, client: &HttpClient,
download_url: &str, download_url: &str,
) -> Result<Vec<u8>, AnyError> { ) -> Result<Vec<u8>, AnyError> {
log::info!("Downloading {}", &download_url); log::info!("{}", colors::gray(format!("Downloading {}", &download_url)));
let maybe_bytes = { let maybe_bytes = {
let progress_bar = ProgressBar::new(ProgressBarStyle::DownloadBars); let progress_bar = ProgressBar::new(ProgressBarStyle::DownloadBars);
// provide an empty string here in order to prefer the downloading // provide an empty string here in order to prefer the downloading