forked from tgaeta/job_tracker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup
More file actions
executable file
·69 lines (56 loc) · 1.91 KB
/
setup
File metadata and controls
executable file
·69 lines (56 loc) · 1.91 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#!/usr/bin/env ruby
require "bundler/inline"
require "fileutils"
begin
Gem::Specification.find_by_name("colorize")
rescue LoadError
puts "Installing colorize gem"
system("gem install colorize")
end
require "colorize"
# path to your application root.
APP_ROOT = File.expand_path("..", __dir__)
# Execute a shell command and raise an error if it fails.
def system!(*args)
system(*args) || abort("\n== Command #{args} failed ==")
end
# Check if a command exists
def command?(name)
[name, *ENV["PATH"].split(File::PATH_SEPARATOR).map { |p| File.join(p, name) }].find { |f| File.executable?(f) }
end
FileUtils.chdir APP_ROOT do
# This script is a way to set up or update your development environment automatically.
# This script is idempotent, so that you can run it at any time and get an expectable outcome.
# Add necessary setup steps to this file.
puts "\n== Installing gems =="
system! "gem install bundler --conservative"
system("bundle check") || system!("bundle install")
puts "Gems installed".green
puts "\n== Installing packages using bun=="
if command?("bun")
system!("bun install")
else
puts "bun not found, visit https://bun.sh/docs/installation to install bun".red
end
puts "\n== Preparing database =="
if File.exist?("config/database.yml")
system! "bin/rails db:prepare"
puts "Database setup complete".green
else
puts "config/database.yml not found".red
exit 1
end
if !Dir.exist?("tmp/pids")
puts "\n== Creating tmp/pids directory =="
system!("bin/rails tmp:create")
puts "tmp/pids directory created".green
end
puts "\n== Removing old logs and tempfiles =="
system! "bin/rails log:clear tmp:clear"
puts "Old logs and tempfiles removed".green
puts ""
puts "You're set!! 🎉🎉🎉".green
puts ""
puts " #{"bin/dev".yellow} to start the server, then visit http://localhost:3000"
puts " #{"bin/rails test:all".yellow} to run tests"
end