wordmove 2.2.1 → 2.3.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 577d35dd76f61badf9aab6f288a1c74484ab05a6
4
- data.tar.gz: e3004bdca2c5729cf59e6c3eb67570fac3667f72
3
+ metadata.gz: 74eb302bd31e07710d405885e8a6bdcc5a038334
4
+ data.tar.gz: db2cd9c305231c49d29d7f907f4e98020a3f3f5a
5
5
  SHA512:
6
- metadata.gz: 8f536d8bac4d2cbc28c13ff57c3b03c09bfd7a91da74760e87b88c8ae7dc60d802e19b9b1605368cd1a1e3a7f2a13d811ab298811556b4f133556d9339321d80
7
- data.tar.gz: 28cb7165326c66e7143d95a60859cda54f947eb6f4d8130607a347d1697aec8808aa3da12d9fccb3e30a716480b06fcd34a7b943452cb847cbfc0cea2e2231d8
6
+ metadata.gz: 36c47235b3f558e184e1650d02f79c6dee5d5da9f177fea5fb9a21f3594bfcba12d6ec9685132586505ba12d6c55d4c9ae6a9442374e6bc861fce04653a815e6
7
+ data.tar.gz: b6df4544d36d308d53c3b38fa129206b1d774be301154ea1440f6aac9739bb4d5d7dc50dc5cd26b1b61cf6a0bf5d12dc45be2aa8aac48b665c50dceb237b4e86
data/.rubocop.yml CHANGED
@@ -5,7 +5,7 @@ Rails/Output:
5
5
  Enabled: false
6
6
 
7
7
  AllCops:
8
- TargetRubyVersion: 2.2
8
+ TargetRubyVersion: 2.4
9
9
  DisplayCopNames: true
10
10
  DisplayStyleGuide: true
11
11
 
data/README.mdown CHANGED
@@ -39,11 +39,13 @@ Wordmove just acts as automation glue bewtween tools you already have and love.
39
39
 
40
40
  ```
41
41
  > wordmove help
42
- Tasks:
43
- wordmove help [TASK] # Describe available tasks or one specific task
44
- wordmove init # Generates a brand new movefile.yml
45
- wordmove pull # Pulls WP data from remote host to the local machine
46
- wordmove push # Pushes WP data from local machine to remote host
42
+ Commands:
43
+ wordmove --version, -v # Print the version
44
+ wordmove doctor # Do some local configuration and environment checks
45
+ wordmove help [TASK] # Describe available tasks or one specific task
46
+ wordmove init # Generates a brand new movefile.yml
47
+ wordmove pull # Pulls WP data from remote host to the local machine
48
+ wordmove push # Pushes WP data from local machine to remote host
47
49
  ```
48
50
 
49
51
  Move inside the Wordpress folder and use `wordmove init` to generate a new `movefile.yml` and edit it with your settings. Read the next paragraph for more info.
