wordmove 1.3.0.pre2 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +2 -0
- data/.rspec +1 -0
- data/.travis.yml +1 -1
- data/CHANGELOG.md +4 -0
- data/Gemfile +1 -1
- data/README.mdown +5 -0
- data/Rakefile +2 -4
- data/assets/images/wordmove.png +0 -0
- data/bin/console +10 -0
- data/bin/rake +16 -0
- data/bin/rspec +16 -0
- data/bin/setup +7 -0
- data/exe/wordmove +6 -0
- data/lib/wordmove.rb +25 -0
- data/lib/wordmove/assets/dump.php.erb +202 -165
- data/lib/wordmove/assets/import.php.erb +1179 -1080
- data/lib/wordmove/cli.rb +18 -18
- data/lib/wordmove/deployer/base.rb +30 -32
- data/lib/wordmove/deployer/ftp.rb +3 -7
- data/lib/wordmove/deployer/ssh.rb +3 -5
- data/lib/wordmove/exceptions.rb +6 -0
- data/lib/wordmove/generators/movefile.rb +0 -3
- data/lib/wordmove/generators/movefile_adapter.rb +3 -4
- data/lib/wordmove/logger.rb +0 -5
- data/lib/wordmove/version.rb +1 -1
- data/wordmove.gemspec +34 -38
- metadata +91 -75
- data/bin/wordmove +0 -6
- data/lib/wordmove/core_ext.rb +0 -11
- data/spec/deployer/base_spec.rb +0 -85
- data/spec/features/movefile_spec.rb +0 -59
- data/spec/fixtures/Movefile +0 -23
- data/spec/fixtures/wp-config.php +0 -90
- data/spec/spec_helper.rb +0 -22
- data/spec/sql_adapter_spec.rb +0 -163
data/bin/wordmove
DELETED
data/lib/wordmove/core_ext.rb
DELETED
data/spec/deployer/base_spec.rb
DELETED
@@ -1,85 +0,0 @@
|
|
1
|
-
require 'wordmove/deployer/base'
|
2
|
-
require 'tempfile'
|
3
|
-
|
4
|
-
describe Wordmove::Deployer::Base do
|
5
|
-
let(:klass) { Wordmove::Deployer::Base }
|
6
|
-
|
7
|
-
context "::fetch_movefile" do
|
8
|
-
TMPDIR = "/tmp/wordmove"
|
9
|
-
|
10
|
-
let(:path) { File.join(TMPDIR, 'Movefile') }
|
11
|
-
let(:yaml) { "name: Waldo\njob: Hider" }
|
12
|
-
|
13
|
-
before do
|
14
|
-
FileUtils.mkdir(TMPDIR)
|
15
|
-
klass.stub(:current_dir).and_return(TMPDIR)
|
16
|
-
klass.stub(:logger).and_return(double('logger').as_null_object)
|
17
|
-
end
|
18
|
-
|
19
|
-
after do
|
20
|
-
FileUtils.rm_rf(TMPDIR)
|
21
|
-
end
|
22
|
-
|
23
|
-
context "when Movefile is missing" do
|
24
|
-
it 'raises an exception' do
|
25
|
-
expect { klass.fetch_movefile }.to raise_error(StandardError)
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
context "when Movefile is present" do
|
30
|
-
before do
|
31
|
-
File.open(path, 'w') { |f| f.write(yaml) }
|
32
|
-
end
|
33
|
-
|
34
|
-
it 'finds a Movefile in current dir' do
|
35
|
-
result = klass.fetch_movefile
|
36
|
-
expect(result['name']).to eq('Waldo')
|
37
|
-
expect(result['job']).to eq('Hider')
|
38
|
-
end
|
39
|
-
|
40
|
-
context "when Movefile has extensions" do
|
41
|
-
let(:path) { File.join(TMPDIR, 'Movefile.yml') }
|
42
|
-
|
43
|
-
it 'finds it aswell' do
|
44
|
-
result = klass.fetch_movefile
|
45
|
-
expect(result['name']).to eq('Waldo')
|
46
|
-
expect(result['job']).to eq('Hider')
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
context "directories traversal" do
|
51
|
-
before do
|
52
|
-
@test_dir = File.join(TMPDIR, "test")
|
53
|
-
FileUtils.mkdir(@test_dir)
|
54
|
-
klass.stub(:current_dir).and_return(@test_dir)
|
55
|
-
end
|
56
|
-
|
57
|
-
it 'goes up through the directory tree and finds it' do
|
58
|
-
result = klass.fetch_movefile
|
59
|
-
expect(result['name']).to eq('Waldo')
|
60
|
-
expect(result['job']).to eq('Hider')
|
61
|
-
end
|
62
|
-
|
63
|
-
context 'Movefile not found, met root node' do
|
64
|
-
it 'raises an exception' do
|
65
|
-
klass.stub(:current_dir).and_return('/tmp')
|
66
|
-
expect { klass.fetch_movefile }.to raise_error(StandardError)
|
67
|
-
end
|
68
|
-
end
|
69
|
-
|
70
|
-
context 'Movefile not found, found wp-config.php' do
|
71
|
-
before do
|
72
|
-
FileUtils.touch(File.join(@test_dir, "wp-config.php"))
|
73
|
-
end
|
74
|
-
|
75
|
-
it 'raises an exception' do
|
76
|
-
expect { klass.fetch_movefile }.to raise_error(StandardError)
|
77
|
-
end
|
78
|
-
end
|
79
|
-
end
|
80
|
-
|
81
|
-
end
|
82
|
-
end
|
83
|
-
|
84
|
-
end
|
85
|
-
|
@@ -1,59 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'wordmove/generators/movefile'
|
3
|
-
|
4
|
-
describe Wordmove::Generators::Movefile do
|
5
|
-
|
6
|
-
let(:movefile) { 'Movefile' }
|
7
|
-
let(:tmpdir) { "/tmp/wordmove" }
|
8
|
-
|
9
|
-
before do
|
10
|
-
@pwd = Dir.pwd
|
11
|
-
FileUtils.mkdir(tmpdir)
|
12
|
-
Dir.chdir(tmpdir)
|
13
|
-
end
|
14
|
-
|
15
|
-
after do
|
16
|
-
Dir.chdir(@pwd)
|
17
|
-
FileUtils.rm_rf(tmpdir)
|
18
|
-
end
|
19
|
-
|
20
|
-
context "::start" do
|
21
|
-
before do
|
22
|
-
capture(:stdout) { Wordmove::Generators::Movefile.start }
|
23
|
-
end
|
24
|
-
|
25
|
-
it 'creates a Movefile' do
|
26
|
-
expect(File.exists?(movefile)).to be true
|
27
|
-
end
|
28
|
-
|
29
|
-
it 'fills local wordpress_path using shell path' do
|
30
|
-
yaml = YAML::load(File.open(movefile))
|
31
|
-
expect(yaml['local']['wordpress_path']).to eq(Dir.pwd)
|
32
|
-
end
|
33
|
-
|
34
|
-
it 'fills database configuration defaults' do
|
35
|
-
yaml = YAML::load(File.open(movefile))
|
36
|
-
expect(yaml['local']['database']['name']).to eq('database_name')
|
37
|
-
expect(yaml['local']['database']['user']).to eq('user')
|
38
|
-
expect(yaml['local']['database']['password']).to eq('password')
|
39
|
-
expect(yaml['local']['database']['host']).to eq('127.0.0.1')
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
context "database configuration" do
|
44
|
-
let(:wp_config) { File.join(File.dirname(__FILE__), "../fixtures/wp-config.php") }
|
45
|
-
|
46
|
-
before do
|
47
|
-
FileUtils.cp(wp_config, ".")
|
48
|
-
capture(:stdout) { Wordmove::Generators::Movefile.start }
|
49
|
-
end
|
50
|
-
|
51
|
-
it 'fills database configuration from wp-config' do
|
52
|
-
yaml = YAML::load(File.open(movefile))
|
53
|
-
expect(yaml['local']['database']['name']).to eq('wordmove_db')
|
54
|
-
expect(yaml['local']['database']['user']).to eq('wordmove_user')
|
55
|
-
expect(yaml['local']['database']['password']).to eq('wordmove_password')
|
56
|
-
expect(yaml['local']['database']['host']).to eq('wordmove_host')
|
57
|
-
end
|
58
|
-
end
|
59
|
-
end
|
data/spec/fixtures/Movefile
DELETED
@@ -1,23 +0,0 @@
|
|
1
|
-
local:
|
2
|
-
vhost: "http://vhost.local"
|
3
|
-
wordpress_path: "~/dev/sites/your_site"
|
4
|
-
database:
|
5
|
-
name: "database_name"
|
6
|
-
user: "user"
|
7
|
-
password: "password"
|
8
|
-
host: "host"
|
9
|
-
remote:
|
10
|
-
vhost: "http://example.com"
|
11
|
-
wordpress_path: "/var/www/your_site"
|
12
|
-
database:
|
13
|
-
name: "database_name"
|
14
|
-
user: "user"
|
15
|
-
password: "password"
|
16
|
-
host: "host"
|
17
|
-
ssh:
|
18
|
-
user: "user"
|
19
|
-
password: "password"
|
20
|
-
host: "host"
|
21
|
-
port: 30000
|
22
|
-
|
23
|
-
|
data/spec/fixtures/wp-config.php
DELETED
@@ -1,90 +0,0 @@
|
|
1
|
-
<?php
|
2
|
-
/**
|
3
|
-
* The base configurations of the WordPress.
|
4
|
-
*
|
5
|
-
* This file has the following configurations: MySQL settings, Table Prefix,
|
6
|
-
* Secret Keys, WordPress Language, and ABSPATH. You can find more information
|
7
|
-
* by visiting {@link http://codex.wordpress.org/Editing_wp-config.php Editing
|
8
|
-
* wp-config.php} Codex page. You can get the MySQL settings from your web host.
|
9
|
-
*
|
10
|
-
* This file is used by the wp-config.php creation script during the
|
11
|
-
* installation. You don't have to use the web site, you can just copy this file
|
12
|
-
* to "wp-config.php" and fill in the values.
|
13
|
-
*
|
14
|
-
* @package WordPress
|
15
|
-
*/
|
16
|
-
|
17
|
-
// ** MySQL settings - You can get this info from your web host ** //
|
18
|
-
/** The name of the database for WordPress */
|
19
|
-
define('DB_NAME', 'wordmove_db');
|
20
|
-
|
21
|
-
/** MySQL database username */
|
22
|
-
define('DB_USER', 'wordmove_user');
|
23
|
-
|
24
|
-
/** MySQL database password */
|
25
|
-
define('DB_PASSWORD', 'wordmove_password');
|
26
|
-
|
27
|
-
/** MySQL hostname */
|
28
|
-
define('DB_HOST', 'wordmove_host');
|
29
|
-
|
30
|
-
/** Database Charset to use in creating database tables. */
|
31
|
-
define('DB_CHARSET', 'utf8');
|
32
|
-
|
33
|
-
/** The Database Collate type. Don't change this if in doubt. */
|
34
|
-
define('DB_COLLATE', '');
|
35
|
-
|
36
|
-
/**#@+
|
37
|
-
* Authentication Unique Keys and Salts.
|
38
|
-
*
|
39
|
-
* Change these to different unique phrases!
|
40
|
-
* You can generate these using the {@link https://api.wordpress.org/secret-key/1.1/salt/ WordPress.org secret-key service}
|
41
|
-
* You can change these at any point in time to invalidate all existing cookies. This will force all users to have to log in again.
|
42
|
-
*
|
43
|
-
* @since 2.6.0
|
44
|
-
*/
|
45
|
-
define('AUTH_KEY', 'put your unique phrase here');
|
46
|
-
define('SECURE_AUTH_KEY', 'put your unique phrase here');
|
47
|
-
define('LOGGED_IN_KEY', 'put your unique phrase here');
|
48
|
-
define('NONCE_KEY', 'put your unique phrase here');
|
49
|
-
define('AUTH_SALT', 'put your unique phrase here');
|
50
|
-
define('SECURE_AUTH_SALT', 'put your unique phrase here');
|
51
|
-
define('LOGGED_IN_SALT', 'put your unique phrase here');
|
52
|
-
define('NONCE_SALT', 'put your unique phrase here');
|
53
|
-
|
54
|
-
/**#@-*/
|
55
|
-
|
56
|
-
/**
|
57
|
-
* WordPress Database Table prefix.
|
58
|
-
*
|
59
|
-
* You can have multiple installations in one database if you give each a unique
|
60
|
-
* prefix. Only numbers, letters, and underscores please!
|
61
|
-
*/
|
62
|
-
$table_prefix = 'wp_';
|
63
|
-
|
64
|
-
/**
|
65
|
-
* WordPress Localized Language, defaults to English.
|
66
|
-
*
|
67
|
-
* Change this to localize WordPress. A corresponding MO file for the chosen
|
68
|
-
* language must be installed to wp-content/languages. For example, install
|
69
|
-
* de_DE.mo to wp-content/languages and set WPLANG to 'de_DE' to enable German
|
70
|
-
* language support.
|
71
|
-
*/
|
72
|
-
define('WPLANG', '');
|
73
|
-
|
74
|
-
/**
|
75
|
-
* For developers: WordPress debugging mode.
|
76
|
-
*
|
77
|
-
* Change this to true to enable the display of notices during development.
|
78
|
-
* It is strongly recommended that plugin and theme developers use WP_DEBUG
|
79
|
-
* in their development environments.
|
80
|
-
*/
|
81
|
-
define('WP_DEBUG', false);
|
82
|
-
|
83
|
-
/* That's all, stop editing! Happy blogging. */
|
84
|
-
|
85
|
-
/** Absolute path to the WordPress directory. */
|
86
|
-
if ( !defined('ABSPATH') )
|
87
|
-
define('ABSPATH', dirname(__FILE__) . '/');
|
88
|
-
|
89
|
-
/** Sets up WordPress vars and included files. */
|
90
|
-
require_once(ABSPATH . 'wp-settings.php');
|
data/spec/spec_helper.rb
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
require 'rubygems'
|
2
|
-
require 'bundler/setup'
|
3
|
-
|
4
|
-
require 'wordmove' # and any other gems you need
|
5
|
-
require 'wordmove/logger'
|
6
|
-
require 'active_support/core_ext'
|
7
|
-
require 'thor'
|
8
|
-
|
9
|
-
RSpec.configure do |config|
|
10
|
-
def capture(stream)
|
11
|
-
begin
|
12
|
-
stream = stream.to_s
|
13
|
-
eval "$#{stream} = StringIO.new"
|
14
|
-
yield
|
15
|
-
result = eval("$#{stream}").string
|
16
|
-
ensure
|
17
|
-
eval("$#{stream} = #{stream.upcase}")
|
18
|
-
end
|
19
|
-
|
20
|
-
result
|
21
|
-
end
|
22
|
-
end
|
data/spec/sql_adapter_spec.rb
DELETED
@@ -1,163 +0,0 @@
|
|
1
|
-
require 'wordmove/sql_adapter'
|
2
|
-
require 'tempfile'
|
3
|
-
|
4
|
-
describe Wordmove::SqlAdapter do
|
5
|
-
|
6
|
-
let(:sql_path) { double }
|
7
|
-
let(:source_config) { double }
|
8
|
-
let(:dest_config) { double }
|
9
|
-
let(:adapter) {
|
10
|
-
Wordmove::SqlAdapter.new(
|
11
|
-
sql_path,
|
12
|
-
source_config,
|
13
|
-
dest_config
|
14
|
-
)
|
15
|
-
}
|
16
|
-
|
17
|
-
context ".initialize" do
|
18
|
-
it "should assign variables correctly on initialization" do
|
19
|
-
adapter.sql_path.should == sql_path
|
20
|
-
adapter.source_config.should == source_config
|
21
|
-
adapter.dest_config.should == dest_config
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
context ".sql_content" do
|
26
|
-
let(:sql) do
|
27
|
-
Tempfile.new('sql').tap { |d| d.write('DUMP'); d.close }
|
28
|
-
end
|
29
|
-
let(:sql_path) { sql.path }
|
30
|
-
|
31
|
-
it "should read the sql file content" do
|
32
|
-
adapter.sql_content.should == 'DUMP'
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
context ".adapt!" do
|
37
|
-
it "should replace host, path and write to sql" do
|
38
|
-
adapter.should_receive(:replace_vhost!).and_return(true)
|
39
|
-
adapter.should_receive(:replace_wordpress_path!).and_return(true)
|
40
|
-
adapter.should_receive(:write_sql!).and_return(true)
|
41
|
-
adapter.adapt!
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
describe "replace single fields" do
|
46
|
-
context ".replace_vhost!" do
|
47
|
-
let(:source_config) do { :vhost => "DUMP" } end
|
48
|
-
let(:dest_config) do { :vhost => "FUNK" } end
|
49
|
-
|
50
|
-
it "should replace source vhost with dest vhost" do
|
51
|
-
adapter.should_receive(:replace_field!).with("DUMP", "FUNK").and_return(true)
|
52
|
-
adapter.replace_vhost!
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
context ".replace_wordpress_path!" do
|
57
|
-
let(:source_config) do { :wordpress_path => "DUMP" } end
|
58
|
-
let(:dest_config) do { :wordpress_path => "FUNK" } end
|
59
|
-
|
60
|
-
it "should replace source vhost with dest wordpress paths" do
|
61
|
-
adapter.should_receive(:replace_field!).with("DUMP", "FUNK").and_return(true)
|
62
|
-
adapter.replace_wordpress_path!
|
63
|
-
end
|
64
|
-
|
65
|
-
context "given an absolute path" do
|
66
|
-
let(:source_config) do { :wordpress_absolute_path => "ABSOLUTE_DUMP", :wordpress_path => "DUMP" } end
|
67
|
-
|
68
|
-
it "should replace the absolute path instead" do
|
69
|
-
adapter.should_receive(:replace_field!).with("ABSOLUTE_DUMP", "FUNK").and_return(true)
|
70
|
-
adapter.replace_wordpress_path!
|
71
|
-
end
|
72
|
-
end
|
73
|
-
end
|
74
|
-
end
|
75
|
-
|
76
|
-
context ".replace_field!" do
|
77
|
-
it "should replace source vhost with dest vhost" do
|
78
|
-
adapter.should_receive(:serialized_replace!).ordered.with("DUMP", "FUNK").and_return(true)
|
79
|
-
adapter.should_receive(:simple_replace!).ordered.with("DUMP", "FUNK").and_return(true)
|
80
|
-
adapter.replace_field!("DUMP", "FUNK")
|
81
|
-
end
|
82
|
-
end
|
83
|
-
|
84
|
-
context ".serialized_replace!" do
|
85
|
-
let(:content) { 'a:3:{i:0;s:20:"http://dump.com/spam";i:1;s:6:"foobar";i:2;s:22:"http://dump.com/foobar";}' }
|
86
|
-
let(:sql) { Tempfile.new('sql').tap do |d| d.write(content); d.close end }
|
87
|
-
let(:sql_path) { sql.path }
|
88
|
-
|
89
|
-
it "should replace source vhost with dest vhost" do
|
90
|
-
adapter.serialized_replace!('http://dump.com', 'http://shrubbery.com')
|
91
|
-
adapter.sql_content.should == 'a:3:{i:0;s:25:"http://shrubbery.com/spam";i:1;s:6:"foobar";i:2;s:27:"http://shrubbery.com/foobar";}'
|
92
|
-
end
|
93
|
-
|
94
|
-
context "given empty strings" do
|
95
|
-
let(:content) { 's:0:"";s:3:"foo";s:0:"";' }
|
96
|
-
|
97
|
-
it "should leave them untouched" do
|
98
|
-
adapter.serialized_replace!('foo', 'sausage')
|
99
|
-
adapter.sql_content.should == 's:0:"";s:7:"sausage";s:0:"";'
|
100
|
-
end
|
101
|
-
|
102
|
-
context "considering escaping" do
|
103
|
-
let(:content) { 's:0:\"\";s:3:\"foo\";s:0:\"\";' }
|
104
|
-
|
105
|
-
it "should leave them untouched" do
|
106
|
-
adapter.serialized_replace!('foo', 'sausage')
|
107
|
-
adapter.sql_content.should == 's:0:\"\";s:7:\"sausage\";s:0:\"\";'
|
108
|
-
end
|
109
|
-
end
|
110
|
-
end
|
111
|
-
|
112
|
-
context "given strings with escaped content" do
|
113
|
-
let(:content) { 's:6:"dump\"\"";' }
|
114
|
-
|
115
|
-
it "should calculate the correct final length" do
|
116
|
-
adapter.serialized_replace!('dump', 'sausage')
|
117
|
-
adapter.sql_content.should == 's:9:"sausage\"\"";'
|
118
|
-
end
|
119
|
-
end
|
120
|
-
|
121
|
-
context "given multiple types of string quoting" do
|
122
|
-
let(:content) { "a:3:{s:20:\\\"http://dump.com/spam\\\";s:6:'foobar';s:22:'http://dump.com/foobar';s:8:'sausages';}" }
|
123
|
-
|
124
|
-
it "should handle replacing just as well" do
|
125
|
-
adapter.serialized_replace!('http://dump.com', 'http://shrubbery.com')
|
126
|
-
adapter.sql_content.should == "a:3:{s:25:\\\"http://shrubbery.com/spam\\\";s:6:'foobar';s:27:'http://shrubbery.com/foobar';s:8:'sausages';}"
|
127
|
-
end
|
128
|
-
end
|
129
|
-
|
130
|
-
context "given multiple occurences in the same string" do
|
131
|
-
let(:content) { 'a:1:{i:0;s:52:"ni http://dump.com/spam ni http://dump.com/foobar ni";}' }
|
132
|
-
|
133
|
-
it "should replace all occurences" do
|
134
|
-
adapter.serialized_replace!('http://dump.com', 'http://shrubbery.com')
|
135
|
-
adapter.sql_content.should == 'a:1:{i:0;s:62:"ni http://shrubbery.com/spam ni http://shrubbery.com/foobar ni";}'
|
136
|
-
end
|
137
|
-
end
|
138
|
-
end
|
139
|
-
|
140
|
-
context ".simple_replace!" do
|
141
|
-
let(:content) { "THE DUMP!" }
|
142
|
-
let(:sql) { Tempfile.new('sql').tap do |d| d.write(content); d.close end }
|
143
|
-
let(:sql_path) { sql.path }
|
144
|
-
|
145
|
-
it "should replace source vhost with dest vhost" do
|
146
|
-
adapter.simple_replace!("DUMP", "FUNK")
|
147
|
-
adapter.sql_content.should == "THE FUNK!"
|
148
|
-
end
|
149
|
-
end
|
150
|
-
|
151
|
-
context ".write_sql!" do
|
152
|
-
let(:content) { "THE DUMP!" }
|
153
|
-
let(:sql) { Tempfile.new('sql').tap do |d| d.write(content); d.close end }
|
154
|
-
let(:sql_path) { sql.path }
|
155
|
-
let(:the_funk) { "THE FUNK THE FUNK THE FUNK" }
|
156
|
-
|
157
|
-
it "should write content to file" do
|
158
|
-
adapter.sql_content = the_funk
|
159
|
-
adapter.write_sql!
|
160
|
-
File.open(sql_path).read == the_funk
|
161
|
-
end
|
162
|
-
end
|
163
|
-
end
|