@laiyon/create-wasapi
Version:
CLI to create WhatsApp bot projects with Wasapi and BuilderBot
80 lines (79 loc) • 2.41 kB
JavaScript
import inquirer from "inquirer";
import chalk from "chalk";
// Database choices (DRY principle) - exported for reuse
export const DATABASE_CHOICES = [
{
name: `${chalk.green("💾")} Memory`,
value: "base-ts-wasapi-memory"
},
{
name: `${chalk.blue("📄")} JSON`,
value: "base-ts-wasapi-json",
},
{
name: `${chalk.yellow("🐬")} MySQL`,
value: "base-ts-wasapi-mysql"
},
{
name: `${chalk.cyan("🍃")} MongoDB`,
value: "base-ts-wasapi-mongo",
disabled: chalk.gray("(Coming Soon)")
},
{
name: `${chalk.magenta("🐘")} PostgreSQL`,
value: "base-ts-wasapi-postgresql",
disabled: chalk.gray("(Coming Soon)")
}
];
// Project name question
const PROJECT_NAME_QUESTION = {
type: "input",
name: "projectName",
message: chalk.blue("📁 Project name:"),
default: "wasabot-app"
};
// Database question
const DATABASE_QUESTION = {
type: "list",
name: "dbType",
message: chalk.blue("🗄️ Database:"),
choices: DATABASE_CHOICES,
default: "base-ts-wasapi-memory"
};
export async function runPrompts(projectNameFromArgs) {
// If project name provided via CLI, only ask for database
if (projectNameFromArgs) {
const dbAnswer = await inquirer.prompt([DATABASE_QUESTION]);
return {
projectName: projectNameFromArgs,
dbType: dbAnswer.dbType
};
}
else {
// Ask for both project name and database
return await inquirer.prompt([PROJECT_NAME_QUESTION, DATABASE_QUESTION]);
}
}
export async function askForAutomaticSetup(canAutoSetup) {
if (!canAutoSetup) {
return false; // Can't do automatic setup
}
console.log("");
console.log(chalk.bgGreen.black(" 🚀 AUTOMATIC SETUP "));
console.log("");
console.log(chalk.green(" ✨ Includes:"));
console.log(chalk.gray(" • Package installation"));
console.log(chalk.gray(" • Development server"));
console.log(chalk.gray(" • ngrok tunnel"));
console.log(chalk.gray(" • WhatsApp QR"));
console.log("");
const { autoSetup } = await inquirer.prompt([
{
type: "confirm",
name: "autoSetup",
message: chalk.blue("🚀 Proceed with automatic setup?"),
default: true
}
]);
return autoSetup;
}