added nodejs to setup

This commit is contained in:
duffyduck 2026-04-03 09:52:06 +02:00
parent bb7d9b7a7d
commit c303461330
1 changed files with 63 additions and 6 deletions

View File

@ -100,13 +100,70 @@ function Import-StarfaceCert($host_, $port_) {
Write-Header "Starface Outlook Sync - Setup"
# Node.js prüfen
# Node.js prüfen und ggf. installieren
if (-not (Test-NodeJs)) {
Write-Err "Node.js ist nicht installiert."
Write-Host " Bitte installieren Sie Node.js von https://nodejs.org/" -ForegroundColor Yellow
Write-Host " (LTS-Version empfohlen)" -ForegroundColor Yellow
Read-Host "Eingabetaste zum Beenden"
exit 1
Write-Warn "Node.js ist nicht installiert."
Write-Host " Node.js wird für den lokalen Webserver benötigt." -ForegroundColor Gray
Write-Host ""
$installNode = Read-Host "Node.js jetzt automatisch herunterladen und installieren? (j/n)"
if ($installNode -eq "j") {
Write-Step "Ermittle System-Architektur ..."
$arch = if ([Environment]::Is64BitOperatingSystem) { "x64" } else { "x86" }
$nodeVersion = "v22.14.0" # LTS
$msiUrl = "https://nodejs.org/dist/$nodeVersion/node-$nodeVersion-$arch.msi"
$msiPath = Join-Path $env:TEMP "node-$nodeVersion-$arch.msi"
Write-Step "Lade Node.js $nodeVersion ($arch) herunter ..."
Write-Host " $msiUrl" -ForegroundColor Gray
try {
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
$ProgressPreference = 'SilentlyContinue' # Beschleunigt den Download
Invoke-WebRequest -Uri $msiUrl -OutFile $msiPath -UseBasicParsing
if (-not (Test-Path $msiPath)) {
Write-Err "Download fehlgeschlagen."
exit 1
}
$fileSize = [math]::Round((Get-Item $msiPath).Length / 1MB, 1)
Write-Step "Download abgeschlossen ($fileSize MB)"
Write-Step "Installiere Node.js (bitte warten) ..."
$msiArgs = "/i `"$msiPath`" /qn /norestart"
$process = Start-Process -FilePath "msiexec.exe" -ArgumentList $msiArgs -Wait -PassThru
if ($process.ExitCode -ne 0) {
Write-Err "Installation fehlgeschlagen (Exit-Code: $($process.ExitCode))"
Write-Host " Bitte Node.js manuell installieren: https://nodejs.org/" -ForegroundColor Yellow
exit 1
}
# PATH aktualisieren (MSI fügt Node.js zum System-PATH hinzu)
$env:Path = [System.Environment]::GetEnvironmentVariable("Path", "Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path", "User")
# Aufräumen
Remove-Item $msiPath -Force -ErrorAction SilentlyContinue
if (Test-NodeJs) {
Write-Step "Node.js erfolgreich installiert!"
} else {
Write-Err "Node.js wurde installiert, ist aber nicht im PATH gefunden."
Write-Host " Bitte das Setup nach einem Neustart erneut ausführen." -ForegroundColor Yellow
exit 1
}
} catch {
Write-Err "Fehler beim Download/Installation: $_"
Write-Host " Bitte Node.js manuell installieren: https://nodejs.org/" -ForegroundColor Yellow
exit 1
}
} else {
Write-Host " Bitte Node.js manuell installieren: https://nodejs.org/" -ForegroundColor Yellow
Write-Host " (LTS-Version empfohlen)" -ForegroundColor Yellow
Read-Host "Eingabetaste zum Beenden"
exit 1
}
}
# ============================================================