-
Notifications
You must be signed in to change notification settings - Fork 205
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
To configure your Ember CLI Rails app to be ready to deploy on Heroku: 1. Run `rails g ember-cli:heroku` generator 1. [Add the NodeJS buildpack][buildpack] and configure NPM to include the `bower` dependency's executable file. ```sh heroku buildpacks:add --index 1 https://github.com/heroku/heroku-buildpack-nodejs heroku config:set NPM_CONFIG_PRODUCTION=false ``` [buildpack]: https://devcenter.heroku.com/articles/using-multiple-buildpacks-for-an-app#adding-a-buildpack
- Loading branch information
1 parent
2dda73a
commit 89bf511
Showing
9 changed files
with
98 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
Description: | ||
Generates files necessary to deploy the project to Heroku | ||
|
||
Example: | ||
rails generate ember-cli:heroku | ||
|
||
This will create: | ||
.buildpacks | ||
package.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
module EmberCLI | ||
class HerokuGenerator < Rails::Generators::Base | ||
source_root File.expand_path("../templates", __FILE__) | ||
|
||
namespace "ember-cli:heroku" | ||
|
||
def copy_package_json_file | ||
template "package.json.erb", "package.json" | ||
end | ||
|
||
def copy_setup_heroku_file | ||
template "bin_heroku_install.erb", "bin/heroku_install" | ||
run "chmod a+x bin/heroku_install" | ||
end | ||
|
||
def inject_12factor_gem | ||
gem "rails_12factor", group: [:staging, :production] | ||
end | ||
|
||
def app_paths | ||
EmberCLI.apps.values.map do |app| | ||
app.root.relative_path_from(Rails.root) | ||
end | ||
end | ||
end | ||
end |
13 changes: 13 additions & 0 deletions
13
lib/generators/ember-cli/heroku/templates/bin_heroku_install.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#!/usr/bin/env sh | ||
|
||
set -e | ||
|
||
bower="$(pwd)/node_modules/.bin/bower" | ||
|
||
for app in <%= app_paths.map { |app_path| %{"#{app_path}"} }.join(" ") -%>; do | ||
cd $app && | ||
npm prune && | ||
npm install && | ||
$bower prune && | ||
$bower install | ||
done |
15 changes: 15 additions & 0 deletions
15
lib/generators/ember-cli/heroku/templates/package.json.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"scripts": { | ||
"postinstall": "./bin/heroku_install" | ||
}, | ||
"devDependencies": { | ||
"bower": "*" | ||
}, | ||
"cacheDirectories": [ | ||
<%- app_paths.each do |app_path| -%> | ||
"<%= app_path %>/node_modules", | ||
"<%= app_path %>/bower_components", | ||
<%- end -%> | ||
"node_modules" | ||
] | ||
} |