From 8ecb8e5ea476886cb3f62a8efa4a8189e2aa4740 Mon Sep 17 00:00:00 2001 From: nsfisis Date: Sat, 21 Feb 2026 11:18:26 +0900 Subject: feat(autoload): generate Composer-compatible PHP autoloader files Implement autoloader generation that produces all standard Composer autoloader files (autoload.php, autoload_real.php, autoload_static.php, autoload_psr4.php, autoload_namespaces.php, autoload_classmap.php, autoload_files.php, installed.php) plus embeds ClassLoader.php, InstalledVersions.php, and LICENSE from the Composer submodule. Wire into the install command (gated by --no-autoloader) and replace the todo!() in dump-autoload with a working implementation. Co-Authored-By: Claude Opus 4.6 --- crates/mozart/src/commands/dump_autoload.rs | 30 +++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) (limited to 'crates/mozart/src/commands/dump_autoload.rs') diff --git a/crates/mozart/src/commands/dump_autoload.rs b/crates/mozart/src/commands/dump_autoload.rs index cd932b0..ff3dfc2 100644 --- a/crates/mozart/src/commands/dump_autoload.rs +++ b/crates/mozart/src/commands/dump_autoload.rs @@ -1,4 +1,5 @@ use clap::Args; +use std::path::PathBuf; #[derive(Args)] pub struct DumpAutoloadArgs { @@ -47,6 +48,31 @@ pub struct DumpAutoloadArgs { pub strict_ambiguous: bool, } -pub fn execute(_args: &DumpAutoloadArgs, _cli: &super::Cli) -> anyhow::Result<()> { - todo!() +pub fn execute(args: &DumpAutoloadArgs, cli: &super::Cli) -> anyhow::Result<()> { + let working_dir = match &cli.working_dir { + Some(dir) => PathBuf::from(dir), + None => std::env::current_dir()?, + }; + + let vendor_dir = working_dir.join("vendor"); + let dev_mode = !args.no_dev; + + // Determine suffix: read from existing autoload.php, or from lock file, or generate + let suffix = crate::autoload::determine_suffix(&working_dir, &vendor_dir)?; + + if args.dry_run { + eprintln!("Dry run: would generate autoload files"); + return Ok(()); + } + + crate::autoload::generate(&crate::autoload::AutoloadConfig { + project_dir: working_dir, + vendor_dir, + dev_mode, + suffix, + })?; + + eprintln!("Generated autoload files"); + + Ok(()) } -- cgit v1.3.1