github.com/joey-fossa/fossa-cli@v0.7.34-0.20190708193710-569f1e8679f0/install.ps1 (about) 1 #Requires -Version 5 2 3 <# 4 .SYNOPSIS 5 Download and install the latest available FOSSA release from GitHub. 6 #> 7 8 [CmdletBinding()] 9 Param() 10 11 $OldEAP = $ErrorActionPreference #Preserve the original value 12 $ErrorActionPreference = "Stop" 13 14 $github = "https://github.com" 15 $latestUri = "$github/fossas/fossa-cli/releases/latest" 16 $extractDir = "$env:ALLUSERSPROFILE\fossa-cli" 17 18 Write-Verbose "Looking up latest release..." 19 20 [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::Tls12 21 22 $releasePage = Invoke-RestMethod $latestUri 23 24 if ($releasePage -inotmatch 'href=\"(.*?releases\/download\/.*?windows.*?)\"') 25 { 26 throw "Did not find latest Windows release at $latestUri" 27 } 28 29 $downloadUri = "$github/$($Matches[1])" 30 Write-Verbose "Downloading from: $downloadUri" 31 32 $TempDir = Join-Path ([System.IO.Path]::GetTempPath()) "fossa-cli" 33 if (![System.IO.Directory]::Exists($TempDir)) {[void][System.IO.Directory]::CreateDirectory($TempDir)} 34 35 $zipFile = "$TempDir\fossa-cli.zip" 36 37 (New-Object System.Net.WebClient).DownloadFile($downloadUri, $zipFile) 38 39 Expand-Archive -Path $zipFile -DestinationPath $extractDir -Force 40 41 $ErrorActionPreference = $OldEAP 42 43 $fossa = "$extractDir\fossa.exe" 44 45 Write-Host "Installed fossa-cli at: $fossa" 46 Write-Host "Get started by running: fossa.exe --help" 47 48 Write-Output $fossa