aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/mozart/src/commands/config_helpers.rs
AgeCommit message (Collapse)Author
2026-05-09refactor(composer): move Composer and Factory from mozart-core to mozartnsfisis
Composer needs DownloadManager (from mozart-registry), but mozart-core sits below mozart-registry in the dependency graph — adding the field would create a dependency cycle. Moving Composer and create_composer to the mozart CLI crate breaks the cycle and lets the root state container hold a DownloadManager. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-09fix(config): align with Composer's ConfigCommand pipelinensfisis
- A1: stub auth keys (bitbucket-oauth.X etc.) with actionable error - A2: audit.ignore / audit.ignore-abandoned writers with --json/--merge - A3: scripts.X writer (scalar vs array) and --unset support - A4: top-level --unset fallback for unknown single-segment keys - A5: bare --unset extra / suggest / audit support - A6/A13: disable-tls enable/disable user-visible messages - A7: editor fallback chain (editor/vim/vi/nano/pico/ed) - A8: --editor --auth opens auth.json - A9: silent exit 0 when no setting-key and no --list - A10: cache-files-maxsize regex validation - A11: cafile/capath existence check + "null" clearing - A14: merge_json_values object merge uses existing-wins (PHP `+`) - A16: repositories.<name>.url sub-path support - A17: wording "cannot" → "can not" to match Composer exactly - A19: add_repository normalizes assoc repos, injects name field, strips stale disable entries Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-08fix(repository): align with Composer's RepositoryCommand pipelinensfisis
Introduce JsonConfigSource in mozart-core mirroring Composer's JsonConfigSource fallback logic (add/insert/set-url/remove repository), and BaseConfigContext mirroring BaseConfigCommand's initialize(). Key behaviour fixes: - list: synthesise [packagist.org] <disabled> only when no composer-type repo with a packagist.org host is present (was: always show enabled default) - disable: idempotent via add_repository(false) matching Composer's branch; now requires a name (no silent default to packagist.org) - enable: calls remove_repository only, no extra empty-array cleanup - set-url: preserves assoc-keyed format instead of converting to list - get-url: assoc fast-path + unquoted error message matching Composer - add: use regex pre-check (starts_with '{') instead of trial-parse - error messages reworded to match Composer verbatim (mozart brand kept) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-05refactor(commands): consolidate working_dir resolution into Cli methodnsfisis
2026-05-05feat(core): add Composer struct mirroring requireComposer/tryComposernsfisis
Introduce mozart_core::composer::Composer with require()/try_load() constructors and a config() accessor, modelled on PHP Composer's BaseCommand::requireComposer / tryComposer. ComposerConfig and composer_home move into mozart-core so Composer::load can resolve placeholders consistently. Migrate dump-autoload, archive, exec and run-script away from ad-hoc composer.json reads. exec and run-script now fail when composer.json is missing instead of silently falling back to "vendor/bin", matching the upstream requireComposer contract. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-04feat(http): honor config.cafile and config.capathnsfisis
Composer's config.cafile/config.capath were accepted by the config command but ignored by every HTTP request. Centralize reqwest client construction in mozart_core::http, pre-load the configured CA bundle at startup, and route every callsite (registry, vcs drivers, diagnose, self-update) through the shared builder so user-supplied roots are actually used during HTTPS verification.
2026-02-23fix(repository): support Composer's associative-key repo formatnsfisis
Composer stores repositories as {"name": {"type":...}} while Mozart only understood [{"name":"name","type":...}]. This adds normalization so Mozart can read both formats for list, get-url, set-url, and remove. Also distinguishes "no URL" from "not found" in get-url errors. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-23fix(global): add ~/.composer fallback, XDG auto-detection, and no-arg handlingnsfisis
Rewrite composer_home() with Composer-compatible resolution: detect XDG environment (any XDG_* var or /etc/xdg), prefer existing directories, and fall back to ~/.composer for legacy systems. Consolidate duplicate composer_home_dir() from global.rs into shared config_helpers. Accept no subcommand gracefully with a helpful error instead of a parse error. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-23fix(config): add missing keys, implement --absolute, fix output formatnsfisis
Add 18 missing config keys to config_value_type() including cache-read-only (was in defaults but unmanageable), audit.* dotted keys, and bool-or-enum keys like store-auths and bump-after-update. Implement --absolute flag to resolve *-dir values to absolute paths. Fix render_value() to JSON-encode arrays and use lowercase "null", matching Composer output. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-22feat(repository): implement repository command with all actionsnsfisis
Extract shared helpers (composer_home, read/write_json_file, add/remove_repository, render_value) from config.rs into config_helpers.rs module. Implement all 7 repository actions: list, add, remove, set-url, get-url, disable, enable with --append/--before/--after positioning support. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>