lib/shuttle/deployment/wordpress/cli.rb in shuttle-deploy-0.2.0.beta3 vs lib/shuttle/deployment/wordpress/cli.rb in shuttle-deploy-0.2.0.beta4
- old
+ new
@@ -1,27 +1,38 @@
module Shuttle
module WordpressCli
CLI_GIT = 'https://github.com/wp-cli/wp-cli.git'
CLI_PATH = '/usr/local/share/wp-cli'
- # Check if CLI is installed
- # @return [Boolean]
def cli_installed?
ssh.run("which wp").success?
end
- # Install wordpress CLI
- # @return [Boolean]
def cli_install
- log "Installing wordpress CLI"
+ log "Installing WordPress CLI"
ssh.run("sudo git clone --recursive --quiet #{CLI_GIT} #{CLI_PATH}")
+
+ if config.wordpress.cli.nil?
+ tags = ssh.capture("cd #{CLI_PATH} && git tag").split("\n").map(&:strip).reverse
+ tag = tags.first
+ rev = ssh.capture("cd #{CLI_PATH} && git rev-parse #{tag}").strip
+ else
+ tag = rev = config.wordpress.cli
+ end
+
+ ssh.run("cd #{CLI_PATH} && sudo git checkout #{rev}")
ssh.run("cd #{CLI_PATH} && sudo utils/dev-build")
if cli_installed?
- log "Wordpress CLI installed"
+ log "WordPress CLI (#{tag}) installed"
else
- error "Unable to install wordpress CLI"
+ error "Unable to install WordPress CLI"
end
+ end
+
+ def cli_uninstall
+ ssh.run("sudo rm $(which wp)")
+ ssh.run("sudo rm -rf #{CLI_PATH}")
end
end
end
\ No newline at end of file