Skip to content

Replace settings.json with global ~/.pv/pv.yml#32

Merged
munezaclovis merged 3 commits intomainfrom
replace-settings-json-with-pv-yml
Mar 9, 2026
Merged

Replace settings.json with global ~/.pv/pv.yml#32
munezaclovis merged 3 commits intomainfrom
replace-settings-json-with-pv-yml

Conversation

@munezaclovis
Copy link
Copy Markdown
Contributor

@munezaclovis munezaclovis commented Mar 9, 2026

Summary

  • Replaces ~/.pv/config/settings.json (JSON) with ~/.pv/pv.yml (YAML), consolidating user-facing config into one format that mirrors per-project pv.yml
  • Settings now nest under a defaults key — GlobalPHP becomes Defaults.PHP, TLD becomes Defaults.TLD
  • Existing users are migrated transparently: LoadSettings() reads old settings.json, writes pv.yml, and removes the JSON file

The resulting global config:

defaults:
    php: "8.4"
    tld: test

Test plan

  • All 22 test packages pass (go test ./...)
  • New test: TestLoadSettings_MigratesFromJSON verifies JSON → YAML migration and old file cleanup
  • New test: TestSettings_SaveAndLoad_WithPHP verifies PHP field round-trips through YAML
  • Existing settings tests updated for new struct shape
  • Manual: verify pv install / pv setup writes ~/.pv/pv.yml correctly
  • Manual: verify existing settings.json gets migrated on first command

Consolidate user-facing config into YAML, matching the per-project pv.yml
format. The global pv.yml uses a `defaults` key for TLD and PHP version:

    defaults:
      php: '8.4'
      tld: test

- Settings struct now nests under Defaults (Defaults.TLD, Defaults.PHP)
- Transparent migration: LoadSettings() reads old settings.json on first
  load, writes pv.yml, and removes the JSON file
- SettingsPath() moves from ~/.pv/config/settings.json to ~/.pv/pv.yml
- All callers updated (18 files across cmd/, internal/)
- Drop migrateOrDefault() and oldSettingsPath() entirely (v0.0.1, no
  backwards compat needed)
- LoadSettings() now returns defaults when pv.yml is missing, errors
  on corrupt YAML
- Save() validates TLD before writing — invalid state can never be
  persisted
- Save() defaults empty TLD to "test" before validation
- New tests: corrupt YAML returns error, Save() rejects invalid TLD,
  Save() defaults empty TLD
- Remove migration test and encoding/json import
- Update E2E scripts to check ~/.pv/pv.yml instead of ~/.pv/config/settings.json
- Propagate LoadSettings() error in install.go instead of silently falling back to defaults
- Update README directory tree to show pv.yml at ~/.pv/ root
@munezaclovis munezaclovis merged commit ccbca6c into main Mar 9, 2026
1 check passed
@munezaclovis munezaclovis deleted the replace-settings-json-with-pv-yml branch March 9, 2026 03:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant