-
Notifications
You must be signed in to change notification settings - Fork 3
/
build.py
37 lines (27 loc) · 1.03 KB
/
build.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
import subprocess
import shutil
import os
# Clean up the 'release' directory
if os.path.exists("./release.zip"):
os.remove("./release.zip")
if os.path.exists("./release"):
shutil.rmtree("./release")
# Build the frontend
print("Building the frontend...")
subprocess.check_call(["cmd", "/c", "npm run build"], cwd="./frontend")
print("Frontend build completed.")
print("Packaging the app into release.zip...")
# Create a directory structure
os.makedirs("release/frontend", exist_ok=True)
# Copy built frontend to the newly created directory
shutil.copytree("./frontend/build", "./release/frontend/build")
# Copy backend to the newly created directory
shutil.copytree("./backend", "./release/backend")
# Copy run.py to the newly created directory
shutil.copy("./run.py", "./release/run.py")
# Create a zip file from the 'release' directory
shutil.make_archive("release", 'zip', "./release")
print("release.zip created.")
# Clean up the 'release' directory
shutil.rmtree("./release")
print("Build completed.")