require "middleman-core/cli" require "middleman-deploy/extension" require 'git' 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", "Copy build directory to a remote host" 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" + < 'gh-pages') # 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}") # push from tmp to self repo.push('origin', 'gh-pages') # push to github github_url = Git.open(ENV['MM_ROOT']).remote.url repo.add_remote('github', github_url) repo.push('github', 'gh-pages') end end end # Alias "d" to "deploy" Base.map({ "d" => "deploy" }) end end