From f41823d34af1001cbe31648a4f3e294e2f77c105 Mon Sep 17 00:00:00 2001 From: Casey Wittrock Date: Mon, 20 Oct 2025 01:10:36 -0500 Subject: [PATCH] update command and install --- custom_ui/commands.py | 20 +++++++++++++++++++- custom_ui/install.py | 3 --- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/custom_ui/commands.py b/custom_ui/commands.py index 79e2273..3a6cf21 100644 --- a/custom_ui/commands.py +++ b/custom_ui/commands.py @@ -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(): diff --git a/custom_ui/install.py b/custom_ui/install.py index 57b0568..314cffd 100644 --- a/custom_ui/install.py +++ b/custom_ui/install.py @@ -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")