Class: Gemfury::Command::App
- Inherits:
-
Thor
- Object
- Thor
- Gemfury::Command::App
show all
- Includes:
- Authorization
- Defined in:
- lib/gemfury/command/app.rb
Defined Under Namespace
Classes: ProgressIO
Constant Summary
collapse
- UserAgent =
"Gemfury CLI #{Gemfury::VERSION}"
- PackageExtensions =
%w[gem egg tar.gz tgz nupkg].freeze
Class Method Summary
collapse
Instance Method Summary
collapse
#has_credentials?, #wipe_credentials!
Methods included from Platform
#config_path, #home_directory, #on_mac?, #on_windows?
Class Method Details
.exit_on_failure? ⇒ Boolean
Make sure we retain the default exit behaviour of 0 even on argument errors
17
18
19
|
# File 'lib/gemfury/command/app.rb', line 17
def self.exit_on_failure?
false
end
|
Instance Method Details
#accounts ⇒ Object
113
114
115
116
117
118
119
120
121
122
123
124
|
# File 'lib/gemfury/command/app.rb', line 113
def accounts
with_checks_and_rescues do
accounts = client.accounts
va = [%w[name kind permission]]
accounts.each do |a|
va << [a['name'], a['type'], a['viewer_permission'].downcase]
end
shell.print_table(va)
end
end
|
#git_config(repo) ⇒ Object
239
240
241
242
243
244
245
246
247
|
# File 'lib/gemfury/command/app.rb', line 239
def git_config(repo)
with_checks_and_rescues do
vars = client.git_config(repo)['config_vars']
shell.say "*** #{repo} build config ***\n"
shell.print_table(vars.map do |kv|
["#{kv[0]}:", kv[1]]
end)
end
end
|
#git_config_set(repo, *vars) ⇒ Object
250
251
252
253
254
255
256
|
# File 'lib/gemfury/command/app.rb', line 250
def git_config_set(repo, *vars)
with_checks_and_rescues do
updates = vars.to_h { |v| v.split('=', 2) }
client.git_config_update(repo, updates)
shell.say "Updated #{repo} build config"
end
end
|
#git_config_unset(repo, *vars) ⇒ Object
259
260
261
262
263
264
265
|
# File 'lib/gemfury/command/app.rb', line 259
def git_config_unset(repo, *vars)
with_checks_and_rescues do
updates = vars.to_h { |v| [v, nil] }
client.git_config_update(repo, updates)
shell.say "Updated #{repo} build config"
end
end
|
#git_list ⇒ Object
198
199
200
201
202
203
204
205
|
# File 'lib/gemfury/command/app.rb', line 198
def git_list
with_checks_and_rescues do
repos = client.git_repos['repos']
shell.say "\n*** GEMFURY GIT REPOS ***\n\n"
names = repos.map { |r| r['name'] }
names.sort.each { |n| shell.say(n) }
end
end
|
#git_rebuild(repo) ⇒ Object
225
226
227
228
229
230
231
|
# File 'lib/gemfury/command/app.rb', line 225
def git_rebuild(repo)
with_checks_and_rescues do
params = { revision: options[:revision] }
shell.say "\n*** Rebuilding #{repo} repository ***\n\n"
shell.say client.git_rebuild(repo, build: params)
end
end
|
#git_rename(repo, new_name) ⇒ Object
208
209
210
211
212
213
|
# File 'lib/gemfury/command/app.rb', line 208
def git_rename(repo, new_name)
with_checks_and_rescues do
client.git_update(repo, repo: { name: new_name })
shell.say "Renamed #{repo} repository to #{new_name}\n"
end
end
|
#git_reset(repo) ⇒ Object
216
217
218
219
220
221
|
# File 'lib/gemfury/command/app.rb', line 216
def git_reset(repo)
with_checks_and_rescues do
client.git_reset(repo)
shell.say "\n*** Yanked #{repo} repository ***\n\n"
end
end
|
#list ⇒ Object
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
# File 'lib/gemfury/command/app.rb', line 38
def list
with_checks_and_rescues do
gems = client.list
shell.say "\n*** GEMFURY PACKAGES ***\n\n"
va = [%w[name kind version privacy]]
gems.each do |g|
va << [g['name'], g['language'],
g.dig('latest_version', 'version') || 'beta',
g['private'] ? 'private' : 'public ']
end
shell.print_table(va)
end
end
|
#login ⇒ Object
94
95
96
97
98
99
|
# File 'lib/gemfury/command/app.rb', line 94
def login
with_checks_and_rescues do
me = client.account_info['name']
shell.say %(You are logged in as "#{me}"), :green
end
end
|
#logout ⇒ Object
83
84
85
86
87
88
89
90
91
|
# File 'lib/gemfury/command/app.rb', line 83
def logout
if !has_credentials?
shell.say 'You are logged out'
elsif shell.yes? 'Are you sure you want to log out? [yN]'
with_checks_and_rescues { client.logout }
wipe_credentials!
shell.say 'You have been logged out'
end
end
|
#migrate(*paths) ⇒ Object
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
|
# File 'lib/gemfury/command/app.rb', line 171
def migrate(*paths)
with_checks_and_rescues do
gem_paths = Dir.glob(paths.map do |p|
if File.directory?(p)
PackageExtensions.map { |ext| "#{p}/**/*.#{ext}" }
elsif File.file?(p)
p
end
end.flatten.compact)
if gem_paths.empty?
die!('Problem: No valid packages found', nil, :migrate)
else
shell.say 'Found the following packages:'
gem_paths.each { |p| shell.say " #{File.basename(p)}" }
push_files(:migrate, gem_paths) if shell.yes? 'Upload these files to Gemfury? [yN]', :green
end
end
end
|
#push(*gems) ⇒ Object
31
32
33
34
35
|
# File 'lib/gemfury/command/app.rb', line 31
def push(*gems)
with_checks_and_rescues do
push_files(:push, gems)
end
end
|
#sharing ⇒ Object
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
|
# File 'lib/gemfury/command/app.rb', line 131
def sharing
with_checks_and_rescues do
account_info = client.account_info
me = account_info['username']
collaborators = client.list_collaborators
if collaborators.empty?
shell.say %(You (#{me}) are the only collaborator\n), :green
else
shell.say %(\n*** Collaborators for "#{me}" ***\n), :green
va = [%w[username permission]]
va << [me, 'owner'] if account_info['type'] == 'user'
collaborators.each { |c| va << [c['username'], c['permission']] }
shell.print_table(va)
end
end
end
|
#sharing_add(username) ⇒ Object
154
155
156
157
158
159
|
# File 'lib/gemfury/command/app.rb', line 154
def sharing_add(username)
with_checks_and_rescues do
client.add_collaborator(username)
shell.say "Invited #{username} as a collaborator"
end
end
|
#sharing_remove(username) ⇒ Object
162
163
164
165
166
167
|
# File 'lib/gemfury/command/app.rb', line 162
def sharing_remove(username)
with_checks_and_rescues do
client.remove_collaborator(username)
shell.say "Removed #{username} as a collaborator"
end
end
|
#version ⇒ Object
23
24
25
|
# File 'lib/gemfury/command/app.rb', line 23
def version
shell.say Gemfury::VERSION
end
|
#versions(gem_name) ⇒ Object
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
# File 'lib/gemfury/command/app.rb', line 55
def versions(gem_name)
with_checks_and_rescues do
versions = client.versions(gem_name)
shell.say "\n*** #{gem_name.capitalize} Versions ***\n\n"
va = []
va = [%w[version uploaded_by uploaded]]
versions.each do |v|
uploaded = time_ago(Time.parse(v['created_at']).getlocal)
va << [v['version'], v['created_by']['name'], uploaded]
end
shell.print_table(va)
end
end
|
#whoami ⇒ Object
102
103
104
105
106
107
108
109
110
|
# File 'lib/gemfury/command/app.rb', line 102
def whoami
if has_credentials?
login
else
shell.say 'You are not logged in', :green
end
end
|
#yank(gem_name) ⇒ Object
73
74
75
76
77
78
79
|
# File 'lib/gemfury/command/app.rb', line 73
def yank(gem_name)
with_checks_and_rescues do
version = options[:version]
client.yank_version(gem_name, version)
shell.say "\n*** Yanked #{gem_name}-#{version} ***\n\n"
end
end
|