Skip to content

Commit

Permalink
should fix #428
Browse files Browse the repository at this point in the history
Here we completely subverted the way we produce rsync command.
Managing subdirectories transfer is now done with rsync's includes
directives and the rsync tranfer root is always the wordpress root.

This way an exclusion such as `wp-content/plugins/myplugin` in the
movefile.yml is always understood from wormdove/rsync when push/pull-ing
`--all`, core, or even a single component.

ref: #428
  • Loading branch information
alessandro-fazzi committed May 22, 2018
1 parent 0caa2fe commit 1642065
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 14 deletions.
43 changes: 37 additions & 6 deletions lib/wordmove/deployer/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,16 +56,19 @@ def remote_put_directory; end
%w[uploads themes plugins mu_plugins languages].each do |task|
define_method "push_#{task}" do
logger.task "Pushing #{task.titleize}"
local_path = send("local_#{task}_dir").path
remote_path = send("remote_#{task}_dir").path
remote_put_directory(local_path, remote_path, paths_to_exclude)
local_path = local_options[:wordpress_path]
remote_path = remote_options[:wordpress_path]

remote_put_directory(local_path, remote_path,
push_exclude_paths, push_inlcude_paths(task))
end

define_method "pull_#{task}" do
logger.task "Pulling #{task.titleize}"
local_path = send("local_#{task}_dir").path
remote_path = send("remote_#{task}_dir").path
remote_get_directory(remote_path, local_path, paths_to_exclude)
local_path = local_options[:wordpress_path]
remote_path = remote_options[:wordpress_path]
remote_get_directory(remote_path, local_path,
pull_exclude_paths, pull_include_paths(task))
end
end

Expand Down Expand Up @@ -202,6 +205,34 @@ def remote_options
def local_options
options[:local].clone
end

def push_inlcude_paths(task)
[
"/#{local_wp_content_dir.relative_path}/",
"/#{local_wp_content_dir.relative_path}/#{task}/"
]
end

def push_exclude_paths
paths_to_exclude + [
"/*",
"/#{local_wp_content_dir.relative_path}/*"
]
end

def pull_include_paths(task)
[
"/#{remote_wp_content_dir.relative_path}/",
"/#{remote_wp_content_dir.relative_path}/#{task}/"
]
end

def pull_exclude_paths
paths_to_exclude + [
"/*",
"/#{remote_wp_content_dir.relative_path}/*"
]
end
end
end
end
10 changes: 5 additions & 5 deletions lib/wordmove/logger.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,23 +19,23 @@ def task_step(local_step, title)
end

def error(message)
puts " error".red + " | ".black + message.to_s
puts " error".red + " | ".black + message.to_s
end

def success(message)
puts " success".green + " | ".black + message.to_s
puts " success".green + " | ".black + message.to_s
end

def debug(message)
puts " debug".magenta + " | ".black + message.to_s
puts " 🛠 debug".magenta + " | ".black + message.to_s
end

def warn(message)
puts " ⚠ warning".yellow + " | ".black + message.to_s
puts " ⚠ warning".yellow + " | ".black + message.to_s
end

def info(message)
puts " ℹ️ info".yellow + " | ".black + message.to_s
puts " ℹ️ info".yellow + " | ".black + message.to_s
end

private
Expand Down
5 changes: 3 additions & 2 deletions spec/deployer/base_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,18 @@
end

context "with ssh remote connection" do
it "returns an instance of Ssh::Default deployer" do
before do
options[:environment] = "staging"
end

it "returns an instance of Ssh::Default deployer" do
expect(described_class.deployer_for(options))
.to be_a Wordmove::Deployer::Ssh::DefaultSqlAdapter
end

context "when Movefile is configured with 'wpcli' sql_adapter" do
it "returns an instance of Ssh::WpcliSqlAdapter deployer" do
options[:config] = movefile_path_for('multi_environments_wpcli_sql_adapter')
options[:environment] = "staging"

expect(described_class.deployer_for(options))
.to be_a Wordmove::Deployer::Ssh::WpcliSqlAdapter
Expand Down
2 changes: 1 addition & 1 deletion wordmove.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ Gem::Specification.new do |spec|
spec.add_runtime_dependency "colorize", "~> 0.8.1"
spec.add_runtime_dependency "dotenv", "~> 2.2.1"
spec.add_runtime_dependency "kwalify", "~> 0"
spec.add_runtime_dependency "photocopier", "~> 1.1", ">= 1.1.3"
spec.add_runtime_dependency "photocopier", "~> 1.2", ">= 1.2.0"
spec.add_runtime_dependency "thor", "~> 0.19.4"

spec.required_ruby_version = ">= 2.4.0"
Expand Down

0 comments on commit 1642065

Please sign in to comment.