-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
24 additions
and
21 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,39 @@ | ||
#!/usr/bin/env ruby | ||
require 'fileutils' | ||
include FileUtils | ||
require "fileutils" | ||
require "bundler" | ||
|
||
# path to your application root. | ||
APP_ROOT = File.expand_path('..', __dir__) | ||
APP_ROOT = File.expand_path("..", __dir__) | ||
|
||
def system!(*args) | ||
system(*args) || abort("\n== Command #{args} failed ==") | ||
system(*args, exception: true) | ||
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') | ||
def using_node? | ||
File.exist? "package.json" | ||
end | ||
|
||
# Install JavaScript dependencies if using Yarn | ||
# system('bin/yarn') | ||
FileUtils.chdir APP_ROOT do | ||
puts "== Installing dependencies ==" | ||
system! "gem install bundler --conservative" | ||
system("bundle check") || system!("bundle install") | ||
system("yarn install --check-files") if using_node? | ||
|
||
# puts "\n== Copying sample files ==" | ||
# unless File.exist?('config/database.yml') | ||
# cp 'config/database.yml.sample', 'config/database.yml' | ||
# end | ||
puts "\n== Preparing database and adding development seed data ==" | ||
if File.exist? "lib/tasks/dev.rake" | ||
system! "bin/rails dev:prime" | ||
else | ||
system! "bin/rails db:prepare" | ||
end | ||
|
||
puts "\n== Preparing database ==" | ||
system! 'bin/rails db:setup' | ||
if Bundler.rubygems.find_name("sprockets") | ||
puts "\n== Generating assets ==" | ||
system! "bin/rails assets:clobber assets:precompile" | ||
end | ||
|
||
puts "\n== Removing old logs and tempfiles ==" | ||
system! 'bin/rails log:clear tmp:clear' | ||
system! "bin/rails log:clear tmp:clear" | ||
|
||
puts "\n== Restarting application server ==" | ||
system! 'bin/rails restart' | ||
system! "bin/rails restart" | ||
end |