package_cloud 0.3.13 → 0.3.15
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 +4 -4
- data/README.md +1 -1
- data/lib/package_cloud/cli/entry.rb +92 -6
- data/lib/package_cloud/client.rb +0 -1
- data/lib/package_cloud/repository.rb +45 -14
- data/lib/package_cloud/version.rb +1 -1
- data/package_cloud.gemspec +6 -4
- metadata +34 -20
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 7137e29274423947660c706e21c9202f53ba02c046928cde787ed48ec06c714c
|
|
4
|
+
data.tar.gz: faecdd0f26599ff1c6eab2b1a17a31176f7cc281f6104adef446ff3a41f67065
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 3b21cf56b65cad88473a522d0863075c6aa7787945fca30475b919c711bacb58894d4df31a4cd42431a523e6492562b238457439e4cfc9fb628360f2e940d2d5
|
|
7
|
+
data.tar.gz: d420d301d173518bfb21b02aa9e422b79e3c4e34c1a9503b7ba0df4e008c7781fc67f4e79bb7ae8b53e8faf5aaaf8318644f65ade21ad76801f0534789d40c07
|
data/README.md
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
require "cgi"
|
|
2
|
+
require "uri"
|
|
3
|
+
|
|
1
4
|
module PackageCloud
|
|
2
5
|
module CLI
|
|
3
6
|
JAVA_EXTS = ["jar", "aar", "war"]
|
|
@@ -103,9 +106,17 @@ module PackageCloud
|
|
|
103
106
|
option "skip-errors", :type => :boolean,
|
|
104
107
|
:desc => "Skip errors encountered during a package push and continue pushing the next package."
|
|
105
108
|
|
|
109
|
+
option "skip-duplicates", :type => :boolean,
|
|
110
|
+
:desc => "Skip packages which already exist and continue pushing the next package."
|
|
111
|
+
|
|
106
112
|
option "coordinates", :type => :string,
|
|
107
113
|
:desc => "Specify the exact maven coordinates to use for a JAR. Useful for JARs without coordinates, 'fat JARs', and WARs."
|
|
108
114
|
|
|
115
|
+
option "upload-before-push",
|
|
116
|
+
:type => :boolean,
|
|
117
|
+
:desc => "Upload package before push",
|
|
118
|
+
:default => false
|
|
119
|
+
|
|
109
120
|
def push(repo, package_file, *package_files)
|
|
110
121
|
total_time = Benchmark.measure do
|
|
111
122
|
ARGV.clear # otherwise gets explodes
|
|
@@ -173,7 +184,9 @@ module PackageCloud
|
|
|
173
184
|
$logger.debug("repository lookup request timing: #{measurement}")
|
|
174
185
|
|
|
175
186
|
package_files.each do |f|
|
|
187
|
+
url = nil
|
|
176
188
|
files = nil
|
|
189
|
+
urls = nil
|
|
177
190
|
ext = f.split(".").last
|
|
178
191
|
|
|
179
192
|
if ext == "dsc"
|
|
@@ -181,12 +194,63 @@ module PackageCloud
|
|
|
181
194
|
files = parse_and_verify_dsc(client_repo, f, dist_id)
|
|
182
195
|
end
|
|
183
196
|
|
|
197
|
+
if options["upload-before-push"]
|
|
198
|
+
print "Uploading #{f}... "
|
|
199
|
+
upload = client_repo.create_upload
|
|
200
|
+
begin
|
|
201
|
+
response = RestClient::Request.execute(
|
|
202
|
+
:method => upload.fetch("form").fetch("method", "POST"),
|
|
203
|
+
:url => upload.fetch("form").fetch("url"),
|
|
204
|
+
:timeout => nil,
|
|
205
|
+
:payload => upload.fetch("form").fetch("data", {}).merge(
|
|
206
|
+
upload.fetch("form").fetch("file_input") => File.open(f, "r"),
|
|
207
|
+
)
|
|
208
|
+
)
|
|
209
|
+
url = response.headers.fetch(:location)
|
|
210
|
+
|
|
211
|
+
# Amazon S3 uploads return urlencoded keys in the Location
|
|
212
|
+
# header, and we want to return the decoded object key for
|
|
213
|
+
# API operations.
|
|
214
|
+
uri = URI.parse(url)
|
|
215
|
+
if uri.host.end_with?(".amazonaws.com")
|
|
216
|
+
uri.path = CGI.unescape(uri.path)
|
|
217
|
+
url = uri.to_s
|
|
218
|
+
end
|
|
219
|
+
|
|
220
|
+
if files
|
|
221
|
+
urls = files.map do |file|
|
|
222
|
+
response = RestClient::Request.execute(
|
|
223
|
+
:method => upload.fetch("form").fetch("method", "POST"),
|
|
224
|
+
:url => upload.fetch("form").fetch("url"),
|
|
225
|
+
:timeout => nil,
|
|
226
|
+
:payload => upload.fetch("form").fetch("data", {}).merge(
|
|
227
|
+
upload.fetch("form").fetch("file_input") => File.open(file, "r"),
|
|
228
|
+
)
|
|
229
|
+
)
|
|
230
|
+
source_url = response.headers.fetch(:location)
|
|
231
|
+
source_uri = URI.parse(source_url)
|
|
232
|
+
if source_uri.host.end_with?(".amazonaws.com")
|
|
233
|
+
source_uri.path = CGI.unescape(source_uri.path)
|
|
234
|
+
source_url = source_uri.to_s
|
|
235
|
+
end
|
|
236
|
+
source_url
|
|
237
|
+
end
|
|
238
|
+
end
|
|
239
|
+
rescue
|
|
240
|
+
print "error!\n".color(:red)
|
|
241
|
+
puts $!, *$!.backtrace, $!.response, $!.response.body
|
|
242
|
+
exit(1)
|
|
243
|
+
end
|
|
244
|
+
end
|
|
245
|
+
|
|
184
246
|
print "Pushing #{f}... "
|
|
185
247
|
measurement = Benchmark.measure do
|
|
186
248
|
if options.has_key?("skip-errors")
|
|
187
|
-
create_package_skip_errors(client_repo, f, dist_id, files, ext, options["coordinates"])
|
|
249
|
+
create_package_skip_errors(client_repo, f, url, dist_id, files, urls, ext, options["coordinates"])
|
|
250
|
+
elsif options.has_key?("skip-duplicates")
|
|
251
|
+
create_package_skip_duplicates(client_repo, f, url, dist_id, files, urls, ext, options["coordinates"])
|
|
188
252
|
else
|
|
189
|
-
create_package(client_repo, f, dist_id, files, ext, options["coordinates"])
|
|
253
|
+
create_package(client_repo, f, url, dist_id, files, urls, ext, options["coordinates"])
|
|
190
254
|
end
|
|
191
255
|
end
|
|
192
256
|
$logger.debug("create package request timing: #{measurement}")
|
|
@@ -233,9 +297,9 @@ module PackageCloud
|
|
|
233
297
|
end
|
|
234
298
|
end
|
|
235
299
|
|
|
236
|
-
def create_package_skip_errors(client_repo, f, dist_id, files, ext, coordinates=nil)
|
|
300
|
+
def create_package_skip_errors(client_repo, f, url, dist_id, files, urls, ext, coordinates=nil)
|
|
237
301
|
begin
|
|
238
|
-
client_repo.create_package(f, dist_id, files, ext, coordinates=nil)
|
|
302
|
+
client_repo.create_package(f, url, dist_id, files, urls, ext, coordinates=nil)
|
|
239
303
|
rescue RestClient::UnprocessableEntity => e
|
|
240
304
|
print "error (skipping):\n".color(:yellow)
|
|
241
305
|
json = JSON.parse(e.response)
|
|
@@ -246,9 +310,31 @@ module PackageCloud
|
|
|
246
310
|
end
|
|
247
311
|
end
|
|
248
312
|
|
|
249
|
-
def
|
|
313
|
+
def create_package_skip_duplicates(client_repo, f, url, dist_id, files, urls, ext, coordinates=nil)
|
|
314
|
+
begin
|
|
315
|
+
client_repo.create_package(f, url, dist_id, files, urls, ext, coordinates=nil)
|
|
316
|
+
rescue RestClient::UnprocessableEntity => e
|
|
317
|
+
json = JSON.parse(e.response)
|
|
318
|
+
if json == { "filename" => ["has already been taken"] }
|
|
319
|
+
print "skipping, already exists.\n".color(:yellow)
|
|
320
|
+
else
|
|
321
|
+
print "error:\n".color(:red)
|
|
322
|
+
json.each do |k,v|
|
|
323
|
+
if v.is_a? String
|
|
324
|
+
puts "\n\t#{k}: #{v}\n"
|
|
325
|
+
elsif v.is_a? Array
|
|
326
|
+
puts "\n\t#{k}: #{v.join(", ")}\n"
|
|
327
|
+
end
|
|
328
|
+
end
|
|
329
|
+
puts ""
|
|
330
|
+
exit(1)
|
|
331
|
+
end
|
|
332
|
+
end
|
|
333
|
+
end
|
|
334
|
+
|
|
335
|
+
def create_package(client_repo, f, url, dist_id, files, urls, ext, coordinates=nil)
|
|
250
336
|
begin
|
|
251
|
-
client_repo.create_package(f, dist_id, files, ext, coordinates)
|
|
337
|
+
client_repo.create_package(f, url, dist_id, files, urls, ext, coordinates)
|
|
252
338
|
rescue RestClient::UnprocessableEntity => e
|
|
253
339
|
print "error:\n".color(:red)
|
|
254
340
|
json = JSON.parse(e.response)
|
data/lib/package_cloud/client.rb
CHANGED
|
@@ -31,28 +31,59 @@ module PackageCloud
|
|
|
31
31
|
end
|
|
32
32
|
end
|
|
33
33
|
|
|
34
|
-
def
|
|
35
|
-
|
|
34
|
+
def create_upload
|
|
35
|
+
base_url = @config.base_url
|
|
36
|
+
url = PackageCloud::Util.compute_url(base_url, paths["create_upload"])
|
|
37
|
+
begin
|
|
38
|
+
JSON.parse(RestClient.post(url, {}))
|
|
39
|
+
rescue RestClient::UnprocessableEntity => e
|
|
40
|
+
print "error!\n".color(:red)
|
|
41
|
+
json = JSON.parse(e.response)
|
|
42
|
+
json.each do |k,v|
|
|
43
|
+
puts "\n\t#{k}: #{v.join(", ")}\n"
|
|
44
|
+
end
|
|
45
|
+
puts
|
|
46
|
+
exit(1)
|
|
47
|
+
rescue RestClient::ResourceNotFound => e
|
|
48
|
+
print "failed!\n".color(:red)
|
|
49
|
+
exit(127)
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
def create_package(file_path, file_url, dist_id, files=nil, urls=nil, filetype=nil, coordinates=nil)
|
|
36
54
|
base_url = @config.base_url
|
|
37
55
|
url = PackageCloud::Util.compute_url(base_url, paths["create_package"])
|
|
38
|
-
params = {
|
|
39
|
-
|
|
56
|
+
params = {
|
|
57
|
+
:distro_version_id => dist_id,
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
if file_url
|
|
61
|
+
params[:url] = file_url
|
|
62
|
+
else
|
|
63
|
+
params[:package_file] = File.new(file_path, 'rb')
|
|
64
|
+
end
|
|
40
65
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
66
|
+
if coordinates
|
|
67
|
+
params[:coordinates] = coordinates
|
|
68
|
+
end
|
|
44
69
|
|
|
45
70
|
if filetype == "dsc"
|
|
46
|
-
|
|
47
|
-
|
|
71
|
+
if urls
|
|
72
|
+
params[:source_urls] = urls
|
|
73
|
+
else
|
|
74
|
+
params[:source_files] = files.map do |f|
|
|
75
|
+
File.new(f, 'rb')
|
|
76
|
+
end
|
|
48
77
|
end
|
|
49
|
-
params.merge!({:source_files => file_ios})
|
|
50
78
|
end
|
|
51
79
|
|
|
52
|
-
RestClient::Request.execute(
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
80
|
+
RestClient::Request.execute(
|
|
81
|
+
:method => 'post',
|
|
82
|
+
:url => url,
|
|
83
|
+
:timeout => nil,
|
|
84
|
+
:payload => { :package => params },
|
|
85
|
+
)
|
|
86
|
+
|
|
56
87
|
print "success!\n".color(:green)
|
|
57
88
|
end
|
|
58
89
|
|
data/package_cloud.gemspec
CHANGED
|
@@ -13,6 +13,7 @@ Gem::Specification.new do |spec|
|
|
|
13
13
|
|
|
14
14
|
spec.homepage = "https://packagecloud.io"
|
|
15
15
|
spec.license = "MIT"
|
|
16
|
+
spec.required_ruby_version = ">= 2.6"
|
|
16
17
|
|
|
17
18
|
spec.files = `git ls-files`.split($/)
|
|
18
19
|
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
|
@@ -20,12 +21,13 @@ Gem::Specification.new do |spec|
|
|
|
20
21
|
spec.require_paths = ["lib"]
|
|
21
22
|
|
|
22
23
|
spec.add_runtime_dependency "thor", "~> 1.2"
|
|
23
|
-
spec.add_runtime_dependency "highline", "~> 2.0
|
|
24
|
+
spec.add_runtime_dependency "highline", "~> 2.0"
|
|
24
25
|
spec.add_runtime_dependency "rest-client", "~> 2.0"
|
|
25
|
-
spec.add_runtime_dependency "
|
|
26
|
-
spec.add_runtime_dependency "
|
|
26
|
+
spec.add_runtime_dependency "json", "~> 2.9"
|
|
27
|
+
spec.add_runtime_dependency "abbrev", "~> 0.1"
|
|
28
|
+
spec.add_runtime_dependency "rainbow", "~> 2.2"
|
|
27
29
|
|
|
28
|
-
spec.add_development_dependency "bundler"
|
|
30
|
+
spec.add_development_dependency "bundler"
|
|
29
31
|
spec.add_development_dependency "rake"
|
|
30
32
|
spec.add_development_dependency "mdl"
|
|
31
33
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: package_cloud
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.3.
|
|
4
|
+
version: 0.3.15
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Joe Damato
|
|
8
|
-
autorequire:
|
|
8
|
+
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2025-10-20 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: thor
|
|
@@ -30,14 +30,14 @@ dependencies:
|
|
|
30
30
|
requirements:
|
|
31
31
|
- - "~>"
|
|
32
32
|
- !ruby/object:Gem::Version
|
|
33
|
-
version: 2.0
|
|
33
|
+
version: '2.0'
|
|
34
34
|
type: :runtime
|
|
35
35
|
prerelease: false
|
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
|
37
37
|
requirements:
|
|
38
38
|
- - "~>"
|
|
39
39
|
- !ruby/object:Gem::Version
|
|
40
|
-
version: 2.0
|
|
40
|
+
version: '2.0'
|
|
41
41
|
- !ruby/object:Gem::Dependency
|
|
42
42
|
name: rest-client
|
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -53,47 +53,61 @@ dependencies:
|
|
|
53
53
|
- !ruby/object:Gem::Version
|
|
54
54
|
version: '2.0'
|
|
55
55
|
- !ruby/object:Gem::Dependency
|
|
56
|
-
name:
|
|
56
|
+
name: json
|
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
|
58
|
+
requirements:
|
|
59
|
+
- - "~>"
|
|
60
|
+
- !ruby/object:Gem::Version
|
|
61
|
+
version: '2.9'
|
|
62
|
+
type: :runtime
|
|
63
|
+
prerelease: false
|
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
65
|
+
requirements:
|
|
66
|
+
- - "~>"
|
|
67
|
+
- !ruby/object:Gem::Version
|
|
68
|
+
version: '2.9'
|
|
69
|
+
- !ruby/object:Gem::Dependency
|
|
70
|
+
name: abbrev
|
|
57
71
|
requirement: !ruby/object:Gem::Requirement
|
|
58
72
|
requirements:
|
|
59
73
|
- - "~>"
|
|
60
74
|
- !ruby/object:Gem::Version
|
|
61
|
-
version:
|
|
75
|
+
version: '0.1'
|
|
62
76
|
type: :runtime
|
|
63
77
|
prerelease: false
|
|
64
78
|
version_requirements: !ruby/object:Gem::Requirement
|
|
65
79
|
requirements:
|
|
66
80
|
- - "~>"
|
|
67
81
|
- !ruby/object:Gem::Version
|
|
68
|
-
version:
|
|
82
|
+
version: '0.1'
|
|
69
83
|
- !ruby/object:Gem::Dependency
|
|
70
84
|
name: rainbow
|
|
71
85
|
requirement: !ruby/object:Gem::Requirement
|
|
72
86
|
requirements:
|
|
73
|
-
- -
|
|
87
|
+
- - "~>"
|
|
74
88
|
- !ruby/object:Gem::Version
|
|
75
|
-
version: 2.2
|
|
89
|
+
version: '2.2'
|
|
76
90
|
type: :runtime
|
|
77
91
|
prerelease: false
|
|
78
92
|
version_requirements: !ruby/object:Gem::Requirement
|
|
79
93
|
requirements:
|
|
80
|
-
- -
|
|
94
|
+
- - "~>"
|
|
81
95
|
- !ruby/object:Gem::Version
|
|
82
|
-
version: 2.2
|
|
96
|
+
version: '2.2'
|
|
83
97
|
- !ruby/object:Gem::Dependency
|
|
84
98
|
name: bundler
|
|
85
99
|
requirement: !ruby/object:Gem::Requirement
|
|
86
100
|
requirements:
|
|
87
|
-
- - "
|
|
101
|
+
- - ">="
|
|
88
102
|
- !ruby/object:Gem::Version
|
|
89
|
-
version: '
|
|
103
|
+
version: '0'
|
|
90
104
|
type: :development
|
|
91
105
|
prerelease: false
|
|
92
106
|
version_requirements: !ruby/object:Gem::Requirement
|
|
93
107
|
requirements:
|
|
94
|
-
- - "
|
|
108
|
+
- - ">="
|
|
95
109
|
- !ruby/object:Gem::Version
|
|
96
|
-
version: '
|
|
110
|
+
version: '0'
|
|
97
111
|
- !ruby/object:Gem::Dependency
|
|
98
112
|
name: rake
|
|
99
113
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -163,7 +177,7 @@ homepage: https://packagecloud.io
|
|
|
163
177
|
licenses:
|
|
164
178
|
- MIT
|
|
165
179
|
metadata: {}
|
|
166
|
-
post_install_message:
|
|
180
|
+
post_install_message:
|
|
167
181
|
rdoc_options: []
|
|
168
182
|
require_paths:
|
|
169
183
|
- lib
|
|
@@ -171,15 +185,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
171
185
|
requirements:
|
|
172
186
|
- - ">="
|
|
173
187
|
- !ruby/object:Gem::Version
|
|
174
|
-
version: '
|
|
188
|
+
version: '2.6'
|
|
175
189
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
176
190
|
requirements:
|
|
177
191
|
- - ">="
|
|
178
192
|
- !ruby/object:Gem::Version
|
|
179
193
|
version: '0'
|
|
180
194
|
requirements: []
|
|
181
|
-
rubygems_version: 3.
|
|
182
|
-
signing_key:
|
|
195
|
+
rubygems_version: 3.5.22
|
|
196
|
+
signing_key:
|
|
183
197
|
specification_version: 4
|
|
184
198
|
summary: The https://packagecloud.io CLI for uploading Node.js, Debian, RPM, RubyGem,
|
|
185
199
|
Python, and Java packages. Check our website or the RubyDoc documentation for detailed
|