UNPKG

node-ff

Version:
78 lines (67 loc) 1.82 kB
import { exeCommands, writeFile } from '../../utils'; import { Control } from './control'; import { IInProcessingDTO } from './interfaces'; class Processig { private name: string; private typing: boolean | undefined; private git: string | boolean | undefined; private orm: string | boolean | undefined; constructor( private resultPrompt: IInProcessingDTO, private initializers: Array<string> = [ 'json', 'code', 'initial', 'eslint', 'no_typing', ], ) { const { project, typing, git, orm } = this.resultPrompt; this.name = project.replace(/\s/g, '-'); this.typing = typing; this.git = git; this.orm = orm; this.in_process(); } private async in_process() { try { await this.create_structure({ project: this.name }); } catch (err) { if (err instanceof Error) { console.error(err.message); } } } private async create_structure({ project }: IInProcessingDTO) { exeCommands.execute({ commands: ` mkdir ${project} && cd ${project} && mkdir src .vscode `, }); if (this.git) { this.initializers.push('git'); exeCommands.execute({ commands: `cd ${this.name} && git init -q`, }); } if (this.typing) { this.initializers.pop(); this.initializers.push('with_typing'); } await new Control( this.name, this.typing, this.initializers, this.orm ? this.orm : false, writeFile, ).exec({ final_comands: exeCommands, initial_msg: '\n✏️ processando...', final_msg: `✅ processo finalizado! \n\n- Não deixe de ver o readme :)`, }); } } export { Processig };