From b286af9ffe78d50b63bf5fda7fc796ab20f2552f Mon Sep 17 00:00:00 2001 From: nsfisis Date: Fri, 8 May 2026 20:06:29 +0900 Subject: fix(reinstall): align with Composer's ReinstallCommand pipeline Switch to Composer::require() for the entrypoint, drop the Mozart-only --dry-run / --no-dev flags, mirror selection inline using a port of BasePackage::packageNameToRegexp, read autoloader options from composer.config(), and route the autoload dump through composer.autoload_generator(). Empty-result and unmatched-pattern warnings now emit on stderr with markup, matching $io->writeError. Plugin/script-event dispatch and Transaction-based operation building remain TODO until the installer_executor lands. Co-Authored-By: Claude Opus 4.7 (1M context) --- crates/mozart-core/src/composer.rs | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) (limited to 'crates/mozart-core/src/composer.rs') diff --git a/crates/mozart-core/src/composer.rs b/crates/mozart-core/src/composer.rs index 66bae92..effcae4 100644 --- a/crates/mozart-core/src/composer.rs +++ b/crates/mozart-core/src/composer.rs @@ -219,11 +219,27 @@ impl LocalPackage { /// commands that walk the local install (currently: `dump-autoload`). pub struct LocalRepository { packages: Vec, + /// Mirrors `InstalledRepositoryInterface::getDevMode()`: `Some(true)` when + /// the last install ran with dev requires, `Some(false)` when run with + /// `--no-dev`, and `None` when the flag was absent (the legacy v1 + /// installed.json shape, or an in-memory repository that was never + /// hydrated from disk). Callers default to `true` on `None`, matching + /// `ReinstallCommand::execute`'s `getDevMode() ?? true`. + dev_mode: Option, } impl LocalRepository { pub fn new(packages: Vec) -> Self { - Self { packages } + Self { + packages, + dev_mode: None, + } + } + + /// Build a [`LocalRepository`] with an explicit `dev` flag taken from + /// `vendor/composer/installed.json`'s top-level `dev` field. + pub fn with_dev_mode(packages: Vec, dev_mode: Option) -> Self { + Self { packages, dev_mode } } /// Mirror of `WritableRepositoryInterface::getCanonicalPackages` — @@ -233,6 +249,14 @@ impl LocalRepository { pub fn canonical_packages(&self) -> impl Iterator { self.packages.iter() } + + /// Mirror of `InstalledRepositoryInterface::getDevMode()` — returns + /// `None` when the source `installed.json` did not record a `dev` + /// flag (e.g. legacy v1 array form). Callers should default to + /// `true` on `None`, matching PHP's `?? true` coalesce. + pub fn dev_mode(&self) -> Option { + self.dev_mode + } } /// Mirror of `Composer\Repository\RepositoryManager`. Today only the -- cgit v1.3.1