Files
vendoo/tools/verify-config-store.mjs
Masterluke77andGitHub 6f48827f4d Vendoo 1.41.2 – Git Ignore Boundary & Module Tracking Hotfix (#18)
* docs: prepare Vendoo 1.41.2 git-ignore boundary hotfix

* fix: track native source modules with root-anchored runtime ignores
2026-07-09 17:09:00 +02:00

24 lines
1.4 KiB
JavaScript

import { mkdtempSync, readFileSync, rmSync, statSync } from 'node:fs';
import { tmpdir } from 'node:os';
import { join } from 'node:path';
const temp = mkdtempSync(join(tmpdir(), 'vendoo-config-store-'));
const path = join(temp, 'config', 'vendoo.env');
process.env.VENDOO_CONFIG_PATH = path;
try {
const mod = await import(`../lib/config-store.mjs?test=${Date.now()}`);
mod.updateRuntimeConfig({ OPENAI_API_KEY: 'test-only-value', PUBLIC_BASE_URL: 'https://vendoo.example.invalid' });
const content = readFileSync(path, 'utf8');
if (!content.includes('OPENAI_API_KEY=test-only-value')) throw new Error('OPENAI_API_KEY wurde nicht gespeichert.');
if (!content.includes('PUBLIC_BASE_URL=https://vendoo.example.invalid')) throw new Error('PUBLIC_BASE_URL wurde nicht gespeichert.');
if (process.env.OPENAI_API_KEY !== 'test-only-value') throw new Error('process.env wurde nicht synchronisiert.');
let rejected = false;
try { mod.updateRuntimeConfig({ SMTP_PASS: 'line1\nline2' }); } catch { rejected = true; }
if (!rejected) throw new Error('Mehrzeiliger Secret-Wert wurde nicht abgelehnt.');
if (process.platform !== 'win32' && (statSync(path).mode & 0o077) !== 0) throw new Error('Konfigurationsdatei ist nicht auf 0600 begrenzt.');
console.log('Konfigurationsspeicher erfolgreich geprüft: persistent, restriktiv und newline-geschützt.');
} finally {
rmSync(temp, { recursive: true, force: true });
}