wordmove 6.0.0.alpha.2 → 6.0.0.alpha.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (34) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +1 -1
  3. data/.ruby-version +1 -1
  4. data/lib/wordmove/actions/adapt_local_db.rb +89 -50
  5. data/lib/wordmove/actions/adapt_remote_db.rb +68 -30
  6. data/lib/wordmove/actions/backup_local_db.rb +29 -17
  7. data/lib/wordmove/actions/ftp/backup_remote_db.rb +0 -2
  8. data/lib/wordmove/actions/ftp/cleanup_after_adapt.rb +0 -2
  9. data/lib/wordmove/actions/ftp/download_remote_db.rb +0 -2
  10. data/lib/wordmove/actions/ftp/put_and_import_dump_remotely.rb +0 -2
  11. data/lib/wordmove/actions/setup_context_for_db.rb +2 -9
  12. data/lib/wordmove/actions/ssh/backup_remote_db.rb +0 -2
  13. data/lib/wordmove/actions/ssh/cleanup_after_adapt.rb +1 -3
  14. data/lib/wordmove/actions/ssh/download_remote_db.rb +6 -3
  15. data/lib/wordmove/actions/ssh/put_and_import_dump_remotely.rb +0 -2
  16. data/lib/wordmove/assets/wordmove_schema_local.yml +1 -3
  17. data/lib/wordmove/cli.rb +16 -23
  18. data/lib/wordmove/doctor/movefile.rb +1 -1
  19. data/lib/wordmove/doctor/mysql.rb +1 -1
  20. data/lib/wordmove/doctor/wpcli.rb +1 -1
  21. data/lib/wordmove/environments_list.rb +3 -3
  22. data/lib/wordmove/generators/movefile.rb +4 -5
  23. data/lib/wordmove/generators/movefile.yml +8 -6
  24. data/lib/wordmove/movefile.rb +25 -5
  25. data/lib/wordmove/organizers/ftp/pull.rb +18 -15
  26. data/lib/wordmove/organizers/ftp/push.rb +19 -16
  27. data/lib/wordmove/organizers/ssh/pull.rb +18 -15
  28. data/lib/wordmove/organizers/ssh/push.rb +19 -16
  29. data/lib/wordmove/version.rb +1 -1
  30. data/lib/wordmove/wpcli.rb +32 -32
  31. data/lib/wordmove.rb +4 -4
  32. data/wordmove.gemspec +2 -2
  33. metadata +6 -7
  34. data/lib/wordmove/generators/movefile_adapter.rb +0 -89
@@ -16,8 +16,8 @@ module Wordmove
16
16
  end
17
17
 
18
18
  def print
19
- contents = parse_movefile(movefile: movefile)
20
- generate_vhost_list(contents: contents)
19
+ contents = parse_movefile(movefile:)
20
+ generate_vhost_list(contents:)
21
21
  output
22
22
  end
23
23
 
@@ -55,7 +55,7 @@ module Wordmove
55
55
  #
56
56
  def generate_vhost_list(contents:)
57
57
  # select object which has 'vhost' only
58
- vhosts = select_vhost(contents: contents)
58
+ vhosts = select_vhost(contents:)
59
59
  vhosts.each do |list|
60
60
  if list[:env] == :local
61
61
  @local_vhost << list
@@ -1,16 +1,15 @@
1
1
  module Wordmove
2
2
  module Generators
3
3
  class Movefile
4
- include MovefileAdapter
5
-
6
4
  def self.generate
7
- new.copy_movefile
5
+ copy_movefile
8
6
  end
9
7
 
10
- def copy_movefile
8
+ def self.copy_movefile
9
+ wordpress_path = File.expand_path(Dir.pwd)
11
10
  content = ERB.new(File.read(File.join(__dir__, 'movefile.yml'))).result(binding)
12
- files = Dry::Files.new
13
11
 
12
+ files = Dry::Files.new
14
13
  files.write('movefile.yml', content)
