kibo 0.4.0 → 0.4.1
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/kibo/commandline.rb +32 -6
- data/lib/kibo/commands/deploy.rb +30 -12
- data/lib/kibo/commands/generate.rb +2 -0
- data/lib/kibo/commands/helpers.rb +1 -1
- data/lib/kibo/commands/info.rb +2 -2
- data/lib/kibo/commands/setup.rb +13 -2
- data/lib/kibo/config.rb +4 -0
- data/lib/kibo/heroku.rb +1 -1
- data/lib/kibo/system.rb +4 -0
- data/lib/kibo/version.rb +1 -1
- data/man/kibo.1 +1 -1
- data/man/kibo.1.html +1 -1
- metadata +3 -3
data/lib/kibo/commandline.rb
CHANGED
@@ -10,19 +10,33 @@ module Kibo::CommandLine
|
|
10
10
|
def subcommand
|
11
11
|
parse; @subcommand
|
12
12
|
end
|
13
|
-
|
13
|
+
|
14
|
+
def environment
|
15
|
+
parse; @environment
|
16
|
+
end
|
17
|
+
|
14
18
|
def args
|
15
19
|
parse; @args
|
16
20
|
end
|
17
21
|
|
18
22
|
private
|
19
23
|
|
24
|
+
COMMANDS_WO_ENVIRONMENT = %w(generate log compress)
|
25
|
+
|
20
26
|
def parse
|
21
27
|
return if @options
|
22
28
|
|
23
|
-
|
24
|
-
|
25
|
-
|
29
|
+
commands, descriptions = Kibo::Commands.commands, Kibo::Commands.descriptions
|
30
|
+
|
31
|
+
commands = commands.map(&:to_s) & descriptions.keys
|
32
|
+
ll_commands, hl_commands = commands.partition { |a| COMMANDS_WO_ENVIRONMENT.include?(a) }
|
33
|
+
|
34
|
+
hl_usage = hl_commands.map do |subcommand|
|
35
|
+
" kibo [options] %-33s ... %s" % [ "#{subcommand} <environment>", descriptions[subcommand] ]
|
36
|
+
end.compact.join("\n")
|
37
|
+
|
38
|
+
ll_usage = ll_commands.map do |subcommand|
|
39
|
+
" kibo [options] %-33s ... %s" % [ subcommand, descriptions[subcommand] ]
|
26
40
|
end.compact.join("\n")
|
27
41
|
|
28
42
|
@options = Trollop::options do
|
@@ -32,13 +46,16 @@ kibo manages multiple application roles on single heroku dynos.
|
|
32
46
|
|
33
47
|
Usage:
|
34
48
|
|
35
|
-
#{
|
49
|
+
#{hl_usage}
|
50
|
+
|
51
|
+
More commands:
|
52
|
+
|
53
|
+
#{ll_usage}
|
36
54
|
|
37
55
|
where [options] are:
|
38
56
|
|
39
57
|
EOS
|
40
58
|
|
41
|
-
opt :environment, "Set environment", :short => 'e', :type => String, :default => "staging"
|
42
59
|
opt :config, "Set Kibofile name", :short => 'c', :type => String, :default => "Kibofile"
|
43
60
|
|
44
61
|
stop_on Kibo::Commands.commands
|
@@ -54,6 +71,15 @@ EOS
|
|
54
71
|
end
|
55
72
|
end
|
56
73
|
|
74
|
+
# Does this subcommand needs the environment setting?
|
75
|
+
# This includes all subcommands except generate and log
|
76
|
+
unless COMMANDS_WO_ENVIRONMENT.include?(@subcommands)
|
77
|
+
@environment = ARGV.shift || begin
|
78
|
+
W "You should supply the <environment> argument. Using default 'staging'"
|
79
|
+
"staging"
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
57
83
|
# Is there a specific subcommand options configuration?
|
58
84
|
|
59
85
|
if proc = Kibo::Commands.options[@subcommand]
|
data/lib/kibo/commands/deploy.rb
CHANGED
@@ -3,22 +3,30 @@ module Kibo::Commands
|
|
3
3
|
|
4
4
|
def deploy
|
5
5
|
ENV["ENVIRONMENT"] = Kibo.environment
|
6
|
-
|
6
|
+
|
7
|
+
missing_instances = Kibo.config.instances - configured_instances
|
8
|
+
unless missing_instances.empty?
|
9
|
+
E "Use 'kibo setup #{Kibo.environment}' to set up these missing instances", *missing_instances
|
10
|
+
end
|
11
|
+
|
7
12
|
#
|
8
13
|
# Run source commands
|
9
14
|
with_commands :source do
|
15
|
+
with_stashed_changes do
|
16
|
+
# create a deployment branch, if there is none yet.
|
17
|
+
in_branch "kibo.#{Kibo.environment}" do
|
18
|
+
git "merge", "master"
|
10
19
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
with_commands :arena do
|
16
|
-
Kibo.config.instances.each do |instance|
|
17
|
-
git "push", "--force", instance, "HEAD:master"
|
20
|
+
with_commands :arena do
|
21
|
+
Kibo.config.instances.each do |instance|
|
22
|
+
git "push", "--force", instance, "HEAD:master"
|
23
|
+
end
|
18
24
|
end
|
19
25
|
end
|
20
26
|
end
|
21
27
|
end
|
28
|
+
rescue FatalError
|
29
|
+
raise
|
22
30
|
rescue StandardError
|
23
31
|
W $!
|
24
32
|
raise
|
@@ -51,13 +59,25 @@ module Kibo::Commands
|
|
51
59
|
run.call("final") if run
|
52
60
|
end
|
53
61
|
|
62
|
+
def dirty?
|
63
|
+
return false if git? "diff-index", "--quiet", "HEAD", :quiet
|
64
|
+
|
65
|
+
true
|
66
|
+
end
|
67
|
+
|
68
|
+
def with_stashed_changes(&block)
|
69
|
+
is_clean = git? "diff-index", "--quiet", "HEAD", :quiet
|
70
|
+
git "stash" unless is_clean
|
71
|
+
yield
|
72
|
+
ensure
|
73
|
+
git "stash", "pop" unless is_clean
|
74
|
+
end
|
75
|
+
|
54
76
|
#
|
55
77
|
# checkout the branch +name+, create it if necessary.
|
56
78
|
def in_branch(name, &block)
|
57
79
|
previous_branch = current_branch
|
58
80
|
|
59
|
-
git "stash"
|
60
|
-
|
61
81
|
if name != previous_branch
|
62
82
|
git "branch", name unless branches.include?(name)
|
63
83
|
git "checkout", name
|
@@ -72,8 +92,6 @@ module Kibo::Commands
|
|
72
92
|
git "reset", "--hard"
|
73
93
|
git "checkout", previous_branch
|
74
94
|
end
|
75
|
-
|
76
|
-
git "stash", "pop"
|
77
95
|
end
|
78
96
|
|
79
97
|
def current_branch
|
data/lib/kibo/commands/info.rb
CHANGED
@@ -33,8 +33,8 @@ module Kibo::Commands
|
|
33
33
|
end
|
34
34
|
|
35
35
|
def configured_instances
|
36
|
-
sys("git remote").split("\n").select { |line|
|
37
|
-
line =~ /^#{Kibo.namespace}
|
36
|
+
sys("git remote", :quiet).split("\n").select { |line|
|
37
|
+
line =~ /^#{Kibo.namespace}-#{Kibo.environment}/
|
38
38
|
}
|
39
39
|
end
|
40
40
|
end
|
data/lib/kibo/commands/setup.rb
CHANGED
@@ -7,13 +7,15 @@ module Kibo::Commands
|
|
7
7
|
subcommand :setup, "Setup and configure application instances" do
|
8
8
|
opt :force, "Reconfigure existing instances, too.", :short => "f"
|
9
9
|
end
|
10
|
+
|
11
|
+
subcommand :reconfigure, "Reconfigure application instances"
|
10
12
|
|
11
13
|
def setup
|
12
14
|
verify_heroku_login
|
13
15
|
|
14
16
|
# create all apps on heroku or make sure that they
|
15
17
|
# exist as remotes in the local git configuration.
|
16
|
-
instances.each do |instance|
|
18
|
+
Kibo.config.instances.each do |instance|
|
17
19
|
next unless create_instance(instance) || Kibo::CommandLine.force?
|
18
20
|
|
19
21
|
# The following only when forced (--force) to do so or when
|
@@ -24,6 +26,15 @@ module Kibo::Commands
|
|
24
26
|
end
|
25
27
|
end
|
26
28
|
|
29
|
+
def reconfigure
|
30
|
+
# create all apps on heroku or make sure that they
|
31
|
+
# exist as remotes in the local git configuration.
|
32
|
+
Kibo.config.instances.each do |instance|
|
33
|
+
# provide_instance instance
|
34
|
+
configure_instance instance
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
27
38
|
def create_instance(instance)
|
28
39
|
return false if sys("git remote | grep #{instance}", :quiet)
|
29
40
|
|
@@ -51,7 +62,7 @@ module Kibo::Commands
|
|
51
62
|
end
|
52
63
|
|
53
64
|
def configure_instance(instance)
|
54
|
-
heroku "config:set", "INSTANCE=#{instance}"
|
65
|
+
heroku "config:set", "INSTANCE=#{instance.instance_name}", "--app", instance
|
55
66
|
end
|
56
67
|
|
57
68
|
def verify_heroku_login
|
data/lib/kibo/config.rb
CHANGED
data/lib/kibo/heroku.rb
CHANGED
@@ -81,7 +81,7 @@ module Kibo::Heroku
|
|
81
81
|
|
82
82
|
# returns names of all apps for the current user on heroku
|
83
83
|
def apps
|
84
|
-
@apps ||= Kibo::System.heroku("apps").
|
84
|
+
@apps ||= Kibo::System.heroku("apps", :quiet).
|
85
85
|
split(/\n/).
|
86
86
|
reject { |line| line.empty? || line =~ /=== / }.
|
87
87
|
map { |line| line.split(" ").first }
|
data/lib/kibo/system.rb
CHANGED
data/lib/kibo/version.rb
CHANGED
data/man/kibo.1
CHANGED
data/man/kibo.1.html
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kibo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-10-
|
12
|
+
date: 2012-10-10 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: trollop
|
@@ -180,7 +180,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
180
180
|
version: '0'
|
181
181
|
segments:
|
182
182
|
- 0
|
183
|
-
hash: -
|
183
|
+
hash: -2440088423911513347
|
184
184
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
185
185
|
none: false
|
186
186
|
requirements:
|