UNPKG

kawkab-frontend

Version:

Kawkab frontend is a frontend library for the Kawkab framework

39 lines (38 loc) 1.41 kB
import fs from 'fs-extra'; import path from 'path'; import chalk from 'chalk'; export function makeModuleCommand(program) { program .command('make:module <name>') .description('Create a new frontend module with its directory structure') .action((name) => { const moduleName = name.toLowerCase(); const modulePath = path.resolve(process.cwd(), 'app', moduleName); if (fs.existsSync(modulePath)) { console.log(chalk.yellow(`⚠️ Module "${moduleName}" already exists.`)); return; } console.log(chalk.cyan(`Creating new module: "${moduleName}"`)); const subdirectories = [ 'components', 'models', 'repositories', 'stores', 'pages', 'hooks', 'utils' ]; try { fs.ensureDirSync(modulePath); subdirectories.forEach(dir => { const dirPath = path.join(modulePath, dir); fs.ensureDirSync(dirPath); console.log(chalk.green(` ✓ Created directory: ${path.join('app', moduleName, dir)}`)); }); console.log(chalk.bold.green(`\n✅ Module "${moduleName}" created successfully!`)); } catch (error) { console.error(chalk.red(`❌ Error creating module "${moduleName}":`), error); } }); }