aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/mozart/src/commands/require.rs
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2026-02-22 00:37:54 +0900
committernsfisis <nsfisis@gmail.com>2026-02-22 00:37:54 +0900
commit0a8e5935e6305819bb02d8c69e2f046ff397913a (patch)
treee5a288e679477b1603d7989e986ca22bbe590aa4 /crates/mozart/src/commands/require.rs
parentb5af594fec7da72b15c9a202c641af0494db6355 (diff)
downloadphp-mozart-0a8e5935e6305819bb02d8c69e2f046ff397913a.tar.gz
php-mozart-0a8e5935e6305819bb02d8c69e2f046ff397913a.tar.zst
php-mozart-0a8e5935e6305819bb02d8c69e2f046ff397913a.zip
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 <noreply@anthropic.com>
Diffstat (limited to 'crates/mozart/src/commands/require.rs')
-rw-r--r--crates/mozart/src/commands/require.rs30
1 files changed, 15 insertions, 15 deletions
diff --git a/crates/mozart/src/commands/require.rs b/crates/mozart/src/commands/require.rs
index 6e76b6e..960182f 100644
--- a/crates/mozart/src/commands/require.rs
+++ b/crates/mozart/src/commands/require.rs
@@ -1,11 +1,11 @@
-use crate::console;
-use crate::lockfile;
-use crate::package::{self, Stability};
-use crate::packagist;
-use crate::resolver::{self, PlatformConfig, ResolveRequest};
-use crate::validation;
-use crate::version;
use clap::Args;
+use mozart_core::console;
+use mozart_core::package::{self, Stability};
+use mozart_core::validation;
+use mozart_registry::lockfile;
+use mozart_registry::packagist;
+use mozart_registry::resolver::{self, PlatformConfig, ResolveRequest};
+use mozart_registry::version;
use std::collections::HashMap;
use std::io::{BufRead, IsTerminal, Write};
@@ -346,7 +346,7 @@ fn interactive_search_packages(
pub fn execute(
args: &RequireArgs,
cli: &super::Cli,
- console: &crate::console::Console,
+ console: &mozart_core::console::Console,
) -> anyhow::Result<()> {
// Collect the effective list of packages to add.
// If none were provided on the CLI, try interactive search (unless --no-interaction).
@@ -609,8 +609,8 @@ pub fn execute(
let mut resolved = match resolver::resolve(&request) {
Ok(packages) => packages,
Err(e) => {
- return Err(crate::exit_code::bail(
- crate::exit_code::DEPENDENCY_RESOLUTION_FAILED,
+ return Err(mozart_core::exit_code::bail(
+ mozart_core::exit_code::DEPENDENCY_RESOLUTION_FAILED,
e.to_string(),
));
}
@@ -758,7 +758,7 @@ pub fn execute(
.map(|s| s.eq_ignore_ascii_case("source"))
.unwrap_or(false);
if prefer_source {
- console.info(&crate::console::warning(
+ console.info(&mozart_core::console::warning(
"Warning: Source installs are not yet supported. Falling back to dist.",
));
}
@@ -836,7 +836,7 @@ mod tests {
/// Verify that --sort-packages sorts both require and require-dev maps.
#[test]
fn test_sort_packages_sorts_both_sections() {
- use crate::package::RawPackageData;
+ use mozart_core::package::RawPackageData;
let mut raw = RawPackageData::new("test/project".to_string());
raw.require
@@ -915,8 +915,8 @@ mod tests {
#[test]
#[ignore]
fn test_require_full_e2e() {
- use crate::lockfile::{LockFileGenerationRequest, generate_lock_file};
- use crate::package::RawPackageData;
+ use mozart_core::package::RawPackageData;
+ use mozart_registry::lockfile::{LockFileGenerationRequest, generate_lock_file};
let composer_json_content = r#"{"name": "test/project", "require": {"psr/log": "^3.0"}}"#;
let composer_json: RawPackageData = serde_json::from_str(composer_json_content).unwrap();
@@ -956,7 +956,7 @@ mod tests {
#[test]
#[ignore]
fn test_require_no_install_writes_lock_only() {
- use crate::package::RawPackageData;
+ use mozart_core::package::RawPackageData;
use tempfile::tempdir;
let dir = tempdir().unwrap();