capistrano-magento2 0.5.3 → 0.5.4

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: 6a81db107c4c34b425b713d6fa60472526266e14
4
- data.tar.gz: 5a3bf1bb110c1f121a3063a6d67a32a3346cba96
3
+ metadata.gz: e6d79df3e4bedfce6d856fb16a166c15096e5031
4
+ data.tar.gz: eff72c1ebbc3d6e89aa416f9d6f6203e6d995578
5
5
  SHA512:
6
- metadata.gz: 1f4f5c17e3e55132443b1bae1658ef3d09ac434a09b10d14709a23707200a51b1adedff986f1d5ca83f54ff86957b3c84fc12c6ba47082ef924e3b9255295e0c
7
- data.tar.gz: ea57f3391c18f3ec8388fb5fe96a97c1405c26dad2b62ec87810a014c22dd053eae1c18092acad7f1d5b60db8e4a2fc4fcee40a32e6b2ffeaf4c512ee13641bd
6
+ metadata.gz: a00856111e7936109a2302fc25af44671041221cc0aabfeb9342217a1275154a00028c925ccfce99091133334a458bc34f5de0218b882426b3b189226ab3318c
7
+ data.tar.gz: c4423aac9ac9656a8f8ce7e2efeb0923f980a0d11b4fa27a4b7abf33b18040febb1415d8d539f6b0c68a7d710ee52d1afc7ed055beebb8f41a451b52499d04aa
@@ -0,0 +1,3 @@
1
+ language: ruby
2
+ rvm:
3
+ 2.2
@@ -1,5 +1,11 @@
1
1
  # Capistrano::Magento2 Change Log
2
2
 
3
+ 0.5.4
4
+ ==========
5
+
6
+ * Fixed issue causing failed releases when there are CSS compilation errors in setup:static-content:deploy task
7
+ * Updated static content deployment to ignore `:magento_deploy_themes` when deploying 2.0 and issue a warning message.
8
+
3
9
  0.5.3
4
10
  ==========
5
11
 
data/Rakefile CHANGED
@@ -8,3 +8,9 @@
8
8
  ##
9
9
 
10
10
  require 'bundler/gem_tasks'
11
+
12
+ task default: %w[test]
13
+
14
+ task :test do
15
+ puts "TODO: Create real integration tests!"
16
+ end
@@ -33,6 +33,6 @@ Gem::Specification.new do |spec|
33
33
  spec.add_dependency 'terminal-notifier', '~> 1.6'
34
34
  spec.add_dependency 'capistrano-pending', '~> 0.1'
35
35
 
36
- spec.add_development_dependency 'bundler', '~> 1.11'
36
+ spec.add_development_dependency 'bundler', '~> 1.7'
37
37
  spec.add_development_dependency 'rake', '~> 10.0'
38
38
  end
@@ -7,12 +7,44 @@
7
7
  # http://davidalger.com/contact/
8
8
  ##
9
9
 
10
+ SSHKit.config.command_map[:magento] = "/usr/bin/env php -f bin/magento --"
11
+
10
12
  module Capistrano
11
- class Magento2
12
- def self.cache_hosts
13
- return fetch(:magento_deploy_cache_shared) ? (primary fetch :magento_deploy_setup_role) : (release_roles :all)
13
+ module Magento2
14
+ module Helpers
15
+ def magento_version
16
+ return (capture "/usr/bin/env php -f #{release_path}/bin/magento -- -V").split(' ').pop.to_f
17
+ end
18
+
19
+ def cache_hosts
20
+ return fetch(:magento_deploy_cache_shared) ? (primary fetch :magento_deploy_setup_role) : (release_roles :all)
21
+ end
22
+ end
23
+
24
+ module Setup
25
+ def static_content_deploy params
26
+ output = capture :magento,
27
+ "setup:static-content:deploy #{params} | stdbuf -o0 tr -d .",
28
+ verbosity: Logger::INFO
29
+
30
+ if not output.to_s.include? 'New version of deployed files'
31
+ raise Exception, "\e[0;31mFailed to compile static assets\e[0m"
32
+ end
33
+
34
+ output.to_s.each_line { |line|
35
+ if line.split('errors: ', 2).pop.to_i > 0
36
+ raise Exception, "\e[0;31mFailed to compile static assets\e[0m"
37
+ end
38
+ }
39
+ end
14
40
  end
