capistrano-magento2 0.6.6 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +10 -0
- data/README.md +8 -2
- data/lib/capistrano/magento2.rb +13 -28
- data/lib/capistrano/magento2/version.rb +1 -1
- data/lib/capistrano/tasks/deploy.rake +2 -0
- data/lib/capistrano/tasks/magento.rake +57 -48
- metadata +13 -13
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 90ba00a287b7ec92daa13ad5b80e5f9c64b2edd1
|
4
|
+
data.tar.gz: 0f80aa8c230a3892b8103cee6988609f2a6a02f7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 434c6479bba71183db18923cedd3547dbdbefcdc03ec77dba93a1934d0cdfb698b4f5d0f913cf0cf7b21da1941554b2518e7d45ba0cd27aad136ed7f58ef6182
|
7
|
+
data.tar.gz: 32804ed94a37041673ff0b54753e5f03f1334611945c5262f8b0710441219edae030dc3b101232de0926b28bf267689d026f564cfdd6d80458c0e405b34d7cbb
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,15 @@
|
|
1
1
|
# Capistrano::Magento2 Change Log
|
2
2
|
|
3
|
+
0.7.0
|
4
|
+
==========
|
5
|
+
|
6
|
+
* Added support for Magento 2.2.0 release candidates
|
7
|
+
* Removed support for deployment of Magento versions older than 2.1.1
|
8
|
+
* Updated and optimized static content deployment for upcoming Magento 2.2.0 release
|
9
|
+
* Updated composer install routine; --no-dev is now used indiscriminately since Magento 2.1.1 and later support it; no more duplicate composer install commands (issue #76)
|
10
|
+
* Updated multi-lingual site deployment workaround to apply only to versions 2.1.3 through 2.1.7 as per 2.1.8 release notes the underlying issue has been resolved (issue #72)
|
11
|
+
* Added tasks to set production mode and show current mode (magento:deploy:mode:production and magento:deploy:mode:show)
|
12
|
+
|
3
13
|
0.6.6
|
4
14
|
==========
|
5
15
|
|
data/README.md
CHANGED
@@ -4,6 +4,10 @@
|
|
4
4
|
|
5
5
|
A Capistrano extension for Magento 2 deployments. Takes care of specific Magento 2 requirements and adds tasks specific to the Magento 2 application.
|
6
6
|
|
7
|
+
## Supported Magento Versions
|
8
|
+
|
9
|
+
**As of version 0.7.0 this gem only supports deployment of Magento 2.1.1 or later; please use an earlier version to deploy older releases of Magento 2**
|
10
|
+
|
7
11
|
## Installation
|
8
12
|
|
9
13
|
### Standalone Installation
|
@@ -119,8 +123,8 @@ Before you can use Capistrano to deploy, you must configure the `config/deploy.r
|
|
119
123
|
| `:magento_deploy_setup_role` | `:all` | Role from which primary host is chosen to run things like setup:upgrade on
|
120
124
|
| `:magento_deploy_cache_shared` | `true` | If true, cache operations are restricted to the primary node in setup role
|
121
125
|
| `:magento_deploy_languages` | `['en_US']` | Array of languages passed to static content deploy routine
|
122
|
-
| `:magento_deploy_themes` | `[]` | Array of themes passed to static content deploy
|
123
|
-
| `:magento_deploy_jobs` | `4` | Number of threads to use for static content deploy
|
126
|
+
| `:magento_deploy_themes` | `[]` | Array of themes passed to static content deploy
|
127
|
+
| `:magento_deploy_jobs` | `4` | Number of threads to use for static content deploy
|
124
128
|
| `:magento_deploy_composer` | `true` | Enables composer install behaviour in the built-in deploy routine
|
125
129
|
| `:magento_deploy_production` | `true` | Enables production specific DI compilation and static content generation
|
126
130
|
| `:magento_deploy_maintenance` | `true` | Enables use of maintenance mode while magento:setup:upgrade runs
|
@@ -212,6 +216,8 @@ All Magento 2 tasks used by the built-in `deploy.rake` file as well as some addi
|
|
212
216
|
| magento:cache:status | Check Magento cache enabled status |
|
213
217
|
| magento:cache:varnish:ban | Add ban to Varnish for url(s) |
|
214
218
|
| magento:composer:install | Run composer install |
|
219
|
+
| magento:deploy:mode:production | Enables production mode |
|
220
|
+
| magento:deploy:mode:show | Displays current application mode |
|
215
221
|
| magento:indexer:info | Shows allowed indexers |
|
216
222
|
| magento:indexer:reindex | Reindex data by all indexers |
|
217
223
|
| magento:indexer:set-mode[mode,index] | Sets mode of all indexers |
|
data/lib/capistrano/magento2.rb
CHANGED
@@ -29,40 +29,25 @@ module Capistrano
|
|
29
29
|
def cache_hosts
|
30
30
|
return fetch(:magento_deploy_cache_shared) ? (primary fetch :magento_deploy_setup_role) : (release_roles :all)
|
31
31
|
end
|
32
|
-
|
33
|
-
# Set pipefail allowing console exit codes in Magento 2.1.1 and later to halt execution when using pipes
|
34
|
-
def Helpers.set_pipefail
|
35
|
-
if not SSHKit.config.command_map[:magento].include? 'set -o pipefail' # avoids trouble on multi-host deploys
|
36
|
-
@@pipefail_less = SSHKit.config.command_map[:magento].dup
|
37
|
-
SSHKit.config.command_map[:magento] = "set -o pipefail; #{@@pipefail_less}"
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
# Reset the command map without prefix, removing pipefail option so it won't affect other commands
|
42
|
-
def Helpers.unset_pipefail
|
43
|
-
SSHKit.config.command_map[:magento] = @@pipefail_less
|
44
|
-
end
|
45
32
|
end
|
46
33
|
|
47
34
|
module Setup
|
48
35
|
def static_content_deploy params
|
49
|
-
|
50
|
-
|
51
|
-
"setup:static-content:deploy
|
52
|
-
|
53
|
-
|
36
|
+
if magento_version >= Gem::Version.new('2.2.0-rc')
|
37
|
+
# Using -f here just in case MAGE_MODE environment variable in shell is set to something other than production
|
38
|
+
execute :magento, "setup:static-content:deploy -f #{params}"
|
39
|
+
else
|
40
|
+
# Sets pipefail option in shell allowing command exit codes to halt execution when piping command output
|
41
|
+
if not SSHKit.config.command_map[:magento].include? 'set -o pipefail' # avoids trouble on multi-host deploys
|
42
|
+
@@pipefail_less = SSHKit.config.command_map[:magento].dup
|
43
|
+
SSHKit.config.command_map[:magento] = "set -o pipefail; #{@@pipefail_less}"
|
44
|
+
end
|
54
45
|
|
55
|
-
|
56
|
-
# immediately when a console exit code is retruned, never evaluating this code.
|
57
|
-
if not output.to_s.include? 'New version of deployed files'
|
58
|
-
raise Exception, "\e[0;31mFailed to compile static assets. No new version found in command output!\e[0m"
|
59
|
-
end
|
46
|
+
execute :magento, "setup:static-content:deploy #{params} | stdbuf -o0 tr -d ."
|
60
47
|
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
end
|
65
|
-
}
|
48
|
+
# Unsets pipefail option in shell so it won't affect future command executions
|
49
|
+
SSHKit.config.command_map[:magento] = @@pipefail_less
|
50
|
+
end
|
66
51
|
end
|
67
52
|
|
68
53
|
def deployed_version
|
@@ -24,7 +24,9 @@ namespace :deploy do
|
|
24
24
|
task :updated do
|
25
25
|
invoke 'magento:deploy:verify'
|
26
26
|
invoke 'magento:composer:install' if fetch(:magento_deploy_composer)
|
27
|
+
invoke 'magento:deploy:version_check'
|
27
28
|
invoke 'magento:setup:permissions'
|
29
|
+
invoke 'magento:deploy:mode:production'
|
28
30
|
if fetch(:magento_deploy_production)
|
29
31
|
invoke 'magento:setup:static-content:deploy'
|
30
32
|
invoke 'magento:setup:di:compile'
|
@@ -85,7 +85,7 @@ namespace :magento do
|
|
85
85
|
|
86
86
|
on release_roles :all do
|
87
87
|
within release_path do
|
88
|
-
composer_flags = '--prefer-dist --no-interaction'
|
88
|
+
composer_flags = '--no-dev --prefer-dist --no-interaction'
|
89
89
|
|
90
90
|
if fetch(:magento_deploy_production)
|
91
91
|
composer_flags += ' --optimize-autoloader'
|
@@ -93,11 +93,6 @@ namespace :magento do
|
|
93
93
|
|
94
94
|
execute :composer, "install #{composer_flags} 2>&1"
|
95
95
|
|
96
|
-
if fetch(:magento_deploy_production) and magento_version >= Gem::Version.new('2.1')
|
97
|
-
composer_flags += ' --no-dev'
|
98
|
-
execute :composer, "install #{composer_flags} 2>&1" # removes require-dev components from prev command
|
99
|
-
end
|
100
|
-
|
101
96
|
if test "[ -f #{release_path}/update/composer.json ]" # can't count on this, but emit warning if not present
|
102
97
|
execute :composer, "install #{composer_flags} -d ./update 2>&1"
|
103
98
|
else
|
@@ -123,6 +118,39 @@ namespace :magento do
|
|
123
118
|
end
|
124
119
|
|
125
120
|
namespace :deploy do
|
121
|
+
namespace :mode do
|
122
|
+
desc "Enables production mode"
|
123
|
+
task :production do
|
124
|
+
on release_roles :all do
|
125
|
+
within release_path do
|
126
|
+
execute :magento, "deploy:mode:set production --skip-compilation"
|
127
|
+
end
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
131
|
+
desc "Displays current application mode"
|
132
|
+
task :show do
|
133
|
+
on release_roles :all do
|
134
|
+
within release_path do
|
135
|
+
execute :magento, "deploy:mode:show"
|
136
|
+
end
|
137
|
+
end
|
138
|
+
end
|
139
|
+
end
|
140
|
+
|
141
|
+
task :version_check do
|
142
|
+
on release_roles :all do
|
143
|
+
within release_path do
|
144
|
+
_magento_version = magento_version
|
145
|
+
unless _magento_version >= Gem::Version.new('2.1.1')
|
146
|
+
error "\e[0;31mVersion 0.7.0 and later of this gem only support deployment of Magento 2.1.1 or newer; " +
|
147
|
+
"attempted to deploy v" + _magento_version.to_s + ". Please try again using an earlier version of this gem!\e[0m"
|
148
|
+
exit 1 # only need to check a single server, exit immediately
|
149
|
+
end
|
150
|
+
end
|
151
|
+
end
|
152
|
+
end
|
153
|
+
|
126
154
|
task :check do
|
127
155
|
on release_roles :all do
|
128
156
|
next unless any? :linked_files_touch
|
@@ -243,16 +271,8 @@ namespace :magento do
|
|
243
271
|
task :compile do
|
244
272
|
on release_roles :all do
|
245
273
|
within release_path do
|
246
|
-
|
247
|
-
|
248
|
-
# present in the develop mainline, so we are testing for multi-tenant presence for long-term portability.
|
249
|
-
if test :magento, 'setup:di:compile-multi-tenant --help >/dev/null 2>&1'
|
250
|
-
output = capture :magento, 'setup:di:compile-multi-tenant --no-ansi', verbosity: Logger::INFO
|
251
|
-
else
|
252
|
-
output = capture :magento, 'setup:di:compile --no-ansi', verbosity: Logger::INFO
|
253
|
-
end
|
254
|
-
|
255
|
-
# 2.0.x never returns a non-zero exit code for errors, so manually check string
|
274
|
+
output = capture :magento, 'setup:di:compile --no-ansi', verbosity: Logger::INFO
|
275
|
+
|
256
276
|
# 2.1.x doesn't return a non-zero exit code for certain errors (see davidalger/capistrano-magento2#41)
|
257
277
|
if output.to_s.include? 'Errors during compilation'
|
258
278
|
raise Exception, 'DI compilation command execution failed'
|
@@ -271,60 +291,49 @@ namespace :magento do
|
|
271
291
|
deploy_themes = fetch(:magento_deploy_themes)
|
272
292
|
deploy_jobs = fetch(:magento_deploy_jobs)
|
273
293
|
|
274
|
-
if deploy_themes.count() > 0
|
294
|
+
if deploy_themes.count() > 0
|
275
295
|
deploy_themes = deploy_themes.join(' -t ').prepend(' -t ')
|
276
|
-
elsif deploy_themes.count() > 0
|
277
|
-
warn "\e[0;31mWarning: the :magento_deploy_themes setting is only supported in Magento 2.1.1 and later\e[0m"
|
278
|
-
deploy_themes = nil
|
279
296
|
else
|
280
297
|
deploy_themes = nil
|
281
298
|
end
|
282
299
|
|
283
|
-
if deploy_jobs
|
300
|
+
if deploy_jobs
|
284
301
|
deploy_jobs = "--jobs #{deploy_jobs} "
|
285
|
-
elsif deploy_jobs
|
286
|
-
warn "\e[0;31mWarning: the :magento_deploy_jobs setting is only supported in Magento 2.1.1 and later\e[0m"
|
287
|
-
deploy_jobs = nil
|
288
302
|
else
|
289
303
|
deploy_jobs = nil
|
290
304
|
end
|
291
305
|
|
292
|
-
# Workaround core-bug with multi-lingual deployments on Magento 2.1.3
|
293
|
-
#
|
294
|
-
if _magento_version >= Gem::Version.new('2.1.3')
|
306
|
+
# Workaround core-bug with multi-lingual deployments on Magento 2.1.3 through 2.1.7. In these versions each
|
307
|
+
# language must be iterated individuall. See issue #72 for details. Fixed in 2.1.8: http://bit.ly/2fSF8w5
|
308
|
+
if _magento_version >= Gem::Version.new('2.1.3') and _magento_version <= Gem::Version.new('2.1.7')
|
295
309
|
deploy_languages = fetch(:magento_deploy_languages)
|
296
310
|
else
|
297
311
|
deploy_languages = [fetch(:magento_deploy_languages).join(' ')]
|
298
312
|
end
|
299
313
|
|
300
|
-
# Output is being checked for a success message because this command may easily fail due to customizations
|
301
|
-
# and 2.0.x CLI commands do not return error exit codes on failure. See magento/magento2#3060 for details.
|
302
314
|
within release_path do
|
303
|
-
|
304
|
-
# Workaround for 2.1 specific issue: https://github.com/magento/magento2/pull/6437
|
315
|
+
# Magento 2.1 will fail to deploy if this file does not exist and static asset signing is enabled
|
305
316
|
execute "touch #{release_path}/pub/static/deployed_version.txt"
|
306
317
|
|
307
|
-
#
|
308
|
-
deploy_languages.each
|
318
|
+
# This loop exists to support deploy on 2.1.3 thru 2.1.7 where each language must be deployed seperately
|
319
|
+
deploy_languages.each do |lang|
|
320
|
+
static_content_deploy "#{deploy_jobs}#{lang}#{deploy_themes}"
|
321
|
+
end
|
309
322
|
end
|
310
323
|
|
311
324
|
# Run again with HTTPS env var set to 'on' to pre-generate secure versions of RequireJS configs
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
325
|
+
# A single run on Magento 2.1 will fail to generate the secure requirejs-config.js file; 2.2 there is no diff
|
326
|
+
if _magento_version < Gem::Version.new('2.2.0-rc')
|
327
|
+
deploy_flags = ['css', 'less', 'images', 'fonts', 'html', 'misc', 'html-minify']
|
328
|
+
.join(' --no-').prepend(' --no-');
|
329
|
+
|
330
|
+
within release_path do with(https: 'on') {
|
331
|
+
# This loop exists to support deploy on 2.1.3 thru 2.1.7 where each language must be deployed seperately
|
332
|
+
deploy_languages.each do |lang|
|
333
|
+
static_content_deploy "#{deploy_jobs}#{lang}#{deploy_themes}#{deploy_flags}"
|
334
|
+
end
|
335
|
+
} end
|
318
336
|
end
|
319
|
-
|
320
|
-
deploy_flags = deploy_flags.join(' --no-').prepend(' --no-');
|
321
|
-
|
322
|
-
# Magento 2.1.0 and earlier lack support for these flags, so generation of secure files requires full re-run
|
323
|
-
deploy_flags = nil if _magento_version <= Gem::Version.new('2.1.0')
|
324
|
-
|
325
|
-
within release_path do with(https: 'on') {
|
326
|
-
deploy_languages.each {|lang| static_content_deploy "#{deploy_jobs}#{lang}#{deploy_themes}#{deploy_flags}"}
|
327
|
-
} end
|
328
337
|
|
329
338
|
# Set the deployed_version of static content to ensure it matches across all hosts
|
330
339
|
upload!(StringIO.new(deployed_version), "#{release_path}/pub/static/deployed_version.txt")
|
metadata
CHANGED
@@ -1,55 +1,55 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: capistrano-magento2
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.7.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-
|
11
|
+
date: 2017-08-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: capistrano
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - ~>
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '3.1'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - ~>
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '3.1'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: bundler
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - ~>
|
31
|
+
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '1.7'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - ~>
|
38
|
+
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '1.7'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rake
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - ~>
|
45
|
+
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '10.0'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- - ~>
|
52
|
+
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '10.0'
|
55
55
|
description: A Capistrano extension for Magento 2 deployments. Takes care of specific
|
@@ -60,8 +60,8 @@ executables: []
|
|
60
60
|
extensions: []
|
61
61
|
extra_rdoc_files: []
|
62
62
|
files:
|
63
|
-
- .gitignore
|
64
|
-
- .travis.yml
|
63
|
+
- ".gitignore"
|
64
|
+
- ".travis.yml"
|
65
65
|
- CHANGELOG.md
|
66
66
|
- Gemfile
|
67
67
|
- LICENSE.md
|
@@ -89,17 +89,17 @@ require_paths:
|
|
89
89
|
- lib
|
90
90
|
required_ruby_version: !ruby/object:Gem::Requirement
|
91
91
|
requirements:
|
92
|
-
- -
|
92
|
+
- - ">="
|
93
93
|
- !ruby/object:Gem::Version
|
94
94
|
version: '0'
|
95
95
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
96
96
|
requirements:
|
97
|
-
- -
|
97
|
+
- - ">="
|
98
98
|
- !ruby/object:Gem::Version
|
99
99
|
version: '0'
|
100
100
|
requirements: []
|
101
101
|
rubyforge_project:
|
102
|
-
rubygems_version: 2.
|
102
|
+
rubygems_version: 2.6.11
|
103
103
|
signing_key:
|
104
104
|
specification_version: 4
|
105
105
|
summary: A Capistrano extension for Magento 2 deployments.
|