wslave 0.1.0 → 0.2.0
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 +1 -0
- data/base/config/deploy-tools/nginx.vhost.erb +40 -24
- data/base/config/deploy.rb +1 -1
- data/base/config/deploy/production.rb +45 -0
- data/base/config/deploy/staging.rb +45 -1
- data/base/docker-compose.yml +1 -1
- data/base/docker/nginx/Dockerfile +1 -3
- data/base/docker/nginx/nginx.vhost +16 -0
- data/base/public/.htaccess +11 -0
- data/bin/wslave +64 -17
- data/lib/wslave_docker.rb +34 -2
- data/lib/wslave_new.rb +3 -3
- data/lib/wslave_sage.rb +70 -3
- data/lib/wslave_update.rb +1 -1
- data/templates/config/definitions.yml +3 -0
- data/wslave.gemspec +5 -5
- metadata +37 -37
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f166ebdd86359e239e14471ae7eabe907ac34adae44529e1e420f437feee2a32
|
4
|
+
data.tar.gz: 42e606369d33accbaf8fa6a00428547b45c340d437bfb543af674dbe9e05f2bc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7ed2dad207e47644c602cf9017c465166dd504bd054d1f0f4be37f8c455fd1177a4e455ea981f8d49c1ca6fa251b8388f2ab1f1866be1d37a2ba4c432d730d3d
|
7
|
+
data.tar.gz: 6d2333831378f71024e36f56fc960260369427c42f7b93404ff4901d8f8878310f8884815155ab9aac7e43aa41d8b33a4db7db2497e55347516c9840d6c6b31b
|
data/base/.gitignore
CHANGED
@@ -1,35 +1,51 @@
|
|
1
1
|
server {
|
2
|
-
|
3
|
-
|
2
|
+
listen 80;
|
3
|
+
listen [::]:80;
|
4
4
|
|
5
|
-
|
5
|
+
server_name <%= server[:name] %>;
|
6
6
|
|
7
|
-
|
7
|
+
root <%= server[:root] %>;
|
8
8
|
|
9
|
-
|
10
|
-
|
9
|
+
access_log <%= server[:root] %>/access.log;
|
10
|
+
error_log <%= server[:root] %>/error.log;
|
11
11
|
|
12
|
-
|
12
|
+
index index.php;
|
13
13
|
|
14
|
-
|
15
|
-
|
14
|
+
location / {
|
15
|
+
rewrite ^/(wp-(admin|includes).*) /wordpress/$1 last;
|
16
16
|
|
17
|
-
|
17
|
+
rewrite ^/$ /wordpress/index.php last;
|
18
18
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
}
|
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] %>;
|
28
27
|
}
|
28
|
+
}
|
29
29
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
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
|
+
}
|
35
51
|
}
|
data/base/config/deploy.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
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')
|
@@ -13,6 +14,8 @@ site_fqdn = opts['deployer']['fqdn']['production']
|
|
13
14
|
disable_rsync = (opts.include?('options') && opts['options'].include?('rsync_enabled') &&
|
14
15
|
opts['options']['rsync_enabled'] == false)
|
15
16
|
|
17
|
+
set :branch, fetch(opts['deployer']['branch']['production'], 'master')
|
18
|
+
|
16
19
|
role :web, "#{deploy_user}@#{host_addr}"
|
17
20
|
|
18
21
|
set :tmp_dir, "#{multisite_root}/tmp"
|
@@ -77,6 +80,47 @@ namespace :deploy do
|
|
77
80
|
end
|
78
81
|
end
|
79
82
|
|
83
|
+
desc 'Builds and Syncs the project Sage theme'
|
84
|
+
task :sync_sage_theme do
|
85
|
+
on roles(:web) do
|
86
|
+
wss = WSlaveSage.new()
|
87
|
+
sage_theme_name = wss.theme_name?
|
88
|
+
if (sage_theme_name == '')
|
89
|
+
puts "Couldn't find a Sage theme for this project."
|
90
|
+
else
|
91
|
+
wss.production()
|
92
|
+
`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`
|
93
|
+
`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`
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
desc 'Builds and Uploads the project Sage theme'
|
99
|
+
task :upload_sage_theme do
|
100
|
+
on roles(:web) do
|
101
|
+
wss = WSlaveSage.new()
|
102
|
+
sage_theme_name = wss.theme_name?
|
103
|
+
if (sage_theme_name == '')
|
104
|
+
puts "Couldn't find a Sage theme for this project."
|
105
|
+
else
|
106
|
+
wss.production()
|
107
|
+
upload! "./public/wp-content/themes/#{sage_theme_name}/vendor", "#{deploy_path}/current/public/wp-content/themes/#{sage_theme_name}/", recursive: true
|
108
|
+
upload! "./public/wp-content/themes/#{sage_theme_name}/dist", "#{deploy_path}/current/public/wp-content/themes/#{sage_theme_name}/", recursive: true
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
desc 'Builds and Deploys the project Sage theme'
|
114
|
+
task :sage do
|
115
|
+
on roles(:web) do
|
116
|
+
if disable_rsync
|
117
|
+
invoke('deploy:upload_sage_theme')
|
118
|
+
else
|
119
|
+
invoke('deploy:sync_sage_theme')
|
120
|
+
end
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
80
124
|
desc 'Finds and replaces localhost:8000 and your Staging address with the Production address'
|
81
125
|
task :chikan do
|
82
126
|
on roles(:web) do
|
@@ -154,6 +198,7 @@ namespace :deploy do
|
|
154
198
|
invoke('deploy:sync_uploads')
|
155
199
|
end
|
156
200
|
invoke('deploy')
|
201
|
+
invoke('sage')
|
157
202
|
invoke('db:seed')
|
158
203
|
invoke('deploy:chikan')
|
159
204
|
invoke('deploy:set_permissions')
|
@@ -1,5 +1,6 @@
|
|
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')
|
@@ -13,6 +14,8 @@ site_fqdn = opts['deployer']['fqdn']['staging']
|
|
13
14
|
disable_rsync = (opts.include?('options') && opts['options'].include?('rsync_enabled') &&
|
14
15
|
opts['options']['rsync_enabled'] == false)
|
15
16
|
|
17
|
+
set :branch, fetch(opts['deployer']['branch']['staging'], 'master')
|
18
|
+
|
16
19
|
role :web, "#{deploy_user}@#{host_addr}"
|
17
20
|
|
18
21
|
set :tmp_dir, "#{multisite_root}/tmp"
|
@@ -23,7 +26,6 @@ set :linked_files, %w{public/wp-config.php}
|
|
23
26
|
|
24
27
|
set :deploy_to, deploy_path
|
25
28
|
|
26
|
-
|
27
29
|
namespace :deploy do
|
28
30
|
desc "Generate wp-config.php for profile"
|
29
31
|
task :wp_config do
|
@@ -77,6 +79,47 @@ namespace :deploy do
|
|
77
79
|
end
|
78
80
|
end
|
79
81
|
|
82
|
+
desc 'Builds and Syncs the project Sage theme'
|
83
|
+
task :sync_sage_theme do
|
84
|
+
on roles(:web) do
|
85
|
+
wss = WSlaveSage.new()
|
86
|
+
sage_theme_name = wss.theme_name?
|
87
|
+
if (sage_theme_name == '')
|
88
|
+
puts "Couldn't find a Sage theme for this project."
|
89
|
+
else
|
90
|
+
wss.production()
|
91
|
+
`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`
|
92
|
+
`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`
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
desc 'Builds and Uploads the project Sage theme'
|
98
|
+
task :upload_sage_theme do
|
99
|
+
on roles(:web) do
|
100
|
+
wss = WSlaveSage.new()
|
101
|
+
sage_theme_name = wss.theme_name?
|
102
|
+
if (sage_theme_name == '')
|
103
|
+
puts "Couldn't find a Sage theme for this project."
|
104
|
+
else
|
105
|
+
wss.production()
|
106
|
+
upload! "./public/wp-content/themes/#{sage_theme_name}/vendor", "#{deploy_path}/current/public/wp-content/themes/#{sage_theme_name}/", recursive: true
|
107
|
+
upload! "./public/wp-content/themes/#{sage_theme_name}/dist", "#{deploy_path}/current/public/wp-content/themes/#{sage_theme_name}/", recursive: true
|
108
|
+
end
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
desc 'Builds and Deploys the project Sage theme'
|
113
|
+
task :sage do
|
114
|
+
on roles(:web) do
|
115
|
+
if disable_rsync
|
116
|
+
invoke('deploy:upload_sage_theme')
|
117
|
+
else
|
118
|
+
invoke('deploy:sync_sage_theme')
|
119
|
+
end
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
80
123
|
desc 'Finds and replaces localhost:8000 and your Production address with the Staging address'
|
81
124
|
task :chikan do
|
82
125
|
on roles(:web) do
|
@@ -154,6 +197,7 @@ namespace :deploy do
|
|
154
197
|
invoke('deploy:sync_uploads')
|
155
198
|
end
|
156
199
|
invoke('deploy')
|
200
|
+
invoke('sage')
|
157
201
|
invoke('db:seed')
|
158
202
|
invoke('deploy:chikan')
|
159
203
|
invoke('deploy:set_permissions')
|
data/base/docker-compose.yml
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
FROM ubuntu:
|
1
|
+
FROM ubuntu:20.04
|
2
2
|
|
3
3
|
COPY nginx.vhost /etc/nginx/sites-enabled/default
|
4
4
|
COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf
|
@@ -14,8 +14,6 @@ RUN adduser www-data root
|
|
14
14
|
RUN mkdir /db \
|
15
15
|
&& chmod 777 /db
|
16
16
|
|
17
|
-
RUN mkdir /run/php
|
18
|
-
|
19
17
|
RUN ln -sf /dev/stdout /var/log/nginx/access.log \
|
20
18
|
&& ln -sf /dev/stderr /var/log/nginx/error.log
|
21
19
|
|
@@ -29,4 +29,20 @@ server {
|
|
29
29
|
access_log off;
|
30
30
|
log_not_found off;
|
31
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
|
+
}
|
32
48
|
}
|
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
@@ -27,35 +27,55 @@ class WSlaveCLI < Thor
|
|
27
27
|
WSlaveUpdate.new()
|
28
28
|
end
|
29
29
|
|
30
|
-
desc '
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
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'])
|
42
61
|
end
|
43
62
|
|
44
|
-
desc '
|
63
|
+
desc 'start [options]', "Starts the development server (short for 'server start')"
|
64
|
+
method_option :v, type: :boolean, default: false, description: 'remove volume data'
|
45
65
|
method_option :f, type: :boolean, default: false, description: 'force close other servers first'
|
46
|
-
def
|
66
|
+
def start()
|
47
67
|
puts 'Starting server...'
|
48
68
|
require_relative '../lib/wslave_docker'
|
49
|
-
WSlaveDocker.new().server(options['f'])
|
69
|
+
WSlaveDocker.new().server(:start, options['f'], options['v'])
|
50
70
|
end
|
51
71
|
|
52
|
-
desc 'stop [options]', "Stops the development server"
|
72
|
+
desc 'stop [options]', "Stops the development server (short for 'server stop')"
|
53
73
|
method_option :v, type: :boolean, default: false, description: 'remove volume data'
|
54
74
|
method_option :f, type: :boolean, default: false, description: 'force close other servers first'
|
55
75
|
def stop()
|
56
76
|
puts 'Stopping server...'
|
57
77
|
require_relative '../lib/wslave_docker'
|
58
|
-
WSlaveDocker.new().stop
|
78
|
+
WSlaveDocker.new().server(:stop, options['f'], options['v'])
|
59
79
|
end
|
60
80
|
|
61
81
|
desc 'sync', "Synchronizes submodules and file permissions"
|
@@ -71,6 +91,33 @@ class WSlaveCLI < Thor
|
|
71
91
|
spec = Gem::Specification::load("#{__dir__}/../wslave.gemspec")
|
72
92
|
puts spec.version
|
73
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
|
74
121
|
end
|
75
122
|
|
76
123
|
WSlaveCLI.start(ARGV)
|
data/lib/wslave_docker.rb
CHANGED
@@ -6,20 +6,52 @@ 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
57
|
File.exist?("docker-compose.yml"))
|
data/lib/wslave_new.rb
CHANGED
@@ -40,14 +40,14 @@ class WSlaveNew
|
|
40
40
|
`cd #{path} && git init && git add --all && git commit -am "initial commit by wslave"`
|
41
41
|
|
42
42
|
`cd #{path} && git submodule add git://github.com/WordPress/WordPress.git public/wordpress`
|
43
|
+
`cd #{path} && git submodule update --init --recursive public/wordpress`
|
43
44
|
if (version == 'edge' || version == 'master')
|
44
45
|
`cd #{path}/public/wordpress && git checkout master`
|
45
46
|
elsif version != ''
|
46
|
-
`cd #{path}/public/wordpress && git checkout #{version}
|
47
|
+
`cd #{path}/public/wordpress && git checkout #{version}`
|
47
48
|
else
|
48
49
|
`cd #{path}/public/wordpress && git checkout #{get_stable_branch_version("#{path}/public/wordpress")}-branch`
|
49
50
|
end
|
50
|
-
`cd #{path} && git submodule update --init --recursive public/wordpress`
|
51
51
|
|
52
52
|
puts " > Preparing detached content directory"
|
53
53
|
FileUtils.cp_r("#{path}/public/wordpress/wp-content", "#{path}/public/wp-content")
|
@@ -71,7 +71,7 @@ class WSlaveNew
|
|
71
71
|
end
|
72
72
|
|
73
73
|
def get_stable_branch_version(path)
|
74
|
-
latest = '5.
|
74
|
+
latest = '5.4' # This is just a fallback (latest at time of update)
|
75
75
|
# TODO Implementation requires this issue be resolved: https://github.com/ruby-git/ruby-git/issues/424
|
76
76
|
#g = Git.open(path)
|
77
77
|
#g.brances.remote.each do |branch|
|
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_update.rb
CHANGED
@@ -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.cp_r("#{base_path}/docker", "#{path}/
|
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")
|
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.0'
|
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,13 +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', '2.0.
|
23
|
+
s.add_dependency 'capistrano', '= 3.14.1'
|
24
|
+
s.add_dependency 'capistrano-git-with-submodules', '~> 2.0', '2.0.4'
|
25
25
|
s.add_dependency 'capistrano-scm-copy', '~> 0.7', '0.7.0'
|
26
26
|
s.add_dependency 'capistrano-file-permissions', '~> 1.0', '1.0.0'
|
27
27
|
|
28
|
-
s.add_dependency 'git', '~> 1.
|
28
|
+
s.add_dependency 'git', '~> 1.7', '1.7.0'
|
29
29
|
|
30
|
-
s.add_dependency 'thor', '~> 0
|
30
|
+
s.add_dependency 'thor', '~> 1.0', '1.0.1'
|
31
31
|
s.add_dependency 'haikunator', '~> 1.1', '1.1.0'
|
32
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.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rei Kagetsuki
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-07-09 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
|
@@ -33,7 +33,7 @@ dependencies:
|
|
33
33
|
version: '2.0'
|
34
34
|
- - '='
|
35
35
|
- !ruby/object:Gem::Version
|
36
|
-
version: 2.0.
|
36
|
+
version: 2.0.4
|
37
37
|
type: :runtime
|
38
38
|
prerelease: false
|
39
39
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -43,107 +43,107 @@ dependencies:
|
|
43
43
|
version: '2.0'
|
44
44
|
- - '='
|
45
45
|
- !ruby/object:Gem::Version
|
46
|
-
version: 2.0.
|
46
|
+
version: 2.0.4
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: capistrano-scm-copy
|
49
49
|
requirement: !ruby/object:Gem::Requirement
|
50
50
|
requirements:
|
51
|
-
- - '='
|
52
|
-
- !ruby/object:Gem::Version
|
53
|
-
version: 0.7.0
|
54
51
|
- - "~>"
|
55
52
|
- !ruby/object:Gem::Version
|
56
53
|
version: '0.7'
|
54
|
+
- - '='
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
version: 0.7.0
|
57
57
|
type: :runtime
|
58
58
|
prerelease: false
|
59
59
|
version_requirements: !ruby/object:Gem::Requirement
|
60
60
|
requirements:
|
61
|
-
- - '='
|
62
|
-
- !ruby/object:Gem::Version
|
63
|
-
version: 0.7.0
|
64
61
|
- - "~>"
|
65
62
|
- !ruby/object:Gem::Version
|
66
63
|
version: '0.7'
|
64
|
+
- - '='
|
65
|
+
- !ruby/object:Gem::Version
|
66
|
+
version: 0.7.0
|
67
67
|
- !ruby/object:Gem::Dependency
|
68
68
|
name: capistrano-file-permissions
|
69
69
|
requirement: !ruby/object:Gem::Requirement
|
70
70
|
requirements:
|
71
|
-
- - '='
|
72
|
-
- !ruby/object:Gem::Version
|
73
|
-
version: 1.0.0
|
74
71
|
- - "~>"
|
75
72
|
- !ruby/object:Gem::Version
|
76
73
|
version: '1.0'
|
74
|
+
- - '='
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: 1.0.0
|
77
77
|
type: :runtime
|
78
78
|
prerelease: false
|
79
79
|
version_requirements: !ruby/object:Gem::Requirement
|
80
80
|
requirements:
|
81
|
-
- - '='
|
82
|
-
- !ruby/object:Gem::Version
|
83
|
-
version: 1.0.0
|
84
81
|
- - "~>"
|
85
82
|
- !ruby/object:Gem::Version
|
86
83
|
version: '1.0'
|
84
|
+
- - '='
|
85
|
+
- !ruby/object:Gem::Version
|
86
|
+
version: 1.0.0
|
87
87
|
- !ruby/object:Gem::Dependency
|
88
88
|
name: git
|
89
89
|
requirement: !ruby/object:Gem::Requirement
|
90
90
|
requirements:
|
91
|
-
- - '='
|
92
|
-
- !ruby/object:Gem::Version
|
93
|
-
version: 1.5.0
|
94
91
|
- - "~>"
|
95
92
|
- !ruby/object:Gem::Version
|
96
|
-
version: '1.
|
93
|
+
version: '1.7'
|
94
|
+
- - '='
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: 1.7.0
|
97
97
|
type: :runtime
|
98
98
|
prerelease: false
|
99
99
|
version_requirements: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
|
-
- - '='
|
102
|
-
- !ruby/object:Gem::Version
|
103
|
-
version: 1.5.0
|
104
101
|
- - "~>"
|
105
102
|
- !ruby/object:Gem::Version
|
106
|
-
version: '1.
|
103
|
+
version: '1.7'
|
104
|
+
- - '='
|
105
|
+
- !ruby/object:Gem::Version
|
106
|
+
version: 1.7.0
|
107
107
|
- !ruby/object:Gem::Dependency
|
108
108
|
name: thor
|
109
109
|
requirement: !ruby/object:Gem::Requirement
|
110
110
|
requirements:
|
111
111
|
- - "~>"
|
112
112
|
- !ruby/object:Gem::Version
|
113
|
-
version: '0
|
113
|
+
version: '1.0'
|
114
114
|
- - '='
|
115
115
|
- !ruby/object:Gem::Version
|
116
|
-
version: 0.
|
116
|
+
version: 1.0.1
|
117
117
|
type: :runtime
|
118
118
|
prerelease: false
|
119
119
|
version_requirements: !ruby/object:Gem::Requirement
|
120
120
|
requirements:
|
121
121
|
- - "~>"
|
122
122
|
- !ruby/object:Gem::Version
|
123
|
-
version: '0
|
123
|
+
version: '1.0'
|
124
124
|
- - '='
|
125
125
|
- !ruby/object:Gem::Version
|
126
|
-
version: 0.
|
126
|
+
version: 1.0.1
|
127
127
|
- !ruby/object:Gem::Dependency
|
128
128
|
name: haikunator
|
129
129
|
requirement: !ruby/object:Gem::Requirement
|
130
130
|
requirements:
|
131
|
-
- - '='
|
132
|
-
- !ruby/object:Gem::Version
|
133
|
-
version: 1.1.0
|
134
131
|
- - "~>"
|
135
132
|
- !ruby/object:Gem::Version
|
136
133
|
version: '1.1'
|
134
|
+
- - '='
|
135
|
+
- !ruby/object:Gem::Version
|
136
|
+
version: 1.1.0
|
137
137
|
type: :runtime
|
138
138
|
prerelease: false
|
139
139
|
version_requirements: !ruby/object:Gem::Requirement
|
140
140
|
requirements:
|
141
|
-
- - '='
|
142
|
-
- !ruby/object:Gem::Version
|
143
|
-
version: 1.1.0
|
144
141
|
- - "~>"
|
145
142
|
- !ruby/object:Gem::Version
|
146
143
|
version: '1.1'
|
144
|
+
- - '='
|
145
|
+
- !ruby/object:Gem::Version
|
146
|
+
version: 1.1.0
|
147
147
|
description: Word Slave includes the wslave command and a control library to generate
|
148
148
|
a "best practice" WordPress installation and includes a pre-rolled Docker setup
|
149
149
|
for running a development server and a Capistrano setup for deployment.
|
@@ -202,7 +202,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
202
202
|
- !ruby/object:Gem::Version
|
203
203
|
version: '0'
|
204
204
|
requirements: []
|
205
|
-
rubygems_version: 3.
|
205
|
+
rubygems_version: 3.1.2
|
206
206
|
signing_key:
|
207
207
|
specification_version: 4
|
208
208
|
summary: '"Word Slave" generates and controls a WordPress installation'
|