capistrano-magento2 0.1.3 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +20 -0
- data/README.md +79 -9
- data/lib/capistrano/magento2.rb +0 -2
- data/lib/capistrano/magento2/deploy.rb +1 -0
- data/lib/capistrano/magento2/{deploy/notify.rb → notifier.rb} +2 -2
- data/lib/capistrano/magento2/version.rb +1 -1
- data/lib/capistrano/tasks/deploy.rake +7 -4
- data/lib/capistrano/tasks/magento.rake +100 -57
- data/lib/capistrano/tasks/{deploy/notify.rake → notifier.rake} +0 -0
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7c26fa9d5aee2efa6058343f4778e782cf3bd819
|
4
|
+
data.tar.gz: 9b0df9b6a112a8d1426bb6d952d5e88bde7720b0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3fbce42ba76649f409114fabe570d5c5403feb556e031d08a7d002c76f2d21e1e47a2b74e4d00f51b7d479312e67ca5d9aeabde739d5a1b8c6c0bc43b40821c6
|
7
|
+
data.tar.gz: ae50da8be58fc6e35c8b11a0b62615897c13bc2d6cd9af178da4ceffaaece366e076b06895f3d61f8dc38f9a93c65aa68a96be177c5262b88bb338cf82e82c3d
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,25 @@
|
|
1
1
|
# Capistrano::Magento2 Change Log
|
2
2
|
|
3
|
+
0.2.0
|
4
|
+
==========
|
5
|
+
|
6
|
+
* Added "smart" magento:setup:di:compile task which uses multi-tenant if available (for compatibility with 2.0 release)
|
7
|
+
* Added a command_map for the bin/magento tool to simplify rake files
|
8
|
+
* Added indexer:info, indexer:status, indexer:show-mode, indexer:set-mode
|
9
|
+
* Added maintenance:status and maintenance:allow-ips, exposes maintenance:disable
|
10
|
+
* Fixed broken error detection logic on setup:static-content:deploy
|
11
|
+
* Fixed bug where magento:setup:upgrade was not using the --keep-generated flag
|
12
|
+
* Fixed log bloat caused by chatty static-content:deploy
|
13
|
+
* Fixed missing dependency include in deploy.rb
|
14
|
+
* Fixed output of magento:cache:varnish:ban command
|
15
|
+
* Fixed potential issue where if a botched release was in production, one could not roll back
|
16
|
+
* Fixed technical dependency bug preventing projects from overriding the deploy.rake with a custom one
|
17
|
+
* Renamed capistrano/magento2/deploy/notify to capistrano/magento2/notifier
|
18
|
+
* Renamed magento:reset_permissions to magento:setup:permissions
|
19
|
+
* Renamed magento:setup:static_content:deploy to magento:setup:static-content:deploy
|
20
|
+
* Updated composer calls to explicitly set --prefer-dist and --no-interaction
|
21
|
+
* Updated README to reflect current setup instructions
|
22
|
+
|
3
23
|
0.1.3
|
4
24
|
==========
|
5
25
|
|
data/README.md
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
# Capistrano::Magento2
|
2
2
|
|
3
|
+
[](https://badge.fury.io/rb/capistrano-magento2)
|
4
|
+
|
3
5
|
A Capistrano extension for Magento 2 deployments. Takes care of specific Magento 2 requirements and adds tasks specific to the Magento 2 application.
|
4
6
|
|
5
7
|
## Installation
|
@@ -22,10 +24,12 @@ Or install it yourself as:
|
|
22
24
|
|
23
25
|
Install Capistrano in your Magento project:
|
24
26
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
27
|
+
```shell
|
28
|
+
$ cd <project_root>
|
29
|
+
$ mkdir -p tools/cap
|
30
|
+
$ cd ./tools/cap
|
31
|
+
$ cap install
|
32
|
+
```
|
29
33
|
|
30
34
|
Update your project `Capfile` to look like the following:
|
31
35
|
|
@@ -34,20 +38,86 @@ Update your project `Capfile` to look like the following:
|
|
34
38
|
require 'capistrano/setup'
|
35
39
|
|
36
40
|
# Load Magento deployment tasks
|
37
|
-
require 'capistrano/
|
41
|
+
require 'capistrano/magento2/deploy'
|
38
42
|
```
|
39
43
|
|
40
|
-
|
44
|
+
## Default Configuration
|
45
|
+
|
46
|
+
### Capistrano Built-Ins
|
47
|
+
|
48
|
+
For the sake of simplicity in new project setups `:linked_dirs` and `:linked_files` are pre-configured per the following.
|
41
49
|
|
42
50
|
```ruby
|
43
|
-
|
51
|
+
set :linked_files, [
|
52
|
+
'app/etc/env.php',
|
53
|
+
'var/.setup_cronjob_status',
|
54
|
+
'var/.update_cronjob_status',
|
55
|
+
'sitemap.xml'
|
56
|
+
]
|
57
|
+
|
58
|
+
set :linked_dirs, [
|
59
|
+
'pub/media',
|
60
|
+
'var/backups',
|
61
|
+
'var/composer_home',
|
62
|
+
'var/importexport',
|
63
|
+
'var/import_history',
|
64
|
+
'var/log',
|
65
|
+
'var/session',
|
66
|
+
'var/tmp'
|
67
|
+
]
|
68
|
+
```
|
69
|
+
|
70
|
+
### Magento 2 Deploy Routine
|
71
|
+
|
72
|
+
A pre-built deploy routine is available out-of-the-box. This can be overriden on a per-project basis by including only the Magento 2 specific tasks and defining your own `deploy.rake` file under `lib/capistrano/tasks` in your projects capistrano install location.
|
73
|
+
|
74
|
+
To see what process the built-in routine runs, take a look at the included rake file here: https://github.com/davidalger/capistrano-magento2/blob/master/lib/capistrano/tasks/deploy.rake
|
75
|
+
|
76
|
+
## Magento Specific Tasks
|
77
|
+
|
78
|
+
All Magento 2 tasks used by the built-in `deploy.rake` file as well as some additional commands are implimented and exposed to the end-user for use directly via the cap tool. You can also see this list by running `cap -T` from your shell.
|
79
|
+
|
80
|
+
| cap command | what it does |
|
81
|
+
| ------------------------------------- | -------------------------------------------------- |
|
82
|
+
| magento:cache:clean | Clean Magento cache by types |
|
83
|
+
| magento:cache:disable | Disable Magento cache |
|
84
|
+
| magento:cache:enable | Enable Magento cache |
|
85
|
+
| magento:cache:flush | Flush Magento cache storage |
|
86
|
+
| magento:cache:status | Check Magento cache enabled status |
|
87
|
+
| magento:cache:varnish:ban | Add ban to Varnish for url(s) |
|
88
|
+
| magento:composer:install | Run composer install |
|
89
|
+
| magento:indexer:info | Shows allowed indexers |
|
90
|
+
| magento:indexer:reindex | Reindex data by all indexers |
|
91
|
+
| magento:indexer:set-mode[mode,index] | Sets mode of all indexers |
|
92
|
+
| magento:indexer:show-mode[index] | Shows mode of all indexers |
|
93
|
+
| magento:indexer:status | Shows status of all indexers |
|
94
|
+
| magento:maintenance:allow-ips[ip] | Sets maintenance mode exempt IPs |
|
95
|
+
| magento:maintenance:disable | Disable maintenance mode |
|
96
|
+
| magento:maintenance:enable | Enable maintenance mode |
|
97
|
+
| magento:maintenance:status | Displays maintenance mode status |
|
98
|
+
| magento:setup:di:compile | Runs dependency injection compilation routine |
|
99
|
+
| magento:setup:permissions | Sets proper permissions on application |
|
100
|
+
| magento:setup:static-content:deploy | Deploys static view files |
|
101
|
+
| magento:setup:upgrade | Run the Magento upgrade process |
|
102
|
+
|
103
|
+
## Using Capistrano
|
104
|
+
|
105
|
+
For inrformation on how to use Capistrano and setup deployment take a look at the [Capistrano documentation](http://capistranorb.com) and [README](https://github.com/capistrano/capistrano/blob/master/README.md) file.
|
106
|
+
|
107
|
+
## Terminal Notifier on OS X
|
108
|
+
This gem specifies [terminal-notifier](https://rubygems.org/gems/terminal-notifier) as a dependency in order to support notifications on OS X via an optional include. To use the built-in notifications, add the following line to your `Capfile`:
|
109
|
+
|
110
|
+
```ruby
|
111
|
+
require 'capistrano/magento2/notifier'
|
44
112
|
```
|
45
113
|
|
46
114
|
## Development
|
47
115
|
|
48
|
-
After checking out the repo, run `bundle install` to install dependencies.
|
116
|
+
After checking out the repo, run `bundle install` to install dependencies. Make the neccesary changes, then run `bundle exec rake install` to install a modified version of the gem on your local system.
|
117
|
+
|
118
|
+
To release a new version, update the version number in `capistrano/magento2/version.rb`, merge all changes to master, and then run `bundle exec rake release`. This will create a git tag for the version (the tag will apply to the current HEAD), push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
49
119
|
|
50
|
-
|
120
|
+
_Note: Releasing a new version of the gem is only possible for those with maintainer access to the gem on rubygems.org._
|
51
121
|
|
52
122
|
## Contributing
|
53
123
|
|
data/lib/capistrano/magento2.rb
CHANGED
@@ -11,10 +11,13 @@ namespace :deploy do
|
|
11
11
|
task :updated do
|
12
12
|
on release_roles :all do
|
13
13
|
invoke 'magento:composer:install'
|
14
|
-
invoke 'magento:
|
15
|
-
invoke 'magento:setup:
|
16
|
-
invoke 'magento:setup:di:
|
17
|
-
invoke 'magento:
|
14
|
+
invoke 'magento:setup:permissions'
|
15
|
+
invoke 'magento:setup:static-content:deploy'
|
16
|
+
invoke 'magento:setup:di:compile'
|
17
|
+
invoke 'magento:setup:permissions'
|
18
|
+
within current_path do
|
19
|
+
execute :magento, 'maintenance:enable'
|
20
|
+
end
|
18
21
|
invoke 'magento:maintenance:enable'
|
19
22
|
invoke 'magento:setup:upgrade'
|
20
23
|
end
|
@@ -14,7 +14,7 @@ namespace :magento do
|
|
14
14
|
task :flush do
|
15
15
|
on release_roles :all do
|
16
16
|
within release_path do
|
17
|
-
execute :
|
17
|
+
execute :magento, 'cache:flush'
|
18
18
|
end
|
19
19
|
end
|
20
20
|
end
|
@@ -23,7 +23,7 @@ namespace :magento do
|
|
23
23
|
task :clean do
|
24
24
|
on release_roles :all do
|
25
25
|
within release_path do
|
26
|
-
execute :
|
26
|
+
execute :magento, 'cache:clean'
|
27
27
|
end
|
28
28
|
end
|
29
29
|
end
|
@@ -32,7 +32,7 @@ namespace :magento do
|
|
32
32
|
task :enable do
|
33
33
|
on release_roles :all do
|
34
34
|
within release_path do
|
35
|
-
execute :
|
35
|
+
execute :magento, 'cache:enable'
|
36
36
|
end
|
37
37
|
end
|
38
38
|
end
|
@@ -41,7 +41,7 @@ namespace :magento do
|
|
41
41
|
task :disable do
|
42
42
|
on release_roles :all do
|
43
43
|
within release_path do
|
44
|
-
execute :
|
44
|
+
execute :magento, 'cache:disable'
|
45
45
|
end
|
46
46
|
end
|
47
47
|
end
|
@@ -50,7 +50,7 @@ namespace :magento do
|
|
50
50
|
task :status do
|
51
51
|
on release_roles :all do
|
52
52
|
within release_path do
|
53
|
-
execute :
|
53
|
+
execute :magento, 'cache:status'
|
54
54
|
end
|
55
55
|
end
|
56
56
|
end
|
@@ -59,19 +59,14 @@ namespace :magento do
|
|
59
59
|
desc 'Add ban to Varnish for url(s)'
|
60
60
|
task :ban do
|
61
61
|
on release_roles :all do
|
62
|
+
# TODO: Document use of :ban_pools and :varnish_cache_hosts in project config file
|
62
63
|
next unless any? :ban_pools
|
63
64
|
next unless any? :varnish_cache_hosts
|
64
65
|
|
65
66
|
within release_path do
|
66
67
|
for pool in fetch(:ban_pools) do
|
67
68
|
for cache_host in fetch(:varnish_cache_hosts) do
|
68
|
-
|
69
|
-
if response.include? '<title>200 Purged</title>'
|
70
|
-
puts " 200 Purged: #{pool}"
|
71
|
-
elsif
|
72
|
-
puts "\e[0;31m Warning: Failed to ban '#{pool}' pool on cache host '#{cache_host}'!\n"
|
73
|
-
puts "#{response}\n\e[0m\n"
|
74
|
-
end
|
69
|
+
execute :curl, %W{-s -H 'X-Pool: #{pool}' -X PURGE #{cache_host}}
|
75
70
|
end
|
76
71
|
end
|
77
72
|
end
|
@@ -85,11 +80,11 @@ namespace :magento do
|
|
85
80
|
task :install do
|
86
81
|
on release_roles :all do
|
87
82
|
within release_path do
|
88
|
-
execute :composer, 'install --no-interaction 2>&1'
|
83
|
+
execute :composer, 'install --prefer-dist --no-interaction 2>&1'
|
89
84
|
|
90
85
|
# Dir should be here if properly setup, but check for it anyways just in case
|
91
86
|
if test "[ -d #{release_path}/update ]"
|
92
|
-
execute :composer, 'install -d ./update 2>&1'
|
87
|
+
execute :composer, 'install --prefer-dist --no-interaction -d ./update 2>&1'
|
93
88
|
else
|
94
89
|
puts "\e[0;31m Warning: ./update dir does not exist in repository!\n\e[0m\n"
|
95
90
|
end
|
@@ -103,45 +98,51 @@ namespace :magento do
|
|
103
98
|
task :upgrade do
|
104
99
|
on release_roles :all do
|
105
100
|
within release_path do
|
106
|
-
execute :
|
101
|
+
execute :magento, 'setup:upgrade --keep-generated'
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
desc 'Sets proper permissions on application'
|
107
|
+
task :permissions do
|
108
|
+
on release_roles :all do
|
109
|
+
within release_path do
|
110
|
+
execute :find, release_path, '-type d -exec chmod 770 {} +'
|
111
|
+
execute :find, release_path, '-type f -exec chmod 660 {} +'
|
112
|
+
execute :chmod, '-R g+s', release_path
|
113
|
+
execute :chmod, '+x ./bin/magento'
|
107
114
|
end
|
108
115
|
end
|
109
116
|
end
|
110
117
|
|
111
|
-
# TODO: Change this once the bug with single tenant compiler is fixed http://devdocs.magento.com/guides/v2.0/config-guide/cli/config-cli-subcommands-compiler.html#config-cli-subcommands-single
|
112
118
|
namespace :di do
|
113
|
-
|
119
|
+
desc 'Runs dependency injection compilation routine'
|
120
|
+
task :compile do
|
114
121
|
on release_roles :all do
|
115
122
|
within release_path do
|
116
|
-
|
117
|
-
|
123
|
+
# Due to a bug in the single-tenant compiler released in 2.0 (see here for details: http://bit.ly/21eMPtt)
|
124
|
+
# we have to use multi-tenant currently. However, the multi-tenant is being dropped in 2.1 and is no longer
|
125
|
+
# present in the develop mainline, so we are testing for multi-tenant presence for long-term portability.
|
126
|
+
if test :magento, 'setup:di:compile-multi-tenant --help'
|
127
|
+
execute :magento, 'setup:di:compile-multi-tenant'
|
128
|
+
execute :rm, '-f var/di/relations.ser' # TODO: Workaround broken DI compilation on PHP 7.0.5 (GH #4070)
|
129
|
+
else
|
130
|
+
execute :magento, 'setup:di:compile'
|
131
|
+
end
|
118
132
|
end
|
119
133
|
end
|
120
134
|
end
|
121
135
|
end
|
122
136
|
|
123
|
-
namespace
|
137
|
+
namespace 'static-content' do
|
138
|
+
desc 'Deploys static view files'
|
124
139
|
task :deploy do
|
125
140
|
on release_roles :all do
|
126
141
|
within release_path do
|
127
|
-
|
128
|
-
#
|
129
|
-
|
130
|
-
|
131
|
-
# compilation is successful. Once the aforementioned bug is fixed, pass a "-q" flag to
|
132
|
-
# 'setup:static-content:deploy' to silence verbose output, as right now the log is being filled with
|
133
|
-
# thousands of extraneous lines, per this issue: https://github.com/magento/magento2/issues/3692
|
134
|
-
output = capture :php, '-f bin/magento -- setup:static-content:deploy', verbosity: Logger::INFO
|
135
|
-
|
136
|
-
# TODO: add method to output heading messages such as this
|
137
|
-
if output.to_s.include? 'Compilation from source'
|
138
|
-
puts "\n\e[0;31m" \
|
139
|
-
" ######################################################################\n" \
|
140
|
-
" # #\n" \
|
141
|
-
" # Failed to compile static assets #\n" \
|
142
|
-
" # #\n" \
|
143
|
-
" ######################################################################\n\n"
|
144
|
-
puts output + "\e[0m\n"
|
142
|
+
# TODO: Remove custom error detection logic once magento/magento2#3060 is resolved
|
143
|
+
# Currently the cli tool is not reporting failures via the exit code, so manual detection is neccesary
|
144
|
+
output = capture :magento, 'setup:static-content:deploy | stdbuf -o0 tr -d .', verbosity: Logger::INFO
|
145
|
+
if not output.to_s.include? 'New version of deployed files'
|
145
146
|
raise Exception, 'Failed to compile static assets'
|
146
147
|
end
|
147
148
|
end
|
@@ -154,33 +155,36 @@ namespace :magento do
|
|
154
155
|
desc 'Enable maintenance mode'
|
155
156
|
task :enable do
|
156
157
|
on release_roles :all do
|
157
|
-
|
158
|
-
|
159
|
-
execute :php, '-f bin/magento -- maintenance:enable'
|
160
|
-
end
|
158
|
+
within release_path do
|
159
|
+
execute :magento, 'maintenance:enable'
|
161
160
|
end
|
162
161
|
end
|
163
162
|
end
|
164
163
|
|
164
|
+
desc 'Disable maintenance mode'
|
165
165
|
task :disable do
|
166
166
|
on release_roles :all do
|
167
|
-
|
168
|
-
|
169
|
-
execute :php, '-f bin/magento -- maintenance:disable'
|
170
|
-
end
|
167
|
+
within release_path do
|
168
|
+
execute :magento, 'maintenance:disable'
|
171
169
|
end
|
172
170
|
end
|
173
171
|
end
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
172
|
+
|
173
|
+
desc 'Displays maintenance mode status'
|
174
|
+
task :status do
|
175
|
+
on release_roles :all do
|
176
|
+
within release_path do
|
177
|
+
execute :magento, 'maintenance:status'
|
178
|
+
end
|
179
|
+
end
|
180
|
+
end
|
181
|
+
|
182
|
+
desc 'Sets maintenance mode exempt IPs'
|
183
|
+
task 'allow-ips', :ip do |t, args|
|
184
|
+
on release_roles :all do
|
185
|
+
within release_path do
|
186
|
+
execute :magento, 'maintenance:allow-ips', args[:ip]
|
187
|
+
end
|
184
188
|
end
|
185
189
|
end
|
186
190
|
end
|
@@ -190,7 +194,43 @@ namespace :magento do
|
|
190
194
|
task :reindex do
|
191
195
|
on release_roles :all do
|
192
196
|
within release_path do
|
193
|
-
execute :
|
197
|
+
execute :magento, 'indexer:reindex'
|
198
|
+
end
|
199
|
+
end
|
200
|
+
end
|
201
|
+
|
202
|
+
desc 'Shows allowed indexers'
|
203
|
+
task :info do
|
204
|
+
on release_roles :all do
|
205
|
+
within release_path do
|
206
|
+
execute :magento, 'indexer:info'
|
207
|
+
end
|
208
|
+
end
|
209
|
+
end
|
210
|
+
|
211
|
+
desc 'Shows status of all indexers'
|
212
|
+
task :status do
|
213
|
+
on release_roles :all do
|
214
|
+
within release_path do
|
215
|
+
execute :magento, 'indexer:status'
|
216
|
+
end
|
217
|
+
end
|
218
|
+
end
|
219
|
+
|
220
|
+
desc 'Shows mode of all indexers'
|
221
|
+
task 'show-mode', :index do |t, args|
|
222
|
+
on release_roles :all do
|
223
|
+
within release_path do
|
224
|
+
execute :magento, 'indexer:show-mode', args[:index]
|
225
|
+
end
|
226
|
+
end
|
227
|
+
end
|
228
|
+
|
229
|
+
desc 'Sets mode of all indexers'
|
230
|
+
task 'set-mode', :mode, :index do |t, args|
|
231
|
+
on release_roles :all do
|
232
|
+
within release_path do
|
233
|
+
execute :magento, 'indexer:set-mode', args[:mode], args[:index]
|
194
234
|
end
|
195
235
|
end
|
196
236
|
end
|
@@ -200,6 +240,9 @@ end
|
|
200
240
|
|
201
241
|
namespace :load do
|
202
242
|
task :defaults do
|
243
|
+
|
244
|
+
SSHKit.config.command_map[:magento] = "/usr/bin/env php -f bin/magento --"
|
245
|
+
|
203
246
|
set :linked_files, fetch(:linked_files, []).push(
|
204
247
|
'app/etc/env.php',
|
205
248
|
'var/.setup_cronjob_status',
|
File without changes
|
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.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Alger
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-04-
|
11
|
+
date: 2016-04-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: capistrano
|
@@ -84,11 +84,11 @@ files:
|
|
84
84
|
- lib/capistrano-magento2.rb
|
85
85
|
- lib/capistrano/magento2.rb
|
86
86
|
- lib/capistrano/magento2/deploy.rb
|
87
|
-
- lib/capistrano/magento2/
|
87
|
+
- lib/capistrano/magento2/notifier.rb
|
88
88
|
- lib/capistrano/magento2/version.rb
|
89
89
|
- lib/capistrano/tasks/deploy.rake
|
90
|
-
- lib/capistrano/tasks/deploy/notify.rake
|
91
90
|
- lib/capistrano/tasks/magento.rake
|
91
|
+
- lib/capistrano/tasks/notifier.rake
|
92
92
|
homepage: https://github.com/davidalger/capistrano-magento2
|
93
93
|
licenses:
|
94
94
|
- OSL-3.0
|