Install db driver on init

This commit is contained in:
rijkvanzanten
2020-07-29 14:33:07 -04:00
parent e5200e5199
commit fbb8d54106

View File

@@ -4,6 +4,8 @@ import { databaseQuestions } from './questions';
import { drivers, getDriverForClient } from '../../utils/drivers';
import createEnv from '../../utils/create-env';
import { v4 as uuidV4 } from 'uuid';
import execa from 'execa';
import ora from 'ora';
import argon2 from 'argon2';
@@ -25,20 +27,20 @@ export default async function init(options: Record<string, any>) {
const dbClient = getDriverForClient(client)!;
const spinnerDriver = ora('Installing Database Driver...').start();
await execa('npm', ['install', dbClient, '--production']);
spinnerDriver.stop();
const credentials: Credentials = await inquirer.prompt(
(databaseQuestions[dbClient] as any[]).map((question: Function) =>
question({ client: dbClient, filepath: rootPath })
)
);
console.log(`Installing database...`);
const db = createDBConnection(dbClient, credentials);
await runSeed(db, 'system');
console.log(`Creating the .env file...`);
await createEnv(dbClient, credentials, rootPath);
console.log(`Create your first admin user:`);