/ scripts / validate-visage-setup.ps1
validate-visage-setup.ps1
  1  # Visage Setup Validation Script
  2  # Validates that a plugin has proper Visage configuration
  3  
  4  param(
  5      [Parameter(Mandatory=$true)]
  6      [string]$PluginName
  7  )
  8  
  9  $ErrorActionPreference = "Stop"
 10  
 11  $RootPath = (Get-Item "$PSScriptRoot\..").FullName
 12  $PluginPath = "plugins\$PluginName"
 13  $SourcePath = "$PluginPath\Source"
 14  $EditorCpp = "$SourcePath\PluginEditor.cpp"
 15  $EditorH = "$SourcePath\PluginEditor.h"
 16  $ControlsH = "$SourcePath\VisageControls.h"
 17  $CMakeLists = "$PluginPath\CMakeLists.txt"
 18  $RootCMake = "$RootPath\CMakeLists.txt"
 19  $StatusJson = "$PluginPath\status.json"
 20  
 21  $Issues = @()
 22  $Warnings = @()
 23  
 24  Write-Host "Validating Visage setup for plugin: $PluginName" -ForegroundColor Cyan
 25  Write-Host ("=" * 60)
 26  
 27  # Check 1: Plugin directory exists
 28  if (-not (Test-Path $PluginPath)) {
 29      Write-Host "ERROR: Plugin directory not found: $PluginPath" -ForegroundColor Red
 30      exit 1
 31  }
 32  
 33  # Check 2: status.json exists and framework is Visage
 34  if (-not (Test-Path $StatusJson)) {
 35      $Warnings += "status.json not found - cannot confirm ui_framework"
 36  } else {
 37      $state = Get-Content $StatusJson -Raw | ConvertFrom-Json
 38      if ($state.ui_framework -ne "visage") {
 39          $Warnings += "ui_framework is '$($state.ui_framework)' (expected 'visage')"
 40      }
 41  }
 42  
 43  # Check 3: Root CMake has Visage option and subdirectory
 44  if (-not (Test-Path $RootCMake)) {
 45      $Issues += "Root CMakeLists.txt not found"
 46  } else {
 47      $rootContent = Get-Content $RootCMake -Raw
 48      if ($rootContent -notmatch "APC_ENABLE_VISAGE") {
 49          $Issues += "Root CMakeLists.txt missing APC_ENABLE_VISAGE option"
 50      }
 51      if ($rootContent -notmatch 'add_subdirectory\("\$\{VISAGE_DIR\}"\)') {
 52          $Warnings += "Root CMakeLists.txt does not add Visage subdirectory (APC_ENABLE_VISAGE may be OFF)"
 53      }
 54      if ($rootContent -notmatch "visage::visage") {
 55          $Warnings += "Root CMakeLists.txt does not create visage::visage alias target"
 56      }
 57  }
 58  
 59  # Check 4: Plugin CMakeLists.txt exists and links Visage
 60  if (-not (Test-Path $CMakeLists)) {
 61      $Issues += "CMakeLists.txt not found"
 62  } else {
 63      $cmakeContent = Get-Content $CMakeLists -Raw
 64      if ($cmakeContent -notmatch "visage::visage") {
 65          $Issues += "CMakeLists.txt missing 'visage::visage' link"
 66      }
 67      if ($cmakeContent -match "NEEDS_WEBVIEW2\\s+TRUE|JUCE_WEB_BROWSER=1|juce::juce_gui_extra") {
 68          $Warnings += "CMakeLists.txt contains WebView-specific flags/modules"
 69      }
 70  }
 71  
 72  # Check 5: VisageControls.h exists
 73  if (-not (Test-Path $ControlsH)) {
 74      $Issues += "VisageControls.h not found"
 75  }
 76  
 77  # Check 6: PluginEditor includes Visage host
 78  if (-not (Test-Path $EditorH)) {
 79      $Warnings += "PluginEditor.h not found"
 80  } else {
 81      $hContent = Get-Content $EditorH -Raw
 82      if ($hContent -notmatch "VisageJuceHost") {
 83          $Warnings += "PluginEditor.h does not include VisageJuceHost.h"
 84      }
 85      if ($hContent -notmatch "VisagePluginEditor") {
 86          $Warnings += "PluginEditor.h does not inherit from VisagePluginEditor"
 87      }
 88  }
 89  
 90  if (-not (Test-Path $EditorCpp)) {
 91      $Warnings += "PluginEditor.cpp not found"
 92  }
 93  
 94  # Report results
 95  Write-Host ""
 96  if ($Issues.Count -eq 0 -and $Warnings.Count -eq 0) {
 97      Write-Host "All checks passed! Visage setup looks correct." -ForegroundColor Green
 98      exit 0
 99  }
100  
101  if ($Issues.Count -gt 0) {
102      Write-Host "CRITICAL ISSUES FOUND:" -ForegroundColor Red
103      foreach ($issue in $Issues) {
104          Write-Host "  [X] $issue" -ForegroundColor Red
105      }
106  }
107  
108  if ($Warnings.Count -gt 0) {
109      Write-Host ""
110      Write-Host "WARNINGS:" -ForegroundColor Yellow
111      foreach ($warning in $Warnings) {
112          Write-Host "  [!] $warning" -ForegroundColor Yellow
113      }
114  }
115  
116  Write-Host ""
117  Write-Host "Validation Summary:" -ForegroundColor Cyan
118  $issueColor = if ($Issues.Count -gt 0) { "Red" } else { "Green" }
119  $warningColor = if ($Warnings.Count -gt 0) { "Yellow" } else { "Green" }
120  Write-Host "  Issues: $($Issues.Count)" -ForegroundColor $issueColor
121  Write-Host "  Warnings: $($Warnings.Count)" -ForegroundColor $warningColor
122  
123  if ($Issues.Count -gt 0) {
124      Write-Host ""
125      Write-Host "See templates in .claude/templates/visage/ for correct implementation" -ForegroundColor Cyan
126      exit 1
127  }
128  
129  exit 0