capistrano-magento2 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +17 -2
- data/Rakefile +0 -5
- data/capistrano-magento2.gemspec +3 -3
- data/lib/capistrano/magento2.rb +12 -0
- data/lib/capistrano/magento2/deploy.rb +12 -0
- data/lib/capistrano/magento2/deploy/notify.rb +12 -0
- data/lib/capistrano/{magento → magento2}/version.rb +2 -2
- data/lib/capistrano/tasks/deploy.rake +38 -0
- data/lib/capistrano/tasks/deploy/notify.rake +47 -0
- data/lib/capistrano/tasks/magento.rake +216 -0
- metadata +19 -13
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b2b0a1e41429c327605f46c5394844088388a3c0
|
4
|
+
data.tar.gz: 8cd6ab0068b94dc74ccd32a8286206088c61b35b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: be3f2be47149eb0a34353c82cbe3526907c918f4d94baea712d7a08be2c81cbc7679e5718e17ca0562cd505f7042fd2418ae813f13754b9f195c6ef1578b4cb2
|
7
|
+
data.tar.gz: ba9baf7b4ea8f6cbd90d921341aa22344302a1deb35c41c35ea6b884d831b53543302e34fbd68f2e14d30c51ca84a9423b6eaffa06a6a7c9c8f2693b45280937
|
data/README.md
CHANGED
@@ -20,11 +20,26 @@ Or install it yourself as:
|
|
20
20
|
|
21
21
|
## Usage
|
22
22
|
|
23
|
-
|
23
|
+
Install Capistrano in your Magento project:
|
24
|
+
|
25
|
+
$ cd <project_root>
|
26
|
+
$ mkdir -p tools/cap
|
27
|
+
$ cd ./tools/cap
|
28
|
+
$ cap install
|
29
|
+
|
30
|
+
Update your project `Capfile` to look like the following:
|
31
|
+
|
32
|
+
```ruby
|
33
|
+
# Load DSL and set up stages
|
34
|
+
require 'capistrano/setup'
|
35
|
+
|
36
|
+
# Load Magento deployment tasks
|
37
|
+
require 'capistrano/magento'
|
38
|
+
```
|
24
39
|
|
25
40
|
## Development
|
26
41
|
|
27
|
-
After checking out the repo, run `bundle install` to install dependencies.
|
42
|
+
After checking out the repo, run `bundle install` to install dependencies.
|
28
43
|
|
29
44
|
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `capistrano/magento2/version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
30
45
|
|
data/Rakefile
CHANGED
data/capistrano-magento2.gemspec
CHANGED
@@ -9,11 +9,11 @@
|
|
9
9
|
|
10
10
|
lib = File.expand_path('../lib', __FILE__)
|
11
11
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
12
|
-
require 'capistrano/
|
12
|
+
require 'capistrano/magento2/version'
|
13
13
|
|
14
14
|
Gem::Specification.new do |spec|
|
15
15
|
spec.name = 'capistrano-magento2'
|
16
|
-
spec.version = Capistrano::
|
16
|
+
spec.version = Capistrano::Magento2::VERSION
|
17
17
|
spec.authors = ['David Alger']
|
18
18
|
spec.email = ['davidmalger@gmail.com']
|
19
19
|
|
@@ -28,8 +28,8 @@ Gem::Specification.new do |spec|
|
|
28
28
|
spec.require_paths = ['lib']
|
29
29
|
|
30
30
|
spec.add_dependency 'capistrano', '~> 3.1'
|
31
|
+
spec.add_dependency 'terminal-notifier', '~> 1.6'
|
31
32
|
|
32
33
|
spec.add_development_dependency 'bundler', '~> 1.11'
|
33
34
|
spec.add_development_dependency 'rake', '~> 10.0'
|
34
|
-
spec.add_development_dependency 'rspec', '~> 3.0'
|
35
35
|
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
##
|
2
|
+
# Copyright © 2016 by David Alger. All rights reserved
|
3
|
+
#
|
4
|
+
# Licensed under the Open Software License 3.0 (OSL-3.0)
|
5
|
+
# See included LICENSE file for full text of OSL-3.0
|
6
|
+
#
|
7
|
+
# http://davidalger.com/contact/
|
8
|
+
##
|
9
|
+
|
10
|
+
require 'capistrano/magento2/deploy'
|
11
|
+
|
12
|
+
load File.expand_path('../tasks/magento.rake', __FILE__)
|
@@ -0,0 +1,12 @@
|
|
1
|
+
##
|
2
|
+
# Copyright © 2016 by David Alger. All rights reserved
|
3
|
+
#
|
4
|
+
# Licensed under the Open Software License 3.0 (OSL-3.0)
|
5
|
+
# See included LICENSE file for full text of OSL-3.0
|
6
|
+
#
|
7
|
+
# http://davidalger.com/contact/
|
8
|
+
##
|
9
|
+
|
10
|
+
require 'capistrano/deploy'
|
11
|
+
|
12
|
+
load File.expand_path('../../tasks/deploy.rake', __FILE__)
|
@@ -0,0 +1,12 @@
|
|
1
|
+
##
|
2
|
+
# Copyright © 2016 by David Alger. All rights reserved
|
3
|
+
#
|
4
|
+
# Licensed under the Open Software License 3.0 (OSL-3.0)
|
5
|
+
# See included LICENSE file for full text of OSL-3.0
|
6
|
+
#
|
7
|
+
# http://davidalger.com/contact/
|
8
|
+
##
|
9
|
+
|
10
|
+
require 'capistrano/magento2/deploy'
|
11
|
+
|
12
|
+
load File.expand_path('../../../tasks/deploy/notify.rake', __FILE__)
|
@@ -0,0 +1,38 @@
|
|
1
|
+
##
|
2
|
+
# Copyright © 2016 by David Alger. All rights reserved
|
3
|
+
#
|
4
|
+
# Licensed under the Open Software License 3.0 (OSL-3.0)
|
5
|
+
# See included LICENSE file for full text of OSL-3.0
|
6
|
+
#
|
7
|
+
# http://davidalger.com/contact/
|
8
|
+
##
|
9
|
+
|
10
|
+
namespace :deploy do
|
11
|
+
task :updated do
|
12
|
+
on release_roles :all do
|
13
|
+
invoke 'magento:composer:install'
|
14
|
+
invoke 'magento:reset_permissions'
|
15
|
+
invoke 'magento:setup:static_content:deploy'
|
16
|
+
invoke 'magento:setup:di:compile_multi_tenant'
|
17
|
+
invoke 'magento:reset_permissions'
|
18
|
+
invoke 'magento:maintenance:enable'
|
19
|
+
invoke 'magento:setup:upgrade'
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
task :published do
|
24
|
+
on release_roles :all do
|
25
|
+
invoke 'magento:cache:flush'
|
26
|
+
invoke 'magento:cache:varnish:ban' # TODO: this should not be needed after magento/magento2#3339 is released
|
27
|
+
invoke 'magento:maintenance:disable'
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
task :reverted do
|
32
|
+
on release_roles :all do
|
33
|
+
invoke 'magento:maintenance:disable'
|
34
|
+
invoke 'magento:cache:flush'
|
35
|
+
invoke 'magento:cache:varnish:ban'
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
##
|
2
|
+
# Copyright © 2016 by David Alger. All rights reserved
|
3
|
+
#
|
4
|
+
# Licensed under the Open Software License 3.0 (OSL-3.0)
|
5
|
+
# See included LICENSE file for full text of OSL-3.0
|
6
|
+
#
|
7
|
+
# http://davidalger.com/contact/
|
8
|
+
##
|
9
|
+
|
10
|
+
require 'terminal-notifier'
|
11
|
+
|
12
|
+
namespace :deploy do
|
13
|
+
before :starting, :confirm_action do
|
14
|
+
if fetch(:deploy_warn_stages).include? fetch(:stage).to_s
|
15
|
+
message = "Are you sure you want to deploy to #{fetch(:stage).to_s}? [y/N]".center(66)
|
16
|
+
|
17
|
+
puts "\n\e[0;31m"
|
18
|
+
puts " ######################################################################"
|
19
|
+
puts " # #"
|
20
|
+
puts " # #{message} #"
|
21
|
+
puts " # #"
|
22
|
+
puts " ######################################################################\e[0m\n"
|
23
|
+
proceed = STDIN.gets[0..0] rescue nil
|
24
|
+
exit unless proceed == 'y' || proceed == 'Y'
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
after 'deploy:failed', :notify_user_failure do
|
29
|
+
run_locally do
|
30
|
+
set :message, "ERROR in deploying " + fetch(:application).to_s + " to " + fetch(:stage).to_s
|
31
|
+
TerminalNotifier.notify(fetch(:message), :title => 'Capistrano')
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
after :finished, :notify_user do
|
36
|
+
run_locally do
|
37
|
+
set :message, "Finished deploying " + fetch(:application).to_s + " to " + fetch(:stage).to_s
|
38
|
+
TerminalNotifier.notify(fetch(:message), :title => 'Capistrano')
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
namespace :load do
|
44
|
+
task :defaults do
|
45
|
+
set :deploy_warn_stages, fetch(:deploy_warn_stages, []).push('prod', 'production')
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,216 @@
|
|
1
|
+
##
|
2
|
+
# Copyright © 2016 by David Alger. All rights reserved
|
3
|
+
#
|
4
|
+
# Licensed under the Open Software License 3.0 (OSL-3.0)
|
5
|
+
# See included LICENSE file for full text of OSL-3.0
|
6
|
+
#
|
7
|
+
# http://davidalger.com/contact/
|
8
|
+
##
|
9
|
+
|
10
|
+
namespace :magento do
|
11
|
+
|
12
|
+
namespace :cache do
|
13
|
+
desc 'Flush Magento cache storage'
|
14
|
+
task :flush do
|
15
|
+
on release_roles :all do
|
16
|
+
within release_path do
|
17
|
+
execute :php, '-f bin/magento -- cache:flush'
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
desc 'Clean Magento cache by types'
|
23
|
+
task :clean do
|
24
|
+
on release_roles :all do
|
25
|
+
within release_path do
|
26
|
+
execute :php, '-f bin/magento -- cache:clean'
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
desc 'Enable Magento cache'
|
32
|
+
task :enable do
|
33
|
+
on release_roles :all do
|
34
|
+
within release_path do
|
35
|
+
execute :php, '-f bin/magento -- cache:enable'
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
desc 'Disable Magento cache'
|
41
|
+
task :disable do
|
42
|
+
on release_roles :all do
|
43
|
+
within release_path do
|
44
|
+
execute :php, '-f bin/magento -- cache:disable'
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
desc 'Check Magento cache enabled status'
|
50
|
+
task :status do
|
51
|
+
on release_roles :all do
|
52
|
+
within release_path do
|
53
|
+
execute :php, '-f bin/magento -- cache:status'
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
namespace :varnish do
|
59
|
+
desc 'Add ban to Varnish for url(s)'
|
60
|
+
task :ban do
|
61
|
+
on release_roles :all do
|
62
|
+
next unless any? :ban_pools
|
63
|
+
within release_path do
|
64
|
+
for pool in fetch(:ban_pools) do
|
65
|
+
response = capture :curl, %W{-svk -H 'X-Pool: #{pool}' -X PURGE 127.0.0.1:6081}
|
66
|
+
if response.include? '<title>200 Purged</title>'
|
67
|
+
puts " 200 Purged: #{pool}"
|
68
|
+
elsif
|
69
|
+
puts "\e[0;31m Warning: Failed to ban '#{pool}' pool!\n#{response}\n\e[0m\n"
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
namespace :composer do
|
79
|
+
desc 'Run composer install'
|
80
|
+
task :install do
|
81
|
+
on release_roles :all do
|
82
|
+
within release_path do
|
83
|
+
execute :composer, 'install --no-interaction 2>&1'
|
84
|
+
|
85
|
+
# Dir should be here if properly setup, but check for it anyways just in case
|
86
|
+
if test "[ -d #{release_path}/update ]"
|
87
|
+
execute :composer, 'install -d ./update 2>&1'
|
88
|
+
else
|
89
|
+
puts "\e[0;31m Warning: ./update dir does not exist in repository!\n\e[0m\n"
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
namespace :setup do
|
97
|
+
desc 'Run the Magento upgrade process'
|
98
|
+
task :upgrade do
|
99
|
+
on release_roles :all do
|
100
|
+
within release_path do
|
101
|
+
execute :php, '-f bin/magento -- setup:upgrade'
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
# 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
|
107
|
+
namespace :di do
|
108
|
+
task :compile_multi_tenant do
|
109
|
+
on release_roles :all do
|
110
|
+
within release_path do
|
111
|
+
execute :php, '-f bin/magento -- setup:di:compile-multi-tenant -q'
|
112
|
+
execute :rm, '-f var/di/relations.ser' # TODO: Workaround for broken DI compilation in 2.0.4 (GH #4070)
|
113
|
+
end
|
114
|
+
end
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
118
|
+
namespace :static_content do
|
119
|
+
task :deploy do
|
120
|
+
on release_roles :all do
|
121
|
+
within release_path do
|
122
|
+
|
123
|
+
# Due to a bug (https://github.com/magento/magento2/issues/3060) in bin/magento, errors in the
|
124
|
+
# compilation will not result in a non-zero exit code, so Capistrano is not aware an error has occurred.
|
125
|
+
# As a result, we must capture the output and manually search for an error string to determine whether
|
126
|
+
# compilation is successful. Once the aforementioned bug is fixed, pass a "-q" flag to
|
127
|
+
# 'setup:static-content:deploy' to silence verbose output, as right now the log is being filled with
|
128
|
+
# thousands of extraneous lines, per this issue: https://github.com/magento/magento2/issues/3692
|
129
|
+
output = capture :php, '-f bin/magento -- setup:static-content:deploy', verbosity: Logger::INFO
|
130
|
+
|
131
|
+
# TODO: add method to output heading messages such as this
|
132
|
+
if output.to_s.include? 'Compilation from source'
|
133
|
+
puts "\n\e[0;31m" \
|
134
|
+
" ######################################################################\n" \
|
135
|
+
" # #\n" \
|
136
|
+
" # Failed to compile static assets #\n" \
|
137
|
+
" # #\n" \
|
138
|
+
" ######################################################################\n\n"
|
139
|
+
puts output + "\e[0m\n"
|
140
|
+
raise Exception, 'Failed to compile static assets'
|
141
|
+
end
|
142
|
+
end
|
143
|
+
end
|
144
|
+
end
|
145
|
+
end
|
146
|
+
end
|
147
|
+
|
148
|
+
namespace :maintenance do
|
149
|
+
desc 'Enable maintenance mode'
|
150
|
+
task :enable do
|
151
|
+
on release_roles :all do
|
152
|
+
for path in [current_path, release_path].uniq
|
153
|
+
within path do
|
154
|
+
execute :php, '-f bin/magento -- maintenance:enable'
|
155
|
+
end
|
156
|
+
end
|
157
|
+
end
|
158
|
+
end
|
159
|
+
|
160
|
+
task :disable do
|
161
|
+
on release_roles :all do
|
162
|
+
for path in [current_path, release_path].uniq
|
163
|
+
within path do
|
164
|
+
execute :php, '-f bin/magento -- maintenance:disable'
|
165
|
+
end
|
166
|
+
end
|
167
|
+
end
|
168
|
+
end
|
169
|
+
end
|
170
|
+
|
171
|
+
desc 'Reset permissions'
|
172
|
+
task :reset_permissions do
|
173
|
+
on release_roles :all do
|
174
|
+
within release_path do
|
175
|
+
execute :find, release_path, '-type d -exec chmod 770 {} +'
|
176
|
+
execute :find, release_path, '-type f -exec chmod 660 {} +'
|
177
|
+
execute :chmod, '-R g+s', release_path
|
178
|
+
execute :chmod, '+x ./bin/magento'
|
179
|
+
end
|
180
|
+
end
|
181
|
+
end
|
182
|
+
|
183
|
+
namespace :indexer do
|
184
|
+
desc 'Reindex data by all indexers'
|
185
|
+
task :reindex do
|
186
|
+
on release_roles :all do
|
187
|
+
within release_path do
|
188
|
+
execute :php, '-f bin/magento -- indexer:reindex'
|
189
|
+
end
|
190
|
+
end
|
191
|
+
end
|
192
|
+
end
|
193
|
+
|
194
|
+
end
|
195
|
+
|
196
|
+
namespace :load do
|
197
|
+
task :defaults do
|
198
|
+
set :linked_files, fetch(:linked_files, []).push(
|
199
|
+
'app/etc/env.php',
|
200
|
+
'var/.setup_cronjob_status',
|
201
|
+
'var/.update_cronjob_status',
|
202
|
+
'sitemap.xml'
|
203
|
+
)
|
204
|
+
|
205
|
+
set :linked_dirs, fetch(:linked_dirs, []).push(
|
206
|
+
'pub/media',
|
207
|
+
'var/backups',
|
208
|
+
'var/composer_home',
|
209
|
+
'var/importexport',
|
210
|
+
'var/import_history',
|
211
|
+
'var/log',
|
212
|
+
'var/session',
|
213
|
+
'var/tmp'
|
214
|
+
)
|
215
|
+
end
|
216
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: capistrano-magento2
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.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: 2016-
|
11
|
+
date: 2016-04-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: capistrano
|
@@ -25,47 +25,47 @@ dependencies:
|
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '3.1'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
28
|
+
name: terminal-notifier
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '1.
|
34
|
-
type: :
|
33
|
+
version: '1.6'
|
34
|
+
type: :runtime
|
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: '1.6'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
42
|
+
name: bundler
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
47
|
+
version: '1.11'
|
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: '1.11'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
|
-
name:
|
56
|
+
name: rake
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: '
|
61
|
+
version: '10.0'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: '
|
68
|
+
version: '10.0'
|
69
69
|
description: A Capistrano extension for Magento 2 deployments. Takes care of specific
|
70
70
|
Magento 2 requirements and adds tasks specific to the Magento 2 application.
|
71
71
|
email:
|
@@ -81,7 +81,13 @@ files:
|
|
81
81
|
- Rakefile
|
82
82
|
- capistrano-magento2.gemspec
|
83
83
|
- lib/capistrano-magento2.rb
|
84
|
-
- lib/capistrano/
|
84
|
+
- lib/capistrano/magento2.rb
|
85
|
+
- lib/capistrano/magento2/deploy.rb
|
86
|
+
- lib/capistrano/magento2/deploy/notify.rb
|
87
|
+
- lib/capistrano/magento2/version.rb
|
88
|
+
- lib/capistrano/tasks/deploy.rake
|
89
|
+
- lib/capistrano/tasks/deploy/notify.rake
|
90
|
+
- lib/capistrano/tasks/magento.rake
|
85
91
|
homepage: https://github.com/davidalger/capistrano-magento2
|
86
92
|
licenses:
|
87
93
|
- OSL-3.0
|