From af0df92e1ecc82823a510646b7545278caeac4b8 Mon Sep 17 00:00:00 2001 From: nsfisis Date: Tue, 24 Feb 2026 00:23:30 +0900 Subject: feat(cache): enable repo cache for all Packagist API calls Remove the Option wrapper from repo_cache in ResolveRequest, LockFileGenerationRequest, and fetch_package_versions. All commands now initialize a Cache via build_cache_config(cli.no_cache), ensuring Packagist metadata is cached to disk (respecting --no-cache flag). Co-Authored-By: Claude Opus 4.6 --- crates/mozart/src/commands/outdated.rs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'crates/mozart/src/commands/outdated.rs') diff --git a/crates/mozart/src/commands/outdated.rs b/crates/mozart/src/commands/outdated.rs index 09e36a9..4d0226d 100644 --- a/crates/mozart/src/commands/outdated.rs +++ b/crates/mozart/src/commands/outdated.rs @@ -102,6 +102,9 @@ 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); + // Validate mutually exclusive level filters let level_count = args.major_only as u8 + args.minor_only as u8 + args.patch_only as u8; if level_count > 1 { @@ -172,7 +175,7 @@ pub async fn execute( } // Fetch latest version from Packagist - let latest = match fetch_latest_version(&pkg.name).await { + let latest = match fetch_latest_version(&pkg.name, &repo_cache).await { Ok(v) => v, Err(_) => { // Skip packages we can't fetch (platform packages, private, etc.) @@ -323,11 +326,14 @@ fn load_locked_packages(working_dir: &Path, no_dev: bool) -> anyhow::Result anyhow::Result { +async fn fetch_latest_version( + name: &str, + repo_cache: &mozart_registry::cache::Cache, +) -> anyhow::Result { use mozart_core::package::Stability; use mozart_registry::version::find_best_candidate; - let versions = mozart_registry::packagist::fetch_package_versions(name, None).await?; + let versions = mozart_registry::packagist::fetch_package_versions(name, repo_cache).await?; let best = find_best_candidate(&versions, Stability::Stable) .ok_or_else(|| anyhow::anyhow!("No stable version found for {name}"))?; -- cgit v1.3.1