wordmove 2.5.1 → 3.0.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: 941f5c1b78b58426d20bd0f39cf893c63caae8f4
4
- data.tar.gz: f2d69577cda70aa963e0e20267302a82d40b1216
3
+ metadata.gz: 79bfda3783565476f883fc3aa842dee647deeb92
4
+ data.tar.gz: 0ff3973a23e4c22d8606dffe12a74e13f5eba15c
5
5
  SHA512:
6
- metadata.gz: 244f9845aa6fb05baaa14197cbcaf6f71ff72505f39cf9a521a3244931ff363264f3995ef1b9fa01b6761c192eeab58f11e17308a60761080550f6b5d2d6620a
7
- data.tar.gz: ad2fe3608d0c173adaaea4e314db2a2d80282d1e13a20f7799f0e09ffff50b580770a7721d7ab9b0f12c54a452dacf78bf79b12e847db8c413aab214b822e5ad
6
+ metadata.gz: 5a78bc56e6282f7b26a352094e4a9c2b490238b186237f645aa95f8991571ee3ca9020782fe09b0182910b629fcbac012d2880a13b353a4b1b3dab8c192f53d6
7
+ data.tar.gz: 76ebde3511b4116ebde5f560a849e752294a67496c6b42829ce0bff8cd750ca359f3e71271869e0fcad608485e17ce9908318a36b2316fc58c5259e95e8415c5
data/README.mdown CHANGED
@@ -32,13 +32,14 @@ And to update:
32
32
 
33
33
  Wordmove just acts as automation glue bewtween tools you already have and love. These are its peer dependencies which you need to have installed and in your $PATH:
34
34
 
35
- | Program | Actions | Mandatory? |
36
- | ------- | ---------------------------- | ------------------------------- |
37
- | rsync | Push and pull files and dirs | Yes for SSH connections |
38
- | mysql | Import and dump database | Yes |
39
- | wp-cli | DB adapt | Nope (but soon will be) |
40
- | lftp | all | Yes, for FTP connections |
41
- | ssh | all | Yes, for SSH connections |
35
+ | Program | Actions | Mandatory? |
36
+ | ------- | ---------------------------- | ------------------------------- |
37
+ | rsync | Mirror files and dirs | Yes for SSH connections |
38
+ | mysql | Import database | Yes |
39
+ | mysqldump | Dump database | Yes |
40
+ | wp-cli | Adapt database | Yes by defalut, but configurable|
41
+ | lftp | all | Yes, for FTP connections |
42
+ | ssh | all | Yes, for SSH connections |
42
43
 
43
44
  ## Usage
44
45
 
@@ -69,7 +70,7 @@ You can configure Wordmove creating a `movefile.yml`. That's a YAML file with lo
69
70
 
