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
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6a182f54bea0a027d35316cdf368c0c3c98a706bdc3bfbc176190fb7928a98df
4
- data.tar.gz: 21ad918da1375bff9004661fcc6f2a3a951fe075b2d9baa722230137d0df7648
3
+ metadata.gz: 1e1645bb92c5ec1ef2f74eb99eb0ad62eb42648af628104c23c6286e3bf1505b
4
+ data.tar.gz: 5b44c223013a491f2fbca11da41d063597363f8a28b07cf14f556d48b79c4aac
5
5
  SHA512:
6
- metadata.gz: 566f88fff0e931d3c9df3cb3a5f121be2e9f43ab8ba6ed7e5f33db3168e84f5b92b8c8b34cee36ef2304d4c478ee1fffbbcf64b3d6864fe6b0cddd2017e64bab
7
- data.tar.gz: a2ccc8a72bfb597a600acfdffe0e1df4800e5bf34c0dc66d21fbf6d12c9c0f4163585a025cb37ea67f0d79adcfeef6ab901a18be5dddc099d17b0848c3bb7f60
6
+ metadata.gz: 1039454681f0c345713c3cb3777429197deac2a50f1f2bddf781fe2145e2ba099365a5600edad49272d680ddaa1b8f4be3a82d7a0f9f9929dbf3eb38c28f5999
7
+ data.tar.gz: 4215958770c983f0d156162e943eaefe06d55c7e4a9cc1d085e7ec87e7130cca7a43daf9881602350b01c65a5f576f38d1c85b12522bbd6964be84beadf5f59b
data/.rubocop.yml CHANGED
@@ -1,5 +1,5 @@
1
1
  AllCops:
2
- TargetRubyVersion: 2.7.1
2
+ TargetRubyVersion: 3.1.0
3
3
  DisplayCopNames: true
4
4
  DisplayStyleGuide: true
5
5
  NewCops: enable
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 2.7.1
1
+ 3.1.0
@@ -9,7 +9,7 @@ module Wordmove
9
9
  class AdaptLocalDb
10
10
  extend ::LightService::Action
11
11
  include Wordmove::Actions::Helpers
12
- include Wordmove::Wpcli
12
+ include Wordmove::WpcliHelpers
13
13
 
14
14
  expects :local_options,
15
15
  :remote_options,
@@ -30,8 +30,6 @@ module Wordmove
30
30
  # @!scope class
31
31
  # @return [LightService::Context] Action's context
32
32
  executed do |context| # rubocop:disable Metrics/BlockLength
33
- next context if context.database_task == false
34
-
35
33
  context.logger.task 'Adapt local DB'
36
34
 
37
35
  unless wp_in_path?
@@ -40,63 +38,104 @@ module Wordmove
40
38
 
41
39
  next context if simulate?(cli_options: context.cli_options)
42
40
 
43
- result = Wordmove::Actions::RunLocalCommand.execute(
44
- cli_options: context.cli_options,
45
- logger: context.logger,
46
- command: mysql_dump_command(
47
- env_db_options: context.local_options[:database],
48
- save_to_path: context.db_paths.local.path
49
- )
50
- )
51
- context.fail_and_return!(result.message) if result.failure?
41
+ context.logger.task_step true, dump_command(context)
42
+ begin
43
+ system(dump_command(context), exception: true)
44
+ rescue RuntimeError, SystemExit => e
45
+ context.fail_and_return!("Local command status reports an error: #{e.message}")
46
+ end
52
47
 
53
48
  if context.cli_options[:no_adapt]
54
49
  context.logger.warn 'Skipping DB adapt'
55
50
  else
