mirror of
https://github.com/denoland/deno.git
synced 2024-12-22 07:14:47 -05:00
feat(upgrade): link to release notes & blog post (#17073)
This change prints a link to the release notes to `deno upgrade` output and its variations. Release notes aren't printed for commands relating to canary versions. Closes #16350.
This commit is contained in:
parent
bf237c6241
commit
0d1471282b
1 changed files with 65 additions and 1 deletions
|
@ -162,6 +162,14 @@ impl<TEnvironment: UpdateCheckerEnvironment> UpdateChecker<TEnvironment> {
|
|||
}
|
||||
}
|
||||
|
||||
fn get_minor_version(version: &str) -> &str {
|
||||
version.rsplitn(2, '.').collect::<Vec<&str>>()[1]
|
||||
}
|
||||
|
||||
fn has_same_minor_version(current_version: &str, new_version: &str) -> bool {
|
||||
get_minor_version(current_version) == get_minor_version(new_version)
|
||||
}
|
||||
|
||||
pub fn check_for_upgrades(http_client: HttpClient, cache_file_path: PathBuf) {
|
||||
if env::var("DENO_NO_UPDATE_CHECK").is_ok() {
|
||||
return;
|
||||
|
@ -199,12 +207,26 @@ pub fn check_for_upgrades(http_client: HttpClient, cache_file_path: PathBuf) {
|
|||
"{} {} → {} ",
|
||||
colors::green("A new release of Deno is available:"),
|
||||
colors::cyan(version::deno()),
|
||||
colors::cyan(upgrade_version)
|
||||
colors::cyan(&upgrade_version)
|
||||
);
|
||||
eprintln!(
|
||||
"{}",
|
||||
colors::italic_gray("Run `deno upgrade` to install it.")
|
||||
);
|
||||
eprint!(
|
||||
"{}{}",
|
||||
colors::yellow(
|
||||
"Release notes: https://github.com/denoland/deno/releases/tag/v"
|
||||
),
|
||||
colors::yellow(&upgrade_version),
|
||||
);
|
||||
if !has_same_minor_version(&version::deno(), &upgrade_version) {
|
||||
eprint!(
|
||||
"{}{}",
|
||||
colors::yellow("Blog post: https://deno.com/blog/v"),
|
||||
colors::yellow(get_minor_version(&upgrade_version)),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
update_checker.store_prompted();
|
||||
|
@ -290,6 +312,16 @@ pub async fn upgrade(
|
|||
&& current_is_passed
|
||||
{
|
||||
log::info!("Version {} is already installed", crate::version::deno());
|
||||
log::info!(
|
||||
"{}{}",
|
||||
"Release notes: https://github.com/denoland/deno/releases/tag/v",
|
||||
crate::version::deno(),
|
||||
);
|
||||
log::info!(
|
||||
"{}{}",
|
||||
"Blog post: https://deno.com/blog/v",
|
||||
get_minor_version(&crate::version::deno())
|
||||
);
|
||||
return Ok(());
|
||||
} else {
|
||||
passed_version
|
||||
|
@ -327,6 +359,18 @@ pub async fn upgrade(
|
|||
crate::version::deno()
|
||||
}
|
||||
);
|
||||
if !upgrade_flags.canary {
|
||||
log::info!(
|
||||
"{}{}",
|
||||
"Release notes: https://github.com/denoland/deno/releases/tag/v",
|
||||
crate::version::deno(),
|
||||
);
|
||||
log::info!(
|
||||
"{}{}",
|
||||
"Blog post: https://deno.com/blog/v",
|
||||
get_minor_version(&crate::version::deno())
|
||||
);
|
||||
}
|
||||
return Ok(());
|
||||
} else {
|
||||
log::info!("Found latest version {}", latest_version);
|
||||
|
@ -364,6 +408,16 @@ pub async fn upgrade(
|
|||
if upgrade_flags.dry_run {
|
||||
fs::remove_file(&new_exe_path)?;
|
||||
log::info!("Upgraded successfully (dry run)");
|
||||
log::info!(
|
||||
"{}{}",
|
||||
"Release notes: https://github.com/denoland/deno/releases/tag/v",
|
||||
install_version,
|
||||
);
|
||||
log::info!(
|
||||
"{}{}",
|
||||
"Blog post: https://deno.com/blog/v",
|
||||
get_minor_version(&install_version)
|
||||
);
|
||||
} else {
|
||||
let output_exe_path =
|
||||
upgrade_flags.output.as_ref().unwrap_or(¤t_exe_path);
|
||||
|
@ -395,6 +449,16 @@ pub async fn upgrade(
|
|||
}
|
||||
}
|
||||
log::info!("Upgraded successfully");
|
||||
log::info!(
|
||||
"{}{}",
|
||||
"Release notes: https://github.com/denoland/deno/releases/tag/v",
|
||||
&install_version,
|
||||
);
|
||||
log::info!(
|
||||
"{}{}",
|
||||
"Blog post: https://deno.com/blog/v",
|
||||
get_minor_version(&install_version)
|
||||
);
|
||||
}
|
||||
|
||||
Ok(())
|
||||
|
|
Loading…
Reference in a new issue