veko
Version:
š Ultra-modern Node.js framework with hot reload, plugins, authentication, and advanced security features
111 lines (98 loc) ⢠3.33 kB
JavaScript
const chalk = require('chalk');
const inquirer = require('inquirer');
const { createSpinner } = require('nanospinner');
class QuickSetup {
constructor(projectName, options = {}) {
this.projectName = projectName;
this.options = options;
this.config = {
projectName,
template: options.template || 'default',
features: ['hotreload', 'layouts'],
database: 'sqlite',
auth: { enabled: false },
plugins: ['logger', 'security'],
styling: 'bootstrap',
git: true,
install: true
};
}
async start() {
console.log(chalk.blue.bold(`\nš Quick Setup for "${this.projectName}"\n`));
if (!this.options.template) {
await this.selectTemplate();
}
await this.askEssentialQuestions();
await this.execute();
}
async selectTemplate() {
const { template } = await inquirer.prompt([{
type: 'list',
name: 'template',
message: 'šÆ Choose a template:',
choices: [
{ name: 'š Default - Full web app', value: 'default' },
{ name: 'š API - REST API only', value: 'api' },
{ name: 'š Blog - Content management', value: 'blog' },
{ name: 'š Admin - Dashboard', value: 'admin' },
{ name: 'š Portfolio - Showcase', value: 'portfolio' }
]
}]);
this.config.template = template;
}
async askEssentialQuestions() {
const questions = [
{
type: 'confirm',
name: 'auth',
message: 'š Include authentication?',
default: ['admin', 'blog'].includes(this.config.template),
when: () => this.config.template !== 'api'
},
{
type: 'list',
name: 'database',
message: 'šļø Database type:',
choices: [
{ name: 'š SQLite (easy)', value: 'sqlite' },
{ name: 'š PostgreSQL', value: 'postgresql' },
{ name: 'š MongoDB', value: 'mongodb' },
{ name: 'š« None', value: 'none' }
],
when: () => ['api', 'blog', 'admin'].includes(this.config.template)
},
{
type: 'list',
name: 'styling',
message: 'šØ CSS framework:',
choices: [
{ name: 'š
±ļø Bootstrap', value: 'bootstrap' },
{ name: 'šÆ Tailwind', value: 'tailwind' },
{ name: 'š Custom', value: 'custom' }
],
when: () => this.config.template !== 'api'
}
];
const answers = await inquirer.prompt(questions);
if (answers.auth) {
this.config.auth.enabled = true;
}
if (answers.database) {
this.config.database = answers.database;
}
if (answers.styling) {
this.config.styling = answers.styling;
}
}
async execute() {
const SetupExecutor = require('./setup-executor');
const executor = new SetupExecutor(this.config);
console.log(chalk.green('\nšÆ Creating your project...\n'));
await executor.execute();
console.log(chalk.green.bold('\n⨠Quick setup complete!\n'));
console.log(chalk.cyan('Next steps:'));
console.log(chalk.white(` cd ${this.projectName}`));
console.log(chalk.white(' npm run dev'));
}
}
module.exports = QuickSetup;