UNPKG

mern-auth-boilerplate

Version:
52 lines (41 loc) • 1.94 kB
#!/usr/bin/env node import fs from 'fs-extra'; import inquirer from 'inquirer'; import path from 'path'; import { fileURLToPath } from 'url'; import { execSync } from 'child_process'; import chalk from 'chalk'; const __filename = fileURLToPath(import.meta.url); const __dirname = path.dirname(__filename); (async () => { console.log(chalk.cyan.bold("\nšŸš€ Welcome to MERN Auth Stack Boilerplate!\n")); console.log(chalk.cyan("šŸ”— Made with ā¤ļø by Jaivardhan Singh")); console.log(chalk.cyan("🌐 GitHub: ") + chalk.underline.blue("https://github.com/Jaivardhan7773\n")); const { projectName } = await inquirer.prompt([ { name: "projectName", type: "input", message: "Enter your project folder name:", validate: input => input ? true : "Project name cannot be empty!" } ]); const targetPath = path.join(process.cwd(), projectName); const sourcePath = path.join(__dirname, "template"); const frontendPath = path.join(targetPath, 'FRONTEND'); const backendPath = path.join(targetPath, 'SERVER'); try { console.log(chalk.yellow("šŸ“ Copying files...")); await fs.copy(sourcePath, targetPath); console.log(chalk.green("āœ… Files copied successfully!\n")); console.log(chalk.yellow("šŸ“¦ Installing dependencies... (this might take a minute)\n")); console.log(chalk.blue("šŸ“¦ Installing dependencies for frontend...")); execSync('npm install', { cwd: frontendPath, stdio: 'inherit' }); console.log(chalk.blue("\nšŸ“¦ Installing dependencies for backend...")); execSync('npm install', { cwd: backendPath, stdio: 'inherit' }); console.log(chalk.green.bold("\nāœ… Project setup complete!")); console.log(chalk.cyan(`\nšŸ‘‰ cd ${projectName}`)); console.log(chalk.cyan("šŸ‘‰ npm run dev")); } catch (err) { console.error(chalk.red("āŒ Failed to scaffold project:"), err); } })();