Developer-Dashboard
view release on metacpan or search on metacpan
install.ps1 view on Meta::CPAN
$curlPath = Resolve-CommandPath -Names @('curl.exe', 'curl')
if (-not [string]::IsNullOrWhiteSpace($curlPath)) {
try {
Invoke-NativeCommand -Label "$Label via curl" -FilePath $curlPath -Arguments @(
'--fail',
'--location',
'--silent',
'--show-error',
'--output', $DestinationPath,
$Uri
)
if ((Test-Path $DestinationPath) -and ((Get-Item $DestinationPath).Length -gt 0)) {
return
}
throw "curl created an empty file for $Uri"
}
catch {
if ((Test-Path $DestinationPath) -and ((Get-Item $DestinationPath).Length -eq 0)) {
Remove-Item -Force $DestinationPath
}
Write-Host ("curl failed for {0}: {1}" -f $Label, $_.Exception.Message) -ForegroundColor Yellow
}
}
try {
Invoke-WebRequest -UseBasicParsing -Uri $Uri -OutFile $DestinationPath
if ((Test-Path $DestinationPath) -and ((Get-Item $DestinationPath).Length -gt 0)) {
return
}
throw "Invoke-WebRequest created an empty file for $Uri"
}
catch {
if ((Test-Path $DestinationPath) -and ((Get-Item $DestinationPath).Length -eq 0)) {
Remove-Item -Force $DestinationPath
}
Write-Host ("Invoke-WebRequest failed for {0}: {1}" -f $Label, $_.Exception.Message) -ForegroundColor Yellow
}
$webClient = New-Object System.Net.WebClient
try {
$webClient.DownloadFile($Uri, $DestinationPath)
if ((Test-Path $DestinationPath) -and ((Get-Item $DestinationPath).Length -gt 0)) {
return
}
throw "WebClient created an empty file for $Uri"
}
catch {
if ((Test-Path $DestinationPath) -and ((Get-Item $DestinationPath).Length -eq 0)) {
Remove-Item -Force $DestinationPath
}
throw ("{0} failed for {1}: {2}" -f $Label, $Uri, $_.Exception.Message)
}
finally {
$webClient.Dispose()
}
}
function Get-RemoteJson {
# Purpose: fetch JSON metadata for Windows bootstrap decisions through the shared resilient downloader.
# Input: a URL string plus an optional label for diagnostics.
# Output: returns the decoded PowerShell object graph from the remote JSON payload.
param(
[Parameter(Mandatory = $true)]
[string]$Uri,
[string]$Label = 'remote JSON request'
)
$jsonText = Get-RemoteText -Uri $Uri -Label $Label
return ($jsonText | ConvertFrom-Json)
}
function Get-WindowsBootstrapArchitecture {
# Purpose: resolve the effective Windows CPU architecture for bootstrap package selection.
# Input: the current process and WOW64 environment variables exposed by Windows.
# Output: returns one of arm64, x64, or x86.
$rawArchitecture = @(
$env:PROCESSOR_ARCHITEW6432,
$env:PROCESSOR_ARCHITECTURE
) | Where-Object { -not [string]::IsNullOrWhiteSpace($_) } | Select-Object -First 1
if ([string]::IsNullOrWhiteSpace($rawArchitecture)) {
$rawArchitecture = ''
}
switch ($rawArchitecture.ToUpperInvariant()) {
'ARM64' { return 'arm64' }
'AMD64' { return 'x64' }
'X86' { return 'x86' }
default {
if ([Environment]::Is64BitOperatingSystem) {
return 'x64'
}
return 'x86'
}
}
}
function Add-ProcessPathSegment {
# Purpose: prepend one directory to the current process PATH once without duplication.
# Input: one directory path string.
# Output: returns nothing after PATH is updated in-process when needed.
param(
[Parameter(Mandatory = $true)]
[string]$PathSegment
)
if ([string]::IsNullOrWhiteSpace($PathSegment) -or -not (Test-Path $PathSegment)) {
return
}
$currentSegments = @()
if (-not [string]::IsNullOrWhiteSpace($env:PATH)) {
$currentSegments = $env:PATH -split ';'
}
if ($currentSegments -contains $PathSegment) {
return
}
$env:PATH = if ($currentSegments.Count -gt 0) {
"$PathSegment;$env:PATH"
}
( run in 0.525 second using v1.01-cache-2.11-cpan-600a1bdf6e4 )