-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.ps1
More file actions
68 lines (55 loc) · 2.06 KB
/
install.ps1
File metadata and controls
68 lines (55 loc) · 2.06 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
# devid PowerShell installer
# Usage: irm https://raw.githubusercontent.com/Naly-programming/devid/main/install.ps1 | iex
$ErrorActionPreference = "Stop"
$Repo = "Naly-programming/devid"
$InstallDir = "$env:LOCALAPPDATA\Programs\devid"
# Detect architecture
$Arch = if ([System.Environment]::Is64BitOperatingSystem) {
if ($env:PROCESSOR_ARCHITECTURE -eq "ARM64") { "arm64" } else { "amd64" }
} else {
Write-Error "32-bit Windows is not supported"
exit 1
}
Write-Host "Fetching latest devid version..."
# Get latest version
try {
$Release = Invoke-RestMethod -Uri "https://api.github.com/repos/$Repo/releases/latest"
$Version = $Release.tag_name -replace '^v', ''
} catch {
Write-Error "Failed to fetch latest release: $_"
exit 1
}
Write-Host "Installing devid v$Version (windows/$Arch)..."
# Download
$Url = "https://github.com/$Repo/releases/download/v$Version/devid_${Version}_windows_${Arch}.zip"
$TmpDir = New-Item -ItemType Directory -Path "$env:TEMP\devid-install-$([System.Guid]::NewGuid())" -Force
$ZipPath = Join-Path $TmpDir "devid.zip"
try {
Invoke-WebRequest -Uri $Url -OutFile $ZipPath -UseBasicParsing
} catch {
Write-Error "Download failed: $_"
Remove-Item -Recurse -Force $TmpDir
exit 1
}
# Extract
Expand-Archive -Path $ZipPath -DestinationPath $TmpDir -Force
# Install
New-Item -ItemType Directory -Path $InstallDir -Force | Out-Null
$BinaryPath = Join-Path $TmpDir "devid.exe"
$DestPath = Join-Path $InstallDir "devid.exe"
Copy-Item -Path $BinaryPath -Destination $DestPath -Force
# Cleanup
Remove-Item -Recurse -Force $TmpDir
# Add to PATH if not already there
$UserPath = [Environment]::GetEnvironmentVariable("Path", "User")
if ($UserPath -notlike "*$InstallDir*") {
[Environment]::SetEnvironmentVariable("Path", "$UserPath;$InstallDir", "User")
Write-Host ""
Write-Host "Added $InstallDir to your user PATH."
Write-Host "Restart your terminal for the change to take effect."
}
Write-Host ""
Write-Host "devid v$Version installed to $DestPath"
Write-Host ""
Write-Host "Get started:"
Write-Host " devid init"