Last active
August 29, 2015 13:55
-
-
Save pyar6329/8760277 to your computer and use it in GitHub Desktop.
rails new shellscrpit (github => travis => heroku)
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
RED=$'\e[0;31;1m' | |
COLOR_OFF=$'\e[0m' | |
if [ ! "$#" = "1" ]; then | |
echo "$RED""please input app_name!""$COLOR_OFF" | |
else | |
mkdir "$1" | |
cd "$1" | |
touch Gemfile | |
echo 'source "http://rubygems.org"' >> Gemfile | |
echo 'gem "rails", "4.0.2"' >> Gemfile | |
bundle install --path .bundle | |
bundle exec rails new "$1" --skip-bundle | |
rm -rf Gemfile | |
rm -rf Gemfile.lock | |
rm -rf .bundle | |
rm -rf vendor | |
cd "$1" | |
sed -i -e "/sqlite3/d" Gemfile | |
echo "" >> Gemfile | |
echo "# Use sqlite3 as the database for Active Record" >> Gemfile | |
echo "group :development do" >> Gemfile | |
echo " gem 'sqlite3'" >> Gemfile | |
echo "end" >> Gemfile | |
echo "" >> Gemfile | |
echo "# Use Travis CI tests" >> Gemfile | |
echo "group :test do" >> Gemfile | |
echo " gem 'rake'" >> Gemfile | |
echo " gem 'rspec-rails'" >> Gemfile | |
echo "end" >> Gemfile | |
echo "" >> Gemfile | |
echo "# Use Heroku deploy" >> Gemfile | |
echo "group :production do" >> Gemfile | |
echo " gem 'rails_12factor'" >> Gemfile | |
echo " gem 'pg'" >> Gemfile | |
echo " gem 'newrelic_rpm'" >> Gemfile | |
echo "end" >> Gemfile | |
echo "" >> Gemfile | |
echo "# Use travis CI command" >> Gemfile | |
echo "gem 'travis'" >> Gemfile | |
bundle install --path .bundle --without test production | |
mv .* ../ | |
mv * ../ | |
cd .. | |
rm -rf "$1" | |
fi |
このシェルスクリプトはrailsのひな形を作成するものです。
実際には、github => travis => heroku(postgreSQL)経由で動くためのものです。
準備するもの
- bundler
- ruby 2.0.0以上
特徴
- 環境を汚さない
詳細
- OSには、「bundlerとrubyだけがインストールされている状態」のまま
- OSには、railsそのものは、インストールされない
- railsは、一度bundleでインストールされ、アプリを作成後削除される
- 作られたアプリの中では
bundle exec rails s
は使える - gemファイル群は railsアプリのディレクトリの中にインストールされる
実行方法
- 以下のコマンドを入力する
$ rails_heroku.sh "アプリケーション名"
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You must install bundler and ruby.
This shellscript is made rails application by clean environment.
You input below command if you want to use this shellscript.