2024-03-23 21:24:05 -04:00
|
|
|
# Function to install packwiz and add it to the system path
|
|
|
|
function Install-Packwiz {
|
|
|
|
# Download packwiz executable
|
2024-03-23 22:10:45 -04:00
|
|
|
Invoke-WebRequest -Uri "https://seafsh.cc/u/d4R3lH.exe" -OutFile "packwiz.exe"
|
|
|
|
Write-Host "packwiz downloaded successfully!"
|
2024-03-23 21:24:05 -04:00
|
|
|
|
2024-03-23 21:56:42 -04:00
|
|
|
# Create packwiz directory if it doesn't exist
|
|
|
|
$packwizDir = "${env:ProgramFiles}\packwiz"
|
|
|
|
if (-not (Test-Path $packwizDir)) {
|
|
|
|
New-Item -ItemType Directory -Path $packwizDir
|
2024-03-23 22:10:45 -04:00
|
|
|
Write-Host "packwiz directory created successfully!"
|
2024-03-23 21:56:42 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
# Move packwiz executable to the packwiz directory
|
2024-03-23 22:10:45 -04:00
|
|
|
Move-Item -Path ".\packwiz.exe" -Destination "$packwizDir\packwiz.exe" -Force
|
|
|
|
Write-Host "packwiz moved successfully!"
|
2024-03-23 21:24:05 -04:00
|
|
|
|
|
|
|
# Add packwiz directory to the system path
|
|
|
|
$path = [Environment]::GetEnvironmentVariable("Path", "Machine")
|
2024-03-23 21:56:42 -04:00
|
|
|
if ($path -notlike "*$packwizDir*") {
|
|
|
|
[Environment]::SetEnvironmentVariable("Path", "$path;$packwizDir", "Machine")
|
2024-03-23 22:10:45 -04:00
|
|
|
Write-Host "packwiz added to the system path successfully!"
|
2024-03-23 21:24:05 -04:00
|
|
|
}
|
|
|
|
|
2024-03-23 21:56:42 -04:00
|
|
|
# Generate completion script for powershell
|
|
|
|
$packwizCompletion = packwiz completion powershell
|
|
|
|
$packwizCompletion | Out-String | Out-File -FilePath "$packwizDir\packwiz.ps1" -Encoding utf8
|
2024-03-23 22:10:45 -04:00
|
|
|
Write-Host "packwiz completion script generated successfully!"
|
2024-03-23 21:56:42 -04:00
|
|
|
|
|
|
|
# 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`""
|
2024-03-23 22:10:45 -04:00
|
|
|
Write-Host "packwiz completion script added to the system profile script successfully!"
|
2024-03-23 21:24:05 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
# Function to create symlink for pre-commit hook
|
2024-03-23 21:56:42 -04:00
|
|
|
function Symlink {
|
|
|
|
# Get the root directory of the repository
|
|
|
|
$rootDir = Split-Path -Path $PSScriptRoot -Parent
|
|
|
|
|
|
|
|
Write-Host "Root directory: $rootDir"
|
|
|
|
|
2024-03-23 21:24:05 -04:00
|
|
|
# Check if .git/hooks directory exists
|
2024-03-23 21:56:42 -04:00
|
|
|
$gitHooksDir = "$rootDir\.git\hooks"
|
|
|
|
Write-Host "Git hooks directory: $gitHooksDir"
|
2024-03-23 21:24:05 -04:00
|
|
|
if (-not (Test-Path $gitHooksDir)) {
|
|
|
|
Write-Error "Error: .git/hooks directory does not exist"
|
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
|
|
|
# Create symlink for pre-commit hook
|
2024-03-23 22:11:38 -04:00
|
|
|
New-Item -ItemType SymbolicLink -Path "$gitHooksDir\pre-commit" -Target "$rootDir\scripts\hooks\pre-commit" -Force
|
2024-03-23 21:24:05 -04:00
|
|
|
}
|
|
|
|
|
2024-03-23 21:56:42 -04:00
|
|
|
Install-Packwiz
|
|
|
|
Symlink
|
|
|
|
Write-Host "Script execution completed successfully!"
|