diff --git a/scripts/deploy-nas.ps1 b/scripts/deploy-nas.ps1 index 2a024da..a40a20b 100644 --- a/scripts/deploy-nas.ps1 +++ b/scripts/deploy-nas.ps1 @@ -24,6 +24,34 @@ function Quote-Sh { return "'" + ($Value -replace "'", "'\''") + "'" } +function Get-ObjectPropertyValue { + param( + [object]$Object, + [string]$Name + ) + if ($null -eq $Object) { + return $null + } + $property = $Object.PSObject.Properties[$Name] + if ($null -eq $property) { + return $null + } + return $property.Value +} + +function Test-ReleaseManifestRenderingGate { + param([object]$Manifest) + $renderingGate = Get-ObjectPropertyValue $Manifest "renderingGate" + $viewport = Get-ObjectPropertyValue $renderingGate "viewport" + return ( + (Get-ObjectPropertyValue $renderingGate "requiredRenderer") -eq "webgl" -and + (Get-ObjectPropertyValue $renderingGate "compatibilityRenderer") -eq "canvas" -and + (Get-ObjectPropertyValue $viewport "width") -eq 1920 -and + (Get-ObjectPropertyValue $viewport "height") -eq 1080 -and + (Get-ObjectPropertyValue $viewport "deviceScaleFactor") -eq 1 + ) +} + Assert-Command "ssh" Assert-Command "scp" Assert-Command "git" @@ -64,9 +92,14 @@ if (Test-Path $releaseManifestPath -PathType Leaf) { if ($existingReleaseManifest.app -ne "heros_web") { throw "Existing release manifest has unexpected app '$($existingReleaseManifest.app)'." } - if ($existingReleaseManifest.commit -eq $fullCommit) { + if ( + $existingReleaseManifest.commit -eq $fullCommit -and + (Test-ReleaseManifestRenderingGate $existingReleaseManifest) + ) { $writeReleaseManifest = $false Write-Host "Using existing $releaseManifestPath for $commit" + } elseif ($existingReleaseManifest.commit -eq $fullCommit) { + Write-Host "Replacing incomplete $releaseManifestPath for $commit" } else { Write-Host "Replacing stale $releaseManifestPath commit $($existingReleaseManifest.commit) with $commit" } @@ -81,6 +114,15 @@ if ($writeReleaseManifest) { shortCommit = $commit qaVersion = $qaVersion generatedAt = (Get-Date).ToUniversalTime().ToString("o") + renderingGate = @{ + requiredRenderer = "webgl" + compatibilityRenderer = "canvas" + viewport = @{ + width = 1920 + height = 1080 + deviceScaleFactor = 1 + } + } } | ConvertTo-Json -Depth 4 $utf8NoBom = New-Object System.Text.UTF8Encoding $false [System.IO.File]::WriteAllText($releaseManifestPath, "$releaseManifestJson`n", $utf8NoBom)