wordmove 6.0.0.alpha.3 → 6.0.0.alpha.7

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/.github/workflows/ruby.yml +1 -1
  3. data/.rubocop.yml +1 -1
  4. data/.ruby-version +1 -1
  5. data/lib/wordmove/actions/adapt_local_db.rb +89 -50
  6. data/lib/wordmove/actions/adapt_remote_db.rb +68 -30
  7. data/lib/wordmove/actions/backup_local_db.rb +30 -18
  8. data/lib/wordmove/actions/ftp/backup_remote_db.rb +0 -2
  9. data/lib/wordmove/actions/ftp/cleanup_after_adapt.rb +0 -2
  10. data/lib/wordmove/actions/ftp/download_remote_db.rb +0 -2
  11. data/lib/wordmove/actions/ftp/put_and_import_dump_remotely.rb +0 -2
  12. data/lib/wordmove/actions/setup_context_for_db.rb +2 -11
  13. data/lib/wordmove/actions/ssh/backup_remote_db.rb +0 -2
  14. data/lib/wordmove/actions/ssh/cleanup_after_adapt.rb +0 -2
  15. data/lib/wordmove/actions/ssh/download_remote_db.rb +0 -2
  16. data/lib/wordmove/actions/ssh/put_and_import_dump_remotely.rb +0 -2
  17. data/lib/wordmove/assets/wordmove_schema_local.yml +1 -3
  18. data/lib/wordmove/cli.rb +16 -23
  19. data/lib/wordmove/doctor/movefile.rb +1 -1
  20. data/lib/wordmove/doctor/mysql.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 +28 -31
  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: 940d75a3bdf8e78dfff726d64c99c2a303ed0d0323c596df8617a1dc7d3e23ee
4
- data.tar.gz: 5b1c355dc1bfd4111f9f1f3cabdfae9f248dd1c4437b3111d4555b70bf6ec02f
3
+ metadata.gz: eb4272b210238aa9a149f8d2bc890a2c038abad4774fabcf32d76c11c000a1cb
4
+ data.tar.gz: a99d350edebe61c428d129c2bd6b121f0ca24dc5bc2e7cbbaed524cdd74af573
5
5
  SHA512:
6
- metadata.gz: 6627537b7592ba9453612c3eea7cce646ab54e8c8383c0b76fa19f6f68dd6f66a5ddb6e82739606e5a8cf5972bff566f7d5a454e9f61b46289f6a43bf543f5c0
7
- data.tar.gz: d12311a3fdd3d48e1fe041a7c58f90337364b281e9c63bda4299fcf23e50712489949860a690c803927b77d721325f962ce9fd2de8e7934ad8217ee33559272e
6
+ metadata.gz: 4b4c36435fe95a960202bba159f30fe94c42273b5dc70d8542a4f97082aa2dc01b919e1178a1015417b9db1faf94d9c202c7b340026b1e0e4876e84f46154bdd
7
+ data.tar.gz: 267622c86ffc5491040540941c75ce445b27d07583e24d2e9ca01b46086a9b989c09ec03cd8a66233ccdfb64b0a64f52b55f0e59dbf0311d7060e249383a37ca
@@ -17,7 +17,7 @@ jobs:
17
17
  test:
18
18
  runs-on: ubuntu-latest
19
19
  container:
20
- image: welaika/wordmove:latest
20
+ image: welaika/wordmove:php7-wordmove6
21
21
 
22
22
  steps:
23
23
  - uses: actions/checkout@v2
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
@@ -20,9 +20,7 @@ module Wordmove
20
20
  # @param logger [Wordmove::Logger]
21
21
  # @!scope class
22
22
  # @return [LightService::Context] Action's context
23
- executed do |context| # rubocop:disable Metrics/BlockLength
24
- next context if context.database_task == false
25
-
23
+ executed do |context|
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,13 +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
- next context if simulate?(cli_options: context.cli_options)
25
-
26
19
  content_dir = local_wp_content_dir(local_options: context.local_options)
27
20
 
28
21
  token = remote_php_scripts_token
@@ -57,12 +50,10 @@ module Wordmove
57
50
  remote_options: context.remote_options
58
51
  ).url('import.php')
59
52
  DbPathsConfig.ftp.local.generated_dump_script_path = generate_dump_script(
60
- remote_db_options: context.remote_options[:database],
61
- token: token
53
+ remote_db_options: context.remote_options[:database], token:
62
54
  )
63
55
  DbPathsConfig.ftp.local.generated_import_script_path = generate_import_script(
64
- remote_db_options: context.remote_options[:database],
65
- token: token
56
+ remote_db_options: context.remote_options[:database], token:
66
57
  )
67
58
  DbPathsConfig.ftp.local.temp_path = local_wp_content_dir(
68
59
  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)
@@ -17,8 +17,6 @@ module Wordmove
17
17
  # @!scope class
18
18
  # @return [LightService::Context] Action's context
19
19
  executed do |context| # rubocop:disable Metrics/BlockLength
20
- next context if context.database_task == false
21
-
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)
@@ -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
@@ -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