kpm 0.7.2 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/.gitignore +2 -0
- data/.rubocop.yml +138 -0
- data/Gemfile +2 -0
- data/README.adoc +144 -107
- data/Rakefile +2 -1
- data/bin/kpm +4 -2
- data/kpm.gemspec +11 -8
- data/lib/kpm.rb +3 -0
- data/lib/kpm/account.rb +268 -338
- data/lib/kpm/base_artifact.rb +33 -39
- data/lib/kpm/base_installer.rb +69 -83
- data/lib/kpm/blob.rb +29 -0
- data/lib/kpm/cli.rb +3 -1
- data/lib/kpm/coordinates.rb +10 -12
- data/lib/kpm/database.rb +94 -113
- data/lib/kpm/diagnostic_file.rb +126 -147
- data/lib/kpm/formatter.rb +76 -48
- data/lib/kpm/inspector.rb +24 -34
- data/lib/kpm/installer.rb +53 -46
- data/lib/kpm/kaui_artifact.rb +4 -3
- data/lib/kpm/killbill_plugin_artifact.rb +10 -7
- data/lib/kpm/killbill_server_artifact.rb +13 -12
- data/lib/kpm/migrations.rb +26 -11
- data/lib/kpm/nexus_helper/actions.rb +52 -9
- data/lib/kpm/nexus_helper/cloudsmith_api_calls.rb +83 -0
- data/lib/kpm/nexus_helper/github_api_calls.rb +70 -0
- data/lib/kpm/nexus_helper/nexus_api_calls_v2.rb +130 -108
- data/lib/kpm/nexus_helper/nexus_facade.rb +5 -3
- data/lib/kpm/plugins_directory.rb +9 -8
- data/lib/kpm/plugins_directory.yml +14 -173
- data/lib/kpm/plugins_manager.rb +29 -24
- data/lib/kpm/sha1_checker.rb +31 -18
- data/lib/kpm/system.rb +104 -135
- data/lib/kpm/system_helpers/cpu_information.rb +56 -55
- data/lib/kpm/system_helpers/disk_space_information.rb +60 -63
- data/lib/kpm/system_helpers/entropy_available.rb +37 -39
- data/lib/kpm/system_helpers/memory_information.rb +52 -51
- data/lib/kpm/system_helpers/os_information.rb +45 -47
- data/lib/kpm/system_helpers/system_proxy.rb +10 -10
- data/lib/kpm/tasks.rb +381 -438
- data/lib/kpm/tenant_config.rb +68 -83
- data/lib/kpm/tomcat_manager.rb +10 -8
- data/lib/kpm/trace_logger.rb +18 -16
- data/lib/kpm/uninstaller.rb +81 -14
- data/lib/kpm/utils.rb +13 -14
- data/lib/kpm/version.rb +3 -1
- data/packaging/Gemfile +2 -0
- data/pom.xml +211 -40
- data/spec/kpm/remote/base_artifact_spec.rb +20 -20
- data/spec/kpm/remote/base_installer_spec.rb +35 -34
- data/spec/kpm/remote/cloudsmith_api_calls_spec.rb +40 -0
- data/spec/kpm/remote/github_api_calls_spec.rb +40 -0
- data/spec/kpm/remote/installer_spec.rb +80 -79
- data/spec/kpm/remote/kaui_artifact_spec.rb +7 -6
- data/spec/kpm/remote/killbill_plugin_artifact_spec.rb +25 -30
- data/spec/kpm/remote/killbill_server_artifact_spec.rb +17 -16
- data/spec/kpm/remote/migrations_spec.rb +12 -11
- data/spec/kpm/remote/nexus_facade_spec.rb +32 -28
- data/spec/kpm/remote/tenant_config_spec.rb +30 -29
- data/spec/kpm/remote/tomcat_manager_spec.rb +4 -3
- data/spec/kpm/unit/actions_spec.rb +52 -0
- data/spec/kpm/unit/base_artifact_spec.rb +19 -18
- data/spec/kpm/unit/cpu_information_spec.rb +67 -0
- data/spec/kpm/unit/disk_space_information_spec.rb +47 -0
- data/spec/kpm/unit/entropy_information_spec.rb +36 -0
- data/spec/kpm/unit/formatter_spec.rb +163 -0
- data/spec/kpm/unit/inspector_spec.rb +34 -42
- data/spec/kpm/unit/installer_spec.rb +7 -6
- data/spec/kpm/unit/memory_information_spec.rb +102 -0
- data/spec/kpm/unit/os_information_spec.rb +38 -0
- data/spec/kpm/unit/plugins_directory_spec.rb +38 -22
- data/spec/kpm/unit/plugins_manager_spec.rb +62 -66
- data/spec/kpm/unit/sha1_checker_spec.rb +107 -60
- data/spec/kpm/unit/uninstaller_spec.rb +118 -72
- data/spec/kpm/unit_mysql/account_spec.rb +127 -142
- data/spec/spec_helper.rb +20 -18
- data/tasks/package.rake +18 -18
- metadata +42 -22
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require_relative 'actions'
|
2
4
|
module KPM
|
3
5
|
module NexusFacade
|
@@ -11,10 +13,10 @@ module KPM
|
|
11
13
|
|
12
14
|
class RemoteFactory
|
13
15
|
class << self
|
14
|
-
def create(overrides, ssl_verify=true, logger=nil)
|
15
|
-
Actions.new(overrides, ssl_verify,logger || NexusFacade.logger)
|
16
|
+
def create(overrides, ssl_verify = true, logger = nil)
|
17
|
+
Actions.new(overrides, ssl_verify, logger || NexusFacade.logger)
|
16
18
|
end
|
17
19
|
end
|
18
20
|
end
|
19
21
|
end
|
20
|
-
end
|
22
|
+
end
|
@@ -1,30 +1,31 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'open-uri'
|
2
4
|
require 'yaml'
|
3
5
|
|
4
6
|
module KPM
|
5
7
|
class PluginsDirectory
|
6
|
-
def self.all(latest=false)
|
8
|
+
def self.all(latest = false)
|
7
9
|
if latest
|
8
10
|
# Look at GitHub (source of truth)
|
9
11
|
begin
|
10
12
|
source = URI.parse('https://raw.githubusercontent.com/killbill/killbill-cloud/master/kpm/lib/kpm/plugins_directory.yml').read
|
11
13
|
rescue StandardError
|
12
14
|
# Default to built-in version if GitHub isn't accessible
|
13
|
-
return
|
15
|
+
return all(false)
|
14
16
|
end
|
15
17
|
YAML.load(source)
|
16
18
|
else
|
17
|
-
source = File.join(
|
19
|
+
source = File.join(__dir__, 'plugins_directory.yml')
|
18
20
|
YAML.load_file(source)
|
19
21
|
end
|
20
22
|
end
|
21
23
|
|
22
|
-
|
23
|
-
|
24
|
-
all(latest).inject({}) { |out, (key, val)| out[key]=val[:versions][kb_version.to_sym] if val[:versions].key?(kb_version.to_sym) ; out}
|
24
|
+
def self.list_plugins(latest = false, kb_version)
|
25
|
+
all(latest).each_with_object({}) { |(key, val), out| out[key] = val[:versions][kb_version.to_sym] if val[:versions].key?(kb_version.to_sym); }
|
25
26
|
end
|
26
27
|
|
27
|
-
def self.lookup(raw_plugin_key, latest=false, raw_kb_version=nil)
|
28
|
+
def self.lookup(raw_plugin_key, latest = false, raw_kb_version = nil)
|
28
29
|
plugin_key = raw_plugin_key.to_s.downcase
|
29
30
|
plugin = all(latest)[plugin_key.to_sym]
|
30
31
|
return nil if plugin.nil?
|
@@ -40,7 +41,7 @@ module KPM
|
|
40
41
|
if raw_kb_version == 'LATEST'
|
41
42
|
version = 'LATEST'
|
42
43
|
else
|
43
|
-
captures = raw_kb_version.nil? ? [] : raw_kb_version.scan(/(\d+\.\d+)(\.\d)?/)
|
44
|
+
captures = raw_kb_version.nil? ? [] : raw_kb_version.scan(/(\d+\.\d+)(\.\d+)?/)
|
44
45
|
if captures.empty? || captures.first.nil? || captures.first.first.nil?
|
45
46
|
version = 'LATEST'
|
46
47
|
else
|
@@ -2,241 +2,82 @@
|
|
2
2
|
:accertify:
|
3
3
|
:type: :java
|
4
4
|
:versions:
|
5
|
-
:0.14: 0.1.0
|
6
|
-
:0.16: 0.2.0
|
7
5
|
:0.18: 0.3.0
|
8
|
-
:require:
|
9
|
-
- :org.killbill.billing.plugin.accertify.url
|
10
|
-
- :org.killbill.billing.plugin.accertify.username
|
11
|
-
- :org.killbill.billing.plugin.accertify.password
|
12
6
|
:adyen:
|
13
7
|
:type: :java
|
14
8
|
:versions:
|
15
|
-
:0.
|
16
|
-
:0.15: 0.2.1
|
17
|
-
:0.16: 0.3.2
|
18
|
-
:0.17: 0.4.10
|
19
|
-
:0.18: 0.5.18
|
20
|
-
:0.19: 0.6.0
|
9
|
+
:0.18: 0.5.26
|
21
10
|
:0.20: 0.7.0
|
22
|
-
:require:
|
23
|
-
- :org.killbill.billing.plugin.adyen.merchantAccount
|
24
|
-
- :org.killbill.billing.plugin.adyen.username
|
25
|
-
- :org.killbill.billing.plugin.adyen.password
|
26
|
-
- :org.killbill.billing.plugin.adyen.paymentUrl
|
27
11
|
:analytics:
|
28
12
|
:type: :java
|
29
13
|
:versions:
|
30
|
-
:0.14: 1.0.3
|
31
|
-
:0.15: 2.0.1
|
32
|
-
:0.16: 3.0.2
|
33
|
-
:0.17: 4.0.5
|
34
14
|
:0.18: 4.2.5
|
35
|
-
:0.19: 5.1.4
|
36
15
|
:0.20: 6.0.1
|
37
|
-
:0.
|
16
|
+
:0.22: 7.0.8
|
38
17
|
:avatax:
|
39
18
|
:type: :java
|
40
19
|
:versions:
|
41
|
-
:0.14: 0.1.0
|
42
|
-
:0.15: 0.2.0
|
43
|
-
:0.16: 0.3.0
|
44
20
|
:0.18: 0.4.1
|
45
|
-
:0.19: 0.5.1
|
46
21
|
:0.20: 0.6.1
|
47
|
-
:0.
|
48
|
-
:require:
|
49
|
-
- :org.killbill.billing.plugin.avatax.url
|
50
|
-
- :org.killbill.billing.plugin.avatax.accountNumber
|
51
|
-
- :org.killbill.billing.plugin.avatax.licenseKey
|
52
|
-
:braintree_blue:
|
53
|
-
:type: :ruby
|
54
|
-
:versions:
|
55
|
-
:0.14: 0.0.1
|
56
|
-
:0.16: 0.2.1
|
57
|
-
:0.18: 0.3.1
|
58
|
-
:require:
|
59
|
-
- :merchant_id
|
60
|
-
- :public_key
|
61
|
-
- :private_key
|
62
|
-
:currency:
|
63
|
-
:type: :ruby
|
64
|
-
:artifact_id: killbill-currency-plugin
|
65
|
-
:versions:
|
66
|
-
:0.16: 2.0.0
|
67
|
-
:0.18: 3.0.0
|
22
|
+
:0.22: 0.7.0
|
68
23
|
:cybersource:
|
69
24
|
:type: :ruby
|
70
25
|
:versions:
|
71
|
-
:0.14: 1.0.0
|
72
|
-
:0.15: 3.3.0
|
73
|
-
:0.16: 4.0.12
|
74
26
|
:0.18: 5.2.7
|
75
|
-
|
76
|
-
|
77
|
-
|
27
|
+
:deposit:
|
28
|
+
:type: :java
|
29
|
+
:versions:
|
30
|
+
:0.22: 0.0.1
|
78
31
|
:dwolla:
|
79
32
|
:type: :java
|
80
33
|
:versions:
|
81
34
|
:0.18: 0.1.0
|
82
|
-
:require:
|
83
|
-
- :org.killbill.billing.plugin.dwolla.baseUrl
|
84
|
-
- :org.killbill.billing.plugin.dwolla.baseOAuthUrl
|
85
|
-
- :org.killbill.billing.plugin.dwolla.scopes
|
86
|
-
- :org.killbill.billing.plugin.dwolla.clientId
|
87
|
-
- :org.killbill.billing.plugin.dwolla.clientSecret
|
88
|
-
- :org.killbill.billing.plugin.dwolla.accountId
|
89
35
|
:email-notifications:
|
90
36
|
:type: :java
|
91
37
|
:artifact_id: killbill-email-notifications-plugin
|
92
38
|
:versions:
|
93
|
-
:0.14: 0.1.0
|
94
|
-
:0.16: 0.2.0
|
95
39
|
:0.18: 0.3.1
|
96
|
-
:0.19: 0.4.0
|
97
40
|
:0.20: 0.5.1
|
98
|
-
:
|
99
|
-
:type: :ruby
|
100
|
-
:artifact_id: firstdata-e4-plugin
|
101
|
-
:versions:
|
102
|
-
:0.16: 0.1.0
|
103
|
-
:0.18: 0.2.0
|
104
|
-
:require:
|
105
|
-
- :login
|
106
|
-
- :password
|
41
|
+
:0.22: 0.6.1
|
107
42
|
:forte:
|
108
43
|
:type: :java
|
109
44
|
:versions:
|
110
|
-
:0.14: 0.1.0
|
111
|
-
:0.16: 0.2.0
|
112
45
|
:0.18: 0.3.0
|
113
|
-
:require:
|
114
|
-
- :org.killbill.billing.plugin.forte.merchantId
|
115
|
-
- :org.killbill.billing.plugin.forte.password
|
116
|
-
- :org.killbill.billing.plugin.forte.host
|
117
|
-
- :org.killbill.billing.plugin.forte.port
|
118
|
-
- :org.killbill.billing.plugin.forte.apiLoginId
|
119
|
-
- :org.killbill.billing.plugin.forte.secureTransactionKey
|
120
46
|
:kpm:
|
121
47
|
:type: :ruby
|
122
48
|
:versions:
|
123
|
-
:0.15: 0.0.2
|
124
|
-
:0.16: 0.0.5
|
125
|
-
:0.17: 1.0.0
|
126
49
|
:0.18: 1.1.2
|
127
|
-
:0.19: 1.2.4
|
128
50
|
:0.20: 1.3.0
|
129
|
-
:litle:
|
130
|
-
:type: :ruby
|
131
|
-
:versions:
|
132
|
-
:0.14: 2.0.0
|
133
|
-
:0.16: 3.0.0
|
134
|
-
:0.18: 4.0.0
|
135
|
-
:0.20: 5.0.0
|
136
|
-
:require:
|
137
|
-
- :account_id
|
138
|
-
- :merchant_id
|
139
|
-
- :username
|
140
|
-
- :password
|
141
|
-
- :secure_page_url
|
142
|
-
- :paypage_id
|
143
|
-
:logging:
|
144
|
-
:type: :ruby
|
145
|
-
:versions:
|
146
|
-
:0.14: 1.7.0
|
147
|
-
:0.15: 2.0.0
|
148
|
-
:0.16: 3.0.0
|
149
|
-
:0.18: 4.0.0
|
150
51
|
:orbital:
|
151
52
|
:type: :ruby
|
152
53
|
:versions:
|
153
|
-
:0.16: 0.0.2
|
154
54
|
:0.18: 0.1.15
|
155
|
-
:require:
|
156
|
-
- :login
|
157
|
-
- :password
|
158
|
-
- :merchant_id
|
159
55
|
:payment_bridge:
|
160
56
|
:type: :java
|
161
57
|
:artifact_id: bridge-plugin
|
162
58
|
:versions:
|
163
|
-
:0.19: 0.0.12
|
164
59
|
:0.20: 0.1.2
|
165
|
-
:0.21: 0.2.
|
166
|
-
:payeezy:
|
167
|
-
:type: :java
|
168
|
-
:versions:
|
169
|
-
:0.17: 0.1.0
|
170
|
-
:require:
|
171
|
-
- :org.killbill.billing.plugin.payeezy.apiKey
|
172
|
-
- :org.killbill.billing.plugin.payeezy.token
|
173
|
-
- :org.killbill.billing.plugin.payeezy.secret
|
174
|
-
- :org.killbill.billing.plugin.payeezy.paymentUrl
|
60
|
+
:0.21: 0.2.1
|
175
61
|
:payment-retries:
|
176
62
|
:type: :java
|
177
63
|
:versions:
|
178
|
-
:0.16: 0.0.1
|
179
|
-
:0.17: 0.1.0
|
180
64
|
:0.18: 0.2.4
|
181
65
|
:paypal:
|
182
66
|
:type: :ruby
|
183
67
|
:artifact_id: paypal-express-plugin
|
184
68
|
:versions:
|
185
|
-
:0.
|
186
|
-
:0.15: 3.0.0
|
187
|
-
:0.16: 4.1.7
|
188
|
-
:0.18: 5.0.9
|
69
|
+
:0.18: 5.0.15
|
189
70
|
:0.20: 6.0.0
|
190
|
-
:require:
|
191
|
-
- :signature
|
192
|
-
- :login
|
193
|
-
- :password
|
194
|
-
:payu_latam:
|
195
|
-
:type: :ruby
|
196
|
-
:artifact_id: payu-latam-plugin
|
197
|
-
:versions:
|
198
|
-
:0.14: 0.1.0
|
199
|
-
:0.16: 0.2.0
|
200
|
-
:0.18: 0.3.0
|
201
|
-
:require:
|
202
|
-
- :api_login
|
203
|
-
- :api_key
|
204
|
-
- :country_account_id
|
205
|
-
- :merchant_id
|
206
71
|
:payment-test:
|
207
|
-
:type: :
|
72
|
+
:type: :java
|
208
73
|
:artifact_id: payment-test-plugin
|
209
74
|
:versions:
|
210
|
-
:0.
|
211
|
-
:0.19: 5.0.0
|
212
|
-
:0.20: 6.0.0
|
75
|
+
:0.22: 7.0.4
|
213
76
|
:securenet:
|
214
77
|
:type: :ruby
|
215
78
|
:versions:
|
216
|
-
:0.16: 0.1.0
|
217
79
|
:0.18: 0.2.0
|
218
|
-
:require:
|
219
|
-
- :login
|
220
|
-
- :password
|
221
80
|
:stripe:
|
222
|
-
:type: :
|
223
|
-
:versions:
|
224
|
-
:0.14: 1.0.0
|
225
|
-
:0.15: 2.0.0
|
226
|
-
:0.16: 3.0.3
|
227
|
-
:0.17: 4.0.0
|
228
|
-
:0.18: 4.1.1
|
229
|
-
:0.19: 5.0.0
|
230
|
-
:0.20: 6.0.1
|
231
|
-
:require:
|
232
|
-
- :api_secret_key
|
233
|
-
:zendesk:
|
234
|
-
:type: :ruby
|
81
|
+
:type: :java
|
235
82
|
:versions:
|
236
|
-
:0.
|
237
|
-
:0.16: 2.0.0
|
238
|
-
:0.18: 3.0.1
|
239
|
-
:require:
|
240
|
-
- :subdomain
|
241
|
-
- :username
|
242
|
-
- :password
|
83
|
+
:0.22: 7.2.0
|
data/lib/kpm/plugins_manager.rb
CHANGED
@@ -1,15 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'pathname'
|
2
4
|
require 'json'
|
3
5
|
|
4
6
|
module KPM
|
5
7
|
class PluginsManager
|
6
|
-
|
7
8
|
def initialize(plugins_dir, logger)
|
8
9
|
@plugins_dir = Pathname.new(plugins_dir)
|
9
10
|
@logger = logger
|
10
11
|
end
|
11
12
|
|
12
|
-
def set_active(plugin_name_or_path, plugin_version=nil)
|
13
|
+
def set_active(plugin_name_or_path, plugin_version = nil)
|
13
14
|
if plugin_name_or_path.nil?
|
14
15
|
@logger.warn('Unable to mark a plugin as active: no name or path specified')
|
15
16
|
return
|
@@ -19,7 +20,7 @@ module KPM
|
|
19
20
|
# Full path specified, with version
|
20
21
|
link = Pathname.new(plugin_name_or_path).join('../SET_DEFAULT')
|
21
22
|
FileUtils.rm_f(link)
|
22
|
-
FileUtils.ln_s(plugin_name_or_path, link, :
|
23
|
+
FileUtils.ln_s(plugin_name_or_path, link, force: true)
|
23
24
|
else
|
24
25
|
# Plugin name (fs directory) specified
|
25
26
|
plugin_dir_glob = @plugins_dir.join('*').join(plugin_name_or_path)
|
@@ -28,7 +29,7 @@ module KPM
|
|
28
29
|
plugin_dir = Pathname.new(plugin_dir_path)
|
29
30
|
link = plugin_dir.join('SET_DEFAULT')
|
30
31
|
FileUtils.rm_f(link)
|
31
|
-
FileUtils.ln_s(plugin_dir.join(plugin_version), link, :
|
32
|
+
FileUtils.ln_s(plugin_dir.join(plugin_version), link, force: true)
|
32
33
|
end
|
33
34
|
end
|
34
35
|
|
@@ -38,7 +39,7 @@ module KPM
|
|
38
39
|
end
|
39
40
|
end
|
40
41
|
|
41
|
-
def uninstall(plugin_name_or_path, plugin_version=nil)
|
42
|
+
def uninstall(plugin_name_or_path, plugin_version = nil)
|
42
43
|
update_fs(plugin_name_or_path, plugin_version) do |tmp_dir|
|
43
44
|
FileUtils.rm_f(tmp_dir.join('restart.txt'))
|
44
45
|
# Be safe, keep the code, just never start it
|
@@ -46,7 +47,7 @@ module KPM
|
|
46
47
|
end
|
47
48
|
end
|
48
49
|
|
49
|
-
def restart(plugin_name_or_path, plugin_version=nil)
|
50
|
+
def restart(plugin_name_or_path, plugin_version = nil)
|
50
51
|
update_fs(plugin_name_or_path, plugin_version) do |tmp_dir|
|
51
52
|
# Remove disabled.txt so that the plugin is started if it was stopped
|
52
53
|
FileUtils.rm_f(tmp_dir.join('disabled.txt'))
|
@@ -59,20 +60,19 @@ module KPM
|
|
59
60
|
entry = identifiers[plugin_key]
|
60
61
|
if entry
|
61
62
|
coordinate_map.each_pair do |key, value|
|
62
|
-
return false
|
63
|
+
return false unless validate_plugin_identifier_key_value(plugin_key, key, entry[key.to_s], value)
|
63
64
|
end
|
64
65
|
end
|
65
66
|
true
|
66
67
|
end
|
67
68
|
|
68
69
|
def add_plugin_identifier_key(plugin_key, plugin_name, language, coordinate_map)
|
69
|
-
|
70
70
|
identifiers = read_plugin_identifiers
|
71
71
|
# If key does not already exists or if the version in the json is not the one we are currently installing we update the entry, if not nothing to do
|
72
|
-
if !identifiers.
|
72
|
+
if !identifiers.key?(plugin_key) ||
|
73
73
|
(coordinate_map && identifiers[plugin_key]['version'] != coordinate_map[:version])
|
74
74
|
|
75
|
-
entry = {'plugin_name' => plugin_name}
|
75
|
+
entry = { 'plugin_name' => plugin_name }
|
76
76
|
entry['language'] = language
|
77
77
|
if coordinate_map
|
78
78
|
entry['group_id'] = coordinate_map[:group_id]
|
@@ -91,7 +91,7 @@ module KPM
|
|
91
91
|
def remove_plugin_identifier_key(plugin_key)
|
92
92
|
identifiers = read_plugin_identifiers
|
93
93
|
# If key does not already exists we update it, if not nothing to do.
|
94
|
-
if identifiers.
|
94
|
+
if identifiers.key?(plugin_key)
|
95
95
|
identifiers.delete(plugin_key)
|
96
96
|
write_plugin_identifiers(identifiers)
|
97
97
|
end
|
@@ -101,7 +101,7 @@ module KPM
|
|
101
101
|
|
102
102
|
def get_plugin_key_and_name(plugin_name_or_key)
|
103
103
|
identifiers = read_plugin_identifiers
|
104
|
-
if identifiers.
|
104
|
+
if identifiers.key?(plugin_name_or_key)
|
105
105
|
# It's a plugin key
|
106
106
|
[plugin_name_or_key, identifiers[plugin_name_or_key]['plugin_name']]
|
107
107
|
else
|
@@ -121,19 +121,20 @@ module KPM
|
|
121
121
|
|
122
122
|
def guess_plugin_name(artifact_id)
|
123
123
|
return nil if artifact_id.nil?
|
124
|
+
|
124
125
|
captures = artifact_id.scan(/(.*)-plugin/)
|
125
|
-
if captures.empty? || captures.first.nil? || captures.first.first.nil?
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
126
|
+
short_name = if captures.empty? || captures.first.nil? || captures.first.first.nil?
|
127
|
+
artifact_id
|
128
|
+
else
|
129
|
+
# 'analytics-plugin' or 'stripe-plugin' passed
|
130
|
+
captures.first.first
|
131
|
+
end
|
131
132
|
Dir.glob(@plugins_dir.join('*').join('*')).each do |plugin_path|
|
132
133
|
plugin_name = File.basename(plugin_path)
|
133
134
|
if plugin_name == short_name ||
|
134
|
-
|
135
|
-
|
136
|
-
|
135
|
+
plugin_name == artifact_id ||
|
136
|
+
!plugin_name.scan(/-#{short_name}/).empty? ||
|
137
|
+
!plugin_name.scan(/#{short_name}-/).empty?
|
137
138
|
return plugin_name
|
138
139
|
end
|
139
140
|
end
|
@@ -148,6 +149,7 @@ module KPM
|
|
148
149
|
JSON.parse(f.read)
|
149
150
|
end
|
150
151
|
rescue Errno::ENOENT
|
152
|
+
# Ignore
|
151
153
|
end
|
152
154
|
identifiers
|
153
155
|
end
|
@@ -166,7 +168,6 @@ module KPM
|
|
166
168
|
end
|
167
169
|
|
168
170
|
def write_plugin_identifiers(identifiers)
|
169
|
-
|
170
171
|
path = Pathname.new(@plugins_dir).join('plugin_identifiers.json')
|
171
172
|
Dir.mktmpdir do |tmp_dir|
|
172
173
|
tmp_path = Pathname.new(tmp_dir).join('plugin_identifiers.json')
|
@@ -179,13 +180,17 @@ module KPM
|
|
179
180
|
end
|
180
181
|
|
181
182
|
# Note: the plugin name here is the directory name on the filesystem
|
182
|
-
def update_fs(plugin_name_or_path, plugin_version=nil
|
183
|
+
def update_fs(plugin_name_or_path, plugin_version = nil)
|
183
184
|
if plugin_name_or_path.nil?
|
184
185
|
@logger.warn('Unable to update the filesystem: no name or path specified')
|
185
186
|
return
|
186
187
|
end
|
187
188
|
|
188
|
-
p = plugin_version.nil?
|
189
|
+
p = if plugin_version.nil?
|
190
|
+
plugin_name_or_path
|
191
|
+
else
|
192
|
+
@plugins_dir.join('*').join(plugin_name_or_path).join(plugin_version == :all ? '*' : plugin_version)
|
193
|
+
end
|
189
194
|
|
190
195
|
modified = []
|
191
196
|
Dir.glob(p).each do |plugin_dir_path|
|