wslave 0.2.3 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9ee627106f6ba97b14f1adf9d636ef8b66a9ffcf89c996b59bb077633f2f1eaa
4
- data.tar.gz: 1d31cf735fbeacb810f2558fd7c3b49af4fcef1a7421f27511aa89b0dbba0dee
3
+ metadata.gz: d7c39b73b05b1be955f9f28b0925120e1b11aa37bce3ef2ffcc5b272aef0ecf5
4
+ data.tar.gz: 75ab79a0688af02c2ae453e170a387e6677ebf4ca275a5ae1a45a4e2166f56e2
5
5
  SHA512:
6
- metadata.gz: ce2bce83363782e099e55132d5cf63730e4ebf16f5588446c69149a536c2d90a250eb94f07dc0748c820106513e210d31b889274c5df6bbcd52d33a4143e474c
7
- data.tar.gz: 53fe21ad452756017e8a4ad0c7ef93b200f08b877b531776e80898e345cdd6f6608db58ffb6d4cb3af81754a97e2abf4329f65bb8b15d5d0032adff703c34fdf
6
+ metadata.gz: 8fa738f7f91f460a8e9a84a5fcc0d38b5251b6d95c6a2443ce7bde8454fcd47169dd720001a9a2caf0f9f322c616b508579770227b4c7a0a1f788a47ead14f7b
7
+ data.tar.gz: e8a2df80d986c1f24993a576d9e116f5f91c379fa037d028d427f870983d89d7e0a809d750e3f35cfae0fa5adbaba3cffc0023b8ee43392b9256620ee046432e
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")
@@ -33,19 +33,19 @@ server {
33
33
  log_not_found off;
34
34
  }
35
35
 
