blazing 0.0.16 → 0.1.0.alpha1
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.
- data/.gitignore +2 -0
- data/.rvmrc +1 -1
- data/Gemfile +0 -10
- data/Gemfile.lock +53 -44
- data/Guardfile +8 -0
- data/README.md +23 -99
- data/Rakefile +21 -4
- data/bin/blazing +23 -5
- data/blazing.gemspec +19 -8
- data/features/help_banner.feature +13 -0
- data/features/step_definitions/blazing_steps.rb +1 -0
- data/features/support/env.rb +9 -0
- data/lib/blazing.rb +4 -13
- data/lib/blazing/config.rb +38 -73
- data/lib/blazing/dsl_setter.rb +20 -0
- data/lib/blazing/recipe.rb +5 -78
- data/lib/blazing/runner.rb +44 -2
- data/lib/blazing/shell.rb +7 -0
- data/lib/blazing/target.rb +44 -134
- data/lib/blazing/templates/config.erb +21 -0
- data/lib/blazing/templates/hook.erb +43 -0
- data/lib/blazing/version.rb +1 -1
- data/spec/blazing/config_spec.rb +104 -48
- data/spec/blazing/integration/init_spec.rb +8 -37
- data/spec/blazing/integration/setup_local_spec.rb +27 -0
- data/spec/blazing/integration/setup_remote_spec.rb +32 -0
- data/spec/blazing/integration/update_spec.rb +38 -0
- data/spec/blazing/recipe_spec.rb +5 -66
- data/spec/blazing/runner_spec.rb +41 -6
- data/spec/blazing/target_spec.rb +26 -99
- data/spec/spec_helper.rb +18 -12
- data/spec/support/{config.rb → empty_config.rb} +0 -0
- metadata +170 -97
- data/TODO +0 -3
- data/lib/blazing/base.rb +0 -41
- data/lib/blazing/bootstrap.rb +0 -27
- data/lib/blazing/cli/base.rb +0 -64
- data/lib/blazing/cli/create.rb +0 -32
- data/lib/blazing/cli/hook.rb +0 -22
- data/lib/blazing/cli/templates/blazing.tt +0 -7
- data/lib/blazing/cli/templates/post-hook.tt +0 -25
- data/lib/blazing/core_ext/object.rb +0 -8
- data/lib/blazing/logger.rb +0 -31
- data/lib/blazing/recipes/bundler_recipe.rb +0 -20
- data/lib/blazing/recipes/rvm_recipe.rb +0 -11
- data/spec/blazing/binary_spec.rb +0 -11
- data/spec/blazing/cli/base_spec.rb +0 -94
- data/spec/blazing/cli/create_spec.rb +0 -27
- data/spec/blazing/cli/hook_spec.rb +0 -16
- data/spec/blazing/logger_spec.rb +0 -50
- data/spec/blazing/recipes/bundler_recipe_spec.rb +0 -32
- data/spec/blazing/recipes/passenger_recipe_spec.rb +0 -6
- data/spec/blazing/recipes/rvm_recipe_spec.rb +0 -11
- data/spec/blazing/remote_spec.rb +0 -136
data/TODO
DELETED
data/lib/blazing/base.rb
DELETED
@@ -1,41 +0,0 @@
|
|
1
|
-
require 'grit'
|
2
|
-
|
3
|
-
module Blazing
|
4
|
-
module Base
|
5
|
-
|
6
|
-
def config
|
7
|
-
@config ||= Blazing::Config.parse
|
8
|
-
end
|
9
|
-
|
10
|
-
def log(type, message)
|
11
|
-
@logger ||= Blazing::Logger.new
|
12
|
-
@logger.log(type, message)
|
13
|
-
end
|
14
|
-
|
15
|
-
def report
|
16
|
-
@logger.report
|
17
|
-
end
|
18
|
-
|
19
|
-
#
|
20
|
-
# Helper that wraps exitstatus of cli stuff
|
21
|
-
#
|
22
|
-
def exit_status
|
23
|
-
@exit_status || $?.exitstatus
|
24
|
-
end
|
25
|
-
|
26
|
-
#
|
27
|
-
# Try to read the default remote
|
28
|
-
#
|
29
|
-
def repository_url
|
30
|
-
Grit::Repo.new(Dir.pwd).config['remote.origin.url'] || 'user@host:/some/path'
|
31
|
-
end
|
32
|
-
|
33
|
-
#
|
34
|
-
# Return true if a Gemfile exists in pwd
|
35
|
-
#
|
36
|
-
def gemfile_present?
|
37
|
-
File.exists? 'Gemfile'
|
38
|
-
end
|
39
|
-
|
40
|
-
end
|
41
|
-
end
|
data/lib/blazing/bootstrap.rb
DELETED
@@ -1,27 +0,0 @@
|
|
1
|
-
module Blazing
|
2
|
-
class Target
|
3
|
-
module Bootstrap
|
4
|
-
|
5
|
-
def clone_command
|
6
|
-
"if [ -e #{@path} ]; then \
|
7
|
-
echo 'directory exists already'; else \
|
8
|
-
git clone #{@repository} #{"--branch #{@branch}" if @branch} #{@path} && cd #{@path} && git config receive.denyCurrentBranch ignore; fi"
|
9
|
-
end
|
10
|
-
|
11
|
-
def clone_repository
|
12
|
-
@runner.run "ssh #{@user}@#{@host} '#{clone_command}'"
|
13
|
-
end
|
14
|
-
|
15
|
-
def add_target_as_remote
|
16
|
-
@runner.run "git remote add #{@name} #{@user}@#{@host}:#{@path}"
|
17
|
-
end
|
18
|
-
|
19
|
-
def setup_post_receive_hook
|
20
|
-
@hook.new([use_rvm?]).generate
|
21
|
-
@runner.run "scp /tmp/post-receive #{@user}@#{@host}:#{@path}/.git/hooks/post-receive"
|
22
|
-
@runner.run "ssh #{@user}@#{@host} 'chmod +x #{@path}/.git/hooks/post-receive'"
|
23
|
-
end
|
24
|
-
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
data/lib/blazing/cli/base.rb
DELETED
@@ -1,64 +0,0 @@
|
|
1
|
-
require 'thor'
|
2
|
-
require 'grit'
|
3
|
-
require 'blazing'
|
4
|
-
require 'blazing/logger'
|
5
|
-
require 'blazing/base'
|
6
|
-
require 'blazing/recipe'
|
7
|
-
require 'blazing/cli/create'
|
8
|
-
|
9
|
-
module Blazing
|
10
|
-
module CLI
|
11
|
-
class Base < Thor
|
12
|
-
|
13
|
-
include Blazing::Base
|
14
|
-
|
15
|
-
desc 'init', 'prepare project for blazing deploys'
|
16
|
-
def init
|
17
|
-
@task ||= Blazing::CLI::Create.new([repository_url])
|
18
|
-
@task.invoke_all
|
19
|
-
end
|
20
|
-
|
21
|
-
desc 'bootstrap TARGET_NAME', 'setup or update blazing on specified target and deploy'
|
22
|
-
def bootstrap(target_name = nil)
|
23
|
-
Blazing::Target.bootstrap(target_name)
|
24
|
-
|
25
|
-
# TODO: Abstract this into module and load it where we need it. Methods / actions should have
|
26
|
-
# a success and failure message
|
27
|
-
if exit_status == 0
|
28
|
-
log :success, "successfully bootstrapped target #{target_name}"
|
29
|
-
else
|
30
|
-
log :error, "failed bootstrapping target #{target_name}"
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
desc 'setup TARGET_NAME', 'setup git remote for one or all targets'
|
35
|
-
def setup(target_name = nil)
|
36
|
-
Blazing::Target.setup(target_name)
|
37
|
-
end
|
38
|
-
|
39
|
-
desc 'deploy TARGET', 'deploy to TARGET'
|
40
|
-
def deploy(target_name = nil)
|
41
|
-
Blazing::Target.deploy(target_name)
|
42
|
-
|
43
|
-
if exit_status == 0
|
44
|
-
log :success, "successfully deployed target #{target_name}"
|
45
|
-
else
|
46
|
-
log :error, "failed deploying on target #{target_name}"
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
desc 'recipes', 'List available recipes'
|
51
|
-
def recipes
|
52
|
-
Blazing::Recipe.list.each do |recipe|
|
53
|
-
log :success, recipe.name
|
54
|
-
end
|
55
|
-
report
|
56
|
-
end
|
57
|
-
|
58
|
-
desc 'post_receive', 'trigger the post-receive actions'
|
59
|
-
def post_receive(target_name = nil)
|
60
|
-
Blazing::Target.post_receive(target_name)
|
61
|
-
end
|
62
|
-
end
|
63
|
-
end
|
64
|
-
end
|
data/lib/blazing/cli/create.rb
DELETED
@@ -1,32 +0,0 @@
|
|
1
|
-
require 'thor'
|
2
|
-
require 'thor/group'
|
3
|
-
require 'blazing/base'
|
4
|
-
|
5
|
-
module Blazing
|
6
|
-
module CLI
|
7
|
-
class Create < Thor::Group
|
8
|
-
|
9
|
-
desc 'create a blazing config file'
|
10
|
-
|
11
|
-
argument :repository
|
12
|
-
|
13
|
-
include Thor::Actions
|
14
|
-
include Blazing::Base
|
15
|
-
|
16
|
-
def self.source_root
|
17
|
-
File.dirname(__FILE__)
|
18
|
-
end
|
19
|
-
|
20
|
-
def create_blazing_dir
|
21
|
-
empty_directory Blazing::DIRECTORY
|
22
|
-
end
|
23
|
-
|
24
|
-
def create_config_file
|
25
|
-
template 'templates/blazing.tt', Blazing::CONFIGURATION_FILE
|
26
|
-
log :info, "Blazing config file has been created in #{Blazing::CONFIGURATION_FILE} with a default remote."
|
27
|
-
log :info, "Check the config and then setup your remote with blazing setup REMOTE"
|
28
|
-
report
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
data/lib/blazing/cli/hook.rb
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
require 'thor'
|
2
|
-
|
3
|
-
module Blazing
|
4
|
-
module CLI
|
5
|
-
class Hook < Thor
|
6
|
-
|
7
|
-
include Thor::Actions
|
8
|
-
|
9
|
-
argument :rvm_string
|
10
|
-
|
11
|
-
desc 'generate', 'generate post-receive hook from template'
|
12
|
-
def generate
|
13
|
-
template('templates/post-hook.tt', '/tmp/post-receive')
|
14
|
-
end
|
15
|
-
|
16
|
-
def self.source_root
|
17
|
-
File.dirname(__FILE__)
|
18
|
-
end
|
19
|
-
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
@@ -1,25 +0,0 @@
|
|
1
|
-
#!/bin/bash
|
2
|
-
|
3
|
-
<%- unless rvm_string == 'none' %>
|
4
|
-
# Load RVM into a shell session *as a function*
|
5
|
-
if [[ -s "$HOME/.rvm/scripts/rvm" ]] ; then
|
6
|
-
|
7
|
-
# First try to load from a user install
|
8
|
-
source "$HOME/.rvm/scripts/rvm"
|
9
|
-
<%= "rvm use #{rvm_string}" %>
|
10
|
-
|
11
|
-
elif [[ -s "/usr/local/rvm/scripts/rvm" ]] ; then
|
12
|
-
|
13
|
-
# Then try to load from a root install
|
14
|
-
source "/usr/local/rvm/scripts/rvm"
|
15
|
-
<%= "rvm use #{rvm_string}" %>
|
16
|
-
|
17
|
-
else
|
18
|
-
printf "ERROR: RVM was enabled in config but no RVM installation was not found.\n"
|
19
|
-
fi
|
20
|
-
<%- end -%>
|
21
|
-
|
22
|
-
cd ..
|
23
|
-
unset GIT_DIR
|
24
|
-
|
25
|
-
bundle exec blazing post_receive
|
data/lib/blazing/logger.rb
DELETED
@@ -1,31 +0,0 @@
|
|
1
|
-
module Blazing
|
2
|
-
class Logger
|
3
|
-
|
4
|
-
LOG_LEVELS = [:info, :success, :warn, :error]
|
5
|
-
|
6
|
-
def initialize(output = $stdout)
|
7
|
-
@output = output
|
8
|
-
end
|
9
|
-
|
10
|
-
def messages
|
11
|
-
@messages ||= []
|
12
|
-
end
|
13
|
-
|
14
|
-
def log(type, message)
|
15
|
-
if LOG_LEVELS.include? type
|
16
|
-
messages << Hash[:message => message, :type => type]
|
17
|
-
else
|
18
|
-
raise
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
def report(type = nil)
|
23
|
-
if type
|
24
|
-
messages.select { |m| m[:type] == type }.each { |m| @output.puts m[:message] }
|
25
|
-
else
|
26
|
-
messages.each { |m| @output.puts m[:message] }
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
end
|
31
|
-
end
|
@@ -1,20 +0,0 @@
|
|
1
|
-
require 'blazing/recipe'
|
2
|
-
|
3
|
-
module Blazing
|
4
|
-
class BundlerRecipe < Blazing::Recipe
|
5
|
-
|
6
|
-
def initialize(name, options = {})
|
7
|
-
options[:flags] ||= '--deployment'
|
8
|
-
super(name, options)
|
9
|
-
end
|
10
|
-
|
11
|
-
def run
|
12
|
-
if File.exists?(File.join(Dir.pwd, 'Gemfile'))
|
13
|
-
@runner.run "bundle install #{@options[:flags]}"
|
14
|
-
else
|
15
|
-
false
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
end
|
20
|
-
end
|
data/spec/blazing/binary_spec.rb
DELETED
@@ -1,11 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'blazing'
|
3
|
-
require 'blazing/cli/base'
|
4
|
-
|
5
|
-
describe 'CLI invocation' do
|
6
|
-
context 'without options' do
|
7
|
-
it 'should raise no errors' do
|
8
|
-
silence(:stderr) { lambda { Blazing::CLI::Base.start }.should_not raise_error }
|
9
|
-
end
|
10
|
-
end
|
11
|
-
end
|
@@ -1,94 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'blazing/cli/base'
|
3
|
-
|
4
|
-
describe Blazing::CLI::Base do
|
5
|
-
|
6
|
-
before :all do
|
7
|
-
Blazing.send(:remove_const, 'CONFIGURATION_FILE')
|
8
|
-
Blazing::CONFIGURATION_FILE = 'spec/support/config.rb'
|
9
|
-
end
|
10
|
-
|
11
|
-
before :each do
|
12
|
-
@logger = double('logger', :log => nil, :report => nil)
|
13
|
-
@runner = double('runner', :run => nil)
|
14
|
-
@hook = double('hook', :new => double('template', :generate => nil))
|
15
|
-
@base = Blazing::CLI::Base.new
|
16
|
-
@base.instance_variable_set('@logger', @logger)
|
17
|
-
@some_target_name = 'test_target'
|
18
|
-
end
|
19
|
-
|
20
|
-
describe '#init' do
|
21
|
-
it 'invokes all CLI::Create tasks' do
|
22
|
-
@create_task = double('create task')
|
23
|
-
@base.instance_variable_set('@task', @create_task)
|
24
|
-
@create_task.should_receive(:invoke_all)
|
25
|
-
@base.init
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
describe '#bootstrap' do
|
30
|
-
|
31
|
-
it 'runs bootstrap on selected target' do
|
32
|
-
Blazing::Target.should_receive(:bootstrap).with(@some_target_name)
|
33
|
-
@base.bootstrap(@some_target_name)
|
34
|
-
end
|
35
|
-
|
36
|
-
it 'logs a success message if exitstatus of setup was 0' do
|
37
|
-
Blazing::Target.stub!(:bootstrap)
|
38
|
-
@base.instance_variable_set('@exit_status', 0)
|
39
|
-
@logger.should_receive(:log).with(:success, "successfully bootstrapped target test_target")
|
40
|
-
@base.bootstrap(@some_target_name)
|
41
|
-
end
|
42
|
-
|
43
|
-
it 'logs an error if exitstatus of setup was not 0' do
|
44
|
-
Blazing::Target.stub!(:bootstrap)
|
45
|
-
@base.instance_variable_set('@exit_status', 1)
|
46
|
-
@logger.should_receive(:log).with(:error, "failed bootstrapping target test_target")
|
47
|
-
@base.bootstrap(@some_target_name)
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
describe '#setup' do
|
52
|
-
it 'runs setup on given target' do
|
53
|
-
Blazing::Target.should_receive(:setup).with(@some_target_name)
|
54
|
-
@base.setup(@some_target_name)
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
describe '#deploy' do
|
59
|
-
|
60
|
-
it 'runs setup on selected target' do
|
61
|
-
Blazing::Target.should_receive(:deploy).with(@some_target_name)
|
62
|
-
@base.deploy(@some_target_name)
|
63
|
-
end
|
64
|
-
|
65
|
-
it 'logs a success message if exitstatus of setup was 0' do
|
66
|
-
Blazing::Target.stub!(:deploy)
|
67
|
-
@base.instance_variable_set('@exit_status', 0)
|
68
|
-
@logger.should_receive(:log).with(:success, "successfully deployed target test_target")
|
69
|
-
@base.deploy(@some_target_name)
|
70
|
-
end
|
71
|
-
|
72
|
-
it 'logs an error if exitstatus of setup was not 0' do
|
73
|
-
Blazing::Target.stub!(:deploy)
|
74
|
-
@base.instance_variable_set('@exit_status', 1)
|
75
|
-
@logger.should_receive(:log).with(:error, "failed deploying on target test_target")
|
76
|
-
@base.deploy(@some_target_name)
|
77
|
-
end
|
78
|
-
end
|
79
|
-
|
80
|
-
describe '#recipes' do
|
81
|
-
it 'prints a list of available recipes' do
|
82
|
-
@logger.should_receive(:log).exactly(2).times
|
83
|
-
@base.recipes
|
84
|
-
end
|
85
|
-
end
|
86
|
-
|
87
|
-
describe '#post_receive' do
|
88
|
-
|
89
|
-
it 'instantiates a new remote and calls its post_receive method' do
|
90
|
-
Blazing::Target.should_receive(:post_receive).with(@some_target_name)
|
91
|
-
@base.post_receive(@some_target_name)
|
92
|
-
end
|
93
|
-
end
|
94
|
-
end
|
@@ -1,27 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'blazing'
|
3
|
-
require 'blazing/cli/create'
|
4
|
-
|
5
|
-
describe Blazing::CLI::Create do
|
6
|
-
|
7
|
-
before :each do
|
8
|
-
@logger = double('logger', :log => nil, :report => nil)
|
9
|
-
@config_generator = Blazing::CLI::Create.new(['repository_url'])
|
10
|
-
@config_generator.instance_variable_set('@logger', @logger)
|
11
|
-
end
|
12
|
-
|
13
|
-
it 'knows the source root for its tempate' do
|
14
|
-
Blazing::CLI::Create.source_root.should == File.dirname(__FILE__).gsub('spec', 'lib')
|
15
|
-
end
|
16
|
-
|
17
|
-
it 'creates an empty directory for the config file' do
|
18
|
-
@config_generator.should_receive(:empty_directory).with(Blazing::DIRECTORY)
|
19
|
-
@config_generator.create_blazing_dir
|
20
|
-
end
|
21
|
-
|
22
|
-
it 'creates the config file' do
|
23
|
-
@config_generator.should_receive(:template).with('templates/blazing.tt', Blazing::CONFIGURATION_FILE)
|
24
|
-
@config_generator.create_config_file
|
25
|
-
end
|
26
|
-
|
27
|
-
end
|
@@ -1,16 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'blazing/cli/hook'
|
3
|
-
|
4
|
-
describe Blazing::CLI::Hook do
|
5
|
-
|
6
|
-
it 'knows the source root for its tempate' do
|
7
|
-
Blazing::CLI::Hook.source_root.should == File.dirname(__FILE__).gsub('spec', 'lib')
|
8
|
-
end
|
9
|
-
|
10
|
-
it 'genereates the hook template in the correct location' do
|
11
|
-
@hook = Blazing::CLI::Hook.new(['test_target'])
|
12
|
-
@hook.should_receive(:template).with('templates/post-hook.tt', '/tmp/post-receive')
|
13
|
-
@hook.generate
|
14
|
-
end
|
15
|
-
|
16
|
-
end
|