aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/shirabe-external-packages/src
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2026-06-07 12:16:09 +0900
committernsfisis <nsfisis@gmail.com>2026-06-07 12:17:24 +0900
commit14138dde4a8c874bdc498edd25d1a2d7dc9022be (patch)
tree6c1cc375a7dd2e4ba3294918fe689f6b734fd434 /crates/shirabe-external-packages/src
parent54af47e286d0fb601e2e60aeb19002f6b7937574 (diff)
downloadphp-shirabe-14138dde4a8c874bdc498edd25d1a2d7dc9022be.tar.gz
php-shirabe-14138dde4a8c874bdc498edd25d1a2d7dc9022be.tar.zst
php-shirabe-14138dde4a8c874bdc498edd25d1a2d7dc9022be.zip
feat(metadata-minifier): port expand for minified package metadata
Implement MetadataMinifier::expand with the PHP list-of-arrays signature (Vec<IndexMap>) and wire it into ComposerRepository so composer/2.0 minified package metadata is expanded, resolving the phase-b TODO. minify() is left unported as it is not used in Composer itself. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Diffstat (limited to 'crates/shirabe-external-packages/src')
-rw-r--r--crates/shirabe-external-packages/src/composer/metadata_minifier/metadata_minifier.rs31
1 files changed, 26 insertions, 5 deletions
diff --git a/crates/shirabe-external-packages/src/composer/metadata_minifier/metadata_minifier.rs b/crates/shirabe-external-packages/src/composer/metadata_minifier/metadata_minifier.rs
index 8861936..f97209d 100644
--- a/crates/shirabe-external-packages/src/composer/metadata_minifier/metadata_minifier.rs
+++ b/crates/shirabe-external-packages/src/composer/metadata_minifier/metadata_minifier.rs
@@ -5,11 +5,32 @@ use shirabe_php_shim::PhpMixed;
pub struct MetadataMinifier;
impl MetadataMinifier {
- pub fn expand(_minified_data: IndexMap<String, PhpMixed>) -> IndexMap<String, PhpMixed> {
- todo!()
- }
+ pub fn expand(versions: Vec<IndexMap<String, PhpMixed>>) -> Vec<IndexMap<String, PhpMixed>> {
+ let mut expanded: Vec<IndexMap<String, PhpMixed>> = Vec::new();
+ let mut expanded_version: Option<IndexMap<String, PhpMixed>> = None;
+ for version_data in versions {
+ if expanded_version.as_ref().map_or(true, |ev| ev.is_empty()) {
+ expanded.push(version_data.clone());
+ expanded_version = Some(version_data);
+ continue;
+ }
+
+ // add any changes from the previous version to the expanded one
+ let ev = expanded_version.as_mut().unwrap();
+ for (key, val) in version_data {
+ if matches!(&val, PhpMixed::String(s) if s == "__unset") {
+ ev.shift_remove(&key);
+ } else {
+ ev.insert(key, val);
+ }
+ }
- pub fn minify(_packages: IndexMap<String, PhpMixed>) -> IndexMap<String, PhpMixed> {
- todo!()
+ expanded.push(ev.clone());
+ }
+
+ expanded
}
+
+ // MetadataMinifier::minify() is not ported because it is not used in Composer itself.
+ // The function is mainly for package repositories.
}