capistrano-magento2 0.4.0 → 0.5.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: ccafa2eeb272e5124e13f302daca97acdf41e9ad
4
- data.tar.gz: 69888babe9fa29f97400350dc877f5897db6fe0d
3
+ metadata.gz: a091e5f5eae6baf2c936cefe403e8383444c6f6e
4
+ data.tar.gz: 5f951908a10ec8018a5c3b806dc7dac13f334860
5
5
  SHA512:
6
- metadata.gz: 49a423449c33c366b55aefc12157495a9efaadf82321b5237435710fa2f5f1dc399e0d05932f8b0b3cb27819994d852f30b61eb88428f600b525c85f7137f7f2
7
- data.tar.gz: 091d8d13cc69479a2a2965e83dda6389e6011453e3405cb6c561b2ec5dc741fe5fb1d917bbcfc61b16b4e59582f1105949861ca7c03561bd62fa1faae5c7c4e0
6
+ metadata.gz: f8c63e7428739a9b571c898db91f76d0817e124284764fa9db4e18ccbed7eed2d6628382509ae17fc46889c2836835f5b595e3d4d32f89d32110d509163bca68
7
+ data.tar.gz: bfdef14c680d81fb9e32d66cb7a8842a26087f920ee7fb15eb140e3a2bad231b8f3fe361cfcd348631b62384031a169e495874b369a0ea881071ff49c1bfe2e3
@@ -1,5 +1,19 @@
1
1
  # Capistrano::Magento2 Change Log
2
2
 