70
71
  ```yaml
71
72
  global:
72
- sql_adapter: default
73
+ sql_adapter: wpcli
73
74
 
74
75
  local:
75
76
  vhost: http://vhost.local
@@ -99,20 +100,22 @@ production:
99
100
  host: host
100
101
  # port: 3308 # Use just in case you have exotic server config
101
102
  # mysqldump_options: --max_allowed_packet=50MB # Only available if using SSH
103
+ # mysql_options: --protocol=TCP # Only available if using SSH
102
104
 
103
105
  exclude:
104
- - .git/
105
- - .gitignore
106
- - .sass-cache/
107
- - bin/
108
- - tmp/*
109
- - Gemfile*
110
- - Movefile
111
- - movefile
112
- - movefile.yml
113
- - movefile.yaml
114
- - wp-config.php
115
- - wp-content/*.sql
106
+ - '.git/'
107
+ - '.gitignore'
108
+ - 'node_modules/'
109
+ - 'bin/'
110
+ - 'tmp/*'
111
+ - 'Gemfile*'
112
+ - 'Movefile'
113
+ - 'movefile'
114
+ - 'movefile.yml'
115
+ - 'movefile.yaml'
116
+ - 'wp-config.php'
117
+ - 'wp-content/*.sql.gz'
118
+ - '*.orig'
116
119
 
117
120
  ssh:
118
121
  host: host
@@ -171,8 +174,8 @@ See the [Windows (un)support disclaimer](https://github.com/welaika/wordmove/wik
171
174
  ### SSH
172
175
 
173
176
  * You need `rsync` on your machine; as far as we know it's already installed on OS X and Linux.
174
- * if you want to use your SSH public key for authentication,just delete the `production.ssh.password` field in your `movefile.yml`. Easy peasy.
175
- * writing the password inside the move file was and is somewhat supported, but **we discourage this practice** in favor of password-less authentication with pub key. Read [here](https://github.com/welaika/wordmove/wiki/%5Bdeprecated%5D-SSH-password-inside-Movefile) for old informations.
177
+ * To use your SSH public key for authentication, just delete the `production.ssh.password` field in your `movefile.yml`. Easy peasy.
178
+ * writing the password inside `movefile.yml` was and is somewhat supported, but **we discourage this practice** in favor of password-less authentication with pub key. Read [here](https://github.com/welaika/wordmove/wiki/%5Bdeprecated%5D-SSH-password-inside-Movefile) for old informations.
176
179
 
177
180
  ### FTP
178
181
 
@@ -181,7 +184,7 @@ See the [Windows (un)support disclaimer](https://github.com/welaika/wordmove/wik
181
184
  * Use the absolute FTP path as `production.wordpress_absolute_path` (you may need to recover this from the `__FILE__` [magic constant](http://php.net/manual/en/language.constants.predefined.php)
182
185
  * if you want to specify a passive FTP connection add to the YAML config a `production.ftp.passive` flag and set it to `true`.
183
186
 
184
- FTP support is [planned to be discontinued](https://github.com/welaika/wordmove/wiki/FTP-support-disclaimer) at some point of future development.
187
+ FTP support development is [discontinued](https://github.com/welaika/wordmove/wiki/FTP-support-disclaimer), but it's always there.
185
188
 
186
189
  ## Notes
187
190
 
data/lib/wordmove.rb CHANGED
@@ -14,21 +14,22 @@ require 'kwalify'
14
14
 
15
15
  require 'photocopier'
16
16
 
17
- require 'wordmove/exceptions'
18
17
  require 'wordmove/cli'
19
18
  require 'wordmove/doctor'
20
19
  require 'wordmove/doctor/movefile'
21
20
  require 'wordmove/doctor/mysql'
22
- require 'wordmove/doctor/wpcli'
23
21
  require 'wordmove/doctor/rsync'
24
22
  require 'wordmove/doctor/ssh'
23
+ require 'wordmove/doctor/wpcli'
24
+ require 'wordmove/exceptions'
25
+ require 'wordmove/guardian'
25
26
  require 'wordmove/hook'
26
27
  require 'wordmove/logger'
27
28
  require 'wordmove/movefile'
28
29
  require 'wordmove/sql_adapter/default'
29
30
  require 'wordmove/sql_adapter/wpcli'
30
- require "wordmove/version"
31
31
  require 'wordmove/wordpress_directory'
32
+ require "wordmove/version"
32
33
 
33
34
  require 'wordmove/generators/movefile_adapter'
34
35
  require 'wordmove/generators/movefile'
@@ -129,3 +129,36 @@ mapping:
129
129
  type: seq
130
130
  sequence:
131
131
  - type: str
132
+ forbid:
133
+ type: map
134
+ mapping:
135
+ pull:
136
+ type: map
137
+ mapping:
138
+ db:
139
+ type: bool
140
+ plugins:
141
+ type: bool
142
+ themes:
143
+ type: bool
144
+ languages:
145
+ type: bool
146
+ uploads:
147
+ type: bool
148
+ mu-plugins:
149
+ type: bool
150
+ push:
151
+ type: map
152
+ mapping:
153
+ db:
154
+ type: bool
155
+ plugins:
156
+ type: bool
157
+ themes:
158
+ type: bool
159
+ languages:
160
+ type: bool
161
+ uploads:
162
+ type: bool
163
+ mu-plugins:
164
+ type: bool
data/lib/wordmove/cli.rb CHANGED
@@ -73,8 +73,10 @@ module Wordmove
73
73
 
74
74
  Wordmove::Hook.run(:pull, :before, options)
75
75
 
76
+ guardian = Wordmove::Guardian.new(options: options, action: :pull)
77
+
76
78
  handle_options(options) do |task|
77
- deployer.send("pull_#{task}")
79
+ deployer.send("pull_#{task}") if guardian.allows(task.to_sym)
78
80
  end
79
81
 
80
82
  Wordmove::Hook.run(:pull, :after, options)
@@ -95,8 +97,10 @@ module Wordmove
95
97
 
96
98
  Wordmove::Hook.run(:push, :before, options)
97
99
 
100
+ guardian = Wordmove::Guardian.new(options: options, action: :push)
101
+
98
102
  handle_options(options) do |task|
99
- deployer.send("push_#{task}")
103
+ deployer.send("push_#{task}") if guardian.allows(task.to_sym)
100
104
  end
101
105
 
102
106
  Wordmove::Hook.run(:push, :after, options)
@@ -145,9 +145,6 @@ module Wordmove
145
145
  if options[:password].present?
146
146
  command << "--password=#{Shellwords.escape(options[:password])}"
147
147
  end
148
- if options[:charset].present?
149
- command << "--default-character-set=#{Shellwords.escape(options[:charset])}"
150
- end
151
148
  command << "--result-file=\"#{save_to_path}\""
152
149
  if options[:mysqldump_options].present?
153
150
  command << Shellwords.split(options[:mysqldump_options])
@@ -164,10 +161,8 @@ module Wordmove
164
161
  if options[:password].present?
165
162
  command << "--password=#{Shellwords.escape(options[:password])}"
166
163
  end
167
- if options[:charset].present?
168
- command << "--default-character-set=#{Shellwords.escape(options[:charset])}"
169
- end
170
164
  command << "--database=#{Shellwords.escape(options[:name])}"
165
+ command << Shellwords.split(options[:mysql_options]) if options[:mysql_options].present?
171
166
  command << "--execute=\"SET autocommit=0;SOURCE #{dump_path};COMMIT\""
172
167
  command.join(" ")
173
168
  end
@@ -52,6 +52,8 @@ module Wordmove
52
52
  # @see initialize
53
53
  %w[get put get_directory put_directory delete].each do |command|
54
54
  define_method "remote_#{command}" do |*args|
55
+ super
56
+
55
57
  logger.task_step false, "#{command}: #{args.join(' ')}"
56
58
  @copier.send(command, *args)
57
59
  end
@@ -1,5 +1,5 @@
1
1
  global:
2
- sql_adapter: default
2
+ sql_adapter: wpcli
3
3
 
4
4
  local:
5
5
  vhost: http://vhost.local
@@ -22,11 +22,11 @@ production:
22
22
  host: host
23
23
  # port: 3308 # Use just in case you have exotic server config
24
24
  # mysqldump_options: --max_allowed_packet=1G # Only available if using SSH
25
+ # mysql_options: --protocol=TCP # mysql command is used to import db
25
26
 
26
27
  exclude:
27
28
  - '.git/'
28
29
  - '.gitignore'
29
- - '.sass-cache/'
30
30
  - 'node_modules/'
31
31
  - 'bin/'
32
32
  - 'tmp/*'
@@ -88,6 +88,21 @@ production:
88
88
  # - 'echo "Do something locally after pull"'
89
89
  # remote:
90
90
  # - 'echo "Do something remotely after pull"'
91
+ # forbid:
92
+ # push:
93
+ # db: false
94
+ # plugins: false
95
+ # themes: false
96
+ # languages: false
97
+ # uploads: false
98
+ # mu-plugins: false
99
+ # pull:
100
+ # db: false
101
+ # plugins: false
102
+ # themes: false
103
+ # languages: false
104
+ # uploads: false
105
+ # mu-plugins: false
91
106
 
92
107
  # staging: # multiple environments can be specified
93
108
  # [...]
@@ -0,0 +1,35 @@
1
+ module Wordmove
2
+ class Guardian
3
+ attr_reader :movefile, :environment, :action, :logger
4
+
5
+ def initialize(options: nil, action: nil)
6
+ @movefile = Wordmove::Movefile.new(options[:config])
7
+ @environment = @movefile.environment(options).to_sym
8
+ @action = action
9
+ @logger = Logger.new(STDOUT).tap { |l| l.level = Logger::DEBUG }
10
+ end
11
+
12
+ def allows(task)
13
+ if forbidden?(task)
14
+ logger.warn("You tried to #{action} #{task}, but is forbidden by configuration. Skipping")
15
+ end
16
+
17
+ !forbidden?(task)
18
+ end
19
+
20
+ private
21
+
22
+ def forbidden?(task)
23
+ return false unless forbidden_tasks[task].present?
24
+ forbidden_tasks[task] == true
25
+ end
26
+
27
+ def forbidden_tasks
28
+ environment_options = movefile.fetch(false)[environment]
29
+ return {} unless environment_options.key?(:forbid)
30
+ return {} unless environment_options[:forbid].key?(action)
31
+
32
+ environment_options[:forbid][action]
33
+ end
34
+ end
35
+ end
data/lib/wordmove/hook.rb CHANGED
@@ -29,7 +29,7 @@ module Wordmove
29
29
  end
30
30
 
31
31
  Wordmove::Hook::Remote.run(
32
- hooks.remote_hooks, options[environment][:ssh], cli_options[:simulate]
32
+ hooks.remote_hooks, options[environment], cli_options[:simulate]
33
33
  )
34
34
  end
35
35
 
@@ -90,15 +90,19 @@ module Wordmove
90
90
  parent.logger
91
91
  end
92
92
 
93
- def self.run(commands, ssh_options, simulate = false)
93
+ def self.run(commands, options, simulate = false)
94
94
  logger.task "Running remote hooks"
95
95
 
96
+ ssh_options = options[:ssh]
97
+ wordpress_path = options[:wordpress_path]
98
+
96
99
  copier = Photocopier::SSH.new(ssh_options).tap { |c| c.logger = logger }
97
100
  commands.each do |command|
98
101
  logger.task_step false, "Exec command: #{command}"
99
102
  return true if simulate
100
103
 
101
- stdout, stderr, exit_code = copier.exec! command
104
+ stdout, stderr, exit_code =
105
+ copier.exec!("bash -l -c 'cd #{wordpress_path} && #{command}'")
102
106
 
103
107
  if exit_code.zero?
104
108
  logger.task_step false, "Output: #{stdout}"
@@ -30,6 +30,10 @@ module Wordmove
30
30
  puts " ⚠ debug".magenta + " | ".black + message.to_s
31
31
  end
32
32
 
33
+ def warn(message)
34
+ puts " ⚠ warning".yellow + " | ".black + message.to_s
35
+ end
36
+
33
37
  private
34
38
 
35
39
  def padding_length(line)
@@ -1,3 +1,3 @@
1
1
  module Wordmove
2
- VERSION = "2.5.1".freeze
2
+ VERSION = "3.0.0".freeze
3
3
  end
data/wordmove.gemspec CHANGED
@@ -46,11 +46,12 @@ Gem::Specification.new do |spec|
46
46
  spec.add_development_dependency "simplecov", "~> 0.9"
47
47
 
48
48
  spec.post_install_message = <<-RAINBOW
49
- Starting from 2.1.0 you'll need to add the global section in your movefile.yml:
50
- global:
51
- sql_adapter: "default"
52
- Or you can spawn a new one with `wordmove init` (backup the old one!)
49
+ Starting from version 3.0.0 `database.charset` option is no longer accepted.
50
+ Pass the '--default-charecter-set' flag into `database.mysqldump_options` or to
51
+ `database.mysql_options` instead, if you need to set the same option.
53
52
 
54
- Starting from 2.2.0 the default name of the config file is `movefile.yml`.
53
+ Starting from version 3.0.0 the default `global.sql_adapter` is "wpcli".
54
+ Therefor `WP-CLI` becomes a required peer dependency, unless you'll
55
+ change to the "default" adapter.
55
56
  RAINBOW
56
57
  end
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.5.1
4
+ version: 3.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stefano Verna
@@ -12,7 +12,7 @@ authors:
12
12
  autorequire:
13
13
  bindir: exe
14
14
  cert_chain: []
15
- date: 2018-03-24 00:00:00.000000000 Z
15
+ date: 2018-04-06 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: activesupport
@@ -265,6 +265,7 @@ files:
265
265
  - lib/wordmove/generators/movefile.rb
266
266
  - lib/wordmove/generators/movefile.yml
267
267
  - lib/wordmove/generators/movefile_adapter.rb
268
+ - lib/wordmove/guardian.rb
268
269
  - lib/wordmove/hook.rb
269
270
  - lib/wordmove/logger.rb
270
271
  - lib/wordmove/movefile.rb
@@ -281,12 +282,13 @@ licenses:
281
282
  - MIT
282
283
  metadata: {}
283
284
  post_install_message: |2
284
- Starting from 2.1.0 you'll need to add the global section in your movefile.yml:
285
- global:
286
- sql_adapter: "default"
287
- Or you can spawn a new one with `wordmove init` (backup the old one!)
285
+ Starting from version 3.0.0 `database.charset` option is no longer accepted.
286
+ Pass the '--default-charecter-set' flag into `database.mysqldump_options` or to
287
+ `database.mysql_options` instead, if you need to set the same option.
288
288
 
289
- Starting from 2.2.0 the default name of the config file is `movefile.yml`.
289
+ Starting from version 3.0.0 the default `global.sql_adapter` is "wpcli".
290
+ Therefor `WP-CLI` becomes a required peer dependency, unless you'll
291
+ change to the "default" adapter.
290
292
  rdoc_options: []
291
293
  require_paths:
292
294
  - lib