wordpress-capistrano-v2 1.0.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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 8648d9f6d8d10ea9cf46990f1aabec97a7d4921f26076ef6258a0b648dea578d
4
+ data.tar.gz: cab090340e59d5b595f9e3313fa341f11700c2e4a4865d577db23d019d594fb5
5
+ SHA512:
6
+ metadata.gz: 1887a9259255ba74461bd977a28472bb18f2c003086437d590fcc903994ed9d6f163e51b8ea4efe5192a0ccf5a45cdbc7c27557f74113f1b7f94a6a8a446ef7d
7
+ data.tar.gz: 9a5c3d8c9ecd45ff05126baab6ffa7e71d30cbf99dba5d667ca1a43a2f2a6332fb81d1e73c85abf077c591d08d5ca623dcd15f58f296c5ff11b5db90640ddd65
data/.gitignore ADDED
@@ -0,0 +1,18 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ coverage
6
+ InstalledFiles
7
+ lib/bundler/man
8
+ pkg
9
+ rdoc
10
+ spec/reports
11
+ test/tmp
12
+ test/version_tmp
13
+ tmp
14
+
15
+ # YARD artifacts
16
+ .yardoc
17
+ _yardoc
18
+ doc/
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in capistrano-bundler.gemspec
4
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,27 @@
1
+ GEM
2
+ remote: https://rubygems.org/
3
+ specs:
4
+ capistrano (3.1.0)
5
+ i18n
6
+ rake (>= 10.0.0)
7
+ sshkit (~> 1.3)
8
+ capistrano-composer (0.0.3)
9
+ capistrano (>= 3.0.0.pre)
10
+ i18n (0.6.9)
11
+ net-scp (1.1.2)
12
+ net-ssh (>= 2.6.5)
13
+ net-ssh (2.8.0)
14
+ rake (10.1.1)
15
+ sshkit (1.3.0)
16
+ net-scp (>= 1.1.2)
17
+ net-ssh
18
+ term-ansicolor
19
+ term-ansicolor (1.3.0)
20
+ tins (~> 1.0)
21
+ tins (1.0.0)
22
+
23
+ PLATFORMS
24
+ ruby
25
+
26
+ DEPENDENCIES
27
+ capistrano-composer
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2014 Craig Morris
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
6
+ this software and associated documentation files (the "Software"), to deal in
7
+ the Software without restriction, including without limitation the rights to
8
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9
+ the Software, and to permit persons to whom the Software is furnished to do so,
10
+ subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,151 @@
1
+ # Capistrano::WordPress
2
+
3
+ A set of recipes for working with WordPress (via WP CLI) and Capistrano 3.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'capistrano', '~> 3.0.0'
11
+ gem 'wordpress-capistrano'
12
+ ```
13
+
14
+ And then execute:
15
+
16
+ $ bundle
17
+
18
+ Or install it yourself as:
19
+
20
+ $ gem install wordpress-capistrano
21
+
22
+ ## Usage
23
+
24
+ Require the module in your `Capfile`:
25
+
26
+ ```ruby
27
+ require 'capistrano/wordpress'
28
+ ```
29
+
30
+ `wordpress/capistrano` comes with 4 tasks:
31
+
32
+ * wordpress:db:push - Exports your local database and imports it on remote server
33
+ * wordpress:db:pull - Exports your remote database and imports it on your local
34
+ * wordpress:db:deploy - Uploads the <database name>.sql in your version control and imports in on remote
35
+ * wordpress:uploads:sync - Synchronises your local and remote wp-content/uploads folder so that you have all assets
36
+ * wordpress:uploads:push - Pushes your local wp-content/uploads folder to the remote.
37
+ * wordpress:uploads:pull - Pulls the remote wp-content/uploads folder to your local installation.
38
+ * wordpress:paths - Updates WordPress paths to match latest release folders
39
+
40
+ You can run any of these by issuing the following commands..
41
+
42
+ ```bash
43
+ $ bundle exec cap production wordpress:db:push
44
+ $ bundle exec cap production wordpress:db:pull
45
+ $ bundle exec cap production wordpress:db:deploy
46
+ $ bundle exec cap production wordpress:uploads:sync
47
+ $ bundle exec cap production wordpress:uploads:pull
48
+ $ bundle exec cap production wordpress:uploads:push
49
+ $ bundle exec cap production wordpress:paths
50
+ ```
51
+
52
+ None of these tasks are built into the default Capistrano deploy as they are potentially damaging.
53
+
54
+ To add any of them, add the following code into your deploy.rb
55
+
56
+ ```ruby
57
+ after :updated, 'wordpress:db:deploy'
58
+ after :updated, 'wordpress:uploads:sync'
59
+ ```
60
+
61
+ These are useful on sites where all content is under version control
62
+
63
+ ### Other Recommended Settings
64
+
65
+ This gem does not have libraries to perform common tasks like symlinking wp-content/uploads or symlinking database
66
+ configuration files. Some recommended settings to go along with your deploy.rb are below.
67
+
68
+ #### Use Composer for WordPress and Plugins
69
+
70
+ ```json
71
+ {
72
+ "repositories": [
73
+ {
74
+ "type": "composer",
75
+ "url": "http://wpackagist.org"
76
+ },
77
+ {
78
+ "type": "package",
79
+ "package": {
80
+ "name": "wordpress",
81
+ "type": "webroot",
82
+ "version": "3.8.1",
83
+ "dist": {
84
+ "type": "zip",
85
+ "url": "http://en-au.wordpress.org/wordpress-3.8.1-en_AU.zip"
86
+ },
87
+ "require": {
88
+ "fancyguy/webroot-installer": "1.0.0"
89
+ }
90
+ }
91
+ },
92
+ ],
93
+ "require": {
94
+ "php": ">=5.3.0",
95
+ "wordpress": "3.8.1",
96
+ "fancyguy/webroot-installer": "1.0.0",
97
+ "wpackagist/advanced-custom-fields": "*",
98
+ "wpackagist/codepress-admin-columns": "*",
99
+ "wpackagist/custom-post-type-ui": "*",
100
+ "wpackagist/wordpress-importer": "*",
101
+ "wpackagist/duplicate-post": "*",
102
+ "wpackagist/simple-page-ordering": "*",
103
+ "wpackagist/adminimize": "*"
104
+ },
105
+ "require-dev": {
106
+ "wpackagist/debug-bar": "*",
107
+ "wpackagist/pretty-debug": "*"
108
+ },
109
+ "extra": {
110
+ "webroot-dir": "wp",
111
+ "webroot-package": "wordpress"
112
+ }
113
+ }
114
+ ```
115
+
116
+ #### Use Linked Dirs and Linked Files
117
+
118
+ ```ruby
119
+ set :linked_dirs, %w{wp-content/uploads}
120
+ set :linked_files, %w{wp-config.local.php}
121
+ ```
122
+
123
+
124
+ ### Configuration
125
+
126
+ Configurable options, shown here with defaults:
127
+
128
+ ```ruby
129
+ set :url, 'www.wordpress.org'
130
+ set :local_url, 'localhost'
131
+ set :wp_path, '.'
132
+ set :local_wp_path, '.'
133
+ set :wp_uploads, 'wp-content/uploads'
134
+ set :local_wp_uploads, 'wp-content/uploads'
135
+ set :wp_themes, 'wp-content/themes'
136
+ ```
137
+
138
+ ## Contributing
139
+
140
+ 1. Fork it
141
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
142
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
143
+ 4. Push to the branch (`git push origin my-new-feature`)
144
+ 5. Create new Pull Request
145
+
146
+ Also, please ask the owner of the capistrano-wordpress gem to give up his name!
147
+
148
+ ## Credits
149
+
150
+ * https://github.com/herrkris/wordpress-capistrano
151
+ * https://github.com/capistrano/composer
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require 'bundler/gem_tasks'
@@ -0,0 +1,189 @@
1
+ namespace :wordpress do
2
+
3
+ namespace :db do
4
+ desc "Pull the remote database"
5
+ task :pull do
6
+
7
+ on roles(:db) do
8
+ within release_path do
9
+ with path: "#{fetch(:path)}:$PATH" do
10
+ execute :wp, "--path=#{fetch(:wp_path)} db export #{fetch(:tmp_dir)}/database.sql"
11
+ execute :gzip, "-f #{fetch(:tmp_dir)}/database.sql"
12
+ end
13
+ end
14
+
15
+ download! "#{fetch(:tmp_dir)}/database.sql.gz", "database.sql.gz"
16
+
17
+ run_locally do
18
+ timestamp = "#{Time.now.year}-#{Time.now.month}-#{Time.now.day}-#{Time.now.hour}-#{Time.now.min}-#{Time.now.sec}"
19
+
20
+ execute :wp, "--path=#{fetch(:local_wp_path)} db export #{fetch(:application)}.#{timestamp}.sql" # backup
21
+
22
+ execute :gunzip, "-f database.sql.gz"
23
+ execute :wp, "--path=#{fetch(:local_wp_path)} db import database.sql"
24
+ execute :wp, "--path=#{fetch(:local_wp_path)} search-replace #{fetch(:url)} #{fetch(:local_url)}"
25
+
26
+ execute :rm, "database.sql.gz", raise_on_non_zero_exit: false
27
+ execute :rm, "database.sql", raise_on_non_zero_exit: false
28
+
29
+ execute :wp, "--path=#{fetch(:local_wp_path)}", :option, :delete, :template_root, raise_on_non_zero_exit: false
30
+ execute :wp, "--path=#{fetch(:local_wp_path)}", :option, :delete, :stylesheet_root, raise_on_non_zero_exit: false
31
+ end
32
+
33
+ execute :rm, "#{fetch(:tmp_dir)}/database.sql", raise_on_non_zero_exit: false
34
+ execute :rm, "#{fetch(:tmp_dir)}/database.sql.gz", raise_on_non_zero_exit: false
35
+ end
36
+
37
+ end
38
+
39
+ # @todo GZIP
40
+ desc "Push the local database"
41
+ task :push do
42
+ on roles(:db) do
43
+
44
+ run_locally do
45
+ execute :wp, "--path=#{fetch(:local_wp_path)} db export database.sql"
46
+ execute :gzip, "-f database.sql"
47
+ end
48
+
49
+ upload! "database.sql.gz", "#{fetch(:tmp_dir)}/database.sql.gz"
50
+
51
+ run_locally do
52
+ execute :rm, "database.sql", raise_on_non_zero_exit: false
53
+ execute :rm, "database.sql.gz", raise_on_non_zero_exit: false
54
+ end
55
+
56
+ within release_path do
57
+ with path: "#{fetch(:path)}:$PATH" do
58
+ timestamp = "#{Time.now.year}-#{Time.now.month}-#{Time.now.day}-#{Time.now.hour}-#{Time.now.min}-#{Time.now.sec}"
59
+
60
+ execute :wp, "--path=#{fetch(:wp_path)} db export #{fetch(:application)}.#{timestamp}.sql" # backup
61
+
62
+ execute :gunzip, "-f #{fetch(:tmp_dir)}/database.sql.gz"
63
+
64
+ execute :wp, "--path=#{fetch(:wp_path)} db import #{fetch(:tmp_dir)}/database.sql"
65
+ execute :wp, "--path=#{fetch(:wp_path)} search-replace #{fetch(:local_url)} #{fetch(:url)}"
66
+
67
+ execute :rm, "#{fetch(:tmp_dir)}/database.sql", raise_on_non_zero_exit: false
68
+ execute :rm, "#{fetch(:tmp_dir)}/database.sql.gz", raise_on_non_zero_exit: false
69
+
70
+ invoke 'wordpress:paths'
71
+
72
+ execute :echo, %{"Database imported at #{timestamp}" >> #{revision_log}}
73
+ end
74
+ end
75
+
76
+ end
77
+ end
78
+
79
+ # Database name locally must match the :application variable in capistrano
80
+ # @todo gzip
81
+ desc "Push the database in version control"
82
+ task :deploy do
83
+
84
+ on roles(:db) do
85
+
86
+ upload! "#{fetch(:application)}.sql", "#{fetch(:tmp_dir)}/database.sql"
87
+
88
+ within release_path do
89
+ with path: "#{fetch(:path)}:$PATH" do
90
+ timestamp = "#{Time.now.year}-#{Time.now.month}-#{Time.now.day}-#{Time.now.hour}-#{Time.now.min}-#{Time.now.sec}"
91
+ execute :wp, "--path=#{fetch(:wp_path)} db export #{fetch(:application)}.#{timestamp}.sql"
92
+ execute :wp, "--path=#{fetch(:wp_path)} db import #{fetch(:tmp_dir)}/database.sql"
93
+ execute :wp, "--path=#{fetch(:wp_path)} search-replace #{fetch(:local_url)} #{fetch(:url)}"
94
+ execute :rm, "#{fetch(:tmp_dir)}/database.sql"
95
+ invoke 'wordpress:paths'
96
+ execute :echo, %{"Database imported at #{timestamp}" >> #{revision_log}}
97
+ end
98
+ end
99
+
100
+ end
101
+
102
+ end
103
+ end
104
+
105
+ namespace :uploads do
106
+
107
+ desc "Synchronise local and remote wp-content/uploads folders"
108
+ task :sync do
109
+ invoke 'pull'
110
+ invoke 'push'
111
+ end
112
+
113
+ desc "Pull remote wp-content/uploads folder"
114
+ task :pull do
115
+ run_locally do
116
+ roles(:web).each do |role|
117
+ puts role.netssh_options[:port]
118
+ port = role.netssh_options[:port] || 22
119
+ user = role.user + "@" if !role.user.nil?
120
+ execute :rsync, "-avz --rsh=ssh --progress -e 'ssh -p #{port}' #{user}#{role.hostname}:#{release_path}/#{fetch(:wp_uploads)}/ #{fetch(:local_wp_uploads)}"
121
+ end
122
+ end
123
+ end
124
+
125
+ desc "Push local wp-content folder to remote wp-content/uploads folder"
126
+ task :push do
127
+ run_locally do
128
+ roles(:web).each do |role|
129
+ puts role.netssh_options[:port]
130
+ port = role.netssh_options[:port] || 22
131
+ user = role.user + "@" if !role.user.nil?
132
+ execute :rsync, "-avz --rsh=ssh --progress -e 'ssh -p #{port}' #{fetch(:local_wp_uploads)}/ #{user}#{role.hostname}:#{release_path}/#{fetch(:wp_uploads)}"
133
+ end
134
+ end
135
+ end
136
+
137
+ end
138
+
139
+ namespace :content do
140
+ desc "Synchronise local and remote wp-content/uploads folders"
141
+ task :sync do
142
+ invoke 'uploads:sync'
143
+ end
144
+ end
145
+
146
+ desc "Update WordPress template root paths to point to the new release"
147
+ task :paths do
148
+
149
+ on roles(:db) do
150
+ within release_path do
151
+ with path: "#{fetch(:path)}:$PATH" do
152
+ if test :wp, :core, 'is-installed'
153
+
154
+ releases = capture("ls #{File.join(fetch(:deploy_to), 'releases')}")
155
+ last_release = File.join(releases_path, releases.split("\n").sort.last, fetch(:wp_themes))
156
+
157
+ [:stylesheet_root, :template_root].each do |option|
158
+ # Only change the value if it's an absolute path
159
+ # i.e. The relative path "/themes" must remain unchanged
160
+ # Also, the option might not be set, in which case we leave it like that
161
+ value = capture :wp, :option, :get, option, raise_on_non_zero_exit: false
162
+ if value != '' && value != '/themes'
163
+ execute :wp, "--path=#{fetch(:wp_path)}", :option, :set, option, last_release
164
+ end
165
+ end
166
+
167
+ end
168
+ end
169
+ end
170
+ end
171
+ end
172
+
173
+ end
174
+
175
+ def set_option_path
176
+
177
+ end
178
+
179
+ namespace :load do
180
+ task :defaults do
181
+ set :url, 'www.wordpress.org'
182
+ set :local_url, 'localhost'
183
+ set :wp_path, '.'
184
+ set :local_wp_path, '.'
185
+ set :wp_uploads, 'wp-content/uploads'
186
+ set :local_wp_uploads, 'wp-content/uploads'
187
+ set :wp_themes, 'wp-content/themes'
188
+ end
189
+ end
@@ -0,0 +1 @@
1
+ load File.expand_path('../tasks/wordpress.rake', __FILE__)
File without changes
@@ -0,0 +1,24 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = 'wordpress-capistrano-v2'
7
+ spec.version = '1.0.0'
8
+ spec.authors = ['Craig Morris', 'Thomas Ferney']
9
+ spec.email = ['craig.michael.morris@gmail.com', 'thomas.ferney@gmail.com']
10
+ spec.description = %q{Deploy your WordPress projects with Capistrano 3.x}
11
+ spec.summary = %q{WordPress support for Capistrano 3.x}
12
+ spec.homepage = 'https://github.com/antiseptikk/wordpress-capistrano'
13
+ spec.license = 'MIT'
14
+
15
+ spec.files = `git ls-files`.split($/)
16
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
17
+ #spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
18
+ spec.require_paths = ['lib']
19
+
20
+ spec.add_dependency 'capistrano', '~> 3.0'
21
+
22
+ spec.add_development_dependency 'bundler', '~> 1.3'
23
+ spec.add_development_dependency 'rake', '~> 0'
24
+ end
metadata ADDED
@@ -0,0 +1,97 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: wordpress-capistrano-v2
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Craig Morris
8
+ - Thomas Ferney
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2023-03-15 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: capistrano
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - "~>"
19
+ - !ruby/object:Gem::Version
20
+ version: '3.0'
21
+ type: :runtime
22
+ prerelease: false
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - "~>"
26
+ - !ruby/object:Gem::Version
27
+ version: '3.0'
28
+ - !ruby/object:Gem::Dependency
29
+ name: bundler
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - "~>"
33
+ - !ruby/object:Gem::Version
34
+ version: '1.3'
35
+ type: :development
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - "~>"
40
+ - !ruby/object:Gem::Version
41
+ version: '1.3'
42
+ - !ruby/object:Gem::Dependency
43
+ name: rake
44
+ requirement: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - "~>"
47
+ - !ruby/object:Gem::Version
48
+ version: '0'
49
+ type: :development
50
+ prerelease: false
51
+ version_requirements: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - "~>"
54
+ - !ruby/object:Gem::Version
55
+ version: '0'
56
+ description: Deploy your WordPress projects with Capistrano 3.x
57
+ email:
58
+ - craig.michael.morris@gmail.com
59
+ - thomas.ferney@gmail.com
60
+ executables: []
61
+ extensions: []
62
+ extra_rdoc_files: []
63
+ files:
64
+ - ".gitignore"
65
+ - Gemfile
66
+ - Gemfile.lock
67
+ - LICENSE
68
+ - README.md
69
+ - Rakefile
70
+ - lib/capistrano/tasks/wordpress.rake
71
+ - lib/capistrano/wordpress.rb
72
+ - lib/wordpress-capistrano.rb
73
+ - wordpress-capistrano.gemspec
74
+ homepage: https://github.com/antiseptikk/wordpress-capistrano
75
+ licenses:
76
+ - MIT
77
+ metadata: {}
78
+ post_install_message:
79
+ rdoc_options: []
80
+ require_paths:
81
+ - lib
82
+ required_ruby_version: !ruby/object:Gem::Requirement
83
+ requirements:
84
+ - - ">="
85
+ - !ruby/object:Gem::Version
86
+ version: '0'
87
+ required_rubygems_version: !ruby/object:Gem::Requirement
88
+ requirements:
89
+ - - ">="
90
+ - !ruby/object:Gem::Version
91
+ version: '0'
92
+ requirements: []
93
+ rubygems_version: 3.1.6
94
+ signing_key:
95
+ specification_version: 4
96
+ summary: WordPress support for Capistrano 3.x
97
+ test_files: []