dpl 2.0.3.beta.4 → 2.0.3.beta.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (85) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +15 -3
  3. data/Gemfile.lock +444 -211
  4. data/Rakefile +36 -34
  5. data/bin/dpl +3 -1
  6. data/dpl.gemspec +25 -0
  7. data/lib/dpl/cli.rb +19 -14
  8. data/lib/dpl/ctx/bash.rb +18 -12
  9. data/lib/dpl/ctx/test.rb +21 -15
  10. data/lib/dpl/ctx.rb +2 -0
  11. data/lib/dpl/helper/assets.rb +4 -2
  12. data/lib/dpl/helper/cmd.rb +20 -18
  13. data/lib/dpl/helper/config_file.rb +5 -3
  14. data/lib/dpl/helper/cookbook_site_streaming_uploader.rb +249 -0
  15. data/lib/dpl/helper/env.rb +26 -22
  16. data/lib/dpl/helper/github.rb +2 -0
  17. data/lib/dpl/helper/interpolate.rb +8 -4
  18. data/lib/dpl/helper/memoize.rb +4 -1
  19. data/lib/dpl/helper/squiggle.rb +3 -1
  20. data/lib/dpl/helper/transliterate.rb +3 -1
  21. data/lib/dpl/helper/wrap.rb +3 -1
  22. data/lib/dpl/helper/zip.rb +3 -1
  23. data/lib/dpl/provider/dsl.rb +18 -4
  24. data/lib/dpl/provider/examples.rb +6 -2
  25. data/lib/dpl/provider/status.rb +26 -24
  26. data/lib/dpl/providers/anynines.rb +22 -20
  27. data/lib/dpl/providers/azure_web_apps.rb +21 -19
  28. data/lib/dpl/providers/bintray.rb +44 -37
  29. data/lib/dpl/providers/bluemixcloudfoundry.rb +38 -36
  30. data/lib/dpl/providers/boxfuse.rb +12 -10
  31. data/lib/dpl/providers/cargo.rb +7 -5
  32. data/lib/dpl/providers/chef_supermarket.rb +82 -80
  33. data/lib/dpl/providers/cloud66.rb +17 -15
  34. data/lib/dpl/providers/cloudfiles.rb +8 -6
  35. data/lib/dpl/providers/cloudformation.rb +191 -187
  36. data/lib/dpl/providers/cloudfoundry.rb +32 -30
  37. data/lib/dpl/providers/codedeploy.rb +35 -33
  38. data/lib/dpl/providers/convox.rb +32 -25
  39. data/lib/dpl/providers/datica.rb +30 -28
  40. data/lib/dpl/providers/ecr.rb +66 -64
  41. data/lib/dpl/providers/elasticbeanstalk.rb +14 -12
  42. data/lib/dpl/providers/engineyard.rb +60 -58
  43. data/lib/dpl/providers/firebase.rb +6 -4
  44. data/lib/dpl/providers/flynn.rb +8 -6
  45. data/lib/dpl/providers/gae.rb +28 -25
  46. data/lib/dpl/providers/gcs.rb +59 -57
  47. data/lib/dpl/providers/git_push.rb +199 -195
  48. data/lib/dpl/providers/gleis.rb +19 -17
  49. data/lib/dpl/providers/hackage.rb +15 -13
  50. data/lib/dpl/providers/hephy.rb +18 -16
  51. data/lib/dpl/providers/heroku/api.rb +72 -70
  52. data/lib/dpl/providers/heroku/git.rb +15 -13
  53. data/lib/dpl/providers/heroku.rb +40 -38
  54. data/lib/dpl/providers/lambda.rb +134 -134
  55. data/lib/dpl/providers/launchpad.rb +45 -43
  56. data/lib/dpl/providers/netlify.rb +7 -5
  57. data/lib/dpl/providers/npm.rb +61 -58
  58. data/lib/dpl/providers/nuget.rb +8 -6
  59. data/lib/dpl/providers/openshift.rb +8 -6
  60. data/lib/dpl/providers/opsworks.rb +23 -21
  61. data/lib/dpl/providers/pages/api.rb +14 -14
  62. data/lib/dpl/providers/pages/git.rb +53 -47
  63. data/lib/dpl/providers/pages.rb +3 -1
  64. data/lib/dpl/providers/puppetforge.rb +6 -4
  65. data/lib/dpl/providers/pypi.rb +55 -54
  66. data/lib/dpl/providers/releases.rb +30 -23
  67. data/lib/dpl/providers/rubygems.rb +35 -31
  68. data/lib/dpl/providers/s3.rb +148 -142
  69. data/lib/dpl/providers/scalingo.rb +18 -16
  70. data/lib/dpl/providers/script.rb +4 -2
  71. data/lib/dpl/providers/snap.rb +12 -9
  72. data/lib/dpl/providers/surge.rb +7 -5
  73. data/lib/dpl/providers/testfairy.rb +47 -43
  74. data/lib/dpl/providers/transifex.rb +20 -18
  75. data/lib/dpl/providers.rb +3 -1
  76. data/lib/dpl/string_ext.rb +3 -1
  77. data/lib/dpl/support/aws_sdk_patch.rb +4 -1
  78. data/lib/dpl/support/gems.rb +7 -3
  79. data/lib/dpl/support/gstore_patch.rb +3 -1
  80. data/lib/dpl/support/version.rb +13 -12
  81. data/lib/dpl/version.rb +3 -1
  82. data/lib/dpl.rb +2 -0
  83. data/status.json +237 -0
  84. metadata +32 -15
  85. /data/lib/dpl/providers/{packagecloud.rb → packagecloud.rb_} +0 -0
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'dpl/helper/zip'
2
4
 
