diff options
| author | nsfisis <nsfisis@gmail.com> | 2026-05-02 17:21:29 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2026-05-02 17:21:29 +0900 |
| commit | 43efd895d24b7ccd2853fa5bcf08ad0e621f33ce (patch) | |
| tree | 6caa14192cb2c753b9699bc3c5d62fe334920718 /crates/mozart/src/commands/remove.rs | |
| parent | 5b767cdd832d39816ee4c2dbf94274c0130dd572 (diff) | |
| download | php-mozart-43efd895d24b7ccd2853fa5bcf08ad0e621f33ce.tar.gz php-mozart-43efd895d24b7ccd2853fa5bcf08ad0e621f33ce.tar.zst php-mozart-43efd895d24b7ccd2853fa5bcf08ad0e621f33ce.zip | |
refactor(registry): plumb RepositorySet and executor through callers
ResolveRequest and LockFileGenerationRequest now take Arc<RepositorySet>
instead of a raw Cache. install_from_lock now accepts &mut dyn
InstallerExecutor instead of constructing FilesystemExecutor internally.
Both changes expose the DI injection points needed by the upcoming
in-process test harness, where Packagist must be replaced with an empty
RepositorySet (Composer's `'packagist' => false` test config) and
filesystem install execution must be replaced with a tracing recorder
(Composer's InstallationManagerMock).
The eager VCS scan and inline-package preload still happen inside
resolve(), so the RawRepository array is kept on ResolveRequest as
raw_repositories - migrating those through RepositorySet remains a
follow-up. RepositorySet gains with_packagist and empty constructors so
production callers and future tests have a uniform construction shape.
All 136 enabled installer fixtures + 114 mozart-registry tests + 541
mozart lib tests still green; clippy clean.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Diffstat (limited to 'crates/mozart/src/commands/remove.rs')
| -rw-r--r-- | crates/mozart/src/commands/remove.rs | 74 |
1 files changed, 54 insertions, 20 deletions
diff --git a/crates/mozart/src/commands/remove.rs b/crates/mozart/src/commands/remove.rs index 7afa51d..8794a10 100644 --- a/crates/mozart/src/commands/remove.rs +++ b/crates/mozart/src/commands/remove.rs @@ -253,9 +253,11 @@ pub async fn execute( platform: PlatformConfig::new(), ignore_platform_reqs: args.ignore_platform_reqs, ignore_platform_req_list: args.ignore_platform_req.clone(), - repo_cache: repo_cache.clone(), + repositories: std::sync::Arc::new( + mozart_registry::repository::RepositorySet::with_packagist(repo_cache.clone()), + ), temporary_constraints: HashMap::new(), - repositories: raw.repositories.clone(), + raw_repositories: raw.repositories.clone(), }; // Print header messages @@ -346,7 +348,9 @@ pub async fn execute( composer_json_content: composer_json_content.clone(), composer_json: raw.clone(), include_dev: dev_mode, - repo_cache: repo_cache.clone(), + repositories: std::sync::Arc::new( + mozart_registry::repository::RepositorySet::with_packagist(repo_cache.clone()), + ), }) .await?; @@ -427,6 +431,10 @@ pub async fn execute( // Install packages (unless --no-install or --dry-run) if !args.no_install && !args.dry_run { + let cache_config = mozart_registry::cache::build_cache_config(cli.no_cache); + let files_cache = mozart_registry::cache::Cache::files(&cache_config); + let mut executor = + mozart_registry::installer_executor::FilesystemExecutor::new(files_cache); super::install::install_from_lock( &new_lock, &working_dir, @@ -447,6 +455,7 @@ pub async fn execute( no_cache: cli.no_cache, }, console, + &mut executor, ) .await?; } @@ -505,9 +514,11 @@ async fn remove_unused( platform: PlatformConfig::new(), ignore_platform_reqs: args.ignore_platform_reqs, ignore_platform_req_list: args.ignore_platform_req.clone(), - repo_cache: repo_cache.clone(), + repositories: std::sync::Arc::new( + mozart_registry::repository::RepositorySet::with_packagist(repo_cache.clone()), + ), temporary_constraints: HashMap::new(), - repositories: raw.repositories.clone(), + raw_repositories: raw.repositories.clone(), }; console.info("Resolving dependencies to detect unused packages..."); @@ -562,7 +573,9 @@ async fn remove_unused( composer_json_content, composer_json: raw.clone(), include_dev: dev_mode, - repo_cache: repo_cache.clone(), + repositories: std::sync::Arc::new( + mozart_registry::repository::RepositorySet::with_packagist(repo_cache.clone()), + ), }) .await?; @@ -572,6 +585,10 @@ async fn remove_unused( // Install if !args.no_install { let vendor_dir = working_dir.join("vendor"); + let cache_config = mozart_registry::cache::build_cache_config(no_cache); + let files_cache = mozart_registry::cache::Cache::files(&cache_config); + let mut executor = + mozart_registry::installer_executor::FilesystemExecutor::new(files_cache); super::install::install_from_lock( &new_lock, working_dir, @@ -592,6 +609,7 @@ async fn remove_unused( no_cache, }, console, + &mut executor, ) .await?; } @@ -838,12 +856,16 @@ mod tests { platform: mozart_registry::resolver::PlatformConfig::new(), ignore_platform_reqs: false, ignore_platform_req_list: vec![], - repo_cache: mozart_registry::cache::Cache::new( - std::env::temp_dir().join("mozart-test-cache"), - false, + repositories: std::sync::Arc::new( + mozart_registry::repository::RepositorySet::with_packagist( + mozart_registry::cache::Cache::new( + std::env::temp_dir().join("mozart-test-cache"), + false, + ), + ), ), temporary_constraints: HashMap::new(), - repositories: vec![], + raw_repositories: vec![], }; let resolved = resolve(&request) .await @@ -853,9 +875,13 @@ mod tests { composer_json_content: content.to_string(), composer_json: raw.clone(), include_dev: false, - repo_cache: mozart_registry::cache::Cache::new( - std::env::temp_dir().join("mozart-test-cache"), - false, + repositories: std::sync::Arc::new( + mozart_registry::repository::RepositorySet::with_packagist( + mozart_registry::cache::Cache::new( + std::env::temp_dir().join("mozart-test-cache"), + false, + ), + ), ), }) .await @@ -881,12 +907,16 @@ mod tests { platform: mozart_registry::resolver::PlatformConfig::new(), ignore_platform_reqs: false, ignore_platform_req_list: vec![], - repo_cache: mozart_registry::cache::Cache::new( - std::env::temp_dir().join("mozart-test-cache"), - false, + repositories: std::sync::Arc::new( + mozart_registry::repository::RepositorySet::with_packagist( + mozart_registry::cache::Cache::new( + std::env::temp_dir().join("mozart-test-cache"), + false, + ), + ), ), temporary_constraints: HashMap::new(), - repositories: vec![], + raw_repositories: vec![], }; let resolved2 = resolve(&request2) .await @@ -898,9 +928,13 @@ mod tests { composer_json_content: composer_json_content2, composer_json: raw, include_dev: false, - repo_cache: mozart_registry::cache::Cache::new( - std::env::temp_dir().join("mozart-test-cache"), - false, + repositories: std::sync::Arc::new( + mozart_registry::repository::RepositorySet::with_packagist( + mozart_registry::cache::Cache::new( + std::env::temp_dir().join("mozart-test-cache"), + false, + ), + ), ), }) .await |
