capistrano-magento2 0.8.7 → 0.9.2

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
  SHA256:
3
- metadata.gz: '0873b9252da2bdba39fcc7f9b3360582696ec9d159ac1e28f3c74ee1823b4f86'
4
- data.tar.gz: 6f3508a50bb1bcc01e7e7c139335da4912241b6779d7ce56f71aa36a7a8ab743
3
+ metadata.gz: b7b7b9c0779c38f43fd63be6e4751b8fc62adecb6764d4b57810694110d6ee7f
4
+ data.tar.gz: 9009bb69c4aeefcdabc24401dc4326f64d3a6a42222a221e7b7ef8161bbd16cb
5
5
  SHA512:
6
- metadata.gz: a30733e4c4f5e48dfe03d6e064042e58a5451ef10963c04cf6e6cdead4839e23acfc98d1f38c203241dfb477a92283953141b03b500fc2583b6e28ccd11d20ea
7
- data.tar.gz: ef98b2145f7526a1aac1b8217941bdf230e24e93ddc37a8331b4a054242acf0d5275d6bbccc6660799127e7d867cbc59e13bec42f611cde13f27d74993faab32
6
+ metadata.gz: e545fd874fac6edecd5e7bfccc2f305d59475c7ee1a524f9d780985576f1863bb803416e9cb0fcc6d524c3974a84eeef1392ec8b7b045822465732c027cf78de
7
+ data.tar.gz: 3a4ad3557415fc876dcc46b025723ad78ca334c0344585208b53038e6363505e7be954f4ec89797226db9cf16e371fe7a4b142f4b6c1c353a7121f52450bb6da
@@ -1,3 +1,7 @@
1
1
  language: ruby
2
2
  rvm:
3
- 2.2
3
+ 2.4
4
+
5
+ before_install:
6
+ - gem update --system
7
+ - gem install bundler
@@ -1,5 +1,57 @@
1
1
  # Capistrano::Magento2 Change Log
2
2
 
3
+ 0.9.2
4
+ =========
5
+
6
+ * Fixed issue preventing use of `after` tasks on `magento:cache:flush` from being used to trigger service reloads at end of deployment ([issue #143](https://github.com/davidalger/capistrano-magento2/issues/143))
7
+ * Updated to use DSL method `invoke!` to call iterant tasks ([see capistrano/capistrano/pull/1911](https://github.com/capistrano/capistrano/pull/1911)))
8
+
9
+ 0.9.1
10
+ =========
11
+
12
+ * 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))
13
+
14
+ 0.9.0
15
+ =========
16
+
17
+ **Upgrade Notes:**
18
+
19
+ 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.
20
+
21
+ 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:
22
+
23
+ ```
24
+ gem 'capistrano', '~> 3.14'
25
+ gem 'capistrano-magento2', '~> 0.9'
26
+ ```
27
+
28
+ If a capistrano version lock is present in a projects `deploy.rb` it will also need to be updated:
29
+
30
+ ```
31
+ lock '~> 3.14'
32
+ ```
33
+
34
+ **Change Summary:**
35
+
36
+ * Dropped support for EOL versions of Magento and scrubbed all gated logic around legacy behaviors in 2.1.x and 2.2.x
37
+ * Removed `magento:deploy:version_check` task and associated warning when attempting to deploy unsupported versions of Magento
38
+ * Updated required version of `capistrano` to `~> 1.13` (>=1.13 and less than 2.0)
39
+ * 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.
40
+ * Dropped explicit default of `:magento_deploy_languages`; will now only be passed to `bin/magento` call when set in project configuration.
41
+ * 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.
42
+ * Added `magento:app:config:status` to available commands for manual execution.
43
+ * 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))
44
+
45
+ 0.8.9
46
+ =========
47
+
48
+ * 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)
49
+
50
+ 0.8.8
51
+ ==========
52
+
53
+ * Added support for zero-side-effect pipeline deployments when scopes/themes have been dumped to config.php
54
+
3
55
  0.8.7
4
56
  ==========
5
57
 
