Files
Brogether/scripts/install-local.ps1
2026-05-23 00:52:54 +02:00

42 lines
2.0 KiB
PowerShell

param(
[string]$BrotatoDir = "C:\Program Files (x86)\Steam\steamapps\common\Brotato",
[string]$WorkshopItemId = "",
[string]$Version = "0.1.0"
)
$ErrorActionPreference = "Stop"
$root = Split-Path -Parent $PSScriptRoot
$packageScript = Join-Path $PSScriptRoot "package.ps1"
$zipPath = Join-Path $root "dist\Brogether-Brogether-$Version.zip"
$legacyModsDir = Join-Path $BrotatoDir "mods"
$steamAppsDir = Split-Path -Parent (Split-Path -Parent $BrotatoDir)
$workshopContentDir = Join-Path $steamAppsDir "workshop\content\1942280"
& $packageScript -Version $Version
if (-not (Test-Path $workshopContentDir)) {
throw "Workshop content folder not found: $workshopContentDir"
}
if ([string]::IsNullOrWhiteSpace($WorkshopItemId)) {
$workshopItem = Get-ChildItem -Path $workshopContentDir -Directory |
Where-Object { $_.Name -match '^\d+$' } |
Select-Object -First 1
if ($null -eq $workshopItem) {
throw "No subscribed Brotato workshop folder found in $workshopContentDir. Subscribe to any Brotato workshop mod once, then rerun this script."
}
} else {
$workshopItem = Get-Item -LiteralPath (Join-Path $workshopContentDir $WorkshopItemId) -ErrorAction Stop
}
Get-ChildItem -Path $workshopContentDir -Recurse -Filter "Brogether-Brogether-*.zip" -ErrorAction SilentlyContinue | Remove-Item -Force
Get-ChildItem -Path $workshopContentDir -Recurse -Filter "PotatoConnect-PotatoConnect-*.zip" -ErrorAction SilentlyContinue | Remove-Item -Force
Get-ChildItem -Path $legacyModsDir -Filter "Brogether-Brogether-*.zip" -ErrorAction SilentlyContinue | Remove-Item -Force
Get-ChildItem -Path $legacyModsDir -Filter "PotatoConnect-PotatoConnect-*.zip" -ErrorAction SilentlyContinue | Remove-Item -Force
Copy-Item -LiteralPath $zipPath -Destination (Join-Path $workshopItem.FullName (Split-Path -Leaf $zipPath)) -Force
Write-Host "Installed to workshop item folder $($workshopItem.FullName)"
Write-Host "Start Brotato from Steam, then open BROGETHER in the main menu or press F5."