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/init.rs | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) (limited to 'crates/mozart/src/commands/init.rs') diff --git a/crates/mozart/src/commands/init.rs b/crates/mozart/src/commands/init.rs index be104c6..25cc70e 100644 --- a/crates/mozart/src/commands/init.rs +++ b/crates/mozart/src/commands/init.rs @@ -1,9 +1,9 @@ -use crate::console; -use crate::package::{self, RawAuthor, RawAutoload, RawPackageData, RawRepository}; -use crate::validation; use anyhow::{Context, bail}; use clap::Args; use colored::Colorize; +use mozart_core::console; +use mozart_core::package::{self, RawAuthor, RawAutoload, RawPackageData, RawRepository}; +use mozart_core::validation; use std::collections::BTreeMap; use std::path::{Path, PathBuf}; use std::process::Command; @@ -211,7 +211,7 @@ fn build_interactive( let name = console.ask_validated( &format!( "Package name (/) [{}]", - crate::console::comment(&default_name), + mozart_core::console::comment(&default_name), ), &default_name, |val| { @@ -229,7 +229,10 @@ fn build_interactive( // Description let default_desc = args.description.clone().unwrap_or_default(); let description = console.ask( - &format!("Description [{}]", crate::console::comment(&default_desc)), + &format!( + "Description [{}]", + mozart_core::console::comment(&default_desc) + ), &default_desc, ); let description = if description.is_empty() { @@ -248,7 +251,7 @@ fn build_interactive( &format!( "Author [{}n to skip]", if !default_author.is_empty() { - format!("{}, ", crate::console::comment(&default_author)) + format!("{}, ", mozart_core::console::comment(&default_author)) } else { String::new() } @@ -272,7 +275,7 @@ fn build_interactive( let stability_input = console.ask( &format!( "Minimum Stability [{}]", - crate::console::comment(&default_stability), + mozart_core::console::comment(&default_stability), ), &default_stability, ); @@ -292,7 +295,7 @@ fn build_interactive( let type_input = console.ask( &format!( "Package Type (e.g. library, project, metapackage, composer-plugin) [{}]", - crate::console::comment(&default_type), + mozart_core::console::comment(&default_type), ), &default_type, ); @@ -305,7 +308,10 @@ fn build_interactive( // License let default_license = args.license.clone().unwrap_or_default(); let license_input = console.ask( - &format!("License [{}]", crate::console::comment(&default_license),), + &format!( + "License [{}]", + mozart_core::console::comment(&default_license), + ), &default_license, ); let license = if license_input.is_empty() { @@ -319,7 +325,7 @@ fn build_interactive( console.info(""); console.info(&format!( "{}", - crate::console::info("Define your dependencies.") + mozart_core::console::info("Define your dependencies.") )); console.info(""); let require = parse_requirements(&args.require)?; @@ -335,7 +341,7 @@ fn build_interactive( &format!( "Add PSR-4 autoload mapping? Maps namespace \"{}\" to the entered relative path. [{}, n to skip]", namespace, - crate::console::comment(&default_autoload), + mozart_core::console::comment(&default_autoload), ), &default_autoload, ); -- cgit v1.3.1