templates/bin_setup in welaika-suspenders-2.29.0.alpha.1 vs templates/bin_setup in welaika-suspenders-2.29.0.alpha.2

- old
+ new

@@ -1,24 +1,34 @@ -#!/bin/sh +#!/usr/bin/env ruby +require 'fileutils' +include FileUtils -# Set up Rails app. Run this script immediately after cloning the codebase. +APP_ROOT = File.expand_path('..', __dir__) -# Exit if any subcommand fails -set -e +def system!(*args) + system(*args) || abort("\n== Command #{args} failed ==") +end -# Set up Ruby dependencies via Bundler -gem install bundler --conservative -bundle check || bundle install +chdir APP_ROOT do + puts '== Installing dependencies ==' + system! 'gem install bundler --conservative' + system('bundle check') || system!('bundle install') -# Set up database and add any development seed data -bin/rails dev:prime + system('bin/yarn') -if [ ! -d .git/safe ] && echo $PATH | grep .git/safe > /dev/null; then - echo "-----------------------------------------------------------------------" - echo - echo "-> When you trust this repo, remember to run: mkdir -p .git/safe" - echo -fi + puts "\n== Copying sample files ==" + unless File.exist?('.env.local') + cp '.env', '.env.local' + end -# Only if this isn't CI -# if [ -z "$CI" ]; then -# fi + puts "\n== Preparing database and seeds ==" + system! 'bin/rake dev:prime' + + puts "\n== Removing old logs and tempfiles ==" + system! 'bin/rails log:clear tmp:clear' + + puts "\n== Restarting application server ==" + system! 'bin/rails restart' + + puts "\n== Activating overcommit ==" + system! 'bin/overcommit --install' +end