Skip to content
New issue

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

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

Already on GitHub? # to your account

feat(upgrade): refresh output #24911

Merged
merged 2 commits into from
Aug 7, 2024
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
55 changes: 37 additions & 18 deletions cli/tools/upgrade.rs
Original file line number Diff line number Diff line change
Expand Up @@ -238,14 +238,18 @@ fn get_minor_version(version: &str) -> &str {
fn print_release_notes(current_version: &str, new_version: &str) {
if get_minor_version(current_version) != get_minor_version(new_version) {
log::info!(
"{}{}",
"Release notes: https://github.com/denoland/deno/releases/tag/v",
&new_version,
"Release notes:\n\n {}\n",
colors::bold(format!(
"https://github.com/denoland/deno/releases/tag/v{}",
&new_version,
))
);
log::info!(
"{}{}",
"Blog post: https://deno.com/blog/v",
get_minor_version(new_version)
"Blog post:\n\n {}\n",
colors::bold(format!(
"https://deno.com/blog/v{}",
get_minor_version(new_version)
))
);
}
}
Expand Down Expand Up @@ -479,10 +483,10 @@ pub async fn upgrade(
}
None => {
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
} else {
log::info!("Looking up latest version");
log::info!("{}", colors::gray("Looking up latest version"));
ReleaseChannel::Stable
};

Expand All @@ -509,16 +513,22 @@ pub async fn upgrade(
&& current_is_most_recent
{
log::info!(
"Local deno version {} is the most recent release",
if upgrade_flags.canary {
crate::version::GIT_COMMIT_HASH
} else {
crate::version::deno()
}
"{}",
colors::green(format!(
"\nLocal deno version {} is the most recent release\n",
if upgrade_flags.canary {
crate::version::GIT_COMMIT_HASH
} else {
crate::version::deno()
}
))
);
return Ok(());
} else {
log::info!("Found latest version {}", latest_version);
log::info!(
"{}",
colors::bold(format!("\nFound latest version {}\n", latest_version))
);
latest_version
}
}
Expand All @@ -540,7 +550,10 @@ pub async fn upgrade(
.await
.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 new_exe_path = unpack_into_dir(
Expand Down Expand Up @@ -589,7 +602,13 @@ pub async fn upgrade(
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 {
print_release_notes(version::deno(), &install_version);
}
Expand Down Expand Up @@ -670,7 +689,7 @@ async fn download_package(
client: &HttpClient,
download_url: &str,
) -> Result<Vec<u8>, AnyError> {
log::info!("Downloading {}", &download_url);
log::info!("{}", colors::gray(format!("Downloading {}", &download_url)));
let maybe_bytes = {
let progress_bar = ProgressBar::new(ProgressBarStyle::DownloadBars);
// provide an empty string here in order to prefer the downloading
Expand Down