Skip to content

Commit

Permalink
Merge branch 'add-generators' of https://github.com/shakacode/react_o…
Browse files Browse the repository at this point in the history
…n_rails into add-generators
  • Loading branch information
jbhatab committed Nov 1, 2015
2 parents 66b7408 + a245ad0 commit 7a7dd68
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 0 deletions.
21 changes: 21 additions & 0 deletions lib/generators/react_on_rails/heroku_deployment_generator.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
require "rails/generators"
require File.expand_path("../generator_helper", __FILE__)
include GeneratorHelper

module ReactOnRails
module Generators
class HerokuDeploymentGenerator < Rails::Generators::Base
hide!
source_root(File.expand_path("../templates", __FILE__))

def copy_heroku_deployment_files
base_path = "heroku_deployment"
%w(.buildpacks Procfile).each { |file| copy_file("#{base_path}/#{file}", file) }
end

def add_heroku_production_gems
gem("rails_12factor", group: :production)
end
end
end
end
1 change: 1 addition & 0 deletions lib/generators/react_on_rails/install_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ def run_generators
invoke "react_on_rails:react_with_redux" if options.redux?
invoke "react_on_rails:linters" unless options.skip_linters?
invoke "react_on_rails:bootstrap"
invoke "react_on_rails:heroku_deployment"
end

private
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
https://github.com/heroku/heroku-buildpack-nodejs.git
https://github.com/heroku/heroku-buildpack-ruby.git
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
web: bundle exec unicorn -p $PORT -c ./config/unicorn.rb
7 changes: 7 additions & 0 deletions spec/react_on_rails/generators/install_generator_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
include_examples "no_redux_generator:no_server_rendering"
include_examples ":linters"
include_examples "bootstrap"
include_examples "heroku_deployment"
end

context "--server-rendering" do
Expand All @@ -21,6 +22,7 @@
include_examples "no_redux_generator:server_rendering"
include_examples ":linters"
include_examples "bootstrap"
include_examples "heroku_deployment"
end

context "-S" do
Expand All @@ -31,6 +33,7 @@
include_examples "no_redux_generator:server_rendering"
include_examples ":linters"
include_examples "bootstrap"
include_examples "heroku_deployment"
end

context "--redux" do
Expand All @@ -40,6 +43,7 @@
include_examples "react_with_redux_generator:base"
include_examples ":linters"
include_examples "bootstrap"
include_examples "heroku_deployment"
end

context "-d" do
Expand All @@ -49,6 +53,7 @@
include_examples "react_with_redux_generator:base"
include_examples ":linters"
include_examples "bootstrap"
include_examples "heroku_deployment"
end

context "--redux --server_rendering" do
Expand All @@ -59,6 +64,7 @@
include_examples "react_with_redux_generator:server_rendering"
include_examples ":linters"
include_examples "bootstrap"
include_examples "heroku_deployment"
end

context "-d -S" do
Expand All @@ -69,5 +75,6 @@
include_examples "react_with_redux_generator:server_rendering"
include_examples ":linters"
include_examples "bootstrap"
include_examples "heroku_deployment"
end
end
6 changes: 6 additions & 0 deletions spec/react_on_rails/support/generator_spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ def run_generator_test_with_args(args)
DATA
simulate_existing_file("app/assets/javascripts/application.js", app_js_data)
simulate_existing_file("app/assets/stylesheets/application.css", " *= require_tree .\n *= require_self\n")
db_yml_data = <<-DATA
production:
<<: *default
database: db/production.sqlite3
DATA
simulate_existing_file("config/database.yml", db_yml_data)
run_generator(args)
end

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
shared_examples "heroku_deployment" do
it "should add heroku deployment files" do
assert_file("Procfile")
assert_file(".buildpacks")
end

it "should add heroku production gems" do
assert_file("Gemfile") do |contents|
assert_match("gem 'rails_12factor', group: :production", contents)
end
end
end

0 comments on commit 7a7dd68

Please sign in to comment.