Implement update execution and provider contract

This commit is contained in:
stoorps 2026-03-20 00:15:40 +00:00
parent 842c390260
commit d8eb7b3cab
Signed by: stoorps
SSH key fingerprint: SHA256:AZlPfu9hTu042EGtZElmDQoy+KvMOeShLDan/fYLoNI
16 changed files with 407 additions and 79 deletions

View file

@ -1,4 +1,5 @@
use aim_core::app::add::AddPlan;
use aim_core::domain::update::UpdateExecutionStatus;
use crate::DispatchResult;
@ -15,6 +16,7 @@ pub fn render_dispatch_result(result: &DispatchResult) -> String {
DispatchResult::UpdatePlan(plan) => {
render_update_summary(plan.items.len(), plan.items.len(), 0)
}
DispatchResult::Updated(result) => render_updated_apps(result),
DispatchResult::Noop => String::new(),
}
}
@ -88,3 +90,29 @@ fn render_removed_app(removed: &aim_core::app::remove::RemovalResult) -> String
format!("{summary}\n{warning_lines}")
}
}
fn render_updated_apps(result: &aim_core::domain::update::UpdateExecutionResult) -> String {
let mut lines = vec![format!(
"updated apps: {}, failed: {}",
result.updated_count(),
result.failed_count()
)];
for item in &result.items {
match &item.status {
UpdateExecutionStatus::Updated => lines.push(format!(
"updated: {} ({}) {} -> {}",
item.display_name,
item.stable_id,
item.from_version.as_deref().unwrap_or("unknown"),
item.to_version.as_deref().unwrap_or("unknown")
)),
UpdateExecutionStatus::Failed { reason } => lines.push(format!(
"failed: {} ({}) {}",
item.display_name, item.stable_id, reason
)),
}
}
lines.join("\n")
}