15
14
  end
16
15
  end
@@ -2,14 +2,15 @@ global:
2
2
  sql_adapter: wpcli
3
3
 
4
4
  local:
5
- vhost: http://vhost.local
6
5
  wordpress_path: <%= wordpress_path %> # use an absolute path here
7
6
 
8
- database:
9
- name: <%= database.name %>
10
- user: <%= database.user %>
11
- password: "<%= database.password %>" # could be blank, so always use quotes around
12
- host: <%= database.host %>
7
+ # paths: # you can customize wordpress internal paths
8
+ # wp_content: wp-content
9
+ # uploads: wp-content/uploads
10
+ # plugins: wp-content/plugins
11
+ # mu_plugins: wp-content/mu-plugins
12
+ # themes: wp-content/themes
13
+ # languages: wp-content/languages
13
14
 
14
15
  production:
15
16
  vhost: http://example.com
@@ -40,6 +41,7 @@ production:
40
41
  - 'wp-config.php'
41
42
  - 'wp-content/*.sql.gz'
42
43
  - '*.orig'
44
+ - 'wp-cli.yml'
43
45
 
44
46
  # paths: # you can customize wordpress internal paths
45
47
  # wp_content: wp-content
@@ -56,8 +56,6 @@ module Wordmove
56
56
  private
57
57
 
58
58
  def fetch(verbose = true) # rubocop:disable Style/OptionalBooleanParameter
59
- load_dotenv
60
-
61
59
  entries = if config_file_name.nil?
62
60
  Dir["#{File.join(start_dir, '{M,m}ovefile')}{,.yml,.yaml}"]
63
61
  else
@@ -75,18 +73,40 @@ module Wordmove
75
73
  end
76
74
 
77
75
  found = entries.first
76
+
78
77
  logger.task("Using Movefile: #{found}") if verbose == true
79
- YAML.safe_load(ERB.new(File.read(found)).result, [], [], true).deep_symbolize_keys!
78
+ load_dotenv(verbose)
79
+
80
+ options = YAML.safe_load(ERB.new(File.read(found)).result, symbolize_names: true)
81
+
82
+ merge_local_options_from_wpcli(options)
83
+ end
84
+
85
+ def merge_local_options_from_wpcli(options)
86
+ config_path = options.dig(:local, :wordpress_path)
87
+
88
+ options.merge(
89
+ local: {
90
+ database: {
91
+ password: Wordmove::WpcliHelpers.get_config('DB_PASSWORD', config_path:),
92
+ host: Wordmove::WpcliHelpers.get_config('DB_HOST', config_path:),
93
+ name: Wordmove::WpcliHelpers.get_config('DB_NAME', config_path:),
94
+ user: Wordmove::WpcliHelpers.get_config('DB_USER', config_path:)
95
+ },
96
+ vhost: Wordmove::WpcliHelpers.get_option('siteurl', config_path:),
97
+ wordpress_path: config_path
98
+ }
99
+ )
80
100
  end
81
101
 
82
- def load_dotenv
102
+ def load_dotenv(verbose)
83
103
  env_files = Dir[File.join(start_dir, '.env')]
84
104
 
85
105
  found_env = env_files.first
86
106
 
87
107
  return false unless found_env.present?
88
108
 
89
- logger.info("Using .env file: #{found_env}")
109
+ logger.info("Using .env file: #{found_env}") if verbose
90
110
  Dotenv.load(found_env)
91
111
  end
92
112
 
@@ -6,21 +6,23 @@ module Wordmove
6
6
  include Wordmove::Actions::Helpers
7
7
  include Wordmove::Actions::Ftp::Helpers
8
8
 
9
- def self.call(cli_options:, movefile:)
9
+ # Can't use keyword arguments since LightService still has some problems with modern
10
+ # ruby syntax: https://github.com/adomokos/light-service/pull/224
11
+ def self.call(cli_options, movefile)
10
12
  logger = Logger.new($stdout, movefile.secrets).tap { |l| l.level = Logger::DEBUG }
