Skip to content

Commit dffe70a

Browse files
committed
Merge branch 'feature/publish-script-updates' into 'develop'
Update publish scripts for UI validation improvements See merge request genaiic-reusable-assets/engagement-artifacts/genaiic-idp-accelerator!328
2 parents 7e4a2ba + 1a133ca commit dffe70a

File tree

3 files changed

+76
-0
lines changed

3 files changed

+76
-0
lines changed

docs/deployment.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ You need to have the following packages installed on your computer:
3636
4. python 3.11 or later
3737
5. A local Docker daemon
3838
6. Python packages for publish.py: `pip install boto3 rich typer PyYAML botocore setuptools`
39+
7. **Node.js 18+** and **npm** (required for UI validation in publish script)
3940

4041
For guidance on setting up a development environment, see:
4142
- [Development Environment Setup Guide on Linux](./setup-development-env-linux.md)

publish.py

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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")

publish.sh

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,37 @@ check_python_version() {
8686
exit 1
8787
}
8888

89+
# Check if Node.js and npm are available for UI validation
90+
check_nodejs_dependencies() {
91+
print_info "Checking Node.js dependencies for UI validation..."
92+
93+
# Check Node.js
94+
if ! command -v node >/dev/null 2>&1; then
95+
print_error "Node.js not found but is required for UI build validation"
96+
print_info "Install Node.js 18+ from: https://nodejs.org/"
97+
exit 1
98+
fi
99+
100+
# Check npm
101+
if ! command -v npm >/dev/null 2>&1; then
102+
print_error "npm not found but is required for UI build validation"
103+
print_info "npm is typically installed with Node.js"
104+
exit 1
105+
fi
106+
107+
# Check Node.js version (require 18+)
108+
node_version=$(node --version 2>/dev/null | sed 's/v//')
109+
node_major=$(echo "$node_version" | cut -d'.' -f1)
110+
111+
if [[ "$node_major" -lt 18 ]]; then
112+
print_error "Node.js $node_version found, but 18+ is required for UI validation"
113+
print_info "Please upgrade Node.js to version 18 or later"
114+
exit 1
115+
else
116+
print_success "Found Node.js $node_version and npm $(npm --version)"
117+
fi
118+
}
119+
89120
# Check if required packages are installed and install them if missing
90121
check_and_install_packages() {
91122
print_info "Checking required Python packages..."
@@ -169,6 +200,9 @@ main() {
169200
# Check Python version
170201
check_python_version
171202

203+
# Check Node.js dependencies for UI validation
204+
check_nodejs_dependencies
205+
172206
# Check and install required packages
173207
check_and_install_packages
174208

0 commit comments

Comments
 (0)