wordmove 2.5.1 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.mdown +26 -23
- data/lib/wordmove.rb +4 -3
- data/lib/wordmove/assets/wordmove_schema_remote.yml +33 -0
- data/lib/wordmove/cli.rb +6 -2
- data/lib/wordmove/deployer/base.rb +1 -6
- data/lib/wordmove/deployer/ssh.rb +2 -0
- data/lib/wordmove/generators/movefile.yml +17 -2
- data/lib/wordmove/guardian.rb +35 -0
- data/lib/wordmove/hook.rb +7 -3
- data/lib/wordmove/logger.rb +4 -0
- data/lib/wordmove/version.rb +1 -1
- data/wordmove.gemspec +6 -5
- metadata +9 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 79bfda3783565476f883fc3aa842dee647deeb92
|
4
|
+
data.tar.gz: 0ff3973a23e4c22d8606dffe12a74e13f5eba15c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5a78bc56e6282f7b26a352094e4a9c2b490238b186237f645aa95f8991571ee3ca9020782fe09b0182910b629fcbac012d2880a13b353a4b1b3dab8c192f53d6
|
7
|
+
data.tar.gz: 76ebde3511b4116ebde5f560a849e752294a67496c6b42829ce0bff8cd750ca359f3e71271869e0fcad608485e17ce9908318a36b2316fc58c5259e95e8415c5
|
data/README.mdown
CHANGED
@@ -32,13 +32,14 @@ And to update:
|
|
32
32
|
|
33
33
|
Wordmove just acts as automation glue bewtween tools you already have and love. These are its peer dependencies which you need to have installed and in your $PATH:
|
34
34
|
|
35
|
-
| Program
|
36
|
-
| -------
|
37
|
-
| rsync
|
38
|
-
| mysql
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
35
|
+
| Program | Actions | Mandatory? |
|
36
|
+
| ------- | ---------------------------- | ------------------------------- |
|
37
|
+
| rsync | Mirror files and dirs | Yes for SSH connections |
|
38
|
+
| mysql | Import database | Yes |
|
39
|
+
| mysqldump | Dump database | Yes |
|
40
|
+
| wp-cli | Adapt database | Yes by defalut, but configurable|
|
41
|
+
| lftp | all | Yes, for FTP connections |
|
42
|
+
| ssh | all | Yes, for SSH connections |
|
42
43
|
|
43
44
|
## Usage
|
44
45
|
|
@@ -69,7 +70,7 @@ You can configure Wordmove creating a `movefile.yml`. That's a YAML file with lo
|
|
69
70
|
|
70
71
|
```yaml
|
71
72
|
global:
|
72
|
-
sql_adapter:
|
73
|
+
sql_adapter: wpcli
|
73
74
|
|
74
75
|
local:
|
75
76
|
vhost: http://vhost.local
|
@@ -99,20 +100,22 @@ production:
|
|
99
100
|
host: host
|
100
101
|
# port: 3308 # Use just in case you have exotic server config
|
101
102
|
# mysqldump_options: --max_allowed_packet=50MB # Only available if using SSH
|
103
|
+
# mysql_options: --protocol=TCP # Only available if using SSH
|
102
104
|
|
103
105
|
exclude:
|
104
|
-
- .git/
|
105
|
-
- .gitignore
|
106
|
-
-
|
107
|
-
- bin/
|
108
|
-
- tmp/*
|
109
|
-
- Gemfile*
|
110
|
-
- Movefile
|
111
|
-
- movefile
|
112
|
-
- movefile.yml
|
113
|
-
- movefile.yaml
|
114
|
-
- wp-config.php
|
115
|
-
- wp-content/*.sql
|
106
|
+
- '.git/'
|
107
|
+
- '.gitignore'
|
108
|
+
- 'node_modules/'
|
109
|
+
- 'bin/'
|
110
|
+
- 'tmp/*'
|
111
|
+
- 'Gemfile*'
|
112
|
+
- 'Movefile'
|
113
|
+
- 'movefile'
|
114
|
+
- 'movefile.yml'
|
115
|
+
- 'movefile.yaml'
|
116
|
+
- 'wp-config.php'
|
117
|
+
- 'wp-content/*.sql.gz'
|
118
|
+
- '*.orig'
|
116
119
|
|
117
120
|
ssh:
|
118
121
|
host: host
|
@@ -171,8 +174,8 @@ See the [Windows (un)support disclaimer](https://github.com/welaika/wordmove/wik
|
|
171
174
|
### SSH
|
172
175
|
|
173
176
|
* You need `rsync` on your machine; as far as we know it's already installed on OS X and Linux.
|
174
|
-
*
|
175
|
-
* writing the password inside
|
177
|
+
* To use your SSH public key for authentication, just delete the `production.ssh.password` field in your `movefile.yml`. Easy peasy.
|
178
|
+
* writing the password inside `movefile.yml` was and is somewhat supported, but **we discourage this practice** in favor of password-less authentication with pub key. Read [here](https://github.com/welaika/wordmove/wiki/%5Bdeprecated%5D-SSH-password-inside-Movefile) for old informations.
|
176
179
|
|
177
180
|
### FTP
|
178
181
|
|
@@ -181,7 +184,7 @@ See the [Windows (un)support disclaimer](https://github.com/welaika/wordmove/wik
|
|
181
184
|
* Use the absolute FTP path as `production.wordpress_absolute_path` (you may need to recover this from the `__FILE__` [magic constant](http://php.net/manual/en/language.constants.predefined.php)
|
182
185
|
* if you want to specify a passive FTP connection add to the YAML config a `production.ftp.passive` flag and set it to `true`.
|
183
186
|
|
184
|
-
FTP support is [
|
187
|
+
FTP support development is [discontinued](https://github.com/welaika/wordmove/wiki/FTP-support-disclaimer), but it's always there.
|
185
188
|
|
186
189
|
## Notes
|
187
190
|
|
data/lib/wordmove.rb
CHANGED
@@ -14,21 +14,22 @@ require 'kwalify'
|
|
14
14
|
|
15
15
|
require 'photocopier'
|
16
16
|
|
17
|
-
require 'wordmove/exceptions'
|
18
17
|
require 'wordmove/cli'
|
19
18
|
require 'wordmove/doctor'
|
20
19
|
require 'wordmove/doctor/movefile'
|
21
20
|
require 'wordmove/doctor/mysql'
|
22
|
-
require 'wordmove/doctor/wpcli'
|
23
21
|
require 'wordmove/doctor/rsync'
|
24
22
|
require 'wordmove/doctor/ssh'
|
23
|
+
require 'wordmove/doctor/wpcli'
|
24
|
+
require 'wordmove/exceptions'
|
25
|
+
require 'wordmove/guardian'
|
25
26
|
require 'wordmove/hook'
|
26
27
|
require 'wordmove/logger'
|
27
28
|
require 'wordmove/movefile'
|
28
29
|
require 'wordmove/sql_adapter/default'
|
29
30
|
require 'wordmove/sql_adapter/wpcli'
|
30
|
-
require "wordmove/version"
|
31
31
|
require 'wordmove/wordpress_directory'
|
32
|
+
require "wordmove/version"
|
32
33
|
|
33
34
|
require 'wordmove/generators/movefile_adapter'
|
34
35
|
require 'wordmove/generators/movefile'
|
@@ -129,3 +129,36 @@ mapping:
|
|
129
129
|
type: seq
|
130
130
|
sequence:
|
131
131
|
- type: str
|
132
|
+
forbid:
|
133
|
+
type: map
|
134
|
+
mapping:
|
135
|
+
pull:
|
136
|
+
type: map
|
137
|
+
mapping:
|
138
|
+
db:
|
139
|
+
type: bool
|
140
|
+
plugins:
|
141
|
+
type: bool
|
142
|
+
themes:
|
143
|
+
type: bool
|
144
|
+
languages:
|
145
|
+
type: bool
|
146
|
+
uploads:
|
147
|
+
type: bool
|
148
|
+
mu-plugins:
|
149
|
+
type: bool
|
150
|
+
push:
|
151
|
+
type: map
|
152
|
+
mapping:
|
153
|
+
db:
|
154
|
+
type: bool
|
155
|
+
plugins:
|
156
|
+
type: bool
|
157
|
+
themes:
|
158
|
+
type: bool
|
159
|
+
languages:
|
160
|
+
type: bool
|
161
|
+
uploads:
|
162
|
+
type: bool
|
163
|
+
mu-plugins:
|
164
|
+
type: bool
|
data/lib/wordmove/cli.rb
CHANGED
@@ -73,8 +73,10 @@ module Wordmove
|
|
73
73
|
|
74
74
|
Wordmove::Hook.run(:pull, :before, options)
|
75
75
|
|
76
|
+
guardian = Wordmove::Guardian.new(options: options, action: :pull)
|
77
|
+
|
76
78
|
handle_options(options) do |task|
|
77
|
-
deployer.send("pull_#{task}")
|
79
|
+
deployer.send("pull_#{task}") if guardian.allows(task.to_sym)
|
78
80
|
end
|
79
81
|
|
80
82
|
Wordmove::Hook.run(:pull, :after, options)
|
@@ -95,8 +97,10 @@ module Wordmove
|
|
95
97
|
|
96
98
|
Wordmove::Hook.run(:push, :before, options)
|
97
99
|
|
100
|
+
guardian = Wordmove::Guardian.new(options: options, action: :push)
|
101
|
+
|
98
102
|
handle_options(options) do |task|
|
99
|
-
deployer.send("push_#{task}")
|
103
|
+
deployer.send("push_#{task}") if guardian.allows(task.to_sym)
|
100
104
|
end
|
101
105
|
|
102
106
|
Wordmove::Hook.run(:push, :after, options)
|
@@ -145,9 +145,6 @@ module Wordmove
|
|
145
145
|
if options[:password].present?
|
146
146
|
command << "--password=#{Shellwords.escape(options[:password])}"
|
147
147
|
end
|
148
|
-
if options[:charset].present?
|
149
|
-
command << "--default-character-set=#{Shellwords.escape(options[:charset])}"
|
150
|
-
end
|
151
148
|
command << "--result-file=\"#{save_to_path}\""
|
152
149
|
if options[:mysqldump_options].present?
|
153
150
|
command << Shellwords.split(options[:mysqldump_options])
|
@@ -164,10 +161,8 @@ module Wordmove
|
|
164
161
|
if options[:password].present?
|
165
162
|
command << "--password=#{Shellwords.escape(options[:password])}"
|
166
163
|
end
|
167
|
-
if options[:charset].present?
|
168
|
-
command << "--default-character-set=#{Shellwords.escape(options[:charset])}"
|
169
|
-
end
|
170
164
|
command << "--database=#{Shellwords.escape(options[:name])}"
|
165
|
+
command << Shellwords.split(options[:mysql_options]) if options[:mysql_options].present?
|
171
166
|
command << "--execute=\"SET autocommit=0;SOURCE #{dump_path};COMMIT\""
|
172
167
|
command.join(" ")
|
173
168
|
end
|
@@ -52,6 +52,8 @@ module Wordmove
|
|
52
52
|
# @see initialize
|
53
53
|
%w[get put get_directory put_directory delete].each do |command|
|
54
54
|
define_method "remote_#{command}" do |*args|
|
55
|
+
super
|
56
|
+
|
55
57
|
logger.task_step false, "#{command}: #{args.join(' ')}"
|
56
58
|
@copier.send(command, *args)
|
57
59
|
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
global:
|
2
|
-
sql_adapter:
|
2
|
+
sql_adapter: wpcli
|
3
3
|
|
4
4
|
local:
|
5
5
|
vhost: http://vhost.local
|
@@ -22,11 +22,11 @@ production:
|
|
22
22
|
host: host
|
23
23
|
# port: 3308 # Use just in case you have exotic server config
|
24
24
|
# mysqldump_options: --max_allowed_packet=1G # Only available if using SSH
|
25
|
+
# mysql_options: --protocol=TCP # mysql command is used to import db
|
25
26
|
|
26
27
|
exclude:
|
27
28
|
- '.git/'
|
28
29
|
- '.gitignore'
|
29
|
-
- '.sass-cache/'
|
30
30
|
- 'node_modules/'
|
31
31
|
- 'bin/'
|
32
32
|
- 'tmp/*'
|
@@ -88,6 +88,21 @@ production:
|
|
88
88
|
# - 'echo "Do something locally after pull"'
|
89
89
|
# remote:
|
90
90
|
# - 'echo "Do something remotely after pull"'
|
91
|
+
# forbid:
|
92
|
+
# push:
|
93
|
+
# db: false
|
94
|
+
# plugins: false
|
95
|
+
# themes: false
|
96
|
+
# languages: false
|
97
|
+
# uploads: false
|
98
|
+
# mu-plugins: false
|
99
|
+
# pull:
|
100
|
+
# db: false
|
101
|
+
# plugins: false
|
102
|
+
# themes: false
|
103
|
+
# languages: false
|
104
|
+
# uploads: false
|
105
|
+
# mu-plugins: false
|
91
106
|
|
92
107
|
# staging: # multiple environments can be specified
|
93
108
|
# [...]
|
@@ -0,0 +1,35 @@
|
|
1
|
+
module Wordmove
|
2
|
+
class Guardian
|
3
|
+
attr_reader :movefile, :environment, :action, :logger
|
4
|
+
|
5
|
+
def initialize(options: nil, action: nil)
|
6
|
+
@movefile = Wordmove::Movefile.new(options[:config])
|
7
|
+
@environment = @movefile.environment(options).to_sym
|
8
|
+
@action = action
|
9
|
+
@logger = Logger.new(STDOUT).tap { |l| l.level = Logger::DEBUG }
|
10
|
+
end
|
11
|
+
|
12
|
+
def allows(task)
|
13
|
+
if forbidden?(task)
|
14
|
+
logger.warn("You tried to #{action} #{task}, but is forbidden by configuration. Skipping")
|
15
|
+
end
|
16
|
+
|
17
|
+
!forbidden?(task)
|
18
|
+
end
|
19
|
+
|
20
|
+
private
|
21
|
+
|
22
|
+
def forbidden?(task)
|
23
|
+
return false unless forbidden_tasks[task].present?
|
24
|
+
forbidden_tasks[task] == true
|
25
|
+
end
|
26
|
+
|
27
|
+
def forbidden_tasks
|
28
|
+
environment_options = movefile.fetch(false)[environment]
|
29
|
+
return {} unless environment_options.key?(:forbid)
|
30
|
+
return {} unless environment_options[:forbid].key?(action)
|
31
|
+
|
32
|
+
environment_options[:forbid][action]
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
data/lib/wordmove/hook.rb
CHANGED
@@ -29,7 +29,7 @@ module Wordmove
|
|
29
29
|
end
|
30
30
|
|
31
31
|
Wordmove::Hook::Remote.run(
|
32
|
-
hooks.remote_hooks, options[environment]
|
32
|
+
hooks.remote_hooks, options[environment], cli_options[:simulate]
|
33
33
|
)
|
34
34
|
end
|
35
35
|
|
@@ -90,15 +90,19 @@ module Wordmove
|
|
90
90
|
parent.logger
|
91
91
|
end
|
92
92
|
|
93
|
-
def self.run(commands,
|
93
|
+
def self.run(commands, options, simulate = false)
|
94
94
|
logger.task "Running remote hooks"
|
95
95
|
|
96
|
+
ssh_options = options[:ssh]
|
97
|
+
wordpress_path = options[:wordpress_path]
|
98
|
+
|
96
99
|
copier = Photocopier::SSH.new(ssh_options).tap { |c| c.logger = logger }
|
97
100
|
commands.each do |command|
|
98
101
|
logger.task_step false, "Exec command: #{command}"
|
99
102
|
return true if simulate
|
100
103
|
|
101
|
-
stdout, stderr, exit_code =
|
104
|
+
stdout, stderr, exit_code =
|
105
|
+
copier.exec!("bash -l -c 'cd #{wordpress_path} && #{command}'")
|
102
106
|
|
103
107
|
if exit_code.zero?
|
104
108
|
logger.task_step false, "Output: #{stdout}"
|
data/lib/wordmove/logger.rb
CHANGED
data/lib/wordmove/version.rb
CHANGED
data/wordmove.gemspec
CHANGED
@@ -46,11 +46,12 @@ Gem::Specification.new do |spec|
|
|
46
46
|
spec.add_development_dependency "simplecov", "~> 0.9"
|
47
47
|
|
48
48
|
spec.post_install_message = <<-RAINBOW
|
49
|
-
Starting from
|
50
|
-
|
51
|
-
|
52
|
-
Or you can spawn a new one with `wordmove init` (backup the old one!)
|
49
|
+
Starting from version 3.0.0 `database.charset` option is no longer accepted.
|
50
|
+
Pass the '--default-charecter-set' flag into `database.mysqldump_options` or to
|
51
|
+
`database.mysql_options` instead, if you need to set the same option.
|
53
52
|
|
54
|
-
Starting from
|
53
|
+
Starting from version 3.0.0 the default `global.sql_adapter` is "wpcli".
|
54
|
+
Therefor `WP-CLI` becomes a required peer dependency, unless you'll
|
55
|
+
change to the "default" adapter.
|
55
56
|
RAINBOW
|
56
57
|
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:
|
4
|
+
version: 3.0.0
|
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: 2018-
|
15
|
+
date: 2018-04-06 00:00:00.000000000 Z
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|
18
18
|
name: activesupport
|
@@ -265,6 +265,7 @@ files:
|
|
265
265
|
- lib/wordmove/generators/movefile.rb
|
266
266
|
- lib/wordmove/generators/movefile.yml
|
267
267
|
- lib/wordmove/generators/movefile_adapter.rb
|
268
|
+
- lib/wordmove/guardian.rb
|
268
269
|
- lib/wordmove/hook.rb
|
269
270
|
- lib/wordmove/logger.rb
|
270
271
|
- lib/wordmove/movefile.rb
|
@@ -281,12 +282,13 @@ licenses:
|
|
281
282
|
- MIT
|
282
283
|
metadata: {}
|
283
284
|
post_install_message: |2
|
284
|
-
Starting from
|
285
|
-
|
286
|
-
|
287
|
-
Or you can spawn a new one with `wordmove init` (backup the old one!)
|
285
|
+
Starting from version 3.0.0 `database.charset` option is no longer accepted.
|
286
|
+
Pass the '--default-charecter-set' flag into `database.mysqldump_options` or to
|
287
|
+
`database.mysql_options` instead, if you need to set the same option.
|
288
288
|
|
289
|
-
Starting from
|
289
|
+
Starting from version 3.0.0 the default `global.sql_adapter` is "wpcli".
|
290
|
+
Therefor `WP-CLI` becomes a required peer dependency, unless you'll
|
291
|
+
change to the "default" adapter.
|
290
292
|
rdoc_options: []
|
291
293
|
require_paths:
|
292
294
|
- lib
|