31 lines
865 B
Python
31 lines
865 B
Python
from pathlib import Path
|
|
import shutil
|
|
import subprocess
|
|
|
|
|
|
CURRENT_DIR = Path(__file__).parent
|
|
STATIC_OUTPUT_DIR = CURRENT_DIR / "anime/static"
|
|
FRONTEND_DIR = CURRENT_DIR / "frontend"
|
|
DIST_DIR = FRONTEND_DIR / "dist"
|
|
|
|
|
|
def build():
|
|
"""
|
|
Build frontend and copy it to the static directory.
|
|
|
|
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.")
|
|
subprocess.run([pnpm_path, "build"], cwd=FRONTEND_DIR, check=True)
|
|
print("Frontend build finished.")
|
|
print("Copying static files ...")
|
|
shutil.rmtree(STATIC_OUTPUT_DIR, ignore_errors=True)
|
|
shutil.copytree(symlinks=True, src=DIST_DIR, dst=STATIC_OUTPUT_DIR)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
build()
|