capistrano-magento2 0.5.9 → 0.6.0

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
  SHA1:
3
- metadata.gz: 8898c62e930f71d3b30804d3c0d3834bb75f22c0
4
- data.tar.gz: 71af2dbbe39540c476c38ba6bdb47d8d95ea1666
3
+ metadata.gz: 8469b82d98864aafd3331f72e0b5082243f835c8
4
+ data.tar.gz: 8eeb51698b72e2a102ef151bfd2d14546c916232
5
5
  SHA512:
6
- metadata.gz: 7c8f3cdc2b99db147d0f0da84f886c65d91ef38c82e26aeb8e47d12366dd3d8efe86e8a8b366ca90257e7b5d45e549e75d0253ab40f48fc1ecd0e41f6385347b
7
- data.tar.gz: 209ce16d410078b31ddcc68bee40529792654fd77e029f8ace6e982286a79a1cd21736eaa197cdf94aa5d02d215f339e850940700f9906644b4ca316894188c2
6
+ metadata.gz: 3afa6eb01bbb5425ba083bc58c0f7efaead6307183847eebc01fb4b89ed3a5501b117e7d71679bcfb016fae5ec60a9b252dd04a1f60bfd87c984e28b10a2663c
7
+ data.tar.gz: ce1bb3f5b21ce33a6d1fcdeb3b5733481109d415bf83afffb2f9ab2bd72ce5c8ffef675c1c8a53527f84aa875cf7df31c18772f184e23e730b1d18a93a675dbd
data/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # Capistrano::Magento2 Change Log
2
2
 
