|
| 1 | +# Validates that uno-config.js references a dotnet.js fingerprint that matches an actual file |
| 2 | +param( |
| 3 | + [Parameter(Mandatory=$true)] |
| 4 | + [string]$PublishPath |
| 5 | +) |
| 6 | + |
| 7 | +$ErrorActionPreference = "Stop" |
| 8 | + |
| 9 | +Write-Host "Validating dotnet.js fingerprint in: $PublishPath" |
| 10 | + |
| 11 | +# Find uno-config.js (it could be in a package_* subdirectory) |
| 12 | +$unoConfig = Get-ChildItem -Path $PublishPath -Recurse -Filter "uno-config.js" | Select-Object -First 1 |
| 13 | + |
| 14 | +if (-not $unoConfig) { |
| 15 | + Write-Host "ERROR: uno-config.js not found in $PublishPath" |
| 16 | + exit 1 |
| 17 | +} |
| 18 | + |
| 19 | +Write-Host "Found uno-config.js: $($unoConfig.FullName)" |
| 20 | + |
| 21 | +# Read the content and extract the fingerprint |
| 22 | +$content = Get-Content -Path $unoConfig.FullName -Raw |
| 23 | +$match = [regex]::Match($content, 'dotnet\.([a-z0-9]+)\.js') |
| 24 | + |
| 25 | +if (-not $match.Success) { |
| 26 | + Write-Host "ERROR: Could not extract dotnet.js fingerprint from uno-config.js" |
| 27 | + Write-Host "Content of uno-config.js:" |
| 28 | + Write-Host $content |
| 29 | + exit 1 |
| 30 | +} |
| 31 | + |
| 32 | +$fingerprint = $match.Groups[1].Value |
| 33 | +Write-Host "Fingerprint in uno-config.js: $fingerprint" |
| 34 | + |
| 35 | +# Check if the fingerprinted dotnet.js file exists |
| 36 | +$frameworkPath = Join-Path $PublishPath "_framework" |
| 37 | +$dotnetJsFile = Join-Path $frameworkPath "dotnet.$fingerprint.js" |
| 38 | + |
| 39 | +if (-not (Test-Path $dotnetJsFile)) { |
| 40 | + Write-Host "ERROR: Fingerprint mismatch!" |
| 41 | + Write-Host " uno-config.js references: dotnet.$fingerprint.js" |
| 42 | + Write-Host " But this file does not exist in: $frameworkPath" |
| 43 | + Write-Host "" |
| 44 | + Write-Host "Available dotnet.*.js files in _framework:" |
| 45 | + Get-ChildItem -Path $frameworkPath -Filter "dotnet.*.js" -ErrorAction SilentlyContinue | ForEach-Object { Write-Host " $($_.Name)" } |
| 46 | + exit 1 |
| 47 | +} |
| 48 | + |
| 49 | +Write-Host "SUCCESS: dotnet.$fingerprint.js exists in _framework" |
| 50 | +Write-Host "Fingerprint validation passed!" |
0 commit comments