capistrano-wpcli 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,34 @@
1
+ *.gem
2
+ *.rbc
3
+ /.config
4
+ /coverage/
5
+ /InstalledFiles
6
+ /pkg/
7
+ /spec/reports/
8
+ /test/tmp/
9
+ /test/version_tmp/
10
+ /tmp/
11
+
12
+ ## Specific to RubyMotion:
13
+ .dat*
14
+ .repl_history
15
+ build/
16
+
17
+ ## Documentation cache and generated files:
18
+ /.yardoc/
19
+ /_yardoc/
20
+ /doc/
21
+ /rdoc/
22
+
23
+ ## Environment normalisation:
24
+ /.bundle/
25
+ /lib/bundler/man/
26
+
27
+ # for a library or gem, you might want to ignore these files since the code is
28
+ # intended to run in multiple environments; otherwise, check them in:
29
+ # Gemfile.lock
30
+ # .ruby-version
31
+ # .ruby-gemset
32
+
33
+ # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
34
+ .rvmrc
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in capistrano-wpcli.gemspec
4
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,31 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ capistrano-wpcli (0.0.1)
5
+ capistrano (>= 3.0)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ capistrano (3.2.1)
11
+ i18n
12
+ rake (>= 10.0.0)
13
+ sshkit (~> 1.3)
14
+ colorize (0.7.3)
15
+ i18n (0.6.9)
16
+ net-scp (1.2.1)
17
+ net-ssh (>= 2.6.5)
18
+ net-ssh (2.9.1)
19
+ rake (10.3.2)
20
+ sshkit (1.5.1)
21
+ colorize
22
+ net-scp (>= 1.1.2)
23
+ net-ssh (>= 2.8.0)
24
+
25
+ PLATFORMS
26
+ ruby
27
+
28
+ DEPENDENCIES
29
+ bundler (~> 1.6)
30
+ capistrano-wpcli!
31
+ rake
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2014 lavmeiker
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, 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,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Juancito Arias
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,65 @@
1
+ # Capistrano::WPCLI
2
+
3
+ **Note: this plugin works only with Capistrano 3.**
4
+
5
+ Simple Capistrano wrapper using WP-CLI
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ gem 'capistrano-wpcli'
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install capistrano-wpcli
20
+
21
+ ## Usage
22
+
23
+ All you need to do is put the following in `Capfile` file:
24
+
25
+ require 'capistrano/wpcli'
26
+
27
+ ### How it works
28
+
29
+ The following tasks are added to Capistrano:
30
+
31
+ * `wpcli:run`<br/>
32
+ Executes the WP-CLI command passed as parameter.
33
+ * `wpcli:db:push`<br/>
34
+ Pushes the local WP database to the remote server and replaces the urls.
35
+ * `wpcli:db:pull`<br/>
36
+ Pulls the remote server WP database to local and replaces the urls.
37
+
38
+ ### Configuration
39
+
40
+ This plugin needs some configuration to work properly. It will try to load these configuration from the env vars. To do so all you need to do is put the following in `.env` file:
41
+
42
+ WP_APP_NAME=example
43
+ WP_HOME=http://example.dev
44
+ WP_REMOTE_URL=http://example.com
45
+
46
+ Alternatively, you can put all your configs in capistrano stage files i.e. `config/deploy/production.rb`.
47
+
48
+ Here's the list of options and the defaults for each option:
49
+
50
+ * `set :application`<br/>
51
+ Name of the application.
52
+
53
+ * `set :remote_url`<br/>
54
+ Url of the Wordpress root installation on the remote server (used by search-replace command).
55
+
56
+ * `set :local_url`<br/>
57
+ Url of the Wordpress root installation on the local server (used by search-replace command).
58
+
59
+ ## Contributing
60
+
61
+ 1. Fork it ( https://github.com/lavmeiker/capistrano-wpcli/fork )
62
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
63
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
64
+ 4. Push to the branch (`git push origin my-new-feature`)
65
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
@@ -0,0 +1,25 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'capistrano/wpcli/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "capistrano-wpcli"
8
+ spec.version = Capistrano::Wpcli::VERSION
9
+ spec.authors = ["Juancito Arias"]
10
+ spec.email = ["trasgofurioso@gmail.com"]
11
+ spec.summary = %q{Simple Capistrano wrapper around WP-CLI}
12
+ spec.description = %q{Capistrano tasks for managing Wordpress}
13
+ spec.homepage = "https://github.com/lavmeiker/capistrano-wpcli"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_dependency 'capistrano', '>= 3.0'
22
+
23
+ spec.add_development_dependency "bundler", "~> 1.6"
24
+ spec.add_development_dependency "rake"
25
+ end
File without changes
@@ -0,0 +1,17 @@
1
+ namespace :load do
2
+ task :defaults do
3
+ set :wp_roles, :all
4
+ end
5
+ end
6
+
7
+ namespace :wpcli do
8
+ desc "Runs a WP-CLI command"
9
+ task :run, :command do |t, args|
10
+ args.with_defaults(:command => :help)
11
+ on release_roles(fetch(:wp_roles)) do
12
+ within release_path do
13
+ execute :wp, args[:command], *args.extras
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,69 @@
1
+ namespace :load do
2
+ task :defaults do
3
+ set :application, ENV["WP_APP_NAME"]
4
+ # A temp dir which is read and writeable by the capistrano
5
+ # deploy user
6
+ set :remote_tmp_dir, ENV["WP_REMOTE_TMP"] || "/tmp"
7
+
8
+ # A local temp dir which is read and writeable
9
+ set :local_tmp_dir, ENV["WP_LOCAL_TMP"] || "/tmp"
10
+
11
+ # The url under which the wordpress installation is
12
+ # available on the remote server
13
+ set :remote_url, ENV["WP_REMOTE_URL"]
14
+
15
+ # The url under which the wordpress installation is
16
+ # available on the local server
17
+ set :local_url, ENV["WP_HOME"]
18
+
19
+ # Shortcuts
20
+ set :remote_db_file, "#{fetch(:remote_tmp_dir)}/#{fetch(:application)}_database.sql"
21
+ set :local_db_file, "#{fetch(:local_tmp_dir)}/#{fetch(:application)}_database.sql"
22
+ end
23
+ end
24
+
25
+ namespace :wpcli do
26
+ namespace :db do
27
+ desc "Pull the remote database"
28
+ task :pull do
29
+ on roles(:web) do
30
+ within release_path do
31
+ with path: "#{fetch(:path)}:$PATH" do
32
+ execute :wp, "db export", fetch(:remote_db_file)
33
+ download! fetch(:remote_db_file), fetch(:local_db_file)
34
+ execute :rm, fetch(:remote_db_file)
35
+ end
36
+ end
37
+
38
+ run_locally do
39
+ execute :wp, "db import", fetch(:local_db_file)
40
+ execute :rm, "#{fetch(:local_db_file)}"
41
+ execute :wp, "search-replace", "'#{fetch(:remote_url)}' '#{fetch(:local_url)}' --skip-columns=guid"
42
+ end
43
+ end
44
+ end
45
+
46
+ desc "Push the local database"
47
+ task :push do
48
+ on roles(:web) do
49
+ run_locally do
50
+ execute :wp, "db export", fetch(:local_db_file)
51
+ end
52
+
53
+ upload! fetch(:local_db_file), fetch(:remote_db_file)
54
+
55
+ run_locally do
56
+ execute :rm, fetch(:local_db_file)
57
+ end
58
+
59
+ within release_path do
60
+ with path: "#{fetch(:path)}:$PATH" do
61
+ execute :wp, "db import", fetch(:remote_db_file)
62
+ execute :rm, fetch(:remote_db_file)
63
+ execute :wp, "search-replace", "'#{fetch(:local_url)}' '#{fetch(:remote_url)}' --skip-columns=guid"
64
+ end
65
+ end
66
+ end
67
+ end
68
+ end
69
+ end
@@ -0,0 +1,6 @@
1
+ # Load configuration from .env
2
+ require "dotenv"
3
+ Dotenv.load
4
+
5
+ load File.expand_path("../tasks/wpcli.rake", __FILE__)
6
+ load File.expand_path("../tasks/wpdb.rake", __FILE__)
@@ -0,0 +1,5 @@
1
+ module Capistrano
2
+ module Wpcli
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
metadata ADDED
@@ -0,0 +1,113 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: capistrano-wpcli
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Juancito Arias
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2014-06-04 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: capistrano
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '3.0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '3.0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: bundler
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ~>
36
+ - !ruby/object:Gem::Version
37
+ version: '1.6'
38
+ type: :development
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ version: '1.6'
46
+ - !ruby/object:Gem::Dependency
47
+ name: rake
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ description: Capistrano tasks for managing Wordpress
63
+ email:
64
+ - trasgofurioso@gmail.com
65
+ executables: []
66
+ extensions: []
67
+ extra_rdoc_files: []
68
+ files:
69
+ - .gitignore
70
+ - Gemfile
71
+ - Gemfile.lock
72
+ - LICENSE
73
+ - LICENSE.txt
74
+ - README.md
75
+ - Rakefile
76
+ - capistrano-wpcli.gemspec
77
+ - lib/capistrano-wpcli.rb
78
+ - lib/capistrano/tasks/wpcli.rake
79
+ - lib/capistrano/tasks/wpdb.rake
80
+ - lib/capistrano/wpcli.rb
81
+ - lib/capistrano/wpcli/version.rb
82
+ homepage: https://github.com/lavmeiker/capistrano-wpcli
83
+ licenses:
84
+ - MIT
85
+ post_install_message:
86
+ rdoc_options: []
87
+ require_paths:
88
+ - lib
89
+ required_ruby_version: !ruby/object:Gem::Requirement
90
+ none: false
91
+ requirements:
92
+ - - ! '>='
93
+ - !ruby/object:Gem::Version
94
+ version: '0'
95
+ segments:
96
+ - 0
97
+ hash: 2580052462737984893
98
+ required_rubygems_version: !ruby/object:Gem::Requirement
99
+ none: false
100
+ requirements:
101
+ - - ! '>='
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ segments:
105
+ - 0
106
+ hash: 2580052462737984893
107
+ requirements: []
108
+ rubyforge_project:
109
+ rubygems_version: 1.8.23
110
+ signing_key:
111
+ specification_version: 3
112
+ summary: Simple Capistrano wrapper around WP-CLI
113
+ test_files: []