18F/identity-dashboard

View on GitHub
bin/setup

Summary

Maintainability
Test Coverage
#!/usr/bin/env ruby

# Set up Rails app. Run this script immediately after cloning the codebase.
# https://github.com/thoughtbot/guides/tree/master/protocol

require 'pathname'
require 'yaml'

# path to your application root.
APP_ROOT = Pathname.new File.expand_path('../../',  __FILE__)

def run(command)
  # puts "command: #{command}"
  abort "command failed (#{$?}): #{command}" unless system command
end

Dir.chdir APP_ROOT do
  # This script is a starting point to setup your application.
  # Add necessary setup steps to this file:

  puts %q{

            ______             _____
            ___  /____________ ___(_)______   _______ _________   __
            __  /_  __ \_  __ `/_  /__  __ \  __  __ `/  __ \_ | / /
            _  / / /_/ /  /_/ /_  / _  / / /___  /_/ // /_/ /_ |/ /
            /_/  \____/_\__, / /_/  /_/ /_/_(_)\__, / \____/_____/
                       /____/                 /____/
        ________              ______ ______                     _________
        ___  __ \_____ __________  /____  /_____________ _____________  /
        __  / / /  __ `/_  ___/_  __ \_  __ \  __ \  __ `/_  ___/  __  /
        _  /_/ // /_/ /_(__  )_  / / /  /_/ / /_/ / /_/ /_  /   / /_/ /
        /_____/ \__,_/ /____/ /_/ /_//_.___/\____/\__,_/ /_/    \__,_/


  }

  puts '== Setting up config overrides =='
  default_application_yml = { 'development' => { 'config_key' => nil } }
  File.write('config/application.yml', default_application_yml.to_yaml) unless File.exist?('config/application.yml')

  puts "\n== Installing dependencies =="
  run 'gem install bundler --conservative'
  run 'gem install foreman --conservative && gem update foreman'
  run 'bundle check || bundle install --without deploy production'
  run 'yarn install'

  puts "\n== Preparing database =="
  run 'bin/rake db:create'
  run 'bin/rake db:environment:set'
  run 'bin/rake dev:prime'

  puts "\n== Removing old logs and tempfiles =="
  run 'rm -f log/*'
  run 'rm -rf tmp/cache'

  puts "\n== Add binstubs to PATH via export PATH=\".git/safe/../../bin:$PATH\" in ~/.zshenv =="
  run 'mkdir -p .git/safe'
end