xbp 0.6.1

XBP is a build pack and deployment management tool to deploy, rust, nextjs etc and manage the NGINX configs below it
Documentation
//! Setup command module
//!
//! Installs common system packages required by deployments. The command runs a
//! curated `apt install` invocation and reports progress and errors. Intended
//! for Ubuntu/Debian systems.
use std::process::Output;
use std::time::{Instant};
use tokio::process::Command;

use crate::logging::{log_timed, LogLevel};

/// Execute the `setup` command.
///
/// Runs a non-interactive set of package installs. When `debug` is true, prints
/// the command and raw output for diagnostics.
pub async fn run_setup(debug: bool) -> Result<(), String> {
    let setup_cmd: String = "sudo apt install -y net-tools nginx pkg-config libssl-dev build-essential plocate sshpass neofetch certbot python3-certbot-nginx".to_string();
    if debug {
        println!("[DEBUG] Running setup command: {}", setup_cmd);
    }
    let start: Instant = Instant::now();
    let output: Output = Command::new("sh")
        .arg("-c")
        .arg(setup_cmd)
        .output()
        .await
        .map_err(|e| format!("Failed to execute setup command: {}", e))?;

    let elapsed = start.elapsed();
    let _ = log_timed(LogLevel::Success, "setup", "Setup completed", elapsed.as_millis() as u64).await;

    if debug {
        println!("[DEBUG] Setup command output: {:?}", output);
        println!("[DEBUG] Setup command took: {:.2?}", elapsed);
    }

    if !output.status.success() {
        return Err(format!(
            "Setup failed: {}",
            String::from_utf8_lossy(&output.stderr)
        ));
    }

    if !output.stdout.is_empty() {
        println!(
            "\x1b[92mSetup output:\x1b[0m {}",
            String::from_utf8_lossy(&output.stdout)
        );
    }

    println!("\x1b[92mSetup completed successfully!\x1b[0m");
    Ok(())
}