Skip to content

Commit 9348a52

Browse files
committed
bump version + update install scripts
1 parent 2c30294 commit 9348a52

File tree

6 files changed

+54
-128
lines changed

6 files changed

+54
-128
lines changed

assets/astra.ico

4.4 KB
Binary file not shown.

build.gradle.kts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ plugins {
1616
}
1717

1818
group = "com.dtsx.astra.cli"
19-
version = "1.0.0-rc.3"
19+
version = "1.0.0-rc.4"
2020

2121
val mockitoAgent = configurations.create("mockitoAgent")
2222

@@ -127,6 +127,8 @@ initNativeArchiveTask<Zip>("nativeZip") {
127127
from(tasks.nativeCompile.get().outputs.files) {
128128
include("*.exe")
129129
}
130+
from("scripts/uninstall.ps1")
131+
from("assets/astra.ico")
130132
}
131133

132134
inline fun <reified T : AbstractArchiveTask>initNativeArchiveTask(name: String, crossinline otherConfiguration: T.() -> Unit) {

scripts/install.ps1

Lines changed: 44 additions & 114 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,6 @@ function Checklist {
3636
Write-Host "-> $args" -ForegroundColor DarkGray
3737
}
3838

39-
function Underline {
40-
param([string]$Text)
41-
return "$Text"
42-
}
43-
4439
function Tildify($Path) {
4540
$userHome = $HOME.TrimEnd('\')
4641
if ($Path -like "$userHome*") {
@@ -119,7 +114,7 @@ function Get-Env {
119114
}
120115

121116
# Constants
122-
$ASTRA_CLI_VERSION = "1.0.0-rc.3"
117+
$ASTRA_CLI_VERSION = "1.0.0-rc.4"
123118

124119
if ($env:ASTRA_HOME) {
125120
$ASTRA_CLI_DIR = "$env:ASTRA_HOME\cli"
@@ -192,7 +187,7 @@ if (-not $existingInstallPath -and (Test-Path (Join-Path $ASTRA_CLI_DIR "astra.e
192187
if ($existingInstallPath) {
193188
Write-Host ""
194189
Write-Host "Error: An existing astra installation was already found." -ForegroundColor Red
195-
Write-Host "An existing installation was found at $( Underline (Tildify (Split-Path $existingInstallPath)) )`n"
190+
Write-Host "An existing installation was found at $(Tildify (Split-Path $existingInstallPath))`n"
196191
Write-MultiColor -Texts @("-> ", "(< astra-cli 1.x)", " Remove the existing installation manually and re-run this installer.") -Colors @("DarkCyan", "DarkGray", "Gray")
197192
Write-MultiColor -Texts @("-> ", "(> astra-cli 1.x)", " Run ", "astra upgrade", " to automatically update to the latest version.") -Colors @("DarkCyan", "DarkGray", "Gray", "DarkCyan", "Gray")
198193
Write-MultiColor -Texts @("-> ", "(> astra-cli 1.x)", " Run ", "astra nuke", " to completely remove the CLI and then re-run this installer.") -Colors @("DarkCyan", "DarkGray", "Gray", "DarkCyan", "Gray")
@@ -202,17 +197,15 @@ if ($existingInstallPath) {
202197
Print-Next-Steps -PathWasAdded $false
203198
throw "Existing installation found"
204199
}
205-
else {
206-
Checklist "No existing installation found."
207-
}
208200

209201
# Create installation directory
210202
New-Item -ItemType Directory -Force -Path $ASTRA_CLI_DIR | Out-Null
211-
Checklist "Using installation dir $( Underline ($ASTRA_CLI_DIR + "\") )"
203+
Checklist "Using installation dir $($ASTRA_CLI_DIR + "\")"
212204

213205
# Download and extract
214206
$zipPath = Join-Path $ASTRA_CLI_DIR "astra-tmp.zip"
215-
$exePath = Join-Path $ASTRA_CLI_DIR "astra.exe"
207+
$uninstallPath = Join-Path $ASTRA_CLI_DIR "uninstall.ps1"
208+
$iconPath = Join-Path $ASTRA_CLI_DIR "astra.ico"
216209

217210
Remove-Item -Force $zipPath -ErrorAction SilentlyContinue
218211

@@ -221,22 +214,17 @@ try {
221214
if ($LASTEXITCODE -ne 0) {
222215
throw "curl download failed with exit code $LASTEXITCODE"
223216
}
224-
if (-not (Test-Path $zipPath) -or (Get-Item $zipPath).Length -eq 0) {
225-
throw "Downloaded file is missing or empty"
226-
}
227217
Checklist "Archive downloaded."
228218
}
229219
catch {
230220
try {
221+
Remove-Item $zipPath -ErrorAction SilentlyContinue
231222
Invoke-RestMethod -Uri $installUrl -OutFile $zipPath
232-
if (-not (Test-Path $zipPath) -or (Get-Item $zipPath).Length -eq 0) {
233-
throw "Downloaded file is missing or empty"
234-
}
235223
Checklist "Archive downloaded via Invoke-RestMethod."
236224
}
237225
catch {
238226
Remove-Item $zipPath -ErrorAction SilentlyContinue
239-
Panic "`nError: Failed to download the archive to $( Underline (Tildify $zipPath) ). Check your internet connection and permissions."
227+
Panic "`nError: Failed to download the archive to $(Tildify $zipPath). Check your internet connection and permissions."
240228
}
241229
}
242230

@@ -249,140 +237,82 @@ try {
249237
Expand-Archive -Path $zipPath -DestinationPath $tempDir -Force
250238
Checklist "Archive extracted to temp dir."
251239

252-
$sourceExe = Join-Path $tempDir "astra\bin\astra.exe"
253-
254-
# Verify extracted file exists
255-
if (-not (Test-Path $sourceExe)) {
256-
Remove-Item -Recurse -Force $tempDir
257-
throw "astra.exe not found in archive. Archive may be corrupted."
258-
}
240+
# Move all files from archive
241+
$sourceBinDir = Join-Path $tempDir "astra\bin"
242+
Get-ChildItem -Path $sourceBinDir | Move-Item -Destination $ASTRA_CLI_DIR -Force
259243

260-
# Check if astra.exe is running before replacing
261-
try {
262-
Remove-Item -Force $exePath -ErrorAction Stop
263-
}
264-
catch [System.UnauthorizedAccessException] {
265-
$openProcesses = Get-Process -Name astra -ErrorAction SilentlyContinue | Where-Object { $_.Path -eq $exePath }
266-
if ($openProcesses.Count -gt 0) {
267-
Remove-Item -Recurse -Force $tempDir
268-
Panic "`nError: An existing astra.exe is running. Please close it and try again."
269-
}
270-
Remove-Item -Recurse -Force $tempDir
271-
Panic "`nError: Failed to replace existing astra.exe. Check file permissions."
272-
}
273-
catch [System.Management.Automation.ItemNotFoundException] {
274-
# File doesn't exist, that's fine
275-
}
276-
277-
Move-Item -Force $sourceExe $exePath
278244
Remove-Item -Recurse -Force $tempDir
279-
280-
# Verify installation succeeded
281-
if (-not (Test-Path $exePath)) {
282-
throw "Failed to install astra.exe to final location"
283-
}
284-
285-
Checklist "Archive verified and extracted."
286245
}
287246
catch {
288-
Panic "`nError: Failed to extract the archive at $( Underline (Tildify $zipPath) )."
247+
Panic "`nError: Failed to extract the archive at $(Tildify $zipPath)."
289248
}
290249
finally {
291250
Remove-Item -Force $zipPath -ErrorAction SilentlyContinue
292251
$global:ProgressPreference = $lastProgressPreference
293252
}
294253

295-
# Download uninstall script
296-
$uninstallPath = Join-Path $ASTRA_CLI_DIR "uninstall.ps1"
297-
$uninstallUrl = "https://raw.githubusercontent.com/datastax/astra-cli/main/scripts/uninstall.ps1"
298-
$uninstallDownloaded = $false
299-
300-
try {
301-
curl.exe "-#sfLo" "$uninstallPath" "$uninstallUrl"
302-
if ($LASTEXITCODE -eq 0) {
303-
$uninstallDownloaded = $true
304-
}
305-
else {
306-
throw "curl download failed"
307-
}
308-
}
309-
catch {
310-
try {
311-
Invoke-RestMethod -Uri $uninstallUrl -OutFile $uninstallPath
312-
$uninstallDownloaded = $true
313-
}
314-
catch {
315-
Write-Host "Warning: Failed to download uninstall script." -ForegroundColor Yellow
316-
}
254+
# Verify required files exist
255+
if (-not (Test-Path (Join-Path $ASTRA_CLI_DIR "astra.exe"))) {
256+
Panic "astra.exe not found in archive. Archive may be corrupted."
317257
}
318258

319-
if ($uninstallDownloaded -and (Test-Path $uninstallPath)) {
320-
Checklist "Downloaded uninstall script."
259+
if (-not (Test-Path $uninstallPath)) {
260+
Panic "uninstall.ps1 not found in archive. Archive may be corrupted."
321261
}
322-
else {
323-
Write-Host "Warning: Uninstaller in Add/Remove Programs will not work." -ForegroundColor Yellow
262+
263+
if (-not (Test-Path $iconPath)) {
264+
Panic "astra.ico not found in archive. Archive may be corrupted."
324265
}
325266

267+
Checklist "Archive extracted."
268+
326269
# Add to PATH automatically
327270
$pathWasAdded = $false
328-
try {
329-
$currentPath = Get-Env -Key "Path"
330-
$Path = if ($null -ne $currentPath) {
331-
$currentPath -split ';'
332-
}
333-
else {
334-
@()
335-
}
271+
if (-not $NoPathUpdate) {
272+
try {
273+
$currentPath = Get-Env -Key "Path"
274+
$Path = if ($null -ne $currentPath) {
275+
$currentPath -split ';'
276+
}
277+
else {
278+
@()
279+
}
336280

337-
if ($Path -notcontains $ASTRA_CLI_DIR) {
338-
if (-not $NoPathUpdate) {
281+
if ($Path -notcontains $ASTRA_CLI_DIR) {
339282
$Path += $ASTRA_CLI_DIR
340283
Write-Env -Key 'Path' -Value ($Path -join ';')
341-
$pathWasAdded = $true
342284
Checklist "Added to PATH."
343285
}
344-
}
345-
else {
346-
Checklist "Already in PATH."
286+
else {
287+
Checklist "Already in PATH."
288+
}
347289
$pathWasAdded = $true
348290
}
349-
}
350-
catch {
351-
Write-Host "Warning: Failed to update PATH. You'll need to add it manually." -ForegroundColor Yellow
291+
catch {
292+
Write-Host "Warning: Failed to update PATH. You'll need to add it manually." -ForegroundColor Yellow
293+
}
352294
}
353295

354296
# Register in Add/Remove Programs
355297
if (-not $NoRegisterInstallation) {
356-
$rootKey = $null
357298
try {
299+
$uninstallPath = Join-Path $ASTRA_CLI_DIR "uninstall.ps1"
300+
$iconPath = Join-Path $ASTRA_CLI_DIR "astra.ico"
301+
358302
$RegistryKey = "HKCU:\Software\Microsoft\Windows\CurrentVersion\Uninstall\AstraCLI"
359-
$rootKey = New-Item -Path $RegistryKey -Force
303+
New-Item -Path $RegistryKey -Force | Out-Null
360304
New-ItemProperty -Path $RegistryKey -Name "DisplayName" -Value "Astra CLI" -PropertyType String -Force | Out-Null
361305
New-ItemProperty -Path $RegistryKey -Name "DisplayVersion" -Value "$ASTRA_CLI_VERSION" -PropertyType String -Force | Out-Null
362306
New-ItemProperty -Path $RegistryKey -Name "Publisher" -Value "DataStax" -PropertyType String -Force | Out-Null
363307
New-ItemProperty -Path $RegistryKey -Name "InstallLocation" -Value "$ASTRA_CLI_DIR" -PropertyType String -Force | Out-Null
364-
New-ItemProperty -Path $RegistryKey -Name "DisplayIcon" -Value "$exePath" -PropertyType String -Force | Out-Null
365-
366-
# Use uninstall script if available, otherwise provide manual instructions
367-
if ($uninstallDownloaded -and (Test-Path $uninstallPath)) {
368-
New-ItemProperty -Path $RegistryKey -Name "UninstallString" -Value "powershell -ExecutionPolicy Bypass -File `"$uninstallPath`" -PauseOnError" -PropertyType String -Force | Out-Null
369-
New-ItemProperty -Path $RegistryKey -Name "QuietUninstallString" -Value "powershell -ExecutionPolicy Bypass -File `"$uninstallPath`"" -PropertyType String -Force | Out-Null
370-
}
371-
else {
372-
# Fallback: Point to a command that provides manual uninstall instructions
373-
$fallbackCmd = "powershell -ExecutionPolicy Bypass -Command `"Write-Host 'To uninstall Astra CLI:' -ForegroundColor Yellow; Write-Host '1. Run: astra nuke' -ForegroundColor Cyan; Write-Host '2. Remove from PATH manually' -ForegroundColor Cyan; Write-Host '3. Delete registry key: HKCU:\Software\Microsoft\Windows\CurrentVersion\Uninstall\AstraCLI' -ForegroundColor Cyan; Read-Host 'Press Enter to close'`""
374-
New-ItemProperty -Path $RegistryKey -Name "UninstallString" -Value $fallbackCmd -PropertyType String -Force | Out-Null
375-
}
376-
308+
New-ItemProperty -Path $RegistryKey -Name "DisplayIcon" -Value "$iconPath" -PropertyType String -Force | Out-Null
309+
New-ItemProperty -Path $RegistryKey -Name "UninstallString" -Value "powershell -ExecutionPolicy Bypass -File `"$uninstallPath`" -PauseOnError" -PropertyType String -Force | Out-Null
310+
New-ItemProperty -Path $RegistryKey -Name "QuietUninstallString" -Value "powershell -ExecutionPolicy Bypass -File `"$uninstallPath`"" -PropertyType String -Force | Out-Null
377311
New-ItemProperty -Path $RegistryKey -Name "NoModify" -Value 1 -PropertyType DWord -Force | Out-Null
378312
New-ItemProperty -Path $RegistryKey -Name "NoRepair" -Value 1 -PropertyType DWord -Force | Out-Null
379313
Checklist "Registered in Add/Remove Programs."
380314
}
381315
catch {
382-
# Cleanup on failure
383-
if ($rootKey -ne $null) {
384-
Remove-Item -Path $RegistryKey -Force -ErrorAction SilentlyContinue
385-
}
386316
Write-Host "Warning: Failed to register in Add/Remove Programs." -ForegroundColor Yellow
387317
}
388318
}

scripts/install.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ renderCommand() {
3737
}
3838

3939
# Constants
40-
ASTRA_CLI_VERSION="1.0.0-rc.3"
40+
ASTRA_CLI_VERSION="1.0.0-rc.4"
4141

4242
if [ -n "${ASTRA_HOME:-}" ]; then
4343
ASTRA_CLI_DIR_RESOLVER="custom"

scripts/uninstall.ps1

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -136,19 +136,13 @@ if ($env:ASTRARC) {
136136
}
137137

138138
# Remove .astrarc file (do not fail if it doesn't exist)
139-
try {
140-
Remove-Item "${AstraRc}" -Force -ErrorAction SilentlyContinue
141-
} catch {
142-
}
139+
Remove-Item "${AstraRc}" -Force -ErrorAction SilentlyContinue
143140

144141
# Remove Entry from PATH
145142
try {
146143
$currentPath = Get-Env -Key 'Path'
147-
if ($null -ne $currentPath) {
148-
$Path = $currentPath -split ';'
149-
$Path = $Path | Where-Object { $_ -ne "" -and $_ -ne "${PSScriptRoot}" }
150-
Write-Env -Key 'Path' -Value ($Path -join ';')
151-
}
144+
$Path = ($currentPath -split ';') | Where-Object { $_ -ne "" -and $_ -ne "${PSScriptRoot}" }
145+
Write-Env -Key 'Path' -Value ($Path -join ';')
152146
} catch {
153147
Write-Host "Could not remove ${PSScriptRoot} from PATH."
154148
Write-Error $_
@@ -160,8 +154,8 @@ try {
160154

161155
# Remove Entry from Windows Installer, if it is owned by this installation.
162156
try {
163-
$item = Get-Item "HKCU:\Software\Microsoft\Windows\CurrentVersion\Uninstall\AstraCLI";
164-
$location = $item.GetValue("InstallLocation");
157+
$item = Get-Item "HKCU:\Software\Microsoft\Windows\CurrentVersion\Uninstall\AstraCLI"
158+
$location = $item.GetValue("InstallLocation")
165159
if ($location -eq "${PSScriptRoot}") {
166160
Remove-Item "HKCU:\Software\Microsoft\Windows\CurrentVersion\Uninstall\AstraCLI" -Recurse
167161
}

src/test/resources/snapshots/AstraCli/help_output.human.approved.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ stderr: / | \\___ \ | | | | \ //__ \_
1010
stderr: \____|__ /____ > |__| |__| (____ /
1111
stderr: \/ \/ \/
1212
stderr:
13-
stderr: Version: 1.0.0-rc.3
13+
stderr: Version: 1.0.0-rc.4
1414
stdout: Documentation: https://docs.datastax.com/en/astra-cli
1515
stdout:
1616
stdout: Usage: astra [-qVv] [--no-input] [--[no-]spinner] [--dump-logs[=FILE]]

0 commit comments

Comments
 (0)