@admac-hub/create-roleauth-core
Version:
Full-stack MERN CLI to scaffold a role-based auth app with Google OAuth and frontend + backend setup.
48 lines (37 loc) • 1.31 kB
JavaScript
const fs = require('fs-extra');
const path = require('path');
const { execSync } = require('child_process');
const projectName = process.argv[2];
if (!projectName) {
console.log("❌ Please provide a project name.");
console.log("Usage: npx create-role-auth-webapp myapp");
process.exit(1);
}
const currentPath = process.cwd();
const targetPath = path.join(currentPath, projectName);
const templatePath = path.join(__dirname, '../template');
console.log(`📁 Creating project at: ${targetPath}`);
try {
// Copy all files from template/ to new folder
fs.copySync(templatePath, targetPath);
console.log("✅ Template copied.");
// Install backend dependencies
console.log("📦 Installing backend dependencies...");
execSync("npm install", {
cwd: path.join(targetPath, "backend"),
stdio: "inherit"
});
// Install client dependencies
console.log("📦 Installing frontend dependencies...");
execSync("npm install", {
cwd: path.join(targetPath, "client"),
stdio: "inherit"
});
console.log("✅ All set! Start by running:");
console.log(` cd ${projectName}`);
console.log(" npm run dev");
} catch (err) {
console.error("❌ Error creating project:", err);
process.exit(1);
}