@itzsunny/starter
Version:
starter package for portal
68 lines (60 loc) • 2.15 kB
JavaScript
import chalk from 'chalk';
import { execSync } from 'child_process';
import clear from 'clear';
import figlet from 'figlet';
import gradient from 'gradient-string';
import { createPromptModule } from 'inquirer';
const runCommand = (command) => {
try {
execSync(command, { stdio: 'inherit' });
} catch (err) {
console.error(`Failed to execute ${command}`, err);
return false;
}
return true;
};
const prompt = createPromptModule();
const questions = [
{
type: 'input',
name: 'projectName',
message: "Please enter your new project's name.",
default: 'react-starter',
},
// {
// type: 'list',
// name: 'projectType',
// message: 'Please select a project template.',
// choices: [`Angular`, `React`]
// }
];
const run = async () => {
clear();
console.log(
gradient(['#FF0000', '#00FF00', '#0000FF'])(
figlet.textSync(`Welcome`, { horizontalLayout: 'controlled smushing', font: 'Larry 3D 2' })
)
);
const { projectName, engineType } = await prompt(questions);
const gitCheckOutCommand = `git clone --branch production https://github.com/maksof-sarwar/react-starter-turbopack.git ${projectName}`;
const installCommand = (engineType) => `cd ${projectName} && ${engineType} install`;
console.log(chalk.yellow.underline(`Cloning the repository with the name ${projectName}`));
const checkOut = runCommand(gitCheckOutCommand);
if (!checkOut) process.exit(-1);
const engineInstall = runCommand(installCommand(`npm i -g pnpm`));
if (!engineInstall) process.exit(-1);
console.log(chalk.yellow.underline(`Installing the dependencies for ${projectName}`));
const installDependencies = runCommand(installCommand(`pnpm`));
if (!installDependencies) process.exit(-1);
console.log(chalk.yellow.underline(`Waiting for dependencies to be installed.`));
const updateDependencies = runCommand(`pnpm update`);
if (!updateDependencies) process.exit(-1);
console.log(
gradient(['#4568dc', '#b06ab3'])(
figlet.textSync(`Congratulaton`, { horizontalLayout: 'controlled smushing', font: 'Larry 3D 2' })
)
);
console.log(chalk.yellow.underline(`cd ${projectName} && pnpm dev`));
};
run();