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 +4 -4
- data/lib/wordmove/hook.rb +52 -47
- data/lib/wordmove/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 827af36f1540f218650df064024c9fcd661d3bd87df075e2ba71f15bc8598fcd
|
4
|
+
data.tar.gz: f744dd778926c98cb5071902b8b410c84f2a8b102f0db4e9890e3cb9b6dc8337
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a37976a8841050d1e25b158c4fb47c30bbc87f6b7d15bba88d0eecbf40a2b193dd4a4b93b868e44f72689dd1ef074f804429b3f714b7d9b9e9cd753cef467dff
|
7
|
+
data.tar.gz: 244d0333c938b18cb7c8bcb479c7876c9d9d4626d4eb1d0e6c9d2efe69a09e3274232fdd7819de2ce3e9018ac13fbe1d488fd48acbad8a4428a14eeebb414bac
|
data/lib/wordmove/hook.rb
CHANGED
@@ -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
|
-
|
19
|
-
Wordmove::Hook::Local.run(hooks.local_hooks, options[:local], cli_options[:simulate])
|
20
|
-
end
|
19
|
+
return if hooks.empty?
|
21
20
|
|
22
|
-
|
21
|
+
logger.task "Running #{action}/#{step} hooks"
|
23
22
|
|
24
|
-
|
25
|
-
|
26
|
-
|
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
|
-
|
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
|
-
|
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
|
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
|
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(
|
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
|
-
|
78
|
-
|
79
|
-
return true if simulate
|
87
|
+
logger.task_step true, "Exec command: #{command_hash[:command]}"
|
88
|
+
return true if simulate
|
80
89
|
|
81
|
-
|
82
|
-
|
90
|
+
stdout_return = `cd #{wordpress_path} && #{command_hash[:command]} 2>&1`
|
91
|
+
logger.task_step true, "Output: #{stdout_return}"
|
83
92
|
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
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(
|
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
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
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
|
data/lib/wordmove/version.rb
CHANGED
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.
|
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-
|
15
|
+
date: 2019-12-13 00:00:00.000000000 Z
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|
18
18
|
name: activesupport
|