UNPKG

@happyvibess/dev-boost

Version:

🚀 Supercharge your development workflow with smart automation

136 lines (119 loc) • 3.7 kB
#!/usr/bin/env node import { Command } from 'commander'; import chalk from 'chalk'; import figlet from 'figlet'; import gradient from 'gradient-string'; import updateNotifier from 'update-notifier'; import ora from 'ora'; // Import command handlers import handleScaffold from '../lib/commands/scaffold.js'; import handleSetup from '../lib/commands/setup.js'; import handleOptimize from '../lib/commands/optimize.js'; import handleCheck from '../lib/commands/check.js'; import handleWorkflow from '../lib/commands/workflow.js'; // Import package.json import { createRequire } from 'module'; const require = createRequire(import.meta.url); const pkg = require('../package.json'); // Check for updates updateNotifier({ pkg }).notify(); // Create CLI program const program = new Command(); // Display beautiful banner console.log( gradient.rainbow.multiline( figlet.textSync('DevBoost', { font: 'Big', horizontalLayout: 'default', verticalLayout: 'default', }) ) ); // Set up program metadata program .name('devboost') .description(chalk.blue('🚀 Supercharge your development workflow')) .version(pkg.version, '-v, --version', 'Output the current version'); // Global options program .option('-d, --debug', 'Enable debug mode') .option('-s, --silent', 'Suppress output'); // Scaffold command program .command('scaffold <template>') .description('Scaffold a new project from template') .option('-n, --name <name>', 'Project name') .option('-p, --path <path>', 'Project path') .action(async (template, options) => { try { await handleScaffold(template, options); } catch (error) { console.error(chalk.red('Scaffolding failed:'), error.message); process.exit(1); } }); // Setup command program .command('setup <environment>') .description('Set up development environment') .option('-f, --force', 'Force setup even if already exists') .option('-c, --config <path>', 'Custom config path') .action(async (environment, options) => { try { await handleSetup(environment, options); } catch (error) { console.error(chalk.red('Setup failed:'), error.message); process.exit(1); } }); // Optimize command program .command('optimize <target>') .description('Optimize project performance') .option('-l, --level <level>', 'Optimization level') .action(async (target, options) => { try { await handleOptimize(target, options); } catch (error) { console.error(chalk.red('Optimization failed:'), error.message); process.exit(1); } }); // Check command program .command('check <type>') .description('Run project checks') .option('-f, --fix', 'Attempt to fix issues') .action(async (type, options) => { try { await handleCheck(type, options); } catch (error) { console.error(chalk.red('Check failed:'), error.message); process.exit(1); } }); // Workflow command program .command('workflow <action>') .description('Manage development workflows') .option('-e, --env <environment>', 'Target environment') .action(async (action, options) => { try { await handleWorkflow(action, options); } catch (error) { console.error(chalk.red('Workflow failed:'), error.message); process.exit(1); } }); // Error handling for unknown commands program.on('command:*', () => { console.error(chalk.red('Invalid command: %s'), program.args.join(' ')); console.log('Use --help for a list of available commands.'); process.exit(1); }); // Parse command line arguments program.parse(); // If no arguments, show help if (!process.argv.slice(2).length) { program.outputHelp(); }