3
+ 0.5.0
4
+ ==========
5
+
6
+ * Added ability to only deploy specific themes via the new `:magento_deploy_themes` array
7
+ * Added `:magento_deploy_confim` setting which requires user confirmation of deployment to specific capistrano stages
8
+ * Added call to pre-generate secure RequireJS config (issue #21)
9
+ * Added workaround for Magento 2.1 specific bug where lack of a deployed_version.txt file would fail static asset deploy
10
+ * Added error check on output of setup:di:compile-multi-tenant since Magento 2.0 doesn't return error codes (issue #25)
11
+ * Updated formatting of pending deployment messaging
12
+ * Updated composer calls to specify --no-dev and --optimize-autoloader when `:magento_deploy_production` is not set (issue #22, #23)
13
+ * Fixed bug causing maintenance mode to be enabled on deploy even when `:magento_deploy_maintenance` was set to false
14
+ * Fixed bug preventing the second call to `magento:setup:permissions` from being executed (issue #18)
15
+ * Removed the undocumented `:deploy_warn_stages` setting from the notifier
16
+
3
17
  0.4.0
4
18
  ==========
5
19
 
data/README.md CHANGED
@@ -111,10 +111,12 @@ Before you can use Capistrano to deploy, you must configure the `config/deploy.r
111
111
 
112
112
  | setting | default | what it does
113
113
  | ----------------------------- | ------- | ---
114
- | `:magento_deploy_languages` | `['en_US']` | Array of languages passed to static content deploy routine |
115
- | `:magento_deploy_composer` | `true` | Enables composer install behaviour in the built-in deploy routine |
116
- | `:magento_deploy_production` | `true` | Enables production specific DI compilation and static content generation |
117
- | `:magento_deploy_maintenance` | `true` | Enables use of maintenance mode while magento:setup:upgrade runs. |
114
+ | `:magento_deploy_languages` | `['en_US']` | Array of languages passed to static content deploy routine
115
+ | `:magento_deploy_themes` | `[]` | Array of themes passed to static content deploy routine (Magento 2.1+ only)
116
+ | `:magento_deploy_composer` | `true` | Enables composer install behaviour in the built-in deploy routine
117
+ | `:magento_deploy_production` | `true` | Enables production specific DI compilation and static content generation
118
+ | `:magento_deploy_maintenance` | `true` | Enables use of maintenance mode while magento:setup:upgrade runs
119
+ | `:magento_deploy_confirm` | `[]` | Used to require confirmation of deployment to a set of capistrano stages
118
120
 
119
121
  #### Example Usage
120
122
 
@@ -28,6 +28,8 @@ Gem::Specification.new do |spec|
28
28
  spec.require_paths = ['lib']
29
29
 
30
30
  spec.add_dependency 'capistrano', '~> 3.1'
31
+
32
+ # TODO explore removing these from gemspec per issue #19
31
33
  spec.add_dependency 'terminal-notifier', '~> 1.6'
32
34
  spec.add_dependency 'capistrano-pending', '~> 0.1'
33
35
 
@@ -9,6 +9,6 @@
9
9
 
10
10
  module Capistrano
11
11
  module Magento2
12
- VERSION = '0.4.0'
12
+ VERSION = '0.5.0'
13
13
  end
14
14
  end
@@ -10,6 +10,14 @@
10
10
  namespace :deploy do
11
11
  before 'deploy:check:linked_files', 'magento:deploy:check'
12
12
 
13
+ before :starting, :confirm_action do
14
+ if fetch(:magento_deploy_confirm).include? fetch(:stage).to_s
15
+ print "\e[0;31m Are you sure you want to deploy to #{fetch(:stage).to_s}? [y/n] \e[0m"
16
+ proceed = STDIN.gets[0..0] rescue nil
17
+ exit unless proceed == 'y' || proceed == 'Y'
18
+ end
19
+ end
20
+
13
21
  task :updated do
14
22
  on release_roles :all do
15
23
  invoke 'magento:deploy:verify'
@@ -20,12 +28,12 @@ namespace :deploy do
20
28
  invoke 'magento:setup:di:compile'
21
29
  end
22
30
  invoke 'magento:setup:permissions'
23
- if test '-d #{current_path}'
31
+ invoke 'magento:maintenance:enable' if fetch(:magento_deploy_maintenance)
32
+ if test "[ -d #{current_path} ]"
24
33
  within current_path do
25
- execute :magento, 'maintenance:enable'
34
+ execute :magento, 'maintenance:enable' if fetch(:magento_deploy_maintenance)
26
35
  end
27
36
  end
28
- invoke 'magento:maintenance:enable' if fetch(:magento_deploy_maintenance)
29
37
  invoke 'magento:setup:upgrade'
30
38
  end
31
39
  end
@@ -50,7 +58,8 @@ end
50
58
  namespace :load do
51
59
  task :defaults do
52
60
  set :magento_deploy_composer, fetch(:magento_deploy_composer, true)
53
- set :magento_deploy_production, fetch(:magento_deploy_production, true)
61
+ set :magento_deploy_confirm, fetch(:magento_deploy_confirm, [])
54
62
  set :magento_deploy_maintenance, fetch(:magento_deploy_maintenance, true)
63
+ set :magento_deploy_production, fetch(:magento_deploy_production, true)
55
64
  end
56
65
  end
@@ -79,13 +79,28 @@ namespace :magento do
79
79
  namespace :composer do
80
80
  desc 'Run composer install'
81
81
  task :install do
82
+
82
83
  on release_roles :all do
83
84
  within release_path do
84
- execute :composer, 'install --prefer-dist --no-interaction 2>&1'
85
+ composer_flags = '--prefer-dist --no-interaction'
86
+
87
+ if fetch(:magento_deploy_production)
88
+ composer_flags += ' --optimize-autoloader'
89
+ end
90
+
91
+ execute :composer, "install #{composer_flags} 2>&1"
92
+
93
+ if fetch(:magento_deploy_production)
94
+ feature_version = capture :magento, "-V | cut -d' ' -f4 | cut -d. -f1-2"
85
95
 
86
- # Dir should be here if properly setup, but check for it anyways just in case
87
- if test "[ -d #{release_path}/update ]"
88
- execute :composer, 'install --prefer-dist --no-interaction -d ./update 2>&1'
96
+ if feature_version.to_f > 2.0
97
+ composer_flags += ' --no-dev'
98
+ execute :composer, "install #{composer_flags} 2>&1" # removes require-dev components from prev command
99
+ end
100
+ end
101
+
102
+ if test "[ -d #{release_path}/update ]" # can't count on this, but emit warning if not present
103
+ execute :composer, "install #{composer_flags} -d ./update 2>&1"
89
104
  else
90
105
  puts "\e[0;31m Warning: ./update dir does not exist in repository!\n\e[0m\n"
91
106
  end
@@ -146,6 +161,7 @@ namespace :magento do
146
161
  execute :chmod, '+x ./bin/magento'
147
162
  end
148
163
  end
164
+ Rake::Task['magento:setup:permissions'].reenable ## make task perpetually callable
149
165
  end
150
166
 
151
167
  namespace :di do
@@ -156,8 +172,12 @@ namespace :magento do
156
172
  # Due to a bug in the single-tenant compiler released in 2.0 (see here for details: http://bit.ly/21eMPtt)
157
173
  # we have to use multi-tenant currently. However, the multi-tenant is being dropped in 2.1 and is no longer
158
174
  # present in the develop mainline, so we are testing for multi-tenant presence for long-term portability.
159
- if test :magento, 'setup:di:compile-multi-tenant --help'
160
- execute :magento, 'setup:di:compile-multi-tenant'
175
+ if test :magento, 'setup:di:compile-multi-tenant --help >/dev/null 2>&1'
176
+ output = capture :magento, 'setup:di:compile-multi-tenant', verbosity: Logger::INFO
177
+
178
+ if output.to_s.include? 'Errors during compilation'
179
+ raise Exception, 'setup:di:compile-multi-tenant command execution failed'
180
+ end
161
181
  else
162
182
  execute :magento, 'setup:di:compile'
163
183
  end
@@ -171,16 +191,46 @@ namespace :magento do
171
191
  task :deploy do
172
192
  on release_roles :all do
173
193
  deploy_languages = fetch(:magento_deploy_languages).join(' ')
194
+ deploy_themes = fetch(:magento_deploy_themes)
195
+
196
+ if deploy_themes.count() > 0
197
+ deploy_themes = ' -t ' + deploy_themes.join(' -t ') # prepare value for cli command if theme(s) specified
198
+ else
199
+ deploy_themes = ''
200
+ end
201
+
202
+ # Output is being checked for a success message because this command may easily fail due to customizations
203
+ # and 2.0.x CLI commands do not return error exit codes on failure. See magento/magento2#3060 for details.
174
204
  within release_path do
175
- # TODO: Remove custom error detection logic once magento/magento2#3060 is resolved
176
- # Currently the cli tool is not reporting failures via the exit code, so manual detection is neccesary
205
+
206
+ # Workaround for 2.1 specific issue: https://github.com/magento/magento2/pull/6437
207
+ execute "touch #{release_path}/pub/static/deployed_version.txt"
208
+
177
209
  output = capture :magento,
178
- "setup:static-content:deploy #{deploy_languages}| stdbuf -o0 tr -d .",
210
+ "setup:static-content:deploy #{deploy_languages}#{deploy_themes} | stdbuf -o0 tr -d .",
179
211
  verbosity: Logger::INFO
180
212
 
181
213
  if not output.to_s.include? 'New version of deployed files'
182
214
  raise Exception, 'Failed to compile static assets'
183
215
  end
216
+
217
+ with(https: 'on') {
218
+ deploy_flags = ''
219
+
220
+ # Magento 2.0 does not have these flags, so only way to generate secure files is to do all of them :/
221
+ if test :magento, 'setup:static-content:deploy --help | grep -- --theme'
222
+ deploy_flags = " --no-javascript --no-css --no-less --no-images" \
223
+ + " --no-fonts --no-html --no-misc --no-html-minify"
224
+ end
225
+
226
+ output = capture :magento,
227
+ "setup:static-content:deploy #{deploy_languages}#{deploy_themes}#{deploy_flags} | stdbuf -o0 tr -d .",
228
+ verbosity: Logger::INFO
229
+
230
+ if not output.to_s.include? 'New version of deployed files'
231
+ raise Exception, 'Failed to compile (secure) static assets'
232
+ end
233
+ }
184
234
  end
185
235
  end
186
236
  end
@@ -305,5 +355,6 @@ namespace :load do
305
355
  )
306
356
 
307
357
  set :magento_deploy_languages, fetch(:magento_deploy_languages, ['en_US'])
358
+ set :magento_deploy_themes, fetch(:magento_deploy_themes, [])
308
359
  end
309
360
  end
@@ -10,21 +10,6 @@
10
10
  require 'terminal-notifier'
11
11
 
12
12
  namespace :deploy do
13
- before :starting, :confirm_action do
14
- if fetch(:deploy_warn_stages).include? fetch(:stage).to_s
15
- message = "Are you sure you want to deploy to #{fetch(:stage).to_s}? [y/N]".center(66)
16
-
17
- puts "\n\e[0;31m"
18
- puts " ######################################################################"
19
- puts " # #"
20
- puts " # #{message} #"
21
- puts " # #"
22
- puts " ######################################################################\e[0m\n"
23
- proceed = STDIN.gets[0..0] rescue nil
24
- exit unless proceed == 'y' || proceed == 'Y'
25
- end
26
- end
27
-
28
13
  after 'deploy:failed', :notify_user_failure do
29
14
  run_locally do
30
15
  set :message, "ERROR in deploying " + fetch(:application).to_s + " to " + fetch(:stage).to_s
@@ -39,10 +24,3 @@ namespace :deploy do
39
24
  end
40
25
  end
41
26
  end
42
-
43
- namespace :load do
44
- task :defaults do
45
- # TODO: Document the :deploy_warn_stages option
46
- set :deploy_warn_stages, fetch(:deploy_warn_stages, []).push('prod', 'production')
47
- end
48
- end
@@ -23,15 +23,16 @@ namespace :deploy do
23
23
 
24
24
  output = _scm.log(from, to, true)
25
25
  if output.to_s.strip.empty?
26
- puts "\e[0;31m"
27
- puts " No changes to deploy (from and to are the same: #{from}..#{to})"
28
- print " Are you sure you want to continue deploying? [y/n] \e[0m"
26
+ puts "\e[0;31m No changes to deploy (from and to are the same: #{from}..#{to})"
27
+ print " Are you sure you want to continue? [y/n] \e[0m"
29
28
 
30
29
  proceed = STDIN.gets[0..0] rescue nil
31
30
  exit unless proceed == 'y' || proceed == 'Y'
32
31
  else
33
- puts "Deploying changes between #{from}..#{to}"
34
- puts output
32
+ puts "\e[0;90m Deploying changes #{from}..#{to}:\e[0m"
33
+ output.each_line do |s|
34
+ puts " " + s
35
+ end
35
36
  end
36
37
  end
37
38
  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.4.0
4
+ version: 0.5.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: 2016-07-26 00:00:00.000000000 Z
11
+ date: 2016-09-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: capistrano