mirror of
https://github.com/pesde-pkg/pesde.git
synced 2025-01-09 09:19:10 +00:00
fix: gracefully handle unparsable versions & dont display metadata
This commit is contained in:
parent
9ee75ec9c9
commit
d35f34e8f0
3 changed files with 23 additions and 11 deletions
|
@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
- Add Roblox types in linker modules even with no config generator script by @daimond113
|
- Add Roblox types in linker modules even with no config generator script by @daimond113
|
||||||
|
- Gracefully handle unparsable tag names when checking for updates & don't display build metadata by @daimond113
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
- Remove lower bound limit of 3 characters for pesde package names by @daimond113
|
- Remove lower bound limit of 3 characters for pesde package names by @daimond113
|
||||||
|
|
|
@ -7,6 +7,7 @@ use crate::cli::{
|
||||||
use anyhow::Context;
|
use anyhow::Context;
|
||||||
use clap::Args;
|
use clap::Args;
|
||||||
use colored::Colorize;
|
use colored::Colorize;
|
||||||
|
use semver::BuildMetadata;
|
||||||
|
|
||||||
#[derive(Debug, Args)]
|
#[derive(Debug, Args)]
|
||||||
pub struct SelfUpgradeCommand {
|
pub struct SelfUpgradeCommand {
|
||||||
|
@ -32,11 +33,17 @@ impl SelfUpgradeCommand {
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let display_latest_version = {
|
||||||
|
let mut ver = latest_version.clone();
|
||||||
|
// remove build metadata to make it more readable
|
||||||
|
ver.build = BuildMetadata::EMPTY;
|
||||||
|
ver.to_string().yellow().bold()
|
||||||
|
};
|
||||||
|
|
||||||
if !inquire::prompt_confirmation(format!(
|
if !inquire::prompt_confirmation(format!(
|
||||||
"are you sure you want to upgrade {} from {} to {}?",
|
"are you sure you want to upgrade {} from {} to {display_latest_version}?",
|
||||||
env!("CARGO_BIN_NAME").cyan(),
|
env!("CARGO_BIN_NAME").cyan(),
|
||||||
current_version().to_string().yellow().bold(),
|
env!("CARGO_PKG_VERSION").yellow().bold()
|
||||||
latest_version.to_string().yellow().bold()
|
|
||||||
))? {
|
))? {
|
||||||
println!("cancelled upgrade");
|
println!("cancelled upgrade");
|
||||||
return Ok(());
|
return Ok(());
|
||||||
|
@ -47,10 +54,7 @@ impl SelfUpgradeCommand {
|
||||||
.unwrap();
|
.unwrap();
|
||||||
update_bin_exe(&path).await?;
|
update_bin_exe(&path).await?;
|
||||||
|
|
||||||
println!(
|
println!("upgraded to version {display_latest_version}!",);
|
||||||
"upgraded to version {}!",
|
|
||||||
latest_version.to_string().yellow().bold()
|
|
||||||
);
|
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,7 +59,7 @@ pub async fn get_latest_remote_version(reqwest: &reqwest::Client) -> anyhow::Res
|
||||||
|
|
||||||
releases
|
releases
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(|release| Version::parse(release.tag_name.trim_start_matches('v')).unwrap())
|
.filter_map(|release| Version::parse(release.tag_name.trim_start_matches('v')).ok())
|
||||||
.max()
|
.max()
|
||||||
.context("failed to find latest version")
|
.context("failed to find latest version")
|
||||||
}
|
}
|
||||||
|
@ -89,11 +89,18 @@ pub async fn check_for_updates(reqwest: &reqwest::Client) -> anyhow::Result<()>
|
||||||
|
|
||||||
if version > current_version {
|
if version > current_version {
|
||||||
let name = env!("CARGO_BIN_NAME");
|
let name = env!("CARGO_BIN_NAME");
|
||||||
let changelog = format!("{}/releases/tag/v{version}", env!("CARGO_PKG_REPOSITORY"),);
|
let changelog = format!("{}/releases/tag/v{version}", env!("CARGO_PKG_REPOSITORY"));
|
||||||
|
|
||||||
|
let display_version = {
|
||||||
|
let mut ver = version.clone();
|
||||||
|
// remove build metadata to make it more readable
|
||||||
|
ver.build = semver::BuildMetadata::EMPTY;
|
||||||
|
ver.to_string()
|
||||||
|
};
|
||||||
|
|
||||||
let unformatted_messages = [
|
let unformatted_messages = [
|
||||||
"".to_string(),
|
"".to_string(),
|
||||||
format!("update available! {current_version} → {version}"),
|
format!("update available! {current_version} → {display_version}"),
|
||||||
format!("changelog: {changelog}"),
|
format!("changelog: {changelog}"),
|
||||||
format!("run `{name} self-upgrade` to upgrade"),
|
format!("run `{name} self-upgrade` to upgrade"),
|
||||||
"".to_string(),
|
"".to_string(),
|
||||||
|
@ -113,7 +120,7 @@ pub async fn check_for_updates(reqwest: &reqwest::Client) -> anyhow::Result<()>
|
||||||
format!(
|
format!(
|
||||||
"update available! {} → {}",
|
"update available! {} → {}",
|
||||||
current_version.to_string().red(),
|
current_version.to_string().red(),
|
||||||
version.to_string().green()
|
display_version.green()
|
||||||
),
|
),
|
||||||
format!("changelog: {}", changelog.blue()),
|
format!("changelog: {}", changelog.blue()),
|
||||||
format!(
|
format!(
|
||||||
|
|
Loading…
Reference in a new issue