56
- result = Wordmove::Actions::RunLocalCommand.execute(
57
- cli_options: context.cli_options,
58
- logger: context.logger,
59
- command: wpcli_search_replace_command(context, :vhost)
60
- )
61
- context.fail_and_return!(result.message) if result.failure?
62
-
63
- result = Wordmove::Actions::RunLocalCommand.execute(
64
- cli_options: context.cli_options,
65
- logger: context.logger,
66
- command: wpcli_search_replace_command(context, :wordpress_path)
67
- )
68
- context.fail_and_return!(result.message) if result.failure?
69
- end
51
+ %i[vhost wordpress_path].each do |key|
52
+ command = search_replace_command(context, key)
53
+ context.logger.task_step true, command
70
54
 
71
- result = Wordmove::Actions::RunLocalCommand.execute(
72
- cli_options: context.cli_options,
55
+ begin
56
+ system(command, exception: true)
57
+ rescue RuntimeError, SystemExit => e
58
+ context.fail_and_return!("Local command status reports an error: #{e.message}")
59
+ end
60
+ end
61
+ end
73
62
 
74
- logger: context.logger,
75
- command: mysql_dump_command(
76
- env_db_options: context.local_options[:database],
77
- save_to_path: context.db_paths.local.adapted_path
78
- )
79
- )
80
- context.fail_and_return!(result.message) if result.failure?
63
+ context.logger.task_step true, dump_adapted_command(context)
64
+ begin
65
+ system(dump_adapted_command(context), exception: true)
66
+ rescue RuntimeError, SystemExit => e
67
+ context.fail_and_return!("Local command status reports an error: #{e.message}")
68
+ end
81
69
 
82
70
  if context.photocopier.is_a? Photocopier::SSH
83
- result = Wordmove::Actions::RunLocalCommand.execute(
84
- cli_options: context.cli_options,
85
- logger: context.logger,
86
- command: compress_command(file_path: context.db_paths.local.adapted_path)
87
- )
88
- context.fail_and_return!(result.message) if result.failure?
71
+ context.logger.task_step true, compress_command(context)
72
+ begin
73
+ system(compress_command(context), exception: true)
74
+ rescue RuntimeError, SystemExit => e
75
+ context.fail_and_return!("Local command status reports an error: #{e.message}")
76
+ end
77
+ end
78
+
79
+ context.logger.task_step true, import_original_db_command(context)
80
+ begin
81
+ system(import_original_db_command(context), exception: true)
82
+ rescue RuntimeError, SystemExit => e
83
+ context.fail_and_return!("Local command status reports an error: #{e.message}")
84
+ end
85
+ end
86
+
87
+ def self.dump_command(context)
88
+ "wp db export #{context.db_paths.local.path} --allow-root --quiet " \
89
+ "--path=#{wpcli_config_path(context)}"
90
+ end
91
+
92
+ def self.dump_adapted_command(context)
93
+ "wp db export #{context.db_paths.local.adapted_path} --allow-root --quiet " \
94
+ "--path=#{wpcli_config_path(context)}"
95
+ end
96
+
97
+ def self.import_original_db_command(context)
98
+ "wp db import #{context.db_paths.local.path} --allow-root --quiet " \
99
+ "--path=#{wpcli_config_path(context)}"
100
+ end
101
+
102
+ def self.compress_command(context)
103
+ command = ['nice']
104
+ command << '-n'
105
+ command << '0'
106
+ command << 'gzip'
107
+ command << '-9'
108
+ command << '-f'
109
+ command << "\"#{context.db_paths.local.adapted_path}\""
110
+ command.join(' ')
111
+ end
112
+
113
+ # Compose and returns the search-replace command. It's intended to be
114
+ # used from a +LightService::Action+
115
+ #
116
+ # @param context [LightService::Context] The context of an action
117
+ # @param config_key [:vhost, :wordpress_path] Determines what will be replaced in DB
118
+ # @return [String]
119
+ # @!scope class
120
+ def self.search_replace_command(context, config_key)
121
+ unless %i[vhost wordpress_path].include?(config_key)
122
+ raise ArgumentError, "Unexpected `config_key` #{config_key}.:vhost" \
123
+ 'or :wordpress_path expected'
89
124
  end
