From 9f0d210021c54f63c9984446862b6ec68834bc63 Mon Sep 17 00:00:00 2001 From: nsfisis Date: Sun, 22 Feb 2026 11:07:42 +0900 Subject: refactor(async): migrate from blocking HTTP to async/await with tokio Replace reqwest::blocking with async reqwest across the entire codebase. All command execute functions, registry API calls (packagist, downloader, resolver, lockfile), and the main entry point now use async/await with the tokio runtime. The pubgrub resolver runs on spawn_blocking since its DependencyProvider trait is synchronous, using Handle::block_on for async I/O within that context. Co-Authored-By: Claude Opus 4.6 --- crates/mozart/src/commands/create_project.rs | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'crates/mozart/src/commands/create_project.rs') diff --git a/crates/mozart/src/commands/create_project.rs b/crates/mozart/src/commands/create_project.rs index e9a1911..d5a9b06 100644 --- a/crates/mozart/src/commands/create_project.rs +++ b/crates/mozart/src/commands/create_project.rs @@ -170,7 +170,7 @@ fn is_dir_non_empty(path: &Path) -> bool { .unwrap_or(false) } -pub fn execute( +pub async fn execute( args: &CreateProjectArgs, cli: &super::Cli, console: &mozart_core::console::Console, @@ -278,7 +278,7 @@ pub fn execute( )); console.info("Loading composer repositories with package information"); - let versions = packagist::fetch_package_versions(&package_name, None)?; + let versions = packagist::fetch_package_versions(&package_name, None).await?; // Find the best candidate matching the version constraint and stability let best = if let Some(ref constraint) = version_constraint { @@ -331,7 +331,8 @@ pub fn execute( ); let bytes = - downloader::download_dist(&dist.url, dist.shasum.as_deref(), Some(&mut progress), None)?; + downloader::download_dist(&dist.url, dist.shasum.as_deref(), Some(&mut progress), None) + .await?; progress.finish(); @@ -422,7 +423,7 @@ pub fn execute( console.info("Resolving dependencies..."); - let resolved = resolver::resolve(&request).map_err(|e| { + let resolved = resolver::resolve(&request).await.map_err(|e| { mozart_core::exit_code::bail( mozart_core::exit_code::DEPENDENCY_RESOLUTION_FAILED, e.to_string(), @@ -437,7 +438,8 @@ pub fn execute( composer_json: raw.clone(), include_dev: dev_mode, repo_cache: None, - })?; + }) + .await?; // Print change report (all will be installs for a new project) let changes = super::update::compute_update_changes(None, &new_lock, dev_mode); @@ -498,7 +500,8 @@ pub fn execute( apcu_autoloader: false, apcu_autoloader_prefix: None, }, - )?; + ) + .await?; Ok(()) } -- cgit v1.3.1