-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.sh
executable file
·58 lines (46 loc) · 1.45 KB
/
install.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
#!/bin/bash
# 1. Retrieve variables
echo -n "What is the name of a project? "
read PROJECT_NAME
echo -n "What is the name of a project in snake_case? "
read PROJECT_NAME_SNAKE
MODULE_NAME=$(echo $PROJECT_NAME_SNAKE | sed -r "s~(^|_)(.)~\U\2~g")
echo -n "What is the ip address of develop server? "
read DEVELOP_ADDRESS
echo -n "What is the address of project git repository? "
read REPO_URL
# 2. Rename project directory
cd ..
mv project_prototype "$PROJECT_NAME_SNAKE"
cd "$PROJECT_NAME_SNAKE"
# 3. Replace project-dependant information with new variables
CURRENT_PATH="$( pwd )"
DPATH="$CURRENT_PATH/*.rb"
find "$CURRENT_PATH" -type f -name '*rb' -or -name '*.haml' | while read f;
do
if [ -f $f -a -r $f ]; then
sed -i "s/Project_Prototype/$PROJECT_NAME/g" "$f"
sed -i "s/project_prototype/$PROJECT_NAME_SNAKE/g" "$f"
sed -i "s/ProjectPrototype/$MODULE_NAME/g" "$f"
sed -i "s/develop_server_address/$DEVELOP_ADDRESS/g" "$f"
sed -i "s/project_repo/$REPO_URL/g" "$f"
else
echo "Error: Cannot read $f"
fi
done
# 4. Install necessary ruby version, create gemset
source "$HOME/.rvm/scripts/rvm"
rvm install 2.3.1
rvm use 2.3.1
rvm gemset create "$PROJECT_NAME_SNAKE"
rvm gemset use "$PROJECT_NAME_SNAKE"
gem install bundler
bundle install
# 5. Add version control
rm -rf .git
git init
git add --all
git commit -m 'Initial commit - project initialized from project_prototype'
git remote add origin "$REPO_URL"
# 6. Generate documentation
rails swagger:docs