From 40bd784824dc5f40e22908ff35d4ae693696ba89 Mon Sep 17 00:00:00 2001 From: nsfisis Date: Mon, 23 Feb 2026 01:11:23 +0900 Subject: fix(depends): prefer installed packages over lockfile and add platform support Without --locked, prefer vendor/composer/installed.json over composer.lock to match Composer's data source priority. Add platform packages (php, ext-*, lib-*) from detect_platform() so queries like `depends php` work. Show a specific error message when a platform package is not found. Co-Authored-By: Claude Opus 4.6 --- crates/mozart/src/commands/dependency.rs | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) (limited to 'crates/mozart/src/commands/dependency.rs') diff --git a/crates/mozart/src/commands/dependency.rs b/crates/mozart/src/commands/dependency.rs index 5073be0..f2856d9 100644 --- a/crates/mozart/src/commands/dependency.rs +++ b/crates/mozart/src/commands/dependency.rs @@ -59,12 +59,35 @@ pub fn load_packages(working_dir: &Path, locked: bool) -> Result = if locked || lock_path.exists() { + let mut packages: Vec = if locked { load_from_lockfile(&lock_path)? } else { - load_from_installed(working_dir)? + let installed = load_from_installed(working_dir); + match installed { + Ok(pkgs) if !pkgs.is_empty() => pkgs, + _ => { + if lock_path.exists() { + load_from_lockfile(&lock_path)? + } else { + vec![] + } + } + } }; + // Add platform packages (php, ext-*, lib-*, composer-*-api) + let platform = mozart_core::platform::detect_platform(); + for pp in &platform { + packages.push(PackageInfo { + name: pp.name.clone(), + version: pp.version.clone(), + require: BTreeMap::new(), + require_dev: BTreeMap::new(), + conflict: BTreeMap::new(), + is_root: false, + }); + } + // Add the root package (composer.json) as a synthetic entry if composer_json_path.exists() && let Ok(root) = mozart_core::package::read_from_file(&composer_json_path) -- cgit v1.3.1