-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.ps1
More file actions
77 lines (59 loc) · 2.51 KB
/
install.ps1
File metadata and controls
77 lines (59 loc) · 2.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# Prompd CLI Windows Installer Script
param(
[string]$InstallDir = "$env:LOCALAPPDATA\prompd",
[switch]$AddToPath
)
$ErrorActionPreference = "Stop"
# Configuration
$REPO = "Logikbug/prompt-markdown"
$BINARY_NAME = "prompd.exe"
# Detect architecture
$ARCH = if ([Environment]::Is64BitOperatingSystem) { "amd64" } else { "386" }
Write-Host "🔍 Finding latest release..." -ForegroundColor Cyan
# Get latest release
$LATEST_URL = "https://api.github.com/repos/$REPO/releases/latest"
try {
$releaseInfo = Invoke-RestMethod -Uri $LATEST_URL
$VERSION = $releaseInfo.tag_name
Write-Host "📦 Latest version: $VERSION" -ForegroundColor Green
} catch {
Write-Host "❌ Could not determine latest version" -ForegroundColor Red
exit 1
}
# Download URL
$ARCHIVE_NAME = "prompd-windows-${ARCH}.zip"
$DOWNLOAD_URL = "https://github.com/$REPO/releases/download/$VERSION/$ARCHIVE_NAME"
Write-Host "⬇️ Downloading $ARCHIVE_NAME..." -ForegroundColor Yellow
# Create install directory
if (!(Test-Path $InstallDir)) {
New-Item -ItemType Directory -Path $InstallDir -Force | Out-Null
}
# Create temp directory
$TMP_DIR = New-TemporaryFile | ForEach-Object { Remove-Item $_; New-Item -ItemType Directory -Path $_ }
try {
# Download and extract
$archivePath = Join-Path $TMP_DIR $ARCHIVE_NAME
Invoke-WebRequest -Uri $DOWNLOAD_URL -OutFile $archivePath
Expand-Archive -Path $archivePath -DestinationPath $TMP_DIR -Force
# Install
Write-Host "📦 Installing to $InstallDir..." -ForegroundColor Cyan
$sourceBinary = Join-Path $TMP_DIR "prompd-windows-${ARCH}.exe"
$targetBinary = Join-Path $InstallDir $BINARY_NAME
Copy-Item $sourceBinary $targetBinary -Force
Write-Host "✅ Prompd CLI installed successfully!" -ForegroundColor Green
# Add to PATH if requested
if ($AddToPath) {
$currentPath = [Environment]::GetEnvironmentVariable("PATH", "User")
if ($currentPath -notlike "*$InstallDir*") {
[Environment]::SetEnvironmentVariable("PATH", "$currentPath;$InstallDir", "User")
Write-Host "📝 Added $InstallDir to your PATH" -ForegroundColor Green
Write-Host " Please restart your terminal to use 'prompd' command" -ForegroundColor Yellow
}
} else {
Write-Host " To add to PATH permanently, run with -AddToPath flag" -ForegroundColor Gray
}
Write-Host "🚀 Try: $targetBinary --help" -ForegroundColor Cyan
} finally {
# Cleanup
Remove-Item $TMP_DIR -Recurse -Force
}