11
13
  remote_options = movefile.options[movefile.environment]
12
- ftp_opts = ftp_options(remote_options: remote_options)
14
+ ftp_opts = ftp_options(remote_options:)
13
15
 
14
16
  LightService::Configuration.logger = ::Logger.new($stdout) if cli_options[:debug]
15
17
 
16
18
  with(
17
- cli_options: cli_options,
19
+ cli_options:,
18
20
  global_options: movefile.options[:global],
19
21
  local_options: movefile.options[:local],
20
- remote_options: remote_options,
21
- movefile: movefile,
22
- guardian: Wordmove::Guardian.new(cli_options: cli_options, action: :pull),
23
- logger: logger,
22
+ remote_options:,
23
+ movefile:,
24
+ guardian: Wordmove::Guardian.new(cli_options:, action: :pull),
25
+ logger:,
24
26
  photocopier: Photocopier::FTP
25
27
  .new(ftp_opts)
26
28
  .tap { |c| c.logger = logger }
@@ -35,14 +37,15 @@ module Wordmove
35
37
  ->(ctx) { ctx.wordpress_task },
36
38
  [Wordmove::Actions::Ftp::PullWordpress]
37
39
  ),
38
- iterate(:folder_tasks, [Wordmove::Actions::Ftp::GetDirectory])
39
- ].concat [
40
- Wordmove::Actions::SetupContextForDb,
41
- Wordmove::Actions::BackupLocalDb,
42
- Wordmove::Actions::Ftp::DownloadRemoteDb,
43
- Wordmove::Actions::AdaptRemoteDb,
44
- Wordmove::Actions::Ftp::CleanupAfterAdapt
45
- ].concat [
40
+ iterate(:folder_tasks, [Wordmove::Actions::Ftp::GetDirectory]),
41
+ reduce_if(->(ctx) { ctx.database_task },
42
+ [
43
+ Wordmove::Actions::SetupContextForDb,
44
+ Wordmove::Actions::BackupLocalDb,
45
+ Wordmove::Actions::Ftp::DownloadRemoteDb,
46
+ Wordmove::Actions::AdaptRemoteDb,
47
+ Wordmove::Actions::Ftp::CleanupAfterAdapt
48
+ ]),
46
49
  Wordmove::Actions::RunAfterPullHook # Will fail and warn the user
47
50
  ]
48
51
  end
@@ -6,21 +6,23 @@ module Wordmove
6
6
  include Wordmove::Actions::Helpers
7
7
  include Wordmove::Actions::Ftp::Helpers
8
8
 
9
- def self.call(cli_options:, movefile:)
9
+ # Can't use keyword arguments since LightService still has some problems with modern
10
+ # ruby syntax: https://github.com/adomokos/light-service/pull/224
11
+ def self.call(cli_options, movefile)
10
12
  logger = Logger.new($stdout, movefile.secrets).tap { |l| l.level = Logger::DEBUG }
11
13
  remote_options = movefile.options[movefile.environment]
12
- ftp_opts = ftp_options(remote_options: remote_options)
14
+ ftp_opts = ftp_options(remote_options:)
13
15
 
14
16
  LightService::Configuration.logger = ::Logger.new($stdout) if cli_options[:debug]
15
17
 
16
18
  with(
17
- cli_options: cli_options,
19
+ cli_options:,
18
20
  global_options: movefile.options[:global],
19
21
  local_options: movefile.options[:local],
20
- remote_options: remote_options,
21
- movefile: movefile,
22
- guardian: Wordmove::Guardian.new(cli_options: cli_options, action: :push),
23
- logger: logger,
22
+ remote_options:,
23
+ movefile:,
24
+ guardian: Wordmove::Guardian.new(cli_options:, action: :push),
25
+ logger:,
24
26
  photocopier: Photocopier::FTP
25
27
  .new(ftp_opts)
26
28
  .tap { |c| c.logger = logger }
@@ -35,15 +37,16 @@ module Wordmove
35
37
  ->(ctx) { ctx.wordpress_task },
36
38
  [Wordmove::Actions::Ftp::PushWordpress]
37
39
  ),