90
125
 
91
- result = Wordmove::Actions::RunLocalCommand.execute(
92
- cli_options: context.cli_options,
93
- logger: context.logger,
94
- command: mysql_import_command(
95
- dump_path: context.db_paths.local.path,
96
- env_db_options: context.local_options[:database]
97
- )
98
- )
99
- context.fail_and_return!(result.message) if result.failure?
126
+ [
127
+ 'wp search-replace',
128
+ "--path=#{wpcli_config_path(context)}",
129
+ '"\A' + context.dig(:local_options, config_key) + '\Z"', # rubocop:disable Style/StringConcatenation
130
+ '"' + context.dig(:remote_options, config_key) + '"', # rubocop:disable Style/StringConcatenation
131
+ '--regex-delimiter="|"',
132
+ '--regex',
133
+ '--precise',
134
+ '--quiet',
135
+ '--skip-columns=guid',
136
+ '--all-tables',
137
+ '--allow-root'
138
+ ].join(' ')
100
139
  end
101
140
  end
102
141
  end
@@ -14,7 +14,7 @@ module Wordmove
14
14
  class AdaptRemoteDb
15
15
  extend ::LightService::Action
16
16
  include Wordmove::Actions::Helpers
17
- include Wordmove::Wpcli
17
+ include Wordmove::WpcliHelpers
18
18
 
19
19
  expects :local_options,
20
20
  :cli_options,
@@ -30,8 +30,6 @@ module Wordmove
30
30
  # @!scope class
31
31
  # @return [LightService::Context] Action's context
32
32
  executed do |context| # rubocop:disable Metrics/BlockLength
33
- next context if context.database_task == false
34
-
35
33
  context.logger.task 'Adapt remote DB'
36
34
 
37
35
  unless wp_in_path?
@@ -41,11 +39,12 @@ module Wordmove
41
39
  next context if simulate?(cli_options: context.cli_options)
42
40
 
43
41
  if File.exist?(context.db_paths.local.gzipped_path)
44
- Wordmove::Actions::RunLocalCommand.execute(
45
- cli_options: context.cli_options,
46
- logger: context.logger,
47
- command: uncompress_command(file_path: context.db_paths.local.gzipped_path)
48
- )
42
+ context.logger.task_step true, uncompress_command(context)
43
+ begin
44
+ system(uncompress_command(context), exception: true)
45
+ rescue RuntimeError, SystemExit => e
46
+ context.fail_and_return!("Local command status reports an error: #{e.message}")
47
+ end
49
48
  end
50
49
 
51
50
  unless File.exist?(context.db_paths.local.path)
@@ -54,37 +53,76 @@ module Wordmove
54
53
  )
55
54
  end
56
55
 
57
- result = Wordmove::Actions::RunLocalCommand.execute(
58
- cli_options: context.cli_options,
59
- logger: context.logger,
60
- command: mysql_import_command(
61
- dump_path: context.db_paths.local.path,
62
- env_db_options: context.local_options[:database]
63
- )
64
- )
65
- context.fail_and_return!(result.message) if result.failure?
56
+ context.logger.task_step true, import_db_command(context)
57
+ begin
58
+ system(import_db_command(context), exception: true)
59
+ rescue RuntimeError, SystemExit => e
60
+ context.fail_and_return!("Local command status reports an error: #{e.message}")
61
+ end
66
62
 
67
63
  if context.cli_options[:no_adapt]
68
64
  context.logger.warn 'Skipping DB adapt'
69
65
  next context
70
66
  end
71
67
 