3
+ 0.6.0
4
+ ==========
5
+
6
+ * Added full-featured pending change logging functionality. See README for details (issue #58)
7
+ * Fixed inability to set PATH in capistrano configuration vs `.bashrc` file (issue #62)
8
+ * Updated README to reflect removing the `terminal-notifier` gem as a hard dependency (issue #19)
9
+ * Removed `capistrano-pending` as a dependency (issue #58)
10
+
3
11
  0.5.9
4
12
  ==========
5
13
 
data/README.md CHANGED
@@ -43,6 +43,7 @@ _Note: By default, Capistrano creates "staging" and "production" stages. If you
43
43
 
44
44
  # Load Magento deployment tasks
45
45
  require 'capistrano/magento2/deploy'
46
+ require 'capistrano/magento2/pending'
46
47
 
47
48
  # Load Git plugin
48
49
  require "capistrano/scm/git"
@@ -179,7 +180,7 @@ To see what process the built-in routine runs, take a look at the included rake
179
180
 
180
181
  ### Web Server Root Path
181
182
 
182
- Before deploying with Capistrano, you must update each of your web servers to point to a `current` directory inside of the `:deploy_to` directory. For example: `/var/www/html/current` Refer to the [Capistrano Structure](http://capistranorb.com/documentation/getting-started/structure/) to learn more about Capistrano's folder structure.
183
+ Before deploying with Capistrano, you must update each of your web servers to point to the `current` directory inside of the configured `:deploy_to` directory. For example: `/var/www/html/current/pub` Refer to the [Capistrano Structure](http://capistranorb.com/documentation/getting-started/structure/) to learn more about Capistrano's folder structure.
183
184
 
184
185
  ## Magento Specific Tasks
185
186
 
@@ -208,21 +209,64 @@ All Magento 2 tasks used by the built-in `deploy.rake` file as well as some addi
208
209
  | magento:setup:static-content:deploy | Deploys static view files |
209
210
  | magento:setup:upgrade | Run the Magento upgrade process |
210
211
 
211
- ## Terminal Notifier on OS X
212
- This gem specifies [terminal-notifier](https://rubygems.org/gems/terminal-notifier) as a dependency in order to support notifications on OS X via an optional include. To use the built-in notifications, add the following line to your `Capfile`:
212
+ ## Pending Changes Support
213
+
214
+ When the line `require 'capistrano/magento2/pending'` is included in your `Capfile` per the recommended configuration above, this gem will report changes pending deployment in an abbreviated git log style format. Here is an example:
215
+
216
+ ```
217
+ 00:00 deploy:pending:log
218
+ 01 git fetch origin
219
+ ✔ 01 dalger@localhost 1.241s
220
+ ✔ 01 dalger@localhost 1.259s
221
+ Changes pending deployment on web1 (tags/2.1.2 -> 2.1):
222
+ f511288 Thu Feb 23 12:19:20 2017 -0600 David Alger (HEAD -> 2.1, tag: 2.1.4, origin/2.1) Magento 2.1.4
223
+ 7fb219c Thu Feb 23 12:17:11 2017 -0600 David Alger (tag: 2.1.3) Magento 2.1.3
224
+ 570c9b3 Thu Feb 23 12:12:43 2017 -0600 David Alger Updated capistrano configuration
225
+ No changes to deploy on web2 (from and to are the same: 2.1 -> 2.1)
226
+ ```
227
+
228
+ When there are no changes due for deployment to any host, a warning requiring confirmation will be emitted by default:
229
+
230
+ ```
231
+ No changes to deploy on web1 (from and to are the same: 2.1 -> 2.1)
232
+ No changes to deploy on web2 (from and to are the same: 2.1 -> 2.1)
233
+ Are you sure you want to continue? [y/n]
234
+ ```
235
+
236
+ This conformational warning can be disabled by including the following in your project's configuration:
213
237
 
214
238
  ```ruby
215
- require 'capistrano/magento2/notifier'
239
+ set :magento_deploy_pending_warn, false
216
240
  ```
217
241
 
218
- ## Pending Changes
242
+ ### Pending Changes Configuration
243
+
244
+ | setting | what it does
245
+ | -------------------------------- | ------- | ---
246
+ | `:magento_deploy_pending_role` | Roles to check for pending changes on. This defaults to `:all`
247
+ | `:magento_deploy_pending_warn` | Set this to `false` to disable the conformational warning on zero-change deployment
248
+ | `:magento_deploy_pending_format` | Can be used to set a custom change log format. See `defaults.rb` for example.
219
249
 
220
- This gem specifies [capistrano-pending](https://rubygems.org/gems/capistrano-pending) as a dependency and adds some (optional) custom functionality on top of that gem: Any time the `deploy` command is run, a one line summary of git commits that will be deployed will be displayed. If the server(s) you are deploying to already have the latest changes, you will be warned of this and a prompt will appear confirming that you want to continue deploying.
250
+ ### Pending Changes Tasks
251
+
252
+ | cap command | what it does |
253
+ | ------------------------------------- | -------------------------------------------------- |
254
+ | deploy:pending | Displays a summary of commits pending deployment |
255
+
256
+ Note: For more details including screenshots of what this functionality does, reference [this post](https://github.com/davidalger/capistrano-magento2/issues/58#issuecomment-282404477).
257
+
258
+ ## Terminal Notifier on OS X
259
+
260
+ This gem includes an optional configuration file include which adds notification support via the [terminal-notifier](https://rubygems.org/gems/terminal-notifier) gem. To configure notifications, simply add the following line to your `Capfile`:
261
+
262
+ ```ruby
263
+ require 'capistrano/magento2/notifier'
264
+ ```
221
265
 
222
- To add the `capistrano-pending` gem and additional functionality to you project, add the following line to your `Capfile`:
266
+ **Notice:** The `terminal-notifier` gem is currently macOS specific and thus can not be used on generic *nix environments. Because this gem has been known to cause ruby stability issues on certain non-macOS environments, it is not specified as a hard requirement in this gem's gemspec. When using this functionality, it is expected the gem either be already present on your working environment or be added to your project's `Gemfile`:
223
267
 
224
268
  ```ruby
225
- require 'capistrano/magento2/pending'
269
+ gem 'terminal-notifier'
226
270
  ```
227
271
 
228
272
  ## Development
@@ -29,10 +29,6 @@ Gem::Specification.new do |spec|
29
29
 
30
30
  spec.add_dependency 'capistrano', '~> 3.1'
31
31
 
32
- # TODO explore removing these from gemspec per issue #19
33
- spec.add_dependency 'terminal-notifier', '~> 1.6'
34
- spec.add_dependency 'capistrano-pending', '~> 0.1'
35
-
36
32
  spec.add_development_dependency 'bundler', '~> 1.7'
37
33
  spec.add_development_dependency 'rake', '~> 10.0'
38
34
  end
@@ -13,7 +13,7 @@ module Capistrano
13
13
  module Magento2
14
14
  module Helpers
15
15
  def magento_version
16
- return Gem::Version::new((capture "/usr/bin/env php -f #{release_path}/bin/magento -- -V").split(' ').pop)
16
+ return Gem::Version::new((capture :php, "-f #{release_path}/bin/magento -- -V").split(' ').pop)
17
17
  end
18
18
 
19
19
  def disabled_modules
@@ -47,3 +47,11 @@ set :magento_deploy_themes, fetch(:magento_deploy_themes, [])
47
47
  # deploy targetting defaults
48
48
  set :magento_deploy_setup_role, fetch(:magento_deploy_setup_role, :all)
49
49
  set :magento_deploy_cache_shared, fetch(:magento_deploy_cache_shared, true)
50
+
51
+ # pending deploy check defaults
52
+ set :magento_deploy_pending_role, fetch(:magento_deploy_pending_role, :all)
53
+ set :magento_deploy_pending_warn, fetch(:magento_deploy_pending_warn, true)
54
+ set :magento_deploy_pending_format, fetch(
55
+ :magento_deploy_pending_format,
56
+ '--pretty="format:%C(yellow)%h %Cblue%>(12)%ad %Cgreen%<(7)%aN%Cred%d %Creset%s"'
57
+ )
@@ -8,46 +8,42 @@
8
8
  ##
9
9
 
10
10
  require 'capistrano/deploy'
11
- require 'capistrano/pending/scm/base'
11
+ require 'capistrano/magento2'
12
12
 
13
13
  module Capistrano
14
- module Pending
15
- module SCM
16
- class Git < Base
17
-
18
- # Enhance capistrano-pending gem's native deploy:pending:log command by updating repository and then
19
- # showing the actual changes that will be deployed. Also changes log output to oneline for easy reading
20
- #
21
- # Params:
22
- # +from+ - commit-ish to compare from
23
- # +to+ - commit-ish to compare to
24
- # +returnOutput+ - whether to return or print the output
25
- #
26
- def log(from, to, returnOutput=false)
14
+ module Magento2
15
+ module Pending
16
+ def ensure_revision inform_user = false
17
+ if test "[ -f #{current_path}/REVISION ]"
18
+ yield
19
+ else
20
+ warn "\e[0;31mSkipping pending changes check on #{host} (no REVISION file found)\e[0m" if inform_user
21
+ return false
22
+ end
23
+ return true
24
+ end
25
+
26
+ def from_rev
27
+ within current_path do
28
+ current_revision = capture(:cat, "REVISION")
29
+
27
30
  run_locally do
28
- execute :git, :fetch, :origin # update repository to ensure accuracy of pending changes report
29
-
30
- # Since the :branch to deploy from may be behind the upstream branch, get name of upstream branch
31
- # and use it for comparison. We are using the test command in case the :branch is set to a specific
32
- # commit hash, in which case there is no upstream branch.
33
-
34
- if test(:git, 'rev-parse', '--abbrev-ref', '--symbolic-full-name', to + '@{u}')
35
- to = capture(:git, 'rev-parse', '--abbrev-ref', '--symbolic-full-name', to + '@{u}')
36
- end
37
-
38
- output = capture(
39
- :git,
40
- :log,
41
- "#{from}..#{to}",
42
- '--pretty="format:%C(yellow)%h %Cblue%>(12)%ad %Cgreen%<(7)%aN%Cred%d %Creset%s"'
43
- )
44
-
45
- if returnOutput
46
- return output
47
- else
48
- puts output
49
- end
31
+ return capture(:git, "name-rev --always --name-only #{current_revision}") # find symbolic name for ref
32
+ end
33
+ end
34
+ end
35
+
36
+ def to_rev
37
+ run_locally do
38
+ to = fetch(:branch)
39
+
40
+ # get target branch upstream if there is one
41
+ if test(:git, "rev-parse --abbrev-ref --symbolic-full-name #{to}@{u}")
42
+ to = capture(:git, "rev-parse --abbrev-ref --symbolic-full-name #{to}@{u}")
50
43
  end
44
+
45
+ # find symbolic name for revision
46
+ to = capture(:git, "name-rev --always --name-only #{to}")
51
47
  end
52
48
  end
53
49
  end
@@ -9,6 +9,6 @@
9
9
 
10
10
  module Capistrano
11
11
  module Magento2
12
- VERSION = '0.5.9'
12
+ VERSION = '0.6.0'
13
13
  end
14
14
  end
@@ -7,33 +7,73 @@
7
7
  # http://davidalger.com/contact/
8
8
  ##
9
9
 
10
- require 'capistrano-pending'
10
+ include Capistrano::Magento2::Pending
11
+
12
+ before :deploy, 'deploy:pending:warn'
11
13
 
12
- before :deploy, 'deploy:pending:check_changes'
13
14
  namespace :deploy do
15
+ desc "Displays a summary of commits pending deployment"
16
+ task :pending => 'deploy:pending:log'
14
17
 
15
- # Check for pending changes on the primary node and then notify user of any incoming
16
- # changes and/or warn that there is nothing to deploy
17
18
  namespace :pending do
18
- task :check_changes do
19
- on primary fetch(:magento_deploy_setup_role) do
20
- # check for pending changes only if REVISION file exists to prevent error
21
- if test "[ -f #{current_path}/REVISION ]"
22
- invoke 'deploy:pending:setup'
23
- from = fetch(:revision)
24
- to = fetch(:branch)
25
-
26
- output = _scm.log(from, to, true)
27
- if output.to_s.strip.empty?
28
- puts "\e[0;31m No changes to deploy (from and to are the same: #{from}..#{to})"
29
- print " Are you sure you want to continue? [y/n] \e[0m"
30
-
31
- proceed = STDIN.gets[0..0] rescue nil
32
- exit unless proceed == 'y' || proceed == 'Y'
19
+ task :warn => :log do
20
+ if fetch(:magento_deploy_pending_warn)
21
+ need_warning = true
22
+
23
+ on roles fetch(:magento_deploy_pending_role) do |host|
24
+ has_revision = ensure_revision do
25
+ # if any host has a change in revision, do not warn user
26
+ need_warning = false if from_rev != to_rev
27
+ end
28
+
29
+ # if a host does not have a revision, do not warn user
30
+ need_warning = false if not has_revision
31
+ end
32
+
33
+ # if there is nothing to deploy on any host, prompt user for confirmation
34
+ if need_warning
35
+ print " Are you sure you want to continue? [y/n] \e[0m"
36
+
37
+ proceed = STDIN.gets[0..0] rescue nil
38
+ exit unless proceed == 'y' || proceed == 'Y'
39
+ end
40
+ end
41
+ end
42
+
43
+ task :log do
44
+ on roles fetch(:magento_deploy_pending_role) do |host|
45
+ ensure_revision true do
46
+ # update local repository to ensure accuracy of report
47
+ run_locally do
48
+ execute :git, :fetch, :origin
49
+ end
50
+
51
+ # fetch current revision and revision to be deployed
52
+ from = from_rev
53
+ to = to_rev
54
+
55
+ # if there is nothing to deploy on this host, inform the user
56
+ if from == to
57
+ info "\e[0;31mNo changes to deploy on #{host} (from and to are the same: #{from} -> #{to})\e[0m"
33
58
  else
34
- puts "\e[0;90m Deploying changes #{from}..#{to}:\e[0m"
35
- output.each_line do |s|
36
- puts " " + s
59
+ run_locally do
60
+ header = "\e[0;90mChanges pending deployment on #{host} (#{from} -> #{to}):\e[0m\n"
61
+
62
+ # capture log of commits between current revision and revision for deploy
63
+ output = capture :git, :log, "#{from}..#{to}", fetch(:magento_deploy_pending_format)
64
+
65
+ # if we get no results, flip refs to look at reverse log in case of rollback deployments
66
+ if output.to_s.strip.empty?
67
+ output = capture :git, :log, "#{to}..#{from}", fetch(:magento_deploy_pending_format)
68
+ if not output.to_s.strip.empty?
69
+ header += "\e[0;31mWarning: It appears you may be going backwards in time on #{host} with this deployment!\e[0m\n"
70
+ end
71
+ end
72
+
73
+ # write pending changes log
74
+ (header + output).each_line do |line|
75
+ info line
76
+ end
37
77
  end
38
78
  end
39
79
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: capistrano-magento2
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.9
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Alger
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-02-07 00:00:00.000000000 Z
11
+ date: 2017-02-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: capistrano
@@ -24,34 +24,6 @@ dependencies:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '3.1'
27
- - !ruby/object:Gem::Dependency
28
- name: terminal-notifier
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - "~>"
32
- - !ruby/object:Gem::Version
33
- version: '1.6'
34
- type: :runtime
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - "~>"
39
- - !ruby/object:Gem::Version
40
- version: '1.6'
41
- - !ruby/object:Gem::Dependency
42
- name: capistrano-pending
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - "~>"
46
- - !ruby/object:Gem::Version
47
- version: '0.1'
48
- type: :runtime
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - "~>"
53
- - !ruby/object:Gem::Version
54
- version: '0.1'
55
27
  - !ruby/object:Gem::Dependency
56
28
  name: bundler
57
29
  requirement: !ruby/object:Gem::Requirement