feat(config): register all defaults in code, shrink example config

Only the database password is truly mandatory to get started, but
config.example.json was 267 lines with 90+ options. Newcomers faced a
wall of settings with no indication of what matters.

Add registerDefaults() with all sane defaults via Viper so a minimal
config (just DB credentials) produces a fully working server. Gameplay
multipliers default to 1.0 instead of Go's zero value 0.0, which
previously zeroed out all quest rewards for minimal configs. Uses
dot-notation defaults for GameplayOptions/DebugOptions so users can
override individual fields without losing other defaults.

- Shrink config.example.json from 267 to 10 lines
- Rename full original to config.reference.json as documentation
- Simplify wizard buildDefaultConfig() from ~220 to ~12 lines
- Fix latent bug: SaveDumps default used wrong key DevModeOptions
- Add tests: minimal config, backward compat, single-field override
- Update release workflow, README, CONTRIBUTING, docker/README
This commit is contained in:
Houmgaor
2026-02-23 21:25:07 +01:00
parent 27fb0faa1e
commit 385b974adc
11 changed files with 655 additions and 494 deletions

View File

@@ -56,13 +56,9 @@ func TestBuildDefaultConfig(t *testing.T) {
t.Errorf("Database.Database = %v, want mydb", db["Database"])
}
// Check that critical sections exist
requiredKeys := []string{
"Host", "BinPath", "Language", "ClientMode", "Database",
"Sign", "API", "Channel", "Entrance", "DebugOptions",
"GameplayOptions", "Discord", "Commands", "Courses",
"SaveDumps", "Capture", "Screenshots",
}
// Wizard config is now minimal — only user-provided values.
// Viper defaults fill the rest at load time.
requiredKeys := []string{"Host", "ClientMode", "AutoCreateAccount", "Database"}
for _, key := range requiredKeys {
if _, ok := cfg[key]; !ok {
t.Errorf("missing required key %q", key)
@@ -74,7 +70,7 @@ func TestBuildDefaultConfig(t *testing.T) {
if err != nil {
t.Fatalf("failed to marshal config: %v", err)
}
if len(data) < 100 {
if len(data) < 50 {
t.Errorf("config JSON unexpectedly short: %d bytes", len(data))
}
}