package_cloud 0.3.00 → 0.3.02

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a7b7267e4072d89dfb7b37402fab0562c751942f
4
- data.tar.gz: 5bf8178c9882d9bc6cb27d10f3ed579f89ee1917
3
+ metadata.gz: a53ac5d579105b8fa81aad30b5da73057ebea78e
4
+ data.tar.gz: 05def5f60f2367cd5bf1136b93280e6165e18a4c
5
5
  SHA512:
6
- metadata.gz: 05aa38f73f717f09eb5c3463f8c81aa1d19a9fa2ca3c2b88fbc3a8ccc1c853bba0735c7926ffa6a059d62ed9bc27208bb8f1e4b64ae9a40e4a59254bc5a75c14
7
- data.tar.gz: d9670c97b42e3b8bc4decfa718fd284859937aaaad2175a0747b4673d797cf1443704808a9e38d2bba248e9b550b424fe6da083ce8cf072d997e49397c7cacad
6
+ metadata.gz: b0f41df24be0a738ed0cd5c255c6a184449690189357b81ace3a9c7c41edc860db7c7ba13da643822d79be27d0cc122050ce4f6d8fe84fb896738678dce159f6
7
+ data.tar.gz: 0b4dc62bfe2f6e13e5f5956a067b065b88966160dd5120d05a07336e9015b72cd110632fc164e1e2a68663856d1b9007e9c4b4e01baeb809874f5737b86a4db1
data/README.md CHANGED
@@ -9,8 +9,8 @@ Only Ruby 2.x and greater is supported, please use version 0.2.45 for Ruby 1.9 s
9
9
  ## Overview
10
10
  The `package_cloud` command line client allows you to easily:
11
11
 