data/README.md CHANGED
@@ -2,11 +2,14 @@
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
 
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**
9
+ The following describes minimum Magento versions supported by releases of this gem. Please use an earlier version to deploy older releases of Magento not supported by the most recent iterations of this gem.
10
+
11
+ * Version 0.9.x supports deployment of Magento 2.3.0 and later.
12
+ * Version 0.7.x supports deployment of Magento 2.1.1 and later.
10
13
 
11
14
  ## Installation
12
15
 
@@ -118,35 +121,33 @@ Before you can use Capistrano to deploy, you must configure the `config/deploy.r
118
121
 
119
122
  ### Magento Deploy Settings
120
123
 
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` | `['en_US']` | 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` | `4` | Number of threads to use for static content deploy
128
- | `:magento_deploy_composer` | `true` | Enables composer install behaviour 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
124
+ | setting | default | what it does
125
+ | ------------------------------ | -------- | ---
126
+ | `:magento_deploy_setup_role` | `:all` | Role from which primary host is chosen to run things like setup:upgrade on
127
+ | `:magento_deploy_cache_shared` | `true` | If true, cache operations are restricted to the primary node in setup role
128
+ | `:magento_deploy_languages` | `[]` | Array of languages passed to static content deploy routine
129
+ | `:magento_deploy_themes` | `[]` | Array of themes passed to static content deploy
130
+ | `:magento_deploy_jobs` | `nil` | Number of threads to use for static content deploy
131
+ | `:magento_deploy_composer` | `true` | Enables composer install behavior in the built-in deploy routine
132
+ | `:magento_deploy_production` | `true` | Enables production specific DI compilation and static content generation
133
+ | `:magento_deploy_no_dev` | `true` | Enables use of --no-dev flag on composer install
134
+ | `:magento_deploy_maintenance` | `true` | Enables use of maintenance mode while magento:setup:upgrade runs
135
+ | `:magento_deploy_confirm` | `[]` | Used to require confirmation of deployment to a set of capistrano stages
136
+ | `:magento_deploy_chmod_d` | `'2770'` | Default permissions applied to all directories in the release path
137
+ | `:magento_deploy_chmod_f` | `'0660'` | Default permissions applied to all non-executable files in the release path
135
138
  | `:magento_deploy_chmod_x` | `['bin/magento']` | Default list of files in release path to set executable bit on
136
- | `:magento_deploy_strategy` | `nil` | Can be `quick`, `standard` or `compact`; supported by Magento 2.2 or later
139
+ | `:magento_deploy_strategy` | `nil` | Can be `quick`, `standard` or `compact`
137
140
 
138
141
  #### Example Usage
139
142
 
140
143
  Add a line similar to the following in `config/deploy.rb` to set a custom value on one of the above settings:
141
144
 
142
145
  ```ruby
146
+ set :magento_deploy_jobs, '$(nproc)'
147
+ set :magento_deploy_themes, ['Magento/backend', 'Magento/blank']
143
148
  set :magento_deploy_languages, ['en_US', 'en_CA']
144
149
  ```
145
150
 
146
- ```ruby
147
- set :magento_deploy_composer, false
148
- ```
149
-
150
151
  ### Capistrano Built-Ins
151
152
 
152
153
  For the sake of simplicity in new project setups `:linked_dirs` and `:linked_files` are pre-configured per the following.
@@ -154,7 +155,6 @@ For the sake of simplicity in new project setups `:linked_dirs` and `:linked_fil
154
155
  ```ruby
155
156
  set :linked_files, [
156
157
  'app/etc/env.php',
157
- 'app/etc/config.local.php',
158
158
  'var/.setup_cronjob_status',
159
159
  'var/.update_cronjob_status'
160
160
  ]
@@ -178,8 +178,6 @@ If you would like to customize the linked files or directories for your project,
178
178
  append :linked_dirs, 'path/to/link'
179
179
  ```
180
180
 
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
181
  ### Composer Auth Credentials
184
182
 
185
183
  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:
@@ -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.1'
30
+ spec.add_dependency 'capistrano', '~> 3.14'
31
31
 
