JordanHatch/maslow-redux

View on GitHub
bin/setup

Summary

Maintainability
Test Coverage
#!/usr/bin/env ruby
require 'pathname'
require 'io/console'

APP_ROOT = Pathname.new File.expand_path('../../',  __FILE__)

Dir.chdir APP_ROOT do
  puts "== Setting up Maslow =="

  puts "\n== Installing dependencies =="
  system "gem install bundler --conservative"
  system "bundle check || bundle install"

  require 'bundler/setup'
  require 'colorize'

  puts "\n== Preparing database =="
  system "bin/rake db:setup"

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

  puts "\n== Creating the first user =="

  print "\nName: "
  name = gets.chomp
  print "Email: "
  email = gets.chomp
  print "Password [min 8 chars, typing hidden]: "
  password = $stdin.noecho(&:gets).chomp

  puts "\n\nProcessing..."
  system "bin/rake users:create_first_user[\"#{name}\",\"#{email}\",\"#{password}\"]"

  puts "\n== Setup complete =="

  puts "\nRun `foreman start` to start the Maslow server.".colorize(:green)
end