capistrano-cul 0.0.12 → 0.0.13
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +7 -4
- data/VERSION +1 -1
- data/lib/capistrano/tasks/wp.cap +99 -4
- data/lib/capistrano/tasks/wp/migrate.cap +157 -56
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bdf61bf425466ac1f834abf8e1b58c343d6ba6d9
|
4
|
+
data.tar.gz: e4f56d47ce5e62884e0c4e3f9d695fdd09fa040f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e44a48f6094f3a73191ee75b321d2ab069b089404a56f00d484606614d3c5acd3d535c1721c41f50819710f2e385cc3306ce63b7331bb2b054bd0b55ace71189
|
7
|
+
data.tar.gz: 8d256b5e8d83985d222b0dcd1522a3bac57cfbc146c7ef418c9232700152c9a76f7c6563e986474a7462bd7a1ba2f1249c9b97a738bd50405b80b4558541c6da
|
data/README.md
CHANGED
@@ -60,16 +60,19 @@ require 'capistrano/cul/wp'
|
|
60
60
|
4. `cap {env} cul:wp:searchreplace`
|
61
61
|
|
62
62
|
Runs a search and replace operation on the tables in a WordPress installation.
|
63
|
-
5. `cap {env} cul:wp:
|
63
|
+
5. `cap {env} cul:wp:migrate:copy_from`
|
64
|
+
|
65
|
+
Copies the WordPress installation from one environment to another (e.g. prod to dev)
|
66
|
+
6. `cap {env} cul:wp:update:core`
|
64
67
|
|
65
68
|
Updates WordPress core to the latest version.
|
66
|
-
|
69
|
+
7. `cap {env} cul:wp:update:plugins`
|
67
70
|
|
68
71
|
Updates non-repo-managed plugins to the latest version.
|
69
|
-
|
72
|
+
8. `cap {env} cul:wp:update:themes`
|
70
73
|
|
71
74
|
Updates non-repo-managed themes to the latest version.
|
72
|
-
|
75
|
+
9. `cap {env} cul:wp:update:all`
|
73
76
|
|
74
77
|
Updates WordPress core, plugins, and themes (in that order) by calling update:core, update:plugins and update:themes tasks.
|
75
78
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.13
|
data/lib/capistrano/tasks/wp.cap
CHANGED
@@ -1,6 +1,51 @@
|
|
1
|
+
CUL_ALLOWED_UPLOAD_TYPES_PLUGIN_NAME = 'cul-allowed-upload-types'
|
2
|
+
CUL_ALLOWED_UPLOAD_TYPES_REPO_URL = "https://github.com/cul/#{CUL_ALLOWED_UPLOAD_TYPES_PLUGIN_NAME}"
|
3
|
+
|
4
|
+
# Set cul_allowed_uplaod_types_version here so it can be overridden by env config
|
5
|
+
set :cul_allowed_uplaod_types_version, 'v0.2.0'
|
6
|
+
|
1
7
|
namespace :cul do
|
2
8
|
namespace :wp do
|
9
|
+
before 'deploy:starting', 'cul:wp:display_maintenance_mode_warning'
|
10
|
+
after 'deploy:starting', 'cul:wp:enable_maintenance_mode'
|
11
|
+
after 'deploy:starting', 'cul:wp:update_cul_allowed_upload_types_plugin'
|
3
12
|
after :deploy, 'cul:wp:symlink_custom_plugins_and_themes'
|
13
|
+
after :deploy, 'cul:wp:disable_maintenance_mode'
|
14
|
+
|
15
|
+
desc "Displays a message to the deploying user about how to disable maintenance mode"
|
16
|
+
task :display_maintenance_mode_warning do
|
17
|
+
puts color_text("WARNING: Starting a deployment will set WordPress to maintenance mode. If you cancel deployment mid-way through, you'll need to manually disable maintenance mode by running: cap [env] cul:wp:disable_maintenance_mode")
|
18
|
+
end
|
19
|
+
|
20
|
+
desc "Enables maintenance mode for the WordPress site in the deploy environment"
|
21
|
+
task :enable_maintenance_mode do
|
22
|
+
path_to_maintenance_file = maintenance_file_path # save path to local variable because we can't call method inside `on roles(:web)`
|
23
|
+
on roles(:web) do
|
24
|
+
within fetch(:wp_docroot) do
|
25
|
+
# Set maintenance $upgrading value to current time.
|
26
|
+
# Note that WordPress will ignore maintenance mode file
|
27
|
+
# after 10 minutes have passed after the maintenance time
|
28
|
+
# we set in the file.
|
29
|
+
execute :echo, "'<?php $upgrading = #{Time.now.to_i};'", '>', path_to_maintenance_file
|
30
|
+
end
|
31
|
+
end
|
32
|
+
puts color_text("Maintenance mode enabled!")
|
33
|
+
end
|
34
|
+
|
35
|
+
desc "Disable maintenance mode for the WordPress site in the deploy environment"
|
36
|
+
task :disable_maintenance_mode do
|
37
|
+
path_to_maintenance_file = maintenance_file_path # save path to local variable because we can't call method inside `on roles(:web)`
|
38
|
+
on roles(:web) do
|
39
|
+
within fetch(:wp_docroot) do
|
40
|
+
if test("[ -f #{path_to_maintenance_file} ]")
|
41
|
+
execute :rm, path_to_maintenance_file
|
42
|
+
else
|
43
|
+
puts "No maintenance file found, so there's nothing to delete."
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
puts color_text("Maintenance mode disabled!")
|
48
|
+
end
|
4
49
|
|
5
50
|
desc "Creates symlinks for custom plugins and themes as part of a WordPress deployment. Generally run as an `after :deploy` hook."
|
6
51
|
task :symlink_custom_plugins_and_themes do
|
@@ -77,7 +122,6 @@ namespace :cul do
|
|
77
122
|
# Create symlink for wp_document_root wp-content to wp_content_path
|
78
123
|
execute :ln, '-sf', wp_content_path, wp_docroot_wp_content_path
|
79
124
|
end
|
80
|
-
|
81
125
|
symlink_custom_plugins_and_themes
|
82
126
|
end
|
83
127
|
|
@@ -119,17 +163,17 @@ namespace :cul do
|
|
119
163
|
|
120
164
|
if test("[ -d #{wp_content_path} ]")
|
121
165
|
|
122
|
-
|
166
|
+
### Create necessary directories
|
123
167
|
execute :mkdir, '-p', wp_content_plugin_path
|
124
168
|
execute :mkdir, '-p', wp_content_mu_plugin_path
|
125
169
|
execute :mkdir, '-p', wp_content_themes_path
|
126
170
|
|
127
|
-
|
171
|
+
### Remove old symlinks
|
128
172
|
[wp_content_plugin_path, wp_content_mu_plugin_path, wp_content_themes_path].each do |dir|
|
129
173
|
execute :find, dir, '-maxdepth 1', '-type l', '-exec rm {} \;'
|
130
174
|
end
|
131
175
|
|
132
|
-
|
176
|
+
### Add latest symlinks
|
133
177
|
fetch(:wp_custom_plugins, {}).each do |plugin, repo_relative_path|
|
134
178
|
execute :ln, '-sf', File.join(current_path, repo_relative_path), File.join(wp_content_plugin_path, plugin)
|
135
179
|
end
|
@@ -141,6 +185,43 @@ namespace :cul do
|
|
141
185
|
fetch(:wp_custom_themes, {}).each do |theme, repo_relative_path|
|
142
186
|
execute :ln, '-sf', File.join(current_path, repo_relative_path), File.join(wp_content_themes_path, theme)
|
143
187
|
end
|
188
|
+
|
189
|
+
### Also symlink to cul-allowed-upload-types plugin files
|
190
|
+
within deploy_path do
|
191
|
+
cul_allowed_upload_types_plugin_top_level_files_and_dirs = capture(:find, CUL_ALLOWED_UPLOAD_TYPES_PLUGIN_NAME, '-mindepth', '2', '-maxdepth', '2').split("\n")
|
192
|
+
# Symlink all plugin files and directories
|
193
|
+
cul_allowed_upload_types_plugin_top_level_files_and_dirs.each do |plugin_file_or_directory_path|
|
194
|
+
#puts 'Run: ' + [:ln, '-sf', File.join(deploy_path, plugin_file_or_directory_path), File.join(wp_content_mu_plugin_path, File.basename(plugin_file_or_directory_path))].join(' ')
|
195
|
+
execute :ln, '-sf', File.join(deploy_path, plugin_file_or_directory_path), File.join(wp_content_mu_plugin_path, File.basename(plugin_file_or_directory_path))
|
196
|
+
end
|
197
|
+
end
|
198
|
+
|
199
|
+
end
|
200
|
+
end
|
201
|
+
end
|
202
|
+
|
203
|
+
desc "Downloads the latest version of the cul-allowed-upload-types plugin"
|
204
|
+
task :update_cul_allowed_upload_types_plugin do
|
205
|
+
# Download plugin to deploy_path
|
206
|
+
on roles(:web) do
|
207
|
+
within deploy_path do
|
208
|
+
# Clear out old plugin directory if it exists
|
209
|
+
execute :rm, '-rf', CUL_ALLOWED_UPLOAD_TYPES_PLUGIN_NAME
|
210
|
+
# Re-create plugin directory and temp dir inside of it
|
211
|
+
allowed_upload_types_tempdir = File.join(CUL_ALLOWED_UPLOAD_TYPES_PLUGIN_NAME, 'tmp')
|
212
|
+
execute :mkdir, '-p', allowed_upload_types_tempdir
|
213
|
+
|
214
|
+
# Download and unzip plugin
|
215
|
+
allowed_upload_types_temp_zipfile = File.join(allowed_upload_types_tempdir, 'plugin.zip')
|
216
|
+
zip_file_name = "#{fetch(:cul_allowed_uplaod_types_version)}.zip"
|
217
|
+
execute :curl, '-L', '--silent', '-o', allowed_upload_types_temp_zipfile, "#{CUL_ALLOWED_UPLOAD_TYPES_REPO_URL}/archive/#{zip_file_name}"
|
218
|
+
execute :unzip, allowed_upload_types_temp_zipfile, '-d', CUL_ALLOWED_UPLOAD_TYPES_PLUGIN_NAME
|
219
|
+
|
220
|
+
# Delete temp dir after unzip
|
221
|
+
execute :rm, '-rf', allowed_upload_types_tempdir
|
222
|
+
|
223
|
+
# Remove .gitignore file from plugin directory so we don't symlink to it later
|
224
|
+
execute :find, CUL_ALLOWED_UPLOAD_TYPES_PLUGIN_NAME, '-name', '.gitignore', '-delete'
|
144
225
|
end
|
145
226
|
end
|
146
227
|
end
|
@@ -176,5 +257,19 @@ namespace :cul do
|
|
176
257
|
end
|
177
258
|
end
|
178
259
|
|
260
|
+
def self.cul_allowed_upload_types_plugin_path
|
261
|
+
File.join('mu-plugins', CUL_ALLOWED_UPLOAD_TYPES_PLUGIN_NAME)
|
262
|
+
end
|
263
|
+
|
264
|
+
def self.maintenance_file_path
|
265
|
+
File.join(fetch(:wp_docroot), '.maintenance')
|
266
|
+
end
|
267
|
+
|
268
|
+
def self.color_text(message, color_number=35)
|
269
|
+
text_color = "\e[#{color_number}m"
|
270
|
+
default_color = "\e[0m"
|
271
|
+
text_color + message + default_color
|
272
|
+
end
|
273
|
+
|
179
274
|
end
|
180
275
|
end
|
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'tempfile'
|
2
|
+
require 'json'
|
2
3
|
|
3
4
|
namespace :cul do
|
4
5
|
namespace :wp do
|
@@ -6,6 +7,8 @@ namespace :cul do
|
|
6
7
|
|
7
8
|
desc "Copies the WordPress installation from one environment to another (e.g. prod to dev)"
|
8
9
|
task :copy_from do
|
10
|
+
# Need to store path as local variable so it can be referenced in `on roles(:web) do` portion of script
|
11
|
+
path_to_allowed_upload_types_plugin = cul_allowed_upload_types_plugin_path
|
9
12
|
|
10
13
|
require_cap_params!([:wp_docroot, :wp_content_path])
|
11
14
|
|
@@ -33,31 +36,121 @@ namespace :cul do
|
|
33
36
|
next
|
34
37
|
end
|
35
38
|
|
39
|
+
# Enter maintenance mode
|
40
|
+
invoke 'cul:wp:enable_maintenance_mode'
|
41
|
+
|
36
42
|
# Check WP version on source and destination WordPress instances
|
43
|
+
failure = false
|
37
44
|
on roles(:web) do
|
38
45
|
within fetch(:src_wp_docroot) do
|
39
46
|
# Ensure that source WordPress is running the latest version
|
40
47
|
result = capture :wp, (fetch(:multisite, false) ? "--url=#{fetch(:source_site_multisite_url)}" : ''), 'core', 'check-update'
|
41
48
|
unless result.index('Success')
|
42
49
|
puts 'Could not copy from source WordPress because it is not running the latest version of WordPress. Please update source before running a copy operation.'
|
50
|
+
failure = true
|
43
51
|
end
|
44
52
|
end
|
45
|
-
|
46
53
|
within fetch(:wp_docroot) do
|
47
54
|
# Ensure that destination WordPress is running the latest version
|
48
55
|
result = capture :wp, (fetch(:multisite, false) ? "--url=#{fetch(:destination_site_multisite_url)}" : ''), 'core', 'check-update'
|
49
56
|
unless result.index('Success')
|
50
57
|
puts "Could not copy TO destination [#{fetch(:stage)}] WordPress because it is not running the latest version of WordPress. Please update [#{fetch(:stage)}] before running a copy operation."
|
58
|
+
failure = true
|
51
59
|
end
|
52
60
|
end
|
53
61
|
end
|
62
|
+
next if failure # End if the previous checks failed
|
63
|
+
|
64
|
+
path_to_list_of_files_to_copy = ''
|
65
|
+
|
54
66
|
on roles(:web) do
|
67
|
+
# In source site's wp-content directory, generate file list to copy
|
68
|
+
within File.join(fetch(:src_wp_docroot), 'wp-content') do
|
69
|
+
# We're going to be copying wp-content in two parts
|
70
|
+
# 1. Everything else under wp-content EXCEPT uploads, blogs.dir,
|
71
|
+
# plugins, themes, mu-plugins
|
72
|
+
# 2. Everything under uploads AND wpblogs.dir with
|
73
|
+
# cul-allowed-upload-types file extension filter applied
|
74
|
+
|
75
|
+
# Generate two find commands for the above searches
|
76
|
+
find_non_upload_dirs = '. -type f ' +
|
77
|
+
# EXCLUDE plugins, themes, mu-plugins, uploads, and blogs.dir
|
78
|
+
"-not \\( -path './plugins/*' -o -path './mu-plugins/*' -o -path './themes/*' -o -path './uploads/*' -o -path './blogs.dir/*' \\) " +
|
79
|
+
# EXCLUDE certain unwanted files and paths
|
80
|
+
"-a -not \\( -name '.nfs*' \\) " +
|
81
|
+
"-a -not \\( -path '*/.git*' -o -path '*/.svn*' -o -path '*/.hg*' \\) "
|
82
|
+
|
83
|
+
find_upload_dirs = '. -type f ' +
|
84
|
+
# INCLUDE ONLY uploads and blogs.dir
|
85
|
+
"\\( -path './uploads/*' -o -path './blogs.dir/*' \\) " +
|
86
|
+
# EXCLUDE certain unwanted files and paths
|
87
|
+
"-a -not \\( -name '.nfs*' \\) " +
|
88
|
+
"-a -not \\( -path '*/.git*' -o -path '*/.svn*' -o -path '*/.hg*' \\) " +
|
89
|
+
# INCLUDE ONLY certain file extensions
|
90
|
+
"-a \\( " + JSON.parse(capture(:wp, (fetch(:multisite, false) ? "--url=#{fetch(:source_site_multisite_url)}" : ''), 'eval', '"echo cul_allowed_upload_file_extensions_as_json();"')).map{ |allowed_file_extension|
|
91
|
+
"-iname '*.#{allowed_file_extension}'"
|
92
|
+
}.join(' -o ') + " \\) "
|
93
|
+
|
94
|
+
path_to_list_of_files_to_copy = '/tmp/WP' + fetch(:wp_docroot).gsub('/', '-') + '-' + Time.now.to_i.to_s + '-files.txt'
|
95
|
+
execute :find, find_non_upload_dirs, ' > ', path_to_list_of_files_to_copy
|
96
|
+
execute :find, find_upload_dirs, ' >> ', path_to_list_of_files_to_copy
|
97
|
+
|
98
|
+
# Print out which files won't be copied
|
99
|
+
files_not_copied = capture(:comm, '-23', "<(find . -type f -path './uploads/*' -o -path './blogs.dir/*' | sort)", "<(find #{find_upload_dirs} | sort)")
|
100
|
+
|
101
|
+
puts (
|
102
|
+
"The following files will not be copied:\n" +
|
103
|
+
"-------------------------\n" +
|
104
|
+
"./plugins\n" +
|
105
|
+
"./mu-plugins\n" +
|
106
|
+
"./themes\n" +
|
107
|
+
files_not_copied + "\n" +
|
108
|
+
"-------------------------"
|
109
|
+
)
|
110
|
+
end
|
111
|
+
|
112
|
+
# For destination wordpress, delete and recreate the wp-content directory
|
113
|
+
execute :rm, '-rf', fetch(:wp_content_path)
|
114
|
+
execute :mkdir, fetch(:wp_content_path)
|
115
|
+
|
116
|
+
# Copy wp-content files (from path_to_list_of_files_to_copy) from source WP to destination WP
|
117
|
+
# Note that because we have the '--copy-links' flag below, we're transforming all symlinks into real file copies
|
118
|
+
rsync_params = [
|
119
|
+
'--recursive',
|
120
|
+
'--perms',
|
121
|
+
'--times',
|
122
|
+
'--devices',
|
123
|
+
'--specials',
|
124
|
+
'--copy-links',
|
125
|
+
'--prune-empty-dirs'
|
126
|
+
]
|
127
|
+
|
128
|
+
# we're only copying files from the given file list
|
129
|
+
rsync_params << "--files-from=#{path_to_list_of_files_to_copy}"
|
130
|
+
# src directory (--files-from values are relative to this src directory)
|
131
|
+
rsync_params << File.join(fetch(:src_wp_docroot), 'wp-content/')
|
132
|
+
# dest directory
|
133
|
+
rsync_params << fetch(:wp_content_path) + '/'
|
134
|
+
|
135
|
+
puts 'Copying wp-content. This may take a while for sites with a lot of uploads...'
|
136
|
+
|
137
|
+
execute :rsync, *rsync_params
|
138
|
+
|
139
|
+
# Next, create symlinks to repo-managed plugins and themes, which will also recreate plugins, mu-plugins, and themes directories
|
140
|
+
|
141
|
+
within fetch(:wp_docroot) do
|
142
|
+
# Regenerate symlinks
|
143
|
+
invoke 'cul:wp:symlink_custom_plugins_and_themes'
|
144
|
+
end
|
145
|
+
|
146
|
+
# Now it's time to copy the database
|
55
147
|
|
56
148
|
db_export_tempfile_path = ''
|
57
149
|
|
58
150
|
within fetch(:src_wp_docroot) do
|
59
151
|
# On source WordPress...
|
60
152
|
|
153
|
+
puts 'Exporting database from source site. This may take a while for large sites...'
|
61
154
|
# Export source WP DB to a temporary file
|
62
155
|
db_export_tempfile_path = Dir::Tmpname.make_tmpname '/tmp/', 'db_export_tempfile.sql'
|
63
156
|
execute :wp, (fetch(:multisite, false) ? "--url=#{fetch(:source_site_multisite_url)}" : ''), 'db', 'export', db_export_tempfile_path
|
@@ -66,6 +159,8 @@ namespace :cul do
|
|
66
159
|
within fetch(:wp_docroot) do
|
67
160
|
# On destination WordPress...
|
68
161
|
|
162
|
+
puts 'Importing database. This may take a while for large sites...'
|
163
|
+
|
69
164
|
# Drop all tables
|
70
165
|
execute :wp, 'db', 'reset', '--yes'
|
71
166
|
|
@@ -75,78 +170,84 @@ namespace :cul do
|
|
75
170
|
# Delete db file now that we're done with it
|
76
171
|
execute :rm, db_export_tempfile_path
|
77
172
|
|
78
|
-
#
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
'
|
86
|
-
'--perms',
|
87
|
-
'--times',
|
88
|
-
'--devices',
|
89
|
-
'--specials',
|
90
|
-
'--copy-links'
|
91
|
-
]
|
92
|
-
# Exclude all repo-managed plugins, mu_plugins and themes
|
93
|
-
fetch(:wp_custom_plugins, {}).each do |plugin, repo_relative_path|
|
94
|
-
rsync_params << "--exclude plugins/#{plugin}"
|
95
|
-
end
|
96
|
-
fetch(:wp_custom_mu_plugins, {}).each do |mu_plugin, repo_relative_path|
|
97
|
-
rsync_params << "--exclude mu-plugins/#{mu_plugin}"
|
98
|
-
end
|
99
|
-
|
100
|
-
fetch(:wp_custom_themes, {}).each do |theme, repo_relative_path|
|
101
|
-
rsync_params << "--exclude themes/#{theme}"
|
173
|
+
# Invoke searchreplace task to update URL
|
174
|
+
puts "\nYou'll probably want to run the cul:wp:searchreplace command now, since it's likely that your WP URL differs between environments."
|
175
|
+
puts "Do you want to run a search and replace operation?"
|
176
|
+
set :confirm_searchreplace, ask('"y" or "yes" to continue')
|
177
|
+
if ['y', 'yes'].include?(fetch(:confirm_searchreplace))
|
178
|
+
invoke 'cul:wp:searchreplace'
|
179
|
+
else
|
180
|
+
puts '- Skipping search and replace because neither "y" nor "yes" were entered.'
|
102
181
|
end
|
103
182
|
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
# Exclude Wordfence wflogs directory, if present
|
108
|
-
rsync_params << '--exclude wflogs'
|
109
|
-
|
110
|
-
# Exclude repository directories
|
111
|
-
rsync_params << '--exclude .svn'
|
112
|
-
rsync_params << '--exclude .git'
|
113
|
-
rsync_params << '--exclude .hg'
|
183
|
+
puts "\nCopy operation complete!"
|
184
|
+
end
|
114
185
|
|
115
|
-
|
116
|
-
rsync_params << File.join(fetch(:src_wp_docroot), 'wp-content/')
|
186
|
+
# Next, install all plugins and themes from src wordpress, matching all versions and active vs. inactive plugin and theme states
|
117
187
|
|
118
|
-
|
119
|
-
|
188
|
+
data_for_plugins = []
|
189
|
+
data_for_themes = []
|
120
190
|
|
121
|
-
|
191
|
+
# Within src wp instance, get list of all plugins and themes with version
|
192
|
+
within File.join(fetch(:src_wp_docroot)) do
|
193
|
+
data_for_plugins = JSON.parse(capture(:wp, (fetch(:multisite, false) ? "--url=#{fetch(:source_site_multisite_url)}" : ''), 'plugin', 'list', '--fields=name,version,status', '--format=json'))
|
194
|
+
data_for_themes = JSON.parse(capture(:wp, (fetch(:multisite, false) ? "--url=#{fetch(:source_site_multisite_url)}" : ''), 'theme', 'list', '--fields=name,version,status', '--format=json'))
|
195
|
+
end
|
122
196
|
|
123
|
-
|
197
|
+
# Within dest wp instance, install specifically versioned plugins and themes
|
198
|
+
within File.join(fetch(:wp_docroot)) do
|
199
|
+
# Get list of already-installed plugins and themes (from dest instance) so that we don't attempt to reinstall them
|
200
|
+
already_installed_plugin_names = JSON.parse(capture(:wp, (fetch(:multisite, false) ? "--url=#{fetch(:source_site_multisite_url)}" : ''), 'plugin', 'list', '--fields=name,version,status', '--format=json')).map{|plugin_info| plugin_info['name']}
|
201
|
+
already_installed_theme_names = JSON.parse(capture(:wp, (fetch(:multisite, false) ? "--url=#{fetch(:source_site_multisite_url)}" : ''), 'theme', 'list', '--fields=name,version,status', '--format=json')).map{|theme_info| theme_info['name']}
|
202
|
+
|
203
|
+
puts 'Already installed plugins: ' + already_installed_plugin_names.inspect
|
204
|
+
puts 'Already installed themes: ' + already_installed_theme_names.inspect
|
205
|
+
|
206
|
+
data_for_plugins.delete_if{|plugin_info| already_installed_plugin_names.include?(plugin_info['name']) }.each do |plugin_info|
|
207
|
+
name = plugin_info['name']
|
208
|
+
version = plugin_info['version']
|
209
|
+
status = plugin_info['status']
|
210
|
+
|
211
|
+
case status
|
212
|
+
when 'active'
|
213
|
+
execute :wp, (fetch(:multisite, false) ? "--url=#{fetch(:source_site_multisite_url)}" : ''), 'plugin', 'install', name, "--version=#{version}", '--activate'
|
214
|
+
when 'active-network'
|
215
|
+
execute :wp, (fetch(:multisite, false) ? "--url=#{fetch(:source_site_multisite_url)}" : ''), 'plugin', 'install', name, "--version=#{version}", '--activate-network'
|
216
|
+
when 'inactive'
|
217
|
+
execute :wp, (fetch(:multisite, false) ? "--url=#{fetch(:source_site_multisite_url)}" : ''), 'plugin', 'install', name, "--version=#{version}"
|
218
|
+
when 'must-use'
|
219
|
+
puts "--- WARNING: must-use plugin #{name} was not migrated over. It should be put in your blog's repository and deployed through a regular deployment."
|
220
|
+
end
|
221
|
+
end
|
124
222
|
|
125
|
-
|
126
|
-
|
223
|
+
data_for_themes.delete_if{|theme_info| already_installed_theme_names.include?(theme_info['name']) }.each do |theme_info|
|
224
|
+
name = theme_info['name']
|
225
|
+
version = theme_info['version']
|
226
|
+
status = theme_info['status']
|
227
|
+
|
228
|
+
case status
|
229
|
+
when 'active'
|
230
|
+
execute :wp, (fetch(:multisite, false) ? "--url=#{fetch(:source_site_multisite_url)}" : ''), 'theme', 'install', name, "--version=#{version}", '--activate'
|
231
|
+
when 'inactive'
|
232
|
+
execute :wp, (fetch(:multisite, false) ? "--url=#{fetch(:source_site_multisite_url)}" : ''), 'theme', 'install', name, "--version=#{version}"
|
233
|
+
end
|
234
|
+
end
|
235
|
+
end
|
127
236
|
|
237
|
+
within fetch(:wp_docroot) do
|
128
238
|
# Make docroot readable and executable for "other" user so nginx, which runs as "nobody", can read
|
129
239
|
# Use -L flag because we want to follow symlinks. The whole deployment relies on symlinks.
|
130
240
|
execute :find, '-L', File.join(fetch(:wp_docroot), 'wp-content'), '-type d -exec chmod o+rx "{}" \;'
|
131
241
|
execute :find, '-L', File.join(fetch(:wp_docroot), 'wp-content'), '-type f -exec chmod o+r "{}" \;'
|
132
|
-
|
133
|
-
|
134
|
-
puts "\nYou'll probably want to run the cul:wp:searchreplace command now, since it's likely that your WP URL differs between environments."
|
135
|
-
puts "Do you want to run a search and replace operation?"
|
136
|
-
set :confirm_searchreplace, ask('"y" or "yes" to continue')
|
137
|
-
if ['y', 'yes'].include?(fetch(:confirm_searchreplace))
|
138
|
-
invoke 'cul:wp:searchreplace'
|
139
|
-
else
|
140
|
-
puts '- Skipping search and replace because neither "y" nor "yes" were entered.'
|
141
|
-
end
|
142
|
-
|
143
|
-
puts "\nCopy operation complete!"
|
242
|
+
# Make sure that wp-config file is not world readable
|
243
|
+
execute :chmod, 'o-r', shared_path.join('wp-config.php')
|
144
244
|
end
|
145
245
|
|
146
246
|
end
|
147
|
-
|
148
247
|
end
|
149
248
|
|
249
|
+
after 'cul:wp:migrate:copy_from', 'cul:wp:disable_maintenance_mode'
|
250
|
+
|
150
251
|
end
|
151
252
|
end
|
152
253
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: capistrano-cul
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.13
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Carla Galarza
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2018-02-05 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: capistrano
|
@@ -81,7 +81,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
81
81
|
version: '0'
|
82
82
|
requirements: []
|
83
83
|
rubyforge_project:
|
84
|
-
rubygems_version: 2.6.
|
84
|
+
rubygems_version: 2.6.14
|
85
85
|
signing_key:
|
86
86
|
specification_version: 4
|
87
87
|
summary: Common capistrano tasks shared across projects at CUL
|