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
Do not generate unused components contents in app:update
task
#29645
Do not generate unused components contents in app:update
task
#29645
Conversation
r? @matthewd (@rails-bot has picked a reviewer for you, use r? to override) |
Didn't we fix this with the |
Currently, |
@kaspth we talked about it.. I think there might be an unmerged PR? IIRC I wasn't excited about adding an extra top-level file for such a rare consideration (plus the potential confusion if you've added/removed a component since the initial generate), so this does seem potentially interesting to me. |
Probably I think that it is about #22790 |
d892854
to
c865916
Compare
railties/lib/rails/app_updater.rb
Outdated
def generator_options | ||
options = { api: !!Rails.application.config.api_only, update: true } | ||
|
||
unless defined?(ActiveRecord) |
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.
Can we make the assumption that if ActiveRecord
is defined we are loading Active Record? I don't think this is true since a gem can define this constant. Maybe we should check for the railties?
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 makes sense. I updated to check railties.
e5af918
to
32ef54d
Compare
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 dig this! Simple, clean. Got 2 things, then 👍
railties/lib/rails/app_updater.rb
Outdated
end | ||
|
||
options | ||
end |
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.
Maybe we should condense these:
def generator_options
options = { api: !!Rails.application.config.api_only, update: true }
options[:skip_active_record] = !defined?(ActiveRecord::Railtie)
options[:skip_action_mailer] = !defined?(ActionMailer::Railtie)
options[:skip_action_cable] = !defined?(ActionCable::Engine)
options[:skip_sprockets] = !defined?(Sprockets::Railtie)
options[:skip_puma] = !defined?(Puma)
options
end
or even just make it a standard hash definition.
railties/CHANGELOG.md
Outdated
@@ -1,3 +1,7 @@ | |||
* Do not generate unused components contents in `app:update` task. |
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.
Let's flesh this out a bit more. How about:
* Skip unused components when running `bin/rails app:update`
If the initial app generation skipped Action Cable, Active Record etc.,
the update task honors those skips too.
Right, #22790 was what I was thinking of — and I was sure we had merged that. But this is far simpler 👍 |
32ef54d
to
dbe42a2
Compare
Currently, `app:update` generates all contents regardless of the component using in application. For example, even if not using Action Cable, `app:update` will generate a contents related to Action Cable. This is a little inconvenient. This PR checks the existence of the component and does not generate unnecessary contents. Can not check all options in this way. However, it will be able to prevent the generation of unnecessary files.
dbe42a2
to
5803640
Compare
Thank you for review! I fixed. |
Nice! |
I wish this would honor the |
Currently,
app:update
generates all contents regardless of the component using in application.For example, even if not using Action Cable,
app:update
will generate a contents related to Action Cable. This is a little inconvenient.This PR checks the existence of the component and does not generate unnecessary contents.
Can not check all options in this way. However, it will be able to prevent the generation of unnecessary files.