start project
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
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<string, string> {
|
||||
const path = fileURLToPath(new URL('../../../.env', import.meta.url));
|
||||
const text = readFileSync(path, 'utf-8');
|
||||
const values: Record<string, string> = {};
|
||||
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!',
|
||||
};
|
||||
Reference in New Issue
Block a user