From 6a759b4ec0545b54ccea553d47c5ffd6c84d90b0 Mon Sep 17 00:00:00 2001 From: Nicolas Meienberger Date: Tue, 13 Aug 2024 22:52:15 +0200 Subject: [PATCH 1/3] refactor(update): improve matching and message formatting --- src/commands/update.rs | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/src/commands/update.rs b/src/commands/update.rs index bc3a05a..5c9334b 100644 --- a/src/commands/update.rs +++ b/src/commands/update.rs @@ -91,12 +91,9 @@ pub fn run(args: UpdateArgs) { run_args.push("--no-permissions".to_string()); } - match args.env_file { - Some(env_file) => { - run_args.push("--env-file".to_string()); - run_args.push(env_file.display().to_string()); - } - None => {} + if let Some(env_file) = args.env_file { + run_args.push("--env-file".to_string()); + run_args.push(env_file.display().to_string()); } // Run command start on new CLI @@ -122,15 +119,14 @@ pub fn run(args: UpdateArgs) { let internal_ip = get_env_value("INTERNAL_IP").unwrap_or("localhost".to_string()); let nginx_port = get_env_value("NGINX_PORT").unwrap_or("80".to_string()); - let ip_and_port = format!("Visit http://{}:{} to access the dashboard", internal_ip, nginx_port); let box_title = "Runtipi started successfully".to_string(); - let box_body = format!( - "{}\n\n{}\n\n{}", - ip_and_port, - format!("You are now running version {}", release.version), - "Tipi is entirely written in TypeScript and we are looking for contributors!" - ); + + let ip_and_port = format!("Visit http://{}:{} to access the dashboard", internal_ip, nginx_port); + let message = format!("You are now running version {}", release.version); + let shameless_plug = "Tipi is entirely written in TypeScript and we are looking for contributors!"; + + let box_body = format!("{}\n\n{}\n\n{}", ip_and_port, message, shameless_plug); let console_box = ConsoleBox::new(box_title, box_body, 80, "green".to_string()); console_box.print(); From 14e9ee317d48bb20e5e6fcb37cb4ffba0f1f221b Mon Sep 17 00:00:00 2001 From: Nicolas Meienberger Date: Tue, 13 Aug 2024 23:03:35 +0200 Subject: [PATCH 2/3] chore: fix linting issues --- src/args.rs | 11 ++++++----- src/commands/app.rs | 16 ++++++++-------- src/commands/reset_password.rs | 1 - src/components/console_box.rs | 2 +- src/components/spinner.rs | 4 +--- 5 files changed, 16 insertions(+), 18 deletions(-) diff --git a/src/args.rs b/src/args.rs index c5f4962..d3ae8be 100644 --- a/src/args.rs +++ b/src/args.rs @@ -1,3 +1,4 @@ +use core::fmt; use semver::{Error as SemverError, Version}; use std::{path::PathBuf, str::FromStr}; @@ -28,12 +29,12 @@ impl FromStr for VersionEnum { } } -impl ToString for VersionEnum { - fn to_string(&self) -> String { +impl fmt::Display for VersionEnum { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { - VersionEnum::Version(version) => version.to_string(), - VersionEnum::Latest => "latest".to_string(), - VersionEnum::Nightly => "nightly".to_string(), + VersionEnum::Version(version) => write!(f, "{}", version), + VersionEnum::Latest => write!(f, "latest"), + VersionEnum::Nightly => write!(f, "nightly"), } } } diff --git a/src/commands/app.rs b/src/commands/app.rs index d5e3301..35e6a92 100644 --- a/src/commands/app.rs +++ b/src/commands/app.rs @@ -28,7 +28,7 @@ pub fn run(args: AppCommand, env_map: EnvMap) { } Err(err) => { spin.fail("Failed to start app."); - println!("{}", format!("Error: {}", err)); + println!("Error: {}", err); } } spin.finish(); @@ -48,7 +48,7 @@ pub fn run(args: AppCommand, env_map: EnvMap) { } Err(err) => { spin.fail("Failed to stop app."); - println!("{}", format!("Error: {}", err)); + println!("Error: {}", err); } } spin.finish(); @@ -68,7 +68,7 @@ pub fn run(args: AppCommand, env_map: EnvMap) { } Err(err) => { spin.fail("Failed to uninstall app."); - println!("{}", format!("Error: {}", err)); + println!("Error: {}", err); } } spin.finish(); @@ -91,7 +91,7 @@ pub fn run(args: AppCommand, env_map: EnvMap) { Err(err) => { spin.fail("Failed to reset app."); spin.finish(); - println!("{}", format!("Error: {}", err)); + println!("Error: {}", err); } } } @@ -113,14 +113,14 @@ pub fn run(args: AppCommand, env_map: EnvMap) { Err(err) => { spin.fail("Failed to update app."); spin.finish(); - println!("{}", format!("Error: {}", err)); + println!("Error: {}", err); } } } AppSubcommand::StartAll(_) => { let spin = spinner::new("Starting all apps..."); let api_response = api_request(format!("{}/{}", base_url, "start-all")); - let error_message = format!("Failed to start apps. See logs/error.log for more details."); + let error_message = "Failed to start apps. See logs/error.log for more details."; match api_response { Ok(response) => { @@ -128,14 +128,14 @@ pub fn run(args: AppCommand, env_map: EnvMap) { spin.succeed("All apps started successfully!!"); spin.finish(); } else { - spin.fail(&error_message); + spin.fail(error_message); spin.finish(); } } Err(err) => { spin.fail("Failed to start apps."); spin.finish(); - println!("{}", format!("Error: {}", err)); + println!("Error: {}", err); } } } diff --git a/src/commands/reset_password.rs b/src/commands/reset_password.rs index d536c0b..b621ea4 100644 --- a/src/commands/reset_password.rs +++ b/src/commands/reset_password.rs @@ -39,7 +39,6 @@ pub fn run() { .unwrap_or("./state/password-change-request"), e ); - return; } } } diff --git a/src/components/console_box.rs b/src/components/console_box.rs index a6e5905..6b095c9 100644 --- a/src/components/console_box.rs +++ b/src/components/console_box.rs @@ -75,7 +75,7 @@ impl ConsoleBox { current_line = String::new(); } current_line.push_str(word); - current_line.push_str(" "); + current_line.push(' '); } split_lines.push(current_line); for line in split_lines { diff --git a/src/components/spinner.rs b/src/components/spinner.rs index 5ac7d06..c011294 100644 --- a/src/components/spinner.rs +++ b/src/components/spinner.rs @@ -54,7 +54,5 @@ impl CustomSpinner { } pub fn new(message: &str) -> CustomSpinner { - let spinner = CustomSpinner::new(message.to_string()); - - return spinner; + CustomSpinner::new(message.to_string()) } From 04d3ecb012a707e49ef34ace6c6e1015bf3161e0 Mon Sep 17 00:00:00 2001 From: Nicolas Meienberger Date: Wed, 25 Sep 2024 19:08:50 +0200 Subject: [PATCH 3/3] chore: bump traefik version --- src/assets/docker-compose.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/assets/docker-compose.yml b/src/assets/docker-compose.yml index 2c6557a..09e03fb 100644 --- a/src/assets/docker-compose.yml +++ b/src/assets/docker-compose.yml @@ -4,7 +4,7 @@ services: depends_on: runtipi: condition: service_healthy - image: traefik:v3.0 + image: traefik:v3.1.4 restart: unless-stopped ports: - ${NGINX_PORT:-80}:80