import { readFileSync } from 'node:fs';
import { resolve } from 'node:path';
const root = resolve(import.meta.dirname, '..');
const read = path => readFileSync(resolve(root, path), 'utf8');
const expect = (text, marker, label) => { if (!text.includes(marker)) throw new Error(`Ein-Klick-Updater-Gate: ${label} fehlt (${marker}).`); };
const bat = read('UPDATE_VENDOO.bat');
const ps = read('scripts/update-vendoo.ps1');
const workflow = read('.github/workflows/vendoo-production-deploy.yml');
const docs = read('docs/EIN_KLICK_UPDATE_1_42_0.md');
const legacy = read('GitHub-Deploy-Assistent.bat');
for (const marker of ['scripts\\update-vendoo.ps1','ExecutionPolicy Bypass','pause']) expect(bat, marker, `BAT ${marker}`);
for (const marker of ["TargetVersion = '1.42.0'","Repository = 'Masterluke77/vendoo'",'prepare-git-staging.mjs',"npm.cmd' @('run','verify:all')","pr','create'","pr','merge'",'COOLIFY_DEPLOY_WEBHOOK_URL',"workflow','run",'/readyz']) expect(ps, marker, `PowerShell ${marker}`);
for (const marker of ['workflow_dispatch:','concurrency:','cancel-in-progress: false','secrets.COOLIFY_DEPLOY_WEBHOOK_URL','--request GET','/readyz?','"$version" == "$TARGET_VERSION"','/healthz?']) expect(workflow, marker, `Workflow ${marker}`);
for (const marker of ['UPDATE_VENDOO.bat','npm run verify:all','/app/data','GitHub Actions Secret']) expect(docs, marker, `Dokumentation ${marker}`);
expect(legacy,'UPDATE_VENDOO.bat','Kompatibilitätsstarter');
if (/COOLIFY_DEPLOY_WEBHOOK_URL\s*=\s*https?:\/\//i.test(ps + workflow)) throw new Error('Ein konkreter Coolify-Webhook darf nicht im Source stehen.');
console.log('Ein-Klick-Updater-Gate 1.42.0 erfolgreich.');