@@ -194,7 +196,7 @@ made with ❤️ and ☕️ by [weLaika](http://dev.welaika.com)
194
196
 
195
197
  (The MIT License)
196
198
 
197
- Copyright © 2013-2015 weLaika
199
+ Copyright © 2013-2018 weLaika
198
200
 
199
201
  Permission is hereby granted, free of charge, to any person obtaining a copy of
200
202
  this software and associated documentation files (the ‘Software’), to deal in
data/bin/bundler ADDED
@@ -0,0 +1,17 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+ #
4
+ # This file was generated by Bundler.
5
+ #
6
+ # The application 'bundler' is installed as part of a gem, and
7
+ # this file is here to facilitate running it.
8
+ #
9
+
10
+ require "pathname"
11
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
12
+ Pathname.new(__FILE__).realpath)
13
+
14
+ require "rubygems"
15
+ require "bundler/setup"
16
+
17
+ load Gem.bin_path("bundler", "bundler")
data/bin/byebug ADDED
@@ -0,0 +1,17 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+ #
4
+ # This file was generated by Bundler.
5
+ #
6
+ # The application 'byebug' is installed as part of a gem, and
7
+ # this file is here to facilitate running it.
8
+ #
9
+
10
+ require "pathname"
11
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
12
+ Pathname.new(__FILE__).realpath)
13
+
14
+ require "rubygems"
15
+ require "bundler/setup"
16
+
17
+ load Gem.bin_path("byebug", "byebug")
data/bin/coderay ADDED
@@ -0,0 +1,17 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+ #
4
+ # This file was generated by Bundler.
5
+ #
6
+ # The application 'coderay' is installed as part of a gem, and
7
+ # this file is here to facilitate running it.
8
+ #
9
+
10
+ require "pathname"
11
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
12
+ Pathname.new(__FILE__).realpath)
13
+
14
+ require "rubygems"
15
+ require "bundler/setup"
16
+
17
+ load Gem.bin_path("coderay", "coderay")
data/bin/htmldiff ADDED
@@ -0,0 +1,17 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+ #
4
+ # This file was generated by Bundler.
5
+ #
6
+ # The application 'htmldiff' is installed as part of a gem, and
7
+ # this file is here to facilitate running it.
8
+ #
9
+
10
+ require "pathname"
11
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
12
+ Pathname.new(__FILE__).realpath)
13
+
14
+ require "rubygems"
15
+ require "bundler/setup"
16
+
17
+ load Gem.bin_path("diff-lcs", "htmldiff")
data/bin/kwalify ADDED
@@ -0,0 +1,17 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+ #
4
+ # This file was generated by Bundler.
5
+ #
6
+ # The application 'kwalify' is installed as part of a gem, and
7
+ # this file is here to facilitate running it.
8
+ #
9
+
10
+ require "pathname"
11
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
12
+ Pathname.new(__FILE__).realpath)
13
+
14
+ require "rubygems"
15
+ require "bundler/setup"
16
+
17
+ load Gem.bin_path("kwalify", "kwalify")
data/bin/ldiff ADDED
@@ -0,0 +1,17 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+ #
4
+ # This file was generated by Bundler.
5
+ #
6
+ # The application 'ldiff' is installed as part of a gem, and
7
+ # this file is here to facilitate running it.
8
+ #
9
+
10
+ require "pathname"
11
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
12
+ Pathname.new(__FILE__).realpath)
13
+
14
+ require "rubygems"
15
+ require "bundler/setup"
16
+
17
+ load Gem.bin_path("diff-lcs", "ldiff")
data/bin/pry ADDED
@@ -0,0 +1,17 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+ #
4
+ # This file was generated by Bundler.
5
+ #
6
+ # The application 'pry' is installed as part of a gem, and
7
+ # this file is here to facilitate running it.
8
+ #
9
+
10
+ require "pathname"
11
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
12
+ Pathname.new(__FILE__).realpath)
13
+
14
+ require "rubygems"
15
+ require "bundler/setup"
16
+
17
+ load Gem.bin_path("pry", "pry")
data/bin/rubocop ADDED
@@ -0,0 +1,17 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+ #
4
+ # This file was generated by Bundler.
5
+ #
6
+ # The application 'rubocop' is installed as part of a gem, and
7
+ # this file is here to facilitate running it.
8
+ #
9
+
10
+ require "pathname"
11
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
12
+ Pathname.new(__FILE__).realpath)
13
+
14
+ require "rubygems"
15
+ require "bundler/setup"
16
+
17
+ load Gem.bin_path("rubocop", "rubocop")
data/bin/ruby-parse ADDED
@@ -0,0 +1,17 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+ #
4
+ # This file was generated by Bundler.
5
+ #
6
+ # The application 'ruby-parse' is installed as part of a gem, and
7
+ # this file is here to facilitate running it.
8
+ #
9
+
10
+ require "pathname"
11
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
12
+ Pathname.new(__FILE__).realpath)
13
+
14
+ require "rubygems"
15
+ require "bundler/setup"
16
+
17
+ load Gem.bin_path("parser", "ruby-parse")
data/bin/ruby-rewrite ADDED
@@ -0,0 +1,17 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+ #
4
+ # This file was generated by Bundler.
5
+ #
6
+ # The application 'ruby-rewrite' is installed as part of a gem, and
7
+ # this file is here to facilitate running it.
8
+ #
9
+
10
+ require "pathname"
11
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
12
+ Pathname.new(__FILE__).realpath)
13
+
14
+ require "rubygems"
15
+ require "bundler/setup"
16
+
17
+ load Gem.bin_path("parser", "ruby-rewrite")
data/bin/rumoji ADDED
@@ -0,0 +1,17 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+ #
4
+ # This file was generated by Bundler.
5
+ #
6
+ # The application 'rumoji' is installed as part of a gem, and
7
+ # this file is here to facilitate running it.
8
+ #
9
+
10
+ require "pathname"
11
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
12
+ Pathname.new(__FILE__).realpath)
13
+
14
+ require "rubygems"
15
+ require "bundler/setup"
16
+
17
+ load Gem.bin_path("rumoji", "rumoji")
data/bin/thor ADDED
@@ -0,0 +1,17 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+ #
4
+ # This file was generated by Bundler.
5
+ #
6
+ # The application 'thor' is installed as part of a gem, and
7
+ # this file is here to facilitate running it.
8
+ #
9
+
10
+ require "pathname"
11
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
12
+ Pathname.new(__FILE__).realpath)
13
+
14
+ require "rubygems"
15
+ require "bundler/setup"
16
+
17
+ load Gem.bin_path("thor", "thor")
data/bin/wordmove ADDED
@@ -0,0 +1,17 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+ #
4
+ # This file was generated by Bundler.
5
+ #
6
+ # The application 'wordmove' is installed as part of a gem, and
7
+ # this file is here to facilitate running it.
8
+ #
9
+
10
+ require "pathname"
11
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
12
+ Pathname.new(__FILE__).realpath)
13
+
14
+ require "rubygems"
15
+ require "bundler/setup"
16
+
17
+ load Gem.bin_path("wordmove", "wordmove")
data/lib/wordmove.rb CHANGED
@@ -10,12 +10,20 @@ require 'erb'
10
10
  require 'open-uri'
