import 'reflect-metadata';
import { config } from 'dotenv';
import { resolve } from 'path';

config({ path: resolve(__dirname, '../../.env') });
process.env.SEED_DEMO_BOOKINGS = 'true';

import { NestFactory } from '@nestjs/core';
import { AppModule } from '../app.module';
import { DemoBookingsSeeder } from '../seed/demo-bookings.seeder';

async function main() {
  const app = await NestFactory.createApplicationContext(AppModule, {
    logger: ['error', 'warn', 'log'],
  });

  try {
    const seeder = app.get(DemoBookingsSeeder);
    await seeder.run();
    console.log('Demo train scheduling data seeded successfully.');
  } finally {
    await app.close();
  }
}

main().catch((err) => {
  console.error('Demo scheduling seed failed:', err);
  process.exit(1);
});