38
- iterate(:folder_tasks, [Wordmove::Actions::Ftp::PutDirectory])
39
- ].concat [
40
- Wordmove::Actions::SetupContextForDb,
41
- Wordmove::Actions::Ftp::DownloadRemoteDb,
42
- Wordmove::Actions::Ftp::BackupRemoteDb,
43
- Wordmove::Actions::AdaptLocalDb,
44
- Wordmove::Actions::Ftp::PutAndImportDumpRemotely,
45
- Wordmove::Actions::Ftp::CleanupAfterAdapt
46
- ].concat [
40
+ iterate(:folder_tasks, [Wordmove::Actions::Ftp::PutDirectory]),
41
+ reduce_if(->(ctx) { ctx.database_task },
42
+ [
43
+ Wordmove::Actions::SetupContextForDb,
44
+ Wordmove::Actions::Ftp::DownloadRemoteDb,
45
+ Wordmove::Actions::Ftp::BackupRemoteDb,
46
+ Wordmove::Actions::AdaptLocalDb,
47
+ Wordmove::Actions::Ftp::PutAndImportDumpRemotely,
48
+ Wordmove::Actions::Ftp::CleanupAfterAdapt
49
+ ]),
47
50
  Wordmove::Actions::RunAfterPushHook # Will fail and warn the user
48
51
  ]
49
52
  end
@@ -6,21 +6,23 @@ module Wordmove
6
6
  include Wordmove::Actions::Helpers
7
7
  include Wordmove::Actions::Ssh::Helpers
8
8
 
9
- def self.call(cli_options:, movefile:)
9
+ # Can't use keyword arguments since LightService still has some problems with modern
10
+ # ruby syntax: https://github.com/adomokos/light-service/pull/224
11
+ def self.call(cli_options, movefile)
10
12
  logger = Logger.new($stdout, movefile.secrets).tap { |l| l.level = Logger::DEBUG }
11
13
  remote_options = movefile.options[movefile.environment]
12
- ssh_opts = ssh_options(remote_options: remote_options, simulate: cli_options[:simulate])
14
+ ssh_opts = ssh_options(remote_options:, simulate: cli_options[:simulate])
13
15
 
14
16
  LightService::Configuration.logger = ::Logger.new($stdout) if cli_options[:debug]
15
17
 
16
18
  with(
17
- cli_options: cli_options,
19
+ cli_options:,
18
20
  global_options: movefile.options[:global],
19
21
  local_options: movefile.options[:local],
20
- remote_options: remote_options,
21
- movefile: movefile,
22
- guardian: Wordmove::Guardian.new(cli_options: cli_options, action: :pull),
23
- logger: logger,
22
+ remote_options:,
23
+ movefile:,
24
+ guardian: Wordmove::Guardian.new(cli_options:, action: :pull),
25
+ logger:,
24
26
  photocopier: Photocopier::SSH
25
27
  .new(ssh_opts)
26
28
  .tap { |c| c.logger = logger }
@@ -35,14 +37,15 @@ module Wordmove
35
37
  ->(ctx) { ctx.wordpress_task },
36
38
  [Wordmove::Actions::Ssh::PullWordpress]
37
39
  ),
