232 lines
7.8 KiB
PowerShell
232 lines
7.8 KiB
PowerShell
# ZitiNexus UI File Organization Audit Script (PowerShell Version)
|
|
# This script checks for file organization issues that can break the UI system
|
|
|
|
Write-Host "==============================================" -ForegroundColor Cyan
|
|
Write-Host "ZitiNexus UI File Organization Audit" -ForegroundColor Cyan
|
|
Write-Host "==============================================" -ForegroundColor Cyan
|
|
Write-Host ""
|
|
|
|
# Initialize counters
|
|
$ERRORS = 0
|
|
$WARNINGS = 0
|
|
|
|
# Function to report error
|
|
function Report-Error {
|
|
param($Message)
|
|
Write-Host "❌ ERROR: $Message" -ForegroundColor Red
|
|
$script:ERRORS++
|
|
}
|
|
|
|
# Function to report warning
|
|
function Report-Warning {
|
|
param($Message)
|
|
Write-Host "⚠️ WARNING: $Message" -ForegroundColor Yellow
|
|
$script:WARNINGS++
|
|
}
|
|
|
|
# Function to report success
|
|
function Report-Success {
|
|
param($Message)
|
|
Write-Host "✅ OK: $Message" -ForegroundColor Green
|
|
}
|
|
|
|
Write-Host "1. Checking for duplicate PHP files..." -ForegroundColor White
|
|
Write-Host "--------------------------------------" -ForegroundColor White
|
|
|
|
# Check for duplicate index.php
|
|
if (Test-Path "UI\index.php") {
|
|
Report-Error "UI\index.php exists (should be removed - use UI\public\index.php only)"
|
|
} else {
|
|
Report-Success "No duplicate index.php found"
|
|
}
|
|
|
|
# Check for duplicate dashboard.php
|
|
if (Test-Path "UI\dashboard.php") {
|
|
Report-Error "UI\dashboard.php exists (should be removed - use UI\public\dashboard.php only)"
|
|
} else {
|
|
Report-Success "No duplicate dashboard.php found"
|
|
}
|
|
|
|
# Check for test files in production
|
|
if (Test-Path "UI\testfiles") {
|
|
Report-Warning "UI\testfiles\ directory exists (should be removed in production)"
|
|
Write-Host " Test files found:" -ForegroundColor Yellow
|
|
Get-ChildItem "UI\testfiles" -Filter "*.php" -Recurse | ForEach-Object {
|
|
Write-Host " - $($_.FullName)" -ForegroundColor Yellow
|
|
}
|
|
} else {
|
|
Report-Success "No testfiles directory found"
|
|
}
|
|
|
|
Write-Host ""
|
|
Write-Host "2. Checking required directory structure..." -ForegroundColor White
|
|
Write-Host "-------------------------------------------" -ForegroundColor White
|
|
|
|
# Check required directories
|
|
if (Test-Path "UI\public") {
|
|
Report-Success "UI\public\ directory exists"
|
|
} else {
|
|
Report-Error "UI\public\ directory missing"
|
|
}
|
|
|
|
if (Test-Path "UI\includes") {
|
|
Report-Success "UI\includes\ directory exists"
|
|
} else {
|
|
Report-Error "UI\includes\ directory missing"
|
|
}
|
|
|
|
if (Test-Path "UI\public\assets") {
|
|
Report-Success "UI\public\assets\ directory exists"
|
|
} else {
|
|
Report-Error "UI\public\assets\ directory missing"
|
|
}
|
|
|
|
if (Test-Path "UI\logs") {
|
|
Report-Success "UI\logs\ directory exists"
|
|
} else {
|
|
Report-Warning "UI\logs\ directory missing (will be created automatically)"
|
|
}
|
|
|
|
Write-Host ""
|
|
Write-Host "3. Checking required files..." -ForegroundColor White
|
|
Write-Host "-----------------------------" -ForegroundColor White
|
|
|
|
# Check required public files
|
|
if (Test-Path "UI\public\index.php") {
|
|
Report-Success "UI\public\index.php exists"
|
|
} else {
|
|
Report-Error "UI\public\index.php missing"
|
|
}
|
|
|
|
if (Test-Path "UI\public\dashboard.php") {
|
|
Report-Success "UI\public\dashboard.php exists"
|
|
} else {
|
|
Report-Error "UI\public\dashboard.php missing"
|
|
}
|
|
|
|
# Check required include files
|
|
if (Test-Path "UI\includes\config.php") {
|
|
Report-Success "UI\includes\config.php exists"
|
|
} else {
|
|
Report-Error "UI\includes\config.php missing"
|
|
}
|
|
|
|
if (Test-Path "UI\includes\auth.php") {
|
|
Report-Success "UI\includes\auth.php exists"
|
|
} else {
|
|
Report-Error "UI\includes\auth.php missing"
|
|
}
|
|
|
|
if (Test-Path "UI\includes\api_client.php") {
|
|
Report-Success "UI\includes\api_client.php exists"
|
|
} else {
|
|
Report-Error "UI\includes\api_client.php missing"
|
|
}
|
|
|
|
if (Test-Path "UI\includes\enrollment.php") {
|
|
Report-Success "UI\includes\enrollment.php exists"
|
|
} else {
|
|
Report-Error "UI\includes\enrollment.php missing"
|
|
}
|
|
|
|
# Check required asset files
|
|
if (Test-Path "UI\public\assets\css\style.css") {
|
|
Report-Success "UI\public\assets\css\style.css exists"
|
|
} else {
|
|
Report-Error "UI\public\assets\css\style.css missing"
|
|
}
|
|
|
|
if (Test-Path "UI\public\assets\js\app.js") {
|
|
Report-Success "UI\public\assets\js\app.js exists"
|
|
} else {
|
|
Report-Error "UI\public\assets\js\app.js missing"
|
|
}
|
|
|
|
Write-Host ""
|
|
Write-Host "4. Checking for misplaced files..." -ForegroundColor White
|
|
Write-Host "----------------------------------" -ForegroundColor White
|
|
|
|
# Check for PHP files in wrong locations (excluding the known duplicates we already checked)
|
|
$MisplacedFiles = Get-ChildItem "UI\" -Filter "*.php" -File | Where-Object { $_.Name -notin @("index.php", "dashboard.php") }
|
|
if ($MisplacedFiles.Count -gt 0) {
|
|
Report-Warning "PHP files found in UI root directory:"
|
|
$MisplacedFiles | ForEach-Object {
|
|
Write-Host " - $($_.Name)" -ForegroundColor Yellow
|
|
}
|
|
} else {
|
|
Report-Success "No misplaced PHP files in UI root"
|
|
}
|
|
|
|
# Check for assets in wrong locations
|
|
if (Test-Path "UI\assets") {
|
|
Report-Error "UI\assets\ directory exists (should be UI\public\assets\)"
|
|
} else {
|
|
Report-Success "No misplaced assets directory found"
|
|
}
|
|
|
|
Write-Host ""
|
|
Write-Host "5. Checking for debug files..." -ForegroundColor White
|
|
Write-Host "------------------------------" -ForegroundColor White
|
|
|
|
# Check for debug files
|
|
$DebugFiles = @()
|
|
$DebugFiles += Get-ChildItem "UI\" -Filter "debug-*.php" -Recurse -ErrorAction SilentlyContinue
|
|
$DebugFiles += Get-ChildItem "UI\" -Filter "test-*.php" -Recurse -ErrorAction SilentlyContinue
|
|
$DebugFiles += Get-ChildItem "UI\" -Filter "*-debug.php" -Recurse -ErrorAction SilentlyContinue
|
|
|
|
if ($DebugFiles.Count -gt 0) {
|
|
Report-Warning "Debug files found (should be removed in production):"
|
|
$DebugFiles | ForEach-Object {
|
|
Write-Host " - $($_.FullName)" -ForegroundColor Yellow
|
|
}
|
|
} else {
|
|
Report-Success "No debug files found"
|
|
}
|
|
|
|
Write-Host ""
|
|
Write-Host "==============================================" -ForegroundColor Cyan
|
|
Write-Host "AUDIT SUMMARY" -ForegroundColor Cyan
|
|
Write-Host "==============================================" -ForegroundColor Cyan
|
|
|
|
if ($ERRORS -eq 0 -and $WARNINGS -eq 0) {
|
|
Write-Host "🎉 EXCELLENT: File organization is perfect!" -ForegroundColor Green
|
|
Write-Host " No errors or warnings found." -ForegroundColor Green
|
|
} elseif ($ERRORS -eq 0) {
|
|
Write-Host "✅ GOOD: No critical errors found." -ForegroundColor Green
|
|
Write-Host " $WARNINGS warning(s) found - consider addressing them." -ForegroundColor Yellow
|
|
} else {
|
|
Write-Host "🚨 ISSUES FOUND:" -ForegroundColor Red
|
|
Write-Host " $ERRORS critical error(s) that MUST be fixed" -ForegroundColor Red
|
|
Write-Host " $WARNINGS warning(s) that should be addressed" -ForegroundColor Yellow
|
|
Write-Host ""
|
|
Write-Host "RECOMMENDED ACTIONS:" -ForegroundColor Yellow
|
|
|
|
if ((Test-Path "UI\index.php") -or (Test-Path "UI\dashboard.php")) {
|
|
Write-Host "1. Remove duplicate PHP files:" -ForegroundColor Yellow
|
|
if (Test-Path "UI\index.php") { Write-Host " Remove-Item UI\index.php" -ForegroundColor Yellow }
|
|
if (Test-Path "UI\dashboard.php") { Write-Host " Remove-Item UI\dashboard.php" -ForegroundColor Yellow }
|
|
}
|
|
|
|
if (Test-Path "UI\testfiles") {
|
|
Write-Host "2. Remove test files directory:" -ForegroundColor Yellow
|
|
Write-Host " Remove-Item UI\testfiles\ -Recurse -Force" -ForegroundColor Yellow
|
|
}
|
|
|
|
if (!(Test-Path "UI\public") -or !(Test-Path "UI\includes")) {
|
|
Write-Host "3. Create missing required directories" -ForegroundColor Yellow
|
|
}
|
|
|
|
Write-Host "4. Review DEVELOPMENT_INSTRUCTIONS.md for detailed guidance" -ForegroundColor Yellow
|
|
}
|
|
|
|
Write-Host ""
|
|
Write-Host "For detailed guidelines, see: UI\DEVELOPMENT_INSTRUCTIONS.md" -ForegroundColor Cyan
|
|
Write-Host "==============================================" -ForegroundColor Cyan
|
|
|
|
# Exit with error code if critical errors found
|
|
if ($ERRORS -gt 0) {
|
|
exit 1
|
|
} else {
|
|
exit 0
|
|
}
|