19
build.py
19
build.py
@ -1,6 +1,7 @@
|
||||
import os
|
||||
from pathlib import Path
|
||||
from shutil import copytree, rmtree
|
||||
import shutil
|
||||
import subprocess
|
||||
|
||||
|
||||
CURRENT_DIR = Path(__file__).parent
|
||||
@ -29,15 +30,19 @@ def build(setup_kwargs):
|
||||
This script is useful for packaging the application.
|
||||
"""
|
||||
print("Starting building frontend ...")
|
||||
pnpm_path = shutil.which("pnpm")
|
||||
if pnpm_path is None:
|
||||
raise Exception("pnpm command is not available. PLease install pnpm.")
|
||||
|
||||
with DirChanger(CURRENT_DIR / "frontend"):
|
||||
ret_status = os.system("pnpm build")
|
||||
if ret_status != 0:
|
||||
raise Exception("Frontend build failed.")
|
||||
subprocess.run(
|
||||
[pnpm_path, "build"],
|
||||
cwd=CURRENT_DIR / "frontend",
|
||||
check=True,
|
||||
)
|
||||
|
||||
print("Frontend build finished.")
|
||||
rmtree(STATIC_OUTPUT_DIR, ignore_errors=True)
|
||||
copytree(symlinks=True, src=DIST_DIR, dst=STATIC_OUTPUT_DIR)
|
||||
shutil.rmtree(STATIC_OUTPUT_DIR, ignore_errors=True)
|
||||
shutil.copytree(symlinks=True, src=DIST_DIR, dst=STATIC_OUTPUT_DIR)
|
||||
|
||||
return setup_kwargs
|
||||
|
||||
|
Reference in New Issue
Block a user