77# of them when querying for the architecture.
88#>
99[System.String []]$SUPPORTED_ARCH = @ (" x86_64" , " arm64" , " amd64" )
10- [System.String ]$DOWNLOAD_BASE_URL = " cdn.parseable.com/"
10+
11+ # Progress bar in powershell slows down downloads a lot, disable it
12+ # https://stackoverflow.com/questions/28682642/powershell-why-is-using-invoke-webrequest-much-slower-than-a-browser-download
13+ $ProgressPreference = ' SilentlyContinue'
1114
1215# util functions
1316function Get-Env {
@@ -105,14 +108,29 @@ function Install-Parseable {
105108 Write-Output " Fetching latest release..."
106109 # Get the latest release information using GitHub API
107110 $release = Invoke-RestMethod - Uri " https://api.github.com/repos/parseablehq/parseable/releases/latest"
108- # Loop through binaries in the release and find the appropriate one
109- $download_url = $DOWNLOAD_BASE_URL + $CPU_ARCH + " -" + $OS + " ." + $release.tag_name
110-
111- mkdir - Force $INSTALLDIR
111+ # Write-Host ($release | Format-List | Out-String) # Write-Host formats the object while printing
112+
113+ $installation_found_flag = 0
114+ $required_installation = " Parseable_OSS_" + $CPU_ARCH + " -" + " pc" + " -" + $OS + " -msvc.exe"
115+ # Loop through assets and select one based on `name`
116+ foreach ($asset in $release.assets ) {
117+ if ($asset.name -contains $required_installation ) {
118+ $installation_found_flag = 1
119+ $download_url = $asset.browser_download_url
120+ # Create installdir since we were able to find the required installation
121+ mkdir - Force $INSTALLDIR
122+ }
123+ }
112124
113125 Write-Output " Downloading Parseable version $release_tag , for OS: $OS , CPU architecture: $CPU_ARCH `n`n "
114126 # Download the binary using Invoke-WebRequest
115- Invoke-WebRequest - Uri $download_url - OutFile $BIN
127+ if ($installation_found_flag ) {
128+ Invoke-WebRequest - Uri $download_url - OutFile $BIN
129+ } else {
130+ Write-Output " Unable to find correct installation. Exiting"
131+ exit
132+ }
133+
116134
117135 Write-Output " Adding Parseable to PATH..."
118136 # Only try adding to path if there isn't already a bun.exe in the path
@@ -127,4 +145,4 @@ function Install-Parseable {
127145Install-Parseable
128146
129147Write-Output " Parseable was downloaded successfully! at $INSTALLDIR "
130- Write-Output " To get started, restart your terminal/editor, then type `" parseable`"`n "
148+ Write-Output " To get started, restart your terminal/editor, then type `" parseable`"`n "
0 commit comments