react-template-uri
Version:
A script to create react template with routes, tailwindcss and redux toolkit
36 lines (26 loc) • 1.18 kB
JavaScript
import { execSync } from "child_process";
import prompts from "prompts";
import chalk from "chalk";
import degit from "degit";
(async () => {
console.log(chalk.green("Welcome to Create Vite React App!"));
const response = await prompts({
type: "text",
name: "projectName",
message: "Enter the project name:",
validate: (name) => (name ? true : "Project name cannot be empty"),
});
const projectName = response.projectName;
if (!projectName) process.exit(1);
console.log(chalk.blue(`\nCreating project: ${projectName}...\n`));
// Clone the template from GitHub using degit
execSync(`npx degit RishabhRawat2003/react-template ${projectName}`, { stdio: "inherit" });
// Navigate into the project folder
process.chdir(projectName);
console.log(chalk.yellow("\nInstalling dependencies...\n"));
execSync("npm install", { stdio: "inherit" });
console.log(chalk.green("\nSetup complete! Run the following commands to start your project:\n"));
console.log(chalk.cyan(`cd ${projectName}`));
console.log(chalk.cyan("npm run dev"));
})();