wslave 0.0.17 → 0.2.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/base/.gitignore +5 -0
- data/base/config/deploy-tools/gen-nginx-vhost.rb +11 -0
- data/base/config/deploy-tools/nginx.vhost.erb +51 -0
- data/base/config/deploy.rb +1 -1
- data/base/config/deploy/.production.rb.swp +0 -0
- data/base/config/deploy/.staging.rb.swp +0 -0
- data/base/config/deploy/production.rb +90 -8
- data/base/config/deploy/staging.rb +90 -8
- data/base/docker-compose.yml +13 -2
- data/base/{Dockerfile → docker/apache/Dockerfile} +2 -4
- data/base/docker/nginx/Dockerfile +24 -0
- data/base/docker/nginx/nginx.vhost +48 -0
- data/base/docker/nginx/supervisord.conf +23 -0
- data/base/public/.htaccess +11 -0
- data/bin/wslave +76 -22
- data/lib/wslave_docker.rb +34 -3
- data/lib/wslave_new.rb +48 -9
- data/lib/wslave_sage.rb +70 -3
- data/lib/wslave_tools.rb +0 -1
- data/lib/wslave_update.rb +2 -2
- data/templates/config/definitions.yml +6 -1
- data/wslave.gemspec +9 -6
- metadata +79 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 61e948f1644206ed6520ad69e43583dbafe1200208eb007d7dab044e09d1c84f
|
4
|
+
data.tar.gz: 351b554954d11957292a027a440f7add6ee8156b7b5eeaa9d97fc7cbb9772fb9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b67317839d90324f73bdd34c998832be78d367174fe2c88737d615a9811b9c5c531ea0bed198461425307b2b7e6742e330a9258abe7a10b99f7af9b1630a4756
|
7
|
+
data.tar.gz: 2513942d0a62658f8a4b72bc0f2afcc3f933ad94c6f5507ad6f9a94c02571cdcfaa0b625049c9e2cf9f55d8789b3223f748c6eee3157a2b96dc0c986001d1d51
|
@@ -0,0 +1,11 @@
|
|
1
|
+
require 'erb'
|
2
|
+
require 'yaml'
|
3
|
+
require 'ostruct'
|
4
|
+
|
5
|
+
def GenerateNginxConfig(profile = 'production', out_path= './')
|
6
|
+
config_path = File.dirname(File.expand_path(File.dirname(__FILE__)))
|
7
|
+
server = {}
|
8
|
+
#server[:name] =
|
9
|
+
#server[:root] =
|
10
|
+
#server[:php_sock_path] =
|
11
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
server {
|
2
|
+
listen 80;
|
3
|
+
listen [::]:80;
|
4
|
+
|
5
|
+
server_name <%= server[:name] %>;
|
6
|
+
|
7
|
+
root <%= server[:root] %>;
|
8
|
+
|
9
|
+
access_log <%= server[:root] %>/access.log;
|
10
|
+
error_log <%= server[:root] %>/error.log;
|
11
|
+
|
12
|
+
index index.php;
|
13
|
+
|
14
|
+
location / {
|
15
|
+
rewrite ^/(wp-(admin|includes).*) /wordpress/$1 last;
|
16
|
+
|
17
|
+
rewrite ^/$ /wordpress/index.php last;
|
18
|
+
|
19
|
+
location ~ \.php {
|
20
|
+
if ($request_uri !~* "/wp-config.php") {
|
21
|
+
rewrite ^/wp-(.*)\.php$ /wordpress/wp-$1.php last;
|
22
|
+
}
|
23
|
+
rewrite ^/index\.php$ /wordpress/index.php last;
|
24
|
+
rewrite ^/wp-login\.php$ /hello.php last;
|
25
|
+
include snippets/fastcgi-php.conf;
|
26
|
+
fastcgi_pass unix:<%= server[:php_sock_path] %>;
|
27
|
+
}
|
28
|
+
}
|
29
|
+
|
30
|
+
location ~ /\. {
|
31
|
+
deny all;
|
32
|
+
access_log off;
|
33
|
+
log_not_found off;
|
34
|
+
}
|
35
|
+
|
36
|
+
location ~- \.(blade\.php)$ {
|
37
|
+
deny all;
|
38
|
+
}
|
39
|
+
|
40
|
+
location ~- composer\.(json|lock)$ {
|
41
|
+
deny all;
|
42
|
+
}
|
43
|
+
|
44
|
+
location ~- package(-lock)?\.json$ {
|
45
|
+
deny all;
|
46
|
+
}
|
47
|
+
|
48
|
+
location ~- yarn\.lock$ {
|
49
|
+
deny all;
|
50
|
+
}
|
51
|
+
}
|
data/base/config/deploy.rb
CHANGED
Binary file
|
Binary file
|
@@ -1,10 +1,12 @@
|
|
1
1
|
require 'yaml'
|
2
2
|
require 'date'
|
3
|
+
require 'wslave_sage'
|
3
4
|
|
4
5
|
opts = YAML.load_file('config/definitions.yml')
|
5
6
|
db_info = YAML.load_file('config/database.yml')
|
6
7
|
|
7
8
|
deploy_user = opts['deployer']['user']
|
9
|
+
deploy_group = opts['deployer']['www_data_group']
|
8
10
|
host_addr = opts['deployer']['host']['production']
|
9
11
|
multisite_root = opts['deployer']['root']
|
10
12
|
site_fqdn = opts['deployer']['fqdn']['production']
|
@@ -12,6 +14,10 @@ site_fqdn = opts['deployer']['fqdn']['production']
|
|
12
14
|
disable_rsync = (opts.include?('options') && opts['options'].include?('rsync_enabled') &&
|
13
15
|
opts['options']['rsync_enabled'] == false)
|
14
16
|
|
17
|
+
if (opts['deployer'].include?('branch') && opts['deployer']['branch'].include?('production'))
|
18
|
+
set :branch, opts['deployer']['branch']['production']
|
19
|
+
end
|
20
|
+
|
15
21
|
role :web, "#{deploy_user}@#{host_addr}"
|
16
22
|
|
17
23
|
set :tmp_dir, "#{multisite_root}/tmp"
|
@@ -76,10 +82,54 @@ namespace :deploy do
|
|
76
82
|
end
|
77
83
|
end
|
78
84
|
|
85
|
+
desc 'Builds and Syncs the project Sage theme'
|
86
|
+
task :sync_sage_theme do
|
87
|
+
on roles(:web) do
|
88
|
+
wss = WSlaveSage.new()
|
89
|
+
sage_theme_name = wss.theme_name?
|
90
|
+
if (sage_theme_name == '')
|
91
|
+
puts "Couldn't find a Sage theme for this project."
|
92
|
+
else
|
93
|
+
wss.production()
|
94
|
+
`rsync -avzPhu --delete ./public/wp-content/themes/#{sage_theme_name}/vendor/ #{deploy_user}@#{host_addr}:#{deploy_path}/current/public/wp-content/themes/#{sage_theme_name}/vendor/`
|
95
|
+
`rsync -avzPhu --delete ./public/wp-content/themes/#{sage_theme_name}/dist/ #{deploy_user}@#{host_addr}:#{deploy_path}/current/public/wp-content/themes/#{sage_theme_name}/dist/`
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
desc 'Builds and Uploads the project Sage theme'
|
101
|
+
task :upload_sage_theme do
|
102
|
+
on roles(:web) do
|
103
|
+
wss = WSlaveSage.new()
|
104
|
+
sage_theme_name = wss.theme_name?
|
105
|
+
if (sage_theme_name == '')
|
106
|
+
puts "Couldn't find a Sage theme for this project."
|
107
|
+
else
|
108
|
+
wss.production()
|
109
|
+
upload! "./public/wp-content/themes/#{sage_theme_name}/vendor/", "#{deploy_path}/current/public/wp-content/themes/#{sage_theme_name}/", recursive: true
|
110
|
+
upload! "./public/wp-content/themes/#{sage_theme_name}/dist/", "#{deploy_path}/current/public/wp-content/themes/#{sage_theme_name}/", recursive: true
|
111
|
+
end
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
desc 'Builds and Deploys the project Sage theme'
|
116
|
+
task :sage do
|
117
|
+
on roles(:web) do
|
118
|
+
if disable_rsync
|
119
|
+
invoke('deploy:upload_sage_theme')
|
120
|
+
else
|
121
|
+
invoke('deploy:sync_sage_theme')
|
122
|
+
end
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
79
126
|
desc 'Finds and replaces localhost:8000 and your Staging address with the Production address'
|
80
127
|
task :chikan do
|
81
128
|
on roles(:web) do
|
82
|
-
puts 'Replacing localhost:8000 and
|
129
|
+
puts 'Replacing localhost:8000 and Production URLs with Staging URLs...'
|
130
|
+
|
131
|
+
# Set an anchor to first homogonize instances of URL's, then replace all the anchors
|
132
|
+
anchor = "URL_REPLACEMENT_ANCHOR_00000"
|
83
133
|
|
84
134
|
# Create a backup, download it, and remove remote copy
|
85
135
|
execute "mkdir -p #{deploy_path}/db/tmp"
|
@@ -91,18 +141,45 @@ namespace :deploy do
|
|
91
141
|
# Regex replace in file
|
92
142
|
db_data = File.read('db/tmp/wordpress.sql')
|
93
143
|
|
94
|
-
|
144
|
+
# This may seem roundabout, but in order to avoid mangling the target URL we need to first
|
145
|
+
# replace instances of it with something that won't match
|
146
|
+
db_data = db_data.gsub(/#{opts['deployer']['fqdn']['production']}/, anchor)
|
147
|
+
|
148
|
+
# Set staging URL's to the anchor
|
95
149
|
if opts['deployer']['fqdn']['staging'] != ''
|
96
|
-
db_data = db_data.gsub(/#{opts['deployer']['fqdn']['staging']}/,
|
150
|
+
db_data = db_data.gsub(/#{opts['deployer']['fqdn']['staging']}/, anchor)
|
97
151
|
end
|
98
152
|
|
153
|
+
# Set localhost entries to the anchor
|
154
|
+
db_data = db_data.gsub(/localhost\%3A8000/, anchor)
|
155
|
+
db_data = db_data.gsub(/localhost:8000/, anchor)
|
156
|
+
|
157
|
+
# Replace anchors with the correct target URL
|
158
|
+
db_data = db_data.gsub(anchor, "#{opts['deployer']['fqdn']['production']}")
|
159
|
+
|
160
|
+
# Save results
|
99
161
|
File.open('db/tmp/wordpress.sql', "w") {|file| file.puts db_data }
|
100
162
|
|
101
163
|
# Upload file and seed
|
102
164
|
upload! 'db/tmp/wordpress.sql', "#{deploy_path}/db/tmp/wordpress.sql"
|
103
165
|
execute "mysql -h#{db_info['production']['host']} -u#{db_info['production']['username']} -p#{db_info['production']['password']} #{db_info['production']['database']} < #{deploy_path}/db/tmp/wordpress.sql"
|
104
166
|
execute "rm #{deploy_path}/db/tmp/*.sql"
|
105
|
-
|
167
|
+
|
168
|
+
# Remove work file
|
169
|
+
# `rm db/tmp/wordpress.sql`
|
170
|
+
end
|
171
|
+
end
|
172
|
+
|
173
|
+
desc 'Sets ownership permissions'
|
174
|
+
task :set_permissions do
|
175
|
+
on roles(:web) do
|
176
|
+
puts 'Setting permissions'
|
177
|
+
if deploy_group != nil
|
178
|
+
puts "Recrusively setting group to #{deploy_group}..."
|
179
|
+
execute "chown -R :#{deploy_group} #{deploy_path}"
|
180
|
+
puts 'Allowing group level Write permission...'
|
181
|
+
execute "chmod -R g+w #{deploy_path}"
|
182
|
+
end
|
106
183
|
end
|
107
184
|
end
|
108
185
|
|
@@ -125,17 +202,20 @@ namespace :deploy do
|
|
125
202
|
invoke('deploy')
|
126
203
|
invoke('db:seed')
|
127
204
|
invoke('deploy:chikan')
|
205
|
+
invoke('deploy:sage')
|
206
|
+
invoke('deploy:set_permissions')
|
128
207
|
end
|
129
208
|
end
|
130
209
|
|
131
210
|
desc 'Clear out remote DB tables and delete all remote files in deploy target directory'
|
132
211
|
task :destruct do
|
133
212
|
on roles(:web) do
|
134
|
-
execute "
|
213
|
+
execute "mysql --user=#{db_info['production']['username']} " \
|
214
|
+
"--password=#{db_info['production']['password']} --host=#{db_info['production']['host']} " \
|
215
|
+
"-Nse 'show tables' #{db_info['production']['database']} | " \
|
216
|
+
"while read table; do echo \"drop table $table;\"; done | " \
|
217
|
+
"mysql --user=#{db_info['production']['username']} " \
|
135
218
|
"--password=#{db_info['production']['password']} --host=#{db_info['production']['host']} " \
|
136
|
-
"--add-drop-table --no-data #{db_info['production']['database']} | " \
|
137
|
-
"grep -e '^DROP \| FOREIGN_KEY_CHECKS' | mysql -u#{db_info['production']['username']} " \
|
138
|
-
"-p#{db_info['production']['password']} -h#{db_info['production']['host']} " \
|
139
219
|
"#{db_info['production']['database']}"
|
140
220
|
|
141
221
|
execute "rm -rf #{deploy_path}/*"
|
@@ -181,6 +261,7 @@ namespace :data do
|
|
181
261
|
download! "#{deploy_path}/shared/public/wp-content/uploads", "./public/wp-content/", recursive: true
|
182
262
|
download! "#{deploy_path}/shared/public/wp-content/plugins", "./public/wp-content/", recursive: true
|
183
263
|
download! "#{deploy_path}/shared/public/wp-content/upgrade", "./public/wp-content/", recursive: true
|
264
|
+
download! "#{deploy_path}/current/public/wp-content/themes", "./public/wp-content/", recursive: true
|
184
265
|
end
|
185
266
|
end
|
186
267
|
|
@@ -191,6 +272,7 @@ namespace :data do
|
|
191
272
|
`rsync -avzPhu --delete #{deploy_user}@#{host_addr}:#{deploy_path}/shared/public/wp-content/uploads/ ./public/wp-content/uploads/`
|
192
273
|
`rsync -avzPhu --delete #{deploy_user}@#{host_addr}:#{deploy_path}/shared/public/wp-content/plugins/ ./public/wp-content/plugins/`
|
193
274
|
`rsync -avzPhu --delete #{deploy_user}@#{host_addr}:#{deploy_path}/shared/public/wp-content/upgrade/ ./public/wp-content/upgrade/`
|
275
|
+
`rsync -avzPhu --delete #{deploy_user}@#{host_addr}:#{deploy_path}/current/public/wp-content/themes/ ./public/wp-content/themes/`
|
194
276
|
end
|
195
277
|
end
|
196
278
|
end
|
@@ -1,10 +1,12 @@
|
|
1
1
|
require 'yaml'
|
2
2
|
require 'date'
|
3
|
+
require 'wslave_sage'
|
3
4
|
|
4
5
|
opts = YAML.load_file('config/definitions.yml')
|
5
6
|
db_info = YAML.load_file('config/database.yml')
|
6
7
|
|
7
8
|
deploy_user = opts['deployer']['user']
|
9
|
+
deploy_group = opts['deployer']['www_data_group']
|
8
10
|
host_addr = opts['deployer']['host']['staging']
|
9
11
|
multisite_root = opts['deployer']['root']
|
10
12
|
site_fqdn = opts['deployer']['fqdn']['staging']
|
@@ -12,6 +14,10 @@ site_fqdn = opts['deployer']['fqdn']['staging']
|
|
12
14
|
disable_rsync = (opts.include?('options') && opts['options'].include?('rsync_enabled') &&
|
13
15
|
opts['options']['rsync_enabled'] == false)
|
14
16
|
|
17
|
+
if (opts['deployer'].include?('branch') && opts['deployer']['branch'].include?('staging'))
|
18
|
+
set :branch, opts['deployer']['branch']['staging']
|
19
|
+
end
|
20
|
+
|
15
21
|
role :web, "#{deploy_user}@#{host_addr}"
|
16
22
|
|
17
23
|
set :tmp_dir, "#{multisite_root}/tmp"
|
@@ -22,11 +28,11 @@ set :linked_files, %w{public/wp-config.php}
|
|
22
28
|
|
23
29
|
set :deploy_to, deploy_path
|
24
30
|
|
25
|
-
|
26
31
|
namespace :deploy do
|
27
32
|
desc "Generate wp-config.php for profile"
|
28
33
|
task :wp_config do
|
29
34
|
on roles(:web) do
|
35
|
+
invoke 'deploy:check:make_linked_dirs'
|
30
36
|
require_relative '../deploy-tools/gen-wp-config'
|
31
37
|
FileUtils.mkdir('./tmp') unless Dir.exist?('./tmp')
|
32
38
|
GenerateWPConfig('staging', './tmp')
|
@@ -76,11 +82,55 @@ namespace :deploy do
|
|
76
82
|
end
|
77
83
|
end
|
78
84
|
|
85
|
+
desc 'Builds and Syncs the project Sage theme'
|
86
|
+
task :sync_sage_theme do
|
87
|
+
on roles(:web) do
|
88
|
+
wss = WSlaveSage.new()
|
89
|
+
sage_theme_name = wss.theme_name?
|
90
|
+
if (sage_theme_name == '')
|
91
|
+
puts "Couldn't find a Sage theme for this project."
|
92
|
+
else
|
93
|
+
wss.production()
|
94
|
+
`rsync -avzPhu --delete ./public/wp-content/themes/#{sage_theme_name}/vendor/ #{deploy_user}@#{host_addr}:#{deploy_path}/current/public/wp-content/themes/#{sage_theme_name}/vendor/`
|
95
|
+
`rsync -avzPhu --delete ./public/wp-content/themes/#{sage_theme_name}/dist/ #{deploy_user}@#{host_addr}:#{deploy_path}/current/public/wp-content/themes/#{sage_theme_name}/dist/`
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
desc 'Builds and Uploads the project Sage theme'
|
101
|
+
task :upload_sage_theme do
|
102
|
+
on roles(:web) do
|
103
|
+
wss = WSlaveSage.new()
|
104
|
+
sage_theme_name = wss.theme_name?
|
105
|
+
if (sage_theme_name == '')
|
106
|
+
puts "Couldn't find a Sage theme for this project."
|
107
|
+
else
|
108
|
+
wss.production()
|
109
|
+
upload! "./public/wp-content/themes/#{sage_theme_name}/vendor/", "#{deploy_path}/current/public/wp-content/themes/#{sage_theme_name}/", recursive: true
|
110
|
+
upload! "./public/wp-content/themes/#{sage_theme_name}/dist/", "#{deploy_path}/current/public/wp-content/themes/#{sage_theme_name}/", recursive: true
|
111
|
+
end
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
desc 'Builds and Deploys the project Sage theme'
|
116
|
+
task :sage do
|
117
|
+
on roles(:web) do
|
118
|
+
if disable_rsync
|
119
|
+
invoke('deploy:upload_sage_theme')
|
120
|
+
else
|
121
|
+
invoke('deploy:sync_sage_theme')
|
122
|
+
end
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
79
126
|
desc 'Finds and replaces localhost:8000 and your Production address with the Staging address'
|
80
127
|
task :chikan do
|
81
128
|
on roles(:web) do
|
82
129
|
puts 'Replacing localhost:8000 and Production URLs with Staging URLs...'
|
83
130
|
|
131
|
+
# Set an anchor to first homogonize instances of URL's, then replace all the anchors
|
132
|
+
anchor = "URL_REPLACEMENT_ANCHOR_00000"
|
133
|
+
|
84
134
|
# Create a backup, download it, and remove remote copy
|
85
135
|
execute "mkdir -p #{deploy_path}/db/tmp"
|
86
136
|
execute "mysqldump --opt --user=#{db_info['staging']['username']} --password=#{db_info['staging']['password']} --host=#{db_info['staging']['host']} #{db_info['staging']['database']} > #{deploy_path}/db/tmp/wordpress.sql"
|
@@ -91,18 +141,45 @@ namespace :deploy do
|
|
91
141
|
# Regex replace in file
|
92
142
|
db_data = File.read('db/tmp/wordpress.sql')
|
93
143
|
|
94
|
-
|
144
|
+
# This may seem roundabout, but in order to avoid mangling the target URL we need to first
|
145
|
+
# replace instances of it with something that won't match
|
146
|
+
db_data = db_data.gsub(/#{opts['deployer']['fqdn']['staging']}/, anchor)
|
147
|
+
|
148
|
+
# Set production URL's to the anchor
|
95
149
|
if opts['deployer']['fqdn']['production'] != ''
|
96
|
-
db_data = db_data.gsub(/#{opts['deployer']['fqdn']['production']}/,
|
150
|
+
db_data = db_data.gsub(/#{opts['deployer']['fqdn']['production']}/, anchor)
|
97
151
|
end
|
98
152
|
|
153
|
+
# Set localhost entries to the anchor
|
154
|
+
db_data = db_data.gsub(/localhost\%3A8000/, anchor)
|
155
|
+
db_data = db_data.gsub(/localhost:8000/, anchor)
|
156
|
+
|
157
|
+
# Replace anchors with the correct target URL
|
158
|
+
db_data = db_data.gsub(anchor, "#{opts['deployer']['fqdn']['staging']}")
|
159
|
+
|
160
|
+
# Save results
|
99
161
|
File.open('db/tmp/wordpress.sql', "w") {|file| file.puts db_data }
|
100
162
|
|
101
163
|
# Upload file and seed
|
102
164
|
upload! 'db/tmp/wordpress.sql', "#{deploy_path}/db/tmp/wordpress.sql"
|
103
165
|
execute "mysql -h#{db_info['staging']['host']} -u#{db_info['staging']['username']} -p#{db_info['staging']['password']} #{db_info['staging']['database']} < #{deploy_path}/db/tmp/wordpress.sql"
|
104
166
|
execute "rm #{deploy_path}/db/tmp/*.sql"
|
105
|
-
|
167
|
+
|
168
|
+
# Remove work file
|
169
|
+
# `rm db/tmp/wordpress.sql`
|
170
|
+
end
|
171
|
+
end
|
172
|
+
|
173
|
+
desc 'Sets ownership permissions'
|
174
|
+
task :set_permissions do
|
175
|
+
on roles(:web) do
|
176
|
+
puts 'Setting permissions'
|
177
|
+
if deploy_group != nil
|
178
|
+
puts "Recrusively setting group to #{deploy_group}..."
|
179
|
+
execute "chown -R :#{deploy_group} #{deploy_path}"
|
180
|
+
puts 'Allowing group level Write permission...'
|
181
|
+
execute "chmod -R g+w #{deploy_path}"
|
182
|
+
end
|
106
183
|
end
|
107
184
|
end
|
108
185
|
|
@@ -125,17 +202,20 @@ namespace :deploy do
|
|
125
202
|
invoke('deploy')
|
126
203
|
invoke('db:seed')
|
127
204
|
invoke('deploy:chikan')
|
205
|
+
invoke('deploy:sage')
|
206
|
+
invoke('deploy:set_permissions')
|
128
207
|
end
|
129
208
|
end
|
130
209
|
|
131
210
|
desc 'Clear out remote DB tables and delete all remote files in deploy target directory'
|
132
211
|
task :destruct do
|
133
212
|
on roles(:web) do
|
134
|
-
execute "
|
213
|
+
execute "mysql --user=#{db_info['staging']['username']} " \
|
214
|
+
"--password=#{db_info['staging']['password']} --host=#{db_info['staging']['host']} " \
|
215
|
+
"-Nse 'show tables' #{db_info['staging']['database']} | " \
|
216
|
+
"while read table; do echo \"drop table $table;\"; done | " \
|
217
|
+
"mysql --user=#{db_info['staging']['username']} " \
|
135
218
|
"--password=#{db_info['staging']['password']} --host=#{db_info['staging']['host']} " \
|
136
|
-
"--add-drop-table --no-data #{db_info['staging']['database']} | " \
|
137
|
-
"grep -e '^DROP \| FOREIGN_KEY_CHECKS' | mysql -u#{db_info['staging']['username']} " \
|
138
|
-
"-p#{db_info['staging']['password']} -h#{db_info['staging']['host']} " \
|
139
219
|
"#{db_info['staging']['database']}"
|
140
220
|
|
141
221
|
execute "rm -rf #{deploy_path}/*"
|
@@ -181,6 +261,7 @@ namespace :data do
|
|
181
261
|
download! "#{deploy_path}/shared/public/wp-content/uploads", "./public/wp-content/", recursive: true
|
182
262
|
download! "#{deploy_path}/shared/public/wp-content/plugins", "./public/wp-content/", recursive: true
|
183
263
|
download! "#{deploy_path}/shared/public/wp-content/upgrade", "./public/wp-content/", recursive: true
|
264
|
+
download! "#{deploy_path}/current/public/wp-content/themes", "./public/wp-content/", recursive: true
|
184
265
|
end
|
185
266
|
end
|
186
267
|
|
@@ -191,6 +272,7 @@ namespace :data do
|
|
191
272
|
`rsync -avzPhu --delete #{deploy_user}@#{host_addr}:#{deploy_path}/shared/public/wp-content/uploads/ ./public/wp-content/uploads/`
|
192
273
|
`rsync -avzPhu --delete #{deploy_user}@#{host_addr}:#{deploy_path}/shared/public/wp-content/plugins/ ./public/wp-content/plugins/`
|
193
274
|
`rsync -avzPhu --delete #{deploy_user}@#{host_addr}:#{deploy_path}/shared/public/wp-content/upgrade/ ./public/wp-content/upgrade/`
|
275
|
+
`rsync -avzPhu --delete #{deploy_user}@#{host_addr}:#{deploy_path}/current/public/wp-content/themes/ ./public/wp-content/themes/`
|
194
276
|
end
|
195
277
|
end
|
196
278
|
end
|
data/base/docker-compose.yml
CHANGED
@@ -2,7 +2,7 @@ version: '3'
|
|
2
2
|
|
3
3
|
services:
|
4
4
|
db:
|
5
|
-
image:
|
5
|
+
image: mariadb:10.5.4-focal
|
6
6
|
volumes:
|
7
7
|
- "./db/dev:/db"
|
8
8
|
- "./db/active:/docker-entrypoint-initdb.d"
|
@@ -12,7 +12,7 @@ services:
|
|
12
12
|
web:
|
13
13
|
depends_on:
|
14
14
|
- db
|
15
|
-
build:
|
15
|
+
build: ./docker/apache/
|
16
16
|
volumes:
|
17
17
|
- "./public:/var/www/html"
|
18
18
|
ports:
|
@@ -20,3 +20,14 @@ services:
|
|
20
20
|
environment:
|
21
21
|
WORDPRESS_DB_HOST: db:3306
|
22
22
|
WORDPRESS_DB_PASSWORD: wordpress
|
23
|
+
nweb:
|
24
|
+
depends_on:
|
25
|
+
- db
|
26
|
+
build: ./docker/nginx/
|
27
|
+
volumes:
|
28
|
+
- "./public:/var/www/html"
|
29
|
+
ports:
|
30
|
+
- "8001:80"
|
31
|
+
environment:
|
32
|
+
WORDPRESS_DB_HOST: db:3306
|
33
|
+
WORDPRESS_DB_PASSWORD: wordpress
|
@@ -1,13 +1,11 @@
|
|
1
|
-
FROM php:
|
1
|
+
FROM php:7.4-apache
|
2
2
|
|
3
3
|
RUN a2enmod rewrite
|
4
4
|
RUN service apache2 restart
|
5
5
|
RUN apt-get update \
|
6
|
-
&& apt-get install -y
|
7
|
-
&& docker-php-ext-configure gd --with-png-dir=/usr --with-jpeg-dir=/usr \
|
6
|
+
&& apt-get install -y libpng-dev libjpeg-dev mariadb-client mariadb-common libonig-dev \
|
8
7
|
&& docker-php-ext-install gd \
|
9
8
|
&& docker-php-ext-install mbstring \
|
10
|
-
&& docker-php-ext-install mysql \
|
11
9
|
&& docker-php-ext-install mysqli \
|
12
10
|
&& docker-php-ext-install pdo \
|
13
11
|
&& docker-php-ext-install pdo_mysql \
|
@@ -0,0 +1,24 @@
|
|
1
|
+
FROM ubuntu:20.04
|
2
|
+
|
3
|
+
COPY nginx.vhost /etc/nginx/sites-enabled/default
|
4
|
+
COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf
|
5
|
+
|
6
|
+
RUN apt-get update
|
7
|
+
RUN DEBIAN_FRONTEND="noninteractive" apt-get -y install tzdata
|
8
|
+
RUN apt-get install -y nginx php-fpm php-mysql \
|
9
|
+
libpng-dev libjpeg-dev \
|
10
|
+
mariadb-client mariadb-common \
|
11
|
+
supervisor curl
|
12
|
+
RUN apt-get clean
|
13
|
+
RUN adduser www-data root
|
14
|
+
RUN mkdir /db \
|
15
|
+
&& chmod 777 /db
|
16
|
+
|
17
|
+
RUN ln -sf /dev/stdout /var/log/nginx/access.log \
|
18
|
+
&& ln -sf /dev/stderr /var/log/nginx/error.log
|
19
|
+
|
20
|
+
EXPOSE 80
|
21
|
+
|
22
|
+
STOPSIGNAL SIGTERM
|
23
|
+
|
24
|
+
CMD ["/usr/bin/supervisord", "-c", "/etc/supervisor/conf.d/supervisord.conf"]
|
@@ -0,0 +1,48 @@
|
|
1
|
+
server {
|
2
|
+
listen 80;
|
3
|
+
listen [::]:80;
|
4
|
+
|
5
|
+
server_name testing;
|
6
|
+
|
7
|
+
root /var/www/html;
|
8
|
+
|
9
|
+
index index.php;
|
10
|
+
|
11
|
+
location / {
|
12
|
+
rewrite ^/(wp-(admin|includes).*) /wordpress/$1 last;
|
13
|
+
|
14
|
+
rewrite ^/$ /wordpress/index.php last;
|
15
|
+
|
16
|
+
location ~ \.php {
|
17
|
+
if ($request_uri !~* "/wp-config.php") {
|
18
|
+
rewrite ^/wp-(.*)\.php$ /wordpress/wp-$1.php last;
|
19
|
+
}
|
20
|
+
rewrite ^/index\.php$ /wordpress/index.php last;
|
21
|
+
rewrite ^/wp-login\.php$ /hello.php last;
|
22
|
+
include snippets/fastcgi-php.conf;
|
23
|
+
fastcgi_pass unix:/run/php/php7.2-fpm.sock;
|
24
|
+
}
|
25
|
+
}
|
26
|
+
|
27
|
+
location ~ /\. {
|
28
|
+
deny all;
|
29
|
+
access_log off;
|
30
|
+
log_not_found off;
|
31
|
+
}
|
32
|
+
|
33
|
+
location ~- \.(blade\.php)$ {
|
34
|
+
deny all;
|
35
|
+
}
|
36
|
+
|
37
|
+
location ~- composer\.(json|lock)$ {
|
38
|
+
deny all;
|
39
|
+
}
|
40
|
+
|
41
|
+
location ~- package(-lock)?\.json$ {
|
42
|
+
deny all;
|
43
|
+
}
|
44
|
+
|
45
|
+
location ~- yarn\.lock$ {
|
46
|
+
deny all;
|
47
|
+
}
|
48
|
+
}
|
@@ -0,0 +1,23 @@
|
|
1
|
+
[supervisord]
|
2
|
+
nodaemon=true
|
3
|
+
logfile=/dev/null
|
4
|
+
logfile_maxbytes=0
|
5
|
+
pidfile=/run/supervisord.pid
|
6
|
+
|
7
|
+
[program:php-fpm]
|
8
|
+
command=php-fpm7.2 -F
|
9
|
+
stdout_logfile=/dev/stdout
|
10
|
+
stdout_logfile_maxbytes=0
|
11
|
+
stderr_logfile=/dev/stderr
|
12
|
+
stderr_logfile_maxbytes=0
|
13
|
+
autorestart=false
|
14
|
+
startretries=0
|
15
|
+
|
16
|
+
[program:nginx]
|
17
|
+
command=nginx -g 'daemon off;'
|
18
|
+
stdout_logfile=/dev/stdout
|
19
|
+
stdout_logfile_maxbytes=0
|
20
|
+
stderr_logfile=/dev/stderr
|
21
|
+
stderr_logfile_maxbytes=0
|
22
|
+
autorestart=false
|
23
|
+
startretries=0
|
data/base/public/.htaccess
CHANGED
@@ -14,3 +14,14 @@
|
|
14
14
|
# BEGIN WordPress
|
15
15
|
# END WordPress
|
16
16
|
</IfModule>
|
17
|
+
<FilesMatch ".+\.(blade\.php)$">
|
18
|
+
<IfModule mod_authz_core.c>
|
19
|
+
# Apache 2.4
|
20
|
+
Require all denied
|
21
|
+
</IfModule>
|
22
|
+
<IfModule !mod_authz_core.c>
|
23
|
+
# Apache 2.2
|
24
|
+
Order deny,allow
|
25
|
+
Deny from all
|
26
|
+
</IfModule>
|
27
|
+
</FilesMatch>
|
data/bin/wslave
CHANGED
@@ -4,13 +4,20 @@ require 'fileutils'
|
|
4
4
|
|
5
5
|
class WSlaveCLI < Thor
|
6
6
|
|
7
|
+
def self.exit_on_failure?
|
8
|
+
true
|
9
|
+
end
|
10
|
+
|
7
11
|
desc 'new [APP_PATH]', "Generate a new app at APP_PATH"
|
8
12
|
long_desc "Creates a new application in the current directory or in the specificed path."
|
9
|
-
|
13
|
+
option :version, default: '',
|
14
|
+
desc: 'Specify the version, EG: "--version 5.3". To specify edge/development master use "--version edge".'
|
15
|
+
option :wspath, default: '',
|
16
|
+
desc: 'specify the path to the wslave distribution, EG: "--wspath ../wslave".'
|
10
17
|
def new(path = './')
|
11
18
|
require_relative '../lib/wslave_new'
|
12
19
|
real_path = File.expand_path(path)
|
13
|
-
WSlaveNew.new(real_path, options['version'])
|
20
|
+
WSlaveNew.new(real_path, options['version'], options['wspath'])
|
14
21
|
end
|
15
22
|
|
16
23
|
desc 'update', "Updates toolchain"
|
@@ -20,35 +27,55 @@ class WSlaveCLI < Thor
|
|
20
27
|
WSlaveUpdate.new()
|
21
28
|
end
|
22
29
|
|
23
|
-
desc '
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
30
|
+
desc 'server COMMAND [options]', "Control the development server container. " \
|
31
|
+
"Commands include: start stop log console"
|
32
|
+
long_desc <<-LONGDESC
|
33
|
+
Start, stop, view logs for, or connect to a console in a development server container.
|
34
|
+
\x5
|
35
|
+
\x5 COMMANDs:
|
36
|
+
\x5 start Starts a development server container. *Will restart the container if already running.
|
37
|
+
\x5 stop Stops a running development container.
|
38
|
+
\x5 log Connects to the container logs and follows them.
|
39
|
+
\x5 console Gives a terminal connection to a bash console on the web container.
|
40
|
+
\x5\x5
|
41
|
+
Examples:
|
42
|
+
\x5 Start dev container servers
|
43
|
+
\x5 > wslave server start
|
44
|
+
\x5 Start or restart dev container servers after resetting all volumes (reinit)
|
45
|
+
\x5 > wslave server start -v
|
46
|
+
\x5 Force stop all dev container servers
|
47
|
+
\x5 > wslave server stop -f
|
48
|
+
\x5 Show logs
|
49
|
+
\x5 > wslave server logs
|
50
|
+
|
51
|
+
|
52
|
+
\x5 * If you do not specify a COMMAND the default is to start a server.
|
53
|
+
\x5 * If a server is alredy running this command will restart the server.
|
54
|
+
LONGDESC
|
55
|
+
method_option :v, type: :boolean, default: false, description: 'remove volume data'
|
56
|
+
method_option :f, type: :boolean, default: false, description: 'force close other servers first'
|
57
|
+
def server(command = 'start')
|
58
|
+
puts 'Starting server...'
|
59
|
+
require_relative '../lib/wslave_docker'
|
60
|
+
WSlaveDocker.new().server(command.to_sym, options['f'], options['v'])
|
35
61
|
end
|
36
62
|
|
37
|
-
desc '
|
38
|
-
method_option :
|
39
|
-
|
63
|
+
desc 'start [options]', "Starts the development server (short for 'server start')"
|
64
|
+
method_option :v, type: :boolean, default: false, description: 'remove volume data'
|
65
|
+
method_option :f, type: :boolean, default: false, description: 'force close other servers first'
|
66
|
+
def start()
|
40
67
|
puts 'Starting server...'
|
41
68
|
require_relative '../lib/wslave_docker'
|
42
|
-
WSlaveDocker.new().server(options['f'])
|
69
|
+
WSlaveDocker.new().server(:start, options['f'], options['v'])
|
43
70
|
end
|
44
71
|
|
45
|
-
desc 'stop [options]', "Stops the development server"
|
46
|
-
method_option :v, default: false, description: 'remove volume data'
|
47
|
-
method_option :f, default: false, description: 'force close other servers first'
|
72
|
+
desc 'stop [options]', "Stops the development server (short for 'server stop')"
|
73
|
+
method_option :v, type: :boolean, default: false, description: 'remove volume data'
|
74
|
+
method_option :f, type: :boolean, default: false, description: 'force close other servers first'
|
48
75
|
def stop()
|
49
76
|
puts 'Stopping server...'
|
50
77
|
require_relative '../lib/wslave_docker'
|
51
|
-
WSlaveDocker.new().stop
|
78
|
+
WSlaveDocker.new().server(:stop, options['f'], options['v'])
|
52
79
|
end
|
53
80
|
|
54
81
|
desc 'sync', "Synchronizes submodules and file permissions"
|
@@ -64,6 +91,33 @@ class WSlaveCLI < Thor
|
|
64
91
|
spec = Gem::Specification::load("#{__dir__}/../wslave.gemspec")
|
65
92
|
puts spec.version
|
66
93
|
end
|
94
|
+
|
95
|
+
desc 'sage COMMAND', "Generate a theme with NAME"
|
96
|
+
long_desc "Generates a theme base with sage in the themes directory with the given " \
|
97
|
+
"NAME. A random name will be generated if you do not specify a NAME."
|
98
|
+
def sage(command = '', arg = '')
|
99
|
+
case command
|
100
|
+
when 'create'
|
101
|
+
require_relative '../lib/wslave_sage'
|
102
|
+
puts "Generating sage theme base for #{arg}"
|
103
|
+
WSlaveSage.new().create(arg)
|
104
|
+
when 'update'
|
105
|
+
require_relative '../lib/wslave_sage'
|
106
|
+
WSlaveSage.new().update()
|
107
|
+
when 'dev'
|
108
|
+
require_relative '../lib/wslave_sage'
|
109
|
+
WSlaveSage.new().dev()
|
110
|
+
when 'build'
|
111
|
+
require_relative '../lib/wslave_sage'
|
112
|
+
WSlaveSage.new().build()
|
113
|
+
when 'production'
|
114
|
+
require_relative '../lib/wslave_sage'
|
115
|
+
WSlaveSage.new().production()
|
116
|
+
else
|
117
|
+
puts "sage command \"#{command}\" not found."
|
118
|
+
puts "sage commands available: create update dev build production"
|
119
|
+
end
|
120
|
+
end
|
67
121
|
end
|
68
122
|
|
69
123
|
WSlaveCLI.start(ARGV)
|
data/lib/wslave_docker.rb
CHANGED
@@ -6,23 +6,54 @@ class WSlaveDocker
|
|
6
6
|
puts 'Initializing WSlave Docker Control'
|
7
7
|
end
|
8
8
|
|
9
|
-
def server(force)
|
9
|
+
def server(command = :start, force = false, volume = false)
|
10
|
+
case (command)
|
11
|
+
when :start
|
12
|
+
start(force, volume)
|
13
|
+
when :stop
|
14
|
+
stop(force, volume)
|
15
|
+
when :log
|
16
|
+
log()
|
17
|
+
when :console
|
18
|
+
console()
|
19
|
+
else
|
20
|
+
puts "server subcommand \"#{command.to_s}\" not found."
|
21
|
+
puts "Available commands: start stop log console"
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def start(force = false, volume = false)
|
10
26
|
return unless _check()
|
11
27
|
_force_down() if force
|
28
|
+
`docker-compose down#{volume ? ' -v' : ''}` # Shutdown existing instances
|
12
29
|
_unfuck_dot_htaccess()
|
13
30
|
WSlaveTools.set_dev_perms
|
14
31
|
`docker-compose up -d`
|
15
32
|
end
|
16
33
|
|
17
|
-
def stop(force, volume)
|
34
|
+
def stop(force = false, volume = false)
|
18
35
|
return unless _check()
|
19
36
|
_force_down() if force
|
20
37
|
`docker-compose down#{volume ? ' -v' : ''}`
|
21
38
|
end
|
22
39
|
|
40
|
+
def log()
|
41
|
+
return unless _check()
|
42
|
+
begin
|
43
|
+
system("docker-compose logs -f")
|
44
|
+
rescue Exception => e
|
45
|
+
puts "\n\nEnding log trace. NOTE: Server containers are still running!\n\n"
|
46
|
+
return
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
def console()
|
51
|
+
return unless _check()
|
52
|
+
system("docker-compose exec web /bin/bash")
|
53
|
+
end
|
54
|
+
|
23
55
|
def _check()
|
24
56
|
return true if (File.exist?("./config/.wslave") &&
|
25
|
-
File.exist?("Dockerfile") &&
|
26
57
|
File.exist?("docker-compose.yml"))
|
27
58
|
puts "This does not appear to be the root of a WSlave managed app."
|
28
59
|
false
|
data/lib/wslave_new.rb
CHANGED
@@ -1,43 +1,82 @@
|
|
1
1
|
require 'fileutils'
|
2
2
|
require 'rubygems'
|
3
|
+
require 'pathname'
|
4
|
+
require 'git'
|
5
|
+
|
3
6
|
require_relative 'wslave_tools'
|
4
7
|
|
5
8
|
class WSlaveNew
|
6
|
-
def initialize(path, version)
|
9
|
+
def initialize(path, version = '', wspath = '')
|
7
10
|
puts '⚙ Initializing Toolchain・・・'
|
8
11
|
|
9
|
-
|
10
|
-
|
12
|
+
if (wspath != '')
|
13
|
+
manual_path = true
|
14
|
+
if ((Pathname.new(wspath)).absolute?)
|
15
|
+
base_path = File.expand_path "#{wspath}/base/"
|
16
|
+
template_path = File.expand_path "#{wspath}/templates/"
|
17
|
+
else
|
18
|
+
base_path = File.expand_path "#{path}/#{wspath}/base/"
|
19
|
+
template_path = File.expand_path "#{path}/#{wspath}/templates/"
|
20
|
+
end
|
21
|
+
else
|
22
|
+
manual_path = false
|
23
|
+
wspath = "#{__dir__}/.."
|
24
|
+
base_path = File.expand_path "#{wspath}/base/"
|
25
|
+
template_path = File.expand_path "#{wspath}/templates/"
|
26
|
+
end
|
11
27
|
|
12
28
|
FileUtils.mkdir_p path
|
13
29
|
|
14
30
|
Dir.chdir path
|
15
|
-
|
31
|
+
|
16
32
|
puts " > Setting up WordPress WSlave setup in: #{path}"
|
17
33
|
FileUtils.cp_r Dir.glob("#{base_path}/*"), path
|
18
34
|
FileUtils.cp_r Dir.glob("#{template_path}/*"), path
|
35
|
+
add_path_to_Gemspec(wspath, path) if manual_path
|
19
36
|
|
20
|
-
spec = Gem::Specification::load("#{
|
37
|
+
spec = Gem::Specification::load("#{wspath}/wslave.gemspec")
|
21
38
|
File.open("#{path}/config/.wslave", 'w') {|f| f.write(spec.version)}
|
22
39
|
|
23
40
|
`cd #{path} && git init && git add --all && git commit -am "initial commit by wslave"`
|
24
41
|
|
25
42
|
`cd #{path} && git submodule add git://github.com/WordPress/WordPress.git public/wordpress`
|
26
|
-
`cd #{path}/public/wordpress && git checkout #{version}-branch` if version != ''
|
27
43
|
`cd #{path} && git submodule update --init --recursive public/wordpress`
|
44
|
+
if (version == 'edge' || version == 'master')
|
45
|
+
`cd #{path}/public/wordpress && git checkout master`
|
46
|
+
elsif version != ''
|
47
|
+
`cd #{path}/public/wordpress && git checkout #{version}`
|
48
|
+
else
|
49
|
+
`cd #{path}/public/wordpress && git checkout #{get_stable_branch_version("#{path}/public/wordpress")}-branch`
|
50
|
+
end
|
28
51
|
|
29
52
|
puts " > Preparing detached content directory"
|
30
53
|
FileUtils.cp_r("#{path}/public/wordpress/wp-content", "#{path}/public/wp-content")
|
31
|
-
FileUtils.mkdir("#{path}/public/wp-content/uploads")
|
54
|
+
FileUtils.mkdir("#{path}/public/wp-content/uploads") unless Dir.exist?("#{path}/public/wp-content/uploads")
|
32
55
|
FileUtils.touch("#{path}/public/wp-content/uploads/.gitkeep")
|
33
|
-
FileUtils.mkdir("#{path}/public/wp-content/upgrade")
|
56
|
+
FileUtils.mkdir("#{path}/public/wp-content/upgrade") unless Dir.exist?("#{path}/public/wp-content/upgrade")
|
34
57
|
FileUtils.touch("#{path}/public/wp-content/upgrade/.gitkeep")
|
35
58
|
Dir.chdir path
|
36
59
|
|
37
60
|
puts " > Setting permissions"
|
38
61
|
WSlaveTools.set_dev_perms
|
39
|
-
|
62
|
+
|
40
63
|
`cd #{path} && git add --all && git commit -am "Add and initialize WordPress#{version}"`
|
41
64
|
puts " > Done!"
|
42
65
|
end
|
66
|
+
|
67
|
+
def add_path_to_Gemspec(wspath, path)
|
68
|
+
gemtext = File.read("#{path}/Gemfile")
|
69
|
+
gemtext.gsub!("gem 'wslave'", "gem 'wslave', path: '#{wspath}'")
|
70
|
+
File.open("#{path}/Gemfile", "w") {|gemfile| gemfile.puts gemtext}
|
71
|
+
end
|
72
|
+
|
73
|
+
def get_stable_branch_version(path)
|
74
|
+
latest = '5.4' # This is just a fallback (latest at time of update)
|
75
|
+
# TODO Implementation requires this issue be resolved: https://github.com/ruby-git/ruby-git/issues/424
|
76
|
+
#g = Git.open(path)
|
77
|
+
#g.brances.remote.each do |branch|
|
78
|
+
#end
|
79
|
+
|
80
|
+
latest
|
81
|
+
end
|
43
82
|
end
|
data/lib/wslave_sage.rb
CHANGED
@@ -1,9 +1,76 @@
|
|
1
|
+
require 'yaml'
|
2
|
+
|
1
3
|
class WSlaveSage
|
2
|
-
|
4
|
+
attr_reader :theme_name
|
5
|
+
|
6
|
+
def initialize()
|
7
|
+
@theme_name = ''
|
8
|
+
end
|
9
|
+
|
10
|
+
def create(name)
|
3
11
|
unless File.exist?("./config/.wslave")
|
4
12
|
puts "This command must be run in the root of a WSlave setup"
|
5
13
|
end
|
6
|
-
|
7
|
-
|
14
|
+
|
15
|
+
name = 'wslave-sage-theme' if name.empty?
|
16
|
+
project_root = Dir.pwd
|
17
|
+
|
18
|
+
puts "Creating Sage theme at public/wp-content/themes/#{name}"
|
19
|
+
`cd public/wp-content/themes && composer create-project roots/sage #{name} dev-master`
|
20
|
+
|
21
|
+
Dir.chdir project_root
|
22
|
+
_write_wslave_sage_config(name)
|
23
|
+
_overwrite_sage_webpack_browsersync_config
|
24
|
+
end
|
25
|
+
|
26
|
+
def update()
|
27
|
+
return unless _check()
|
28
|
+
system("cd public/wp-content/themes/#{@theme_name} && yarn && yarn build")
|
29
|
+
end
|
30
|
+
|
31
|
+
def dev()
|
32
|
+
return unless _check()
|
33
|
+
system("cd public/wp-content/themes/#{@theme_name} && yarn start")
|
34
|
+
end
|
35
|
+
|
36
|
+
def build()
|
37
|
+
return unless _check()
|
38
|
+
system("cd public/wp-content/themes/#{@theme_name} && yarn build")
|
39
|
+
end
|
40
|
+
|
41
|
+
def production()
|
42
|
+
return unless _check()
|
43
|
+
system("cd public/wp-content/themes/#{@theme_name} && yarn build:production")
|
44
|
+
end
|
45
|
+
|
46
|
+
def theme_name?()
|
47
|
+
return '' unless _check()
|
48
|
+
@theme_name
|
49
|
+
end
|
50
|
+
|
51
|
+
def _write_wslave_sage_config(name)
|
52
|
+
File.open("./config/sage.yml", 'w') {|f| YAML.dump({theme: name}, f)}
|
53
|
+
end
|
54
|
+
|
55
|
+
def _overwrite_sage_webpack_browsersync_config
|
56
|
+
return unless _check()
|
57
|
+
theme_info = YAML.load_file("./config/sage.yml")
|
58
|
+
Dir.chdir "#{Dir.pwd}/public/wp-content/themes/#{theme_info[:theme]}"
|
59
|
+
|
60
|
+
webpack_config_path = './webpack.mix.js'
|
61
|
+
new_webpack_config = File.read(webpack_config_path).gsub(
|
62
|
+
/browserSync\('sage.test'\)/, "browserSync('localhost:8000')"
|
63
|
+
)
|
64
|
+
File.open(webpack_config_path, 'w') { |f| f.puts new_webpack_config }
|
65
|
+
end
|
66
|
+
|
67
|
+
def _check()
|
68
|
+
if (File.exist?("./config/.wslave") && File.exist?("./config/sage.yml"))
|
69
|
+
theme_info = YAML.load_file("./config/sage.yml")
|
70
|
+
@theme_name = theme_info[:theme]
|
71
|
+
return true
|
72
|
+
end
|
73
|
+
puts "This does not appear to be the root of a WSlave managed app with a Sage theme."
|
74
|
+
false
|
8
75
|
end
|
9
76
|
end
|
data/lib/wslave_tools.rb
CHANGED
@@ -3,7 +3,6 @@ require 'fileutils'
|
|
3
3
|
class WSlaveTools
|
4
4
|
def self.wslave_root?()
|
5
5
|
return true if (File.exist?("./config/.wslave") &&
|
6
|
-
File.exist?("Dockerfile") &&
|
7
6
|
File.exist?("docker-compose.yml"))
|
8
7
|
puts "This does not appear to be the root of a WSlave managed app."
|
9
8
|
puts "Run command again from the root directory of a WSlave app."
|
data/lib/wslave_update.rb
CHANGED
@@ -9,7 +9,7 @@ class WSlaveUpdate
|
|
9
9
|
path = Dir.pwd
|
10
10
|
if !File.exist?("#{path}/config/.wslave")
|
11
11
|
puts "!!!This command must be run in a WSlave generated project!!!"
|
12
|
-
|
12
|
+
return
|
13
13
|
end
|
14
14
|
|
15
15
|
base_path = File.expand_path "#{__dir__}/../base/"
|
@@ -21,7 +21,7 @@ class WSlaveUpdate
|
|
21
21
|
FileUtils.cp("#{base_path}/Capfile", "#{path}/Capfile")
|
22
22
|
# FileUtils.cp("#{base_path}/Gemfile", "#{path}/Gemfile")
|
23
23
|
FileUtils.cp("#{base_path}/Rakefile", "#{path}/Rakefile")
|
24
|
-
FileUtils.
|
24
|
+
FileUtils.cp_r("#{base_path}/docker", "#{path}/")
|
25
25
|
FileUtils.cp("#{base_path}/docker-compose.yml", "#{path}/docker-compose.yml")
|
26
26
|
FileUtils.cp("#{base_path}/public/.htaccess", "#{path}/public/.htaccess")
|
27
27
|
FileUtils.cp_r(Dir.glob("#{base_path}/config/*"), "#{path}/config")
|
@@ -1,5 +1,7 @@
|
|
1
1
|
deployer:
|
2
|
-
user:
|
2
|
+
user:
|
3
|
+
# Uncomment this line if you are not on a shared host/if your web server runs under a different user than what you specified in the user field above
|
4
|
+
# www_data_group: www-data
|
3
5
|
host:
|
4
6
|
staging:
|
5
7
|
production:
|
@@ -7,6 +9,9 @@ deployer:
|
|
7
9
|
fqdn:
|
8
10
|
staging:
|
9
11
|
production:
|
12
|
+
branch:
|
13
|
+
staging: master
|
14
|
+
production: master
|
10
15
|
app:
|
11
16
|
name:
|
12
17
|
repo:
|
data/wslave.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = 'wslave'
|
3
|
-
s.version = '0.
|
3
|
+
s.version = '0.2.2'
|
4
4
|
s.licenses = ['GPL-3.0', 'AGPL-3.0']
|
5
5
|
s.summary = '"Word Slave" generates and controls a WordPress installation'
|
6
6
|
s.description = 'Word Slave includes the wslave command and a control library to generate a ' \
|
@@ -20,10 +20,13 @@ Gem::Specification.new do |s|
|
|
20
20
|
s.bindir = 'bin'
|
21
21
|
s.executables << 'wslave'
|
22
22
|
|
23
|
-
s.add_dependency 'capistrano', '= 3.
|
24
|
-
s.add_dependency 'capistrano-git-with-submodules', '~> 2.0'
|
25
|
-
s.add_dependency 'capistrano-scm-copy', '~> 0.7'
|
23
|
+
s.add_dependency 'capistrano', '= 3.14.1'
|
24
|
+
s.add_dependency 'capistrano-git-with-submodules', '~> 2.0', '2.0.4'
|
25
|
+
s.add_dependency 'capistrano-scm-copy', '~> 0.7', '0.7.0'
|
26
|
+
s.add_dependency 'capistrano-file-permissions', '~> 1.0', '1.0.0'
|
26
27
|
|
27
|
-
s.add_dependency '
|
28
|
-
|
28
|
+
s.add_dependency 'git', '~> 1.7', '1.7.0'
|
29
|
+
|
30
|
+
s.add_dependency 'thor', '~> 1.0', '1.0.1'
|
31
|
+
s.add_dependency 'haikunator', '~> 1.1', '1.1.0'
|
29
32
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wslave
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rei Kagetsuki
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-07-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: capistrano
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - '='
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 3.
|
19
|
+
version: 3.14.1
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - '='
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 3.
|
26
|
+
version: 3.14.1
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: capistrano-git-with-submodules
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -31,6 +31,9 @@ dependencies:
|
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '2.0'
|
34
|
+
- - '='
|
35
|
+
- !ruby/object:Gem::Version
|
36
|
+
version: 2.0.4
|
34
37
|
type: :runtime
|
35
38
|
prerelease: false
|
36
39
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -38,6 +41,9 @@ dependencies:
|
|
38
41
|
- - "~>"
|
39
42
|
- !ruby/object:Gem::Version
|
40
43
|
version: '2.0'
|
44
|
+
- - '='
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: 2.0.4
|
41
47
|
- !ruby/object:Gem::Dependency
|
42
48
|
name: capistrano-scm-copy
|
43
49
|
requirement: !ruby/object:Gem::Requirement
|
@@ -45,6 +51,9 @@ dependencies:
|
|
45
51
|
- - "~>"
|
46
52
|
- !ruby/object:Gem::Version
|
47
53
|
version: '0.7'
|
54
|
+
- - '='
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
version: 0.7.0
|
48
57
|
type: :runtime
|
49
58
|
prerelease: false
|
50
59
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -52,20 +61,69 @@ dependencies:
|
|
52
61
|
- - "~>"
|
53
62
|
- !ruby/object:Gem::Version
|
54
63
|
version: '0.7'
|
64
|
+
- - '='
|
65
|
+
- !ruby/object:Gem::Version
|
66
|
+
version: 0.7.0
|
67
|
+
- !ruby/object:Gem::Dependency
|
68
|
+
name: capistrano-file-permissions
|
69
|
+
requirement: !ruby/object:Gem::Requirement
|
70
|
+
requirements:
|
71
|
+
- - "~>"
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
version: '1.0'
|
74
|
+
- - '='
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: 1.0.0
|
77
|
+
type: :runtime
|
78
|
+
prerelease: false
|
79
|
+
version_requirements: !ruby/object:Gem::Requirement
|
80
|
+
requirements:
|
81
|
+
- - "~>"
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: '1.0'
|
84
|
+
- - '='
|
85
|
+
- !ruby/object:Gem::Version
|
86
|
+
version: 1.0.0
|
87
|
+
- !ruby/object:Gem::Dependency
|
88
|
+
name: git
|
89
|
+
requirement: !ruby/object:Gem::Requirement
|
90
|
+
requirements:
|
91
|
+
- - "~>"
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '1.7'
|
94
|
+
- - '='
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: 1.7.0
|
97
|
+
type: :runtime
|
98
|
+
prerelease: false
|
99
|
+
version_requirements: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '1.7'
|
104
|
+
- - '='
|
105
|
+
- !ruby/object:Gem::Version
|
106
|
+
version: 1.7.0
|
55
107
|
- !ruby/object:Gem::Dependency
|
56
108
|
name: thor
|
57
109
|
requirement: !ruby/object:Gem::Requirement
|
58
110
|
requirements:
|
59
111
|
- - "~>"
|
60
112
|
- !ruby/object:Gem::Version
|
61
|
-
version: '0
|
113
|
+
version: '1.0'
|
114
|
+
- - '='
|
115
|
+
- !ruby/object:Gem::Version
|
116
|
+
version: 1.0.1
|
62
117
|
type: :runtime
|
63
118
|
prerelease: false
|
64
119
|
version_requirements: !ruby/object:Gem::Requirement
|
65
120
|
requirements:
|
66
121
|
- - "~>"
|
67
122
|
- !ruby/object:Gem::Version
|
68
|
-
version: '0
|
123
|
+
version: '1.0'
|
124
|
+
- - '='
|
125
|
+
- !ruby/object:Gem::Version
|
126
|
+
version: 1.0.1
|
69
127
|
- !ruby/object:Gem::Dependency
|
70
128
|
name: haikunator
|
71
129
|
requirement: !ruby/object:Gem::Requirement
|
@@ -73,6 +131,9 @@ dependencies:
|
|
73
131
|
- - "~>"
|
74
132
|
- !ruby/object:Gem::Version
|
75
133
|
version: '1.1'
|
134
|
+
- - '='
|
135
|
+
- !ruby/object:Gem::Version
|
136
|
+
version: 1.1.0
|
76
137
|
type: :runtime
|
77
138
|
prerelease: false
|
78
139
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -80,6 +141,9 @@ dependencies:
|
|
80
141
|
- - "~>"
|
81
142
|
- !ruby/object:Gem::Version
|
82
143
|
version: '1.1'
|
144
|
+
- - '='
|
145
|
+
- !ruby/object:Gem::Version
|
146
|
+
version: 1.1.0
|
83
147
|
description: Word Slave includes the wslave command and a control library to generate
|
84
148
|
a "best practice" WordPress installation and includes a pre-rolled Docker setup
|
85
149
|
for running a development server and a Capistrano setup for deployment.
|
@@ -89,19 +153,26 @@ executables:
|
|
89
153
|
extensions: []
|
90
154
|
extra_rdoc_files: []
|
91
155
|
files:
|
156
|
+
- base/.gitignore
|
92
157
|
- base/Capfile
|
93
|
-
- base/Dockerfile
|
94
158
|
- base/Gemfile
|
95
159
|
- base/Rakefile
|
160
|
+
- base/config/deploy-tools/gen-nginx-vhost.rb
|
96
161
|
- base/config/deploy-tools/gen-salts.rb
|
97
162
|
- base/config/deploy-tools/gen-wp-config.rb
|
163
|
+
- base/config/deploy-tools/nginx.vhost.erb
|
98
164
|
- base/config/deploy-tools/wp-config.php.erb
|
99
165
|
- base/config/deploy-tools/wp-config.php.local
|
100
166
|
- base/config/deploy.rb
|
101
167
|
- base/config/deploy/.production.rb.swp
|
168
|
+
- base/config/deploy/.staging.rb.swp
|
102
169
|
- base/config/deploy/production.rb
|
103
170
|
- base/config/deploy/staging.rb
|
104
171
|
- base/docker-compose.yml
|
172
|
+
- base/docker/apache/Dockerfile
|
173
|
+
- base/docker/nginx/Dockerfile
|
174
|
+
- base/docker/nginx/nginx.vhost
|
175
|
+
- base/docker/nginx/supervisord.conf
|
105
176
|
- base/public/.htaccess
|
106
177
|
- base/public/wp-config.php
|
107
178
|
- bin/wslave
|
@@ -133,8 +204,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
133
204
|
- !ruby/object:Gem::Version
|
134
205
|
version: '0'
|
135
206
|
requirements: []
|
136
|
-
|
137
|
-
rubygems_version: 2.7.3
|
207
|
+
rubygems_version: 3.1.2
|
138
208
|
signing_key:
|
139
209
|
specification_version: 4
|
140
210
|
summary: '"Word Slave" generates and controls a WordPress installation'
|