wordmove 3.0.2 → 3.1.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: 340a4d6b588c3aa99922d41aa684b0e2bc6b3a5f
4
- data.tar.gz: dee8d76ea56e73fca649e5b41848e9cad8241f48
3
+ metadata.gz: 415b8493170b6b7c1a104594977944feea297510
4
+ data.tar.gz: 959b2d34d6021d1065674809b07334ea606466fa
5
5
  SHA512:
6
- metadata.gz: 120795ed6849c97d92cac8a8b9df8d3fc9166384853554bdc9308c369254e43808510ce1ff5ea7ad2fc366925df3894a8b6bb7069f5923204344a542d29ca91f
7
- data.tar.gz: da33fddca0c38541cb49ce77b948acfe8511f1c5b1b8e046ca1b013c112f39246836c45b0b2ffd96765d4fb22958853a60c5e5a63af7ed5ff54b9b788a51aea3
6
+ metadata.gz: 1f9a738b923f299eaa5902ef82d217d40fbb8aa8a8a54840cf32e94da1891706a3bc9b2708f8828b8049f5467ea04b5945773b3d1f2a02489bba13a3921d6b0d
7
+ data.tar.gz: 9b79a7a4d9bd137f24202de1742e5bb061de33928f74fdbea019114e48e01040c5364e794c75617bd75a91b0874637d5938e588f5b509dd430d810e0fb43619f
data/README.mdown CHANGED
@@ -163,6 +163,40 @@ will push your local database to the staging environment only.
163
163
  We warmly **recommend** to read the wiki article: [Multiple environments explained
164
164
  ](https://github.com/welaika/wordmove/wiki/Multiple-environments-explained)
165
165
 
166
+ ## Secrets
167
+
168
+ If you intend on committing movefiles to your repos, consider using ERB tags to hide sensitive variables and credentials:
169
+
170
+ ```yaml
171
+ production:
172
+ database:
173
+ user: "<%= ENV['PROD_DB_USER'] %>"
174
+ password: "<%= ENV['PROD_DB_PASS'] %>"
175
+ ```
176
+
177
+ This can either be specified through shell variables or a dotenv file.
178
+
179
+ ### Shell
180
+ You can set variables like so:
181
+
182
+ ```bash
183
+ # bash
184
+ export PROD_DB_USER="username" PROD_DB_PASS="password"
185
+
186
+ # fish
187
+ set --export --global PROD_DB_USER "username"; set --export --global PROD_DB_PASS "password"
188
+ ```
189
+
190
+ ### Dotenv
191
+ Wordmove supports the [dotenv](https://github.com/bkeepers/dotenv) module. Simply create a file named `.env` next to your movefile:
192
+
193
+ ```dosini
194
+ PROD_DB_USER=username
195
+ PROD_DB_PASS=password
196
+ ```
197
+
198
+ You may also use `.env.{environmentname}`, but this is discouraged.
199
+
166
200
  ## Supports
167
201
 
168
202
  ### OS
data/lib/wordmove.rb CHANGED
@@ -1,16 +1,17 @@
1
1
  require 'English'
2
2
 
3
- require 'thor'
4
- require 'thor/group'
5
- require 'colorize'
6
- require 'logger'
7
- require 'yaml'
8
- require 'ostruct'
9
- require 'erb'
10
- require 'open-uri'
11
3
  require 'active_support'
12
4
  require 'active_support/core_ext'
5
+ require 'colorize'
6
+ require 'dotenv'
7
+ require 'erb'
13
8
  require 'kwalify'
9
+ require 'logger'
10
+ require 'open-uri'
11
+ require 'ostruct'
12
+ require 'thor'
13
+ require 'thor/group'
14
+ require 'yaml'
14
15
 
15
16
  require 'photocopier'
16
17
 
@@ -8,6 +8,8 @@ module Wordmove
8
8
  class << self
9
9
  def deployer_for(cli_options)
10
10
  movefile = Wordmove::Movefile.new(cli_options[:config])
11
+ movefile.load_dotenv(cli_options)
12
+
11
13
  options = movefile.fetch.merge! cli_options
12
14
  environment = movefile.environment(cli_options)
13
15
 
@@ -54,16 +56,19 @@ module Wordmove
54
56
  %w[uploads themes plugins mu_plugins languages].each do |task|
55
57
  define_method "push_#{task}" do
56
58
  logger.task "Pushing #{task.titleize}"
57
- local_path = send("local_#{task}_dir").path
58
- remote_path = send("remote_#{task}_dir").path
59
- remote_put_directory(local_path, remote_path, paths_to_exclude)
59
+ local_path = local_options[:wordpress_path]
60
+ remote_path = remote_options[:wordpress_path]
61
+
62
+ remote_put_directory(local_path, remote_path,
63
+ push_exclude_paths, push_inlcude_paths(task))
60
64
  end
61
65
 
62
66
  define_method "pull_#{task}" do
63
67
  logger.task "Pulling #{task.titleize}"
64
- local_path = send("local_#{task}_dir").path
65
- remote_path = send("remote_#{task}_dir").path
66
- remote_get_directory(remote_path, local_path, paths_to_exclude)
68
+ local_path = local_options[:wordpress_path]
69
+ remote_path = remote_options[:wordpress_path]
70
+ remote_get_directory(remote_path, local_path,
71
+ pull_exclude_paths, pull_include_paths(task))
67
72
  end
68
73
  end
69
74
 
@@ -172,7 +177,6 @@ module Wordmove
172
177
  command << "--best"
173
178
  command << "--force"
174
179
  command << "\"#{path}\""
175
- puts command.join(" ")
176
180
  command.join(" ")
177
181
  end
178
182
 
@@ -181,7 +185,6 @@ module Wordmove
181
185
  command << "-d"
182
186
  command << "--force"
183
187
  command << "\"#{path}\""
184
- puts command.join(" ")
185
188
  command.join(" ")
186
189
  end
187
190
 
@@ -202,6 +205,34 @@ module Wordmove
202
205
  def local_options
203
206
  options[:local].clone
204
207
  end
208
+
209
+ def push_inlcude_paths(task)
210
+ [
211
+ "/#{local_wp_content_dir.relative_path}/",
212
+ "/#{local_wp_content_dir.relative_path}/#{task}/"
213
+ ]
214
+ end
215
+
216
+ def push_exclude_paths
217
+ paths_to_exclude + [
218
+ "/*",
219
+ "/#{local_wp_content_dir.relative_path}/*"
220
+ ]
221
+ end
222
+
223
+ def pull_include_paths(task)
224
+ [
225
+ "/#{remote_wp_content_dir.relative_path}/",
226
+ "/#{remote_wp_content_dir.relative_path}/#{task}/"
227
+ ]
228
+ end
229
+
230
+ def pull_exclude_paths
231
+ paths_to_exclude + [
232
+ "/*",
233
+ "/#{remote_wp_content_dir.relative_path}/*"
234
+ ]
235
+ end
205
236
  end
206
237
  end
207
238
  end
@@ -21,12 +21,14 @@ production:
21
21
  password: password
22
22
  host: host
23
23
  # port: 3308 # Use just in case you have exotic server config
24
- # mysqldump_options: --max_allowed_packet=1G # Only available if using SSH
25
- # mysql_options: --protocol=TCP # mysql command is used to import db
24
+ # mysqldump_options: '--max_allowed_packet=1G' # Only available if using SSH
25
+ # mysql_options: '--protocol=TCP' # mysql command is used to import db
26
26
 
27
27
  exclude:
28
28
  - '.git/'
29
29
  - '.gitignore'
30
+ - '.gitmodules'
31
+ - '.env'
30
32
  - 'node_modules/'
31
33
  - 'bin/'
32
34
  - 'tmp/*'
@@ -52,7 +54,7 @@ production:
52
54
  # user: user
53
55
  # password: password # password is optional, will use public keys if available.
54
56
  # port: 22 # Port is optional
55
- # rsync_options: --verbose --itemize-changes# Additional rsync options, optional
57
+ # rsync_options: '--verbose --itemize-changes' # Additional rsync options, optional
56
58
  # gateway: # Gateway is optional
57
59
  # host: host
58
60
  # user: user
@@ -19,19 +19,23 @@ module Wordmove
19
19
  end
20
20
 
21
21
  def error(message)
22
- puts " error".red + " | ".black + message.to_s
22
+ puts " error".red + " | ".black + message.to_s
23
23
  end
24
24
 
25
25
  def success(message)
26
- puts " success".green + " | ".black + message.to_s
26
+ puts " success".green + " | ".black + message.to_s
27
27
  end
28
28
 
29
29
  def debug(message)
30
- puts " debug".magenta + " | ".black + message.to_s
30
+ puts " 🛠 debug".magenta + " | ".black + message.to_s
31
31
  end
32
32
 
33
33
  def warn(message)
34
- puts " warning".yellow + " | ".black + message.to_s
34
+ puts " ⚠️ warning".yellow + " | ".black + message.to_s
35
+ end
36
+
37
+ def info(message)
38
+ puts " ℹ️ info".yellow + " | ".black + message.to_s
35
39
  end
36
40
 
37
41
  private
@@ -26,6 +26,18 @@ module Wordmove
26
26
  YAML.safe_load(ERB.new(File.read(found)).result, [], [], true).deep_symbolize_keys!
27
27
  end
28
28
 
29
+ def load_dotenv(cli_options = {})
30
+ env = environment(cli_options)
31
+ env_files = Dir[File.join(start_dir, ".env{.#{env},}")]
32
+
33
+ found_env = env_files.first
34
+
35
+ return false unless found_env.present?
36
+
37
+ logger.info("Using .env file: #{found_env}")
38
+ Dotenv.load(found_env)
39
+ end
40
+
29
41
  def environment(cli_options = {})
30
42
  options = fetch(false)
31
43
  available_enviroments = extract_available_envs(options)
@@ -1,3 +1,3 @@
1
1
  module Wordmove
2
- VERSION = "3.0.2".freeze
2
+ VERSION = "3.1.0".freeze
3
3
  end
data/wordmove.gemspec CHANGED
@@ -31,8 +31,9 @@ Gem::Specification.new do |spec|
31
31
 
32
32
  spec.add_runtime_dependency "activesupport", '~> 5.1', '>= 5.1.1'
33
33
  spec.add_runtime_dependency "colorize", "~> 0.8.1"
34
+ spec.add_runtime_dependency "dotenv", "~> 2.2.1"
34
35
  spec.add_runtime_dependency "kwalify", "~> 0"
35
- spec.add_runtime_dependency "photocopier", "~> 1.1", ">= 1.1.3"
36
+ spec.add_runtime_dependency "photocopier", "~> 1.2", ">= 1.2.0"
36
37
  spec.add_runtime_dependency "thor", "~> 0.19.4"
37
38
 
38
39
  spec.required_ruby_version = ">= 2.4.0"
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: 3.0.2
4
+ version: 3.1.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-04-06 00:00:00.000000000 Z
15
+ date: 2018-05-22 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: activesupport
@@ -48,6 +48,20 @@ dependencies:
48
48
  - - "~>"
49
49
  - !ruby/object:Gem::Version
50
50
  version: 0.8.1
51
+ - !ruby/object:Gem::Dependency
52
+ name: dotenv
53
+ requirement: !ruby/object:Gem::Requirement
54
+ requirements:
55
+ - - "~>"
56
+ - !ruby/object:Gem::Version
57
+ version: 2.2.1
58
+ type: :runtime
59
+ prerelease: false
60
+ version_requirements: !ruby/object:Gem::Requirement
61
+ requirements:
62
+ - - "~>"
63
+ - !ruby/object:Gem::Version
64
+ version: 2.2.1
51
65
  - !ruby/object:Gem::Dependency
52
66
  name: kwalify
53
67
  requirement: !ruby/object:Gem::Requirement
@@ -68,20 +82,20 @@ dependencies:
68
82
  requirements:
69
83
  - - "~>"
70
84
  - !ruby/object:Gem::Version
71
- version: '1.1'
85
+ version: '1.2'
72
86
  - - ">="
73
87
  - !ruby/object:Gem::Version
74
- version: 1.1.3
88
+ version: 1.2.0
75
89
  type: :runtime
76
90
  prerelease: false
77
91
  version_requirements: !ruby/object:Gem::Requirement
78
92
  requirements:
79
93
  - - "~>"
80
94
  - !ruby/object:Gem::Version
81
- version: '1.1'
95
+ version: '1.2'
82
96
  - - ">="
83
97
  - !ruby/object:Gem::Version
84
- version: 1.1.3
98
+ version: 1.2.0
85
99
  - !ruby/object:Gem::Dependency
86
100
  name: thor
87
101
  requirement: !ruby/object:Gem::Requirement