Skip to content

Instantly share code, notes, and snippets.

@yurikoval
Last active April 22, 2023 15:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yurikoval/797d8d6486271d67582cf29c620fa2e8 to your computer and use it in GitHub Desktop.
Save yurikoval/797d8d6486271d67582cf29c620fa2e8 to your computer and use it in GitHub Desktop.
Simple script to jumpstart a new Rails app with your favourite gems
#!/bin/bash
# This script accepts one argument, which is the name of the your new project
if [ "$#" -ne 1 ]; then
echo "Usage: $0 generate new rails app"
exit 1
fi
app=$1
echo "Creating new app: $app"
rails new "$app" --skip-jbuilder --database=postgresql --css=tailwind --skip-test
cd "$app"
gems=("pundit" "kaminari" "redis-rails" "connection_pool" "sidekiq" "simple_form" "devise" "omniauth-rails_csrf_protection")
dev_gems=("standard" "binding_of_caller" "better_errors" "web-console")
test_dev_gems=("capybara" "webdrivers" "i18n-tasks" "rspec-rails" "rspec-its" "factory_bot_rails" "vcr" "webmock")
test_gems=("shoulda-matchers" "rspec-sidekiq")
for gem in "${gems[@]}"; do
echo "Adding $gem to the bundle..."
bundler add "$gem" --optimistic --skip-install
done
for gem in "${dev_gems[@]}"; do
echo "Adding $gem to the bundle..."
bundler add "$gem" -g development --optimistic --skip-install
done
for gem in "${test_dev_gems[@]}"; do
echo "Adding $gem to the bundle..."
bundler add "$gem" -g "test, development" --optimistic --skip-install
done
for gem in "${test_gems[@]}"; do
echo "Adding $gem to the bundle..."
bundler add "$gem" -g test --optimistic --skip-install
done
bundle install
bundle exec rails generate simple_form:install
bundle exec rails generate devise:install
bundle exec rails generate rspec:install
bundle exec rails db:setup
bundle exec rails db:migrate
bundle exec i18n-tasks normalize
bundle exec standardrb --fix-unsafely
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment