rake-wordpress_upgrader_former03 0.0.1
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 +7 -0
- data/.gitignore +14 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +38 -0
- data/Rakefile +2 -0
- data/lib/rake/wordpress_upgrader_former03.rb +124 -0
- data/lib/rake/wordpress_upgrader_former03/task.rb +37 -0
- data/lib/rake/wordpress_upgrader_former03/version.rb +5 -0
- data/rake-wordpress_upgrader_former03.gemspec +24 -0
- data/share/wp-cli/wp-cli.phar +0 -0
- metadata +96 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 0cb39662a8859e61fddeb429e413b04377e35b90
|
4
|
+
data.tar.gz: 8c80a3b747c56c6762ac4da9c76d6ca9d56d2444
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: fd37d0496a43fcd0f3e56582f19b77248880543d505ca1e2fdf647d7d6b4768b6bc2c6e7b18c15aacb7fac948f197ee3128b9a229814a71ff19a99fbbbb18eb3
|
7
|
+
data.tar.gz: 6e7ef4d057acf7edb8a33fee09bbd677aad0e1aa33e0874dd902ab3435fcbe3026d4996a7d8924a020dff404a33c1e3892bb1543874d1cfa8c1dcbb0f1c8a9ae
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2015 Christian Simon
|
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,38 @@
|
|
1
|
+
# Gem rake-wordpress_upgrader_former03
|
2
|
+
|
3
|
+
Rake tasks for upgrading wordpress with wp-cli
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'rake-wordpress_upgrader_former03'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle install
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install rake-wordpress_upgrader_former03
|
20
|
+
|
21
|
+
Finally add to your Rakefile:
|
22
|
+
|
23
|
+
```ruby
|
24
|
+
begin
|
25
|
+
require 'rake/wordpress_upgrader_former03/task'
|
26
|
+
Rake::WordpressUpgraderFormer03::Task.new(:wpupgrade)
|
27
|
+
rescue LoadError
|
28
|
+
end
|
29
|
+
```
|
30
|
+
|
31
|
+
## Usage
|
32
|
+
|
33
|
+
```
|
34
|
+
rake wpupgrade:all # Upgrade everything
|
35
|
+
rake wpupgrade:core # Upgrade core
|
36
|
+
rake wpupgrade:json # Write json file
|
37
|
+
rake wpupgrade:plugins # Upgrade all wordpress plugins
|
38
|
+
```
|
data/Rakefile
ADDED
@@ -0,0 +1,124 @@
|
|
1
|
+
require 'rake/wordpress_upgrader_former03/version'
|
2
|
+
require 'wpcli'
|
3
|
+
require 'json'
|
4
|
+
|
5
|
+
module Rake
|
6
|
+
module WordpressUpgraderFormer03
|
7
|
+
|
8
|
+
class WpUpgrade < Wpcli::Client
|
9
|
+
|
10
|
+
def initialize(conf={})
|
11
|
+
if not conf.has_key? :wp_cli_path
|
12
|
+
conf[:wp_cli_path] = wp_cli_path
|
13
|
+
end
|
14
|
+
if not conf.has_key? :wordpress_path
|
15
|
+
conf[:wordpress_path] = 'wwwroot'
|
16
|
+
end
|
17
|
+
if not conf.has_key? :json_path
|
18
|
+
conf[:json_path] = 'wordpress.json'
|
19
|
+
end
|
20
|
+
@conf = conf
|
21
|
+
super conf[:wordpress_path]
|
22
|
+
end
|
23
|
+
|
24
|
+
def wp_cli_path
|
25
|
+
File.expand_path(
|
26
|
+
File.join(
|
27
|
+
File.expand_path(File.dirname(__FILE__)),
|
28
|
+
"../../share/wp-cli/wp-cli.phar"
|
29
|
+
)
|
30
|
+
)
|
31
|
+
end
|
32
|
+
|
33
|
+
def run_noparse command
|
34
|
+
`#{@conf[:wp_cli_path]}#{@path.empty? ? " " : " --path=" + @path + " "}#{command}`
|
35
|
+
end
|
36
|
+
|
37
|
+
def run command
|
38
|
+
output = run_noparse command
|
39
|
+
parse output
|
40
|
+
end
|
41
|
+
|
42
|
+
def run_success command
|
43
|
+
output = run command
|
44
|
+
if not output.last.values.first.match(/^Success:/)
|
45
|
+
fail "Failed running command '#{command}'\n\n#{output}"
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
def core_update
|
50
|
+
output = run "core check-update"
|
51
|
+
if output.length < 1
|
52
|
+
puts "No core update available"
|
53
|
+
return
|
54
|
+
end
|
55
|
+
git_clean!
|
56
|
+
old_version = core_version
|
57
|
+
run_success "core update"
|
58
|
+
new_version = core_version
|
59
|
+
puts "core #{old_version} -> #{new_version}"
|
60
|
+
git_commit! "Upgrade wordpress core\n\n * from version #{old_version} to #{new_version}"
|
61
|
+
end
|
62
|
+
|
63
|
+
def plugins_update
|
64
|
+
plugins = run "plugin list"
|
65
|
+
plugins.each do |plugin|
|
66
|
+
if plugin[:update] != 'none'
|
67
|
+
plugin_update plugin
|
68
|
+
end
|
69
|
+
end
|
70
|
+
puts "All plugins updated"
|
71
|
+
end
|
72
|
+
|
73
|
+
def core_version
|
74
|
+
run_noparse("core version").chomp
|
75
|
+
end
|
76
|
+
|
77
|
+
def plugin_update plugin
|
78
|
+
git_clean!
|
79
|
+
old_version = plugin[:version]
|
80
|
+
cmd = "plugin update #{plugin[:name]}"
|
81
|
+
run_success cmd
|
82
|
+
new_version = run("plugin get #{plugin[:name]}").first[:version]
|
83
|
+
puts "#{plugin[:name]} #{old_version} -> #{new_version}"
|
84
|
+
git_commit! "Upgrade plugin '#{plugin[:name]}'\n\n * from version #{old_version} to #{new_version}"
|
85
|
+
end
|
86
|
+
|
87
|
+
def git_clean!
|
88
|
+
output = `git status #{@path} -s`
|
89
|
+
if output.chomp.length != 0
|
90
|
+
raise "Git is unclean:\n#{output}"
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
def git_commit! message
|
95
|
+
`git add -A #{@path}`
|
96
|
+
`git commit -m "#{message}"`
|
97
|
+
end
|
98
|
+
|
99
|
+
def plugins
|
100
|
+
output = run("plugin list")
|
101
|
+
output.map do |plugin|
|
102
|
+
plugin.delete(:update)
|
103
|
+
plugin
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
def wordpress
|
108
|
+
{
|
109
|
+
version: core_version,
|
110
|
+
plugins: plugins,
|
111
|
+
}
|
112
|
+
end
|
113
|
+
|
114
|
+
def json_update
|
115
|
+
path = @conf[:json_path]
|
116
|
+
File.open(path, 'w') do |file|
|
117
|
+
file.write(JSON.pretty_generate(wordpress))
|
118
|
+
end
|
119
|
+
`git add #{path}`
|
120
|
+
`git commit #{path} -m "Updates wordpress.json"`
|
121
|
+
end
|
122
|
+
end
|
123
|
+
end
|
124
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'rake'
|
2
|
+
require 'rake/tasklib'
|
3
|
+
|
4
|
+
module Rake
|
5
|
+
module WordpressUpgraderFormer03
|
6
|
+
class Task < ::Rake::TaskLib
|
7
|
+
include ::Rake::DSL if defined?(::Rake::DSL)
|
8
|
+
def initialize name
|
9
|
+
@name = name || :wpupgrade
|
10
|
+
define
|
11
|
+
end
|
12
|
+
|
13
|
+
def define
|
14
|
+
namespace @name do
|
15
|
+
task :setup do
|
16
|
+
require 'rake/wordpress_upgrader_former03'
|
17
|
+
@wpupgrade = Rake::WordpressUpgraderFormer03::WpUpgrade.new
|
18
|
+
end
|
19
|
+
desc 'Upgrade all wordpress plugins'
|
20
|
+
task :plugins => [:setup] do
|
21
|
+
@wpupgrade.plugins_update
|
22
|
+
end
|
23
|
+
desc 'Write json file'
|
24
|
+
task :json => [:setup] do
|
25
|
+
@wpupgrade.json_update
|
26
|
+
end
|
27
|
+
desc 'Upgrade core'
|
28
|
+
task :core => [:setup] do
|
29
|
+
@wpupgrade.core_update
|
30
|
+
end
|
31
|
+
desc 'Upgrade everything'
|
32
|
+
task :all => [:core, :plugins, :json]
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -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
|
+
require 'rake/wordpress_upgrader_former03/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "rake-wordpress_upgrader_former03"
|
8
|
+
spec.version = Rake::WordpressUpgraderFormer03::VERSION
|
9
|
+
spec.authors = ["Christian Simon"]
|
10
|
+
spec.email = ["simon@swine.de"]
|
11
|
+
spec.summary = %q{Rake tasks for upgrading wordpress with wp-cli}
|
12
|
+
spec.description = %q{Rake tasks for upgrading wordpress with wp-cli}
|
13
|
+
spec.homepage = ""
|
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_development_dependency "bundler", "~> 1.7"
|
22
|
+
spec.add_dependency "rake"
|
23
|
+
spec.add_dependency "wpcli", "~> 0.2.8"
|
24
|
+
end
|
Binary file
|
metadata
ADDED
@@ -0,0 +1,96 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rake-wordpress_upgrader_former03
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Christian Simon
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-03-18 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.7'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.7'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: wpcli
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ~>
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 0.2.8
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 0.2.8
|
55
|
+
description: Rake tasks for upgrading wordpress with wp-cli
|
56
|
+
email:
|
57
|
+
- simon@swine.de
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- .gitignore
|
63
|
+
- Gemfile
|
64
|
+
- LICENSE.txt
|
65
|
+
- README.md
|
66
|
+
- Rakefile
|
67
|
+
- lib/rake/wordpress_upgrader_former03.rb
|
68
|
+
- lib/rake/wordpress_upgrader_former03/task.rb
|
69
|
+
- lib/rake/wordpress_upgrader_former03/version.rb
|
70
|
+
- rake-wordpress_upgrader_former03.gemspec
|
71
|
+
- share/wp-cli/wp-cli.phar
|
72
|
+
homepage: ''
|
73
|
+
licenses:
|
74
|
+
- MIT
|
75
|
+
metadata: {}
|
76
|
+
post_install_message:
|
77
|
+
rdoc_options: []
|
78
|
+
require_paths:
|
79
|
+
- lib
|
80
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
81
|
+
requirements:
|
82
|
+
- - '>='
|
83
|
+
- !ruby/object:Gem::Version
|
84
|
+
version: '0'
|
85
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - '>='
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
requirements: []
|
91
|
+
rubyforge_project:
|
92
|
+
rubygems_version: 2.4.3
|
93
|
+
signing_key:
|
94
|
+
specification_version: 4
|
95
|
+
summary: Rake tasks for upgrading wordpress with wp-cli
|
96
|
+
test_files: []
|