15
41
  end
16
42
  end
17
43
 
18
44
  load File.expand_path('../tasks/magento.rake', __FILE__)
45
+
46
+ namespace :load do
47
+ task :defaults do
48
+ load 'capistrano/magento2/defaults.rb'
49
+ end
50
+ end
@@ -0,0 +1,50 @@
1
+ ##
2
+ # Copyright © 2016 by David Alger. All rights reserved
3
+ #
4
+ # Licensed under the Open Software License 3.0 (OSL-3.0)
5
+ # See included LICENSE file for full text of OSL-3.0
6
+ #
7
+ # http://davidalger.com/contact/
8
+ ##
9
+
10
+ set :linked_files, fetch(:linked_files, []).push(
11
+ 'app/etc/env.php',
12
+ 'var/.setup_cronjob_status',
13
+ 'var/.update_cronjob_status',
14
+ 'pub/sitemap.xml'
15
+ )
16
+
17
+ set :linked_files_touch, fetch(:linked_files_touch, []).push(
18
+ 'app/etc/env.php',
19
+ 'var/.setup_cronjob_status',
20
+ 'var/.update_cronjob_status',
21
+ 'pub/sitemap.xml'
22
+ )
23
+
24
+ set :linked_dirs, fetch(:linked_dirs, []).push(
25
+ 'pub/media',
26
+ 'var/backups',
27
+ 'var/composer_home',
28
+ 'var/importexport',
29
+ 'var/import_history',
30
+ 'var/log',
31
+ 'var/session',
32
+ 'var/tmp'
33
+ )
34
+
35
+ # deploy permissions defaults
36
+ set :magento_deploy_chmod_d, fetch(:magento_deploy_chmod_d, '2770')
37
+ set :magento_deploy_chmod_f, fetch(:magento_deploy_chmod_f, '0660')
38
+ set :magento_deploy_chmod_x, fetch(:magento_deploy_chmod_x, ['bin/magento'])
39
+
40
+ # deploy configuration defaults
41
+ set :magento_deploy_composer, fetch(:magento_deploy_composer, true)
42
+ set :magento_deploy_confirm, fetch(:magento_deploy_confirm, [])
43
+ set :magento_deploy_languages, fetch(:magento_deploy_languages, ['en_US'])
44
+ set :magento_deploy_maintenance, fetch(:magento_deploy_maintenance, true)
45
+ set :magento_deploy_production, fetch(:magento_deploy_production, true)
46
+ set :magento_deploy_themes, fetch(:magento_deploy_themes, [])
47
+
48
+ # deploy targetting defaults
49
+ set :magento_deploy_setup_role, fetch(:magento_deploy_setup_role, :all)
50
+ set :magento_deploy_cache_shared, fetch(:magento_deploy_cache_shared, true)
@@ -9,6 +9,6 @@
9
9
 
10
10
  module Capistrano
11
11
  module Magento2
12
- VERSION = '0.5.3'
12
+ VERSION = '0.5.4'
13
13
  end
14
14
  end
@@ -7,12 +7,15 @@
7
7
  # http://davidalger.com/contact/
8
8
  ##
9
9
 
10
+ include Capistrano::Magento2::Helpers
11
+ include Capistrano::Magento2::Setup
12
+
10
13
  namespace :magento do
11
14
 
12
15
  namespace :cache do
13
16
  desc 'Flush Magento cache storage'
14
17
  task :flush do
15
- on Capistrano::Magento2.cache_hosts do
18
+ on cache_hosts do
16
19
  within release_path do
17
20
  execute :magento, 'cache:flush'
18
21
  end
@@ -21,7 +24,7 @@ namespace :magento do
21
24
 
22
25
  desc 'Clean Magento cache by types'
23
26
  task :clean do
24
- on Capistrano::Magento2.cache_hosts do
27
+ on cache_hosts do
25
28
  within release_path do
26
29
  execute :magento, 'cache:clean'
27
30
  end
@@ -30,7 +33,7 @@ namespace :magento do
30
33
 
31
34
  desc 'Enable Magento cache'
