Skip to content
This repository
Browse code

Merge remote branch 'arlo/master'

  • Loading branch information...
commit c9f9f4a06ac26d698ef001b8e9952947e99aeb40 2 parents 1e6c4d7 + d826b75
Konstantin Kudryashov authored June 17, 2010

Showing 1 changed file with 32 additions and 18 deletions. Show diff stats Hide diff stats

  1. 50  lib/capifony.rb
50  lib/capifony.rb
@@ -21,9 +21,9 @@
21 21
 # Symfony lib path
22 22
 set(:symfony_lib)     { guess_symfony_lib }
23 23
 
24  
-def prompt_with_default(var, default)
  24
+def prompt_with_default(var, default, &block)
25 25
   set(var) do
26  
-    Capistrano::CLI.ui.ask "#{var} [#{default}] : "
  26
+    Capistrano::CLI.ui.ask("#{var} [#{default}] : ", &block)
27 27
   end
28 28
   set var, default if eval("#{var.to_s}.empty?")
29 29
 end
@@ -151,11 +151,11 @@ def load_database_config(data, env)
151 151
   namespace :configure do
152 152
     desc "Configure database DSN"
153 153
     task :database do
154  
-      prompt_with_default(:dsn,   "mysql:host=localhost;dbname=example_dev")
155  
-      prompt_with_default(:user,  "root")
156  
-      prompt_with_default(:pass,  "")
  154
+      prompt_with_default(:dsn,         "mysql:host=localhost;dbname=example_dev")
  155
+      prompt_with_default(:db_username, "root")
  156
+      prompt_with_default(:db_password, "") { |q| q.echo = "x" }
157 157
 
158  
-      run "#{php_bin} #{latest_release}/symfony configure:database '#{dsn}' '#{user}' '#{pass}'"
  158
+      run "#{php_bin} #{latest_release}/symfony configure:database '#{dsn}' '#{db_username}' '#{db_password}'"
159 159
     end
160 160
   end
161 161
 
@@ -244,7 +244,9 @@ def load_database_config(data, env)
244 244
   
245 245
     desc "Migrates database to current version"
246 246
     task :migrate do
247  
-      find_and_execute_task("symfony:#{symfony_orm}:migrate")
  247
+      if Capistrano::CLI.ui.agree("Do you really want to migrate your #{symfony_env}'s database ? (type yes or no)")
  248
+        find_and_execute_task("symfony:#{symfony_orm}:migrate")
  249
+      end
248 250
     end
249 251
 
250 252
     desc "Generate model lib form and filters classes based on your schema"
@@ -254,22 +256,30 @@ def load_database_config(data, env)
254 256
 
255 257
     desc "Generate code & database based on your schema"
256 258
     task :build_all do
257  
-      find_and_execute_task("symfony:#{symfony_orm}:build_all")
  259
+      if Capistrano::CLI.ui.agree("Do you really want to rebuild #{symfony_env}'s database ? (type yes or no)")
  260
+        find_and_execute_task("symfony:#{symfony_orm}:build_all")
  261
+      end
258 262
     end
259 263
 
260 264
     desc "Generate code & database based on your schema & load fixtures"
261 265
     task :build_all_and_load do
262  
-      find_and_execute_task("symfony:#{symfony_orm}:build_all_and_load")
  266
+      if Capistrano::CLI.ui.agree("Do you really want to rebuild #{symfony_env}'s database and load #{symfony_env}'s fixtures ? (type yes or no)")
  267
+        find_and_execute_task("symfony:#{symfony_orm}:build_all_and_load")
  268
+      end
263 269
     end
264 270
 
265 271
     desc "Generate sql & database based on your schema"
266 272
     task :build_db do
267  
-      find_and_execute_task("symfony:#{symfony_orm}:build_db")
  273
+      if Capistrano::CLI.ui.agree("Do you really want to rebuild #{symfony_env}'s database ? (type yes or no)")
  274
+        find_and_execute_task("symfony:#{symfony_orm}:build_db")
  275
+      end
268 276
     end
269 277
 
270 278
     desc "Generate sql & database based on your schema & load fixtures"
271 279
     task :build_db_and_load do
272  
-      find_and_execute_task("symfony:#{symfony_orm}:build_db_and_load")
  280
+      if Capistrano::CLI.ui.agree("Do you really want to rebuild #{symfony_env}'s database and load #{symfony_env}'s fixtures ? (type yes or no)")
  281
+        find_and_execute_task("symfony:#{symfony_orm}:build_db_and_load")
  282
+      end
273 283
     end
274 284
   end
275 285
 
@@ -519,10 +529,14 @@ def load_database_config(data, env)
519 529
   end
520 530
 end
521 531
 
522  
-after "deploy:finalize_update", # After finalizing update:
523  
-  "symfony:orm:setup",                # 0. Ensure that ORM is configured
524  
-  "symfony:orm:build_classes",        # 1. (Re)build the model
525  
-  "symfony:cc",                       # 2. Clear cache
526  
-  "symfony:plugin:publish_assets",    # 3. Publish plugin assets
527  
-  "symfony:project:permissions",      # 4. Fix project permissions
528  
-  "symfony:project:clear_controllers" # 5. Clear controllers
  532
+# After finalizing update:
  533
+after "deploy:finalize_update" do
  534
+  symfony.orm.setup                       # 0. Ensure that ORM is configured
  535
+  symfony.orm.build_classes               # 1. (Re)build the model
  536
+  symfony.cc                              # 2. Clear cache
  537
+  symfony.plugin.publish_assets           # 3. Publish plugin assets
  538
+  symfony.project.permissions             # 4. Fix project permissions
  539
+  if symfony_env.eql?("prod")
  540
+    symfony.project.clear_controllers     # 5. Clear controllers in production environment
  541
+  end
  542
+end

0 notes on commit c9f9f4a

Please sign in to comment.
Something went wrong with that request. Please try again.