72 lines
2.5 KiB
PowerShell
72 lines
2.5 KiB
PowerShell
# Build Script dla Ping-Pong Game
|
|
# Minifikuje i obfuskuje kod JavaScript dla produkcji
|
|
# Wymagania: Node.js, npm, javascript-obfuscator
|
|
|
|
Write-Host "🔨 Building Neon Ping-Pong Game..." -ForegroundColor Cyan
|
|
|
|
# Sprawdź czy javascript-obfuscator jest zainstalowany
|
|
$obfuscatorInstalled = Get-Command javascript-obfuscator -ErrorAction SilentlyContinue
|
|
|
|
if (-not $obfuscatorInstalled) {
|
|
Write-Host "⚠️ javascript-obfuscator nie jest zainstalowany." -ForegroundColor Yellow
|
|
Write-Host "Instaluję javascript-obfuscator..." -ForegroundColor Yellow
|
|
npm install -g javascript-obfuscator
|
|
}
|
|
|
|
# Utwórz folder dist jeśli nie istnieje
|
|
$distPath = Join-Path $PSScriptRoot "dist"
|
|
if (-not (Test-Path $distPath)) {
|
|
New-Item -ItemType Directory -Path $distPath | Out-Null
|
|
}
|
|
|
|
$distJsPath = Join-Path $distPath "js"
|
|
if (-not (Test-Path $distJsPath)) {
|
|
New-Item -ItemType Directory -Path $distJsPath | Out-Null
|
|
}
|
|
|
|
# Lista plików do obfuskacji
|
|
$jsFiles = @(
|
|
"js/audio-manager.js",
|
|
"js/bot-ai.js",
|
|
"js/game.js",
|
|
"js/ui-manager.js"
|
|
)
|
|
|
|
Write-Host "📦 Obfuskacja plików JavaScript..." -ForegroundColor Green
|
|
|
|
foreach ($file in $jsFiles) {
|
|
$inputFile = Join-Path $PSScriptRoot $file
|
|
$fileName = Split-Path $file -Leaf
|
|
$outputFile = Join-Path $distJsPath $fileName
|
|
|
|
Write-Host " Processing: $fileName" -ForegroundColor Gray
|
|
|
|
# Obfuskacja z agresywnymi ustawieniami
|
|
javascript-obfuscator $inputFile `
|
|
--output $outputFile `
|
|
--compact true `
|
|
--control-flow-flattening true `
|
|
--control-flow-flattening-threshold 0.75 `
|
|
--dead-code-injection true `
|
|
--dead-code-injection-threshold 0.4 `
|
|
--debug-protection true `
|
|
--debug-protection-interval 2000 `
|
|
--disable-console-output true `
|
|
--identifier-names-generator hexadecimal `
|
|
--log false `
|
|
--rename-globals true `
|
|
--rotate-string-array true `
|
|
--self-defending true `
|
|
--string-array true `
|
|
--string-array-encoding 'rc4' `
|
|
--string-array-threshold 0.75 `
|
|
--transform-object-keys true `
|
|
--unicode-escape-sequence true
|
|
}
|
|
|
|
Write-Host "✅ Build zakończony pomyślnie!" -ForegroundColor Green
|
|
Write-Host "📁 Pliki produkcyjne: $distPath" -ForegroundColor Cyan
|
|
Write-Host ""
|
|
Write-Host "⚠️ WAŻNE: Użyj plików z folderu 'dist' w produkcji!" -ForegroundColor Yellow
|
|
Write-Host " Pliki w 'js/' są tylko do development." -ForegroundColor Yellow
|