Sha256: aab3d31c1fe42a0ace7342806e67a8c18ba403b3d7cb9fb203c8c99beec224d2

Contents?: true

Size: 1011 Bytes

Versions: 1

Compression:

Stored size: 1011 Bytes

Contents

module Shuttle
  module WordpressCli
    CLI_GIT  = 'https://github.com/wp-cli/wp-cli.git'
    CLI_PATH = '/usr/local/share/wp-cli'

    def cli_installed?
      ssh.run("which wp").success?
    end

    def cli_install
      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 (#{tag}) installed"
      else
        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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
shuttle-deploy-0.2.0.beta4 lib/shuttle/deployment/wordpress/cli.rb