72
- result = Wordmove::Actions::RunLocalCommand.execute(
73
- cli_options: context.cli_options,
74
- logger: context.logger,
75
- command: wpcli_search_replace_command(context, :vhost)
76
- )
77
- context.fail_and_return!(result.message) if result.failure?
78
-
79
- result = Wordmove::Actions::RunLocalCommand.execute(
80
- cli_options: context.cli_options,
81
- logger: context.logger,
82
- command: wpcli_search_replace_command(context, :wordpress_path)
83
- )
84
- context.fail_and_return!(result.message) if result.failure?
68
+ %i[vhost wordpress_path].each do |key|
69
+ command = search_replace_command(context, key)
70
+ context.logger.task_step true, command
71
+ begin
72
+ system(command, exception: true)
73
+ rescue RuntimeError, SystemExit => e
74
+ context.fail_and_return!("Local command status reports an error: #{e.message}")
75
+ end
76
+ end
85
77
 
86
78
  context.logger.success 'Local DB adapted'
87
79
  end
80
+
81
+ # Construct the command to deflate a compressed file as a string.
82
+ #
83
+ # @param file_path [String] The path where the file to be deflated is located
84
+ # @return [String] the command
85
+ # @!scope class
86
+ def self.uncompress_command(context)
87
+ command = ['gzip']
88
+ command << '-d'
89
+ command << '-f'
90
+ command << "\"#{context.db_paths.local.gzipped_path}\""
91
+ command.join(' ')
92
+ end
93
+
94
+ def self.import_db_command(context)
95
+ "wp db import #{context.db_paths.local.path} --allow-root --quiet " \
96
+ "--path=#{wpcli_config_path(context)}"
97
+ end
98
+
99
+ # Compose and returns the search-replace command. It's intended to be
100
+ # used from a +LightService::Action+
101
+ #
102
+ # @param context [LightService::Context] The context of an action
103
+ # @param config_key [:vhost, :wordpress_path] Determines what will be replaced in DB
104
+ # @return [String]
105
+ # @!scope class
106
+ def self.search_replace_command(context, config_key)
107
+ unless %i[vhost wordpress_path].include?(config_key)
108
+ raise ArgumentError, "Unexpected `config_key` #{config_key}.:vhost" \
109
+ 'or :wordpress_path expected'
110
+ end
111
+
112
+ [
113
+ 'wp search-replace',
114
+ "--path=#{wpcli_config_path(context)}",
115
+ '"\A' + context.dig(:remote_options, config_key) + '\Z"', # rubocop:disable Style/StringConcatenation
116
+ '"' + context.dig(:local_options, config_key) + '"', # rubocop:disable Style/StringConcatenation
117
+ '--regex-delimiter="|"',
118
+ '--regex',
119
+ '--precise',
120
+ '--quiet',
121
+ '--skip-columns=guid',
122
+ '--all-tables',
123
+ '--allow-root'
124
+ ].join(' ')
125
+ end
88
126
  end
89
127
  end
90
128
  end
@@ -21,8 +21,6 @@ module Wordmove
21
21
  # @!scope class
22
22
  # @return [LightService::Context] Action's context
23
23
  executed do |context|
24
- next context if context.database_task == false
25
-
26
24
  context.logger.task 'Backup local DB'
27
25
 
28
26
  if simulate?(cli_options: context.cli_options)
@@ -32,27 +30,41 @@ module Wordmove
32
30
  next context
33
31
  end
34
32
 
35
- result = Wordmove::Actions::RunLocalCommand.execute(
36
- cli_options: context.cli_options,
37
- logger: context.logger,
38
- command: mysql_dump_command(
39
- env_db_options: context.local_options[:database],
40
- save_to_path: context.db_paths.backup.local.path
41
- )
42
- )
43
- context.fail_and_return!(result.message) if result.failure?
33
+ context.logger.task_step true, dump_command(context)
44
34
 