3
5
  module Dpl
@@ -9,13 +11,13 @@ module Dpl
9
11
 
10
12
  full_name 'AWS Lambda'
11
13
 
12
- description sq(<<-str)
14
+ description sq(<<-STR)
13
15
  tbd
14
- str
16
+ STR
15
17
 
16
- gem 'aws-sdk-lambda', '~> 1.84.0'
17
- gem 'nokogiri', '< 1.10'
18
- gem 'rubyzip', '~> 1.2.2', require: 'zip'
18
+ gem 'aws-sdk-lambda', '~> 1.104.0'
19
+ gem 'nokogiri', '~> 1.15'
20
+ gem 'rubyzip', '~> 2.3', require: 'zip'
19
21
 
20
22
  env :aws, :lambda
21
23
  config '~/.aws/credentials', '~/.aws/config', prefix: 'aws'
@@ -32,23 +34,23 @@ module Dpl
32
34
  opt '--memory_size MB', 'Amount of memory in MB to allocate to this Lambda', default: 128
33
35
  opt '--subnet_ids IDS', 'List of subnet IDs to be added to the function', type: :array, note: 'Needs the ec2:DescribeSubnets and ec2:DescribeVpcs permission for the user of the access/secret key to work'
34
36
  opt '--security_group_ids IDS', 'List of security group IDs to be added to the function', type: :array, note: 'Needs the ec2:DescribeSecurityGroups and ec2:DescribeVpcs permission for the user of the access/secret key to work'
35
- opt '--environment VARS', 'List of Environment Variables to add to the function', type: :array, format: /[\w\-]+=.+/, note: 'Can be encrypted for added security', alias: :environment_variables
36
- opt '--runtime NAME', 'Lambda runtime to use', note: 'required when creating a new function', default: 'nodejs12.x', enum: %w(nodejs16.x nodejs14.x nodejs12.x python3.8 python3.7 python3.6 python2.7 ruby2.7 ruby2.5 java11 java8 go1.x dotnetcore2.1)
37
+ opt '--environment VARS', 'List of Environment Variables to add to the function', type: :array, format: /[\w-]+=.+/, note: 'Can be encrypted for added security', alias: :environment_variables
38
+ opt '--runtime NAME', 'Lambda runtime to use', note: 'required when creating a new function', default: 'nodejs12.x', enum: %w[nodejs16.x nodejs14.x nodejs12.x python3.8 python3.7 python3.6 python2.7 ruby2.7 ruby2.5 java11 java8 go1.x dotnetcore2.1]
37
39
  opt '--dead_letter_arn ARN', 'ARN to an SNS or SQS resource used for the dead letter queue.'
