diff --git a/scripts/install-core.ps1 b/scripts/install-core.ps1 index 950835b..2d79288 100644 --- a/scripts/install-core.ps1 +++ b/scripts/install-core.ps1 @@ -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" diff --git a/setup.bat b/setup.bat index d728f71..49ca5b4 100644 --- a/setup.bat +++ b/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