import path from 'path' import fs, { existsSync } from 'fs-extra' import chalk from 'chalk' import { Command } from '@oclif/command' import { runInitialStructureCompilation } from '../utils/createInitialStructure' import { logger } from '../utils/logger' export default class Create extends Command { public static description = 'Creates the base structure for Sales App project' public static examples: string[] | undefined = [ '$ sales-app create {my_custom_path}', ] public static args: Command['ctor']['args'] = [ { name: 'path', description: 'path where the sales app base structure will be saved', required: true, }, ] public async run() { const { args } = this.parse(Create) const targetDir = path.resolve(args.path) if (existsSync(targetDir)) { logger.error(`${chalk.red('Error')} - Project already created`) return } this.log( `${chalk.blue('Info')} - Creating project structure in ${targetDir}...` ) fs.mkdirSync(targetDir, { recursive: true }) runInitialStructureCompilation(targetDir) this.log( `${chalk.green('Success')} - Project structure created successfully` ) } }