38
40
  opt '--kms_key_arn ARN', 'KMS key ARN to use to encrypt environment_variables.'
39
- opt '--tracing_mode MODE', 'Tracing mode', default: 'PassThrough', enum: %w(Active PassThrough), note: 'Needs xray:PutTraceSegments xray:PutTelemetryRecords on the role'
41
+ opt '--tracing_mode MODE', 'Tracing mode', default: 'PassThrough', enum: %w[Active PassThrough], note: 'Needs xray:PutTraceSegments xray:PutTelemetryRecords on the role'
40
42
  opt '--layers LAYERS', 'Function layer arns', type: :array
41
- opt '--function_tags TAGS', 'List of tags to add to the function', type: :array, format: /[\w\-]+=.+/, note: 'Can be encrypted for added security'
43
+ opt '--function_tags TAGS', 'List of tags to add to the function', type: :array, format: /[\w-]+=.+/, note: 'Can be encrypted for added security'
42
44
  opt '--publish', 'Create a new version of the code instead of replacing the existing one.'
43
45
  opt '--zip PATH', 'Path to a packaged Lambda, a directory to package, or a single file to package', default: '.'
44
46
  opt '--dot_match', 'Include hidden .* files to the zipped archive'
45
47
 
46
- msgs login: 'Using Access Key: %{access_key_id}',
48
+ msgs login: 'Using Access Key: %{access_key_id}',
47
49
  create_function: 'Creating function %{function_name}.',
48
- update_config: 'Updating existing function %{function_name}.',
49
- update_tags: 'Updating tags.',
50
- update_code: 'Updating code.',
51
- description: 'Deploy build %{build_number} to AWS Lambda via Travis CI'
50
+ update_config: 'Updating existing function %{function_name}.',
51
+ update_tags: 'Updating tags.',
52
+ update_code: 'Updating code.',
53
+ description: 'Deploy build %{build_number} to AWS Lambda via Travis CI'
52
54
 
53
55
  def login
54
56
  info :login
@@ -62,150 +64,148 @@ module Dpl
62
64
 
63
65
  private
64
66
 
65
- def exists?
66
- !!client.get_function(function_name: function_name)
67
- rescue ::Aws::Lambda::Errors::ResourceNotFoundException
68
- false
69
- end
67
+ def exists?
68
+ !!client.get_function(function_name:)
69
+ rescue ::Aws::Lambda::Errors::ResourceNotFoundException
70
+ false
71
+ end
70
72
 
71
- def create
72
- info :create_function
73
- config = function_config
74
- config = config.merge(code: { zip_file: function_zip })
75
- config = config.merge(tags: function_tags) if function_tags?
76
- client.create_function(config)
77
- end
73
+ def create
74
+ info :create_function
75
+ config = function_config
76
+ config = config.merge(code: { zip_file: function_zip })
77
+ config = config.merge(tags: function_tags) if function_tags?
78
+ client.create_function(config)
79
+ end
78
80
 
79
- def update
80
- begin
81
- arn = update_config
82
- client.wait_until(:function_updated, { function_name: function_name })
83
- update_tags(arn) if function_tags?
84
- client.wait_until(:function_updated, { function_name: function_name })
85
- update_code
86
- rescue Aws::Waiters::Errors::WaiterFailed
87
- error 'Update timed out.'
88
- end
89
- end
81
+ def update
82
+ arn = update_config
83
+ client.wait_until(:function_updated, { function_name: })
84
+ update_tags(arn) if function_tags?
85
+ client.wait_until(:function_updated, { function_name: })
86
+ update_code
87
+ rescue Aws::Waiters::Errors::WaiterFailed
88
+ error 'Update timed out.'
89
+ end
90
90
 
91
- def update_config
92
- info :update_config
93
- response = client.update_function_configuration(function_config)
94
- response.function_arn
95
- end
91
+ def update_config
92
+ info :update_config
93
+ response = client.update_function_configuration(function_config)
94
+ response.function_arn
95
+ end
96
96
 
97
- def update_tags(arn)
98
- info :update_tags
99
- client.tag_resource(tag_resource(arn))
100
- end
97
+ def update_tags(arn)
98
+ info :update_tags
99
+ client.tag_resource(tag_resource(arn))
100
+ end
101
101
 