45
- result = Wordmove::Actions::RunLocalCommand.execute(
46
- cli_options: context.cli_options,
47
- logger: context.logger,
48
- command: compress_command(file_path: context.db_paths.backup.local.path)
49
- )
50
- context.fail_and_return!(result.message) if result.failure?
35
+ begin
36
+ system(dump_command(context), exception: true)
37
+ rescue RuntimeError, SystemExit => e
38
+ context.fail_and_return!("Local command status reports an error: #{e.message}")
39
+ end
40
+
41
+ context.logger.task_step true, compress_command(context)
42
+
43
+ begin
44
+ system(compress_command(context), exception: true)
45
+ rescue RuntimeError, SystemExit => e
46
+ context.fail_and_return!("Local command status reports an error: #{e.message}")
47
+ end
51
48
 
52
49
  context.logger.success(
53
50
  "Backup saved at #{context.db_paths.backup.local.gzipped_path}"
54
51
  )
55
52
  end
53
+
54
+ def self.dump_command(context)
55
+ "wp db export #{context.db_paths.backup.local.path} --allow-root --quiet"
56
+ end
57
+
58
+ def self.compress_command(context)
59
+ command = ['nice']
60
+ command << '-n'
61
+ command << '0'
62
+ command << 'gzip'
63
+ command << '-9'
64
+ command << '-f'
65
+ command << "\"#{context.db_paths.backup.local.path}\""
66
+ command.join(' ')
67
+ end
56
68
  end
57
69
  end
58
70
  end
@@ -21,8 +21,6 @@ module Wordmove
21
21
  # @!scope class
22
22
  # @return [LightService::Context] Action's context
23
23
  executed do |context|
24
- next context if context.database_task == false
25
-
26
24
  context.logger.task 'Backup remote DB'
27
25
 
28
26
  if simulate?(cli_options: context.cli_options)
@@ -19,8 +19,6 @@ module Wordmove
19
19
  # @!scope class
20
20
  # @return [LightService::Context] Action's context
21
21
  executed do |context| # rubocop:disable Metrics/BlockLength
22
- next context if context.database_task == false
23
-
24
22
  context.logger.task 'Cleanup'
25
23
 
26
24
  if simulate?(cli_options: context.cli_options)
@@ -25,8 +25,6 @@ module Wordmove
25
25
  # @!scope class
26
26
  # @return [LightService::Context] Action's context
27
27
  executed do |context| # rubocop:disable Metrics/BlockLength
28
- next context if context.database_task == false
29
-
30
28
  context.logger.task 'Download remote DB'
31
29
 
32
30
  if simulate?(cli_options: context.cli_options)
@@ -25,8 +25,6 @@ module Wordmove
25
25
  # @!scope class
26
26
  # @return [LightService::Context] Action's context
27
27
  executed do |context| # rubocop:disable Metrics/BlockLength
28
- next context if context.database_task == false
29
-
30
28
  context.logger.task 'Upload and import adapted DB'
31
29
 
32
30
  result = Wordmove::Actions::PutFile.execute(
@@ -16,11 +16,6 @@ module Wordmove
16
16
  promises :db_paths
17
17
 
18
18
  executed do |context| # rubocop:disable Metrics/BlockLength
19
- if context.database_task == false
20
- context.db_paths = false
21
- next context
22
- end
23
-
24
19
  next context if simulate?(cli_options: context.cli_options)
25
20
 
26
21
  content_dir = local_wp_content_dir(local_options: context.local_options)
@@ -57,12 +52,10 @@ module Wordmove
57
52
  remote_options: context.remote_options
58
53
  ).url('import.php')
59
54
  DbPathsConfig.ftp.local.generated_dump_script_path = generate_dump_script(
60
- remote_db_options: context.remote_options[:database],
61
- token: token
55
+ remote_db_options: context.remote_options[:database], token:
62
56
  )
63
57
  DbPathsConfig.ftp.local.generated_import_script_path = generate_import_script(
64
- remote_db_options: context.remote_options[:database],
65
- token: token
58
+ remote_db_options: context.remote_options[:database], token:
66
59
  )
