dpl 1.7.21.travis.958.4 → 1.7.21.travis.959.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/lib/dpl/provider/npm.rb +13 -1
- data/spec/provider/npm_spec.rb +18 -2
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
YjhmZWQ2ODY1NjlkNTc3YjRhZWExNDczY2Q5ZjJlYjM0ZDJlMDU4Yg==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
Y2UyMTU2ZGM5ZmEzMjg5OGY2Y2FkNTJjMjhhYjFiMjIxN2ExMTczNw==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
YTE5ZmViNzA2MmJkN2RlYTJhZjMzNTRiMTU4MzNmZTZiZjUyNzE4OGU5OWQ2
|
10
|
+
NTE0NDVjZGVjZjg0Y2E1OWQwZTQ2NmM2MjUyZmQ5MTk3ZTFjZDNiOGNlMzA3
|
11
|
+
Y2RhOGM1OGJiYWY0NjEzYjYzNGIyOGZkODg0Y2Y0NmEwNTIwOTE=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
OTFiMGY3MmU2NWVlMDU4Njk1NDc3NDEwMmJjYzFlZjhmNmY1ODVmMzIzZjJh
|
14
|
+
Nzg4MGQ5ZGZjMGVlODc1MjE0MTBjNDIwYzAyMmFmMDgzY2NiN2VkNTNlOWEx
|
15
|
+
NGNjZDg4MmI2OGY0MjY2M2EyZDI2YzZjYzg2MmM3MTQ3ZWY0Y2E=
|
data/lib/dpl/provider/npm.rb
CHANGED
@@ -15,7 +15,7 @@ module DPL
|
|
15
15
|
|
16
16
|
def setup_auth
|
17
17
|
file = File.open(File.expand_path(NPMRC_FILE), 'w')
|
18
|
-
file.puts(
|
18
|
+
file.puts(npmrc_file_content)
|
19
19
|
file.flush
|
20
20
|
end
|
21
21
|
|
@@ -41,6 +41,18 @@ module DPL
|
|
41
41
|
|
42
42
|
DEFAULT_NPM_REGISTRY
|
43
43
|
end
|
44
|
+
|
45
|
+
def npmrc_file_content
|
46
|
+
if npm_version =~ /^1/
|
47
|
+
"_auth = ${NPM_API_KEY}\nemail = #{option(:email)}\nregistry = #{package_registry}"
|
48
|
+
else
|
49
|
+
"//#{package_registry}/:_authToken=${NPM_API_KEY}"
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
def npm_version
|
54
|
+
`npm --version`
|
55
|
+
end
|
44
56
|
end
|
45
57
|
end
|
46
58
|
end
|
data/spec/provider/npm_spec.rb
CHANGED
@@ -2,6 +2,10 @@ require 'spec_helper'
|
|
2
2
|
require 'dpl/provider/npm'
|
3
3
|
|
4
4
|
describe DPL::Provider::NPM do
|
5
|
+
before :each do
|
6
|
+
allow(subject).to receive(:npm_version).and_return('2.11.3')
|
7
|
+
end
|
8
|
+
|
5
9
|
subject :provider do
|
6
10
|
described_class.new(DummyContext.new, :email => 'foo@blah.com', :api_key => 'test')
|
7
11
|
end
|
@@ -28,6 +32,18 @@ describe DPL::Provider::NPM do
|
|
28
32
|
end
|
29
33
|
end
|
30
34
|
|
35
|
+
context 'when NPM is version 1.x' do
|
36
|
+
before :each do
|
37
|
+
allow(subject).to receive(:npm_version).and_return('1.4.28')
|
38
|
+
end
|
39
|
+
|
40
|
+
describe "#setup_auth" do
|
41
|
+
example do
|
42
|
+
test_setup_auth(DPL::Provider::NPM::DEFAULT_NPM_REGISTRY, "_auth = ${NPM_API_KEY}\nemail = foo@blah.com\nregistry = #{DPL::Provider::NPM::DEFAULT_NPM_REGISTRY}")
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
31
47
|
context 'when package.json exists' do
|
32
48
|
let(:custom_rpm_registry) { 'npm.example.com' }
|
33
49
|
before :each do
|
@@ -56,10 +72,10 @@ describe DPL::Provider::NPM do
|
|
56
72
|
end
|
57
73
|
end
|
58
74
|
|
59
|
-
def test_setup_auth(registry=DPL::Provider::NPM::DEFAULT_NPM_REGISTRY)
|
75
|
+
def test_setup_auth(registry = DPL::Provider::NPM::DEFAULT_NPM_REGISTRY, content = "//#{registry}/:_authToken=${NPM_API_KEY}")
|
60
76
|
f = double(:npmrc)
|
61
77
|
expect(File).to receive(:open).with(File.expand_path(DPL::Provider::NPM::NPMRC_FILE), 'w').and_return(f)
|
62
|
-
expect(f).to receive(:puts).with(
|
78
|
+
expect(f).to receive(:puts).with(content)
|
63
79
|
allow(f).to receive(:flush)
|
64
80
|
provider.setup_auth
|
65
81
|
end
|