aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/mozart-core/src/repository/packagist.rs
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2026-05-11 02:05:34 +0900
committernsfisis <nsfisis@gmail.com>2026-05-11 02:05:34 +0900
commit4df5f8491320e5795718cf0222e80fa27e57c8ad (patch)
tree707e19f34dbdef18490ec3245d34389e3d189a57 /crates/mozart-core/src/repository/packagist.rs
parent8871b923fa3df1935c263db155cb8bc3d59705cd (diff)
downloadphp-mozart-4df5f8491320e5795718cf0222e80fa27e57c8ad.tar.gz
php-mozart-4df5f8491320e5795718cf0222e80fa27e57c8ad.tar.zst
php-mozart-4df5f8491320e5795718cf0222e80fa27e57c8ad.zip
refactor(package): rename traits and switch dep maps to IndexMap
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.
Diffstat (limited to 'crates/mozart-core/src/repository/packagist.rs')
-rw-r--r--crates/mozart-core/src/repository/packagist.rs20
1 files changed, 10 insertions, 10 deletions
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<String, String>,
+ pub require: indexmap::IndexMap<String, String>,
#[serde(default, deserialize_with = "deserialize_unset_as_default")]
- pub replace: BTreeMap<String, String>,
+ pub replace: indexmap::IndexMap<String, String>,
#[serde(default, deserialize_with = "deserialize_unset_as_default")]
- pub provide: BTreeMap<String, String>,
+ pub provide: indexmap::IndexMap<String, String>,
#[serde(default, deserialize_with = "deserialize_unset_as_default")]
- pub conflict: BTreeMap<String, String>,
+ pub conflict: indexmap::IndexMap<String, String>,
#[serde(default, deserialize_with = "deserialize_unset_as_none")]
pub dist: Option<PackagistDist>,
#[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<String, String>,
+ pub require_dev: indexmap::IndexMap<String, String>,
#[serde(default, deserialize_with = "deserialize_unset_as_none")]
- pub suggest: Option<BTreeMap<String, String>>,
+ pub suggest: Option<indexmap::IndexMap<String, String>>,
#[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<String, String> {
+ pub fn branch_aliases(&self) -> indexmap::IndexMap<String, String> {
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()