hanzo 0.4.2 → 0.4.3
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 +4 -4
- data/.rubocop.yml +58 -0
- data/.travis.yml +1 -0
- data/bin/hanzo +1 -2
- data/hanzo.gemspec +4 -2
- data/lib/hanzo/cli.rb +2 -2
- data/lib/hanzo/fetchers/environment.rb +27 -0
- data/lib/hanzo/heroku.rb +1 -3
- data/lib/hanzo/modules/config.rb +5 -5
- data/lib/hanzo/modules/deploy.rb +27 -16
- data/lib/hanzo/modules/install.rb +1 -1
- data/lib/hanzo/modules/installers/labs.rb +6 -6
- data/lib/hanzo/modules/installers/remotes.rb +5 -1
- data/lib/hanzo/version.rb +1 -1
- data/lib/hanzo.rb +9 -2
- data/spec/cli/config_spec.rb +22 -22
- data/spec/cli/deploy_spec.rb +47 -20
- data/spec/cli/install_spec.rb +17 -16
- data/spec/fetchers/environment_spec.rb +48 -0
- data/spec/spec_helper.rb +2 -2
- metadata +38 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5bf18b51a540cd3579bf82622bfd45fc4f034449
|
4
|
+
data.tar.gz: af91b4057463254d56c85702720fd50e7c99148c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 98700c6b8a43094637a57ba492730ba12894e213ec6cd59b30b1f6ee40d8823ad23a968147b9ecfb5e7687bad8c78cfb064a07332429b82e1d00140311f9a0d1
|
7
|
+
data.tar.gz: a0ddffdf1bac4fd26f7b6cb618f887a60ef25ef70238d492777448f4e1d8bfc3183e0b09e094c752b53cb51aec0c571573cd4b75f12b8b8f0f3594a22e63d615
|
data/.rubocop.yml
ADDED
@@ -0,0 +1,58 @@
|
|
1
|
+
Documentation:
|
2
|
+
Enabled: false
|
3
|
+
|
4
|
+
Encoding:
|
5
|
+
Enabled: false
|
6
|
+
|
7
|
+
LineLength:
|
8
|
+
Max: 200
|
9
|
+
|
10
|
+
ClassLength:
|
11
|
+
Max: 200
|
12
|
+
|
13
|
+
AccessModifierIndentation:
|
14
|
+
EnforcedStyle: outdent
|
15
|
+
|
16
|
+
IfUnlessModifier:
|
17
|
+
Enabled: false
|
18
|
+
|
19
|
+
CaseIndentation:
|
20
|
+
IndentWhenRelativeTo: case
|
21
|
+
IndentOneStep: true
|
22
|
+
|
23
|
+
MethodLength:
|
24
|
+
CountComments: false
|
25
|
+
Max: 20
|
26
|
+
|
27
|
+
SignalException:
|
28
|
+
Enabled: false
|
29
|
+
|
30
|
+
ColonMethodCall:
|
31
|
+
Enabled: false
|
32
|
+
|
33
|
+
AsciiComments:
|
34
|
+
Enabled: false
|
35
|
+
|
36
|
+
Lambda:
|
37
|
+
Enabled: false
|
38
|
+
|
39
|
+
RegexpLiteral:
|
40
|
+
Enabled: false
|
41
|
+
|
42
|
+
RedundantBegin:
|
43
|
+
Enabled: false
|
44
|
+
|
45
|
+
AssignmentInCondition:
|
46
|
+
Enabled: false
|
47
|
+
|
48
|
+
ParameterLists:
|
49
|
+
Enabled: false
|
50
|
+
|
51
|
+
ClassAndModuleChildren:
|
52
|
+
Enabled: false
|
53
|
+
|
54
|
+
DoubleNegation:
|
55
|
+
Enabled: false
|
56
|
+
|
57
|
+
TrivialAccessors:
|
58
|
+
ExactNameMatch: true
|
data/.travis.yml
CHANGED
data/bin/hanzo
CHANGED
data/hanzo.gemspec
CHANGED
@@ -14,14 +14,16 @@ Gem::Specification.new do |spec|
|
|
14
14
|
spec.homepage = 'https://github.com/mirego/hanzo'
|
15
15
|
spec.license = 'BSD 3-Clause'
|
16
16
|
|
17
|
-
spec.files = `git ls-files`.split(
|
17
|
+
spec.files = `git ls-files`.split("\n")
|
18
18
|
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
19
19
|
spec.test_files = spec.files.grep(%r{^(spec)/})
|
20
20
|
spec.require_paths = ['lib']
|
21
21
|
|
22
22
|
spec.add_development_dependency 'bundler', '~> 1.3'
|
23
|
+
spec.add_development_dependency 'phare', '~> 0.6'
|
24
|
+
spec.add_development_dependency 'rubocop', '~> 0.24'
|
23
25
|
spec.add_development_dependency 'rake'
|
24
|
-
spec.add_development_dependency 'rspec'
|
26
|
+
spec.add_development_dependency 'rspec', '~> 3.1'
|
25
27
|
|
26
28
|
spec.add_dependency 'highline', '>= 1.6.19'
|
27
29
|
end
|
data/lib/hanzo/cli.rb
CHANGED
@@ -3,7 +3,7 @@ require 'hanzo/modules/install'
|
|
3
3
|
require 'hanzo/modules/config'
|
4
4
|
|
5
5
|
module Hanzo
|
6
|
-
|
6
|
+
class CLI < Base
|
7
7
|
def run
|
8
8
|
@options.parse!(@args) if @opts.respond_to? :parse!
|
9
9
|
puts @options unless @options.to_s == "Usage: hanzo [options]\n"
|
@@ -16,7 +16,7 @@ module Hanzo
|
|
16
16
|
end
|
17
17
|
|
18
18
|
def initialize_cli
|
19
|
-
initialize_help
|
19
|
+
initialize_help && return if @app.nil?
|
20
20
|
|
21
21
|
begin
|
22
22
|
@options = Hanzo.const_get(@app.capitalize).new(@args).options
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module Hanzo
|
2
|
+
module Fetchers
|
3
|
+
class Environment
|
4
|
+
def initialize(env)
|
5
|
+
@env = env
|
6
|
+
end
|
7
|
+
|
8
|
+
def exist?
|
9
|
+
environments.include?(@env)
|
10
|
+
end
|
11
|
+
|
12
|
+
def installed?
|
13
|
+
installed_environments.include?(@env)
|
14
|
+
end
|
15
|
+
|
16
|
+
protected
|
17
|
+
|
18
|
+
def installed_environments
|
19
|
+
Hanzo::Installers::Remotes.installed_environments
|
20
|
+
end
|
21
|
+
|
22
|
+
def environments
|
23
|
+
Hanzo::Installers::Remotes.environments
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
data/lib/hanzo/heroku.rb
CHANGED
@@ -1,9 +1,8 @@
|
|
1
1
|
module Hanzo
|
2
2
|
module Heroku
|
3
3
|
class << self
|
4
|
-
|
5
4
|
def available_labs
|
6
|
-
Hanzo.run(
|
5
|
+
Hanzo.run('heroku labs').each_line.to_a.reduce([]) do |memo, line|
|
7
6
|
if line = /^\[\s\]\s+(?<name>\w+)\s+(?<description>.+)$/.match(line)
|
8
7
|
memo << [line[:name], line[:description]]
|
9
8
|
else
|
@@ -11,7 +10,6 @@ module Hanzo
|
|
11
10
|
end
|
12
11
|
end
|
13
12
|
end
|
14
|
-
|
15
13
|
end
|
16
14
|
end
|
17
15
|
end
|
data/lib/hanzo/modules/config.rb
CHANGED
@@ -1,11 +1,10 @@
|
|
1
1
|
module Hanzo
|
2
2
|
class Config < Base
|
3
|
-
|
4
3
|
def compare
|
5
|
-
Hanzo.title
|
4
|
+
Hanzo.title('Fetching environment variables')
|
6
5
|
fetch_variables
|
7
6
|
|
8
|
-
Hanzo.title
|
7
|
+
Hanzo.title('Comparing environment variables')
|
9
8
|
compare_variables
|
10
9
|
end
|
11
10
|
|
@@ -16,7 +15,8 @@ module Hanzo
|
|
16
15
|
end
|
17
16
|
|
18
17
|
def initialize_cli
|
19
|
-
initialize_help
|
18
|
+
initialize_help && return if @type != 'compare'
|
19
|
+
|
20
20
|
compare
|
21
21
|
end
|
22
22
|
|
@@ -32,7 +32,7 @@ module Hanzo
|
|
32
32
|
private
|
33
33
|
|
34
34
|
def fetch_variables
|
35
|
-
@variables = Hanzo::Installers::Remotes.environments.keys.
|
35
|
+
@variables = Hanzo::Installers::Remotes.environments.keys.reduce({}) do |memo, env|
|
36
36
|
# Fetch the variables over at Heroku
|
37
37
|
config = Hanzo.run("heroku config -r #{env}", true).split("\n")
|
38
38
|
|
data/lib/hanzo/modules/deploy.rb
CHANGED
@@ -1,21 +1,24 @@
|
|
1
1
|
module Hanzo
|
2
2
|
class Deploy < Base
|
3
|
+
UnknownEnvironment = Class.new(StandardError)
|
4
|
+
UninstalledEnvironment = Class.new(StandardError)
|
3
5
|
|
4
6
|
protected
|
5
7
|
|
6
8
|
def initialize_variables
|
7
9
|
@env = extract_argument(1)
|
8
|
-
|
9
|
-
if @env.nil? and Hanzo::Installers::Remotes.environments.keys.length == 1
|
10
|
-
@env = Hanzo::Installers::Remotes.environments.keys.first
|
11
|
-
end
|
10
|
+
@env ||= Hanzo::Installers::Remotes.environments.keys.first
|
12
11
|
end
|
13
12
|
|
14
13
|
def initialize_cli
|
15
|
-
initialize_help
|
16
|
-
|
17
|
-
deploy
|
18
|
-
|
14
|
+
initialize_help && return if @env.nil?
|
15
|
+
|
16
|
+
deploy && run_migrations
|
17
|
+
rescue UnknownEnvironment
|
18
|
+
Hanzo.unindent_print "Environment `#{@env}` doesn't exist. Add it to .heroku-remotes and run:\n hanzo install remotes", :red
|
19
|
+
Hanzo.unindent_print "\nFor more information, read https://github.com/mirego/hanzo#install-remotes", :red
|
20
|
+
rescue UninstalledEnvironment
|
21
|
+
Hanzo.unindent_print "Environment `#{@env}` has been found in your .heroku-remotes file. Before using it, you must install it:\n hanzo install remotes", :red
|
19
22
|
end
|
20
23
|
|
21
24
|
def initialize_help
|
@@ -31,20 +34,28 @@ module Hanzo
|
|
31
34
|
end
|
32
35
|
|
33
36
|
def deploy
|
34
|
-
|
37
|
+
validate_environment_existence!
|
38
|
+
|
39
|
+
branch = Hanzo.ask("Branch to deploy in #{@env}:") { |q| q.default = 'HEAD' }
|
35
40
|
|
36
41
|
Hanzo.run "git push -f #{@env} #{branch}:master"
|
37
42
|
end
|
38
43
|
|
39
44
|
def run_migrations
|
40
|
-
|
41
|
-
|
45
|
+
return unless Dir.exist?('db/migrate')
|
46
|
+
return unless Hanzo.agree('Run migrations?')
|
42
47
|
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
+
Hanzo.run "heroku run rake db:migrate --remote #{@env}"
|
49
|
+
Hanzo.run "heroku ps:restart --remote #{@env}"
|
50
|
+
end
|
51
|
+
|
52
|
+
def validate_environment_existence!
|
53
|
+
raise UnknownEnvironment unless fetcher.exist?
|
54
|
+
raise UninstalledEnvironment unless fetcher.installed?
|
55
|
+
end
|
56
|
+
|
57
|
+
def fetcher
|
58
|
+
@fetcher ||= Hanzo::Fetchers::Environment.new(@env)
|
48
59
|
end
|
49
60
|
end
|
50
61
|
end
|
@@ -2,13 +2,13 @@ module Hanzo
|
|
2
2
|
module Installers
|
3
3
|
module Labs
|
4
4
|
def install_labs
|
5
|
-
Hanzo.title
|
5
|
+
Hanzo.title('Activating Heroku Labs')
|
6
6
|
|
7
|
-
Hanzo::Heroku.available_labs.each do |name,
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
7
|
+
Hanzo::Heroku.available_labs.each do |name, _|
|
8
|
+
next unless Hanzo.agree("Add #{name}?")
|
9
|
+
|
10
|
+
Hanzo::Installers::Remotes.environments.each_pair do |env, _|
|
11
|
+
Hanzo::Installers::Labs.enable(env, name)
|
12
12
|
end
|
13
13
|
end
|
14
14
|
end
|
@@ -16,12 +16,16 @@ module Hanzo
|
|
16
16
|
end
|
17
17
|
|
18
18
|
def self.environments
|
19
|
-
return YAML.load_file('.heroku-remotes') if File.
|
19
|
+
return YAML.load_file('.heroku-remotes') if File.exist?('.heroku-remotes')
|
20
20
|
|
21
21
|
Hanzo.print 'Cannot locate .heroku-remotes'
|
22
22
|
Hanzo.print 'For more information, please read https://github.com/mirego/hanzo'
|
23
23
|
exit
|
24
24
|
end
|
25
|
+
|
26
|
+
def self.installed_environments
|
27
|
+
`git remote`.split("\n")
|
28
|
+
end
|
25
29
|
end
|
26
30
|
end
|
27
31
|
end
|
data/lib/hanzo/version.rb
CHANGED
data/lib/hanzo.rb
CHANGED
@@ -7,6 +7,8 @@ require 'hanzo/cli'
|
|
7
7
|
require 'hanzo/heroku'
|
8
8
|
require 'hanzo/version'
|
9
9
|
|
10
|
+
require 'hanzo/fetchers/environment'
|
11
|
+
|
10
12
|
module Hanzo
|
11
13
|
def self.run(command, fetch_output = false)
|
12
14
|
print(command, :green)
|
@@ -16,7 +18,7 @@ module Hanzo
|
|
16
18
|
if fetch_output
|
17
19
|
output = `#{command}`
|
18
20
|
else
|
19
|
-
system(command)
|
21
|
+
output = system(command)
|
20
22
|
end
|
21
23
|
end
|
22
24
|
|
@@ -37,6 +39,11 @@ module Hanzo
|
|
37
39
|
HighLine.say HighLine.color(" #{text}", *colors)
|
38
40
|
end
|
39
41
|
|
42
|
+
def self.unindent_print(text = '', *colors)
|
43
|
+
colors = colors.map { |c| HighLine.const_get(c.to_s.upcase) }
|
44
|
+
HighLine.say HighLine.color(text, *colors)
|
45
|
+
end
|
46
|
+
|
40
47
|
def self.title(text)
|
41
48
|
HighLine.say HighLine.color("-----> #{text}", :blue)
|
42
49
|
end
|
@@ -52,6 +59,6 @@ end
|
|
52
59
|
|
53
60
|
class String
|
54
61
|
def unindent
|
55
|
-
gsub
|
62
|
+
gsub(/^#{scan(/^\s*/).min_by { |l| l.length }}/, '')
|
56
63
|
end
|
57
64
|
end
|
data/spec/cli/config_spec.rb
CHANGED
@@ -5,7 +5,7 @@ describe Hanzo::CLI do
|
|
5
5
|
let(:config!) { Hanzo::CLI.new(['config', action]) }
|
6
6
|
let(:heroku_remotes) { { 'production' => 'heroku-app-production', 'qa' => 'heroku-app-qa' } }
|
7
7
|
|
8
|
-
before { Hanzo::Installers::Remotes.
|
8
|
+
before { expect(Hanzo::Installers::Remotes).to receive(:environments).and_return(heroku_remotes) }
|
9
9
|
|
10
10
|
describe :compare do
|
11
11
|
let(:action) { 'compare' }
|
@@ -16,31 +16,31 @@ describe Hanzo::CLI do
|
|
16
16
|
|
17
17
|
let(:environment_one_name) { 'production' }
|
18
18
|
let(:environment_two_name) { 'qa' }
|
19
|
-
let(:environment_one)
|
20
|
-
<<-RUBY
|
21
|
-
SMTP_PORT: 25
|
22
|
-
SMTP_PASSWORD: hanzo
|
23
|
-
SMTP_HOST: localhost
|
24
|
-
RUBY
|
25
|
-
|
26
|
-
let(:environment_two)
|
27
|
-
<<-RUBY
|
28
|
-
SMTP_PORT: 25
|
29
|
-
SMTP_USERNAME: hanzo
|
30
|
-
RUBY
|
31
|
-
|
19
|
+
let(:environment_one) do
|
20
|
+
<<-RUBY.unindent
|
21
|
+
SMTP_PORT: 25
|
22
|
+
SMTP_PASSWORD: hanzo
|
23
|
+
SMTP_HOST: localhost
|
24
|
+
RUBY
|
25
|
+
end
|
26
|
+
let(:environment_two) do
|
27
|
+
<<-RUBY.unindent
|
28
|
+
SMTP_PORT: 25
|
29
|
+
SMTP_USERNAME: hanzo
|
30
|
+
RUBY
|
31
|
+
end
|
32
32
|
|
33
33
|
before do
|
34
|
-
Hanzo.
|
35
|
-
Hanzo.
|
34
|
+
expect(Hanzo).to receive(:title).with(fetch_environment_title)
|
35
|
+
expect(Hanzo).to receive(:title).with(compare_environment_title)
|
36
36
|
|
37
|
-
Hanzo.
|
38
|
-
Hanzo.
|
37
|
+
expect(Hanzo).to receive(:run).with("#{config_cmd} -r #{environment_one_name}", true).and_return(environment_one)
|
38
|
+
expect(Hanzo).to receive(:run).with("#{config_cmd} -r #{environment_two_name}", true).and_return(environment_two)
|
39
39
|
|
40
|
-
Hanzo.
|
41
|
-
Hanzo.
|
42
|
-
Hanzo.
|
43
|
-
Hanzo.
|
40
|
+
expect(Hanzo).to receive(:print).with("Missing variables in #{environment_one_name}", :yellow)
|
41
|
+
expect(Hanzo).to receive(:print).with(['- SMTP_USERNAME'])
|
42
|
+
expect(Hanzo).to receive(:print).with("Missing variables in #{environment_two_name}", :yellow)
|
43
|
+
expect(Hanzo).to receive(:print).with(['- SMTP_PASSWORD', '- SMTP_HOST'])
|
44
44
|
end
|
45
45
|
|
46
46
|
it 'should install specified labs for each environment' do
|
data/spec/cli/deploy_spec.rb
CHANGED
@@ -5,7 +5,6 @@ describe Hanzo::CLI do
|
|
5
5
|
let(:env) { 'production' }
|
6
6
|
let(:branch) { '1.0.0' }
|
7
7
|
let(:deploy!) { Hanzo::CLI.new(['deploy', env]) }
|
8
|
-
let(:migrations_exist) { false }
|
9
8
|
let(:heroku_remotes) { { 'production' => 'heroku-app-production' } }
|
10
9
|
let(:migration_dir) { 'db/migrate' }
|
11
10
|
|
@@ -17,43 +16,71 @@ describe Hanzo::CLI do
|
|
17
16
|
let(:deploy_cmd) { "git push -f #{env} #{branch}:master" }
|
18
17
|
|
19
18
|
before do
|
20
|
-
|
21
|
-
Hanzo::Installers::Remotes.
|
22
|
-
Hanzo.should_receive(:ask).with(deploy_question).and_return(branch)
|
23
|
-
Hanzo.should_receive(:run).with(deploy_cmd).once
|
19
|
+
expect(Hanzo::Installers::Remotes).to receive(:environments).and_return(['production'])
|
20
|
+
expect(Hanzo::Installers::Remotes).to receive(:installed_environments).and_return(['production'])
|
24
21
|
end
|
25
22
|
|
26
|
-
context 'without
|
23
|
+
context 'successful deploy and without migrations' do
|
24
|
+
let(:migrations_exist) { false }
|
25
|
+
let(:deploy_result) { true }
|
26
|
+
|
27
|
+
before do
|
28
|
+
expect(Dir).to receive(:exist?).with(migration_dir).and_return(migrations_exist)
|
29
|
+
expect(Hanzo).to receive(:ask).with(deploy_question).and_return(branch)
|
30
|
+
expect(Hanzo).to receive(:run).with(deploy_cmd).once.and_return(deploy_result)
|
31
|
+
end
|
32
|
+
|
27
33
|
it 'should git push to heroku upstream' do
|
28
34
|
deploy!
|
29
35
|
end
|
30
36
|
end
|
31
37
|
|
32
|
-
context 'with migrations' do
|
38
|
+
context 'with existing migrations' do
|
33
39
|
let(:migrations_exist) { true }
|
34
40
|
|
35
|
-
|
41
|
+
before do
|
42
|
+
expect(Hanzo).to receive(:ask).with(deploy_question).and_return(branch)
|
43
|
+
expect(Hanzo).to receive(:run).with(deploy_cmd).once.and_return(deploy_result)
|
44
|
+
end
|
45
|
+
|
46
|
+
context 'with successful deploy' do
|
47
|
+
let(:deploy_result) { true }
|
48
|
+
|
36
49
|
before do
|
37
|
-
|
38
|
-
Hanzo.should_receive(:run).with(migration_cmd)
|
39
|
-
Hanzo.should_receive(:run).with(restart_cmd)
|
50
|
+
expect(Dir).to receive(:exist?).with(migration_dir).and_return(migrations_exist)
|
40
51
|
end
|
41
52
|
|
42
|
-
|
43
|
-
|
53
|
+
context 'and migrations that should be ran' do
|
54
|
+
before do
|
55
|
+
expect(Hanzo).to receive(:agree).with(migration_question).and_return(true)
|
56
|
+
expect(Hanzo).to receive(:run).with(migration_cmd)
|
57
|
+
expect(Hanzo).to receive(:run).with(restart_cmd)
|
58
|
+
end
|
59
|
+
|
60
|
+
specify { deploy! }
|
61
|
+
end
|
62
|
+
|
63
|
+
context 'and migrations that should not be ran' do
|
64
|
+
before do
|
65
|
+
expect(Hanzo).to receive(:agree).with(migration_question).and_return(false)
|
66
|
+
expect(Hanzo).not_to receive(:run).with(migration_cmd)
|
67
|
+
expect(Hanzo).not_to receive(:run).with(restart_cmd)
|
68
|
+
end
|
69
|
+
|
70
|
+
specify { deploy! }
|
44
71
|
end
|
45
72
|
end
|
46
73
|
|
47
|
-
context '
|
74
|
+
context 'without successful deploy' do
|
75
|
+
let(:deploy_result) { false }
|
76
|
+
|
48
77
|
before do
|
49
|
-
Hanzo.
|
50
|
-
Hanzo.
|
51
|
-
Hanzo.
|
78
|
+
expect(Hanzo).not_to receive(:agree).with(migration_question)
|
79
|
+
expect(Hanzo).not_to receive(:run).with(migration_cmd)
|
80
|
+
expect(Hanzo).not_to receive(:run).with(restart_cmd)
|
52
81
|
end
|
53
82
|
|
54
|
-
|
55
|
-
deploy!
|
56
|
-
end
|
83
|
+
specify { deploy! }
|
57
84
|
end
|
58
85
|
end
|
59
86
|
end
|
data/spec/cli/install_spec.rb
CHANGED
@@ -10,20 +10,20 @@ describe Hanzo::CLI do
|
|
10
10
|
let(:labs_title) { 'Activating Heroku Labs' }
|
11
11
|
let(:available_labs) { { 'user-env-compile' => 'Description' } }
|
12
12
|
|
13
|
-
let(:enable_labs_cmd) {
|
13
|
+
let(:enable_labs_cmd) { 'heroku labs:enable' }
|
14
14
|
let(:enable_labs_info) { '- Enabled for' }
|
15
15
|
|
16
16
|
before do
|
17
|
-
Hanzo::Installers::Remotes.
|
18
|
-
Hanzo::Heroku.
|
19
|
-
Hanzo.
|
17
|
+
expect(Hanzo::Installers::Remotes).to receive(:environments).and_return(heroku_remotes)
|
18
|
+
expect(Hanzo::Heroku).to receive(:available_labs).and_return(available_labs)
|
19
|
+
expect(Hanzo).to receive(:title).with(labs_title)
|
20
20
|
|
21
|
-
available_labs.each do |name,
|
22
|
-
Hanzo.
|
21
|
+
available_labs.each do |name, _|
|
22
|
+
expect(Hanzo).to receive(:agree).with("Add #{name}?").and_return(true)
|
23
23
|
|
24
|
-
heroku_remotes.each do |env,
|
25
|
-
Hanzo.
|
26
|
-
Hanzo.
|
24
|
+
heroku_remotes.each do |env, _|
|
25
|
+
expect(Hanzo).to receive(:run).with("#{enable_labs_cmd} #{name} --remote #{env}")
|
26
|
+
expect(Hanzo).to receive(:print).with("#{enable_labs_info} #{env}")
|
27
27
|
end
|
28
28
|
end
|
29
29
|
end
|
@@ -37,15 +37,16 @@ describe Hanzo::CLI do
|
|
37
37
|
let(:type) { 'remotes' }
|
38
38
|
let(:create_remotes_title) { 'Creating git remotes' }
|
39
39
|
|
40
|
-
before { Hanzo.
|
40
|
+
before { expect(Hanzo).to receive(:title).with(create_remotes_title) }
|
41
41
|
|
42
42
|
context '.heroku-remotes exists' do
|
43
43
|
before do
|
44
|
-
Hanzo::Installers::Remotes.
|
44
|
+
expect(Hanzo::Installers::Remotes).to receive(:environments).and_return(heroku_remotes)
|
45
|
+
|
45
46
|
heroku_remotes.each do |env, app|
|
46
|
-
Hanzo.
|
47
|
-
Hanzo.
|
48
|
-
Hanzo.
|
47
|
+
expect(Hanzo).to receive(:print).with("Adding #{env}")
|
48
|
+
expect(Hanzo).to receive(:run).with("git remote rm #{env} 2>&1 > /dev/null")
|
49
|
+
expect(Hanzo).to receive(:run).with("git remote add #{env} git@heroku.com:#{app}.git")
|
49
50
|
end
|
50
51
|
end
|
51
52
|
|
@@ -55,10 +56,10 @@ describe Hanzo::CLI do
|
|
55
56
|
end
|
56
57
|
|
57
58
|
context '.heroku-remotes file is missing' do
|
58
|
-
before { Hanzo.
|
59
|
+
before { expect(Hanzo).to receive(:print).twice }
|
59
60
|
|
60
61
|
it 'should display error message' do
|
61
|
-
|
62
|
+
expect { install! }.to raise_error SystemExit
|
62
63
|
end
|
63
64
|
end
|
64
65
|
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Hanzo::Fetchers::Environment do
|
4
|
+
let(:fetcher) { Hanzo::Fetchers::Environment.new(current_environment) }
|
5
|
+
let(:current_environment) { 'production' }
|
6
|
+
|
7
|
+
describe :exist? do
|
8
|
+
let(:environments) { ['production'] }
|
9
|
+
|
10
|
+
before { expect(fetcher).to receive(:environments).and_return(environments) }
|
11
|
+
|
12
|
+
context 'with an existing environment' do
|
13
|
+
it { expect(fetcher.exist?).to be_truthy }
|
14
|
+
end
|
15
|
+
|
16
|
+
context 'with an unexisting environment' do
|
17
|
+
let(:current_environment) { 'staging' }
|
18
|
+
it { expect(fetcher.exist?).to be_falsey }
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
describe :installed? do
|
23
|
+
let(:environments) { ['production'] }
|
24
|
+
|
25
|
+
before { expect(fetcher).to receive(:installed_environments).and_return(environments) }
|
26
|
+
|
27
|
+
context 'with an installed environment' do
|
28
|
+
it { expect(fetcher.installed?).to be_truthy }
|
29
|
+
end
|
30
|
+
|
31
|
+
context 'with an uninstalled environment' do
|
32
|
+
let(:current_environment) { 'staging' }
|
33
|
+
it { expect(fetcher.installed?).to be_falsey }
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
describe :installed_environments do
|
38
|
+
before { expect(Hanzo::Installers::Remotes).to receive(:installed_environments) }
|
39
|
+
|
40
|
+
specify { fetcher.send(:installed_environments) }
|
41
|
+
end
|
42
|
+
|
43
|
+
describe :environments do
|
44
|
+
before { expect(Hanzo::Installers::Remotes).to receive(:environments) }
|
45
|
+
|
46
|
+
specify { fetcher.send(:environments) }
|
47
|
+
end
|
48
|
+
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hanzo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samuel Garneau
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-04-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -24,6 +24,34 @@ dependencies:
|
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '1.3'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: phare
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0.6'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0.6'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rubocop
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0.24'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0.24'
|
27
55
|
- !ruby/object:Gem::Dependency
|
28
56
|
name: rake
|
29
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -42,16 +70,16 @@ dependencies:
|
|
42
70
|
name: rspec
|
43
71
|
requirement: !ruby/object:Gem::Requirement
|
44
72
|
requirements:
|
45
|
-
- - "
|
73
|
+
- - "~>"
|
46
74
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
75
|
+
version: '3.1'
|
48
76
|
type: :development
|
49
77
|
prerelease: false
|
50
78
|
version_requirements: !ruby/object:Gem::Requirement
|
51
79
|
requirements:
|
52
|
-
- - "
|
80
|
+
- - "~>"
|
53
81
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
82
|
+
version: '3.1'
|
55
83
|
- !ruby/object:Gem::Dependency
|
56
84
|
name: highline
|
57
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -76,6 +104,7 @@ extra_rdoc_files: []
|
|
76
104
|
files:
|
77
105
|
- ".gitignore"
|
78
106
|
- ".rspec"
|
107
|
+
- ".rubocop.yml"
|
79
108
|
- ".travis.yml"
|
80
109
|
- Gemfile
|
81
110
|
- LICENSE.md
|
@@ -86,6 +115,7 @@ files:
|
|
86
115
|
- lib/hanzo.rb
|
87
116
|
- lib/hanzo/base.rb
|
88
117
|
- lib/hanzo/cli.rb
|
118
|
+
- lib/hanzo/fetchers/environment.rb
|
89
119
|
- lib/hanzo/heroku.rb
|
90
120
|
- lib/hanzo/modules/config.rb
|
91
121
|
- lib/hanzo/modules/deploy.rb
|
@@ -96,6 +126,7 @@ files:
|
|
96
126
|
- spec/cli/config_spec.rb
|
97
127
|
- spec/cli/deploy_spec.rb
|
98
128
|
- spec/cli/install_spec.rb
|
129
|
+
- spec/fetchers/environment_spec.rb
|
99
130
|
- spec/spec_helper.rb
|
100
131
|
homepage: https://github.com/mirego/hanzo
|
101
132
|
licenses:
|
@@ -125,4 +156,5 @@ test_files:
|
|
125
156
|
- spec/cli/config_spec.rb
|
126
157
|
- spec/cli/deploy_spec.rb
|
127
158
|
- spec/cli/install_spec.rb
|
159
|
+
- spec/fetchers/environment_spec.rb
|
128
160
|
- spec/spec_helper.rb
|