fix: Windows compatibility for install scripts
- Use Join-Path for reliable path handling in PowerShell - Replace fragile New-TemporaryFile with GetTempPath + GUID - Enable delayed expansion in batch for reliable errorlevel checks - Add call statements for proper subprocess error propagation - Verify core.exe exists before running commands - Update repo reference and build path Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
e7ee34ec5f
commit
86a80ec2e1
2 changed files with 26 additions and 15 deletions
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
$ErrorActionPreference = "Stop"
|
||||
|
||||
$Repo = "Snider/Core"
|
||||
$Repo = "host-uk/core"
|
||||
$InstallDir = "$env:LOCALAPPDATA\Programs\core"
|
||||
|
||||
function Write-Info { Write-Host "[INFO] $args" -ForegroundColor Green }
|
||||
|
|
@ -17,7 +17,7 @@ function Test-Command($cmd) {
|
|||
# Download pre-built binary
|
||||
function Download-Binary {
|
||||
$arch = if ([Environment]::Is64BitOperatingSystem) { "amd64" } else { "386" }
|
||||
$url = "https://github.com/$Repo/releases/latest/download/core-windows-$arch.exe"
|
||||
$url = "https://github.com/$Repo/releases/download/dev/core-windows-$arch.exe"
|
||||
|
||||
Write-Info "Attempting to download pre-built binary..."
|
||||
Write-Info "URL: $url"
|
||||
|
|
@ -39,18 +39,20 @@ function Build-FromSource {
|
|||
Write-Err "Go is required to build from source. Run '.\scripts\install-deps.ps1' first"
|
||||
}
|
||||
|
||||
$tmpdir = New-TemporaryFile | ForEach-Object { Remove-Item $_; New-Item -ItemType Directory -Path $_ }
|
||||
$tmpdir = Join-Path ([System.IO.Path]::GetTempPath()) ([System.Guid]::NewGuid().ToString())
|
||||
New-Item -ItemType Directory -Force -Path $tmpdir | Out-Null
|
||||
|
||||
Write-Info "Cloning $Repo..."
|
||||
git clone --depth 1 "https://github.com/$Repo.git" "$tmpdir\Core"
|
||||
$cloneDir = Join-Path $tmpdir "Core"
|
||||
git clone --depth 1 "https://github.com/$Repo.git" $cloneDir
|
||||
|
||||
Write-Info "Building core CLI..."
|
||||
Push-Location "$tmpdir\Core"
|
||||
go build -o core.exe ./cmd/core
|
||||
Push-Location $cloneDir
|
||||
go build -o core.exe .
|
||||
Pop-Location
|
||||
|
||||
New-Item -ItemType Directory -Force -Path $InstallDir | Out-Null
|
||||
Move-Item "$tmpdir\Core\core.exe" "$InstallDir\core.exe" -Force
|
||||
Move-Item (Join-Path $cloneDir "core.exe") (Join-Path $InstallDir "core.exe") -Force
|
||||
|
||||
Remove-Item -Recurse -Force $tmpdir
|
||||
Write-Info "Built and installed to $InstallDir\core.exe"
|
||||
|
|
|
|||
25
setup.bat
25
setup.bat
|
|
@ -1,13 +1,14 @@
|
|||
@echo off
|
||||
setlocal enabledelayedexpansion
|
||||
REM Quick setup script for Windows
|
||||
REM Run as Administrator: .\setup.bat
|
||||
REM Run as Administrator: setup.bat
|
||||
|
||||
echo === Host UK Developer Workspace Setup ===
|
||||
echo.
|
||||
|
||||
REM Check for admin rights
|
||||
net session >nul 2>&1
|
||||
if %errorlevel% neq 0 (
|
||||
if !errorlevel! neq 0 (
|
||||
echo ERROR: Please run this script as Administrator
|
||||
echo Right-click and select "Run as administrator"
|
||||
pause
|
||||
|
|
@ -16,36 +17,44 @@ if %errorlevel% neq 0 (
|
|||
|
||||
REM Install dependencies
|
||||
echo Installing dependencies...
|
||||
powershell -ExecutionPolicy Bypass -File "%~dp0scripts\install-deps.ps1"
|
||||
if %errorlevel% neq 0 goto :error
|
||||
call powershell -ExecutionPolicy Bypass -File "%~dp0scripts\install-deps.ps1"
|
||||
if !errorlevel! neq 0 goto :error
|
||||
|
||||
REM Install core CLI
|
||||
echo.
|
||||
echo Installing core CLI...
|
||||
powershell -ExecutionPolicy Bypass -File "%~dp0scripts\install-core.ps1"
|
||||
if %errorlevel% neq 0 goto :error
|
||||
call powershell -ExecutionPolicy Bypass -File "%~dp0scripts\install-core.ps1"
|
||||
if !errorlevel! neq 0 goto :error
|
||||
|
||||
REM Refresh PATH
|
||||
set "PATH=%PATH%;%LOCALAPPDATA%\Programs\core"
|
||||
|
||||
REM Verify core.exe exists before running
|
||||
if not exist "%LOCALAPPDATA%\Programs\core\core.exe" (
|
||||
echo ERROR: core.exe not found at %LOCALAPPDATA%\Programs\core\core.exe
|
||||
goto :error
|
||||
)
|
||||
|
||||
REM Run doctor
|
||||
echo.
|
||||
echo === Verifying environment ===
|
||||
core doctor
|
||||
call "%LOCALAPPDATA%\Programs\core\core.exe" doctor
|
||||
|
||||
REM Clone repos
|
||||
echo.
|
||||
echo === Cloning repositories ===
|
||||
core setup
|
||||
call "%LOCALAPPDATA%\Programs\core\core.exe" setup
|
||||
|
||||
echo.
|
||||
echo === Setup complete! ===
|
||||
echo Run 'core health' to check status
|
||||
pause
|
||||
endlocal
|
||||
exit /b 0
|
||||
|
||||
:error
|
||||
echo.
|
||||
echo Setup failed! Check the error above.
|
||||
pause
|
||||
endlocal
|
||||
exit /b 1
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue