Merge branch 'main' into develop-frontend

This commit is contained in:
Casey Wittrock 2025-10-20 01:11:30 -05:00
commit d5ca543d9c
2 changed files with 19 additions and 4 deletions

View File

@ -5,7 +5,8 @@ import frappe
from custom_ui.utils import create_module
@click.command("build-frontend")
def build_frontend():
@click.option("--site", default=None, help="Site to build frontend for")
def build_frontend(site):
app_package_path = frappe.get_app_path("custom_ui")
app_root = os.path.dirname(app_package_path)
@ -31,6 +32,23 @@ def build_frontend():
else:
frappe.log_error(message="No frontend directory found for custom_ui", title="Frontend Build Skipped")
click.echo(f"\n⚠️ Frontend directory does not exist. Skipping build. Path was {frontend_path}\n")
if not site:
return
try:
print(f"\n🧹 Clearing cache for site {site}...\n")
subprocess.check_call(["bench", "--site", site, "clear-cache"])
subprocess.check_call(["bench", "--site", site, "clear-website-cache"])
except subprocess.CalledProcessError as e:
frappe.log_error(message=str(e), title="Clear Cache Failed")
print(f"\n❌ Clearing cache failed: {e}\n")
# Restart bench
try:
print("\n🔄 Restarting bench...\n")
subprocess.check_call(["bench", "restart"])
except subprocess.CalledProcessError as e:
frappe.log_error(message=str(e), title="Bench Restart Failed")
print(f"\n❌ Bench restart failed: {e}\n")
@click.command("create-module")
def create_module_command():

View File

@ -31,9 +31,6 @@ def build_frontend():
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")