gitpusshuten 0.0.1
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/.bundle/config +2 -0
- data/.gitignore +4 -0
- data/Gemfile +9 -0
- data/Gemfile.lock +53 -0
- data/README.md +7 -0
- data/bin/gitpusshuten +4 -0
- data/bin/heavenly +4 -0
- data/bin/ten +4 -0
- data/gitpusshuten.gemspec +26 -0
- data/lib/gitpusshuten/cli.rb +78 -0
- data/lib/gitpusshuten/command.rb +147 -0
- data/lib/gitpusshuten/commands/base.rb +246 -0
- data/lib/gitpusshuten/commands/delete.rb +27 -0
- data/lib/gitpusshuten/commands/help.rb +36 -0
- data/lib/gitpusshuten/commands/initialize.rb +61 -0
- data/lib/gitpusshuten/commands/push.rb +54 -0
- data/lib/gitpusshuten/commands/remote.rb +29 -0
- data/lib/gitpusshuten/commands/user.rb +252 -0
- data/lib/gitpusshuten/commands/version.rb +21 -0
- data/lib/gitpusshuten/configuration.rb +122 -0
- data/lib/gitpusshuten/environment.rb +70 -0
- data/lib/gitpusshuten/gem.rb +33 -0
- data/lib/gitpusshuten/git.rb +111 -0
- data/lib/gitpusshuten/helpers/environment/installers.rb +59 -0
- data/lib/gitpusshuten/helpers/environment/packages.rb +21 -0
- data/lib/gitpusshuten/helpers/environment/scp.rb +57 -0
- data/lib/gitpusshuten/helpers/environment/ssh.rb +77 -0
- data/lib/gitpusshuten/helpers/environment/ssh_key.rb +79 -0
- data/lib/gitpusshuten/helpers/environment/user.rb +70 -0
- data/lib/gitpusshuten/helpers/spinner.rb +98 -0
- data/lib/gitpusshuten/hook.rb +26 -0
- data/lib/gitpusshuten/hooks.rb +147 -0
- data/lib/gitpusshuten/initializer.rb +95 -0
- data/lib/gitpusshuten/local.rb +35 -0
- data/lib/gitpusshuten/log.rb +83 -0
- data/lib/gitpusshuten/modules/active_record/hooks.rb +19 -0
- data/lib/gitpusshuten/modules/apache/command.rb +354 -0
- data/lib/gitpusshuten/modules/bundler/command.rb +43 -0
- data/lib/gitpusshuten/modules/bundler/hooks.rb +8 -0
- data/lib/gitpusshuten/modules/mysql/command.rb +192 -0
- data/lib/gitpusshuten/modules/nanoc/hooks.rb +9 -0
- data/lib/gitpusshuten/modules/nginx/command.rb +447 -0
- data/lib/gitpusshuten/modules/passenger/command.rb +310 -0
- data/lib/gitpusshuten/modules/passenger/hooks.rb +4 -0
- data/lib/gitpusshuten/modules/rvm/command.rb +277 -0
- data/lib/gitpusshuten.rb +21 -0
- data/lib/templates/config.rb +37 -0
- data/lib/templates/hooks.rb +40 -0
- data/spec/cli_spec.rb +83 -0
- data/spec/command_spec.rb +76 -0
- data/spec/configuration_spec.rb +45 -0
- data/spec/environment_spec.rb +64 -0
- data/spec/fixtures/combined_hooks.rb +23 -0
- data/spec/fixtures/config.rb +23 -0
- data/spec/fixtures/hooks.rb +37 -0
- data/spec/fixtures/passenger.json +1 -0
- data/spec/gem_spec.rb +28 -0
- data/spec/git_spec.rb +59 -0
- data/spec/gitpusshuten_spec.rb +9 -0
- data/spec/hook_spec.rb +48 -0
- data/spec/hooks_spec.rb +150 -0
- data/spec/initializer_spec.rb +26 -0
- data/spec/log_spec.rb +20 -0
- data/spec/spec_helper.rb +43 -0
- metadata +220 -0
data/.bundle/config
ADDED
data/.gitignore
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
gitpusshuten (0.0.1)
|
5
|
+
activesupport (~> 3.0.0)
|
6
|
+
highline (~> 1.6.0)
|
7
|
+
json (~> 1.4.0)
|
8
|
+
net-scp (~> 1.0.0)
|
9
|
+
net-ssh (~> 2.0.0)
|
10
|
+
rainbow (~> 1.1.0)
|
11
|
+
|
12
|
+
GEM
|
13
|
+
remote: http://rubygems.org/
|
14
|
+
specs:
|
15
|
+
activesupport (3.0.1)
|
16
|
+
diff-lcs (1.1.2)
|
17
|
+
highline (1.6.1)
|
18
|
+
infinity_test (0.2.0)
|
19
|
+
watchr (>= 0.7)
|
20
|
+
json (1.4.6)
|
21
|
+
mocha (0.9.8)
|
22
|
+
rake
|
23
|
+
net-scp (1.0.4)
|
24
|
+
net-ssh (>= 1.99.1)
|
25
|
+
net-ssh (2.0.23)
|
26
|
+
rainbow (1.1)
|
27
|
+
rake (0.8.7)
|
28
|
+
rspec (2.0.1)
|
29
|
+
rspec-core (~> 2.0.1)
|
30
|
+
rspec-expectations (~> 2.0.1)
|
31
|
+
rspec-mocks (~> 2.0.1)
|
32
|
+
rspec-core (2.0.1)
|
33
|
+
rspec-expectations (2.0.1)
|
34
|
+
diff-lcs (>= 1.1.2)
|
35
|
+
rspec-mocks (2.0.1)
|
36
|
+
rspec-core (~> 2.0.1)
|
37
|
+
rspec-expectations (~> 2.0.1)
|
38
|
+
watchr (0.7)
|
39
|
+
|
40
|
+
PLATFORMS
|
41
|
+
ruby
|
42
|
+
|
43
|
+
DEPENDENCIES
|
44
|
+
activesupport (~> 3.0.0)
|
45
|
+
gitpusshuten!
|
46
|
+
highline (~> 1.6.0)
|
47
|
+
infinity_test
|
48
|
+
json (~> 1.4.0)
|
49
|
+
mocha
|
50
|
+
net-scp (~> 1.0.0)
|
51
|
+
net-ssh (~> 2.0.0)
|
52
|
+
rainbow (~> 1.1.0)
|
53
|
+
rspec
|
data/README.md
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
Git Pusshuten ( プッシュ点 )
|
2
|
+
|
3
|
+
Heavenly Git-based (Application) Deployment!
|
4
|
+
|
5
|
+
Visit [Git Pusshuten's Official Website](http://gitpusshuten.com/) for documentation, guides and other information!
|
6
|
+
|
7
|
+
"Git Pusshuten's Official Website" is also [open source](https://github.com/meskyanichi/gitpusshuten-website)!
|
data/bin/gitpusshuten
ADDED
data/bin/heavenly
ADDED
data/bin/ten
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
Gem::Specification.new do |gem|
|
2
|
+
|
3
|
+
gem.name = 'gitpusshuten'
|
4
|
+
gem.version = '0.0.1'
|
5
|
+
gem.platform = Gem::Platform::RUBY
|
6
|
+
gem.authors = 'Michael van Rooijen'
|
7
|
+
gem.email = 'meskyanichi@gmail.com'
|
8
|
+
gem.homepage = 'http://gitpusshuten.com/'
|
9
|
+
gem.summary = 'Heavenly Git-based Application Deployment.'
|
10
|
+
gem.description = 'A Git-based application deployment tool that allows you to define your environment
|
11
|
+
by utilizing modules and provision your server with basic deployment needs.'
|
12
|
+
|
13
|
+
gem.files = %x[git ls-files].split("\n")
|
14
|
+
gem.test_files = %x[git ls-files -- {spec}/*].split("\n")
|
15
|
+
gem.require_path = 'lib'
|
16
|
+
|
17
|
+
gem.executables = ['gitpusshuten', 'heavenly', 'ten']
|
18
|
+
|
19
|
+
gem.add_dependency 'rainbow', ['~> 1.1.0']
|
20
|
+
gem.add_dependency 'highline', ['~> 1.6.0']
|
21
|
+
gem.add_dependency 'net-ssh', ['~> 2.0.0']
|
22
|
+
gem.add_dependency 'net-scp', ['~> 1.0.0']
|
23
|
+
gem.add_dependency 'activesupport', ['~> 3.0.0']
|
24
|
+
gem.add_dependency 'json', ['~> 1.4.0']
|
25
|
+
|
26
|
+
end
|
@@ -0,0 +1,78 @@
|
|
1
|
+
module GitPusshuTen
|
2
|
+
class CLI
|
3
|
+
|
4
|
+
##
|
5
|
+
# Arguments
|
6
|
+
attr_accessor :arguments
|
7
|
+
|
8
|
+
##
|
9
|
+
# Environment
|
10
|
+
attr_accessor :environment
|
11
|
+
|
12
|
+
##
|
13
|
+
# Command
|
14
|
+
attr_accessor :command
|
15
|
+
|
16
|
+
def initialize(*args)
|
17
|
+
|
18
|
+
##
|
19
|
+
# Clean up arguments
|
20
|
+
@arguments = args.flatten.uniq.compact.map(&:strip)
|
21
|
+
|
22
|
+
##
|
23
|
+
# If the arguments match the following pattern, it'll simply assign
|
24
|
+
# the variables accordingly
|
25
|
+
if @arguments.join(' ') =~ /(\w+\-?\w*) (.+) (for|to|from|on) (\w+)(.+)?/
|
26
|
+
@command = $1
|
27
|
+
@arguments = $2.split(' ')
|
28
|
+
@environment = $4.to_sym
|
29
|
+
|
30
|
+
##
|
31
|
+
# Allows for more arguments to be passed in after the regular expression.
|
32
|
+
# These arguments will be converted to an array and apended to the "@arguments" array
|
33
|
+
if $5.is_a?(String)
|
34
|
+
@arguments += $5.split(' ')
|
35
|
+
end
|
36
|
+
return
|
37
|
+
end
|
38
|
+
|
39
|
+
##
|
40
|
+
# If the arguments match the following pattern, it'll assign the variables
|
41
|
+
# and check check if the last argument in the array of @arguments is a
|
42
|
+
# "for", "to", "from" or "on" string value, and deletes it if it is
|
43
|
+
if @arguments.join(' ') =~ /(\w+\-?\w*) (.+) (\w+) environment/
|
44
|
+
@command = $1
|
45
|
+
@arguments = $2.split(' ')
|
46
|
+
@environment = $3.to_sym
|
47
|
+
|
48
|
+
##
|
49
|
+
# Clean up any for/to/from/on if it's the last argument
|
50
|
+
# of the @arguments array since that'd be part of the CLI
|
51
|
+
if %w[for to from on].include? @arguments.last
|
52
|
+
@arguments.delete_at(@arguments.count - 1)
|
53
|
+
end
|
54
|
+
return
|
55
|
+
end
|
56
|
+
|
57
|
+
##
|
58
|
+
# If no arguments are specified it'll just take the command,
|
59
|
+
# set the arguments to an empty array and set the environment
|
60
|
+
if @arguments.join(' ') =~ /(\w+\-?\w*) (.+) (\w+)$/
|
61
|
+
@command = $1
|
62
|
+
@arguments = []
|
63
|
+
@environment = $2.to_sym
|
64
|
+
return
|
65
|
+
end
|
66
|
+
|
67
|
+
##
|
68
|
+
# If only a command and one or more arguments are specified,
|
69
|
+
# without an environment, the regular expression below is matched.
|
70
|
+
if @arguments.join(' ') =~ /(\w+\-?\w*) (.+)$/
|
71
|
+
@command = $1
|
72
|
+
@arguments = $2.split(' ')
|
73
|
+
return
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
end
|
78
|
+
end
|
@@ -0,0 +1,147 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
module GitPusshuTen
|
4
|
+
class Command
|
5
|
+
|
6
|
+
##
|
7
|
+
# Contains an array of blacklisted commands
|
8
|
+
# These are files that aren't actually CLI commands but just
|
9
|
+
# classes that are used by Git プ ッ シ ュ 天
|
10
|
+
BLACKLISTED = %w[base]
|
11
|
+
|
12
|
+
##
|
13
|
+
# Command-line Interface
|
14
|
+
attr_accessor :cli
|
15
|
+
|
16
|
+
##
|
17
|
+
# Configuration (Environment)
|
18
|
+
attr_accessor :configuration
|
19
|
+
|
20
|
+
##
|
21
|
+
# Contains pre/post-deployment hooks
|
22
|
+
attr_accessor :hooks
|
23
|
+
|
24
|
+
##
|
25
|
+
# Environment connection
|
26
|
+
attr_accessor :environment
|
27
|
+
|
28
|
+
##
|
29
|
+
# Initializes the specified command if it exists or
|
30
|
+
# errors out when it does not exist in the commands/*.rb
|
31
|
+
def initialize(cli, configuration, hooks, environment)
|
32
|
+
@cli = cli
|
33
|
+
@configuration = configuration
|
34
|
+
@hooks = hooks
|
35
|
+
@environment = environment
|
36
|
+
|
37
|
+
if cli.command.nil?
|
38
|
+
display_commands
|
39
|
+
exit
|
40
|
+
end
|
41
|
+
|
42
|
+
unless available_commands.include?(cli.command)
|
43
|
+
GitPusshuTen::Log.error "Command <#{cli.command.color(:red)}> not found."
|
44
|
+
exit
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
##
|
49
|
+
# Performs the target command, based on the CLI and Configuration
|
50
|
+
def perform!
|
51
|
+
%w[validate! pre_perform! perform! post_perform!].each do |action|
|
52
|
+
command.send(action)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
##
|
57
|
+
# Wrapper for the command instance
|
58
|
+
def command
|
59
|
+
@command ||= "GitPusshuTen::Commands::#{cli.command.classify}".constantize.new(cli, configuration, hooks, environment)
|
60
|
+
end
|
61
|
+
|
62
|
+
##
|
63
|
+
# Returns an array of available commands
|
64
|
+
def available_commands
|
65
|
+
commands = commands_directory.map do |command|
|
66
|
+
unless blacklisted?(command)
|
67
|
+
find(command)
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
if configuration.respond_to?(:additional_modules)
|
72
|
+
module_directory.each do |command|
|
73
|
+
configuration.additional_modules.each do |additional_module|
|
74
|
+
if command =~ /\/modules\/(#{additional_module})\/command\.rb/
|
75
|
+
commands << $1
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
commands.flatten.compact.uniq
|
82
|
+
end
|
83
|
+
|
84
|
+
##
|
85
|
+
# Returns the absolute path to each command (ruby file)
|
86
|
+
# insidethe commands directory and returns an array of each entry
|
87
|
+
def commands_directory
|
88
|
+
Dir[File.expand_path(File.join(File.dirname(__FILE__), 'commands/*.rb'))]
|
89
|
+
end
|
90
|
+
|
91
|
+
def module_directory
|
92
|
+
Dir[File.expand_path(File.join(File.dirname(__FILE__), 'modules', '*', 'command.rb'))]
|
93
|
+
end
|
94
|
+
|
95
|
+
##
|
96
|
+
# Determines whether the provided command is blacklisted or not
|
97
|
+
def blacklisted?(command)
|
98
|
+
BLACKLISTED.include?(find(command))
|
99
|
+
end
|
100
|
+
|
101
|
+
##
|
102
|
+
# Expects a (full) path to the command ruby file and returns
|
103
|
+
# only the file name without the .rb extension
|
104
|
+
def find(command)
|
105
|
+
command.gsub(/\.rb/, '').split('/').last
|
106
|
+
end
|
107
|
+
|
108
|
+
##
|
109
|
+
# Displays a list of available commands in the CLI
|
110
|
+
def display_commands
|
111
|
+
puts "\nGit Pusshu Ten\n\s\s\s\sプッシュ点\n\n"
|
112
|
+
puts "[Aliases]\n\n"
|
113
|
+
puts "\s\s#{y('gitpusshuten')}, #{y('heavenly')}, #{y('ten')}\n\n"
|
114
|
+
puts "[Commands]\n\n"
|
115
|
+
available_commands.compact.sort.each do |command|
|
116
|
+
puts "\s\s" + y(command) + (command.length < 6 ? "\t" : "") + "\t" + get_constant_for(command).description
|
117
|
+
end
|
118
|
+
puts "\n[Command Specific Help]\n\n" + "\s\sheavenly help <command>\n".color(:yellow)
|
119
|
+
puts "For more information, visit: #{y 'http://gitpusshuten.com/'}"
|
120
|
+
end
|
121
|
+
|
122
|
+
##
|
123
|
+
# Displays command specific details in the CLI
|
124
|
+
def display_usage(command)
|
125
|
+
puts "\nGit Pusshu Ten\n\s\s\s\sプッシュ点\n\n"
|
126
|
+
puts "[Command]\n\n\s\s#{y(command)}\n\n"
|
127
|
+
puts "[Description]\n\n\s\s#{get_constant_for(command).description}\n\n"
|
128
|
+
puts "[Usage]\n\n\s\s#{y get_constant_for(command).usage}\n\n"
|
129
|
+
puts "[Examples]\n#{get_constant_for(command).example}\n\n"
|
130
|
+
puts "For a list of all commands: #{y 'heavenly help'}"
|
131
|
+
puts "For more information, visit: #{y 'http://gitpusshuten.com/'}"
|
132
|
+
end
|
133
|
+
|
134
|
+
##
|
135
|
+
# Returns the constant of a command
|
136
|
+
def get_constant_for(command)
|
137
|
+
"GitPusshuTen::Commands::#{command.classify}".constantize
|
138
|
+
end
|
139
|
+
|
140
|
+
##
|
141
|
+
# Wrapper for coloring text yellow
|
142
|
+
def y(value)
|
143
|
+
value.to_s.color(:yellow)
|
144
|
+
end
|
145
|
+
|
146
|
+
end
|
147
|
+
end
|
@@ -0,0 +1,246 @@
|
|
1
|
+
module GitPusshuTen
|
2
|
+
module Commands
|
3
|
+
class Base
|
4
|
+
|
5
|
+
##
|
6
|
+
# Command-line Interface
|
7
|
+
attr_accessor :cli
|
8
|
+
|
9
|
+
##
|
10
|
+
# Configuration (Environment)
|
11
|
+
attr_accessor :configuration
|
12
|
+
|
13
|
+
##
|
14
|
+
# Stores the pre and post deploy hooks
|
15
|
+
attr_accessor :hooks
|
16
|
+
|
17
|
+
##
|
18
|
+
# Environment connection
|
19
|
+
attr_accessor :environment
|
20
|
+
|
21
|
+
##
|
22
|
+
# Contains the invoked command
|
23
|
+
attr_accessor :command
|
24
|
+
|
25
|
+
##
|
26
|
+
# This is a flag, that, when set to true, will invoke the
|
27
|
+
# potentially specified deployment hooks. When "perform_hooks"
|
28
|
+
# is set to false, deployment hooks will not be invoked. This is the default
|
29
|
+
# behavior. If hooks should be enabled for a specific command, invoke the
|
30
|
+
# "perform_hooks!" command from within the "initialize" method of that particular command
|
31
|
+
attr_accessor :perform_hooks
|
32
|
+
alias :perform_hooks? :perform_hooks
|
33
|
+
|
34
|
+
##
|
35
|
+
# This is used by the "help" command to display the
|
36
|
+
# description of the command in the CLI
|
37
|
+
def self.description(value = nil)
|
38
|
+
if value.nil?
|
39
|
+
@description
|
40
|
+
else
|
41
|
+
@description = value
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
##
|
46
|
+
# This is used by the "help" command to display the
|
47
|
+
# usage of the command in the CLI
|
48
|
+
def self.usage(value = nil)
|
49
|
+
if value.nil?
|
50
|
+
@usage
|
51
|
+
else
|
52
|
+
@usage = value
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
##
|
57
|
+
# This is used by the "help" command to display an
|
58
|
+
# example of the command in the CLI
|
59
|
+
def self.example(value = nil)
|
60
|
+
if value.nil?
|
61
|
+
@example
|
62
|
+
else
|
63
|
+
@example ||= ""
|
64
|
+
@example << "\n\s\s#{value}"
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
##
|
69
|
+
# Sets the "perform_hooks" flag to "true"
|
70
|
+
def perform_hooks!
|
71
|
+
@perform_hooks = true
|
72
|
+
end
|
73
|
+
|
74
|
+
##
|
75
|
+
# Displays the help screen for the current command
|
76
|
+
def help
|
77
|
+
command_object.display_usage(cli.command)
|
78
|
+
exit
|
79
|
+
end
|
80
|
+
|
81
|
+
##
|
82
|
+
# Contains an instance of the command object
|
83
|
+
def command_object
|
84
|
+
@command_object ||= GitPusshuTen::Command.new(cli, configuration, hooks, environment)
|
85
|
+
end
|
86
|
+
|
87
|
+
##
|
88
|
+
# Git object wrapper
|
89
|
+
def git
|
90
|
+
@git ||= GitPusshuTen::Git.new
|
91
|
+
end
|
92
|
+
|
93
|
+
##
|
94
|
+
# Local object wrapper
|
95
|
+
def local
|
96
|
+
@local ||= GitPusshuTen::Local.new
|
97
|
+
end
|
98
|
+
|
99
|
+
##
|
100
|
+
# Wrapper for the configuration object
|
101
|
+
def c
|
102
|
+
configuration
|
103
|
+
end
|
104
|
+
|
105
|
+
##
|
106
|
+
# Wrapper for the environment object
|
107
|
+
def e
|
108
|
+
environment
|
109
|
+
end
|
110
|
+
|
111
|
+
##
|
112
|
+
# Wrapper for coloring ANSI/CLI Green
|
113
|
+
def g(value)
|
114
|
+
value.to_s.color(:green)
|
115
|
+
end
|
116
|
+
|
117
|
+
##
|
118
|
+
# Wrapper for coloring ANSI/CLI Yellow
|
119
|
+
def y(value)
|
120
|
+
value.to_s.color(:yellow)
|
121
|
+
end
|
122
|
+
|
123
|
+
##
|
124
|
+
# Wrapper for coloring ANSI/CLI Red
|
125
|
+
def r(value)
|
126
|
+
value.to_s.color(:red)
|
127
|
+
end
|
128
|
+
|
129
|
+
##
|
130
|
+
# Helper method for prompting the user
|
131
|
+
def yes?
|
132
|
+
choose do |menu|
|
133
|
+
menu.prompt = ''
|
134
|
+
menu.choice('yes') { true }
|
135
|
+
menu.choice('no') { false }
|
136
|
+
end
|
137
|
+
end
|
138
|
+
|
139
|
+
##
|
140
|
+
# Shorthand for creating standard messages
|
141
|
+
def standard(text)
|
142
|
+
GitPusshuTen::Log.standard(text)
|
143
|
+
end
|
144
|
+
|
145
|
+
##
|
146
|
+
# Shorthand for creating normal messages
|
147
|
+
def message(text)
|
148
|
+
GitPusshuTen::Log.message(text)
|
149
|
+
end
|
150
|
+
|
151
|
+
##
|
152
|
+
# Shorthand for creating warning messages
|
153
|
+
def warning(text)
|
154
|
+
GitPusshuTen::Log.warning(text)
|
155
|
+
end
|
156
|
+
|
157
|
+
##
|
158
|
+
# Shorthand for creating error messages
|
159
|
+
def error(text)
|
160
|
+
GitPusshuTen::Log.error(text)
|
161
|
+
end
|
162
|
+
|
163
|
+
##
|
164
|
+
# Shorthand for silently creating logs
|
165
|
+
def silent(text)
|
166
|
+
GitPusshuTen::Log.silent(text)
|
167
|
+
end
|
168
|
+
|
169
|
+
##
|
170
|
+
# Initialize a new command
|
171
|
+
def initialize(cli, configuration, hooks, environment)
|
172
|
+
@cli = cli
|
173
|
+
@configuration = configuration
|
174
|
+
@hooks = hooks
|
175
|
+
@environment = environment
|
176
|
+
@perform_hooks = false
|
177
|
+
end
|
178
|
+
|
179
|
+
##
|
180
|
+
# Performs one of the commands inside a command class
|
181
|
+
def perform!
|
182
|
+
send("perform_#{command}!")
|
183
|
+
end
|
184
|
+
|
185
|
+
##
|
186
|
+
# Validates if the method that's about to be invoked actually exists
|
187
|
+
def validate!
|
188
|
+
if not respond_to?("perform_#{command}!")
|
189
|
+
type = self.class.to_s.split("::").last.downcase
|
190
|
+
error "Unknown #{y(type)} command: <#{r(command)}>"
|
191
|
+
error "Run #{y("gitpusshuten help #{type}")} for a list #{y(type)} commands."
|
192
|
+
exit
|
193
|
+
end
|
194
|
+
end
|
195
|
+
|
196
|
+
##
|
197
|
+
# The Pre-perform command
|
198
|
+
# It should be invoked before the #perform! command
|
199
|
+
def pre_perform!
|
200
|
+
return unless perform_hooks?
|
201
|
+
unless hooks.pre_hooks.any?
|
202
|
+
GitPusshuTen::Log.message "No pre deploy hooks to perform."
|
203
|
+
return
|
204
|
+
end
|
205
|
+
|
206
|
+
##
|
207
|
+
# Connect to the remote environment and perform the pre deploy hooks
|
208
|
+
hooks.render_commands(hooks.pre_hooks).each do |name, commands|
|
209
|
+
GitPusshuTen::Log.message("Performing pre deploy hook: #{y(name)}")
|
210
|
+
standard environment.execute_as_user("cd '#{e.app_dir}'; #{commands}")
|
211
|
+
end
|
212
|
+
end
|
213
|
+
|
214
|
+
##
|
215
|
+
# The Post-perform command
|
216
|
+
# It should be invoked after the #perform! command
|
217
|
+
def post_perform!
|
218
|
+
return unless perform_hooks?
|
219
|
+
unless hooks.post_hooks.any?
|
220
|
+
GitPusshuTen::Log.message "No post deploy hooks to perform."
|
221
|
+
return
|
222
|
+
end
|
223
|
+
|
224
|
+
##
|
225
|
+
# Connect to the remote environment and perform the post deploy hooks
|
226
|
+
hooks.render_commands(hooks.post_hooks).each do |name, commands|
|
227
|
+
GitPusshuTen::Log.message("Performing post deploy hook: #{y(name)}")
|
228
|
+
standard environment.execute_as_user("cd '#{e.app_dir}'; #{commands}")
|
229
|
+
end
|
230
|
+
end
|
231
|
+
|
232
|
+
##
|
233
|
+
# Makes the user authenticate itself as root
|
234
|
+
def prompt_for_root_password!
|
235
|
+
e.execute_as_root('')
|
236
|
+
end
|
237
|
+
|
238
|
+
##
|
239
|
+
# Makes the user authenticate itself as a user
|
240
|
+
def prompt_for_user_password!
|
241
|
+
e.execute_as_user('')
|
242
|
+
end
|
243
|
+
|
244
|
+
end
|
245
|
+
end
|
246
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module GitPusshuTen
|
2
|
+
module Commands
|
3
|
+
class Delete < GitPusshuTen::Commands::Base
|
4
|
+
description "Deletes the application of the specified environment."
|
5
|
+
usage "delete <environment> environment"
|
6
|
+
example "heavenly delete staging environment # Deletes the application in the staging environment."
|
7
|
+
example "heavenly delete production environment # Deletes the application in the production environment."
|
8
|
+
|
9
|
+
def initialize(*objects)
|
10
|
+
super
|
11
|
+
|
12
|
+
help if e.name.nil?
|
13
|
+
end
|
14
|
+
|
15
|
+
##
|
16
|
+
# Deletes the application directory from the remote server
|
17
|
+
def perform_!
|
18
|
+
message "Are you sure you wish to delete #{y(c.application)} from the #{y(e.name)} environment (#{y(c.ip)})?"
|
19
|
+
if yes?
|
20
|
+
message "Deleting #{y(c.application)}."
|
21
|
+
e.delete!
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
module GitPusshuTen
|
2
|
+
module Commands
|
3
|
+
class Help < GitPusshuTen::Commands::Base
|
4
|
+
description "Displays the command list, or the help screen for a specific command."
|
5
|
+
usage "help | help <command>"
|
6
|
+
example "heavenly help # Displays the main help screen."
|
7
|
+
example "heavenly help initialize # Displays the help screen for the initialize command."
|
8
|
+
example "heavenly help setup # Displays the help screen for the setup command."
|
9
|
+
example "heavenly help tag # Displays the help screen for the tag command."
|
10
|
+
|
11
|
+
attr_accessor :command_name
|
12
|
+
|
13
|
+
def initialize(*objects)
|
14
|
+
super
|
15
|
+
|
16
|
+
@command_name = cli.arguments.shift
|
17
|
+
end
|
18
|
+
|
19
|
+
##
|
20
|
+
# Displays the help screen if no arguments are specified
|
21
|
+
# Displays the help screen for a particular command if an argument is specified
|
22
|
+
def perform_!
|
23
|
+
if command_name.nil?
|
24
|
+
command_object.display_commands
|
25
|
+
else
|
26
|
+
if command_object.available_commands.include?(command_name)
|
27
|
+
command_object.display_usage(command_name)
|
28
|
+
else
|
29
|
+
error "Command <#{r(command_name)}> not found."
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|