|
| 1 | +# Variables |
| 2 | +$installDir = "$HOME\.skidfuscator" |
| 3 | +$wrapperDir = "$HOME\AppData\Local\Microsoft\WindowsApps" |
| 4 | +$wrapperPath = "$wrapperDir\skidfuscator.bat" |
| 5 | +$repo = "skidfuscatordev/skidfuscator-java-obfuscator" |
| 6 | +$jarName = "skidfuscator.jar" |
| 7 | + |
| 8 | +# Check for Java |
| 9 | +if (-not (Get-Command java -ErrorAction SilentlyContinue)) { |
| 10 | + Write-Host "Java is required but not installed. Install Java and try again." -ForegroundColor Red |
| 11 | + Exit 1 |
| 12 | +} |
| 13 | + |
| 14 | +# Fetch the latest release URL |
| 15 | +Write-Host "Fetching the latest Skidfuscator release..." |
| 16 | +$releaseData = Invoke-RestMethod -Uri "https://api.github.com/repos/$repo/releases/latest" |
| 17 | +$releaseUrl = $releaseData.assets | Where-Object { $_.name -eq $jarName } | Select-Object -ExpandProperty browser_download_url |
| 18 | + |
| 19 | +if (-not $releaseUrl) { |
| 20 | + Write-Host "Failed to find the latest release. Ensure the repository and asset names are correct." -ForegroundColor Red |
| 21 | + Exit 1 |
| 22 | +} |
| 23 | + |
| 24 | +# Create install directory |
| 25 | +Write-Host "Installing Skidfuscator to $installDir..." |
| 26 | +if (-not (Test-Path -Path $installDir)) { |
| 27 | + New-Item -ItemType Directory -Path $installDir | Out-Null |
| 28 | +} |
| 29 | +Invoke-WebRequest -Uri $releaseUrl -OutFile "$installDir\$jarName" |
| 30 | + |
| 31 | +# Create wrapper script |
| 32 | +Write-Host "Creating wrapper script at $wrapperPath..." |
| 33 | +if (-not (Test-Path -Path $wrapperDir)) { |
| 34 | + New-Item -ItemType Directory -Path $wrapperDir | Out-Null |
| 35 | +} |
| 36 | +$wrapperContent = @" |
| 37 | +@echo off |
| 38 | +java -jar $installDir\$jarName %* |
| 39 | +"@ |
| 40 | +Set-Content -Path $wrapperPath -Value $wrapperContent -Encoding ASCII |
| 41 | + |
| 42 | +# Add wrapper directory to PATH |
| 43 | +Write-Host "Ensuring $wrapperDir is in the system PATH..." |
| 44 | +$envPath = [System.Environment]::GetEnvironmentVariable("Path", [System.EnvironmentVariableTarget]::User) |
| 45 | +if (-not $envPath -like "*$wrapperDir*") { |
| 46 | + Write-Host "Adding $wrapperDir to PATH..." |
| 47 | + [System.Environment]::SetEnvironmentVariable("Path", "$envPath;$wrapperDir", [System.EnvironmentVariableTarget]::User) |
| 48 | +} else { |
| 49 | + Write-Host "$wrapperDir is already in PATH." |
| 50 | +} |
| 51 | + |
| 52 | +Write-Host "Installation complete. Restart your terminal or run 'refreshenv' to update your PATH." |
| 53 | +Write-Host "Run 'skidfuscator --help' to get started." -ForegroundColor Green |
0 commit comments