36
- location ~- \.(blade\.php)$ {
36
+ location ~* \.(blade\.php)$ {
37
37
  deny all;
38
38
  }
39
39
 
40
- location ~- composer\.(json|lock)$ {
40
+ location ~* composer\.(json|lock)$ {
41
41
  deny all;
42
42
  }
43
43
 
44
- location ~- package(-lock)?\.json$ {
44
+ location ~* package(-lock)?\.json$ {
45
45
  deny all;
46
46
  }
47
47
 
48
- location ~- yarn\.lock$ {
48
+ location ~* yarn\.lock$ {
49
49
  deny all;
50
50
  }
51
51
  }
@@ -1,5 +1,5 @@
1
1
  # config valid only for current version of Capistrano
2
- lock "3.14.1"
2
+ lock "3.16.0"
3
3
 
4
4
  require 'yaml'
5
5
  opts = YAML.load_file('config/definitions.yml')
Binary file
@@ -1,8 +1,8 @@
1
- version: '3'
1
+ version: '3.7'
2
2
 
3
3
  services:
4
4
  db:
5
- image: mariadb:10.5.4-focal
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
@@ -5,7 +5,10 @@ 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
@@ -1,48 +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
32
 
33
- location ~- \.(blade\.php)$ {
33
+ location ~* \.(blade\.php)$ {
34
34
  deny all;
35
35
  }
36
36
 
37
- location ~- composer\.(json|lock)$ {
37
+ location ~* composer\.(json|lock)$ {
38
38
  deny all;
39
39
  }
40
40
 
41
- location ~- package(-lock)?\.json$ {
41
+ location ~* package(-lock)?\.json$ {
42
42
  deny all;
43
43
  }
44
44
 
45
- location ~- yarn\.lock$ {
45
+ location ~* yarn\.lock$ {
46
46
  deny all;
47
47
  }
48
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
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,57 +34,6 @@ class WSlaveCLI < Thor
27
34
  WSlaveUpdate.new()
28
35
  end
29
36
 
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'])
61
- end
62
-
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()
67
- puts 'Starting server...'
68
- require_relative '../lib/wslave_docker'
69
- WSlaveDocker.new().server(:start, options['f'], options['v'])
70
- end
71
-
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'
75
- def stop()
76
- puts 'Stopping server...'
77
- require_relative '../lib/wslave_docker'
78
- WSlaveDocker.new().server(:stop, options['f'], options['v'])
79
- end
80
-
81
37
  desc 'sync', "Synchronizes submodules and file permissions"
82
38
  def sync()
83
39
  require_relative '../lib/wslave_tools'
@@ -85,39 +41,76 @@ class WSlaveCLI < Thor
85
41
  WSlaveTools.sync()
86
42
  end
87
43
 
88
- desc 'version', "Prints the version of the installed WSlave"
89
- def version()
90
- require 'rubygems'
91
- spec = Gem::Specification::load("#{__dir__}/../wslave.gemspec")
92
- 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
93
76
  end
77
+ desc 'server COMMAND [options]', "Control the development server container"
78
+ subcommand 'server', Server
94
79
 
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'
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")
101
83
  require_relative '../lib/wslave_sage'
102
- puts "Generating sage theme base for #{arg}"
103
- WSlaveSage.new().create(arg)
104
- when 'update'
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
105
90
  require_relative '../lib/wslave_sage'
106
91
  WSlaveSage.new().update()
107
- when 'dev'
92
+ end
93
+
94
+ desc 'dev', "Starts a development server which dynamically compiles the theme"
95
+ def dev
108
96
  require_relative '../lib/wslave_sage'
109
97
  WSlaveSage.new().dev()
110
- when 'build'
98
+ end
99
+
100
+ desc 'build', "Builds the theme (generates development grade static assets)"
101
+ def build
111
102
  require_relative '../lib/wslave_sage'
112
103
  WSlaveSage.new().build()
113
- when 'production'
104
+ end
105
+
106
+ desc 'production', "Builds the theme (generates production grade static assets)"
107
+ def production
114
108
  require_relative '../lib/wslave_sage'
115
109
  WSlaveSage.new().production()
116
- else
117
- puts "sage command \"#{command}\" not found."
118
- puts "sage commands available: create update dev build production"
119
110
  end
120
111
  end
112
+ desc 'sage COMMAND', "Generates and manages a Sage theme"
113
+ subcommand 'sage', Sage
121
114
  end
122
115
 
123
116
  WSlaveCLI.start(ARGV)
data/lib/wslave_docker.rb CHANGED
@@ -6,12 +6,16 @@ class WSlaveDocker
6
6
  puts 'Initializing WSlave Docker Control'
7
7
  end
8
8
 
9
- def server(command = :start, force = false, volume = false)
9
+ def server(command = :start, force = false)
10
10
  case (command)
11
11
  when :start
12
- start(force, volume)
12
+ start(force)
13
13
  when :stop
14
- stop(force, volume)
14
+ stop(force)
15
+ when :reset
16
+ reset(force)
17
+ when :remove
18
+ remove(force)
15
19
  when :log
16
20
  log()
17
21
  when :console
@@ -22,19 +26,35 @@ class WSlaveDocker
22
26
  end
23
27
  end
24
28
 
25
- def start(force = false, volume = false)
29
+ def start(force = false)
26
30
  return unless _check()
27
31
  _force_down() if force
28
- `docker-compose down#{volume ? ' -v' : ''}` # Shutdown existing instances
32
+ `docker-compose stop` # Shutdown existing instances
29
33
  _unfuck_dot_htaccess()
30
34
  WSlaveTools.set_dev_perms
35
+ `docker-compose build`
36
+ `docker-compose start -d`
31
37
  `docker-compose up -d`
32
38
  end
33
39
 
34
- def stop(force = false, volume = false)
40
+ def stop(force = false)
35
41
  return unless _check()
36
42
  _force_down() if force
37
- `docker-compose down#{volume ? ' -v' : ''}`
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`
51
+ `docker-compose up -d`
52
+ end
53
+
54
+ def remove(force = false)
55
+ return unless _check()
56
+ _force_down() if force
57
+ `docker-compose down -v`
38
58
  end
39
59
 
40
60
  def log()
data/lib/wslave_new.rb CHANGED
@@ -57,7 +57,7 @@ class WSlaveNew
57
57
  FileUtils.touch("#{path}/public/wp-content/upgrade/.gitkeep")
58
58
  Dir.chdir path
59
59
 
60
- puts " > Preparing statid data directory"
60
+ puts " > Preparing static data directory"
61
61
  FileUtils.mkdir("#{path}/public/data") unless Dir.exist?("#{path}/public/data")
62
62
 
63
63
  puts " > Setting permissions"
@@ -74,12 +74,28 @@ class WSlaveNew
74
74
  end
75
75
 
76
76
  def get_stable_branch_version(path)
77
- latest = '5.4' # This is just a fallback (latest at time of update)
78
- # TODO Implementation requires this issue be resolved: https://github.com/ruby-git/ruby-git/issues/424
79
- #g = Git.open(path)
80
- #g.brances.remote.each do |branch|
81
- #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)
82
96
 
97
+ latest = "#{latest_major}.#{latest_minor}"
98
+ puts "> Detected latest WordPress version as: #{latest}"
83
99
  latest
84
100
  end
85
101
  end
data/wslave.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'wslave'
3
- s.version = '0.2.3'
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.14.1'
23
+ s.add_dependency 'capistrano', '= 3.16.0'
24
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.7', '1.7.0'
28
+ s.add_dependency 'git', '~> 1.8', '1.8.1'
29
29
 
30
- s.add_dependency 'thor', '~> 1.0', '1.0.1'
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.2.3
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-11-19 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.14.1
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.14.1
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
@@ -90,40 +90,40 @@ dependencies:
90
90
  requirements:
91
91
  - - "~>"
92
92
  - !ruby/object:Gem::Version
93
- version: '1.7'
93
+ version: '1.8'
94
94
  - - '='
95
95
  - !ruby/object:Gem::Version
96
- version: 1.7.0
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
101
  - - "~>"
102
102
  - !ruby/object:Gem::Version
103
- version: '1.7'
103
+ version: '1.8'
104
104
  - - '='
105
105
  - !ruby/object:Gem::Version
106
- version: 1.7.0
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: '1.0'
113
+ version: '1.1'
114
114
  - - '='
115
115
  - !ruby/object:Gem::Version
116
- version: 1.0.1
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: '1.0'
123
+ version: '1.1'
124
124
  - - '='
125
125
  - !ruby/object:Gem::Version
126
- version: 1.0.1
126
+ version: 1.1.0
127
127
  - !ruby/object:Gem::Dependency
128
128
  name: haikunator
129
129
  requirement: !ruby/object:Gem::Requirement
@@ -133,7 +133,7 @@ dependencies:
133
133
  version: '1.1'
134
134
  - - '='
135
135
  - !ruby/object:Gem::Version
136
- version: 1.1.0
136
+ version: 1.1.1
137
137
  type: :runtime
138
138
  prerelease: false
139
139
  version_requirements: !ruby/object:Gem::Requirement
@@ -143,7 +143,7 @@ dependencies:
143
143
  version: '1.1'
144
144
  - - '='
145
145
  - !ruby/object:Gem::Version
146
- version: 1.1.0
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