UNPKG

kawkab-frontend

Version:

Kawkab frontend is a frontend library for the Kawkab framework

46 lines (45 loc) • 1.81 kB
import fs from 'fs-extra'; import path from 'path'; import chalk from 'chalk'; export function cleanCommand(program) { program .command('clean') .description('Remove all build artifacts, caches, and cross-platform directories.') .action(() => { const projectRoot = process.cwd(); const itemsToRemove = [ // Build artifacts path.join(projectRoot, 'web'), path.join(projectRoot, 'build'), // Legacy build dir // Caches path.join(projectRoot, '.react-router'), // Capacitor & Electron directories path.join(projectRoot, 'android'), path.join(projectRoot, 'ios'), path.join(projectRoot, 'electron'), // Capacitor config file path.join(projectRoot, 'capacitor.config.ts') ]; console.log(chalk.blue('šŸš€ Cleaning project directories and artifacts...')); let cleanedCount = 0; itemsToRemove.forEach(itemPath => { const itemName = path.relative(projectRoot, itemPath); if (fs.existsSync(itemPath)) { try { fs.removeSync(itemPath); // removeSync works for both files and directories console.log(chalk.green(` āœ“ Removed: ${itemName}`)); cleanedCount++; } catch (error) { console.error(chalk.red(`āŒ Failed to remove ${itemName}:`), error); } } }); if (cleanedCount > 0) { console.log(chalk.bold.green(`\nšŸŽ‰ Project cleaned successfully. (${cleanedCount} items removed)`)); } else { console.log(chalk.bold.green('\nāœ… Project is already clean.')); } }); }