wordmove 4.0.2.pre4 → 5.0.0.dev
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 +5 -5
- data/.rubocop.yml +1 -7
- data/.ruby-version +1 -1
- data/.travis.yml +2 -4
- data/README.mdown +18 -24
- data/exe/wordmove +1 -1
- data/lib/wordmove.rb +1 -0
- data/lib/wordmove/assets/wordmove_schema_remote.yml +53 -40
- data/lib/wordmove/cli.rb +28 -15
- data/lib/wordmove/deployer/base.rb +7 -3
- data/lib/wordmove/deployer/ftp.rb +1 -1
- data/lib/wordmove/deployer/ssh.rb +1 -1
- data/lib/wordmove/deployer/ssh/wpcli_sql_adapter.rb +2 -1
- data/lib/wordmove/doctor/wpcli.rb +2 -2
- data/lib/wordmove/environments_list.rb +68 -0
- data/lib/wordmove/generators/movefile.yml +11 -16
- data/lib/wordmove/guardian.rb +1 -0
- data/lib/wordmove/hook.rb +15 -12
- data/lib/wordmove/logger.rb +24 -9
- data/lib/wordmove/movefile.rb +24 -2
- data/lib/wordmove/sql_adapter/wpcli.rb +5 -3
- data/lib/wordmove/version.rb +1 -1
- data/lib/wordmove/wordpress_directory.rb +5 -5
- data/wordmove.gemspec +8 -8
- metadata +17 -17
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
|
-
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 1e6f34b9e96b87aa9b75b8f7638ab4a6f333276a8e190c91e48381f502af8415
|
|
4
|
+
data.tar.gz: 34a8960d6361f277ecf5245d52c4b3dcc50c6431074135a5900eb30c21689aba
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: d058c3fc18fae2a29d5b0ae7f5a86e1e5922ee10bdb9067db92ef18d56b940bdb51142806362086e927dc55420ca6fe31821ba5fc412cd72b0f7f2bcf7641ae8
|
|
7
|
+
data.tar.gz: cb0751f039fa0d3aad7fd939865d1b14ba43c5528b49ad4aaed3cb633f3da80dd7bcaaa1719a88f4de7fa42ca333056b64ab05c95ac62ad3e7595fb6d3448a1b
|
data/.rubocop.yml
CHANGED
data/.ruby-version
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
2.
|
|
1
|
+
2.6.5
|
data/.travis.yml
CHANGED
data/README.mdown
CHANGED
|
@@ -50,6 +50,7 @@ Commands:
|
|
|
50
50
|
wordmove doctor # Do some local configuration and environment checks
|
|
51
51
|
wordmove help [TASK] # Describe available tasks or one specific task
|
|
52
52
|
wordmove init # Generates a brand new movefile.yml
|
|
53
|
+
wordmove list # List all environments and vhosts
|
|
53
54
|
wordmove pull # Pulls WP data from remote host to the local machine
|
|
54
55
|
wordmove push # Pushes WP data from local machine to remote host
|
|
55
56
|
```
|
|
@@ -121,29 +122,23 @@ production:
|
|
|
121
122
|
host: host
|
|
122
123
|
user: user
|
|
123
124
|
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
# - 'echo "Do something remotely before pull"'
|
|
142
|
-
# after:
|
|
143
|
-
# local:
|
|
144
|
-
# - 'echo "Do something locally after pull"'
|
|
145
|
-
# remote:
|
|
146
|
-
# - 'echo "Do something remotely after pull"'
|
|
125
|
+
# hooks: # Remote hooks won't work with FTP
|
|
126
|
+
# push:
|
|
127
|
+
# before:
|
|
128
|
+
# - command: 'echo "do something"'
|
|
129
|
+
# where: local
|
|
130
|
+
# raise: false # raise is true by default
|
|
131
|
+
# after:
|
|
132
|
+
# - command: 'echo "do something"'
|
|
133
|
+
# where: remote
|
|
134
|
+
# pull:
|
|
135
|
+
# before:
|
|
136
|
+
# - command: 'echo "do something"'
|
|
137
|
+
# where: local
|
|
138
|
+
# raise: false
|
|
139
|
+
# after:
|
|
140
|
+
# - command: 'echo "do something"'
|
|
141
|
+
# where: remote
|
|
147
142
|
```
|
|
148
143
|
|
|
149
144
|
**We warmly recommend to read the wiki article [Multiple environments explained
|
|
@@ -321,4 +316,3 @@ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
|
|
321
316
|
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
|
322
317
|
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
323
318
|
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
324
|
-
|
data/exe/wordmove
CHANGED
data/lib/wordmove.rb
CHANGED
|
@@ -31,6 +31,7 @@ require 'wordmove/sql_adapter/default'
|
|
|
31
31
|
require 'wordmove/sql_adapter/wpcli'
|
|
32
32
|
require 'wordmove/wordpress_directory'
|
|
33
33
|
require "wordmove/version"
|
|
34
|
+
require "wordmove/environments_list"
|
|
34
35
|
|
|
35
36
|
require 'wordmove/generators/movefile_adapter'
|
|
36
37
|
require 'wordmove/generators/movefile'
|
|
@@ -87,52 +87,65 @@ mapping:
|
|
|
87
87
|
type: map
|
|
88
88
|
mapping:
|
|
89
89
|
before:
|
|
90
|
-
type:
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
90
|
+
type: seq
|
|
91
|
+
sequence:
|
|
92
|
+
- type: map
|
|
93
|
+
mapping:
|
|
94
|
+
command:
|
|
95
|
+
type: str
|
|
96
|
+
required: true
|
|
97
|
+
where:
|
|
98
|
+
type: str
|
|
99
|
+
required: true
|
|
100
|
+
pattern: /\Alocal\Z|\Aremote\Z/
|
|
101
|
+
raise:
|
|
102
|
+
type: bool
|
|
100
103
|
after:
|
|
101
|
-
type:
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
104
|
+
type: seq
|
|
105
|
+
sequence:
|
|
106
|
+
- type: map
|
|
107
|
+
mapping:
|
|
108
|
+
command:
|
|
109
|
+
type: str
|
|
110
|
+
required: true
|
|
111
|
+
where:
|
|
112
|
+
type: str
|
|
113
|
+
required: true
|
|
114
|
+
pattern: /\Alocal\Z|\Aremote\Z/
|
|
115
|
+
raise:
|
|
116
|
+
type: bool
|
|
111
117
|
pull:
|
|
112
118
|
type: map
|
|
113
119
|
mapping:
|
|
114
120
|
before:
|
|
115
|
-
type:
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
121
|
+
type: seq
|
|
122
|
+
sequence:
|
|
123
|
+
- type: map
|
|
124
|
+
mapping:
|
|
125
|
+
command:
|
|
126
|
+
type: str
|
|
127
|
+
required: true
|
|
128
|
+
where:
|
|
129
|
+
type: str
|
|
130
|
+
required: true
|
|
131
|
+
pattern: /\Alocal\Z|\Aremote\Z/
|
|
132
|
+
raise:
|
|
133
|
+
type: bool
|
|
125
134
|
after:
|
|
126
|
-
type:
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
135
|
+
type: seq
|
|
136
|
+
sequence:
|
|
137
|
+
- type: map
|
|
138
|
+
mapping:
|
|
139
|
+
command:
|
|
140
|
+
type: str
|
|
141
|
+
required: true
|
|
142
|
+
where:
|
|
143
|
+
type: str
|
|
144
|
+
required: true
|
|
145
|
+
pattern: /\Alocal\Z|\Aremote\Z/
|
|
146
|
+
raise:
|
|
147
|
+
type: bool
|
|
148
|
+
|
|
136
149
|
forbid:
|
|
137
150
|
type: map
|
|
138
151
|
mapping:
|
data/lib/wordmove/cli.rb
CHANGED
|
@@ -18,22 +18,20 @@ module Wordmove
|
|
|
18
18
|
end
|
|
19
19
|
|
|
20
20
|
shared_options = {
|
|
21
|
-
wordpress:
|
|
22
|
-
uploads:
|
|
23
|
-
themes:
|
|
24
|
-
plugins:
|
|
25
|
-
mu_plugins:
|
|
26
|
-
languages:
|
|
27
|
-
db:
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
simulate: { aliases: "-s", type: :boolean },
|
|
21
|
+
wordpress: { aliases: "-w", type: :boolean },
|
|
22
|
+
uploads: { aliases: "-u", type: :boolean },
|
|
23
|
+
themes: { aliases: "-t", type: :boolean },
|
|
24
|
+
plugins: { aliases: "-p", type: :boolean },
|
|
25
|
+
mu_plugins: { aliases: "-m", type: :boolean },
|
|
26
|
+
languages: { aliases: "-l", type: :boolean },
|
|
27
|
+
db: { aliases: "-d", type: :boolean },
|
|
28
|
+
verbose: { aliases: "-v", type: :boolean },
|
|
29
|
+
simulate: { aliases: "-s", type: :boolean },
|
|
31
30
|
environment: { aliases: "-e" },
|
|
32
|
-
config:
|
|
33
|
-
debug:
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
all: { type: :boolean }
|
|
31
|
+
config: { aliases: "-c" },
|
|
32
|
+
debug: { type: :boolean },
|
|
33
|
+
no_adapt: { type: :boolean },
|
|
34
|
+
all: { type: :boolean }
|
|
37
35
|
}
|
|
38
36
|
|
|
39
37
|
no_tasks do
|
|
@@ -49,6 +47,7 @@ module Wordmove
|
|
|
49
47
|
|
|
50
48
|
def ensure_wordpress_options_presence!(options)
|
|
51
49
|
return if (options.keys & (wordpress_options + ["all"])).present?
|
|
50
|
+
|
|
52
51
|
puts "No options given. See wordmove --help"
|
|
53
52
|
exit 1
|
|
54
53
|
end
|
|
@@ -58,6 +57,20 @@ module Wordmove
|
|
|
58
57
|
end
|
|
59
58
|
end
|
|
60
59
|
|
|
60
|
+
desc "list", "List all environments and vhosts"
|
|
61
|
+
shared_options.each do |option, args|
|
|
62
|
+
method_option option, args
|
|
63
|
+
end
|
|
64
|
+
def list
|
|
65
|
+
Wordmove::EnvironmentsList.print(options)
|
|
66
|
+
rescue Wordmove::MovefileNotFound => e
|
|
67
|
+
logger.error(e.message)
|
|
68
|
+
exit 1
|
|
69
|
+
rescue Psych::SyntaxError => e
|
|
70
|
+
logger.error("Your movefile is not parsable due to a syntax error: #{e.message}")
|
|
71
|
+
exit 1
|
|
72
|
+
end
|
|
73
|
+
|
|
61
74
|
desc "pull", "Pulls WP data from remote host to the local machine"
|
|
62
75
|
shared_options.each do |option, args|
|
|
63
76
|
method_option option, args
|
|
@@ -30,15 +30,17 @@ module Wordmove
|
|
|
30
30
|
'.'
|
|
31
31
|
end
|
|
32
32
|
|
|
33
|
-
def logger
|
|
34
|
-
Logger.new(STDOUT).tap { |l| l.level = Logger::DEBUG }
|
|
33
|
+
def logger(secrets)
|
|
34
|
+
Logger.new(STDOUT, secrets).tap { |l| l.level = Logger::DEBUG }
|
|
35
35
|
end
|
|
36
36
|
end
|
|
37
37
|
|
|
38
38
|
def initialize(environment, options = {})
|
|
39
39
|
@environment = environment.to_sym
|
|
40
40
|
@options = options
|
|
41
|
-
|
|
41
|
+
|
|
42
|
+
movefile_secrets = Wordmove::Movefile.new(options[:config]).secrets
|
|
43
|
+
@logger = self.class.logger(movefile_secrets)
|
|
42
44
|
end
|
|
43
45
|
|
|
44
46
|
def push_db
|
|
@@ -98,9 +100,11 @@ module Wordmove
|
|
|
98
100
|
|
|
99
101
|
return true if simulate?
|
|
100
102
|
|
|
103
|
+
# rubocop:todo Security/Open
|
|
101
104
|
open(local_path, 'w') do |file|
|
|
102
105
|
file << open(url).read
|
|
103
106
|
end
|
|
107
|
+
# rubocop:enable Security/Open
|
|
104
108
|
end
|
|
105
109
|
|
|
106
110
|
def simulate?
|
|
@@ -46,7 +46,8 @@ module Wordmove
|
|
|
46
46
|
return if options[:no_adapt]
|
|
47
47
|
|
|
48
48
|
logger.task_step true, "adapt dump for #{config_key}"
|
|
49
|
-
|
|
49
|
+
path = local_options[:wordpress_path]
|
|
50
|
+
SqlAdapter::Wpcli.new(local, remote, config_key, path).command unless simulate?
|
|
50
51
|
end
|
|
51
52
|
end
|
|
52
53
|
end
|
|
@@ -19,13 +19,13 @@ module Wordmove
|
|
|
19
19
|
logger.error <<-LONG
|
|
20
20
|
wp-cli is not up to date.
|
|
21
21
|
Use `wp cli update` to update to the latest version.
|
|
22
|
-
|
|
22
|
+
LONG
|
|
23
23
|
end
|
|
24
24
|
else
|
|
25
25
|
logger.error <<-LONG
|
|
26
26
|
wp-cli is not installed (or not in your $PATH).
|
|
27
27
|
Read http://wp-cli.org/#installing for installation info.
|
|
28
|
-
|
|
28
|
+
LONG
|
|
29
29
|
end
|
|
30
30
|
end
|
|
31
31
|
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
module Wordmove
|
|
2
|
+
class EnvironmentsList
|
|
3
|
+
attr_reader :movefile, :logger, :remote_vhosts, :local_vhost
|
|
4
|
+
|
|
5
|
+
class << self
|
|
6
|
+
def print(cli_options)
|
|
7
|
+
new(cli_options).print
|
|
8
|
+
end
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def initialize(options)
|
|
12
|
+
@logger = Logger.new(STDOUT).tap { |l| l.level = Logger::INFO }
|
|
13
|
+
@movefile = Wordmove::Movefile.new(options[:config])
|
|
14
|
+
@remote_vhosts = []
|
|
15
|
+
@local_vhost = []
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def print
|
|
19
|
+
contents = parse_movefile(movefile: movefile)
|
|
20
|
+
generate_vhost_list(contents: contents)
|
|
21
|
+
output
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
private
|
|
25
|
+
|
|
26
|
+
def select_vhost(contents:)
|
|
27
|
+
target = contents.select { |_key, env| env[:vhost].present? }
|
|
28
|
+
target.map { |key, env| { env: key, vhost: env[:vhost] } }
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def parse_movefile(movefile:)
|
|
32
|
+
movefile.fetch
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def output
|
|
36
|
+
logger.task('Listing Local')
|
|
37
|
+
logger.plain(output_string(vhost_list: local_vhost))
|
|
38
|
+
|
|
39
|
+
logger.task('Listing Remotes')
|
|
40
|
+
logger.plain(output_string(vhost_list: remote_vhosts))
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def output_string(vhost_list:)
|
|
44
|
+
return 'vhost list is empty' if vhost_list.empty?
|
|
45
|
+
|
|
46
|
+
vhost_list.each_with_object("") do |entry, retval|
|
|
47
|
+
retval << "#{entry[:env]}: #{entry[:vhost]}\n"
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
#
|
|
52
|
+
# return env, vhost map
|
|
53
|
+
# Exp. {:env=>:local, :vhost=>"http://vhost.local"},
|
|
54
|
+
# {:env=>:production, :vhost=>"http://example.com"}
|
|
55
|
+
#
|
|
56
|
+
def generate_vhost_list(contents:)
|
|
57
|
+
# select object which has 'vhost' only
|
|
58
|
+
vhosts = select_vhost(contents: contents)
|
|
59
|
+
vhosts.each do |list|
|
|
60
|
+
if list[:env] == :local
|
|
61
|
+
@local_vhost << list
|
|
62
|
+
else
|
|
63
|
+
@remote_vhosts << list
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
end
|
|
@@ -71,26 +71,21 @@ production:
|
|
|
71
71
|
# hooks: # Remote hooks won't work with FTP
|
|
72
72
|
# push:
|
|
73
73
|
# before:
|
|
74
|
-
#
|
|
75
|
-
#
|
|
76
|
-
#
|
|
77
|
-
# - 'echo "Do something remotely before push"'
|
|
74
|
+
# - command: 'echo "do something"'
|
|
75
|
+
# where: local
|
|
76
|
+
# raise: false # raise is true by default
|
|
78
77
|
# after:
|
|
79
|
-
#
|
|
80
|
-
#
|
|
81
|
-
# remote:
|
|
82
|
-
# - 'echo "Do something remotely after push"'
|
|
78
|
+
# - command: 'echo "do something"'
|
|
79
|
+
# where: remote
|
|
83
80
|
# pull:
|
|
84
81
|
# before:
|
|
85
|
-
#
|
|
86
|
-
#
|
|
87
|
-
#
|
|
88
|
-
# - 'echo "Do something remotely before pull"'
|
|
82
|
+
# - command: 'echo "do something"'
|
|
83
|
+
# where: local
|
|
84
|
+
# raise: false
|
|
89
85
|
# after:
|
|
90
|
-
#
|
|
91
|
-
#
|
|
92
|
-
#
|
|
93
|
-
# - 'echo "Do something remotely after pull"'
|
|
86
|
+
# - command: 'echo "do something"'
|
|
87
|
+
# where: remote
|
|
88
|
+
#
|
|
94
89
|
# forbid:
|
|
95
90
|
# push:
|
|
96
91
|
# db: false
|
data/lib/wordmove/guardian.rb
CHANGED
data/lib/wordmove/hook.rb
CHANGED
|
@@ -41,13 +41,15 @@ module Wordmove
|
|
|
41
41
|
def local_hooks
|
|
42
42
|
return [] if empty_step?
|
|
43
43
|
|
|
44
|
-
options[action][step]
|
|
44
|
+
options[action][step]
|
|
45
|
+
.select { |hook| hook[:where] == 'local' } || []
|
|
45
46
|
end
|
|
46
47
|
|
|
47
48
|
def remote_hooks
|
|
48
49
|
return [] if empty_step?
|
|
49
50
|
|
|
50
|
-
options[action][step]
|
|
51
|
+
options[action][step]
|
|
52
|
+
.select { |hook| hook[:where] == 'remote' } || []
|
|
51
53
|
end
|
|
52
54
|
|
|
53
55
|
private
|
|
@@ -56,6 +58,7 @@ module Wordmove
|
|
|
56
58
|
return true unless options
|
|
57
59
|
return true if options[action].nil?
|
|
58
60
|
return true if options[action][step].nil?
|
|
61
|
+
return true if options[action][step].empty?
|
|
59
62
|
|
|
60
63
|
false
|
|
61
64
|
end
|
|
@@ -66,23 +69,23 @@ module Wordmove
|
|
|
66
69
|
parent.logger
|
|
67
70
|
end
|
|
68
71
|
|
|
69
|
-
def self.run(
|
|
72
|
+
def self.run(hooks, options, simulate = false)
|
|
70
73
|
logger.task "Running local hooks"
|
|
71
74
|
|
|
72
75
|
wordpress_path = options[:wordpress_path]
|
|
73
76
|
|
|
74
|
-
|
|
75
|
-
logger.task_step true, "Exec command: #{command}"
|
|
77
|
+
hooks.each do |hook|
|
|
78
|
+
logger.task_step true, "Exec command: #{hook[:command]}"
|
|
76
79
|
return true if simulate
|
|
77
80
|
|
|
78
|
-
stdout_return = `cd #{wordpress_path} && #{command} 2>&1`
|
|
81
|
+
stdout_return = `cd #{wordpress_path} && #{hook[:command]} 2>&1`
|
|
79
82
|
logger.task_step true, "Output: #{stdout_return}"
|
|
80
83
|
|
|
81
84
|
if $CHILD_STATUS.exitstatus.zero?
|
|
82
85
|
logger.success ""
|
|
83
86
|
else
|
|
84
87
|
logger.error "Error code: #{$CHILD_STATUS.exitstatus}"
|
|
85
|
-
raise Wordmove::LocalHookException
|
|
88
|
+
raise Wordmove::LocalHookException unless hook[:raise].eql? false
|
|
86
89
|
end
|
|
87
90
|
end
|
|
88
91
|
end
|
|
@@ -93,19 +96,19 @@ module Wordmove
|
|
|
93
96
|
parent.logger
|
|
94
97
|
end
|
|
95
98
|
|
|
96
|
-
def self.run(
|
|
99
|
+
def self.run(hooks, options, simulate = false)
|
|
97
100
|
logger.task "Running remote hooks"
|
|
98
101
|
|
|
99
102
|
ssh_options = options[:ssh]
|
|
100
103
|
wordpress_path = options[:wordpress_path]
|
|
101
104
|
|
|
102
105
|
copier = Photocopier::SSH.new(ssh_options).tap { |c| c.logger = logger }
|
|
103
|
-
|
|
104
|
-
logger.task_step false, "Exec command: #{command}"
|
|
106
|
+
hooks.each do |hook|
|
|
107
|
+
logger.task_step false, "Exec command: #{hook[:command]}"
|
|
105
108
|
return true if simulate
|
|
106
109
|
|
|
107
110
|
stdout, stderr, exit_code =
|
|
108
|
-
copier.exec!("cd #{wordpress_path} && #{command}")
|
|
111
|
+
copier.exec!("cd #{wordpress_path} && #{hook[:command]}")
|
|
109
112
|
|
|
110
113
|
if exit_code.zero?
|
|
111
114
|
logger.task_step false, "Output: #{stdout}"
|
|
@@ -113,7 +116,7 @@ module Wordmove
|
|
|
113
116
|
else
|
|
114
117
|
logger.task_step false, "Output: #{stderr}"
|
|
115
118
|
logger.error "Error code #{exit_code}"
|
|
116
|
-
raise Wordmove::RemoteHookException
|
|
119
|
+
raise Wordmove::RemoteHookException unless hook[:raise].eql? false
|
|
117
120
|
end
|
|
118
121
|
end
|
|
119
122
|
end
|
data/lib/wordmove/logger.rb
CHANGED
|
@@ -2,40 +2,55 @@ module Wordmove
|
|
|
2
2
|
class Logger < ::Logger
|
|
3
3
|
MAX_LINE = 70
|
|
4
4
|
|
|
5
|
+
def initialize(device, strings_to_hide = [])
|
|
6
|
+
super(device, formatter: proc { |_severity, _datetime, _progname, message|
|
|
7
|
+
formatted_message = if strings_to_hide.empty?
|
|
8
|
+
message
|
|
9
|
+
else
|
|
10
|
+
message.gsub(Regexp.new(strings_to_hide.join('|')), '[secret]')
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
"\n#{formatted_message}\n"
|
|
14
|
+
})
|
|
15
|
+
end
|
|
16
|
+
|
|
5
17
|
def task(title)
|
|
6
18
|
prefix = "▬" * 2
|
|
7
19
|
title = " #{title} "
|
|
8
20
|
padding = "▬" * padding_length(title)
|
|
9
|
-
|
|
10
|
-
puts "\n" + prefix + title.light_white + padding
|
|
21
|
+
add(INFO, prefix + title.light_white + padding)
|
|
11
22
|
end
|
|
12
23
|
|
|
13
24
|
def task_step(local_step, title)
|
|
14
25
|
if local_step
|
|
15
|
-
|
|
26
|
+
add(INFO, " local".cyan + " | ".black + title.to_s)
|
|
16
27
|
else
|
|
17
|
-
|
|
28
|
+
add(INFO, " remote".yellow + " | ".black + title.to_s)
|
|
18
29
|
end
|
|
19
30
|
end
|
|
20
31
|
|
|
21
32
|
def error(message)
|
|
22
|
-
|
|
33
|
+
add(ERROR, " ❌ error".red + " | ".black + message.to_s)
|
|
23
34
|
end
|
|
24
35
|
|
|
25
36
|
def success(message)
|
|
26
|
-
|
|
37
|
+
add(INFO, " ✅ success".green + " | ".black + message.to_s)
|
|
27
38
|
end
|
|
28
39
|
|
|
29
40
|
def debug(message)
|
|
30
|
-
|
|
41
|
+
add(DEBUG, " 🛠 debug".magenta + " | ".black + message.to_s)
|
|
31
42
|
end
|
|
32
43
|
|
|
33
44
|
def warn(message)
|
|
34
|
-
|
|
45
|
+
add(WARN, " ⚠️ warning".yellow + " | ".black + message.to_s)
|
|
35
46
|
end
|
|
36
47
|
|
|
37
48
|
def info(message)
|
|
38
|
-
|
|
49
|
+
add(INFO, " ℹ️ info".yellow + " | ".black + message.to_s)
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
def plain(message)
|
|
53
|
+
add(INFO, message.to_s)
|
|
39
54
|
end
|
|
40
55
|
|
|
41
56
|
private
|
data/lib/wordmove/movefile.rb
CHANGED
|
@@ -16,9 +16,13 @@ module Wordmove
|
|
|
16
16
|
end
|
|
17
17
|
|
|
18
18
|
if entries.empty?
|
|
19
|
-
|
|
19
|
+
if last_dir?(start_dir)
|
|
20
|
+
raise MovefileNotFound, "Could not find a valid Movefile. Searched"\
|
|
21
|
+
" for filename \"#{name}\" in folder \"#{start_dir}\""
|
|
22
|
+
end
|
|
23
|
+
|
|
20
24
|
@start_dir = upper_dir(start_dir)
|
|
21
|
-
return fetch
|
|
25
|
+
return fetch(verbose)
|
|
22
26
|
end
|
|
23
27
|
|
|
24
28
|
found = entries.first
|
|
@@ -53,6 +57,24 @@ module Wordmove
|
|
|
53
57
|
(options[:environment] || available_enviroments.first).to_sym
|
|
54
58
|
end
|
|
55
59
|
|
|
60
|
+
def secrets
|
|
61
|
+
options = fetch(false)
|
|
62
|
+
|
|
63
|
+
secrets = []
|
|
64
|
+
options.each_key do |env|
|
|
65
|
+
secrets << options.dig(env, :database, :password)
|
|
66
|
+
secrets << options.dig(env, :database, :host)
|
|
67
|
+
secrets << options.dig(env, :vhost)
|
|
68
|
+
secrets << options.dig(env, :ssh, :password)
|
|
69
|
+
secrets << options.dig(env, :ssh, :host)
|
|
70
|
+
secrets << options.dig(env, :ftp, :password)
|
|
71
|
+
secrets << options.dig(env, :ftp, :host)
|
|
72
|
+
secrets << options.dig(env, :wordpress_path)
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
secrets.compact.delete_if(&:empty?)
|
|
76
|
+
end
|
|
77
|
+
|
|
56
78
|
private
|
|
57
79
|
|
|
58
80
|
def extract_available_envs(options)
|
|
@@ -2,11 +2,12 @@ module Wordmove
|
|
|
2
2
|
module SqlAdapter
|
|
3
3
|
class Wpcli
|
|
4
4
|
attr_accessor :sql_content
|
|
5
|
-
attr_reader :from, :to
|
|
5
|
+
attr_reader :from, :to, :local_path
|
|
6
6
|
|
|
7
|
-
def initialize(source_config, dest_config, config_key)
|
|
7
|
+
def initialize(source_config, dest_config, config_key, local_path)
|
|
8
8
|
@from = source_config[config_key]
|
|
9
9
|
@to = dest_config[config_key]
|
|
10
|
+
@local_path = local_path
|
|
10
11
|
end
|
|
11
12
|
|
|
12
13
|
def command
|
|
@@ -14,7 +15,8 @@ module Wordmove
|
|
|
14
15
|
raise UnmetPeerDependencyError, "WP-CLI is not installed or not in your $PATH"
|
|
15
16
|
end
|
|
16
17
|
|
|
17
|
-
"wp search-replace #{from} #{to} --quiet
|
|
18
|
+
"wp search-replace --path=#{local_path} #{from} #{to} --quiet "\
|
|
19
|
+
"--skip-columns=guid --all-tables --allow-root"
|
|
18
20
|
end
|
|
19
21
|
end
|
|
20
22
|
end
|
data/lib/wordmove/version.rb
CHANGED
|
@@ -10,12 +10,12 @@ class WordpressDirectory
|
|
|
10
10
|
|
|
11
11
|
DEFAULT_PATHS = {
|
|
12
12
|
Path::WP_CONTENT => 'wp-content',
|
|
13
|
-
Path::WP_CONFIG
|
|
14
|
-
Path::PLUGINS
|
|
13
|
+
Path::WP_CONFIG => 'wp-config.php',
|
|
14
|
+
Path::PLUGINS => 'wp-content/plugins',
|
|
15
15
|
Path::MU_PLUGINS => 'wp-content/mu-plugins',
|
|
16
|
-
Path::THEMES
|
|
17
|
-
Path::UPLOADS
|
|
18
|
-
Path::LANGUAGES
|
|
16
|
+
Path::THEMES => 'wp-content/themes',
|
|
17
|
+
Path::UPLOADS => 'wp-content/uploads',
|
|
18
|
+
Path::LANGUAGES => 'wp-content/languages'
|
|
19
19
|
}.freeze
|
|
20
20
|
|
|
21
21
|
def self.default_path_for(sym)
|
data/wordmove.gemspec
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
lib = File.expand_path('
|
|
1
|
+
lib = File.expand_path('lib', __dir__)
|
|
2
2
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
3
3
|
require 'wordmove/version'
|
|
4
4
|
|
|
@@ -31,20 +31,20 @@ Gem::Specification.new do |spec|
|
|
|
31
31
|
|
|
32
32
|
spec.add_runtime_dependency "activesupport", '~> 5.1', '>= 5.1.1'
|
|
33
33
|
spec.add_runtime_dependency "colorize", "~> 0.8.1"
|
|
34
|
-
spec.add_runtime_dependency "dotenv", "~> 2.
|
|
34
|
+
spec.add_runtime_dependency "dotenv", "~> 2.7.5"
|
|
35
35
|
spec.add_runtime_dependency "kwalify", "~> 0"
|
|
36
36
|
spec.add_runtime_dependency "photocopier", "1.3.3.pre3"
|
|
37
|
-
spec.add_runtime_dependency "thor", "~> 0.
|
|
37
|
+
spec.add_runtime_dependency "thor", "~> 0.20.3"
|
|
38
38
|
|
|
39
|
-
spec.required_ruby_version = ">= 2.
|
|
39
|
+
spec.required_ruby_version = ">= 2.6.0"
|
|
40
40
|
|
|
41
41
|
spec.add_development_dependency "bundler", "~> 2.0"
|
|
42
42
|
spec.add_development_dependency "priscilla", "~> 1.0"
|
|
43
43
|
spec.add_development_dependency "pry-byebug", "~> 3.1"
|
|
44
|
-
spec.add_development_dependency "rake", "~>
|
|
45
|
-
spec.add_development_dependency "rspec", "~> 3.
|
|
46
|
-
spec.add_development_dependency "rubocop", "~> 0.
|
|
47
|
-
spec.add_development_dependency "simplecov", "~> 0.
|
|
44
|
+
spec.add_development_dependency "rake", "~> 13.0.1"
|
|
45
|
+
spec.add_development_dependency "rspec", "~> 3.9"
|
|
46
|
+
spec.add_development_dependency "rubocop", "~> 0.76.0"
|
|
47
|
+
spec.add_development_dependency "simplecov", "~> 0.17.1"
|
|
48
48
|
|
|
49
49
|
spec.post_install_message = <<-RAINBOW
|
|
50
50
|
Starting from version 3.0.0 `database.charset` option is no longer accepted.
|
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:
|
|
4
|
+
version: 5.0.0.dev
|
|
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-
|
|
15
|
+
date: 2019-11-27 00:00:00.000000000 Z
|
|
16
16
|
dependencies:
|
|
17
17
|
- !ruby/object:Gem::Dependency
|
|
18
18
|
name: activesupport
|
|
@@ -54,14 +54,14 @@ dependencies:
|
|
|
54
54
|
requirements:
|
|
55
55
|
- - "~>"
|
|
56
56
|
- !ruby/object:Gem::Version
|
|
57
|
-
version: 2.
|
|
57
|
+
version: 2.7.5
|
|
58
58
|
type: :runtime
|
|
59
59
|
prerelease: false
|
|
60
60
|
version_requirements: !ruby/object:Gem::Requirement
|
|
61
61
|
requirements:
|
|
62
62
|
- - "~>"
|
|
63
63
|
- !ruby/object:Gem::Version
|
|
64
|
-
version: 2.
|
|
64
|
+
version: 2.7.5
|
|
65
65
|
- !ruby/object:Gem::Dependency
|
|
66
66
|
name: kwalify
|
|
67
67
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -96,14 +96,14 @@ dependencies:
|
|
|
96
96
|
requirements:
|
|
97
97
|
- - "~>"
|
|
98
98
|
- !ruby/object:Gem::Version
|
|
99
|
-
version: 0.
|
|
99
|
+
version: 0.20.3
|
|
100
100
|
type: :runtime
|
|
101
101
|
prerelease: false
|
|
102
102
|
version_requirements: !ruby/object:Gem::Requirement
|
|
103
103
|
requirements:
|
|
104
104
|
- - "~>"
|
|
105
105
|
- !ruby/object:Gem::Version
|
|
106
|
-
version: 0.
|
|
106
|
+
version: 0.20.3
|
|
107
107
|
- !ruby/object:Gem::Dependency
|
|
108
108
|
name: bundler
|
|
109
109
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -152,56 +152,56 @@ dependencies:
|
|
|
152
152
|
requirements:
|
|
153
153
|
- - "~>"
|
|
154
154
|
- !ruby/object:Gem::Version
|
|
155
|
-
version:
|
|
155
|
+
version: 13.0.1
|
|
156
156
|
type: :development
|
|
157
157
|
prerelease: false
|
|
158
158
|
version_requirements: !ruby/object:Gem::Requirement
|
|
159
159
|
requirements:
|
|
160
160
|
- - "~>"
|
|
161
161
|
- !ruby/object:Gem::Version
|
|
162
|
-
version:
|
|
162
|
+
version: 13.0.1
|
|
163
163
|
- !ruby/object:Gem::Dependency
|
|
164
164
|
name: rspec
|
|
165
165
|
requirement: !ruby/object:Gem::Requirement
|
|
166
166
|
requirements:
|
|
167
167
|
- - "~>"
|
|
168
168
|
- !ruby/object:Gem::Version
|
|
169
|
-
version: '3.
|
|
169
|
+
version: '3.9'
|
|
170
170
|
type: :development
|
|
171
171
|
prerelease: false
|
|
172
172
|
version_requirements: !ruby/object:Gem::Requirement
|
|
173
173
|
requirements:
|
|
174
174
|
- - "~>"
|
|
175
175
|
- !ruby/object:Gem::Version
|
|
176
|
-
version: '3.
|
|
176
|
+
version: '3.9'
|
|
177
177
|
- !ruby/object:Gem::Dependency
|
|
178
178
|
name: rubocop
|
|
179
179
|
requirement: !ruby/object:Gem::Requirement
|
|
180
180
|
requirements:
|
|
181
181
|
- - "~>"
|
|
182
182
|
- !ruby/object:Gem::Version
|
|
183
|
-
version: 0.
|
|
183
|
+
version: 0.76.0
|
|
184
184
|
type: :development
|
|
185
185
|
prerelease: false
|
|
186
186
|
version_requirements: !ruby/object:Gem::Requirement
|
|
187
187
|
requirements:
|
|
188
188
|
- - "~>"
|
|
189
189
|
- !ruby/object:Gem::Version
|
|
190
|
-
version: 0.
|
|
190
|
+
version: 0.76.0
|
|
191
191
|
- !ruby/object:Gem::Dependency
|
|
192
192
|
name: simplecov
|
|
193
193
|
requirement: !ruby/object:Gem::Requirement
|
|
194
194
|
requirements:
|
|
195
195
|
- - "~>"
|
|
196
196
|
- !ruby/object:Gem::Version
|
|
197
|
-
version:
|
|
197
|
+
version: 0.17.1
|
|
198
198
|
type: :development
|
|
199
199
|
prerelease: false
|
|
200
200
|
version_requirements: !ruby/object:Gem::Requirement
|
|
201
201
|
requirements:
|
|
202
202
|
- - "~>"
|
|
203
203
|
- !ruby/object:Gem::Version
|
|
204
|
-
version:
|
|
204
|
+
version: 0.17.1
|
|
205
205
|
description: Wordmove deploys your WordPress websites at the speed of light.
|
|
206
206
|
email:
|
|
207
207
|
- stefano.verna@welaika.com
|
|
@@ -264,6 +264,7 @@ files:
|
|
|
264
264
|
- lib/wordmove/doctor/rsync.rb
|
|
265
265
|
- lib/wordmove/doctor/ssh.rb
|
|
266
266
|
- lib/wordmove/doctor/wpcli.rb
|
|
267
|
+
- lib/wordmove/environments_list.rb
|
|
267
268
|
- lib/wordmove/exceptions.rb
|
|
268
269
|
- lib/wordmove/generators/movefile.rb
|
|
269
270
|
- lib/wordmove/generators/movefile.yml
|
|
@@ -299,15 +300,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
299
300
|
requirements:
|
|
300
301
|
- - ">="
|
|
301
302
|
- !ruby/object:Gem::Version
|
|
302
|
-
version: 2.
|
|
303
|
+
version: 2.6.0
|
|
303
304
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
304
305
|
requirements:
|
|
305
306
|
- - ">"
|
|
306
307
|
- !ruby/object:Gem::Version
|
|
307
308
|
version: 1.3.1
|
|
308
309
|
requirements: []
|
|
309
|
-
|
|
310
|
-
rubygems_version: 2.6.11
|
|
310
|
+
rubygems_version: 3.0.3
|
|
311
311
|
signing_key:
|
|
312
312
|
specification_version: 4
|
|
313
313
|
summary: Wordmove, Capistrano for Wordpress
|