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

config({ path: resolve(__dirname, '../../.env') });

import { NestFactory } from '@nestjs/core';
import { AppModule } from '../app.module';
import { Batch14TestDataSeeder } from '../seed/batch1-4-test-data.seeder';
import { Batch5TestDataSeeder } from '../seed/batch5-test-data.seeder';
import { Batch7TestDataSeeder } from '../seed/batch7-test-data.seeder';
import { Batch8TestDataSeeder } from '../seed/batch8-test-data.seeder';
import { IndodeFacilitySeeder } from '../seed/indode-facility.seeder';
import { PricingDataSeeder } from '../seed/pricing-data.seeder';
import { WarehouseDemoSeeder } from '../seed/warehouse-demo.seeder';

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

  try {
    await app.get(PricingDataSeeder).run();
    await app.get(IndodeFacilitySeeder).run();
    await app.get(Batch14TestDataSeeder).run();
    await app.get(Batch5TestDataSeeder).run();
    await app.get(Batch7TestDataSeeder).run();
    await app.get(Batch8TestDataSeeder).run();
    await app.get(WarehouseDemoSeeder).run();

    console.log('Warehouse demo data seeded.');
  } finally {
    await app.close();
  }
}

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