From 06e8e14520a4a38fed500581d2b75a42418b22c4 Mon Sep 17 00:00:00 2001 From: nsfisis Date: Thu, 4 Jun 2026 21:09:02 +0900 Subject: feat(package): implement PackageInterface accessor layer for Package/CompletePackage/RootPackage Fill the trait-impl todo!() across the package accessor layer so loaded packages are actually usable (the ArrayLoader::load path depends on it): - Package: implement BasePackage/PackageInterface from struct fields and existing inherent methods; Display via get_unique_name. - CompletePackage: delegate PackageInterface to inner Package. - RootPackage: delegate CompletePackageInterface/PackageInterface to inner CompletePackage; RootPackageInterface link setters delegate to Package. Correct three unfaithful trait signatures found during implementation: - get_target_dir returns Option (PHP computes a normalized value; a borrow cannot represent it, and AliasPackage could not implement &str across its aliasOf handle). - RootPackageInterface link setters take IndexMap, matching Package and the real ArrayLoader caller (PHP RootPackage inherits Package::setRequires; the Link[] docblock was imprecise). - get_full_pretty_version takes a DisplayMode enum instead of a raw i64; the match is now exhaustive, so it returns String without an error path. Move mirror conversion to the boundaries: PackageInterface mirror methods use Vec (the typed form, matching the inherent methods), with array<->Mirror conversion done by the producer (ComposerRepository) and consumer (ArrayDumper). Co-Authored-By: Claude Opus 4.8 --- crates/shirabe/src/command/show_command.rs | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) (limited to 'crates/shirabe/src/command/show_command.rs') diff --git a/crates/shirabe/src/command/show_command.rs b/crates/shirabe/src/command/show_command.rs index e7fcfe1..f992798 100644 --- a/crates/shirabe/src/command/show_command.rs +++ b/crates/shirabe/src/command/show_command.rs @@ -606,8 +606,9 @@ impl ShowCommand { && latest_package .as_ref() .unwrap() - .get_full_pretty_version(true, 0) - != package.get_full_pretty_version(true, 0) + .get_full_pretty_version(true, crate::package::DisplayMode::SourceRefIfDev) + != package + .get_full_pretty_version(true, crate::package::DisplayMode::SourceRefIfDev) && (latest_package .as_ref() .unwrap() @@ -905,9 +906,13 @@ impl ShowCommand { // Determine if Composer is checking outdated dependencies and if current package should trigger non-default exit code let mut package_is_up_to_date = if let Some(latest) = latest_package { - latest.get_full_pretty_version(true, 0) - == package.get_full_pretty_version(true, 0) - && latest.as_complete().map_or(true, |c| !c.is_abandoned()) + latest.get_full_pretty_version( + true, + crate::package::DisplayMode::SourceRefIfDev, + ) == package.get_full_pretty_version( + true, + crate::package::DisplayMode::SourceRefIfDev, + ) && latest.as_complete().map_or(true, |c| !c.is_abandoned()) } else { false }; @@ -967,7 +972,10 @@ impl ShowCommand { } name_length = name_length.max(package.get_pretty_name().len()); if write_version { - let mut version_str = package.get_full_pretty_version(true, 0); + let mut version_str = package.get_full_pretty_version( + true, + crate::package::DisplayMode::SourceRefIfDev, + ); if format == "text" { version_str = version_str.trim_start_matches('v').to_string(); } @@ -1003,7 +1011,10 @@ impl ShowCommand { } if write_latest && latest_package.is_some() { let latest = latest_package.unwrap(); - let mut latest_version_str = latest.get_full_pretty_version(true, 0); + let mut latest_version_str = latest.get_full_pretty_version( + true, + crate::package::DisplayMode::SourceRefIfDev, + ); if format == "text" { latest_version_str = latest_version_str.trim_start_matches('v').to_string(); @@ -2518,8 +2529,8 @@ impl ShowCommand { latest_package: PackageInterfaceHandle, package: PackageInterfaceHandle, ) -> String { - if latest_package.get_full_pretty_version(true, 0) - == package.get_full_pretty_version(true, 0) + if latest_package.get_full_pretty_version(true, crate::package::DisplayMode::SourceRefIfDev) + == package.get_full_pretty_version(true, crate::package::DisplayMode::SourceRefIfDev) { return "up-to-date".to_string(); } -- cgit v1.3.1