bundler-push-host-key 1.0.0
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/.gitignore +2 -0
- data/README.md +40 -0
- data/Rakefile +10 -0
- data/bundler-push-host-key.gemspec +11 -0
- data/lib/bundler/gem_helper/push_host_key.rb +4 -0
- data/lib/bundler/gem_tasks/push_host_key.rb +4 -0
- data/lib/bundler_push_host_key.rb +10 -0
- data/test/bin/gem +5 -0
- data/test/gem/all-allowed.gemspec +10 -0
- data/test/gem/example-net-allowed.gemspec +14 -0
- data/test/test_push_host_key.rb +50 -0
- metadata +56 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: bbd344862c377182985d31e5318a7059d813d3b0d0a52ac0b34a2de10a422a02
|
4
|
+
data.tar.gz: cfcfd8ca9c9083de7bd366c1e601eb8e3ac1e0b3253000956f35210c75f3abe3
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 8b2aacc143a0c023b8268ce6841eb7ab0ecab338659f678bbac35e0aae5fcbd8b0d2bb3029139ec4080c873f3be79dd5788a997cee2a9f9474db481a978e3f9e
|
7
|
+
data.tar.gz: cedd1cb486de90be3b47a3a4ecdcecd3c91bcd4f982ad8592d3ab95a2c862346201b1937c6887d0f1043293d6b8b895de37525887d9307e36edbc5056b8fd80a
|
data/.gitignore
ADDED
data/README.md
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
# bundle-push-host-key
|
2
|
+
|
3
|
+
This gem adds support for multiple keys when pushing gems using the bundler rake tasks
|
4
|
+
|
5
|
+
## Usage
|
6
|
+
|
7
|
+
* In the Rakefile, replace `require 'bundler/gem_tasks'` with `require 'bundler/gem_tasks/push_host_key'`
|
8
|
+
* In `.gem/credentials add a new credential with your gemserver's hostname (only the hostname!) as key`:
|
9
|
+
|
10
|
+
---
|
11
|
+
# Official rubygems API key entry
|
12
|
+
:rubygems_api_key: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
13
|
+
|
14
|
+
# Your custom API key for gemserver.example.net
|
15
|
+
:gemserver.example.net: <API Key>
|
16
|
+
|
17
|
+
# Basic Authentication instead of API key
|
18
|
+
:gemserver.example.net: "Basic dXNlcjpwYXNzCg=="
|
19
|
+
|
20
|
+
* In your gemspecs, set the `allowed_push_host`:
|
21
|
+
|
22
|
+
Gem::Specification.new do |gem|
|
23
|
+
# ...
|
24
|
+
gem.metadata = {
|
25
|
+
'allowed_push_host' => 'https://gemserver.example.com',
|
26
|
+
}
|
27
|
+
# ...
|
28
|
+
end
|
29
|
+
|
30
|
+
## Notes
|
31
|
+
|
32
|
+
This gem uses the `--key` feature of the `gem` command.
|
33
|
+
When pushing with the `gem` command directly, you can specify `--key gemserver.example.net`
|
34
|
+
|
35
|
+
Afaik, the `gem` command has no official way to authenticate when loading gems.
|
36
|
+
In Bundler you can set the basic auth credentials with this command: `bundle config gemserver.example.net user:pass`
|
37
|
+
|
38
|
+
If there is a better, official way to have multiple private gemserver with individual credentials
|
39
|
+
and not only push-authentication, I will happily drop this gem.
|
40
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
Gem::Specification.new do |s|
|
2
|
+
s.name = 'bundler-push-host-key'
|
3
|
+
s.authors = ['Christian Haase']
|
4
|
+
|
5
|
+
s.version = '1.0.0'
|
6
|
+
s.date = '2020-07-03'
|
7
|
+
s.summary = 'Use the correct api key when pushing gems'
|
8
|
+
s.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR)
|
9
|
+
s.test_files = s.files.grep(%r{^(test|spec|features)/})
|
10
|
+
s.require_paths = ['lib']
|
11
|
+
end
|
data/test/bin/gem
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
Gem::Specification.new do |s|
|
2
|
+
s.name = 'gem'
|
3
|
+
s.authors = ['Somebody else']
|
4
|
+
|
5
|
+
s.metadata = {
|
6
|
+
'allowed_push_host' => 'http://example.net',
|
7
|
+
}
|
8
|
+
|
9
|
+
s.version = '1.0.0'
|
10
|
+
s.date = '2020-07-03'
|
11
|
+
s.summary = 'A Gem'
|
12
|
+
s.files = []
|
13
|
+
s.require_paths = []
|
14
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
$LOAD_PATH << File.join(__dir__, '..', 'lib')
|
2
|
+
require 'minitest/autorun'
|
3
|
+
require 'rake'
|
4
|
+
require 'tempfile'
|
5
|
+
require 'bundler/gem_helper'
|
6
|
+
require 'bundler/gem_helper/push_host_key'
|
7
|
+
|
8
|
+
|
9
|
+
class TestPushHostKey < Minitest::Test
|
10
|
+
def setup
|
11
|
+
@orig_path = ENV['PATH']
|
12
|
+
ENV['PATH'] = File.join(__dir__, 'bin')
|
13
|
+
|
14
|
+
Tempfile.new.tap { |t| @gem_commandline_path = t.path }.close
|
15
|
+
ENV['GEM_COMMANDLINE'] = @gem_commandline_path
|
16
|
+
end
|
17
|
+
|
18
|
+
def teardown
|
19
|
+
Rake.application = nil
|
20
|
+
Bundler::GemHelper.instance = nil
|
21
|
+
ENV['PATH'] = @orig_path
|
22
|
+
ENV['GEM_COMMANDLINE'] = nil
|
23
|
+
File.unlink(@gem_commandline_path)
|
24
|
+
end
|
25
|
+
|
26
|
+
def gem_commandline
|
27
|
+
File.read(@gem_commandline_path).strip
|
28
|
+
end
|
29
|
+
|
30
|
+
def push_testgem(name)
|
31
|
+
Bundler::GemHelper.install_tasks(dir: File.join(__dir__, 'gem'), name: name)
|
32
|
+
Bundler.ui = nil
|
33
|
+
|
34
|
+
Rake::Task['release:rubygem_push'].reenable
|
35
|
+
Rake::Task['release:rubygem_push'].execute
|
36
|
+
end
|
37
|
+
|
38
|
+
def test_push_to_custom_host
|
39
|
+
push_testgem('example-net-allowed')
|
40
|
+
assert_includes(gem_commandline, '--key example.net')
|
41
|
+
assert_includes(gem_commandline, '--host http://example.net')
|
42
|
+
end
|
43
|
+
|
44
|
+
def test_push_to_rubygems
|
45
|
+
push_testgem('all-allowed')
|
46
|
+
|
47
|
+
refute_includes(gem_commandline, '--host')
|
48
|
+
refute_includes(gem_commandline, '--key')
|
49
|
+
end
|
50
|
+
end
|
metadata
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: bundler-push-host-key
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Christian Haase
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2020-07-03 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description:
|
14
|
+
email:
|
15
|
+
executables: []
|
16
|
+
extensions: []
|
17
|
+
extra_rdoc_files: []
|
18
|
+
files:
|
19
|
+
- ".gitignore"
|
20
|
+
- README.md
|
21
|
+
- Rakefile
|
22
|
+
- bundler-push-host-key.gemspec
|
23
|
+
- lib/bundler/gem_helper/push_host_key.rb
|
24
|
+
- lib/bundler/gem_tasks/push_host_key.rb
|
25
|
+
- lib/bundler_push_host_key.rb
|
26
|
+
- test/bin/gem
|
27
|
+
- test/gem/all-allowed.gemspec
|
28
|
+
- test/gem/example-net-allowed.gemspec
|
29
|
+
- test/test_push_host_key.rb
|
30
|
+
homepage:
|
31
|
+
licenses: []
|
32
|
+
metadata: {}
|
33
|
+
post_install_message:
|
34
|
+
rdoc_options: []
|
35
|
+
require_paths:
|
36
|
+
- lib
|
37
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - ">="
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: '0'
|
42
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
43
|
+
requirements:
|
44
|
+
- - ">="
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '0'
|
47
|
+
requirements: []
|
48
|
+
rubygems_version: 3.0.8
|
49
|
+
signing_key:
|
50
|
+
specification_version: 4
|
51
|
+
summary: Use the correct api key when pushing gems
|
52
|
+
test_files:
|
53
|
+
- test/bin/gem
|
54
|
+
- test/gem/all-allowed.gemspec
|
55
|
+
- test/gem/example-net-allowed.gemspec
|
56
|
+
- test/test_push_host_key.rb
|