mina 0.3.8 → 1.0.0.beta1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.codeclimate.yml +16 -0
- data/.gitignore +0 -1
- data/.rubocop.yml +1156 -0
- data/Gemfile +2 -8
- data/{CHANGELOG.md → PRE_1_CHANGELOG.md} +0 -0
- data/Rakefile +2 -18
- data/Readme.md +39 -1116
- data/bin/mina +1 -62
- data/data/deploy.rb +19 -46
- data/data/deploy.sh.erb +22 -23
- data/docs/Readme.md +8 -0
- data/docs/command_line_options.md +33 -0
- data/docs/deploying.md +97 -0
- data/docs/faq.md +1 -0
- data/docs/getting_started.md +44 -0
- data/docs/migrating.md +30 -0
- data/docs/writing_your_own_tasks.md +117 -0
- data/lib/Minafile +3 -0
- data/lib/mina.rb +30 -18
- data/lib/mina/application.rb +74 -0
- data/lib/mina/backend/local.rb +22 -0
- data/lib/mina/backend/remote.rb +42 -0
- data/lib/mina/commands.rb +45 -0
- data/lib/mina/configuration.rb +36 -0
- data/lib/mina/dsl.rb +47 -0
- data/lib/mina/helpers/internal.rb +29 -0
- data/lib/mina/helpers/output.rb +42 -0
- data/lib/mina/runner.rb +39 -0
- data/lib/mina/runner/exec.rb +15 -0
- data/lib/mina/runner/pretty.rb +53 -0
- data/lib/mina/runner/printer.rb +17 -0
- data/lib/mina/runner/system.rb +15 -0
- data/lib/mina/version.rb +1 -3
- data/mina.gemspec +27 -16
- data/spec/lib/mina/application_spec.rb +39 -0
- data/spec/lib/mina/backend/local_spec.rb +16 -0
- data/spec/lib/mina/backend/remote_spec.rb +17 -0
- data/spec/lib/mina/commands_spec.rb +93 -0
- data/spec/lib/mina/configuration_spec.rb +52 -0
- data/spec/lib/mina/helpers/internal_spec.rb +50 -0
- data/spec/lib/mina/helpers/output_spec.rb +48 -0
- data/spec/lib/mina/runner_spec.rb +36 -0
- data/spec/lib/mina_spec.rb +7 -0
- data/spec/spec_helper.rb +13 -21
- data/spec/support/run_helper.rb +36 -0
- data/tasks/mina/bundler.rb +15 -0
- data/tasks/mina/chruby.rb +19 -0
- data/tasks/mina/default.rb +36 -0
- data/tasks/mina/deploy.rb +85 -0
- data/tasks/mina/git.rb +36 -0
- data/tasks/mina/install.rb +18 -0
- data/tasks/mina/rails.rb +108 -0
- data/tasks/mina/rbenv.rb +15 -0
- data/tasks/mina/rvm.rb +39 -0
- data/tasks/mina/ry.rb +26 -0
- data/test_env/config/deploy.rb +44 -72
- metadata +82 -59
- data/.travis.yml +0 -21
- data/CONTRIBUTING.md +0 -124
- data/HISTORY.md +0 -394
- data/Makefile +0 -32
- data/Notes.md +0 -70
- data/lib/mina/bundler.rb +0 -49
- data/lib/mina/chruby.rb +0 -49
- data/lib/mina/default.rb +0 -158
- data/lib/mina/deploy.rb +0 -160
- data/lib/mina/deploy_helpers.rb +0 -34
- data/lib/mina/exec_helpers.rb +0 -111
- data/lib/mina/foreman.rb +0 -83
- data/lib/mina/git.rb +0 -69
- data/lib/mina/helpers.rb +0 -408
- data/lib/mina/local_helpers.rb +0 -97
- data/lib/mina/npm.rb +0 -89
- data/lib/mina/output_helpers.rb +0 -92
- data/lib/mina/rails.rb +0 -245
- data/lib/mina/rake.rb +0 -10
- data/lib/mina/rbenv.rb +0 -47
- data/lib/mina/rvm.rb +0 -88
- data/lib/mina/ry.rb +0 -55
- data/lib/mina/settings.rb +0 -32
- data/lib/mina/ssh_helpers.rb +0 -125
- data/lib/mina/tools.rb +0 -20
- data/lib/mina/whenever.rb +0 -51
- data/manual/index.md +0 -15
- data/manual/modules.md +0 -2
- data/spec/command_helper.rb +0 -52
- data/spec/commands/cleanup_spec.rb +0 -16
- data/spec/commands/command_spec.rb +0 -71
- data/spec/commands/custom_config_spec.rb +0 -20
- data/spec/commands/deploy_spec.rb +0 -40
- data/spec/commands/outside_project_spec.rb +0 -35
- data/spec/commands/real_deploy_spec.rb +0 -56
- data/spec/commands/ssh_spec.rb +0 -14
- data/spec/commands/verbose_spec.rb +0 -21
- data/spec/dsl/invoke_spec.rb +0 -49
- data/spec/dsl/queue_spec.rb +0 -49
- data/spec/dsl/settings_in_rake_spec.rb +0 -39
- data/spec/dsl/settings_spec.rb +0 -61
- data/spec/dsl/to_spec.rb +0 -20
- data/spec/fixtures/custom_file_env/custom_deploy.rb +0 -15
- data/spec/fixtures/empty_env/config/deploy.rb +0 -15
- data/spec/helpers/exec_helper_spec.rb +0 -19
- data/spec/helpers/local_helper_spec.rb +0 -70
- data/spec/helpers/output_helper_spec.rb +0 -38
- data/support/Readme-footer.md +0 -31
- data/support/Readme-header.md +0 -16
- data/support/guide.md +0 -297
- data/support/index.html +0 -53
- data/support/third_party_modules.md +0 -23
- data/support/to_md.rb +0 -11
data/lib/mina/local_helpers.rb
DELETED
@@ -1,97 +0,0 @@
|
|
1
|
-
# # Helpers: Local helpers
|
2
|
-
# You don't need to invoke these helpers, they're already invoked automatically.
|
3
|
-
|
4
|
-
module Mina
|
5
|
-
module LocalHelpers
|
6
|
-
# ### local
|
7
|
-
# Executes a command.
|
8
|
-
#
|
9
|
-
# Returns nothing usually, but if `{ return: true }` is given, returns the
|
10
|
-
# STDOUT output.
|
11
|
-
#
|
12
|
-
# `options` is a hash of options:
|
13
|
-
#
|
14
|
-
# - `:pretty` - Prettify the output if true.
|
15
|
-
# - `:return` - If set to true, returns the output.
|
16
|
-
#
|
17
|
-
# Example
|
18
|
-
#
|
19
|
-
# local("ls", return: true)
|
20
|
-
|
21
|
-
def local(cmd, options = {})
|
22
|
-
script = cmd.join("\n") if cmd.is_a?(Array)
|
23
|
-
|
24
|
-
if options[:return] == true
|
25
|
-
`#{script}`
|
26
|
-
elsif simulate_mode?
|
27
|
-
Local.simulate(script)
|
28
|
-
else
|
29
|
-
result = Local.invoke(script, self)
|
30
|
-
Local.ensure_successful result, self
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
# ## Private methods
|
35
|
-
# `local` delegates to these.
|
36
|
-
|
37
|
-
module Local
|
38
|
-
extend self
|
39
|
-
|
40
|
-
# ### Local.simulate
|
41
|
-
# __Internal:__ Prints command.
|
42
|
-
|
43
|
-
def simulate(cmd)
|
44
|
-
str = "Executing the following:"
|
45
|
-
puts "#!/usr/bin/env bash"
|
46
|
-
puts "# #{str}"
|
47
|
-
puts "#"
|
48
|
-
|
49
|
-
puts cmd
|
50
|
-
|
51
|
-
0
|
52
|
-
end
|
53
|
-
|
54
|
-
# ### Local.invoke
|
55
|
-
# __Internal:__ Initiates an SSH session with script `script` with given
|
56
|
-
# `term_mode`. Called by `local`.
|
57
|
-
|
58
|
-
def invoke(script, this)
|
59
|
-
# Ruby 1.8.7 doesn't let you have empty symbols
|
60
|
-
term_mode = :"#{this.settings.term_mode}" if this.settings.term_mode
|
61
|
-
code = "#{script}"
|
62
|
-
|
63
|
-
# Certain environments can't do :pretty mode.
|
64
|
-
term_mode = :exec if term_mode == :pretty && !pretty_supported?
|
65
|
-
|
66
|
-
case term_mode
|
67
|
-
when :pretty
|
68
|
-
require 'shellwords'
|
69
|
-
code = Shellwords.escape(code)
|
70
|
-
this.pretty_system(code)
|
71
|
-
when :exec
|
72
|
-
Kernel.exec code
|
73
|
-
else
|
74
|
-
Kernel.system code
|
75
|
-
$?.exitstatus
|
76
|
-
end
|
77
|
-
end
|
78
|
-
|
79
|
-
# TODO: Move to concern
|
80
|
-
def pretty_supported?
|
81
|
-
# open4 is not supported under Windows.
|
82
|
-
# https://github.com/nadarei/mina/issues/58
|
83
|
-
require 'rbconfig'
|
84
|
-
! (RbConfig::CONFIG['host_os'] =~ /mswin|mingw/)
|
85
|
-
end
|
86
|
-
|
87
|
-
# ### Local.ensure_successful
|
88
|
-
# __Internal:__ Halts the execution if the given result code is not
|
89
|
-
# successful (non-zero).
|
90
|
-
|
91
|
-
def ensure_successful(result, this)
|
92
|
-
this.die result if result.is_a?(Fixnum) && result > 0
|
93
|
-
result
|
94
|
-
end
|
95
|
-
end
|
96
|
-
end
|
97
|
-
end
|
data/lib/mina/npm.rb
DELETED
@@ -1,89 +0,0 @@
|
|
1
|
-
# # Modules: Npm
|
2
|
-
# Adds settings and tasks for managing Node packages.
|
3
|
-
#
|
4
|
-
# require 'mina/npm'
|
5
|
-
|
6
|
-
# ## Settings
|
7
|
-
# Any and all of these settings can be overriden in your `deploy.rb`.
|
8
|
-
|
9
|
-
# ### npm_bin
|
10
|
-
# Sets the npm binary.
|
11
|
-
|
12
|
-
set_default :npm_bin, 'npm'
|
13
|
-
|
14
|
-
# ### bower_bin
|
15
|
-
# Sets the bower binary.
|
16
|
-
|
17
|
-
set_default :bower_bin, 'bower'
|
18
|
-
|
19
|
-
# ### grunt_bin
|
20
|
-
# Sets the grunt binary.
|
21
|
-
|
22
|
-
set_default :grunt_bin, 'grunt'
|
23
|
-
|
24
|
-
# ### npm_options
|
25
|
-
# Sets the options for installing modules via npm.
|
26
|
-
|
27
|
-
set_default :npm_options, '--production'
|
28
|
-
|
29
|
-
# ### bower_options
|
30
|
-
# Sets the options for installing modules via bower.
|
31
|
-
|
32
|
-
set_default :bower_options, '--allow-root'
|
33
|
-
|
34
|
-
# ### grunt_options
|
35
|
-
# Sets the options for grunt.
|
36
|
-
|
37
|
-
set_default :grunt_options, ''
|
38
|
-
|
39
|
-
# ### grunt_task
|
40
|
-
# Sets the task parameters for grunt.
|
41
|
-
|
42
|
-
set_default :grunt_task, 'build'
|
43
|
-
|
44
|
-
|
45
|
-
# ## Deploy tasks
|
46
|
-
# These tasks are meant to be invoked inside deploy scripts, not invoked on
|
47
|
-
# their own.
|
48
|
-
|
49
|
-
namespace :npm do
|
50
|
-
# ### npm:install
|
51
|
-
# Installs node modules. Takes into account if executed `in_directory` and namespaces the installed modules in the shared folder.
|
52
|
-
desc "Install node modules using Npm."
|
53
|
-
task :install => :environment do
|
54
|
-
queue %{
|
55
|
-
echo "-----> Installing node modules using Npm"
|
56
|
-
sub_directory=$(pwd | sed -r "s/.*?$(basename $build_path)//g")
|
57
|
-
#{echo_cmd %[mkdir -p "#{deploy_to}/#{shared_path}/$sub_directory/node_modules"]}
|
58
|
-
#{echo_cmd %[ln -s "#{deploy_to}/#{shared_path}/$sub_directory/node_modules" "node_modules"]}
|
59
|
-
#{echo_cmd %[#{npm_bin} install #{npm_options}]}
|
60
|
-
}
|
61
|
-
end
|
62
|
-
end
|
63
|
-
|
64
|
-
namespace :bower do
|
65
|
-
# ### bower:install
|
66
|
-
# Installs bower modules. Takes into account if executed `in_directory` and namespaces the installed modules in the shared folder.
|
67
|
-
desc "Install bower modules."
|
68
|
-
task :install => :environment do
|
69
|
-
queue %{
|
70
|
-
echo "-----> Installing bower modules"
|
71
|
-
sub_directory=$(pwd | sed -r "s/.*?$(basename $build_path)//g")
|
72
|
-
#{echo_cmd %[mkdir -p "#{deploy_to}/#{shared_path}/$sub_directory/bower_components"]}
|
73
|
-
#{echo_cmd %[ln -s "#{deploy_to}/#{shared_path}/$sub_directory/bower_components" "bower_components"]}
|
74
|
-
#{echo_cmd %[[ -f bower.json ] && (#{bower_bin} install #{bower_options}) || ! [ -f bower.json ]]}
|
75
|
-
}
|
76
|
-
end
|
77
|
-
end
|
78
|
-
|
79
|
-
namespace :grunt do
|
80
|
-
# ### grunt:install
|
81
|
-
# Launch a task with grunt. Set the grunt_task (defaults to \"build\") variable before calling this.
|
82
|
-
desc "Launch a task with grunt. Set the grunt_task (defaults to \"build\") variable before calling this."
|
83
|
-
task :task => :environment do
|
84
|
-
queue %{
|
85
|
-
echo "-----> Launch a build with Grunt"
|
86
|
-
#{echo_cmd %[[ -f Gruntfile.js ] && (#{grunt_bin} #{grunt_task} #{grunt_options}) || ! [ -f Gruntfile.js ]]}
|
87
|
-
}
|
88
|
-
end
|
89
|
-
end
|
data/lib/mina/output_helpers.rb
DELETED
@@ -1,92 +0,0 @@
|
|
1
|
-
# # Helpers: Output helpers
|
2
|
-
# Protip! make a module that overrides these settings, then use `extend YourModule`
|
3
|
-
# to make your own pretty printing thing.
|
4
|
-
module Mina
|
5
|
-
module OutputHelpers
|
6
|
-
|
7
|
-
# ### print_str
|
8
|
-
# Prints a string by delegating it to the proper output helper.
|
9
|
-
#
|
10
|
-
# It takes an input with text and prints them nicely. The text block can
|
11
|
-
# have statuses (prefixed with `-----> `), errors (prefixed with `! `),
|
12
|
-
# commands (prefixed with `$ `) or anything else. Depending on the type of
|
13
|
-
# the message, they will be delegated to the proper print_* helper.
|
14
|
-
#
|
15
|
-
# -----> Unlocking
|
16
|
-
# $ unlock foo
|
17
|
-
# Unlocked.
|
18
|
-
# ! ERROR: Failed
|
19
|
-
#
|
20
|
-
# Returns nothing.
|
21
|
-
#
|
22
|
-
def print_str(line)
|
23
|
-
if line =~ /^\-+> (.*?)$/
|
24
|
-
print_status $1
|
25
|
-
elsif line =~ /^! (.*?)$/
|
26
|
-
print_error $1
|
27
|
-
elsif line =~ /^\$ (.*?)$/
|
28
|
-
print_command $1
|
29
|
-
else
|
30
|
-
print_stdout line
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
# ### print_char
|
35
|
-
# Prints a single character.
|
36
|
-
def print_char(ch)
|
37
|
-
$last ||= ''
|
38
|
-
|
39
|
-
if ch == "\n"
|
40
|
-
print_clear
|
41
|
-
print_str $last
|
42
|
-
$last = ''
|
43
|
-
else
|
44
|
-
print ' ' if $last == ''
|
45
|
-
print ch
|
46
|
-
$last += ch
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
def print_clear
|
51
|
-
print "\033[1K\r"
|
52
|
-
end
|
53
|
-
|
54
|
-
# ### print_status
|
55
|
-
# Prints a status message. (`----->`)
|
56
|
-
def print_status(msg)
|
57
|
-
puts "" if verbose_mode?
|
58
|
-
puts "#{color('----->', 32)} #{msg}"
|
59
|
-
end
|
60
|
-
|
61
|
-
# ### print_error
|
62
|
-
# Prints an error message (header).
|
63
|
-
def print_error(msg)
|
64
|
-
puts " #{color("!", 33)} #{color(msg, 31)}"
|
65
|
-
end
|
66
|
-
|
67
|
-
# ### print_stderr
|
68
|
-
# Prints an error message (body), or prints stderr output.
|
69
|
-
def print_stderr(msg)
|
70
|
-
puts " #{color(msg, 31)}"
|
71
|
-
end
|
72
|
-
|
73
|
-
# ### print_command
|
74
|
-
# Prints a command.
|
75
|
-
def print_command(msg)
|
76
|
-
puts " #{color("$", 32)} #{color(msg, 32)}"
|
77
|
-
end
|
78
|
-
|
79
|
-
# ### print_stdout
|
80
|
-
# Prints a normal message.
|
81
|
-
def print_stdout(msg)
|
82
|
-
puts " #{msg}"
|
83
|
-
end
|
84
|
-
|
85
|
-
# ### color
|
86
|
-
# Colorizes a string.
|
87
|
-
# Returns the string `str` with the color `c`.
|
88
|
-
def color(str, c)
|
89
|
-
ENV['NO_COLOR'] ? str : "\033[#{c}m#{str}\033[0m"
|
90
|
-
end
|
91
|
-
end
|
92
|
-
end
|
data/lib/mina/rails.rb
DELETED
@@ -1,245 +0,0 @@
|
|
1
|
-
# # Modules: Rails
|
2
|
-
# Adds settings and tasks for managing Rails projects.
|
3
|
-
#
|
4
|
-
# require 'mina/rails'
|
5
|
-
|
6
|
-
require 'mina/bundler'
|
7
|
-
|
8
|
-
# ## Settings
|
9
|
-
# Any and all of these settings can be overriden in your `deploy.rb`.
|
10
|
-
|
11
|
-
# ### rails_env
|
12
|
-
# Sets the Rails environment for `rake` and `rails` commands.
|
13
|
-
#
|
14
|
-
# Note that changing this will NOT change the environment that your application
|
15
|
-
# is run in.
|
16
|
-
|
17
|
-
set_default :rails_env, 'production'
|
18
|
-
|
19
|
-
# ### bundle_prefix
|
20
|
-
# Prefix for Bundler commands. Often to something like `RAILS_ENV=production
|
21
|
-
# bundle exec`.
|
22
|
-
#
|
23
|
-
# queue! "#{bundle_prefix} annotate -r"
|
24
|
-
|
25
|
-
set_default :bundle_prefix, lambda { %{RAILS_ENV="#{rails_env}" #{bundle_bin} exec} }
|
26
|
-
|
27
|
-
# ### rake
|
28
|
-
# The prefix for `rake` commands. Use like so:
|
29
|
-
#
|
30
|
-
# queue! "#{rake} db:migrate"
|
31
|
-
|
32
|
-
set_default :rake, lambda { %{#{bundle_prefix} rake} }
|
33
|
-
|
34
|
-
# ### rails
|
35
|
-
# The prefix for `rails` commands. Use like so:
|
36
|
-
#
|
37
|
-
# queue! "#{rails} console"
|
38
|
-
|
39
|
-
set_default :rails, lambda { %{#{bundle_prefix} rails} }
|
40
|
-
|
41
|
-
# ### asset_paths
|
42
|
-
# The paths to be checked.
|
43
|
-
#
|
44
|
-
# Whenever assets are compiled, the asset files are checked if they have
|
45
|
-
# changed from the previous release.
|
46
|
-
#
|
47
|
-
# If they're unchanged, compiled assets will simply be copied over to the new
|
48
|
-
# release.
|
49
|
-
#
|
50
|
-
# Override this if you have custom asset paths declared in your Rails's
|
51
|
-
# `config.assets.paths` setting.
|
52
|
-
|
53
|
-
set_default :asset_paths, ['vendor/assets/', 'app/assets/']
|
54
|
-
|
55
|
-
# ### compiled_asset_path
|
56
|
-
# The path to be copied to the new release.
|
57
|
-
#
|
58
|
-
# The path your assets are compiled to. If your `assets_path` assets have changed,
|
59
|
-
# this is the folder that gets copied accross from the current release to the new release.
|
60
|
-
#
|
61
|
-
# Override this if you have custom public asset paths.
|
62
|
-
|
63
|
-
set_default :compiled_asset_path, 'public/assets'
|
64
|
-
|
65
|
-
# ### rake_assets_precompile
|
66
|
-
# The command to invoke when precompiling assets.
|
67
|
-
# Override me if you like.
|
68
|
-
|
69
|
-
settings.rake_assets_precompile ||= lambda { "#{rake} assets:precompile RAILS_GROUPS=assets" }
|
70
|
-
|
71
|
-
# ----
|
72
|
-
|
73
|
-
# Macro used later by :rails, :rake, etc
|
74
|
-
make_run_task = lambda { |name, sample_args|
|
75
|
-
task name, [:arguments] => :environment do |t, args|
|
76
|
-
arguments = args[:arguments]
|
77
|
-
command = send name
|
78
|
-
unless arguments
|
79
|
-
puts %{You need to provide arguments. Try: mina "#{name}[#{sample_args}]"}
|
80
|
-
exit 1
|
81
|
-
end
|
82
|
-
queue echo_cmd %[cd "#{deploy_to!}/#{current_path!}" && #{command} #{arguments}]
|
83
|
-
end
|
84
|
-
}
|
85
|
-
|
86
|
-
def check_for_changes_script(options={})
|
87
|
-
diffs = options[:at].map { |path|
|
88
|
-
%[diff -rN "#{deploy_to}/#{current_path}/#{path}" "./#{path}" 2>/dev/null]
|
89
|
-
}.join("\n")
|
90
|
-
|
91
|
-
unindent %[
|
92
|
-
if [ -e "#{deploy_to}/#{current_path}/#{options[:check]}" ]; then
|
93
|
-
count=`(
|
94
|
-
#{reindent 4, diffs}
|
95
|
-
) | wc -l`
|
96
|
-
|
97
|
-
if [ "$((count))" = "0" ]; then
|
98
|
-
#{reindent 4, options[:skip]} &&
|
99
|
-
exit
|
100
|
-
else
|
101
|
-
#{reindent 4, options[:changed]}
|
102
|
-
fi
|
103
|
-
else
|
104
|
-
#{reindent 2, options[:default]}
|
105
|
-
fi
|
106
|
-
]
|
107
|
-
end
|
108
|
-
|
109
|
-
# ## Command-line tasks
|
110
|
-
# These tasks can be invoked in the command line.
|
111
|
-
|
112
|
-
# ### rails[]
|
113
|
-
# Invokes a rails command.
|
114
|
-
#
|
115
|
-
# $ mina "rails[console]"
|
116
|
-
|
117
|
-
desc "Execute a Rails command in the current deploy."
|
118
|
-
make_run_task[:rails, 'console']
|
119
|
-
|
120
|
-
# ### rake[]
|
121
|
-
# Invokes a rake command.
|
122
|
-
#
|
123
|
-
# $ mina "rake[db:migrate]"
|
124
|
-
|
125
|
-
desc "Execute a Rake command in the current deploy."
|
126
|
-
make_run_task[:rake, 'db:migrate']
|
127
|
-
|
128
|
-
# ### console
|
129
|
-
# Opens the Ruby console for the currently-deployed version.
|
130
|
-
#
|
131
|
-
# $ mina console
|
132
|
-
|
133
|
-
desc "Starts an interactive console."
|
134
|
-
task :console => :environment do
|
135
|
-
queue echo_cmd %[cd "#{deploy_to!}/#{current_path!}" && #{rails} console && exit]
|
136
|
-
end
|
137
|
-
|
138
|
-
# ### log
|
139
|
-
# Tail log from server
|
140
|
-
#
|
141
|
-
# $ mina log
|
142
|
-
|
143
|
-
desc "Tail log from server"
|
144
|
-
task :log => :environment do
|
145
|
-
queue %[tail -f #{deploy_to}/#{current_path}/log/#{rails_env}.log]
|
146
|
-
end
|
147
|
-
|
148
|
-
# ## Deploy tasks
|
149
|
-
# These tasks are meant to be invoked inside deploy scripts, not invoked on
|
150
|
-
# their own.
|
151
|
-
|
152
|
-
namespace :rails do
|
153
|
-
# ### rails:db_migrate
|
154
|
-
desc "Migrates the Rails database (skips if nothing has changed since the last release)."
|
155
|
-
task :db_migrate do
|
156
|
-
if ENV['force_migrate']
|
157
|
-
invoke :'rails:db_migrate:force'
|
158
|
-
else
|
159
|
-
message = verbose_mode? ?
|
160
|
-
'$((count)) changes found, migrating database' :
|
161
|
-
'Migrating database'
|
162
|
-
|
163
|
-
queue check_for_changes_script \
|
164
|
-
:check => 'db/migrate/',
|
165
|
-
:at => ['db/migrate/'],
|
166
|
-
:skip => %[
|
167
|
-
echo "-----> DB migrations unchanged; skipping DB migration"
|
168
|
-
],
|
169
|
-
:changed => %[
|
170
|
-
echo "-----> #{message}"
|
171
|
-
#{echo_cmd %[#{rake} db:migrate]}
|
172
|
-
],
|
173
|
-
:default => %[
|
174
|
-
echo "-----> Migrating database"
|
175
|
-
#{echo_cmd %[#{rake} db:migrate]}
|
176
|
-
]
|
177
|
-
end
|
178
|
-
end
|
179
|
-
|
180
|
-
# ### rails:db_migrate:force
|
181
|
-
desc "Migrates the Rails database."
|
182
|
-
task :'db_migrate:force' do
|
183
|
-
queue %{
|
184
|
-
echo "-----> Migrating database"
|
185
|
-
#{echo_cmd %[#{rake} db:migrate]}
|
186
|
-
}
|
187
|
-
end
|
188
|
-
|
189
|
-
# ### rails:db_create
|
190
|
-
desc "Creates the Rails database."
|
191
|
-
task :'db_create' do
|
192
|
-
queue %{
|
193
|
-
echo "-----> Creating database"
|
194
|
-
#{echo_cmd %[#{rake} db:create]}
|
195
|
-
}
|
196
|
-
end
|
197
|
-
|
198
|
-
# ### rails:db_rollback
|
199
|
-
desc "Rollbacks the Rails database."
|
200
|
-
task :'db_rollback' do
|
201
|
-
queue %{
|
202
|
-
echo "-----> Rollbacking database"
|
203
|
-
#{echo_cmd %[#{rake} db:rollback]}
|
204
|
-
}
|
205
|
-
end
|
206
|
-
|
207
|
-
# ### rails:assets_precompile:force
|
208
|
-
desc "Precompiles assets."
|
209
|
-
task :'assets_precompile:force' do
|
210
|
-
queue %{
|
211
|
-
echo "-----> Precompiling asset files"
|
212
|
-
#{echo_cmd %[#{rake_assets_precompile}]}
|
213
|
-
}
|
214
|
-
end
|
215
|
-
|
216
|
-
# ### rails:assets_precompile
|
217
|
-
desc "Precompiles assets (skips if nothing has changed since the last release)."
|
218
|
-
task :'assets_precompile' do
|
219
|
-
if ENV['force_assets']
|
220
|
-
invoke :'rails:assets_precompile:force'
|
221
|
-
else
|
222
|
-
message = verbose_mode? ?
|
223
|
-
'$((count)) changes found, precompiling asset files' :
|
224
|
-
'Precompiling asset files'
|
225
|
-
|
226
|
-
queue check_for_changes_script \
|
227
|
-
:check => compiled_asset_path,
|
228
|
-
:at => [*asset_paths],
|
229
|
-
:skip => %[
|
230
|
-
echo "-----> Skipping asset precompilation"
|
231
|
-
#{echo_cmd %[mkdir -p "#{deploy_to}/$build_path/#{compiled_asset_path}"]}
|
232
|
-
#{echo_cmd %[cp -R "#{deploy_to}/#{current_path}/#{compiled_asset_path}/." "#{deploy_to}/$build_path/#{compiled_asset_path}"]}
|
233
|
-
],
|
234
|
-
:changed => %[
|
235
|
-
echo "-----> #{message}"
|
236
|
-
#{echo_cmd %[#{rake_assets_precompile}]}
|
237
|
-
],
|
238
|
-
:default => %[
|
239
|
-
echo "-----> Precompiling asset files"
|
240
|
-
#{echo_cmd %[#{rake_assets_precompile}]}
|
241
|
-
]
|
242
|
-
end
|
243
|
-
end
|
244
|
-
|
245
|
-
end
|