67
60
  DbPathsConfig.ftp.local.temp_path = local_wp_content_dir(
68
61
  local_options: context.local_options
@@ -17,8 +17,6 @@ module Wordmove
17
17
  # @!scope class
18
18
  # @return [LightService::Context] Action's context
19
19
  executed do |context|
20
- next context if context.database_task == false
21
-
22
20
  context.logger.task 'Backup remote DB'
23
21
 
24
22
  if simulate?(cli_options: context.cli_options)
@@ -16,9 +16,7 @@ module Wordmove
16
16
  # @param logger [Wordmove::Logger]
17
17
  # @!scope class
18
18
  # @return [LightService::Context] Action's context
19
- executed do |context|
20
- next context if context.database_task == false
21
-
19
+ executed do |context| # rubocop:disable Metrics/BlockLength
22
20
  context.logger.task 'Cleanup'
23
21
 
24
22
  if simulate?(cli_options: context.cli_options)
@@ -24,8 +24,6 @@ module Wordmove
24
24
  # @!scope class
25
25
  # @return [LightService::Context] Action's context
26
26
  executed do |context| # rubocop:disable Metrics/BlockLength
27
- next context if context.database_task == false
28
-
29
27
  context.logger.task 'Download remote DB'
30
28
 
31
29
  next context if simulate?(cli_options: context.cli_options)
@@ -66,7 +64,12 @@ module Wordmove
66
64
  cli_options: context.cli_options,
67
65
  remote_file: context.db_paths.remote.gzipped_path
68
66
  )
69
- context.fail_and_return!(result.message) if result.failure?
67
+ if result.failure?
68
+ context.logger.warning 'Failed to delete remote file ' \
69
+ "#{context.db_paths.remote.gzipped_path} because: " \
70
+ "#{result.message}" \
71
+ '. Manual intervention required'
72
+ end
70
73
 
