gemfury 0.9.1 → 0.12.0.rc1
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 +26 -1
- data/lib/gemfury.rb +36 -6
- data/lib/gemfury/client.rb +75 -6
- data/lib/gemfury/command.rb +2 -1
- data/lib/gemfury/command/app.rb +183 -17
- data/lib/gemfury/configuration.rb +37 -61
- data/lib/gemfury/version.rb +1 -1
- metadata +29 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fa1399aeab2f739da48ef55e4a7a6654ce9bb8527d722a9b7ce022ac082f2c2f
|
4
|
+
data.tar.gz: 176541eb909afc8610b8a4f94b3653dece97f898518a69fc137a7bd46533df25
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c69342a8284196e6e43b9a3dc3bead88cfe17b2ae098db213d5055314d703aefada6e5df8f4cd3d08a8c6a413bc27f211bd8f8be3dd802f4a8000f3c35121666
|
7
|
+
data.tar.gz: ed29f372dbec0526a614d2d8bb4ca8982ab47114a0c3d42857c4f06a480db690f7d9c898221b3be654b1e177f5d20f78382aa2069318a732b2a1ee08fb2ea71c
|
data/README.md
CHANGED
@@ -4,6 +4,8 @@ Gemfury CLI
|
|
4
4
|
[](http://badge.fury.io/rb/gemfury)
|
5
5
|
[](https://travis-ci.org/gemfury/gemfury)
|
6
6
|
[](https://codeclimate.com/github/gemfury/gemfury)
|
7
|
+
[](http://www.rubydoc.info/gems/gemfury)
|
8
|
+
[](http://inch-ci.org/github/gemfury/gemfury)
|
7
9
|
|
8
10
|
This is the Gemfury CLI used to manage your Gemfury packages from the command line. If you're
|
9
11
|
familiar with the service and want to jump straight into command line action, please proceed to
|
@@ -30,6 +32,29 @@ any package to any host. It's simple, reliable, and hassle-free.
|
|
30
32
|
* [Install private Composer packages](https://gemfury.com/help/php-composer-server)
|
31
33
|
* [Private RubyGems on Heroku](https://gemfury.com/help/private-gems-on-heroku)
|
32
34
|
|
35
|
+
|
36
|
+
## Using the Gemfury Client
|
37
|
+
|
38
|
+
You can also use the client directly via Ruby; you will need a "Full access token" (API token) from `https://manage.fury.io/manage/YOUR-ACCOUNT-NAME/tokens/api`
|
39
|
+
|
40
|
+
```ruby
|
41
|
+
require 'gemfury'
|
42
|
+
|
43
|
+
client = Gemfury::Client.new(user_api_key: "YOUR API TOKEN")
|
44
|
+
|
45
|
+
all_artifacts = client.list
|
46
|
+
puts "Available artifacts:"
|
47
|
+
puts all_artifacts
|
48
|
+
|
49
|
+
one_artifact = all_artifacts[0]
|
50
|
+
puts "Versions of the #{one_artifact['language']} artifact #{one_artifact['name']}:"
|
51
|
+
artifact_versions = client.versions(one_artifact["name"])
|
52
|
+
puts artifact_versions.map { |v| v["version"] }
|
53
|
+
```
|
54
|
+
|
55
|
+
More information about the `Gemfury::Client` API is [hosted on rubydoc.info](https://rubydoc.info/gems/gemfury/Gemfury/Client).
|
56
|
+
|
57
|
+
|
33
58
|
## Contribution and Improvements
|
34
59
|
|
35
60
|
Please [email us](mailto:support@gemfury.com) if we've missed some key functionality or you have problems installing the CLI client. Better yet, fork the code, make the changes, and submit a pull request to speed things along.
|
@@ -59,4 +84,4 @@ Over time, dependencies for this gem will get stale and may interfere with your
|
|
59
84
|
|
60
85
|
## Questions
|
61
86
|
|
62
|
-
Please email support@gemfury.com or file a Github Issue if you have any other questions or problems.
|
87
|
+
Please email support@gemfury.com or file a Github Issue if you have any other questions or problems.
|
data/lib/gemfury.rb
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
gem "multi_json", "~> 1.10"
|
2
|
-
gem "faraday", ">= 0.9.0", "<
|
2
|
+
gem "faraday", ">= 0.9.0", "< 1.1.0.pre"
|
3
3
|
gem "netrc", ">= 0.10.0", "< 0.12.0.pre"
|
4
4
|
|
5
|
+
require 'time'
|
5
6
|
require 'cgi'
|
6
7
|
require 'uri'
|
7
8
|
require 'netrc'
|
@@ -22,6 +23,8 @@ require 'gemfury/client'
|
|
22
23
|
|
23
24
|
module Gemfury
|
24
25
|
extend Configuration
|
26
|
+
VALID_OPTIONS_KEYS = Configuration::CONFIGURATION_DEFAULTS.keys.freeze
|
27
|
+
|
25
28
|
class << self
|
26
29
|
# Alias for Gemfury::Client.new
|
27
30
|
#
|
@@ -30,6 +33,27 @@ module Gemfury
|
|
30
33
|
Gemfury::Client.new(options)
|
31
34
|
end
|
32
35
|
|
36
|
+
# Convenience method to allow configuration options to be set in a block
|
37
|
+
def configure
|
38
|
+
yield self
|
39
|
+
end
|
40
|
+
|
41
|
+
# Create a hash of options and their values
|
42
|
+
# @return [Hash] the options and their values
|
43
|
+
def options
|
44
|
+
VALID_OPTIONS_KEYS.inject({}) do |options, k|
|
45
|
+
options[k] = send(k)
|
46
|
+
options
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
# Reset all configuration options to defaults
|
51
|
+
# @return [Configuration] The default configuration
|
52
|
+
def reset
|
53
|
+
CONFIGURATION_DEFAULTS.each { |k, v| send("#{k}=", v) }
|
54
|
+
self
|
55
|
+
end
|
56
|
+
|
33
57
|
# Delegate to Gemfury::Client
|
34
58
|
def method_missing(method, *args, &block)
|
35
59
|
return super unless new.respond_to?(method)
|
@@ -39,14 +63,20 @@ module Gemfury
|
|
39
63
|
def respond_to?(method, include_private = false)
|
40
64
|
new.respond_to?(method, include_private) || super(method, include_private)
|
41
65
|
end
|
66
|
+
|
42
67
|
end
|
43
68
|
end
|
44
69
|
|
70
|
+
# Initialize configuration
|
71
|
+
Gemfury.reset
|
72
|
+
|
73
|
+
# Polyfill #dig for Ruby 2.2 and earlier
|
45
74
|
class Hash
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
75
|
+
unless self.instance_methods.include?(:dig)
|
76
|
+
def dig(*parts)
|
77
|
+
parts.inject(self) do |hash, part|
|
78
|
+
hash.is_a?(Hash) ? hash[part] : nil
|
79
|
+
end
|
50
80
|
end
|
51
81
|
end
|
52
|
-
end
|
82
|
+
end
|
data/lib/gemfury/client.rb
CHANGED
@@ -1,24 +1,37 @@
|
|
1
1
|
module Gemfury
|
2
2
|
class Client
|
3
3
|
include Gemfury::Client::Filters
|
4
|
-
|
4
|
+
include Gemfury::Configuration
|
5
5
|
|
6
6
|
# Creates a new API
|
7
|
+
# @param options [Hash] values for attributes described in {Gemfury::Configuration}
|
7
8
|
def initialize(options={})
|
8
9
|
options = Gemfury.options.merge(options)
|
9
|
-
|
10
|
+
Gemfury::VALID_OPTIONS_KEYS.each do |key|
|
10
11
|
send("#{key}=", options[key])
|
11
12
|
end
|
12
13
|
end
|
13
14
|
|
14
15
|
# Get the information for the current account
|
16
|
+
# @return [Hash]
|
15
17
|
def account_info
|
16
18
|
ensure_ready!(:authorization)
|
17
19
|
response = connection.get('users/me')
|
18
20
|
checked_response_body(response)
|
19
21
|
end
|
20
22
|
|
21
|
-
#
|
23
|
+
# Get the information for the all accounts that this account has some level of access to
|
24
|
+
# @return [Array<Hash>]
|
25
|
+
def accounts
|
26
|
+
ensure_ready!(:authorization)
|
27
|
+
response = connection.get('accounts')
|
28
|
+
checked_response_body(response)
|
29
|
+
end
|
30
|
+
|
31
|
+
# Upload an artifact file
|
32
|
+
# @param file [String] the filename to upload
|
33
|
+
# @param options [Hash] Faraday client options
|
34
|
+
# @return [Hash]
|
22
35
|
def push_gem(file, options = {})
|
23
36
|
ensure_ready!(:authorization)
|
24
37
|
push_api = connection(:url => self.pushpoint)
|
@@ -26,14 +39,19 @@ module Gemfury
|
|
26
39
|
checked_response_body(response)
|
27
40
|
end
|
28
41
|
|
29
|
-
# List available
|
42
|
+
# List available artifacts
|
43
|
+
# @param options [Hash] Faraday client options
|
44
|
+
# @return [Array<Hash>]
|
30
45
|
def list(options = {})
|
31
46
|
ensure_ready!(:authorization)
|
32
47
|
response = connection.get('gems', options)
|
33
48
|
checked_response_body(response)
|
34
49
|
end
|
35
50
|
|
36
|
-
# List versions for
|
51
|
+
# List versions for an artifact
|
52
|
+
# @param name [String] the name of the artifact
|
53
|
+
# @param options [Hash] Faraday client options
|
54
|
+
# @return [Array<Hash>]
|
37
55
|
def versions(name, options = {})
|
38
56
|
ensure_ready!(:authorization)
|
39
57
|
url = "gems/#{escape(name)}/versions"
|
@@ -41,7 +59,11 @@ module Gemfury
|
|
41
59
|
checked_response_body(response)
|
42
60
|
end
|
43
61
|
|
44
|
-
# Delete
|
62
|
+
# Delete an artifact version
|
63
|
+
# @param name [String] the name of the artifact
|
64
|
+
# @param version [String] the version of the artifact
|
65
|
+
# @param options [Hash] Faraday client options
|
66
|
+
# @return [Hash]
|
45
67
|
def yank_version(name, version, options = {})
|
46
68
|
ensure_ready!(:authorization)
|
47
69
|
url = "gems/#{escape(name)}/versions/#{escape(version)}"
|
@@ -55,6 +77,10 @@ module Gemfury
|
|
55
77
|
end
|
56
78
|
|
57
79
|
# Get authentication info via email/password
|
80
|
+
# @param email [String] the account email address
|
81
|
+
# @param password [String] the account password
|
82
|
+
# @param opts [Hash] Faraday client options
|
83
|
+
# @return [Hash]
|
58
84
|
def login(email, password, opts = {})
|
59
85
|
ensure_ready!
|
60
86
|
opts = opts.merge(:email => email, :password => password)
|
@@ -62,6 +88,7 @@ module Gemfury
|
|
62
88
|
end
|
63
89
|
|
64
90
|
# Invalidate session token
|
91
|
+
# @return [Hash]
|
65
92
|
def logout
|
66
93
|
ensure_ready!(:authorization)
|
67
94
|
response = connection.post('logout')
|
@@ -69,6 +96,8 @@ module Gemfury
|
|
69
96
|
end
|
70
97
|
|
71
98
|
# List collaborators for this account
|
99
|
+
# @param options [Hash] Faraday client options
|
100
|
+
# @return [Array<Hash>]
|
72
101
|
def list_collaborators(options = {})
|
73
102
|
ensure_ready!(:authorization)
|
74
103
|
response = connection.get('collaborators', options)
|
@@ -76,6 +105,8 @@ module Gemfury
|
|
76
105
|
end
|
77
106
|
|
78
107
|
# Add a collaborator to the account
|
108
|
+
# @param options [Hash] Faraday client options
|
109
|
+
# @return [Hash]
|
79
110
|
def add_collaborator(login, options = {})
|
80
111
|
ensure_ready!(:authorization)
|
81
112
|
url = "collaborators/#{escape(login)}"
|
@@ -84,6 +115,9 @@ module Gemfury
|
|
84
115
|
end
|
85
116
|
|
86
117
|
# Remove a collaborator to the account
|
118
|
+
# @param login [String] the account login
|
119
|
+
# @param options [Hash] Faraday client options
|
120
|
+
# @return [Hash]
|
87
121
|
def remove_collaborator(login, options = {})
|
88
122
|
ensure_ready!(:authorization)
|
89
123
|
url = "collaborators/#{escape(login)}"
|
@@ -92,6 +126,8 @@ module Gemfury
|
|
92
126
|
end
|
93
127
|
|
94
128
|
# List Git repos for this account
|
129
|
+
# @param options [Hash] Faraday client options
|
130
|
+
# @return [Hash]
|
95
131
|
def git_repos(options = {})
|
96
132
|
ensure_ready!(:authorization)
|
97
133
|
response = connection.get(git_repo_path, options)
|
@@ -99,6 +135,9 @@ module Gemfury
|
|
99
135
|
end
|
100
136
|
|
101
137
|
# Update repository name and settings
|
138
|
+
# @param repo [String] the repo name
|
139
|
+
# @param options [Hash] Faraday client options
|
140
|
+
# @return [Hash]
|
102
141
|
def git_update(repo, options = {})
|
103
142
|
ensure_ready!(:authorization)
|
104
143
|
response = connection.patch(git_repo_path(repo), options)
|
@@ -106,6 +145,9 @@ module Gemfury
|
|
106
145
|
end
|
107
146
|
|
108
147
|
# Reset repository to initial state
|
148
|
+
# @param repo [String] the repo name
|
149
|
+
# @param options [Hash] Faraday client options
|
150
|
+
# @return [Hash]
|
109
151
|
def git_reset(repo, options = {})
|
110
152
|
ensure_ready!(:authorization)
|
111
153
|
response = connection.delete(git_repo_path(repo), options)
|
@@ -113,6 +155,9 @@ module Gemfury
|
|
113
155
|
end
|
114
156
|
|
115
157
|
# Rebuild Git repository package
|
158
|
+
# @param repo [String] the repo name
|
159
|
+
# @param options [Hash] Faraday client options
|
160
|
+
# @return [Hash]
|
116
161
|
def git_rebuild(repo, options = {})
|
117
162
|
ensure_ready!(:authorization)
|
118
163
|
url = "#{git_repo_path(repo)}/builds"
|
@@ -120,6 +165,30 @@ module Gemfury
|
|
120
165
|
checked_response_body(api.post(url, options))
|
121
166
|
end
|
122
167
|
|
168
|
+
# List Git repo's build configuration
|
169
|
+
# @param repo [String] the repo name
|
170
|
+
# @param options [Hash] Faraday client options
|
171
|
+
# @return [Hash]
|
172
|
+
def git_config(repo, options = {})
|
173
|
+
ensure_ready!(:authorization)
|
174
|
+
path = "#{git_repo_path(repo)}/config-vars"
|
175
|
+
response = connection.get(path, options)
|
176
|
+
checked_response_body(response)
|
177
|
+
end
|
178
|
+
|
179
|
+
# Update Git repo's build configuration
|
180
|
+
# @param repo [String] the repo name
|
181
|
+
# @param updates [Hash] Updates to configuration
|
182
|
+
# @param options [Hash] Faraday client options
|
183
|
+
# @return [Hash]
|
184
|
+
def git_config_update(repo, updates, options = {})
|
185
|
+
ensure_ready!(:authorization)
|
186
|
+
path = "#{git_repo_path(repo)}/config-vars"
|
187
|
+
opts = options.merge(:config_vars => updates)
|
188
|
+
response = connection.patch(path, opts)
|
189
|
+
checked_response_body(response)
|
190
|
+
end
|
191
|
+
|
123
192
|
private
|
124
193
|
def escape(str)
|
125
194
|
CGI.escape(str)
|
data/lib/gemfury/command.rb
CHANGED
data/lib/gemfury/command/app.rb
CHANGED
@@ -1,5 +1,9 @@
|
|
1
|
+
require 'progressbar'
|
2
|
+
require 'delegate'
|
3
|
+
|
1
4
|
class Gemfury::Command::App < Thor
|
2
5
|
include Gemfury::Command::Authorization
|
6
|
+
UserAgent = "Gemfury CLI #{Gemfury::VERSION}".freeze
|
3
7
|
PackageExtensions = %w(gem egg tar.gz tgz nupkg)
|
4
8
|
|
5
9
|
# Impersonation
|
@@ -14,6 +18,7 @@ class Gemfury::Command::App < Thor
|
|
14
18
|
|
15
19
|
### PACKAGE MANAGEMENT ###
|
16
20
|
option :public, :type => :boolean, :desc => "Create as public package"
|
21
|
+
option :quiet, :type => :boolean, :aliases => "-q", :desc => "Do not show progress bar", :default => false
|
17
22
|
desc "push FILE", "Upload a new version of a package"
|
18
23
|
def push(*gems)
|
19
24
|
with_checks_and_rescues do
|
@@ -26,11 +31,15 @@ class Gemfury::Command::App < Thor
|
|
26
31
|
with_checks_and_rescues do
|
27
32
|
gems = client.list
|
28
33
|
shell.say "\n*** GEMFURY PACKAGES ***\n\n"
|
34
|
+
|
35
|
+
va = [ %w{ name kind version privacy } ]
|
29
36
|
gems.each do |g|
|
30
|
-
|
31
|
-
|
32
|
-
|
37
|
+
va << [ g['name'], g['language'],
|
38
|
+
g.dig('latest_version', 'version') || 'beta',
|
39
|
+
g['private'] ? 'private' : 'public ' ]
|
33
40
|
end
|
41
|
+
|
42
|
+
shell.print_table(va)
|
34
43
|
end
|
35
44
|
end
|
36
45
|
|
@@ -39,9 +48,15 @@ class Gemfury::Command::App < Thor
|
|
39
48
|
with_checks_and_rescues do
|
40
49
|
versions = client.versions(gem_name)
|
41
50
|
shell.say "\n*** #{gem_name.capitalize} Versions ***\n\n"
|
51
|
+
|
52
|
+
va = []
|
53
|
+
va = [ %w{ version uploaded_by uploaded } ]
|
42
54
|
versions.each do |v|
|
43
|
-
|
55
|
+
uploaded = time_ago(Time.parse(v['created_at']).getlocal)
|
56
|
+
va << [ v['version'], v['created_by']['name'], uploaded ]
|
44
57
|
end
|
58
|
+
|
59
|
+
shell.print_table(va)
|
45
60
|
end
|
46
61
|
end
|
47
62
|
|
@@ -82,6 +97,20 @@ class Gemfury::Command::App < Thor
|
|
82
97
|
end
|
83
98
|
end
|
84
99
|
|
100
|
+
desc "accounts", "Show info about your Gemfury accounts"
|
101
|
+
def accounts
|
102
|
+
with_checks_and_rescues do
|
103
|
+
accounts = client.accounts
|
104
|
+
|
105
|
+
va = [ %w{ name kind permission } ]
|
106
|
+
accounts.each do |a|
|
107
|
+
va << [ a['name'], a['type'], a['viewer_permission'].downcase ]
|
108
|
+
end
|
109
|
+
|
110
|
+
shell.print_table(va)
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
85
114
|
### COLLABORATION MANAGEMENT ###
|
86
115
|
map "sharing:add" => 'sharing_add'
|
87
116
|
map "sharing:remove" => 'sharing_remove'
|
@@ -89,16 +118,25 @@ class Gemfury::Command::App < Thor
|
|
89
118
|
desc "sharing", "List collaborators"
|
90
119
|
def sharing
|
91
120
|
with_checks_and_rescues do
|
92
|
-
|
121
|
+
account_info = client.account_info
|
122
|
+
me = account_info['username']
|
123
|
+
|
93
124
|
collaborators = client.list_collaborators
|
94
125
|
if collaborators.empty?
|
95
|
-
shell.say
|
126
|
+
shell.say %Q(You (#{me}) are the only collaborator\n), :green
|
96
127
|
else
|
97
128
|
shell.say %Q(\n*** Collaborators for "#{me}" ***\n), :green
|
98
|
-
|
99
|
-
|
129
|
+
|
130
|
+
va = [ %w{ username permission } ]
|
131
|
+
|
132
|
+
if account_info['type'] == 'user'
|
133
|
+
va << [ me, 'owner' ]
|
134
|
+
end
|
135
|
+
|
136
|
+
collaborators.each { |c| va << [ c['username'], c['permission'] ] }
|
137
|
+
|
138
|
+
shell.print_table(va)
|
100
139
|
end
|
101
|
-
shell.say "\n"
|
102
140
|
end
|
103
141
|
end
|
104
142
|
|
@@ -186,12 +224,48 @@ class Gemfury::Command::App < Thor
|
|
186
224
|
end
|
187
225
|
end
|
188
226
|
|
227
|
+
### GIT REPOSITORY BUILD CONFIG ###
|
228
|
+
map 'git:config' => 'git_config'
|
229
|
+
map 'git:config:set' => 'git_config_set'
|
230
|
+
map 'git:config:unset' => 'git_config_unset'
|
231
|
+
|
232
|
+
desc "git:config", "List Git repository's build environment"
|
233
|
+
def git_config(repo)
|
234
|
+
with_checks_and_rescues do
|
235
|
+
vars = client.git_config(repo)['config_vars']
|
236
|
+
shell.say "*** #{repo} build config ***\n"
|
237
|
+
shell.print_table(vars.map { |kv|
|
238
|
+
["#{kv[0]}:", kv[1]]
|
239
|
+
})
|
240
|
+
end
|
241
|
+
end
|
242
|
+
|
243
|
+
desc "git:config:set", "Update Git repository's build environment"
|
244
|
+
def git_config_set(repo, *vars)
|
245
|
+
with_checks_and_rescues do
|
246
|
+
updates = Hash[vars.map { |v| v.split("=", 2) }]
|
247
|
+
client.git_config_update(repo, updates)
|
248
|
+
shell.say "Updated #{repo} build config"
|
249
|
+
end
|
250
|
+
end
|
251
|
+
|
252
|
+
desc "git:config:unset", "Remove variables from Git repository's build environment"
|
253
|
+
def git_config_unset(repo, *vars)
|
254
|
+
with_checks_and_rescues do
|
255
|
+
updates = Hash[vars.map { |v| [v, nil] }]
|
256
|
+
client.git_config_update(repo, updates)
|
257
|
+
shell.say "Updated #{repo} build config"
|
258
|
+
end
|
259
|
+
end
|
260
|
+
|
189
261
|
private
|
190
262
|
def client
|
191
263
|
opts = {}
|
192
264
|
opts[:user_api_key] = @user_api_key if @user_api_key
|
193
265
|
opts[:account] = options[:as] if options[:as]
|
194
|
-
Gemfury::Client.new(opts)
|
266
|
+
client = Gemfury::Client.new(opts)
|
267
|
+
client.user_agent = UserAgent
|
268
|
+
return client
|
195
269
|
end
|
196
270
|
|
197
271
|
def with_checks_and_rescues(&block)
|
@@ -221,6 +295,10 @@ private
|
|
221
295
|
g.is_a?(String) ? File.new(g) : g rescue nil
|
222
296
|
end.compact
|
223
297
|
|
298
|
+
if !options[:quiet] && !shell.mute? && $stdout.tty?
|
299
|
+
files = files.map { |g| ProgressIO.new(g) }
|
300
|
+
end
|
301
|
+
|
224
302
|
if files.empty?
|
225
303
|
die!("Problem: No valid packages found", nil, command)
|
226
304
|
end
|
@@ -230,23 +308,96 @@ private
|
|
230
308
|
push_options[:public] = options[:public]
|
231
309
|
end
|
232
310
|
|
233
|
-
|
311
|
+
error_ex = nil
|
312
|
+
|
234
313
|
files.each do |file|
|
314
|
+
show_bar = file.is_a?(ProgressIO) && file.show_bar?
|
315
|
+
title = "Uploading #{File.basename(file.path)} "
|
316
|
+
|
235
317
|
begin
|
236
|
-
|
237
|
-
|
318
|
+
if show_bar
|
319
|
+
begin
|
320
|
+
client.push_gem(file, push_options)
|
321
|
+
ensure
|
322
|
+
shell.say "\e[A\e[0K", nil, false
|
323
|
+
shell.say title
|
324
|
+
end
|
325
|
+
else
|
326
|
+
shell.say title
|
327
|
+
client.push_gem(file, push_options)
|
328
|
+
end
|
329
|
+
|
238
330
|
shell.say "- done"
|
239
|
-
rescue Gemfury::CorruptGemFile
|
331
|
+
rescue Gemfury::CorruptGemFile => e
|
240
332
|
shell.say "- problem processing this package", :red
|
241
|
-
|
333
|
+
error_ex = e
|
334
|
+
rescue Gemfury::DupeVersion => e
|
242
335
|
shell.say "- this version already exists", :red
|
243
|
-
|
336
|
+
error_ex = e
|
337
|
+
rescue Gemfury::TimeoutError, Errno::EPIPE => e
|
244
338
|
shell.say "- this file is too much to handle", :red
|
245
339
|
shell.say " Visit http://www.gemfury.com/large-package for more info"
|
340
|
+
error_ex = e
|
246
341
|
rescue => e
|
247
342
|
shell.say "- oops", :red
|
248
|
-
|
343
|
+
error_ex = e
|
344
|
+
end
|
345
|
+
end
|
346
|
+
|
347
|
+
unless error_ex.nil?
|
348
|
+
die!('There was a problem uploading at least 1 package', error_ex)
|
349
|
+
end
|
350
|
+
end
|
351
|
+
|
352
|
+
C50K = 50000
|
353
|
+
|
354
|
+
class ProgressIO < SimpleDelegator
|
355
|
+
attr_reader :content_type, :original_filename, :local_path
|
356
|
+
|
357
|
+
def initialize(filename_or_io, content_type = 'application/octet-stream', fname = nil)
|
358
|
+
io = filename_or_io
|
359
|
+
local_path = ''
|
360
|
+
|
361
|
+
if io.respond_to? :read
|
362
|
+
local_path = filename_or_io.respond_to?(:path) ? filename_or_io.path : 'local.path'
|
363
|
+
else
|
364
|
+
io = File.open(filename_or_io)
|
365
|
+
local_path = filename_or_io
|
366
|
+
end
|
367
|
+
|
368
|
+
fname ||= local_path
|
369
|
+
|
370
|
+
@content_type = content_type
|
371
|
+
@original_filename = File.basename(fname)
|
372
|
+
@local_path = local_path
|
373
|
+
|
374
|
+
if io.respond_to? :size
|
375
|
+
filesize = io.size
|
376
|
+
else
|
377
|
+
filesize = io.stat.size
|
378
|
+
end
|
379
|
+
|
380
|
+
if filesize > C50K
|
381
|
+
title = 'Uploading %s ' % File.basename(fname)
|
382
|
+
@bar = ProgressBar.create(:title => title, :total => filesize)
|
383
|
+
else
|
384
|
+
@bar = nil
|
249
385
|
end
|
386
|
+
|
387
|
+
super(io)
|
388
|
+
end
|
389
|
+
|
390
|
+
def show_bar?
|
391
|
+
@bar != nil
|
392
|
+
end
|
393
|
+
|
394
|
+
def read(length)
|
395
|
+
buf = __getobj__.read(length)
|
396
|
+
unless @bar.nil? || buf.nil?
|
397
|
+
@bar.progress += buf.bytesize
|
398
|
+
end
|
399
|
+
|
400
|
+
buf
|
250
401
|
end
|
251
402
|
end
|
252
403
|
|
@@ -256,4 +407,19 @@ private
|
|
256
407
|
shell.say %Q(#{err.class.name}: #{err}\n#{err.backtrace.join("\n")}) if err && ENV['DEBUG']
|
257
408
|
exit(1)
|
258
409
|
end
|
410
|
+
|
411
|
+
def time_ago(tm)
|
412
|
+
ago = tm.strftime('%F %R')
|
413
|
+
|
414
|
+
in_secs = Time.now - tm
|
415
|
+
if in_secs < 60
|
416
|
+
ago += ' (~ %ds ago)' % in_secs
|
417
|
+
elsif in_secs < 3600
|
418
|
+
ago += ' (~ %sm ago)' % (in_secs / 60).floor
|
419
|
+
elsif in_secs < (3600 * 24)
|
420
|
+
ago += ' (~ %sh ago)' % (in_secs / 3600).floor
|
421
|
+
end
|
422
|
+
|
423
|
+
ago
|
424
|
+
end
|
259
425
|
end
|
@@ -1,72 +1,48 @@
|
|
1
1
|
module Gemfury
|
2
|
-
# Defines constants and methods related to configuration
|
3
2
|
module Configuration
|
4
|
-
# An array of valid keys in the options hash when configuring
|
5
|
-
VALID_OPTIONS_KEYS = [
|
6
|
-
:user_api_key,
|
7
|
-
:adapter,
|
8
|
-
:endpoint,
|
9
|
-
:gitpoint,
|
10
|
-
:pushpoint,
|
11
|
-
:user_agent,
|
12
|
-
:api_version,
|
13
|
-
:account].freeze
|
14
3
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
4
|
+
CONFIGURATION_DEFAULTS = {
|
5
|
+
:user_api_key => nil,
|
6
|
+
:adapter => :net_http,
|
7
|
+
:endpoint => 'https://api.fury.io/',
|
8
|
+
:gitpoint => 'https://git.fury.io/',
|
9
|
+
:pushpoint => 'https://push.fury.io/',
|
10
|
+
:user_agent => "Gemfury RubyGem #{Gemfury::VERSION} (Ruby #{RUBY_VERSION})",
|
11
|
+
:api_version => 1,
|
12
|
+
:account => nil
|
13
|
+
}.freeze
|
14
|
+
|
15
|
+
# user API key, also known as "full access token"
|
16
|
+
# @return [String]
|
17
|
+
attr_accessor :user_api_key
|
18
|
+
|
19
|
+
# The adapter that will be used to connect
|
20
|
+
# @return [Symbol]
|
21
|
+
attr_accessor :adapter
|
22
|
+
|
23
|
+
# The endpoint that will be used to connect
|
24
|
+
# @return [String]
|
25
|
+
attr_accessor :endpoint
|
20
26
|
|
21
27
|
# The HTTP endpoint for git repo (used for .netrc credentials)
|
22
|
-
|
23
|
-
|
24
|
-
# The endpoint for the Push API if not set
|
25
|
-
DEFAULT_PUSHPOINT = 'https://push.fury.io/'.freeze
|
26
|
-
|
27
|
-
# The value sent in the 'User-Agent' header if none is set
|
28
|
-
DEFAULT_USER_AGENT = "Gemfury RubyGem #{Gemfury::VERSION}".freeze
|
29
|
-
|
30
|
-
# Default API version
|
31
|
-
DEFAULT_API_VERSION = 1
|
32
|
-
|
33
|
-
# Default user API key
|
34
|
-
DEFAULT_API_KEY = nil
|
35
|
-
|
36
|
-
# Use the current account (no impersonation)
|
37
|
-
DEFAULT_ACCOUNT = nil
|
38
|
-
|
39
|
-
# @private
|
40
|
-
attr_accessor *VALID_OPTIONS_KEYS
|
28
|
+
# @return [String]
|
29
|
+
attr_accessor :gitpoint
|
41
30
|
|
42
|
-
#
|
43
|
-
|
44
|
-
|
45
|
-
end
|
31
|
+
# The endpoint for the Push API
|
32
|
+
# @return [String]
|
33
|
+
attr_accessor :pushpoint
|
46
34
|
|
47
|
-
#
|
48
|
-
|
49
|
-
|
50
|
-
end
|
35
|
+
# The value sent in the 'User-Agent' header
|
36
|
+
# @return [String]
|
37
|
+
attr_accessor :user_agent
|
51
38
|
|
52
|
-
#
|
53
|
-
|
54
|
-
|
55
|
-
VALID_OPTIONS_KEYS.each{|k| options[k] = send(k)}
|
56
|
-
options
|
57
|
-
end
|
39
|
+
# Gemfury remote API version
|
40
|
+
# @return [Integer]
|
41
|
+
attr_accessor :api_version
|
58
42
|
|
59
|
-
#
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
self.endpoint = DEFAULT_ENDPOINT
|
64
|
-
self.gitpoint = DEFAULT_GITPOINT
|
65
|
-
self.pushpoint = DEFAULT_PUSHPOINT
|
66
|
-
self.user_agent = DEFAULT_USER_AGENT
|
67
|
-
self.api_version = DEFAULT_API_VERSION
|
68
|
-
self.account = DEFAULT_ACCOUNT
|
69
|
-
self
|
70
|
-
end
|
43
|
+
# The account to impersonate, if you have permissions for multiple accounts
|
44
|
+
# (If nil, no impersonation)
|
45
|
+
# @return [String]
|
46
|
+
attr_accessor :account
|
71
47
|
end
|
72
48
|
end
|
data/lib/gemfury/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gemfury
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.12.0.rc1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Rykov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-07-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: multi_json
|
@@ -33,7 +33,7 @@ dependencies:
|
|
33
33
|
version: 0.14.0
|
34
34
|
- - "<"
|
35
35
|
- !ruby/object:Gem::Version
|
36
|
-
version: 1.
|
36
|
+
version: 1.1.0.pre
|
37
37
|
type: :runtime
|
38
38
|
prerelease: false
|
39
39
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -43,7 +43,7 @@ dependencies:
|
|
43
43
|
version: 0.14.0
|
44
44
|
- - "<"
|
45
45
|
- !ruby/object:Gem::Version
|
46
|
-
version: 1.
|
46
|
+
version: 1.1.0.pre
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: netrc
|
49
49
|
requirement: !ruby/object:Gem::Requirement
|
@@ -73,7 +73,7 @@ dependencies:
|
|
73
73
|
version: 0.9.0
|
74
74
|
- - "<"
|
75
75
|
- !ruby/object:Gem::Version
|
76
|
-
version:
|
76
|
+
version: 1.1.0.pre
|
77
77
|
type: :runtime
|
78
78
|
prerelease: false
|
79
79
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -83,7 +83,7 @@ dependencies:
|
|
83
83
|
version: 0.9.0
|
84
84
|
- - "<"
|
85
85
|
- !ruby/object:Gem::Version
|
86
|
-
version:
|
86
|
+
version: 1.1.0.pre
|
87
87
|
- !ruby/object:Gem::Dependency
|
88
88
|
name: highline
|
89
89
|
requirement: !ruby/object:Gem::Requirement
|
@@ -104,6 +104,26 @@ dependencies:
|
|
104
104
|
- - "<"
|
105
105
|
- !ruby/object:Gem::Version
|
106
106
|
version: 2.1.0.pre
|
107
|
+
- !ruby/object:Gem::Dependency
|
108
|
+
name: progressbar
|
109
|
+
requirement: !ruby/object:Gem::Requirement
|
110
|
+
requirements:
|
111
|
+
- - ">="
|
112
|
+
- !ruby/object:Gem::Version
|
113
|
+
version: 1.10.1
|
114
|
+
- - "<"
|
115
|
+
- !ruby/object:Gem::Version
|
116
|
+
version: 2.0.0.pre
|
117
|
+
type: :runtime
|
118
|
+
prerelease: false
|
119
|
+
version_requirements: !ruby/object:Gem::Requirement
|
120
|
+
requirements:
|
121
|
+
- - ">="
|
122
|
+
- !ruby/object:Gem::Version
|
123
|
+
version: 1.10.1
|
124
|
+
- - "<"
|
125
|
+
- !ruby/object:Gem::Version
|
126
|
+
version: 2.0.0.pre
|
107
127
|
description: 'Hosted repo for your public and private packages at https://gemfury.com
|
108
128
|
|
109
129
|
'
|
@@ -165,12 +185,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
165
185
|
version: '0'
|
166
186
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
167
187
|
requirements:
|
168
|
-
- - "
|
188
|
+
- - ">"
|
169
189
|
- !ruby/object:Gem::Version
|
170
|
-
version:
|
190
|
+
version: 1.3.1
|
171
191
|
requirements: []
|
172
192
|
rubyforge_project:
|
173
|
-
rubygems_version: 2.7.
|
193
|
+
rubygems_version: 2.7.8
|
174
194
|
signing_key:
|
175
195
|
specification_version: 4
|
176
196
|
summary: Hosted repo for your public and private packages
|