@@ -1110,6 +1110,43 @@ def compute_ui_hash(self):
11101110 ui_dir = "src/ui"
11111111 return self .get_directory_checksum (ui_dir )
11121112
1113+ def validate_ui_build (self ):
1114+ """Validate UI build to catch ESLint/Prettier errors before packaging"""
1115+ try :
1116+ self .console .print ("[bold cyan]🔍 VALIDATING UI build[/bold cyan]" )
1117+ ui_dir = "src/ui"
1118+
1119+ if not os .path .exists (ui_dir ):
1120+ self .console .print (
1121+ "[yellow]No UI directory found, skipping UI validation[/yellow]"
1122+ )
1123+ return
1124+
1125+ # Run npm install first
1126+ self .log_verbose ("Running npm install for UI dependencies..." )
1127+ success , result = self .run_subprocess_with_logging (
1128+ ["npm" , "install" ], "UI npm install" , ui_dir
1129+ )
1130+
1131+ if not success :
1132+ raise Exception ("npm install failed" )
1133+
1134+ # Run npm run build to validate ESLint/Prettier
1135+ self .log_verbose ("Running npm run build for UI validation..." )
1136+ success , result = self .run_subprocess_with_logging (
1137+ ["npm" , "run" , "build" ], "UI build validation" , ui_dir
1138+ )
1139+
1140+ if not success :
1141+ raise Exception ("UI build validation failed" )
1142+
1143+ self .console .print ("[green]✅ UI build validation passed[/green]" )
1144+
1145+ except Exception as e :
1146+ self .console .print ("[red]❌ UI build validation failed:[/red]" )
1147+ self .console .print (str (e ), style = "red" , markup = False )
1148+ sys .exit (1 )
1149+
11131150 def package_ui (self ):
11141151 """Package UI source code"""
11151152 ui_hash = self .compute_ui_hash ()
@@ -1222,6 +1259,10 @@ def build_main_template(self, webui_zipfile, components_needing_rebuild):
12221259 # Main template needs rebuilding, if any component needs rebuilding
12231260 if components_needing_rebuild :
12241261 self .console .print ("[yellow]Main template needs rebuilding[/yellow]" )
1262+
1263+ # Validate UI build before rebuilding
1264+ self .validate_ui_build ()
1265+
12251266 # Validate Python syntax in src directory before building
12261267 if not self ._validate_python_syntax ("src" ):
12271268 raise Exception ("Python syntax validation failed" )
0 commit comments