Skip to content

[Feature] Allow ruby_ui:component to accept multiple components#416

Open
jacksonpires wants to merge 3 commits into
ruby-ui:mainfrom
jacksonpires:feature/component-generator-multiple-components
Open

[Feature] Allow ruby_ui:component to accept multiple components#416
jacksonpires wants to merge 3 commits into
ruby-ui:mainfrom
jacksonpires:feature/component-generator-multiple-components

Conversation

@jacksonpires

@jacksonpires jacksonpires commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

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.

Written for commit 11cf172. Summary will update on new commits.

Review in cubic

The component generator now accepts multiple component names in a single
invocation (e.g. `bin/rails g ruby_ui:component Button Link Input Textarea`),
matching the command already produced by the MCP add-command tool.

- Switch the generator argument to an array and validate all names upfront,
  reporting every missing component at once.
- Run the Stimulus manifest update a single time at the end instead of once
  per component.
- Generate all components via a single invocation in the `:all` generator.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@jacksonpires jacksonpires requested a review from cirdes as a code owner June 11, 2026 14:11

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 issues found across 4 files

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread gem/lib/generators/ruby_ui/component/all_generator.rb Outdated
Comment thread gem/lib/generators/ruby_ui/component_generator.rb Outdated
jacksonpires and others added 2 commits June 11, 2026 11:22
`validate_components!` used a bare `exit`, which in Ruby is `exit(true)` and
yields exit status 0. A failed generation therefore reported success to the
shell, so CI steps and scripts gating on the exit code treated missing-component
errors as passing runs. Use `exit 1` so the failure is observable.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The batch generator filtered out only `.rb` files, so any other non-directory
entry at the source root (e.g. a macOS `.DS_Store`) survived and was passed as
a component name. Since the names are now generated in a single invocation,
`validate_components!` would reject the whole batch and abort the entire
all-components run. Components are always directories, so select directories
only — this excludes `.rb` files, dotfiles, and any stray file at once.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

@cirdes cirdes left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm!

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.

2 participants