From 8cc1ba8a02c0318b65658f1634de378c780392b9 Mon Sep 17 00:00:00 2001 From: nsfisis Date: Sun, 10 May 2026 00:32:08 +0900 Subject: refactor(workspace): consolidate crates into mozart-core Merged mozart-archiver, mozart-autoload, mozart-registry, mozart-sat-resolver, and mozart-vcs into mozart-core to align the source layout with Composer's structure. Co-Authored-By: Claude Sonnet 4.6 --- crates/mozart/src/commands/archive.rs | 15 ++-- crates/mozart/src/commands/audit.rs | 24 ++--- crates/mozart/src/commands/browse.rs | 6 +- crates/mozart/src/commands/bump.rs | 15 ++-- crates/mozart/src/commands/check_platform_reqs.rs | 12 +-- crates/mozart/src/commands/clear_cache.rs | 2 +- crates/mozart/src/commands/create_project.rs | 31 +++---- crates/mozart/src/commands/dependency.rs | 4 +- crates/mozart/src/commands/dump_autoload.rs | 2 +- crates/mozart/src/commands/fund.rs | 6 +- crates/mozart/src/commands/init.rs | 10 +-- crates/mozart/src/commands/install.rs | 28 +++--- crates/mozart/src/commands/licenses.rs | 22 ++--- crates/mozart/src/commands/reinstall.rs | 10 +-- crates/mozart/src/commands/remove.rs | 58 ++++++------ crates/mozart/src/commands/require.rs | 48 +++++----- crates/mozart/src/commands/search.rs | 14 +-- crates/mozart/src/commands/show.rs | 104 ++++++++++++---------- crates/mozart/src/commands/status.rs | 2 +- crates/mozart/src/commands/suggests.rs | 28 +++--- crates/mozart/src/commands/update.rs | 41 ++++----- crates/mozart/src/commands/validate.rs | 6 +- crates/mozart/src/composer.rs | 2 +- crates/mozart/src/factory.rs | 2 +- 24 files changed, 255 insertions(+), 237 deletions(-) (limited to 'crates/mozart/src') diff --git a/crates/mozart/src/commands/archive.rs b/crates/mozart/src/commands/archive.rs index 7e1697f..d83bdb5 100644 --- a/crates/mozart/src/commands/archive.rs +++ b/crates/mozart/src/commands/archive.rs @@ -1,8 +1,8 @@ use crate::composer::Composer; use clap::Args; -use mozart_archiver::{ArchiveManager, ArchivePackage}; use mozart_core::console_writeln; use mozart_core::factory::create_config; +use mozart_core::package::archiver::{ArchiveManager, ArchivePackage}; use std::borrow::Cow; use std::path::{Path, PathBuf}; @@ -74,9 +74,9 @@ async fn archive( working_dir: &Path, no_cache: bool, ) -> anyhow::Result<()> { - let cache_config = mozart_registry::cache::build_cache_config(no_cache); - let repo_cache = mozart_registry::cache::Cache::repo(&cache_config); - let files_cache = mozart_registry::cache::Cache::files(&cache_config); + let cache_config = mozart_core::repository::cache::build_cache_config(no_cache); + let repo_cache = mozart_core::repository::cache::Cache::repo(&cache_config); + let files_cache = mozart_core::repository::cache::Cache::files(&cache_config); let archive_manager = ArchiveManager::new(); @@ -138,10 +138,10 @@ async fn select_package( io: &mozart_core::console::Console, package_name: &str, version: Option<&str>, - repo_cache: &mozart_registry::cache::Cache, + repo_cache: &mozart_core::repository::cache::Cache, ) -> anyhow::Result { use mozart_core::package::Stability; - use mozart_registry::version::find_best_candidate; + use mozart_core::repository::version::find_best_candidate; io.info("Searching for the specified package."); @@ -160,7 +160,8 @@ async fn select_package( let version = version.as_deref(); let packages = - mozart_registry::packagist::fetch_package_versions(package_name, repo_cache).await?; + mozart_core::repository::packagist::fetch_package_versions(package_name, repo_cache) + .await?; if packages.is_empty() { anyhow::bail!("No versions found for package \"{}\"", package_name); } diff --git a/crates/mozart/src/commands/audit.rs b/crates/mozart/src/commands/audit.rs index 30f0716..72d4408 100644 --- a/crates/mozart/src/commands/audit.rs +++ b/crates/mozart/src/commands/audit.rs @@ -4,9 +4,9 @@ use crate::composer::Composer; use clap::Args; use indexmap::IndexMap; use mozart_core::advisory::{AbandonedHandling, AuditConfig, AuditFormat}; -use mozart_registry::advisory::{AuditOptions, Auditor, PackageInfo}; -use mozart_registry::cache::{Cache, build_cache_config}; -use mozart_registry::repository::RepositorySet; +use mozart_core::repository::advisory::{AuditOptions, Auditor, PackageInfo}; +use mozart_core::repository::cache::{Cache, build_cache_config}; +use mozart_core::repository::repository::RepositorySet; #[derive(Args)] pub struct AuditArgs { @@ -127,7 +127,7 @@ fn get_packages(composer: &Composer, args: &AuditArgs) -> anyhow::Result anyhow::Result> { let vendor_dir = working_dir.join("vendor"); - let installed = mozart_registry::installed::InstalledPackages::read(&vendor_dir)?; + let installed = mozart_core::repository::installed::InstalledPackages::read(&vendor_dir)?; let dev_names: indexmap::IndexSet = installed .dev_package_names @@ -166,9 +166,9 @@ fn load_locked_packages(working_dir: &Path, no_dev: bool) -> anyhow::Result = + let mut all_packages: Vec<&mozart_core::repository::lockfile::LockedPackage> = lock.packages.iter().collect(); if !no_dev && let Some(ref pkgs_dev) = lock.packages_dev { @@ -196,7 +196,7 @@ mod tests { use std::collections::BTreeMap; use super::*; - use mozart_registry::lockfile::{LockFile, LockedPackage}; + use mozart_core::repository::lockfile::{LockFile, LockedPackage}; fn make_pkg(name: &str, version: &str, version_normalized: Option<&str>) -> PackageInfo { PackageInfo { @@ -228,8 +228,8 @@ mod tests { let working_dir = dir.path(); let vendor_dir = working_dir.join("vendor"); - let mut installed = mozart_registry::installed::InstalledPackages::new(); - installed.upsert(mozart_registry::installed::InstalledPackageEntry { + let mut installed = mozart_core::repository::installed::InstalledPackages::new(); + installed.upsert(mozart_core::repository::installed::InstalledPackageEntry { name: "monolog/monolog".to_string(), version: "1.5.0".to_string(), version_normalized: Some("1.5.0.0".to_string()), @@ -259,8 +259,8 @@ mod tests { let working_dir = dir.path(); let vendor_dir = working_dir.join("vendor"); - let mut installed = mozart_registry::installed::InstalledPackages::new(); - installed.upsert(mozart_registry::installed::InstalledPackageEntry { + let mut installed = mozart_core::repository::installed::InstalledPackages::new(); + installed.upsert(mozart_core::repository::installed::InstalledPackageEntry { name: "monolog/monolog".to_string(), version: "1.5.0".to_string(), version_normalized: None, @@ -274,7 +274,7 @@ mod tests { support: None, extra_fields: BTreeMap::new(), }); - installed.upsert(mozart_registry::installed::InstalledPackageEntry { + installed.upsert(mozart_core::repository::installed::InstalledPackageEntry { name: "phpunit/phpunit".to_string(), version: "10.0.0".to_string(), version_normalized: None, diff --git a/crates/mozart/src/commands/browse.rs b/crates/mozart/src/commands/browse.rs index a8ccab3..f646577 100644 --- a/crates/mozart/src/commands/browse.rs +++ b/crates/mozart/src/commands/browse.rs @@ -4,9 +4,9 @@ use mozart_core::console::Console; use mozart_core::console_writeln; use mozart_core::console_writeln_error; use mozart_core::exit_code; -use mozart_registry::browse_repos::{BrowseRepos, CompletePackageView}; -use mozart_registry::cache::{Cache, build_cache_config}; -use mozart_registry::installed::InstalledPackages; +use mozart_core::repository::browse_repos::{BrowseRepos, CompletePackageView}; +use mozart_core::repository::cache::{Cache, build_cache_config}; +use mozart_core::repository::installed::InstalledPackages; use std::process::Command; #[derive(Args)] diff --git a/crates/mozart/src/commands/bump.rs b/crates/mozart/src/commands/bump.rs index 4722fe2..ee611d1 100644 --- a/crates/mozart/src/commands/bump.rs +++ b/crates/mozart/src/commands/bump.rs @@ -109,13 +109,13 @@ pub async fn do_bump( // to an empty map (`getLockedRepository` would throw in PHP — Mozart degrades // gracefully because `bump` has nothing to bump in that case anyway). if composer.locker().is_locked() { - let lock = mozart_registry::lockfile::LockFile::read_from_file(lock_path)?; + let lock = mozart_core::repository::lockfile::LockFile::read_from_file(lock_path)?; build_locked_versions_from_lock(&lock) } else { IndexMap::new() } } else if composer.locker().is_locked() { - let lock = mozart_registry::lockfile::LockFile::read_from_file(lock_path)?; + let lock = mozart_core::repository::lockfile::LockFile::read_from_file(lock_path)?; if !lock.is_fresh(&contents) { console_writeln_error!( io, @@ -282,9 +282,10 @@ fn update_file_cleanly( /// successful in-place edit so the lockfile stays "fresh" for the next install. fn update_lock_hash(lock_path: &Path, composer_json_path: &Path) -> anyhow::Result<()> { let new_composer_json_content = std::fs::read_to_string(composer_json_path)?; - let new_hash = - mozart_registry::lockfile::LockFile::compute_content_hash(&new_composer_json_content)?; - let mut lock = mozart_registry::lockfile::LockFile::read_from_file(lock_path)?; + let new_hash = mozart_core::repository::lockfile::LockFile::compute_content_hash( + &new_composer_json_content, + )?; + let mut lock = mozart_core::repository::lockfile::LockFile::read_from_file(lock_path)?; lock.content_hash = new_hash; lock.write_to_file(lock_path)?; Ok(()) @@ -304,7 +305,7 @@ fn is_writable(path: &Path) -> bool { /// Build a map of lowercase package names to (pretty_version, version_normalized) /// from a parsed `composer.lock`. fn build_locked_versions_from_lock( - lock: &mozart_registry::lockfile::LockFile, + lock: &mozart_core::repository::lockfile::LockFile, ) -> IndexMap)> { let mut map: IndexMap)> = IndexMap::new(); let all_packages = lock @@ -352,7 +353,7 @@ fn strip_inline_constraint(arg: &str) -> &str { #[cfg(test)] mod tests { use super::*; - use mozart_registry::lockfile::{LockFile, LockedPackage}; + use mozart_core::repository::lockfile::{LockFile, LockedPackage}; use tempfile::tempdir; fn minimal_lock(packages: Vec, packages_dev: Vec) -> LockFile { diff --git a/crates/mozart/src/commands/check_platform_reqs.rs b/crates/mozart/src/commands/check_platform_reqs.rs index 1a10882..31cdb35 100644 --- a/crates/mozart/src/commands/check_platform_reqs.rs +++ b/crates/mozart/src/commands/check_platform_reqs.rs @@ -89,12 +89,13 @@ pub async fn execute( load_lock(&lock_path, args.no_dev, &mut installed_repo, &mut requires)?; } else { let installed_packages_present = installed_path.exists() - && !mozart_registry::installed::InstalledPackages::read(&vendor_dir)? + && !mozart_core::repository::installed::InstalledPackages::read(&vendor_dir)? .packages .is_empty(); if installed_packages_present { - let installed = mozart_registry::installed::InstalledPackages::read(&vendor_dir)?; + let installed = + mozart_core::repository::installed::InstalledPackages::read(&vendor_dir)?; console_writeln_error!( console, "Checking {}platform requirements for packages in the vendor dir", @@ -252,9 +253,10 @@ fn load_lock( repo: &mut InstalledRepoLite, requires: &mut BTreeMap>, ) -> anyhow::Result<()> { - let lock = mozart_registry::lockfile::LockFile::read_from_file(lock_path)?; + let lock = mozart_core::repository::lockfile::LockFile::read_from_file(lock_path)?; - let mut all: Vec<&mozart_registry::lockfile::LockedPackage> = lock.packages.iter().collect(); + let mut all: Vec<&mozart_core::repository::lockfile::LockedPackage> = + lock.packages.iter().collect(); if !no_dev && let Some(ref pkgs_dev) = lock.packages_dev { all.extend(pkgs_dev.iter()); } @@ -277,7 +279,7 @@ fn load_lock( } fn load_installed( - installed: &mozart_registry::installed::InstalledPackages, + installed: &mozart_core::repository::installed::InstalledPackages, no_dev: bool, repo: &mut InstalledRepoLite, requires: &mut BTreeMap>, diff --git a/crates/mozart/src/commands/clear_cache.rs b/crates/mozart/src/commands/clear_cache.rs index 9ee27ed..6a601da 100644 --- a/crates/mozart/src/commands/clear_cache.rs +++ b/crates/mozart/src/commands/clear_cache.rs @@ -4,7 +4,7 @@ use crate::composer::Composer; use clap::Args; use mozart_core::console_writeln_error; use mozart_core::factory::create_config; -use mozart_registry::cache::Cache; +use mozart_core::repository::cache::Cache; #[derive(Args)] pub struct ClearCacheArgs { diff --git a/crates/mozart/src/commands/create_project.rs b/crates/mozart/src/commands/create_project.rs index ff9776d..2b2fbe1 100644 --- a/crates/mozart/src/commands/create_project.rs +++ b/crates/mozart/src/commands/create_project.rs @@ -3,12 +3,12 @@ use indexmap::IndexMap; use mozart_core::console::Console; use mozart_core::console_format; use mozart_core::package::{self, Stability}; +use mozart_core::repository::downloader; +use mozart_core::repository::lockfile; +use mozart_core::repository::packagist; +use mozart_core::repository::resolver::{self, PlatformConfig, ResolveRequest}; +use mozart_core::repository::version; use mozart_core::validation; -use mozart_registry::downloader; -use mozart_registry::lockfile; -use mozart_registry::packagist; -use mozart_registry::resolver::{self, PlatformConfig, ResolveRequest}; -use mozart_registry::version; use std::path::{Path, PathBuf}; #[derive(Args)] @@ -498,8 +498,8 @@ async fn install_project( .and_then(|v| v.as_bool()) .unwrap_or(false); - let cache_config = mozart_registry::cache::build_cache_config(cli.no_cache); - let repo_cache = mozart_registry::cache::Cache::repo(&cache_config); + let cache_config = mozart_core::repository::cache::build_cache_config(cli.no_cache); + let repo_cache = mozart_core::repository::cache::Cache::repo(&cache_config); let request = ResolveRequest { root_name: raw.name.clone(), @@ -515,7 +515,7 @@ async fn install_project( ignore_platform_reqs: args.ignore_platform_reqs, ignore_platform_req_list: args.ignore_platform_req.clone(), repositories: std::sync::Arc::new( - mozart_registry::repository::RepositorySet::with_packagist(repo_cache.clone()), + mozart_core::repository::repository::RepositorySet::with_packagist(repo_cache.clone()), ), temporary_constraints: IndexMap::new(), raw_repositories: raw.repositories.clone(), @@ -559,7 +559,7 @@ async fn install_project( composer_json: raw.clone(), include_dev: dev_mode, repositories: std::sync::Arc::new( - mozart_registry::repository::RepositorySet::with_packagist(repo_cache.clone()), + mozart_core::repository::repository::RepositorySet::with_packagist(repo_cache.clone()), ), previous_lock: None, lock_pinned_names: indexmap::IndexSet::new(), @@ -611,9 +611,10 @@ async fn install_project( .and_then(|v| v.as_bool()) .unwrap_or(false); - 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); + let cache_config = mozart_core::repository::cache::build_cache_config(cli.no_cache); + let files_cache = mozart_core::repository::cache::Cache::files(&cache_config); + let mut executor = + mozart_core::repository::installer_executor::FilesystemExecutor::new(files_cache); super::install::install_from_lock( &new_lock, &target_dir, @@ -726,9 +727,9 @@ async fn install_root_package( let (_, minimum_stability) = resolve_stability(stability, package_version.as_deref())?; // --- Find the best candidate matching constraint + stability --- - let cache_config = mozart_registry::cache::build_cache_config(cli.no_cache); - let repo_cache = mozart_registry::cache::Cache::repo(&cache_config); - let files_cache = mozart_registry::cache::Cache::files(&cache_config); + let cache_config = mozart_core::repository::cache::build_cache_config(cli.no_cache); + let repo_cache = mozart_core::repository::cache::Cache::repo(&cache_config); + let files_cache = mozart_core::repository::cache::Cache::files(&cache_config); let versions = packagist::fetch_package_versions(&name, &repo_cache).await?; diff --git a/crates/mozart/src/commands/dependency.rs b/crates/mozart/src/commands/dependency.rs index f4e7430..0bdd3da 100644 --- a/crates/mozart/src/commands/dependency.rs +++ b/crates/mozart/src/commands/dependency.rs @@ -258,7 +258,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 = mozart_registry::lockfile::LockFile::read_from_file(lock_path)?; + let lock = mozart_core::repository::lockfile::LockFile::read_from_file(lock_path)?; let mut packages: Vec = Vec::new(); @@ -291,7 +291,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 = mozart_registry::installed::InstalledPackages::read(&vendor_dir)?; + let installed = mozart_core::repository::installed::InstalledPackages::read(&vendor_dir)?; let packages = installed .packages diff --git a/crates/mozart/src/commands/dump_autoload.rs b/crates/mozart/src/commands/dump_autoload.rs index 7557d37..f8222bb 100644 --- a/crates/mozart/src/commands/dump_autoload.rs +++ b/crates/mozart/src/commands/dump_autoload.rs @@ -1,6 +1,6 @@ use crate::composer::Composer; use clap::Args; -use mozart_autoload::AutoloadGeneratorExt; +use mozart_core::autoload::AutoloadGeneratorExt; use mozart_core::composer::AutoloadDumpOptions; use mozart_core::console_writeln; diff --git a/crates/mozart/src/commands/fund.rs b/crates/mozart/src/commands/fund.rs index 90a8418..792edd6 100644 --- a/crates/mozart/src/commands/fund.rs +++ b/crates/mozart/src/commands/fund.rs @@ -4,9 +4,9 @@ use mozart_core::console::{Console, hyperlink}; use mozart_core::console_format; use mozart_core::console_writeln; use mozart_core::exit_code; -use mozart_registry::cache::{Cache, build_cache_config}; -use mozart_registry::installed::InstalledPackages; -use mozart_registry::repository::{PackageQuery, RepositorySet}; +use mozart_core::repository::cache::{Cache, build_cache_config}; +use mozart_core::repository::installed::InstalledPackages; +use mozart_core::repository::repository::{PackageQuery, RepositorySet}; use serde::Serialize; use std::collections::{BTreeMap, BTreeSet}; diff --git a/crates/mozart/src/commands/init.rs b/crates/mozart/src/commands/init.rs index 5d6d501..90a5806 100644 --- a/crates/mozart/src/commands/init.rs +++ b/crates/mozart/src/commands/init.rs @@ -6,8 +6,8 @@ use mozart_core::console_format; use mozart_core::package::{ self, RawAuthor, RawAutoload, RawPackageData, RawRepository, Stability, }; +use mozart_core::repository::{packagist, version}; use mozart_core::validation; -use mozart_registry::{packagist, version}; use std::collections::BTreeMap; use std::io::{BufRead, Write}; use std::path::Path; @@ -66,8 +66,8 @@ pub async fn execute( cli: &super::Cli, console: &console::Console, ) -> anyhow::Result<()> { - let cache_config = mozart_registry::cache::build_cache_config(cli.no_cache); - let repo_cache = mozart_registry::cache::Cache::repo(&cache_config); + let cache_config = mozart_core::repository::cache::build_cache_config(cli.no_cache); + let repo_cache = mozart_core::repository::cache::Cache::repo(&cache_config); let working_dir = cli.working_dir()?; @@ -235,7 +235,7 @@ async fn build_interactive( args: &InitArgs, console: &console::Console, working_dir: &Path, - repo_cache: &mozart_registry::cache::Cache, + repo_cache: &mozart_core::repository::cache::Cache, ) -> anyhow::Result { console.info(""); console.info(&format!( @@ -487,7 +487,7 @@ async fn interactive_search_packages( label: &str, already_required: &BTreeMap, preferred_stability: Stability, - repo_cache: &mozart_registry::cache::Cache, + repo_cache: &mozart_core::repository::cache::Cache, console: &console::Console, ) -> anyhow::Result> { let stdin = std::io::stdin(); diff --git a/crates/mozart/src/commands/install.rs b/crates/mozart/src/commands/install.rs index 64af756..59d400b 100644 --- a/crates/mozart/src/commands/install.rs +++ b/crates/mozart/src/commands/install.rs @@ -2,14 +2,14 @@ use clap::Args; use indexmap::IndexSet; use mozart_core::console; use mozart_core::console_format; -use mozart_registry::installed; -use mozart_registry::installer_executor::{ +use mozart_core::repository::installed; +use mozart_core::repository::installer_executor::{ Action, ExecuteContext, FilesystemExecutor, InstallerExecutor, PackageOperation, compute_operations, compute_stale_installed_aliases, format_full_pretty_version, format_full_pretty_version_for_installed, format_update_pretty_versions, locked_to_installed_entry, previously_installed_alias_versions, }; -use mozart_registry::lockfile; +use mozart_core::repository::lockfile; use std::collections::BTreeMap; use std::path::Path; @@ -815,7 +815,7 @@ pub async fn install_from_lock( let suffix = lock.content_hash.clone(); let _result = - mozart_autoload::autoload::generate(&mozart_autoload::autoload::AutoloadConfig { + mozart_core::autoload::generate(&mozart_core::autoload::AutoloadConfig { project_dir: working_dir.to_path_buf(), vendor_dir: vendor_dir.to_path_buf(), dev_mode, @@ -826,7 +826,7 @@ pub async fn install_from_lock( apcu_prefix: config.apcu_autoloader_prefix.clone(), strict_psr: false, strict_ambiguous: false, - platform_check: mozart_autoload::autoload::PlatformCheckMode::Full, + platform_check: mozart_core::autoload::PlatformCheckMode::Full, ignore_platform_reqs: config.ignore_platform_reqs, })?; } @@ -835,19 +835,21 @@ pub async fn install_from_lock( Ok(()) } -/// CLI entry point. Builds production [`mozart_registry::repository::RepositorySet`] +/// CLI entry point. Builds production [`mozart_core::repository::repository::RepositorySet`] /// (Packagist) and [`FilesystemExecutor`] from `cli`, then dispatches to [`run`]. pub async fn execute( args: &InstallArgs, cli: &super::Cli, console: &mozart_core::console::Console, ) -> anyhow::Result<()> { - let cache_config = mozart_registry::cache::build_cache_config(cli.no_cache); - let repositories = - std::sync::Arc::new(mozart_registry::repository::RepositorySet::with_packagist( - mozart_registry::cache::Cache::repo(&cache_config), - )); - let mut executor = FilesystemExecutor::new(mozart_registry::cache::Cache::files(&cache_config)); + let cache_config = mozart_core::repository::cache::build_cache_config(cli.no_cache); + let repositories = std::sync::Arc::new( + mozart_core::repository::repository::RepositorySet::with_packagist( + mozart_core::repository::cache::Cache::repo(&cache_config), + ), + ); + let mut executor = + FilesystemExecutor::new(mozart_core::repository::cache::Cache::files(&cache_config)); let working_dir = cli.working_dir()?; run( &working_dir, @@ -875,7 +877,7 @@ pub async fn run( path_repo_base_override: Option<&Path>, args: &InstallArgs, console: &mozart_core::console::Console, - repositories: std::sync::Arc, + repositories: std::sync::Arc, executor: &mut dyn InstallerExecutor, ) -> anyhow::Result<()> { // Step 2: Validate arguments — order matches Composer's InstallCommand::execute (80–101): diff --git a/crates/mozart/src/commands/licenses.rs b/crates/mozart/src/commands/licenses.rs index 671ce2a..344a5fa 100644 --- a/crates/mozart/src/commands/licenses.rs +++ b/crates/mozart/src/commands/licenses.rs @@ -144,7 +144,7 @@ fn load_installed_entries( no_dev: bool, ) -> anyhow::Result> { let vendor_dir = working_dir.join("vendor"); - let installed = mozart_registry::installed::InstalledPackages::read(&vendor_dir)?; + let installed = mozart_core::repository::installed::InstalledPackages::read(&vendor_dir)?; let entries: Vec = installed.packages.iter().map(installed_to_entry).collect(); @@ -179,7 +179,7 @@ fn load_locked_entries( "Valid composer.json and composer.lock files are required to run this command with --locked" ); } - let lock = mozart_registry::lockfile::LockFile::read_from_file(&lock_path)?; + let lock = mozart_core::repository::lockfile::LockFile::read_from_file(&lock_path)?; // Mirrors `Locker::getLockedRepository(!$noDev)`: the prod-only call // returns just `packages`, the dev-included call returns the union. @@ -190,7 +190,9 @@ fn load_locked_entries( Ok(entries) } -fn installed_to_entry(pkg: &mozart_registry::installed::InstalledPackageEntry) -> LicenseEntry { +fn installed_to_entry( + pkg: &mozart_core::repository::installed::InstalledPackageEntry, +) -> LicenseEntry { let licenses = pkg .extra_fields .get("license") @@ -240,7 +242,7 @@ fn installed_to_entry(pkg: &mozart_registry::installed::InstalledPackageEntry) - } } -fn locked_to_entry(pkg: &mozart_registry::lockfile::LockedPackage) -> LicenseEntry { +fn locked_to_entry(pkg: &mozart_core::repository::lockfile::LockedPackage) -> LicenseEntry { let support_source = pkg .support .as_ref() @@ -537,7 +539,7 @@ mod tests { #[test] fn installed_to_entry_extracts_require_and_license() { - use mozart_registry::installed::InstalledPackageEntry; + use mozart_core::repository::installed::InstalledPackageEntry; let mut extra = BTreeMap::new(); extra.insert("license".to_string(), serde_json::json!(["MIT"])); extra.insert( @@ -565,7 +567,7 @@ mod tests { #[test] fn installed_to_entry_pulls_support_source_and_source_url() { - use mozart_registry::installed::InstalledPackageEntry; + use mozart_core::repository::installed::InstalledPackageEntry; let pkg = InstalledPackageEntry { name: "vendor/pkg".to_string(), version: "1.0.0".to_string(), @@ -608,8 +610,8 @@ mod tests { ) .unwrap(); - let mut installed = mozart_registry::installed::InstalledPackages::new(); - installed.upsert(mozart_registry::installed::InstalledPackageEntry { + let mut installed = mozart_core::repository::installed::InstalledPackages::new(); + installed.upsert(mozart_core::repository::installed::InstalledPackageEntry { name: "a/a".to_string(), version: "1.0.0".to_string(), version_normalized: None, @@ -623,7 +625,7 @@ mod tests { support: None, extra_fields: BTreeMap::new(), }); - installed.upsert(mozart_registry::installed::InstalledPackageEntry { + installed.upsert(mozart_core::repository::installed::InstalledPackageEntry { name: "b/b".to_string(), version: "1.0.0".to_string(), version_normalized: None, @@ -653,7 +655,7 @@ mod tests { #[test] fn locked_no_dev_drops_packages_dev() { - use mozart_registry::lockfile::{LockFile, LockedPackage}; + use mozart_core::repository::lockfile::{LockFile, LockedPackage}; let dir = tempfile::tempdir().unwrap(); let working_dir = dir.path(); std::fs::write( diff --git a/crates/mozart/src/commands/reinstall.rs b/crates/mozart/src/commands/reinstall.rs index dc99a91..52dfd52 100644 --- a/crates/mozart/src/commands/reinstall.rs +++ b/crates/mozart/src/commands/reinstall.rs @@ -1,6 +1,6 @@ use crate::composer::Composer; use clap::Args; -use mozart_autoload::AutoloadGeneratorExt; +use mozart_core::autoload::AutoloadGeneratorExt; use mozart_core::composer::{AutoloadDumpOptions, LocalPackage}; use mozart_core::console_format; use mozart_core::validation::package_name_to_regexp; @@ -138,8 +138,8 @@ pub async fn execute( // `mozart-registry::installer_executor` exposes the same shape, we // remove the install dir and re-download in place using each package's // recorded `dist` info. - let cache_config = mozart_registry::cache::build_cache_config(cli.no_cache); - let files_cache = mozart_registry::cache::Cache::files(&cache_config); + let cache_config = mozart_core::repository::cache::build_cache_config(cli.no_cache); + let files_cache = mozart_core::repository::cache::Cache::files(&cache_config); let installation_manager = composer.installation_manager(); for package in &packages_to_reinstall { @@ -166,12 +166,12 @@ pub async fn execute( std::fs::remove_dir_all(&install_path)?; } - let mut progress = mozart_registry::downloader::DownloadProgress::new( + let mut progress = mozart_core::repository::downloader::DownloadProgress::new( !args.no_progress, format!("{} ({})", package.pretty_name(), package.pretty_version()), ); - mozart_registry::downloader::install_package( + mozart_core::repository::downloader::install_package( &dist.url, &dist.kind, dist.shasum.as_deref(), diff --git a/crates/mozart/src/commands/remove.rs b/crates/mozart/src/commands/remove.rs index d4d727f..c2d4d47 100644 --- a/crates/mozart/src/commands/remove.rs +++ b/crates/mozart/src/commands/remove.rs @@ -3,9 +3,9 @@ use indexmap::{IndexMap, IndexSet}; use mozart_core::console_format; use mozart_core::console_writeln; use mozart_core::package; -use mozart_registry::installed; -use mozart_registry::lockfile; -use mozart_registry::resolver::{self, PlatformConfig, ResolveRequest}; +use mozart_core::repository::installed; +use mozart_core::repository::lockfile; +use mozart_core::repository::resolver::{self, PlatformConfig, ResolveRequest}; #[derive(Args)] pub struct RemoveArgs { @@ -102,8 +102,8 @@ pub async fn execute( cli: &super::Cli, console: &mozart_core::console::Console, ) -> anyhow::Result<()> { - let cache_config = mozart_registry::cache::build_cache_config(cli.no_cache); - let repo_cache = mozart_registry::cache::Cache::repo(&cache_config); + let cache_config = mozart_core::repository::cache::build_cache_config(cli.no_cache); + let repo_cache = mozart_core::repository::cache::Cache::repo(&cache_config); if args.packages.is_empty() && !args.unused { anyhow::bail!("Not enough arguments (missing: \"packages\")."); @@ -242,7 +242,7 @@ pub async fn execute( ignore_platform_reqs: args.ignore_platform_reqs, ignore_platform_req_list: args.ignore_platform_req.clone(), repositories: std::sync::Arc::new( - mozart_registry::repository::RepositorySet::with_packagist(repo_cache.clone()), + mozart_core::repository::repository::RepositorySet::with_packagist(repo_cache.clone()), ), temporary_constraints: IndexMap::new(), raw_repositories: composer.repositories.clone(), @@ -344,7 +344,7 @@ pub async fn execute( composer_json: composer.clone(), include_dev: dev_mode, repositories: std::sync::Arc::new( - mozart_registry::repository::RepositorySet::with_packagist(repo_cache.clone()), + mozart_core::repository::repository::RepositorySet::with_packagist(repo_cache.clone()), ), previous_lock: old_lock.clone(), lock_pinned_names: IndexSet::new(), @@ -430,10 +430,10 @@ pub async fn execute( } if !args.no_install && !args.dry_run { - let cache_config = mozart_registry::cache::build_cache_config(no_cache); - let files_cache = mozart_registry::cache::Cache::files(&cache_config); + let cache_config = mozart_core::repository::cache::build_cache_config(no_cache); + let files_cache = mozart_core::repository::cache::Cache::files(&cache_config); let mut executor = - mozart_registry::installer_executor::FilesystemExecutor::new(files_cache); + mozart_core::repository::installer_executor::FilesystemExecutor::new(files_cache); super::install::install_from_lock( &new_lock, &working_dir, @@ -499,7 +499,7 @@ async fn remove_unused( composer: &package::RawPackageData, working_dir: &std::path::Path, args: &RemoveArgs, - repo_cache: &mozart_registry::cache::Cache, + repo_cache: &mozart_core::repository::cache::Cache, no_cache: bool, console: &mozart_core::console::Console, ) -> anyhow::Result<()> { @@ -546,7 +546,7 @@ async fn remove_unused( ignore_platform_reqs: args.ignore_platform_reqs, ignore_platform_req_list: args.ignore_platform_req.clone(), repositories: std::sync::Arc::new( - mozart_registry::repository::RepositorySet::with_packagist(repo_cache.clone()), + mozart_core::repository::repository::RepositorySet::with_packagist(repo_cache.clone()), ), temporary_constraints: IndexMap::new(), raw_repositories: composer.repositories.clone(), @@ -625,7 +625,7 @@ async fn remove_unused( composer_json: composer.clone(), include_dev: dev_mode, repositories: std::sync::Arc::new( - mozart_registry::repository::RepositorySet::with_packagist(repo_cache.clone()), + mozart_core::repository::repository::RepositorySet::with_packagist(repo_cache.clone()), ), previous_lock: Some(old_lock.clone()), lock_pinned_names: IndexSet::new(), @@ -637,10 +637,10 @@ async fn remove_unused( 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 cache_config = mozart_core::repository::cache::build_cache_config(no_cache); + let files_cache = mozart_core::repository::cache::Cache::files(&cache_config); let mut executor = - mozart_registry::installer_executor::FilesystemExecutor::new(files_cache); + mozart_core::repository::installer_executor::FilesystemExecutor::new(files_cache); super::install::install_from_lock( &new_lock, working_dir, @@ -672,7 +672,7 @@ async fn remove_unused( mod tests { use super::*; use mozart_core::package::RawPackageData; - use mozart_registry::lockfile; + use mozart_core::repository::lockfile; use std::collections::BTreeMap; fn make_locked_package(name: &str, version: &str) -> lockfile::LockedPackage { @@ -920,8 +920,8 @@ mod tests { #[ignore] async fn test_remove_full_e2e() { use indexmap::{IndexMap, IndexSet}; - use mozart_registry::lockfile::{LockFileGenerationRequest, generate_lock_file}; - use mozart_registry::resolver::{ResolveRequest, resolve}; + use mozart_core::repository::lockfile::{LockFileGenerationRequest, generate_lock_file}; + use mozart_core::repository::resolver::{ResolveRequest, resolve}; use tempfile::tempdir; let dir = tempdir().unwrap(); @@ -944,12 +944,12 @@ mod tests { stability_flags: IndexMap::new(), prefer_stable: true, prefer_lowest: false, - platform: mozart_registry::resolver::PlatformConfig::new(), + platform: mozart_core::repository::resolver::PlatformConfig::new(), ignore_platform_reqs: false, ignore_platform_req_list: vec![], repositories: std::sync::Arc::new( - mozart_registry::repository::RepositorySet::with_packagist( - mozart_registry::cache::Cache::new( + mozart_core::repository::repository::RepositorySet::with_packagist( + mozart_core::repository::cache::Cache::new( std::env::temp_dir().join("mozart-test-cache"), false, ), @@ -976,8 +976,8 @@ mod tests { composer_json: composer.clone(), include_dev: false, repositories: std::sync::Arc::new( - mozart_registry::repository::RepositorySet::with_packagist( - mozart_registry::cache::Cache::new( + mozart_core::repository::repository::RepositorySet::with_packagist( + mozart_core::repository::cache::Cache::new( std::env::temp_dir().join("mozart-test-cache"), false, ), @@ -1005,12 +1005,12 @@ mod tests { stability_flags: IndexMap::new(), prefer_stable: true, prefer_lowest: false, - platform: mozart_registry::resolver::PlatformConfig::new(), + platform: mozart_core::repository::resolver::PlatformConfig::new(), ignore_platform_reqs: false, ignore_platform_req_list: vec![], repositories: std::sync::Arc::new( - mozart_registry::repository::RepositorySet::with_packagist( - mozart_registry::cache::Cache::new( + mozart_core::repository::repository::RepositorySet::with_packagist( + mozart_core::repository::cache::Cache::new( std::env::temp_dir().join("mozart-test-cache"), false, ), @@ -1039,8 +1039,8 @@ mod tests { composer_json: composer, include_dev: false, repositories: std::sync::Arc::new( - mozart_registry::repository::RepositorySet::with_packagist( - mozart_registry::cache::Cache::new( + mozart_core::repository::repository::RepositorySet::with_packagist( + mozart_core::repository::cache::Cache::new( std::env::temp_dir().join("mozart-test-cache"), false, ), diff --git a/crates/mozart/src/commands/require.rs b/crates/mozart/src/commands/require.rs index 3ccba96..9ec4195 100644 --- a/crates/mozart/src/commands/require.rs +++ b/crates/mozart/src/commands/require.rs @@ -3,12 +3,12 @@ use indexmap::{IndexMap, IndexSet}; use mozart_core::console_format; use mozart_core::console_writeln; use mozart_core::package::{self, RawPackageData, Stability}; +use mozart_core::repository::lockfile; +use mozart_core::repository::packagist; +use mozart_core::repository::resolver::{self, PlatformConfig, ResolveRequest}; +use mozart_core::repository::version; +use mozart_core::repository::version_selector::VersionSelector; use mozart_core::validation; -use mozart_registry::lockfile; -use mozart_registry::packagist; -use mozart_registry::resolver::{self, PlatformConfig, ResolveRequest}; -use mozart_registry::version; -use mozart_registry::version_selector::VersionSelector; use std::io::{BufRead, IsTerminal, Write}; use std::path::{Path, PathBuf}; @@ -270,8 +270,8 @@ async fn do_update( ) -> anyhow::Result<()> { let working_dir = cli.working_dir()?; let vendor_dir = working_dir.join("vendor"); - let cache_config = mozart_registry::cache::build_cache_config(cli.no_cache); - let repo_cache = mozart_registry::cache::Cache::repo(&cache_config); + let cache_config = mozart_core::repository::cache::build_cache_config(cli.no_cache); + let repo_cache = mozart_core::repository::cache::Cache::repo(&cache_config); let dev_mode = !args.update_no_dev; @@ -322,7 +322,7 @@ async fn do_update( ignore_platform_reqs: args.ignore_platform_reqs, ignore_platform_req_list: args.ignore_platform_req.clone(), repositories: std::sync::Arc::new( - mozart_registry::repository::RepositorySet::with_packagist(repo_cache.clone()), + mozart_core::repository::repository::RepositorySet::with_packagist(repo_cache.clone()), ), temporary_constraints: IndexMap::new(), raw_repositories: raw.repositories.clone(), @@ -444,7 +444,7 @@ async fn do_update( composer_json: raw.clone(), include_dev: dev_mode, repositories: std::sync::Arc::new( - mozart_registry::repository::RepositorySet::with_packagist(repo_cache.clone()), + mozart_core::repository::repository::RepositorySet::with_packagist(repo_cache.clone()), ), previous_lock: old_lock.clone(), lock_pinned_names: IndexSet::new(), @@ -548,11 +548,11 @@ async fn do_update( .and_then(|v| v.as_bool()) .unwrap_or(false); - let files_cache = mozart_registry::cache::Cache::files( - &mozart_registry::cache::build_cache_config(cli.no_cache), + let files_cache = mozart_core::repository::cache::Cache::files( + &mozart_core::repository::cache::build_cache_config(cli.no_cache), ); let mut executor = - mozart_registry::installer_executor::FilesystemExecutor::new(files_cache); + mozart_core::repository::installer_executor::FilesystemExecutor::new(files_cache); super::install::install_from_lock( &new_lock, &working_dir, @@ -590,7 +590,7 @@ async fn interactive_search_packages( already_required: &indexmap::IndexSet, preferred_stability: Stability, fixed: bool, - repo_cache: &mozart_registry::cache::Cache, + repo_cache: &mozart_core::repository::cache::Cache, console: &mozart_core::console::Console, ) -> anyhow::Result> { let stdin = std::io::stdin(); @@ -784,8 +784,8 @@ pub async fn execute( cli: &super::Cli, console: &mozart_core::console::Console, ) -> anyhow::Result<()> { - let cache_config = mozart_registry::cache::build_cache_config(cli.no_cache); - let repo_cache = mozart_registry::cache::Cache::repo(&cache_config); + let cache_config = mozart_core::repository::cache::build_cache_config(cli.no_cache); + let repo_cache = mozart_core::repository::cache::Cache::repo(&cache_config); // --- Deprecated flag warnings --- // Mirrors Composer\Command\RequireCommand::execute() L134-136. @@ -1316,7 +1316,7 @@ mod tests { async fn test_require_full_e2e() { use indexmap::IndexSet; use mozart_core::package::RawPackageData; - use mozart_registry::lockfile::{LockFileGenerationRequest, generate_lock_file}; + use mozart_core::repository::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(); @@ -1335,8 +1335,8 @@ mod tests { ignore_platform_reqs: false, ignore_platform_req_list: vec![], repositories: std::sync::Arc::new( - mozart_registry::repository::RepositorySet::with_packagist( - mozart_registry::cache::Cache::new( + mozart_core::repository::repository::RepositorySet::with_packagist( + mozart_core::repository::cache::Cache::new( std::env::temp_dir().join("mozart-test-cache"), false, ), @@ -1367,8 +1367,8 @@ mod tests { composer_json, include_dev: false, repositories: std::sync::Arc::new( - mozart_registry::repository::RepositorySet::with_packagist( - mozart_registry::cache::Cache::new( + mozart_core::repository::repository::RepositorySet::with_packagist( + mozart_core::repository::cache::Cache::new( std::env::temp_dir().join("mozart-test-cache"), false, ), @@ -1416,8 +1416,8 @@ mod tests { ignore_platform_reqs: false, ignore_platform_req_list: vec![], repositories: std::sync::Arc::new( - mozart_registry::repository::RepositorySet::with_packagist( - mozart_registry::cache::Cache::new( + mozart_core::repository::repository::RepositorySet::with_packagist( + mozart_core::repository::cache::Cache::new( std::env::temp_dir().join("mozart-test-cache"), false, ), @@ -1445,8 +1445,8 @@ mod tests { composer_json: raw, include_dev: false, repositories: std::sync::Arc::new( - mozart_registry::repository::RepositorySet::with_packagist( - mozart_registry::cache::Cache::new( + mozart_core::repository::repository::RepositorySet::with_packagist( + mozart_core::repository::cache::Cache::new( std::env::temp_dir().join("mozart-test-cache"), false, ), diff --git a/crates/mozart/src/commands/search.rs b/crates/mozart/src/commands/search.rs index 14d50dd..a5ab04a 100644 --- a/crates/mozart/src/commands/search.rs +++ b/crates/mozart/src/commands/search.rs @@ -2,8 +2,8 @@ use clap::Args; use mozart_core::console::{Console, hyperlink}; use mozart_core::console_format; use mozart_core::console_writeln; -use mozart_registry::packagist::SearchResult; -use mozart_registry::repository::{RepositorySet, SearchMode}; +use mozart_core::repository::packagist::SearchResult; +use mozart_core::repository::repository::{RepositorySet, SearchMode}; use serde::Serialize; /// JSON output structure matching Composer's search result schema. @@ -111,8 +111,8 @@ pub async fn execute(args: &SearchArgs, cli: &super::Cli, console: &Console) -> // 5. Build the repository set. Configured remote repositories from // `composer.json` are not yet wired up; this is a known divergence // from Composer's full `CompositeRepository`. - let cache_config = mozart_registry::cache::build_cache_config(cli.no_cache); - let repo_cache = mozart_registry::cache::Cache::repo(&cache_config); + let cache_config = mozart_core::repository::cache::build_cache_config(cli.no_cache); + let repo_cache = mozart_core::repository::cache::Cache::repo(&cache_config); let repos = RepositorySet::with_packagist(repo_cache); // 6. Dispatch. @@ -199,7 +199,7 @@ mod tests { #[test] fn test_parse_search_response() { - use mozart_registry::packagist::SearchResponse; + use mozart_core::repository::packagist::SearchResponse; let json = r#"{ "results": [ @@ -245,7 +245,7 @@ mod tests { #[test] fn test_parse_search_response_with_abandoned() { - use mozart_registry::packagist::SearchResponse; + use mozart_core::repository::packagist::SearchResponse; let json = r#"{ "results": [ @@ -288,7 +288,7 @@ mod tests { #[test] fn test_parse_search_response_with_next() { - use mozart_registry::packagist::SearchResponse; + use mozart_core::repository::packagist::SearchResponse; let json = r#"{ "results": [], diff --git a/crates/mozart/src/commands/show.rs b/crates/mozart/src/commands/show.rs index f0b82b3..8876694 100644 --- a/crates/mozart/src/commands/show.rs +++ b/crates/mozart/src/commands/show.rs @@ -110,8 +110,8 @@ pub async fn execute( cli: &super::Cli, console: &mozart_core::console::Console, ) -> anyhow::Result<()> { - let cache_config = mozart_registry::cache::build_cache_config(cli.no_cache); - let repo_cache = mozart_registry::cache::Cache::repo(&cache_config); + let cache_config = mozart_core::repository::cache::build_cache_config(cli.no_cache); + let repo_cache = mozart_core::repository::cache::Cache::repo(&cache_config); // A9: --installed deprecation warning (mirrors Composer 143-145) if args.installed && !args.self_info { @@ -296,12 +296,13 @@ async fn fetch_latest_for_package( name: &str, current_normalized: &str, args: &ShowArgs, - repo_cache: &mozart_registry::cache::Cache, + repo_cache: &mozart_core::repository::cache::Cache, ) -> anyhow::Result { use mozart_core::package::Stability; - use mozart_registry::version::find_best_candidate; + use mozart_core::repository::version::find_best_candidate; - let versions = mozart_registry::packagist::fetch_package_versions(name, repo_cache).await?; + let versions = + mozart_core::repository::packagist::fetch_package_versions(name, repo_cache).await?; let current_major = extract_major(current_normalized); let current_minor = extract_minor(current_normalized); @@ -313,7 +314,7 @@ async fn fetch_latest_for_package( anyhow::bail!("Cannot determine major update for dev version of {name}"); } - let filtered: Vec = versions + let filtered: Vec = versions .iter() .filter(|v| { let v_norm = &v.version_normalized; @@ -355,7 +356,7 @@ fn abandoned_info(val: &serde_json::Value) -> Option { } fn classify_update_category(current_normalized: &str, latest_normalized: &str) -> ListUpdateKind { - use mozart_registry::version::compare_normalized_versions; + use mozart_core::repository::version::compare_normalized_versions; use std::cmp::Ordering; if compare_normalized_versions(latest_normalized, current_normalized) != Ordering::Greater { @@ -400,10 +401,10 @@ fn extract_minor(version_normalized: &str) -> u64 { // ============================================================================ async fn collect_installed_entries( - packages: &[&mozart_registry::installed::InstalledPackageEntry], + packages: &[&mozart_core::repository::installed::InstalledPackageEntry], args: &ShowArgs, direct_names: &IndexSet, - repo_cache: &mozart_registry::cache::Cache, + repo_cache: &mozart_core::repository::cache::Cache, ) -> Vec { let show_latest = args.latest || args.outdated; let mut entries = Vec::new(); @@ -435,7 +436,7 @@ async fn collect_installed_entries( if args.outdated { if let Some(ref li) = latest_info { - use mozart_registry::version::compare_normalized_versions; + use mozart_core::repository::version::compare_normalized_versions; use std::cmp::Ordering; if compare_normalized_versions(&li.version_normalized, &version_normalized) != Ordering::Greater @@ -462,10 +463,10 @@ async fn collect_installed_entries( } async fn collect_locked_entries( - packages: &[&mozart_registry::lockfile::LockedPackage], + packages: &[&mozart_core::repository::lockfile::LockedPackage], args: &ShowArgs, direct_names: &IndexSet, - repo_cache: &mozart_registry::cache::Cache, + repo_cache: &mozart_core::repository::cache::Cache, ) -> Vec { let show_latest = args.latest || args.outdated; let mut entries = Vec::new(); @@ -497,7 +498,7 @@ async fn collect_locked_entries( if args.outdated { if let Some(ref li) = latest_info { - use mozart_registry::version::compare_normalized_versions; + use mozart_core::repository::version::compare_normalized_versions; use std::cmp::Ordering; if compare_normalized_versions(&li.version_normalized, &version_normalized) != Ordering::Greater @@ -803,7 +804,7 @@ fn render_list_json( /// Build a `PackageDetail` from an installed package entry. fn installed_to_detail( - pkg: &mozart_registry::installed::InstalledPackageEntry, + pkg: &mozart_core::repository::installed::InstalledPackageEntry, vendor_dir: &Path, ) -> PackageDetail { let install_path = vendor_dir.join(&pkg.name); @@ -871,7 +872,7 @@ fn installed_to_detail( } /// Build a `PackageDetail` from a locked package entry. -fn locked_to_detail(pkg: &mozart_registry::lockfile::LockedPackage) -> PackageDetail { +fn locked_to_detail(pkg: &mozart_core::repository::lockfile::LockedPackage) -> PackageDetail { let mut names = vec![pkg.name.clone()]; names.extend(pkg.provide.keys().cloned()); names.extend(pkg.replace.keys().cloned()); @@ -927,7 +928,7 @@ fn locked_to_detail(pkg: &mozart_registry::lockfile::LockedPackage) -> PackageDe async fn print_package_detail( detail: &PackageDetail, args: &ShowArgs, - repo_cache: &mozart_registry::cache::Cache, + repo_cache: &mozart_core::repository::cache::Cache, console: &mozart_core::console::Console, ) -> anyhow::Result<()> { if args.format == "json" { @@ -1157,7 +1158,7 @@ fn print_links_section( async fn print_package_detail_json( detail: &PackageDetail, args: &ShowArgs, - repo_cache: &mozart_registry::cache::Cache, + repo_cache: &mozart_core::repository::cache::Cache, console: &mozart_core::console::Console, ) -> anyhow::Result<()> { let mut obj = serde_json::json!({ @@ -1225,11 +1226,11 @@ async fn print_package_detail_json( async fn execute_installed( args: &ShowArgs, working_dir: &Path, - repo_cache: &mozart_registry::cache::Cache, + repo_cache: &mozart_core::repository::cache::Cache, console: &mozart_core::console::Console, ) -> anyhow::Result<()> { let vendor_dir = working_dir.join("vendor"); - let installed = mozart_registry::installed::InstalledPackages::read(&vendor_dir)?; + let installed = mozart_core::repository::installed::InstalledPackages::read(&vendor_dir)?; if installed.packages.is_empty() { let composer_json_path = working_dir.join("composer.json"); @@ -1343,11 +1344,11 @@ async fn execute_installed( } fn filter_installed_packages<'a>( - installed: &'a mozart_registry::installed::InstalledPackages, + installed: &'a mozart_core::repository::installed::InstalledPackages, args: &ShowArgs, direct_names: &IndexSet, -) -> Vec<&'a mozart_registry::installed::InstalledPackageEntry> { - let mut packages: Vec<&mozart_registry::installed::InstalledPackageEntry> = +) -> Vec<&'a mozart_core::repository::installed::InstalledPackageEntry> { + let mut packages: Vec<&mozart_core::repository::installed::InstalledPackageEntry> = installed.packages.iter().collect(); // --no-dev: exclude dev packages @@ -1376,7 +1377,7 @@ fn filter_installed_packages<'a>( async fn execute_locked( args: &ShowArgs, working_dir: &Path, - repo_cache: &mozart_registry::cache::Cache, + repo_cache: &mozart_core::repository::cache::Cache, console: &mozart_core::console::Console, ) -> anyhow::Result<()> { let lock_path = working_dir.join("composer.lock"); @@ -1386,9 +1387,9 @@ async fn execute_locked( ); } - let lock = mozart_registry::lockfile::LockFile::read_from_file(&lock_path)?; + let lock = mozart_core::repository::lockfile::LockFile::read_from_file(&lock_path)?; - let mut packages: Vec<&mozart_registry::lockfile::LockedPackage> = + let mut packages: Vec<&mozart_core::repository::lockfile::LockedPackage> = lock.packages.iter().collect(); if let Some(ref pkgs_dev) = lock.packages_dev @@ -1573,10 +1574,10 @@ fn show_tree( let root = mozart_core::package::read_from_file(&composer_json_path)?; - let pkg_map: IndexMap; + let pkg_map: IndexMap; let lock_storage; if lock_path.exists() { - lock_storage = mozart_registry::lockfile::LockFile::read_from_file(&lock_path)?; + lock_storage = mozart_core::repository::lockfile::LockFile::read_from_file(&lock_path)?; pkg_map = lock_storage .packages .iter() @@ -1635,7 +1636,7 @@ fn show_tree( fn print_tree_node( pkg_name: &str, constraint: &str, - pkg_map: &IndexMap, + pkg_map: &IndexMap, prefix: &str, child_prefix: &str, visited: &mut IndexSet, @@ -1736,7 +1737,7 @@ fn show_platform( let lock_path = working_dir.join("composer.lock"); if lock_path.exists() { - let lock = mozart_registry::lockfile::LockFile::read_from_file(&lock_path)?; + let lock = mozart_core::repository::lockfile::LockFile::read_from_file(&lock_path)?; if let Some(obj) = lock.platform.as_object() { for (name, version_val) in obj { @@ -1839,7 +1840,7 @@ fn show_platform( async fn show_available( args: &ShowArgs, working_dir: &Path, - repo_cache: &mozart_registry::cache::Cache, + repo_cache: &mozart_core::repository::cache::Cache, console: &mozart_core::console::Console, ) -> anyhow::Result<()> { if let Some(ref pkg_name) = args.package { @@ -1847,21 +1848,21 @@ async fn show_available( } let vendor_dir = working_dir.join("vendor"); - let installed = mozart_registry::installed::InstalledPackages::read(&vendor_dir); + let installed = mozart_core::repository::installed::InstalledPackages::read(&vendor_dir); let installed = match installed { Ok(i) if !i.packages.is_empty() => i, _ => { let lock_path = working_dir.join("composer.lock"); if lock_path.exists() { - let lock = mozart_registry::lockfile::LockFile::read_from_file(&lock_path)?; + let lock = mozart_core::repository::lockfile::LockFile::read_from_file(&lock_path)?; console_writeln!( console, "Available versions for locked packages (from Packagist):", ); console_writeln!(console, ""); - let mut all_packages: Vec<&mozart_registry::lockfile::LockedPackage> = + let mut all_packages: Vec<&mozart_core::repository::lockfile::LockedPackage> = lock.packages.iter().collect(); if !args.no_dev && let Some(ref dev_pkgs) = lock.packages_dev @@ -1898,7 +1899,9 @@ async fn show_available( if is_platform_package(&pkg.name) { continue; } - match mozart_registry::packagist::fetch_package_versions(&pkg.name, repo_cache).await { + match mozart_core::repository::packagist::fetch_package_versions(&pkg.name, repo_cache) + .await + { Ok(versions) => { let version_strings: Vec = versions.iter().map(|v| v.version.clone()).collect(); @@ -1934,11 +1937,12 @@ async fn show_available( async fn show_available_versions( pkg_name: &str, - repo_cache: &mozart_registry::cache::Cache, + repo_cache: &mozart_core::repository::cache::Cache, args: &ShowArgs, console: &mozart_core::console::Console, ) -> anyhow::Result<()> { - let versions = mozart_registry::packagist::fetch_package_versions(pkg_name, repo_cache).await?; + let versions = + mozart_core::repository::packagist::fetch_package_versions(pkg_name, repo_cache).await?; if versions.is_empty() { console_writeln!(console, "No versions found for {pkg_name}"); return Ok(()); @@ -1967,10 +1971,10 @@ async fn show_available_versions( async fn show_available_versions_inline( pkg_name: &str, - repo_cache: &mozart_registry::cache::Cache, + repo_cache: &mozart_core::repository::cache::Cache, console: &mozart_core::console::Console, ) { - match mozart_registry::packagist::fetch_package_versions(pkg_name, repo_cache).await { + match mozart_core::repository::packagist::fetch_package_versions(pkg_name, repo_cache).await { Ok(versions) => { if versions.is_empty() { console_writeln!( @@ -2020,7 +2024,9 @@ fn format_version_highlight(version: &str) -> String { format!("* {}", format_version(version)) } -fn get_installed_description(pkg: &mozart_registry::installed::InstalledPackageEntry) -> String { +fn get_installed_description( + pkg: &mozart_core::repository::installed::InstalledPackageEntry, +) -> String { pkg.extra_fields .get("description") .and_then(|v| v.as_str()) @@ -2029,7 +2035,7 @@ fn get_installed_description(pkg: &mozart_registry::installed::InstalledPackageE } fn get_installed_keywords_vec( - pkg: &mozart_registry::installed::InstalledPackageEntry, + pkg: &mozart_core::repository::installed::InstalledPackageEntry, ) -> Vec { pkg.extra_fields .get("keywords") @@ -2042,7 +2048,9 @@ fn get_installed_keywords_vec( .unwrap_or_default() } -fn get_installed_licenses(pkg: &mozart_registry::installed::InstalledPackageEntry) -> Vec { +fn get_installed_licenses( + pkg: &mozart_core::repository::installed::InstalledPackageEntry, +) -> Vec { pkg.extra_fields .get("license") .and_then(|v| v.as_array()) @@ -2055,7 +2063,7 @@ fn get_installed_licenses(pkg: &mozart_registry::installed::InstalledPackageEntr } fn get_installed_homepage( - pkg: &mozart_registry::installed::InstalledPackageEntry, + pkg: &mozart_core::repository::installed::InstalledPackageEntry, ) -> Option { pkg.extra_fields .get("homepage") @@ -2064,7 +2072,7 @@ fn get_installed_homepage( } fn get_installed_release_date( - pkg: &mozart_registry::installed::InstalledPackageEntry, + pkg: &mozart_core::repository::installed::InstalledPackageEntry, ) -> Option { pkg.extra_fields .get("time") @@ -2075,7 +2083,7 @@ fn get_installed_release_date( /// Extract a map of `{name: constraint}` from an installed package's /// extra_fields for the given key (e.g. "require", "conflict", "provide"). fn get_installed_link_map( - pkg: &mozart_registry::installed::InstalledPackageEntry, + pkg: &mozart_core::repository::installed::InstalledPackageEntry, key: &str, ) -> BTreeMap { pkg.extra_fields @@ -2091,7 +2099,7 @@ fn get_installed_link_map( /// Extract a map of `{package: reason}` from an installed package's suggest field. fn get_installed_suggest_map( - pkg: &mozart_registry::installed::InstalledPackageEntry, + pkg: &mozart_core::repository::installed::InstalledPackageEntry, ) -> BTreeMap { pkg.extra_fields .get("suggest") @@ -2274,7 +2282,7 @@ mod tests { "description".to_string(), serde_json::Value::String("A logging library".to_string()), ); - let pkg = mozart_registry::installed::InstalledPackageEntry { + let pkg = mozart_core::repository::installed::InstalledPackageEntry { name: "monolog/monolog".to_string(), version: "3.0.0".to_string(), version_normalized: None, @@ -2294,7 +2302,7 @@ mod tests { #[test] fn test_get_installed_description_absent() { use std::collections::BTreeMap; - let pkg = mozart_registry::installed::InstalledPackageEntry { + let pkg = mozart_core::repository::installed::InstalledPackageEntry { name: "psr/log".to_string(), version: "3.0.0".to_string(), version_normalized: None, @@ -2319,7 +2327,7 @@ mod tests { "keywords".to_string(), serde_json::json!(["log", "psr3", "logging"]), ); - let pkg = mozart_registry::installed::InstalledPackageEntry { + let pkg = mozart_core::repository::installed::InstalledPackageEntry { name: "psr/log".to_string(), version: "3.0.0".to_string(), version_normalized: None, diff --git a/crates/mozart/src/commands/status.rs b/crates/mozart/src/commands/status.rs index d15ffb3..f0445bf 100644 --- a/crates/mozart/src/commands/status.rs +++ b/crates/mozart/src/commands/status.rs @@ -5,7 +5,7 @@ use mozart_core::console::Console; use mozart_core::console_writeln; use mozart_core::console_writeln_error; use mozart_core::exit_code; -use mozart_vcs::version_guesser::{VersionGuesser, VersionParser}; +use mozart_core::vcs::version_guesser::{VersionGuesser, VersionParser}; #[derive(Args)] pub struct StatusArgs {} diff --git a/crates/mozart/src/commands/suggests.rs b/crates/mozart/src/commands/suggests.rs index 690b9d3..1643e94 100644 --- a/crates/mozart/src/commands/suggests.rs +++ b/crates/mozart/src/commands/suggests.rs @@ -62,7 +62,7 @@ pub async fn execute( // Iterate every package that contributes suggestions: locked/installed, // then root. Mirrors `$installedRepo->getPackages() + $composer->getPackage()`. if has_lock { - let lock = mozart_registry::lockfile::LockFile::read_from_file(&lock_path)?; + let lock = mozart_core::repository::lockfile::LockFile::read_from_file(&lock_path)?; for pkg in lock.packages.iter() { if filter.is_empty() || filter.contains(&pkg.name) { reporter.add_suggestions_from_package(pkg); @@ -79,7 +79,7 @@ pub async fn execute( } } else { let vendor_dir = working_dir.join("vendor"); - let installed = mozart_registry::installed::InstalledPackages::read(&vendor_dir)?; + let installed = mozart_core::repository::installed::InstalledPackages::read(&vendor_dir)?; if installed.packages.is_empty() { let installed_json = vendor_dir.join("composer/installed.json"); @@ -148,9 +148,9 @@ fn build_installed_repo( if has_lock { let lock_path = working_dir.join("composer.lock"); - let lock = mozart_registry::lockfile::LockFile::read_from_file(&lock_path)?; + let lock = mozart_core::repository::lockfile::LockFile::read_from_file(&lock_path)?; - let mut all_packages: Vec<&mozart_registry::lockfile::LockedPackage> = + let mut all_packages: Vec<&mozart_core::repository::lockfile::LockedPackage> = lock.packages.iter().collect(); if !no_dev && let Some(ref pkgs_dev) = lock.packages_dev { all_packages.extend(pkgs_dev.iter()); @@ -179,7 +179,7 @@ fn build_installed_repo( } } else { let vendor_dir = working_dir.join("vendor"); - let installed = mozart_registry::installed::InstalledPackages::read(&vendor_dir)?; + let installed = mozart_core::repository::installed::InstalledPackages::read(&vendor_dir)?; let dev_names: IndexSet = installed .dev_package_names @@ -238,8 +238,8 @@ mod tests { fn make_locked_package( name: &str, suggest: Option>, - ) -> mozart_registry::lockfile::LockedPackage { - mozart_registry::lockfile::LockedPackage { + ) -> mozart_core::repository::lockfile::LockedPackage { + mozart_core::repository::lockfile::LockedPackage { name: name.to_string(), version: "1.0.0".to_string(), version_normalized: None, @@ -269,7 +269,7 @@ mod tests { fn make_installed_entry( name: &str, suggest: Option>, - ) -> mozart_registry::installed::InstalledPackageEntry { + ) -> mozart_core::repository::installed::InstalledPackageEntry { let mut extra_fields: BTreeMap = BTreeMap::new(); if let Some(s) = suggest { let map: serde_json::Map = s @@ -278,7 +278,7 @@ mod tests { .collect(); extra_fields.insert("suggest".to_string(), serde_json::Value::Object(map)); } - mozart_registry::installed::InstalledPackageEntry { + mozart_core::repository::installed::InstalledPackageEntry { name: name.to_string(), version: "1.0.0".to_string(), version_normalized: None, @@ -295,11 +295,11 @@ mod tests { } fn minimal_lock( - packages: Vec, - packages_dev: Option>, - ) -> mozart_registry::lockfile::LockFile { - mozart_registry::lockfile::LockFile { - readme: mozart_registry::lockfile::LockFile::default_readme(), + packages: Vec, + packages_dev: Option>, + ) -> mozart_core::repository::lockfile::LockFile { + mozart_core::repository::lockfile::LockFile { + readme: mozart_core::repository::lockfile::LockFile::default_readme(), content_hash: "abc123".to_string(), packages, packages_dev, diff --git a/crates/mozart/src/commands/update.rs b/crates/mozart/src/commands/update.rs index 11672fd..5498983 100644 --- a/crates/mozart/src/commands/update.rs +++ b/crates/mozart/src/commands/update.rs @@ -4,8 +4,8 @@ use indexmap::{IndexMap, IndexSet}; use mozart_core::console_format; use mozart_core::package; use mozart_core::platform::is_platform_package; -use mozart_registry::lockfile; -use mozart_registry::resolver::{ +use mozart_core::repository::lockfile; +use mozart_core::repository::resolver::{ self, LockedPackageInfo, PlatformConfig, ResolveRequest, ResolvedPackage, }; @@ -559,13 +559,13 @@ pub fn collect_repo_requires( repositories: &[mozart_core::package::RawRepository], ) -> IndexMap> { let mut out: IndexMap> = IndexMap::new(); - for ipkg in mozart_registry::inline_package::collect_inline_packages(repositories) { + for ipkg in mozart_core::repository::inline_package::collect_inline_packages(repositories) { let entry = out.entry(ipkg.name.to_lowercase()).or_default(); for req in ipkg.version.require.keys() { entry.insert(req.to_lowercase()); } } - for cpkg in mozart_registry::composer_repo::collect_composer_packages(repositories) { + for cpkg in mozart_core::repository::composer_repo::collect_composer_packages(repositories) { let entry = out.entry(cpkg.name.to_lowercase()).or_default(); for req in cpkg.version.require.keys() { entry.insert(req.to_lowercase()); @@ -923,13 +923,14 @@ pub async fn execute( cli: &super::Cli, console: &mozart_core::console::Console, ) -> anyhow::Result<()> { - let cache_config = mozart_registry::cache::build_cache_config(cli.no_cache); - let repositories = - std::sync::Arc::new(mozart_registry::repository::RepositorySet::with_packagist( - mozart_registry::cache::Cache::repo(&cache_config), - )); - let mut executor = mozart_registry::installer_executor::FilesystemExecutor::new( - mozart_registry::cache::Cache::files(&cache_config), + let cache_config = mozart_core::repository::cache::build_cache_config(cli.no_cache); + let repositories = std::sync::Arc::new( + mozart_core::repository::repository::RepositorySet::with_packagist( + mozart_core::repository::cache::Cache::repo(&cache_config), + ), + ); + let mut executor = mozart_core::repository::installer_executor::FilesystemExecutor::new( + mozart_core::repository::cache::Cache::files(&cache_config), ); let working_dir = cli.working_dir()?; run( @@ -962,8 +963,8 @@ pub async fn run( path_repo_base_override: Option<&std::path::Path>, args: &UpdateArgs, console: &mozart_core::console::Console, - repositories: std::sync::Arc, - executor: &mut dyn mozart_registry::installer_executor::InstallerExecutor, + repositories: std::sync::Arc, + executor: &mut dyn mozart_core::repository::installer_executor::InstallerExecutor, ) -> anyhow::Result<()> { // Step 2: Handle deprecated flags if args.dev { @@ -1005,7 +1006,7 @@ pub async fn run( let path_repo_base = path_repo_base_override.unwrap_or(working_dir); let composer_json_expanded = { let mut clone = composer_json.clone(); - clone.repositories = mozart_registry::path_repository::expand_path_repositories( + clone.repositories = mozart_core::repository::path_repository::expand_path_repositories( &clone.repositories, path_repo_base, ); @@ -2379,8 +2380,8 @@ mod tests { #[ignore] async fn test_update_full_e2e() { use mozart_core::package::RawPackageData; - use mozart_registry::lockfile::{LockFileGenerationRequest, generate_lock_file}; - use mozart_registry::resolver::{ResolveRequest, resolve}; + use mozart_core::repository::lockfile::{LockFileGenerationRequest, generate_lock_file}; + use mozart_core::repository::resolver::{ResolveRequest, resolve}; let composer_json_content = r#"{"name": "test/project", "require": {"monolog/monolog": "^3.0"}}"#; @@ -2400,8 +2401,8 @@ mod tests { ignore_platform_reqs: false, ignore_platform_req_list: vec![], repositories: std::sync::Arc::new( - mozart_registry::repository::RepositorySet::with_packagist( - mozart_registry::cache::Cache::new( + mozart_core::repository::repository::RepositorySet::with_packagist( + mozart_core::repository::cache::Cache::new( std::env::temp_dir().join("mozart-test-cache"), false, ), @@ -2430,8 +2431,8 @@ mod tests { composer_json, include_dev: false, repositories: std::sync::Arc::new( - mozart_registry::repository::RepositorySet::with_packagist( - mozart_registry::cache::Cache::new( + mozart_core::repository::repository::RepositorySet::with_packagist( + mozart_core::repository::cache::Cache::new( std::env::temp_dir().join("mozart-test-cache"), false, ), diff --git a/crates/mozart/src/commands/validate.rs b/crates/mozart/src/commands/validate.rs index 873b371..853eb2b 100644 --- a/crates/mozart/src/commands/validate.rs +++ b/crates/mozart/src/commands/validate.rs @@ -337,7 +337,7 @@ fn check_lock_freshness( return; } - match mozart_registry::lockfile::LockFile::read_from_file(&lock_path) { + match mozart_core::repository::lockfile::LockFile::read_from_file(&lock_path) { Ok(lock) => { if !lock.is_fresh(composer_json_content) { lock_errors.push( @@ -578,7 +578,7 @@ mod tests { #[test] fn test_check_lock_freshness_fresh_lock() { - use mozart_registry::lockfile::LockFile; + use mozart_core::repository::lockfile::LockFile; use tempfile::tempdir; let dir = tempdir().unwrap(); @@ -614,7 +614,7 @@ mod tests { #[test] fn test_check_lock_freshness_stale_lock() { - use mozart_registry::lockfile::LockFile; + use mozart_core::repository::lockfile::LockFile; use tempfile::tempdir; let dir = tempdir().unwrap(); diff --git a/crates/mozart/src/composer.rs b/crates/mozart/src/composer.rs index 108a5d3..337b053 100644 --- a/crates/mozart/src/composer.rs +++ b/crates/mozart/src/composer.rs @@ -17,7 +17,7 @@ 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_registry::download_manager::DownloadManager; +use mozart_core::repository::download_manager::DownloadManager; /// Project-level Composer state. Mirrors `Composer\PartialComposer` / /// `Composer\Composer` in PHP, exposing the subset of getters command diff --git a/crates/mozart/src/factory.rs b/crates/mozart/src/factory.rs index 67fc9a3..ca46671 100644 --- a/crates/mozart/src/factory.rs +++ b/crates/mozart/src/factory.rs @@ -17,7 +17,7 @@ use mozart_core::composer::{ use mozart_core::config::resolve_references; use mozart_core::factory::create_config; use mozart_core::package::read_from_file; -use mozart_registry::download_manager::DownloadManager; +use mozart_core::repository::download_manager::DownloadManager; /// Rust port of `Factory::createComposer()`. /// -- cgit v1.3.1