functionInitialize-Installation { Write-Log"Verifying 7-Zip installation..."-Level Info if (-not (Test-Path-Path$SevenZipExe)) { throw"7-Zip not found at $SevenZipExe. Please install it at https://www.7-zip.org/ first." } Write-Log"Done."-Level Success
foreach ($Pathin$RootDir, $TmpDir) { Write-Log"Checking and creating directory: $Path."-Level Info New-Directory-Path$Path Write-Log"Done."-Level Success } }
functionInstall-MinGW64 { Write-Log"Configuring MinGW64..."-Level Info
Write-Log"Fetching lastest MinGW64 download link at https://winlibs.com/..."-Level Info $WinlibsResponse = Invoke-WebRequest-Uri"https://winlibs.com/"-UseBasicParsing $MinGW64DownloadLink = ($WinlibsResponse.Links | Where-Object { $_.href -like"*winlibs-x86_64-posix-seh-gcc-*-mingw-w64ucrt-*.zip" } | Select-Object-First1).href
if (-not$MinGW64DownloadLink) { throw"Could not find a valid MinGW64 download link on WinLibs." } Write-Log"Done."-Level Success
$MinGW64ZipFile = Join-Path$TmpDir"mingw64.zip" Write-Log"Downloading MinGW64 to $MinGW64ZipFile at $MinGW64DownloadLink..."-Level Info Invoke-WebRequest-Uri$MinGW64DownloadLink-UseBasicParsing-OutFile$MinGW64ZipFile Write-Log"Done."-Level Success
Write-Log"Extracting MinGW64 to $RootDir\mingw64..."-Level Info & $SevenZipExe x $MinGW64ZipFile-o"$RootDir"-y Write-Log"Done."-Level Success
Write-Log"Configuring environment variables..."-Level Info $MinGW64BinDir = Join-Path$RootDir"mingw64\bin" do { $Confirm = Read-Host"Add $MinGW64BinDir to User Path? (Y/N)" $Confirm = $Confirm.ToUpper() } while ($Confirm-notin@("Y", "N"))
if ($Confirm-eq"Y") { Write-Log"Adding $MinGW64BinDir to User Path..."-Level Warning Add-UserPath-Path$MinGW64BinDir Write-Log"Done."-Level Success } else { Write-Log"Adding was canceled. You may need to manually configure User Path."-Level Warning }
functionInstall-Git { Write-Log"Configuring Git..."-Level Info
Write-Log"Fetching lastest PortableGit download link at https://git-scm.com/install/windows..."-Level Info $GitScmResponse = Invoke-WebRequest-Uri"https://git-scm.com/install/windows"-UseBasicParsing $PortableGitDownloadLink = ($GitScmResponse.Links | Where-Object { $_.href -like"*PortableGit-*-64-bit.7z.exe" } | Select-Object-First1).href
if (-not$PortableGitDownloadLink) { throw"Could not find a valid PortableGit download link." } Write-Log"Done."-Level Success
$PortableGitExeFile = Join-Path$TmpDir"portable-git.exe" Write-Log"Downloading PortableGit to $PortableGitExeFile at $PortableGitDownloadLink..."-Level Info Invoke-WebRequest-Uri$PortableGitDownloadLink-UseBasicParsing-OutFile$PortableGitExeFile Write-Log"Done."-Level Success
$GitDir = Join-Path$RootDir"git" Write-Log"Extracting Git to $GitDir..."-Level Info & $PortableGitExeFile-o$GitDir-y Write-Log"Done."-Level Success Write-Log"YOU NEED TO WAIT A FEW SECONDS AFTER EXTRACTION"-Level Warning
Write-Log"Configuring environment variables..."-Level Info $GitBinDir = Join-Path$GitDir"cmd" do { $Confirm = Read-Host"Add $GitBinDir to User Path? (Y/N)" $Confirm = $Confirm.ToUpper() } while ($Confirm-notin@("Y", "N"))
if ($Confirm-eq"Y") { Write-Log"Adding $GitBinDir to User Path..."-Level Warning Add-UserPath-Path$GitBinDir Write-Log"Done."-Level Success } else { Write-Log"Adding was canceled. You may need to manually configure User Path."-Level Warning }