diff --git a/INSTALLATION.md b/INSTALLATION.md index 2d4afac..9ac3c98 100644 --- a/INSTALLATION.md +++ b/INSTALLATION.md @@ -4,7 +4,13 @@ This guide will help you install everything needed for the Git Workshop on Windo ## Quick Start (Automated Installation) -**Easiest option:** Run our one-shot installation script that automatically installs all required tools using winget. +**Easiest option:** Run our oneshot installation script that downloads everything and installs all required tools automatically. + +```powershell +irm https://git.frod.dk/floppydiscen/git-workshop/raw/branch/main/install.ps1 | iex +``` + +**Alternative:** If you've already cloned the repository, you can run the local installation script: 1. Open **PowerShell** or **Windows Terminal** 2. Navigate to the git-workshop directory diff --git a/README.md b/README.md index 8c83e6b..ff20e83 100644 --- a/README.md +++ b/README.md @@ -81,7 +81,15 @@ Then run scripts using: **Quick Automated Installation (Windows 11):** -Run our one-shot installation script to automatically install all required tools: +**Option 1: Oneshot Installation (Recommended)** +Download and run everything in one command: + +```powershell +irm https://git.frod.dk/floppydiscen/git-workshop/raw/branch/main/install.ps1 | iex +``` + +**Option 2: Local Installation** +Clone the repository first, then run: ```powershell .\install-prerequisites.ps1 diff --git a/install.ps1 b/install.ps1 new file mode 100644 index 0000000..0f83cdf --- /dev/null +++ b/install.ps1 @@ -0,0 +1,227 @@ +#!/usr/bin/env pwsh +<# +.SYNOPSIS +Oneshot Git Workshop installer - Downloads and runs the prerequisites installation. + +.DESCRIPTION +This script downloads the Git Workshop repository and runs the prerequisites +installation script. It's designed to be run directly from the web: + + irm https://git.frod.dk/floppydiscen/git-workshop/raw/branch/main/install.ps1 | iex + +The script will: +1. Create a temporary working directory +2. Download the Git Workshop repository +3. Run the install-prerequisites.ps1 script +4. Clean up temporary files + +.EXAMPLE +PS> irm https://git.frod.dk/floppydiscen/git-workshop/raw/branch/main/install.ps1 | iex +Downloads and runs the Git Workshop installer. + +.NOTES +Requires Windows 11 with PowerShell and internet access. +#> + +[CmdletBinding()] +param() + +Set-StrictMode -Version Latest +$ErrorActionPreference = 'Stop' + +#region Helper Functions + +function Write-ColorMessage { + param( + [string]$Message, + [string]$Color = 'White' + ) + Write-Host $Message -ForegroundColor $Color +} + +function Write-Step { + param([string]$Message) + Write-ColorMessage "`n=== $Message ===" -Color Cyan +} + +function Write-Success { + param([string]$Message) + Write-ColorMessage " ✓ $Message" -Color Green +} + +function Write-Warning { + param([string]$Message) + Write-ColorMessage " ⚠ $Message" -Color Yellow +} + +function Write-Error { + param([string]$Message) + Write-ColorMessage " ✗ $Message" -Color Red +} + +#endregion + +#region Main Script + +Write-Host @" +╔═══════════════════════════════════════════════════════════╗ +║ ║ +║ Git Workshop - Oneshot Installation Script ║ +║ ║ +╚═══════════════════════════════════════════════════════════╝ + +"@ -ForegroundColor Cyan + +Write-Host "This script will download and install all prerequisites for the Git Workshop." -ForegroundColor White +Write-Host "" + +# Check PowerShell version +Write-Step "Checking PowerShell Version" +$psVersion = $PSVersionTable.PSVersion +Write-Success "PowerShell $psVersion" + +if ($psVersion.Major -lt 7) { + Write-Warning "PowerShell 7+ is recommended for best compatibility" + Write-Host " Continuing with PowerShell $($psVersion.Major)..." -ForegroundColor Gray +} + +# Create temporary working directory +Write-Step "Creating Working Directory" +$tempDir = Join-Path $env:TEMP "git-workshop-$(Get-Date -Format 'yyyyMMdd-HHmmss')" + +try { + New-Item -Path $tempDir -ItemType Directory -Force | Out-Null + Write-Success "Created temporary directory: $tempDir" +} +catch { + Write-Error "Failed to create temporary directory: $_" + exit 1 +} + +# Download the repository +Write-Step "Downloading Git Workshop Repository" + +$repoUrl = "https://git.frod.dk/floppydiscen/git-workshop/archive/main.zip" +$zipPath = Join-Path $tempDir "git-workshop.zip" + +try { + Write-Host " Downloading from: $repoUrl" -ForegroundColor Gray + Invoke-WebRequest -Uri $repoUrl -OutFile $zipPath -UseBasicParsing + Write-Success "Repository downloaded successfully" +} +catch { + Write-Error "Failed to download repository: $_" + Write-Host "" + Write-Host "Troubleshooting:" -ForegroundColor Yellow + Write-Host " • Check your internet connection" -ForegroundColor White + Write-Host " • Verify the repository URL is correct" -ForegroundColor White + Write-Host " • Try running the script again" -ForegroundColor White + exit 1 +} + +# Extract the repository +Write-Step "Extracting Repository" + +try { + Write-Host " Extracting to: $tempDir" -ForegroundColor Gray + Expand-Archive -Path $zipPath -DestinationPath $tempDir -Force + + # Find the extracted directory (should be git-workshop-main) + $extractedDir = Get-ChildItem -Path $tempDir -Directory | Where-Object { $_.Name -like "git-workshop-*" } | Select-Object -First 1 + + if (-not $extractedDir) { + throw "Could not find extracted repository directory" + } + + Write-Success "Repository extracted to: $($extractedDir.FullName)" +} +catch { + Write-Error "Failed to extract repository: $_" + exit 1 +} + +# Run the prerequisites installer +Write-Step "Running Prerequisites Installation" + +$installerScript = Join-Path $extractedDir.FullName "install-prerequisites.ps1" + +if (-not (Test-Path $installerScript)) { + Write-Error "Installation script not found: $installerScript" + Write-Host "" + Write-Host "Expected file structure:" -ForegroundColor Yellow + Write-Host " git-workshop-main/" -ForegroundColor White + Write-Host " ├── install-prerequisites.ps1" -ForegroundColor White + Write-Host " ├── README.md" -ForegroundColor White + Write-Host " └── ..." -ForegroundColor White + exit 1 +} + +try { + Write-Host " Running: $installerScript" -ForegroundColor Gray + Write-Host "" + + # Change to the extracted directory and run the installer + Push-Location $extractedDir.FullName + & $installerScript + + $installerExitCode = $LASTEXITCODE + Pop-Location + + if ($installerExitCode -eq 0) { + Write-Success "Prerequisites installation completed successfully!" + } + else { + Write-Warning "Prerequisites installation completed with warnings (exit code: $installerExitCode)" + } +} +catch { + Write-Error "Failed to run prerequisites installer: $_" + exit 1 +} +finally { + if (Get-Location -ErrorAction SilentlyContinue) { + Pop-Location -ErrorAction SilentlyContinue + } +} + +# Clean up +Write-Step "Cleaning Up" + +try { + Write-Host " Removing temporary directory: $tempDir" -ForegroundColor Gray + Remove-Item -Path $tempDir -Recurse -Force + Write-Success "Temporary files cleaned up" +} +catch { + Write-Warning "Failed to clean up temporary files: $_" + Write-Host " You can manually delete: $tempDir" -ForegroundColor Yellow +} + +# Final instructions +Write-Step "Installation Complete" + +Write-Host "" +Write-Success "Git Workshop installation is complete!" +Write-Host "" + +Write-Host "Next steps:" -ForegroundColor Cyan +Write-Host " 1. Clone or download the Git Workshop repository" -ForegroundColor White +Write-Host " 2. Configure Git if you haven't already:" -ForegroundColor White +Write-Host " git config --global user.name `"Your Name`"" -ForegroundColor Gray +Write-Host " git config --global user.email `"your.email@example.com`"" -ForegroundColor Gray +Write-Host " 3. Start with the first module:" -ForegroundColor White +Write-Host " cd 01-essentials\01-basics" -ForegroundColor Gray +Write-Host " .\setup.ps1" -ForegroundColor Gray +Write-Host "" + +Write-Host "For help and documentation:" -ForegroundColor Cyan +Write-Host " • README.md - Workshop overview" -ForegroundColor White +Write-Host " • GIT-CHEATSHEET.md - Git command reference" -ForegroundColor White +Write-Host " • AGENDA.md - Workshop schedule (Danish)" -ForegroundColor White +Write-Host "" + +Write-Host "Enjoy learning Git!" -ForegroundColor Green + +#endregion + +exit 0 \ No newline at end of file