capistrano-exts 1.13.2 → 1.14.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -0
- data/README.md +2 -0
- data/capistrano-exts.gemspec +10 -12
- data/lib/capistrano-exts/receipts/contao.rb +55 -26
- data/lib/capistrano-exts/receipts/functions.rb +44 -5
- data/lib/capistrano-exts/receipts/web.rb +1 -1
- data/lib/capistrano-exts/version.rb +3 -3
- metadata +93 -34
data/.gitignore
CHANGED
data/README.md
CHANGED
@@ -7,6 +7,8 @@ doing by hand far too often. It provides many helpful post-deployment tasks to
|
|
7
7
|
help you import/export database and contents as well as sync one stage with
|
8
8
|
another.
|
9
9
|
|
10
|
+
[![Click here to lend your support to: Open Source Projects and make a donation at www.pledgie.com !](http://www.pledgie.com/campaigns/16123.png?skin_name=chrome)](http://www.pledgie.com/campaigns/16123)
|
11
|
+
|
10
12
|
# Installation
|
11
13
|
|
12
14
|
Install the gem
|
data/capistrano-exts.gemspec
CHANGED
@@ -26,19 +26,17 @@ EOD
|
|
26
26
|
s.require_paths = ["lib"]
|
27
27
|
|
28
28
|
# Run-time dependencies
|
29
|
-
s.add_dependency
|
30
|
-
s.add_dependency
|
31
|
-
s.add_dependency
|
32
|
-
s.add_dependency
|
29
|
+
s.add_dependency 'capistrano'
|
30
|
+
s.add_dependency 'capistrano_colors'
|
31
|
+
s.add_dependency 'i18n'
|
32
|
+
s.add_dependency 'activesupport', '~>3.2.3'
|
33
33
|
|
34
34
|
# Development dependencies
|
35
|
-
s.add_development_dependency
|
36
|
-
s.add_development_dependency
|
37
|
-
s.add_development_dependency
|
35
|
+
s.add_development_dependency 'guard'
|
36
|
+
s.add_development_dependency 'guard-bundler'
|
37
|
+
s.add_development_dependency 'guard-rspec'
|
38
38
|
|
39
39
|
# Development / Test dependencies
|
40
|
-
s.add_development_dependency
|
41
|
-
|
42
|
-
|
43
|
-
# s.add_development_dependency('faker19', '~>1.0.5')
|
44
|
-
end
|
40
|
+
s.add_development_dependency 'rspec'
|
41
|
+
s.add_development_dependency 'rake'
|
42
|
+
end
|
@@ -17,8 +17,13 @@ Capistrano::Configuration.instance(:must_exist).load do
|
|
17
17
|
end
|
18
18
|
|
19
19
|
namespace :contao do
|
20
|
-
desc "[internal] Setup contao
|
20
|
+
desc "[internal] Setup contao"
|
21
21
|
task :setup, :roles => :app, :except => { :no_release => true } do
|
22
|
+
# Empty task, the rest should hook to it
|
23
|
+
end
|
24
|
+
|
25
|
+
desc "[internal] Setup contao shared contents"
|
26
|
+
task :setup_shared_folder, :roles => :app, :except => { :no_release => true } do
|
22
27
|
shared_path = fetch :shared_path
|
23
28
|
run <<-CMD
|
24
29
|
#{try_sudo} mkdir -p #{shared_path}/logs &&
|
@@ -35,29 +40,31 @@ Capistrano::Configuration.instance(:must_exist).load do
|
|
35
40
|
desc "[internal] Setup contao's localconfig"
|
36
41
|
task :setup_localconfig, :roles => :app, :except => { :no_release => true } do
|
37
42
|
localconfig_php_config_path = "#{fetch :shared_path}/config/public_system_config_localconfig.php"
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
43
|
+
on_rollback { run "rm -f #{localconfig_php_config_path}" }
|
44
|
+
|
45
|
+
localconfig = File.read("config/examples/localconfig.php.erb")
|
46
|
+
mysql_credentials = fetch :mysql_credentials
|
47
|
+
|
48
|
+
mysql_host = mysql_credentials[:host]
|
49
|
+
mysql_user = mysql_credentials[:user]
|
50
|
+
mysql_password = mysql_credentials[:pass]
|
51
|
+
mysql_database = fetch :mysql_db_name
|
52
|
+
contao_env = :production
|
53
|
+
|
54
|
+
put ERB.new(localconfig).result(binding), localconfig_php_config_path
|
55
|
+
end
|
56
|
+
|
57
|
+
desc "[internal] Link files from contao to inside public folder"
|
58
|
+
task :link_contao_files, :roles => :app, :except => { :no_release => true } do
|
59
|
+
files = exhaustive_list_of_files_to_link("#{fetch :latest_release}/contao", "#{fetch :latest_release}/public")
|
60
|
+
commands = files.map do |list|
|
61
|
+
"#{try_sudo} ln -nsf #{list[0]} #{list[1]}"
|
62
|
+
end
|
63
|
+
|
64
|
+
begin
|
65
|
+
run commands.join(';')
|
66
|
+
rescue Capistrano::CommandError
|
67
|
+
abort "Unable to create to link contao files"
|
61
68
|
end
|
62
69
|
end
|
63
70
|
|
@@ -76,14 +83,36 @@ Capistrano::Configuration.instance(:must_exist).load do
|
|
76
83
|
#{try_sudo} ln -nsf #{shared_path}/logs #{latest_release}/public/system/logs
|
77
84
|
CMD
|
78
85
|
end
|
86
|
+
|
87
|
+
desc "Upload contao assets"
|
88
|
+
task :upload_assets, :roles => :app, :except => { :no_release => true } do
|
89
|
+
upload("public/resources", "#{fetch :latest_release}/public/resources", :via => :scp, :recursive => true)
|
90
|
+
end
|
91
|
+
|
92
|
+
desc "[internal] Generate production assets"
|
93
|
+
task :generate_production_assets, :roles => :app, :except => { :no_release => true } do
|
94
|
+
run_locally "bundle exec rake CONTAO_ENV=production assets:precompile"
|
95
|
+
end
|
96
|
+
|
97
|
+
desc "[internal] Generate development assets"
|
98
|
+
task :generate_development_assets, :roles => :app, :except => { :no_release => true } do
|
99
|
+
run_locally "bundle exec rake assets:precompile"
|
100
|
+
end
|
79
101
|
end
|
80
102
|
|
81
103
|
# Dependencies
|
82
104
|
after "deploy:setup", "contao:setup"
|
105
|
+
after "contao:setup", "contao:setup_shared_folder"
|
83
106
|
after "contao:setup", "contao:setup_localconfig"
|
84
|
-
after "deploy:finalize_update", "contao:
|
107
|
+
after "deploy:finalize_update", "contao:link_contao_files"
|
108
|
+
after "contao:link_contao_files", "contao:fix_links"
|
109
|
+
|
110
|
+
# Assets
|
111
|
+
after "contao:link_contao_files", "contao:upload_assets"
|
112
|
+
before "contao:upload_assets", "contao:generate_production_assets"
|
113
|
+
after "contao:upload_assets", "contao:generate_development_assets"
|
85
114
|
|
86
115
|
# Mysql Credentials
|
87
116
|
before "contao:setup_localconfig", "mysql:credentials"
|
88
117
|
before "contao:setup_db", "mysql:credentials"
|
89
|
-
end
|
118
|
+
end
|
@@ -30,6 +30,39 @@ Capistrano::Configuration.instance(:must_exist).load do
|
|
30
30
|
end
|
31
31
|
end
|
32
32
|
|
33
|
+
# Return an array of arrays of files to link
|
34
|
+
#
|
35
|
+
# @param [String] Absolute path to folder from which to link
|
36
|
+
# @param [String] Absolute path to folder to which to link
|
37
|
+
# @return [Array]
|
38
|
+
def exhaustive_list_of_files_to_link(from, to)
|
39
|
+
script = <<-END
|
40
|
+
exhaustive_list_of_files_to_link() {
|
41
|
+
files="";
|
42
|
+
|
43
|
+
for f in `ls -A1 ${1}`; do
|
44
|
+
file="${2}/${f}";
|
45
|
+
f="${1}/${f}";
|
46
|
+
if [[ -e "${file}" ]]; then
|
47
|
+
files="${files} `exhaustive_list_of_files_to_link ${f} ${file}`";
|
48
|
+
else
|
49
|
+
files="${files} ${f}:${file}";
|
50
|
+
fi;
|
51
|
+
done;
|
52
|
+
echo "${files}";
|
53
|
+
};
|
54
|
+
END
|
55
|
+
|
56
|
+
script << "exhaustive_list_of_files_to_link '#{from}' '#{to}';"
|
57
|
+
|
58
|
+
begin
|
59
|
+
files = capture(script).strip.split(' ')
|
60
|
+
files.map {|f| f.split(':')}
|
61
|
+
rescue Capistrano::CommandError
|
62
|
+
abort "Unable to get files list"
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
33
66
|
def link_files(path, files = {})
|
34
67
|
files.each do |f|
|
35
68
|
file_name = f.dup.gsub(/\//, '_')
|
@@ -39,10 +72,16 @@ Capistrano::Configuration.instance(:must_exist).load do
|
|
39
72
|
#{try_sudo} cp -a #{latest_release}/#{f} #{path}/#{file_name}
|
40
73
|
CMD
|
41
74
|
rescue Capistrano::CommandError
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
75
|
+
if remote_file_exists?("#{latest_release}/#{f}.default")
|
76
|
+
run <<-CMD
|
77
|
+
#{try_sudo} cp #{latest_release}/#{f}.default #{path}/#{file_name}
|
78
|
+
CMD
|
79
|
+
else
|
80
|
+
run <<-CMD
|
81
|
+
#{try_sudo} touch #{path}/#{file_name}
|
82
|
+
CMD
|
83
|
+
logger.info "WARNING: You should edit '#{path}/#{file_name}' or re-create it as a folder if that's your intention."
|
84
|
+
end
|
46
85
|
end
|
47
86
|
end
|
48
87
|
|
@@ -151,4 +190,4 @@ password: #{credentials[:pass]}
|
|
151
190
|
def try_bundle_exec
|
152
191
|
"bundle exec"
|
153
192
|
end
|
154
|
-
end
|
193
|
+
end
|
@@ -103,7 +103,7 @@ Capistrano::Configuration.instance(:must_exist).load do
|
|
103
103
|
put result, "#{fetch :shared_path}/__system__/maintenance/index.html", :mode => 0644
|
104
104
|
end
|
105
105
|
|
106
|
-
if fetch(:web_server_app) == :apache
|
106
|
+
if !exists?(:web_server_app) || fetch(:web_server_app) == :apache
|
107
107
|
warn <<-EOHTACCESS
|
108
108
|
|
109
109
|
# Please add something like this to your site's htaccess to redirect users to the maintenance page.
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: capistrano-exts
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.14.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,96 +9,152 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2012-05-23 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: capistrano
|
16
|
-
requirement:
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
|
-
- -
|
19
|
+
- - ! '>='
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version:
|
21
|
+
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements:
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
25
30
|
- !ruby/object:Gem::Dependency
|
26
31
|
name: capistrano_colors
|
27
|
-
requirement:
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
28
33
|
none: false
|
29
34
|
requirements:
|
30
|
-
- -
|
35
|
+
- - ! '>='
|
31
36
|
- !ruby/object:Gem::Version
|
32
|
-
version: 0
|
37
|
+
version: '0'
|
33
38
|
type: :runtime
|
34
39
|
prerelease: false
|
35
|
-
version_requirements:
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
36
46
|
- !ruby/object:Gem::Dependency
|
37
47
|
name: i18n
|
38
|
-
requirement:
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
39
49
|
none: false
|
40
50
|
requirements:
|
41
|
-
- -
|
51
|
+
- - ! '>='
|
42
52
|
- !ruby/object:Gem::Version
|
43
|
-
version: 0
|
53
|
+
version: '0'
|
44
54
|
type: :runtime
|
45
55
|
prerelease: false
|
46
|
-
version_requirements:
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
47
62
|
- !ruby/object:Gem::Dependency
|
48
63
|
name: activesupport
|
49
|
-
requirement:
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
50
65
|
none: false
|
51
66
|
requirements:
|
52
67
|
- - ~>
|
53
68
|
- !ruby/object:Gem::Version
|
54
|
-
version: 3.
|
69
|
+
version: 3.2.3
|
55
70
|
type: :runtime
|
56
71
|
prerelease: false
|
57
|
-
version_requirements:
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ~>
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: 3.2.3
|
58
78
|
- !ruby/object:Gem::Dependency
|
59
79
|
name: guard
|
60
|
-
requirement:
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
61
81
|
none: false
|
62
82
|
requirements:
|
63
|
-
- -
|
83
|
+
- - ! '>='
|
64
84
|
- !ruby/object:Gem::Version
|
65
|
-
version: 0
|
85
|
+
version: '0'
|
66
86
|
type: :development
|
67
87
|
prerelease: false
|
68
|
-
version_requirements:
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ! '>='
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '0'
|
69
94
|
- !ruby/object:Gem::Dependency
|
70
95
|
name: guard-bundler
|
71
|
-
requirement:
|
96
|
+
requirement: !ruby/object:Gem::Requirement
|
72
97
|
none: false
|
73
98
|
requirements:
|
74
|
-
- -
|
99
|
+
- - ! '>='
|
75
100
|
- !ruby/object:Gem::Version
|
76
|
-
version: 0
|
101
|
+
version: '0'
|
77
102
|
type: :development
|
78
103
|
prerelease: false
|
79
|
-
version_requirements:
|
104
|
+
version_requirements: !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
106
|
+
requirements:
|
107
|
+
- - ! '>='
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0'
|
80
110
|
- !ruby/object:Gem::Dependency
|
81
111
|
name: guard-rspec
|
82
|
-
requirement:
|
112
|
+
requirement: !ruby/object:Gem::Requirement
|
83
113
|
none: false
|
84
114
|
requirements:
|
85
|
-
- -
|
115
|
+
- - ! '>='
|
86
116
|
- !ruby/object:Gem::Version
|
87
|
-
version: 0
|
117
|
+
version: '0'
|
88
118
|
type: :development
|
89
119
|
prerelease: false
|
90
|
-
version_requirements:
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
none: false
|
122
|
+
requirements:
|
123
|
+
- - ! '>='
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
version: '0'
|
91
126
|
- !ruby/object:Gem::Dependency
|
92
127
|
name: rspec
|
93
|
-
requirement:
|
128
|
+
requirement: !ruby/object:Gem::Requirement
|
94
129
|
none: false
|
95
130
|
requirements:
|
96
|
-
- -
|
131
|
+
- - ! '>='
|
132
|
+
- !ruby/object:Gem::Version
|
133
|
+
version: '0'
|
134
|
+
type: :development
|
135
|
+
prerelease: false
|
136
|
+
version_requirements: !ruby/object:Gem::Requirement
|
137
|
+
none: false
|
138
|
+
requirements:
|
139
|
+
- - ! '>='
|
140
|
+
- !ruby/object:Gem::Version
|
141
|
+
version: '0'
|
142
|
+
- !ruby/object:Gem::Dependency
|
143
|
+
name: rake
|
144
|
+
requirement: !ruby/object:Gem::Requirement
|
145
|
+
none: false
|
146
|
+
requirements:
|
147
|
+
- - ! '>='
|
97
148
|
- !ruby/object:Gem::Version
|
98
|
-
version:
|
149
|
+
version: '0'
|
99
150
|
type: :development
|
100
151
|
prerelease: false
|
101
|
-
version_requirements:
|
152
|
+
version_requirements: !ruby/object:Gem::Requirement
|
153
|
+
none: false
|
154
|
+
requirements:
|
155
|
+
- - ! '>='
|
156
|
+
- !ruby/object:Gem::Version
|
157
|
+
version: '0'
|
102
158
|
description: ! 'Capistrano exts is a set of helper tasks to help with the initial
|
103
159
|
server
|
104
160
|
|
@@ -198,9 +254,12 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
198
254
|
- - ! '>='
|
199
255
|
- !ruby/object:Gem::Version
|
200
256
|
version: '0'
|
257
|
+
segments:
|
258
|
+
- 0
|
259
|
+
hash: 3949251139176994680
|
201
260
|
requirements: []
|
202
261
|
rubyforge_project:
|
203
|
-
rubygems_version: 1.8.
|
262
|
+
rubygems_version: 1.8.24
|
204
263
|
signing_key:
|
205
264
|
specification_version: 3
|
206
265
|
summary: Set of helper tasks to help with the initial server configuration and application
|