[Feature] Allow ruby_ui:component to accept multiple components

Merged
JA
5mo ago
+84-35

Description

The ruby_ui:component generator previously accepted only a single component name. This PR allows multiple component names to be passed in a single invocation:

bin/rails g ruby_ui:component Button Link Input Textarea

This also aligns the generator with the command already produced by the MCP add-command tool (get_add_command_for_items), which was already joining multiple component names into a single rails g ruby_ui:component ... command.

Changes

  • Switch the generator argument from a single string to an array, keeping single-component usage fully backward compatible.
  • Validate all component names upfront and report every missing component at once (instead of aborting on the first).
  • Run the Stimulus controllers manifest update a single time at the end, instead of once per component.
  • ruby_ui:component:all now delegates to a single generator invocation with all component folders, avoiding one Rails boot per component.
  • Add tests and a README example.

Result

โžœ  testappconverter git:(main) โœ— bin/rails g ruby_ui:component Button Link Input Textarea
Generating Button files...
Generating components
      create  app/components/ruby_ui/button/button.rb
Generating Link files...
Generating components
      create  app/components/ruby_ui/link/link.rb
Generating Input files...
Generating components
      create  app/components/ruby_ui/input/input.rb
Generating Textarea files...
Generating components
      create  app/components/ruby_ui/textarea/textarea.rb

โžœ  testappconverter git:(main) โœ— bin/rails g ruby_ui:component Button Link Input Textarea
Generating Button files...
Generating components
   identical  app/components/ruby_ui/button/button.rb
Generating Link files...
Generating components
   identical  app/components/ruby_ui/link/link.rb
Generating Input files...
Generating components
   identical  app/components/ruby_ui/input/input.rb
Generating Textarea files...
Generating components
   identical  app/components/ruby_ui/textarea/textarea.rb

Testing steps

cd gem
bundle exec rake   # tests + standardrb

Both the full test suite (217 runs, 0 failures) and StandardRB (364 files, no offenses) pass.

๐Ÿค– Generated with Claude Code


Summary by cubic

Add multi-component support to the ruby_ui:component generator to speed up bulk generation and align with the MCP add-command output.

  • New Features

    • Accept multiple component names in one command (e.g., bin/rails g ruby_ui:component Button Link Input Textarea). Backward compatible with single-name usage.
    • Validate all names upfront, report all missing together, and exit with status 1 if any are missing.
    • Update the Stimulus controllers manifest once after all copies.
    • Make ruby_ui:component:all call a single generator run with all folders to avoid repeated Rails boots.
    • Add tests and a README example.
  • Bug Fixes

    • ruby_ui:component:all now selects directories only, ignoring stray files (e.g., .DS_Store) to prevent batch aborts during validation.