wslave 0.1.0 → 0.3.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d5f66ec5135ab82042cc857c9f6f5b47e0ea95d5f52a995d43eed1c2d7319d86
4
- data.tar.gz: 981881f07224bc43bf887f58a7561cc970dd6cad9dc8915206844bff08a4322b
3
+ metadata.gz: d7c39b73b05b1be955f9f28b0925120e1b11aa37bce3ef2ffcc5b272aef0ecf5
4
+ data.tar.gz: 75ab79a0688af02c2ae453e170a387e6677ebf4ca275a5ae1a45a4e2166f56e2
5
5
  SHA512:
6
- metadata.gz: d922fd571f7c599417333a3d462c30049e1448fdea965e0f8891f2a256d9179c9c5b670ac5f7f0710bcff5c921665a9e73f7fbf752543489944c21214bbecf3d
7
- data.tar.gz: b6937ce57fa47c62393d771f02da7367a7f8c52329478f099d40306812fd614bb8f3feee114daf3e4d97b42f27a39bcce31d450e9168e8a29cb9fe66580a16d5
6
+ metadata.gz: 8fa738f7f91f460a8e9a84a5fcc0d38b5251b6d95c6a2443ce7bde8454fcd47169dd720001a9a2caf0f9f322c616b508579770227b4c7a0a1f788a47ead14f7b
7
+ data.tar.gz: e8a2df80d986c1f24993a576d9e116f5f91c379fa037d028d427f870983d89d7e0a809d750e3f35cfae0fa5adbaba3cffc0023b8ee43392b9256620ee046432e
data/base/.gitignore CHANGED
@@ -2,3 +2,4 @@ log
2
2
  .swp
3
3
  .swo
