|
| 1 | +$ErrorActionPreference = 'Stop' |
| 2 | +$PSNativeCommandUseErrorActionPreference = $true |
| 3 | + |
| 4 | +$VfoxVersion = if ($env:VFOX_VERSION) { $env:VFOX_VERSION } else { 'latest' } |
| 5 | +if ($env:PROCESSOR_ARCHITECTURE -ne 'AMD64') { throw "x86_64 only, got $env:PROCESSOR_ARCHITECTURE" } |
| 6 | + |
| 7 | +$RepoRoot = (Resolve-Path "$PSScriptRoot\..\..").Path |
| 8 | +$WorkDir = "$env:TEMP\vfox-flutter-e2e" |
| 9 | +New-Item -ItemType Directory -Force -Path $WorkDir | Out-Null |
| 10 | +$VfoxExe = "$WorkDir\vfox.exe" |
| 11 | +$PluginZip = "$WorkDir\flutter.zip" |
| 12 | +$Pwsh = 'C:\Program Files\PowerShell\7\pwsh.exe' |
| 13 | +$env:PATH = "$WorkDir;$env:PATH" |
| 14 | + |
| 15 | +function Install-VfoxRelease { |
| 16 | + $tag = ((& curl.exe -fsSLI -o NUL -w '%{url_effective}' 'https://github.com/version-fox/vfox/releases/latest') -split '/tag/')[-1].Trim() |
| 17 | + $zip = "$WorkDir\vfox.zip" |
| 18 | + & curl.exe -fsSL -o $zip "https://github.com/version-fox/vfox/releases/download/$tag/vfox_$($tag.TrimStart('v'))_windows_x86_64.zip" |
| 19 | + tar -xf $zip -C $WorkDir |
| 20 | + Remove-Item $zip |
| 21 | + Copy-Item -Path (Get-ChildItem -Path $WorkDir -Recurse -Filter 'vfox.exe') -Destination $VfoxExe |
| 22 | +} |
| 23 | + |
| 24 | +function Install-VfoxMain { |
| 25 | + $goMsi = "$env:TEMP\go.msi" |
| 26 | + & curl.exe -fsSL -o $goMsi 'https://go.dev/dl/go1.27.1.windows-amd64.msi' |
| 27 | + Start-Process msiexec.exe -Wait -ArgumentList '/i', "`"$goMsi`"", '/quiet', '/norestart' |
| 28 | + Remove-Item $goMsi |
| 29 | + $env:PATH = "$WorkDir;" + [Environment]::GetEnvironmentVariable('Path', 'Machine') |
| 30 | + $src = "$WorkDir\vfox-src" |
| 31 | + git clone --depth 1 https://github.com/version-fox/vfox $src |
| 32 | + Push-Location $src |
| 33 | + try { go build -trimpath -o $VfoxExe . } finally { Pop-Location } |
| 34 | +} |
| 35 | + |
| 36 | +if ($VfoxVersion -eq 'main') { Install-VfoxMain } else { Install-VfoxRelease } |
| 37 | + |
| 38 | +tar -a -cf $PluginZip -C $RepoRoot metadata.lua hooks lib |
| 39 | + |
| 40 | +Invoke-Expression ((vfox activate pwsh) -join "`n") |
| 41 | +vfox add flutter --source $PluginZip |
| 42 | +vfox install flutter@3.47.4 |
| 43 | +vfox use --global flutter@3.47.4 |
| 44 | + |
| 45 | +$check = "$WorkDir\check.ps1" |
| 46 | +@' |
| 47 | +$ErrorActionPreference = 'Stop' |
| 48 | +$PSNativeCommandUseErrorActionPreference = $true |
| 49 | +Invoke-Expression ((vfox activate pwsh) -join "`n") |
| 50 | +dart --version |
| 51 | +flutter --version --no-version-check |
| 52 | +'@ | Set-Content -Path $check -Encoding UTF8 |
| 53 | +& $Pwsh -NoProfile -File $check |
0 commit comments