diff --git a/.idea/HarTex.iml b/.idea/HarTex.iml index a84a7b1c6..1aea5cf7f 100644 --- a/.idea/HarTex.iml +++ b/.idea/HarTex.iml @@ -2,7 +2,7 @@ - + @@ -58,9 +58,11 @@ + + \ No newline at end of file diff --git a/api-backend/hartex-backend-routes/src/uptime.rs b/api-backend/hartex-backend-routes/src/uptime.rs index 48ce71119..f2583f5cc 100644 --- a/api-backend/hartex-backend-routes/src/uptime.rs +++ b/api-backend/hartex-backend-routes/src/uptime.rs @@ -26,15 +26,9 @@ use axum::Json; use axum::extract::Query; -use axum::extract::State; use axum::http::StatusCode; use axum_extra::extract::WithRejection; -use bb8_postgres::PostgresConnectionManager; -use bb8_postgres::bb8::Pool; -use bb8_postgres::tokio_postgres::GenericClient; -use bb8_postgres::tokio_postgres::NoTls; use chrono::DateTime; -use futures_util::stream::TryStreamExt; use hartex_backend_models::Response; use hartex_backend_models::uptime::UptimeQuery; use hartex_backend_models::uptime::UptimeQueryRejection; diff --git a/tools/Cargo.lock b/tools/Cargo.lock index 42e98e52f..342170ede 100644 --- a/tools/Cargo.lock +++ b/tools/Cargo.lock @@ -20,6 +20,7 @@ version = "0.14.0" dependencies = [ "clap", "fd-lock", + "owo-colors", "serde", "toml", ] @@ -160,6 +161,12 @@ version = "1.20.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1261fe7e33c73b354eab43b1273a57c8f967d0391e80353e51f764ac02cf6775" +[[package]] +name = "owo-colors" +version = "4.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fb37767f6569cd834a413442455e0f066d0d522de8630436e2a1761d9726ba56" + [[package]] name = "path-slash" version = "0.2.1" @@ -325,7 +332,7 @@ version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cf221c93e13a30d793f7645a0e7762c55d169dbb0a49671918a2319d289b10bb" dependencies = [ - "windows-sys 0.52.0", + "windows-sys 0.59.0", ] [[package]] diff --git a/tools/bootstrap/Cargo.toml b/tools/bootstrap/Cargo.toml index dcf488774..f1d1f4d52 100644 --- a/tools/bootstrap/Cargo.toml +++ b/tools/bootstrap/Cargo.toml @@ -11,6 +11,7 @@ rust-version = "1.86.0" [dependencies] clap = { version = "4.5.24", default-features = false, features = ["std", "usage", "help", "derive", "error-context"] } fd-lock = "4.0.2" +owo-colors = "4.1.0" serde = { version = "1.0.217", features = ["derive"] } toml = "0.8.19" diff --git a/tools/bootstrap/bootstrap.py b/tools/bootstrap/bootstrap.py index da7f7cc95..7550c2b90 100644 --- a/tools/bootstrap/bootstrap.py +++ b/tools/bootstrap/bootstrap.py @@ -69,7 +69,9 @@ def main(): help_triggered = args.help or len(sys.argv) == 1 if help_triggered: - print("NOTE: Building bootstrap before processing help command.") + bold = "\033[1m" + end = "\033[0m" + print(f"{bold + 'note:' + end} Building bootstrap before processing help command.") status = 0 success = "successfully" diff --git a/tools/bootstrap/builder.py b/tools/bootstrap/builder.py index 0acc2911a..031be4bc5 100644 --- a/tools/bootstrap/builder.py +++ b/tools/bootstrap/builder.py @@ -39,7 +39,9 @@ def build_bootstrap(self): if "GITHUB_ACTIONS" in env: print("::group::Building bootstrap") else: - print("INFO: Building bootstrap") + bold = "\033[1m" + end = "\033[0m" + print(f"{bold + 'info:' + end} Building bootstrap") args = self.build_bootstrap_cmd(env) run_cmd(args, env=env) diff --git a/tools/bootstrap/src/bin/main.rs b/tools/bootstrap/src/bin/main.rs index eda6a3e34..fe8f5eec2 100644 --- a/tools/bootstrap/src/bin/main.rs +++ b/tools/bootstrap/src/bin/main.rs @@ -29,6 +29,7 @@ use std::process; use bootstrap::build::Build; use bootstrap::config::Config; use bootstrap::config::flags::BootstrapSubcommand; +use owo_colors::OwoColorize; use fd_lock::RwLock; /// Entry point to the bootstrap binary, invoked by x.py. @@ -64,7 +65,7 @@ pub fn main() { } error => { drop(error); - println!("WARN: build directory locked by process {process_id}"); + println!("{} build directory locked by process {process_id}", "warning:".yellow().bold()); let mut lock = lock.write().expect("failed to get write lock on lockfile"); lock.write(process::id().to_string().as_ref()) @@ -75,9 +76,10 @@ pub fn main() { } if config.config_path.is_none() && !matches!(config.subcommand, BootstrapSubcommand::Setup) { - println!("WARN: no `hartex.conf` configuration file is found, using default configuration"); + println!("{} no `hartex.conf` configuration file is found, using default configuration", "warning:".yellow().bold()); println!( - "HELP: consider running `./x.py setup` or copying `hartex.example.conf` by running `cp hartex.example.conf hartex.conf`" + "{} consider running `./x.py setup` or copying `hartex.example.conf` by running `cp hartex.example.conf hartex.conf`", + "help:".bold(), ) } diff --git a/tools/bootstrap/src/steps/build.rs b/tools/bootstrap/src/steps/build.rs index 0502080b5..03bc2ddcc 100644 --- a/tools/bootstrap/src/steps/build.rs +++ b/tools/bootstrap/src/steps/build.rs @@ -22,7 +22,7 @@ use std::process::Command; use std::process::exit; - +use owo_colors::OwoColorize; use crate::builder::Builder; use crate::builder::RunConfig; use crate::builder::Step; @@ -169,7 +169,7 @@ pub fn build_cargo_project(project: &'static str, builder: &Builder<'_>) { ); command.env("RUSTFLAGS", rustflags); - println!("INFO: Building {project} project"); + println!("{} Building {project} project", "info:".bold()); let status = command.status().expect("failed to get status"); if !status.success() { exit(status.code().unwrap_or(1)); diff --git a/tools/bootstrap/src/steps/check.rs b/tools/bootstrap/src/steps/check.rs index 763f9ce9c..513e040e4 100644 --- a/tools/bootstrap/src/steps/check.rs +++ b/tools/bootstrap/src/steps/check.rs @@ -22,7 +22,7 @@ use std::process::Command; use std::process::exit; - +use owo_colors::OwoColorize; use crate::builder::Builder; use crate::builder::RunConfig; use crate::builder::Step; @@ -162,7 +162,7 @@ fn check_cargo_project(project: &'static str, builder: &Builder<'_>) { command.current_dir(pwd); - println!("INFO: Checking {project} project"); + println!("{} Checking {project} project", "info:".bold()); let status = command.status().expect("failed to get status"); if !status.success() { exit(status.code().unwrap_or(1)); diff --git a/tools/bootstrap/src/steps/clean.rs b/tools/bootstrap/src/steps/clean.rs index c0e1eaef3..219de17ea 100644 --- a/tools/bootstrap/src/steps/clean.rs +++ b/tools/bootstrap/src/steps/clean.rs @@ -21,7 +21,7 @@ */ use std::fs; - +use owo_colors::OwoColorize; use crate::builder::Builder; use crate::builder::RunConfig; use crate::builder::Step; @@ -156,9 +156,9 @@ fn clean(project: &'static str, builder: &Builder<'_>) { .join(env!("BOOTSTRAP_TARGET")) .join(project); - println!("INFO: deleting {}", dir.display()); + println!("{} deleting {}", "info:".bold(), dir.display()); if !dir.exists() { - println!("WARN: directory {} does not exist, skipping", dir.display()); + println!("{} directory {} does not exist, skipping", "warning:".yellow().bold(), dir.display()); return; } diff --git a/tools/bootstrap/src/steps/clippy.rs b/tools/bootstrap/src/steps/clippy.rs index 21c281f6c..cbadcb50c 100644 --- a/tools/bootstrap/src/steps/clippy.rs +++ b/tools/bootstrap/src/steps/clippy.rs @@ -22,7 +22,7 @@ use std::process::Command; use std::process::exit; - +use owo_colors::OwoColorize; use crate::builder::Builder; use crate::builder::RunConfig; use crate::builder::Step; @@ -152,7 +152,7 @@ fn clippy_cargo_project(project: &'static str, builder: &Builder<'_>) { command.arg("clippy"); command.current_dir(pwd); - println!("INFO: Clippying {project} project"); + println!("{} Clippying {project} project", "info:".bold()); let status = command.status().expect("failed to get status"); if !status.success() { exit(status.code().unwrap_or(1)); diff --git a/tools/bootstrap/src/steps/setup.rs b/tools/bootstrap/src/steps/setup.rs index 084d2cc51..a47e51c64 100644 --- a/tools/bootstrap/src/steps/setup.rs +++ b/tools/bootstrap/src/steps/setup.rs @@ -28,7 +28,7 @@ use std::io::BufRead; use std::io::Write; use std::path::PathBuf; use std::str::FromStr; - +use owo_colors::OwoColorize; use crate::builder::Builder; use crate::builder::RunConfig; use crate::builder::Step; @@ -141,7 +141,8 @@ impl Step for SetupProfile { .unwrap_or(PathBuf::from("hartex.conf")); if path.exists() { eprintln!( - "WARN: a configuration file already exists at {}", + "{} a configuration file already exists at {}", + "warning:".yellow().bold(), path.canonicalize() .expect("failed to canonicalize path") .display() @@ -202,8 +203,8 @@ pub fn interactive_profile() -> io::Result { break match parse_profile(&choice) { Ok(profile) => profile, Err(err) => { - eprintln!("ERROR: {err}. Please retry."); - eprintln!("NOTE: press Ctrl+C to exit"); + eprintln!("{} {err}. Please retry.", "error:".red().bold()); + eprintln!("{} press Ctrl+C to exit", "note:".bold()); continue; } }; @@ -216,8 +217,8 @@ pub fn interactive_profile() -> io::Result { #[allow(clippy::missing_panics_doc)] #[allow(clippy::module_name_repetitions)] pub fn setup_profile(config: &Config, profile: SetupProfile) { - println!("INFO: using profile {profile}"); - println!("INFO: copying `tools/bootstrap/profiles/hartex.{profile}.conf` to `hartex.conf`"); + println!("{} using profile {profile}", "info:".bold()); + println!("{} copying `tools/bootstrap/profiles/hartex.{profile}.conf` to `hartex.conf`", "info:".bold()); fs::copy( config @@ -228,7 +229,7 @@ pub fn setup_profile(config: &Config, profile: SetupProfile) { .expect("failed to copy files"); println!( - "INFO: Done. `x.py` will now use the specified configuration in `hartex.conf` for further invocations." + "{} Done. `x.py` will now use the specified configuration in `hartex.conf` for further invocations.", "info:".bold() ); } @@ -247,7 +248,8 @@ impl Step for ConfigureVscode { let vscode_config = run.builder.config.root.join(".vscode/settings.json"); if vscode_config.exists() { eprintln!( - "WARN: a vscode configuration file already exists at {}", + "{} a vscode configuration file already exists at {}", + "warning:".yellow().bold(), vscode_config .canonicalize() .expect("failed to canonicalize path") @@ -263,7 +265,7 @@ impl Step for ConfigureVscode { } } - println!("INFO: Preview of the recommended vscode configuration file is as follows"); + println!("{} Preview of the recommended vscode configuration file is as follows", "info:".bold()); println!("{VSCODE_SETTINGS}"); match question_bool("Do you wish to continue?", true) { @@ -280,7 +282,7 @@ impl Step for ConfigureVscode { #[allow(clippy::module_name_repetitions)] #[allow(clippy::unused_io_amount)] pub fn setup_vscode_config(builder: &Builder<'_>) { - println!("INFO: writing new `.vscode/settings.json`"); + println!("{} writing new `.vscode/settings.json`", "info:".bold()); let vscode_dir = builder.config.root.join(".vscode"); if !vscode_dir.exists() { @@ -312,7 +314,8 @@ impl Step for ConfigureFleet { if fleet_config.exists() { eprintln!( - "WARN: a fleet configuration file already exists at {}", + "{} a fleet configuration file already exists at {}", + "warning:".yellow().bold(), fleet_config .canonicalize() .expect("failed to canonicalize path") @@ -328,7 +331,7 @@ impl Step for ConfigureFleet { } } - println!("INFO: Preview of the recommended fleet configuration file is as follows"); + println!("{} Preview of the recommended fleet configuration file is as follows", "info:".bold()); println!("{FLEET_SETTINGS}"); match question_bool("Do you wish to continue?", true) { @@ -345,7 +348,7 @@ impl Step for ConfigureFleet { #[allow(clippy::module_name_repetitions)] #[allow(clippy::unused_io_amount)] pub fn setup_fleet_config(builder: &Builder<'_>) { - println!("INFO: writing new `.fleet/settings.json`"); + println!("{} writing new `.fleet/settings.json`", "info:".bold()); let fleet_dir = builder.config.root.join(".fleet"); if !fleet_dir.exists() { @@ -377,7 +380,8 @@ impl Step for ConfigureZed { if zed_config.exists() { eprintln!( - "WARN: a zed configuration file already exists at {}", + "{} a zed configuration file already exists at {}", + "warning:".yellow().bold(), zed_config .canonicalize() .expect("failed to canonicalize path") @@ -393,7 +397,7 @@ impl Step for ConfigureZed { } } - println!("INFO: Preview of the recommended Zed configuration file is as follows"); + println!("{} Preview of the recommended Zed configuration file is as follows", "info:".bold()); println!("{ZED_SETTINGS}"); match question_bool("Do you wish to continue?", true) { @@ -410,7 +414,7 @@ impl Step for ConfigureZed { #[allow(clippy::module_name_repetitions)] #[allow(clippy::unused_io_amount)] pub fn setup_zed_config(builder: &Builder<'_>) { - println!("INFO: writing new `.zed/settings.json`"); + println!("{} writing new `.zed/settings.json`", "info:".bold()); let zed_dir = builder.config.root.join(".zed"); if !zed_dir.exists() { diff --git a/tools/bootstrap/src/steps/test.rs b/tools/bootstrap/src/steps/test.rs index f226f96b4..b3827d73a 100644 --- a/tools/bootstrap/src/steps/test.rs +++ b/tools/bootstrap/src/steps/test.rs @@ -22,7 +22,7 @@ use std::process::Command; use std::process::exit; - +use owo_colors::OwoColorize; use crate::builder::Builder; use crate::builder::RunConfig; use crate::builder::Step; @@ -67,7 +67,7 @@ fn build_testsuite_tool(builder: &Builder<'_>) { ); command.env("RUSTFLAGS", rustflags); - println!("INFO: Building testsuite tool before running tests"); + println!("{} Building testsuite tool before running tests", "info:".bold()); let status = command.status().expect("failed to get status"); if !status.success() { exit(status.code().unwrap_or(1)); @@ -103,7 +103,7 @@ fn run_ui_tests(builder: &Builder<'_>) { command.args(&builder.config.subcommand_args); command.current_dir(&builder.config.root); - println!("INFO: Running testsuite tool"); + println!("{} Running testsuite tool", "info:".bold()); let status = command.status().expect("failed to get status"); if !status.success() { exit(status.code().unwrap_or(1)); diff --git a/tools/testsuite/src/tests.rs b/tools/testsuite/src/tests.rs index 7eb679ffe..4e24e8ad1 100644 --- a/tools/testsuite/src/tests.rs +++ b/tools/testsuite/src/tests.rs @@ -120,7 +120,7 @@ fn make_test(config: Arc, path: PathBuf) -> Option { let Ok(header) = header::parse_header(&path) else { eprintln!( - "WARN: test file {} does not have a valid test file header, ignoring", + "{} test file {} does not have a valid test file header, ignoring", path.display() ); return None;