Permalink
Browse files

updated capifony binary to support both symfony1 and Symfony2

  • Loading branch information...
1 parent 08d895d commit e84475792eabded7af893203934da89fe9c3535d @everzet committed Mar 22, 2011
Showing with 47 additions and 12 deletions.
  1. +47 −12 bin/capifony
View
@@ -3,6 +3,8 @@
require 'optparse'
require 'fileutils'
+symfony_version_option = nil
+
OptionParser.new do |opts|
opts.banner = "Usage: #{File.basename($0)} [path]"
@@ -11,6 +13,10 @@ OptionParser.new do |opts|
exit 0
end
+ opts.on("-s", "--symfony VERSION", "Capify specific symfony verion (1|2)") do |version|
+ symfony_version_option = version.to_i
+ end
+
begin
opts.parse!(ARGV)
rescue OptionParser::ParseError => e
@@ -27,23 +33,28 @@ elsif !File.exists?(ARGV.first)
elsif !File.directory?(ARGV.first)
abort "`#{ARGV.first}' is not a directory."
elsif ARGV.length > 1
- abort "Too many arguments; please specify only the directory to capifony."
+ abort "Too many arguments; please specify only the directory to capify."
end
def unindent(string)
indentation = string[/\A\s*/]
string.strip.gsub(/^#{indentation}/, "")
end
-files = {
- "Capfile" => unindent(<<-FILE),
- load 'deploy' if respond_to?(:namespace) # cap2 differentiator
- Dir['plugins/*/lib/recipes/*.rb'].each { |plugin| load(plugin) }
- load Gem.required_location('capifony', 'capifony.rb')
- load 'config/deploy' # remove this line to skip loading any of the default tasks
- FILE
+base = ARGV.shift
+symfony_version = (File.directory? File.join(base, 'config')) ? 1 : 2
+symfony_version = symfony_version_option == nil ? symfony_version : symfony_version_option
+
+if symfony_version == 2
+ files = {
+ "Capfile" => unindent(<<-FILE),
+ load 'deploy' if respond_to?(:namespace) # cap2 differentiator
+ Dir['vendor/bundles/*/*/recipes/*.rb'].each { |bundle| load(bundle) }
+ load Gem.required_location('capifony', 'symfony2.rb')
+ load 'app/config/deploy'
+ FILE
- "config/deploy.rb" => 'set :application, "set your application name here"
+ "app/config/deploy.rb" => 'set :application, "set your application name here"
set :domain, "#{application}.com"
set :deploy_to, "/var/www/#{domain}"
@@ -55,9 +66,33 @@ role :web, domain # Your HTTP server, Apache/etc
role :app, domain # This may be the same as your `Web` server
role :db, domain, :primary => true # This is where Rails migrations will run
-set :keep_releases, 3'}
+set :keep_releases, 3'
+ }
+else
+ files = {
+ "Capfile" => unindent(<<-FILE),
+ load 'deploy' if respond_to?(:namespace) # cap2 differentiator
+ Dir['plugins/*/lib/recipes/*.rb'].each { |plugin| load(plugin) }
+ load Gem.required_location('capifony', 'symfony1.rb')
+ load 'config/deploy'
+ FILE
+
+ "config/deploy.rb" => 'set :application, "set your application name here"
+set :domain, "#{application}.com"
+set :deploy_to, "/var/www/#{domain}"
+
+set :repository, "#{domain}:/var/repos/#{application}.git"
+set :scm, :git
+# Or: `accurev`, `bzr`, `cvs`, `darcs`, `subversion`, `mercurial`, `perforce`, `subversion` or `none`
+
+role :web, domain # Your HTTP server, Apache/etc
+role :app, domain # This may be the same as your `Web` server
+role :db, domain, :primary => true # This is where Rails migrations will run
+
+set :keep_releases, 3'
+ }
+end
-base = ARGV.shift
files.each do |file, content|
file = File.join(base, file)
if File.exists?(file)
@@ -74,4 +109,4 @@ files.each do |file, content|
end
end
-puts "[done] capifonied!"
+puts "[done] Symfony#{symfony_version.to_s} project capifonied!"

0 comments on commit e844757

Please sign in to comment.