-
Notifications
You must be signed in to change notification settings - Fork 1
/
make.bat
executable file
·96 lines (90 loc) · 2.11 KB
/
make.bat
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
@ECHO OFF
REM Setting all the environent variables for smoother experience
SET PYTHON_EXE=python
SET MANAGE=.\Scripts\python manage.py
SET ENV_FILE=.env
SET DJANGO_PORT=8000
IF [%1]==[] (
ECHO Please specify the function to execute
EXIT
)
IF "%1"=="virtualenv" (
CALL :virtualenv
)
IF "%1"=="genkey" (
CALL :genkey
)
IF "%1"=="install" (
CALL :install
)
IF "%1"=="dev" (
CALL :dev
)
IF "%1"=="project" (
CALL :dev
IF [%2]==[] (
ECHO Please specify a project name
EXIT
)
django-admin startproject --template=.\etc\structure %2 .
ECHO Clearing Redundant Files
rmdir etc/structure
)
IF "%1"=="migrate" (
ECHO - Migrating Database
%MANAGE% makemigrations
%MANAGE% migrate
)
IF "%1"=="run" (
ECHO - Starting Django Server
%MANAGE% runserver %DJANGO_PORT%
)
IF "%1"== "flush" (
ECHO - Flushing Database
%MANAGE% flush
)
IF "%1"=="format" (
ECHO - Run isort imports ordering validation
.\Scripts\isort --profile black --gitignore .
ECHO - Run black validation
.\Scripts\black .
)
IF "%1"=="test" (
ECHO - Running Unit Tests
%MANAGE% test
)
IF "%1"=="check" (
ECHO - Running Unit Tests
%MANAGE% test
ECHO - Running black validation
.\Scripts\black --check .
)
EXIT /B 0
:: ----------------------------------------------------------
:: Functions
:: ----------------------------------------------------------
:virtualenv
ECHO - Making Virtual Environment
%PYTHON_EXE% -m venv .
EXIT /B 0
:genkey
IF NOT EXIST .env (
ECHO - Generating Secret key
.\Scripts\%PYTHON_EXE% -c "from django.core.management.utils import get_random_secret_key;key = get_random_secret_key();print(f'SECRET_KEY={key}\nDEVELOPMENT=True')" -> .env
) ELSE (
ECHO .env file already exists
)
TYPE etc/env.txt >> .env
EXIT /B 0
:install
CALL :virtualenv
ECHO - Installing Dependencies
.\Scripts\%PYTHON_EXE% -m pip install -r etc/base.txt
CALL :genkey
EXIT /B 0
:dev
CALL :virtualenv
ECHO - Installing Dependencies
.\Scripts\%PYTHON_EXE% -m pip install -r etc/dev.txt
CALL :genkey
EXIT /B 0