import { readdirSync } from 'node:fs';
import path from 'node:path';
import process from 'node:process';

import { config as configureEmailTemplates } from '@vue-email/compiler';

export const emailsDir = path.join(process.cwd(), 'components/emails');

export const emailTemplates = configureEmailTemplates(emailsDir, { verbose: false });

export function listEmailTemplates() {
	return readdirSync(emailsDir)
		.filter((file) => file.endsWith('.vue'))
		.map((file) => file.replace(/\.vue$/, ''));
}
