UNPKG

@laiyon/create-wasapi

Version:

CLI to create WhatsApp bot projects with Wasapi and BuilderBot

38 lines (37 loc) • 1.75 kB
import inquirer from "inquirer"; import chalk from "chalk"; export async function askToCreateDatabase(dbName, dbType) { console.log(""); console.log(chalk.bgYellow.black(" 🗄️ DATABASE NOT FOUND ")); console.log(""); console.log(chalk.yellow(`The database '${dbName}' does not exist on your ${dbType.toUpperCase()} server.`)); console.log(""); console.log(chalk.blue("Would you like me to create it automatically?")); console.log(chalk.gray("This will create the database with the necessary tables for your WhatsApp bot.")); console.log(""); console.log(chalk.cyan("Benefits of automatic creation:")); console.log(chalk.gray(" • Saves time and manual configuration")); console.log(chalk.gray(" • Ensures proper database structure")); console.log(chalk.gray(" • Ready to use immediately")); console.log(""); const { shouldCreate } = await inquirer.prompt([ { type: "confirm", name: "shouldCreate", message: chalk.blue(`Create database '${dbName}' automatically?`), default: true } ]); if (shouldCreate) { console.log(chalk.green(`\n✅ Database '${dbName}' will be created automatically.`)); console.log(chalk.gray(" This may take a few moments...")); } else { console.log(chalk.yellow(`\n⚠️ Database '${dbName}' will not be created.`)); console.log(chalk.yellow("You'll need to create it manually before the bot can work properly.")); console.log(""); console.log(chalk.cyan("Manual creation command:")); console.log(chalk.gray(` mysql -h localhost -P 3308 -u root -p -e "CREATE DATABASE ${dbName};"`)); } return shouldCreate; }