UNPKG

@incidental/project-templates

Version:

Claude Code template library for JavaScript projects with framework auto-detection

36 lines (29 loc) 1.03 kB
import { logger } from '../utils/logger.js'; import { detectFramework } from '../detectors/framework-detector.js'; import TemplateInstaller from '../installers/template-installer.js'; export async function addCommandHandler(name, options) { logger.header(`Adding command: ${name}`); // Determine framework let framework = options.framework; if (!framework) { const detected = await detectFramework(); if (detected) { framework = detected; logger.info(`Using detected framework: ${framework}`); } else { logger.warning('Could not detect framework, using "shared" templates'); framework = 'shared'; } } // Install the command const installer = new TemplateInstaller(); try { await installer.installCommand(name, framework); logger.success('Command installed successfully!'); logger.dim(`\nUse it with: /${name}`); } catch (error) { logger.error(`Failed to install command: ${error.message}`); throw error; } } export default addCommandHandler;