hanzo 0.2.3 → 0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +2 -0
- data/lib/hanzo/cli.rb +9 -7
- data/lib/hanzo/modules/config.rb +59 -0
- data/lib/hanzo/modules/deploy.rb +4 -4
- data/lib/hanzo/modules/install.rb +5 -5
- data/lib/hanzo/version.rb +1 -1
- data/lib/hanzo.rb +11 -2
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4740905e91e0e036d29b67be68245425bacae8a1
|
4
|
+
data.tar.gz: e653917084f0b4b442ea4e983eeb1fa0b393ca25
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4c5d1e3d5d0d79b9231b89cfcd2fd13753cd119ef30a910a07ffd155bea208682c0222d6b4adedd55fa3ab2a8041e6c55515987564fd4bcc5ac85284651a3a82
|
7
|
+
data.tar.gz: 455dacbe103c05eb86dba320fefcbd44c77fef3323cd27c4399a5213b99ba115e721a183e0cb66d92491a608e262013c4f2268040dad79cd73f68486082f5188
|
data/Gemfile
ADDED
data/lib/hanzo/cli.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'hanzo/modules/deploy'
|
2
2
|
require 'hanzo/modules/install'
|
3
|
+
require 'hanzo/modules/config'
|
3
4
|
|
4
5
|
module Hanzo
|
5
6
|
class CLI < Base
|
@@ -25,15 +26,16 @@ module Hanzo
|
|
25
26
|
end
|
26
27
|
|
27
28
|
def initialize_help
|
28
|
-
@options.banner = <<-BANNER
|
29
|
-
Usage: hanzo action [options]
|
29
|
+
@options.banner = <<-BANNER.unindent
|
30
|
+
Usage: hanzo action [options]
|
30
31
|
|
31
|
-
Available actions:
|
32
|
-
|
33
|
-
|
32
|
+
Available actions:
|
33
|
+
deploy - Deploy a branch or a tag
|
34
|
+
install - Install Hanzo configuration
|
35
|
+
config - Manage Heroku configuration variables
|
34
36
|
|
35
|
-
Options:
|
36
|
-
BANNER
|
37
|
+
Options:
|
38
|
+
BANNER
|
37
39
|
@options.on('-h', '--help', 'You\'re looking at it.') { puts @options }
|
38
40
|
@options.on('-v', '--version', 'Print version') { puts "Hanzo #{Hanzo::VERSION}" }
|
39
41
|
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
module Hanzo
|
2
|
+
class Config < Base
|
3
|
+
|
4
|
+
def compare
|
5
|
+
Hanzo.title("Fetching environment variables")
|
6
|
+
fetch_variables
|
7
|
+
|
8
|
+
Hanzo.title "Comparing environment variables"
|
9
|
+
compare_variables
|
10
|
+
end
|
11
|
+
|
12
|
+
protected
|
13
|
+
|
14
|
+
def initialize_variables
|
15
|
+
@type = extract_argument(1)
|
16
|
+
end
|
17
|
+
|
18
|
+
def initialize_cli
|
19
|
+
initialize_help and return if @type != "compare"
|
20
|
+
compare
|
21
|
+
end
|
22
|
+
|
23
|
+
def initialize_help
|
24
|
+
@options.banner = <<-BANNER.unindent
|
25
|
+
Usage: hanzo config TYPE
|
26
|
+
|
27
|
+
Available install type:
|
28
|
+
compare - Compare the environment variables set across the remotes
|
29
|
+
BANNER
|
30
|
+
end
|
31
|
+
|
32
|
+
private
|
33
|
+
|
34
|
+
def fetch_variables
|
35
|
+
@variables = Hanzo::Installers::Remotes.environments.keys.inject({}) do |memo, env|
|
36
|
+
# Fetch the variables over at Heroku
|
37
|
+
config = Hanzo.run("heroku config -r #{env}").split("\n")
|
38
|
+
|
39
|
+
# Reject the first line (Heroku header)
|
40
|
+
config = config.reject { |line| line =~ /^=/ }
|
41
|
+
|
42
|
+
# Only keep the variable name, not their value
|
43
|
+
config = config.map { |line| line.gsub(/^([^:]+):.*$/, '\1') }
|
44
|
+
|
45
|
+
memo.merge env => config
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
def compare_variables
|
50
|
+
all_variables = @variables.values.flatten.uniq
|
51
|
+
|
52
|
+
@variables.each_pair do |env, variables|
|
53
|
+
missing_variables = all_variables - variables
|
54
|
+
Hanzo.print "Missing variables in #{env}", :yellow
|
55
|
+
Hanzo.print missing_variables.map { |v| "- #{v}" }
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
data/lib/hanzo/modules/deploy.rb
CHANGED
@@ -19,11 +19,11 @@ module Hanzo
|
|
19
19
|
end
|
20
20
|
|
21
21
|
def initialize_help
|
22
|
-
@options.banner = <<-BANNER
|
23
|
-
Usage: hanzo deploy ENVIRONMENT
|
22
|
+
@options.banner = <<-BANNER.unindent
|
23
|
+
Usage: hanzo deploy ENVIRONMENT
|
24
24
|
|
25
|
-
Available environments
|
26
|
-
BANNER
|
25
|
+
Available environments
|
26
|
+
BANNER
|
27
27
|
|
28
28
|
Hanzo::Installers::Remotes.environments.each do |env|
|
29
29
|
@options.banner << " - #{env.first}\n"
|
@@ -25,12 +25,12 @@ module Hanzo
|
|
25
25
|
end
|
26
26
|
|
27
27
|
def initialize_help
|
28
|
-
@options.banner = <<-BANNER
|
29
|
-
Usage: hanzo install TYPE
|
28
|
+
@options.banner = <<-BANNER.unindent
|
29
|
+
Usage: hanzo install TYPE
|
30
30
|
|
31
|
-
Available install type:
|
32
|
-
|
33
|
-
BANNER
|
31
|
+
Available install type:
|
32
|
+
remotes - Add git remotes to current repository
|
33
|
+
BANNER
|
34
34
|
end
|
35
35
|
end
|
36
36
|
end
|
data/lib/hanzo/version.rb
CHANGED
data/lib/hanzo.rb
CHANGED
@@ -10,11 +10,14 @@ require 'hanzo/version'
|
|
10
10
|
module Hanzo
|
11
11
|
def self.run(command)
|
12
12
|
print(command, :green)
|
13
|
-
|
13
|
+
output = nil
|
14
|
+
::Bundler.with_clean_env { output = `#{command}` }
|
15
|
+
output
|
14
16
|
end
|
15
17
|
|
16
|
-
def self.print(text, *colors)
|
18
|
+
def self.print(text = '', *colors)
|
17
19
|
colors = colors.map { |c| HighLine.const_get(c.to_s.upcase) }
|
20
|
+
text = text.join("\n ") if text.is_a?(Array)
|
18
21
|
HighLine.say HighLine.color(" #{text}", *colors)
|
19
22
|
end
|
20
23
|
|
@@ -30,3 +33,9 @@ module Hanzo
|
|
30
33
|
HighLine.ask "-----> #{question} ", &blk
|
31
34
|
end
|
32
35
|
end
|
36
|
+
|
37
|
+
class String
|
38
|
+
def unindent
|
39
|
+
gsub /^#{scan(/^\s*/).min_by{|l|l.length}}/, ''
|
40
|
+
end
|
41
|
+
end
|
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
|
+
version: '0.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: 2013-
|
11
|
+
date: 2013-10-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -75,6 +75,7 @@ extensions: []
|
|
75
75
|
extra_rdoc_files: []
|
76
76
|
files:
|
77
77
|
- .gitignore
|
78
|
+
- Gemfile
|
78
79
|
- LICENSE.md
|
79
80
|
- README.md
|
80
81
|
- Rakefile
|
@@ -84,6 +85,7 @@ files:
|
|
84
85
|
- lib/hanzo/base.rb
|
85
86
|
- lib/hanzo/cli.rb
|
86
87
|
- lib/hanzo/heroku.rb
|
88
|
+
- lib/hanzo/modules/config.rb
|
87
89
|
- lib/hanzo/modules/deploy.rb
|
88
90
|
- lib/hanzo/modules/install.rb
|
89
91
|
- lib/hanzo/modules/installers/labs.rb
|
@@ -109,9 +111,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
109
111
|
version: '0'
|
110
112
|
requirements: []
|
111
113
|
rubyforge_project:
|
112
|
-
rubygems_version: 2.
|
114
|
+
rubygems_version: 2.1.0
|
113
115
|
signing_key:
|
114
116
|
specification_version: 4
|
115
117
|
summary: Hanzo is a tool to handle deployments in multiple environments on Heroku.
|
116
118
|
test_files: []
|
117
|
-
has_rdoc:
|