diff --git a/src/cli/commands/update.rs b/src/cli/commands/update.rs index 785219b..e532342 100644 --- a/src/cli/commands/update.rs +++ b/src/cli/commands/update.rs @@ -7,6 +7,7 @@ use crate::{ error::{MultiError, PakkerError}, model::{Config, LockFile, UpdateStrategy}, ui_utils::{prompt_select, prompt_typo_suggestion, prompt_yes_no}, + utils::FlexVer, }; pub async fn execute( @@ -141,6 +142,15 @@ pub async fn execute( && !updated_project.files.is_empty() && let Some(old_file) = lockfile.projects[idx].files.first() { + // Sort files by FlexVer if that strategy is set + if old_project.update_strategy == UpdateStrategy::FlexVer { + updated_project.files.sort_by(|a, b| { + // Use FlexVer for comparison - b.cmp(a) gives descending order + // (newest first) + FlexVer(&b.file_name).cmp(&FlexVer(&a.file_name)) + }); + } + // Clone data needed for comparisons to avoid borrow issues let new_file_id = updated_project.files.first().unwrap().id.clone(); let new_file_name =