letsencrypt_heroku 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b52be9e0e2fe21b8964da504173ac1c2738df3d1
4
- data.tar.gz: 6f692ca48375a72b5144533a2b2bda01307e57e8
3
+ metadata.gz: 2cac0b25f72c3190be77975f3a93dec7041cc3a0
4
+ data.tar.gz: c02456232fa21321e1b6edda57f4ecd49e2e7973
5
5
  SHA512:
6
- metadata.gz: 8dc68e1b0c70986fd5e4b28abc6f6f759f7db358b035e6c4ee65a8574d678b6cbd5a00b29b1a93be244999d8530b206345cafd78a0a9a57e758aed10592643ca
7
- data.tar.gz: 9fda84ec7e8bece8a56de57a06d09e16987c7dc318c40f7c832159a224c599d27315389e6b5b8abb5914d01ddea8ef8b23464392ed5e1fddba846e7f82937b83
6
+ metadata.gz: 1dbeb5d5b31f62654d02085d2e62423ea4b0c04c56a10514ffa2e6518ef3cd09f3279231825fe3b2c0a4101efa7fb7ab48a25c3d5bad298b327a0d76cb588186
7
+ data.tar.gz: 07fe6c940ecb08a24937c8e34b18c720a16b28fe0151664a6832328b26db4580c47df48cace4a4c662d3f0fea5398a9820592e8013e57c74884aeeca7316f81b
@@ -14,14 +14,17 @@ Gem::Specification.new do |spec|
14
14
  spec.homepage = 'https://github.com/xijo/letsencrypt_heroku'
15
15
 
16
16
  spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
17
- spec.bindir = "bin"
18
- spec.require_paths = ["lib"]
17
+ spec.bindir = 'bin'
18
+ spec.require_paths = ['lib']
19
19
  spec.executables << 'letsencrypt_heroku'
20
20
 
21
- spec.add_dependency "rainbow"
22
- spec.add_dependency "acme-client"
21
+ spec.add_dependency 'rainbow'
22
+ spec.add_dependency 'acme-client'
23
+ spec.add_dependency 'tty-spinner'
24
+ # See https://github.com/schubergphilis/letsencrypt/issues/36
25
+ spec.add_dependency 'json-jwt', '1.5.2'
23
26
 
24
- spec.add_development_dependency "bundler", "~> 1.12"
25
- spec.add_development_dependency "rake", "~> 10.0"
26
- spec.add_development_dependency "rspec", "~> 3.0"
27
+ spec.add_development_dependency 'bundler', '~> 1.12'
28
+ spec.add_development_dependency 'rake', '~> 10.0'
29
+ spec.add_development_dependency 'rspec', '~> 3.0'
27
30
  end
@@ -1,4 +1,5 @@
1
1
  require 'rainbow'
2
+ require 'tty-spinner'
2
3
  require 'yaml'
3
4
  require 'acme-client'
4
5
  require 'openssl'
@@ -1,3 +1,5 @@
1
+ require 'open3'
2
+
1
3
  module LetsencryptHeroku
2
4
  class Setup
3
5
  class SetupError < StandardError ; end
@@ -33,9 +35,7 @@ module LetsencryptHeroku
33
35
  run_task "authorize #{domain}" do
34
36
  @challenge = @client.authorize(domain: domain).http01
35
37
 
36
- command = "heroku config:set LETSENCRYPT_RESPONSE=#{@challenge.file_content}"
37
- output = `#{command}`
38
- $?.success? or fail_task(output)
38
+ execute "heroku config:set LETSENCRYPT_RESPONSE=#{@challenge.file_content}"
39
39
 
40
40
  test_response(domain: domain, challenge: @challenge)
41
41
 
@@ -53,14 +53,11 @@ module LetsencryptHeroku
53
53
  File.write('privkey.pem', certificate.request.private_key.to_pem)
54
54
  File.write('fullchain.pem', certificate.fullchain_to_pem)
55
55
 
56
- command = "heroku _certs:update fullchain.pem privkey.pem --confirm #{config.herokuapp}"
57
- output = `#{command}`
58
- $?.success? or fail_task(output)
59
-
56
+ execute "heroku _certs:update fullchain.pem privkey.pem --confirm #{config.herokuapp}"
60
57
  FileUtils.rm %w(privkey.pem fullchain.pem)
61
58
  end
62
59
  rescue SetupError => e
63
- puts Rainbow(e.message).red
60
+ exit
64
61
  end
65
62
 
66
63
  def test_response(domain:, challenge:)
@@ -78,15 +75,27 @@ module LetsencryptHeroku
78
75
  fail_task('failed test response')
79
76
  end
80
77
 
78
+ def execute(command)
79
+ Open3.popen3(command) do |stdin, stdout, stderr, wait_thr|
80
+ wait_thr.value.success? or fail_task(stderr.read.force_encoding('utf-8').sub(' ▸ ', 'heroku: '))
81
+ end
82
+ end
83
+
81
84
  def run_task(name)
82
- @_current_task = name
83
- print Rainbow(" #{@_current_task}").yellow
85
+ @_spinner = TTY::Spinner.new(" :spinner #{name}",
86
+ format: :dots,
87
+ interval: 20,
88
+ frames: [ "⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏" ].map { |s| Rainbow(s).yellow.bright },
89
+ success_mark: Rainbow('✔').green,
90
+ error_mark: Rainbow('✘').red
91
+ )
92
+ @_spinner.start
84
93
  yield
85
- puts Rainbow("\r ✔ #{@_current_task}").green
94
+ @_spinner.success
86
95
  end
87
96
 
88
97
  def fail_task(reason = nil)
89
- puts Rainbow("\r ✘ #{@_current_task}").red
98
+ @_spinner.error("(#{reason.strip})")
90
99
  raise SetupError, reason
91
100
  end
92
101
  end
@@ -1,3 +1,3 @@
1
1
  module LetsencryptHeroku
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.3"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: letsencrypt_heroku
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Johannes Opper
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-07-16 00:00:00.000000000 Z
11
+ date: 2016-07-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rainbow
@@ -38,6 +38,34 @@ dependencies:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: tty-spinner
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: json-jwt
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '='
60
+ - !ruby/object:Gem::Version
61
+ version: 1.5.2
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '='
67
+ - !ruby/object:Gem::Version
68
+ version: 1.5.2
41
69
  - !ruby/object:Gem::Dependency
42
70
  name: bundler
43
71
  requirement: !ruby/object:Gem::Requirement