-
-
Notifications
You must be signed in to change notification settings - Fork 29
/
Copy path.build.py
32 lines (21 loc) · 968 Bytes
/
.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
#!/usr/bin/env python3
import sys
from os import chdir, getenv, system
from pathlib import Path
from shutil import copytree, which
def build_ui():
print(f" - Running custom build hook in {Path(__file__)}")
# if the DEVBOX_PROJECT_ROOT exists, it'll be returned as a string, make sure it's a Path object
root = Path(getenv("DEVBOX_PROJECT_ROOT", Path.cwd()))
Path(root / "mmpm" / "ui").mkdir(exist_ok=True, parents=True)
chdir(root / "ui")
if not which("bun") and not which("npm"):
print("ERROR: both `npm` and `bun` are not installed. Cannot continue")
sys.exit(1)
node = which("bun") or "npm"
system(f"{node} install --legacy-peer-deps")
system("./node_modules/@angular/cli/bin/ng.js build --configuration production --output-hashing none --base-href /")
chdir(root)
copytree(root / "ui" / "build" / "browser", root / "mmpm" / "ui", dirs_exist_ok=True)
if __name__ == "__main__":
build_ui()