-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfun.sh
121 lines (98 loc) · 2.68 KB
/
fun.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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
#!/usr/bin/bash
# tree -L 2 # my tree
# .
# ├── fun
# │ ├── db.sqlite3
# │ ├── eduhub
# │ ├── fun
# │ ├── funauth
# │ ├── fundeveloper
# │ ├── funfile
# │ ├── funhome
# │ ├── funlog
# │ ├── funmiddleware
# │ ├── funuser
# │ ├── locale
# │ └── manage.py
# ├── fun.sh
# ├── LICENSE
# ├── README.md
# ├── requirements
# │ ├── dev.txt
# │ └── produc.txt
# ├── setup.py
# └── venv
# ├── bin
# ├── lib
# └── pyvenv.cfg
#
_args=("$@") # all parameters from terminal.
activate_source(){
if [[ -x "$(which virtualenv)" ]]; then
[[ -f "./venv/bin/activate" ]] || virtualenv venv
source ./venv/bin/activate
else
echo "virtualenv doesn't exist, please install it" && exit
fi
}
p8(){
activate_source
isort -v ./fun/
autopep8 -i -a -a -r -v ./fun/
}
pi(){
activate_source
pip3 install $( cat requirements/*.txt | grep -v "#" )
}
init(){
activate_source; pi;
[[ -x "$(which yarn)" ]] && cd ./fun/funhome/static && \
yarn install && cd ../../..
[[ -d "./fun/funlog" ]] || mkdir ./fun/funlog
[[ -f "./fun/funlog/django_fun.log" ]] || touch ./fun/funlog/django_fun.log
[[ -d "./funfile/files" ]] || mkdir -p ./fun/funfile/files
[[ -f "./fun/fun/settings.py" ]] || \
cp ./fun/fun/settings_.py ./fun/fun/settings.py
python3 ./fun/manage.py makemigrations
python3 ./fun/manage.py migrate
python3 ./fun/manage.py compilemessages
read -p "Create superuser?(y/N)" _createsuperuser
[[ "Yy" == *"${_createsuperuser}"* ]] && \
python3 ./fun/manage.py createsuperuser
python3 ./fun/manage.py runserver
echo "Done."
}
update_gitignore(){
git rm -r --cached . && git add .
read -p "commit now?(y/N)" commit_now
[[ "Yy" == *"$commit_now"* ]] && git commit -m 'update .gitignore'
echo "gitignore updated!"
}
_msgfmt(){
for _po in $(find ./fun/locale -name "*.po"); do
echo -e "$_po ${_po/.po/.mo}"
msgfmt -v -o ${_po/.po/.mo} $_po
done
}
_start(){
activate_source
cd ./fun
cd ./funstatic/static
if [[ -x "$(which yarn)" ]]; then
yarn
cd ../..
else
echo "yarn doesn't exist, please install it"
cd ../../..
exit
fi
python3 ./manage.py migrate
python3 ./manage.py runserver
cd ..
}
ug(){ update_gitignore; }
_s(){ _start; }
gita(){ p8; git add . ; }
as(){ activate_source; }
_msg(){ _msgfmt; }
${_args[0]}