38
- iterate(:folder_tasks, [Wordmove::Actions::Ssh::GetDirectory])
39
- ].concat [
40
- Wordmove::Actions::SetupContextForDb,
41
- Wordmove::Actions::BackupLocalDb,
42
- Wordmove::Actions::Ssh::DownloadRemoteDb,
43
- Wordmove::Actions::AdaptRemoteDb,
44
- Wordmove::Actions::Ssh::CleanupAfterAdapt
45
- ].concat [
40
+ iterate(:folder_tasks, [Wordmove::Actions::Ssh::GetDirectory]),
41
+ reduce_if(->(ctx) { ctx.database_task },
42
+ [
43
+ Wordmove::Actions::SetupContextForDb,
44
+ Wordmove::Actions::BackupLocalDb,
45
+ Wordmove::Actions::Ssh::DownloadRemoteDb,
46
+ Wordmove::Actions::AdaptRemoteDb,
47
+ Wordmove::Actions::Ssh::CleanupAfterAdapt
48
+ ]),
46
49
  Wordmove::Actions::RunAfterPullHook
47
50
  ]
48
51
  end
@@ -6,21 +6,23 @@ module Wordmove
6
6
  include Wordmove::Actions::Helpers
7
7
  include Wordmove::Actions::Ssh::Helpers
8
8
 
9
- def self.call(cli_options:, movefile:)
9
+ # Can't use keyword arguments since LightService still has some problems with modern
10
+ # ruby syntax: https://github.com/adomokos/light-service/pull/224
11
+ def self.call(cli_options, movefile)
10
12
  logger = Logger.new($stdout, movefile.secrets).tap { |l| l.level = Logger::DEBUG }
11
13
  remote_options = movefile.options[movefile.environment]
12
- ssh_opts = ssh_options(remote_options: remote_options, simulate: cli_options[:simulate])
14
+ ssh_opts = ssh_options(remote_options:, simulate: cli_options[:simulate])
13
15
 
14
16
  LightService::Configuration.logger = ::Logger.new($stdout) if cli_options[:debug]
15
17
 
16
18
  with(
17
- cli_options: cli_options,
19
+ cli_options:,
18
20
  global_options: movefile.options[:global],
19
21
  local_options: movefile.options[:local],
20
- remote_options: remote_options,
21
- movefile: movefile,
22
- guardian: Wordmove::Guardian.new(cli_options: cli_options, action: :push),
23
- logger: logger,
22
+ remote_options:,
23
+ movefile:,
24
+ guardian: Wordmove::Guardian.new(cli_options:, action: :push),
25
+ logger:,
24
26
  photocopier: Photocopier::SSH
25
27
  .new(ssh_opts)
26
28
  .tap { |c| c.logger = logger }
@@ -35,15 +37,16 @@ module Wordmove
35
37
  ->(ctx) { ctx.wordpress_task },
36
38
  [Wordmove::Actions::Ssh::PushWordpress]
37
39
  ),
38
- iterate(:folder_tasks, [Wordmove::Actions::Ssh::PutDirectory])
39
- ].concat [
40
- Wordmove::Actions::SetupContextForDb,
41
- Wordmove::Actions::Ssh::DownloadRemoteDb,
42
- Wordmove::Actions::Ssh::BackupRemoteDb,
43
- Wordmove::Actions::AdaptLocalDb,
44
- Wordmove::Actions::Ssh::PutAndImportDumpRemotely,
45
- Wordmove::Actions::Ssh::CleanupAfterAdapt
46
- ].concat [
40
+ iterate(:folder_tasks, [Wordmove::Actions::Ssh::PutDirectory]),
41
+ reduce_if(->(ctx) { ctx.database_task },
42
+ [
43
+ Wordmove::Actions::SetupContextForDb,
44
+ Wordmove::Actions::Ssh::DownloadRemoteDb,
45
+ Wordmove::Actions::Ssh::BackupRemoteDb,
46
+ Wordmove::Actions::AdaptLocalDb,
47
+ Wordmove::Actions::Ssh::PutAndImportDumpRemotely,
48
+ Wordmove::Actions::Ssh::CleanupAfterAdapt
49
+ ]),
47
50
  Wordmove::Actions::RunAfterPushHook
48
51
  ]
49
52
  end
@@ -1,3 +1,3 @@
1
1
  module Wordmove
