capifony 2.1.12 → 2.1.13

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG CHANGED
@@ -1,3 +1,17 @@
1
+ == 2.1.13 / August 21, 2012
2
+
3
+ * check all .php files in stead of only _app.php
4
+ * fix clear controllers to also work with try_sudo
5
+ * use try_sudo in stead of run to execute commands, refs #189
6
+ * Add a symfony:project:clear_controllers
7
+ * .first instead of .last as the selected gem for symfony1/symfony2
8
+ * Enhance deploy:set_permissions to grant permissions to the shell user
9
+ * Fix currentVersion regex always returning nil
10
+ * Improve composer path checking
11
+ * Fix remote_command_exists
12
+ * Fix running doctrine migrations with allocated PTY
13
+ * Update lib/symfony1.rb
14
+
1
15
  == 2.1.12 / August 6, 2012
2
16
 
3
17
  * Enable options for assets:install
@@ -54,7 +54,7 @@ if symfony_version == 2
54
54
  "Capfile" => unindent(<<-FILE),
55
55
  load 'deploy' if respond_to?(:namespace) # cap2 differentiator
56
56
  Dir['vendor/**/Resources/recipes/*.rb'].each { |bundle| load(bundle) }
57
- load Gem.find_files('symfony2.rb').last.to_s
57
+ load Gem.find_files('symfony2.rb').first.to_s
58
58
  load '#{symfony_app_path}/config/deploy'
59
59
  FILE
60
60
 
@@ -86,7 +86,7 @@ else
86
86
  "Capfile" => unindent(<<-FILE),
87
87
  load 'deploy' if respond_to?(:namespace) # cap2 differentiator
88
88
  Dir['plugins/*/lib/recipes/*.rb'].each { |plugin| load(plugin) }
89
- load Gem.find_files('symfony1.rb').last.to_s
89
+ load Gem.find_files('symfony1.rb').first.to_s
90
90
  load 'config/deploy'
91
91
  FILE
92
92
 
@@ -55,7 +55,7 @@ namespace :deploy do
55
55
  DESC
56
56
  task :setup, :roles => :app, :except => { :no_release => true } do
57
57
  dirs = [deploy_to, releases_path, shared_path]
58
- run "mkdir -p #{dirs.join(' ')}"
59
- run "chmod g+w #{dirs.join(' ')}" if fetch(:group_writable, true)
58
+ try_sudo "mkdir -p #{dirs.join(' ')}"
59
+ try_sudo "chmod g+w #{dirs.join(' ')}" if fetch(:group_writable, true)
60
60
  end
61
61
  end
@@ -53,6 +53,11 @@ def guess_symfony_lib
53
53
  end
54
54
 
55
55
  def deep_merge(hash1, hash2)
