wordmove 5.0.1 → 5.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a8295afc0c284c3fb0f3e28938875c43b5c2bbf2d4c2a5a3eaca80d69c64ab1a
4
- data.tar.gz: 876abf510acbbae9b9c97c50839081e4685758a32995357d2974cdfba99ed0d6
3
+ metadata.gz: 827af36f1540f218650df064024c9fcd661d3bd87df075e2ba71f15bc8598fcd
4
+ data.tar.gz: f744dd778926c98cb5071902b8b410c84f2a8b102f0db4e9890e3cb9b6dc8337
5
5
  SHA512:
6
- metadata.gz: bcd8e3b1769ae854dfb37213c47f46b6cc2f556e0c2893a930e1161df313d6d271389fda3819dc791393e39a1bedb0a4b1984c13b7b221a157f99afe29487912
7
- data.tar.gz: 4e82ad3971ee2766bc8478122cc0f33ee84d44de0a1b75c52ae927857144071d6eaeaa1a19541af9a177c6be47543aed5945d12137448d53f55f154533702806
6
+ metadata.gz: a37976a8841050d1e25b158c4fb47c30bbc87f6b7d15bba88d0eecbf40a2b193dd4a4b93b868e44f72689dd1ef074f804429b3f714b7d9b9e9cd753cef467dff
7
+ data.tar.gz: 244d0333c938b18cb7c8bcb479c7876c9d9d4626d4eb1d0e6c9d2efe69a09e3274232fdd7819de2ce3e9018ac13fbe1d488fd48acbad8a4428a14eeebb414bac
@@ -4,6 +4,7 @@ module Wordmove
4
4
  Logger.new(STDOUT).tap { |l| l.level = Logger::DEBUG }
5
5
  end
6
6
 
7
+ # rubocop:disable Metrics/MethodLength
7
8
  def self.run(action, step, cli_options)
8
9
  movefile = Wordmove::Movefile.new(cli_options[:config])
9
10
  options = movefile.fetch(false)
@@ -15,37 +16,48 @@ module Wordmove
15
16
  step
16
17
  )
17
18
 
18
- unless hooks.local_hooks.empty?
19
- Wordmove::Hook::Local.run(hooks.local_hooks, options[:local], cli_options[:simulate])
20
- end
19
+ return if hooks.empty?
21
20
 
22
- return if hooks.remote_hooks.empty?
21
+ logger.task "Running #{action}/#{step} hooks"
23
22
 
24
- if options[environment][:ftp]
25
- logger.debug "You have configured remote hooks to run over "\
26
- "an FTP connection, but this is not possible. Skipping."
23
+ hooks.all_commands.each do |command|
24
+ case command[:where]
25
+ when 'local'
26
+ Wordmove::Hook::Local.run(command, options[:local], cli_options[:simulate])
27
+ when 'remote'
28
+ if options[environment][:ftp]
29
+ logger.debug "You have configured remote hooks to run over "\
30
+ "an FTP connection, but this is not possible. Skipping."
31
+ next
32
+ end
27
33
 
28
- return
34
+ Wordmove::Hook::Remote.run(command, options[environment], cli_options[:simulate])
35
+ else
36
+ next
37
+ end
29
38
  end
30
-
31
- Wordmove::Hook::Remote.run(
32
- hooks.remote_hooks, options[environment], cli_options[:simulate]
33
- )
34
39
  end
40
+ # rubocop:enable Metrics/MethodLength
35
41
 
36
42
  Config = Struct.new(:options, :action, :step) do
37
43
  def empty?
38
- (local_hooks + remote_hooks).empty?
44
+ all_commands.empty?
45
+ end
46
+
47
+ def all_commands
48
+ return [] if empty_step?
49
+
50
+ options[action][step] || []
39
51
  end
40
52
 
41
- def local_hooks
53
+ def local_commands
42
54
  return [] if empty_step?
43
55
 
44
56
  options[action][step]
