2012-08-21 19:31:24 +02:00
|
|
|
require "middleman-core/cli"
|
2012-08-22 20:45:33 +02:00
|
|
|
|
|
|
|
require "middleman-deploy/extension"
|
|
|
|
|
|
|
|
module Middleman
|
|
|
|
module Cli
|
|
|
|
# This class provides a "deploy" command for the middleman CLI.
|
|
|
|
class Deploy < Thor
|
|
|
|
include Thor::Actions
|
|
|
|
|
|
|
|
check_unknown_options!
|
|
|
|
|
|
|
|
namespace :deploy
|
|
|
|
|
|
|
|
# Tell Thor to exit with a nonzero exit code on failure
|
|
|
|
def self.exit_on_failure?
|
|
|
|
true
|
|
|
|
end
|
|
|
|
|
|
|
|
desc "deploy", "Deploy to a remote host over rsync"
|
|
|
|
def deploy
|
2012-08-22 21:37:37 +02:00
|
|
|
options = ::Middleman::Application.server.inst.options
|
2012-08-22 20:45:33 +02:00
|
|
|
|
2012-08-22 21:37:37 +02:00
|
|
|
# These only exists when the config.rb sets them!
|
|
|
|
if (options.host && options.user && options.path)
|
|
|
|
run "rsync -avze '" + "ssh -p #{options.port}" + "' #{"--delete" if options.delete == true} build/ #{options.user}@#{options.host}:#{options.path}"
|
2012-08-22 20:45:33 +02:00
|
|
|
else
|
|
|
|
raise Thor::Error.new "You need to activate the deploy extension in config.rb "
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
# Alias "d" to "deploy"
|
|
|
|
Base.map({ "d" => "deploy" })
|
|
|
|
end
|
|
|
|
end
|