UNPKG

create-roadkit

Version:

Beautiful Next.js roadmap website generator with full-screen kanban boards, dark/light mode, and static export

133 lines (113 loc) • 3.65 kB
#!/usr/bin/env bun /** * CLI tool for generating Next.js roadmap projects * Simplified interactive CLI - just asks for project name * Usage: bun src/cli/generate.ts [project-name] */ import { generateRoadmapProject, ProjectConfig } from '../core/template-generator' import { intro, outro, text, confirm, isCancel, cancel } from '@clack/prompts' import path from 'path' /** * Show help message */ function showHelp() { console.log(` šŸš€ RoadKit Template Generator Usage: bun src/cli/generate.ts [project-name] Arguments: project-name Optional: Name of the project to create Examples: bun src/cli/generate.ts # Interactive mode bun src/cli/generate.ts my-awesome-roadmap # Direct mode `) } // Parse command line arguments const args = process.argv.slice(2) // Handle help flag if (args.includes('--help') || args.includes('-h')) { showHelp() process.exit(0) } let projectName: string const outputDir = './' /** * Interactive CLI mode - prompt user for project name */ async function interactiveMode(): Promise<string> { intro('šŸš€ Welcome to RoadKit!') const projectNameInput = await text({ message: "What's your project name?", placeholder: 'my-awesome-roadmap', validate: (value) => { if (!value) return 'Project name is required' if (!/^[a-zA-Z0-9-_]+$/.test(value)) { return 'Project name must contain only alphanumeric characters, hyphens, and underscores' } } }) if (isCancel(projectNameInput)) { cancel('Operation cancelled') process.exit(0) } return projectNameInput as string } // Generate the template async function main() { try { // Get project name either from args or interactive mode if (args.length === 0) { // Interactive mode projectName = await interactiveMode() } else if (args.length === 1) { // Direct mode with project name argument projectName = args[0] } else { console.error('āŒ Too many arguments. Use --help for usage information.') process.exit(1) } console.log('') console.log('šŸŽÆ Generating Next.js roadmap project...') console.log(` Project: ${projectName}`) console.log(` TypeScript: Always enabled`) console.log(` Output: ${path.resolve(outputDir)}`) console.log('') const config: ProjectConfig = { name: projectName, outputPath: path.resolve(outputDir), theme: 'modern', typescript: true, features: { analytics: false, auth: false, darkMode: true, exportFeature: true } } await generateRoadmapProject(config) console.log('') outro('āœ… Generated Next.js roadmap at ./' + projectName) console.log('') console.log('šŸ“‹ Next steps:') console.log(` 1. cd ${projectName}`) console.log(` 2. bun run dev`) console.log(` 3. Open http://localhost:3000`) console.log(` 4. Edit src/data/roadmap-data.ts to customize your roadmap`) console.log('') console.log('šŸ“š Additional resources:') console.log(' • Next.js Documentation: https://nextjs.org/docs') console.log(' • Tailwind CSS: https://tailwindcss.com/docs') console.log(' • Shadcn/ui: https://ui.shadcn.com/') } catch (error) { console.error('') console.error('šŸ’„ Unexpected error occurred!') console.error(` ${error instanceof Error ? error.message : 'Unknown error'}`) if (error instanceof Error && error.stack) { console.error('') console.error('Stack trace:') console.error(error.stack) } process.exit(1) } } // Run the CLI main()