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