2
- VERSION = '6.0.0.alpha.2'.freeze
2
+ VERSION = '6.0.0.alpha.6'.freeze
3
3
  end
@@ -1,7 +1,7 @@
1
1
  module Wordmove
2
2
  # This class is a sort of mini-wrapper around the wp-cli executable.
3
3
  # It's responsible to run or produce wp-cli commands.
4
- module Wpcli
4
+ module WpcliHelpers
5
5
  extend ActiveSupport::Concern
6
6
 
7
7
  included do
@@ -17,40 +17,28 @@ module Wordmove
17
17
  system('which wp > /dev/null 2>&1')
18
18
  end
19
19
 
20
- # Compose and returns the search-replace command. It's intended to be
21
- # used from a +LightService::Action+
22
- #
23
- # @param context [LightService::Context] The context of an action
24
- # @param config_key [:vhost, :wordpress_path] Determines what will be replaced in DB
25
- # @return [String]
26
- # @!scope class
27
- def wpcli_search_replace_command(context, config_key)
28
- unless %i[vhost wordpress_path].include?(config_key)
29
- raise ArgumentError, "Unexpected `config_key` #{config_key}.:vhost" \
30
- 'or :wordpress_path expected'
31
- end
32
-
33
- [
34
- 'wp search-replace',
35
- "--path=#{wpcli_config_path(context)}",
36
- context.remote_options[config_key],
37
- context.local_options[config_key],
38
- '--quiet',
39
- '--skip-columns=guid',
40
- '--all-tables',
41
- '--allow-root'
42
- ].join(' ')
43
- end
44
-
45
20
  # Returns the wordpress path from wp-cli (with precedence) or from movefile
46
21
  #
47
- # It's intended to be used from a +LightService::Action+
22
+ # It's intended to be used from a +LightService::Action+, but it also supports
23
+ # to receive a path as argument. If the argument is not a LightService::Context
24
+ # then it will be treated as a path.
25
+ # The path passed as argument should be the wordpress installation path, but it's
26
+ # not strictly mandatory: the method will try to load a wpcli's YAML config
27
+ # from that path, so you can potentially use it with any path
48
28
  #
49
- # @param context [LightService::Context] The context of an action
29
+ # @param context [LightService::Context|String] The context of an action or a path as string
50
30
  # @return [String]
51
31
  # @!scope class
52
- def wpcli_config_path(context)
53
- load_from_yml(context) || load_from_wpcli || context.local_options[:wordpress_path]
32
+ def wpcli_config_path(context_or_path)
33
+ context = if context_or_path.is_a? LightService::Context
34
+ context_or_path
35
+ else
36
+ # We need to make it quack like a duck in order to be
37
+ # backward compatible with previous code
38
+ { local_options: { wordpress_path: context_or_path } }
39
+ end
40
+
41
+ load_from_yml(context) || load_from_wpcli || context.dig(:local_options, :wordpress_path)
54
42
  end
55
43
 
56
44
  # If wordpress installation brings a `wp-cli.yml` file in its root folder,
@@ -60,7 +48,8 @@ module Wordmove
60
48
  # @!scope class
61
49
  # @!visibility private
62
50
  def load_from_yml(context)
63
- yml_path = File.join(context.local_options[:wordpress_path], 'wp-cli.yml')
51
+ config_path = context.dig(:local_options, :wordpress_path) || '.'
52
+ yml_path = File.join(config_path, 'wp-cli.yml')
64
53
 
65
54
  return unless File.exist?(yml_path)
66
55
 
@@ -75,11 +64,22 @@ module Wordmove
75
64
  # @!scope class
76
65
  # @!visibility private
77
66
  def load_from_wpcli
78
- wpcli_config = JSON.parse(`wp cli param-dump --with-values`, symbolize_names: true)
67
+ wpcli_config = JSON.parse(
68
+ `wp cli param-dump --with-values --allow-root`,
69
+ symbolize_names: true
70
+ )
79
71
  wpcli_config.dig(:path, :current)
