From 4caf72463de598ea9b6454f3b7b7332dd0071318 Mon Sep 17 00:00:00 2001 From: nsfisis Date: Sun, 10 May 2026 01:18:44 +0900 Subject: refactor(package): port RootPackageLoader into RootPackageData::from_raw Mirrors Composer\Package\Loader\RootPackageLoader::load(): converts the parsed RawPackageData into fully typed RootPackageData with Link objects, defaulted fields, and trait-based accessors. Composer::package() now returns RootPackageData instead of RawPackageData, eliminating the pre-normalised JSON workaround noted in the previous comment. --- crates/mozart/src/composer.rs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'crates/mozart/src/composer.rs') diff --git a/crates/mozart/src/composer.rs b/crates/mozart/src/composer.rs index 337b053..0484344 100644 --- a/crates/mozart/src/composer.rs +++ b/crates/mozart/src/composer.rs @@ -16,7 +16,7 @@ use std::path::{Path, PathBuf}; use crate::factory::create_composer; use mozart_core::composer::{AutoloadGenerator, InstallationManager, Locker, RepositoryManager}; use mozart_core::config::Config; -use mozart_core::package::RawPackageData; +use mozart_core::package::RootPackageData; use mozart_core::repository::download_manager::DownloadManager; /// Project-level Composer state. Mirrors `Composer\PartialComposer` / @@ -27,7 +27,7 @@ use mozart_core::repository::download_manager::DownloadManager; pub struct Composer { project_dir: PathBuf, config: Config, - package: RawPackageData, + package: RootPackageData, repository_manager: RepositoryManager, installation_manager: InstallationManager, download_manager: DownloadManager, @@ -45,7 +45,7 @@ impl Composer { pub fn new( project_dir: PathBuf, config: Config, - package: RawPackageData, + package: RootPackageData, repository_manager: RepositoryManager, installation_manager: InstallationManager, download_manager: DownloadManager, @@ -111,12 +111,12 @@ impl Composer { &self.config } - /// Root package loaded from the project's `composer.json`. Mirrors - /// `Composer::getPackage()`; ideally this would return a fully - /// resolved `RootPackageInterface` equivalent, but Mozart does not - /// yet have a `RootPackageLoader` port — for now callers see the - /// raw, pre-normalised JSON shape. - pub fn package(&self) -> &RawPackageData { + /// Root package loaded from the project's `composer.json`. + /// Mirrors `Composer::getPackage()` — returns a fully typed + /// [`RootPackageData`] that implements the [`RootPackage`] trait + /// hierarchy (`Package` → `CompletePackage` → `RootPackage`), + /// equivalent to PHP's `RootPackageInterface`. + pub fn package(&self) -> &RootPackageData { &self.package } -- cgit v1.3.1