32
35
  task :enable do
33
- on Capistrano::Magento2.cache_hosts do
36
+ on cache_hosts do
34
37
  within release_path do
35
38
  execute :magento, 'cache:enable'
36
39
  end
@@ -39,7 +42,7 @@ namespace :magento do
39
42
 
40
43
  desc 'Disable Magento cache'
41
44
  task :disable do
42
- on Capistrano::Magento2.cache_hosts do
45
+ on cache_hosts do
43
46
  within release_path do
44
47
  execute :magento, 'cache:disable'
45
48
  end
@@ -48,7 +51,7 @@ namespace :magento do
48
51
 
49
52
  desc 'Check Magento cache enabled status'
50
53
  task :status do
51
- on Capistrano::Magento2.cache_hosts do
54
+ on cache_hosts do
52
55
  within release_path do
53
56
  execute :magento, 'cache:status'
54
57
  end
@@ -90,13 +93,9 @@ namespace :magento do
90
93
 
91
94
  execute :composer, "install #{composer_flags} 2>&1"
92
95
 
93
- if fetch(:magento_deploy_production)
94
- feature_version = capture :magento, "-V | cut -d' ' -f4 | cut -d. -f1-2"
95
-
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
96
+ if fetch(:magento_deploy_production) and magento_version > 2.0
97
+ composer_flags += ' --no-dev'
98
+ execute :composer, "install #{composer_flags} 2>&1" # removes require-dev components from prev command
100
99
  end
101
100
 
102
101
  if test "[ -d #{release_path}/update ]" # can't count on this, but emit warning if not present
@@ -195,13 +194,18 @@ namespace :magento do
195
194
  desc 'Deploys static view files'
196
195
  task :deploy do
197
196
  on release_roles :all do
197
+ _magento_version = magento_version
198
+
198
199
  deploy_languages = fetch(:magento_deploy_languages).join(' ')
199
200
  deploy_themes = fetch(:magento_deploy_themes)
200
201
 
201
- if deploy_themes.count() > 0
202
- deploy_themes = ' -t ' + deploy_themes.join(' -t ') # prepare value for cli command if theme(s) specified
202
+ if deploy_themes.count() > 0 and _magento_version >= 2.1
203
+ deploy_themes = deploy_themes.join(' -t ').prepend(' -t ')
204
+ elsif deploy_themes.count() > 0
205
+ warn "\e[0;31mWarning: Magento 2.0 does not support :magento_deploy_themes setting (ignoring value)\e[0m"
206
+ deploy_themes = nil
203
207
  else
204
- deploy_themes = ''
208
+ deploy_themes = nil
205
209
  end
206
210
 
207
211
  # Output is being checked for a success message because this command may easily fail due to customizations
@@ -211,32 +215,20 @@ namespace :magento do
211
215
  # Workaround for 2.1 specific issue: https://github.com/magento/magento2/pull/6437
212
216
  execute "touch #{release_path}/pub/static/deployed_version.txt"
213
217
 
214
- output = capture :magento,
215
- "setup:static-content:deploy #{deploy_languages}#{deploy_themes} | stdbuf -o0 tr -d .",
216
- verbosity: Logger::INFO
217
-
218
- if not output.to_s.include? 'New version of deployed files'
219
- raise Exception, 'Failed to compile static assets'
220
- end
221
-
222
- with(https: 'on') {
223
- deploy_flags = ''
218
+ # Generates all but the secure versions of RequireJS configs
219
+ static_content_deploy "#{deploy_languages}#{deploy_themes}"
220
+ end
224
221
 
225
- # Magento 2.0 does not have these flags, so only way to generate secure files is to do all of them :/
226
- if test :magento, 'setup:static-content:deploy --help | grep -- --theme'
227
- deploy_flags = " --no-javascript --no-css --no-less --no-images" \
228
- + " --no-fonts --no-html --no-misc --no-html-minify"
229
- end
222
+ # Run again with HTTPS env var set to 'on' to pre-generate secure versions of RequireJS configs
223
+ deploy_flags = ['javascript', 'css', 'less', 'images', 'fonts', 'html', 'misc', 'html-minify']
224
+ .join(' --no-').prepend(' --no-');
230
225
 
231
- output = capture :magento,
232
- "setup:static-content:deploy #{deploy_languages}#{deploy_themes}#{deploy_flags} | stdbuf -o0 tr -d .",
233
- verbosity: Logger::INFO
226
+ # Magento 2.0 does not have these flags, so only way to generate secure files is to do all of them :/
227
+ deploy_flags = nil if _magento_version <= 2.0
234
228
 
235
- if not output.to_s.include? 'New version of deployed files'
236
- raise Exception, 'Failed to compile (secure) static assets'
237
- end
238
- }
239
- end
229
+ within release_path do with(https: 'on') {
230
+ static_content_deploy "#{deploy_languages}#{deploy_themes}#{deploy_flags}"
231
+ } end
240
232
  end
