# Function to install packwiz and add it to the system path function Install-Packwiz { # Download packwiz executable Invoke-WebRequest -Uri "https://seafsh.cc/u/d4R3lH.exe" -OutFile "packwiz.exe" Write-Host "packwiz downloaded successfully!" # Create packwiz directory if it doesn't exist $packwizDir = "${env:ProgramFiles}\packwiz" if (-not (Test-Path $packwizDir)) { New-Item -ItemType Directory -Path $packwizDir Write-Host "packwiz directory created successfully!" } # Move packwiz executable to the packwiz directory Move-Item -Path ".\packwiz.exe" -Destination "$packwizDir\packwiz.exe" -Force Write-Host "packwiz moved successfully!" # Add packwiz directory to the system path $path = [Environment]::GetEnvironmentVariable("Path", "Machine") if ($path -notlike "*$packwizDir*") { [Environment]::SetEnvironmentVariable("Path", "$path;$packwizDir", "Machine") Write-Host "packwiz added to the system path successfully!" } # Generate completion script for powershell $packwizCompletion = packwiz completion powershell $packwizCompletion | Out-String | Out-File -FilePath "$packwizDir\packwiz.ps1" -Encoding utf8 Write-Host "packwiz completion script generated successfully!" # Define the path to the system PowerShell profile script $systemProfilePath = "${env:SystemRoot}\System32\WindowsPowerShell\v1.0\profile.ps1" # Check if the system profile script exists if (-not (Test-Path $systemProfilePath)) { Write-Host "System profile script not found. Creating a new one..." New-Item -Path $systemProfilePath -ItemType File | Out-Null } Add-Content -Path $systemProfilePath -Value ". `"$packwizDir\packwiz.ps1`"" Write-Host "packwiz completion script added to the system profile script successfully!" } # Function to create symlink for pre-commit hook function Symlink { # Get the root directory of the repository $rootDir = Split-Path -Path $PSScriptRoot -Parent Write-Host "Root directory: $rootDir" # Check if .git/hooks directory exists $gitHooksDir = "$rootDir\.git\hooks" Write-Host "Git hooks directory: $gitHooksDir" if (-not (Test-Path $gitHooksDir)) { Write-Error "Error: .git/hooks directory does not exist" exit 1 } # Create symlink for pre-commit hook New-Item -ItemType SymbolicLink -Path "$gitHooksDir\post-commit" -Target "$rootDir\scripts\hooks\post-commit" -Force } Install-Packwiz Symlink Write-Host "Script execution completed successfully!"