package_cloud 0.3.00 → 0.3.07
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +114 -45
- data/lib/package_cloud/cli/distro.rb +1 -1
- data/lib/package_cloud/cli/entry.rb +77 -14
- data/lib/package_cloud/config_file.rb +4 -0
- data/lib/package_cloud/repository.rb +13 -5
- data/lib/package_cloud/validator.rb +3 -5
- data/lib/package_cloud/version.rb +1 -1
- data/markdown_lint_config.rb +2 -0
- data/package_cloud.gemspec +3 -2
- metadata +24 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f9a2b9a23675e7111f4d7a5bdae131bfa6ca037c
|
4
|
+
data.tar.gz: 2064cb76dfb3155849b76cabc3f2d4cd7b1720cc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 03b0aeb185803c8399b770ef758a357c3eb3bf181ca6ed1e841206afdff72dbfcd1f34e8a5dcae13db6083b301425887148f8e0279ac6a28a42ec0fd4ef88596
|
7
|
+
data.tar.gz: c55d5fd8caf861fe2901bf137480e0f3603fea7d17c7d61400f56985379d47ec88cbdefa05a65e95b788b6d95f489458bc5a93fb0e7c404750ec707affee3267
|
data/README.md
CHANGED
@@ -3,29 +3,36 @@
|
|
3
3
|
Greetings! Welcome to the [packagecloud](https://packagecloud.io) command line
|
4
4
|
client, `package_cloud`.
|
5
5
|
|
6
|
-
|
6
|
+
## Requirements
|
7
|
+
|
7
8
|
Only Ruby 2.x and greater is supported, please use version 0.2.45 for Ruby 1.9 support.
|
8
9
|
|
9
10
|
## Overview
|
11
|
+
|
10
12
|
The `package_cloud` command line client allows you to easily:
|
11
13
|
|
12
|
-
* Create Debian, RPM, RubyGem, Python, and Maven package repositories
|
13
|
-
|
14
|
+
* Create Node.js, Debian, RPM, RubyGem, Python, and Maven package repositories
|
15
|
+
on [packagecloud](https://packagecloud.io).
|
16
|
+
* Upload Node.js, Debian, RPM, RubyGem, Python, and Java JAR/WAR/AAR packages
|
17
|
+
to your repositories.
|
14
18
|
* [Delete packages](https://packagecloud.io/docs#yank_pkg).
|
15
|
-
* [Promote packages](https://packagecloud.io/docs#promote_pkg) between
|
19
|
+
* [Promote packages](https://packagecloud.io/docs#promote_pkg) between
|
20
|
+
repositories.
|
16
21
|
* Upload a package signing GPG key.
|
17
22
|
* Create and delete [master and read
|
18
23
|
tokens](https://packagecloud.io/docs#token_auth) to control repository
|
19
24
|
access.
|
20
25
|
|
21
26
|
This tool is intended to be used on the command line either manually or in an
|
22
|
-
automated environment (like a build or CI process).
|
27
|
+
automated environment (like a build or CI process). See more examples on how
|
28
|
+
to use the command-line interface by visiting the
|
29
|
+
[CLI page](https://packagecloud.io/l/cli).
|
23
30
|
|
24
31
|
## Installation
|
25
32
|
|
26
33
|
Simply run:
|
27
34
|
|
28
|
-
|
35
|
+
gem install package_cloud
|
29
36
|
|
30
37
|
to install the command line client.
|
31
38
|
|
@@ -51,10 +58,11 @@ You can interact with our system programmatically as well by using our
|
|
51
58
|
|
52
59
|
### Creating a repository
|
53
60
|
|
54
|
-
You can create a package repository named 'example' on
|
61
|
+
You can create a package repository named 'example' on
|
62
|
+
[packagecloud](https://packagecloud.io) by running:
|
55
63
|
|
56
64
|
```
|
57
|
-
|
65
|
+
package_cloud repository create example
|
58
66
|
```
|
59
67
|
|
60
68
|
### Environment variables
|
@@ -66,11 +74,12 @@ that will override the settings found in `~/.packagecloud`:
|
|
66
74
|
token (available [here](https://packagecloud.io/api_token)). If set, the
|
67
75
|
CLI *will not* read the `~/.packagecloud` configuration file to get the API
|
68
76
|
token.
|
77
|
+
|
69
78
|
2. If and only if the `PACKAGECLOUD_TOKEN` variable is set, you may also set
|
70
79
|
`PACKAGECLOUD_URL`. This environment should only be used by
|
71
80
|
packagecloud:enterprise customers. It allows you to set the URL of the
|
72
81
|
packagecloud installation. Customers using our hosted, cloud based product
|
73
|
-
should not set this variable; it is defaulted to http://packagecloud.io
|
82
|
+
should not set this variable; it is defaulted to `http://packagecloud.io`
|
74
83
|
automatically.
|
75
84
|
|
76
85
|
### Pushing a package
|
@@ -81,15 +90,17 @@ repository you've created by using the `push` command.
|
|
81
90
|
Most package types require specifying a `distribution/version` pair when
|
82
91
|
uploading. See the examples that follow for more information.
|
83
92
|
|
84
|
-
Please note that packages will be available for download via the packagecloud
|
93
|
+
Please note that packages will be available for download via the packagecloud
|
94
|
+
web UI
|
85
95
|
immediately after they are uploaded, but they will not necessarily be
|
86
96
|
available for installation via a package manager immediately. This is because
|
87
|
-
our system
|
97
|
+
our system regenerates the repository metadata needed by package managers as a
|
88
98
|
background job on our system. Jobs are added to a queue and processed.
|
89
99
|
Processing time depends on the number of packages in your repository and the
|
90
100
|
number of reindex jobs in front of yours.
|
91
101
|
|
92
|
-
The following examples will show an example user name of `example-user` and a
|
102
|
+
The following examples will show an example user name of `example-user` and a
|
103
|
+
repository
|
93
104
|
name of `example-repository`.
|
94
105
|
|
95
106
|
After the examples below, there will be an additional section documenting
|
@@ -97,10 +108,11 @@ important optional parameters you can specify when pushing packages.
|
|
97
108
|
|
98
109
|
#### Uploading a Debian package
|
99
110
|
|
100
|
-
You can upload a Debian package found at the path `/tmp/example.deb` for
|
111
|
+
You can upload a Debian package found at the path `/tmp/example.deb` for
|
112
|
+
Ubuntu Xenial by running:
|
101
113
|
|
102
114
|
```
|
103
|
-
|
115
|
+
package_cloud push example-user/example-repository/ubuntu/xenial /tmp/example.deb
|
104
116
|
```
|
105
117
|
|
106
118
|
This command will upload `/tmp/example.deb` to the `example-repository`
|
@@ -110,7 +122,7 @@ We also support Debian source packages (DSCs). You can upload a
|
|
110
122
|
`/tmp/example.dsc` for Ubuntu Xenial by running:
|
111
123
|
|
112
124
|
```
|
113
|
-
|
125
|
+
package_cloud push example-user/example-repository/ubuntu/xenial /tmp/example.dsc
|
114
126
|
```
|
115
127
|
|
116
128
|
Note that all files associated with the DSC (like source tarballs, patches,
|
@@ -126,7 +138,7 @@ You can upload an RPM package found at the path `/tmp/example.rpm` for CentOS
|
|
126
138
|
6 by running:
|
127
139
|
|
128
140
|
```
|
129
|
-
|
141
|
+
package_cloud push example-user/example-repository/el/6 /tmp/example.rpm
|
130
142
|
```
|
131
143
|
|
132
144
|
This command will upload `/tmp/example.rpm` to the `example-repository`
|
@@ -143,7 +155,7 @@ You can upload a RubyGem package found at the path `/tmp/example.gem` by
|
|
143
155
|
running:
|
144
156
|
|
145
157
|
```
|
146
|
-
|
158
|
+
package_cloud push example-user/example-repository /tmp/example.gem
|
147
159
|
```
|
148
160
|
|
149
161
|
This command will upload `/tmp/example.gem` to the `example-repository`
|
@@ -158,7 +170,7 @@ You can upload a Python package found at the path `/tmp/example.whl` by
|
|
158
170
|
running:
|
159
171
|
|
160
172
|
```
|
161
|
-
|
173
|
+
package_cloud push example-user/example-repository/python /tmp/example.whl
|
162
174
|
```
|
163
175
|
|
164
176
|
This command will upload `/tmp/example.whl` to the `example-repository`
|
@@ -171,28 +183,38 @@ eggs in PyPI repositories.
|
|
171
183
|
If you'd like to upload a Python egg despite this, you can do so by running:
|
172
184
|
|
173
185
|
```
|
174
|
-
|
186
|
+
package_cloud push example-user/example-repository/python /tmp/example.egg
|
175
187
|
```
|
176
188
|
|
177
|
-
#### Uploading a Java JAR or
|
189
|
+
#### Uploading a Java JAR, WAR, or AAR package
|
178
190
|
|
179
191
|
You can upload a Java JAR package found at the path `/tmp/example.jar` by
|
180
192
|
running:
|
181
193
|
|
182
194
|
```
|
183
|
-
|
195
|
+
package_cloud push example-user/example-repository/java/maven2 /tmp/example.jar
|
184
196
|
```
|
185
197
|
|
186
198
|
WAR files can be uploaded the same way.
|
187
199
|
|
188
200
|
It is important to note that in some cases (for example: 'fat JARs', or JARs
|
189
|
-
without `pom.xml` files, etc) our system will not be able to automatically
|
201
|
+
without `pom.xml` files, etc) our system will not be able to automatically
|
202
|
+
detect
|
190
203
|
the [Maven coordinates](https://maven.apache.org/pom.html#Maven_Coordinates).
|
191
204
|
In these cases you will receive an error, and you should specify the
|
192
205
|
coordinates manually on the command line:
|
193
206
|
|
194
207
|
```
|
195
|
-
|
208
|
+
package_cloud push example-user/example-repository/java/maven2 /tmp/example.jar --coordinates=com.mygroup:packagename:1.0.2
|
209
|
+
```
|
210
|
+
|
211
|
+
#### Uploading a Node.js package
|
212
|
+
|
213
|
+
To upload a Node.js package located at `/tmp/test-1.0.0.tgz` to a packagecloud
|
214
|
+
NPM registry called `example-user/example-repository`:
|
215
|
+
|
216
|
+
```
|
217
|
+
package_cloud push example-user/example-repository/node /tmp/example-1.0.tgz
|
196
218
|
```
|
197
219
|
|
198
220
|
#### Additional options
|
@@ -214,7 +236,8 @@ more advanced use cases:
|
|
214
236
|
continue uploading packages.
|
215
237
|
* `--coordinates` - This flag is used for Java JARs or WARs which do not have
|
216
238
|
an internal `pom.xml` specifying the Maven coordinates. You can specify your
|
217
|
-
own Maven coordinates for this file using this flag:
|
239
|
+
own Maven coordinates for this file using this flag:
|
240
|
+
`--coordinates=com.mygroup:packagename:1.0.2`.
|
218
241
|
* `--config` - This flag is used to specify a custom configuration file path
|
219
242
|
for the CLI. This file specifies the website URL and your API token. This is
|
220
243
|
default to `~/.packagecloud`.
|
@@ -243,7 +266,7 @@ uploaded for Ubuntu Xenial from the repository `example-repository` owned by
|
|
243
266
|
the user `example-user` by running the following command:
|
244
267
|
|
245
268
|
```
|
246
|
-
|
269
|
+
package_cloud yank example-user/example-repository/ubuntu/xenial example_1.0.1-1_amd64.deb
|
247
270
|
```
|
248
271
|
|
249
272
|
This will delete the package and trigger a reindex of the repository's
|
@@ -251,12 +274,12 @@ metadata.
|
|
251
274
|
|
252
275
|
#### Deleting an RPM package
|
253
276
|
|
254
|
-
You can delete an RPM package named `example-1.0-1.x86_64.rpm
|
277
|
+
You can delete an RPM package named `example-1.0-1.x86_64.rpm` that was
|
255
278
|
uploaded for CentOS 6 from the repository `example-repository` owned by
|
256
279
|
the user `example-user` by running the following command:
|
257
280
|
|
258
281
|
```
|
259
|
-
|
282
|
+
package_cloud yank example-user/example-repository/el/6 example-1.0-1.x86_64.rpm
|
260
283
|
```
|
261
284
|
|
262
285
|
This will delete the package and trigger a reindex of the repository's
|
@@ -264,12 +287,12 @@ metadata.
|
|
264
287
|
|
265
288
|
#### Deleting a RubyGem package
|
266
289
|
|
267
|
-
You can delete a RubyGem package named `example-1.0.gem
|
290
|
+
You can delete a RubyGem package named `example-1.0.gem` from the
|
268
291
|
repository `example-repository` owned by the user `example-user`
|
269
292
|
by running the following command:
|
270
293
|
|
271
294
|
```
|
272
|
-
|
295
|
+
package_cloud yank example-user/example-repository example-1.0.gem
|
273
296
|
```
|
274
297
|
|
275
298
|
This will delete the package and trigger a reindex of the repository's
|
@@ -282,26 +305,51 @@ You can delete a Python package named `example-1.0.1.whl` from the repository
|
|
282
305
|
command:
|
283
306
|
|
284
307
|
```
|
285
|
-
|
308
|
+
package_cloud yank example-user/example-repository/python example-1.0.1.whl
|
286
309
|
```
|
287
310
|
|
288
311
|
This will delete the package and trigger a reindex of the repository's metadata.
|
289
312
|
Python eggs and sdists can be deleted in a similar manner.
|
290
313
|
|
291
|
-
|
292
314
|
#### Deleting a Java package
|
293
315
|
|
294
|
-
You can delete a Java package named `example-1.0.3.jar`
|
316
|
+
You can delete a Java package named `example-1.0.3.jar` with the group
|
317
|
+
`com.groupid` from the repository
|
295
318
|
`example-repository` owned by the user `example-user` by running the following
|
296
319
|
command:
|
297
320
|
|
298
321
|
```
|
299
|
-
|
322
|
+
package_cloud yank example-user/example-repository/java com.groupid/example-1.0.3.jar
|
300
323
|
```
|
301
324
|
|
302
325
|
This will delete the package and trigger a reindex of the repository's
|
303
326
|
metadata. WARs can be deleted in a similar manner.
|
304
327
|
|
328
|
+
#### Deleting a Node.js package
|
329
|
+
|
330
|
+
You can delete a Node.js package named `example-1.0.tgz` from the NPM registry
|
331
|
+
`example-repository` owned by the user `example-user` by running the following
|
332
|
+
command:
|
333
|
+
|
334
|
+
```
|
335
|
+
package_cloud yank example-user/example-repository/node example-1.0.tgz
|
336
|
+
```
|
337
|
+
|
338
|
+
If the package has a scope, you can delete it by passing the scope like so:
|
339
|
+
|
340
|
+
```
|
341
|
+
package_cloud yank example-user/example-repository/node @scoped-user/example-1.0.tgz
|
342
|
+
```
|
343
|
+
|
344
|
+
This will delete the package and trigger a reindex of the registry's
|
345
|
+
metadata.
|
346
|
+
|
347
|
+
Note that deleting Node.js packages can have unexpected side effects when
|
348
|
+
mixed with
|
349
|
+
[NPM distribution tags](https://docs.npmjs.com/getting-started/using-tags). Read
|
350
|
+
more about how [promoting on packagecloud can affect dist tags
|
351
|
+
here.](https://packagecloud.io/docs/#node_promote)
|
352
|
+
|
305
353
|
### GPG Keys
|
306
354
|
|
307
355
|
Some package managers use [GPG keys](https://packagecloud.io/docs#gpg)
|
@@ -324,7 +372,7 @@ your system at `/tmp/gpg.key` for the repository `example-repository` owned by
|
|
324
372
|
the user `example-user`, you can run the following command:
|
325
373
|
|
326
374
|
```
|
327
|
-
|
375
|
+
package_cloud gpg_key create example-user/example-repository /tmp/gpg.key
|
328
376
|
```
|
329
377
|
|
330
378
|
Note that if you attempt to upload a private key to packagecloud, we will
|
@@ -337,7 +385,7 @@ You can list the GPG keys associated with the repository `example-repository`
|
|
337
385
|
owned by user `example-user` by running the following command:
|
338
386
|
|
339
387
|
```
|
340
|
-
|
388
|
+
package_cloud gpg_key list example-user/example-repository
|
341
389
|
```
|
342
390
|
|
343
391
|
The key name specified in the output of this command is the key name you should
|
@@ -351,7 +399,7 @@ named `example-repository` and owned by the user `example-user` by running the
|
|
351
399
|
following command:
|
352
400
|
|
353
401
|
```
|
354
|
-
|
402
|
+
package_cloud gpg_key destroy example-user/example-repository example-user-example-repository-56D06.pub.gpg
|
355
403
|
```
|
356
404
|
|
357
405
|
You can get the key name for a key you'd like to delete by using the GPG key
|
@@ -361,19 +409,39 @@ list command above.
|
|
361
409
|
|
362
410
|
Package promotion is a feature which can be used to easily move packages
|
363
411
|
between repositories. This is useful for moving a package from a private
|
364
|
-
staging repository to a public production ready repository during a software
|
365
|
-
workflow.
|
412
|
+
staging repository to a public production ready repository during a software
|
413
|
+
release workflow.
|
366
414
|
|
367
415
|
To move a package named `example_1.0-1_amd64.deb` from the user
|
368
416
|
`example-user`'s repository named `repo1` over to the same users repository
|
369
417
|
named `repo2`, you would issue the following command:
|
370
418
|
|
371
419
|
```
|
372
|
-
|
420
|
+
package_cloud promote example-user/repo1/ubuntu/xenial example_1.0-1_amd64.deb example-user/repo2
|
421
|
+
```
|
422
|
+
|
423
|
+
If the package has a scope (Node.js packages), you can promote it by including
|
424
|
+
the scope like so:
|
425
|
+
|
426
|
+
```
|
427
|
+
package_cloud promote example-user/repo1/node @scoped-user/example-1.0.tgz example-user/repo2
|
428
|
+
```
|
429
|
+
|
430
|
+
If the package has a group (Java packages), you can promote it by
|
431
|
+
including the group like so:
|
432
|
+
|
433
|
+
```
|
434
|
+
package_cloud promote example-user/repo1/java com.groupid/jake-2.3.jar example-user/repo2
|
373
435
|
```
|
374
436
|
|
375
|
-
After the package is moved, a reindex will be triggered for both `repo1`
|
376
|
-
`repo2`.
|
437
|
+
After the package is moved, a reindex will be triggered for both `repo1`
|
438
|
+
and `repo2`.
|
439
|
+
|
440
|
+
Note that promoting Node.js packages can have unexpected side effects when
|
441
|
+
mixed with
|
442
|
+
[NPM distribution tags](https://docs.npmjs.com/getting-started/using-tags).
|
443
|
+
Read more about how [promoting on packagecloud can affect dist tags
|
444
|
+
here](https://packagecloud.io/docs/#node_promote).
|
377
445
|
|
378
446
|
### Creating, deleting, and listing master and read tokens
|
379
447
|
|
@@ -400,7 +468,7 @@ you can create a master token name "Example-Token" for the repository
|
|
400
468
|
command:
|
401
469
|
|
402
470
|
```
|
403
|
-
|
471
|
+
package_cloud master_token create example-user/example-repository Example-Token
|
404
472
|
```
|
405
473
|
|
406
474
|
#### Listing master tokens
|
@@ -410,7 +478,7 @@ You can list all master tokens associated with the repository
|
|
410
478
|
command:
|
411
479
|
|
412
480
|
```
|
413
|
-
|
481
|
+
package_cloud master_token list example-user/example-repository
|
414
482
|
```
|
415
483
|
|
416
484
|
#### Deleting master tokens
|
@@ -420,7 +488,7 @@ repository `example-repository` owned by the user `example-user` by running
|
|
420
488
|
the following command:
|
421
489
|
|
422
490
|
```
|
423
|
-
|
491
|
+
package_cloud master_token destroy example-user/example-repository Example-Token
|
424
492
|
```
|
425
493
|
|
426
494
|
This will also automatically delete all read tokens associated with this
|
@@ -429,4 +497,5 @@ tokens.
|
|
429
497
|
|
430
498
|
## Still need help?
|
431
499
|
|
432
|
-
Feel free to reach out to
|
500
|
+
Feel free to reach out to
|
501
|
+
[support@packagecloud.io](mailto:support@packagecloud.io) with questions.
|
@@ -12,7 +12,7 @@ module PackageCloud
|
|
12
12
|
if distros
|
13
13
|
puts "Listing distributions for #{package_type}:"
|
14
14
|
distros.each do |distro|
|
15
|
-
next if distro["index_name"] == "any"
|
15
|
+
next if (distro["index_name"] == "any" || distro["index_name"] == "rpm_any")
|
16
16
|
puts "\n #{parse_display_name(distro["display_name"])} (#{distro["index_name"]}):\n\n"
|
17
17
|
distro["versions"].each do |ver|
|
18
18
|
puts " #{parse_version_name(ver["display_name"])} (#{ver["index_name"]})"
|
@@ -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", "apk"]
|
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
|
-
dist = source_repo_desc.split("/")[2..3].join("/")
|
28
|
+
dist = expand_dist_shortcut(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,30 @@ module PackageCloud
|
|
36
41
|
repo = client.repository(dest_repo_desc)
|
37
42
|
print "success!\n"
|
38
43
|
|
39
|
-
|
40
|
-
|
44
|
+
if package_name.include?('@')
|
45
|
+
scope, unscoped_package_name = package_scope(package_name)
|
46
|
+
|
47
|
+
print "Attempting to promote scoped package #{scope}/#{unscoped_package_name} from #{repo_name}/#{dist} to #{dest_repo_name}..."
|
48
|
+
packages = src_repo.promote(dist, unscoped_package_name, dest_repo_name, scope)
|
49
|
+
else
|
50
|
+
print "Attempting to promote #{repo_name}/#{dist}/#{package_name} to #{dest_repo_name}..."
|
51
|
+
packages = src_repo.promote(dist, package_name, dest_repo_name)
|
52
|
+
end
|
41
53
|
puts "done!".color(:green)
|
54
|
+
|
55
|
+
if dist == "node/1"
|
56
|
+
puts "WARNING: This Node.js package will NOT be downloadable by clients until a dist tag is created. Read more: https://packagecloud.io/docs/#node_promote".color(:yellow)
|
57
|
+
end
|
42
58
|
end
|
43
59
|
|
44
|
-
desc "yank user/repo[/distro/version] package_name",
|
60
|
+
desc "yank user/repo[/distro/version] [@scope/]package_name",
|
45
61
|
"yank package from user/repo [in dist/version]"
|
46
62
|
def yank(repo_desc, package_name)
|
47
63
|
ARGV.clear # otherwise gets explodes
|
48
64
|
|
49
65
|
# strip os/dist
|
50
66
|
repo_name = repo_desc.split("/")[0..1].join("/")
|
51
|
-
dist = repo_desc.split("/")[2..3].join("/")
|
67
|
+
dist = expand_dist_shortcut(repo_desc.split("/")[2..3].join("/"))
|
52
68
|
|
53
69
|
if dist == "" && package_name =~ /\.gem$/
|
54
70
|
dist = "gems"
|
@@ -58,9 +74,19 @@ module PackageCloud
|
|
58
74
|
repo = client.repository(repo_desc)
|
59
75
|
print "success!\n"
|
60
76
|
|
61
|
-
|
62
|
-
|
77
|
+
if package_name.include?('@')
|
78
|
+
scope, unscoped_package_name = package_scope(package_name)
|
79
|
+
print "Attempting to yank scoped package at #{repo_name}/#{dist} #{package_name}..."
|
80
|
+
repo.yank(dist, unscoped_package_name, scope)
|
81
|
+
else
|
82
|
+
print "Attempting to yank package at #{repo_name}/#{dist}/#{package_name}..."
|
83
|
+
repo.yank(dist, package_name)
|
84
|
+
end
|
63
85
|
puts "done!".color(:green)
|
86
|
+
|
87
|
+
if dist == "node/1"
|
88
|
+
puts "WARNING: Deleting Node.js packages can have unexpected side effects with dist tags. Read more: https://packagecloud.io/docs/#node_delete".color(:yellow)
|
89
|
+
end
|
64
90
|
end
|
65
91
|
|
66
92
|
desc "push user/repo[/distro/version] /path/to/packages",
|
@@ -84,16 +110,17 @@ module PackageCloud
|
|
84
110
|
package_files << package_file
|
85
111
|
|
86
112
|
exts = package_files.map { |f| f.split(".").last }.uniq
|
113
|
+
exts = handle_special_exts(repo, exts)
|
87
114
|
|
88
115
|
if package_files.length > 1 && exts.length > 1
|
89
116
|
abort("You can't push multiple packages of different types at the same time.\nFor example, use *.deb to push all your debs at once.".color(:red))
|
90
117
|
end
|
91
118
|
|
92
119
|
invalid_packages = package_files.select do |f|
|
93
|
-
!
|
120
|
+
!SUPPORTED_EXTS.include?(f.split(".").last.downcase)
|
94
121
|
end
|
95
122
|
|
96
|
-
if
|
123
|
+
if JAVA_EXTS.include?(exts.first.downcase) && options.has_key?("coordinates")
|
97
124
|
puts "Using coordinates #{options["coordinates"].color(:yellow)}"
|
98
125
|
end
|
99
126
|
|
@@ -102,7 +129,7 @@ module PackageCloud
|
|
102
129
|
invalid_packages.each do |p|
|
103
130
|
message << " #{p}\n"
|
104
131
|
end
|
105
|
-
message << "\npackage_cloud only supports
|
132
|
+
message << "\npackage_cloud only supports node.js, deb, gem, java, python, or rpm packages".color(:red)
|
106
133
|
abort(message)
|
107
134
|
end
|
108
135
|
|
@@ -117,9 +144,11 @@ module PackageCloud
|
|
117
144
|
end
|
118
145
|
|
119
146
|
validator = Validator.new(client)
|
120
|
-
if
|
147
|
+
if PY_EXTS.include?(exts.first.downcase)
|
121
148
|
dist_id = validator.distribution_id(repo, package_files, 'py')
|
122
|
-
elsif
|
149
|
+
elsif NODE_EXTS.include?(exts.first.downcase)
|
150
|
+
dist_id = validator.distribution_id(repo, package_files, 'node')
|
151
|
+
elsif JAVA_EXTS.include?(exts.first.downcase)
|
123
152
|
abort_if_snapshot!(package_files)
|
124
153
|
dist_id = validator.distribution_id(repo, package_files, 'jar')
|
125
154
|
else
|
@@ -167,6 +196,40 @@ module PackageCloud
|
|
167
196
|
end
|
168
197
|
|
169
198
|
private
|
199
|
+
def handle_special_exts(repo, exts)
|
200
|
+
exts.map do |elem|
|
201
|
+
case elem
|
202
|
+
when 'apk'
|
203
|
+
elem = repo.include?("alpine") ? "alpine" : elem
|
204
|
+
else
|
205
|
+
elem
|
206
|
+
end
|
207
|
+
end
|
208
|
+
end
|
209
|
+
|
210
|
+
def expand_dist_shortcut(dist)
|
211
|
+
case dist
|
212
|
+
when 'java'
|
213
|
+
'java/maven2'
|
214
|
+
when 'python'
|
215
|
+
'python/1'
|
216
|
+
when 'node'
|
217
|
+
'node/1'
|
218
|
+
else
|
219
|
+
dist
|
220
|
+
end
|
221
|
+
end
|
222
|
+
|
223
|
+
def package_scope(package_name)
|
224
|
+
name_parts = package_name.split('/')
|
225
|
+
if name_parts.size != 2 || !package_name.include?('@')
|
226
|
+
abort("Could not determine scope for '#{package_name}', it should look like: @my-scope/package-1.0.tgz".color(:red))
|
227
|
+
end
|
228
|
+
scope = name_parts[0]
|
229
|
+
unscoped_package_name = name_parts[1]
|
230
|
+
[scope, unscoped_package_name]
|
231
|
+
end
|
232
|
+
|
170
233
|
def abort_if_snapshot!(files)
|
171
234
|
if files.any? { |file| file.include?("-SNAPSHOT") }
|
172
235
|
abort("SNAPSHOT uploads are not supported by the CLI, please use Maven instead: https://packagecloud.io/docs#wagon-instructions")
|
@@ -15,6 +15,10 @@ module PackageCloud
|
|
15
15
|
|
16
16
|
def read_or_create
|
17
17
|
if ENV["PACKAGECLOUD_TOKEN"]
|
18
|
+
if ENV["PACKAGECLOUD_TOKEN"].length < 48
|
19
|
+
puts "Found PACKAGECLOUD_TOKEN environment variable but is empty or too short! Visit https://packagecloud.io/api_token and confirm it is correct."
|
20
|
+
exit!
|
21
|
+
end
|
18
22
|
@token = ENV["PACKAGECLOUD_TOKEN"]
|
19
23
|
@url = URI(ENV["PACKAGECLOUD_URL"]) if ENV["PACKAGECLOUD_URL"]
|
20
24
|
output_host_and_token
|
@@ -130,12 +130,16 @@ 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 =
|
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
|
-
rescue RestClient::ResourceNotFound => e
|
142
|
+
rescue RestClient::UnprocessableEntity, RestClient::ResourceNotFound => e
|
139
143
|
print "error:\n".color(:red)
|
140
144
|
json = JSON.parse(e.response)
|
141
145
|
json.each do |k,v|
|
@@ -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
|
-
|
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
|
-
|
12
|
-
|
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
|
@@ -71,7 +69,7 @@ module PackageCloud
|
|
71
69
|
puts "If you don't see your OS or version here, send us an email at support@packagecloud.io:\n\n"
|
72
70
|
all_distros = distributions[package_type]
|
73
71
|
|
74
|
-
filtered_distros = all_distros.select {|dist| dist["index_name"] != "any"}
|
72
|
+
filtered_distros = all_distros.select {|dist| dist["index_name"] != "any" && dist["index_name"] != "rpm_any" }
|
75
73
|
|
76
74
|
filtered_distros.each_with_index do |dist, index|
|
77
75
|
puts "\t#{index}. #{dist["display_name"]}"
|
data/package_cloud.gemspec
CHANGED
@@ -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"
|
@@ -27,4 +27,5 @@ Gem::Specification.new do |spec|
|
|
27
27
|
|
28
28
|
spec.add_development_dependency "bundler", "~> 1.3"
|
29
29
|
spec.add_development_dependency "rake"
|
30
|
+
spec.add_development_dependency "mdl"
|
30
31
|
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.07
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Joe Damato
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-04-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|
@@ -108,8 +108,23 @@ dependencies:
|
|
108
108
|
- - ">="
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: '0'
|
111
|
-
|
112
|
-
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: mdl
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
125
|
+
description: The https://packagecloud.io CLI for uploading Node.js, Debian, RPM, RubyGem,
|
126
|
+
Python, and Java packages. Check our website or the RubyDoc documentation for detailed
|
127
|
+
information.
|
113
128
|
email:
|
114
129
|
- support@packagecloud.io
|
115
130
|
executables:
|
@@ -142,6 +157,7 @@ files:
|
|
142
157
|
- lib/package_cloud/util.rb
|
143
158
|
- lib/package_cloud/validator.rb
|
144
159
|
- lib/package_cloud/version.rb
|
160
|
+
- markdown_lint_config.rb
|
145
161
|
- package_cloud.gemspec
|
146
162
|
homepage: https://packagecloud.io
|
147
163
|
licenses:
|
@@ -163,9 +179,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
163
179
|
version: '0'
|
164
180
|
requirements: []
|
165
181
|
rubyforge_project:
|
166
|
-
rubygems_version: 2.
|
182
|
+
rubygems_version: 2.5.2.3
|
167
183
|
signing_key:
|
168
184
|
specification_version: 4
|
169
|
-
summary: The https://packagecloud.io CLI for uploading Debian, RPM, RubyGem,
|
170
|
-
and Java packages. Check our website or the RubyDoc documentation for detailed
|
185
|
+
summary: The https://packagecloud.io CLI for uploading Node.js, Debian, RPM, RubyGem,
|
186
|
+
Python, and Java packages. Check our website or the RubyDoc documentation for detailed
|
187
|
+
information.
|
171
188
|
test_files: []
|