UNPKG

cvm-cli

Version:

A unified CLI tool for managing PHP, Node.js, and Python versions with virtual environment and dependency management support.

104 lines (86 loc) • 3.19 kB
#!/usr/bin/env node const { program } = require('commander'); const chalk = require('chalk'); const ProjectManager = require('../lib/projectManager'); program .name('cpm') .version('1.0.0') .description('Cross-Platform Project Manager - Create projects from templates'); program .command('make <template> <project-name>') .description('Create a new project from a template') .option('-i, --interactive', 'Use interactive mode') .action(async (template, projectName, options) => { if (options.interactive) { await ProjectManager.interactiveCreate(); } else { await ProjectManager.createProject(template, projectName); } }); program .command('list') .alias('ls') .description('List all available project templates') .action(async () => { await ProjectManager.listTemplates(); }); program .command('search <keyword>') .description('Search for templates by keyword') .action(async (keyword) => { const templates = ProjectManager.getAvailableTemplates(); const filtered = templates.filter(name => name.toLowerCase().includes(keyword.toLowerCase()) || ProjectManager.getTemplate(name).description.toLowerCase().includes(keyword.toLowerCase()) ); if (filtered.length === 0) { console.log(chalk.yellow(`No templates found matching '${keyword}'`)); return; } console.log(chalk.blue(`\nšŸ” Templates matching '${keyword}':\n`)); filtered.forEach(name => { const template = ProjectManager.getTemplate(name); console.log(` ${chalk.green(name.padEnd(15))} - ${template.description}`); }); console.log(); }); program .command('info <template>') .description('Show detailed information about a template') .action(async (templateName) => { const template = ProjectManager.getTemplate(templateName); if (!template) { console.log(chalk.red(`āŒ Template '${templateName}' not found.`)); console.log(chalk.yellow('Run "cpm list" to see available templates.')); return; } console.log(chalk.blue(`\nšŸ“‹ Template Information: ${templateName}\n`)); console.log(`${chalk.yellow('Description:')} ${template.description}`); console.log(`${chalk.yellow('Language:')} ${template.language}`); console.log(`${chalk.yellow('Command:')} ${template.command}`); console.log(`${chalk.yellow('Requirements:')} ${template.requirements.join(', ')}`); if (template.minVersion) { console.log(`${chalk.yellow('Min Version:')} ${template.minVersion}`); } if (template.setup) { console.log(`${chalk.yellow('Setup Commands:')}`); template.setup.forEach(cmd => console.log(` - ${cmd}`)); } if (template.postSetup) { console.log(`${chalk.yellow('Post Setup:')}`); template.postSetup.forEach(cmd => console.log(` - ${cmd}`)); } console.log(); }); program .command('interactive') .alias('i') .description('Create a project using interactive mode') .action(async () => { await ProjectManager.interactiveCreate(); }); // Show help if no command is provided if (process.argv.length <= 2) { program.help(); } program.parse(process.argv);