94 lines
3.3 KiB
PowerShell
94 lines
3.3 KiB
PowerShell
param(
|
|
[switch]$verbose
|
|
)
|
|
|
|
Write-Host "=== Verifying Build Health ===" -ForegroundColor Green
|
|
|
|
$errors = @()
|
|
$warnings = @()
|
|
|
|
# Check for common build issues
|
|
Write-Host "Checking for common build issues..." -ForegroundColor Yellow
|
|
|
|
# Check for mismatched .d.ts files in source directories
|
|
Write-Host "Checking for .d.ts files in source directories..." -ForegroundColor Blue
|
|
$sourceDtsFiles = Get-ChildItem -Path ".\libs\*\src\**\*.d.ts" -Recurse -ErrorAction SilentlyContinue
|
|
if ($sourceDtsFiles.Count -gt 0) {
|
|
$warnings += "Found .d.ts files in source directories:"
|
|
foreach ($file in $sourceDtsFiles) {
|
|
$warnings += " - $($file.FullName)"
|
|
}
|
|
}
|
|
|
|
# Check for missing dist directories after build
|
|
Write-Host "Checking for missing dist directories..." -ForegroundColor Blue
|
|
$libraries = @("types", "config", "logger", "utils", "cache", "http")
|
|
foreach ($lib in $libraries) {
|
|
$distPath = "libs\$lib\dist"
|
|
if (-not (Test-Path $distPath)) {
|
|
$errors += "Missing dist directory for $lib"
|
|
} else {
|
|
$indexFile = "$distPath\index.js"
|
|
if (-not (Test-Path $indexFile)) {
|
|
$errors += "Missing index.js in $lib dist directory"
|
|
}
|
|
}
|
|
}
|
|
|
|
# Check for stale tsbuildinfo files
|
|
Write-Host "Checking for stale tsbuildinfo files..." -ForegroundColor Blue
|
|
$tsbuildFiles = Get-ChildItem -Path ".\**\*.tsbuildinfo" -Recurse -ErrorAction SilentlyContinue
|
|
if ($tsbuildFiles.Count -gt 0) {
|
|
$warnings += "Found stale .tsbuildinfo files:"
|
|
foreach ($file in $tsbuildFiles) {
|
|
$warnings += " - $($file.FullName)"
|
|
}
|
|
}
|
|
|
|
# Check package.json dependencies
|
|
Write-Host "Checking package.json files..." -ForegroundColor Blue
|
|
$packageFiles = Get-ChildItem -Path ".\**\package.json" -Recurse -ErrorAction SilentlyContinue
|
|
foreach ($packageFile in $packageFiles) {
|
|
try {
|
|
$packageContent = Get-Content $packageFile.FullName | ConvertFrom-Json
|
|
if (-not $packageContent.name) {
|
|
$errors += "Package.json missing name: $($packageFile.FullName)"
|
|
}
|
|
if (-not $packageContent.version) {
|
|
$warnings += "Package.json missing version: $($packageFile.FullName)"
|
|
}
|
|
} catch {
|
|
$errors += "Invalid package.json: $($packageFile.FullName)"
|
|
}
|
|
}
|
|
|
|
# Report results
|
|
Write-Host "`n=== Build Health Report ===" -ForegroundColor Green
|
|
|
|
if ($errors.Count -gt 0) {
|
|
Write-Host "❌ ERRORS FOUND:" -ForegroundColor Red
|
|
foreach ($error in $errors) {
|
|
Write-Host " $error" -ForegroundColor Red
|
|
}
|
|
}
|
|
|
|
if ($warnings.Count -gt 0) {
|
|
Write-Host "⚠ WARNINGS:" -ForegroundColor Yellow
|
|
foreach ($warning in $warnings) {
|
|
Write-Host " $warning" -ForegroundColor Yellow
|
|
}
|
|
}
|
|
|
|
if ($errors.Count -eq 0 -and $warnings.Count -eq 0) {
|
|
Write-Host "✅ No issues found - build environment is healthy!" -ForegroundColor Green
|
|
} elseif ($errors.Count -eq 0) {
|
|
Write-Host "✅ No critical errors found (only warnings)" -ForegroundColor Green
|
|
} else {
|
|
Write-Host "❌ Critical errors found - build may fail" -ForegroundColor Red
|
|
exit 1
|
|
}
|
|
|
|
Write-Host "`nRecommended commands:" -ForegroundColor Cyan
|
|
Write-Host " Clean build: bun run reset" -ForegroundColor Gray
|
|
Write-Host " Quick build: bun run build" -ForegroundColor Gray
|
|
Write-Host " Clean only: bun run clean:dist" -ForegroundColor Gray
|