80
72
  rescue JSON::ParserError => _e
81
73
  nil
82
74
  end
83
75
  end
76
+
77
+ def self.get_option(option, config_path:)
78
+ `wp option get #{option} --allow-root --path=#{config_path}`.chomp
79
+ end
80
+
81
+ def self.get_config(config, config_path:)
82
+ `wp config get #{config} --allow-root --path=#{config_path}`.chomp
83
+ end
84
84
  end
85
85
  end
data/lib/wordmove.rb CHANGED
@@ -17,6 +17,8 @@ require 'yaml'
17
17
 
18
18
  require 'photocopier'
19
19
 
20
+ require 'wordmove/wpcli'
21
+
20
22
  require 'wordmove/cli'
21
23
  require 'wordmove/doctor'
22
24
  require 'wordmove/doctor/movefile'
@@ -32,9 +34,7 @@ require 'wordmove/movefile'
32
34
  require 'wordmove/wordpress_directory'
33
35
  require 'wordmove/version'
34
36
  require 'wordmove/environments_list'
35
- require 'wordmove/wpcli'
36
37
 
37
- require 'wordmove/generators/movefile_adapter'
38
38
  require 'wordmove/generators/movefile'
39
39
 
40
40
  require 'wordmove/db_paths_config'
@@ -42,8 +42,8 @@ require 'wordmove/db_paths_config'
42
42
  require 'wordmove/actions/helpers'
43
43
  require 'wordmove/actions/ssh/helpers'
44
44
  require 'wordmove/actions/ftp/helpers'
45
- Dir[File.join(__dir__, 'wordmove/actions/**/*.rb')].sort.each { |file| require file }
46
- Dir[File.join(__dir__, 'wordmove/organizers/**/*.rb')].sort.each { |file| require file }
45
+ Dir[File.join(__dir__, 'wordmove/actions/**/*.rb')].each { |file| require file }
46
+ Dir[File.join(__dir__, 'wordmove/organizers/**/*.rb')].each { |file| require file }
47
47
 
48
48
  module Wordmove
49
49
  # Interactors' namespce. Interactors are called "Actions", following the LightService convention.
data/wordmove.gemspec CHANGED
@@ -36,12 +36,12 @@ Gem::Specification.new do |spec|
36
36
  spec.add_runtime_dependency 'dry-configurable', '~> 0.13.0'
37
37
  spec.add_runtime_dependency 'kwalify', '~> 0.7.2'
38
38
  spec.add_runtime_dependency 'light-service', '~> 0.17.0'
39
- spec.add_runtime_dependency 'photocopier', '~> 1.4', '>= 1.4.0'
39
+ spec.add_runtime_dependency 'photocopier', '~> 1.4', '>= 1.4.1'
40
40
  # spec.add_runtime_dependency 'thor', '~> 0.20.3'
41
41
  spec.add_runtime_dependency 'dry-cli', '~> 0.7.0'
42
42
  spec.add_runtime_dependency 'dry-files', '~> 0.1.0'
43
43
 
44
- spec.required_ruby_version = '>= 2.6.0' # rubocop:disable Gemspec/RequiredRubyVersion
44
+ spec.required_ruby_version = '>= 3.1.0'
45
45
 
46
46
  spec.add_development_dependency 'bundler', '~> 2.3.3'
47
47
  spec.add_development_dependency 'pry-byebug', '~> 3.1'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wordmove
3
3
  version: !ruby/object:Gem::Version
4
- version: 6.0.0.alpha.2
4
+ version: 6.0.0.alpha.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stefano Verna
@@ -12,7 +12,7 @@ authors:
12
12
  autorequire:
13
13
  bindir: exe
14
14
  cert_chain: []
15
- date: 2021-12-27 00:00:00.000000000 Z
15
+ date: 2022-01-04 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: activesupport
@@ -107,7 +107,7 @@ dependencies:
107
107
  version: '1.4'
