Sha256: be4de32049a32bf78f0e4aaeaca6d14dc0651f70dc114580c262019a9b1f31b0

Contents?: true

Size: 1.85 KB

Versions: 11

Compression:

Stored size: 1.85 KB

Contents

module DanarchyDeploy
  module Applicator
    module WordPress
      class WPCLI
        def initialize(app, options)
          puts "\n > Initializing WordPress CLI"
          @database = app[:database]
          @prefix   = app[:prefix]
          @path     = app[:path]
          @user     = app[:user]
          @options  = options
          wpcli_install
        end

        def install
          cmd = @prefix + "'wp core download --path=#{@path}'"
          DanarchyDeploy::Helpers.run_command(cmd, @options)
        end

        def update
          cmd = @prefix + "'wp core update --path=#{@path}'"
          DanarchyDeploy::Helpers.run_command(cmd, @options)
        end

        def version
          cmd = @prefix + "'wp core version --path=#{@path}'"
          DanarchyDeploy::Helpers.run_command(cmd, @options)
        end

        def check_update
          cmd = @prefix + "'wp core check-update --path=#{@path}'"
          DanarchyDeploy::Helpers.run_command(cmd, @options)
        end

        def siteurl
          cmd = @prefix + "'wp option get siteurl --path=#{@path}'"
          siteurl = DanarchyDeploy::Helpers.run_command(cmd, @options)

          if siteurl[:stdout]
            return siteurl[:stdout].chomp
          else
            return siteurl[:stderr]
          end
        end

        def import
          cmd = @prefix + "'wp db import #{@database[:backup]} --path=#{@path}'"
          DanarchyDeploy::Helpers.run_command(cmd, @options)
        end

        private

        def wpcli_install
          install_cmd = 'bash ' + __dir__ + '/wpcli_install.sh'
          wpcli_result = DanarchyDeploy::Helpers.run_command(
            install_cmd, @options)

          if wpcli_result[:stderr]
            abort('   ! WP-CLI installation failed!')
          else
            puts '   |+ WP-CLI installed.'
          end
        end
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
danarchy_deploy-0.2.11 lib/danarchy_deploy/applicator/wordpress/wpcli.rb
danarchy_deploy-0.2.10 lib/danarchy_deploy/applicator/wordpress/wpcli.rb
danarchy_deploy-0.2.9 lib/danarchy_deploy/applicator/wordpress/wpcli.rb
danarchy_deploy-0.2.8 lib/danarchy_deploy/applicator/wordpress/wpcli.rb
danarchy_deploy-0.2.7 lib/danarchy_deploy/applicator/wordpress/wpcli.rb
danarchy_deploy-0.2.6 lib/danarchy_deploy/applicator/wordpress/wpcli.rb
danarchy_deploy-0.2.5 lib/danarchy_deploy/applicator/wordpress/wpcli.rb
danarchy_deploy-0.2.4 lib/danarchy_deploy/applicator/wordpress/wpcli.rb
danarchy_deploy-0.2.3 lib/danarchy_deploy/applicator/wordpress/wpcli.rb
danarchy_deploy-0.2.2 lib/danarchy_deploy/applicator/wordpress/wpcli.rb
danarchy_deploy-0.2.1 lib/danarchy_deploy/applicator/wordpress/wpcli.rb