annotate bin/setup @ 86:5bfc986200db

The caching becomes a bit confusing because of parameters
author nanaya <me@myconan.net>
date Mon, 27 Jun 2016 05:14:10 +0900
parents 257910c60eb3
children f67f3ad50270
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
42
97a6973e9d94 Reset default scripts.
edogawaconan <me@myconan.net>
parents:
diff changeset
1 #!/usr/bin/env ruby
44
541427960031 Fix rubocop compliance.
edogawaconan <me@myconan.net>
parents: 42
diff changeset
2 require "pathname"
72
257910c60eb3 Rails 5 \o/
nanaya <me@myconan.net>
parents: 44
diff changeset
3 require "fileutils"
257910c60eb3 Rails 5 \o/
nanaya <me@myconan.net>
parents: 44
diff changeset
4 include FileUtils
42
97a6973e9d94 Reset default scripts.
edogawaconan <me@myconan.net>
parents:
diff changeset
5
97a6973e9d94 Reset default scripts.
edogawaconan <me@myconan.net>
parents:
diff changeset
6 # path to your application root.
72
257910c60eb3 Rails 5 \o/
nanaya <me@myconan.net>
parents: 44
diff changeset
7 APP_ROOT = Pathname.new File.expand_path("../../", __FILE__)
42
97a6973e9d94 Reset default scripts.
edogawaconan <me@myconan.net>
parents:
diff changeset
8
72
257910c60eb3 Rails 5 \o/
nanaya <me@myconan.net>
parents: 44
diff changeset
9 def system!(*args)
257910c60eb3 Rails 5 \o/
nanaya <me@myconan.net>
parents: 44
diff changeset
10 system(*args) || abort("\n== Command #{args} failed ==")
257910c60eb3 Rails 5 \o/
nanaya <me@myconan.net>
parents: 44
diff changeset
11 end
257910c60eb3 Rails 5 \o/
nanaya <me@myconan.net>
parents: 44
diff changeset
12
257910c60eb3 Rails 5 \o/
nanaya <me@myconan.net>
parents: 44
diff changeset
13 chdir APP_ROOT do
42
97a6973e9d94 Reset default scripts.
edogawaconan <me@myconan.net>
parents:
diff changeset
14 # This script is a starting point to setup your application.
72
257910c60eb3 Rails 5 \o/
nanaya <me@myconan.net>
parents: 44
diff changeset
15 # Add necessary setup steps to this file.
42
97a6973e9d94 Reset default scripts.
edogawaconan <me@myconan.net>
parents:
diff changeset
16
97a6973e9d94 Reset default scripts.
edogawaconan <me@myconan.net>
parents:
diff changeset
17 puts "== Installing dependencies =="
72
257910c60eb3 Rails 5 \o/
nanaya <me@myconan.net>
parents: 44
diff changeset
18 system! "gem install bundler --conservative"
257910c60eb3 Rails 5 \o/
nanaya <me@myconan.net>
parents: 44
diff changeset
19 system("bundle check") || system!("bundle install")
42
97a6973e9d94 Reset default scripts.
edogawaconan <me@myconan.net>
parents:
diff changeset
20
97a6973e9d94 Reset default scripts.
edogawaconan <me@myconan.net>
parents:
diff changeset
21 # puts "\n== Copying sample files =="
72
257910c60eb3 Rails 5 \o/
nanaya <me@myconan.net>
parents: 44
diff changeset
22 # unless File.exist?('config/database.yml')
257910c60eb3 Rails 5 \o/
nanaya <me@myconan.net>
parents: 44
diff changeset
23 # cp 'config/database.yml.sample', 'config/database.yml'
42
97a6973e9d94 Reset default scripts.
edogawaconan <me@myconan.net>
parents:
diff changeset
24 # end
97a6973e9d94 Reset default scripts.
edogawaconan <me@myconan.net>
parents:
diff changeset
25
97a6973e9d94 Reset default scripts.
edogawaconan <me@myconan.net>
parents:
diff changeset
26 puts "\n== Preparing database =="
72
257910c60eb3 Rails 5 \o/
nanaya <me@myconan.net>
parents: 44
diff changeset
27 system! "bin/rails db:setup"
42
97a6973e9d94 Reset default scripts.
edogawaconan <me@myconan.net>
parents:
diff changeset
28
97a6973e9d94 Reset default scripts.
edogawaconan <me@myconan.net>
parents:
diff changeset
29 puts "\n== Removing old logs and tempfiles =="
72
257910c60eb3 Rails 5 \o/
nanaya <me@myconan.net>
parents: 44
diff changeset
30 system! "bin/rails log:clear tmp:clear"
42
97a6973e9d94 Reset default scripts.
edogawaconan <me@myconan.net>
parents:
diff changeset
31
97a6973e9d94 Reset default scripts.
edogawaconan <me@myconan.net>
parents:
diff changeset
32 puts "\n== Restarting application server =="
72
257910c60eb3 Rails 5 \o/
nanaya <me@myconan.net>
parents: 44
diff changeset
33 system! "bin/rails restart"
42
97a6973e9d94 Reset default scripts.
edogawaconan <me@myconan.net>
parents:
diff changeset
34 end