Created
February 20, 2017 15:27
-
-
Save etagwerker/312f3421e000defa8eb4e315e65f2b37 to your computer and use it in GitHub Desktop.
bin-setup
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
#!/usr/bin/env ruby | |
require 'pathname' | |
require 'fileutils' | |
include FileUtils | |
# path to your application root. | |
APP_ROOT = Pathname.new File.expand_path('../../', __FILE__) | |
def system!(*args) | |
system(*args) || abort("\n== Command #{args} failed ==") | |
end | |
chdir APP_ROOT do | |
# This script is a starting point to setup your application. | |
# Add necessary setup steps to this file. | |
puts '== Installing dependencies ==' | |
system! 'gem install bundler --conservative' | |
system('bundle check') || system!('bundle install') | |
puts "\n== Copying sample files ==" | |
unless File.exist?('config/database.yml') | |
cp 'config/database.example.yml', 'config/database.yml' | |
end | |
unless File.exist?('.env') | |
cp '.env.example', '.env' | |
end | |
puts "\n== Preparing database ==" | |
system! 'bin/rails db:setup' | |
puts "\n== Removing old logs and tempfiles ==" | |
system! 'bin/rails log:clear tmp:clear' | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment