diff options
| author | Ogulcan Celik <ogulcancelik@gmail.com> | 2026-06-07 21:53:59 +0300 |
|---|---|---|
| committer | Ogulcan Celik <ogulcancelik@gmail.com> | 2026-06-07 21:54:29 +0300 |
| commit | 6f459691056b68c2c99d8341b5f8dd4b811a53c1 (patch) | |
| tree | 24c780f3813945feef4c0b48be1645ac22067691 /website/install.ps1 | |
| parent | 0a635a3fc1e971030079945a447c73e2b24489f8 (diff) | |
fix(update): keep windows installs on preview
Diffstat (limited to 'website/install.ps1')
| -rw-r--r-- | website/install.ps1 | 67 |
1 files changed, 66 insertions, 1 deletions
diff --git a/website/install.ps1 b/website/install.ps1 index d07a5f1c..ca22974f 100644 --- a/website/install.ps1 +++ b/website/install.ps1 @@ -12,7 +12,7 @@ $ErrorActionPreference = "Stop" $ProgressPreference = "SilentlyContinue" if ([string]::IsNullOrWhiteSpace($Channel)) { - $Channel = "stable" + $Channel = "preview" } function Write-Step { @@ -283,6 +283,64 @@ function Resolve-HerdrVersion { return [string]$Manifest.version } +function Get-HerdrConfigPath { + if (-not [string]::IsNullOrWhiteSpace($env:HERDR_CONFIG_PATH)) { + return $env:HERDR_CONFIG_PATH + } + + $appDir = "herdr" + if (-not [string]::IsNullOrWhiteSpace($env:XDG_CONFIG_HOME)) { + return Join-Path (Join-Path $env:XDG_CONFIG_HOME $appDir) "config.toml" + } + if (-not [string]::IsNullOrWhiteSpace($env:APPDATA)) { + return Join-Path (Join-Path $env:APPDATA $appDir) "config.toml" + } + if (-not [string]::IsNullOrWhiteSpace($env:USERPROFILE)) { + return Join-Path (Join-Path (Join-Path (Join-Path $env:USERPROFILE "AppData") "Roaming") $appDir) "config.toml" + } + if (-not [string]::IsNullOrWhiteSpace($env:HOME)) { + return Join-Path (Join-Path (Join-Path $env:HOME ".config") $appDir) "config.toml" + } + + return Join-Path (Join-Path ([System.IO.Path]::GetTempPath()) $appDir) "config.toml" +} + +function Set-HerdrUpdateChannelConfig { + param([string]$SelectedChannel) + + $configPath = Get-HerdrConfigPath + $configDir = Split-Path -Parent $configPath + if (-not [string]::IsNullOrWhiteSpace($configDir)) { + New-Item -ItemType Directory -Force -Path $configDir | Out-Null + } + + $content = if (Test-Path -LiteralPath $configPath -PathType Leaf) { + Get-Content -LiteralPath $configPath -Raw + } else { + "" + } + + $valueLine = "channel = `"$SelectedChannel`"" + $match = [regex]::Match($content, "(?ms)^(\s*\[update\]\s*)(.*?)(?=^\s*\[|\z)") + if ($match.Success) { + $body = $match.Groups[2].Value + if ($body -match "(?m)^\s*channel\s*=") { + $updatedBody = [regex]::Replace($body, "(?m)^\s*channel\s*=.*$", $valueLine, 1) + } else { + $updatedBody = $body.TrimEnd() + "`r`n$valueLine`r`n" + } + $bodyStart = $match.Groups[2].Index + $updated = $content.Substring(0, $bodyStart) + $updatedBody + $content.Substring($bodyStart + $body.Length) + } elseif ([string]::IsNullOrWhiteSpace($content)) { + $updated = "[update]`r`n$valueLine`r`n" + } else { + $updated = $content.TrimEnd() + "`r`n`r`n[update]`r`n$valueLine`r`n" + } + + Set-Content -LiteralPath $configPath -Value $updated -NoNewline + Write-Step "Herdr update channel set to $SelectedChannel in $configPath." +} + if ($env:OS -ne "Windows_NT") { Write-Error "install.ps1 supports Windows only. Use install.sh on Linux or macOS." exit 1 @@ -293,6 +351,11 @@ if (-not [Environment]::Is64BitOperatingSystem) { exit 1 } +if ($Channel -eq "stable") { + Write-Error "Windows builds are preview-only for now. Omit -Channel or use -Channel preview." + exit 1 +} + $architecture = [System.Runtime.InteropServices.RuntimeInformation,mscorlib]::OSArchitecture.ToString() switch ($architecture) { "X64" { @@ -383,6 +446,8 @@ try { Remove-Item -LiteralPath $tempDir -Recurse -Force -ErrorAction SilentlyContinue } +Set-HerdrUpdateChannelConfig -SelectedChannel $Channel + $userPath = [Environment]::GetEnvironmentVariable("Path", "User") $newUserPath = Prepend-PathEntry -PathValue $userPath -Entry $visibleBinDir if ($newUserPath -cne $userPath) { |
