capistrano-magento2 0.8.6 → 0.9.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +5 -1
- data/CHANGELOG.md +51 -0
- data/README.md +18 -23
- data/capistrano-magento2.gemspec +3 -3
- data/lib/capistrano/magento2.rb +0 -22
- data/lib/capistrano/magento2/defaults.rb +3 -5
- data/lib/capistrano/magento2/version.rb +1 -1
- data/lib/capistrano/tasks/deploy.rake +36 -14
- data/lib/capistrano/tasks/magento.rake +71 -118
- metadata +9 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5a8cefc34c3d2656d432987b2c9ddba3385aac14bb5c8f7426a88ac76ffb546c
|
4
|
+
data.tar.gz: e74897a6f3a8da59050bc6bcc246cbc2fcba7192dbdec39d8a48957ea5bed0ba
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4036dbf2bd8507f646a8c7ccb304b5f31a17af33dba7bdd8e9dce572dac7000ce3494eadee0c6c23cf128114216c08c57403ebcf12907e38acbb942ddece2cde
|
7
|
+
data.tar.gz: 101c081d5bf23f30dedf00368ec58d9eceef2fd3e56e6522cfe33558bd819b570d189207c85e397dbe56f678a2e53c73cd968d09a73a86283d6c060dc72860c8
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,56 @@
|
|
1
1
|
# Capistrano::Magento2 Change Log
|
2
2
|
|
3
|
+
0.9.1
|
4
|
+
=========
|
5
|
+
|
6
|
+
* Fixed regression in 0.9.0 where relying on the `-l` flag broke multilingual static content deployment ([issue #141](https://github.com/davidalger/capistrano-magento2/issues/141))
|
7
|
+
|
8
|
+
0.9.0
|
9
|
+
=========
|
10
|
+
|
11
|
+
**Upgrade Notes:**
|
12
|
+
|
13
|
+
As of this release only Magento 2.3 and later are supported and **support has been dropped for prior versions** which have long since reached their end-of-life. Moving forward versions past their EOL will no longer be supported by subsequent releases of this gem. Older versions of this gem may continue to be used to deploy older and EOL versions.
|
14
|
+
|
15
|
+
If using a `Gemfile` with Bundler to lock versions of dependencies used for execution, the version lock on `capistrano` should be updated to `~>1.13` to match the minimal requirement of this release, otherwise `bundle update` will fail to update to version `0.9.0` of this gem. The following is recommended:
|
16
|
+
|
17
|
+
```
|
18
|
+
gem 'capistrano', '~> 3.14'
|
19
|
+
gem 'capistrano-magento2', '~> 0.9'
|
20
|
+
```
|
21
|
+
|
22
|
+
If a capistrano version lock is present in a projects `deploy.rb` it will also need to be updated:
|
23
|
+
|
24
|
+
```
|
25
|
+
lock '~> 3.14'
|
26
|
+
```
|
27
|
+
|
28
|
+
**Change Summary:**
|
29
|
+
|
30
|
+
* Dropped support for EOL versions of Magento and scrubbed all gated logic around legacy behaviors in 2.1.x and 2.2.x
|
31
|
+
* Removed `magento:deploy:version_check` task and associated warning when attempting to deploy unsupported versions of Magento
|
32
|
+
* Updated required version of `capistrano` to `~> 1.13` (>=1.13 and less than 2.0)
|
33
|
+
* Resolved inability to use `--dry-run` flag ([issue #128](https://github.com/davidalger/capistrano-magento2/issues/128)) as made possible by the removal of all version related gating logic.
|
34
|
+
* Dropped explicit default of `:magento_deploy_languages`; will now only be passed to `bin/magento` call when set in project configuration.
|
35
|
+
* Updated zero-down deployment logic to rely on `app:config:status` to detect config changes rather than the md5sum of config.php in current and release directories.
|
36
|
+
* Added `magento:app:config:status` to available commands for manual execution.
|
37
|
+
* Fixes issue in 2.3.4 and later where app:config:import may fail if cache:flush is not run immediately prior ([issue #138](https://github.com/davidalger/capistrano-magento2/issues/138))
|
38
|
+
|
39
|
+
0.8.9
|
40
|
+
=========
|
41
|
+
|
42
|
+
* Fixed issue with RabbitMQ settings caused by app:config:import running after setup-upgrade step vs prior to the database upgrades (which connects to RabbitMQ in recurring data upgrade scripts)
|
43
|
+
|
44
|
+
0.8.8
|
45
|
+
==========
|
46
|
+
|
47
|
+
* Added support for zero-side-effect pipeline deployments when scopes/themes have been dumped to config.php
|
48
|
+
|
49
|
+
0.8.7
|
50
|
+
==========
|
51
|
+
|
52
|
+
* Updated use of `touch` to run such that SSHKit prefixes may be used (PR #110)
|
53
|
+
|
3
54
|
0.8.6
|
4
55
|
==========
|
5
56
|
|
data/README.md
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
[![Gem Version](https://badge.fury.io/rb/capistrano-magento2.svg)](https://badge.fury.io/rb/capistrano-magento2)
|
4
4
|
|
5
|
-
A Capistrano extension for Magento 2 deployments. Takes care of specific Magento 2 requirements and adds tasks specific to the Magento 2 application.
|
5
|
+
A Capistrano extension for Magento 2 deployments. Takes care of specific Magento 2 requirements and adds tasks specific to the Magento 2 application. Supports zero-down deployments based on differences in deployed `config.php` and db status as reported by Magento's `setup:db:status` CLI command. When themes and scopes have been dumped to `config.php` via `bin/magento app:config:dump scopes themes i18n` then zero-side-effect pipeline will be utilized such that no database nor cache backend configuration are available during the build process.
|
6
6
|
|
7
7
|
## Supported Magento Versions
|
8
8
|
|
@@ -118,35 +118,33 @@ Before you can use Capistrano to deploy, you must configure the `config/deploy.r
|
|
118
118
|
|
119
119
|
### Magento Deploy Settings
|
120
120
|
|
121
|
-
| setting | default
|
122
|
-
| ------------------------------ |
|
123
|
-
| `:magento_deploy_setup_role` | `:all`
|
124
|
-
| `:magento_deploy_cache_shared` | `true`
|
125
|
-
| `:magento_deploy_languages` | `[
|
126
|
-
| `:magento_deploy_themes` | `[]`
|
127
|
-
| `:magento_deploy_jobs` | `
|
128
|
-
| `:magento_deploy_composer` | `true`
|
129
|
-
| `:magento_deploy_production` | `true`
|
130
|
-
| `:magento_deploy_no_dev` | `true`
|
131
|
-
| `:magento_deploy_maintenance` | `true`
|
132
|
-
| `:magento_deploy_confirm` | `[]`
|
133
|
-
| `:magento_deploy_chmod_d` | `2770` | Default permissions applied to all directories in the release path
|
134
|
-
| `:magento_deploy_chmod_f` | `0660` | Default permissions applied to all non-executable files in the release path
|
121
|
+
| setting | default | what it does
|
122
|
+
| ------------------------------ | -------- | ---
|
123
|
+
| `:magento_deploy_setup_role` | `:all` | Role from which primary host is chosen to run things like setup:upgrade on
|
124
|
+
| `:magento_deploy_cache_shared` | `true` | If true, cache operations are restricted to the primary node in setup role
|
125
|
+
| `:magento_deploy_languages` | `[]` | Array of languages passed to static content deploy routine
|
126
|
+
| `:magento_deploy_themes` | `[]` | Array of themes passed to static content deploy
|
127
|
+
| `:magento_deploy_jobs` | `nil` | Number of threads to use for static content deploy
|
128
|
+
| `:magento_deploy_composer` | `true` | Enables composer install behavior in the built-in deploy routine
|
129
|
+
| `:magento_deploy_production` | `true` | Enables production specific DI compilation and static content generation
|
130
|
+
| `:magento_deploy_no_dev` | `true` | Enables use of --no-dev flag on composer install
|
131
|
+
| `:magento_deploy_maintenance` | `true` | Enables use of maintenance mode while magento:setup:upgrade runs
|
132
|
+
| `:magento_deploy_confirm` | `[]` | Used to require confirmation of deployment to a set of capistrano stages
|
133
|
+
| `:magento_deploy_chmod_d` | `'2770'` | Default permissions applied to all directories in the release path
|
134
|
+
| `:magento_deploy_chmod_f` | `'0660'` | Default permissions applied to all non-executable files in the release path
|
135
135
|
| `:magento_deploy_chmod_x` | `['bin/magento']` | Default list of files in release path to set executable bit on
|
136
|
-
| `:magento_deploy_strategy` | `nil`
|
136
|
+
| `:magento_deploy_strategy` | `nil` | Can be `quick`, `standard` or `compact`
|
137
137
|
|
138
138
|
#### Example Usage
|
139
139
|
|
140
140
|
Add a line similar to the following in `config/deploy.rb` to set a custom value on one of the above settings:
|
141
141
|
|
142
142
|
```ruby
|
143
|
+
set :magento_deploy_jobs, '$(nproc)'
|
144
|
+
set :magento_deploy_themes, ['Magento/backend', 'Magento/blank']
|
143
145
|
set :magento_deploy_languages, ['en_US', 'en_CA']
|
144
146
|
```
|
145
147
|
|
146
|
-
```ruby
|
147
|
-
set :magento_deploy_composer, false
|
148
|
-
```
|
149
|
-
|
150
148
|
### Capistrano Built-Ins
|
151
149
|
|
152
150
|
For the sake of simplicity in new project setups `:linked_dirs` and `:linked_files` are pre-configured per the following.
|
@@ -154,7 +152,6 @@ For the sake of simplicity in new project setups `:linked_dirs` and `:linked_fil
|
|
154
152
|
```ruby
|
155
153
|
set :linked_files, [
|
156
154
|
'app/etc/env.php',
|
157
|
-
'app/etc/config.local.php',
|
158
155
|
'var/.setup_cronjob_status',
|
159
156
|
'var/.update_cronjob_status'
|
160
157
|
]
|
@@ -178,8 +175,6 @@ If you would like to customize the linked files or directories for your project,
|
|
178
175
|
append :linked_dirs, 'path/to/link'
|
179
176
|
```
|
180
177
|
|
181
|
-
Support for a `app/etc/config.local.php` configuration file was added to Magento 2.1.6. This file will be linked in from the `shared/app/etc` directory as of v0.6.4 of this gem. If this file is present in the project repository, the file will not be linked.
|
182
|
-
|
183
178
|
### Composer Auth Credentials
|
184
179
|
|
185
180
|
Magento 2's composer repository requires auth credentials to install. These can be set on target servers in a global composer `auth.json` file, the project's `composer.json` or by setting them in your deployment configuration using the following two settings:
|
data/capistrano-magento2.gemspec
CHANGED
@@ -27,8 +27,8 @@ Gem::Specification.new do |spec|
|
|
27
27
|
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
28
28
|
spec.require_paths = ['lib']
|
29
29
|
|
30
|
-
spec.add_dependency 'capistrano', '~> 3.
|
30
|
+
spec.add_dependency 'capistrano', '~> 3.14'
|
31
31
|
|
32
|
-
spec.add_development_dependency 'bundler', '~> 1
|
33
|
-
spec.add_development_dependency 'rake', '~>
|
32
|
+
spec.add_development_dependency 'bundler', '~> 2.1'
|
33
|
+
spec.add_development_dependency 'rake', '~> 13.0'
|
34
34
|
end
|
data/lib/capistrano/magento2.rb
CHANGED
@@ -14,10 +14,6 @@ SSHKit.config.command_map[:magento] = "/usr/bin/env php -f bin/magento --"
|
|
14
14
|
module Capistrano
|
15
15
|
module Magento2
|
16
16
|
module Helpers
|
17
|
-
def magento_version
|
18
|
-
return Gem::Version::new((capture :php, "-f #{release_path}/bin/magento -- -V --no-ansi").split(' ').pop)
|
19
|
-
end
|
20
|
-
|
21
17
|
def disabled_modules
|
22
18
|
output = capture :magento, 'module:status --no-ansi'
|
23
19
|
output = output.split("disabled modules:\n", 2)[1]
|
@@ -34,24 +30,6 @@ module Capistrano
|
|
34
30
|
end
|
35
31
|
|
36
32
|
module Setup
|
37
|
-
def static_content_deploy params
|
38
|
-
if magento_version >= Gem::Version.new('2.2.0-rc')
|
39
|
-
# Using -f here just in case MAGE_MODE environment variable in shell is set to something other than production
|
40
|
-
execute :magento, "setup:static-content:deploy -f #{params}"
|
41
|
-
else
|
42
|
-
# Sets pipefail option in shell allowing command exit codes to halt execution when piping command output
|
43
|
-
if not SSHKit.config.command_map[:magento].include? 'set -o pipefail' # avoids trouble on multi-host deploys
|
44
|
-
@@pipefail_less = SSHKit.config.command_map[:magento].dup
|
45
|
-
SSHKit.config.command_map[:magento] = "set -o pipefail; #{@@pipefail_less}"
|
46
|
-
end
|
47
|
-
|
48
|
-
execute :magento, "setup:static-content:deploy #{params} | stdbuf -o0 tr -d ."
|
49
|
-
|
50
|
-
# Unsets pipefail option in shell so it won't affect future command executions
|
51
|
-
SSHKit.config.command_map[:magento] = @@pipefail_less
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
33
|
def deployed_version
|
56
34
|
# Generate a static content version string, but only if one has not already been set on a previous call
|
57
35
|
if not fetch(:magento_static_deployed_version)
|
@@ -9,14 +9,12 @@
|
|
9
9
|
|
10
10
|
set :linked_files, fetch(:linked_files, []).push(
|
11
11
|
'app/etc/env.php',
|
12
|
-
'app/etc/config.local.php',
|
13
12
|
'var/.setup_cronjob_status',
|
14
13
|
'var/.update_cronjob_status'
|
15
14
|
)
|
16
15
|
|
17
16
|
set :linked_files_touch, fetch(:linked_files_touch, []).push(
|
18
17
|
'app/etc/env.php',
|
19
|
-
'app/etc/config.local.php',
|
20
18
|
'var/.setup_cronjob_status',
|
21
19
|
'var/.update_cronjob_status'
|
22
20
|
)
|
@@ -47,13 +45,13 @@ set :magento_deploy_chmod_x, fetch(:magento_deploy_chmod_x, ['bin/magento'])
|
|
47
45
|
# deploy configuration defaults
|
48
46
|
set :magento_deploy_composer, fetch(:magento_deploy_composer, true)
|
49
47
|
set :magento_deploy_confirm, fetch(:magento_deploy_confirm, [])
|
50
|
-
set :magento_deploy_languages, fetch(:magento_deploy_languages, [
|
48
|
+
set :magento_deploy_languages, fetch(:magento_deploy_languages, [])
|
51
49
|
set :magento_deploy_maintenance, fetch(:magento_deploy_maintenance, true)
|
52
50
|
set :magento_deploy_production, fetch(:magento_deploy_production, true)
|
53
51
|
set :magento_deploy_no_dev, fetch(:magento_deploy_no_dev, true)
|
54
52
|
set :magento_deploy_themes, fetch(:magento_deploy_themes, [])
|
55
|
-
set :magento_deploy_jobs, fetch(:magento_deploy_jobs, nil)
|
56
|
-
set :magento_deploy_strategy, fetch(:magento_deploy_strategy, nil)
|
53
|
+
set :magento_deploy_jobs, fetch(:magento_deploy_jobs, nil)
|
54
|
+
set :magento_deploy_strategy, fetch(:magento_deploy_strategy, nil)
|
57
55
|
|
58
56
|
# deploy targetting defaults
|
59
57
|
set :magento_deploy_setup_role, fetch(:magento_deploy_setup_role, :all)
|
@@ -11,7 +11,23 @@ include Capistrano::Magento2::Helpers
|
|
11
11
|
|
12
12
|
namespace :deploy do
|
13
13
|
before 'deploy:check:linked_files', 'magento:deploy:check'
|
14
|
-
|
14
|
+
|
15
|
+
# If both 'scopes' and 'themes' are available in app/etc/config.php then the build should not require database or
|
16
|
+
# cache backend configuration to deploy. Removing the link to app/etc/env.php in this case prevents any possible
|
17
|
+
# side effects that may arise from the build running in parallel to the live production release (such as the cache
|
18
|
+
# being randomly disabled during the composer install step of the build, something which has been observed). This
|
19
|
+
# requires "bin/magento scopes themes i18n" be run to dump theme/store config and the result comitted to repository
|
20
|
+
before 'deploy:symlink:linked_files', :detect_scd_config do
|
21
|
+
on primary fetch(:magento_deploy_setup_role) do
|
22
|
+
unless test %Q[#{SSHKit.config.command_map[:php]} -r '
|
23
|
+
$cfg = include "#{release_path}/app/etc/config.php";
|
24
|
+
exit((int)(isset($cfg["scopes"]) && isset($cfg["themes"])));
|
25
|
+
']
|
26
|
+
info "Removing app/etc/env.php from :linked_dirs for zero-side-effect pipeline deployment."
|
27
|
+
remove :linked_files, 'app/etc/env.php'
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
15
31
|
|
16
32
|
before :starting, :confirm_action do
|
17
33
|
if fetch(:magento_deploy_confirm).include? fetch(:stage).to_s
|
@@ -21,17 +37,32 @@ namespace :deploy do
|
|
21
37
|
end
|
22
38
|
end
|
23
39
|
|
40
|
+
# Links app/etc/env.php if previously dropped from :linked_dirs in :detect_scd_config
|
41
|
+
task 'symlink:link_env_php' do
|
42
|
+
on release_roles :all do
|
43
|
+
# Normally this would be wrapped in a conditional, but during SCD and/or DI compile Magento frequently writes
|
44
|
+
# to cache_types -> compiled_config resulting in an env.php file being present (albeit the wrong one)
|
45
|
+
execute :ln, "-fsn #{shared_path}/app/etc/env.php #{release_path}/app/etc/env.php"
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
24
49
|
task :updated do
|
25
50
|
invoke 'magento:deploy:verify'
|
26
51
|
invoke 'magento:composer:install' if fetch(:magento_deploy_composer)
|
27
|
-
invoke 'magento:deploy:version_check'
|
28
52
|
invoke 'magento:setup:permissions'
|
53
|
+
|
29
54
|
if fetch(:magento_deploy_production)
|
30
|
-
invoke 'magento:deploy:mode:production'
|
31
55
|
invoke 'magento:setup:static-content:deploy'
|
32
56
|
invoke 'magento:setup:di:compile'
|
33
57
|
invoke 'magento:composer:dump-autoload' if fetch(:magento_deploy_composer)
|
34
58
|
end
|
59
|
+
|
60
|
+
invoke 'deploy:symlink:link_env_php'
|
61
|
+
|
62
|
+
if fetch(:magento_deploy_production)
|
63
|
+
invoke 'magento:deploy:mode:production'
|
64
|
+
end
|
65
|
+
|
35
66
|
invoke 'magento:setup:permissions'
|
36
67
|
invoke 'magento:maintenance:check'
|
37
68
|
invoke 'magento:maintenance:enable' if fetch(:magento_deploy_maintenance)
|
@@ -44,20 +75,11 @@ namespace :deploy do
|
|
44
75
|
end
|
45
76
|
end
|
46
77
|
|
78
|
+
invoke 'magento:cache:flush' if not fetch(:magento_internal_zero_down_flag)
|
79
|
+
invoke 'magento:app:config:import' if not fetch(:magento_internal_zero_down_flag)
|
47
80
|
invoke 'magento:setup:db:schema:upgrade' if not fetch(:magento_internal_zero_down_flag)
|
48
81
|
invoke 'magento:setup:db:data:upgrade' if not fetch(:magento_internal_zero_down_flag)
|
49
82
|
|
50
|
-
# The app:config:import command was introduced in 2.2.0; check if it exists before invoking it
|
51
|
-
on primary fetch(:magento_deploy_setup_role) do
|
52
|
-
within release_path do
|
53
|
-
if test :magento, 'app:config:import --help >/dev/null 2>&1'
|
54
|
-
if not fetch(:magento_internal_zero_down_flag)
|
55
|
-
invoke 'magento:app:config:import'
|
56
|
-
end
|
57
|
-
end
|
58
|
-
end
|
59
|
-
end
|
60
|
-
|
61
83
|
on primary fetch(:magento_deploy_setup_role) do
|
62
84
|
within release_path do
|
63
85
|
_disabled_modules = disabled_modules
|
@@ -31,6 +31,15 @@ namespace :magento do
|
|
31
31
|
end
|
32
32
|
end
|
33
33
|
end
|
34
|
+
|
35
|
+
desc 'Checks if config propagation requires update'
|
36
|
+
task :status do
|
37
|
+
on primary fetch(:magento_deploy_setup_role) do
|
38
|
+
within release_path do
|
39
|
+
execute :magento, 'app:config:status'
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
34
43
|
end
|
35
44
|
end
|
36
45
|
|
@@ -42,6 +51,7 @@ namespace :magento do
|
|
42
51
|
execute :magento, 'cache:flush'
|
43
52
|
end
|
44
53
|
end
|
54
|
+
Rake::Task['magento:cache:flush'].reenable ## make task perpetually callable
|
45
55
|
end
|
46
56
|
|
47
57
|
desc 'Clean Magento cache by types'
|
@@ -184,26 +194,13 @@ namespace :magento do
|
|
184
194
|
end
|
185
195
|
end
|
186
196
|
|
187
|
-
task :version_check do
|
188
|
-
on release_roles(:all), in: :sequence, wait: 1 do
|
189
|
-
within release_path do
|
190
|
-
_magento_version = magento_version
|
191
|
-
unless _magento_version >= Gem::Version.new('2.1.1')
|
192
|
-
error "\e[0;31mVersion 0.7.0 and later of this gem only support deployment of Magento 2.1.1 or newer; " +
|
193
|
-
"attempted to deploy v" + _magento_version.to_s + ". Please try again using an earlier version of this gem!\e[0m"
|
194
|
-
exit 1 # only need to check a single server, exit immediately
|
195
|
-
end
|
196
|
-
end
|
197
|
-
end
|
198
|
-
end
|
199
|
-
|
200
197
|
task :check do
|
201
198
|
on release_roles :all do
|
202
199
|
next unless any? :linked_files_touch
|
203
200
|
on release_roles :all do |host|
|
204
201
|
join_paths(shared_path, fetch(:linked_files_touch)).each do |file|
|
205
202
|
unless test "[ -f #{file} ]"
|
206
|
-
execute
|
203
|
+
execute :touch, file
|
207
204
|
end
|
208
205
|
end
|
209
206
|
end
|
@@ -218,8 +215,10 @@ namespace :magento do
|
|
218
215
|
exit 1 # only need to check the repo once, so we immediately exit
|
219
216
|
end
|
220
217
|
|
218
|
+
# Checking app/etc/env.php in shared_path vs release_path to support the zero-side-effect
|
219
|
+
# builds as implemented in the :detect_scd_config hook of deploy.rake
|
221
220
|
unless test %Q[#{SSHKit.config.command_map[:php]} -r '
|
222
|
-
$cfg = include "#{
|
221
|
+
$cfg = include "#{shared_path}/app/etc/env.php";
|
223
222
|
exit((int)!isset($cfg["install"]["date"]));
|
224
223
|
']
|
225
224
|
error "\e[0;31mError on #{host}:\e[0m No environment configuration could be found." +
|
@@ -229,17 +228,6 @@ namespace :magento do
|
|
229
228
|
end
|
230
229
|
exit 1 if is_err
|
231
230
|
end
|
232
|
-
|
233
|
-
task :local_config do
|
234
|
-
on release_roles :all do
|
235
|
-
if test "[ -f #{release_path}/app/etc/config.local.php ]"
|
236
|
-
info "The repository contains app/etc/config.local.php, removing from :linked_files list."
|
237
|
-
_linked_files = fetch(:linked_files, [])
|
238
|
-
_linked_files.delete('app/etc/config.local.php')
|
239
|
-
set :linked_files, _linked_files
|
240
|
-
end
|
241
|
-
end
|
242
|
-
end
|
243
231
|
end
|
244
232
|
|
245
233
|
namespace :setup do
|
@@ -256,7 +244,7 @@ namespace :magento do
|
|
256
244
|
end
|
257
245
|
|
258
246
|
namespace :db do
|
259
|
-
desc 'Checks if
|
247
|
+
desc 'Checks if DB schema or data requires upgrade'
|
260
248
|
task :status do
|
261
249
|
on primary fetch(:magento_deploy_setup_role) do
|
262
250
|
within release_path do
|
@@ -317,11 +305,8 @@ namespace :magento do
|
|
317
305
|
task :compile do
|
318
306
|
on release_roles :all do
|
319
307
|
within release_path do
|
320
|
-
|
321
|
-
|
322
|
-
# 2.1.x doesn't return a non-zero exit code for certain errors (see davidalger/capistrano-magento2#41)
|
323
|
-
if output.to_s.include? 'Errors during compilation'
|
324
|
-
raise Exception, 'DI compilation command execution failed'
|
308
|
+
with mage_mode: :production do
|
309
|
+
execute :magento, "setup:di:compile"
|
325
310
|
end
|
326
311
|
end
|
327
312
|
end
|
@@ -332,66 +317,42 @@ namespace :magento do
|
|
332
317
|
desc 'Deploys static view files'
|
333
318
|
task :deploy do
|
334
319
|
on release_roles :all do
|
335
|
-
|
336
|
-
|
337
|
-
deploy_themes = fetch(:magento_deploy_themes)
|
338
|
-
deploy_jobs = fetch(:magento_deploy_jobs)
|
339
|
-
|
340
|
-
if deploy_themes.count() > 0
|
341
|
-
deploy_themes = deploy_themes.join(' -t ').prepend(' -t ')
|
342
|
-
else
|
343
|
-
deploy_themes = nil
|
344
|
-
end
|
345
|
-
|
346
|
-
if deploy_jobs
|
347
|
-
deploy_jobs = "--jobs #{deploy_jobs} "
|
348
|
-
else
|
349
|
-
deploy_jobs = nil
|
350
|
-
end
|
351
|
-
|
352
|
-
# Workaround core-bug with multi-lingual deployments on Magento 2.1.3 and greater. In these versions each
|
353
|
-
# language must be iterated individually. See issue #72 for details.
|
354
|
-
if _magento_version >= Gem::Version.new('2.1.3')
|
320
|
+
with mage_mode: :production do
|
355
321
|
deploy_languages = fetch(:magento_deploy_languages)
|
356
|
-
|
357
|
-
|
358
|
-
|
322
|
+
if deploy_languages.count() > 0
|
323
|
+
deploy_languages = deploy_languages.join(' ').prepend(' ')
|
324
|
+
else
|
325
|
+
deploy_languages = nil
|
326
|
+
end
|
359
327
|
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
compilation_strategy = nil
|
367
|
-
end
|
328
|
+
deploy_themes = fetch(:magento_deploy_themes)
|
329
|
+
if deploy_themes.count() > 0
|
330
|
+
deploy_themes = deploy_themes.join(' -t ').prepend(' -t ')
|
331
|
+
else
|
332
|
+
deploy_themes = nil
|
333
|
+
end
|
368
334
|
|
369
|
-
|
370
|
-
|
371
|
-
|
335
|
+
deploy_jobs = fetch(:magento_deploy_jobs)
|
336
|
+
if deploy_jobs
|
337
|
+
deploy_jobs = " --jobs #{deploy_jobs}"
|
338
|
+
else
|
339
|
+
deploy_jobs = nil
|
340
|
+
end
|
372
341
|
|
373
|
-
#
|
374
|
-
|
375
|
-
|
342
|
+
# Static content compilation strategies that can be one of the following:
|
343
|
+
# quick (default), standard (like previous versions) or compact
|
344
|
+
compilation_strategy = fetch(:magento_deploy_strategy)
|
345
|
+
if compilation_strategy
|
346
|
+
compilation_strategy = " -s #{compilation_strategy}"
|
376
347
|
end
|
377
|
-
end
|
378
348
|
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
deploy_flags = ['css', 'less', 'images', 'fonts', 'html', 'misc', 'html-minify']
|
383
|
-
.join(' --no-').prepend(' --no-');
|
349
|
+
within release_path do
|
350
|
+
execute :magento, "setup:static-content:deploy#{compilation_strategy}#{deploy_jobs}#{deploy_languages}#{deploy_themes}"
|
351
|
+
end
|
384
352
|
|
385
|
-
|
386
|
-
|
387
|
-
deploy_languages.each do |lang|
|
388
|
-
static_content_deploy "#{compilation_strategy}#{deploy_jobs}#{lang}#{deploy_themes}#{deploy_flags}"
|
389
|
-
end
|
390
|
-
} end
|
353
|
+
# Set the deployed_version of static content to ensure it matches across all hosts
|
354
|
+
upload!(StringIO.new(deployed_version), "#{release_path}/pub/static/deployed_version.txt")
|
391
355
|
end
|
392
|
-
|
393
|
-
# Set the deployed_version of static content to ensure it matches across all hosts
|
394
|
-
upload!(StringIO.new(deployed_version), "#{release_path}/pub/static/deployed_version.txt")
|
395
356
|
end
|
396
357
|
end
|
397
358
|
end
|
@@ -444,51 +405,43 @@ namespace :magento do
|
|
444
405
|
end
|
445
406
|
|
446
407
|
within release_path do
|
447
|
-
|
448
|
-
|
449
|
-
|
450
|
-
|
451
|
-
info "Checking database status..."
|
452
|
-
# Check setup:db:status output and disable maintenance mode if all modules are up-to-date
|
453
|
-
database_status = capture :magento, 'setup:db:status', raise_on_non_zero_exit: false
|
454
|
-
|
455
|
-
if database_status.to_s.include? 'All modules are up to date'
|
456
|
-
info "All modules are up to date. No database updates should occur during this release."
|
457
|
-
info ""
|
458
|
-
disable_maintenance = true
|
459
|
-
else
|
460
|
-
puts " #{database_status.gsub("\n", "\n ").sub("Run 'setup:upgrade' to update your DB schema and data.", "")}"
|
461
|
-
end
|
408
|
+
info "Checking database status..."
|
409
|
+
# Check setup:db:status output and if out-of-date do not disable maintenance mode
|
410
|
+
database_status = capture :magento, 'setup:db:status', raise_on_non_zero_exit: false
|
411
|
+
database_uptodate = false
|
462
412
|
|
463
|
-
|
464
|
-
info "
|
465
|
-
|
466
|
-
|
467
|
-
|
468
|
-
|
469
|
-
|
470
|
-
end
|
413
|
+
if database_status.to_s.include? 'All modules are up to date'
|
414
|
+
info "All modules are up to date."
|
415
|
+
info ""
|
416
|
+
database_uptodate = true
|
417
|
+
else
|
418
|
+
puts " #{database_status.gsub("\n", "\n ").sub(" Run 'setup:upgrade' to update your DB schema and data.", "")}"
|
419
|
+
end
|
471
420
|
|
472
|
-
|
473
|
-
|
474
|
-
|
421
|
+
# Check app:config:status output and if out-of-date do not disable maintenance mode
|
422
|
+
info "Checking config status..."
|
423
|
+
config_status = capture :magento, 'app:config:status', raise_on_non_zero_exit: false
|
424
|
+
config_uptodate = false
|
475
425
|
|
476
|
-
|
477
|
-
|
478
|
-
|
479
|
-
|
480
|
-
|
481
|
-
info ""
|
426
|
+
if config_status.to_s.include? 'Config files are up to date'
|
427
|
+
info "Config files are up to date."
|
428
|
+
config_uptodate = true
|
429
|
+
else
|
430
|
+
puts " #{config_status.gsub("\n", "\n ").sub(" Run app:config:import or setup:upgrade command to synchronize configuration.", "")}"
|
482
431
|
end
|
432
|
+
info ""
|
483
433
|
|
484
|
-
|
485
|
-
|
434
|
+
# If both checks above reported up-to-date status checks disable maintenance mode
|
435
|
+
if database_uptodate and config_uptodate
|
436
|
+
disable_maintenance = true
|
486
437
|
end
|
487
438
|
|
488
439
|
if maintenance_enabled
|
440
|
+
info "Disabling maintenance mode management..."
|
489
441
|
info "Maintenance mode was already active prior to deploy."
|
490
442
|
set :magento_deploy_maintenance, false
|
491
443
|
elsif disable_maintenance
|
444
|
+
info "Disabling maintenance mode management..."
|
492
445
|
info "There are no database updates or config changes. This is a zero-down deployment."
|
493
446
|
set :magento_internal_zero_down_flag, true # Set internal flag to stop db schema/data upgrades from running
|
494
447
|
set :magento_deploy_maintenance, false # Disable maintenance mode management since it is not neccessary
|
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
|
+
version: 0.9.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Alger
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-06-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: capistrano
|
@@ -16,42 +16,42 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '3.
|
19
|
+
version: '3.14'
|
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
|
-
version: '3.
|
26
|
+
version: '3.14'
|
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
|
-
version: '1
|
33
|
+
version: '2.1'
|
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
|
-
version: '1
|
40
|
+
version: '2.1'
|
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
|
-
version: '
|
47
|
+
version: '13.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
|
-
version: '
|
54
|
+
version: '13.0'
|
55
55
|
description: A Capistrano extension for Magento 2 deployments. Takes care of specific
|
56
56
|
Magento 2 requirements and adds tasks specific to the Magento 2 application.
|
57
57
|
email:
|
@@ -100,8 +100,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
100
100
|
- !ruby/object:Gem::Version
|
101
101
|
version: '0'
|
102
102
|
requirements: []
|
103
|
-
|
104
|
-
rubygems_version: 2.7.6
|
103
|
+
rubygems_version: 3.1.2
|
105
104
|
signing_key:
|
106
105
|
specification_version: 4
|
107
106
|
summary: A Capistrano extension for Magento 2 deployments.
|