102
- def update_code
103
- info :update_code
104
- client.update_function_code(function_code)
105
- end
102
+ def update_code
103
+ info :update_code
104
+ client.update_function_code(function_code)
105
+ end
106
106
 
107
- def function_config
108
- compact(
109
- function_name: function_name,
110
- role: role,
111
- handler: handler,
112
- description: description,
113
- timeout: timeout,
114
- memory_size: memory_size,
115
- vpc_config: vpc_config,
116
- environment: environment,
117
- runtime: runtime,
118
- dead_letter_config: dead_letter_arn,
119
- kms_key_arn: kms_key_arn,
120
- tracing_config: tracing_config,
121
- layers: layers
122
- )
123
- end
107
+ def function_config
108
+ compact(
109
+ function_name:,
110
+ role:,
111
+ handler:,
112
+ description:,
113
+ timeout:,
114
+ memory_size:,
115
+ vpc_config:,
116
+ environment:,
117
+ runtime:,
118
+ dead_letter_config: dead_letter_arn,
119
+ kms_key_arn:,
120
+ tracing_config:,
121
+ layers:
122
+ )
123
+ end
124
124
 
125
- def tag_resource(arn)
126
- {
127
- resource: arn,
128
- tags: function_tags
129
- }
130
- end
125
+ def tag_resource(arn)
126
+ {
127
+ resource: arn,
128
+ tags: function_tags
129
+ }
130
+ end
131
131
 
132
- def function_code
133
- {
134
- function_name: function_name,
135
- zip_file: function_zip,
136
- publish: publish?
137
- }
138
- end
132
+ def function_code
133
+ {
134
+ function_name:,
135
+ zip_file: function_zip,
136
+ publish: publish?
137
+ }
138
+ end
139
139
 
140
- def handler
141
- Handler.new(runtime, module_name, handler_name).to_s if handler_name?
142
- end
140
+ def handler
141
+ Handler.new(runtime, module_name, handler_name).to_s if handler_name?
142
+ end
143
143
 
144
- def function_zip
145
- Zip.new(zip, tmp_filename, opts).zip
146
- end
144
+ def function_zip
145
+ Zip.new(zip, tmp_filename, opts).zip
146
+ end
147
147
 
148
- def vpc_config
149
- compact(subnet_ids: subnet_ids, security_group_ids: security_group_ids)
150
- end
148
+ def vpc_config
149
+ compact(subnet_ids:, security_group_ids:)
150
+ end
151
151
 
152
- def environment
153
- { variables: split_vars(super) } if environment?
154
- end
152
+ def environment
153
+ { variables: split_vars(super) } if environment?
154
+ end
155
155
 
156
- def dead_letter_arn
157
- { target_arn: super } if dead_letter_arn?
158
- end
156
+ def dead_letter_arn
157
+ { target_arn: super } if dead_letter_arn?
158
+ end
159
159
 
160
- def tracing_config
161
- { mode: tracing_mode } if tracing_mode?
162
- end
160
+ def tracing_config
161
+ { mode: tracing_mode } if tracing_mode?
162
+ end
163
163
 
164
- def function_tags
165
- split_vars(super) if function_tags?
166
- end
164
+ def function_tags
165
+ split_vars(super) if function_tags?
166
+ end
167
167
 
168
- def description
169
- interpolate(super || msg(:description), vars: vars)
170
- end
168
+ def description
169
+ interpolate(super || msg(:description), vars:)
170
+ end
171
171
 
172
- def client
173
- @client ||= Aws::Lambda::Client.new(region: region, credentials: credentials)
174
- end
172
+ def client
173
+ @client ||= Aws::Lambda::Client.new(region:, credentials:)
174
+ end
175
175
 
176
- def credentials
177
- Aws::Credentials.new(access_key_id, secret_access_key)
178
- end
176
+ def credentials
177
+ Aws::Credentials.new(access_key_id, secret_access_key)
178
+ end
179
179
 
