-
Notifications
You must be signed in to change notification settings - Fork 62
Add generator for all components #289
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
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.
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.
stephannv
left a comment
There was a problem hiding this 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| |
There was a problem hiding this comment.
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".
There was a problem hiding this comment.
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" |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
I was getting a segmentation fault when running the tests on head
* 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
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.