capifony 2.1.4 → 2.1.5
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +0 -6
- data/lib/symfony1.rb +1 -1
- data/lib/symfony2.rb +178 -11
- metadata +3 -3
data/CHANGELOG
CHANGED
data/lib/symfony1.rb
CHANGED
@@ -132,7 +132,7 @@ namespace :symfony do
|
|
132
132
|
|
133
133
|
desc "Clears the cache"
|
134
134
|
task :cc do
|
135
|
-
run "cd #{latest_release} && #{php_bin} ./symfony cache:clear"
|
135
|
+
run "cd #{latest_release} && #{try_sudo} #{php_bin} ./symfony cache:clear"
|
136
136
|
run "chmod -R g+w #{latest_release}/cache"
|
137
137
|
end
|
138
138
|
|
data/lib/symfony2.rb
CHANGED
@@ -9,6 +9,9 @@ set :web_path, "web"
|
|
9
9
|
# Symfony console bin
|
10
10
|
set :symfony_console, app_path + "/console"
|
11
11
|
|
12
|
+
# Symfony bin vendors
|
13
|
+
set :symfony_vendors, "bin/vendors"
|
14
|
+
|
12
15
|
# Symfony log path
|
13
16
|
set :log_path, app_path + "/logs"
|
14
17
|
|
@@ -21,6 +24,9 @@ set :dump_assetic_assets, false
|
|
21
24
|
# Whether to run the bin/vendors script to update vendors
|
22
25
|
set :update_vendors, false
|
23
26
|
|
27
|
+
# Whether to use composer to install vendors. This needs :update_vendors to false
|
28
|
+
set :use_composer, false
|
29
|
+
|
24
30
|
# run bin/vendors script in mode (upgrade, install (faster if shared /vendor folder) or reinstall)
|
25
31
|
set :vendors_mode, "reinstall"
|
26
32
|
|
@@ -42,6 +48,140 @@ set :asset_children, [web_path + "/css", web_path + "/images", web_path + "
|
|
42
48
|
set :model_manager, "doctrine"
|
43
49
|
# Or: `propel`
|
44
50
|
|
51
|
+
|
52
|
+
def load_database_config(data, env)
|
53
|
+
parameters = YAML::load(data)
|
54
|
+
|
55
|
+
parameters['parameters']
|
56
|
+
end
|
57
|
+
|
58
|
+
namespace :database do
|
59
|
+
namespace :dump do
|
60
|
+
desc "Dump remote database"
|
61
|
+
task :remote do
|
62
|
+
filename = "#{application}.remote_dump.#{Time.now.to_i}.sql.gz"
|
63
|
+
file = "/tmp/#{filename}"
|
64
|
+
sqlfile = "#{application}_dump.sql"
|
65
|
+
config = ""
|
66
|
+
|
67
|
+
run "cat #{current_path}/app/config/parameters.yml" do |ch, st, data|
|
68
|
+
config = load_database_config data, symfony_env_prod
|
69
|
+
end
|
70
|
+
|
71
|
+
case config['database_driver']
|
72
|
+
when 'pdo_mysql'
|
73
|
+
run "mysqldump -u#{config['database_user']} --password='#{config['database_password']}' #{config['database_name']} | gzip -c > #{file}" do |ch, stream, data|
|
74
|
+
puts data
|
75
|
+
end
|
76
|
+
when 'pdo_pgsql'
|
77
|
+
run "pg_dump -U #{config['database_user']} --password='#{config['database_password']}' #{config['database_name']} | gzip -c > #{file}" do |ch, stream, data|
|
78
|
+
puts data
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
require "FileUtils"
|
83
|
+
FileUtils.mkdir_p("backups")
|
84
|
+
get file, "backups/#{filename}"
|
85
|
+
begin
|
86
|
+
FileUtils.ln_sf(filename, "backups/#{application}.remote_dump.latest.sql.gz")
|
87
|
+
rescue NotImplementedError # hack for windows which doesnt support symlinks
|
88
|
+
FileUtils.cp_r("backups/#{filename}", "backups/#{application}.remote_dump.latest.sql.gz")
|
89
|
+
end
|
90
|
+
run "rm #{file}"
|
91
|
+
end
|
92
|
+
|
93
|
+
desc "Dump local database"
|
94
|
+
task :local do
|
95
|
+
filename = "#{application}.local_dump.#{Time.now.to_i}.sql.gz"
|
96
|
+
tmpfile = "backups/#{application}_dump_tmp.sql"
|
97
|
+
file = "backups/#{filename}"
|
98
|
+
config = load_database_config IO.read('app/config/parameters.yml'), symfony_env_local
|
99
|
+
sqlfile = "#{application}_dump.sql"
|
100
|
+
|
101
|
+
require "FileUtils"
|
102
|
+
FileUtils::mkdir_p("backups")
|
103
|
+
case config['database_driver']
|
104
|
+
when 'pdo_mysql'
|
105
|
+
`mysqldump -u#{config['database_user']} --password=\"#{config['database_password']}\" #{config['database_name']} > #{tmpfile}`
|
106
|
+
when 'pdo_pgsql'
|
107
|
+
`pg_dump -U #{config['database_user']} --password=\"#{config['database_password']}\" #{config['database_name']} > #{tmpfile}`
|
108
|
+
end
|
109
|
+
File.open(tmpfile, "r+") do |f|
|
110
|
+
gz = Zlib::GzipWriter.open(file)
|
111
|
+
while (line = f.gets)
|
112
|
+
gz << line
|
113
|
+
end
|
114
|
+
gz.flush
|
115
|
+
gz.close
|
116
|
+
end
|
117
|
+
|
118
|
+
begin
|
119
|
+
FileUtils.ln_sf(filename, "backups/#{application}.local_dump.latest.sql.gz")
|
120
|
+
rescue NotImplementedError # hack for windows which doesnt support symlinks
|
121
|
+
FileUtils.cp_r("backups/#{filename}", "backups/#{application}.local_dump.latest.sql.gz")
|
122
|
+
end
|
123
|
+
FileUtils.rm(tmpfile)
|
124
|
+
end
|
125
|
+
end
|
126
|
+
|
127
|
+
namespace :move do
|
128
|
+
desc "Dump remote database, download it to local & populate here"
|
129
|
+
task :to_local do
|
130
|
+
filename = "#{application}.remote_dump.latest.sql.gz"
|
131
|
+
config = load_database_config IO.read('app/config/parameters.yml'), symfony_env_local
|
132
|
+
sqlfile = "#{application}_dump.sql"
|
133
|
+
|
134
|
+
database.dump.remote
|
135
|
+
|
136
|
+
require "FileUtils"
|
137
|
+
f = File.new("backups/#{sqlfile}", "a+")
|
138
|
+
require "zlib"
|
139
|
+
gz = Zlib::GzipReader.new(File.open("backups/#{filename}", "r"))
|
140
|
+
f << gz.read
|
141
|
+
f.close
|
142
|
+
|
143
|
+
case config['database_driver']
|
144
|
+
when 'pdo_mysql'
|
145
|
+
`mysql -u#{config['database_user']} --password=\"#{config['database_password']}\" #{config['database_name']} < backups/#{sqlfile}`
|
146
|
+
when 'pdo_pgsql'
|
147
|
+
`psql -U #{config['database_user']} --password=\"#{config['database_password']}\" #{config['database_name']} < backups/#{sqlfile}`
|
148
|
+
end
|
149
|
+
FileUtils.rm("backups/#{sqlfile}")
|
150
|
+
end
|
151
|
+
|
152
|
+
desc "Dump local database, load it to remote & populate there"
|
153
|
+
task :to_remote do
|
154
|
+
filename = "#{application}.local_dump.latest.sql.gz"
|
155
|
+
file = "backups/#{filename}"
|
156
|
+
sqlfile = "#{application}_dump.sql"
|
157
|
+
config = ""
|
158
|
+
|
159
|
+
database.dump.local
|
160
|
+
|
161
|
+
upload(file, "/tmp/#{filename}", :via => :scp)
|
162
|
+
run "gunzip -c /tmp/#{filename} > /tmp/#{sqlfile}"
|
163
|
+
|
164
|
+
run "cat #{shared_path}/config/databases.yml" do |ch, st, data|
|
165
|
+
config = load_database_config data, symfony_env_prod
|
166
|
+
end
|
167
|
+
|
168
|
+
case config['database_driver']
|
169
|
+
when 'pdo_mysql'
|
170
|
+
run "mysql -u#{config['database_user']} --password='#{config['database_password']}' #{config['database_name']} < /tmp/#{sqlfile}" do |ch, stream, data|
|
171
|
+
puts data
|
172
|
+
end
|
173
|
+
when 'pdo_pgsql'
|
174
|
+
run "psql -U #{config['database_user']} --password='#{config['database_password']}' #{config['database_name']} < /tmp/#{sqlfile}" do |ch, stream, data|
|
175
|
+
puts data
|
176
|
+
end
|
177
|
+
end
|
178
|
+
|
179
|
+
run "rm /tmp/#{filename}"
|
180
|
+
run "rm /tmp/#{sqlfile}"
|
181
|
+
end
|
182
|
+
end
|
183
|
+
end
|
184
|
+
|
45
185
|
namespace :deploy do
|
46
186
|
desc "Symlink static directories and static files that need to remain between deployments."
|
47
187
|
task :share_childs do
|
@@ -71,10 +211,6 @@ namespace :deploy do
|
|
71
211
|
|
72
212
|
share_childs
|
73
213
|
|
74
|
-
asset_children.each do |child|
|
75
|
-
run "if [ -d #{child} ] ; then mkdir -p #{child}; fi"
|
76
|
-
end
|
77
|
-
|
78
214
|
if fetch(:normalize_asset_timestamps, true)
|
79
215
|
stamp = Time.now.utc.strftime("%Y%m%d%H%M.%S")
|
80
216
|
asset_paths = asset_children.map { |p| "#{latest_release}/#{p}" }.join(" ")
|
@@ -98,8 +234,8 @@ namespace :deploy do
|
|
98
234
|
desc "Migrate Symfony2 Doctrine ORM database."
|
99
235
|
task :migrate do
|
100
236
|
currentVersion = nil
|
101
|
-
run "cd #{latest_release} && #{php_bin} #{symfony_console} doctrine:migrations:status --
|
102
|
-
if stream == :out and out =~ /Current Version:[^$]+\(([
|
237
|
+
run "cd #{latest_release} && #{php_bin} #{symfony_console} doctrine:migrations:status --env=#{symfony_env_prod}" do |ch, stream, out|
|
238
|
+
if stream == :out and out =~ /Current Version:[^$]+\(([\w]+)\)/
|
103
239
|
currentVersion = Regexp.last_match(1)
|
104
240
|
end
|
105
241
|
if stream == :out and out =~ /Current Version:\s*0\s*$/
|
@@ -149,17 +285,31 @@ namespace :symfony do
|
|
149
285
|
namespace :vendors do
|
150
286
|
desc "Runs the bin/vendors script to install the vendors (fast if already installed)"
|
151
287
|
task :install do
|
152
|
-
run "cd #{latest_release} && #{php_bin}
|
288
|
+
run "cd #{latest_release} && #{php_bin} #{symfony_vendors} install"
|
153
289
|
end
|
154
290
|
|
155
291
|
desc "Runs the bin/vendors script to reinstall the vendors"
|
156
292
|
task :reinstall do
|
157
|
-
run "cd #{latest_release} && #{php_bin}
|
293
|
+
run "cd #{latest_release} && #{php_bin} #{symfony_vendors} install --reinstall"
|
158
294
|
end
|
159
295
|
|
160
296
|
desc "Runs the bin/vendors script to upgrade the vendors"
|
161
297
|
task :upgrade do
|
162
|
-
run "cd #{latest_release} && #{php_bin}
|
298
|
+
run "cd #{latest_release} && #{php_bin} #{symfony_vendors} update"
|
299
|
+
end
|
300
|
+
end
|
301
|
+
|
302
|
+
namespace :bootstrap do
|
303
|
+
desc "Runs the bin/build_bootstrap whithout upgrade the vendors"
|
304
|
+
task :build do
|
305
|
+
run "cd #{latest_release} && #{php_bin} bin/build_bootstrap"
|
306
|
+
end
|
307
|
+
end
|
308
|
+
|
309
|
+
namespace :composer do
|
310
|
+
desc "Runs composer install to install vendors from composer.lock file"
|
311
|
+
task :install do
|
312
|
+
run "cd #{latest_release} && #{php_bin} composer.phar install"
|
163
313
|
end
|
164
314
|
end
|
165
315
|
|
@@ -234,7 +384,9 @@ namespace :symfony do
|
|
234
384
|
namespace :migrations do
|
235
385
|
desc "Execute a migration to a specified version or the latest available version."
|
236
386
|
task :migrate do
|
237
|
-
|
387
|
+
if Capistrano::CLI.ui.agree("Do you really want to migrate #{symfony_env_prod}'s database? (y/N)")
|
388
|
+
run "cd #{latest_release} && #{php_bin} #{symfony_console} doctrine:migrations:migrate --env=#{symfony_env_prod} --no-interaction"
|
389
|
+
end
|
238
390
|
end
|
239
391
|
|
240
392
|
desc "View the status of a set of migrations."
|
@@ -275,6 +427,14 @@ namespace :symfony do
|
|
275
427
|
end
|
276
428
|
end
|
277
429
|
|
430
|
+
namespace :init do
|
431
|
+
desc "Mounts ACL tables in the database"
|
432
|
+
task :acl do
|
433
|
+
run "cd #{latest_release} && #{php_bin} #{symfony_console} init:acl --env=#{symfony_env_prod}"
|
434
|
+
end
|
435
|
+
end
|
436
|
+
|
437
|
+
|
278
438
|
namespace :propel do
|
279
439
|
namespace :database do
|
280
440
|
desc "Create the configured databases."
|
@@ -318,8 +478,15 @@ after "deploy:finalize_update" do
|
|
318
478
|
when "install" then symfony.vendors.install
|
319
479
|
when "reinstall" then symfony.vendors.reinstall
|
320
480
|
end
|
481
|
+
elsif use_composer
|
482
|
+
symfony.composer.install
|
483
|
+
else
|
484
|
+
# share the children first (to get the vendor symlink)
|
485
|
+
deploy.share_childs
|
486
|
+
vendors_mode.chomp # To remove trailing whiteline
|
487
|
+
symfony.bootstrap.build
|
321
488
|
end
|
322
|
-
|
489
|
+
|
323
490
|
if assets_install
|
324
491
|
symfony.assets.install # 2. Publish bundle assets
|
325
492
|
end
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 2
|
7
7
|
- 1
|
8
|
-
-
|
9
|
-
version: 2.1.
|
8
|
+
- 5
|
9
|
+
version: 2.1.5
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Konstantin Kudryashov
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date:
|
17
|
+
date: 2012-03-29 00:00:00 +02:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|