Module: Shuttle::WordpressCli
- Included in:
- Wordpress
- Defined in:
- lib/shuttle/deployment/wordpress/cli.rb
Constant Summary collapse
- CLI_GIT =
'https://github.com/wp-cli/wp-cli.git'
- CLI_PATH =
'/usr/local/share/wp-cli'
Instance Method Summary collapse
-
#cli_checkout_code ⇒ Object
Checkout a proper wp-cli revision.
- #cli_install ⇒ Object
- #cli_installed? ⇒ Boolean
- #cli_uninstall ⇒ Object
Instance Method Details
#cli_checkout_code ⇒ Object
Checkout a proper wp-cli revision. By default it’ll install latest available tag from git. That’s considered a stable version. To install latest code, set ‘cli` option in config:
wordpress:
cli: master
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/shuttle/deployment/wordpress/cli.rb', line 35 def cli_checkout_code ssh.run("sudo git clone --recursive --quiet #{CLI_GIT} #{CLI_PATH}") if config.wordpress.cli.nil? = ssh.capture("cd #{CLI_PATH} && git tag").split("\n").map(&:strip).reverse tag = .first rev = ssh.capture("cd #{CLI_PATH} && git rev-parse #{tag}").strip else tag = config.wordpress.cli if tag =~ /^[\d\.]+$/ # version def tag = "v#{tag}" unless tag =~ /v[\d]+/ end rev = tag end res = ssh.run("cd #{CLI_PATH} && sudo git checkout #{rev}") if res.failure? error "Unable to checkout revision #{rev}: #{res.output}" end #rev, tag end |
#cli_install ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/shuttle/deployment/wordpress/cli.rb', line 10 def cli_install log "Installing WordPress CLI" rev, tag = cli_checkout_code res = ssh.run("cd #{CLI_PATH} && sudo utils/dev-build") if res.failure? error "Unable to build cli: #{res.output}" end if cli_installed? log "WordPress CLI (#{tag}) installed" else error "Wordpress CLI installation failed" end end |
#cli_installed? ⇒ Boolean
6 7 8 |
# File 'lib/shuttle/deployment/wordpress/cli.rb', line 6 def cli_installed? ssh.run("which wp").success? end |
#cli_uninstall ⇒ Object
61 62 63 64 |
# File 'lib/shuttle/deployment/wordpress/cli.rb', line 61 def cli_uninstall ssh.run("sudo rm $(which wp)") ssh.run("sudo rm -rf #{CLI_PATH}") end |