Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@ test/tmp
test/version_tmp
tmp
.vs/
pkg/
2 changes: 1 addition & 1 deletion lib/wordmove.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
require 'English'

require 'logger'
require 'active_support'
require 'active_support/core_ext'
require 'colorize'
Expand All @@ -10,7 +11,6 @@
require 'erb'
require 'kwalify'
require 'light-service'
require 'logger'
require 'open-uri'
require 'ostruct'
require 'yaml'
Expand Down
11 changes: 5 additions & 6 deletions lib/wordmove/actions/adapt_remote_db.rb
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -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<String>]
# @!scope class
def self.search_replace_command(context, config_key)
unless %i[vhost wordpress_path].include?(config_key)
Expand All @@ -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',
Expand Down
2 changes: 1 addition & 1 deletion lib/wordmove/actions/ssh/get_directory.rb
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 9 additions & 3 deletions lib/wordmove/doctor/rsync.rb
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
21 changes: 1 addition & 20 deletions lib/wordmove/movefile.rb
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion lib/wordmove/version.rb
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module Wordmove
VERSION = '6.0.0.alpha.8'.freeze
VERSION = '6.0.0'.freeze
end
Binary file removed pkg/wordmove-0.0.1.gem
Binary file not shown.
Binary file removed pkg/wordmove-0.0.2.gem
Binary file not shown.
1 change: 1 addition & 0 deletions spec/doctor/mysql_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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!)

Expand Down
5 changes: 5 additions & 0 deletions spec/fixtures/movefiles/multi_environments
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
5 changes: 5 additions & 0 deletions spec/fixtures/movefiles/with_secrets
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
3 changes: 1 addition & 2 deletions spec/movefile_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,6 @@
%w[
local_database_password
local_database_host
http://example.com
~/dev/sites/your_site
remote_database_password
remote_database_host
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions spec/wordpress_directory_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 6 additions & 6 deletions wordmove.gemspec
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -36,19 +36,19 @@ 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'

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'
Expand Down