-
Notifications
You must be signed in to change notification settings - Fork 357
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
Better inflector support for ui rake tasks and asset plugins #3986
Better inflector support for ui rake tasks and asset plugins #3986
Conversation
Thanks @NickLaMuro, once (if?) merged, I'll add this to the "backport the necessary webpack/engine switching bits to gaprindashvili" PR :). |
lib/tasks/manageiq/ui_tasks.rake
Outdated
all_engines = Rails::Engine.subclasses.each_with_object({}) do |engine, acc| | ||
acc[engine] = engine.root.realpath.to_s | ||
end | ||
@asset_engines ||= begin do |
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.
looks like begin do
is not a thing ;)
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.
@himdel heh, looks like #smugNickisSmug got cocky a little to early. Didn't test with that change... go figure it is the one that breaks (facepalm).
Will push a chance in a second.
8b3d1ae
to
897ccdb
Compare
Loads the lib/vmdb/inflections.rb file from the main app to inject the inflectors into tasks that aren't loading the entire Rails environment. Allows the inflectors to be evaluated without loading the entire Rails environment, which causes issues when compiling assets in the appliance build. This gets ride of the gross hardcoding business of the ManageIQ inflector that was done previously as a stopgap.
Adds a task to load inflectors from asset engines that define them. This assumes the convention of `config/initializers/inflectors.rb` being the path where the we set the inflectors in our plugins.
This is now getting called a few times when doing something `update:ui`, so memoize it so we limit the number of filesystem checks we do.
897ccdb
to
ba77c31
Compare
Checked commits NickLaMuro/manageiq-ui-classic@40b76be~...ba77c31 with ruby 2.3.3, rubocop 0.52.1, haml-lint 0.20.0, and yamllint 1.10.0 |
I am good with this for now, but I think it would be preferable if this lived in the core repo in some way. Perhaps |
v2v is also bringing assets - they're using the asset pipeline for css (but Webpack 5 should have sane support for non-javascript packs, so maybe that will go away) |
Not backported as part of #4071, but after that one gets in gaprindashvili, this one will backport cleanly. So.. adding This will only be useful after ManageIQ/manageiq-v2v#344, right? Meaning not needed for today's build so not needing the |
@himdel yeah, that sounds right to me. |
@NickLaMuro not sure if anything changed but ... the rake task doesn't inflect as intended:
|
😭 WHYYYYYYYYYYYYY!!!1! Okay... I will try and take a look in a bit... |
Thanks! :) Just verified that --- a/lib/tasks/manageiq/ui_tasks.rake
+++ b/lib/tasks/manageiq/ui_tasks.rake
@@ -162,6 +162,9 @@ def asset_engines
end
def asset_engines_plugins_hash
+ ActiveSupport::Inflector.inflections do |inflect|
+ inflect.acronym("V2V")
+ end
asset_engines.each_with_object({}) do |(engine, path), plugin_hash|
# remove '::Engine' from the constant name, underscore it, and replace
# backslashes with dashes works just fine, so it must be something in how we load the inflectors. |
@NickLaMuro Ok, never mind... This is not ":load_asset_engine_inflectors doesn't work". Sorry for the confusion :) |
Oh, interesting. I wonder if that should be added as a dependency to that task. |
Or that :) I tried to fix this in #4205 But if this is needed for other stuff too.. |
I see, that is why I got pinged so much. Just saw that now. Will comment there. |
I waited on merging the rename thinking this fixed it, so this is a problem now that the rename has been merged. |
This better supports the
ActiveSupport::Inflectors
that are set by both the main app and any asset engines that are pulled in by thewebpack
tasks.The PR creates two new tasks in the
:ui
namespace:rake ui:load_app_inflectors
rake ui:load_asset_engine_inflectors
The first loads the inflectors from the main application, and the second pulls in any inflectors from the
asset_engines
that are present. Theasset_engine
inflector task does assume the file lives in theconfig/initializers/inflections.rb
, so that is sort of being set as the standard as part of this PR.Also, minor addition: The
asset_engines
method is now memoized. Your welcome. #smugNickIsSmugLinks
miq_v2v_ui_plugin
rename tomanageiq-v2v
, which is currently in progress: Rename to manageiq-v2v manageiq-v2v#344Steps for Testing/QA
When the aforementioned rename of
miq_v2v_ui_plugin
has completed, we should testrake update:ui
from both this repo and the main repo to confirm everything is working as expectedSpoiler! I have already done this from the main repo with these, and seems to work as expected. That said, others should do the same.