Commit b84216e4c96fc245233a02656fb85ce704bf8ef5
1 parent
07e97318
Exists in
master
and in
1 other branch
tweaking script/create_project and heroku:setup rake tasks
Showing
2 changed files
with
20 additions
and
17 deletions
Show diff stats
lib/tasks/heroku.rake
| 1 | +require 'rake' | ||
| 2 | + | ||
| 1 | namespace :heroku do | 3 | namespace :heroku do |
| 2 | def ask_yn(q) | 4 | def ask_yn(q) |
| 3 | print "#{q} (y/n) " | 5 | print "#{q} (y/n) " |
| @@ -6,7 +8,7 @@ namespace :heroku do | @@ -6,7 +8,7 @@ namespace :heroku do | ||
| 6 | 8 | ||
| 7 | def ask_value(q) | 9 | def ask_value(q) |
| 8 | print " #{q}: " | 10 | print " #{q}: " |
| 9 | - STDIN.gets.strip.downcase | 11 | + STDIN.gets.strip |
| 10 | end | 12 | end |
| 11 | 13 | ||
| 12 | desc "Prompt for all the config vars and set them on the Heroku app" | 14 | desc "Prompt for all the config vars and set them on the Heroku app" |
| @@ -34,7 +36,7 @@ namespace :heroku do | @@ -34,7 +36,7 @@ namespace :heroku do | ||
| 34 | 36 | ||
| 35 | puts "Setting all config vars on Heroku app" | 37 | puts "Setting all config vars on Heroku app" |
| 36 | vars_string = vars.map { |k,v| "#{k}='#{v}'" }.join(' ') | 38 | vars_string = vars.map { |k,v| "#{k}='#{v}'" }.join(' ') |
| 37 | - sh "heroku config:add #{vars_string}" | 39 | + `heroku config:add #{vars_string}` |
| 38 | end | 40 | end |
| 39 | 41 | ||
| 40 | desc "Create a new app" | 42 | desc "Create a new app" |
| @@ -43,7 +45,7 @@ namespace :heroku do | @@ -43,7 +45,7 @@ namespace :heroku do | ||
| 43 | unless $?.success? | 45 | unless $?.success? |
| 44 | puts "It doesn't look like this is a Heroku app (no git remote)." | 46 | puts "It doesn't look like this is a Heroku app (no git remote)." |
| 45 | exit 1 unless ask_yn("Would you like to create a Heroku app now?") | 47 | exit 1 unless ask_yn("Would you like to create a Heroku app now?") |
| 46 | - sh "heroku create" | 48 | + `heroku create` |
| 47 | end | 49 | end |
| 48 | end | 50 | end |
| 49 | 51 |
script/create_project
| 1 | #!/usr/bin/env ruby | 1 | #!/usr/bin/env ruby |
| 2 | require File.dirname(__FILE__) + '/../config/boot' | 2 | require File.dirname(__FILE__) + '/../config/boot' |
| 3 | +require File.join(File.dirname(__FILE__), "..", "lib", "tasks", "heroku.rake") | ||
| 3 | require 'rubygems' | 4 | require 'rubygems' |
| 4 | require 'activesupport' | 5 | require 'activesupport' |
| 5 | require 'pathname' | 6 | require 'pathname' |
| @@ -52,22 +53,22 @@ Dir.glob("#{project_directory}/**/session_store.rb").each do |file| | @@ -52,22 +53,22 @@ Dir.glob("#{project_directory}/**/session_store.rb").each do |file| | ||
| 52 | search_and_replace(file, changesession, Digest::MD5.hexdigest("#{project_name} #{datestring}")) | 53 | search_and_replace(file, changesession, Digest::MD5.hexdigest("#{project_name} #{datestring}")) |
| 53 | end | 54 | end |
| 54 | 55 | ||
| 55 | -run("git commit -a -m 'Initial commit'") | ||
| 56 | -run("rake db:migrate") | 56 | +run("git commit -a -m 'New Heroku Suspenders app'") |
| 57 | + | ||
| 58 | +run "rake heroku:setup" | ||
| 59 | + | ||
| 60 | +puts "Deploying..." | ||
| 61 | +run "git push heroku master" | ||
| 62 | +run "heroku rake db:migrate" | ||
| 63 | + | ||
| 64 | +puts "Opening app..." | ||
| 65 | +run "heroku open" | ||
| 66 | + | ||
| 67 | +run("rake db:migrate RAILS_ENV=development") | ||
| 57 | run("rake db:migrate RAILS_ENV=test") | 68 | run("rake db:migrate RAILS_ENV=test") |
| 58 | run("rake db:migrate RAILS_ENV=cucumber") | 69 | run("rake db:migrate RAILS_ENV=cucumber") |
| 59 | run("rake") | 70 | run("rake") |
| 60 | 71 | ||
| 61 | -puts | ||
| 62 | -puts "If you want email, edit config/initializers/mail.rb" | ||
| 63 | -puts "If you want error notifications, edit config/initializers/hoptoad.rb" | ||
| 64 | -puts "If you want file uploads, edit config/s3.yml" | ||
| 65 | -puts | ||
| 66 | -puts "When you're ready to deploy, run these commands:" | ||
| 67 | -puts | ||
| 68 | -puts "heroku create (or heroku create #{project_name})" | ||
| 69 | -puts "git push heroku master" | ||
| 70 | -puts "heroku rake db:migrate" | ||
| 71 | -puts "heroku open" | ||
| 72 | - | 72 | +puts "Rename your app at any time with:" |
| 73 | +puts "heroku rename newname" | ||
| 73 | 74 |