From 9ebbf6aace7dce3c65a9e6ef8253b68fc5896551 Mon Sep 17 00:00:00 2001 From: Bojan Kucera Date: Mon, 9 Jun 2025 20:46:49 -0400 Subject: [PATCH] new script for building --- package.json | 4 +- scripts/build-all.bat | 40 ++++++++++++++++ scripts/build-all.ps1 | 106 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 149 insertions(+), 1 deletion(-) create mode 100644 scripts/build-all.bat create mode 100644 scripts/build-all.ps1 diff --git a/package.json b/package.json index 8a75111..326bfa4 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,9 @@ "type": "module", "scripts": { "dev": "turbo run dev", - "build": "turbo run build", + "build": "powershell ./scripts/build-all.ps1", + "build:all:clean": "powershell ./scripts/build-all.ps1 -Clean", + "build:all:verbose": "powershell ./scripts/build-all.ps1 -Verbose", "build:libs": "powershell ./scripts/build-libs.ps1", "test": "turbo run test", "test:watch": "bun test --watch", diff --git a/scripts/build-all.bat b/scripts/build-all.bat new file mode 100644 index 0000000..ae5fc63 --- /dev/null +++ b/scripts/build-all.bat @@ -0,0 +1,40 @@ +@echo off +REM Build All Script for Stock Bot (Batch version) +REM Builds libraries first, then apps with Turbo, then dashboard with Angular CLI + +echo ๐Ÿš€ Starting complete build process... + +REM Store original directory +set "ORIGINAL_DIR=%CD%" +cd /d "g:\repos\stock-bot" + +REM Step 1: Build libraries first +echo ๐Ÿ“š Building libraries... +call powershell ./scripts/build-libs.ps1 +if %ERRORLEVEL% NEQ 0 ( + echo โŒ Library build failed + cd /d "%ORIGINAL_DIR%" + exit /b 1 +) + +REM Step 2: Build apps with Turbo (excluding dashboard) +echo ๐Ÿ—๏ธ Building applications with Turbo... +call turbo run build --filter="./apps/data-service" --filter="./apps/execution-service" --filter="./apps/portfolio-service" --filter="./apps/processing-service" --filter="./apps/strategy-service" +if %ERRORLEVEL% NEQ 0 ( + echo โŒ Turbo app build failed + cd /d "%ORIGINAL_DIR%" + exit /b 1 +) + +REM Step 3: Build dashboard with Angular CLI +echo ๐ŸŽจ Building Angular dashboard... +cd apps\dashboard +call ng build --configuration production +if %ERRORLEVEL% NEQ 0 ( + echo โŒ Dashboard build failed + cd /d "%ORIGINAL_DIR%" + exit /b 1 +) + +cd /d "%ORIGINAL_DIR%" +echo ๐ŸŽ‰ Complete build finished successfully! diff --git a/scripts/build-all.ps1 b/scripts/build-all.ps1 new file mode 100644 index 0000000..991d07d --- /dev/null +++ b/scripts/build-all.ps1 @@ -0,0 +1,106 @@ +# Build All Script for Stock Bot +# Builds libraries first, then apps with Turbo, then dashboard with Angular CLI + +param( + [switch]$Clean, + [switch]$Verbose +) + +$ErrorActionPreference = "Stop" + +Write-Host "๐Ÿš€ Starting complete build process..." -ForegroundColor Cyan + +# Store original location +$originalLocation = Get-Location +Set-Location "g:\repos\stock-bot" + +try { + # Step 1: Clean if requested + if ($Clean) { + Write-Host "๐Ÿงน Cleaning previous builds..." -ForegroundColor Yellow + & powershell ./scripts/clean.ps1 -dist + if ($LASTEXITCODE -ne 0) { + throw "Clean failed" + } + } + + # Step 2: Build libraries first + Write-Host "๐Ÿ“š Building libraries..." -ForegroundColor Green + & powershell ./scripts/build-libs.ps1 + if ($LASTEXITCODE -ne 0) { + throw "Library build failed" + } + + # Step 3: Build apps with Turbo (excluding dashboard) + Write-Host "๐Ÿ—๏ธ Building applications with Turbo..." -ForegroundColor Green + + # Get list of apps excluding dashboard + $appDirs = Get-ChildItem -Path "apps" -Directory | Where-Object { $_.Name -ne "dashboard" } + $appFilters = $appDirs | ForEach-Object { "./apps/$($_.Name)" } + + if ($appFilters.Count -gt 0) { + $filterArg = $appFilters -join " " + $turboCmd = "turbo run build --filter=`"$filterArg`"" + + if ($Verbose) { + Write-Host "Running: $turboCmd" -ForegroundColor DarkGray + } + + Invoke-Expression $turboCmd + if ($LASTEXITCODE -ne 0) { + throw "Turbo app build failed" + } + + Write-Host "โœ… Apps built successfully: $($appDirs.Name -join ', ')" -ForegroundColor Green + } else { + Write-Host "โ„น๏ธ No non-dashboard apps found to build with Turbo" -ForegroundColor Yellow + } + + # Step 4: Build dashboard with Angular CLI + $dashboardPath = "apps/dashboard" + if (Test-Path $dashboardPath) { + Write-Host "๐ŸŽจ Building Angular dashboard..." -ForegroundColor Green + + Set-Location $dashboardPath + + # Check if ng is available + try { + ng version | Out-Null + } catch { + Write-Host "โŒ Angular CLI not found. Installing..." -ForegroundColor Red + npm install -g @angular/cli + if ($LASTEXITCODE -ne 0) { + throw "Failed to install Angular CLI" + } + } + + # Build dashboard + ng build --configuration production + if ($LASTEXITCODE -ne 0) { + throw "Dashboard build failed" + } + + Write-Host "โœ… Dashboard built successfully" -ForegroundColor Green + Set-Location $originalLocation + } else { + Write-Host "โš ๏ธ Dashboard not found at $dashboardPath" -ForegroundColor Yellow + } + + Write-Host "๐ŸŽ‰ Complete build finished successfully!" -ForegroundColor Green + Write-Host "" + Write-Host "Build Summary:" -ForegroundColor Cyan + Write-Host " โœ… Libraries built" -ForegroundColor Green + if ($appFilters.Count -gt 0) { + Write-Host " โœ… Apps built: $($appDirs.Name -join ', ')" -ForegroundColor Green + } + if (Test-Path "apps/dashboard") { + Write-Host " โœ… Dashboard built" -ForegroundColor Green + } + +} catch { + Write-Host "โŒ Build failed: $($_.Exception.Message)" -ForegroundColor Red + Set-Location $originalLocation + exit 1 +} finally { + Set-Location $originalLocation +}