diff --git a/scripts/install-core.ps1 b/scripts/install-core.ps1 index 2d79288..463cca0 100644 --- a/scripts/install-core.ps1 +++ b/scripts/install-core.ps1 @@ -35,6 +35,9 @@ function Download-Binary { # Build from source function Build-FromSource { + if (-not (Test-Command git)) { + Write-Err "Git is required to build from source. Run '.\scripts\install-deps.ps1' first" + } if (-not (Test-Command go)) { Write-Err "Go is required to build from source. Run '.\scripts\install-deps.ps1' first" } @@ -42,20 +45,32 @@ function Build-FromSource { $tmpdir = Join-Path ([System.IO.Path]::GetTempPath()) ([System.Guid]::NewGuid().ToString()) New-Item -ItemType Directory -Force -Path $tmpdir | Out-Null - Write-Info "Cloning $Repo..." - $cloneDir = Join-Path $tmpdir "Core" - git clone --depth 1 "https://github.com/$Repo.git" $cloneDir + try { + Write-Info "Cloning $Repo..." + $cloneDir = Join-Path $tmpdir "Core" + git clone --depth 1 "https://github.com/$Repo.git" $cloneDir + if ($LASTEXITCODE -ne 0) { + Write-Err "Failed to clone repository" + } - Write-Info "Building core CLI..." - Push-Location $cloneDir - go build -o core.exe . - Pop-Location + Write-Info "Building core CLI..." + Push-Location $cloneDir + go build -o core.exe . + if ($LASTEXITCODE -ne 0) { + Pop-Location + Write-Err "Go build failed" + } + Pop-Location - New-Item -ItemType Directory -Force -Path $InstallDir | Out-Null - Move-Item (Join-Path $cloneDir "core.exe") (Join-Path $InstallDir "core.exe") -Force + New-Item -ItemType Directory -Force -Path $InstallDir | Out-Null + 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" + Write-Info "Built and installed to $InstallDir\core.exe" + } finally { + if (Test-Path $tmpdir) { + Remove-Item -Recurse -Force $tmpdir -ErrorAction SilentlyContinue + } + } } # Add to PATH diff --git a/setup.bat b/setup.bat index 49ca5b4..df65fa8 100644 --- a/setup.bat +++ b/setup.bat @@ -39,11 +39,15 @@ REM Run doctor echo. echo === Verifying environment === call "%LOCALAPPDATA%\Programs\core\core.exe" doctor +if !errorlevel! neq 0 ( + echo WARNING: core doctor reported issues +) REM Clone repos echo. echo === Cloning repositories === call "%LOCALAPPDATA%\Programs\core\core.exe" setup +if !errorlevel! neq 0 goto :error echo. echo === Setup complete! ===