wordmove 5.0.0 → 5.2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b9bad2c9642b0664b21d86fe8ff6f07e32ece69a3be37bcc5d42d455e5d9ed1e
4
- data.tar.gz: c1b4a105e73411c3e4a022858afe6cebe561b21174a8bd847b927a12e8c0de21
3
+ metadata.gz: 2cbb1afb7ab4ef850f0ccd9cec81f6f245a71cdc39fdf2414568be16ab7c63df
4
+ data.tar.gz: d6b797a8a66c0dc6cd46f356df6600a79f0703dad1948ff9981ce6c2199a3288
5
5
  SHA512:
6
- metadata.gz: cb6a58864144648e6fa9c9b67974ef1faab88d68ab08e01a0aefa77ff9c62b6078fc41200276f77dbc480fca0e3fa07a4c23a89b31089cb6f2706e06162fa83f
7
- data.tar.gz: e883c9c12032408e4b80581ddf1447d558db3f34edbe32f611bd5d3518d6a31bfdb0a41f5003d217b811542a591f6802a118caf3b98148149d2cdd89d7238248
6
+ metadata.gz: bf8a84d271029cb2949370887dd2aebc3ce6a95b64567af162872f2ab928c5a866d8e9471ae4161d930b0a060c0056afd9067860daf5340411bfd10a28fd2f32
7
+ data.tar.gz: 78329f9afdf0a6e3660b39dcdaa77209cfae8ba0447b0fbd42d50b9945afacb88457a080df317ff9295f9cc3b6db48b8222de5adae92b8b051b6928820dc39d5
@@ -0,0 +1,33 @@
1
+ ---
2
+ name: Bug report
3
+ about: Create a report to help us improve
4
+ title: ''
5
+ labels: bug
6
+ assignees: ''
7
+
8
+ ---
9
+
10
+ **Describe the bug**
11
+ A clear and concise description of what the bug is.
12
+
13
+ **Wordmove command**
14
+ Command used on the CLI: (e.g.: `wordmove pull --all --no-db`)
15
+
16
+ **Expected behavior**
17
+ A clear and concise description of what you expected to happen.
18
+
19
+ **movefile.yml**
20
+ Paste (removing personal data) the interesting part, if any, of your `movefile.yml` formatting it inside a code block with `yml` syntax and double checking the indentation.
21
+
22
+ **Exception/trace**
23
+ Paste (removing personal data) the entire trace of error/exception you encountered, if any
24
+
25
+ **Environment (please complete the following information):**
26
+ - OS:
27
+ - Ruby: (`ruby --version`)
28
+ - Wordmove: (`wordmove --version`)
29
+
30
+ **Doctor**
31
+ * [x] `wordmove doctor` is all green
32
+
33
+ (If it is not, report the error you got.)
@@ -0,0 +1,10 @@
1
+ ---
2
+ name: Discussion
3
+ about: Open discussions are welcome :)
4
+ title: ''
5
+ labels: ''
6
+ assignees: ''
7
+
8
+ ---
9
+
10
+
@@ -0,0 +1,20 @@
1
+ ---
2
+ name: Feature request
3
+ about: Suggest an idea for this project
4
+ title: ''
5
+ labels: feature
6
+ assignees: ''
7
+
8
+ ---
9
+
10
+ **Is your feature request related to a problem? Please describe.**
11
+ A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
12
+
13
+ **Describe the solution you'd like**
14
+ A clear and concise description of what you want to happen.
15
+
16
+ **Describe alternatives you've considered**
17
+ A clear and concise description of any alternative solutions or features you've considered.
18
+
19
+ **Additional context**
20
+ Add any other context or screenshots about the feature request here.
@@ -0,0 +1,17 @@
1
+ # Number of days of inactivity before an issue becomes stale
2
+ daysUntilStale: 60
3
+ # Number of days of inactivity before a stale issue is closed
4
+ daysUntilClose: 7
5
+ # Issues with these labels will never be considered stale
6
+ exemptLabels:
7
+ - feature
8
+ - bug
9
+ # Label to use when marking an issue as stale
10
+ staleLabel: wontfix
11
+ # Comment to post when marking an issue as stale. Set to `false` to disable
12
+ markComment: >
13
+ This issue has been automatically marked as stale because it has not had
14
+ recent activity. It will be closed if no further activity occurs. Thank you
15
+ for your contributions.
16
+ # Comment to post when closing a stale issue. Set to `false` to disable
17
+ closeComment: false
@@ -0,0 +1,30 @@
1
+ # This workflow uses actions that are not certified by GitHub.
2
+ # They are provided by a third-party and are governed by
3
+ # separate terms of service, privacy policy, and support
4
+ # documentation.
5
+ # This workflow will download a prebuilt Ruby version, install dependencies and run tests with Rake
6
+ # For more information see: https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby
7
+
8
+ name: Tests
9
+
10
+ on:
11
+ push:
12
+ branches: [ master ]
13
+ pull_request:
14
+ branches: [ master ]
15
+
16
+ jobs:
17
+ test:
18
+
19
+ runs-on: ubuntu-latest
20
+
21
+ steps:
22
+ - uses: actions/checkout@v2
23
+ - name: Set up Ruby
24
+ uses: ruby/setup-ruby@v1
25
+ with:
26
+ ruby-version: 2.6
27
+ - name: Install dependencies
28
+ run: bundle install
29
+ - name: Run tests
30
+ run: bundle exec rake
@@ -0,0 +1,86 @@
1
+ Welcome to the contributor guide. If you can't find important information you're welcome
2
+ to edit this page or open a discussion issue to talk with maintainers.
3
+
4
+ In this guide you'll find informations about:
5
+ * [Bug reporting](#bug-reporting)
6
+ * [Development](#development)
7
+ * [Maintainer tasks](#maintainer-tasks)
8
+
9
+ ### Bug reporting
10
+
11
+ Wordmove is an hard piece of software to debug and it is used by many users with many
12
+ different environments - Windows also, even if it isn't officially supported by the dev team.
13
+
14
+ So *please*, help the community adding some crucial informations and posting well
15
+ formatted code. Inspirational details:
16
+
17
+ * OS
18
+ * Ruby version
19
+ * Wordmove version
20
+ * Are you using system Ruby, rbenv or RVM?
21
+ * Describe at your best the action you required to Wordmove: push/pull, ftp/ssh
22
+ * Paste (safely) your full or partial `movefile.yml`
23
+ * Paste (safely) the entire trace of error/exception you encountered, if any
24
+ * If you paste code or the STDOUT log/trace **format them**. If it sound as a joke I swear I'm serious:
25
+ use GitHub's Markdown syntax to keep things readable if you'd like to discuss your problem with the community.
26
+ * Label the issue if you can
27
+
28
+ As a general advise: we tend to not support Wordmove's versions older than the latest stable.
29
+ We'd appreciate your help opening an in depth report if you'd find that an older version is working
30
+ better for you.
31
+
32
+ Thank you all for your support and for the love <3
33
+
34
+ ### Development
35
+
36
+ #### Get Wordmove
37
+
38
+ * fork wordmove
39
+ * clone your own repo
40
+ * be sure to check-out the right branch, usually `master`
41
+
42
+ ##### Installing Ruby
43
+
44
+ To install ruby, please, use [rbenv](https://github.com/rbenv/rbenv) or [RVM](https://rvm.io).
45
+
46
+ ##### Contribute
47
+
48
+ * run `bundle install` to install gem dependencies
49
+ * `git checkout -b my_feature_or_fix_name`
50
+ * code, commit, push and send a pull request on GitHub
51
+
52
+ > Version bump is considered to be a maintainer's task, so please leave the version
53
+ alone while working on your branch.
54
+
55
+
56
+ ##### Test Wordmove
57
+
58
+ Wordmove has a decent test coverage. We _require_ that pull requests does not break tests launched by the CI.
59
+ In order to launch tests on you dev machine
60
+
61
+ ```fish
62
+ rake
63
+ ```
64
+
65
+ The command will launch the test suite - written with RSpec - and rubocop.
66
+
67
+ In order to use the gem locally you can install it
68
+
69
+ ```fish
70
+ rake install
71
+ wordmove --version
72
+ ```
73
+
74
+ or run the executable directly
75
+
76
+ ```fish
77
+ bin/wordmove --version
78
+ ```
79
+
80
+ ### Maintainer tasks
81
+
82
+ ToDo:
83
+
84
+ * [ ] versioning and version dumping
85
+ * [ ] changelog/release
86
+ * [ ] publishing the gem
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2013-2019 weLaika Soc. Coop.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -2,18 +2,17 @@
2
2
 
3
3
  ![logo](https://raw.githubusercontent.com/welaika/wordmove/master/assets/images/wordmove.png)
4
4
 
5
- Wordmove is a gem that lets you automatically mirror local WordPress
5
+ Wordmove is a command line tool that lets you automatically mirror local WordPress
6
6
  installations and DB data back and forth from your local development machine to
7
- the remote server.
7
+ one or more remote servers.
8
8
 
9
- Wordmove has also a neat hook system which enables you to run arbitrary commands
10
- before and after push/pull actions. Local and remote commands are both supported, but remote
11
- ones will be run only if using SSH protocol. Read the [dedicated wiki page](https://github.com/welaika/wordmove/wiki/Hooks) for more info.
9
+ Wordmove has also a neat [hook](https://github.com/welaika/wordmove/wiki/Hooks) system which enables you to run arbitrary commands
10
+ before and after push/pull actions. Local and remote commands are both supported (remote
11
+ ones only on SSH protocol).
12
12
 
13
- [FTP support has been discontinued](https://github.com/welaika/wordmove/wiki/FTP-support-disclaimer), thus most recent features won't work,
14
- while base functionalities are granted.
13
+ [FTP support development has been discontinued](https://github.com/welaika/wordmove/wiki/FTP-support-disclaimer), thus not all features are granted when using this protocol.
15
14
 
16
- [![Build Status](https://travis-ci.org/welaika/wordmove.svg?branch=master)](https://travis-ci.org/welaika/wordmove)
15
+ [![Tests](https://github.com/welaika/wordmove/workflows/Tests/badge.svg)](https://github.com/welaika/wordmove/actions)
17
16
  [![Slack channel](https://img.shields.io/badge/Slack-WP--Hub-blue.svg)](https://wphub-auto-invitation.herokuapp.com/)
18
17
  [![Gem Version](https://badge.fury.io/rb/wordmove.svg)](https://rubygems.org/gems/wordmove)
19
18
  [![Docker Build Status](https://img.shields.io/docker/automated/welaika/wordmove.svg)](https://hub.docker.com/r/welaika/wordmove/)
@@ -21,7 +20,9 @@ while base functionalities are granted.
21
20
 
22
21
  ## Installation
23
22
 
24
- That's easy:
23
+ Wordmove is developed in ruby and packaged and distributed as a gem.
24
+
25
+ To install:
25
26
 
26
27
  gem install wordmove
27
28
 
@@ -29,17 +30,21 @@ And to update:
29
30
 
30
31
  gem update wordmove
31
32
 
33
+ You can read more about ruby gems ecosystem on the official site https://rubygems.org/.
34
+
32
35
  ## Peer dependencies
33
36
 
34
- Wordmove just acts as automation glue between tools you already have and love. These are its peer dependencies which you need to have installed and in your $PATH:
37
+ Wordmove acts as automation glue between tools you already have and love. These are its peer dependencies which **you need to have installed** and executable through your system $PATH:
38
+
39
+ | Program | Mandatory? |
40
+ | --------- | -------------------------------- |
41
+ | rsync | Yes for SSH protocol |
42
+ | mysql | Yes |
43
+ | mysqldump | Yes |
44
+ | wp-cli | Yes by default, but configurable |
45
+ | lftp | Yes, for FTP protocol |
35
46
 
36
- | Program | Actions | Mandatory? |
37
- | ------- | ---------------------------- | ------------------------------- |
38
- | rsync | Mirror files and dirs | Yes for SSH connections |
39
- | mysql | Import database | Yes |
40
- | mysqldump | Dump database | Yes |
41
- | wp-cli | Adapt database | Yes by default, but configurable|
42
- | lftp | all | Yes, for FTP connections |
47
+ Wordmove also expect that the remote server will have the following commands: `gzip`, `nice`, `mysql`, `rsync`. All of these should be always present by default on any WordPress hosting.
43
48
 
44
49
  ## Usage
45
50
 
@@ -59,11 +64,17 @@ Move inside the WordPress folder and use `wordmove init` to generate a new `move
59
64
 
60
65
  **See the wiki article: [Usage and flags explained](https://github.com/welaika/wordmove/wiki/Usage-and-flags-explained) for more info.**
61
66
 
62
- ### Screencasts
63
67
 
64
- * Push all WordPress, including database and uploads: http://vimeo.com/74648079
65
- * Pull database and uploads, adapting paths and urls: http://vimeo.com/74646861
66
- * Push only theme, transfer only modified files: http://vimeo.com/74647529
68
+
69
+ ### Multistage
70
+
71
+ You can define multiple remote environments in your `movefile.yml`, such as production, staging, etc. Every first level key in the YAML other than the defaults and mandatory `global` and `local` will be interpreted as a remote environment.
72
+
73
+ Use `-e` with `pull` or `push` to run the command on the specified environment.
74
+
75
+ For example: `wordmove push -e staging -d` will push your local database to the staging environment.
76
+
77
+ We warmly **recommend to read the wiki article**: [Multiple environments explained](https://github.com/welaika/wordmove/wiki/Multiple-environments-explained)
67
78
 
68
79
  ## movefile.yml
69
80
 
@@ -141,24 +152,12 @@ production:
141
152
  # where: remote
142
153
  ```
143
154
 
144
- **We warmly recommend to read the wiki article [Multiple environments explained
145
- ](https://github.com/welaika/wordmove/wiki/Multiple-environments-explained) if you need multi-stage support,
146
- and the wiki article [Movefile configurations explained](https://github.com/welaika/wordmove/wiki/movefile.yml-configurations-explained)
147
- to understand about the supported configurations.**
155
+ We warmly **recommend to read the wiki articles**
148
156
 
149
- ## Multistage
157
+ * [Multiple environments explained](https://github.com/welaika/wordmove/wiki/Multiple-environments-explained)
158
+ * [Movefile configurations explained](https://github.com/welaika/wordmove/wiki/movefile.yml-configurations-explained)
150
159
 
151
- You can define multiple environments in your `movefile.yml`, such as production, staging, etc.
152
- Use `-e` with `pull` or `push` to run the command on the specified environment.
153
-
154
- For example:
155
-
156
- wordmove push -e staging -d
157
-
158
- will push your local database to the staging environment only.
159
-
160
- We warmly **recommend** to read the wiki article: [Multiple environments explained
161
- ](https://github.com/welaika/wordmove/wiki/Multiple-environments-explained)
160
+ to understand more about supported configurations.
162
161
 
163
162
  ## Environment Variables
164
163
 
@@ -171,6 +170,7 @@ Environment variables are written using the **ERB tags** syntax:
171
170
  ```
172
171
 
173
172
  ### Variables set up
173
+
174
174
  Environment variables can be set up using two methods:
175
175
 
176
176
  #### Using the shell:
@@ -281,38 +281,10 @@ Visit [Wordpress Tools](https://www.wptools.it).
281
281
 
282
282
  ## Contribute
283
283
 
284
- In order to promote a simpler contribution workflow we have decided to fork and PR the `master` branch.
285
- We will accordingly tag and release or pre-release versions to the rubygems.org repository.
286
- Do not consider the `dev` branch for your forks and PR.
287
- We will never more use version-named branches as in the past, but we'll tag release on `master` and pre-release on `dev`.
288
-
289
- ### Please, **read the full [contributor guide](https://github.com/welaika/wordmove/wiki/Contributor-Guide)**.
284
+ Please, read the [contributor guide](https://github.com/welaika/wordmove/blob/master/CONTRIBUTING.md).
290
285
 
291
- Feel free to open an issue about contribution if more you need more info
286
+ Feel free to open a discussion issue about contribution if you need more info.
292
287
 
293
288
  ## Author
294
289
 
295
290
  made with ❤️ and ☕️ by [weLaika](https://dev.welaika.com)
296
-
297
- ## License
298
-
299
- (The MIT License)
300
-
301
- Copyright © 2013-2019 weLaika
302
-
303
- Permission is hereby granted, free of charge, to any person obtaining a copy of
304
- this software and associated documentation files (the ‘Software’), to deal in
305
- the Software without restriction, including without limitation the rights to
306
- use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
307
- the Software, and to permit persons to whom the Software is furnished to do so,
308
- subject to the following conditions:
309
-
310
- The above copyright notice and this permission notice shall be included in all
311
- copies or substantial portions of the Software.
312
-
313
- THE SOFTWARE IS PROVIDED ‘AS IS’, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
314
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
315
- FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
316
- COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
317
- IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
318
- CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -1,3 +1,3 @@
1
1
  #! /usr/bin/env bash
2
2
 
3
- curl -H "Content-Type: application/json" --data '{"docker_tag": "latest"}' -X POST "$DOCKER_TRIGGER"
3
+ curl -H "Content-Type: application/json" -X POST "$DOCKER_TRIGGER"
@@ -100,11 +100,9 @@ module Wordmove
100
100
 
101
101
  return true if simulate?
102
102
 
103
- # rubocop:todo Security/Open
104
- open(local_path, 'w') do |file|
105
- file << open(url).read
103
+ File.open(local_path, 'w') do |file|
104
+ file << URI.open(url).read
106
105
  end
107
- # rubocop:enable Security/Open
108
106
  end
109
107
 
110
108
  def simulate?
@@ -4,6 +4,7 @@ module Wordmove
4
4
  Logger.new(STDOUT).tap { |l| l.level = Logger::DEBUG }
5
5
  end
6
6
 
7
+ # rubocop:disable Metrics/MethodLength
7
8
  def self.run(action, step, cli_options)
8
9
  movefile = Wordmove::Movefile.new(cli_options[:config])
9
10
  options = movefile.fetch(false)
@@ -15,37 +16,48 @@ module Wordmove
15
16
  step
16
17
  )
17
18
 
18
- unless hooks.local_hooks.empty?
19
- Wordmove::Hook::Local.run(hooks.local_hooks, options[:local], cli_options[:simulate])
20
- end
19
+ return if hooks.empty?
21
20
 
22
- return if hooks.remote_hooks.empty?
21
+ logger.task "Running #{action}/#{step} hooks"
23
22
 
24
- if options[environment][:ftp]
25
- logger.debug "You have configured remote hooks to run over "\
26
- "an FTP connection, but this is not possible. Skipping."
23
+ hooks.all_commands.each do |command|
24
+ case command[:where]
25
+ when 'local'
26
+ Wordmove::Hook::Local.run(command, options[:local], cli_options[:simulate])
27
+ when 'remote'
28
+ if options[environment][:ftp]
29
+ logger.debug "You have configured remote hooks to run over "\
30
+ "an FTP connection, but this is not possible. Skipping."
31
+ next
32
+ end
27
33
 
28
- return
34
+ Wordmove::Hook::Remote.run(command, options[environment], cli_options[:simulate])
35
+ else
36
+ next
37
+ end
29
38
  end
30
-
31
- Wordmove::Hook::Remote.run(
32
- hooks.remote_hooks, options[environment], cli_options[:simulate]
33
- )
34
39
  end
40
+ # rubocop:enable Metrics/MethodLength
35
41
 
36
42
  Config = Struct.new(:options, :action, :step) do
37
43
  def empty?
38
- (local_hooks + remote_hooks).empty?
44
+ all_commands.empty?
45
+ end
46
+
47
+ def all_commands
48
+ return [] if empty_step?
49
+
50
+ options[action][step] || []
39
51
  end
40
52
 
41
- def local_hooks
53
+ def local_commands
42
54
  return [] if empty_step?
43
55
 
44
56
  options[action][step]
45
57
  .select { |hook| hook[:where] == 'local' } || []
46
58
  end
47
59
 
48
- def remote_hooks
60
+ def remote_commands
49
61
  return [] if empty_step?
50
62
 
51
63
  options[action][step]
@@ -66,58 +78,51 @@ module Wordmove
66
78
 
67
79
  class Local
68
80
  def self.logger
69
- parent.logger
81
+ Wordmove::Hook.logger
70
82
  end
71
83
 
72
- def self.run(hooks, options, simulate = false)
73
- logger.task "Running local hooks"
74
-
84
+ def self.run(command_hash, options, simulate = false)
75
85
  wordpress_path = options[:wordpress_path]
76
86
 
77
- hooks.each do |hook|
78
- logger.task_step true, "Exec command: #{hook[:command]}"
79
- return true if simulate
87
+ logger.task_step true, "Exec command: #{command_hash[:command]}"
88
+ return true if simulate
80
89
 
81
- stdout_return = `cd #{wordpress_path} && #{hook[:command]} 2>&1`
82
- logger.task_step true, "Output: #{stdout_return}"
90
+ stdout_return = `cd #{wordpress_path} && #{command_hash[:command]} 2>&1`
91
+ logger.task_step true, "Output: #{stdout_return}"
83
92
 
84
- if $CHILD_STATUS.exitstatus.zero?
85
- logger.success ""
86
- else
87
- logger.error "Error code: #{$CHILD_STATUS.exitstatus}"
88
- raise Wordmove::LocalHookException unless hook[:raise].eql? false
89
- end
93
+ if $CHILD_STATUS.exitstatus.zero?
94
+ logger.success ""
95
+ else
96
+ logger.error "Error code: #{$CHILD_STATUS.exitstatus}"
97
+ raise Wordmove::LocalHookException unless command_hash[:raise].eql? false
90
98
  end
91
99
  end
92
100
  end
93
101
 
94
102
  class Remote
95
103
  def self.logger
96
- parent.logger
104
+ Wordmove::Hook.logger
97
105
  end
98
106
 
99
- def self.run(hooks, options, simulate = false)
100
- logger.task "Running remote hooks"
101
-
107
+ def self.run(command_hash, options, simulate = false)
102
108
  ssh_options = options[:ssh]
103
109
  wordpress_path = options[:wordpress_path]
104
110
 
105
111
  copier = Photocopier::SSH.new(ssh_options).tap { |c| c.logger = logger }
106
- hooks.each do |hook|
107
- logger.task_step false, "Exec command: #{hook[:command]}"
108
- return true if simulate
109
-
110
- stdout, stderr, exit_code =
111
- copier.exec!("cd #{wordpress_path} && #{hook[:command]}")
112
-
113
- if exit_code.zero?
114
- logger.task_step false, "Output: #{stdout}"
115
- logger.success ""
116
- else
117
- logger.task_step false, "Output: #{stderr}"
118
- logger.error "Error code #{exit_code}"
119
- raise Wordmove::RemoteHookException unless hook[:raise].eql? false
120
- end
112
+
113
+ logger.task_step false, "Exec command: #{command_hash[:command]}"
114
+ return true if simulate
115
+
116
+ stdout, stderr, exit_code =
117
+ copier.exec!("cd #{wordpress_path} && #{command_hash[:command]}")
118
+
119
+ if exit_code.zero?
120
+ logger.task_step false, "Output: #{stdout}"
121
+ logger.success ""
122
+ else
123
+ logger.task_step false, "Output: #{stderr}"
124
+ logger.error "Error code #{exit_code}"
125
+ raise Wordmove::RemoteHookException unless command_hash[:raise].eql? false
121
126
  end
122
127
  end
123
128
  end
@@ -7,7 +7,12 @@ module Wordmove
7
7
  formatted_message = if strings_to_hide.empty?
8
8
  message
9
9
  else
10
- message.gsub(Regexp.new(strings_to_hide.join('|')), '[secret]')
10
+ message.gsub(
11
+ Regexp.new(
12
+ strings_to_hide.map { |string| Regexp.escape(string) }.join('|')
13
+ ),
14
+ '[secret]'
15
+ )
11
16
  end
12
17
 
13
18
  "\n#{formatted_message}\n"
@@ -47,11 +47,20 @@ module Wordmove
47
47
  available_enviroments = extract_available_envs(options)
48
48
  options.merge!(cli_options).deep_symbolize_keys!
49
49
 
50
- if available_enviroments.size > 1 && options[:environment].nil?
51
- raise(
52
- UndefinedEnvironment,
53
- "You need to specify an environment with --environment parameter"
54
- )
50
+ if options[:environment] != 'local'
51
+ if available_enviroments.size > 1 && options[:environment].nil?
52
+ raise(
53
+ UndefinedEnvironment,
54
+ "You need to specify an environment with --environment parameter"
55
+ )
56
+ end
57
+
58
+ if options[:environment].present?
59
+ unless available_enviroments.include?(options[:environment].to_sym)
60
+ raise UndefinedEnvironment, "No environment found for \"#{options[:environment]}\". "\
61
+ "Available Environments: #{available_enviroments.join(' ')}"
62
+ end
63
+ end
55
64
  end
56
65
 
57
66
  (options[:environment] || available_enviroments.first).to_sym
@@ -11,12 +11,43 @@ module Wordmove
11
11
  end
12
12
 
13
13
  def command
14
- unless system('which wp > /dev/null 2>&1')
14
+ unless wp_in_path?
15
15
  raise UnmetPeerDependencyError, "WP-CLI is not installed or not in your $PATH"
16
16
  end
17
17
 
18
- "wp search-replace --path=#{local_path} #{from} #{to} --quiet "\
19
- "--skip-columns=guid --all-tables --allow-root"
18
+ opts = [
19
+ "--path=#{cli_config_path}",
20
+ from,
21
+ to,
22
+ "--quiet",
23
+ "--skip-columns=guid",
24
+ "--all-tables",
25
+ "--allow-root"
26
+ ]
27
+
28
+ "wp search-replace #{opts.join(' ')}"
29
+ end
30
+
31
+ private
32
+
33
+ def wp_in_path?
34
+ system('which wp > /dev/null 2>&1')
35
+ end
36
+
37
+ def cli_config_path
38
+ load_from_yml || load_from_cli || local_path
39
+ end
40
+
41
+ def load_from_yml
42
+ cli_config_path = File.join(local_path, "wp-cli.yml")
43
+ return unless File.exist?(cli_config_path)
44
+
45
+ YAML.load_file(cli_config_path).with_indifferent_access["path"]
46
+ end
47
+
48
+ def load_from_cli
49
+ cli_config = JSON.parse(`wp cli param-dump --with-values`, symbolize_names: true)
50
+ cli_config.dig(:path, :current)
20
51
  end
21
52
  end
22
53
  end
@@ -1,3 +1,3 @@
1
1
  module Wordmove
2
- VERSION = "5.0.0".freeze
2
+ VERSION = "5.2.1".freeze
3
3
  end
@@ -29,11 +29,11 @@ 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 "activesupport", '~> 5.1', '>= 5.1.1'
32
+ spec.add_runtime_dependency "activesupport", '~> 6.1'
33
33
  spec.add_runtime_dependency "colorize", "~> 0.8.1"
34
34
  spec.add_runtime_dependency "dotenv", "~> 2.7.5"
35
35
  spec.add_runtime_dependency "kwalify", "~> 0"
36
- spec.add_runtime_dependency "photocopier", "~> 1.3", ">= 1.3.2"
36
+ spec.add_runtime_dependency "photocopier", "~> 1.4", ">= 1.4.0"
37
37
  spec.add_runtime_dependency "thor", "~> 0.20.3"
38
38
 
39
39
  spec.required_ruby_version = ">= 2.6.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: 5.0.0
4
+ version: 5.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stefano Verna
@@ -9,10 +9,10 @@ authors:
9
9
  - Fabrizio Monti
10
10
  - Alessandro Fazzi
11
11
  - Filippo Gangi Dino
12
- autorequire:
12
+ autorequire:
13
13
  bindir: exe
14
14
  cert_chain: []
15
- date: 2019-11-27 00:00:00.000000000 Z
15
+ date: 2020-12-13 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: activesupport
@@ -20,20 +20,14 @@ dependencies:
20
20
  requirements:
21
21
  - - "~>"
22
22
  - !ruby/object:Gem::Version
23
- version: '5.1'
24
- - - ">="
25
- - !ruby/object:Gem::Version
26
- version: 5.1.1
23
+ version: '6.1'
27
24
  type: :runtime
28
25
  prerelease: false
29
26
  version_requirements: !ruby/object:Gem::Requirement
30
27
  requirements:
31
28
  - - "~>"
32
29
  - !ruby/object:Gem::Version
33
- version: '5.1'
34
- - - ">="
35
- - !ruby/object:Gem::Version
36
- version: 5.1.1
30
+ version: '6.1'
37
31
  - !ruby/object:Gem::Dependency
38
32
  name: colorize
39
33
  requirement: !ruby/object:Gem::Requirement
@@ -80,22 +74,22 @@ dependencies:
80
74
  name: photocopier
81
75
  requirement: !ruby/object:Gem::Requirement
82
76
  requirements:
83
- - - "~>"
84
- - !ruby/object:Gem::Version
85
- version: '1.3'
86
77
  - - ">="
87
78
  - !ruby/object:Gem::Version
88
- version: 1.3.2
79
+ version: 1.4.0
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '1.4'
89
83
  type: :runtime
90
84
  prerelease: false
91
85
  version_requirements: !ruby/object:Gem::Requirement
92
86
  requirements:
93
- - - "~>"
94
- - !ruby/object:Gem::Version
95
- version: '1.3'
96
87
  - - ">="
97
88
  - !ruby/object:Gem::Version
98
- version: 1.3.2
89
+ version: 1.4.0
90
+ - - "~>"
91
+ - !ruby/object:Gem::Version
92
+ version: '1.4'
99
93
  - !ruby/object:Gem::Dependency
100
94
  name: thor
101
95
  requirement: !ruby/object:Gem::Requirement
@@ -220,15 +214,21 @@ executables:
220
214
  extensions: []
221
215
  extra_rdoc_files: []
222
216
  files:
217
+ - ".github/ISSUE_TEMPLATE/bug_report.md"
218
+ - ".github/ISSUE_TEMPLATE/discussion.md"
219
+ - ".github/ISSUE_TEMPLATE/feature_request.md"
220
+ - ".github/stale.yml"
221
+ - ".github/workflows/ruby.yml"
223
222
  - ".gitignore"
224
223
  - ".rspec"
225
224
  - ".rubocop.yml"
226
225
  - ".ruby-gemset"
227
226
  - ".ruby-version"
228
- - ".travis.yml"
229
227
  - ".vscode/launch.json"
230
228
  - CHANGELOG.md
229
+ - CONTRIBUTING.md
231
230
  - Gemfile
231
+ - LICENSE
232
232
  - README.mdown
233
233
  - Rakefile
234
234
  - assets/images/wordmove.png
@@ -314,7 +314,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
314
314
  version: '0'
315
315
  requirements: []
316
316
  rubygems_version: 3.0.3
317
- signing_key:
317
+ signing_key:
318
318
  specification_version: 4
319
319
  summary: Wordmove, Capistrano for Wordpress
320
320
  test_files: []
@@ -1,24 +0,0 @@
1
- language: ruby
2
-
3
- rvm:
4
- - 2.6.5
5
-
6
- cache: bundler
7
-
8
- before_install:
9
- - gem update --system
10
- - gem install bundler
11
-
12
- install:
13
- - curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
14
- - chmod +x wp-cli.phar
15
- - sudo mv wp-cli.phar /usr/local/bin/wp
16
- - bundle install --jobs=3 --retry=3
17
-
18
- deploy:
19
- provider: script
20
- script: bash deploy/deploy.sh
21
- on:
22
- tags: true
23
- branch: master
24
- ruby: '2.6.5'