-
Notifications
You must be signed in to change notification settings - Fork 898
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
Vmdb::Plugins::AssetPath - add node_modules, development_gem? #17818
Conversation
lib/vmdb/plugins/asset_path.rb
Outdated
@@ -7,6 +7,8 @@ class AssetPath | |||
attr_reader :name | |||
attr_reader :path | |||
attr_reader :namespace | |||
attr_reader :node_modules | |||
attr_reader :is_gem |
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.
Prefer gem?
over is_gem
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.
That means I need to write a method, but sure :)
I don't understand the full design of this approach ... why does knowing something is a gem or not matter? technically, they are all gems, just different sources (git vs path vs actual rubygem which we don't have yet) Can you elaborate? |
Re source = bundler_specs_by_path[engine.root.to_s].source
is_path = Bundler::Source::Path === source
is_git = Bundler::Source::Git === source
is_gem = !is_path || is_git |
Ok, as far as I know, these are the real constraints:
But.. the same goes for any ui plugin: if you're not doing any v2v development, you're likely using something like if you are doing v2v development, the paths probably looks like So.. this is my attempt to detect that. With this...
|
I don't think we can test for OTOH if you check out that repo manually, you probably intend to be running things there. |
Updated to use |
Reasons we can't do this for what we now call development gems:
So.. either this only needs to happen for gems where people won't be doing local changes, |
lib/vmdb/plugins.rb
Outdated
source = bundler_specs_by_path[engine.root.to_s].source | ||
is_path = Bundler::Source::Path === source | ||
is_git = Bundler::Source::Git === source | ||
development_gem = !is_path || is_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.
So, I think I see what you are trying to do, but I think we should go about it differently. From what I can tell you are concerned with just not infecting gems when they live in the Bundler owned gems directory (whether real gem or a git based gem).
So, this can easily be handled by seeing if the plugins path is in bundler's install path. This code should do:
in_bundler_gems = engine.root.expand_path.to_s.start_with?(Bundler.install_path.expand_path.to_s)
AssetPath.new(engine, in_bundler_gems) if AssetPath.asset_path?(engine)
Then down below:
@node_modules = in_bundler_gems ? Pathname.new("/tmp/test/#{@namespace}/node_modules") : @path.join('node_modules')
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.
Aaah, yeah that might be better, definitely seems like this involves less poking inside bundler's ..insides :).
Updating.
Ok, so looks like we may have the right way of determining which packages should be treated which way. So for the path then... does I'm not sure With the last change:
|
vendor sounds perfect. I am going to merge this. |
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 can you just squash the commits, and then this is good to go.
lib/vmdb/plugins.rb
Outdated
@@ -77,7 +77,11 @@ def provider_plugins | |||
def asset_paths | |||
@asset_paths ||= begin | |||
require_relative 'plugins/asset_path' | |||
map { |engine| AssetPath.new(engine) if AssetPath.asset_path?(engine) }.compact | |||
map do |engine| | |||
in_bundler_gems = engine.root.expand_path.to_s.start_with?(Bundler.install_path.expand_path.to_s) |
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.
Minor, but this logic can live right in the AssetPath class...then you don't need to modify the params to initialize. Since the information comes from the engine itself, and we are already passing the engine in, then it's not a problem for it to be in there.
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.
Makes sense 👍
…e_root AssetPath now knows about the path and name of each engine But to move node_modules outside of gem directories, we also need to know whether the developer will be doing chances in that particular engine or not - `#development_gem?` assumes anything installed in bundler gems will not get modified. This will enable the ui tasks to use a different node_modules path for gems, no longer polluting the gem dir. Non-development gems will use `manageiq/vendor/node_root/<engine name>/node_modules`, while anything *not* in bundler gems will end up with `node_modules` inside that engine's root. This only provides the info to the appropriate ui rake tasks.
Perfect, thanks! :) Squashed now.. |
Checked commit https://github.com/himdel/manageiq/commit/34a016a7cbef35316499a9cb4800948e1ffa629d with ruby 2.3.3, rubocop 0.52.1, haml-lint 0.20.0, and yamllint 1.10.0 |
AssetPath now knows about the path and name of each engine.
But to move node_modules outside of gem directories, we also need to know whether the engine is a gem or not, and need to compute the path to node_modules accordingly.
This (together with ManageIQ/manageiq-ui-classic#4435) will enable the ui tasks to use a different node_modules path for gems, no longer polluting the gem dir.
Cc @Fryguy
@miq-bot add_label wip
There are currently two TODO items on this side:
is_gem
- I'm not quite sure matching the pathname againstbundler/gems
is the right way of telling/tmp/test/@namespace/node_modules
may not be the most universal place for these