7
7
# of them when querying for the architecture.
8
8
#>
9
9
[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'
11
14
12
15
# util functions
13
16
function Get-Env {
@@ -105,14 +108,29 @@ function Install-Parseable {
105
108
Write-Output " Fetching latest release..."
106
109
# Get the latest release information using GitHub API
107
110
$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
+ }
112
124
113
125
Write-Output " Downloading Parseable version $release_tag , for OS: $OS , CPU architecture: $CPU_ARCH `n`n "
114
126
# 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
+
116
134
117
135
Write-Output " Adding Parseable to PATH..."
118
136
# Only try adding to path if there isn't already a bun.exe in the path
@@ -127,4 +145,4 @@ function Install-Parseable {
127
145
Install-Parseable
128
146
129
147
Write-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