This repository has been archived by the owner on Dec 2, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
setup.sh
executable file
·61 lines (49 loc) · 1.61 KB
/
setup.sh
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
#!/bin/bash -e
export LC_CTYPE=C
export LANG=C
# TODO: can add OS check so scripts work on linux as well
echo "presently the script only supports mac"
parent_dir_full=$(dirname "$PWD")
parent_dir=${parent_dir_full##*/}
curr_dir=${PWD##*/}
echo "current directory name: $curr_dir"
echo "parent directory name: $parent_dir"
if [ -z "$curr_dir" ]; then
echo "should set current directory as first parameter"
echo "eg: $./setup.sh <current_folder_name>"
exit 1
fi
## GOLANG
echo "checking go version..."
if command -v "go" &>/dev/null; then
go version
else
echo "go is not installed. please install go."
fi
## NPM
if command -v "npm" &>/dev/null; then
echo "npm already installed. skipping..."
else
echo "installing npm"
brew install npm || true
fi
echo "installing dependencies from package.json"
npm install
# replace import "github.com/niranjan92/go-hackathon-starter" with import "github.com/<your_username>/<project_dir_name>"
find . -type f -name "*.go" | xargs sed -i .backup "s/niranjan92\/go_hackathon_starter/$parent_dir\/$curr_dir/g"
find . -type f -name "*.backup" -delete
echo "checking dep"
if command -v "dep" &>/dev/null; then
echo "dep already installed. skipping..."
else
echo "installing dep"
go get -u github.com/golang/dep
export PATH=$PATH:~/go/bin
fi
dep ensure
echo "creating db. Please check that database.yml is configured correctly. Press y to continue"
#TODO: add while loop based on user's input
buffalo db create -a || true # ignore errors here
# run migrations
buffalo db migrate
echo "finished setting up project, you can run 'buffalo dev' to start the project"