Update publish-to-main.ps1 for improved clarity and consistency: Corrected German translations for various parameters and messages, ensuring uniformity in language usage. Added AllowDirty parameter to enable handling of uncommitted changes during the production build process.
This commit is contained in:
@@ -1,22 +1,25 @@
|
||||
#Requires -Version 5.1
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Erstellt einen Production-Build und veröffentlicht ihn auf den Branch main.
|
||||
Erstellt einen Production-Build und veroeffentlicht ihn auf den Branch main.
|
||||
|
||||
.DESCRIPTION
|
||||
1. Wechselt auf main und setzt ihn auf den Stand von dev
|
||||
2. Entfernt Kommentare, minifiziert CSS, obfuskiert JavaScript
|
||||
3. Committet und pusht main (optional)
|
||||
4. Wechselt zurück auf dev (Quellcode bleibt unverändert)
|
||||
4. Wechselt zurueck auf dev (Quellcode bleibt unveraendert)
|
||||
|
||||
.PARAMETER Push
|
||||
Pusht main nach origin (Standard: nur lokaler Commit)
|
||||
|
||||
.PARAMETER DryRun
|
||||
Führt Git-Schritte nur simuliert aus (Build wird trotzdem erstellt)
|
||||
Fuehrt Git-Schritte nur simuliert aus (Build wird trotzdem erstellt)
|
||||
|
||||
.PARAMETER AllowDirty
|
||||
Erlaubt uncommittete Aenderungen
|
||||
|
||||
.PARAMETER Message
|
||||
Commit-Nachricht für den Production-Build
|
||||
Commit-Nachricht fuer den Production-Build
|
||||
|
||||
.EXAMPLE
|
||||
.\scripts\publish-to-main.ps1
|
||||
@@ -45,7 +48,7 @@ function Write-Step([string]$Text) {
|
||||
function Ensure-GitClean {
|
||||
$status = git -C $Root status --porcelain
|
||||
if ($status) {
|
||||
throw "Uncommittete Änderungen im Repository. Bitte zuerst committen oder stashen."
|
||||
throw "Uncommittete Aenderungen im Repository. Bitte zuerst committen oder stashen."
|
||||
}
|
||||
}
|
||||
|
||||
@@ -92,7 +95,7 @@ try {
|
||||
if (-not $AllowDirty) {
|
||||
Ensure-GitClean
|
||||
} else {
|
||||
Write-Warning "AllowDirty aktiv – uncommittete Änderungen werden mit veröffentlicht."
|
||||
Write-Warning "AllowDirty aktiv - uncommittete Aenderungen werden mit veroeffentlicht."
|
||||
}
|
||||
|
||||
$OriginalBranch = (git branch --show-current).Trim()
|
||||
@@ -104,7 +107,7 @@ try {
|
||||
$Message = "chore(release): production build $(Get-Date -Format 'yyyy-MM-dd HH:mm')"
|
||||
}
|
||||
|
||||
Write-Step "Installiere Build-Abhängigkeiten"
|
||||
Write-Step "Installiere Build-Abhaengigkeiten"
|
||||
Set-Location $BuildDir
|
||||
if (-not $DryRun) {
|
||||
& $NpmExe ci --no-fund --no-audit
|
||||
@@ -114,8 +117,8 @@ try {
|
||||
Write-Step "Wechsle auf main und synchronisiere mit dev"
|
||||
Set-Location $Root
|
||||
if ($DryRun) {
|
||||
Write-Host "[DryRun] git checkout main"
|
||||
Write-Host "[DryRun] git reset --hard dev"
|
||||
Write-Host '[DryRun] git checkout main'
|
||||
Write-Host '[DryRun] git reset --hard dev'
|
||||
} else {
|
||||
git checkout main
|
||||
git reset --hard dev
|
||||
@@ -124,7 +127,7 @@ try {
|
||||
Write-Step "Production-Build (Kommentare entfernen, JS obfuscaten)"
|
||||
Set-Location $BuildDir
|
||||
if ($DryRun) {
|
||||
Write-Host "[DryRun] npm run build:in-place"
|
||||
Write-Host '[DryRun] npm run build:in-place'
|
||||
} else {
|
||||
& $NpmExe run build:in-place
|
||||
if ($LASTEXITCODE -ne 0) { throw "Production-Build fehlgeschlagen" }
|
||||
@@ -133,13 +136,13 @@ try {
|
||||
Write-Step "Production-Build committen"
|
||||
Set-Location $Root
|
||||
if ($DryRun) {
|
||||
Write-Host "[DryRun] git add -A"
|
||||
Write-Host "[DryRun] git commit -m `"$Message`""
|
||||
Write-Host '[DryRun] git add -A'
|
||||
Write-Host ('[DryRun] git commit -m "' + $Message + '"')
|
||||
} else {
|
||||
git add -A
|
||||
$null = git diff --cached --quiet
|
||||
if ($LASTEXITCODE -eq 0) {
|
||||
Write-Warning "Keine Build-Änderungen – nichts zu committen."
|
||||
Write-Warning "Keine Build-Aenderungen - nichts zu committen."
|
||||
} else {
|
||||
git commit -m $Message
|
||||
}
|
||||
@@ -148,7 +151,7 @@ try {
|
||||
if ($Push) {
|
||||
Write-Step "Push nach origin/main"
|
||||
if ($DryRun) {
|
||||
Write-Host "[DryRun] git push origin main"
|
||||
Write-Host '[DryRun] git push origin main'
|
||||
} else {
|
||||
git push origin main
|
||||
}
|
||||
@@ -156,7 +159,7 @@ try {
|
||||
Write-Host "Hinweis: Ohne -Push wurde nur lokal auf main gebaut." -ForegroundColor Yellow
|
||||
}
|
||||
|
||||
Write-Step "Zurück auf $OriginalBranch"
|
||||
Write-Step "Zurueck auf $OriginalBranch"
|
||||
if (-not $DryRun) {
|
||||
if ([string]::IsNullOrWhiteSpace($OriginalBranch)) {
|
||||
git checkout dev
|
||||
@@ -168,12 +171,12 @@ try {
|
||||
Write-Host ""
|
||||
Write-Host "Production-Release abgeschlossen." -ForegroundColor Green
|
||||
if (-not $Push -and -not $DryRun) {
|
||||
Write-Host "Zum Veröffentlichen: git push origin main" -ForegroundColor Yellow
|
||||
Write-Host "Zum Veroeffentlichen: git push origin main" -ForegroundColor Yellow
|
||||
}
|
||||
}
|
||||
catch {
|
||||
Write-Host ""
|
||||
Write-Host "FEHLER: $($_.Exception.Message)" -ForegroundColor Red
|
||||
Write-Host ('FEHLER: ' + $_.Exception.Message) -ForegroundColor Red
|
||||
Set-Location $Root
|
||||
if ($OriginalBranch -and -not $DryRun) {
|
||||
git checkout $OriginalBranch 2>$null
|
||||
|
||||
Reference in New Issue
Block a user