-
Notifications
You must be signed in to change notification settings - Fork 165
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This, if it will born, will be version 6
Fix bug in AdaptRemoteDb Undefined method `waring` was called on logger Fix wrong signature on method call in AdaptRemoteDb Warn when db adapt is skipper SetupContextForDb won't run unless necessary Update some log messages for better clarity Fix mu-plugins key in mu_plugins. Fixes #619 Please the rubocop Remove FTP support and cleanup as consequently Re-implement #597 in this branch Improve wpcli_search_replace_command with argument check Add yard documentation Fix bug in FilterAndSetupTasksToRun action Was getting key by string on a symbolized hash Migreate from Thor do dry-cli Improve UX a bit w/ better log messages Remove unused WordpressDirectory::HelperMethods module Re-enable --debug flag Update version: will stick to a pre-release Update scaffold and namespace for organizers WIP: re-implement FTP support WIP: re-implement FTP support Fix typo and reword a variable WIP: re-implement FTP support WIP: re-implement FTP support WIP: re-implement FTP support WIP: re-implement FTP support WIP: re-implement FTP support WIP: re-implement FTP support WIP: re-implement FTP support WIP: re-implement FTP support Update get_file_spec Update hook_spec Update rspec config Add adapt_local_db_spec Various cleanups, typos, rubocop disables Fix Wordmove::Movefile by removing - never triggered - wrong logic Update deps and please the (new) rubocop
- Loading branch information
1 parent
0fc74a1
commit 94cba67
Showing
88 changed files
with
1,900 additions
and
834 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
module Wordmove | ||
module Actions | ||
# | ||
# Adapt the local DB for the remote destination. | ||
# "To adapt" in Wordmove jargon means to transform URLs strings into the database. This action | ||
# will substitute local URLs with remote ones, in order to make the DB to work correctly once | ||
# pushed to the remote wordpress installation. | ||
# | ||
class AdaptLocalDb | ||
extend ::LightService::Action | ||
include Wordmove::Actions::Helpers | ||
include Wordmove::Wpcli | ||
|
||
expects :local_options, | ||
:remote_options, | ||
:cli_options, | ||
:logger, | ||
:photocopier, | ||
:db_paths | ||
|
||
# @!method execute | ||
# @param local_options [Hash] Local host options fetched from | ||
# movefile (with symbolized keys) | ||
# @param remote_options [Hash] Remote host options fetched from | ||
# movefile (with symbolized keys) | ||
# @param cli_options [Hash] Command line options | ||
# @param logger [Wordmove::Logger] | ||
# @param photocopier [Photocopier::SSH|Photocopier::FTP] | ||
# @param db_paths [BbPathsConfig] Configuration object for database | ||
# @!scope class | ||
# @return [LightService::Context] Action's context | ||
executed do |context| # rubocop:disable Metrics/BlockLength | ||
context.logger.task 'Adapt local DB' | ||
|
||
unless wp_in_path? | ||
raise UnmetPeerDependencyError, 'WP-CLI is not installed or not in your $PATH' | ||
end | ||
|
||
next context if simulate?(cli_options: context.cli_options) | ||
|
||
Wordmove::Actions::RunLocalCommand.execute( | ||
cli_options: context.cli_options, | ||
logger: context.logger, | ||
command: mysql_dump_command( | ||
env_db_options: context.local_options[:database], | ||
save_to_path: context.db_paths.local.path | ||
) | ||
) | ||
|
||
if context.cli_options[:no_adapt] | ||
context.logger.warn 'Skipping DB adapt' | ||
else | ||
Wordmove::Actions::RunLocalCommand.execute( | ||
cli_options: context.cli_options, | ||
logger: context.logger, | ||
command: wpcli_search_replace_command(context, :vhost) | ||
) | ||
|
||
Wordmove::Actions::RunLocalCommand.execute( | ||
cli_options: context.cli_options, | ||
logger: context.logger, | ||
command: wpcli_search_replace_command(context, :wordpress_path) | ||
) | ||
end | ||
|
||
Wordmove::Actions::RunLocalCommand.execute( | ||
cli_options: context.cli_options, | ||
|
||
logger: context.logger, | ||
command: mysql_dump_command( | ||
env_db_options: context.local_options[:database], | ||
save_to_path: context.db_paths.local.adapted_path | ||
) | ||
) | ||
|
||
if context.photocopier.is_a? Photocopier::SSH | ||
Wordmove::Actions::RunLocalCommand.execute( | ||
cli_options: context.cli_options, | ||
logger: context.logger, | ||
command: compress_command(file_path: context.db_paths.local.adapted_path) | ||
) | ||
end | ||
|
||
Wordmove::Actions::RunLocalCommand.execute( | ||
cli_options: context.cli_options, | ||
logger: context.logger, | ||
command: mysql_import_command( | ||
dump_path: context.db_paths.local.path, | ||
env_db_options: context.local_options[:database] | ||
) | ||
) | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
module Wordmove | ||
module Actions | ||
# | ||
# Adapt the remote DB for the local destination. | ||
# "To adapt" in Wordmove jargon means to transform URLs strings into the database. This action | ||
# will substitute remote URLs with local ones, in order to make the DB to work correctly once | ||
# pulled to the local wordpress installation. | ||
# | ||
# @note This action is not responsible to download the remote DB nor to backup any DB at all. | ||
# It expects to find a dump of the remote DB into +context.db_paths.local.gzipped_path+ | ||
# (SSH) or +context.db_paths.local.path+ (FTP), otherwise it will fail and stop the | ||
# procedure. | ||
# | ||
class AdaptRemoteDb | ||
extend ::LightService::Action | ||
include Wordmove::Actions::Helpers | ||
include Wordmove::Wpcli | ||
|
||
expects :local_options, | ||
:cli_options, | ||
:logger, | ||
:db_paths | ||
|
||
# @!method execute | ||
# @param local_options [Hash] Local host options fetched from | ||
# movefile (with symbolized keys) | ||
# @param cli_options [Hash] Command line options | ||
# @param logger [Wordmove::Logger] | ||
# @param db_paths [BbPathsConfig] Configuration object for database | ||
# @!scope class | ||
# @return [LightService::Context] Action's context | ||
executed do |context| # rubocop:disable Metrics/BlockLength | ||
context.logger.task 'Adapt remote DB' | ||
|
||
unless wp_in_path? | ||
raise UnmetPeerDependencyError, 'WP-CLI is not installed or not in your $PATH' | ||
end | ||
|
||
next context if simulate?(cli_options: context.cli_options) | ||
|
||
if File.exist?(context.db_paths.local.gzipped_path) | ||
Wordmove::Actions::RunLocalCommand.execute( | ||
cli_options: context.cli_options, | ||
logger: context.logger, | ||
command: uncompress_command(file_path: context.db_paths.local.gzipped_path) | ||
) | ||
end | ||
|
||
unless File.exist?(context.db_paths.local.path) | ||
context.fail_and_return!( | ||
"Cannot find the dump file to adapt in #{context.db_paths.local.path}" | ||
) | ||
end | ||
|
||
Wordmove::Actions::RunLocalCommand.execute( | ||
cli_options: context.cli_options, | ||
logger: context.logger, | ||
command: mysql_import_command( | ||
dump_path: context.db_paths.local.path, | ||
env_db_options: context.local_options[:database] | ||
) | ||
) | ||
|
||
if context.cli_options[:no_adapt] | ||
context.logger.warn 'Skipping DB adapt' | ||
next context | ||
end | ||
|
||
result = Wordmove::Actions::RunLocalCommand.execute( | ||
cli_options: context.cli_options, | ||
logger: context.logger, | ||
command: wpcli_search_replace_command(context, :vhost) | ||
) | ||
context.fail_and_return!(result.message) if result.failure? | ||
|
||
result = Wordmove::Actions::RunLocalCommand.execute( | ||
cli_options: context.cli_options, | ||
logger: context.logger, | ||
command: wpcli_search_replace_command(context, :wordpress_path) | ||
) | ||
context.fail_and_return!(result.message) if result.failure? | ||
|
||
context.logger.success 'Local DB adapted' | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
module Wordmove | ||
module Actions | ||
# | ||
# Take a backup of the local database and save it in +wp-content/+ folder. | ||
# | ||
class BackupLocalDb | ||
extend ::LightService::Action | ||
include Wordmove::Actions::Helpers | ||
|
||
expects :local_options | ||
expects :cli_options | ||
expects :db_paths | ||
expects :logger | ||
|
||
# @!method execute | ||
# @param local_options [Hash] Local host options fetched from | ||
# movefile (with symbolized keys) | ||
# @param cli_options [Hash] Command line options | ||
# @param db_paths [BbPathsConfig] Configuration object for database | ||
# @param logger [Wordmove::Logger] | ||
# @!scope class | ||
# @return [LightService::Context] Action's context | ||
executed do |context| | ||
context.logger.task 'Backup local DB' | ||
|
||
if simulate?(cli_options: context.cli_options) | ||
context.logger.info 'A backup of the local DB would have been saved into ' \ | ||
"#{context.db_paths.backup.local.gzipped_path}, " \ | ||
'but you\'re simulating' | ||
next context | ||
end | ||
|
||
Wordmove::Actions::RunLocalCommand.execute( | ||
cli_options: context.cli_options, | ||
logger: context.logger, | ||
command: mysql_dump_command( | ||
env_db_options: context.local_options[:database], | ||
save_to_path: context.db_paths.backup.local.path | ||
) | ||
) | ||
|
||
Wordmove::Actions::RunLocalCommand.execute( | ||
cli_options: context.cli_options, | ||
logger: context.logger, | ||
command: compress_command(file_path: context.db_paths.backup.local.path) | ||
) | ||
|
||
context.logger.success( | ||
"Backup saved at #{context.db_paths.backup.local.gzipped_path}" | ||
) | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.