wordmove 5.2.0 → 6.0.0.alpha.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/.github/workflows/ruby.yml +12 -5
- data/.rubocop.yml +2 -5
- data/.ruby-version +1 -1
- data/.yardopts +1 -0
- data/CONTRIBUTING.md +15 -0
- data/Rakefile +4 -3
- data/exe/wordmove +2 -1
- data/lib/wordmove/actions/adapt_local_db.rb +103 -0
- data/lib/wordmove/actions/adapt_remote_db.rb +90 -0
- data/lib/wordmove/actions/backup_local_db.rb +58 -0
- data/lib/wordmove/actions/delete_local_file.rb +34 -0
- data/lib/wordmove/actions/delete_remote_file.rb +43 -0
- data/lib/wordmove/actions/filter_and_setup_tasks_to_run.rb +42 -0
- data/lib/wordmove/actions/ftp/backup_remote_db.rb +56 -0
- data/lib/wordmove/actions/ftp/cleanup_after_adapt.rb +72 -0
- data/lib/wordmove/actions/ftp/download_remote_db.rb +71 -0
- data/lib/wordmove/actions/ftp/get_directory.rb +67 -0
- data/lib/wordmove/actions/ftp/helpers.rb +91 -0
- data/lib/wordmove/actions/ftp/pull_wordpress.rb +56 -0
- data/lib/wordmove/actions/ftp/push_wordpress.rb +54 -0
- data/lib/wordmove/actions/ftp/put_and_import_dump_remotely.rb +83 -0
- data/lib/wordmove/actions/ftp/put_directory.rb +67 -0
- data/lib/wordmove/actions/get_file.rb +38 -0
- data/lib/wordmove/actions/helpers.rb +142 -0
- data/lib/wordmove/actions/put_file.rb +48 -0
- data/lib/wordmove/actions/run_after_pull_hook.rb +26 -0
- data/lib/wordmove/actions/run_after_push_hook.rb +26 -0
- data/lib/wordmove/actions/run_before_pull_hook.rb +26 -0
- data/lib/wordmove/actions/run_before_push_hook.rb +26 -0
- data/lib/wordmove/actions/run_local_command.rb +34 -0
- data/lib/wordmove/actions/setup_context_for_db.rb +78 -0
- data/lib/wordmove/actions/ssh/backup_remote_db.rb +51 -0
- data/lib/wordmove/actions/ssh/cleanup_after_adapt.rb +56 -0
- data/lib/wordmove/actions/ssh/download_remote_db.rb +78 -0
- data/lib/wordmove/actions/ssh/get_directory.rb +76 -0
- data/lib/wordmove/actions/ssh/helpers.rb +128 -0
- data/lib/wordmove/actions/ssh/pull_wordpress.rb +56 -0
- data/lib/wordmove/actions/ssh/push_wordpress.rb +54 -0
- data/lib/wordmove/actions/ssh/put_and_import_dump_remotely.rb +77 -0
- data/lib/wordmove/actions/ssh/put_directory.rb +76 -0
- data/lib/wordmove/actions/ssh/run_remote_command.rb +39 -0
- data/lib/wordmove/assets/dump.php.erb +6 -6
- data/lib/wordmove/assets/import.php.erb +7 -7
- data/lib/wordmove/assets/wordmove_schema_global.yml +2 -0
- data/lib/wordmove/assets/wordmove_schema_remote.yml +2 -2
- data/lib/wordmove/cli.rb +152 -91
- data/lib/wordmove/db_paths_config.rb +44 -0
- data/lib/wordmove/doctor/movefile.rb +8 -8
- data/lib/wordmove/doctor/mysql.rb +18 -15
- data/lib/wordmove/doctor/rsync.rb +2 -2
- data/lib/wordmove/doctor/ssh.rb +3 -3
- data/lib/wordmove/doctor/wpcli.rb +4 -4
- data/lib/wordmove/environments_list.rb +4 -4
- data/lib/wordmove/exceptions.rb +13 -0
- data/lib/wordmove/generators/movefile.rb +7 -5
- data/lib/wordmove/generators/movefile_adapter.rb +11 -5
- data/lib/wordmove/guardian.rb +5 -5
- data/lib/wordmove/hook.rb +15 -16
- data/lib/wordmove/logger.rb +11 -10
- data/lib/wordmove/movefile.rb +63 -59
- data/lib/wordmove/organizers/ftp/pull.rb +52 -0
- data/lib/wordmove/organizers/ftp/push.rb +53 -0
- data/lib/wordmove/organizers/ssh/pull.rb +52 -0
- data/lib/wordmove/organizers/ssh/push.rb +53 -0
- data/lib/wordmove/version.rb +1 -1
- data/lib/wordmove/wordpress_directory.rb +76 -8
- data/lib/wordmove/wpcli.rb +85 -0
- data/lib/wordmove.rb +33 -11
- data/wordmove.gemspec +37 -30
- metadata +141 -43
- data/lib/wordmove/deployer/base.rb +0 -193
- data/lib/wordmove/deployer/ftp.rb +0 -160
- data/lib/wordmove/deployer/ssh/default_sql_adapter.rb +0 -47
- data/lib/wordmove/deployer/ssh/wpcli_sql_adapter.rb +0 -55
- data/lib/wordmove/deployer/ssh.rb +0 -169
- data/lib/wordmove/sql_adapter/default.rb +0 -68
- data/lib/wordmove/sql_adapter/wpcli.rb +0 -54
- data/lib/wordmove/wordpress_directory/path.rb +0 -11
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: 6.0.0.alpha.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:
|
15
|
+
date: 2021-12-27 00:00:00.000000000 Z
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|
18
18
|
name: activesupport
|
@@ -20,20 +20,14 @@ dependencies:
|
|
20
20
|
requirements:
|
21
21
|
- - "~>"
|
22
22
|
- !ruby/object:Gem::Version
|
23
|
-
version: '
|
24
|
-
- - ">="
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
version: 5.1.1
|
23
|
+
version: '6.1'
|
27
24
|
type: :runtime
|
28
25
|
prerelease: false
|
29
26
|
version_requirements: !ruby/object:Gem::Requirement
|
30
27
|
requirements:
|
31
28
|
- - "~>"
|
32
29
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
34
|
-
- - ">="
|
35
|
-
- !ruby/object:Gem::Version
|
36
|
-
version: 5.1.1
|
30
|
+
version: '6.1'
|
37
31
|
- !ruby/object:Gem::Dependency
|
38
32
|
name: colorize
|
39
33
|
requirement: !ruby/object:Gem::Requirement
|
@@ -63,81 +57,109 @@ dependencies:
|
|
63
57
|
- !ruby/object:Gem::Version
|
64
58
|
version: 2.7.5
|
65
59
|
- !ruby/object:Gem::Dependency
|
66
|
-
name:
|
60
|
+
name: dry-configurable
|
67
61
|
requirement: !ruby/object:Gem::Requirement
|
68
62
|
requirements:
|
69
63
|
- - "~>"
|
70
64
|
- !ruby/object:Gem::Version
|
71
|
-
version:
|
65
|
+
version: 0.13.0
|
72
66
|
type: :runtime
|
73
67
|
prerelease: false
|
74
68
|
version_requirements: !ruby/object:Gem::Requirement
|
75
69
|
requirements:
|
76
70
|
- - "~>"
|
77
71
|
- !ruby/object:Gem::Version
|
78
|
-
version:
|
72
|
+
version: 0.13.0
|
79
73
|
- !ruby/object:Gem::Dependency
|
80
|
-
name:
|
74
|
+
name: kwalify
|
81
75
|
requirement: !ruby/object:Gem::Requirement
|
82
76
|
requirements:
|
83
|
-
- - "
|
77
|
+
- - "~>"
|
84
78
|
- !ruby/object:Gem::Version
|
85
|
-
version:
|
79
|
+
version: 0.7.2
|
80
|
+
type: :runtime
|
81
|
+
prerelease: false
|
82
|
+
version_requirements: !ruby/object:Gem::Requirement
|
83
|
+
requirements:
|
86
84
|
- - "~>"
|
87
85
|
- !ruby/object:Gem::Version
|
88
|
-
version:
|
86
|
+
version: 0.7.2
|
87
|
+
- !ruby/object:Gem::Dependency
|
88
|
+
name: light-service
|
89
|
+
requirement: !ruby/object:Gem::Requirement
|
90
|
+
requirements:
|
91
|
+
- - "~>"
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: 0.17.0
|
89
94
|
type: :runtime
|
90
95
|
prerelease: false
|
91
96
|
version_requirements: !ruby/object:Gem::Requirement
|
92
97
|
requirements:
|
98
|
+
- - "~>"
|
99
|
+
- !ruby/object:Gem::Version
|
100
|
+
version: 0.17.0
|
101
|
+
- !ruby/object:Gem::Dependency
|
102
|
+
name: photocopier
|
103
|
+
requirement: !ruby/object:Gem::Requirement
|
104
|
+
requirements:
|
105
|
+
- - "~>"
|
106
|
+
- !ruby/object:Gem::Version
|
107
|
+
version: '1.4'
|
93
108
|
- - ">="
|
94
109
|
- !ruby/object:Gem::Version
|
95
110
|
version: 1.4.0
|
111
|
+
type: :runtime
|
112
|
+
prerelease: false
|
113
|
+
version_requirements: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
96
115
|
- - "~>"
|
97
116
|
- !ruby/object:Gem::Version
|
98
117
|
version: '1.4'
|
118
|
+
- - ">="
|
119
|
+
- !ruby/object:Gem::Version
|
120
|
+
version: 1.4.0
|
99
121
|
- !ruby/object:Gem::Dependency
|
100
|
-
name:
|
122
|
+
name: dry-cli
|
101
123
|
requirement: !ruby/object:Gem::Requirement
|
102
124
|
requirements:
|
103
125
|
- - "~>"
|
104
126
|
- !ruby/object:Gem::Version
|
105
|
-
version: 0.
|
127
|
+
version: 0.7.0
|
106
128
|
type: :runtime
|
107
129
|
prerelease: false
|
108
130
|
version_requirements: !ruby/object:Gem::Requirement
|
109
131
|
requirements:
|
110
132
|
- - "~>"
|
111
133
|
- !ruby/object:Gem::Version
|
112
|
-
version: 0.
|
134
|
+
version: 0.7.0
|
113
135
|
- !ruby/object:Gem::Dependency
|
114
|
-
name:
|
136
|
+
name: dry-files
|
115
137
|
requirement: !ruby/object:Gem::Requirement
|
116
138
|
requirements:
|
117
139
|
- - "~>"
|
118
140
|
- !ruby/object:Gem::Version
|
119
|
-
version:
|
120
|
-
type: :
|
141
|
+
version: 0.1.0
|
142
|
+
type: :runtime
|
121
143
|
prerelease: false
|
122
144
|
version_requirements: !ruby/object:Gem::Requirement
|
123
145
|
requirements:
|
124
146
|
- - "~>"
|
125
147
|
- !ruby/object:Gem::Version
|
126
|
-
version:
|
148
|
+
version: 0.1.0
|
127
149
|
- !ruby/object:Gem::Dependency
|
128
|
-
name:
|
150
|
+
name: bundler
|
129
151
|
requirement: !ruby/object:Gem::Requirement
|
130
152
|
requirements:
|
131
153
|
- - "~>"
|
132
154
|
- !ruby/object:Gem::Version
|
133
|
-
version:
|
155
|
+
version: 2.3.3
|
134
156
|
type: :development
|
135
157
|
prerelease: false
|
136
158
|
version_requirements: !ruby/object:Gem::Requirement
|
137
159
|
requirements:
|
138
160
|
- - "~>"
|
139
161
|
- !ruby/object:Gem::Version
|
140
|
-
version:
|
162
|
+
version: 2.3.3
|
141
163
|
- !ruby/object:Gem::Dependency
|
142
164
|
name: pry-byebug
|
143
165
|
requirement: !ruby/object:Gem::Requirement
|
@@ -186,28 +208,70 @@ dependencies:
|
|
186
208
|
requirements:
|
187
209
|
- - "~>"
|
188
210
|
- !ruby/object:Gem::Version
|
189
|
-
version:
|
211
|
+
version: 1.24.0
|
212
|
+
type: :development
|
213
|
+
prerelease: false
|
214
|
+
version_requirements: !ruby/object:Gem::Requirement
|
215
|
+
requirements:
|
216
|
+
- - "~>"
|
217
|
+
- !ruby/object:Gem::Version
|
218
|
+
version: 1.24.0
|
219
|
+
- !ruby/object:Gem::Dependency
|
220
|
+
name: rubocop-rspec
|
221
|
+
requirement: !ruby/object:Gem::Requirement
|
222
|
+
requirements:
|
223
|
+
- - "~>"
|
224
|
+
- !ruby/object:Gem::Version
|
225
|
+
version: 2.6.0
|
190
226
|
type: :development
|
191
227
|
prerelease: false
|
192
228
|
version_requirements: !ruby/object:Gem::Requirement
|
193
229
|
requirements:
|
194
230
|
- - "~>"
|
195
231
|
- !ruby/object:Gem::Version
|
196
|
-
version:
|
232
|
+
version: 2.6.0
|
197
233
|
- !ruby/object:Gem::Dependency
|
198
234
|
name: simplecov
|
199
235
|
requirement: !ruby/object:Gem::Requirement
|
200
236
|
requirements:
|
201
237
|
- - "~>"
|
202
238
|
- !ruby/object:Gem::Version
|
203
|
-
version: 0.
|
239
|
+
version: 0.21.2
|
204
240
|
type: :development
|
205
241
|
prerelease: false
|
206
242
|
version_requirements: !ruby/object:Gem::Requirement
|
207
243
|
requirements:
|
208
244
|
- - "~>"
|
209
245
|
- !ruby/object:Gem::Version
|
210
|
-
version: 0.
|
246
|
+
version: 0.21.2
|
247
|
+
- !ruby/object:Gem::Dependency
|
248
|
+
name: yard
|
249
|
+
requirement: !ruby/object:Gem::Requirement
|
250
|
+
requirements:
|
251
|
+
- - ">="
|
252
|
+
- !ruby/object:Gem::Version
|
253
|
+
version: '0'
|
254
|
+
type: :development
|
255
|
+
prerelease: false
|
256
|
+
version_requirements: !ruby/object:Gem::Requirement
|
257
|
+
requirements:
|
258
|
+
- - ">="
|
259
|
+
- !ruby/object:Gem::Version
|
260
|
+
version: '0'
|
261
|
+
- !ruby/object:Gem::Dependency
|
262
|
+
name: yard-activesupport-concern
|
263
|
+
requirement: !ruby/object:Gem::Requirement
|
264
|
+
requirements:
|
265
|
+
- - ">="
|
266
|
+
- !ruby/object:Gem::Version
|
267
|
+
version: '0'
|
268
|
+
type: :development
|
269
|
+
prerelease: false
|
270
|
+
version_requirements: !ruby/object:Gem::Requirement
|
271
|
+
requirements:
|
272
|
+
- - ">="
|
273
|
+
- !ruby/object:Gem::Version
|
274
|
+
version: '0'
|
211
275
|
description: Wordmove deploys your WordPress websites at the speed of light.
|
212
276
|
email:
|
213
277
|
- stefano.verna@welaika.com
|
@@ -231,6 +295,7 @@ files:
|
|
231
295
|
- ".ruby-gemset"
|
232
296
|
- ".ruby-version"
|
233
297
|
- ".vscode/launch.json"
|
298
|
+
- ".yardopts"
|
234
299
|
- CHANGELOG.md
|
235
300
|
- CONTRIBUTING.md
|
236
301
|
- Gemfile
|
@@ -259,17 +324,47 @@ files:
|
|
259
324
|
- deploy/deploy.sh
|
260
325
|
- exe/wordmove
|
261
326
|
- lib/wordmove.rb
|
327
|
+
- lib/wordmove/actions/adapt_local_db.rb
|
328
|
+
- lib/wordmove/actions/adapt_remote_db.rb
|
329
|
+
- lib/wordmove/actions/backup_local_db.rb
|
330
|
+
- lib/wordmove/actions/delete_local_file.rb
|
331
|
+
- lib/wordmove/actions/delete_remote_file.rb
|
332
|
+
- lib/wordmove/actions/filter_and_setup_tasks_to_run.rb
|
333
|
+
- lib/wordmove/actions/ftp/backup_remote_db.rb
|
334
|
+
- lib/wordmove/actions/ftp/cleanup_after_adapt.rb
|
335
|
+
- lib/wordmove/actions/ftp/download_remote_db.rb
|
336
|
+
- lib/wordmove/actions/ftp/get_directory.rb
|
337
|
+
- lib/wordmove/actions/ftp/helpers.rb
|
338
|
+
- lib/wordmove/actions/ftp/pull_wordpress.rb
|
339
|
+
- lib/wordmove/actions/ftp/push_wordpress.rb
|
340
|
+
- lib/wordmove/actions/ftp/put_and_import_dump_remotely.rb
|
341
|
+
- lib/wordmove/actions/ftp/put_directory.rb
|
342
|
+
- lib/wordmove/actions/get_file.rb
|
343
|
+
- lib/wordmove/actions/helpers.rb
|
344
|
+
- lib/wordmove/actions/put_file.rb
|
345
|
+
- lib/wordmove/actions/run_after_pull_hook.rb
|
346
|
+
- lib/wordmove/actions/run_after_push_hook.rb
|
347
|
+
- lib/wordmove/actions/run_before_pull_hook.rb
|
348
|
+
- lib/wordmove/actions/run_before_push_hook.rb
|
349
|
+
- lib/wordmove/actions/run_local_command.rb
|
350
|
+
- lib/wordmove/actions/setup_context_for_db.rb
|
351
|
+
- lib/wordmove/actions/ssh/backup_remote_db.rb
|
352
|
+
- lib/wordmove/actions/ssh/cleanup_after_adapt.rb
|
353
|
+
- lib/wordmove/actions/ssh/download_remote_db.rb
|
354
|
+
- lib/wordmove/actions/ssh/get_directory.rb
|
355
|
+
- lib/wordmove/actions/ssh/helpers.rb
|
356
|
+
- lib/wordmove/actions/ssh/pull_wordpress.rb
|
357
|
+
- lib/wordmove/actions/ssh/push_wordpress.rb
|
358
|
+
- lib/wordmove/actions/ssh/put_and_import_dump_remotely.rb
|
359
|
+
- lib/wordmove/actions/ssh/put_directory.rb
|
360
|
+
- lib/wordmove/actions/ssh/run_remote_command.rb
|
262
361
|
- lib/wordmove/assets/dump.php.erb
|
263
362
|
- lib/wordmove/assets/import.php.erb
|
264
363
|
- lib/wordmove/assets/wordmove_schema_global.yml
|
265
364
|
- lib/wordmove/assets/wordmove_schema_local.yml
|
266
365
|
- lib/wordmove/assets/wordmove_schema_remote.yml
|
267
366
|
- lib/wordmove/cli.rb
|
268
|
-
- lib/wordmove/
|
269
|
-
- lib/wordmove/deployer/ftp.rb
|
270
|
-
- lib/wordmove/deployer/ssh.rb
|
271
|
-
- lib/wordmove/deployer/ssh/default_sql_adapter.rb
|
272
|
-
- lib/wordmove/deployer/ssh/wpcli_sql_adapter.rb
|
367
|
+
- lib/wordmove/db_paths_config.rb
|
273
368
|
- lib/wordmove/doctor.rb
|
274
369
|
- lib/wordmove/doctor/movefile.rb
|
275
370
|
- lib/wordmove/doctor/mysql.rb
|
@@ -285,18 +380,21 @@ files:
|
|
285
380
|
- lib/wordmove/hook.rb
|
286
381
|
- lib/wordmove/logger.rb
|
287
382
|
- lib/wordmove/movefile.rb
|
288
|
-
- lib/wordmove/
|
289
|
-
- lib/wordmove/
|
383
|
+
- lib/wordmove/organizers/ftp/pull.rb
|
384
|
+
- lib/wordmove/organizers/ftp/push.rb
|
385
|
+
- lib/wordmove/organizers/ssh/pull.rb
|
386
|
+
- lib/wordmove/organizers/ssh/push.rb
|
290
387
|
- lib/wordmove/version.rb
|
291
388
|
- lib/wordmove/wordpress_directory.rb
|
292
|
-
- lib/wordmove/
|
389
|
+
- lib/wordmove/wpcli.rb
|
293
390
|
- pkg/wordmove-0.0.1.gem
|
294
391
|
- pkg/wordmove-0.0.2.gem
|
295
392
|
- wordmove.gemspec
|
296
393
|
homepage: https://github.com/welaika/wordmove
|
297
394
|
licenses:
|
298
395
|
- MIT
|
299
|
-
metadata:
|
396
|
+
metadata:
|
397
|
+
rubygems_mfa_required: 'true'
|
300
398
|
post_install_message: |2
|
301
399
|
Starting from version 3.0.0 `database.charset` option is no longer accepted.
|
302
400
|
Pass the '--default-charecter-set' flag into `database.mysqldump_options` or to
|
@@ -315,11 +413,11 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
315
413
|
version: 2.6.0
|
316
414
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
317
415
|
requirements:
|
318
|
-
- - "
|
416
|
+
- - ">"
|
319
417
|
- !ruby/object:Gem::Version
|
320
|
-
version:
|
418
|
+
version: 1.3.1
|
321
419
|
requirements: []
|
322
|
-
rubygems_version: 3.
|
420
|
+
rubygems_version: 3.1.2
|
323
421
|
signing_key:
|
324
422
|
specification_version: 4
|
325
423
|
summary: Wordmove, Capistrano for Wordpress
|
@@ -1,193 +0,0 @@
|
|
1
|
-
module Wordmove
|
2
|
-
module Deployer
|
3
|
-
class Base
|
4
|
-
attr_reader :options
|
5
|
-
attr_reader :logger
|
6
|
-
attr_reader :environment
|
7
|
-
|
8
|
-
class << self
|
9
|
-
def deployer_for(cli_options)
|
10
|
-
movefile = Wordmove::Movefile.new(cli_options[:config])
|
11
|
-
movefile.load_dotenv(cli_options)
|
12
|
-
|
13
|
-
options = movefile.fetch.merge! cli_options
|
14
|
-
environment = movefile.environment(cli_options)
|
15
|
-
|
16
|
-
return FTP.new(environment, options) if options[environment][:ftp]
|
17
|
-
|
18
|
-
if options[environment][:ssh] && options[:global][:sql_adapter] == 'wpcli'
|
19
|
-
return Ssh::WpcliSqlAdapter.new(environment, options)
|
20
|
-
end
|
21
|
-
|
22
|
-
if options[environment][:ssh] && options[:global][:sql_adapter] == 'default'
|
23
|
-
return Ssh::DefaultSqlAdapter.new(environment, options)
|
24
|
-
end
|
25
|
-
|
26
|
-
raise NoAdapterFound, "No valid adapter found."
|
27
|
-
end
|
28
|
-
|
29
|
-
def current_dir
|
30
|
-
'.'
|
31
|
-
end
|
32
|
-
|
33
|
-
def logger(secrets)
|
34
|
-
Logger.new(STDOUT, secrets).tap { |l| l.level = Logger::DEBUG }
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
def initialize(environment, options = {})
|
39
|
-
@environment = environment.to_sym
|
40
|
-
@options = options
|
41
|
-
|
42
|
-
movefile_secrets = Wordmove::Movefile.new(options[:config]).secrets
|
43
|
-
@logger = self.class.logger(movefile_secrets)
|
44
|
-
end
|
45
|
-
|
46
|
-
def push_db
|
47
|
-
logger.task "Pushing Database"
|
48
|
-
end
|
49
|
-
|
50
|
-
def pull_db
|
51
|
-
logger.task "Pulling Database"
|
52
|
-
end
|
53
|
-
|
54
|
-
def remote_get_directory; end
|
55
|
-
|
56
|
-
def remote_put_directory; end
|
57
|
-
|
58
|
-
def exclude_dir_contents(path)
|
59
|
-
"#{path}/*"
|
60
|
-
end
|
61
|
-
|
62
|
-
def push_wordpress
|
63
|
-
logger.task "Pushing wordpress core"
|
64
|
-
|
65
|
-
local_path = local_options[:wordpress_path]
|
66
|
-
remote_path = remote_options[:wordpress_path]
|
67
|
-
exclude_wp_content = exclude_dir_contents(local_wp_content_dir.relative_path)
|
68
|
-
exclude_paths = paths_to_exclude.push(exclude_wp_content)
|
69
|
-
|
70
|
-
remote_put_directory(local_path, remote_path, exclude_paths)
|
71
|
-
end
|
72
|
-
|
73
|
-
def pull_wordpress
|
74
|
-
logger.task "Pulling wordpress core"
|
75
|
-
|
76
|
-
local_path = local_options[:wordpress_path]
|
77
|
-
remote_path = remote_options[:wordpress_path]
|
78
|
-
exclude_wp_content = exclude_dir_contents(remote_wp_content_dir.relative_path)
|
79
|
-
exclude_paths = paths_to_exclude.push(exclude_wp_content)
|
80
|
-
|
81
|
-
remote_get_directory(remote_path, local_path, exclude_paths)
|
82
|
-
end
|
83
|
-
|
84
|
-
protected
|
85
|
-
|
86
|
-
def paths_to_exclude
|
87
|
-
remote_options[:exclude] || []
|
88
|
-
end
|
89
|
-
|
90
|
-
def run(command)
|
91
|
-
logger.task_step true, command
|
92
|
-
return true if simulate?
|
93
|
-
|
94
|
-
system(command)
|
95
|
-
raise ShellCommandError, "Return code reports an error" unless $CHILD_STATUS.success?
|
96
|
-
end
|
97
|
-
|
98
|
-
def download(url, local_path)
|
99
|
-
logger.task_step true, "download #{url} > #{local_path}"
|
100
|
-
|
101
|
-
return true if simulate?
|
102
|
-
|
103
|
-
File.open(local_path, 'w') do |file|
|
104
|
-
file << URI.open(url).read
|
105
|
-
end
|
106
|
-
end
|
107
|
-
|
108
|
-
def simulate?
|
109
|
-
options[:simulate]
|
110
|
-
end
|
111
|
-
|
112
|
-
[
|
113
|
-
WordpressDirectory::Path::WP_CONTENT,
|
114
|
-
WordpressDirectory::Path::PLUGINS,
|
115
|
-
WordpressDirectory::Path::MU_PLUGINS,
|
116
|
-
WordpressDirectory::Path::THEMES,
|
117
|
-
WordpressDirectory::Path::UPLOADS,
|
118
|
-
WordpressDirectory::Path::LANGUAGES
|
119
|
-
].each do |type|
|
120
|
-
%i[remote local].each do |location|
|
121
|
-
define_method "#{location}_#{type}_dir" do
|
122
|
-
options = send("#{location}_options")
|
123
|
-
WordpressDirectory.new(type, options)
|
124
|
-
end
|
125
|
-
end
|
126
|
-
end
|
127
|
-
|
128
|
-
def mysql_dump_command(options, save_to_path)
|
129
|
-
command = ["mysqldump"]
|
130
|
-
command << "--host=#{Shellwords.escape(options[:host])}" if options[:host].present?
|
131
|
-
command << "--port=#{Shellwords.escape(options[:port])}" if options[:port].present?
|
132
|
-
command << "--user=#{Shellwords.escape(options[:user])}" if options[:user].present?
|
133
|
-
if options[:password].present?
|
134
|
-
command << "--password=#{Shellwords.escape(options[:password])}"
|
135
|
-
end
|
136
|
-
command << "--result-file=\"#{save_to_path}\""
|
137
|
-
if options[:mysqldump_options].present?
|
138
|
-
command << Shellwords.split(options[:mysqldump_options])
|
139
|
-
end
|
140
|
-
command << Shellwords.escape(options[:name])
|
141
|
-
command.join(" ")
|
142
|
-
end
|
143
|
-
|
144
|
-
def mysql_import_command(dump_path, options)
|
145
|
-
command = ["mysql"]
|
146
|
-
command << "--host=#{Shellwords.escape(options[:host])}" if options[:host].present?
|
147
|
-
command << "--port=#{Shellwords.escape(options[:port])}" if options[:port].present?
|
148
|
-
command << "--user=#{Shellwords.escape(options[:user])}" if options[:user].present?
|
149
|
-
if options[:password].present?
|
150
|
-
command << "--password=#{Shellwords.escape(options[:password])}"
|
151
|
-
end
|
152
|
-
command << "--database=#{Shellwords.escape(options[:name])}"
|
153
|
-
command << Shellwords.split(options[:mysql_options]) if options[:mysql_options].present?
|
154
|
-
command << "--execute=\"SET autocommit=0;SOURCE #{dump_path};COMMIT\""
|
155
|
-
command.join(" ")
|
156
|
-
end
|
157
|
-
|
158
|
-
def compress_command(path)
|
159
|
-
command = ["gzip"]
|
160
|
-
command << "-9"
|
161
|
-
command << "-f"
|
162
|
-
command << "\"#{path}\""
|
163
|
-
command.join(" ")
|
164
|
-
end
|
165
|
-
|
166
|
-
def uncompress_command(path)
|
167
|
-
command = ["gzip"]
|
168
|
-
command << "-d"
|
169
|
-
command << "-f"
|
170
|
-
command << "\"#{path}\""
|
171
|
-
command.join(" ")
|
172
|
-
end
|
173
|
-
|
174
|
-
def local_delete(path)
|
175
|
-
logger.task_step true, "delete: '#{path}'"
|
176
|
-
File.delete(path) unless simulate?
|
177
|
-
end
|
178
|
-
|
179
|
-
def save_local_db(local_dump_path)
|
180
|
-
# dump local mysql into file
|
181
|
-
run mysql_dump_command(local_options[:database], local_dump_path)
|
182
|
-
end
|
183
|
-
|
184
|
-
def remote_options
|
185
|
-
options[environment].clone
|
186
|
-
end
|
187
|
-
|
188
|
-
def local_options
|
189
|
-
options[:local].clone
|
190
|
-
end
|
191
|
-
end
|
192
|
-
end
|
193
|
-
end
|
@@ -1,160 +0,0 @@
|
|
1
|
-
module Wordmove
|
2
|
-
module Deployer
|
3
|
-
class FTP < Base
|
4
|
-
def initialize(environment, options)
|
5
|
-
super(environment, options)
|
6
|
-
ftp_options = remote_options[:ftp]
|
7
|
-
@copier = Photocopier::FTP.new(ftp_options).tap { |c| c.logger = logger }
|
8
|
-
end
|
9
|
-
|
10
|
-
def push_db
|
11
|
-
super
|
12
|
-
|
13
|
-
return true if simulate?
|
14
|
-
|
15
|
-
local_dump_path = local_wp_content_dir.path("dump.sql")
|
16
|
-
remote_dump_path = remote_wp_content_dir.path("dump.sql")
|
17
|
-
local_backup_path = local_wp_content_dir.path("remote-backup-#{Time.now.to_i}.sql")
|
18
|
-
|
19
|
-
download_remote_db(local_backup_path)
|
20
|
-
save_local_db(local_dump_path)
|
21
|
-
|
22
|
-
# gsub sql
|
23
|
-
adapt_sql(local_dump_path, local_options, remote_options)
|
24
|
-
# upload it
|
25
|
-
remote_put(local_dump_path, remote_dump_path)
|
26
|
-
|
27
|
-
import_remote_dump
|
28
|
-
|
29
|
-
# remove dump remotely
|
30
|
-
remote_delete(remote_dump_path)
|
31
|
-
# and locally
|
32
|
-
local_delete(local_dump_path)
|
33
|
-
end
|
34
|
-
|
35
|
-
def pull_db
|
36
|
-
super
|
37
|
-
|
38
|
-
return true if simulate?
|
39
|
-
|
40
|
-
local_dump_path = local_wp_content_dir.path("dump.sql")
|
41
|
-
local_backup_path = local_wp_content_dir.path("local-backup-#{Time.now.to_i}.sql")
|
42
|
-
|
43
|
-
save_local_db(local_backup_path)
|
44
|
-
download_remote_db(local_dump_path)
|
45
|
-
|
46
|
-
# gsub sql
|
47
|
-
adapt_sql(local_dump_path, remote_options, local_options)
|
48
|
-
# import locally
|
49
|
-
run mysql_import_command(local_dump_path, local_options[:database])
|
50
|
-
|
51
|
-
# and locally
|
52
|
-
if options[:debug]
|
53
|
-
logger.debug "Remote dump located at: #{local_dump_path}"
|
54
|
-
else
|
55
|
-
local_delete(local_dump_path)
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
private
|
60
|
-
|
61
|
-
%w[uploads themes plugins mu_plugins languages].each do |task|
|
62
|
-
define_method "push_#{task}" do
|
63
|
-
logger.task "Pushing #{task.titleize}"
|
64
|
-
local_path = send("local_#{task}_dir").path
|
65
|
-
remote_path = send("remote_#{task}_dir").path
|
66
|
-
remote_put_directory(local_path, remote_path, paths_to_exclude)
|
67
|
-
end
|
68
|
-
|
69
|
-
define_method "pull_#{task}" do
|
70
|
-
logger.task "Pulling #{task.titleize}"
|
71
|
-
local_path = send("local_#{task}_dir").path
|
72
|
-
remote_path = send("remote_#{task}_dir").path
|
73
|
-
remote_get_directory(remote_path, local_path, paths_to_exclude)
|
74
|
-
end
|
75
|
-
end
|
76
|
-
|
77
|
-
%w[get get_directory put_directory delete].each do |command|
|
78
|
-
define_method "remote_#{command}" do |*args|
|
79
|
-
logger.task_step false, "#{command}: #{args.join(' ')}"
|
80
|
-
@copier.send(command, *args) unless simulate?
|
81
|
-
end
|
82
|
-
end
|
83
|
-
|
84
|
-
def remote_put(thing, path)
|
85
|
-
if File.exist?(thing)
|
86
|
-
logger.task_step false, "copying #{thing} to #{path}"
|
87
|
-
else
|
88
|
-
logger.task_step false, "write #{path}"
|
89
|
-
end
|
90
|
-
@copier.put(thing, path) unless simulate?
|
91
|
-
end
|
92
|
-
|
93
|
-
def escape_php(string)
|
94
|
-
return '' unless string
|
95
|
-
|
96
|
-
# replaces \ with \\
|
97
|
-
# replaces ' with \'
|
98
|
-
string.gsub('\\', '\\\\\\').gsub(/[']/, '\\\\\'')
|
99
|
-
end
|
100
|
-
|
101
|
-
def generate_dump_script(db, password)
|
102
|
-
template = ERB.new File.read(File.join(File.dirname(__FILE__), "../assets/dump.php.erb"))
|
103
|
-
template.result(binding)
|
104
|
-
end
|
105
|
-
|
106
|
-
def generate_import_script(db, password)
|
107
|
-
template = ERB.new File.read(File.join(File.dirname(__FILE__), "../assets/import.php.erb"))
|
108
|
-
template.result(binding)
|
109
|
-
end
|
110
|
-
|
111
|
-
def download_remote_db(local_dump_path)
|
112
|
-
remote_dump_script = remote_wp_content_dir.path("dump.php")
|
113
|
-
# generate a secure one-time password
|
114
|
-
one_time_password = SecureRandom.hex(40)
|
115
|
-
# generate dump script
|
116
|
-
dump_script = generate_dump_script(remote_options[:database], one_time_password)
|
117
|
-
# upload the dump script
|
118
|
-
remote_put(dump_script, remote_dump_script)
|
119
|
-
# download the resulting dump (using the password)
|
120
|
-
dump_url = "#{remote_wp_content_dir.url('dump.php')}?shared_key=#{one_time_password}"
|
121
|
-
download(dump_url, local_dump_path)
|
122
|
-
# cleanup remotely
|
123
|
-
remote_delete(remote_dump_script)
|
124
|
-
remote_delete(remote_wp_content_dir.path("dump.mysql"))
|
125
|
-
end
|
126
|
-
|
127
|
-
def import_remote_dump
|
128
|
-
temp_path = local_wp_content_dir.path("log.html")
|
129
|
-
remote_import_script_path = remote_wp_content_dir.path("import.php")
|
130
|
-
# generate a secure one-time password
|
131
|
-
one_time_password = SecureRandom.hex(40)
|
132
|
-
# generate import script
|
133
|
-
import_script = generate_import_script(remote_options[:database], one_time_password)
|
134
|
-
# upload import script
|
135
|
-
remote_put(import_script, remote_import_script_path)
|
136
|
-
# run import script
|
137
|
-
import_url = [
|
138
|
-
remote_wp_content_dir.url('import.php').to_s,
|
139
|
-
"?shared_key=#{one_time_password}",
|
140
|
-
"&start=1&foffset=0&totalqueries=0&fn=dump.sql"
|
141
|
-
].join
|
142
|
-
download(import_url, temp_path)
|
143
|
-
if options[:debug]
|
144
|
-
logger.debug "Operation log located at: #{temp_path}"
|
145
|
-
else
|
146
|
-
local_delete(temp_path)
|
147
|
-
end
|
148
|
-
# remove script remotely
|
149
|
-
remote_delete(remote_import_script_path)
|
150
|
-
end
|
151
|
-
|
152
|
-
def adapt_sql(save_to_path, local, remote)
|
153
|
-
return if options[:no_adapt]
|
154
|
-
|
155
|
-
logger.task_step true, "Adapt dump"
|
156
|
-
SqlAdapter::Default.new(save_to_path, local, remote).adapt! unless simulate?
|
157
|
-
end
|
158
|
-
end
|
159
|
-
end
|
160
|
-
end
|