4
4
  db/tmp/*
5
+ .vscode
data/base/Rakefile CHANGED
@@ -3,6 +3,11 @@ require 'yaml'
3
3
 
4
4
  @opts = YAML.load_file('config/definitions.yml')
5
5
 
6
+ desc "Print simple instructions."
7
+ task :default do
8
+ puts 'Please call rake with a taks name, such as "db:dev", or list tasks with "rake -T".'
9
+ end
10
+
6
11
  def rm_dbfile(profile)
7
12
  puts "Deleting db/#{profile}/wordpress.sql"
8
13
  FileUtils.rm("db/#{profile}/wordpress.sql") if File.exist?("db/#{profile}/wordpress.sql")
@@ -1,35 +1,51 @@
1
1
  server {
2
- listen 80;
3
- listen [::]:80;
2
+ listen 80;
3
+ listen [::]:80;
4
4
 
5
- server_name <%= server[:name] %>;
5
+ server_name <%= server[:name] %>;
6
6
 
7
- root <%= server[:root] %>;
7
+ root <%= server[:root] %>;
8
8
 
9
- access_log <%= server[:root] %>/access.log;
10
- error_log <%= server[:root] %>/error.log;
9
+ access_log <%= server[:root] %>/access.log;
10
+ error_log <%= server[:root] %>/error.log;
11
11
 
12
- index index.php;
12
+ index index.php;
13
13
 
14
- location / {
15
- rewrite ^/(wp-(admin|includes).*) /wordpress/$1 last;
14
+ location / {
15
+ rewrite ^/(wp-(admin|includes).*) /wordpress/$1 last;
16
16
 
17
- rewrite ^/$ /wordpress/index.php last;
17
+ rewrite ^/$ /wordpress/index.php last;
18
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
- }
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
- location ~ /\. {
31
- deny all;
32
- access_log off;
33
- log_not_found off;
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
  }
@@ -1,5 +1,5 @@
1
1
  # config valid only for current version of Capistrano
2
- lock "3.11.2"
2
+ lock "3.16.0"
3
3
 
4
4
  require 'yaml'
5
5
  opts = YAML.load_file('config/definitions.yml')
Binary file
@@ -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,12 +14,16 @@ 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
+ if (opts['deployer'].include?('branch') && opts['deployer']['branch'].include?('production'))
18
+ set :branch, opts['deployer']['branch']['production']
19
+ end
20
+
16
21
  role :web, "#{deploy_user}@#{host_addr}"
17
22
 
18
23
  set :tmp_dir, "#{multisite_root}/tmp"
19
24
  deploy_path = "#{multisite_root}/#{site_fqdn}"
20
25
 
21
- set :linked_dirs, %w{public/wp-content/uploads public/wordpress public/wp-content/upgrade public/wp-content/plugins tmp}
26
+ set :linked_dirs, %w{public/wp-content/uploads public/wordpress public/wp-content/upgrade public/wp-content/plugins public/data tmp}
22
27
  set :linked_files, %w{public/wp-config.php}
23
28
 
24
29
  set :deploy_to, deploy_path
@@ -77,6 +82,61 @@ namespace :deploy do
77
82
  end
78
83
  end
79
84
 
85
+ desc 'Syncs the static data directory with rsync'
86
+ task :sync_static_data do
87
+ on roles(:web) do
88
+ `rsync -avzPhu --delete ./public/data/ #{deploy_user}@#{host_addr}:#{deploy_path}/shared/public/data/`
89
+ end
90
+ end
91
+
92
+ desc 'Uploads the static data directory'
93
+ task :upload_static_data do
94
+ on roles(:web) do
95
+ upload! './public/data', "#{deploy_path}/shared/public/data/", recursive: true
96
+ end
97
+ end
98
+
99
+ desc 'Builds and Syncs the project Sage theme'
100
+ task :sync_sage_theme do
101
+ on roles(:web) do
102
+ wss = WSlaveSage.new()
103
+ sage_theme_name = wss.theme_name?
104
+ if (sage_theme_name == '')
105
+ puts "Couldn't find a Sage theme for this project."
106
+ else
107
+ wss.production()
108
+ `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/`
109
+ `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/`
110
+ end
111
+ end
112
+ end
113
+
114
+ desc 'Builds and Uploads the project Sage theme'
115
+ task :upload_sage_theme do
116
+ on roles(:web) do
117
+ wss = WSlaveSage.new()
118
+ sage_theme_name = wss.theme_name?
119
+ if (sage_theme_name == '')
120
+ puts "Couldn't find a Sage theme for this project."
121
+ else
122
+ wss.production()
123
+ upload! "./public/wp-content/themes/#{sage_theme_name}/vendor/", "#{deploy_path}/current/public/wp-content/themes/#{sage_theme_name}/", recursive: true
124
+ upload! "./public/wp-content/themes/#{sage_theme_name}/dist/", "#{deploy_path}/current/public/wp-content/themes/#{sage_theme_name}/", recursive: true
125
+ end
126
+ end
127
+ end
128
+
129
+ desc 'Builds and Deploys the project Sage theme'
130
+ task :sage do
131
+ on roles(:web) do
132
+ if disable_rsync
133
+ invoke('deploy:upload_sage_theme')
134
+ else
135
+ invoke('deploy:sync_sage_theme')
136
+ end
137
+ end
138
+ end
139
+
80
140
  desc 'Finds and replaces localhost:8000 and your Staging address with the Production address'
81
141
  task :chikan do
82
142
  on roles(:web) do
@@ -148,14 +208,17 @@ namespace :deploy do
148
208
  invoke('deploy:upload_wp')
149
209
  invoke('deploy:upload_plugins')
150
210
  invoke('deploy:upload_uploads')
211
+ invoke('deploy:upload_static_data')
151
212
  else
152
213
  invoke('deploy:sync_wp')
153
214
  invoke('deploy:sync_plugins')
154
215
  invoke('deploy:sync_uploads')
216
+ invoke('deploy:sync_static_data')
155
217
  end
156
218
  invoke('deploy')
157
219
  invoke('db:seed')
158
220
  invoke('deploy:chikan')
221
+ invoke('deploy:sage')
159
222
  invoke('deploy:set_permissions')
160
223
  end
161
224
  end
@@ -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,21 +14,25 @@ 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
+ if (opts['deployer'].include?('branch') && opts['deployer']['branch'].include?('staging'))
18
+ set :branch, opts['deployer']['branch']['staging']
19
+ end
20
+
16
21
  role :web, "#{deploy_user}@#{host_addr}"
17
22
 
18
23
  set :tmp_dir, "#{multisite_root}/tmp"
19
24
  deploy_path = "#{multisite_root}/#{site_fqdn}"
20
25
 
21
- set :linked_dirs, %w{public/wp-content/uploads public/wordpress public/wp-content/upgrade public/wp-content/plugins tmp}
26
+ set :linked_dirs, %w{public/wp-content/uploads public/wordpress public/wp-content/upgrade public/wp-content/plugins public/data tmp}
22
27
  set :linked_files, %w{public/wp-config.php}
23
28
 
24
29
  set :deploy_to, deploy_path
25
30
 
26
-
27
31
  namespace :deploy do
28
32
  desc "Generate wp-config.php for profile"
29
33
  task :wp_config do
30
34
  on roles(:web) do
35
+ invoke 'deploy:check:make_linked_dirs'
31
36
  require_relative '../deploy-tools/gen-wp-config'
32
37
  FileUtils.mkdir('./tmp') unless Dir.exist?('./tmp')
33
38
  GenerateWPConfig('staging', './tmp')
@@ -77,6 +82,61 @@ namespace :deploy do
77
82
  end
78
83
  end
79
84
 
85
+ desc 'Syncs the static data directory with rsync'
86
+ task :sync_static_data do
87
+ on roles(:web) do
88
+ `rsync -avzPhu --delete ./public/data/ #{deploy_user}@#{host_addr}:#{deploy_path}/shared/public/data/`
89
+ end
90
+ end
91
+
92
+ desc 'Uploads the static data directory'
93
+ task :upload_static_data do
94
+ on roles(:web) do
95
+ upload! './public/data', "#{deploy_path}/shared/public/data/", recursive: true
96
+ end
97
+ end
98
+
99
+ desc 'Builds and Syncs the project Sage theme'
100
+ task :sync_sage_theme do
101
+ on roles(:web) do
102
+ wss = WSlaveSage.new()
103
+ sage_theme_name = wss.theme_name?
104
+ if (sage_theme_name == '')
105
+ puts "Couldn't find a Sage theme for this project."
106
+ else
107
+ wss.production()
108
+ `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/`
109
+ `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/`
110
+ end
111
+ end
112
+ end
113
+
114
+ desc 'Builds and Uploads the project Sage theme'
115
+ task :upload_sage_theme do
116
+ on roles(:web) do
117
+ wss = WSlaveSage.new()
118
+ sage_theme_name = wss.theme_name?
119
+ if (sage_theme_name == '')
120
+ puts "Couldn't find a Sage theme for this project."
121
+ else
122
+ wss.production()
123
+ upload! "./public/wp-content/themes/#{sage_theme_name}/vendor/", "#{deploy_path}/current/public/wp-content/themes/#{sage_theme_name}/", recursive: true
124
+ upload! "./public/wp-content/themes/#{sage_theme_name}/dist/", "#{deploy_path}/current/public/wp-content/themes/#{sage_theme_name}/", recursive: true
125
+ end
126
+ end
127
+ end
128
+
129
+ desc 'Builds and Deploys the project Sage theme'
130
+ task :sage do
131
+ on roles(:web) do
132
+ if disable_rsync
133
+ invoke('deploy:upload_sage_theme')
134
+ else
135
+ invoke('deploy:sync_sage_theme')
136
+ end
137
+ end
138
+ end
139
+
80
140
  desc 'Finds and replaces localhost:8000 and your Production address with the Staging address'
81
141
  task :chikan do
82
142
  on roles(:web) do
@@ -148,14 +208,17 @@ namespace :deploy do
148
208
  invoke('deploy:upload_wp')
149
209
  invoke('deploy:upload_plugins')
150
210
  invoke('deploy:upload_uploads')
211
+ invoke('deploy:upload_static_data')
151
212
  else
152
213
  invoke('deploy:sync_wp')
153
214
  invoke('deploy:sync_plugins')
154
215
  invoke('deploy:sync_uploads')
216
+ invoke('deploy:sync_static_data')
155
217
  end
156
218
  invoke('deploy')
157
219
  invoke('db:seed')
158
220
  invoke('deploy:chikan')
221
+ invoke('deploy:sage')
159
222
  invoke('deploy:set_permissions')
160
223
  end
161
224
  end
@@ -1,8 +1,8 @@
1
- version: '3'
1
+ version: '3.7'
2
2
 
3
3
  services:
4
4
  db:
5
- image: mariadb:10.5.1-bionic
5
+ image: mariadb:10.5-focal
6
6
  volumes:
7
7
  - "./db/dev:/db"
8
8
  - "./db/active:/docker-entrypoint-initdb.d"
@@ -1,4 +1,4 @@
1
- FROM php:7.4-apache
1
+ FROM php:8.0-apache
2
2
 
3
3
  RUN a2enmod rewrite
4
4
  RUN service apache2 restart
@@ -1,11 +1,14 @@
1
- FROM ubuntu:18.04
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
5
5
 
6
6
  RUN apt-get update
7
7
  RUN DEBIAN_FRONTEND="noninteractive" apt-get -y install tzdata
8
- RUN apt-get install -y nginx php-fpm php-mysql \
8
+ # NOTE: When the PHP FPM version changes, you MUST update the
9
+ # version named in base/docker/nginx/supervisord.conf and
10
+ # in base/docker/nginx/nginx.vhost, then rebuild the nweb image!
11
+ RUN apt-get install -y nginx php7.4-fpm php-mysql \
9
12
  libpng-dev libjpeg-dev \
10
13
  mariadb-client mariadb-common \
11
14
  supervisor curl
@@ -14,8 +17,6 @@ RUN adduser www-data root
14
17
  RUN mkdir /db \
15
18
  && chmod 777 /db
16
19
 
17
- RUN mkdir /run/php
18
-
19
20
  RUN ln -sf /dev/stdout /var/log/nginx/access.log \
20
21
  && ln -sf /dev/stderr /var/log/nginx/error.log
21
22
 
@@ -1,32 +1,48 @@
1
1
  server {
2
- listen 80;
3
- listen [::]:80;
2
+ listen 80;
3
+ listen [::]:80;
4
4
 
5
- server_name testing;
5
+ server_name testing;
6
6
 
7
- root /var/www/html;
7
+ root /var/www/html;
8
8
 
9
- index index.php;
9
+ index index.php;
10
10
 
11
- location / {
12
- rewrite ^/(wp-(admin|includes).*) /wordpress/$1 last;
11
+ location / {
12
+ rewrite ^/(wp-(admin|includes).*) /wordpress/$1 last;
13
13
 
14
- rewrite ^/$ /wordpress/index.php last;
14
+ rewrite ^/$ /wordpress/index.php last;
15
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
- }
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.4-fpm.sock;
25
24
  }
25
+ }
26
26
 
27
- location ~ /\. {
28
- deny all;
29
- access_log off;
30
- log_not_found off;
31
- }
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
+ }
32
48
  }
@@ -5,7 +5,7 @@ logfile_maxbytes=0
5
5
  pidfile=/run/supervisord.pid
6
6
 
7
7
  [program:php-fpm]
8
- command=php-fpm7.2 -F
8
+ command=php-fpm7.4 -F
9
9
  stdout_logfile=/dev/stdout
10
10
  stdout_logfile_maxbytes=0
11
11
  stderr_logfile=/dev/stderr
@@ -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
@@ -8,6 +8,13 @@ class WSlaveCLI < Thor
8
8
  true
9
9
  end
10
10
 
11
+ desc 'version', "Prints the version of the installed WSlave"
12
+ def version()
13
+ require 'rubygems'
14
+ spec = Gem::Specification::load("#{__dir__}/../wslave.gemspec")
15
+ puts spec.version
16
+ end
17
+
11
18
  desc 'new [APP_PATH]', "Generate a new app at APP_PATH"
12
19
  long_desc "Creates a new application in the current directory or in the specificed path."
13
20
  option :version, default: '',
@@ -27,37 +34,6 @@ class WSlaveCLI < Thor
27
34
  WSlaveUpdate.new()
28
35
  end
29
36
 
30
- desc 'sage NAME', "Generate a theme with NAME"
31
- long_desc "Generates a theme base with sage in the themes directory with the given" \
32
- "NAME. A random name will be generated if you do not specify a NAME."
33
- method_option :version, default: ''
34
- def sage(name = '')
35
- if name == ''
36
- require 'haikunator'
37
- name = Haikunator.haikunate(0)
38
- end
39
- puts "Generating sage theme base for #{name}"
40
- require_relative '../lib/wslave_sage'
41
- WSlaveSage.new(name, options['version'])
42
- end
43
-
44
- desc 'server', "Starts the development server"
45
- method_option :f, type: :boolean, default: false, description: 'force close other servers first'
46
- def server()
47
- puts 'Starting server...'
48
- require_relative '../lib/wslave_docker'
49
- WSlaveDocker.new().server(options['f'])
50
- end
51
-
52
- desc 'stop [options]', "Stops the development server"
53
- method_option :v, type: :boolean, default: false, description: 'remove volume data'
54
- method_option :f, type: :boolean, default: false, description: 'force close other servers first'
55
- def stop()
56
- puts 'Stopping server...'
57
- require_relative '../lib/wslave_docker'
58
- WSlaveDocker.new().stop(options['f'], options['v'])
59
- end
60
-
61
37
  desc 'sync', "Synchronizes submodules and file permissions"
62
38
  def sync()
63
39
  require_relative '../lib/wslave_tools'
@@ -65,12 +41,76 @@ class WSlaveCLI < Thor
65
41
  WSlaveTools.sync()
66
42
  end
67
43
 
68
- desc 'version', "Prints the version of the installed WSlave"
69
- def version()
70
- require 'rubygems'
71
- spec = Gem::Specification::load("#{__dir__}/../wslave.gemspec")
72
- puts spec.version
44
+ class Server < Thor
45
+ desc 'start [options]', "Starts the development server"
46
+ method_option :f, type: :boolean, default: false, description: 'force close other servers first'
47
+ def start()
48
+ puts 'Starting server...'
49
+ require_relative '../lib/wslave_docker'
50
+ WSlaveDocker.new().server(:start, options['f'])
51
+ end
52
+
53
+ desc 'stop [options]', "Stops the development server"
54
+ method_option :f, type: :boolean, default: false, description: 'force close other servers first'
55
+ def stop()
56
+ puts 'Stopping server...'
57
+ require_relative '../lib/wslave_docker'
58
+ WSlaveDocker.new().server(:stop, options['f'])
59
+ end
60
+
61
+ desc 'reset [options]', "Deletes all container data and volumes, then rebuilds and restarts the containers"
62
+ method_option :f, type: :boolean, default: false, description: 'force close other servers first'
63
+ def reset()
64
+ puts 'Stopping server...'
65
+ require_relative '../lib/wslave_docker'
66
+ WSlaveDocker.new().server(:reset, options['f'])
67
+ end
68
+
69
+ desc 'reset [options]', "Shuts down containers and deletes all container data and volumes"
70
+ method_option :f, type: :boolean, default: false, description: 'force close other servers first'
71
+ def remove()
72
+ puts 'Stopping server...'
73
+ require_relative '../lib/wslave_docker'
74
+ WSlaveDocker.new().server(:remove, options['f'])
75
+ end
76
+ end
77
+ desc 'server COMMAND [options]', "Control the development server container"
78
+ subcommand 'server', Server
79
+
80
+ class Sage < Thor
81
+ desc 'create THEME_NAME', "Creates a theme with the specified name using Sage"
82
+ def create(theme_name = "wslave_sage_theme")
83
+ require_relative '../lib/wslave_sage'
84
+ puts "Generating sage theme base for #{theme_name}"
85
+ WSlaveSage.new().create(theme_name)
86
+ end
87
+
88
+ desc 'update', "Updates theme generator components"
89
+ def update
90
+ require_relative '../lib/wslave_sage'
91
+ WSlaveSage.new().update()
92
+ end
93
+
94
+ desc 'dev', "Starts a development server which dynamically compiles the theme"
95
+ def dev
96
+ require_relative '../lib/wslave_sage'
97
+ WSlaveSage.new().dev()
98
+ end
99
+
100
+ desc 'build', "Builds the theme (generates development grade static assets)"
101
+ def build
102
+ require_relative '../lib/wslave_sage'
103
+ WSlaveSage.new().build()
104
+ end
105
+
106
+ desc 'production', "Builds the theme (generates production grade static assets)"
107
+ def production
108
+ require_relative '../lib/wslave_sage'
109
+ WSlaveSage.new().production()
110
+ end
73
111
  end
112
+ desc 'sage COMMAND', "Generates and manages a Sage theme"
113
+ subcommand 'sage', Sage
74
114
  end
75
115
 
76
116
  WSlaveCLI.start(ARGV)
data/lib/wslave_docker.rb CHANGED
@@ -6,18 +6,70 @@ 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)
10
+ case (command)
11
+ when :start
12
+ start(force)
13
+ when :stop
14
+ stop(force)
15
+ when :reset
16
+ reset(force)
17
+ when :remove
18
+ remove(force)
19
+ when :log
20
+ log()
21
+ when :console
22
+ console()
23
+ else
24
+ puts "server subcommand \"#{command.to_s}\" not found."
25
+ puts "Available commands: start stop log console"
26
+ end
27
+ end
28
+
29
+ def start(force = false)
10
30
  return unless _check()
11
31
  _force_down() if force
32
+ `docker-compose stop` # Shutdown existing instances
12
33
  _unfuck_dot_htaccess()
13
34
  WSlaveTools.set_dev_perms
35
+ `docker-compose build`
36
+ `docker-compose start -d`
37
+ `docker-compose up -d`
38
+ end
39
+
40
+ def stop(force = false)
41
+ return unless _check()
42
+ _force_down() if force
43
+ `docker-compose stop`
44
+ end
45
+
46
+ def reset(force = false)
47
+ return unless _check()
48
+ _force_down() if force
49
+ `docker-compose down -v`
50
+ `docker-compose build`
14
51
  `docker-compose up -d`
15
52
  end
16
53
 
17
- def stop(force, volume)
54
+ def remove(force = false)
18
55
  return unless _check()
19
56
  _force_down() if force
20
- `docker-compose down#{volume ? ' -v' : ''}`
57
+ `docker-compose down -v`
58
+ end
59
+
60
+ def log()
61
+ return unless _check()
62
+ begin
63
+ system("docker-compose logs -f")
64
+ rescue Exception => e
65
+ puts "\n\nEnding log trace. NOTE: Server containers are still running!\n\n"
66
+ return
67
+ end
68
+ end
69
+
70
+ def console()
71
+ return unless _check()
72
+ system("docker-compose exec web /bin/bash")
21
73
  end
22
74
 
23
75
  def _check()
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}-branch`
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")
@@ -57,6 +57,9 @@ class WSlaveNew
57
57
  FileUtils.touch("#{path}/public/wp-content/upgrade/.gitkeep")
58
58
  Dir.chdir path
59
59
 
60
+ puts " > Preparing static data directory"
61
+ FileUtils.mkdir("#{path}/public/data") unless Dir.exist?("#{path}/public/data")
62
+
60
63
  puts " > Setting permissions"
61
64
  WSlaveTools.set_dev_perms
62
65
 
@@ -71,12 +74,28 @@ class WSlaveNew
71
74
  end
72
75
 
73
76
  def get_stable_branch_version(path)
74
- latest = '5.3' # 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
77
+ latest_major = 5
78
+ latest_minor = 7
79
+
80
+ reg = /^(\d*)\.(\d)-branch$/
81
+ puts "> Checking for WordPress versions in: #{path}"
82
+ cdir = Dir.pwd()
83
+ Dir.chdir(path)
84
+ g = Git.open("./")
85
+ g.branches.remote.each do |branch|
86
+ ver = reg.match(branch.name)
87
+ if (ver) # If the branch matched the x.y-branch pattern
88
+ if ((ver[1].to_i >= latest_major) && (ver[2].to_i > latest_minor))
89
+ latest_major = ver[1].to_i
90
+ latest_minor = ver[2].to_i
91
+ end
92
+ end
93
+
94
+ end
95
+ Dir.chdir(cdir)
79
96
 
97
+ latest = "#{latest_major}.#{latest_minor}"
98
+ puts "> Detected latest WordPress version as: #{latest}"
80
99
  latest
81
100
  end
82
101
  end
data/lib/wslave_sage.rb CHANGED
@@ -1,9 +1,76 @@
1
+ require 'yaml'
2
+
1
3
  class WSlaveSage
2
- def initialize(name, version)
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
- `cd public/wp-content/themes && composer create-project roots/sage #{name} #{version}`
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
@@ -23,6 +23,8 @@ class WSlaveTools
23
23
  FileUtils.chmod(0775, "#{path}/public/wp-content/plugins")
24
24
  FileUtils.chown(nil, 'www-data', "#{path}/public/wp-content/upgrade")
25
25
  FileUtils.chmod(0775, "#{path}/public/wp-content/upgrade")
26
+ FileUtils.chown(nil, 'www-data', "#{path}/public/data")
27
+ FileUtils.chmod(0775, "#{path}/public/data")
26
28
 
27
29
  unless Dir.exist?("#{path}/db")
28
30
  FileUtils.mkdir("#{path}/db")
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}/docker")
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")
@@ -9,6 +9,9 @@ deployer:
9
9
  fqdn:
10
10
  staging:
11
11
  production:
12
+ branch:
13
+ staging: master
14
+ production: master
12
15
  app:
13
16
  name:
14
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.1.0'
3
+ s.version = '0.3.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.11.2'
24
- s.add_dependency 'capistrano-git-with-submodules', '~> 2.0', '2.0.3'
23
+ s.add_dependency 'capistrano', '= 3.16.0'
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.5', '1.5.0'
28
+ s.add_dependency 'git', '~> 1.8', '1.8.1'
29
29
 
30
- s.add_dependency 'thor', '~> 0.20', '0.20.3'
31
- s.add_dependency 'haikunator', '~> 1.1', '1.1.0'
30
+ s.add_dependency 'thor', '~> 1.1', '1.1.0'
31
+ s.add_dependency 'haikunator', '~> 1.1', '1.1.1'
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.1.0
4
+ version: 0.3.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-03-03 00:00:00.000000000 Z
11
+ date: 2021-04-15 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.11.2
19
+ version: 3.16.0
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.11.2
26
+ version: 3.16.0
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.3
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.3
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.5'
93
+ version: '1.8'
94
+ - - '='
95
+ - !ruby/object:Gem::Version
96
+ version: 1.8.1
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.5'
103
+ version: '1.8'
104
+ - - '='
105
+ - !ruby/object:Gem::Version
106
+ version: 1.8.1
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.20'
113
+ version: '1.1'
114
114
  - - '='
115
115
  - !ruby/object:Gem::Version
116
- version: 0.20.3
116
+ version: 1.1.0
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.20'
123
+ version: '1.1'
124
124
  - - '='
125
125
  - !ruby/object:Gem::Version
126
- version: 0.20.3
126
+ version: 1.1.0
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.1
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.1
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.
@@ -164,6 +164,8 @@ files:
164
164
  - base/config/deploy-tools/wp-config.php.erb
165
165
  - base/config/deploy-tools/wp-config.php.local
166
166
  - base/config/deploy.rb
167
+ - base/config/deploy/.production.rb.swp
168
+ - base/config/deploy/.staging.rb.swp
167
169
  - base/config/deploy/production.rb
168
170
  - base/config/deploy/staging.rb
169
171
  - base/docker-compose.yml
@@ -202,7 +204,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
202
204
  - !ruby/object:Gem::Version
203
205
  version: '0'
204
206
  requirements: []
205
- rubygems_version: 3.0.6
207
+ rubygems_version: 3.1.2
206
208
  signing_key:
207
209
  specification_version: 4
208
210
  summary: '"Word Slave" generates and controls a WordPress installation'