Skip to content

Commit

Permalink
Merge 90c565a into 2d1d8a4
Browse files Browse the repository at this point in the history
  • Loading branch information
parndt committed Jan 27, 2015
2 parents 2d1d8a4 + 90c565a commit 08687c1
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 25 deletions.
63 changes: 56 additions & 7 deletions core/lib/generators/refinery/cms/cms_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class CmsGenerator < Rails::Generators::Base
:desc => "Allow Refinery to remove default Rails files in a fresh installation"
class_option :heroku, :type => :string, :default => nil, :group => :runtime, :banner => 'APP_NAME',
:desc => "Deploy to Heroku after the generator has run."
class_option :stack, :type => :string, :default => 'cedar', :group => :runtime,
class_option :stack, :type => :string, :default => 'cedar-14', :group => :runtime,
:desc => "Specify which Heroku stack you want to use. Requires --heroku option to function."
class_option :skip_db, :type => :boolean, :default => false, :aliases => nil, :group => :runtime,
:desc => "Skip over any database creation, migration or seeding."
Expand Down Expand Up @@ -75,20 +75,33 @@ def append_gitignore!
end

def append_heroku_gems!
append_file 'Gemfile', %q{
append_file 'Gemfile', %Q{
# The Ruby version is specified here so that Heroku uses the right version.
ruby #{ENV['RUBY_VERSION'].inspect}
# The Heroku gem allows you to interface with Heroku's API
gem 'heroku'
# Fog allows you to use S3 assets (added for Heroku)
gem 'fog'
group :production do
# Fog allows you to use S3 assets (added for Heroku)
gem 'dragonfly-s3_data_store'
# Gems that are recommended for using Heroku:
gem 'rails_12factor'
gem 'puma'
}
# If postgres is not the database in use, Heroku still needs it.
if destination_path.join('Gemfile').file? && destination_path.join('Gemfile').read !~ %r{gem ['"]pg['"]}
append_file 'Gemfile', %q{
# Postgres support (added for Heroku)
gem 'pg'
# Postgres support (added for Heroku)
gem 'pg'
}
end

append_file 'Gemfile', %q{
end
} # close the production group that was opened for dragonfly, and pg.
end

def bundle!
Expand All @@ -112,6 +125,37 @@ def create_decorators!
end
end

def create_heroku_procfile!
create_file "Procfile" do
"web: bundle exec puma -C config/puma.rb"
end unless destination_path.join('Procfile').file?

create_file "config/puma.rb" do
%{threads Integer(ENV['MIN_THREADS'] || 1), Integer(ENV['MAX_THREADS'] || 16)
workers Integer(ENV['PUMA_WORKERS'] || 3)
rackup DefaultRackup
port ENV['PORT'] || 3000
environment ENV['RACK_ENV'] || 'development'
preload_app!
on_worker_boot do
# worker specific setup
ActiveSupport.on_load(:active_record) do
ActiveRecord::Base.establish_connection
end
# If you are using Redis but not Resque, change this
if defined?(Resque)
Resque.redis = ENV["OPENREDIS_URL"] || "redis://127.0.0.1:6379"
Rails.logger.info('Connected to Redis')
end
end
}
end unless destination_path.join('config', 'puma.rb').file?
end

def deploy_to_hosting?
if heroku?
append_heroku_gems!
Expand All @@ -121,6 +165,8 @@ def deploy_to_hosting?
# Sanity check the heroku application name and save whatever messages are produced.
message = sanity_check_heroku_application_name!

create_heroku_procfile!

# Supply the deploy process with the previous messages to make them visible.
deploy_to_hosting_heroku!(message)
end
Expand All @@ -142,7 +188,10 @@ def deploy_to_hosting_heroku!(message = nil)
run "git push heroku master"

say_status "Setting up the Heroku database..", nil
run "heroku#{' run' if options[:stack] == 'cedar'} rake db:migrate"
run "heroku#{' run' if options[:stack] == 'cedar-14'} rake db:migrate"

say_status "Seeding the Heroku database..", nil
run "heroku#{' run' if options[:stack] == 'cedar-14'} rake db:seed"

say_status "Restarting servers...", nil
run "heroku restart"
Expand Down
1 change: 0 additions & 1 deletion images/refinerycms-images.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ Gem::Specification.new do |s|
s.test_files = `git ls-files -- spec/*`.split("\n")

s.add_dependency 'dragonfly', '~> 1.0.0'
s.add_dependency 'dragonfly-s3_data_store', '~> 1.0.0'
s.add_dependency 'refinerycms-core', version

s.required_ruby_version = Refinery::Version.required_ruby_version
Expand Down
1 change: 0 additions & 1 deletion resources/refinerycms-resources.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ Gem::Specification.new do |s|

s.add_dependency 'acts_as_indexed', '~> 0.8.0'
s.add_dependency 'dragonfly', '~> 1.0.0'
s.add_dependency 'dragonfly-s3_data_store', '~> 1.0.0'
s.add_dependency 'refinerycms-core', version

s.required_ruby_version = Refinery::Version.required_ruby_version
Expand Down
24 changes: 8 additions & 16 deletions templates/refinery/edge.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
require 'rbconfig'

# We want to ensure that you have an ExecJS runtime available!
begin
require 'execjs'
begin
::ExecJS::Runtimes.autodetect
rescue
gsub_file 'Gemfile', "# gem 'therubyracer'", "gem 'therubyracer'"
end
rescue LoadError
abort "ExecJS is not installed. Please re-start the installer after running:\ngem install execjs"
end
Expand All @@ -13,29 +16,18 @@

append_file 'Gemfile' do
"
gem 'refinerycms', git: 'https://github.com/refinery/refinerycms', branch: 'master'
gem 'refinerycms', git: 'https://github.com/refinery/refinerycms', branch: 'template_test'
gem 'quiet_assets', :group => :development
# Add support for refinerycms-acts-as-indexed
# Add support for searching inside Refinery's admin interface.
gem 'refinerycms-acts-as-indexed', ['~> 2.0', '>= 2.0.0']
# Add support for refinerycms-wymeditor
# Add support for Refinery's custom fork of the visual editor WYMeditor.
gem 'refinerycms-wymeditor', ['~> 1.0', '>= 1.0.6']
gem 'seo_meta', git: 'https://github.com/parndt/seo_meta', branch: 'master'
gem 'paper_trail', git: 'https://github.com/airblade/paper_trail', branch: 'master'
"
end

begin
require 'execjs'
::ExecJS::Runtimes.autodetect
rescue
gsub_file 'Gemfile', "# gem 'therubyracer'", "gem 'therubyracer'"
end

run 'bundle install'

rake 'db:create'
Expand Down

0 comments on commit 08687c1

Please sign in to comment.