require "middleman-core/cli" require "middleman-deploy/extension" require "middleman-deploy/pkg-info" require "git" PACKAGE = "#{Middleman::Deploy::PACKAGE}" VERSION = "#{Middleman::Deploy::VERSION}" 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 build directory to a remote host via rsync or git" method_option "clean", :type => :boolean, :aliases => "-c", :desc => "Remove orphaned files or directories on the remote host" def deploy send("deploy_#{self.deploy_options.method}") end protected def print_usage_and_die(message) raise Error, "ERROR: " + message + "\n" + < branch) # copy ./build/* to tmp FileUtils.cp_r(Dir.glob(File.join(ENV["MM_ROOT"], "build", "*")), tmp) # git add and commit in tmp repo.add repo.commit("Automated commit at #{Time.now.utc} by #{PACKAGE} #{VERSION}") # push back into ENV["MM_ROOT"] repo.push("origin", branch) end orig.push(remote, branch) orig.remote(remote).fetch end end # Alias "d" to "deploy" Base.map({ "d" => "deploy" }) end end