180
- def split_vars(vars)
181
- vars.map { |var| var.split('=', 2) }.to_h
180
+ def split_vars(vars)
181
+ vars.map { |var| var.split('=', 2) }.to_h
182
+ end
183
+
184
+ def tmp_filename
185
+ @tmp_filename ||= "#{tmp_dir}/#{repo_name}.zip"
186
+ end
187
+
188
+ class Handler < Struct.new(:runtime, :module_name, :handler_name)
189
+ SEP = {
190
+ default: '.',
191
+ java: '::',
192
+ dotnet: '::',
193
+ go: ''
194
+ }.freeze
195
+
196
+ def to_s
197
+ [go? ? nil : module_name, sep, handler_name].compact.join
182
198
  end
183
199
 
184
- def tmp_filename
185
- @tmp_filename ||= "#{tmp_dir}/#{repo_name}.zip"
200
+ def sep
201
+ key = SEP.keys.detect { |key| runtime.start_with?(key.to_s) }
202
+ SEP[key || :default]
186
203
  end
187
204
 
188
- class Handler < Struct.new(:runtime, :module_name, :handler_name)
189
- SEP = {
190
- default: '.',
191
- java: '::',
192
- dotnet: '::',
193
- go: ''
194
- }
195
-
196
- def to_s
197
- [go? ? nil : module_name, sep, handler_name].compact.join
198
- end
199
-
200
- def sep
201
- key = SEP.keys.detect { |key| runtime.start_with?(key.to_s) }
202
- SEP[key || :default]
203
- end
204
-
205
- def go?
206
- runtime.start_with?('go')
207
- end
205
+ def go?
206
+ runtime.start_with?('go')
208
207
  end
208
+ end
209
209
  end
210
210
  end
211
211
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Dpl
2
4
  module Providers
3
5
  class Launchpad < Provider
@@ -5,18 +7,18 @@ module Dpl
5
7
 
6
8
  status :alpha
7
9
 
8
- description sq(<<-str)
10
+ description sq(<<-STR)
9
11
  tbd
10
- str
12
+ STR
11
13
 
12
14
  env :launchpad
13
15
 
14
16
  opt '--oauth_token TOKEN', 'Launchpad OAuth token', secret: true
15
17
  opt '--oauth_token_secret SECRET', 'Launchpad OAuth token secret', secret: true
16
- opt '--slug SLUG', 'Launchpad project slug', format: /^~[^\/]+\/[^\/]+\/[^\/]+$/, example: '~user-name/project-name/branch-name'
18
+ opt '--slug SLUG', 'Launchpad project slug', format: %r{^~[^/]+/[^/]+/[^/]+$}, example: '~user-name/project-name/branch-name'
17
19
 
18
20
  msgs invalid_credentials: 'Invalid credentials (%s)',
19
- unknown_error: 'Error: %s (%s)'
21
+ unknown_error: 'Error: %s (%s)'
20
22
 
21
23
  def deploy
22
24
  handle_response(post)
@@ -24,34 +26,34 @@ module Dpl
24
26
 
25
27
  private
26
28
 
27
- def post
28
- req = Net::HTTP::Post.new(path)
29
- req['Authorization'] = authorization
30
- req.set_form_data(data)
31
- http.request(req)
32
- end
33
-
34
- def handle_response(res)
35
- error :invalid_credentials, res.code if res.code == '401'
36
- error :unknown_error, res.body, res.code unless res.kind_of?(Net::HTTPSuccess)
37
- end
38
-
39
- def http
40
- http = Net::HTTP.new('api.launchpad.net', 443)
41
- http.use_ssl = true
42
- http
43
- end
44
-
45
- def path
46
- "/1.0/#{slug}/+code-import"
47
- end
48
-
49
- def data
50
- { 'ws.op' => 'requestImport' }
51
- end
52
-
53
- def authorization
54
- squish(<<-auth)
29
+ def post
30
+ req = Net::HTTP::Post.new(path)
31
+ req['Authorization'] = authorization
32
+ req.set_form_data(data)
33
+ http.request(req)
34
+ end
35
+
36
+ def handle_response(res)
37
+ error :invalid_credentials, res.code if res.code == '401'
38
+ error :unknown_error, res.body, res.code unless res.is_a?(Net::HTTPSuccess)
39
+ end
40
+
41
+ def http
42
+ http = Net::HTTP.new('api.launchpad.net', 443)
43
+ http.use_ssl = true
44
+ http
45
+ end
46
+
47
+ def path
48
+ "/1.0/#{slug}/+code-import"
49
+ end
50
+
51
+ def data
52
+ { 'ws.op' => 'requestImport' }
53
+ end
54
+
55
+ def authorization
56
+ squish(<<-AUTH)
55
57
  OAuth oauth_consumer_key="Travis%20Deploy",
