capifony 2.2.9 → 2.2.10
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +11 -0
- data/bin/capifony +1 -1
- data/lib/capifony_symfony2.rb +44 -10
- data/lib/capistrano/recipes/deploy/strategy/capifony_copy_local.rb +25 -0
- data/lib/symfony2/database.rb +10 -5
- data/lib/symfony2/symfony.rb +69 -17
- metadata +23 -6
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,14 @@
|
|
1
|
+
### 2.2.10 / June 9, 2013
|
2
|
+
|
3
|
+
* "interactive_mode" should also affect composer
|
4
|
+
* Override copy strategy to allow vendors to be installed locally.
|
5
|
+
* Add "--no-progress" to composers default options
|
6
|
+
* Improved #112 password is passed to pg_dump and psql
|
7
|
+
* Implemented progress bar on "database:dump:remote"
|
8
|
+
* Implemented wrapper around "ruby-progressbar" gem
|
9
|
+
* also copy vendors for vendors:install and vendors:upgrade
|
10
|
+
* Updated composer_options for the upcoming changes in composer.
|
11
|
+
|
1
12
|
### 2.2.9 / May 6, 2013
|
2
13
|
|
3
14
|
* Change setfacl call to match Symfony2 permission granting instructions
|
data/bin/capifony
CHANGED
data/lib/capifony_symfony2.rb
CHANGED
@@ -6,6 +6,7 @@ require 'fileutils'
|
|
6
6
|
require 'inifile'
|
7
7
|
require 'yaml'
|
8
8
|
require 'zlib'
|
9
|
+
require 'ruby-progressbar'
|
9
10
|
|
10
11
|
module Capifony
|
11
12
|
module Symfony2
|
@@ -29,7 +30,7 @@ module Capifony
|
|
29
30
|
|
30
31
|
# Symfony console bin
|
31
32
|
set :symfony_console, app_path + "/console"
|
32
|
-
|
33
|
+
|
33
34
|
# Symfony debug flag for console commands
|
34
35
|
set :symfony_debug, false
|
35
36
|
|
@@ -55,12 +56,15 @@ module Capifony
|
|
55
56
|
# If set to false, it will use the bin/vendors script
|
56
57
|
set :use_composer, false
|
57
58
|
|
59
|
+
# Whether to use composer to install vendors to a local temp directory.
|
60
|
+
set :use_composer_tmp, false
|
61
|
+
|
58
62
|
# Path to composer binary
|
59
63
|
# If set to false, Capifony will download/install composer
|
60
64
|
set :composer_bin, false
|
61
65
|
|
62
66
|
# Options to pass to composer when installing/updating
|
63
|
-
set :composer_options, "--no-scripts --verbose --prefer-dist --optimize-autoloader"
|
67
|
+
set :composer_options, "--no-scripts --no-dev --verbose --prefer-dist --optimize-autoloader --no-progress"
|
64
68
|
|
65
69
|
# Whether to update vendors using the configured dependency manager (composer or bin/vendors)
|
66
70
|
set :update_vendors, false
|
@@ -118,8 +122,8 @@ module Capifony
|
|
118
122
|
|
119
123
|
# Doctrine custom entity manager
|
120
124
|
set :doctrine_em, false
|
121
|
-
|
122
|
-
# Use --flush option in doctrine:clear_* task
|
125
|
+
|
126
|
+
# Use --flush option in doctrine:clear_* task
|
123
127
|
set :doctrine_clear_use_flush_option, false
|
124
128
|
|
125
129
|
# Symfony2 version
|
@@ -152,14 +156,14 @@ module Capifony
|
|
152
156
|
def remote_command_exists?(command)
|
153
157
|
'true' == capture("if [ -x \"$(which #{command})\" ]; then echo 'true'; fi").strip
|
154
158
|
end
|
155
|
-
|
159
|
+
|
156
160
|
def console_options
|
157
161
|
console_options = "--env=#{symfony_env_prod}"
|
158
|
-
|
162
|
+
|
159
163
|
if !symfony_debug
|
160
164
|
console_options += " --no-debug"
|
161
165
|
end
|
162
|
-
|
166
|
+
|
163
167
|
return console_options
|
164
168
|
end
|
165
169
|
|
@@ -211,6 +215,36 @@ module Capifony
|
|
211
215
|
end
|
212
216
|
end
|
213
217
|
|
218
|
+
$progress_bar = nil
|
219
|
+
$download_msg_padding = nil
|
220
|
+
|
221
|
+
def capifony_progress_start(msg = "--> Working")
|
222
|
+
$download_msg_padding = '.' * (60 - msg.size)
|
223
|
+
# Format is equivalent to "Title............82% ETA: 00:00:12"
|
224
|
+
$progress_bar = ProgressBar.create(
|
225
|
+
:title => msg,
|
226
|
+
:format => "%t%B %p%% %e",
|
227
|
+
:length => 60,
|
228
|
+
:progress_mark => "."
|
229
|
+
)
|
230
|
+
end
|
231
|
+
|
232
|
+
def capifony_progress_update(current, total)
|
233
|
+
unless $progress_bar
|
234
|
+
raise "Please create a progress bar using capifony_progress_start"
|
235
|
+
end
|
236
|
+
|
237
|
+
percent = (current.to_f / total.to_f * 100).floor
|
238
|
+
|
239
|
+
if percent > 99
|
240
|
+
green_tick = '✔'.green
|
241
|
+
# Format is equivalent to "Title.............✔"
|
242
|
+
$progress_bar.format("%t#{$download_msg_padding}#{green_tick}")
|
243
|
+
end
|
244
|
+
|
245
|
+
$progress_bar.progress = percent
|
246
|
+
end
|
247
|
+
|
214
248
|
[
|
215
249
|
"symfony:doctrine:cache:clear_metadata",
|
216
250
|
"symfony:doctrine:cache:clear_query",
|
@@ -227,7 +261,7 @@ module Capifony
|
|
227
261
|
end
|
228
262
|
end
|
229
263
|
|
230
|
-
["symfony:composer:install", "symfony:composer:update"].each do |action|
|
264
|
+
["symfony:composer:install", "symfony:composer:update", "symfony:vendors:install", "symfony:vendors:upgrade"].each do |action|
|
231
265
|
before action do
|
232
266
|
if copy_vendors
|
233
267
|
symfony.composer.copy_vendors
|
@@ -236,7 +270,7 @@ module Capifony
|
|
236
270
|
end
|
237
271
|
|
238
272
|
after "deploy:finalize_update" do
|
239
|
-
if use_composer
|
273
|
+
if use_composer && !use_composer_tmp
|
240
274
|
if update_vendors
|
241
275
|
symfony.composer.update
|
242
276
|
else
|
@@ -263,7 +297,7 @@ module Capifony
|
|
263
297
|
symfony.propel.build.model
|
264
298
|
end
|
265
299
|
|
266
|
-
if use_composer
|
300
|
+
if use_composer && !use_composer_tmp
|
267
301
|
symfony.composer.dump_autoload
|
268
302
|
end
|
269
303
|
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'capistrano/recipes/deploy/strategy/copy'
|
2
|
+
require 'fileutils'
|
3
|
+
require 'capifony_symfony2'
|
4
|
+
|
5
|
+
module Capistrano
|
6
|
+
module Deploy
|
7
|
+
module Strategy
|
8
|
+
class CapifonyCopyLocal < Copy
|
9
|
+
print "--> Using Copy Local Strategy\n"
|
10
|
+
# Deploy
|
11
|
+
def deploy!
|
12
|
+
copy_cache ? run_copy_cache_strategy : run_copy_strategy
|
13
|
+
create_revision_file
|
14
|
+
$temp_destination = destination # Make temp location avaliable globally.
|
15
|
+
symfony.composer.install
|
16
|
+
symfony.bootstrap.build
|
17
|
+
compress_repository
|
18
|
+
distribute!
|
19
|
+
ensure
|
20
|
+
rollback_changes
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
data/lib/symfony2/database.rb
CHANGED
@@ -19,12 +19,17 @@ namespace :database do
|
|
19
19
|
data = capture("#{try_sudo} sh -c 'mysqldump -u#{config['database_user']} --host='#{config['database_host']}' --password='#{config['database_password']}' #{config['database_name']} | gzip -c > #{file}'")
|
20
20
|
puts data
|
21
21
|
when "pdo_pgsql", "pgsql"
|
22
|
-
data = capture("#{try_sudo} sh -c 'pg_dump -U #{config['database_user']} #{config['database_name']} --clean | gzip -c > #{file}'")
|
22
|
+
data = capture("#{try_sudo} sh -c 'PGPASSWORD=\"#{config['database_password']}\" pg_dump -U #{config['database_user']} #{config['database_name']} --clean | gzip -c > #{file}'")
|
23
23
|
puts data
|
24
24
|
end
|
25
25
|
|
26
26
|
FileUtils.mkdir_p("backups")
|
27
|
-
|
27
|
+
|
28
|
+
capifony_progress_start
|
29
|
+
get(file, "backups/#{filename}", :via => :scp) do |channel, name, sent, total|
|
30
|
+
capifony_progress_update(sent, total)
|
31
|
+
end
|
32
|
+
|
28
33
|
begin
|
29
34
|
FileUtils.ln_sf(filename, "backups/#{application}.#{env}_dump.latest.sql.gz")
|
30
35
|
rescue Exception # fallback for file systems that don't support symlinks
|
@@ -46,7 +51,7 @@ namespace :database do
|
|
46
51
|
when "pdo_mysql", "mysql"
|
47
52
|
`mysqldump -u#{config['database_user']} --password=\"#{config['database_password']}\" #{config['database_name']} > #{tmpfile}`
|
48
53
|
when "pdo_pgsql", "pgsql"
|
49
|
-
`pg_dump -U #{config['database_user']} #{config['database_name']} --clean > #{tmpfile}`
|
54
|
+
`PGPASSWORD=\"#{config['database_password']}\" pg_dump -U #{config['database_user']} #{config['database_name']} --clean > #{tmpfile}`
|
50
55
|
end
|
51
56
|
|
52
57
|
File.open(tmpfile, "r+") do |f|
|
@@ -86,7 +91,7 @@ namespace :database do
|
|
86
91
|
when "pdo_mysql", "mysql"
|
87
92
|
`mysql -u#{config['database_user']} --password=\"#{config['database_password']}\" #{config['database_name']} < backups/#{sqlfile}`
|
88
93
|
when "pdo_pgsql", "pgsql"
|
89
|
-
`psql -U #{config['database_user']} #{config['database_name']} < backups/#{sqlfile}`
|
94
|
+
`PGPASSWORD=\"#{config['database_password']}\" psql -U #{config['database_user']} #{config['database_name']} < backups/#{sqlfile}`
|
90
95
|
end
|
91
96
|
FileUtils.rm("backups/#{sqlfile}")
|
92
97
|
end
|
@@ -111,7 +116,7 @@ namespace :database do
|
|
111
116
|
data = capture("#{try_sudo} mysql -u#{config['database_user']} --host='#{config['database_host']}' --password='#{config['database_password']}' #{config['database_name']} < #{remote_tmp_dir}/#{sqlfile}")
|
112
117
|
puts data
|
113
118
|
when "pdo_pgsql", "pgsql"
|
114
|
-
data = capture("#{try_sudo} psql -U #{config['database_user']} #{config['database_name']} < #{remote_tmp_dir}/#{sqlfile}")
|
119
|
+
data = capture("#{try_sudo} PGPASSWORD=\"#{config['database_password']}\" psql -U #{config['database_user']} #{config['database_name']} < #{remote_tmp_dir}/#{sqlfile}")
|
115
120
|
puts data
|
116
121
|
end
|
117
122
|
|
data/lib/symfony2/symfony.rb
CHANGED
@@ -84,15 +84,26 @@ namespace :symfony do
|
|
84
84
|
namespace :bootstrap do
|
85
85
|
desc "Runs the bin/build_bootstrap script"
|
86
86
|
task :build, :roles => :app, :except => { :no_release => true } do
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
87
|
+
if use_composer_tmp
|
88
|
+
logger.debug "Building bootstrap file in #{$temp_destination}"
|
89
|
+
capifony_pretty_print "--> Building bootstrap file in temp location"
|
90
|
+
|
91
|
+
if !File.exists?("#{$temp_destination}/#{build_bootstrap}") && true == use_composer then
|
92
|
+
set :build_bootstrap, "vendor/sensio/distribution-bundle/Sensio/Bundle/DistributionBundle/Resources/bin/build_bootstrap.php"
|
93
|
+
run_locally "cd #{$temp_destination} && test -f #{build_bootstrap} && #{php_bin} #{build_bootstrap} #{app_path} || echo '#{build_bootstrap} not found, skipped'"
|
94
|
+
else
|
95
|
+
run_locally "cd #{$temp_destination} && test -f #{build_bootstrap} && #{php_bin} #{build_bootstrap} || echo '#{build_bootstrap} not found, skipped'"
|
96
|
+
end
|
92
97
|
else
|
93
|
-
|
94
|
-
end
|
98
|
+
capifony_pretty_print "--> Building bootstrap file"
|
95
99
|
|
100
|
+
if !remote_file_exists?("#{latest_release}/#{build_bootstrap}") && true == use_composer then
|
101
|
+
set :build_bootstrap, "vendor/sensio/distribution-bundle/Sensio/Bundle/DistributionBundle/Resources/bin/build_bootstrap.php"
|
102
|
+
run "#{try_sudo} sh -c 'cd #{latest_release} && test -f #{build_bootstrap} && #{php_bin} #{build_bootstrap} #{app_path} || echo '#{build_bootstrap} not found, skipped''"
|
103
|
+
else
|
104
|
+
run "#{try_sudo} sh -c 'cd #{latest_release} && test -f #{build_bootstrap} && #{php_bin} #{build_bootstrap} || echo '#{build_bootstrap} not found, skipped''"
|
105
|
+
end
|
106
|
+
end
|
96
107
|
capifony_puts_ok
|
97
108
|
end
|
98
109
|
end
|
@@ -100,14 +111,21 @@ namespace :symfony do
|
|
100
111
|
namespace :composer do
|
101
112
|
desc "Gets composer and installs it"
|
102
113
|
task :get, :roles => :app, :except => { :no_release => true } do
|
103
|
-
if
|
104
|
-
|
105
|
-
|
106
|
-
|
114
|
+
if use_composer_tmp
|
115
|
+
# Because we always install to temp location we assume that we download composer every time.
|
116
|
+
logger.debug "Downloading composer to #{$temp_destination}"
|
117
|
+
capifony_pretty_print "--> Downloading Composer to temp location"
|
118
|
+
run_locally "cd #{$temp_destination} && curl -s http://getcomposer.org/installer | #{php_bin}"
|
107
119
|
else
|
108
|
-
|
120
|
+
if !remote_file_exists?("#{latest_release}/composer.phar")
|
121
|
+
capifony_pretty_print "--> Downloading Composer"
|
122
|
+
|
123
|
+
run "#{try_sudo} sh -c 'cd #{latest_release} && curl -s http://getcomposer.org/installer | #{php_bin}'"
|
124
|
+
else
|
125
|
+
capifony_pretty_print "--> Updating Composer"
|
109
126
|
|
110
|
-
|
127
|
+
run "#{try_sudo} sh -c 'cd #{latest_release} && #{php_bin} composer.phar self-update'"
|
128
|
+
end
|
111
129
|
end
|
112
130
|
capifony_puts_ok
|
113
131
|
end
|
@@ -116,14 +134,27 @@ namespace :symfony do
|
|
116
134
|
|
117
135
|
desc "Runs composer to install vendors from composer.lock file"
|
118
136
|
task :install, :roles => :app, :except => { :no_release => true } do
|
137
|
+
|
119
138
|
if !composer_bin
|
120
139
|
symfony.composer.get
|
121
140
|
set :composer_bin, "#{php_bin} composer.phar"
|
122
141
|
end
|
123
142
|
|
124
|
-
|
125
|
-
|
126
|
-
|
143
|
+
options = "#{composer_options}"
|
144
|
+
if !interactive_mode
|
145
|
+
options += " --no-interaction"
|
146
|
+
end
|
147
|
+
|
148
|
+
if use_composer_tmp
|
149
|
+
logger.debug "Installing composer dependencies to #{$temp_destination}"
|
150
|
+
capifony_pretty_print "--> Installing Composer dependencies in temp location"
|
151
|
+
run_locally "cd #{$temp_destination} && #{composer_bin} install #{options}"
|
152
|
+
capifony_puts_ok
|
153
|
+
else
|
154
|
+
capifony_pretty_print "--> Installing Composer dependencies"
|
155
|
+
run "#{try_sudo} sh -c 'cd #{latest_release} && #{composer_bin} install #{options}'"
|
156
|
+
capifony_puts_ok
|
157
|
+
end
|
127
158
|
end
|
128
159
|
|
129
160
|
desc "Runs composer to update vendors, and composer.lock file"
|
@@ -133,8 +164,13 @@ namespace :symfony do
|
|
133
164
|
set :composer_bin, "#{php_bin} composer.phar"
|
134
165
|
end
|
135
166
|
|
167
|
+
options = "#{composer_options}"
|
168
|
+
if !interactive_mode
|
169
|
+
options += " --no-interaction"
|
170
|
+
end
|
171
|
+
|
136
172
|
capifony_pretty_print "--> Updating Composer dependencies"
|
137
|
-
run "#{try_sudo} sh -c 'cd #{latest_release} && #{composer_bin} update #{
|
173
|
+
run "#{try_sudo} sh -c 'cd #{latest_release} && #{composer_bin} update #{options}'"
|
138
174
|
capifony_puts_ok
|
139
175
|
end
|
140
176
|
|
@@ -156,6 +192,22 @@ namespace :symfony do
|
|
156
192
|
run "vendorDir=#{current_path}/vendor; if [ -d $vendorDir ] || [ -h $vendorDir ]; then cp -a $vendorDir #{latest_release}/vendor; fi;"
|
157
193
|
capifony_puts_ok
|
158
194
|
end
|
195
|
+
|
196
|
+
# Install composer to temp directory.
|
197
|
+
# Not sure if this is required yet.
|
198
|
+
desc "Dumps an optimized autoloader"
|
199
|
+
task :dump_autoload_temp, :roles => :app, :except => { :no_release => true } do
|
200
|
+
if !composer_bin
|
201
|
+
symfony.composer.get_temp
|
202
|
+
set :composer_bin, "#{php_bin} composer.phar"
|
203
|
+
end
|
204
|
+
|
205
|
+
logger.debug "Dumping an optimised autoloader to #{$temp_destination}"
|
206
|
+
capifony_pretty_print "--> Dumping an optimized autoloader to temp location"
|
207
|
+
run_locally cd "#{$temp_destination} && #{composer_bin} dump-autoload --optimize"
|
208
|
+
capifony_puts_ok
|
209
|
+
end
|
210
|
+
|
159
211
|
end
|
160
212
|
|
161
213
|
namespace :cache do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: capifony
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.2.
|
4
|
+
version: 2.2.10
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2013-06-
|
13
|
+
date: 2013-06-09 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: capistrano
|
@@ -20,9 +20,9 @@ dependencies:
|
|
20
20
|
- - ! '>='
|
21
21
|
- !ruby/object:Gem::Version
|
22
22
|
version: 2.13.5
|
23
|
-
- -
|
23
|
+
- - <=
|
24
24
|
- !ruby/object:Gem::Version
|
25
|
-
version:
|
25
|
+
version: 2.15.4
|
26
26
|
type: :runtime
|
27
27
|
prerelease: false
|
28
28
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -31,9 +31,9 @@ dependencies:
|
|
31
31
|
- - ! '>='
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: 2.13.5
|
34
|
-
- -
|
34
|
+
- - <=
|
35
35
|
- !ruby/object:Gem::Version
|
36
|
-
version:
|
36
|
+
version: 2.15.4
|
37
37
|
- !ruby/object:Gem::Dependency
|
38
38
|
name: colored
|
39
39
|
requirement: !ruby/object:Gem::Requirement
|
@@ -82,6 +82,22 @@ dependencies:
|
|
82
82
|
- - '='
|
83
83
|
- !ruby/object:Gem::Version
|
84
84
|
version: 0.0.3
|
85
|
+
- !ruby/object:Gem::Dependency
|
86
|
+
name: ruby-progressbar
|
87
|
+
requirement: !ruby/object:Gem::Requirement
|
88
|
+
none: false
|
89
|
+
requirements:
|
90
|
+
- - '='
|
91
|
+
- !ruby/object:Gem::Version
|
92
|
+
version: 1.0.2
|
93
|
+
type: :runtime
|
94
|
+
prerelease: false
|
95
|
+
version_requirements: !ruby/object:Gem::Requirement
|
96
|
+
none: false
|
97
|
+
requirements:
|
98
|
+
- - '='
|
99
|
+
- !ruby/object:Gem::Version
|
100
|
+
version: 1.0.2
|
85
101
|
description: ! ' Capistrano is an open source tool for running scripts on multiple
|
86
102
|
servers. It’s primary use is for easily deploying applications. While it was built
|
87
103
|
specifically for deploying Rails apps, it’s pretty simple to customize it to deploy
|
@@ -101,6 +117,7 @@ files:
|
|
101
117
|
- lib/capifony.rb
|
102
118
|
- lib/capifony_symfony1.rb
|
103
119
|
- lib/capifony_symfony2.rb
|
120
|
+
- lib/capistrano/recipes/deploy/strategy/capifony_copy_local.rb
|
104
121
|
- lib/symfony1/database.rb
|
105
122
|
- lib/symfony1/deploy.rb
|
106
123
|
- lib/symfony1/doctrine.rb
|