71
74
  context.logger.success(
72
75
  "Remote DB dump downloaded in #{context.db_paths.local.gzipped_path}"
@@ -24,8 +24,6 @@ module Wordmove
24
24
  # @!scope class
25
25
  # @return [LightService::Context] Action's context
26
26
  executed do |context| # rubocop:disable Metrics/BlockLength
27
- next context if context.database_task == false
28
-
29
27
  context.logger.task 'Upload and import adapted DB'
30
28
 
31
29
  result = Wordmove::Actions::PutFile.execute(
@@ -3,6 +3,7 @@ mapping:
3
3
  vhost:
4
4
  pattern: /^https?:\/\//
5
5
  wordpress_path:
6
+ required: true
6
7
  database:
7
8
  type: map
8
9
  required: true
@@ -15,9 +16,6 @@ mapping:
15
16
  required: true
16
17
  host:
17
18
  required: true
18
- mysqldump_options:
19
- port:
20
- charset:
21
19
  paths:
22
20
  type: map
23
21
  mapping:
data/lib/wordmove/cli.rb CHANGED
@@ -32,23 +32,16 @@ module Wordmove
32
32
  exit 1
33
33
  end
34
34
 
35
- def initial_context(cli_options)
36
- cli_options.deep_symbolize_keys!
37
- movefile = Wordmove::Movefile.new(cli_options)
38
-
39
- [cli_options, movefile]
40
- end
41
-
42
- def movefile_from(**cli_options)
35
+ def movefile_from(cli_options)
43
36
  ensure_wordpress_options_presence!(cli_options)
44
- Wordmove::Movefile.new(cli_options)
37
+ Wordmove::Movefile.new(cli_options, nil, true)
45
38
  rescue MovefileNotFound => e
46
39
  Logger.new($stdout).error(e.message)
47
40
  exit 1
48
41
  end
49
42
 
50
- def call_organizer_with(klass:, movefile:, **cli_options)
51
- result = klass.call(cli_options: cli_options, movefile: movefile)
43
+ def call_organizer_with(klass:, movefile:, cli_options:)
44
+ result = klass.call(cli_options, movefile)
52
45
 
53
46
  exit 0 if result.success?
54
47
 
@@ -114,22 +107,22 @@ module Wordmove
114
107
  private
115
108
 
116
109
  def call_pull_organizer_with(**cli_options)
117
- movefile = movefile_from(**cli_options)
110
+ movefile = movefile_from(cli_options)
118
111
 
119
112
  if movefile.options.dig(movefile.environment, :ssh)
120
113
  call_organizer_with(
121
114
  klass: Wordmove::Organizers::Ssh::Pull,
122
- movefile: movefile,
123
- **cli_options
115
+ movefile:, cli_options:
124
116
  )
125
117
  elsif movefile.options.dig(movefile.environment, :ftp)
126
118
  call_organizer_with(
127
119
  klass: Wordmove::Organizers::Ftp::Pull,
128
- movefile: movefile,
129
- **cli_options
120
+ movefile:, cli_options:
130
121
  )
131
122
  else
132
- raise NoAdapterFound, 'No valid adapter found.'
123
+ raise NoAdapterFound, 'No valid adapter found. It seems like your movefile.yml lacks ' \
124
+ 'an ssh or ftp section for the current environment. ' \
125
+ 'Run `wordmove doctor` for more info'
133
126
  end
134
127
  rescue NoAdapterFound => e
135
128
  Logger.new($stdout).error(e.message)
@@ -149,22 +142,22 @@ module Wordmove
149
142
  private
150
143
 
151
144
  def call_push_organizer_with(**cli_options)
152
- movefile = movefile_from(**cli_options)
145
+ movefile = movefile_from(cli_options)
153
146
 
154
147
  if movefile.options.dig(movefile.environment, :ssh)
155
148
  call_organizer_with(
156
149
  klass: Wordmove::Organizers::Ssh::Push,
157
- movefile: movefile,
158
- **cli_options
150
+ movefile:, cli_options:
159
151
  )
160
152
  elsif movefile.options.dig(movefile.environment, :ftp)
161
153
  call_organizer_with(
162
154
  klass: Wordmove::Organizers::Ftp::Push,
163
- movefile: movefile,
164
- **cli_options
155
+ movefile:, cli_options:
165
156
  )
166
157
  else
167
- raise NoAdapterFound, 'No valid adapter found.'
158
+ raise NoAdapterFound, 'No valid adapter found. It seems like your movefile.yml lacks ' \
159
+ 'an ssh or ftp section for the current environment. ' \
160
+ 'Run `wordmove doctor` for more info'
168
161
  end
169
162
  rescue NoAdapterFound => e
170
163
  Logger.new($stdout).error(e.message)
@@ -5,7 +5,7 @@ module Wordmove
5
5
  attr_reader :movefile, :contents, :root_keys
6
6
 
7
7
  def initialize(cli_options = {}, dir = '.')
8
- @movefile = Wordmove::Movefile.new(cli_options, dir)
8
+ @movefile = Wordmove::Movefile.new(cli_options, dir, false)
9
9
 
10
10
  begin
11
11
  @contents = movefile.options
@@ -7,7 +7,7 @@ module Wordmove
7
7
  @logger = Logger.new($stdout).tap { |l| l.level = Logger::INFO }
8
8
  begin
9
9
  @config = Wordmove::Movefile
10
- .new({ config: movefile_name }, movefile_dir)
10
+ .new({ config: movefile_name }, movefile_dir, false)
11
11
  .options[:local][:database]
12
12
  rescue Psych::SyntaxError => e
13
13
  logger.error e.message
@@ -36,7 +36,7 @@ module Wordmove
36
36
  end
37
37
 
38
38
  def up_to_date?
39
- `wp cli check-update --format=json`.empty?
39
+ `wp cli check-update --format=json --allow-root`.empty?
40
40
  end
41
41
  end
42
42
  end