import { readFileSync } from 'node:fs'; import { fileURLToPath } from 'node:url'; /** * Reads the demo analyst credentials straight out of the repo's `.env` * (created by `make env` from `.env.example`) instead of hard-coding them, so * the e2e suite keeps working if the seeded demo password ever changes. */ function readDotEnv(): Record { const path = fileURLToPath(new URL('../../../.env', import.meta.url)); const text = readFileSync(path, 'utf-8'); const values: Record = {}; for (const line of text.split('\n')) { const match = /^([A-Z0-9_]+)=(.*)$/.exec(line.trim()); const key = match?.[1]; if (key !== undefined) values[key] = match?.[2] ?? ''; } return values; } const env = readDotEnv(); export const DEMO_ANALYST = { email: env.DEMO_ANALYST_EMAIL ?? 'analyst@example.com', password: env.DEMO_ANALYST_PASSWORD ?? 'Analyst-Passw0rd!', };