From 5254a9e9b698c3618229f4f802b39a82baf9169a Mon Sep 17 00:00:00 2001 From: nsfisis Date: Tue, 5 May 2026 20:34:27 +0900 Subject: feat(core): port Factory::createConfig() as factory::create_config() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Adds crates/mozart-core/src/factory.rs with get_cache_dir(), get_data_dir(), and create_config() — a Rust port of Composer\Factory::createConfig() (auth loading and htaccess creation are out of scope for now). Also fixes a correctness bug on Linux: the previous Config::default() resolved cache-dir to $XDG_CONFIG_HOME/composer/cache via the {$home}/cache placeholder, whereas Composer uses the XDG cache base ($XDG_CACHE_HOME or ~/.cache), giving ~/.cache/composer. Callers updated: - Composer::load() uses create_config() as the global baseline before merging project-level config. - config command execute_read() builds the global baseline with create_config() and overlays local config on top when not --global, matching Composer's actual layering order. Co-Authored-By: Claude Sonnet 4.6 --- crates/mozart-core/src/composer.rs | 3 ++- 1 file changed, 2 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 76427a7..2e252c6 100644 --- a/crates/mozart-core/src/composer.rs +++ b/crates/mozart-core/src/composer.rs @@ -12,6 +12,7 @@ use std::collections::BTreeMap; use std::path::{Path, PathBuf}; use crate::config::{Config, resolve_references}; +use crate::factory::create_config; /// Return the Composer home directory, respecting `COMPOSER_HOME` and falling /// back to the platform default using Composer-compatible logic. @@ -109,7 +110,7 @@ impl Composer { fn load(project_dir: PathBuf, composer_json: &Path) -> anyhow::Result { let content = std::fs::read_to_string(composer_json)?; let value: serde_json::Value = serde_json::from_str(&content)?; - let mut config = Config::default(); + let mut config = create_config()?; if let Some(cfg_obj) = value.get("config").and_then(|v| v.as_object()) { let overrides: BTreeMap = cfg_obj .iter() -- cgit v1.3.1