12
- * Create Debian, RPM, RubyGem, Python, and Maven package repositories on [packagecloud](https://packagecloud.io).
13
- * Upload Debian, RPM, RubyGem, Python, and Java JAR/WAR packages to your repositories.
12
+ * Create Node.js, Debian, RPM, RubyGem, Python, and Maven package repositories on [packagecloud](https://packagecloud.io).
13
+ * Upload Node.js, Debian, RPM, RubyGem, Python, and Java JAR/WAR/AAR packages to your repositories.
14
14
  * [Delete packages](https://packagecloud.io/docs#yank_pkg).
15
15
  * [Promote packages](https://packagecloud.io/docs#promote_pkg) between repositories.
16
16
  * Upload a package signing GPG key.
@@ -84,7 +84,7 @@ uploading. See the examples that follow for more information.
84
84
  Please note that packages will be available for download via the packagecloud web UI
85
85
  immediately after they are uploaded, but they will not necessarily be
86
86
  available for installation via a package manager immediately. This is because
87
- our system rengenerates the repository metadata needed by package managers as a
87
+ our system regenerates the repository metadata needed by package managers as a
88
88
  background job on our system. Jobs are added to a queue and processed.
89
89
  Processing time depends on the number of packages in your repository and the
90
90
  number of reindex jobs in front of yours.
@@ -174,7 +174,7 @@ If you'd like to upload a Python egg despite this, you can do so by running:
174
174
  $ package_cloud push example-user/example-repository/python /tmp/example.egg
175
175
  ```
176
176
 
177
- #### Uploading a Java JAR or WAR package
177
+ #### Uploading a Java JAR, WAR, or AAR package
178
178
 
179
179
  You can upload a Java JAR package found at the path `/tmp/example.jar` by
180
180
  running:
@@ -195,6 +195,14 @@ coordinates manually on the command line:
195
195
  $ package_cloud push example-user/example-repository/java/maven2 /tmp/example.jar --coordinates=com.mygroup:packagename:1.0.2
196
196
  ```
197
197
 
198
+ #### Uploading a Node.js package
199
+
200
+ To upload a Node.js package located at `/tmp/test-1.0.0.tgz` to a packagecloud NPM registry called `example-user/example-repository`:
201
+
202
+ ```
203
+ $ package_cloud push example-user/example-repository/node /tmp/example-1.0.tgz
204
+ ```
205
+
198
206
  #### Additional options
199
207
 
200
208
  There are a few additional options you can use to fine tune package upload for
@@ -251,7 +259,7 @@ metadata.
251
259
 
252
260
  #### Deleting an RPM package
253
261
 
254
- You can delete an RPM package named `example-1.0-1.x86_64.rpm' that was
262
+ You can delete an RPM package named `example-1.0-1.x86_64.rpm` that was
255
263
  uploaded for CentOS 6 from the repository `example-repository` owned by
256
264
  the user `example-user` by running the following command:
257
265
 
@@ -282,7 +290,7 @@ You can delete a Python package named `example-1.0.1.whl` from the repository
282
290
  command:
283
291
 
284
292
  ```
285
- $ package_cloud yank example-user/example-repository example-1.0.1.whl
293
+ $ package_cloud yank example-user/example-repository/python example-1.0.1.whl
286
294
  ```
287
295
 
288
296
  This will delete the package and trigger a reindex of the repository's metadata.
@@ -291,17 +299,36 @@ Python eggs and sdists can be deleted in a similar manner.
291
299
 
292
300
  #### Deleting a Java package
293
301
 
294
- You can delete a Java package named `example-1.0.3.jar` from the repository
302
+ You can delete a Java package named `example-1.0.3.jar` with the group `com.groupid` from the repository
295
303
  `example-repository` owned by the user `example-user` by running the following
296
304
  command:
297
305
 
298
306
  ```
299
- $ package_cloud yank example-user/example-repository example-1.0.3.jar
307
+ $ package_cloud yank example-user/example-repository/java com.groupid/example-1.0.3.jar
300
308
  ```
301
309
 
302
310
  This will delete the package and trigger a reindex of the repository's
303
311
  metadata. WARs can be deleted in a similar manner.
304
312
 
313
+ #### Deleting a Node.js package
314
+
315
+ You can delete a Node.js package named `example-1.0.tgz` from the NPM registry
316
+ `example-repository` owned by the user `example-user` by running the following
317
+ command:
318
+
319
+ ```
320
+ $ package_cloud yank example-user/example-repository/node example-1.0.tgz
321
+ ```
322
+
323
+ If the package has a scope, you can delete it by passing the scope like so:
324
+
325
+ ```
326
+ $ package_cloud yank example-user/example-repository/node @scoped-user/example-1.0.tgz
327
+ ```
328
+
329
+ This will delete the package and trigger a reindex of the registry's
330
+ metadata.
331
+
305
332
  ### GPG Keys
306
333
 
307
334
  Some package managers use [GPG keys](https://packagecloud.io/docs#gpg)
@@ -372,6 +399,19 @@ named `repo2`, you would issue the following command:
372
399
  $ package_cloud promote example-user/repo1/ubuntu/xenial example_1.0-1_amd64.deb example-user/repo2
373
400
  ```
374
401
 
402
+ If the package has a scope (Node.js packages), you can promote it by including the scope like so:
403
+
404
+ ```
405
+ $ package_cloud promote example-user/repo1/node @scoped-user/example-1.0.tgz example-user/repo2
406
+ ```
407
+
408
+ If the package has a group (Java packages), you can promote it by including the group like so:
409
+
410
+ ```
411
+ $ package_cloud promote example-user/repo1/java com.groupid/jake-2.3.jar example-user/repo2
412
+ ```
413
+
414
+
375
415
  After the package is moved, a reindex will be triggered for both `repo1` and
376
416
  `repo2`.
377
417
 
@@ -1,5 +1,10 @@
1
1
  module PackageCloud
2
2
  module CLI
3
+ JAVA_EXTS = ["jar", "aar", "war"]
4
+ PY_EXTS = ["gz", "bz2", "z", "tar", "egg-info", "zip", "whl", "egg"]
5
+ NODE_EXTS = ["tgz"]
6
+ SUPPORTED_EXTS = JAVA_EXTS + PY_EXTS + NODE_EXTS + ["gem", "deb", "rpm", "dsc"]
7
+
3
8
  class Entry < Base
4
9
  desc "repository SUBCMD ...ARGS", "manage repositories"
5
10
  subcommand "repository", Repository
@@ -16,13 +21,13 @@ module PackageCloud
16
21
  desc "gpg_key SUBCMD ...ARGS", "manage GPG keys"
17
22
  subcommand "gpg_key", GpgKey
18
23
 
19
- desc "promote user/repo[/distro/version] package_name user/destination_repo",
24
+ desc "promote user/repo[/distro/version] [@scope/]package_name user/destination_repo",
20
25
  "promotes a package from user/repo [in dist/version] to user/destination_repo [also in dist/version]"
21
26
  def promote(source_repo_desc, package_name, dest_repo_desc)
22
27
  repo_name = source_repo_desc.split("/")[0..1].join("/")
23
28
  dist = source_repo_desc.split("/")[2..3].join("/")
24
29
 
25
- dest_repo_name = dest_repo_desc.split("/")[0..1].join("/")
30
+ dest_repo_name = expand_dist_shortcut(dest_repo_desc.split("/")[0..1].join("/"))
26
31
 
27
32
  if dist == "" && package_name =~ /\.gem$/
28
33
  dist = "gems"
@@ -36,19 +41,25 @@ module PackageCloud
36
41
  repo = client.repository(dest_repo_desc)
37
42
  print "success!\n"
38
43
 
39
- print "Attempting to promote #{repo_name}/#{dist}/#{package_name} to #{dest_repo_name}..."
40
- packages = src_repo.promote(dist, package_name, dest_repo_name)
44
+ if package_name.include?('@')
45
+ print "Attempting to promote scoped package #{repo_name}/#{dist} #{package_name} to #{dest_repo_name}..."
46
+ scope, unscoped_package_name = package_scope(package_name)
47
+ packages = src_repo.promote(dist, unscoped_package_name, dest_repo_name, scope)
48
+ else
49
+ print "Attempting to promote #{repo_name}/#{dist}/#{package_name} to #{dest_repo_name}..."
50
+ packages = src_repo.promote(dist, package_name, dest_repo_name)
51
+ end
41
52
  puts "done!".color(:green)
42
53
  end
43
54
 
44
- desc "yank user/repo[/distro/version] package_name",
55
+ desc "yank user/repo[/distro/version] [@scope/]package_name",
45
56
  "yank package from user/repo [in dist/version]"
46
57
  def yank(repo_desc, package_name)
47
58
  ARGV.clear # otherwise gets explodes
48
59
 
49
60
  # strip os/dist
50
61
  repo_name = repo_desc.split("/")[0..1].join("/")
51
- dist = repo_desc.split("/")[2..3].join("/")
62
+ dist = expand_dist_shortcut(repo_desc.split("/")[2..3].join("/"))
52
63
 
53
64
  if dist == "" && package_name =~ /\.gem$/
54
65
  dist = "gems"
@@ -58,8 +69,14 @@ module PackageCloud
58
69
  repo = client.repository(repo_desc)
59
70
  print "success!\n"
60
71
 
61
- print "Attempting to yank package at #{repo_name}/#{dist}/#{package_name}..."
62
- packages = repo.yank(dist, package_name)
72
+ if package_name.include?('@')
73
+ scope, unscoped_package_name = package_scope(package_name)
74
+ print "Attempting to yank scoped package at #{repo_name}/#{dist} #{package_name}..."
75
+ repo.yank(dist, unscoped_package_name, scope)
76
+ else
77
+ print "Attempting to yank package at #{repo_name}/#{dist}/#{package_name}..."
78
+ repo.yank(dist, package_name)
79
+ end
63
80
  puts "done!".color(:green)
64
81
  end
65
82
 
@@ -90,10 +107,10 @@ module PackageCloud
90
107
  end
91
108
 
92
109
  invalid_packages = package_files.select do |f|
93
- !["gem", "deb", "rpm", "dsc", "gz", "bz2", "z", "tar", "egg-info", "zip", "whl", "egg", "jar", "aar"].include?(f.split(".").last.downcase)
110
+ !SUPPORTED_EXTS.include?(f.split(".").last.downcase)
94
111
  end
95
112
 
96
- if ["jar", "aar"].include?(exts.first.downcase) && options.has_key?("coordinates")
113
+ if JAVA_EXTS.include?(exts.first.downcase) && options.has_key?("coordinates")
97
114
  puts "Using coordinates #{options["coordinates"].color(:yellow)}"
98
115
  end
99
116
 
@@ -102,7 +119,7 @@ module PackageCloud
102
119
  invalid_packages.each do |p|
103
120
  message << " #{p}\n"
104
121
  end
105
- message << "\npackage_cloud only supports debs, gems, jars, python packages, and rpms.".color(:red)
122
+ message << "\npackage_cloud only supports node.js, deb, gem, java, python, or rpm packages".color(:red)
106
123
  abort(message)
107
124
  end
108
125
 
@@ -117,9 +134,11 @@ module PackageCloud
117
134
  end
118
135
 
119
136
  validator = Validator.new(client)
120
- if ["gz", "bz2", "z", "tar", "egg-info", "zip", "whl", "egg"].include?(exts.first.downcase)
137
+ if PY_EXTS.include?(exts.first.downcase)
121
138
  dist_id = validator.distribution_id(repo, package_files, 'py')
122
- elsif ["jar", "aar"].include?(exts.first.downcase)
139
+ elsif NODE_EXTS.include?(exts.first.downcase)
140
+ dist_id = validator.distribution_id(repo, package_files, 'node')
141
+ elsif JAVA_EXTS.include?(exts.first.downcase)
123
142
  abort_if_snapshot!(package_files)
124
143
  dist_id = validator.distribution_id(repo, package_files, 'jar')
125
144
  else
@@ -167,6 +186,29 @@ module PackageCloud
167
186
  end
168
187
 
169
188
  private
189
+ def expand_dist_shortcut(dist)
190
+ case dist
191
+ when 'java'
192
+ 'java/maven2'
193
+ when 'python'
194
+ 'python/1'
195
+ when 'node'
196
+ 'node/1'
197
+ else
198
+ dist
199
+ end
200
+ end
201
+
202
+ def package_scope(package_name)
203
+ name_parts = package_name.split('/')
204
+ if name_parts.size != 2 || !package_name.include?('@')
205
+ abort("Could not determine scope for '#{package_name}', it should look like: @my-scope/package-1.0.tgz".color(:red))
206
+ end
207
+ scope = name_parts[0]
208
+ unscoped_package_name = name_parts[1]
209
+ [scope, unscoped_package_name]
210
+ end
211
+
170
212
  def abort_if_snapshot!(files)
171
213
  if files.any? { |file| file.include?("-SNAPSHOT") }
172
214
  abort("SNAPSHOT uploads are not supported by the CLI, please use Maven instead: https://packagecloud.io/docs#wagon-instructions")
@@ -130,10 +130,14 @@ module PackageCloud
130
130
  resp
131
131
  end
132
132
 
133
- def promote(dist, package_name, dest_repo_name)
133
+ def promote(dist, package_name, dest_repo_name, scope=nil)
134
134
  begin
135
135
  url = PackageCloud::Util.compute_url(@config.base_url, paths["self"] + "/" + [dist, package_name, "promote.json"].compact.join("/"))
136
- resp = RestClient.post(url, :destination => dest_repo_name)
136
+ resp = if scope
137
+ RestClient.post(url, destination: dest_repo_name, scope: scope)
138
+ else
139
+ RestClient.post(url, destination: dest_repo_name)
140
+ end
137
141
  resp = JSON.parse(resp)
138
142
  rescue RestClient::ResourceNotFound => e
139
143
  print "error:\n".color(:red)
@@ -146,10 +150,14 @@ module PackageCloud
146
150
  end
147
151
  end
148
152
 
149
- def yank(dist, package_name)
153
+ def yank(dist, package_name, scope=nil)
150
154
  begin
151
155
  url = PackageCloud::Util.compute_url(@config.base_url, paths["self"] + "/" + [dist, package_name].compact.join("/"))
152
- RestClient.delete(url)
156
+ if scope
157
+ RestClient.delete(url, params: { scope: scope })
158
+ else
159
+ RestClient.delete(url)
160
+ end
153
161
  rescue RestClient::ResourceNotFound => e
154
162
  print "error:\n".color(:red)
155
163
  json = JSON.parse(e.response)
@@ -8,10 +8,8 @@ module PackageCloud
8
8
  if distributions[package_type]
9
9
  _,_,dist_sel,ver_sel = repo.split("/")
10
10
 
11
- if dist_sel == "python"
12
- dist = distributions[package_type].detect { |d| d["index_name"] == dist_sel }
13
- dist["versions"].first["id"]
14
- elsif dist_sel == "java"
11
+ # These are all 'single version' distros
12
+ if (dist_sel == "python" || dist_sel == "java" || dist_sel == "node")
15
13
  dist = distributions[package_type].detect { |d| d["index_name"] == dist_sel }
16
14
  dist["versions"].first["id"]
17
15
  elsif dist_sel && ver_sel
@@ -1,7 +1,7 @@
1
1
  module PackageCloud
2
2
  MAJOR_VERSION = "0"
3
3
  MINOR_VERSION = "3"
4
- PATCH_VERSION = "00"
4
+ PATCH_VERSION = "02"
5
5
 
6
6
  VERSION = [MAJOR_VERSION, MINOR_VERSION, PATCH_VERSION].join(".")
7
7
  end
@@ -8,8 +8,8 @@ Gem::Specification.new do |spec|
8
8
  spec.version = PackageCloud::VERSION
9
9
  spec.authors = ["Joe Damato"]
10
10
  spec.email = ["support@packagecloud.io"]
11
- spec.description = %q{The https://packagecloud.io CLI for uploading Debian, RPM, RubyGem, Python, and Java packages. Check our website or the RubyDoc documentation for detailed information.}
12
- spec.summary = %q{The https://packagecloud.io CLI for uploading Debian, RPM, RubyGem, Python, and Java packages. Check our website or the RubyDoc documentation for detailed information.}
11
+ spec.description = %q{The https://packagecloud.io CLI for uploading Node.js, Debian, RPM, RubyGem, Python, and Java packages. Check our website or the RubyDoc documentation for detailed information.}
12
+ spec.summary = %q{The https://packagecloud.io CLI for uploading Node.js, Debian, RPM, RubyGem, Python, and Java packages. Check our website or the RubyDoc documentation for detailed information.}
13
13
 
14
14
  spec.homepage = "https://packagecloud.io"
15
15
  spec.license = "MIT"
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.00
4
+ version: 0.3.02
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joe Damato
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-10-18 00:00:00.000000000 Z
11
+ date: 2017-12-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -108,8 +108,9 @@ dependencies:
108
108
  - - ">="
109
109
  - !ruby/object:Gem::Version
110
110
  version: '0'
111
- description: The https://packagecloud.io CLI for uploading Debian, RPM, RubyGem, Python,
112
- and Java packages. Check our website or the RubyDoc documentation for detailed information.
111
+ description: The https://packagecloud.io CLI for uploading Node.js, Debian, RPM, RubyGem,
112
+ Python, and Java packages. Check our website or the RubyDoc documentation for detailed
113
+ information.
113
114
  email:
114
115
  - support@packagecloud.io
115
116
  executables:
@@ -166,6 +167,7 @@ rubyforge_project:
166
167
  rubygems_version: 2.6.13
167
168
  signing_key:
168
169
  specification_version: 4
169
- summary: The https://packagecloud.io CLI for uploading Debian, RPM, RubyGem, Python,
170
- and Java packages. Check our website or the RubyDoc documentation for detailed information.
170
+ summary: The https://packagecloud.io CLI for uploading Node.js, Debian, RPM, RubyGem,
171
+ Python, and Java packages. Check our website or the RubyDoc documentation for detailed
172
+ information.
171
173
  test_files: []