agno
Version:
Agnostic Migrations and Seeders for Node.js (NPM & NPX support)
46 lines (38 loc) • 1.27 kB
JavaScript
const seeders = require('./seeders');
const prompts = require('prompts');
const args = process.argv.slice(2);
console.log(args);
let type;
let seeder_config = './seeders/seeder.config.js';
(async () => {
if(!type)
type = (await prompts({
type: 'select',
name: 'type',
message: 'What do you want to do?',
choices: [
{ title: 'Migration', value: 'migration' },
{ title: 'Seeder', value: 'seeder' },
],
})).type;
if (type === 'migration') {
throw 'Migrations are not supported yet.';
}
if (type === 'seeder') {
if(!seeder_config)
seeder_config = (await prompts({
type: 'text',
name: 'seeder_config',
message: 'Where\'s located the seeder config.js file',
})).seeder_config;
return await seeders.execute({ config_path: seeder_config })
}
throw 'Invalid options';
})()
.catch(err => console.log(err))
.finally(() => process.exit());
/*
seeders.execute()
.then((inserted) => console.log(`\n\nDatabase Seeded with ${inserted} rows\n\n`))
.catch((err) => console.log("\n\nDatabase Couldnt be seeded, because...\n\n", err, "\n"))
*/