32
- spec.add_development_dependency 'bundler', '~> 2.0'
33
- spec.add_development_dependency 'rake', '~> 10.0'
32
+ spec.add_development_dependency 'bundler', '~> 2.1'
33
+ spec.add_development_dependency 'rake', '~> 13.0'
34
34
  end
@@ -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, ['en_US'])
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) # this defaults to 4 when supported by bin/magento
56
- set :magento_deploy_strategy, fetch(:magento_deploy_strategy, nil) # Magento 2.2 or later only: http://bit.ly/2yhMvVv
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)
@@ -9,6 +9,6 @@
9
9
 
10
10
  module Capistrano
11
11
  module Magento2
12
- VERSION = '0.8.7'
12
+ VERSION = '0.9.2'
13
13
  end
14
14
  end
@@ -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
- before 'deploy:symlink:linked_files', 'magento:deploy:local_config'
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,18 +37,33 @@ 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
35
- invoke 'magento:setup:permissions'
59
+
60
+ invoke 'deploy:symlink:link_env_php'
61
+
62
+ if fetch(:magento_deploy_production)
63
+ invoke 'magento:deploy:mode:production'
64
+ end
65
+
66
+ invoke! 'magento:setup:permissions'
36
67
  invoke 'magento:maintenance:check'
37
68
  invoke 'magento:maintenance:enable' if fetch(:magento_deploy_maintenance)
38
69
 
@@ -44,18 +75,15 @@ namespace :deploy do
44
75
  end
45
76
  end
46
77
 
47
- invoke 'magento:setup:db:schema:upgrade' if not fetch(:magento_internal_zero_down_flag)
48
- invoke 'magento:setup:db:data:upgrade' if not fetch(:magento_internal_zero_down_flag)
49
-
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
78
+ if not fetch(:magento_internal_zero_down_flag)
79
+ on cache_hosts do
80
+ within release_path do
81
+ execute :magento, 'cache:flush'
57
82
  end
58
83
  end
84
+ invoke 'magento:app:config:import'
85
+ invoke 'magento:setup:db:schema:upgrade'
86
+ invoke 'magento:setup:db:data:upgrade'
59
87
  end
60
88
 
61
89
  on primary fetch(:magento_deploy_setup_role) do
@@ -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
 
@@ -184,19 +193,6 @@ namespace :magento do
184
193
  end
185
194
  end
186
195
 
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
196
  task :check do
201
197
  on release_roles :all do
202
198
  next unless any? :linked_files_touch
@@ -218,8 +214,10 @@ namespace :magento do
218
214
  exit 1 # only need to check the repo once, so we immediately exit
219
215
  end
220
216
 
