diff --git a/.gitignore b/.gitignore index 251a868c..391038cf 100644 --- a/.gitignore +++ b/.gitignore @@ -19,3 +19,4 @@ test/tmp test/version_tmp tmp .vs/ +pkg/ diff --git a/lib/wordmove.rb b/lib/wordmove.rb index a3b619b0..8a328179 100644 --- a/lib/wordmove.rb +++ b/lib/wordmove.rb @@ -1,5 +1,6 @@ require 'English' +require 'logger' require 'active_support' require 'active_support/core_ext' require 'colorize' @@ -10,7 +11,6 @@ require 'erb' require 'kwalify' require 'light-service' -require 'logger' require 'open-uri' require 'ostruct' require 'yaml' diff --git a/lib/wordmove/actions/adapt_remote_db.rb b/lib/wordmove/actions/adapt_remote_db.rb old mode 100644 new mode 100755 index 9fa59046..e5ccbfae --- a/lib/wordmove/actions/adapt_remote_db.rb +++ b/lib/wordmove/actions/adapt_remote_db.rb @@ -96,12 +96,14 @@ def self.import_db_command(context) "--path=#{wpcli_config_path(context)}" end - # Compose and returns the search-replace command. It's intended to be + # Compose and returns the search-replace commands. It's intended to be # used from a +LightService::Action+ # + # @note For the :vhost config key, two commands will be returned: one for http and one for https scheme. + # # @param context [LightService::Context] The context of an action # @param config_key [:vhost, :wordpress_path] Determines what will be replaced in DB - # @return [String] + # @return [Array] # @!scope class def self.search_replace_command(context, config_key) unless %i[vhost wordpress_path].include?(config_key) @@ -112,11 +114,8 @@ def self.search_replace_command(context, config_key) [ 'wp search-replace', "--path=#{wpcli_config_path(context)}", - '"\A' + context.dig(:remote_options, config_key) + '\Z"', # rubocop:disable Style/StringConcatenation + '"' + context.dig(:remote_options, config_key) + '"', # rubocop:disable Style/StringConcatenation '"' + context.dig(:local_options, config_key) + '"', # rubocop:disable Style/StringConcatenation - '--regex-delimiter="|"', - '--regex', - '--precise', '--quiet', '--skip-columns=guid', '--all-tables', diff --git a/lib/wordmove/actions/ssh/get_directory.rb b/lib/wordmove/actions/ssh/get_directory.rb old mode 100644 new mode 100755 index 9c876d73..dfeeafe0 --- a/lib/wordmove/actions/ssh/get_directory.rb +++ b/lib/wordmove/actions/ssh/get_directory.rb @@ -68,7 +68,7 @@ class GetDirectory next context if result == true - context.fail!("Failed to push #{context.folder_task}") + context.fail!("Failed to pull #{context.folder_task}") end end end diff --git a/lib/wordmove/doctor/rsync.rb b/lib/wordmove/doctor/rsync.rb old mode 100644 new mode 100755 index 7915dc14..d534f597 --- a/lib/wordmove/doctor/rsync.rb +++ b/lib/wordmove/doctor/rsync.rb @@ -10,10 +10,16 @@ def initialize def check! logger.task 'Checking rsync' - if (version = /\d\.\d.\d/.match(`rsync --version | head -n1`)[0]) - logger.success "rsync is installed at version #{version}" + version_output = `rsync --version | head -n1 2>&1` + + if version_output.downcase.include?('openrsync') + protocol_version = version_output[/protocol version (\d+)/i, 1] + logger.success "openrsync detected (protocol version #{protocol_version || 'unknown'})" + elsif (match = /\d+\.\d+\.\d+/.match(version_output)) + logger.success "rsync is installed at version #{match[0]}" else - logger.error "rsync not found. And belive me: it's really strange it's not there." + logger.error "rsync not found or the version could not be detected. "\ + "Output was: #{version_output.strip}" end end end diff --git a/lib/wordmove/movefile.rb b/lib/wordmove/movefile.rb old mode 100644 new mode 100755 index b10381ab..723d5f6a --- a/lib/wordmove/movefile.rb +++ b/lib/wordmove/movefile.rb @@ -77,26 +77,7 @@ def fetch(verbose = true) # rubocop:disable Style/OptionalBooleanParameter logger.task("Using Movefile: #{found}") if verbose == true load_dotenv(verbose) - options = YAML.safe_load(ERB.new(File.read(found)).result, symbolize_names: true) - - merge_local_options_from_wpcli(options) - end - - def merge_local_options_from_wpcli(options) - config_path = options.dig(:local, :wordpress_path) - - options.merge( - local: { - database: { - password: Wordmove::WpcliHelpers.get_config('DB_PASSWORD', config_path:), - host: Wordmove::WpcliHelpers.get_config('DB_HOST', config_path:), - name: Wordmove::WpcliHelpers.get_config('DB_NAME', config_path:), - user: Wordmove::WpcliHelpers.get_config('DB_USER', config_path:) - }, - vhost: Wordmove::WpcliHelpers.get_option('home', config_path:), - wordpress_path: config_path - } - ) + YAML.safe_load(ERB.new(File.read(found)).result, symbolize_names: true) end def load_dotenv(verbose) diff --git a/lib/wordmove/version.rb b/lib/wordmove/version.rb old mode 100644 new mode 100755 index 80555e63..03698e9f --- a/lib/wordmove/version.rb +++ b/lib/wordmove/version.rb @@ -1,3 +1,3 @@ module Wordmove - VERSION = '6.0.0.alpha.8'.freeze + VERSION = '6.0.0'.freeze end diff --git a/pkg/wordmove-0.0.1.gem b/pkg/wordmove-0.0.1.gem deleted file mode 100644 index 21f32448..00000000 Binary files a/pkg/wordmove-0.0.1.gem and /dev/null differ diff --git a/pkg/wordmove-0.0.2.gem b/pkg/wordmove-0.0.2.gem deleted file mode 100644 index dbf3c5b6..00000000 Binary files a/pkg/wordmove-0.0.2.gem and /dev/null differ diff --git a/spec/doctor/mysql_spec.rb b/spec/doctor/mysql_spec.rb index 889ce300..7a89540d 100644 --- a/spec/doctor/mysql_spec.rb +++ b/spec/doctor/mysql_spec.rb @@ -8,6 +8,7 @@ allow(doctor).to receive(:mysql_server_doctor).and_return true allow(doctor).to receive(:mysql_database_doctor).and_return true end + it 'implements #check! method' do expect(doctor).to receive(:check!) diff --git a/spec/fixtures/movefiles/multi_environments b/spec/fixtures/movefiles/multi_environments index db8daa01..461bc7cb 100644 --- a/spec/fixtures/movefiles/multi_environments +++ b/spec/fixtures/movefiles/multi_environments @@ -3,6 +3,11 @@ global: local: wordpress_path: "/home/welaika/sites/your_site" + database: + name: "database_name" + user: "user" + password: "password" + host: "host" staging: vhost: "http://staging.mysite.example.com" diff --git a/spec/fixtures/movefiles/with_secrets b/spec/fixtures/movefiles/with_secrets index aa72f987..c7a05386 100644 --- a/spec/fixtures/movefiles/with_secrets +++ b/spec/fixtures/movefiles/with_secrets @@ -2,6 +2,11 @@ global: sql_adapter: "wpcli" local: wordpress_path: "~/dev/sites/your_site" + database: + name: "local_database_name" + user: "local_user" + password: "local_database_password" + host: "local_database_host" remote: vhost: "http://secrets.example.com" wordpress_path: "/var/www/your_site" diff --git a/spec/fixtures/movefiles/with_secrets_with_empty_local_db_password b/spec/fixtures/movefiles/with_secrets_with_empty_local_db_password index 0236e8f0..99ccd4a9 100644 --- a/spec/fixtures/movefiles/with_secrets_with_empty_local_db_password +++ b/spec/fixtures/movefiles/with_secrets_with_empty_local_db_password @@ -2,6 +2,11 @@ global: sql_adapter: "wpcli" local: wordpress_path: "~/dev/sites/your_site" + vhost: "http://your_site.local" + database: + name: "local_database_name" + user: "local_user" + host: "local_database_host" remote: vhost: "http://secrets.example.com" wordpress_path: "/var/www/your_site" diff --git a/spec/movefile_spec.rb b/spec/movefile_spec.rb index 264a72a4..b01dfeab 100644 --- a/spec/movefile_spec.rb +++ b/spec/movefile_spec.rb @@ -159,7 +159,6 @@ %w[ local_database_password local_database_host - http://example.com ~/dev/sites/your_site remote_database_password remote_database_host @@ -185,7 +184,7 @@ expect(movefile.secrets).to eq( %w[ local_database_host - http://example.com + http://your_site.local ~/dev/sites/your_site remote_database_password remote_database_host diff --git a/spec/wordpress_directory_spec.rb b/spec/wordpress_directory_spec.rb index bfb4b6af..9e50bc96 100644 --- a/spec/wordpress_directory_spec.rb +++ b/spec/wordpress_directory_spec.rb @@ -50,14 +50,14 @@ context 'given an additional path as a string' do it 'returns the URL of the folder joined with the additional path' do wd = described_class.new(:uploads, options) - expect(wd.url('pirate.png')).to eq('http://example.com/wp-content/uploads/pirate.png') + expect(wd.url('pirate.png')).to eq('http://vhost.local/wp-content/uploads/pirate.png') end end context 'without arguments' do it 'returns the URL for the required folder' do wd = described_class.new(:uploads, options) - expect(wd.url).to eq('http://example.com/wp-content/uploads') + expect(wd.url).to eq('http://vhost.local/wp-content/uploads') end end end diff --git a/wordmove.gemspec b/wordmove.gemspec old mode 100644 new mode 100755 index 0fc6999d..caee35ed --- a/wordmove.gemspec +++ b/wordmove.gemspec @@ -36,7 +36,7 @@ Gem::Specification.new do |spec| spec.add_runtime_dependency 'dry-configurable', '~> 0.13.0' spec.add_runtime_dependency 'kwalify', '~> 0.7.2' spec.add_runtime_dependency 'light-service', '~> 0.17.0' - spec.add_runtime_dependency 'photocopier', '~> 1.4', '>= 1.4.1' + spec.add_runtime_dependency 'photocopier', '~> 1.5', '>= 1.5.0' # spec.add_runtime_dependency 'thor', '~> 0.20.3' spec.add_runtime_dependency 'dry-cli', '~> 0.7.0' spec.add_runtime_dependency 'dry-files', '~> 0.1.0' @@ -44,11 +44,11 @@ Gem::Specification.new do |spec| spec.required_ruby_version = '>= 3.1.0' spec.add_development_dependency 'bundler', '~> 2.3.3' - spec.add_development_dependency 'debug', '~> 1.4.0' - spec.add_development_dependency 'rake', '~> 13.0.1' - spec.add_development_dependency 'rspec', '~> 3.9' - spec.add_development_dependency 'rubocop', '~> 1.24.0' - spec.add_development_dependency 'rubocop-rspec', '~> 2.6.0' + spec.add_development_dependency 'debug', '~> 1.11.0' + spec.add_development_dependency 'rake', '~> 13.3.1' + spec.add_development_dependency 'rspec', '~> 3.13.2' + spec.add_development_dependency 'rubocop', '~> 1.81.7' + spec.add_development_dependency 'rubocop-rspec', '~> 3.8.0' spec.add_development_dependency 'simplecov', '~> 0.21.2' spec.add_development_dependency 'yard' spec.add_development_dependency 'yard-activesupport-concern'