-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathbuild_and_run_project.py
49 lines (32 loc) · 1.13 KB
/
build_and_run_project.py
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
"""
King of Tokyo game script
This file performs all of the necessary commands in order to build
the project and run the Django server so that the game can be
played locally.
"""
import subprocess
import sys
WINDOWS_COMMAND_PORTIONS = ["cmd.exe", "/c"]
GO_TO_FRONTEND_FOLDER = ["cd", "frontend"]
INSTALL_REACT_REQUIREMENTS = ["npm", "install"]
BUILD_REACT_PROJECT = ["npm", "run", "build"]
GO_TO_BACKEND_FOLDER = ["cd", "backend"]
INSTALL_DJANGO_REQUIREMENTS = ["pip", "install", "-r", "requirements.txt"]
GO_TO_SRC_FROM_BACKEND_FOLDER = ["cd", "src"]
RUN_DJANGO_SERVER = ["python", "manage.py", "runserver"]
def main():
prepend_command_with = []
if sys.platform == "win32":
prepend_command_with = WINDOWS_COMMAND_PORTIONS
for command in [
GO_TO_FRONTEND_FOLDER + ["&&"] +
INSTALL_REACT_REQUIREMENTS + ["&&"] +
BUILD_REACT_PROJECT,
GO_TO_BACKEND_FOLDER + ["&&"] +
INSTALL_DJANGO_REQUIREMENTS + ["&&"] +
GO_TO_SRC_FROM_BACKEND_FOLDER + ["&&"] +
RUN_DJANGO_SERVER
]:
subprocess.call(prepend_command_with + command)
if __name__ == "__main__":
main()