217
+ # Checking app/etc/env.php in shared_path vs release_path to support the zero-side-effect
218
+ # builds as implemented in the :detect_scd_config hook of deploy.rake
221
219
  unless test %Q[#{SSHKit.config.command_map[:php]} -r '
222
- $cfg = include "#{release_path}/app/etc/env.php";
220
+ $cfg = include "#{shared_path}/app/etc/env.php";
223
221
  exit((int)!isset($cfg["install"]["date"]));
224
222
  ']
225
223
  error "\e[0;31mError on #{host}:\e[0m No environment configuration could be found." +
@@ -229,17 +227,6 @@ namespace :magento do
229
227
  end
230
228
  exit 1 if is_err
231
229
  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
230
  end
244
231
 
245
232
  namespace :setup do
@@ -256,7 +243,7 @@ namespace :magento do
256
243
  end
257
244
 
258
245
  namespace :db do
259
- desc 'Checks if database schema and/or data require upgrading'
246
+ desc 'Checks if DB schema or data requires upgrade'
260
247
  task :status do
261
248
  on primary fetch(:magento_deploy_setup_role) do
262
249
  within release_path do
@@ -309,7 +296,6 @@ namespace :magento do
309
296
  end
310
297
  end
311
298
  end
312
- Rake::Task['magento:setup:permissions'].reenable ## make task perpetually callable
313
299
  end
314
300
 
315
301
  namespace :di do
@@ -317,11 +303,8 @@ namespace :magento do
317
303
  task :compile do
318
304
  on release_roles :all do
319
305
  within release_path do
320
- output = capture :magento, 'setup:di:compile --no-ansi', verbosity: Logger::INFO
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'
306
+ with mage_mode: :production do
307
+ execute :magento, "setup:di:compile"
325
308
  end
326
309
  end
327
310
  end
@@ -332,66 +315,42 @@ namespace :magento do
332
315
  desc 'Deploys static view files'
333
316
  task :deploy do
334
317
  on release_roles :all do
335
- _magento_version = magento_version
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')
318
+ with mage_mode: :production do
355
319
  deploy_languages = fetch(:magento_deploy_languages)
356
- else
357
- deploy_languages = [fetch(:magento_deploy_languages).join(' ')]
358
- end
320
+ if deploy_languages.count() > 0
321
+ deploy_languages = deploy_languages.join(' ').prepend(' ')
322
+ else
323
+ deploy_languages = nil
324
+ end
359
325
 
360
- # Magento 2.2 introduced static content compilation strategies that can be one of the following:
361
- # quick (default), standard (like previous versions) or compact
362
- compilation_strategy = fetch(:magento_deploy_strategy)
363
- if compilation_strategy and _magento_version >= Gem::Version.new('2.2.0')
364
- compilation_strategy = "-s #{compilation_strategy} "
365
- else
366
- compilation_strategy = nil
367
- end
326
+ deploy_themes = fetch(:magento_deploy_themes)
327
+ if deploy_themes.count() > 0
328
+ deploy_themes = deploy_themes.join(' -t ').prepend(' -t ')
329
+ else
330
+ deploy_themes = nil
331
+ end
368
332
 
369
- within release_path do
370
- # Magento 2.1 will fail to deploy if this file does not exist and static asset signing is enabled
371
- execute :touch, "#{release_path}/pub/static/deployed_version.txt"
333
+ deploy_jobs = fetch(:magento_deploy_jobs)
334
+ if deploy_jobs
335
+ deploy_jobs = " --jobs #{deploy_jobs}"
336
+ else
337
+ deploy_jobs = nil
338
+ end
372
339
 
373
- # This loop exists to support deploy on versions where each language must be deployed seperately
374
- deploy_languages.each do |lang|
375
- static_content_deploy "#{compilation_strategy}#{deploy_jobs}#{lang}#{deploy_themes}"
340
+ # Static content compilation strategies that can be one of the following:
341
+ # quick (default), standard (like previous versions) or compact
342
+ compilation_strategy = fetch(:magento_deploy_strategy)
343
+ if compilation_strategy
344
+ compilation_strategy = " -s #{compilation_strategy}"
376
345
  end
377
- end
378
346
 
379
- # Run again with HTTPS env var set to 'on' to pre-generate secure versions of RequireJS configs. A
380
- # single run on these Magento versions will fail to generate the secure requirejs-config.js file.
381
- if _magento_version < Gem::Version.new('2.1.8')
382
- deploy_flags = ['css', 'less', 'images', 'fonts', 'html', 'misc', 'html-minify']
383
- .join(' --no-').prepend(' --no-');
347
+ within release_path do
348
+ execute :magento, "setup:static-content:deploy#{compilation_strategy}#{deploy_jobs}#{deploy_languages}#{deploy_themes}"
349
+ end
384
350
 
385
- within release_path do with(https: 'on') {
386
- # This loop exists to support deploy on versions where each language must be deployed seperately
387
- deploy_languages.each do |lang|
388
- static_content_deploy "#{compilation_strategy}#{deploy_jobs}#{lang}#{deploy_themes}#{deploy_flags}"
389
- end
390
- } end
351
+ # Set the deployed_version of static content to ensure it matches across all hosts
352
+ upload!(StringIO.new(deployed_version), "#{release_path}/pub/static/deployed_version.txt")
391
353
  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
354
  end
396
355
  end
397
356
  end
@@ -444,51 +403,43 @@ namespace :magento do
444
403
  end
445
404
 
446
405
  within release_path do
447
- # The setup:db:status command is only available in Magento 2.2.2 and later
448
- if not test :magento, 'setup:db:status --help >/dev/null 2>&1'
449
- info "Magento CLI command setup:db:status is not available. Maintenance mode will be used by default."
450
- else
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
406
+ info "Checking database status..."
407
+ # Check setup:db:status output and if out-of-date do not disable maintenance mode
408
+ database_status = capture :magento, 'setup:db:status', raise_on_non_zero_exit: false
409
+ database_uptodate = false
462
410
 
463
- # Gather md5sums of app/etc/config.php on current and new release
464
- info "Checking config status..."
465
- config_hash_release = capture :md5sum, "#{release_path}/app/etc/config.php"
466
- if test "[ -f #{current_path}/app/etc/config.php ]"
467
- config_hash_current = capture :md5sum, "#{current_path}/app/etc/config.php"
468
- else
469
- config_hash_current = ("%-34s" % "n/a") + "#{current_path}/app/etc/config.php"
470
- end
411
+ if database_status.to_s.include? 'All modules are up to date'
412
+ info "All modules are up to date."
413
+ info ""
414
+ database_uptodate = true
415
+ else
416
+ puts " #{database_status.gsub("\n", "\n ").sub(" Run 'setup:upgrade' to update your DB schema and data.", "")}"
417
+ end
471
418
 
472
- # Output some informational messages showing the config.php hash values
473
- info "<release_path>/app/etc/config.php hash: #{config_hash_release.split(" ")[0]}"
474
- info "<current_path>/app/etc/config.php hash: #{config_hash_current.split(" ")[0]}"
419
+ # Check app:config:status output and if out-of-date do not disable maintenance mode
420
+ info "Checking config status..."
421
+ config_status = capture :magento, 'app:config:status', raise_on_non_zero_exit: false
422
+ config_uptodate = false
475
423
 
476
- # If hashes differ, maintenance mode should not be disabled even if there are no database changes.
477
- if config_hash_release.split(" ")[0] != config_hash_current.split(" ")[0]
478
- info "Maintenance mode will not be disabled (config hashes differ)."
479
- disable_maintenance = false
480
- end
481
- info ""
424
+ if config_status.to_s.include? 'Config files are up to date'
425
+ info "Config files are up to date."
426
+ config_uptodate = true
427
+ else
428
+ puts " #{config_status.gsub("\n", "\n ").sub(" Run app:config:import or setup:upgrade command to synchronize configuration.", "")}"
482
429
  end
430
+ info ""
483
431
 
484
- if maintenance_enabled or disable_maintenance
485
- info "Disabling maintenance mode management..."
432
+ # If both checks above reported up-to-date status checks disable maintenance mode
433
+ if database_uptodate and config_uptodate
434
+ disable_maintenance = true
486
435
  end
487
436
 
488
437
  if maintenance_enabled
438
+ info "Disabling maintenance mode management..."
489
439
  info "Maintenance mode was already active prior to deploy."
490
440
  set :magento_deploy_maintenance, false
491
441
  elsif disable_maintenance
442
+ info "Disabling maintenance mode management..."
492
443
  info "There are no database updates or config changes. This is a zero-down deployment."
493
444
  set :magento_internal_zero_down_flag, true # Set internal flag to stop db schema/data upgrades from running
494
445
  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.8.7
4
+ version: 0.9.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Alger
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-03-01 00:00:00.000000000 Z
11
+ date: 2020-06-12 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.1'
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.1'
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: '2.0'
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: '2.0'
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: '10.0'
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: '10.0'
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,7 +100,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
100
100
  - !ruby/object:Gem::Version
101
101
  version: '0'
102
102
  requirements: []
103
- rubygems_version: 3.0.2
103
+ rubygems_version: 3.1.2
104
104
  signing_key:
105
105
  specification_version: 4
106
106
  summary: A Capistrano extension for Magento 2 deployments.