From 0a8e5935e6305819bb02d8c69e2f046ff397913a Mon Sep 17 00:00:00 2001 From: nsfisis Date: Sun, 22 Feb 2026 00:37:54 +0900 Subject: refactor(workspace): split monolithic crate into 6 workspace crates Extract modules from the single `mozart` crate into 5 focused library crates to improve compilation parallelism and architectural clarity: - mozart-constraint: version constraint parser (independent) - mozart-core: base types, console, validation, platform utilities - mozart-archiver: archive creation (tar, zip, bzip2) - mozart-registry: Packagist API, cache, resolver, downloader, lockfile - mozart-autoload: autoloader generation and PHP scanner Refactor Console::from_cli and build_cache_config to accept primitive args instead of &Cli to break circular dependencies. Introduce [workspace.dependencies] for centralized version management. Remove 9 unused direct dependencies from the CLI crate. Co-Authored-By: Claude Opus 4.6 --- crates/mozart/src/commands/dependency.rs | 52 ++++++++++++++++---------------- 1 file changed, 26 insertions(+), 26 deletions(-) (limited to 'crates/mozart/src/commands/dependency.rs') diff --git a/crates/mozart/src/commands/dependency.rs b/crates/mozart/src/commands/dependency.rs index 0ae8bb4..4714de2 100644 --- a/crates/mozart/src/commands/dependency.rs +++ b/crates/mozart/src/commands/dependency.rs @@ -67,7 +67,7 @@ pub fn load_packages(working_dir: &Path, locked: bool) -> Result = root @@ -98,7 +98,7 @@ fn load_from_lockfile(lock_path: &Path) -> Result> { if !lock_path.exists() { anyhow::bail!("composer.lock not found — run `mozart install` first or omit --locked"); } - let lock = crate::lockfile::LockFile::read_from_file(lock_path)?; + let lock = mozart_registry::lockfile::LockFile::read_from_file(lock_path)?; let mut packages: Vec = Vec::new(); @@ -131,7 +131,7 @@ fn load_from_lockfile(lock_path: &Path) -> Result> { fn load_from_installed(working_dir: &Path) -> Result> { let vendor_dir = working_dir.join("vendor"); - let installed = crate::installed::InstalledPackages::read(&vendor_dir)?; + let installed = mozart_registry::installed::InstalledPackages::read(&vendor_dir)?; let packages = installed .packages @@ -192,7 +192,7 @@ fn load_from_installed(working_dir: &Path) -> Result> { pub fn get_dependents( packages: &[PackageInfo], needles: &[String], - constraint: Option<&crate::constraint::VersionConstraint>, + constraint: Option<&mozart_constraint::VersionConstraint>, inverted: bool, recursive: bool, ) -> Result> { @@ -317,7 +317,7 @@ fn recurse_dependents( fn get_prohibitors( packages: &[PackageInfo], needles: &[String], - constraint: Option<&crate::constraint::VersionConstraint>, + constraint: Option<&mozart_constraint::VersionConstraint>, _recursive: bool, ) -> Result> { let mut results: Vec = Vec::new(); @@ -333,7 +333,7 @@ fn get_prohibitors( .find(|(k, _)| k.to_lowercase() == needle_lower) && let Some(requested_version) = constraint && let Ok(pkg_constraint) = - crate::constraint::VersionConstraint::parse(req_constraint_str) + mozart_constraint::VersionConstraint::parse(req_constraint_str) { // The package requires `needle` but with a different // (incompatible) constraint — it blocks the requested version. @@ -359,7 +359,7 @@ fn get_prohibitors( .find(|(k, _)| k.to_lowercase() == needle_lower) && let Some(requested_version) = constraint && let Ok(pkg_constraint) = - crate::constraint::VersionConstraint::parse(req_constraint_str) + mozart_constraint::VersionConstraint::parse(req_constraint_str) && constraint_prohibits(requested_version, &pkg_constraint) { results.push(DependencyResult { @@ -380,7 +380,7 @@ fn get_prohibitors( .find(|(k, _)| k.to_lowercase() == needle_lower) && let Some(requested_version) = constraint && let Ok(conflict_constraint) = - crate::constraint::VersionConstraint::parse(conflict_constraint_str) + mozart_constraint::VersionConstraint::parse(conflict_constraint_str) { // If the conflict constraint overlaps with (matches) the // requested version range, this package conflicts with it. @@ -408,8 +408,8 @@ fn get_prohibitors( /// We sample a set of "representative versions" from the requested constraint /// and check whether none of them satisfy the package's constraint. fn constraint_prohibits( - requested: &crate::constraint::VersionConstraint, - pkg_constraint: &crate::constraint::VersionConstraint, + requested: &mozart_constraint::VersionConstraint, + pkg_constraint: &mozart_constraint::VersionConstraint, ) -> bool { // We try to determine if there is any version satisfying *requested* that // does NOT satisfy *pkg_constraint*. @@ -430,8 +430,8 @@ fn constraint_prohibits( /// That is, if the conflict constraint matches at least one version that the /// requested constraint also matches. fn constraint_overlaps( - requested: &crate::constraint::VersionConstraint, - conflict_constraint: &crate::constraint::VersionConstraint, + requested: &mozart_constraint::VersionConstraint, + conflict_constraint: &mozart_constraint::VersionConstraint, ) -> bool { let probes = sample_versions_from_constraint(requested); if probes.is_empty() { @@ -446,9 +446,9 @@ fn constraint_overlaps( /// constraint. These are used for the "does this constraint overlap/prohibit /// that constraint?" heuristic. fn sample_versions_from_constraint( - constraint: &crate::constraint::VersionConstraint, -) -> Vec { - use crate::constraint::Version; + constraint: &mozart_constraint::VersionConstraint, +) -> Vec { + use mozart_constraint::Version; // Broad grid of versions to probe let candidates: &[&str] = &[ @@ -498,7 +498,7 @@ fn sample_versions_from_constraint( /// Columns: package name | version | link description | link constraint pub fn print_table(results: &[DependencyResult]) { if results.is_empty() { - println!("{}", crate::console::info("No relationships found.")); + println!("{}", mozart_core::console::info("No relationships found.")); return; } @@ -522,10 +522,10 @@ pub fn print_table(results: &[DependencyResult]) { for r in results { println!( "{: