mirror of
https://git.hexahost.dev/smueller/HexaHost-Frontend.git
synced 2026-06-02 05:08:43 +00:00
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
|
#Requires -Version 5.1
|
||||||
<#
|
<#
|
||||||
.SYNOPSIS
|
.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
|
.DESCRIPTION
|
||||||
1. Wechselt auf main und setzt ihn auf den Stand von dev
|
1. Wechselt auf main und setzt ihn auf den Stand von dev
|
||||||
2. Entfernt Kommentare, minifiziert CSS, obfuskiert JavaScript
|
2. Entfernt Kommentare, minifiziert CSS, obfuskiert JavaScript
|
||||||
3. Committet und pusht main (optional)
|
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
|
.PARAMETER Push
|
||||||
Pusht main nach origin (Standard: nur lokaler Commit)
|
Pusht main nach origin (Standard: nur lokaler Commit)
|
||||||
|
|
||||||
.PARAMETER DryRun
|
.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
|
.PARAMETER Message
|
||||||
Commit-Nachricht für den Production-Build
|
Commit-Nachricht fuer den Production-Build
|
||||||
|
|
||||||
.EXAMPLE
|
.EXAMPLE
|
||||||
.\scripts\publish-to-main.ps1
|
.\scripts\publish-to-main.ps1
|
||||||
@@ -45,7 +48,7 @@ function Write-Step([string]$Text) {
|
|||||||
function Ensure-GitClean {
|
function Ensure-GitClean {
|
||||||
$status = git -C $Root status --porcelain
|
$status = git -C $Root status --porcelain
|
||||||
if ($status) {
|
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) {
|
if (-not $AllowDirty) {
|
||||||
Ensure-GitClean
|
Ensure-GitClean
|
||||||
} else {
|
} 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()
|
$OriginalBranch = (git branch --show-current).Trim()
|
||||||
@@ -104,7 +107,7 @@ try {
|
|||||||
$Message = "chore(release): production build $(Get-Date -Format 'yyyy-MM-dd HH:mm')"
|
$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
|
Set-Location $BuildDir
|
||||||
if (-not $DryRun) {
|
if (-not $DryRun) {
|
||||||
& $NpmExe ci --no-fund --no-audit
|
& $NpmExe ci --no-fund --no-audit
|
||||||
@@ -114,8 +117,8 @@ try {
|
|||||||
Write-Step "Wechsle auf main und synchronisiere mit dev"
|
Write-Step "Wechsle auf main und synchronisiere mit dev"
|
||||||
Set-Location $Root
|
Set-Location $Root
|
||||||
if ($DryRun) {
|
if ($DryRun) {
|
||||||
Write-Host "[DryRun] git checkout main"
|
Write-Host '[DryRun] git checkout main'
|
||||||
Write-Host "[DryRun] git reset --hard dev"
|
Write-Host '[DryRun] git reset --hard dev'
|
||||||
} else {
|
} else {
|
||||||
git checkout main
|
git checkout main
|
||||||
git reset --hard dev
|
git reset --hard dev
|
||||||
@@ -124,7 +127,7 @@ try {
|
|||||||
Write-Step "Production-Build (Kommentare entfernen, JS obfuscaten)"
|
Write-Step "Production-Build (Kommentare entfernen, JS obfuscaten)"
|
||||||
Set-Location $BuildDir
|
Set-Location $BuildDir
|
||||||
if ($DryRun) {
|
if ($DryRun) {
|
||||||
Write-Host "[DryRun] npm run build:in-place"
|
Write-Host '[DryRun] npm run build:in-place'
|
||||||
} else {
|
} else {
|
||||||
& $NpmExe run build:in-place
|
& $NpmExe run build:in-place
|
||||||
if ($LASTEXITCODE -ne 0) { throw "Production-Build fehlgeschlagen" }
|
if ($LASTEXITCODE -ne 0) { throw "Production-Build fehlgeschlagen" }
|
||||||
@@ -133,13 +136,13 @@ try {
|
|||||||
Write-Step "Production-Build committen"
|
Write-Step "Production-Build committen"
|
||||||
Set-Location $Root
|
Set-Location $Root
|
||||||
if ($DryRun) {
|
if ($DryRun) {
|
||||||
Write-Host "[DryRun] git add -A"
|
Write-Host '[DryRun] git add -A'
|
||||||
Write-Host "[DryRun] git commit -m `"$Message`""
|
Write-Host ('[DryRun] git commit -m "' + $Message + '"')
|
||||||
} else {
|
} else {
|
||||||
git add -A
|
git add -A
|
||||||
$null = git diff --cached --quiet
|
$null = git diff --cached --quiet
|
||||||
if ($LASTEXITCODE -eq 0) {
|
if ($LASTEXITCODE -eq 0) {
|
||||||
Write-Warning "Keine Build-Änderungen – nichts zu committen."
|
Write-Warning "Keine Build-Aenderungen - nichts zu committen."
|
||||||
} else {
|
} else {
|
||||||
git commit -m $Message
|
git commit -m $Message
|
||||||
}
|
}
|
||||||
@@ -148,7 +151,7 @@ try {
|
|||||||
if ($Push) {
|
if ($Push) {
|
||||||
Write-Step "Push nach origin/main"
|
Write-Step "Push nach origin/main"
|
||||||
if ($DryRun) {
|
if ($DryRun) {
|
||||||
Write-Host "[DryRun] git push origin main"
|
Write-Host '[DryRun] git push origin main'
|
||||||
} else {
|
} else {
|
||||||
git push origin main
|
git push origin main
|
||||||
}
|
}
|
||||||
@@ -156,7 +159,7 @@ try {
|
|||||||
Write-Host "Hinweis: Ohne -Push wurde nur lokal auf main gebaut." -ForegroundColor Yellow
|
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 (-not $DryRun) {
|
||||||
if ([string]::IsNullOrWhiteSpace($OriginalBranch)) {
|
if ([string]::IsNullOrWhiteSpace($OriginalBranch)) {
|
||||||
git checkout dev
|
git checkout dev
|
||||||
@@ -168,12 +171,12 @@ try {
|
|||||||
Write-Host ""
|
Write-Host ""
|
||||||
Write-Host "Production-Release abgeschlossen." -ForegroundColor Green
|
Write-Host "Production-Release abgeschlossen." -ForegroundColor Green
|
||||||
if (-not $Push -and -not $DryRun) {
|
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 {
|
catch {
|
||||||
Write-Host ""
|
Write-Host ""
|
||||||
Write-Host "FEHLER: $($_.Exception.Message)" -ForegroundColor Red
|
Write-Host ('FEHLER: ' + $_.Exception.Message) -ForegroundColor Red
|
||||||
Set-Location $Root
|
Set-Location $Root
|
||||||
if ($OriginalBranch -and -not $DryRun) {
|
if ($OriginalBranch -and -not $DryRun) {
|
||||||
git checkout $OriginalBranch 2>$null
|
git checkout $OriginalBranch 2>$null
|
||||||
|
|||||||
Reference in New Issue
Block a user