11
11
  require 'active_support'
12
12
  require 'active_support/core_ext'
13
+ require 'kwalify'
13
14
 
14
15
  require 'photocopier'
15
16
 
16
17
  require 'wordmove/exceptions'
17
18
  require 'wordmove/cli'
19
+ require 'wordmove/doctor'
20
+ require 'wordmove/doctor/movefile'
21
+ require 'wordmove/doctor/mysql'
22
+ require 'wordmove/doctor/wpcli'
23
+ require 'wordmove/doctor/rsync'
24
+ require 'wordmove/doctor/ssh'
18
25
  require 'wordmove/logger'
26
+ require 'wordmove/movefile'
19
27
  require 'wordmove/sql_adapter/default'
20
28
  require 'wordmove/sql_adapter/wpcli'
21
29
  require "wordmove/version"
@@ -0,0 +1,4 @@
1
+ type: map
2
+ mapping:
3
+ sql_adapter:
4
+ required: true
@@ -0,0 +1,22 @@
1
+ type: map
2
+ mapping:
3
+ vhost:
4
+ pattern: /^http:\/\//
5
+ wordpress_path:
6
+ database:
7
+ type: map
8
+ mapping:
9
+ name:
10
+ required: true
11
+ user:
12
+ required: true
13
+ password:
14
+ required: true
15
+ host:
16
+ required: true
17
+ mysqldump_options:
18
+ required: false
19
+ port:
20
+ required: false
21
+ charset:
22
+ required: false
@@ -0,0 +1,88 @@
1
+ type: map
2
+ mapping:
3
+ vhost:
4
+ type: str
5
+ pattern: /^http:\/\//
6
+ required: true
7
+ wordpress_path:
8
+ type: str
9
+ required: true
10
+ wordpress_absolute_path:
11
+ type: str
12
+ required: false
13
+ database:
14
+ type: map
15
+ required: true
16
+ mapping:
17
+ name:
18
+ type: str
19
+ required: true
20
+ user:
21
+ type: str
22
+ required: true
23
+ password:
24
+ type: str
25
+ required: true
26
+ host:
27
+ type: str
28
+ required: true
29
+ mysqldump_options:
30
+ type: str
31
+ required: false
32
+ port:
33
+ type: str
34
+ required: false
35
+ charset:
36
+ type: str
37
+ required: false
38
+ exclude:
39
+ type: seq
40
+ required: false
41
+ sequence:
42
+ - type: str
43
+ paths:
44
+ type: map
45
+ required: false
46
+ mapping:
47
+ wp_content:
48
+ wp_config:
49
+ uploads:
50
+ plugins:
51
+ mu_plugins:
52
+ themes:
53
+ languages:
54
+ ssh:
55
+ type: map
56
+ required: false
57
+ mapping:
58
+ host:
59
+ required: true
60
+ user:
61
+ required: false # If host is configured in ~/.ssh/config
62
+ password:
63
+ required: false
64
+ port:
65
+ type: int
66
+ rsync_options:
67
+ gateway:
68
+ type: map
69
+ required: false
70
+ mapping:
71
+ host:
72
+ required: true
73
+ user:
74
+ required: true
75
+ password:
76
+ ftp:
77
+ type: map
78
+ required: false
79
+ mapping:
80
+ user:
81
+ required: true
82
+ password:
83
+ required: true
84
+ host:
85
+ required: true
86
+ passive:
87
+ type: bool
88
+ scheme:
data/lib/wordmove/cli.rb CHANGED
@@ -12,6 +12,11 @@ module Wordmove
12
12
  Wordmove::Generators::Movefile.start
13
13
  end
14
14
 
