Skip to content

Commit 4e8e5cd

Browse files
committed
wip
1 parent d44861e commit 4e8e5cd

File tree

2 files changed

+56
-37
lines changed

2 files changed

+56
-37
lines changed

eng/scripts/get-aspire-cli-pr.ps1

Lines changed: 27 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ $Script:GHReposBase = "repos/dotnet/aspire"
9393
$InvokedFromFile = -not [string]::IsNullOrEmpty($PSCommandPath)
9494

9595
# =============================================================================
96-
# START: Code shared with get-aspire-cli-pr.ps1
96+
# START: Shared code
9797
# =============================================================================
9898

9999
# Consolidated output function with fallback for platforms that don't support Write-Host
@@ -388,24 +388,10 @@ function Expand-AspireCliArchive {
388388
}
389389

390390
# Simplified installation path determination
391-
function Get-InstallPrefix {
391+
function Get-DefaultInstallPrefix {
392392
[CmdletBinding()]
393393
[OutputType([string])]
394-
param(
395-
[Parameter()]
396-
[string]$InstallPrefix
397-
)
398-
399-
if (-not [string]::IsNullOrWhiteSpace($InstallPrefix)) {
400-
# Validate that the path is not just whitespace and can be created
401-
try {
402-
$resolvedPath = [System.IO.Path]::GetFullPath($InstallPrefix)
403-
return $resolvedPath
404-
}
405-
catch {
406-
throw "Invalid installation path: $InstallPrefix - $($_.Exception.Message)"
407-
}
408-
}
394+
param()
409395

410396
# Get home directory cross-platform
411397
$homeDirectory = Invoke-WithPowerShellVersion -ModernAction {
@@ -560,7 +546,7 @@ function Remove-TempDirectory {
560546
}
561547

562548
# =============================================================================
563-
# END: Code shared with get-aspire-cli.ps1
549+
# END: Shared code
564550
# =============================================================================
565551

566552
# Function to check if gh command is available
@@ -583,6 +569,29 @@ function Test-GitHubCLIDependency {
583569
}
584570
}
585571

572+
# Simplified installation path determination
573+
function Get-InstallPrefix {
574+
[CmdletBinding()]
575+
[OutputType([string])]
576+
param(
577+
[Parameter()]
578+
[string]$InstallPrefix
579+
)
580+
581+
if (-not [string]::IsNullOrWhiteSpace($InstallPrefix)) {
582+
# Validate that the path is not just whitespace and can be created
583+
try {
584+
$resolvedPath = [System.IO.Path]::GetFullPath($InstallPrefix)
585+
return $resolvedPath
586+
}
587+
catch {
588+
throw "Invalid installation path: $InstallPrefix - $($_.Exception.Message)"
589+
}
590+
}
591+
592+
return Get-DefaultInstallPrefix
593+
}
594+
586595
# Function to make GitHub API calls with proper error handling
587596
function Invoke-GitHubAPICall {
588597
[CmdletBinding()]

eng/scripts/get-aspire-cli.ps1

Lines changed: 29 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ $Script:Config = @{
127127
$InvokedFromFile = -not [string]::IsNullOrEmpty($PSCommandPath)
128128

129129
# =============================================================================
130-
# START: Code shared with get-aspire-cli-pr.ps1
130+
# START: Shared code
131131
# =============================================================================
132132

133133
# Consolidated output function with fallback for platforms that don't support Write-Host
@@ -422,24 +422,10 @@ function Expand-AspireCliArchive {
422422
}
423423

424424
# Simplified installation path determination
425-
function Get-InstallPath {
425+
function Get-DefaultInstallPrefix {
426426
[CmdletBinding()]
427427
[OutputType([string])]
428-
param(
429-
[Parameter()]
430-
[string]$InstallPath
431-
)
432-
433-
if (-not [string]::IsNullOrWhiteSpace($InstallPath)) {
434-
# Validate that the path is not just whitespace and can be created
435-
try {
436-
$resolvedPath = [System.IO.Path]::GetFullPath($InstallPath)
437-
return $resolvedPath
438-
}
439-
catch {
440-
throw "Invalid installation path: $InstallPath - $($_.Exception.Message)"
441-
}
442-
}
428+
param()
443429

444430
# Get home directory cross-platform
445431
$homeDirectory = Invoke-WithPowerShellVersion -ModernAction {
@@ -466,7 +452,7 @@ function Get-InstallPath {
466452
throw "Unable to determine user home directory. Please specify -InstallPath parameter."
467453
}
468454

469-
$defaultPath = Join-Path $homeDirectory (Join-Path ".aspire" "bin")
455+
$defaultPath = Join-Path $homeDirectory ".aspire"
470456
return [System.IO.Path]::GetFullPath($defaultPath)
471457
}
472458

@@ -594,9 +580,33 @@ function Remove-TempDirectory {
594580
}
595581

596582
# =============================================================================
597-
# END: Code shared with get-aspire-cli-pr.ps1
583+
# END: Shared code
598584
# =============================================================================
599585

586+
# Simplified installation path determination
587+
function Get-InstallPath {
588+
[CmdletBinding()]
589+
[OutputType([string])]
590+
param(
591+
[Parameter()]
592+
[string]$InstallPath
593+
)
594+
595+
if (-not [string]::IsNullOrWhiteSpace($InstallPath)) {
596+
# Validate that the path is not just whitespace and can be created
597+
try {
598+
$resolvedPath = [System.IO.Path]::GetFullPath($InstallPath)
599+
return $resolvedPath
600+
}
601+
catch {
602+
throw "Invalid installation path: $InstallPath - $($_.Exception.Message)"
603+
}
604+
}
605+
606+
$defaultPath = Join-Path (Get-DefaultInstallPrefix) "bin"
607+
return [System.IO.Path]::GetFullPath($defaultPath)
608+
}
609+
600610
function Get-ContentTypeFromUri {
601611
[CmdletBinding()]
602612
[OutputType([string])]

0 commit comments

Comments
 (0)