241
233
  end
242
234
  end
@@ -327,52 +319,3 @@ namespace :magento do
327
319
  end
328
320
  end
329
321
  end
330
-
331
- namespace :load do
332
- task :defaults do
333
-
334
- SSHKit.config.command_map[:magento] = "/usr/bin/env php -f bin/magento --"
335
-
336
- set :linked_files, fetch(:linked_files, []).push(
337
- 'app/etc/env.php',
338
- 'var/.setup_cronjob_status',
339
- 'var/.update_cronjob_status',
340
- 'pub/sitemap.xml'
341
- )
342
-
343
- set :linked_files_touch, fetch(:linked_files_touch, []).push(
344
- 'app/etc/env.php',
345
- 'var/.setup_cronjob_status',
346
- 'var/.update_cronjob_status',
347
- 'pub/sitemap.xml'
348
- )
349
-
350
- set :linked_dirs, fetch(:linked_dirs, []).push(
351
- 'pub/media',
352
- 'var/backups',
353
- 'var/composer_home',
354
- 'var/importexport',
355
- 'var/import_history',
356
- 'var/log',
357
- 'var/session',
358
- 'var/tmp'
359
- )
360
-
361
- # deploy permissions defaults
362
- set :magento_deploy_chmod_d, fetch(:magento_deploy_chmod_d, '2770')
363
- set :magento_deploy_chmod_f, fetch(:magento_deploy_chmod_f, '0660')
364
- set :magento_deploy_chmod_x, fetch(:magento_deploy_chmod_x, ['bin/magento'])
365
-
366
- # deploy configuration defaults
367
- set :magento_deploy_composer, fetch(:magento_deploy_composer, true)
368
- set :magento_deploy_confirm, fetch(:magento_deploy_confirm, [])
369
- set :magento_deploy_languages, fetch(:magento_deploy_languages, ['en_US'])
370
- set :magento_deploy_maintenance, fetch(:magento_deploy_maintenance, true)
371
- set :magento_deploy_production, fetch(:magento_deploy_production, true)
372
- set :magento_deploy_themes, fetch(:magento_deploy_themes, [])
373
-
374
- # deploy targetting defaults
375
- set :magento_deploy_setup_role, fetch(:magento_deploy_setup_role, :all)
376
- set :magento_deploy_cache_shared, fetch(:magento_deploy_cache_shared, true)
377
- end
378
- 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.3
4
+ version: 0.5.4
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-10-10 00:00:00.000000000 Z
11
+ date: 2016-10-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: capistrano
@@ -58,14 +58,14 @@ dependencies:
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: '1.11'
61
+ version: '1.7'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: '1.11'
68
+ version: '1.7'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: rake
71
71
  requirement: !ruby/object:Gem::Requirement
@@ -89,6 +89,7 @@ extensions: []
89
89
  extra_rdoc_files: []
90
90
  files:
91
91
  - ".gitignore"
92
+ - ".travis.yml"
92
93
  - CHANGELOG.md
93
94
  - Gemfile
94
95
  - LICENSE.md
@@ -97,6 +98,7 @@ files:
97
98
  - capistrano-magento2.gemspec
98
99
  - lib/capistrano-magento2.rb
99
100
  - lib/capistrano/magento2.rb
101
+ - lib/capistrano/magento2/defaults.rb
100
102
  - lib/capistrano/magento2/deploy.rb
101
103
  - lib/capistrano/magento2/notifier.rb
102
104
  - lib/capistrano/magento2/pending.rb