108
108
  - - ">="
109
109
  - !ruby/object:Gem::Version
110
- version: 1.4.0
110
+ version: 1.4.1
111
111
  type: :runtime
112
112
  prerelease: false
113
113
  version_requirements: !ruby/object:Gem::Requirement
@@ -117,7 +117,7 @@ dependencies:
117
117
  version: '1.4'
118
118
  - - ">="
119
119
  - !ruby/object:Gem::Version
120
- version: 1.4.0
120
+ version: 1.4.1
121
121
  - !ruby/object:Gem::Dependency
122
122
  name: dry-cli
123
123
  requirement: !ruby/object:Gem::Requirement
@@ -375,7 +375,6 @@ files:
375
375
  - lib/wordmove/exceptions.rb
376
376
  - lib/wordmove/generators/movefile.rb
377
377
  - lib/wordmove/generators/movefile.yml
378
- - lib/wordmove/generators/movefile_adapter.rb
379
378
  - lib/wordmove/guardian.rb
380
379
  - lib/wordmove/hook.rb
381
380
  - lib/wordmove/logger.rb
@@ -410,14 +409,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
410
409
  requirements:
411
410
  - - ">="
412
411
  - !ruby/object:Gem::Version
413
- version: 2.6.0
412
+ version: 3.1.0
414
413
  required_rubygems_version: !ruby/object:Gem::Requirement
415
414
  requirements:
416
415
  - - ">"
417
416
  - !ruby/object:Gem::Version
418
417
  version: 1.3.1
419
418
  requirements: []
420
- rubygems_version: 3.1.2
419
+ rubygems_version: 3.3.3
421
420
  signing_key:
422
421
  specification_version: 4
423
422
  summary: Wordmove, Capistrano for Wordpress
@@ -1,89 +0,0 @@
1
- module Wordmove
2
- module Generators
3
- module MovefileAdapter
4
- def wordpress_path
5
- File.expand_path(Dir.pwd)
6
- end
7
-
8
- def database
9
- DBConfigReader.config
10
- end
11
- end
12
-
13
- class DBConfigReader
14
- def self.config
15
- new.config
16
- end
17
-
18
- def config
19
- Struct.new(
20
- :name,
21
- :user,
22
- :password,
23
- :host,
24
- keyword_init: true
25
- ).new(database_config)
26
- end
27
-
28
- def database_config
29
- if wp_config_exists?
30
- WordpressDBConfig.config
31
- else
32
- DefaultDBConfig.config
33
- end
34
- end
35
-
36
- def wp_config_exists?
37
- File.exist?(WordpressDirectory.default_path_for(:wp_config))
38
- end
39
- end
40
-
41
- class DefaultDBConfig
42
- def self.config
43
- {
44
- name: 'database_name',
45
- user: 'user',
46
- password: 'password',
47
- host: '127.0.0.1'
48
- }
49
- end
50
- end
51
-
52
- class WordpressDBConfig
53
- def self.config
54
- new.config
55
- end
56
-
57
- def wp_config
58
- @wp_config ||= File.read(
59
- WordpressDirectory.default_path_for(:wp_config)
60
- ).encode('utf-8', invalid: :replace)
61
- end
62
-
63
- def wp_definitions
64
- {
65
- name: 'DB_NAME',
66
- user: 'DB_USER',
67
- password: 'DB_PASSWORD',
68
- host: 'DB_HOST'
69
- }
70
- end
71
-
72
- def wp_definition_regex(definition)
73
- /['"]#{definition}['"],\s*["'](?<value>.*)['"]/
74
- end
75
-
76
- def defaults
77
- DefaultDBConfig.config.clone
78
- end
79
-
80
- def config
81
- wp_definitions.each_with_object(defaults) do |(key, definition), result|
82
- wp_config.match(wp_definition_regex(definition)) do |match|
83
- result[key] = match[:value]
84
- end
85
- end
86
- end
87
- end
88
- end
89
- end