Skip to content

Add three-layer preset system with config overlays#3

Merged
dpaluy merged 1 commit intomasterfrom
feature/preset
Nov 22, 2025
Merged

Add three-layer preset system with config overlays#3
dpaluy merged 1 commit intomasterfrom
feature/preset

Conversation

@dpaluy
Copy link
Copy Markdown
Owner

@dpaluy dpaluy commented Nov 22, 2025

Summary

  • Implements comprehensive three-layer preset system (builtin → user → preset)
  • Adds CLI flags --preset NAME and --default for preset selection and non-interactive defaults
  • Enables users to define custom configuration overlays for different Rails app types (API-only, minimal, etc.)
  • Includes shipped presets: default.yaml (PostgreSQL + Tailwind + Importmap) and api-only.yaml

Key Features

  • Config-overlay schema with id-based merging for questions and post_actions
  • Preset resolution: user presets override built-in gem presets
  • Support for both interactive and non-interactive modes with presets
  • Proper error handling: explicit --preset raises on missing file, --default silently falls back
  • CLI error handling fix: Changed UndefinedCommandError → Thor::UndefinedCommandError

Architecture Changes

  • Config.load now accepts preset_path parameter for flexible preset resolution
  • CLI preset resolution checks ~/.config/railstart/presets/ first, then falls back to gem presets
  • Generator modes respect preset overlays for both use_defaults and interactive flows
  • Always confirms generation before execution (even in --default mode)

Changes

  • New preset config files (2 shipped presets)
  • Enhanced CLI with preset flags and resolution logic
  • Updated Config class with deep merging support
  • Updated Generator with preset overlay support
  • Comprehensive test coverage for preset merging and behavior
  • Version bump: 0.1.0 → 0.2.0
  • Updated README with preset examples and architecture documentation

Test plan

  • All RuboCop linting checks pass (17 files inspected, no offenses)
  • All 30 tests pass with 80 assertions
  • Preset overlay merging validated (test_preset_overlay_merges_on_top_of_user_config)
  • End-to-end preset behavior verified (test_preset_changes_generator_default_behavior)
  • Manual testing of --preset and --default flags completed

@dpaluy dpaluy force-pushed the feature/preset branch 2 times, most recently from e6729e3 to 66b5be1 Compare November 22, 2025 21:20
Add comprehensive preset support allowing users to define custom
configuration overlays for different Rails app types (API-only,
minimal, etc.).

Key Features:
- Three-layer config merging: builtin → user → preset
- CLI flags: --preset NAME and --default
- Preset resolution: user presets override built-in gem presets
- Config-overlay schema (questions/post_actions merged by id)
- Both interactive and non-interactive modes with presets

Architecture:
- Config.load now accepts preset_path parameter
- CLI preset resolution checks ~/.config/railstart/presets/ first,
  then falls back to gem's config/presets/
- Generator modes respect preset overlays for both use_defaults
  and interactive flows
- Proper error handling: explicit --preset raises on missing file,
  --default silently falls back to builtin config

Shipped Presets:
- config/presets/default.yaml (PostgreSQL + Tailwind + Importmap)
- config/presets/api-only.yaml (PostgreSQL + API mode + skip features)

Tests:
- test_preset_overlay_merges_on_top_of_user_config validates merge precedence
- test_preset_changes_generator_default_behavior validates end-to-end behavior
- All tests pass (30 runs, 80 assertions, 0 failures)

Fixes:
- CLI: Changed UndefinedCommandError → Thor::UndefinedCommandError
- Generator: Always confirms before generation (even in --default mode)
- Config: Proper deep merging with id-based array merging

Documentation:
- Updated README with preset examples and architecture
- Added preset usage modes and configuration guide
- Documented three-layer config system

Version: 0.1.0 → 0.2.0
@dpaluy dpaluy merged commit 7aed07a into master Nov 22, 2025
1 check passed
@dpaluy dpaluy deleted the feature/preset branch November 22, 2025 21:55
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