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 |
def generator_options | ||
options = { api: !!Rails.application.config.api_only, update: true } | ||
|
||
unless defined?(ActiveRecord) |
rafaelfranca
Jul 4, 2017
Member
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?
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?
y-yagi
Jul 4, 2017
Author
Member
It makes sense. I updated to check railties.
It makes sense. I updated to check railties.
I dig this! Simple, clean. Got 2 things, then |
end | ||
|
||
options | ||
end |
kaspth
Jul 15, 2017
Member
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.
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.
@@ -1,3 +1,7 @@ | |||
* Do not generate unused components contents in `app:update` task. |
kaspth
Jul 15, 2017
Member
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.
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 |
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.
Thank you for review! I fixed. |
Nice! |
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.