56
+
57
+ #There might not be a second has to cascade to
58
+ if(hash2 == nil)
59
+ return hash1;
60
+ end
56
61
  hash1.merge(hash2){|key, subhash1, subhash2|
57
62
  if (subhash1.is_a?(Hash) && subhash2.is_a?(Hash))
58
63
  next deep_merge(subhash1, subhash2)
@@ -7,12 +7,12 @@ namespace :database do
7
7
  sqlfile = "#{application}_dump.sql"
8
8
  config = ""
9
9
 
10
- run "cat #{shared_path}/config/databases.yml" do |ch, st, data|
10
+ try_sudo "cat #{shared_path}/config/databases.yml" do |ch, st, data|
11
11
  config = load_database_config data, symfony_env_prod
12
12
  end
13
13
 
14
14
  sql_dump_cmd = generate_sql_command('dump', config)
15
- run "#{sql_dump_cmd} | gzip -c > #{file}" do |ch, stream, data|
15
+ try_sudo "#{sql_dump_cmd} | gzip -c > #{file}" do |ch, stream, data|
16
16
  puts data
17
17
  end
18
18
 
@@ -24,7 +24,7 @@ namespace :database do
24
24
  rescue NotImplementedError # hack for windows which doesnt support symlinks
25
25
  FileUtils.cp_r("backups/#{filename}", "backups/#{application}.remote_dump.latest.sql.gz")
26
26
  end
27
- run "rm #{file}"
27
+ try_sudo "rm #{file}"
28
28
  end
29
29
 
30
30
  desc "Dump local database"
@@ -96,23 +96,23 @@ namespace :database do
96
96
  database.dump.local
97
97
 
98
98
  upload(file, "#{remote_tmp_dir}/#{filename}", :via => :scp)
99
- run "gunzip -c #{remote_tmp_dir}/#{filename} > #{remote_tmp_dir}/#{sqlfile}"
99
+ try_sudo "gunzip -c #{remote_tmp_dir}/#{filename} > #{remote_tmp_dir}/#{sqlfile}"
100
100
 
101
- run "cat #{shared_path}/config/databases.yml" do |ch, st, data|
101
+ try_sudo "cat #{shared_path}/config/databases.yml" do |ch, st, data|
102
102
  config = load_database_config data, symfony_env_prod
103
103
  end
104
104
 
105
- run generate_sql_command('drop', config)
106
- run generate_sql_command('create', config)
105
+ try_sudo generate_sql_command('drop', config)
106
+ try_sudo generate_sql_command('create', config)
107
107
 
108
108
  sql_import_cmd = generate_sql_command('import', config)
109
109
 
110
- run "#{sql_import_cmd} < #{remote_tmp_dir}/#{sqlfile}" do |ch, stream, data|
110
+ try_sudo "#{sql_import_cmd} < #{remote_tmp_dir}/#{sqlfile}" do |ch, stream, data|
111
111
  puts data
112
112
  end
113
113
 
114
- run "rm #{remote_tmp_dir}/#{filename}"
115
- run "rm #{remote_tmp_dir}/#{sqlfile}"
114
+ try_sudo "rm #{remote_tmp_dir}/#{filename}"
115
+ try_sudo "rm #{remote_tmp_dir}/#{sqlfile}"
116
116
  end
117
117
  end
118
118
  end
@@ -8,26 +8,26 @@ namespace :deploy do
8
8
  task :share_childs do
9
9
  if shared_children
10
10
  shared_children.each do |link|
11
- run "mkdir -p #{shared_path}/#{link}"
12
- run "if [ -d #{release_path}/#{link} ] ; then rm -rf #{release_path}/#{link}; fi"
13
- run "ln -nfs #{shared_path}/#{link} #{release_path}/#{link}"
11
+ try_sudo "mkdir -p #{shared_path}/#{link}"
12
+ try_sudo "sh -c 'if [ -d #{release_path}/#{link} ] ; then rm -rf #{release_path}/#{link}; fi'"
13
+ try_sudo "ln -nfs #{shared_path}/#{link} #{release_path}/#{link}"
14
14
  end
15
15
  end
16
16
  if shared_files
17
17
  shared_files.each do |link|
18
18
  link_dir = File.dirname("#{shared_path}/#{link}")
19
- run "mkdir -p #{link_dir}"
20
- run "touch #{shared_path}/#{link}"
21
- run "ln -nfs #{shared_path}/#{link} #{release_path}/#{link}"
19
+ try_sudo "mkdir -p #{link_dir}"
20
+ try_sudo "touch #{shared_path}/#{link}"
21
+ try_sudo "ln -nfs #{shared_path}/#{link} #{release_path}/#{link}"
22
22
  end
23
23
  end
24
24
  end
25
25
 
26
26
  desc "Customize the finalize_update task to work with symfony."
27
27
  task :finalize_update, :except => { :no_release => true } do
28
- run "chmod -R g+w #{latest_release}" if fetch(:group_writable, true)
29
- run "mkdir -p #{latest_release}/cache"
30
- run "chmod -R g+w #{latest_release}/cache"
28
+ try_sudo "chmod -R g+w #{latest_release}" if fetch(:group_writable, true)
29
+ try_sudo "mkdir -p #{latest_release}/cache"
30
+ try_sudo "chmod -R g+w #{latest_release}/cache"
31
31
 
32
32
  # Share common files & folders
33
33
  share_childs
@@ -35,7 +35,7 @@ namespace :deploy do
35
35
  if fetch(:normalize_asset_timestamps, true)
36
36
  stamp = Time.now.utc.strftime("%Y%m%d%H%M.%S")
37
37
  asset_paths = asset_children.map { |p| "#{latest_release}/#{p}" }.join(" ")
38
- run "find #{asset_paths} -exec touch -t #{stamp} {} ';'; true", :env => { "TZ" => "UTC" }
38
+ try_sudo "find #{asset_paths} -exec touch -t #{stamp} {} ';'; true", :env => { "TZ" => "UTC" }
39
39
  end
40
40
  end
41
41
 
@@ -2,7 +2,7 @@ namespace :symfony do
2
2
  namespace :doctrine do
3
3
  desc "Compile doctrine"
4
4
  task :compile do
5
- run "cd #{latest_release} && #{php_bin} ./symfony doctrine:compile"
5
+ try_sudo "sh -c 'cd #{latest_release} && #{php_bin} ./symfony doctrine:compile'"
6
6
  end
7
7
 
8
8
  desc "Ensure Doctrine is correctly configured"
@@ -22,54 +22,54 @@ namespace :symfony do
22
22
 
23
23
  desc "Dumps data to the fixtures directory"
24
24
  task :data_dump do
25
- run "cd #{latest_release} && #{php_bin} ./symfony doctrine:data-dump --env=#{symfony_env_prod}"
25
+ try_sudo "sh -c 'cd #{latest_release} && #{php_bin} ./symfony doctrine:data-dump --env=#{symfony_env_prod}'"
26
26
  end
27
27
 
28
28
  desc "Loads YAML fixture data"
29
29
  task :data_load do
30
- run "cd #{latest_release} && #{php_bin} ./symfony doctrine:data-load --env=#{symfony_env_prod}"
30
+ try_sudo "sh -c 'cd #{latest_release} && #{php_bin} ./symfony doctrine:data-load --env=#{symfony_env_prod}'"
31
31
  end
32
32
 
33
33
  desc "Loads YAML fixture data without remove"
34
34
  task :data_load_append do
35
- run "cd #{latest_release} && #{php_bin} ./symfony doctrine:data-load --append --env=#{symfony_env_prod}"
35
+ try_sudo "sh -c 'cd #{latest_release} && #{php_bin} ./symfony doctrine:data-load --append --env=#{symfony_env_prod}'"
36
36
  end
37
37
 
38
38
  desc "Migrates database to current version"
39
39
  task :migrate do
40
- run "cd #{latest_release} && #{php_bin} ./symfony doctrine:migrate --env=#{symfony_env_prod}"
40
+ try_sudo "sh -c 'cd #{latest_release} && #{php_bin} ./symfony doctrine:migrate --env=#{symfony_env_prod}'"
41
41
  end
42
42
 
43
43
  desc "Generate model lib form and filters classes based on your schema"
44
44
  task :build_classes do
45
- run "cd #{latest_release} && #{php_bin} ./symfony doctrine:build --all-classes --env=#{symfony_env_prod}"
45
+ try_sudo "sh -c 'cd #{latest_release} && #{php_bin} ./symfony doctrine:build --all-classes --env=#{symfony_env_prod}'"
46
46
  end
47
47
 
48
48
  desc "Generate code & database based on your schema"
49
49
  task :build_all do
50
50
  if Capistrano::CLI.ui.agree("Do you really want to rebuild #{symfony_env_prod}'s database? (y/N)")
51
- run "cd #{latest_release} && #{php_bin} ./symfony doctrine:build --all --no-confirmation --env=#{symfony_env_prod}"
51
+ try_sudo "sh -c 'cd #{latest_release} && #{php_bin} ./symfony doctrine:build --all --no-confirmation --env=#{symfony_env_prod}'"
52
52
  end
53
53
  end
54
54
 
55
55
  desc "Generate code & database based on your schema & load fixtures"
56
56
  task :build_all_and_load do
57
57
  if Capistrano::CLI.ui.agree("Do you really want to rebuild #{symfony_env_prod}'s database and load #{symfony_env_prod}'s fixtures? (y/N)")
58
- run "cd #{latest_release} && #{php_bin} ./symfony doctrine:build --all --and-load --no-confirmation --env=#{symfony_env_prod}"
58
+ try_sudo "sh -c 'cd #{latest_release} && #{php_bin} ./symfony doctrine:build --all --and-load --no-confirmation --env=#{symfony_env_prod}'"
59
59
  end
60
60
  end
61
61
 
62
62
  desc "Generate sql & database based on your schema"
63
63
  task :build_db do
64
64
  if Capistrano::CLI.ui.agree("Do you really want to rebuild #{symfony_env_prod}'s database? (y/N)")
65
- run "cd #{latest_release} && #{php_bin} ./symfony doctrine:build --sql --db --no-confirmation --env=#{symfony_env_prod}"
65
+ try_sudo "sh -c 'cd #{latest_release} && #{php_bin} ./symfony doctrine:build --sql --db --no-confirmation --env=#{symfony_env_prod}'"
66
66
  end
67
67
  end
68
68
 
69
69
  desc "Generate sql & database based on your schema & load fixtures"
70
70
  task :build_db_and_load do
71
71
  if Capistrano::CLI.ui.agree("Do you really want to rebuild #{symfony_env_prod}'s database and load #{symfony_env_prod}'s fixtures? (y/N)")
72
- run "cd #{latest_release} && #{php_bin} ./symfony doctrine:build --sql --db --and-load --no-confirmation --env=#{symfony_env_prod}"
72
+ try_sudo "sh -c 'cd #{latest_release} && #{php_bin} ./symfony doctrine:build --sql --db --and-load --no-confirmation --env=#{symfony_env_prod}'"
73
73
  end
74
74
  end
75
75
  end
@@ -9,7 +9,7 @@ namespace :symfony do
9
9
  deploy.share_childs
10
10
 
11
11
  if (!conf_files_exists.eql?("exists"))
12
- run "cp #{symfony_lib}/plugins/sfPropelPlugin/config/skeleton/config/propel.ini #{shared_path}/config/propel.ini"
12
+ try_sudo "cp #{symfony_lib}/plugins/sfPropelPlugin/config/skeleton/config/propel.ini #{shared_path}/config/propel.ini"
13
13
  symfony.configure.database
14
14
  end
15
15
  end
@@ -21,36 +21,36 @@ namespace :symfony do
21
21
 
22
22
  desc "Generate model lib form and filters classes based on your schema"
23
23
  task :build_classes do
24
- run "php #{latest_release}/symfony propel:build --model --env=#{symfony_env_prod}"
25
- run "php #{latest_release}/symfony propel:build --forms --env=#{symfony_env_prod}"
26
- run "php #{latest_release}/symfony propel:build --filters --env=#{symfony_env_prod}"
24
+ try_sudo "php #{latest_release}/symfony propel:build --model --env=#{symfony_env_prod}"
25
+ try_sudo "php #{latest_release}/symfony propel:build --forms --env=#{symfony_env_prod}"
26
+ try_sudo "php #{latest_release}/symfony propel:build --filters --env=#{symfony_env_prod}"
27
27
  end
28
28
 
29
29
  desc "Generate code & database based on your schema"
30
30
  task :build_all do
31
31
  if Capistrano::CLI.ui.agree("Do you really want to rebuild #{symfony_env_prod}'s database? (y/N)")
32
- run "cd #{latest_release} && #{php_bin} ./symfony propel:build --sql --db --no-confirmation --env=#{symfony_env_prod}"
32
+ try_sudo "sh -c 'cd #{latest_release} && #{php_bin} ./symfony propel:build --sql --db --no-confirmation --env=#{symfony_env_prod}'"
33
33
  end
34
34
  end
35
35
 
36
36
  desc "Generate code & database based on your schema & load fixtures"
37
37
  task :build_all_and_load do
38
38
  if Capistrano::CLI.ui.agree("Do you really want to rebuild #{symfony_env_prod}'s database and load #{symfony_env_prod}'s fixtures? (y/N)")
39
- run "cd #{latest_release} && #{php_bin} ./symfony propel:build --sql --db --and-load --no-confirmation --env=#{symfony_env_prod}"
39
+ try_sudo "sh -c 'cd #{latest_release} && #{php_bin} ./symfony propel:build --sql --db --and-load --no-confirmation --env=#{symfony_env_prod}'"
40
40
  end
41
41
  end
42
42
 
43
43
  desc "Generate sql & database based on your schema"
44
44
  task :build_db do
45
45
  if Capistrano::CLI.ui.agree("Do you really want to rebuild #{symfony_env_prod}'s database? (y/N)")
46
- run "cd #{latest_release} && #{php_bin} ./symfony propel:build --sql --db --no-confirmation --env=#{symfony_env_prod}"
46
+ try_sudo "sh -c 'cd #{latest_release} && #{php_bin} ./symfony propel:build --sql --db --no-confirmation --env=#{symfony_env_prod}'"
47
47
  end
48
48
  end
49
49
 
50
50
  desc "Generate sql & database based on your schema & load fixtures"
51
51
  task :build_db_and_load do
52
52
  if Capistrano::CLI.ui.agree("Do you really want to rebuild #{symfony_env_prod}'s database and load #{symfony_env_prod}'s fixtures? (y/N)")
53
- run "cd #{latest_release} && #{php_bin} ./symfony propel:build --sql --db --and-load --no-confirmation --env=#{symfony_env_prod}"
53
+ try_sudo "sh -c 'cd #{latest_release} && #{php_bin} ./symfony propel:build --sql --db --and-load --no-confirmation --env=#{symfony_env_prod}'"
54
54
  end
55
55
  end
56
56
  end
@@ -40,7 +40,7 @@ namespace :shared do
40
40
  task :download do
41
41
  prompt_with_default(:version, symfony_version)
42
42
 
43
- run <<-CMD
43
+ try_sudo <<-CMD
44
44
  if [ ! -d #{shared_path}/symfony-#{version} ]; then
45
45
  wget -q http://www.symfony-project.org/get/symfony-#{version}.tgz -O- | tar -zxf - -C #{shared_path};
46
46
  fi
@@ -10,15 +10,15 @@ namespace :symfony do
10
10
  task :check_configuration do
11
11
  prompt_with_default(:version, "1.4")
12
12
 
13
- run "wget http://sf-to.org/#{version}/check.php -O /tmp/check_configuration.php"
13
+ try_sudo "wget http://sf-to.org/#{version}/check.php -O /tmp/check_configuration.php"
14
14
  stream "#{php_bin} /tmp/check_configuration.php"
15
- run "rm /tmp/check_configuration.php"
15
+ try_sudo "rm /tmp/check_configuration.php"
16
16
  end
17
17
 
18
18
  desc "Clears the cache"
19
19
  task :cc do
20
- run "cd #{latest_release} && #{try_sudo} #{php_bin} ./symfony cache:clear"
21
- run "chmod -R g+w #{latest_release}/cache"
20
+ try_sudo "sh -c 'cd #{latest_release} && #{try_sudo} #{php_bin} ./symfony cache:clear'"
21
+ try_sudo "chmod -R g+w #{latest_release}/cache"
22
22
  end
23
23
 
24
24
  desc "Creates symbolic link to symfony lib in shared"
@@ -26,8 +26,8 @@ namespace :symfony do
26
26
  prompt_with_default(:version, symfony_version)
27
27
  symlink_path = "#{latest_release}/lib/vendor/symfony"
28
28
 
29
- run "if [ ! -d #{shared_path}/symfony-#{version} ]; then exit 1; fi;"
30
- run "ln -nfs #{shared_path}/symfony-#{version} #{symlink_path};"
29
+ try_sudo "sh -c 'if [ ! -d #{shared_path}/symfony-#{version} ]; then exit 1; fi;'"
30
+ try_sudo "ln -nfs #{shared_path}/symfony-#{version} #{symlink_path};"
31
31
  end
32
32
 
33
33
  namespace :configure do
@@ -54,29 +54,29 @@ namespace :symfony do
54
54
  namespace :project do
55
55
  desc "Disables an application in a given environment"
56
56
  task :disable do
57
- run "cd #{latest_release} && #{php_bin} ./symfony project:disable #{symfony_env_prod}"
57
+ try_sudo "sh -c 'cd #{latest_release} && #{php_bin} ./symfony project:disable #{symfony_env_prod}'"
58
58
  end
59
59
 
60
60
  desc "Enables an application in a given environment"
61
61
  task :enable do
62
- run "cd #{latest_release} && #{php_bin} ./symfony project:enable #{symfony_env_prod}"
62
+ try_sudo "sh -c 'cd #{latest_release} && #{php_bin} ./symfony project:enable #{symfony_env_prod}'"
63
63
  end
64
64
 
65
65
  desc "Fixes symfony directory permissions"
66
66
  task :permissions do
67
- run "cd #{latest_release} && #{php_bin} ./symfony project:permissions"
67
+ try_sudo "sh -c 'cd #{latest_release} && #{php_bin} ./symfony project:permissions'"
68
68
  end
69
69
 
70
70
  desc "Optimizes a project for better performance"
71
71
  task :optimize do
72
72
  prompt_with_default(:application, "frontend")
73
73
 
74
- run "cd #{latest_release} && #{php_bin} ./symfony project:optimize #{application}"
74
+ try_sudo "sh -c 'cd #{latest_release} && #{php_bin} ./symfony project:optimize #{application}'"
75
75
  end
76
76
 
77
77
  desc "Clears all non production environment controllers"
78
78
  task :clear_controllers do
79
- run "cd #{latest_release} && #{php_bin} ./symfony project:clear-controllers"
79
+ try_sudo "sh -c 'cd #{latest_release} && #{php_bin} ./symfony project:clear-controllers'"
80
80
  end
81
81
 
82
82
  desc "Sends emails stored in a queue"
@@ -103,7 +103,7 @@ namespace :symfony do
103
103
  cmd << "cp #{release_path}/web/#{app}_#{env}.php #{release_path}/web/#{app}.php"
104
104
  end
105
105
 
106
- run cmd.join(';') if cmd.join(';')
106
+ try_sudo "-s #{cmd.join(';')}" if cmd.join(';')
107
107
  end
108
108
  end
109
109
  end
@@ -111,40 +111,40 @@ namespace :symfony do
111
111
  namespace :plugin do
112
112
  desc "Publishes web assets for all plugins"
113
113
  task :publish_assets do
114
- run "cd #{latest_release} && #{php_bin} ./symfony plugin:publish-assets"
114
+ try_sudo "sh -c 'cd #{latest_release} && #{php_bin} ./symfony plugin:publish-assets'"
115
115
  end
116
116
  end
117
117
 
118
118
  namespace :log do
119
119
  desc "Clears log files"
120
120
  task :clear do
121
- run "cd #{latest_release} && #{php_bin} ./symfony log:clear"
121
+ try_sudo "sh -c 'cd #{latest_release} && #{php_bin} ./symfony log:clear'"
122
122
  end
123
123
 
124
124
  desc "Rotates an application's log files"
125
125
  task :rotate do
126
126
  prompt_with_default(:application, "frontend")
127
127
 
128
- run "cd #{latest_release} && #{php_bin} ./symfony log:rotate #{application} #{symfony_env_prod}"
128
+ try_sudo "sh -c 'cd #{latest_release} && #{php_bin} ./symfony log:rotate #{application} #{symfony_env_prod}'"
129
129
  end
130
130
  end
131
131
 
132
132
  namespace :tests do
133
133
  desc "Launches all tests"
134
134
  task :all do
135
- run "cd #{latest_release} && #{php_bin} ./symfony test:all"
135
+ try_sudo "sh -c 'cd #{latest_release} && #{php_bin} ./symfony test:all'"
136
136
  end
137
137
 
138
138
  desc "Launches functional tests"
139
139
  task :functional do
140
140
  prompt_with_default(:application, "frontend")
141
141
 
142
- run "cd #{latest_release} && #{php_bin} ./symfony test:functional #{application}"
142
+ try_sudo "sh -c 'cd #{latest_release} && #{php_bin} ./symfony test:functional #{application}'"
143
143
  end
144
144
 
145
145
  desc "Launches unit tests"
146
146
  task :unit do
147
- run "cd #{latest_release} && #{php_bin} ./symfony test:unit"
147
+ try_sudo "sh -c 'cd #{latest_release} && #{php_bin} ./symfony test:unit'"
148
148
  end
149
149
  end
150
150
 
@@ -56,6 +56,9 @@ set :assets_relative, false
56
56
  # Whether to update `assets_version` in `config.yml`
57
57
  set :update_assets_version, false
58
58
 
59
+ # Need to clear *_dev controllers
60
+ set :clear_controllers, true
61
+
59
62
  # Files that need to remain the same between deploys
60
63
  set :shared_files, false
61
64
 
@@ -99,7 +102,7 @@ def remote_file_exists?(full_path)
99
102
  end
100
103
 
101
104
  def remote_command_exists?(command)
102
- 'true' == capture("type -P #{command} &>/dev/null && echo 'true' || echo 'false'")
105
+ 'true' == capture("type -P #{command} &>/dev/null && echo 'true' || echo 'false'").strip
103
106
  end
104
107
 
105
108
  after "deploy:finalize_update" do
@@ -141,6 +144,10 @@ after "deploy:finalize_update" do
141
144
  if dump_assetic_assets
142
145
  symfony.assetic.dump # 5. Dump assetic assets
143
146
  end
147
+
148
+ if clear_controllers
149
+ symfony.project.clear_controllers
150
+ end
144
151
  end
145
152
 
146
153
  before "deploy:update_code" do
@@ -10,17 +10,17 @@ namespace :database do
10
10
  sqlfile = "#{application}_dump.sql"
11
11
  config = ""
12
12
 
13
- run "cat #{current_path}/#{app_path}/config/parameters.yml" do |ch, st, data|
13
+ try_sudo "cat #{current_path}/#{app_path}/config/parameters.yml" do |ch, st, data|
14
14
  config = load_database_config data, symfony_env_prod
15
15
  end
16
16
 
17
17
  case config['database_driver']
18
18
  when "pdo_mysql", "mysql"
19
- run "mysqldump -u#{config['database_user']} --password='#{config['database_password']}' #{config['database_name']} | gzip -c > #{file}" do |ch, stream, data|
19
+ try_sudo "mysqldump -u#{config['database_user']} --password='#{config['database_password']}' #{config['database_name']} | gzip -c > #{file}" do |ch, stream, data|
20
20
  puts data
21
21
  end
22
22
  when "pdo_pgsql", "pgsql"
23
- run "pg_dump -U #{config['database_user']} #{config['database_name']} --clean | gzip -c > #{file}" do |ch, stream, data|
23
+ try_sudo "pg_dump -U #{config['database_user']} #{config['database_name']} --clean | gzip -c > #{file}" do |ch, stream, data|
24
24
  puts data
25
25
  end
26
26
  end
@@ -32,7 +32,7 @@ namespace :database do
32
32
  rescue NotImplementedError # hack for windows which doesnt support symlinks
33
33
  FileUtils.cp_r("backups/#{filename}", "backups/#{application}.remote_dump.latest.sql.gz")
34
34
  end
35
- run "rm #{file}"
35
+ try_sudo "rm #{file}"
36
36
  end
37
37
 
38
38
  desc "Dumps local database"
@@ -102,25 +102,25 @@ namespace :database do
102
102
  database.dump.local
103
103
 
104
104
  upload(file, "#{remote_tmp_dir}/#{filename}", :via => :scp)
105
- run "gunzip -c #{remote_tmp_dir}/#{filename} > #{remote_tmp_dir}/#{sqlfile}"
105
+ try_sudo "gunzip -c #{remote_tmp_dir}/#{filename} > #{remote_tmp_dir}/#{sqlfile}"
106
106
 
107
- run "cat #{current_path}/#{app_path}/config/parameters.yml" do |ch, st, data|
107
+ try_sudo "cat #{current_path}/#{app_path}/config/parameters.yml" do |ch, st, data|
108
108
  config = load_database_config data, symfony_env_prod
109
109
  end
110
110
 
111
111
  case config['database_driver']
112
112
  when "pdo_mysql", "mysql"
113
- run "mysql -u#{config['database_user']} --password='#{config['database_password']}' #{config['database_name']} < #{remote_tmp_dir}/#{sqlfile}" do |ch, stream, data|
113
+ try_sudo "mysql -u#{config['database_user']} --password='#{config['database_password']}' #{config['database_name']} < #{remote_tmp_dir}/#{sqlfile}" do |ch, stream, data|
114
114
  puts data
115
115
  end
116
116
  when "pdo_pgsql", "pgsql"
117
- run "psql -U #{config['database_user']} #{config['database_name']} < #{remote_tmp_dir}/#{sqlfile}" do |ch, stream, data|
117
+ try_sudo "psql -U #{config['database_user']} #{config['database_name']} < #{remote_tmp_dir}/#{sqlfile}" do |ch, stream, data|
118
118
  puts data
119
119
  end
120
120
  end
121
121
 
122
- run "rm #{remote_tmp_dir}/#{filename}"
123
- run "rm #{remote_tmp_dir}/#{sqlfile}"
122
+ try_sudo "rm #{remote_tmp_dir}/#{filename}"
123
+ try_sudo "rm #{remote_tmp_dir}/#{sqlfile}"
124
124
  end
125
125
  end
126
126
  end
@@ -19,23 +19,30 @@ namespace :deploy do
19
19
  end
20
20
 
21
21
  methods = {
22
- :chmod => "chmod +a \"#{webserver_user} allow delete,write,append,file_inherit,directory_inherit\" %s",
23
- :acl => "setfacl -dR -m u:#{webserver_user}:rwx %s",
24
- :chown => "chown #{webserver_user} %s"
22
+ :chmod => [
23
+ "chmod +a \"#{user} allow delete,write,append,file_inherit,directory_inherit\" %s",
24
+ "chmod +a \"#{webserver_user} allow delete,write,append,file_inherit,directory_inherit\" %s"
25
+ ],
26
+ :acl => ["setfacl -dR -m u:#{user}:rwx -m u:#{webserver_user}:rwx %s"],
27
+ :chown => ["chown #{webserver_user} %s"]
25
28
  }
26
29
 
27
30
  if methods[permission_method]
28
31
  pretty_print "--> Setting permissions"
29
32
 
30
33
  if fetch(:use_sudo, false)
31
- sudo sprintf(methods[permission_method], dirs.join(' '))
34
+ methods[permission_method].each do |cmd|
35
+ sudo sprintf(cmd, dirs.join(' '))
36
+ end
32
37
  elsif permission_method == :chown
33
38
  puts " You can't use chown method without sudoing"
34
39
  else
35
40
  dirs.each do |dir|
36
41
  is_owner = (capture "`echo stat #{dir} -c %U`").chomp == user
37
42
  if is_owner && permission_method != :chown
38
- run sprintf(methods[permission_method], dir)
43
+ methods[permission_method].each do |cmd|
44
+ try_sudo sprintf(cmd, dir)
45
+ end
39
46
  else
40
47
  puts " #{dir} is not owned by #{user} or you are using 'chown' method without ':use_sudo'"
41
48
  end
@@ -54,9 +61,9 @@ namespace :deploy do
54
61
  pretty_print "--> Creating symlinks for shared directories"
55
62
 
56
63
  shared_children.each do |link|
57
- run "mkdir -p #{shared_path}/#{link}"
58
- run "if [ -d #{release_path}/#{link} ] ; then rm -rf #{release_path}/#{link}; fi"
59
- run "ln -nfs #{shared_path}/#{link} #{release_path}/#{link}"
64
+ try_sudo "mkdir -p #{shared_path}/#{link}"
65
+ try_sudo "sh -c 'if [ -d #{release_path}/#{link} ] ; then rm -rf #{release_path}/#{link}; fi'"
66
+ try_sudo "ln -nfs #{shared_path}/#{link} #{release_path}/#{link}"
60
67
  end
61
68
 
62
69
  puts_ok
@@ -67,9 +74,9 @@ namespace :deploy do
67
74
 
68
75
  shared_files.each do |link|
69
76
  link_dir = File.dirname("#{shared_path}/#{link}")
70
- run "mkdir -p #{link_dir}"
71
- run "touch #{shared_path}/#{link}"
72
- run "ln -nfs #{shared_path}/#{link} #{release_path}/#{link}"
77
+ try_sudo "mkdir -p #{link_dir}"
78
+ try_sudo "touch #{shared_path}/#{link}"
79
+ try_sudo "ln -nfs #{shared_path}/#{link} #{release_path}/#{link}"
73
80
  end
74
81
 
75
82
  puts_ok
@@ -78,13 +85,13 @@ namespace :deploy do
78
85
 
79
86
  desc "Updates latest release source path"
80
87
  task :finalize_update, :roles => :app, :except => { :no_release => true } do
81
- run "chmod -R g+w #{latest_release}" if fetch(:group_writable, true)
88
+ try_sudo "chmod -R g+w #{latest_release}" if fetch(:group_writable, true)
82
89
 
83
90
  pretty_print "--> Creating cache directory"
84
91
 
85
- run "if [ -d #{latest_release}/#{cache_path} ] ; then rm -rf #{latest_release}/#{cache_path}; fi"
86
- run "mkdir -p #{latest_release}/#{cache_path} && chmod -R 0777 #{latest_release}/#{cache_path}"
87
- run "chmod -R g+w #{latest_release}/#{cache_path}"
92
+ try_sudo "sh -c 'if [ -d #{latest_release}/#{cache_path} ] ; then rm -rf #{latest_release}/#{cache_path}; fi'"
93
+ try_sudo "sh -c 'mkdir -p #{latest_release}/#{cache_path} && chmod -R 0777 #{latest_release}/#{cache_path}'"
94
+ try_sudo "chmod -R g+w #{latest_release}/#{cache_path}"
88
95
 
89
96
  puts_ok
90
97
 
@@ -99,7 +106,7 @@ namespace :deploy do
99
106
  else
100
107
  pretty_print "--> Normalizing asset timestamps"
101
108
 
102
- run "find #{asset_paths} -exec touch -t #{stamp} {} ';' &> /dev/null || true", :env => { "TZ" => "UTC" }
109
+ try_sudo "find #{asset_paths} -exec touch -t #{stamp} {} ';' &> /dev/null || true", :env => { "TZ" => "UTC" }
103
110
  puts_ok
104
111
  end
105
112
  end
@@ -118,7 +125,7 @@ namespace :deploy do
118
125
  task :testall, :roles => :app, :except => { :no_release => true } do
119
126
  update_code
120
127
  create_symlink
121
- run "cd #{latest_release} && phpunit -c #{app_path} src"
128
+ try_sudo "sh -c 'cd #{latest_release} && phpunit -c #{app_path} src'"
122
129
  end
123
130
 
124
131
  desc "Runs the Symfony2 migrations"
@@ -5,7 +5,7 @@ namespace :symfony do
5
5
  task :clear_metadata, :roles => :app, :except => { :no_release => true } do
6
6
  pretty_print "--> Clearing Doctrine metadata cache"
7
7
 
8
- run "cd #{latest_release} && #{php_bin} #{symfony_console} doctrine:cache:clear-metadata --env=#{symfony_env_prod}"
8
+ try_sudo "sh -c 'cd #{latest_release} && #{php_bin} #{symfony_console} doctrine:cache:clear-metadata --env=#{symfony_env_prod}'"
9
9
  puts_ok
10
10
  end
11
11
 
@@ -13,7 +13,7 @@ namespace :symfony do
13
13
  task :clear_query, :roles => :app, :except => { :no_release => true } do
14
14
  pretty_print "--> Clearing Doctrine query cache"
15
15
 
16
- run "cd #{latest_release} && #{php_bin} #{symfony_console} doctrine:cache:clear-query --env=#{symfony_env_prod}"
16
+ try_sudo "sh -c 'cd #{latest_release} && #{php_bin} #{symfony_console} doctrine:cache:clear-query --env=#{symfony_env_prod}'"
17
17
  puts_ok
18
18
  end
19
19
 
@@ -21,7 +21,7 @@ namespace :symfony do
21
21
  task :clear_result, :roles => :app, :except => { :no_release => true } do
22
22
  pretty_print "--> Clearing Doctrine result cache"
23
23
 
24
- run "cd #{latest_release} && #{php_bin} #{symfony_console} doctrine:cache:clear-result --env=#{symfony_env_prod}"
24
+ try_sudo "sh -c 'cd #{latest_release} && #{php_bin} #{symfony_console} doctrine:cache:clear-result --env=#{symfony_env_prod}'"
25
25
  puts_ok
26
26
  end
27
27
  end
@@ -37,7 +37,7 @@ namespace :symfony do
37
37
  pretty_print "--> Dropping databases"
38
38
  end
39
39
 
40
- run "cd #{latest_release} && #{php_bin} #{symfony_console} doctrine:database:#{action.to_s} --env=#{symfony_env_prod}", :once => true
40
+ try_sudo "sh -c 'cd #{latest_release} && #{php_bin} #{symfony_console} doctrine:database:#{action.to_s} --env=#{symfony_env_prod}'", :once => true
41
41
  puts_ok
42
42
  end
43
43
  end
@@ -46,12 +46,12 @@ namespace :symfony do
46
46
  namespace :schema do
47
47
  desc "Processes the schema and either create it directly on EntityManager Storage Connection or generate the SQL output"
48
48
  task :create, :roles => :app, :except => { :no_release => true } do
49
- run "cd #{latest_release} && #{php_bin} #{symfony_console} doctrine:schema:create --env=#{symfony_env_prod}", :once => true
49
+ try_sudo "sh -c 'cd #{latest_release} && #{php_bin} #{symfony_console} doctrine:schema:create --env=#{symfony_env_prod}'", :once => true
50
50
  end
51
51
 
52
52
  desc "Drops the complete database schema of EntityManager Storage Connection or generate the corresponding SQL output"
53
53
  task :drop, :roles => :app, :except => { :no_release => true } do
54
- run "cd #{latest_release} && #{php_bin} #{symfony_console} doctrine:schema:drop --env=#{symfony_env_prod}", :once => true
54
+ try_sudo "sh -c 'cd #{latest_release} && #{php_bin} #{symfony_console} doctrine:schema:drop --env=#{symfony_env_prod}'", :once => true
55
55
  end
56
56
  end
57
57
 
@@ -59,8 +59,8 @@ namespace :symfony do
59
59
  desc "Executes a migration to a specified version or the latest available version"
60
60
  task :migrate, :roles => :app, :except => { :no_release => true } do
61
61
  currentVersion = nil
62
- run "cd #{latest_release} && #{php_bin} #{symfony_console} doctrine:migrations:status --env=#{symfony_env_prod}", :once => true do |ch, stream, out|
63
- if stream == :out and out =~ /Current Version:[^$]+\(([\w]+)\)/
62
+ try_sudo "sh -c 'cd #{latest_release} && #{php_bin} #{symfony_console} --no-ansi doctrine:migrations:status --env=#{symfony_env_prod}'", :once => true do |ch, stream, out|
63
+ if stream == :out and out =~ /Current Version:.+\(([\w]+)\)/
64
64
  currentVersion = Regexp.last_match(1)
65
65
  end
66
66
  if stream == :out and out =~ /Current Version:\s*0\s*$/
@@ -75,18 +75,18 @@ namespace :symfony do
75
75
 
76
76
  on_rollback {
77
77
  if !interactive_mode || Capistrano::CLI.ui.agree("Do you really want to migrate #{symfony_env_prod}'s database back to version #{currentVersion}? (y/N)")
78
- run "cd #{latest_release} && #{php_bin} #{symfony_console} doctrine:migrations:migrate #{currentVersion} --env=#{symfony_env_prod} --no-interaction", :once => true
78
+ try_sudo "sh -c 'cd #{latest_release} && #{php_bin} #{symfony_console} doctrine:migrations:migrate #{currentVersion} --env=#{symfony_env_prod} --no-interaction'", :once => true
79
79
  end
80
80
  }
81
81
 
82
82
  if !interactive_mode || Capistrano::CLI.ui.agree("Do you really want to migrate #{symfony_env_prod}'s database? (y/N)")
83
- run "cd #{latest_release} && #{php_bin} #{symfony_console} doctrine:migrations:migrate --env=#{symfony_env_prod} --no-interaction", :once => true
83
+ try_sudo "sh -c 'cd #{latest_release} && #{php_bin} #{symfony_console} doctrine:migrations:migrate --env=#{symfony_env_prod} --no-interaction'", :once => true
84
84
  end
85
85
  end
86
86
 
87
87
  desc "Views the status of a set of migrations"
88
88
  task :status, :roles => :app, :except => { :no_release => true } do
89
- run "cd #{latest_release} && #{php_bin} #{symfony_console} doctrine:migrations:status --env=#{symfony_env_prod}", :once => true
89
+ try_sudo "sh -c 'cd #{latest_release} && #{php_bin} #{symfony_console} doctrine:migrations:status --env=#{symfony_env_prod}'", :once => true
90
90
  end
91
91
  end
92
92
 
@@ -97,7 +97,7 @@ namespace :symfony do
97
97
  task action, :roles => :app, :except => { :no_release => true } do
98
98
  pretty_print "--> Executing MongoDB schema #{action.to_s}"
99
99
 
100
- run "cd #{latest_release} && #{php_bin} #{symfony_console} doctrine:mongodb:schema:#{action.to_s} --env=#{symfony_env_prod}", :once => true
100
+ try_sudo "sh -c 'cd #{latest_release} && #{php_bin} #{symfony_console} doctrine:mongodb:schema:#{action.to_s} --env=#{symfony_env_prod}'", :once => true
101
101
  puts_ok
102
102
  end
103
103
  end
@@ -107,7 +107,7 @@ namespace :symfony do
107
107
  task action, :roles => :app do
108
108
  pretty_print "--> Executing MongoDB indexes #{action.to_s}"
109
109
 
110
- run "cd #{latest_release} && #{php_bin} #{symfony_console} doctrine:mongodb:schema:#{action.to_s} --index --env=#{symfony_env_prod}", :once => true
110
+ try_sudo "sh -c 'cd #{latest_release} && #{php_bin} #{symfony_console} doctrine:mongodb:schema:#{action.to_s} --index --env=#{symfony_env_prod}'", :once => true
111
111
  puts_ok
112
112
  end
113
113
  end
@@ -120,7 +120,7 @@ namespace :symfony do
120
120
  task :acl, :roles => :app, :except => { :no_release => true } do
121
121
  pretty_print "--> Mounting Doctrine ACL tables"
122
122
 
123
- run "cd #{latest_release} && #{php_bin} #{symfony_console} init:acl --env=#{symfony_env_prod}", :once => true
123
+ try_sudo "sh -c 'cd #{latest_release} && #{php_bin} #{symfony_console} init:acl --env=#{symfony_env_prod}'", :once => true
124
124
  puts_ok
125
125
  end
126
126
  end
@@ -11,7 +11,7 @@ namespace :symfony do
11
11
  pretty_print "--> Dropping databases"
12
12
  end
13
13
 
14
- run "cd #{latest_release} && #{php_bin} #{symfony_console} propel:database:#{action.to_s} --env=#{symfony_env_prod}", :once => true
14
+ try_sudo "sh -c 'cd #{latest_release} && #{php_bin} #{symfony_console} propel:database:#{action.to_s} --env=#{symfony_env_prod}'", :once => true
15
15
  puts_ok
16
16
  end
17
17
  end
@@ -27,7 +27,7 @@ namespace :symfony do
27
27
 
28
28
  pretty_print "--> Generating Propel classes"
29
29
 
30
- run "cd #{latest_release} && #{php_bin} #{symfony_console} #{command} --env=#{symfony_env_prod}"
30
+ try_sudo "sh -c 'cd #{latest_release} && #{php_bin} #{symfony_console} #{command} --env=#{symfony_env_prod}'"
31
31
  puts_ok
32
32
  end
33
33
 
@@ -40,7 +40,7 @@ namespace :symfony do
40
40
 
41
41
  pretty_print "--> Generating Propel SQL"
42
42
 
43
- run "cd #{latest_release} && #{php_bin} #{symfony_console} #{command} --env=#{symfony_env_prod}"
43
+ try_sudo "sh -c 'cd #{latest_release} && #{php_bin} #{symfony_console} #{command} --env=#{symfony_env_prod}'"
44
44
  puts_ok
45
45
  end
46
46
 
@@ -53,7 +53,7 @@ namespace :symfony do
53
53
 
54
54
  pretty_print "--> Inserting Propel SQL"
55
55
 
56
- run "cd #{latest_release} && #{php_bin} #{symfony_console} #{command} --force --env=#{symfony_env_prod}", :once => true
56
+ try_sudo "sh -c 'cd #{latest_release} && #{php_bin} #{symfony_console} #{command} --force --env=#{symfony_env_prod}'", :once => true
57
57
  puts_ok
58
58
  end
59
59
 
@@ -61,18 +61,18 @@ namespace :symfony do
61
61
  task :all_and_load, :roles => :app, :except => { :no_release => true } do
62
62
  pretty_print "--> Setting up Propel (classes, SQL)"
63
63
 
64
- run "cd #{latest_release} && #{php_bin} #{symfony_console} propel:build --insert-sql --env=#{symfony_env_prod}"
64
+ try_sudo "sh -c 'cd #{latest_release} && #{php_bin} #{symfony_console} propel:build --insert-sql --env=#{symfony_env_prod}'"
65
65
  puts_ok
66
66
  end
67
67
 
68
68
  desc "Generates ACLs models"
69
69
  task :acl, :roles => :app, :except => { :no_release => true } do
70
- run "cd #{latest_release} && #{php_bin} #{symfony_console} propel:acl:init --env=#{symfony_env_prod}"
70
+ try_sudo "sh -c 'cd #{latest_release} && #{php_bin} #{symfony_console} propel:acl:init --env=#{symfony_env_prod}'"
71
71
  end
72
72
 
73
73
  desc "Inserts propel ACL tables"
74
74
  task :acl_load, :roles => :app, :except => { :no_release => true } do
75
- run "cd #{latest_release} && #{php_bin} #{symfony_console} propel:acl:init --env=#{symfony_env_prod} --force", :once => true
75
+ try_sudo "sh -c 'cd #{latest_release} && #{php_bin} #{symfony_console} propel:acl:init --env=#{symfony_env_prod} --force'", :once => true
76
76
  end
77
77
  end
78
78
  end
@@ -12,7 +12,7 @@ namespace :symfony do
12
12
  log = action.to_s == 'tail' ? 'prod.log' : 'dev.log'
13
13
  desc "Tail #{log}"
14
14
  task action, :roles => :app, :except => { :no_release => true } do
15
- run "tail -n #{lines} -f #{shared_path}/#{log_path}/#{log}" do |channel, stream, data|
15
+ try_sudo "tail -n #{lines} -f #{shared_path}/#{log_path}/#{log}" do |channel, stream, data|
16
16
  trap("INT") { puts 'Interupted'; exit 0; }
17
17
  puts
18
18
  puts "#{channel[:host]}: #{data}"
@@ -25,7 +25,7 @@ namespace :symfony do
25
25
  namespace :assets do
26
26
  desc "Updates assets version (in config.yml)"
27
27
  task :update_version, :roles => :app, :except => { :no_release => true } do
28
- run "sed -i 's/\\(assets_version: \\)\\(.*\\)$/\\1 #{real_revision}/g' #{latest_release}/#{app_path}/config/config.yml"
28
+ try_sudo "sed -i 's/\\(assets_version: \\)\\(.*\\)$/\\1 #{real_revision}/g' #{latest_release}/#{app_path}/config/config.yml"
29
29
  end
30
30
 
31
31
  desc "Installs bundle's assets"
@@ -42,7 +42,7 @@ namespace :symfony do
42
42
  install_options += " --relative"
43
43
  end
44
44
 
45
- run "cd #{latest_release} && #{php_bin} #{symfony_console} assets:install #{web_path} #{install_options} --env=#{symfony_env_prod}"
45
+ try_sudo "sh -c 'cd #{latest_release} && #{php_bin} #{symfony_console} assets:install #{web_path} #{install_options} --env=#{symfony_env_prod}'"
46
46
  puts_ok
47
47
  end
48
48
  end
@@ -52,7 +52,7 @@ namespace :symfony do
52
52
  task :dump, :roles => :app, :except => { :no_release => true } do
53
53
  pretty_print "--> Dumping all assets to the filesystem"
54
54
 
55
- run "cd #{latest_release} && #{php_bin} #{symfony_console} assetic:dump --env=#{symfony_env_prod} --no-debug"
55
+ try_sudo "sh -c 'cd #{latest_release} && #{php_bin} #{symfony_console} assetic:dump --env=#{symfony_env_prod} --no-debug'"
56
56
  puts_ok
57
57
  end
58
58
  end
@@ -62,7 +62,7 @@ namespace :symfony do
62
62
  task :install, :roles => :app, :except => { :no_release => true } do
63
63
  pretty_print "--> Installing vendors"
64
64
 
65
- run "cd #{latest_release} && #{php_bin} #{symfony_vendors} install"
65
+ try_sudo "sh -c 'cd #{latest_release} && #{php_bin} #{symfony_vendors} install'"
66
66
  puts_ok
67
67
  end
68
68
 
@@ -70,7 +70,7 @@ namespace :symfony do
70
70
  task :reinstall, :roles => :app, :except => { :no_release => true } do
71
71
  pretty_print "--> Reinstalling vendors"
72
72
 
73
- run "cd #{latest_release} && #{php_bin} #{symfony_vendors} install --reinstall"
73
+ try_sudo "sh -c 'cd #{latest_release} && #{php_bin} #{symfony_vendors} install --reinstall'"
74
74
  puts_ok
75
75
  end
76
76
 
@@ -78,7 +78,7 @@ namespace :symfony do
78
78
  task :upgrade, :roles => :app, :except => { :no_release => true } do
79
79
  pretty_print "--> Upgrading vendors"
80
80
 
81
- run "cd #{latest_release} && #{php_bin} #{symfony_vendors} update"
81
+ try_sudo "sh -c 'cd #{latest_release} && #{php_bin} #{symfony_vendors} update'"
82
82
  puts_ok
83
83
  end
84
84
  end
@@ -90,9 +90,9 @@ namespace :symfony do
90
90
 
91
91
  if !remote_file_exists?("#{latest_release}/#{build_bootstrap}") && true == use_composer then
92
92
  set :build_bootstrap, "vendor/sensio/distribution-bundle/Sensio/Bundle/DistributionBundle/Resources/bin/build_bootstrap.php"
93
- run "cd #{latest_release} && test -f #{build_bootstrap} && #{php_bin} #{build_bootstrap} #{app_path} || echo '#{build_bootstrap} not found, skipped'"
93
+ try_sudo "sh -c 'cd #{latest_release} && test -f #{build_bootstrap} && #{php_bin} #{build_bootstrap} #{app_path} || echo '#{build_bootstrap} not found, skipped''"
94
94
  else
95
- run "cd #{latest_release} && test -f #{build_bootstrap} && #{php_bin} #{build_bootstrap} || echo '#{build_bootstrap} not found, skipped'"
95
+ try_sudo "sh -c 'cd #{latest_release} && test -f #{build_bootstrap} && #{php_bin} #{build_bootstrap} || echo '#{build_bootstrap} not found, skipped''"
96
96
  end
97
97
 
98
98
  puts_ok
@@ -105,11 +105,11 @@ namespace :symfony do
105
105
  if remote_command_exists?('composer')
106
106
  pretty_print "--> Updating Composer in PATH"
107
107
 
108
- run "composer self-update"
108
+ try_sudo "composer self-update"
109
109
  else
110
110
  pretty_print "--> Downloading Composer"
111
111
 
112
- run "cd #{latest_release} && curl -s http://getcomposer.org/installer | #{php_bin}"
112
+ try_sudo "sh -c 'cd #{latest_release} && curl -s http://getcomposer.org/installer | #{php_bin}'"
113
113
  end
114
114
 
115
115
  puts_ok
@@ -117,25 +117,31 @@ namespace :symfony do
117
117
 
118
118
  desc "Runs composer to install vendors from composer.lock file"
119
119
  task :install, :roles => :app, :except => { :no_release => true } do
120
- if !remote_file_exists?("#{latest_release}/composer.phar")
120
+ composer_bin = "#{php_bin} composer.phar"
121
+ if remote_command_exists?('composer')
122
+ composer_bin = "composer"
123
+ elsif !remote_file_exists?("#{latest_release}/composer.phar")
121
124
  symfony.composer.get
122
125
  end
123
126
 
124
127
  pretty_print "--> Installing Composer dependencies"
125
128
 
126
- run "cd #{latest_release} && #{php_bin} composer.phar install --no-scripts --verbose"
129
+ try_sudo "sh -c 'cd #{latest_release} && #{composer_bin} install --no-scripts --verbose'"
127
130
  puts_ok
128
131
  end
129
132
 
130
133
  desc "Runs composer to update vendors, and composer.lock file"
131
134
  task :update, :roles => :app, :except => { :no_release => true } do
132
- if !remote_file_exists?("#{latest_release}/composer.phar")
135
+ composer_bin = "#{php_bin} composer.phar"
136
+ if remote_command_exists?('composer')
137
+ composer_bin = "composer"
138
+ elsif !remote_file_exists?("#{latest_release}/composer.phar")
133
139
  symfony.composer.get
134
140
  end
135
141
 
136
142
  pretty_print "--> Updating Composer dependencies"
137
143
 
138
- run "cd #{latest_release} && #{php_bin} composer.phar update --no-scripts --verbose"
144
+ try_sudo "sh -c 'cd #{latest_release} && #{composer_bin} update --no-scripts --verbose'"
139
145
  puts_ok
140
146
  end
141
147
  end
@@ -145,8 +151,8 @@ namespace :symfony do
145
151
  task :clear, :roles => :app, :except => { :no_release => true } do
146
152
  pretty_print "--> Clearing cache"
147
153
 
148
- run "cd #{latest_release} && #{php_bin} #{symfony_console} cache:clear --env=#{symfony_env_prod}"
149
- run "chmod -R g+w #{latest_release}/#{cache_path}"
154
+ try_sudo "sh -c 'cd #{latest_release} && #{php_bin} #{symfony_console} cache:clear --env=#{symfony_env_prod}'"
155
+ try_sudo "chmod -R g+w #{latest_release}/#{cache_path}"
150
156
  puts_ok
151
157
  end
152
158
 
@@ -154,8 +160,18 @@ namespace :symfony do
154
160
  task :warmup, :roles => :app, :except => { :no_release => true } do
155
161
  pretty_print "--> Warming up cache"
156
162
 
157
- run "cd #{latest_release} && #{php_bin} #{symfony_console} cache:warmup --env=#{symfony_env_prod}"
158
- run "chmod -R g+w #{latest_release}/#{cache_path}"
163
+ try_sudo "sh -c 'cd #{latest_release} && #{php_bin} #{symfony_console} cache:warmup --env=#{symfony_env_prod}'"
164
+ try_sudo "chmod -R g+w #{latest_release}/#{cache_path}"
165
+ puts_ok
166
+ end
167
+ end
168
+
169
+ namespace :project do
170
+ desc "Clears all non production environment controllers"
171
+ task :clear_controllers do
172
+ pretty_print "--> Clear controllers"
173
+
174
+ try_sudo "sh -c 'for file in #{latest_release}/web/*.php; do grep -HLP \"new AppKernel\\('prod[a-z]*'\" $file | xargs -I {} rm -f {}; done;'"
159
175
  puts_ok
160
176
  end
161
177
  end
@@ -63,7 +63,7 @@ namespace :deploy do
63
63
  web-accessible again.
64
64
  DESC
65
65
  task :enable, :roles => :web, :except => { :no_release => true } do
66
- run "rm #{latest_release}/#{web_path}/#{maintenance_basename}.html"
66
+ try_sudo "rm #{latest_release}/#{web_path}/#{maintenance_basename}.html"
67
67
  end
68
68
  end
69
69
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: capifony
3
3
  version: !ruby/object:Gem::Version
4
- hash: 19
4
+ hash: 17
5
5
  prerelease:
6
6
  segments:
7
7
  - 2
8
8
  - 1
9
- - 12
10
- version: 2.1.12
9
+ - 13
10
+ version: 2.1.13
11
11
  platform: ruby
12
12
  authors:
13
13
  - Konstantin Kudryashov
@@ -16,7 +16,7 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2012-08-06 00:00:00 Z
19
+ date: 2012-08-21 00:00:00 Z
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
22
22
  name: capistrano