gemfury 0.12.0 → 0.13.0.beta1
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 +3 -3
- data/bin/fury +3 -4
- data/bin/gemfury +3 -1
- data/lib/faraday/adapter/fury_http.rb +14 -21
- data/lib/faraday/request/multipart_with_file.rb +3 -3
- data/lib/gemfury/client/filters.rb +7 -6
- data/lib/gemfury/client/middleware.rb +5 -3
- data/lib/gemfury/client.rb +44 -47
- data/lib/gemfury/command/app.rb +117 -112
- data/lib/gemfury/command/authorization.rb +14 -11
- data/lib/gemfury/command.rb +5 -3
- data/lib/gemfury/configuration.rb +10 -9
- data/lib/gemfury/const.rb +5 -2
- data/lib/gemfury/error.rb +2 -0
- data/lib/gemfury/platform.rb +4 -2
- data/lib/gemfury/tasks/release.rake +9 -8
- data/lib/gemfury/tasks.rb +3 -1
- data/lib/gemfury/version.rb +3 -1
- data/lib/gemfury.rb +11 -8
- data/lib/rubygems/commands/fury_command.rb +4 -2
- data/lib/rubygems_plugin.rb +2 -0
- metadata +59 -39
data/lib/gemfury/command/app.rb
CHANGED
@@ -1,70 +1,75 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'progressbar'
|
2
4
|
require 'delegate'
|
3
5
|
|
4
6
|
class Gemfury::Command::App < Thor
|
5
7
|
include Gemfury::Command::Authorization
|
6
|
-
UserAgent = "Gemfury CLI #{Gemfury::VERSION}"
|
7
|
-
PackageExtensions = %w
|
8
|
+
UserAgent = "Gemfury CLI #{Gemfury::VERSION}"
|
9
|
+
PackageExtensions = %w[gem egg tar.gz tgz nupkg].freeze
|
8
10
|
|
9
11
|
# Impersonation
|
10
|
-
class_option :as, :
|
11
|
-
class_option :api_token, :
|
12
|
+
class_option :as, desc: 'Access an account other than your own'
|
13
|
+
class_option :api_token, desc: 'API token to use for commands'
|
14
|
+
class_option :no_warnings, hide: true, type: :boolean
|
12
15
|
|
13
16
|
# Make sure we retain the default exit behaviour of 0 even on argument errors
|
14
|
-
def self.exit_on_failure
|
17
|
+
def self.exit_on_failure?
|
18
|
+
false
|
19
|
+
end
|
15
20
|
|
16
|
-
map
|
17
|
-
desc
|
21
|
+
map '-v' => :version
|
22
|
+
desc 'version', 'Show Gemfury version', hide: true
|
18
23
|
def version
|
19
24
|
shell.say Gemfury::VERSION
|
20
25
|
end
|
21
26
|
|
22
27
|
### PACKAGE MANAGEMENT ###
|
23
|
-
option :public, :
|
24
|
-
option :quiet, :
|
25
|
-
desc
|
28
|
+
option :public, type: :boolean, desc: 'Create as public package'
|
29
|
+
option :quiet, type: :boolean, aliases: '-q', desc: 'Do not show progress bar', default: false
|
30
|
+
desc 'push FILE', 'Upload a new version of a package'
|
26
31
|
def push(*gems)
|
27
32
|
with_checks_and_rescues do
|
28
33
|
push_files(:push, gems)
|
29
34
|
end
|
30
35
|
end
|
31
36
|
|
32
|
-
desc
|
37
|
+
desc 'list', 'List your packages'
|
33
38
|
def list
|
34
39
|
with_checks_and_rescues do
|
35
40
|
gems = client.list
|
36
41
|
shell.say "\n*** GEMFURY PACKAGES ***\n\n"
|
37
42
|
|
38
|
-
va = [
|
43
|
+
va = [%w[name kind version privacy]]
|
39
44
|
gems.each do |g|
|
40
|
-
va << [
|
41
|
-
|
42
|
-
|
45
|
+
va << [g['name'], g['language'],
|
46
|
+
g.dig('latest_version', 'version') || 'beta',
|
47
|
+
g['private'] ? 'private' : 'public ']
|
43
48
|
end
|
44
49
|
|
45
50
|
shell.print_table(va)
|
46
51
|
end
|
47
52
|
end
|
48
53
|
|
49
|
-
desc
|
54
|
+
desc 'versions NAME', 'List all the package versions'
|
50
55
|
def versions(gem_name)
|
51
56
|
with_checks_and_rescues do
|
52
57
|
versions = client.versions(gem_name)
|
53
58
|
shell.say "\n*** #{gem_name.capitalize} Versions ***\n\n"
|
54
59
|
|
55
60
|
va = []
|
56
|
-
va = [
|
61
|
+
va = [%w[version uploaded_by uploaded]]
|
57
62
|
versions.each do |v|
|
58
63
|
uploaded = time_ago(Time.parse(v['created_at']).getlocal)
|
59
|
-
va << [
|
64
|
+
va << [v['version'], v['created_by']['name'], uploaded]
|
60
65
|
end
|
61
66
|
|
62
67
|
shell.print_table(va)
|
63
68
|
end
|
64
69
|
end
|
65
70
|
|
66
|
-
desc
|
67
|
-
method_options %w
|
71
|
+
desc 'yank NAME', 'Delete a package version'
|
72
|
+
method_options %w[version -v] => :required
|
68
73
|
def yank(gem_name)
|
69
74
|
with_checks_and_rescues do
|
70
75
|
version = options[:version]
|
@@ -74,40 +79,44 @@ class Gemfury::Command::App < Thor
|
|
74
79
|
end
|
75
80
|
|
76
81
|
### AUTHENTICATION ###
|
77
|
-
desc
|
82
|
+
desc 'logout', 'Remove Gemfury credentials'
|
78
83
|
def logout
|
79
84
|
if !has_credentials?
|
80
|
-
shell.say
|
81
|
-
elsif shell.yes?
|
85
|
+
shell.say 'You are logged out'
|
86
|
+
elsif shell.yes? 'Are you sure you want to log out? [yN]'
|
82
87
|
with_checks_and_rescues { client.logout }
|
83
88
|
wipe_credentials!
|
84
|
-
shell.say
|
89
|
+
shell.say 'You have been logged out'
|
85
90
|
end
|
86
91
|
end
|
87
92
|
|
88
|
-
desc
|
93
|
+
desc 'login', 'Save Gemfury credentials'
|
89
94
|
def login
|
90
95
|
with_checks_and_rescues do
|
91
96
|
me = client.account_info['name']
|
92
|
-
shell.say %
|
97
|
+
shell.say %(You are logged in as "#{me}"), :green
|
93
98
|
end
|
94
99
|
end
|
95
100
|
|
96
|
-
desc
|
101
|
+
desc 'whoami', 'Show current user'
|
97
102
|
def whoami
|
98
|
-
has_credentials?
|
99
|
-
|
103
|
+
if has_credentials?
|
104
|
+
login
|
105
|
+
else
|
106
|
+
|
107
|
+
shell.say 'You are not logged in', :green
|
108
|
+
|
100
109
|
end
|
101
110
|
end
|
102
111
|
|
103
|
-
desc
|
112
|
+
desc 'accounts', 'Show info about your Gemfury accounts'
|
104
113
|
def accounts
|
105
114
|
with_checks_and_rescues do
|
106
115
|
accounts = client.accounts
|
107
116
|
|
108
|
-
va = [
|
117
|
+
va = [%w[name kind permission]]
|
109
118
|
accounts.each do |a|
|
110
|
-
va << [
|
119
|
+
va << [a['name'], a['type'], a['viewer_permission'].downcase]
|
111
120
|
end
|
112
121
|
|
113
122
|
shell.print_table(va)
|
@@ -115,10 +124,10 @@ class Gemfury::Command::App < Thor
|
|
115
124
|
end
|
116
125
|
|
117
126
|
### COLLABORATION MANAGEMENT ###
|
118
|
-
map
|
119
|
-
map
|
127
|
+
map 'sharing:add' => 'sharing_add'
|
128
|
+
map 'sharing:remove' => 'sharing_remove'
|
120
129
|
|
121
|
-
desc
|
130
|
+
desc 'sharing', 'List collaborators'
|
122
131
|
def sharing
|
123
132
|
with_checks_and_rescues do
|
124
133
|
account_info = client.account_info
|
@@ -126,24 +135,22 @@ class Gemfury::Command::App < Thor
|
|
126
135
|
|
127
136
|
collaborators = client.list_collaborators
|
128
137
|
if collaborators.empty?
|
129
|
-
shell.say %
|
138
|
+
shell.say %(You (#{me}) are the only collaborator\n), :green
|
130
139
|
else
|
131
|
-
shell.say %
|
140
|
+
shell.say %(\n*** Collaborators for "#{me}" ***\n), :green
|
132
141
|
|
133
|
-
va = [
|
142
|
+
va = [%w[username permission]]
|
134
143
|
|
135
|
-
if account_info['type'] == 'user'
|
136
|
-
va << [ me, 'owner' ]
|
137
|
-
end
|
144
|
+
va << [me, 'owner'] if account_info['type'] == 'user'
|
138
145
|
|
139
|
-
collaborators.each { |c| va << [
|
146
|
+
collaborators.each { |c| va << [c['username'], c['permission']] }
|
140
147
|
|
141
148
|
shell.print_table(va)
|
142
149
|
end
|
143
150
|
end
|
144
151
|
end
|
145
152
|
|
146
|
-
desc
|
153
|
+
desc 'sharing:add EMAIL', 'Add a collaborator'
|
147
154
|
def sharing_add(username)
|
148
155
|
with_checks_and_rescues do
|
149
156
|
client.add_collaborator(username)
|
@@ -151,7 +158,7 @@ class Gemfury::Command::App < Thor
|
|
151
158
|
end
|
152
159
|
end
|
153
160
|
|
154
|
-
desc
|
161
|
+
desc 'sharing:remove EMAIL', 'Remove a collaborator'
|
155
162
|
def sharing_remove(username)
|
156
163
|
with_checks_and_rescues do
|
157
164
|
client.remove_collaborator(username)
|
@@ -160,7 +167,7 @@ class Gemfury::Command::App < Thor
|
|
160
167
|
end
|
161
168
|
|
162
169
|
### MIGRATION (Pushing directories) ###
|
163
|
-
desc
|
170
|
+
desc 'migrate DIR', 'Upload all packages within a directory'
|
164
171
|
def migrate(*paths)
|
165
172
|
with_checks_and_rescues do
|
166
173
|
gem_paths = Dir.glob(paths.map do |p|
|
@@ -168,30 +175,26 @@ class Gemfury::Command::App < Thor
|
|
168
175
|
PackageExtensions.map { |ext| "#{p}/**/*.#{ext}" }
|
169
176
|
elsif File.file?(p)
|
170
177
|
p
|
171
|
-
else
|
172
|
-
nil
|
173
178
|
end
|
174
179
|
end.flatten.compact)
|
175
180
|
|
176
181
|
if gem_paths.empty?
|
177
|
-
die!(
|
182
|
+
die!('Problem: No valid packages found', nil, :migrate)
|
178
183
|
else
|
179
|
-
shell.say
|
184
|
+
shell.say 'Found the following packages:'
|
180
185
|
gem_paths.each { |p| shell.say " #{File.basename(p)}" }
|
181
|
-
if shell.yes?
|
182
|
-
push_files(:migrate, gem_paths)
|
183
|
-
end
|
186
|
+
push_files(:migrate, gem_paths) if shell.yes? 'Upload these files to Gemfury? [yN]', :green
|
184
187
|
end
|
185
188
|
end
|
186
189
|
end
|
187
190
|
|
188
191
|
### GIT REPOSITORY MANAGEMENT ###
|
189
|
-
map
|
190
|
-
map
|
191
|
-
map
|
192
|
-
map
|
192
|
+
map 'git:list' => 'git_list'
|
193
|
+
map 'git:reset' => 'git_reset'
|
194
|
+
map 'git:rename' => 'git_rename'
|
195
|
+
map 'git:rebuild' => 'git_rebuild'
|
193
196
|
|
194
|
-
desc
|
197
|
+
desc 'git:list', 'List Git repositories'
|
195
198
|
def git_list
|
196
199
|
with_checks_and_rescues do
|
197
200
|
repos = client.git_repos['repos']
|
@@ -201,15 +204,15 @@ class Gemfury::Command::App < Thor
|
|
201
204
|
end
|
202
205
|
end
|
203
206
|
|
204
|
-
desc
|
207
|
+
desc 'git:rename REPO_NAME NEW_NAME', 'Rename a Git repository'
|
205
208
|
def git_rename(repo, new_name)
|
206
209
|
with_checks_and_rescues do
|
207
|
-
client.git_update(repo, :
|
210
|
+
client.git_update(repo, repo: { name: new_name })
|
208
211
|
shell.say "Renamed #{repo} repository to #{new_name}\n"
|
209
212
|
end
|
210
213
|
end
|
211
214
|
|
212
|
-
desc
|
215
|
+
desc 'git:reset REPO_NAME', 'Remove a Git repository'
|
213
216
|
def git_reset(repo)
|
214
217
|
with_checks_and_rescues do
|
215
218
|
client.git_reset(repo)
|
@@ -217,13 +220,13 @@ class Gemfury::Command::App < Thor
|
|
217
220
|
end
|
218
221
|
end
|
219
222
|
|
220
|
-
desc
|
221
|
-
method_options %w
|
223
|
+
desc 'git:rebuild REPO_NAME', 'Rebuild a Git repository'
|
224
|
+
method_options %w[revision -r] => :string
|
222
225
|
def git_rebuild(repo)
|
223
226
|
with_checks_and_rescues do
|
224
|
-
params = { :
|
227
|
+
params = { revision: options[:revision] }
|
225
228
|
shell.say "\n*** Rebuilding #{repo} repository ***\n\n"
|
226
|
-
shell.say client.git_rebuild(repo, :
|
229
|
+
shell.say client.git_rebuild(repo, build: params)
|
227
230
|
end
|
228
231
|
end
|
229
232
|
|
@@ -232,84 +235,85 @@ class Gemfury::Command::App < Thor
|
|
232
235
|
map 'git:config:set' => 'git_config_set'
|
233
236
|
map 'git:config:unset' => 'git_config_unset'
|
234
237
|
|
235
|
-
desc
|
238
|
+
desc 'git:config REPO_NAME', "List Git repository's build environment"
|
236
239
|
def git_config(repo)
|
237
240
|
with_checks_and_rescues do
|
238
241
|
vars = client.git_config(repo)['config_vars']
|
239
242
|
shell.say "*** #{repo} build config ***\n"
|
240
|
-
shell.print_table(vars.map
|
243
|
+
shell.print_table(vars.map do |kv|
|
241
244
|
["#{kv[0]}:", kv[1]]
|
242
|
-
|
245
|
+
end)
|
243
246
|
end
|
244
247
|
end
|
245
248
|
|
246
|
-
desc
|
249
|
+
desc 'git:config:set REPO_NAME KEY=VALUE ...', "Update Git repository's build environment"
|
247
250
|
def git_config_set(repo, *vars)
|
248
251
|
with_checks_and_rescues do
|
249
|
-
updates =
|
252
|
+
updates = vars.to_h { |v| v.split('=', 2) }
|
250
253
|
client.git_config_update(repo, updates)
|
251
254
|
shell.say "Updated #{repo} build config"
|
252
255
|
end
|
253
256
|
end
|
254
257
|
|
255
|
-
desc
|
258
|
+
desc 'git:config:unset REPO_NAME KEY ...', "Remove variables from Git repository's build environment"
|
256
259
|
def git_config_unset(repo, *vars)
|
257
260
|
with_checks_and_rescues do
|
258
|
-
updates =
|
261
|
+
updates = vars.to_h { |v| [v, nil] }
|
259
262
|
client.git_config_update(repo, updates)
|
260
263
|
shell.say "Updated #{repo} build config"
|
261
264
|
end
|
262
265
|
end
|
263
266
|
|
264
|
-
private
|
267
|
+
private
|
268
|
+
|
265
269
|
def client
|
266
270
|
opts = {}
|
267
271
|
opts[:user_api_key] = @user_api_key if @user_api_key
|
268
272
|
opts[:account] = options[:as] if options[:as]
|
269
273
|
client = Gemfury::Client.new(opts)
|
270
274
|
client.user_agent = UserAgent
|
271
|
-
|
275
|
+
client
|
272
276
|
end
|
273
277
|
|
274
278
|
def with_checks_and_rescues(&block)
|
275
279
|
@user_api_key = options[:api_token] if options[:api_token]
|
280
|
+
|
281
|
+
msg = '[DEPRECATED] This CLI is no longer supported. Please upgrade to the new CLI: https://gemfury.com/guide/cli'
|
282
|
+
shell.say(msg, :yellow) if !options[:quiet] && !options[:no_warnings] && !current_command_chain.include?(:logout)
|
283
|
+
|
276
284
|
with_authorization(&block)
|
277
285
|
rescue Gemfury::InvalidGemVersion => e
|
278
|
-
shell.say
|
279
|
-
if shell.yes?
|
280
|
-
exec(
|
286
|
+
shell.say 'You have a deprecated Gemfury client', :red
|
287
|
+
if shell.yes? 'Would you like to update it now? [yN]'
|
288
|
+
exec('gem update gemfury')
|
281
289
|
else
|
282
|
-
shell.say
|
290
|
+
shell.say 'No problem. You can also run "gem update gemfury"'
|
283
291
|
end
|
284
292
|
rescue Gemfury::Conflict => e
|
285
|
-
die!(
|
293
|
+
die!('Oops! Locked for another user. Try again later.', e)
|
286
294
|
rescue Gemfury::Forbidden => e
|
287
295
|
die!("Oops! You're not allowed to access this", e)
|
288
296
|
rescue Gemfury::NotFound => e
|
289
297
|
die!("Oops! Doesn't look like this exists", e)
|
290
298
|
rescue Gemfury::Error => e
|
291
|
-
die!(
|
299
|
+
die!('Oops! %s' % e.message, e)
|
292
300
|
rescue StandardError => e
|
293
|
-
die!(
|
301
|
+
die!('Oops! Something went wrong. Please contact support.', e)
|
294
302
|
end
|
295
303
|
|
296
304
|
def push_files(command, gem_paths)
|
297
305
|
files = gem_paths.map do |g|
|
298
|
-
g.is_a?(String) ? File.new(g) : g
|
306
|
+
g.is_a?(String) ? File.new(g) : g
|
307
|
+
rescue StandardError
|
308
|
+
nil
|
299
309
|
end.compact
|
300
310
|
|
301
|
-
if !options[:quiet] && !shell.mute? && $stdout.tty?
|
302
|
-
files = files.map { |g| ProgressIO.new(g) }
|
303
|
-
end
|
311
|
+
files = files.map { |g| ProgressIO.new(g) } if !options[:quiet] && !shell.mute? && $stdout.tty?
|
304
312
|
|
305
|
-
if files.empty?
|
306
|
-
die!("Problem: No valid packages found", nil, command)
|
307
|
-
end
|
313
|
+
die!('Problem: No valid packages found', nil, command) if files.empty?
|
308
314
|
|
309
|
-
push_options = {
|
310
|
-
unless options[:public].nil?
|
311
|
-
push_options[:public] = options[:public]
|
312
|
-
end
|
315
|
+
push_options = {}
|
316
|
+
push_options[:public] = options[:public] unless options[:public].nil?
|
313
317
|
|
314
318
|
error_ex = nil
|
315
319
|
|
@@ -330,29 +334,32 @@ private
|
|
330
334
|
client.push_gem(file, push_options)
|
331
335
|
end
|
332
336
|
|
333
|
-
shell.say
|
337
|
+
shell.say '- done'
|
334
338
|
rescue Gemfury::CorruptGemFile => e
|
335
|
-
shell.say
|
339
|
+
shell.say '- problem processing this package', :red
|
336
340
|
error_ex = e
|
337
341
|
rescue Gemfury::DupeVersion => e
|
338
|
-
shell.say
|
342
|
+
shell.say '- this version already exists', :red
|
339
343
|
error_ex = e
|
340
344
|
rescue Gemfury::TimeoutError, Errno::EPIPE => e
|
341
|
-
shell.say
|
342
|
-
shell.say
|
345
|
+
shell.say '- this file is too much to handle', :red
|
346
|
+
shell.say ' Visit http://www.gemfury.com/large-package for more info'
|
347
|
+
error_ex = e
|
348
|
+
rescue Gemfury::Error => e
|
349
|
+
shell.say "- #{e.message.downcase}", :red
|
343
350
|
error_ex = e
|
344
|
-
rescue => e
|
345
|
-
shell.say
|
351
|
+
rescue StandardError => e
|
352
|
+
shell.say '- oops', :red
|
346
353
|
error_ex = e
|
347
354
|
end
|
348
355
|
end
|
349
356
|
|
350
|
-
|
351
|
-
|
352
|
-
|
357
|
+
return if error_ex.nil?
|
358
|
+
|
359
|
+
die!('There was a problem uploading at least 1 package', error_ex)
|
353
360
|
end
|
354
361
|
|
355
|
-
C50K =
|
362
|
+
C50K = 50_000
|
356
363
|
|
357
364
|
class ProgressIO < SimpleDelegator
|
358
365
|
attr_reader :content_type, :original_filename, :local_path
|
@@ -374,15 +381,15 @@ private
|
|
374
381
|
@original_filename = File.basename(fname)
|
375
382
|
@local_path = local_path
|
376
383
|
|
377
|
-
if io.respond_to? :size
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
384
|
+
filesize = if io.respond_to? :size
|
385
|
+
io.size
|
386
|
+
else
|
387
|
+
io.stat.size
|
388
|
+
end
|
382
389
|
|
383
390
|
if filesize > C50K
|
384
391
|
title = 'Uploading %s ' % File.basename(fname)
|
385
|
-
@bar = ProgressBar.create(:
|
392
|
+
@bar = ProgressBar.create(title: title, total: filesize)
|
386
393
|
else
|
387
394
|
@bar = nil
|
388
395
|
end
|
@@ -396,9 +403,7 @@ private
|
|
396
403
|
|
397
404
|
def read(length)
|
398
405
|
buf = __getobj__.read(length)
|
399
|
-
unless @bar.nil? || buf.nil?
|
400
|
-
@bar.progress += buf.bytesize
|
401
|
-
end
|
406
|
+
@bar.progress += buf.bytesize unless @bar.nil? || buf.nil?
|
402
407
|
|
403
408
|
buf
|
404
409
|
end
|
@@ -407,7 +412,7 @@ private
|
|
407
412
|
def die!(msg, err = nil, command = nil)
|
408
413
|
shell.say msg, :red
|
409
414
|
help(command) if command
|
410
|
-
shell.say %
|
415
|
+
shell.say %(#{err.class.name}: #{err}\n#{err.backtrace.join("\n")}) if err && ENV['DEBUG']
|
411
416
|
exit(1)
|
412
417
|
end
|
413
418
|
|
@@ -1,18 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Gemfury::Command::Authorization
|
2
4
|
include Gemfury::Platform
|
3
5
|
|
4
6
|
def wipe_credentials!
|
5
|
-
FileUtils.rm(config_path, :
|
7
|
+
FileUtils.rm(config_path, force: true) # never raises exception
|
6
8
|
each_netrc_host { |h| netrc_conf.delete(h) }
|
7
9
|
netrc_conf.save
|
8
10
|
end
|
9
11
|
|
10
12
|
def has_credentials?
|
11
13
|
!!netrc_conf[netrc_api_host] ||
|
12
|
-
|
14
|
+
read_config_file.key?(:gemfury_api_key)
|
13
15
|
end
|
14
16
|
|
15
|
-
private
|
17
|
+
private
|
18
|
+
|
16
19
|
def with_authorization(&block)
|
17
20
|
# Load up the credentials if user_api_key is not already set
|
18
21
|
load_credentials! if @user_api_key.nil?
|
@@ -24,9 +27,9 @@ private
|
|
24
27
|
block.call
|
25
28
|
rescue Gemfury::Unauthorized
|
26
29
|
if acct = client.account
|
27
|
-
shell.say %
|
30
|
+
shell.say %(Oops! You don't have access to "#{acct}"), :red
|
28
31
|
else
|
29
|
-
shell.say
|
32
|
+
shell.say 'Oops! Authentication failure.', :red
|
30
33
|
@user_api_key = nil
|
31
34
|
retry
|
32
35
|
end
|
@@ -41,10 +44,10 @@ private
|
|
41
44
|
passw = highline.ask('Password: ') { |q| q.echo = false }
|
42
45
|
|
43
46
|
# Request and save the API access token
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
47
|
+
return unless !email.empty? && !passw.empty?
|
48
|
+
|
49
|
+
@user_api_key = client.get_access_token(email, passw)
|
50
|
+
write_credentials!(email)
|
48
51
|
end
|
49
52
|
|
50
53
|
def load_credentials!
|
@@ -72,8 +75,8 @@ private
|
|
72
75
|
end
|
73
76
|
|
74
77
|
def each_netrc_host
|
75
|
-
[
|
78
|
+
%i[endpoint gitpoint].each do |c|
|
76
79
|
yield(URI.parse(client.send(c)).host)
|
77
80
|
end
|
78
81
|
end
|
79
|
-
end
|
82
|
+
end
|
data/lib/gemfury/command.rb
CHANGED
@@ -1,6 +1,8 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
gem
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
gem 'highline', '>= 1.6.0', '< 2.2.0.pre'
|
4
|
+
gem 'progressbar', '>= 1.10.1', '< 2.0.0.pre'
|
5
|
+
gem 'thor', '>= 0.14.0', '< 1.3.0.pre'
|
4
6
|
|
5
7
|
require 'thor'
|
6
8
|
require 'yaml'
|
@@ -1,15 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Gemfury
|
2
4
|
module Configuration
|
3
|
-
|
4
5
|
CONFIGURATION_DEFAULTS = {
|
5
|
-
:
|
6
|
-
:
|
7
|
-
:
|
8
|
-
:
|
9
|
-
:
|
10
|
-
:
|
11
|
-
:
|
12
|
-
:
|
6
|
+
user_api_key: nil,
|
7
|
+
adapter: :net_http,
|
8
|
+
endpoint: 'https://api.fury.io/',
|
9
|
+
gitpoint: 'https://git.fury.io/',
|
10
|
+
pushpoint: 'https://push.fury.io/',
|
11
|
+
user_agent: "Gemfury RubyGem #{Gemfury::VERSION} (Ruby #{RUBY_VERSION})",
|
12
|
+
api_version: 1,
|
13
|
+
account: nil
|
13
14
|
}.freeze
|
14
15
|
|
15
16
|
# user API key, also known as "full access token"
|
data/lib/gemfury/const.rb
CHANGED
@@ -1,9 +1,11 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Gemfury
|
2
4
|
module Const
|
3
5
|
class << self
|
4
6
|
def host
|
5
7
|
'www.gemfury.com'
|
6
|
-
#'localhost:3000'
|
8
|
+
# 'localhost:3000'
|
7
9
|
end
|
8
10
|
|
9
11
|
def welcome
|
@@ -11,11 +13,12 @@ module Gemfury
|
|
11
13
|
end
|
12
14
|
|
13
15
|
def email_error
|
14
|
-
|
16
|
+
'Invalid email address. Please try again.'
|
15
17
|
end
|
16
18
|
|
17
19
|
def email_regex
|
18
20
|
return @email_regex if @email_regex
|
21
|
+
|
19
22
|
email_name_regex = '[A-Z0-9_\.%\+\-\']+'
|
20
23
|
domain_head_regex = '(?:[A-Z0-9\-]+\.)+'
|
21
24
|
domain_tld_regex = '(?:[A-Z]{2,4}|museum|travel)'
|
data/lib/gemfury/error.rb
CHANGED
data/lib/gemfury/platform.rb
CHANGED
@@ -1,7 +1,9 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Gemfury
|
2
4
|
module Platform
|
3
5
|
def home_directory
|
4
|
-
on_windows? ? ENV
|
6
|
+
on_windows? ? ENV.fetch('USERPROFILE', nil) : Dir.home
|
5
7
|
end
|
6
8
|
|
7
9
|
def config_path
|
@@ -16,4 +18,4 @@ module Gemfury
|
|
16
18
|
RUBY_PLATFORM =~ /-darwin\d/
|
17
19
|
end
|
18
20
|
end
|
19
|
-
end
|
21
|
+
end
|