nexus_cli 2.0.2 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/nexus_cli/connection.rb +7 -7
- data/lib/nexus_cli/mixins/artifact_actions.rb +7 -4
- data/lib/nexus_cli/mixins/pro/custom_metadata_actions.rb +20 -13
- data/lib/nexus_cli/mixins/pro/smart_proxy_actions.rb +7 -2
- data/lib/nexus_cli/n3_metadata.rb +14 -8
- data/lib/nexus_cli/remote_factory.rb +0 -1
- data/lib/nexus_cli.rb +1 -1
- data/nexus_cli.gemspec +0 -1
- metadata +5 -21
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
3.0.0
|
data/lib/nexus_cli/connection.rb
CHANGED
@@ -44,14 +44,14 @@ module NexusCli
|
|
44
44
|
response = nexus.get(nexus_url("service/local/status"))
|
45
45
|
case response.status
|
46
46
|
when 200
|
47
|
-
doc =
|
47
|
+
doc = REXML::Document.new(response.content).elements["/status/data"]
|
48
48
|
data = Hash.new
|
49
|
-
data['app_name'] = doc.
|
50
|
-
data['version'] = doc.
|
51
|
-
data['edition_long'] = doc.
|
52
|
-
data['state'] = doc.
|
53
|
-
data['started_at'] = doc.
|
54
|
-
data['base_url'] = doc.
|
49
|
+
data['app_name'] = doc.elements["appName"].text
|
50
|
+
data['version'] = doc.elements["version"].text
|
51
|
+
data['edition_long'] = doc.elements["editionLong"].text
|
52
|
+
data['state'] = doc.elements["state"].text
|
53
|
+
data['started_at'] = doc.elements["startedAt"].text
|
54
|
+
data['base_url'] = doc.elements["baseUrl"].text
|
55
55
|
return data
|
56
56
|
when 401
|
57
57
|
raise PermissionsException
|
@@ -14,7 +14,8 @@ module NexusCli
|
|
14
14
|
# @return [Hash] Some information about the artifact that was pulled.
|
15
15
|
def pull_artifact(artifact, destination=nil)
|
16
16
|
group_id, artifact_id, version, extension = parse_artifact_string(artifact)
|
17
|
-
version =
|
17
|
+
version = REXML::Document.new(get_artifact_info(artifact)).elements["//version"].text if version.casecmp("latest")
|
18
|
+
|
18
19
|
file_name = "#{artifact_id}-#{version}.#{extension}"
|
19
20
|
destination = File.join(File.expand_path(destination || "."), file_name)
|
20
21
|
response = nexus.get(nexus_url("service/local/artifact/maven/redirect"), :query => {:g => group_id, :a => artifact_id, :v => version, :e => extension, :r => configuration['repository']})
|
@@ -123,7 +124,7 @@ module NexusCli
|
|
123
124
|
response = nexus.get(nexus_url("service/local/data_index"), :query => {:g => group_id, :a => artifact_id})
|
124
125
|
case response.status
|
125
126
|
when 200
|
126
|
-
doc =
|
127
|
+
doc = REXML::Document.new(response.content)
|
127
128
|
return format_search_results(doc, group_id, artifact_id)
|
128
129
|
else
|
129
130
|
raise UnexpectedStatusCodeException.new(response.status)
|
@@ -139,13 +140,15 @@ module NexusCli
|
|
139
140
|
# Formats the given XML into an [Array<String>] so it
|
140
141
|
# can be displayed nicely.
|
141
142
|
#
|
142
|
-
# @param doc [
|
143
|
+
# @param doc [REXML::Document] the xml search results
|
143
144
|
# @param group_id [String] the group id
|
144
145
|
# @param artifact_id [String] the artifact id
|
145
146
|
#
|
146
147
|
# @return [type] [description]
|
147
148
|
def format_search_results(doc, group_id, artifact_id)
|
148
|
-
|
149
|
+
|
150
|
+
versions = []
|
151
|
+
REXML::XPath.each(doc, "//version") { |matched_version| versions << matched_version.text }
|
149
152
|
if versions.length > 0
|
150
153
|
indent_size = versions.max{|a,b| a.length <=> b.length}.size+4
|
151
154
|
formated_results = ['Found Versions:']
|
@@ -66,7 +66,7 @@ module NexusCli
|
|
66
66
|
response = nexus.get(nexus_url("service/local/search/m2/freeform"), :query => {:p => param[0], :t => param[1], :v => param[2]})
|
67
67
|
case response.status
|
68
68
|
when 200
|
69
|
-
nodesets.push(
|
69
|
+
nodesets.push(REXML::Document.new(response.body).elements["/search-results/data"])
|
70
70
|
when 400
|
71
71
|
raise BadSearchRequestException
|
72
72
|
when 404
|
@@ -77,7 +77,9 @@ module NexusCli
|
|
77
77
|
end
|
78
78
|
# Perform array intersection across all NodeSets for the final common set.
|
79
79
|
result = nodesets.inject(nodesets.first) {|memo, nodeset| get_common_artifact_set(memo, nodeset)}
|
80
|
-
|
80
|
+
formatter = REXML::Formatters::Pretty.new(4)
|
81
|
+
formatter.compact = true
|
82
|
+
return result.nil? ? "" : formatter.write(result, "")
|
81
83
|
end
|
82
84
|
|
83
85
|
private
|
@@ -147,22 +149,27 @@ module NexusCli
|
|
147
149
|
end
|
148
150
|
|
149
151
|
# Gets the intersection of two artifact arrays, returning the common set
|
150
|
-
#
|
151
|
-
# @
|
152
|
-
|
153
|
-
|
154
|
-
|
152
|
+
#
|
153
|
+
# @param [REXML::Document] left_document, right_document
|
154
|
+
# The two REXML::Document objects to intersect
|
155
|
+
#
|
156
|
+
# @result [REXML::Document nil]
|
157
|
+
# The resulting object generated from the intersectection or nil
|
158
|
+
def get_common_artifact_set(left_document, right_document)
|
159
|
+
intersection = get_artifact_array(left_document) & get_artifact_array(right_document)
|
160
|
+
return intersection.count > 0 ? REXML::Document.new("<data>#{intersection.join}</data>").root : nil
|
155
161
|
end
|
156
162
|
|
157
163
|
# Collect <artifact> elements into an array
|
164
|
+
#
|
158
165
|
# @info This will allow use of array intersection to find common artifacts in searches
|
159
|
-
#
|
166
|
+
#
|
167
|
+
# @param [REXML::Document] document The object to be divided by <artifact> elements
|
168
|
+
#
|
160
169
|
# @result [Array] The result array of artifact elements
|
161
|
-
def get_artifact_array(
|
162
|
-
|
163
|
-
|
164
|
-
artifacts
|
165
|
-
end
|
170
|
+
def get_artifact_array(document)
|
171
|
+
artifacts = []
|
172
|
+
REXML::XPath.each(document, "//artifact") { |matched_artifact| artifacts << matched_artifact.text }
|
166
173
|
end
|
167
174
|
end
|
168
175
|
end
|
@@ -47,7 +47,7 @@ module NexusCli
|
|
47
47
|
#
|
48
48
|
# @return [Boolean] true if the repository is now subscribing, false otherwise
|
49
49
|
def enable_artifact_subscribe(repository_id, preemptive_fetch)
|
50
|
-
raise NotProxyRepositoryException.new(repository_id) unless
|
50
|
+
raise NotProxyRepositoryException.new(repository_id) unless is_proxy_repository?(get_repository_info(repository_id))
|
51
51
|
|
52
52
|
params = {:repositoryId => repository_id}
|
53
53
|
params[:subscribe] = true
|
@@ -61,7 +61,7 @@ module NexusCli
|
|
61
61
|
#
|
62
62
|
# @return [Boolean] true if the repository is disabled, false otherwise
|
63
63
|
def disable_artifact_subscribe(repository_id)
|
64
|
-
raise NotProxyRepositoryException.new(repository_id) unless
|
64
|
+
raise NotProxyRepositoryException.new(repository_id) unless is_proxy_repository?(get_repository_info(repository_id))
|
65
65
|
|
66
66
|
params = {:repositoryId => repository_id}
|
67
67
|
params[:subscribe] = false
|
@@ -210,5 +210,10 @@ module NexusCli
|
|
210
210
|
raise UnexpectedStatusCodeException.new(response.status)
|
211
211
|
end
|
212
212
|
end
|
213
|
+
|
214
|
+
private
|
215
|
+
def is_proxy_repository?(repository_xml)
|
216
|
+
REXML::Document.new(repository_xml).elements["/repository/data/repoType"].text == "proxy"
|
217
|
+
end
|
213
218
|
end
|
214
219
|
end
|
@@ -1,4 +1,3 @@
|
|
1
|
-
require 'nokogiri'
|
2
1
|
require 'base64'
|
3
2
|
|
4
3
|
module NexusCli
|
@@ -29,19 +28,26 @@ module NexusCli
|
|
29
28
|
# Parses the regular custom metadata xml into a simpler format containing only the custom metadata.
|
30
29
|
def convert_result_to_simple_xml(custom_metadata)
|
31
30
|
request = []
|
32
|
-
|
33
|
-
|
31
|
+
document = REXML::Document.new(custom_metadata)
|
32
|
+
REXML::XPath.each(document, "//customMetadataResponse/data/customMetadata[namespace=\"urn:nexus/user#\"]") do |row|
|
33
|
+
request.push(create_tag(row.elements["key"].text.strip, row.elements["value"].text.strip))
|
34
34
|
end
|
35
|
-
|
35
|
+
formatter = REXML::Formatters::Pretty.new(4)
|
36
|
+
formatter.compact = true
|
37
|
+
document = REXML::Document.new("<artifact-resolution><data>#{request.join}</data></artifact-resolution>")
|
38
|
+
out = ""
|
39
|
+
formatter.write(document, out)
|
40
|
+
out
|
36
41
|
end
|
37
42
|
|
38
43
|
# Parses the regular custom metadata xml into a hash containing only the custom metadata.
|
39
44
|
def convert_result_to_hash(custom_metadata)
|
40
45
|
request = {}
|
41
|
-
|
42
|
-
|
46
|
+
document = REXML::Document.new(custom_metadata)
|
47
|
+
REXML::XPath.each(document, "//customMetadataResponse/data/customMetadata[namespace=\"urn:nexus/user#\"]") do |row|
|
48
|
+
request[row.elements["key"].text.strip] = row.elements["value"].text.strip
|
43
49
|
end
|
44
|
-
|
50
|
+
request
|
45
51
|
end
|
46
52
|
|
47
53
|
# Create the request from the specified list of custom metadata key:value pairs
|
@@ -64,7 +70,7 @@ module NexusCli
|
|
64
70
|
private
|
65
71
|
|
66
72
|
def create_tag(tag, value)
|
67
|
-
|
73
|
+
"<#{tag}>#{value}</#{tag}>"
|
68
74
|
end
|
69
75
|
end
|
70
76
|
end
|
data/lib/nexus_cli.rb
CHANGED
data/nexus_cli.gemspec
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nexus_cli
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 3.0.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2013-02-19 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: thor
|
@@ -43,22 +43,6 @@ dependencies:
|
|
43
43
|
- - '='
|
44
44
|
- !ruby/object:Gem::Version
|
45
45
|
version: 2.2.5
|
46
|
-
- !ruby/object:Gem::Dependency
|
47
|
-
name: nokogiri
|
48
|
-
requirement: !ruby/object:Gem::Requirement
|
49
|
-
none: false
|
50
|
-
requirements:
|
51
|
-
- - ! '>='
|
52
|
-
- !ruby/object:Gem::Version
|
53
|
-
version: '0'
|
54
|
-
type: :runtime
|
55
|
-
prerelease: false
|
56
|
-
version_requirements: !ruby/object:Gem::Requirement
|
57
|
-
none: false
|
58
|
-
requirements:
|
59
|
-
- - ! '>='
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: '0'
|
62
46
|
- !ruby/object:Gem::Dependency
|
63
47
|
name: extlib
|
64
48
|
requirement: !ruby/object:Gem::Requirement
|
@@ -266,7 +250,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
266
250
|
version: '0'
|
267
251
|
segments:
|
268
252
|
- 0
|
269
|
-
hash:
|
253
|
+
hash: 1427229917539912472
|
270
254
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
271
255
|
none: false
|
272
256
|
requirements:
|
@@ -275,10 +259,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
275
259
|
version: '0'
|
276
260
|
segments:
|
277
261
|
- 0
|
278
|
-
hash:
|
262
|
+
hash: 1427229917539912472
|
279
263
|
requirements: []
|
280
264
|
rubyforge_project:
|
281
|
-
rubygems_version: 1.8.
|
265
|
+
rubygems_version: 1.8.24
|
282
266
|
signing_key:
|
283
267
|
specification_version: 3
|
284
268
|
summary: A command-line wrapper for making REST calls to Sonatype Nexus.
|