UNPKG

@eve-tools/cli

Version:

Everest cli to speed up project start-up and standardized frontend , backend architecture

28 lines (27 loc) 1.39 kB
import { execSync } from 'child_process'; import { FRAMEWORK, LANGUAGE } from '../constants/constants.js'; import { combineShellCommand } from '../utils/combine-shell-command.js'; import { getAbsolutePath } from '../utils/get-absolute-path.js'; import { execAsync } from '../utils/promisified.js'; import { spinner } from '../utils/spinner.js'; import { tryCatchWrapper } from '../utils/try-catch-wrapper.js'; const { NESTJS, NEXT } = FRAMEWORK; const { NODE, TS } = LANGUAGE; const templateGithub = new Map() .set(`${NODE}-${NESTJS}`, 'https://github.com/Akuma225/nestjs-prisma-mono-skeleton.git') .set(`${TS}-${NEXT}`, 'https://github.com/Danmo-Ar/nextjs-architecture.git'); export const clonningProcess = async (project) => { const { start, fail, succeed } = spinner('Clonning the project 🚀'); await tryCatchWrapper(async () => { start(); await execAsync(`git clone ${templateGithub.get(`${project.language}-${project.framework}`)} ${project.name}`); initGit(project.name); succeed('Project clonned successfully 😄'); }, () => { fail('Project clonning failed 😞'); }); }; const initGit = (path) => { const projectPath = getAbsolutePath(path); execSync(combineShellCommand('rm -rf .git', 'git init', 'git checkout -b main', 'git add .', "git commit -m 'first initialisation' "), { cwd: projectPath }); };