56
58
  oauth_nonce="#{nonce}",
57
59
  oauth_signature="%26#{oauth_token_secret}",
@@ -59,20 +61,20 @@ module Dpl
59
61
  oauth_timestamp="#{now}",
60
62
  oauth_token="#{oauth_token}",
61
63
  oauth_version="1.0"
62
- auth
63
- end
64
+ AUTH
65
+ end
64
66
 
65
- def nonce
66
- rand(36 ** 32).to_s(36)
67
- end
67
+ def nonce
68
+ rand(36**32).to_s(36)
69
+ end
68
70
 
69
- def now
70
- Time::now().to_i
71
- end
71
+ def now
72
+ Time.now.to_i
73
+ end
72
74
 
73
- def squish(str)
74
- str.strip.gsub(/\s+/, ' ')
75
- end
75
+ def squish(str)
76
+ str.strip.gsub(/\s+/, ' ')
77
+ end
76
78
  end
77
79
  end
78
80
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Dpl
2
4
  module Providers
3
5
  class Netlify < Provider
@@ -5,9 +7,9 @@ module Dpl
5
7
 
6
8
  status :stable
7
9
 
8
- description sq(<<-str)
10
+ description sq(<<-STR)
9
11
  tbd
10
- str
12
+ STR
11
13
 
12
14
  node_js '>= 12.0.0'
13
15
 
@@ -28,9 +30,9 @@ module Dpl
28
30
 
29
31
  private
30
32
 
31
- def deploy_opts
32
- opts_for(%i(site auth dir functions message prod))
33
- end
33
+ def deploy_opts
34
+ opts_for(%i[site auth dir functions message prod])
35
+ end
34
36
  end
35
37
  end
36
38
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Dpl
2
4
  module Providers
3
5
  class Npm < Provider
@@ -7,9 +9,9 @@ module Dpl
7
9
 
8
10
  full_name 'npm'
9
11
 
10
- description sq(<<-str)
12
+ description sq(<<-STR)
11
13
  tbd
12
- str
14
+ STR
13
15
 
14
16
  gem 'json'
15
17
 
@@ -17,27 +19,27 @@ module Dpl
17
19
 
18
20
  opt '--email EMAIL', 'npm account email'
19
21
  opt '--api_token TOKEN', 'npm api token', alias: :api_key, required: true, secret: true, note: 'can be retrieved from your local ~/.npmrc file', see: 'https://docs.npmjs.com/creating-and-viewing-authentication-tokens'
20
- opt '--access ACCESS', 'Access level', enum: %w(public private)
22
+ opt '--access ACCESS', 'Access level', enum: %w[public private]
21
23
  opt '--registry URL', 'npm registry url'
22
24
  opt '--src SRC', 'directory or tarball to publish', default: '.'
23
25
  opt '--tag TAGS', 'distribution tags to add'
24
26
  opt '--run_script SCRIPT', 'run the given script from package.json', type: :array, note: 'skips running npm publish'
25
27
  opt '--dry_run', 'performs test run without uploading to registry'
26
- opt '--auth_method METHOD', 'Authentication method', enum: %w(auth)
28
+ opt '--auth_method METHOD', 'Authentication method', enum: %w[auth]
27
29
 
28
30
  REGISTRY = 'https://registry.npmjs.org'
29
31
  NPMRC = '~/.npmrc'
30
32
 
31
- msgs version: 'npm version: %{npm_version}',
32
- login: 'Authenticated with API token %{api_token}'
33
+ msgs version: 'npm version: %{npm_version}',
34
+ login: 'Authenticated with API token %{api_token}'
33
35
 
34
36
  cmds registry: 'npm config set registry "%{registry}"',
