This commit is contained in:
Casey Wittrock 2025-10-19 22:57:58 -05:00
parent c5e27c0f70
commit 309925c191
28 changed files with 1757 additions and 4 deletions

46
custom_ui/install.py Normal file
View file

@ -0,0 +1,46 @@
import os
import subprocess
import frappe
from .utils import create_module
def after_install():
create_module()
build_frontend()
def after_migrate():
build_frontend()
def build_frontend():
app_package_path = frappe.get_app_path("custom_ui")
app_root = os.path.dirname(app_package_path)
candidates = [
os.path.join(app_root, "frontend"),
os.path.join(app_package_path, "frontend")
]
frontend_path = None
for p in candidates:
if os.path.exists(p):
frontend_path = p
break
if not frontend_path:
frappe.log_error(message="No frontend directory found for custom_ui", title="Frontend Build Skipped")
print(f"⚠️ Frontend directory does not exist. Skipping build. Path was {frontend_path}")
return
dist_path = os.path.join(app_root, "custom_ui", "public", "dist")
should_build = True
if os.path.exists(dist_path) and os.listdir(dist_path):
print(" Frontend already built. Skipping rebuild.")
should_build = False
if should_build:
print("\n📦 Building frontend for custom_ui...\n")
try:
subprocess.check_call(["npm", "install"], cwd=frontend_path)
subprocess.check_call(["npm", "run", "build"], cwd=frontend_path)
print("\n✅ Frontend build completed successfully.\n")
except subprocess.CalledProcessError as e:
frappe.log_error(message=str(e), title="Frontend Build Failed")
print(f"\n❌ Frontend build failed: {e}\n")