aboutsummaryrefslogtreecommitdiff
path: root/website
diff options
context:
space:
mode:
Diffstat (limited to 'website')
-rw-r--r--website/index.html2
-rw-r--r--website/install.ps167
2 files changed, 67 insertions, 2 deletions
diff --git a/website/index.html b/website/index.html
index 1a06efc0..b27d3cd6 100644
--- a/website/index.html
+++ b/website/index.html
@@ -175,7 +175,7 @@
<div class="install-card install-card-secondary" aria-label="Windows beta install command">
<span class="prompt">PS&gt;</span>
<code id="windows-install-cmd" class="is-compact"
- >$env:HERDR_CHANNEL="preview"; irm https://herdr.dev/install.ps1 | iex</code
+ >irm https://herdr.dev/install.ps1 | iex</code
>
<button type="button" data-copy-target="windows-install-cmd">Copy</button>
</div>
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) {