15
+ desc "doctor", "Do some local configuration and environment checks"
16
+ def doctor
17
+ Wordmove::Doctor.start
18
+ end
19
+
15
20
  shared_options = {
16
21
  wordpress: { aliases: "-w", type: :boolean },
17
22
  uploads: { aliases: "-u", type: :boolean },
@@ -37,34 +37,14 @@ module Wordmove
37
37
  end
38
38
 
39
39
  def fetch_movefile(name = nil, start_dir = current_dir)
40
- entries = if name.nil?
41
- Dir["#{File.join(start_dir, '{M,m}ovefile')}{,.yml,.yaml}"]
42
- else
43
- Dir["#{File.join(start_dir, name)}{,.yml,.yaml}"]
44
- end
45
-
46
- if entries.empty?
47
- raise MovefileNotFound, "Could not find a valid Movefile" if last_dir?(start_dir)
48
- return fetch_movefile(name, upper_dir(start_dir))
49
- end
50
-
51
- found = entries.first
52
- logger.task("Using Movefile: #{found}")
53
- YAML.safe_load(ERB.new(File.read(found)).result, [], [], true)
40
+ movefile = Wordmove::Movefile.new
41
+ movefile.fetch name, start_dir
54
42
  end
55
43
 
56
44
  def current_dir
57
45
  '.'
58
46
  end
59
47
 
60
- def last_dir?(directory)
61
- directory == "/" || File.exist?(File.join(directory, 'wp-config.php'))
62
- end
63
-
64
- def upper_dir(directory)
65
- File.expand_path(File.join(directory, '..'))
66
- end
67
-
68
48
  def logger
69
49
  Logger.new(STDOUT).tap { |l| l.level = Logger::DEBUG }
70
50
  end
@@ -0,0 +1,68 @@
1
+ module Wordmove
2
+ class Doctor
3
+ def self.start
4
+ banner
5
+ movefile
6
+ mysql
7
+ wpcli
8
+ rsync
9
+ ssh
10
+ end
11
+
12
+ def self.movefile
13
+ movefile_doctor = Wordmove::Doctor::Movefile.new
14
+ movefile_doctor.validate!
15
+ end
16
+
17
+ def self.mysql
18
+ mysql_doctor = Wordmove::Doctor::Mysql.new
19
+ mysql_doctor.check!
20
+ end
21
+
22
+ def self.wpcli
23
+ wpcli_doctor = Wordmove::Doctor::Wpcli.new
24
+ wpcli_doctor.check!
25
+ end
26
+
27
+ def self.rsync
28
+ rsync_doctor = Wordmove::Doctor::Rsync.new
29
+ rsync_doctor.check!
30
+ end
31
+
32
+ def self.ssh
33
+ ssh_doctor = Wordmove::Doctor::Ssh.new
34
+ ssh_doctor.check!
35
+ end
36
+
37
+ # rubocop:disable Metrics/MethodLength
38
+ def self.banner
39
+ paint = <<-'ASCII'
40
+ .------------------------.
41
+ | PSYCHIATRIC |
42
+ | HELP 5¢ |
43
+ |________________________|
44
+ || .-"""--. ||
45
+ || / \.-. ||
46
+ || | ._, \ ||
47
+ || \_/`-' '-.,_/ ||
48
+ || (_ (' _)') \ ||
49
+ || /| |\ ||
50
+ || | \ __ / | ||
51
+ || \_).,_____,/}/ ||
52
+ __||____;_--'___'/ ( ||
53
+ |\ || (__,\\ \_/------||
54
+ ||\||______________________||
55
+ |||| |
56
+ |||| THE DOCTOR |
57
+ \||| IS [IN] _____|
58
+ \|| (______)
59
+ `|___________________//||\\
60
+ //=||=\\
61
+ ` `` `
62
+ ASCII
63
+
64
+ puts paint
65
+ end
66
+ # rubocop:enable Metrics/MethodLength
67
+ end
68
+ end
@@ -0,0 +1,80 @@
1
+ module Wordmove
2
+ class Doctor
3
+ class Movefile
4
+ MANDATORY_SECTIONS = %w[global local].freeze
5
+ attr_reader :movefile, :contents, :root_keys
6
+
7
+ def initialize(name = nil, dir = '.')
8
+ @movefile = Wordmove::Movefile.new
9
+ @contents = movefile.fetch(name, dir)
10
+ @root_keys = contents.keys
11
+ end
12
+
13
+ def validate!
14
+ MANDATORY_SECTIONS.each do |key|
15
+ movefile.logger.task "Validating movefile section: #{key}"
16
+ validate_mandatory_section(key)
17
+ end
18
+
19
+ root_keys.each do |remote|
20
+ movefile.logger.task "Validating movefile section: #{remote}"
21
+ validate_remote_section(remote)
22
+ end
23
+ end
24
+
25
+ private
26
+
27
+ def validate_section(key)
28
+ validator = validator_for(key)
29
+
30
+ errors = validator.validate(contents[key])
31
+
32
+ if errors&.empty?
33
+ movefile.logger.success "Formal validation passed"
34
+
35
+ return true
36
+ end
37
+
38
+ errors.each do |e|
39
+ movefile.logger.error "[#{e.path}] #{e.message}"
40
+ end
41
+ end
42
+
43
+ def validate_mandatory_section(key)
44
+ return false unless root_keys.delete(key) do
45
+ movefile.logger.error "#{key} section not present"
46
+
47
+ false
48
+ end
49
+
50
+ validate_section(key)
51
+ end
52
+
53
+ def validate_remote_section(key)
54
+ return false unless validate_protocol_presence(contents[key].keys)
55
+
56
+ validate_section(key)
57
+ end
58
+
59
+ def validate_protocol_presence(keys)
60
+ return true if keys.include?('ssh') || keys.include?('ftp')
61
+
62
+ movefile.logger.error "This remote has not ssh nor ftp protocol defined"
63
+
64
+ false
65
+ end
66
+
67
+ def validator_for(key)
68
+ suffix = if MANDATORY_SECTIONS.include? key
69
+ key
70
+ else
71
+ 'remote'
72
+ end
73
+
74
+ schema = Kwalify::Yaml.load_file("#{__dir__}/../assets/wordmove_schema_#{suffix}.yml")
75
+
76
+ Kwalify::Validator.new(schema)
77
+ end
78
+ end
79
+ end
80
+ end
@@ -0,0 +1,61 @@
1
+ module Wordmove
2
+ class Doctor
3
+ class Mysql
4
+ attr_reader :config, :logger
5
+
6
+ def initialize(movefile_name = nil, movefile_dir = '.')
7
+ @config = Wordmove::Movefile.new.fetch(movefile_name, movefile_dir)["local"]["database"]
8
+ @logger = Logger.new(STDOUT).tap { |l| l.level = Logger::INFO }
9
+ end
10
+
11
+ def check!
12
+ logger.task "Checking local database commands and connection"
13
+
14
+ mysql_client_doctor
15
+ mysqldump_doctor
16
+ mysql_server_doctor
17
+ end
18
+
19
+ private
20
+
21
+ def mysql_client_doctor
22
+ if system("which mysql", out: File::NULL)
23
+ logger.success "`mysql` command is in $PATH"
24
+ else
25
+ logger.error "`mysql` command is not in $PATH"
26
+ end
27
+ end
28
+
29
+ def mysqldump_doctor
30
+ if system("which mysqldump", out: File::NULL)
31
+ logger.success "`mysqldump` command is in $PATH"
32
+ else
33
+ logger.error "`mysqldump` command is not in $PATH"
34
+ end
35
+ end
36
+
37
+ def mysql_server_doctor
38
+ command = ["mysql"]
39
+ command << "-u #{config['user']}"
40
+ command << "-p#{config['password']}" unless config['password'].blank?
41
+ command << "-h #{config['host']}"
42
+ command << "-e'QUIT'"
43
+ command = command.join(" ")
44
+
45
+ if system(command, out: File::NULL, err: File::NULL)
46
+ logger.success "Successfully connected to the database"
47
+ else
48
+ logger.error <<~LONG
49
+ We can't connect to the database using credentials
50
+ specified in the Movefile. Double check them or try
51
+ to debug your system configuration.
52
+
53
+ The command used to test was:
54
+
55
+ #{command}
56
+ LONG
57
+ end
58
+ end
59
+ end
60
+ end
61
+ end
@@ -0,0 +1,21 @@
1
+ module Wordmove
2
+ class Doctor
3
+ class Rsync
4
+ attr_reader :logger
5
+
6
+ def initialize
7
+ @logger = Logger.new(STDOUT).tap { |l| l.level = Logger::INFO }
8
+ end
9
+
10
+ def check!
11
+ logger.task "Checking rsync"
12
+
13
+ if (version = /\d\.\d.\d/.match(`rsync --version | head -n1`)[0])
14
+ logger.success "rsync is installed at version #{version}"
15
+ else
16
+ logger.error "rsync not found. And belive me: it's really strange it's not there."
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,21 @@
1
+ module Wordmove
2
+ class Doctor
3
+ class Ssh
4
+ attr_reader :logger
5
+
6
+ def initialize
7
+ @logger = Logger.new(STDOUT).tap { |l| l.level = Logger::INFO }
8
+ end
9
+
10
+ def check!
11
+ logger.task "Checking SSH client"
12
+
13
+ if system('which ssh', out: File::NULL, err: File::NULL)
14
+ logger.success "SSH command found"
15
+ else
16
+ logger.error "SSH command not found. And belive me: it's really strange it's not there."
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,21 @@
1
+ module Wordmove
2
+ class Doctor
3
+ class Wpcli
4
+ attr_reader :logger
5
+
6
+ def initialize
7
+ @logger = Logger.new(STDOUT).tap { |l| l.level = Logger::INFO }
8
+ end
9
+
10
+ def check!
11
+ logger.task "Checking local wp-cli installation"
12
+
13
+ if system('wp cli check-update --quiet')
14
+ logger.success "wp-cli is correctly installed and up to date"
15
+ else
16
+ logger.error "wp-cli is not installed (or not in your $PATH) or not up to date"
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
@@ -22,6 +22,10 @@ module Wordmove
22
22
  puts " error".red + " | ".black + message.to_s
23
23
  end
24
24
 
25
+ def success(message)
26
+ puts " success".green + " | ".black + message.to_s
27
+ end
28
+
25
29
  def debug(message)
26
30
  puts " debug".magenta + " | ".black + message.to_s
27
31
  end
@@ -30,7 +34,7 @@ module Wordmove
30
34
 
31
35
  def padding_length(line)
32
36
  result = MAX_LINE - line.length
33
- result > 0 ? result : 0
37
+ result.positive? ? result : 0
34
38
  end
35
39
  end
36
40
  end
@@ -0,0 +1,40 @@
1
+ module Wordmove
2
+ class Movefile
3
+ attr_reader :logger
4
+
5
+ def initialize
6
+ @logger = Logger.new(STDOUT).tap { |l| l.level = Logger::DEBUG }
7
+ end
8
+
9
+ def fetch(name = nil, start_dir = current_dir)
10
+ entries = if name.nil?
11
+ Dir["#{File.join(start_dir, '{M,m}ovefile')}{,.yml,.yaml}"]
12
+ else
13
+ Dir["#{File.join(start_dir, name)}{,.yml,.yaml}"]
14
+ end
15
+
16
+ if entries.empty?
17
+ raise MovefileNotFound, "Could not find a valid Movefile" if last_dir?(start_dir)
18
+ return fetch(name, upper_dir(start_dir))
19
+ end
20
+
21
+ found = entries.first
22
+ logger.task("Using Movefile: #{found}")
23
+ YAML.safe_load(ERB.new(File.read(found)).result, [], [], true)
24
+ end
25
+
26
+ private
27
+
28
+ def last_dir?(directory)
29
+ directory == "/" || File.exist?(File.join(directory, 'wp-config.php'))
30
+ end
31
+
32
+ def upper_dir(directory)
33
+ File.expand_path(File.join(directory, '..'))
34
+ end
35
+
36
+ def current_dir
37
+ '.'
38
+ end
39
+ end
40
+ end
@@ -1,7 +1,7 @@
1
1
  module Wordmove
2
2
  module SqlAdapter
3
3
  class Default
4
- attr_accessor :sql_content
4
+ attr_writer :sql_content
5
5
  attr_reader :sql_path, :source_config, :dest_config
6
6
 
7
7
  def initialize(sql_path, source_config, dest_config)
@@ -1,3 +1,3 @@
1
1
  module Wordmove
2
- VERSION = "2.2.1".freeze
2
+ VERSION = "2.3.0".freeze
3
3
  end
data/wordmove.gemspec CHANGED
@@ -29,20 +29,21 @@ Gem::Specification.new do |spec|
29
29
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
30
30
  spec.require_paths = ["lib"]
31
31
 
32
- spec.add_runtime_dependency "colorize", "~> 0.8.1"
33
- spec.add_runtime_dependency "thor", "~> 0.19.4"
34
32
  spec.add_runtime_dependency "activesupport", '~> 5.1', '>= 5.1.1'
33
+ spec.add_runtime_dependency "colorize", "~> 0.8.1"
34
+ spec.add_runtime_dependency "kwalify", "~> 0"
35
35
  spec.add_runtime_dependency "photocopier", "~> 1.1", ">= 1.1.3"
36
+ spec.add_runtime_dependency "thor", "~> 0.19.4"
36
37
 
37
38
  spec.required_ruby_version = "~> 2.4.0"
38
39
 
39
40
  spec.add_development_dependency "bundler", "~> 1.14", ">= 1.14.6"
41
+ spec.add_development_dependency "priscilla", "~> 1.0"
42
+ spec.add_development_dependency "pry-byebug", "~> 3.1"
40
43
  spec.add_development_dependency "rake", "~> 10.0"
41
44
  spec.add_development_dependency "rspec", "~> 3.3"
45
+ spec.add_development_dependency "rubocop", "~> 0.51.0"
42
46
  spec.add_development_dependency "simplecov", "~> 0.9"
43
- spec.add_development_dependency "pry-byebug", "~> 3.1"
44
- spec.add_development_dependency "priscilla", "~> 1.0"
45
- spec.add_development_dependency "rubocop", "~> 0.49.0"
46
47
 
47
48
  spec.post_install_message = <<-RAINBOW
48
49
  Starting from 2.1.0 you'll need to add the global section in your movefile.yml:
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wordmove
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.1
4
+ version: 2.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stefano Verna
@@ -12,56 +12,56 @@ authors:
12
12
  autorequire:
13
13
  bindir: exe
14
14
  cert_chain: []
15
- date: 2017-11-27 00:00:00.000000000 Z
15
+ date: 2017-12-09 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
- name: colorize
18
+ name: activesupport
19
19
  requirement: !ruby/object:Gem::Requirement
20
20
  requirements:
21
21
  - - "~>"
22
22
  - !ruby/object:Gem::Version
23
- version: 0.8.1
23
+ version: '5.1'
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: 5.1.1
24
27
  type: :runtime
25
28
  prerelease: false
26
29
  version_requirements: !ruby/object:Gem::Requirement
27
30
  requirements:
28
31
  - - "~>"
29
32
  - !ruby/object:Gem::Version
30
- version: 0.8.1
33
+ version: '5.1'
34
+ - - ">="
35
+ - !ruby/object:Gem::Version
36
+ version: 5.1.1
31
37
  - !ruby/object:Gem::Dependency
32
- name: thor
38
+ name: colorize
33
39
  requirement: !ruby/object:Gem::Requirement
34
40
  requirements:
35
41
  - - "~>"
36
42
  - !ruby/object:Gem::Version
37
- version: 0.19.4
43
+ version: 0.8.1
38
44
  type: :runtime
39
45
  prerelease: false
40
46
  version_requirements: !ruby/object:Gem::Requirement
41
47
  requirements:
42
48
  - - "~>"
43
49
  - !ruby/object:Gem::Version
44
- version: 0.19.4
50
+ version: 0.8.1
45
51
  - !ruby/object:Gem::Dependency
46
- name: activesupport
52
+ name: kwalify
47
53
  requirement: !ruby/object:Gem::Requirement
48
54
  requirements:
49
55
  - - "~>"
50
56
  - !ruby/object:Gem::Version
51
- version: '5.1'
52
- - - ">="
53
- - !ruby/object:Gem::Version
54
- version: 5.1.1
57
+ version: '0'
55
58
  type: :runtime
56
59
  prerelease: false
57
60
  version_requirements: !ruby/object:Gem::Requirement
58
61
  requirements:
59
62
  - - "~>"
60
63
  - !ruby/object:Gem::Version
61
- version: '5.1'
62
- - - ">="
63
- - !ruby/object:Gem::Version
64
- version: 5.1.1
64
+ version: '0'
65
65
  - !ruby/object:Gem::Dependency
66
66
  name: photocopier
67
67
  requirement: !ruby/object:Gem::Requirement
@@ -82,6 +82,20 @@ dependencies:
82
82
  - - ">="
83
83
  - !ruby/object:Gem::Version
84
84
  version: 1.1.3
85
+ - !ruby/object:Gem::Dependency
86
+ name: thor
87
+ requirement: !ruby/object:Gem::Requirement
88
+ requirements:
89
+ - - "~>"
90
+ - !ruby/object:Gem::Version
91
+ version: 0.19.4
92
+ type: :runtime
93
+ prerelease: false
94
+ version_requirements: !ruby/object:Gem::Requirement
95
+ requirements:
96
+ - - "~>"
97
+ - !ruby/object:Gem::Version
98
+ version: 0.19.4
85
99
  - !ruby/object:Gem::Dependency
86
100
  name: bundler
87
101
  requirement: !ruby/object:Gem::Requirement
@@ -103,89 +117,89 @@ dependencies:
103
117
  - !ruby/object:Gem::Version
104
118
  version: 1.14.6
105
119
  - !ruby/object:Gem::Dependency
106
- name: rake
120
+ name: priscilla
107
121
  requirement: !ruby/object:Gem::Requirement
108
122
  requirements:
109
123
  - - "~>"
110
124
  - !ruby/object:Gem::Version
111
- version: '10.0'
125
+ version: '1.0'
112
126
  type: :development
113
127
  prerelease: false
114
128
  version_requirements: !ruby/object:Gem::Requirement
115
129
  requirements:
116
130
  - - "~>"
117
131
  - !ruby/object:Gem::Version
118
- version: '10.0'
132
+ version: '1.0'
119
133
  - !ruby/object:Gem::Dependency
120
- name: rspec
134
+ name: pry-byebug
121
135
  requirement: !ruby/object:Gem::Requirement
122
136
  requirements:
123
137
  - - "~>"
124
138
  - !ruby/object:Gem::Version
125
- version: '3.3'
139
+ version: '3.1'
126
140
  type: :development
127
141
  prerelease: false
128
142
  version_requirements: !ruby/object:Gem::Requirement
129
143
  requirements:
130
144
  - - "~>"
131
145
  - !ruby/object:Gem::Version
132
- version: '3.3'
146
+ version: '3.1'
133
147
  - !ruby/object:Gem::Dependency
134
- name: simplecov
148
+ name: rake
135
149
  requirement: !ruby/object:Gem::Requirement
136
150
  requirements:
137
151
  - - "~>"
138
152
  - !ruby/object:Gem::Version
139
- version: '0.9'
153
+ version: '10.0'
140
154
  type: :development
141
155
  prerelease: false
142
156
  version_requirements: !ruby/object:Gem::Requirement
143
157
  requirements:
144
158
  - - "~>"
145
159
  - !ruby/object:Gem::Version
146
- version: '0.9'
160
+ version: '10.0'
147
161
  - !ruby/object:Gem::Dependency
148
- name: pry-byebug
162
+ name: rspec
149
163
  requirement: !ruby/object:Gem::Requirement
150
164
  requirements:
151
165
  - - "~>"
152
166
  - !ruby/object:Gem::Version
153
- version: '3.1'
167
+ version: '3.3'
154
168
  type: :development
155
169
  prerelease: false
156
170
  version_requirements: !ruby/object:Gem::Requirement
157
171
  requirements:
158
172
  - - "~>"
159
173
  - !ruby/object:Gem::Version
160
- version: '3.1'
174
+ version: '3.3'
161
175
  - !ruby/object:Gem::Dependency
162
- name: priscilla
176
+ name: rubocop
163
177
  requirement: !ruby/object:Gem::Requirement
164
178
  requirements:
165
179
  - - "~>"
166
180
  - !ruby/object:Gem::Version
167
- version: '1.0'
181
+ version: 0.51.0
168
182
  type: :development
169
183
  prerelease: false
170
184
  version_requirements: !ruby/object:Gem::Requirement
171
185
  requirements:
172
186
  - - "~>"
173
187
  - !ruby/object:Gem::Version
174
- version: '1.0'
188
+ version: 0.51.0
175
189
  - !ruby/object:Gem::Dependency
176
- name: rubocop
190
+ name: simplecov
177
191
  requirement: !ruby/object:Gem::Requirement
178
192
  requirements:
179
193
  - - "~>"
180
194
  - !ruby/object:Gem::Version
181
- version: 0.49.0
195
+ version: '0.9'
182
196
  type: :development
183
197
  prerelease: false
184
198
  version_requirements: !ruby/object:Gem::Requirement
185
199
  requirements:
186
200
  - - "~>"
187
201
  - !ruby/object:Gem::Version
188
- version: 0.49.0
202
+ version: '0.9'
189
203
  description: Wordmove deploys your WordPress websites at the speed of light.
190
204
  email:
191
205
  - stefano.verna@welaika.com
@@ -210,25 +224,48 @@ files:
210
224
  - README.mdown
211
225
  - Rakefile
212
226
  - assets/images/wordmove.png
227
+ - bin/bundler
228
+ - bin/byebug
229
+ - bin/coderay
213
230
  - bin/console
231
+ - bin/htmldiff
232
+ - bin/kwalify
233
+ - bin/ldiff
234
+ - bin/pry
214
235
  - bin/rake
215
236
  - bin/rspec
237
+ - bin/rubocop
238
+ - bin/ruby-parse
239
+ - bin/ruby-rewrite
240
+ - bin/rumoji
216
241
  - bin/setup
242
+ - bin/thor
243
+ - bin/wordmove
217
244
  - exe/wordmove
218
245
  - lib/wordmove.rb
219
246
  - lib/wordmove/assets/dump.php.erb
220
247
  - lib/wordmove/assets/import.php.erb
248
+ - lib/wordmove/assets/wordmove_schema_global.yml
249
+ - lib/wordmove/assets/wordmove_schema_local.yml
250
+ - lib/wordmove/assets/wordmove_schema_remote.yml
221
251
  - lib/wordmove/cli.rb
222
252
  - lib/wordmove/deployer/base.rb
223
253
  - lib/wordmove/deployer/ftp.rb
224
254
  - lib/wordmove/deployer/ssh.rb
225
255
  - lib/wordmove/deployer/ssh/default_sql_adapter.rb
226
256
  - lib/wordmove/deployer/ssh/wpcli_sql_adapter.rb
257
+ - lib/wordmove/doctor.rb
258
+ - lib/wordmove/doctor/movefile.rb
259
+ - lib/wordmove/doctor/mysql.rb
260
+ - lib/wordmove/doctor/rsync.rb
261
+ - lib/wordmove/doctor/ssh.rb
262
+ - lib/wordmove/doctor/wpcli.rb
227
263
  - lib/wordmove/exceptions.rb
228
264
  - lib/wordmove/generators/movefile.rb
229
265
  - lib/wordmove/generators/movefile.yml
230
266
  - lib/wordmove/generators/movefile_adapter.rb
231
267
  - lib/wordmove/logger.rb
268
+ - lib/wordmove/movefile.rb
232
269
  - lib/wordmove/sql_adapter/default.rb
233
270
  - lib/wordmove/sql_adapter/wpcli.rb
234
271
  - lib/wordmove/version.rb