35
- publish: 'npm publish %{src} %{publish_opts}',
36
- run: 'npm run %{script}'
37
+ publish: 'npm publish %{src} %{publish_opts}',
38
+ run: 'npm run %{script}'
37
39
 
38
40
  errs registry: 'Failed to set registry config',
39
- publish: 'Failed to publish',
40
- run: 'Failed to run script %{script}'
41
+ publish: 'Failed to publish',
42
+ run: 'Failed to run script %{script}'
41
43
 
42
44
  def login
43
45
  info :version
@@ -60,68 +62,69 @@ module Dpl
60
62
 
61
63
  private
62
64
 
63
- def run_scripts
64
- run_script.each do |script|
65
- shell :run, script: script
66
- end
65
+ def run_scripts
66
+ run_script.each do |script|
67
+ shell :run, script:
67
68
  end
69
+ end
68
70
 
69
- def publish_opts
70
- opts_for(%i(access tag dry_run), dashed: true)
71
- end
71
+ def publish_opts
72
+ opts_for(%i[access tag dry_run], dashed: true)
73
+ end
72
74
 
73
- def write_npmrc
74
- write_file(npmrc_path, npmrc)
75
- info "#{NPMRC} size: #{file_size(npmrc_path)}"
76
- end
75
+ def write_npmrc
76
+ write_file(npmrc_path, npmrc)
77
+ info "#{NPMRC} size: #{file_size(npmrc_path)}"
78
+ end
77
79
 
78
- def remove_npmrc
79
- rm_f npmrc_path
80
- end
80
+ def remove_npmrc
81
+ rm_f npmrc_path
82
+ end
81
83
 
82
- def npmrc_path
83
- expand(NPMRC)
84
- end
84
+ def npmrc_path
85
+ expand(NPMRC)
86
+ end
85
87
 
86
- def npmrc
87
- if npm_version =~ /^1/ || auth_method == 'auth'
88
- "_auth = #{api_token}\nemail = #{email}"
89
- else
90
- "//#{auth_endpoint}/:_authToken=#{api_token}"
91
- end
88
+ def npmrc
89
+ if npm_version =~ /^1/ || auth_method == 'auth'
90
+ "_auth = #{api_token}\nemail = #{email}"
91
+ else
92
+ "//#{auth_endpoint}/:_authToken=#{api_token}"
92
93
  end
94
+ end
93
95
 
94
- def auth_endpoint
95
- str = registry
96
- str = strip_path(str) if str.include?('npm.pkg.github.com')
97
- str = strip_protocol(str).sub(%r(/$), '')
98
- str
99
- end
96
+ def auth_endpoint
97
+ str = registry
98
+ str = strip_path(str) if str.include?('npm.pkg.github.com')
99
+ str = strip_protocol(str).sub(%r{/$}, '')
100
+ str
101
+ end
100
102
 
101
- def registry
102
- super || registry_from_package_json || REGISTRY
103
- end
103
+ def registry
104
+ super || registry_from_package_json || REGISTRY
105
+ end
104
106
 
105
- def registry_from_package_json
106
- return unless data = package_json
107
- data && data.fetch('publishConfig', {})['registry']
108
- end
107
+ def registry_from_package_json
108
+ return unless data = package_json
109
109
 
110
- def strip_path(url)
111
- url.sub(URI(url).path, '')
112
- end
110
+ data && data.fetch('publishConfig', {})['registry']
111
+ end
113
112
 
114
- def strip_protocol(url)
115
- url.sub("#{URI(url).scheme}://", '')
116
- end
113
+ def strip_path(url)
114
+ url.sub(URI(url).path, '')
115
+ end
117
116
 
118
- def host(url)
119
- URI(url).host
120
- end
117
+ def strip_protocol(url)
118
+ url.sub("#{URI(url).scheme}://", '')
119
+ end
121
120
 
122
- def package_json
123
- File.exists?('package.json') ? JSON.parse(File.read('package.json')) : {}
124
- end
121
+ def host(url)
122
+ URI(url).host
123
+ end
124
+
125
+ def package_json
126
+ File.exist?('package.json') ? JSON.parse(File.read('package.json')) : {}
127
+ end
125
128
  end
126
129
  end
127
130
  end