wordpress-deploy 1.0.0.alpha1
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.
- data/.gitignore +2 -0
- data/Gemfile +7 -0
- data/Gemfile.lock +71 -0
- data/LICENSE.md +24 -0
- data/README.md +22 -0
- data/Rakefile +7 -0
- data/bin/wp-deploy +11 -0
- data/lib/wordpress_deploy/cli/helpers.rb +91 -0
- data/lib/wordpress_deploy/cli/utility.rb +53 -0
- data/lib/wordpress_deploy/config.rb +68 -0
- data/lib/wordpress_deploy/database/base.rb +53 -0
- data/lib/wordpress_deploy/database/mysql.rb +159 -0
- data/lib/wordpress_deploy/errors.rb +70 -0
- data/lib/wordpress_deploy/logger.rb +152 -0
- data/lib/wordpress_deploy/pipeline.rb +110 -0
- data/lib/wordpress_deploy/storage/base.rb +99 -0
- data/lib/wordpress_deploy/storage/ftp.rb +133 -0
- data/lib/wordpress_deploy/storage/local.rb +82 -0
- data/lib/wordpress_deploy/storage/scp.rb +99 -0
- data/lib/wordpress_deploy/storage/sftp.rb +108 -0
- data/lib/wordpress_deploy/version.rb +3 -0
- data/lib/wordpress_deploy.rb +61 -0
- data/spec/config_spec.rb +16 -0
- data/spec/spec_helper.rb +5 -0
- data/wordpress_deploy.gemspec +26 -0
- metadata +201 -0
@@ -0,0 +1,108 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
##
|
4
|
+
# Only load the Net::SFTP library/gem when the WordpressDeploy::Storage::SFTP class is loaded
|
5
|
+
WordpressDeploy::Dependency.load('net-ssh')
|
6
|
+
WordpressDeploy::Dependency.load('net-sftp')
|
7
|
+
|
8
|
+
module WordpressDeploy
|
9
|
+
module Storage
|
10
|
+
class SFTP < Base
|
11
|
+
|
12
|
+
##
|
13
|
+
# Server credentials
|
14
|
+
attr_accessor :username, :password
|
15
|
+
|
16
|
+
##
|
17
|
+
# Server IP Address and SFTP port
|
18
|
+
attr_accessor :ip, :port
|
19
|
+
|
20
|
+
##
|
21
|
+
# Path to store backups to
|
22
|
+
attr_accessor :path
|
23
|
+
|
24
|
+
##
|
25
|
+
# Creates a new instance of the storage object
|
26
|
+
def initialize(model, storage_id = nil, &block)
|
27
|
+
super(model, storage_id)
|
28
|
+
|
29
|
+
@port ||= 22
|
30
|
+
@path ||= 'backups'
|
31
|
+
|
32
|
+
instance_eval(&block) if block_given?
|
33
|
+
|
34
|
+
@path = path.sub(/^\~\//, '')
|
35
|
+
end
|
36
|
+
|
37
|
+
private
|
38
|
+
|
39
|
+
##
|
40
|
+
# Establishes a connection to the remote server
|
41
|
+
def connection
|
42
|
+
Net::SFTP.start(
|
43
|
+
ip, username,
|
44
|
+
:password => password,
|
45
|
+
:port => port
|
46
|
+
) {|sftp| yield sftp }
|
47
|
+
end
|
48
|
+
|
49
|
+
##
|
50
|
+
# Transfers the archived file to the specified remote server
|
51
|
+
def transfer!
|
52
|
+
remote_path = remote_path_for(@package)
|
53
|
+
|
54
|
+
connection do |sftp|
|
55
|
+
create_remote_path(remote_path, sftp)
|
56
|
+
|
57
|
+
files_to_transfer_for(@package) do |local_file, remote_file|
|
58
|
+
Logger.message "#{storage_name} started transferring " +
|
59
|
+
"'#{ local_file }' to '#{ ip }'."
|
60
|
+
|
61
|
+
sftp.upload!(
|
62
|
+
File.join(local_path, local_file),
|
63
|
+
File.join(remote_path, remote_file)
|
64
|
+
)
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
##
|
70
|
+
# Removes the transferred archive file(s) from the storage location.
|
71
|
+
# Any error raised will be rescued during Cycling
|
72
|
+
# and a warning will be logged, containing the error message.
|
73
|
+
def remove!(package)
|
74
|
+
remote_path = remote_path_for(package)
|
75
|
+
|
76
|
+
connection do |sftp|
|
77
|
+
transferred_files_for(package) do |local_file, remote_file|
|
78
|
+
Logger.message "#{storage_name} started removing " +
|
79
|
+
"'#{ local_file }' from '#{ ip }'."
|
80
|
+
|
81
|
+
sftp.remove!(File.join(remote_path, remote_file))
|
82
|
+
end
|
83
|
+
|
84
|
+
sftp.rmdir!(remote_path)
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
##
|
89
|
+
# Creates (if they don't exist yet) all the directories on the remote
|
90
|
+
# server in order to upload the backup file. Net::SFTP does not support
|
91
|
+
# paths to directories that don't yet exist when creating new
|
92
|
+
# directories. Instead, we split the parts up in to an array (for each
|
93
|
+
# '/') and loop through that to create the directories one by one.
|
94
|
+
# Net::SFTP raises an exception when the directory it's trying to create
|
95
|
+
# already exists, so we have rescue it
|
96
|
+
def create_remote_path(remote_path, sftp)
|
97
|
+
path_parts = Array.new
|
98
|
+
remote_path.split('/').each do |path_part|
|
99
|
+
path_parts << path_part
|
100
|
+
begin
|
101
|
+
sftp.mkdir!(path_parts.join('/'))
|
102
|
+
rescue Net::SFTP::StatusException; end
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
# Load Ruby Core Libraries
|
4
|
+
require 'rubygems'
|
5
|
+
require 'fileutils'
|
6
|
+
require 'tempfile'
|
7
|
+
require 'yaml'
|
8
|
+
require 'etc'
|
9
|
+
|
10
|
+
require 'open4'
|
11
|
+
require 'thor'
|
12
|
+
|
13
|
+
##
|
14
|
+
# The Wordpress Deploy Ruby Gem
|
15
|
+
module WordpressDeploy
|
16
|
+
|
17
|
+
##
|
18
|
+
# Wordpress Deploy's internal paths
|
19
|
+
ROOT_PATH = File.dirname(__FILE__)
|
20
|
+
LIBRARY_PATH = File.join(ROOT_PATH, 'wordpress_deploy')
|
21
|
+
CLI_PATH = File.join(LIBRARY_PATH, 'cli')
|
22
|
+
DATABASE_PATH = File.join(LIBRARY_PATH, 'database')
|
23
|
+
STORAGE_PATH = File.join(LIBRARY_PATH, 'storage')
|
24
|
+
|
25
|
+
##
|
26
|
+
# Autoload Wordpress Deploy CLI files
|
27
|
+
module CLI
|
28
|
+
autoload :Helpers, File.join(CLI_PATH, 'helpers')
|
29
|
+
autoload :Utility, File.join(CLI_PATH, 'utility')
|
30
|
+
end
|
31
|
+
|
32
|
+
##
|
33
|
+
# Autoload Wordpress Deploy storage files
|
34
|
+
module Storage
|
35
|
+
autoload :Base, File.join(STORAGE_PATH, 'base')
|
36
|
+
autoload :FTP, File.join(STORAGE_PATH, 'ftp')
|
37
|
+
autoload :SFTP, File.join(STORAGE_PATH, 'sftp')
|
38
|
+
autoload :SCP, File.join(STORAGE_PATH, 'scp')
|
39
|
+
autoload :Local, File.join(STORAGE_PATH, 'local')
|
40
|
+
end
|
41
|
+
|
42
|
+
##
|
43
|
+
# Autoload Wordpress Deploy database files
|
44
|
+
module Database
|
45
|
+
autoload :Base, File.join(DATABASE_PATH, 'base')
|
46
|
+
autoload :MySQL, File.join(DATABASE_PATH, 'mysql')
|
47
|
+
autoload :PostgreSQL, File.join(DATABASE_PATH, 'postgresql')
|
48
|
+
autoload :MongoDB, File.join(DATABASE_PATH, 'mongodb')
|
49
|
+
autoload :Redis, File.join(DATABASE_PATH, 'redis')
|
50
|
+
autoload :Riak, File.join(DATABASE_PATH, 'riak')
|
51
|
+
end
|
52
|
+
|
53
|
+
%w{
|
54
|
+
config
|
55
|
+
errors
|
56
|
+
logger
|
57
|
+
pipeline
|
58
|
+
version
|
59
|
+
}.each {|lib| require File.join(LIBRARY_PATH, lib) }
|
60
|
+
|
61
|
+
end
|
data/spec/config_spec.rb
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe WordpressDeploy::Config do
|
4
|
+
it { should respond_to :env }
|
5
|
+
it { should respond_to :environment }
|
6
|
+
it { should respond_to :base_dir }
|
7
|
+
it { should respond_to :config_dir }
|
8
|
+
it { should respond_to :sites_dir }
|
9
|
+
it { should respond_to :ftp_config }
|
10
|
+
it { should respond_to :wp_config }
|
11
|
+
it { should respond_to :wp_config_sample }
|
12
|
+
it { should respond_to :wp_config_output }
|
13
|
+
it { should respond_to :environment }
|
14
|
+
it { WordpressDeploy::Config.env.should == "production" }
|
15
|
+
it { WordpressDeploy::Config.env.should eq WordpressDeploy::Config.environment }
|
16
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path('../lib/wordpress_deploy/version', __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |gem|
|
5
|
+
gem.authors = ["Ryan Lovelett"]
|
6
|
+
gem.email = ["ryan@wahvee.com"]
|
7
|
+
gem.description = %q{Used to deploy a Wordpress site.}
|
8
|
+
gem.summary = %q{}
|
9
|
+
gem.homepage = %q{https://github.com/RLovelett/jsb3}
|
10
|
+
|
11
|
+
gem.files = `git ls-files`.split($\)
|
12
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
13
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
14
|
+
gem.name = "wordpress-deploy"
|
15
|
+
gem.require_paths = ["lib"]
|
16
|
+
gem.version = WordpressDeploy::VERSION
|
17
|
+
|
18
|
+
gem.add_dependency 'thor', ['~> 0.14.6']
|
19
|
+
gem.add_dependency 'open4', ['~> 1.3.0']
|
20
|
+
gem.add_dependency 'actionpack', ['~> 3.2.6']
|
21
|
+
gem.add_dependency 'colorize', ['~> 0.5.8']
|
22
|
+
gem.add_development_dependency "rake"
|
23
|
+
gem.add_development_dependency "rspec"
|
24
|
+
gem.add_development_dependency "mocha"
|
25
|
+
gem.add_development_dependency "timecop"
|
26
|
+
end
|
metadata
ADDED
@@ -0,0 +1,201 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: wordpress-deploy
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0.alpha1
|
5
|
+
prerelease: 6
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Ryan Lovelett
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-07-02 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: thor
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 0.14.6
|
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: 0.14.6
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: open4
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ~>
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: 1.3.0
|
38
|
+
type: :runtime
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ~>
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: 1.3.0
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: actionpack
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ~>
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: 3.2.6
|
54
|
+
type: :runtime
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 3.2.6
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: colorize
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ~>
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: 0.5.8
|
70
|
+
type: :runtime
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ~>
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: 0.5.8
|
78
|
+
- !ruby/object:Gem::Dependency
|
79
|
+
name: rake
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
82
|
+
requirements:
|
83
|
+
- - ! '>='
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '0'
|
86
|
+
type: :development
|
87
|
+
prerelease: false
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ! '>='
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '0'
|
94
|
+
- !ruby/object:Gem::Dependency
|
95
|
+
name: rspec
|
96
|
+
requirement: !ruby/object:Gem::Requirement
|
97
|
+
none: false
|
98
|
+
requirements:
|
99
|
+
- - ! '>='
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: '0'
|
102
|
+
type: :development
|
103
|
+
prerelease: false
|
104
|
+
version_requirements: !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
106
|
+
requirements:
|
107
|
+
- - ! '>='
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0'
|
110
|
+
- !ruby/object:Gem::Dependency
|
111
|
+
name: mocha
|
112
|
+
requirement: !ruby/object:Gem::Requirement
|
113
|
+
none: false
|
114
|
+
requirements:
|
115
|
+
- - ! '>='
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
none: false
|
122
|
+
requirements:
|
123
|
+
- - ! '>='
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
version: '0'
|
126
|
+
- !ruby/object:Gem::Dependency
|
127
|
+
name: timecop
|
128
|
+
requirement: !ruby/object:Gem::Requirement
|
129
|
+
none: false
|
130
|
+
requirements:
|
131
|
+
- - ! '>='
|
132
|
+
- !ruby/object:Gem::Version
|
133
|
+
version: '0'
|
134
|
+
type: :development
|
135
|
+
prerelease: false
|
136
|
+
version_requirements: !ruby/object:Gem::Requirement
|
137
|
+
none: false
|
138
|
+
requirements:
|
139
|
+
- - ! '>='
|
140
|
+
- !ruby/object:Gem::Version
|
141
|
+
version: '0'
|
142
|
+
description: Used to deploy a Wordpress site.
|
143
|
+
email:
|
144
|
+
- ryan@wahvee.com
|
145
|
+
executables:
|
146
|
+
- wp-deploy
|
147
|
+
extensions: []
|
148
|
+
extra_rdoc_files: []
|
149
|
+
files:
|
150
|
+
- .gitignore
|
151
|
+
- Gemfile
|
152
|
+
- Gemfile.lock
|
153
|
+
- LICENSE.md
|
154
|
+
- README.md
|
155
|
+
- Rakefile
|
156
|
+
- bin/wp-deploy
|
157
|
+
- lib/wordpress_deploy.rb
|
158
|
+
- lib/wordpress_deploy/cli/helpers.rb
|
159
|
+
- lib/wordpress_deploy/cli/utility.rb
|
160
|
+
- lib/wordpress_deploy/config.rb
|
161
|
+
- lib/wordpress_deploy/database/base.rb
|
162
|
+
- lib/wordpress_deploy/database/mysql.rb
|
163
|
+
- lib/wordpress_deploy/errors.rb
|
164
|
+
- lib/wordpress_deploy/logger.rb
|
165
|
+
- lib/wordpress_deploy/pipeline.rb
|
166
|
+
- lib/wordpress_deploy/storage/base.rb
|
167
|
+
- lib/wordpress_deploy/storage/ftp.rb
|
168
|
+
- lib/wordpress_deploy/storage/local.rb
|
169
|
+
- lib/wordpress_deploy/storage/scp.rb
|
170
|
+
- lib/wordpress_deploy/storage/sftp.rb
|
171
|
+
- lib/wordpress_deploy/version.rb
|
172
|
+
- spec/config_spec.rb
|
173
|
+
- spec/spec_helper.rb
|
174
|
+
- wordpress_deploy.gemspec
|
175
|
+
homepage: https://github.com/RLovelett/jsb3
|
176
|
+
licenses: []
|
177
|
+
post_install_message:
|
178
|
+
rdoc_options: []
|
179
|
+
require_paths:
|
180
|
+
- lib
|
181
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
182
|
+
none: false
|
183
|
+
requirements:
|
184
|
+
- - ! '>='
|
185
|
+
- !ruby/object:Gem::Version
|
186
|
+
version: '0'
|
187
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
188
|
+
none: false
|
189
|
+
requirements:
|
190
|
+
- - ! '>'
|
191
|
+
- !ruby/object:Gem::Version
|
192
|
+
version: 1.3.1
|
193
|
+
requirements: []
|
194
|
+
rubyforge_project:
|
195
|
+
rubygems_version: 1.8.24
|
196
|
+
signing_key:
|
197
|
+
specification_version: 3
|
198
|
+
summary: ''
|
199
|
+
test_files:
|
200
|
+
- spec/config_spec.rb
|
201
|
+
- spec/spec_helper.rb
|