From 4df5f8491320e5795718cf0222e80fa27e57c8ad Mon Sep 17 00:00:00 2001 From: nsfisis Date: Mon, 11 May 2026 02:05:34 +0900 Subject: refactor(package): rename traits and switch dep maps to IndexMap MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Rename Package/CompletePackage to PackageInterface/CompletePackageInterface to mirror Composer's interface names, and split each into its own module under crates/mozart-core/src/package/. Switch dependency-link and metadata maps from BTreeMap to indexmap::IndexMap so serialized JSON preserves the original key ordering rather than sorting alphabetically — matching PHP associative-array semantics. The --sort-packages behaviour in `require` is preserved via sort_unstable_keys. --- crates/mozart-core/src/repository/packagist.rs | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'crates/mozart-core/src/repository/packagist.rs') diff --git a/crates/mozart-core/src/repository/packagist.rs b/crates/mozart-core/src/repository/packagist.rs index 199ff51..91b47df 100644 --- a/crates/mozart-core/src/repository/packagist.rs +++ b/crates/mozart-core/src/repository/packagist.rs @@ -55,13 +55,13 @@ pub struct PackagistVersion { pub version: String, pub version_normalized: String, #[serde(default, deserialize_with = "deserialize_unset_as_default")] - pub require: BTreeMap, + pub require: indexmap::IndexMap, #[serde(default, deserialize_with = "deserialize_unset_as_default")] - pub replace: BTreeMap, + pub replace: indexmap::IndexMap, #[serde(default, deserialize_with = "deserialize_unset_as_default")] - pub provide: BTreeMap, + pub provide: indexmap::IndexMap, #[serde(default, deserialize_with = "deserialize_unset_as_default")] - pub conflict: BTreeMap, + pub conflict: indexmap::IndexMap, #[serde(default, deserialize_with = "deserialize_unset_as_none")] pub dist: Option, #[serde(default, deserialize_with = "deserialize_unset_as_none")] @@ -72,10 +72,10 @@ pub struct PackagistVersion { default, deserialize_with = "deserialize_unset_as_default" )] - pub require_dev: BTreeMap, + pub require_dev: indexmap::IndexMap, #[serde(default, deserialize_with = "deserialize_unset_as_none")] - pub suggest: Option>, + pub suggest: Option>, #[serde( rename = "type", @@ -160,17 +160,17 @@ impl PackagistVersion { /// /// Returns a map from branch name (e.g. `"dev-master"`) to alias target /// (e.g. `"2.x-dev"`). Returns an empty map when no aliases are declared. - pub fn branch_aliases(&self) -> BTreeMap { + pub fn branch_aliases(&self) -> indexmap::IndexMap { let Some(extra) = &self.extra else { - return BTreeMap::new(); + return indexmap::IndexMap::new(); }; let Some(branch_alias) = extra.get("branch-alias") else { - return BTreeMap::new(); + return indexmap::IndexMap::new(); }; let Some(map) = branch_alias.as_object() else { - return BTreeMap::new(); + return indexmap::IndexMap::new(); }; map.iter() -- cgit v1.3.1