@incidental/project-templates
Version:
Claude Code template library for JavaScript projects with framework auto-detection
76 lines (62 loc) • 2.41 kB
JavaScript
import { Command } from 'commander';
import { readFileSync } from 'fs';
import { fileURLToPath } from 'url';
import { dirname, join } from 'path';
// Import command handlers
import { initCommand } from '../src/commands/init.js';
import { addAgentHandler } from '../src/commands/add-agent.js';
import { addCommandHandler } from '../src/commands/add-command.js';
import { addSkillHandler } from '../src/commands/add-skill.js';
import { listCommand } from '../src/commands/list.js';
import { updateCommand } from '../src/commands/update.js';
const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);
// Read package.json for version
const packageJson = JSON.parse(
readFileSync(join(__dirname, '../package.json'), 'utf-8')
);
const program = new Command();
program
.name('project-templates')
.description('Claude Code template library for JavaScript projects with framework auto-detection')
.version(packageJson.version);
// init command
program
.command('init')
.description('Initialize Claude Code templates in your project')
.option('-f, --framework <framework>', 'Specify framework (nextjs, react, vanilla)')
.option('-y, --yes', 'Skip prompts and install all templates')
.action(initCommand);
// add-command command
program
.command('add-command <name>')
.description('Install a specific command template')
.option('-f, --framework <framework>', 'Specify framework (nextjs, react, vanilla)')
.action(addCommandHandler);
// add-agent command
program
.command('add-agent <name>')
.description('Install a specific agent template')
.option('-f, --framework <framework>', 'Specify framework (nextjs, react, vanilla)')
.action(addAgentHandler);
// add-skill command
program
.command('add-skill <name>')
.description('Install a specific skill template')
.action(addSkillHandler);
// list command
program
.command('list')
.description('List all available templates')
.option('-t, --type <type>', 'Filter by type (commands, agents, skills, steering)')
.option('-f, --framework <framework>', 'Filter by framework (nextjs, react, vanilla)')
.action(listCommand);
// update command
program
.command('update')
.description('Update installed templates to latest version')
.option('-a, --all', 'Update all installed templates')
.action(updateCommand);
// Parse arguments
program.parse(process.argv);