-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.bat
More file actions
63 lines (52 loc) · 2.19 KB
/
Copy pathinstall.bat
File metadata and controls
63 lines (52 loc) · 2.19 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
@echo off
setlocal enabledelayedexpansion
echo Installing Krait Programming Language (v1.0.0)...
:: Setup Directories
set "KRAIT_DIR=%USERPROFILE%\.krait"
set "BIN_DIR=%KRAIT_DIR%\bin"
set "EXE_PATH=%BIN_DIR%\krait.exe"
if not exist "%BIN_DIR%" (
mkdir "%BIN_DIR%" >nul 2>&1
)
:: Detect System Architecture
set "ASSET_NAME="
if "%PROCESSOR_ARCHITECTURE%"=="ARM64" (
set "ASSET_NAME=krait-windows-arm64.exe"
) else if "%PROCESSOR_ARCHITECTURE%"=="AMD64" (
set "ASSET_NAME=krait-windows-x64.exe"
) else (
echo Error: Unsupported Windows architecture (%PROCESSOR_ARCHITECTURE%).
exit /b 1
)
echo Fetching latest release from KraitDev/Krait (%ASSET_NAME%)...
:: Use PowerShell under the hood to securely grab the download URL from the GitHub API
:: FIXED: Removed the hard-coded [Net.ServicePointManager]::SecurityProtocol line so it automatically uses the best TLS version
set "API_URL=https://api.github.com/repos/KraitDev/Krait/releases/latest"
for /f "delims=" %%I in ('powershell -NoProfile -Command ^
"try { ^
$Release = Invoke-RestMethod -Uri '%API_URL%' -Headers @{'User-Agent'='CMD-Krait-Installer'}; ^
$Url = ($Release.assets | Where-Object { $_.name -eq '%ASSET_NAME%' }).browser_download_url; ^
if ($Url) { Write-Output $Url } ^
} catch { exit 1 }"') do (
set "DOWNLOAD_URL=%%I"
)
if "%DOWNLOAD_URL%"=="" (
echo Error: Could not find binary asset '%ASSET_NAME%' or failed to reach GitHub API.
exit /b 1
)
:: Download the binary using PowerShell
echo Downloading from %DOWNLOAD_URL%...
powershell -NoProfile -Command "Invoke-WebRequest -Uri '%DOWNLOAD_URL%' -OutFile '%EXE_PATH%'"
:: Add to User PATH via PowerShell environment tracking to avoid messy registry hacks
powershell -NoProfile -Command ^
"$UserPath = [Environment]::GetEnvironmentVariable('PATH', 'User'); ^
if ($UserPath -notlike '*%BIN_DIR%*') { ^
$UserPath = $UserPath -replace ';+$', ''; ^
[Environment]::SetEnvironmentVariable('PATH', \"$UserPath;%BIN_DIR%\", 'User'); ^
Write-Output 'Added Krait to your User PATH.' ^
}"
echo.
echo Checkmark Krait installed successfully!
echo Please restart your Command Prompt window and type 'krait'.
echo.
pause