diff options
| author | nsfisis <nsfisis@gmail.com> | 2026-05-08 20:06:29 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2026-05-08 20:06:29 +0900 |
| commit | b286af9ffe78d50b63bf5fda7fc796ab20f2552f (patch) | |
| tree | 3b3cb80e790aaa6b457cfeca1e7efab7126e016a /crates/mozart-core/src/composer.rs | |
| parent | 5cb8fc4e306970764e84bb850da2c56f844c3b12 (diff) | |
| download | php-mozart-b286af9ffe78d50b63bf5fda7fc796ab20f2552f.tar.gz php-mozart-b286af9ffe78d50b63bf5fda7fc796ab20f2552f.tar.zst php-mozart-b286af9ffe78d50b63bf5fda7fc796ab20f2552f.zip | |
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 <warning> 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) <noreply@anthropic.com>
Diffstat (limited to 'crates/mozart-core/src/composer.rs')
| -rw-r--r-- | crates/mozart-core/src/composer.rs | 26 |
1 files changed, 25 insertions, 1 deletions
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<LocalPackage>, + /// 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<bool>, } impl LocalRepository { pub fn new(packages: Vec<LocalPackage>) -> 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<LocalPackage>, dev_mode: Option<bool>) -> Self { + Self { packages, dev_mode } } /// Mirror of `WritableRepositoryInterface::getCanonicalPackages` — @@ -233,6 +249,14 @@ impl LocalRepository { pub fn canonical_packages(&self) -> impl Iterator<Item = &LocalPackage> { 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<bool> { + self.dev_mode + } } /// Mirror of `Composer\Repository\RepositoryManager`. Today only the |
