gemfury 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 +7 -0
- data/README.md +87 -0
- data/bin/fury +10 -0
- data/bin/gemfury +2 -0
- data/lib/faraday/adapter/fury_http.rb +32 -0
- data/lib/faraday/request/multipart_with_file.rb +34 -0
- data/lib/gemfury.rb +82 -0
- data/lib/gemfury/client.rb +273 -0
- data/lib/gemfury/client/filters.rb +18 -0
- data/lib/gemfury/client/middleware.rb +23 -0
- data/lib/gemfury/command.rb +13 -0
- data/lib/gemfury/command/app.rb +425 -0
- data/lib/gemfury/command/authorization.rb +79 -0
- data/lib/gemfury/configuration.rb +48 -0
- data/lib/gemfury/const.rb +26 -0
- data/lib/gemfury/error.rb +28 -0
- data/lib/gemfury/platform.rb +19 -0
- data/lib/gemfury/tasks.rb +2 -0
- data/lib/gemfury/tasks/release.rake +36 -0
- data/lib/gemfury/version.rb +3 -0
- data/lib/rubygems/commands/fury_command.rb +29 -0
- data/lib/rubygems_plugin.rb +2 -0
- metadata +197 -0
@@ -0,0 +1,79 @@
|
|
1
|
+
module Gemfury::Command::Authorization
|
2
|
+
include Gemfury::Platform
|
3
|
+
|
4
|
+
def wipe_credentials!
|
5
|
+
FileUtils.rm(config_path, :force => true) # never raises exception
|
6
|
+
each_netrc_host { |h| netrc_conf.delete(h) }
|
7
|
+
netrc_conf.save
|
8
|
+
end
|
9
|
+
|
10
|
+
def has_credentials?
|
11
|
+
!!netrc_conf[netrc_api_host] ||
|
12
|
+
read_config_file.key?(:gemfury_api_key)
|
13
|
+
end
|
14
|
+
|
15
|
+
private
|
16
|
+
def with_authorization(&block)
|
17
|
+
# Load up the credentials if user_api_key is not already set
|
18
|
+
load_credentials! if @user_api_key.nil?
|
19
|
+
|
20
|
+
# Attempt the operation and prompt user in case of
|
21
|
+
# lack of authorization or a 401 response from the server
|
22
|
+
begin
|
23
|
+
prompt_credentials! if @user_api_key.nil?
|
24
|
+
block.call
|
25
|
+
rescue Gemfury::Unauthorized
|
26
|
+
if acct = client.account
|
27
|
+
shell.say %Q(Oops! You don't have access to "#{acct}"), :red
|
28
|
+
else
|
29
|
+
shell.say "Oops! Authentication failure.", :red
|
30
|
+
@user_api_key = nil
|
31
|
+
retry
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def prompt_credentials!
|
37
|
+
# Prompt credentials
|
38
|
+
highline = HighLine.new
|
39
|
+
highline.say 'Please enter your Gemfury credentials.'
|
40
|
+
email = highline.ask('Email: ')
|
41
|
+
passw = highline.ask('Password: ') { |q| q.echo = false }
|
42
|
+
|
43
|
+
# Request and save the API access token
|
44
|
+
if !email.empty? && !passw.empty?
|
45
|
+
@user_api_key = client.get_access_token(email, passw)
|
46
|
+
write_credentials!(email)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
def load_credentials!
|
51
|
+
# Get credentials from ~/.netrc
|
52
|
+
_, @user_api_key = netrc_conf[netrc_api_host]
|
53
|
+
# Legacy loading from ~/.gem/gemfury
|
54
|
+
@user_api_key ||= read_config_file[:gemfury_api_key]
|
55
|
+
end
|
56
|
+
|
57
|
+
def write_credentials!(email)
|
58
|
+
each_netrc_host { |h| netrc_conf[h] = email, @user_api_key }
|
59
|
+
netrc_conf.save
|
60
|
+
end
|
61
|
+
|
62
|
+
def read_config_file
|
63
|
+
File.exist?(config_path) ? YAML.load_file(config_path) : {}
|
64
|
+
end
|
65
|
+
|
66
|
+
def netrc_conf
|
67
|
+
@netrc ||= Netrc.read
|
68
|
+
end
|
69
|
+
|
70
|
+
def netrc_api_host
|
71
|
+
URI.parse(client.endpoint).host
|
72
|
+
end
|
73
|
+
|
74
|
+
def each_netrc_host
|
75
|
+
[:endpoint, :gitpoint].each do |c|
|
76
|
+
yield(URI.parse(client.send(c)).host)
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
module Gemfury
|
2
|
+
module Configuration
|
3
|
+
|
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
|
26
|
+
|
27
|
+
# The HTTP endpoint for git repo (used for .netrc credentials)
|
28
|
+
# @return [String]
|
29
|
+
attr_accessor :gitpoint
|
30
|
+
|
31
|
+
# The endpoint for the Push API
|
32
|
+
# @return [String]
|
33
|
+
attr_accessor :pushpoint
|
34
|
+
|
35
|
+
# The value sent in the 'User-Agent' header
|
36
|
+
# @return [String]
|
37
|
+
attr_accessor :user_agent
|
38
|
+
|
39
|
+
# Gemfury remote API version
|
40
|
+
# @return [Integer]
|
41
|
+
attr_accessor :api_version
|
42
|
+
|
43
|
+
# The account to impersonate, if you have permissions for multiple accounts
|
44
|
+
# (If nil, no impersonation)
|
45
|
+
# @return [String]
|
46
|
+
attr_accessor :account
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module Gemfury
|
2
|
+
module Const
|
3
|
+
class << self
|
4
|
+
def host
|
5
|
+
'www.gemfury.com'
|
6
|
+
#'localhost:3000'
|
7
|
+
end
|
8
|
+
|
9
|
+
def welcome
|
10
|
+
"Welcome to Gemfury!\nPlease complete the following information"
|
11
|
+
end
|
12
|
+
|
13
|
+
def email_error
|
14
|
+
"Invalid email address. Please try again."
|
15
|
+
end
|
16
|
+
|
17
|
+
def email_regex
|
18
|
+
return @email_regex if @email_regex
|
19
|
+
email_name_regex = '[A-Z0-9_\.%\+\-\']+'
|
20
|
+
domain_head_regex = '(?:[A-Z0-9\-]+\.)+'
|
21
|
+
domain_tld_regex = '(?:[A-Z]{2,4}|museum|travel)'
|
22
|
+
@email_regex = /^#{email_name_regex}@#{domain_head_regex}#{domain_tld_regex}$/i
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module Gemfury
|
2
|
+
# Base Error class
|
3
|
+
Error = Class.new(StandardError)
|
4
|
+
|
5
|
+
# The Gemfury gem version doesn't match the one on the server
|
6
|
+
InvalidGemVersion = Class.new(Error)
|
7
|
+
|
8
|
+
# Client#user_api_key is not defined or Gemfury returns 401
|
9
|
+
Unauthorized = Class.new(Error)
|
10
|
+
|
11
|
+
# Client is not allowed to perform this operation
|
12
|
+
Forbidden = Class.new(Error)
|
13
|
+
|
14
|
+
# Account is locked for another operation
|
15
|
+
Conflict = Class.new(Error)
|
16
|
+
|
17
|
+
# Returned if something is not found
|
18
|
+
NotFound = Class.new(Error)
|
19
|
+
|
20
|
+
# Corrupt Gem File
|
21
|
+
CorruptGemFile = Class.new(Error)
|
22
|
+
|
23
|
+
# Version already exists
|
24
|
+
DupeVersion = Class.new(Error)
|
25
|
+
|
26
|
+
# TimeoutError for 503s
|
27
|
+
TimeoutError = Class.new(Error)
|
28
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Gemfury
|
2
|
+
module Platform
|
3
|
+
def home_directory
|
4
|
+
on_windows? ? ENV['USERPROFILE'] : ENV['HOME']
|
5
|
+
end
|
6
|
+
|
7
|
+
def config_path
|
8
|
+
File.expand_path('.gem/gemfury', home_directory)
|
9
|
+
end
|
10
|
+
|
11
|
+
def on_windows?
|
12
|
+
RUBY_PLATFORM =~ /mswin32|mingw32/
|
13
|
+
end
|
14
|
+
|
15
|
+
def on_mac?
|
16
|
+
RUBY_PLATFORM =~ /-darwin\d/
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'rubygems/package'
|
2
|
+
require 'gemfury'
|
3
|
+
require 'gemfury/command'
|
4
|
+
|
5
|
+
namespace 'fury' do
|
6
|
+
desc "Build gem and push it to Gemfury"
|
7
|
+
task :release, [:gemspec, :as] do |t, args|
|
8
|
+
gemspec = args[:gemspec] ||
|
9
|
+
FileList["#{Dir.pwd}/*.gemspec"][0]
|
10
|
+
|
11
|
+
if gemspec.nil? || !File.exist?(gemspec)
|
12
|
+
puts "No gemspec found"
|
13
|
+
else
|
14
|
+
puts "Building #{File.basename(gemspec)}"
|
15
|
+
spec = Gem::Specification.load(gemspec)
|
16
|
+
|
17
|
+
if Gem::Package.respond_to?(:build)
|
18
|
+
Gem::Package.build(spec)
|
19
|
+
else
|
20
|
+
require 'rubygems/builder'
|
21
|
+
Gem::Builder.new(spec).build
|
22
|
+
end
|
23
|
+
|
24
|
+
gemfile = File.basename(spec.cache_file)
|
25
|
+
|
26
|
+
params = ['push', gemfile]
|
27
|
+
params << "--as=#{args[:as]}" if args[:as]
|
28
|
+
|
29
|
+
Gemfury::Command::App.start(params)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
namespace 'gemfury' do
|
35
|
+
task :release => 'fury:release'
|
36
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'gemfury'
|
2
|
+
require 'gemfury/command'
|
3
|
+
|
4
|
+
class Gem::Commands::FuryCommand < Gem::Command
|
5
|
+
def description
|
6
|
+
'Push a private gem to your Gemfury account'
|
7
|
+
end
|
8
|
+
|
9
|
+
def arguments
|
10
|
+
"GEM built gem file to push"
|
11
|
+
end
|
12
|
+
|
13
|
+
def usage
|
14
|
+
"#{program_name} GEM"
|
15
|
+
end
|
16
|
+
|
17
|
+
def initialize
|
18
|
+
super 'fury', description
|
19
|
+
add_option('-a', '--as USERNAME', 'Impersonate another account') do |value, options|
|
20
|
+
options[:as] = value
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def execute
|
25
|
+
opts = options.dup
|
26
|
+
args = opts.delete(:args)
|
27
|
+
Gemfury::Command::App.send(:dispatch, "push", args, opts, {})
|
28
|
+
end
|
29
|
+
end
|
metadata
ADDED
@@ -0,0 +1,197 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: gemfury
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.12.0.rc1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Michael Rykov
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2020-07-08 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: multi_json
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.10'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.10'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: thor
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 0.14.0
|
34
|
+
- - "<"
|
35
|
+
- !ruby/object:Gem::Version
|
36
|
+
version: 1.1.0.pre
|
37
|
+
type: :runtime
|
38
|
+
prerelease: false
|
39
|
+
version_requirements: !ruby/object:Gem::Requirement
|
40
|
+
requirements:
|
41
|
+
- - ">="
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: 0.14.0
|
44
|
+
- - "<"
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: 1.1.0.pre
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: netrc
|
49
|
+
requirement: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - ">="
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: 0.10.0
|
54
|
+
- - "<"
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
version: 0.12.0.pre
|
57
|
+
type: :runtime
|
58
|
+
prerelease: false
|
59
|
+
version_requirements: !ruby/object:Gem::Requirement
|
60
|
+
requirements:
|
61
|
+
- - ">="
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
version: 0.10.0
|
64
|
+
- - "<"
|
65
|
+
- !ruby/object:Gem::Version
|
66
|
+
version: 0.12.0.pre
|
67
|
+
- !ruby/object:Gem::Dependency
|
68
|
+
name: faraday
|
69
|
+
requirement: !ruby/object:Gem::Requirement
|
70
|
+
requirements:
|
71
|
+
- - ">="
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
version: 0.9.0
|
74
|
+
- - "<"
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: 1.1.0.pre
|
77
|
+
type: :runtime
|
78
|
+
prerelease: false
|
79
|
+
version_requirements: !ruby/object:Gem::Requirement
|
80
|
+
requirements:
|
81
|
+
- - ">="
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: 0.9.0
|
84
|
+
- - "<"
|
85
|
+
- !ruby/object:Gem::Version
|
86
|
+
version: 1.1.0.pre
|
87
|
+
- !ruby/object:Gem::Dependency
|
88
|
+
name: highline
|
89
|
+
requirement: !ruby/object:Gem::Requirement
|
90
|
+
requirements:
|
91
|
+
- - ">="
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: 1.6.0
|
94
|
+
- - "<"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: 2.1.0.pre
|
97
|
+
type: :runtime
|
98
|
+
prerelease: false
|
99
|
+
version_requirements: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: 1.6.0
|
104
|
+
- - "<"
|
105
|
+
- !ruby/object:Gem::Version
|
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
|
127
|
+
description: 'Hosted repo for your public and private packages at https://gemfury.com
|
128
|
+
|
129
|
+
'
|
130
|
+
email: hello@gemfury.com
|
131
|
+
executables:
|
132
|
+
- gemfury
|
133
|
+
- fury
|
134
|
+
extensions: []
|
135
|
+
extra_rdoc_files: []
|
136
|
+
files:
|
137
|
+
- README.md
|
138
|
+
- bin/fury
|
139
|
+
- bin/gemfury
|
140
|
+
- lib/faraday/adapter/fury_http.rb
|
141
|
+
- lib/faraday/request/multipart_with_file.rb
|
142
|
+
- lib/gemfury.rb
|
143
|
+
- lib/gemfury/client.rb
|
144
|
+
- lib/gemfury/client/filters.rb
|
145
|
+
- lib/gemfury/client/middleware.rb
|
146
|
+
- lib/gemfury/command.rb
|
147
|
+
- lib/gemfury/command/app.rb
|
148
|
+
- lib/gemfury/command/authorization.rb
|
149
|
+
- lib/gemfury/configuration.rb
|
150
|
+
- lib/gemfury/const.rb
|
151
|
+
- lib/gemfury/error.rb
|
152
|
+
- lib/gemfury/platform.rb
|
153
|
+
- lib/gemfury/tasks.rb
|
154
|
+
- lib/gemfury/tasks/release.rake
|
155
|
+
- lib/gemfury/version.rb
|
156
|
+
- lib/rubygems/commands/fury_command.rb
|
157
|
+
- lib/rubygems_plugin.rb
|
158
|
+
homepage: https://gemfury.com
|
159
|
+
licenses:
|
160
|
+
- MIT
|
161
|
+
metadata: {}
|
162
|
+
post_install_message: |
|
163
|
+
************************************************************************
|
164
|
+
|
165
|
+
Upload your first package to start using Gemfury:
|
166
|
+
fury push my-package-1.0.0.gem
|
167
|
+
|
168
|
+
If you have a directory with packages, you can use:
|
169
|
+
fury migrate ./path/to/codez
|
170
|
+
|
171
|
+
Find out what else you can do:
|
172
|
+
fury help
|
173
|
+
|
174
|
+
Follow @gemfury on Twitter for announcements, updates, and news.
|
175
|
+
https://twitter.com/gemfury
|
176
|
+
|
177
|
+
************************************************************************
|
178
|
+
rdoc_options: []
|
179
|
+
require_paths:
|
180
|
+
- lib
|
181
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
182
|
+
requirements:
|
183
|
+
- - ">="
|
184
|
+
- !ruby/object:Gem::Version
|
185
|
+
version: '0'
|
186
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
187
|
+
requirements:
|
188
|
+
- - ">"
|
189
|
+
- !ruby/object:Gem::Version
|
190
|
+
version: 1.3.1
|
191
|
+
requirements: []
|
192
|
+
rubyforge_project:
|
193
|
+
rubygems_version: 2.7.8
|
194
|
+
signing_key:
|
195
|
+
specification_version: 4
|
196
|
+
summary: Hosted repo for your public and private packages
|
197
|
+
test_files: []
|