-
Notifications
You must be signed in to change notification settings - Fork 4.4k
/
Copy pathlist_plugins.rb
76 lines (67 loc) · 2.29 KB
/
list_plugins.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
require "vagrant/plugin/manager"
module VagrantPlugins
module CommandPlugin
module Action
# This middleware lists all the installed plugins.
#
# This is a bit more complicated than simply listing installed
# gems or what is in the state file as installed. Instead, this
# actually compares installed gems with what the state file claims
# is installed, and outputs the appropriate truly installed
# plugins.
class ListPlugins
def initialize(app, env)
@app = app
end
def call(env)
manager = Vagrant::Plugin::Manager.instance
plugins = manager.installed_plugins
specs = Hash[
manager.installed_specs.map do |spec|
[spec.name, spec]
end
]
# Output!
if specs.empty?
env[:ui].info(I18n.t("vagrant.commands.plugin.no_plugins"))
return @app.call(env)
end
plugins.each do |plugin_name, plugin|
spec = specs[plugin_name]
next if spec.nil?
meta = ", global"
if plugin
meta = ", system" if plugin["system"]
meta = ", local" if plugin["env_local"]
end
env[:ui].info "#{spec.name} (#{spec.version}#{meta})"
env[:ui].machine("plugin-name", spec.name)
env[:ui].machine(
"plugin-version",
"#{spec.version}#{meta}",
target: spec.name)
if plugin["gem_version"] && plugin["gem_version"] != ""
env[:ui].info(I18n.t(
"vagrant.commands.plugin.plugin_version",
version: plugin["gem_version"]))
env[:ui].machine(
"plugin-version-constraint",
plugin["gem_version"],
target: spec.name)
end
if plugin["require"] && plugin["require"] != ""
env[:ui].info(I18n.t(
"vagrant.commands.plugin.plugin_require",
require: plugin["require"]))
env[:ui].machine(
"plugin-custom-entrypoint",
plugin["require"],
target: spec.name)
end
end
@app.call(env)
end
end
end
end
end