From 211d3eb96ae1764b027ed36dc938128254f11675 Mon Sep 17 00:00:00 2001 From: EttyKitty <20323032+EttyKitty@users.noreply.github.com> Date: Fri, 22 May 2026 12:49:02 +0300 Subject: [PATCH 1/2] chore: Refactor gobo script; add config --- .goborc.json | 11 +++++ run_gobo.bat | 17 ------- run_gobo.ps1 | 131 ++++++++++++++++++++++++++------------------------- 3 files changed, 77 insertions(+), 82 deletions(-) create mode 100644 .goborc.json delete mode 100644 run_gobo.bat diff --git a/.goborc.json b/.goborc.json new file mode 100644 index 0000000000..28f4c291eb --- /dev/null +++ b/.goborc.json @@ -0,0 +1,11 @@ +{ + "useTabs": false, + "tabSize": 4, + "verticalStructs": true, + "verticalArrays": true, + "multilineTernary": false, + "blankLineAfterBlocks": false, + "flatExpressions": false, + "explicitUndefined": false, + "multilineArguments": 0 +} diff --git a/run_gobo.bat b/run_gobo.bat deleted file mode 100644 index 1fec000fe0..0000000000 --- a/run_gobo.bat +++ /dev/null @@ -1,17 +0,0 @@ -@echo off - -:: Run the script -powershell -ExecutionPolicy Bypass -File "run_gobo.ps1" - -:: If the exit code is not 0, something went wrong. Pause the window. -if %errorlevel% neq 0 ( - echo. - echo [TERMINATED] The script encountered a fatal error. - pause - exit /b 1 -) else ( - echo. - echo [FINISHED] Press any key to close... - pause >nul - exit /b 0 -) \ No newline at end of file diff --git a/run_gobo.ps1 b/run_gobo.ps1 index ee1d1899bf..a29c069130 100644 --- a/run_gobo.ps1 +++ b/run_gobo.ps1 @@ -3,91 +3,92 @@ $Repo = "EttyKitty/Gobo" $FormatterName = "Gobo" $Formatter = "gobo.exe" $ZipFile = "gobo-windows.zip" -$Exclusions = "extensions|.git|.svn|prefabs" $Extension = "*.gml" -Write-Host "--- Gobo: GML Formatter ---" -ForegroundColor Cyan -Write-Host "" +Clear-Host +Write-Host "=========================================" -ForegroundColor Cyan +Write-Host " Gobo: GML Formatter " -ForegroundColor White +Write-Host "=========================================" -ForegroundColor Cyan +# --- AUTO-UPDATE --- +if (!(Test-Path $Formatter)) { + Write-Host "" + Write-Host "[INFO] Downloading latest release..." -ForegroundColor Yellow + $ApiUrl = "https://api.github.com/repos/$Repo/releases/latest" + $Asset = (Invoke-RestMethod -Uri $ApiUrl).assets | Where-Object { $_.name -like "*windows*.zip" } | Select-Object -First 1 + Invoke-WebRequest -Uri $Asset.browser_download_url -OutFile "temp.zip" + Expand-Archive -Path "temp.zip" -DestinationPath "." -Force + Remove-Item "temp.zip" + Write-Host "[SUCCESS] Formatter ready.`n" -ForegroundColor Green +} + +Write-Host "" Write-Host "[INFO] This script will run $FormatterName on all $Extension files in the project" -ForegroundColor Cyan -Write-Host "[INFO] The following patterns will be excluded: $Exclusions" -ForegroundColor Cyan Write-Host "" pause Write-Host "" -# --- AUTO-UPDATE --- -if (!(Test-Path $Formatter)) { - Write-Host "[INFO] $Formatter not found. Fetching latest release info..." -ForegroundColor Yellow - - try { - $ApiUrl = "https://api.github.com/repos/$Repo/releases/latest" - $ReleaseInfo = Invoke-RestMethod -Uri $ApiUrl -ErrorAction Stop - - $Asset = $ReleaseInfo.assets | Where-Object { $_.name -like "*windows*.zip" } | Select-Object -First 1 - - if ($null -eq $Asset) { throw "Could not find a Windows zip in the latest release." } - - $DownloadUrl = $Asset.browser_download_url - Write-Host "[INFO] Found version $($ReleaseInfo.tag_name). Downloading..." -ForegroundColor Gray - - Invoke-WebRequest -Uri $DownloadUrl -OutFile $ZipFile -ErrorAction Stop - - Write-Host "[INFO] Extracting..." -ForegroundColor Gray - Expand-Archive -Path $ZipFile -DestinationPath "." -Force - Remove-Item $ZipFile - - Write-Host "[SUCCESS] Installed $Formatter (Version: $($ReleaseInfo.tag_name))`n" -ForegroundColor Green - } catch { - Write-Host "`n[FATAL ERROR] Could not setup formatter!" -ForegroundColor Red - Write-Host "Reason: $($_.Exception.Message)" -ForegroundColor White - exit 1 - } -} - -# --- FILE GATHERING --- -Write-Host "[INFO] Gathering files..." -ForegroundColor Cyan +Write-Host "[INFO] Formatting project..." -ForegroundColor Cyan -$Files = Get-ChildItem -Recurse -Filter $Extension | Where-Object { $_.FullName -notmatch $Exclusions } -$Total = $Files.Count -$Count = 0 -$Errors = 0 - -if ($Total -eq 0) { - Write-Host "[WARN] No $Extension files found!" -ForegroundColor Yellow - pause; exit 0 -} +$Stopwatch = [System.Diagnostics.Stopwatch]::StartNew() -Write-Host "[INFO] Found $Total files" -ForegroundColor Cyan +# Run Gobo and capture ALL output (Stdout and Stderr) into an array of strings +$Output = & "./$Formatter" . 2>&1 -# --- PROCESSING --- -Write-Host "[INFO] Formatting..." -ForegroundColor Cyan +$Stopwatch.Stop() -$Stopwatch = [System.Diagnostics.Stopwatch]::StartNew() +# --- PARSE RESULTS --- +$Errors = 0 +$Warnings = 0 +$FilesProcessed = "Unknown" -foreach ($File in $Files) { - $Count++ - $Host.UI.RawUI.WindowTitle = "$($File.Name) [$Count / $Total]" - - # Run the formatter - & "./$Formatter" $File.FullName | Out-Null - - if ($LASTEXITCODE -ne 0) { - Write-Host "[ERROR] Failed on $($File.FullName)" -ForegroundColor Red +foreach ($Line in $Output) { + if ($Line -match "\[Error\]") { + Write-Host $Line -ForegroundColor Red $Errors++ } + elseif ($Line -match "\[Warn\]") { + Write-Host $Line -ForegroundColor Yellow + $Warnings++ + } + else { + Write-Host $Line -ForegroundColor Gray + if ($Line -match "Formatted (\d+) files") { + $FilesProcessed = $Matches[1] + } + } } -$Stopwatch.Stop() - -# --- SUMMARY --- +# --- SUMMARY BLOCK --- $Time = $Stopwatch.Elapsed.ToString("hh\:mm\:ss\.ff") Write-Host "" -Write-Host "[INFO] Formatting Complete!" -ForegroundColor Green -Write-Host "[INFO] Total Processed: $Total" -ForegroundColor Cyan -Write-Host "[INFO] Time Elapsed: $Time" -ForegroundColor Cyan -Write-Host "[INFO] Errors: $Errors" -ForegroundColor $(if ($Errors -gt 0) { "Red" } else { "Cyan" }) +Write-Host "-----------------------------------------" -ForegroundColor Cyan +Write-Host "[SUMMARY] Formatting Complete" -ForegroundColor Green +Write-Host "-----------------------------------------" -ForegroundColor Cyan +Write-Host "Files Processed: $FilesProcessed" -ForegroundColor White +Write-Host "Time Elapsed: $Time" -ForegroundColor White + +if ($Errors -gt 0) { + Write-Host "Errors: $Errors" -ForegroundColor Red +} else { + Write-Host "Errors: 0" -ForegroundColor Green +} + +if ($Warnings -gt 0) { + Write-Host "Warnings: $Warnings" -ForegroundColor Yellow +} + +Write-Host "=========================================" -ForegroundColor Cyan Write-Host "" -pause \ No newline at end of file +if ($LASTEXITCODE -ne 0 -or $Errors -gt 0) { + Write-Host "[TERMINATED] Finished with errors." -ForegroundColor Red + pause + exit 1 +} else { + Write-Host "[SUCCESS] Press any key to close..." -ForegroundColor Green + pause + exit 0 +} From a4ca8c87162c0004c91030444c3d8045f884b0ae Mon Sep 17 00:00:00 2001 From: EttyKitty <20323032+EttyKitty@users.noreply.github.com> Date: Tue, 23 Jun 2026 09:39:33 +0300 Subject: [PATCH 2/2] Cross platform gobo script (I hope) --- run_gobo.ps1 | 64 ++++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 52 insertions(+), 12 deletions(-) diff --git a/run_gobo.ps1 b/run_gobo.ps1 index a29c069130..c8d538460c 100644 --- a/run_gobo.ps1 +++ b/run_gobo.ps1 @@ -1,10 +1,23 @@ # --- CONFIGURATION --- $Repo = "EttyKitty/Gobo" $FormatterName = "Gobo" -$Formatter = "gobo.exe" -$ZipFile = "gobo-windows.zip" $Extension = "*.gml" +# Detect operating system and set platform-specific variables +if ($IsWindows) { + $Formatter = "gobo.exe" + $PlatformKeyword = "windows" +} elseif ($IsLinux) { + $Formatter = "gobo" + $PlatformKeyword = "linux" +} elseif ($IsMacOS) { + $Formatter = "gobo" + $PlatformKeyword = "mac" +} else { + Write-Error "Unsupported operating system." + exit 1 +} + Clear-Host Write-Host "=========================================" -ForegroundColor Cyan Write-Host " Gobo: GML Formatter " -ForegroundColor White @@ -12,13 +25,41 @@ Write-Host "=========================================" -ForegroundColor Cyan # --- AUTO-UPDATE --- if (!(Test-Path $Formatter)) { - Write-Host "" + Write-Host "" Write-Host "[INFO] Downloading latest release..." -ForegroundColor Yellow $ApiUrl = "https://api.github.com/repos/$Repo/releases/latest" - $Asset = (Invoke-RestMethod -Uri $ApiUrl).assets | Where-Object { $_.name -like "*windows*.zip" } | Select-Object -First 1 - Invoke-WebRequest -Uri $Asset.browser_download_url -OutFile "temp.zip" - Expand-Archive -Path "temp.zip" -DestinationPath "." -Force - Remove-Item "temp.zip" + $Assets = (Invoke-RestMethod -Uri $ApiUrl).assets + + # Match asset based on platform keyword + $Asset = $Assets | Where-Object { $_.name -like "*$PlatformKeyword*" } | Select-Object -First 1 + + # Fallback for macOS if asset name uses "osx" instead of "mac" + if (!$Asset -and $IsMacOS) { + $Asset = $Assets | Where-Object { $_.name -like "*osx*" } | Select-Object -First 1 + } + + if (!$Asset) { + Write-Error "Could not find a valid release asset for this platform." + exit 1 + } + + $FileName = $Asset.name + Invoke-WebRequest -Uri $Asset.browser_download_url -OutFile $FileName + + # Handle extraction based on file extension + if ($FileName -like "*.zip") { + Expand-Archive -Path $FileName -DestinationPath "." -Force + } elseif ($FileName -like "*.tar.gz" -or $FileName -like "*.tgz") { + tar -xzf $FileName + } + + Remove-Item $FileName + + # Set execution permissions on Linux and macOS + if (!$IsWindows) { + chmod +x "./$Formatter" + } + Write-Host "[SUCCESS] Formatter ready.`n" -ForegroundColor Green } @@ -26,10 +67,9 @@ Write-Host "" Write-Host "[INFO] This script will run $FormatterName on all $Extension files in the project" -ForegroundColor Cyan Write-Host "" -pause +[void](Read-Host "Press Enter to continue") Write-Host "" - Write-Host "[INFO] Formatting project..." -ForegroundColor Cyan $Stopwatch = [System.Diagnostics.Stopwatch]::StartNew() @@ -85,10 +125,10 @@ Write-Host "" if ($LASTEXITCODE -ne 0 -or $Errors -gt 0) { Write-Host "[TERMINATED] Finished with errors." -ForegroundColor Red - pause + [void](Read-Host "Press Enter to exit") exit 1 } else { - Write-Host "[SUCCESS] Press any key to close..." -ForegroundColor Green - pause + Write-Host "[SUCCESS] Press Enter to close..." -ForegroundColor Green + [void](Read-Host "Press Enter to exit") exit 0 }