Skip to content
Browse files

Merge branch 'master' into file-path-fix

Conflicts:
	lib/symfony1.rb
  • Loading branch information...
2 parents 46e7143 + cc1c9af commit 8c040c50ca15c601080e72bc902220c28f079903 @marijn marijn committed May 17, 2011
Showing with 88 additions and 27 deletions.
  1. +14 −1 CHANGELOG
  2. +1 −1 capifony.gemspec
  3. +43 −1 lib/symfony1.rb
  4. +30 −24 lib/symfony2.rb
View
15 CHANGELOG
@@ -1,3 +1,16 @@
+== 2.0.6 / May 4, 2011
+
+* add write access to cache folder for deployer's usergroup
+
+== 2.0.5 / May 3, 2011
+
+* made the Symfony2 console command configurable (symfony_console) (thanks @ruudk)
+* added --env=#{symfony_env_prod} to every Symfony2 console command (thanks @ruudk)
+
+== 2.0.4 / April 23, 2011
+
+* shared lib support in symfony1 (thanks @jakzal)
+
== 2.0.3 / April 16, 2011
* windows support for symfony1 database: tasks (thanks @akloboucnik)
@@ -70,4 +83,4 @@
== 0.1.0 / June 3, 2010
-First ever working version.
+First ever working version.
View
2 capifony.gemspec
@@ -1,7 +1,7 @@
Gem::Specification.new do |spec|
spec.name = 'capifony'
- spec.version = '2.0.3'
+ spec.version = '2.0.6'
spec.platform = Gem::Platform::RUBY
spec.description = <<-DESC
Capistrano is an open source tool for running scripts on multiple servers. It’s primary use is for easily deploying applications. While it was built specifically for deploying Rails apps, it’s pretty simple to customize it to deploy other types of applications. This package is a deployment “recipe” to work with symfony (both 1 and 2) applications.
View
44 lib/symfony1.rb 100755 → 100644
@@ -19,6 +19,10 @@
# Symfony lib path
set(:symfony_lib) { guess_symfony_lib }
+# Shared symfony lib
+set :use_shared_symfony, false
+set :symfony_version, "1.4.11"
+
def guess_symfony_orm
databases = YAML::load(IO.read('config/databases.yml'))
@@ -81,6 +85,7 @@ def load_database_config(data, env)
task :finalize_update, :except => { :no_release => true } do
run "chmod -R g+w #{latest_release}" if fetch(:group_writable, true)
run "mkdir -p #{latest_release}/cache"
+ run "chmod -R g+w #{latest_release}/cache"
# Share common files & folders
share_childs
@@ -127,7 +132,17 @@ def load_database_config(data, env)
desc "Clears the cache"
task :cc do
- run "cd #{latest_release} && #{php_bin} ./symfony cache:clear"
+ run "#{php_bin} #{latest_release}/symfony cache:clear"
+ run "chmod -R g+w #{latest_release}/cache"
+ end
+
+ desc "Creates symbolic link to symfony lib in shared"
+ task :create_lib_symlink do
+ prompt_with_default(:version, symfony_version)
+ symlink_path = "#{latest_release}/lib/vendor/symfony"
+
+ run "if [ ! -d #{shared_path}/symfony-#{version} ]; then exit 1; fi;"
+ run "ln -nfs #{shared_path}/symfony-#{version} #{symlink_path};"
end
namespace :configure do
@@ -578,6 +593,33 @@ def load_database_config(data, env)
upload("web/uploads", "#{shared_path}/web", :via => :scp, :recursive => true)
end
end
+
+ namespace :symfony do
+ desc "Downloads symfony framework to shared directory"
+ task :download do
+ prompt_with_default(:version, symfony_version)
+
+ run <<-CMD
+ if [ ! -d #{shared_path}/symfony-#{version} ]; then
+ wget -q http://www.symfony-project.org/get/symfony-#{version}.tgz -O- | tar -zxf - -C #{shared_path};
+ fi
+ CMD
+ end
+ end
+end
+
+# After setup
+after "deploy:setup" do
+ if use_shared_symfony
+ shared.symfony.download
+ end
+end
+
+# Before finalizing update
+before "deploy:finalize_update" do
+ if use_shared_symfony
+ symfony.create_lib_symlink
+ end
end
# After finalizing update:
View
54 lib/symfony2.rb
@@ -6,6 +6,9 @@
# Symfony web path
set :web_path, "web"
+# Symfony console bin
+set :symfony_console, "console"
+
# Use AsseticBundle
set :dump_assetic_assets, false
@@ -43,6 +46,7 @@
run "chmod -R g+w #{latest_release}" if fetch(:group_writable, true)
run "if [ -d #{latest_release}/#{app_path}/cache ] ; then rm -rf #{latest_release}/#{app_path}/cache; fi"
run "mkdir -p #{latest_release}/#{app_path}/cache && chmod -R 0777 #{latest_release}/#{app_path}/cache"
+ run "chmod -R g+w #{latest_release}/#{app_path}/cache"
share_childs
@@ -69,7 +73,7 @@
desc "Migrate Symfony2 Doctrine ORM database."
task :migrate do
currentVersion = nil
- run "#{php-bin} #{app-path}/console doctrine:migrations:status" do |ch, stream, out|
+ run "#{php-bin} #{app-path}/#{symfony_console} doctrine:migrations:status --env=#{symfony_env_prod}" do |ch, stream, out|
if stream == :out and out =~ /Current Version:[^$]+\(([0-9]+)\)/
currentVersion = Regexp.last_match(1)
end
@@ -84,14 +88,14 @@
puts "Current database version #{currentVersion}"
on_rollback {
- run "#{php-bin} #{app-path}/console doctrine:migrations:migrate #{currentVersion}" do |ch, stream, out|
+ run "#{php-bin} #{app-path}/#{symfony_console} doctrine:migrations:migrate #{currentVersion} --env=#{symfony_env_prod}" do |ch, stream, out|
if out =~ /Are you sure you wish to continue/
ch.send_data("y\r\n")
end
end
}
- run "#{php-bin} #{app-path}/console doctrine:migrations:migrate" do |ch, stream, out|
+ run "#{php-bin} #{app-path}/#{symfony_console} doctrine:migrations:migrate --env=#{symfony_env_prod}" do |ch, stream, out|
if out =~ /Are you sure you wish to continue/
ch.send_data("y\r\n")
end
@@ -104,128 +108,130 @@
task :default do
prompt_with_default(:task_arguments, "cache:clear")
- stream "cd #{latest_release} && #{php_bin} #{app_path}/console #{task_arguments}"
+ stream "cd #{latest_release} && #{php_bin} #{app_path}/#{symfony_console} #{task_arguments} --env=#{symfony_env_prod}"
end
namespace :assets do
desc "Install bundle's assets"
task :install do
- run "cd #{latest_release} && #{php_bin} #{app_path}/console assets:install #{web_path}"
+ run "cd #{latest_release} && #{php_bin} #{app_path}/#{symfony_console} assets:install #{web_path} --env=#{symfony_env_prod}"
end
end
namespace :assetic do
desc "Dumps all assets to the filesystem"
task :dump do
- run "cd #{latest_release} && #{php_bin} #{app_path}/console assetic:dump #{web_path} --env=#{symfony_env_prod}"
+ run "cd #{latest_release} && #{php_bin} #{app_path}/#{symfony_console} assetic:dump #{web_path} --env=#{symfony_env_prod}"
end
end
namespace :cache do
desc "Clears project cache."
task :clear do
- run "cd #{latest_release} && #{php_bin} #{app_path}/console cache:clear"
+ run "cd #{latest_release} && #{php_bin} #{app_path}/#{symfony_console} cache:clear --env=#{symfony_env_prod}"
+ run "chmod -R g+w #{latest_release}/#{app_path}/cache"
end
desc "Warms up an empty cache."
task :warmup do
- run "cd #{latest_release} && #{php_bin} #{app_path}/console cache:warmup"
+ run "cd #{latest_release} && #{php_bin} #{app_path}/#{symfony_console} cache:warmup --env=#{symfony_env_prod}"
+ run "chmod -R g+w #{latest_release}/#{app_path}/cache"
end
end
namespace :doctrine do
namespace :cache do
desc "Clear all metadata cache for a entity manager."
task :clear_metadata do
- run "cd #{latest_release} && #{php_bin} #{app_path}/console doctrine:cache:clear-metadata"
+ run "cd #{latest_release} && #{php_bin} #{app_path}/#{symfony_console} doctrine:cache:clear-metadata --env=#{symfony_env_prod}"
end
desc "Clear all query cache for a entity manager."
task :clear_query do
- run "cd #{latest_release} && #{php_bin} #{app_path}/console doctrine:cache:clear-query"
+ run "cd #{latest_release} && #{php_bin} #{app_path}/#{symfony_console} doctrine:cache:clear-query --env=#{symfony_env_prod}"
end
desc "Clear result cache for a entity manager."
task :clear_result do
- run "cd #{latest_release} && #{php_bin} #{app_path}/console doctrine:cache:clear-result"
+ run "cd #{latest_release} && #{php_bin} #{app_path}/#{symfony_console} doctrine:cache:clear-result --env=#{symfony_env_prod}"
end
end
namespace :database do
desc "Create the configured databases."
task :create do
- run "cd #{latest_release} && #{php_bin} #{app_path}/console doctrine:database:create"
+ run "cd #{latest_release} && #{php_bin} #{app_path}/#{symfony_console} doctrine:database:create --env=#{symfony_env_prod}"
end
desc "Drop the configured databases."
task :drop do
- run "cd #{latest_release} && #{php_bin} #{app_path}/console doctrine:database:drop"
+ run "cd #{latest_release} && #{php_bin} #{app_path}/#{symfony_console} doctrine:database:drop --env=#{symfony_env_prod}"
end
end
namespace :generate do
desc "Generates proxy classes for entity classes."
task :hydrators do
- run "cd #{latest_release} && #{php_bin} #{app_path}/console doctrine:generate:proxies"
+ run "cd #{latest_release} && #{php_bin} #{app_path}/#{symfony_console} doctrine:generate:proxies --env=#{symfony_env_prod}"
end
desc "Generate repository classes from your mapping information."
task :hydrators do
- run "cd #{latest_release} && #{php_bin} #{app_path}/console doctrine:generate:repositories"
+ run "cd #{latest_release} && #{php_bin} #{app_path}/#{symfony_console} doctrine:generate:repositories --env=#{symfony_env_prod}"
end
end
namespace :schema do
desc "Processes the schema and either create it directly on EntityManager Storage Connection or generate the SQL output."
task :create do
- run "cd #{latest_release} && #{php_bin} #{app_path}/console doctrine:schema:create"
+ run "cd #{latest_release} && #{php_bin} #{app_path}/#{symfony_console} doctrine:schema:create --env=#{symfony_env_prod}"
end
desc "Drop the complete database schema of EntityManager Storage Connection or generate the corresponding SQL output."
task :drop do
- run "cd #{latest_release} && #{php_bin} #{app_path}/console doctrine:schema:drop"
+ run "cd #{latest_release} && #{php_bin} #{app_path}/#{symfony_console} doctrine:schema:drop --env=#{symfony_env_prod}"
end
end
namespace :migrations do
desc "Execute a migration to a specified version or the latest available version."
task :migrate do
- run "cd #{latest_release} && #{php_bin} #{app_path}/console doctrine:migrations:migrate"
+ run "cd #{latest_release} && #{php_bin} #{app_path}/#{symfony_console} doctrine:migrations:migrate --env=#{symfony_env_prod}"
end
desc "View the status of a set of migrations."
task :status do
- run "cd #{latest_release} && #{php_bin} #{app_path}/console doctrine:migrations:status"
+ run "cd #{latest_release} && #{php_bin} #{app_path}/#{symfony_console} doctrine:migrations:status --env=#{symfony_env_prod}"
end
end
namespace :mongodb do
namespace :generate do
desc "Generates hydrator classes for document classes."
task :hydrators do
- run "cd #{latest_release} && #{php_bin} #{app_path}/console doctrine:mongodb:generate:hydrators"
+ run "cd #{latest_release} && #{php_bin} #{app_path}/#{symfony_console} doctrine:mongodb:generate:hydrators --env=#{symfony_env_prod}"
end
desc "Generates proxy classes for document classes."
task :hydrators do
- run "cd #{latest_release} && #{php_bin} #{app_path}/console doctrine:mongodb:generate:proxies"
+ run "cd #{latest_release} && #{php_bin} #{app_path}/#{symfony_console} doctrine:mongodb:generate:proxies --env=#{symfony_env_prod}"
end
desc "Generates repository classes for document classes."
task :hydrators do
- run "cd #{latest_release} && #{php_bin} #{app_path}/console doctrine:mongodb:generate:repositories"
+ run "cd #{latest_release} && #{php_bin} #{app_path}/#{symfony_console} doctrine:mongodb:generate:repositories --env=#{symfony_env_prod}"
end
end
namespace :schema do
desc "Allows you to create databases, collections and indexes for your documents."
task :create do
- run "cd #{latest_release} && #{php_bin} #{app_path}/console doctrine:mongodb:schema:create"
+ run "cd #{latest_release} && #{php_bin} #{app_path}/#{symfony_console} doctrine:mongodb:schema:create --env=#{symfony_env_prod}"
end
desc "Allows you to drop databases, collections and indexes for your documents."
task :drop do
- run "cd #{latest_release} && #{php_bin} #{app_path}/console doctrine:mongodb:schema:drop"
+ run "cd #{latest_release} && #{php_bin} #{app_path}/#{symfony_console} doctrine:mongodb:schema:drop --env=#{symfony_env_prod}"
end
end
end

0 comments on commit 8c040c5

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