Repository navigation
feat: default to prod, fix cross-platform config writes, support Windows installs #54
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
163c187
feat: default to prod, fix cross-platform config writes, support Wind…
jpage-godaddy e02ec98
review: filter persisted env to known values; guard tar in install.sh
jpage-godaddy 66a134f
review: harden Windows install scripts (apostrophe paths, no session …
jpage-godaddy dd9a844
review: include resolved .gdenv path in set_env error
jpage-godaddy 1a4f32e
review: advertise PowerShell installer in alpha release notes
jpage-godaddy 7ff5469
review: default to a user-writable install prefix on Windows
jpage-godaddy 9de751f
review: guard unset LOCALAPPDATA/HOME/USERPROFILE in installers
jpage-godaddy b9ac3ec
review: clarify per-OS default prefix in install.sh --help
jpage-godaddy File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,154 @@ | ||
| <# | ||
| .SYNOPSIS | ||
| gddy installer (Rust-port alpha) for Windows / PowerShell. | ||
|
|
||
| .DESCRIPTION | ||
| Downloads, verifies, and installs the GoDaddy CLI Rust-port ALPHA binary | ||
| (gddy.exe) from the rolling `alpha` GitHub prerelease. | ||
|
|
||
| `gddy` installs alongside the legacy `godaddy` CLI so you can run both. It is | ||
| an experimental build that tracks the tip of `rust-port`; expect breakage. | ||
|
|
||
| macOS/Linux (and Git Bash/MSYS2/Cygwin) users should use install.sh instead. | ||
|
|
||
| .PARAMETER Prefix | ||
| Install directory. Defaults to "$env:LOCALAPPDATA\Programs\gddy". | ||
|
|
||
| .EXAMPLE | ||
| irm https://github.com/godaddy/cli/releases/download/alpha/install.ps1 | iex | ||
|
|
||
| .EXAMPLE | ||
| .\install.ps1 -Prefix "C:\tools\gddy" | ||
| #> | ||
| [CmdletBinding()] | ||
| param( | ||
| [string]$Prefix | ||
| ) | ||
|
jpage-godaddy marked this conversation as resolved.
Resolved
|
||
|
|
||
| Set-StrictMode -Version Latest | ||
| $ErrorActionPreference = 'Stop' | ||
|
|
||
| $Repo = 'godaddy/cli' | ||
| $Tag = 'alpha' | ||
|
|
||
| function Write-Info { param([string]$Message) Write-Host "==> $Message" -ForegroundColor Blue } | ||
| function Write-Warn { param([string]$Message) Write-Host "WARN: $Message" -ForegroundColor Yellow } | ||
| # Use `throw`, not `exit`: the documented invocation is `irm ... | iex`, which | ||
| # runs this script in the caller's session — `exit` would close their terminal. | ||
| function Die { param([string]$Message) Write-Host "ERROR: $Message" -ForegroundColor Red; throw $Message } | ||
|
|
||
| # Resolve the default install dir here (not in the param default) so a missing | ||
| # LOCALAPPDATA can fall back / error cleanly instead of throwing in Join-Path | ||
| # before Die is available. | ||
| if (-not $Prefix) { | ||
| $base = if ($env:LOCALAPPDATA) { $env:LOCALAPPDATA } | ||
| elseif ($env:USERPROFILE) { $env:USERPROFILE } | ||
| else { Die "Cannot determine a default install directory (LOCALAPPDATA and USERPROFILE are both unset). Re-run with -Prefix <dir>." } | ||
| $Prefix = Join-Path $base 'Programs\gddy' | ||
| } | ||
|
|
||
| # Force TLS 1.2 for older PowerShell / .NET defaults. | ||
| try { [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocol]::Tls12 } catch { } | ||
|
|
||
| # ── 1. Detect platform ─────────────────────────────────────────────────────── | ||
|
|
||
| $arch = [System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture.ToString().ToLower() | ||
| switch ($arch) { | ||
| 'x64' { $platform = 'x86_64-pc-windows-msvc' } | ||
| default { | ||
| Die ("Unsupported architecture '$arch'. Only x86_64-pc-windows-msvc is published today. " + | ||
| "Download the matching asset manually from https://github.com/$Repo/releases/tag/$Tag") | ||
| } | ||
| } | ||
|
|
||
| $bin = 'gddy.exe' | ||
| $archive = "gddy-$platform.zip" | ||
| $checksums = 'gddy-checksums-sha256.txt' | ||
| $baseUrl = "https://github.com/$Repo/releases/download/$Tag" | ||
|
|
||
| Write-Info "Detected platform: $platform" | ||
| Write-Info "Installing gddy alpha ($Tag)" | ||
|
|
||
| # ── 2. Download + verify ───────────────────────────────────────────────────── | ||
|
|
||
| $work = Join-Path ([System.IO.Path]::GetTempPath()) ("gddy-" + [System.Guid]::NewGuid().ToString('N')) | ||
| New-Item -ItemType Directory -Path $work -Force | Out-Null | ||
| try { | ||
| $archivePath = Join-Path $work $archive | ||
| $checksumsPath = Join-Path $work $checksums | ||
|
|
||
| Write-Info "Downloading $archive and checksums..." | ||
| try { | ||
| Invoke-WebRequest -Uri "$baseUrl/$archive" -OutFile $archivePath -UseBasicParsing | ||
| } catch { | ||
| Die "Failed to download $archive. Has the $Tag release been published yet?" | ||
| } | ||
| try { | ||
| Invoke-WebRequest -Uri "$baseUrl/$checksums" -OutFile $checksumsPath -UseBasicParsing | ||
| } catch { | ||
| Die "Failed to download $checksums." | ||
| } | ||
|
jpage-godaddy marked this conversation as resolved.
Resolved
|
||
|
|
||
| Write-Info "Verifying checksum..." | ||
| # Each line is "<sha256> <filename>"; match the filename exactly. | ||
| $expected = $null | ||
| foreach ($line in Get-Content $checksumsPath) { | ||
| $parts = $line -split '\s+', 2 | ||
| if ($parts.Count -eq 2 -and $parts[1].Trim() -eq $archive) { | ||
| $expected = $parts[0].Trim().ToLower() | ||
| break | ||
| } | ||
| } | ||
| if (-not $expected) { Die "Checksum for $archive not found in $checksums." } | ||
|
|
||
| $actual = (Get-FileHash -Algorithm SHA256 -LiteralPath $archivePath).Hash.ToLower() | ||
| if ($expected -ne $actual) { | ||
| Die "Checksum mismatch!`n Expected: $expected`n Got: $actual" | ||
| } | ||
| Write-Info "Checksum verified." | ||
|
|
||
| # ── 3. Extract + install ───────────────────────────────────────────────── | ||
|
|
||
| $extractDir = Join-Path $work 'extract' | ||
| New-Item -ItemType Directory -Path $extractDir -Force | Out-Null | ||
| Expand-Archive -LiteralPath $archivePath -DestinationPath $extractDir -Force | ||
|
|
||
| $extractedBin = Join-Path $extractDir $bin | ||
| if (-not (Test-Path -LiteralPath $extractedBin)) { | ||
| Die "Unexpected archive layout — expected a '$bin' binary at the archive root." | ||
| } | ||
|
|
||
| New-Item -ItemType Directory -Path $Prefix -Force | Out-Null | ||
| $destBin = Join-Path $Prefix $bin | ||
| Copy-Item -LiteralPath $extractedBin -Destination $destBin -Force | ||
| Write-Info "Binary installed to $destBin" | ||
|
|
||
| # ── 4. PATH ────────────────────────────────────────────────────────────── | ||
|
|
||
| $userPath = [Environment]::GetEnvironmentVariable('Path', 'User') | ||
| $onPath = ($userPath -split ';' | Where-Object { $_.TrimEnd('\') -ieq $Prefix.TrimEnd('\') }).Count -gt 0 | ||
| if (-not $onPath) { | ||
| $newPath = if ([string]::IsNullOrEmpty($userPath)) { $Prefix } else { "$userPath;$Prefix" } | ||
| [Environment]::SetEnvironmentVariable('Path', $newPath, 'User') | ||
| $env:Path = "$env:Path;$Prefix" # current session | ||
| Write-Info "Added $Prefix to your user PATH (restart your shell for new shells to see it)." | ||
| } | ||
| } finally { | ||
| Remove-Item -Recurse -Force -LiteralPath $work -ErrorAction SilentlyContinue | ||
| } | ||
|
|
||
| # ── 5. Success ──────────────────────────────────────────────────────────────── | ||
|
|
||
| Write-Host "" | ||
| Write-Info "gddy alpha ($Tag) installed successfully!" | ||
| Write-Host "" | ||
| Write-Host " Binary: $(Join-Path $Prefix $bin)" | ||
| Write-Host " Verify: gddy --version" | ||
| Write-Host "" | ||
| Write-Host " Note: this is an experimental Rust-port alpha that installs alongside" | ||
| Write-Host " the current 'godaddy' CLI." | ||
| Write-Host "" | ||
| Write-Host "Share this one-liner with your team:" | ||
| Write-Host "" | ||
| Write-Host " irm https://github.com/$Repo/releases/download/$Tag/install.ps1 | iex" | ||
| Write-Host "" | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.