-
Notifications
You must be signed in to change notification settings - Fork 2
Description
Slightly ambitious, should be interesting. Rough approach:
- Parse the generator classes (probably best to use something like https://github.com/rubocop/rubocop-ast / https://github.com/whitequark/parser, so yes, we'll probably add Ruby here)
- Output generator React files (at least a starter template. Since we add Ruby previously, may as well use thor)
Example generator classes:
- https://github.com/rails/rails/blob/main/railties/lib/rails/generators/rails/model/model_generator.rb
- https://github.com/rails/rails/blob/main/railties/lib/rails/generators/rails/controller/controller_generator.rb
- https://github.com/rails/rails/blob/main/railties/lib/rails/generators/rails/migration/migration_generator.rb
We should be able to extract the argument
and class_options
and generate some generic components in React. There will be some that we want special logic (e.g. in [migrations](- https://github.com/rails/rails/blob/main/railties/lib/rails/generators/rails/migration/migration_generator.rb
) there is an argument: :attributes, type: :array...
which we could use to insert the AttributeArguments
component) but those can be edited manually.
There's also some intricacy to how some generators hook into others, which I haven't quite figured out yet e.g. there's a lot more logic relating to the model/migration's attributes. I'm guessing it invokes the ActiveRecord Model Generator)