xbp 10.40.0

XBP is a zero-config build pack that can also interact with proxies, kafka, sockets, synthetic monitors.
Documentation
use std::path::Path;

use colored::Colorize;

use crate::strategies::XbpConfig;

use super::plan::DeployPlan;
use super::providers::execute_step;
use super::types::{DeployExecutionReport, DeployMode};

pub async fn execute_plan(
    project_root: &Path,
    config: &XbpConfig,
    plan: &DeployPlan,
    mode: DeployMode,
    yes: bool,
    debug: bool,
) -> Result<DeployExecutionReport, String> {
    let mut lines = Vec::new();
    let mut failed = Vec::new();

    lines.push(format!(
        "{} {} services mode={mode:?}",
        "Executing".bright_cyan().bold(),
        plan.steps.len()
    ));

    for step in &plan.steps {
        println!(
            "{} {} ({})",
            "".bright_blue().bold(),
            step.service.bright_white().bold(),
            step.provider.bright_yellow()
        );
        match execute_step(project_root, config, step, mode, yes, debug).await {
            Ok(step_lines) => {
                for line in step_lines {
                    println!("  {line}");
                    lines.push(line);
                }
            }
            Err(error) => {
                let msg = format!("[{}] ERROR: {error}", step.service);
                println!("  {}", msg.bright_red());
                lines.push(msg);
                failed.push(step.service.clone());
                // Continue remaining services so a group gets partial progress visibility
            }
        }
    }

    Ok(DeployExecutionReport {
        ok: failed.is_empty(),
        lines,
        failed_services: failed,
    })
}