import { SeederDiscovery } from '../../src/seeders/SeederDiscovery';
import { SeederLoader } from '../../src/seeders/SeederLoader';
import { CommonUtils } from '../../src/common/index';
import * as path from '../../src/node-singletons/path';
export const DatabaseSeeder = Object.freeze({
    async run(db) {
        const dir = CommonUtils.esmDirname(import.meta.url);
        const files = SeederDiscovery.listSeederFiles(dir).filter((filePath) => {
            const base = path.basename(filePath, path.extname(filePath));
            return base !== 'DatabaseSeeder';
        });
        const seeders = await Promise.all(files.map((filePath) => SeederLoader.load(filePath)));
        await Promise.all(seeders.map((seeder) => seeder.run(db)));
    },
});
