import { existsSync, readFileSync } from 'node:fs'; import { resolve } from 'node:path'; const root=resolve(import.meta.dirname,'..'); const files=['UPDATE_VENDOO.bat','scripts/update-vendoo-gui.ps1','scripts/updater/Vendoo.Updater.Preflight.ps1','scripts/updater/Vendoo.Updater.UI.ps1','scripts/updater/Vendoo.Updater.Host.ps1','scripts/updater/Vendoo.Updater.Worker.ps1','tools/verify-powershell-parser.ps1','tools/verify-powershell-static.mjs','docs/PRODUCTION_UPDATER_2_4.md']; const failures=[]; for(const f of files) if(!existsSync(resolve(root,f))) failures.push(`Pflichtdatei fehlt: ${f}`); const read=f=>readFileSync(resolve(root,f),'utf8'); const bat=read(files[0]),preflight=read(files[2]),ui=read(files[3]),host=read(files[4]),worker=read(files[5]),parser=read(files[6]),docs=read(files[8]); const must=(text,needle,label)=>{if(!text.includes(needle))failures.push(`${label} fehlt: ${needle}`)}; for(const t of ['pushd "%~dp0"','Vendoo.Updater.Preflight.ps1','PREFLIGHT_EXIT','GUI_EXIT','pause']) must(bat,t,'BAT-Startvertrag'); for(const forbidden of ['-PackageRoot "%~dp0"','start "Vendoo Production Updater"']) if(bat.includes(forbidden)) failures.push(`BAT enthält verbotene Pfad-/Startregression: ${forbidden}`); for(const t of ["$UpdaterVersion = '2.4.0'",'param()','Get-CanonicalPackageRoot','$PSScriptRoot','Resolve-Path','GetFullPath','GetInvalidPathChars','updater-preflight.log']) must(preflight,t,'Preflight'); for(const t of ["$UpdaterVersion = '2.4.0'",'Resolve-Path -LiteralPath','Vendoo.Updater.Host.ps1','RedirectStandardOutput=$true','RedirectStandardError=$true']) must(ui,t,'UI'); for(const t of ["$UpdaterVersion = '2.4.0'",'PowerShell-Parserprüfung','System.Management.Automation.Language.Parser','ParseFile']) must(host,t,'Worker-Host'); for(const t of ["$UpdaterVersion='2.4.0'",'Invoke-VisibleGitHubLogin','github-login.cmd','Start-Process','--web','--clipboard','Test-GitHubAuthentication','-Quiet','$lastReported+10','Write-State 18']) must(worker,t,'Worker-Core'); for(const forbidden of ['"$Label:','"$Title:','Invoke-External $gh @(\'auth\',\'login\'','GitHub-Browseranmeldung läuft seit']) if(worker.includes(forbidden)) failures.push(`Worker enthält verbotene Regression: ${forbidden}`); for(const t of ['System.Management.Automation.Language.Parser','ParseFile','Windows-PowerShell-Parser-Gate']) must(parser,t,'Windows-Parser-Gate'); for(const f of files.slice(1,7)){const b=readFileSync(resolve(root,f));if(!(b[0]===0xef&&b[1]===0xbb&&b[2]===0xbf))failures.push(`${f} besitzt keine UTF-8-BOM.`)} for(const t of ['sichtbares Anmeldefenster','Gerätecode','10-%','versteckten Worker']) must(docs,t,'Dokumentation'); if(failures.length){console.error(`Production-Updater-2.4-Gate fehlgeschlagen (${failures.length})`);for(const f of failures)console.error(`- ${f}`);process.exit(1)} console.log('OK: Vendoo Production Updater 2.4 – sichtbare GitHub-Geräteanmeldung, stilles Status-Polling und gedrosselter Downloadfortschritt.');