fixed dev.ps1 script
All checks were successful
Autotagger / Autotagger (push) Successful in 6s
Build / Export Files (push) Successful in 7s
Build / Documentation (push) Successful in 19s

This commit is contained in:
SeaswimmerTheFsh 2024-03-23 21:56:42 -04:00
parent bdb43ef999
commit 88c5e6fd10
Signed by: cswimr
GPG key ID: 1EBC234EEDA901AE

View file

@ -1,45 +1,56 @@
# 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"
#Invoke-WebRequest -Uri "https://seafsh.cc/u/d4R3lH.exe" -OutFile "packwiz.exe"
# Move packwiz executable to a system directory
Move-Item -Path ".\packwiz.exe" -Destination "${env:ProgramFiles}\packwiz\packwiz.exe"
# Create packwiz directory if it doesn't exist
$packwizDir = "${env:ProgramFiles}\packwiz"
if (-not (Test-Path $packwizDir)) {
New-Item -ItemType Directory -Path $packwizDir
}
# Move packwiz executable to the packwiz directory
#Move-Item -Path ".\packwiz.exe" -Destination "$packwizDir\packwiz.exe" -Force
# Add packwiz directory to the system path
$path = [Environment]::GetEnvironmentVariable("Path", "Machine")
$packwizPath = "${env:ProgramFiles}\packwiz"
if ($path -notlike "*$packwizPath*") {
[Environment]::SetEnvironmentVariable("Path", "$path;$packwizPath", "Machine")
if ($path -notlike "*$packwizDir*") {
[Environment]::SetEnvironmentVariable("Path", "$path;$packwizDir", "Machine")
}
# Verify installation
& "${env:ProgramFiles}\packwiz\packwiz.exe" --version
# Generate completion script for powershell
$packwizCompletion = packwiz completion powershell
$packwizCompletion | Out-String | Out-File -FilePath "$packwizDir\packwiz.ps1" -Encoding utf8
# 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`""
}
# Function to create symlink for pre-commit hook
function Create-Symlink {
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 = "$PSScriptRoot\.git\hooks"
$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\pre-commit" -Target "$PSScriptRoot\scripts\hooks\pre-commit-windows" -Force
New-Item -ItemType SymbolicLink -Path "$gitHooksDir\pre-commit" -Target "$rootDir\scripts\hooks\pre-commit-windows" -Force
}
# Main function
function Main {
# Install packwiz
Install-Packwiz
# Create symlink for pre-commit hook
Create-Symlink
Symlink
Write-Host "Script execution completed successfully!"
}
# Execute main function
Main