Skip to content

Conversation

@cirdes
Copy link
Collaborator

@cirdes cirdes commented May 10, 2025

Add a new generator that allows users to generate all components at once using the command bin/rails g ruby_ui:component:all.

This makes it easier for users who want to install the complete set of components without having to run individual commands for each component.

In my notebook, it's tanking 1m 3s to generate all components. We can improve this but i tried to keep the same approach as the component generator to make it easier to maintain.

cirdes added 3 commits May 10, 2025 18:34
Add a new generator that allows users to generate all components at once
using the command `bin/rails g ruby_ui:component:all`.

This makes it easier for users who want to install the complete set of
components without having to run individual commands for each component.

In my notebook, it's tanking 1m 3s to generate all components. We can improve
this but i tried to keep the same approach as the component generator to
make it easier to maintain.
@cirdes cirdes requested a review from stephannv May 11, 2025 15:56
cirdes added a commit to ruby-ui/web that referenced this pull request May 11, 2025
Verify_components.yml workflow ensures components are properly generated
ruby-ui/ruby_ui#289 should be merged first

Button, Checkbox, Link, Separator, TableFooter, TableRow components were
out of sync with ruby_ui.
Copy link
Contributor

@stephannv stephannv left a comment

Choose a reason for hiding this comment

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

LGTM!

def generate_components
say "Generating all components..."

Dir.children(self.class.source_root).each do |folder_name|
Copy link
Contributor

Choose a reason for hiding this comment

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

If you do something like Dir.glob("path/to/ruby_ui/*/") you will get ruby_ui folders, then you won't need to do next if folder_name == "base.rb".

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It started to return the full path. I decided to check if the string ends_with?(".rb") to make it more generic and robust

folder_name: /Users/cirdes/Workspace/ruby-ui/ruby_ui/lib/ruby_ui/accordion/

next if folder_name == "base.rb"

component_name = folder_name.camelize
run "bin/rails generate ruby_ui:component #{component_name} --force true"
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure if this should be --force true by default since it is an irreversible action if the overwritten files are not in git.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@stephannv , good point. I have changed it to be an option with default: false now

cirdes added 2 commits May 12, 2025 19:01
I was getting a segmentation fault when running the tests on head
@cirdes cirdes merged commit 1a21bdb into main May 12, 2025
2 checks passed
@cirdes cirdes deleted the cirdes/all-generator branch May 12, 2025 22:07
cirdes added a commit to ruby-ui/web that referenced this pull request May 12, 2025
* Add verify_components.yml workflow

Verify_components.yml workflow ensures components are properly generated
ruby-ui/ruby_ui#289 should be merged first

Button, Checkbox, Link, Separator, TableFooter, TableRow components were
out of sync with ruby_ui.

* add endline
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.

3 participants