45
57
  .select { |hook| hook[:where] == 'local' } || []
46
58
  end
47
59
 
48
- def remote_hooks
60
+ def remote_commands
49
61
  return [] if empty_step?
50
62
 
51
63
  options[action][step]
@@ -69,24 +81,20 @@ module Wordmove
69
81
  parent.logger
70
82
  end
71
83
 
72
- def self.run(hooks, options, simulate = false)
73
- logger.task "Running local hooks"
74
-
84
+ def self.run(command_hash, options, simulate = false)
75
85
  wordpress_path = options[:wordpress_path]
76
86
 
77
- hooks.each do |hook|
78
- logger.task_step true, "Exec command: #{hook[:command]}"
79
- return true if simulate
87
+ logger.task_step true, "Exec command: #{command_hash[:command]}"
88
+ return true if simulate
80
89
 
81
- stdout_return = `cd #{wordpress_path} && #{hook[:command]} 2>&1`
82
- logger.task_step true, "Output: #{stdout_return}"
90
+ stdout_return = `cd #{wordpress_path} && #{command_hash[:command]} 2>&1`
91
+ logger.task_step true, "Output: #{stdout_return}"
83
92
 
84
- if $CHILD_STATUS.exitstatus.zero?
85
- logger.success ""
86
- else
87
- logger.error "Error code: #{$CHILD_STATUS.exitstatus}"
88
- raise Wordmove::LocalHookException unless hook[:raise].eql? false
89
- end
93
+ if $CHILD_STATUS.exitstatus.zero?
94
+ logger.success ""
95
+ else
96
+ logger.error "Error code: #{$CHILD_STATUS.exitstatus}"
97
+ raise Wordmove::LocalHookException unless command_hash[:raise].eql? false
90
98
  end
91
99
  end
92
100
  end
@@ -96,28 +104,25 @@ module Wordmove
96
104
  parent.logger
97
105
  end
98
106
 
99
- def self.run(hooks, options, simulate = false)
100
- logger.task "Running remote hooks"
101
-
107
+ def self.run(command_hash, options, simulate = false)
102
108
  ssh_options = options[:ssh]
103
109
  wordpress_path = options[:wordpress_path]
104
110
 
105
111
  copier = Photocopier::SSH.new(ssh_options).tap { |c| c.logger = logger }
106
- hooks.each do |hook|
107
- logger.task_step false, "Exec command: #{hook[:command]}"
108
- return true if simulate
109
-
110
- stdout, stderr, exit_code =
111
- copier.exec!("cd #{wordpress_path} && #{hook[:command]}")
112
-
113
- if exit_code.zero?
114
- logger.task_step false, "Output: #{stdout}"
115
- logger.success ""
116
- else
117
- logger.task_step false, "Output: #{stderr}"
118
- logger.error "Error code #{exit_code}"
119
- raise Wordmove::RemoteHookException unless hook[:raise].eql? false
120
- end
112
+
113
+ logger.task_step false, "Exec command: #{command_hash[:command]}"
114
+ return true if simulate
115
+
116
+ stdout, stderr, exit_code =
117
+ copier.exec!("cd #{wordpress_path} && #{command_hash[:command]}")
118
+
119
+ if exit_code.zero?
120
+ logger.task_step false, "Output: #{stdout}"
121
+ logger.success ""
122
+ else
123
+ logger.task_step false, "Output: #{stderr}"
124
+ logger.error "Error code #{exit_code}"
125
+ raise Wordmove::RemoteHookException unless command_hash[:raise].eql? false
121
126
  end
122
127
  end
123
128
  end
@@ -1,3 +1,3 @@
1
1
  module Wordmove
2
- VERSION = "5.0.1".freeze
2
+ VERSION = "5.0.2".freeze
3
3
  end
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: 5.0.1
4
+ version: 5.0.2
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: 2019-12-12 00:00:00.000000000 Z
15
+ date: 2019-12-13 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: activesupport