test-publishing.ps1
|
# Test script for module publishing validation Write-Host "=== Testing Bluscream-BuildTools Module for Publishing ===" -ForegroundColor Cyan try { # Test 1: Validate module manifest Write-Host "1. Testing module manifest..." -ForegroundColor Yellow $Manifest = Test-ModuleManifest "Bluscream-BuildTools.psd1" Write-Host " ✓ Module manifest is valid" -ForegroundColor Green Write-Host " Module Version: $($Manifest.Version)" -ForegroundColor Gray Write-Host " Author: $($Manifest.Author)" -ForegroundColor Gray # Test 2: Check if all functions are available Write-Host "2. Testing function availability..." -ForegroundColor Yellow Import-Module "Bluscream-BuildTools" -Force $Functions = Get-Command -Module Bluscream-BuildTools Write-Host " ✓ Found $($Functions.Count) functions" -ForegroundColor Green # Test 3: Test key functions Write-Host "3. Testing key functions..." -ForegroundColor Yellow # Test dependency management if (Get-Command Show-DependencyStatus -ErrorAction SilentlyContinue) { Write-Host " ✓ Show-DependencyStatus available" -ForegroundColor Green } else { Write-Host " ✗ Show-DependencyStatus not found" -ForegroundColor Red } # Test version management if (Get-Command Set-Version -ErrorAction SilentlyContinue) { Write-Host " ✓ Set-Version available" -ForegroundColor Green } else { Write-Host " ✗ Set-Version not found" -ForegroundColor Red } # Test Git operations if (Get-Command Git-CreateRepository -ErrorAction SilentlyContinue) { Write-Host " ✓ Git-CreateRepository available" -ForegroundColor Green } else { Write-Host " ✗ Git-CreateRepository not found" -ForegroundColor Red } # Test 4: Check for syntax errors Write-Host "4. Checking for syntax errors..." -ForegroundColor Yellow $FunctionFiles = Get-ChildItem "Functions" -Filter "*.ps1" $ErrorCount = 0 foreach ($File in $FunctionFiles) { try { $null = [System.Management.Automation.PSParser]::Tokenize((Get-Content $File.FullName -Raw), [ref]$null) Write-Host " ✓ $($File.Name)" -ForegroundColor Green } catch { Write-Host " ✗ $($File.Name): $($_.Exception.Message)" -ForegroundColor Red $ErrorCount++ } } if ($ErrorCount -eq 0) { Write-Host " ✓ No syntax errors found" -ForegroundColor Green } else { Write-Host " ✗ Found $ErrorCount syntax errors" -ForegroundColor Red } # Test 5: Check if API key is available Write-Host "5. Checking publishing credentials..." -ForegroundColor Yellow if ($env:PSGALLERY_KEY) { Write-Host " ✓ PowerShell Gallery API key found" -ForegroundColor Green } else { Write-Host " ⚠ PowerShell Gallery API key not found" -ForegroundColor Yellow Write-Host " Set PSGALLERY_KEY environment variable to publish" -ForegroundColor Gray } Write-Host "" Write-Host "=== Module Publishing Test Complete ===" -ForegroundColor Cyan Write-Host "Module is ready for publishing!" -ForegroundColor Green } catch { Write-Host "Error during testing: $_" -ForegroundColor Red Write-Host "Module may have issues that need to be fixed before publishing." -ForegroundColor Yellow } |