Download cli.js from chahuadev/Chahuadev-smart-roadmap: direct link, hf CLI and curl.
- Browser
- Download file 6.79 kB
-
https://huggingface.co/datasets/chahuadev/Chahuadev-smart-roadmap/resolve/main/cli.js
- Command line
-
hf download hf://datasets/chahuadev/Chahuadev-smart-roadmap/cli.js
-
curl -L -o cli.js https://huggingface.co/datasets/chahuadev/Chahuadev-smart-roadmap/resolve/main/cli.js
6.79 kB
| // Smart Roadmap CLI | |
| // Command Line Interface for Smart Roadmap Scanner | |
| // Version: 1.0.0 | |
| const SmartRoadmapScanner = require('./src/index'); | |
| const path = require('path'); | |
| const fs = require('fs'); | |
| // Parse command line arguments | |
| function parseArguments(args) { | |
| const options = { | |
| command: 'scan', | |
| projectPath: process.cwd(), | |
| verbose: false, | |
| dryRun: false, | |
| outputDir: 'docs', | |
| format: 'all', | |
| help: false, | |
| version: false | |
| }; | |
| const validCommands = ['scan', 'analyze', 'help']; | |
| let commandFound = false; | |
| for (let i = 0; i < args.length; i++) { | |
| const arg = args[i]; | |
| if (arg === '-h' || arg === '--help') { | |
| options.help = true; | |
| } else if (arg === '--version') { | |
| options.version = true; | |
| } else if (arg === '-v' || arg === '--verbose') { | |
| options.verbose = true; | |
| } else if (arg === '-d' || arg === '--dry-run') { | |
| options.dryRun = true; | |
| } else if (arg === '-o' || arg === '--output') { | |
| if (i + 1 < args.length) { | |
| options.outputDir = args[i + 1]; | |
| i++; | |
| } | |
| } else if (arg === '--format') { | |
| if (i + 1 < args.length) { | |
| options.format = args[i + 1]; | |
| i++; | |
| } | |
| } else if (!arg.startsWith('-')) { | |
| // First non-option arg: command or path | |
| if (!commandFound && validCommands.includes(arg)) { | |
| options.command = arg; | |
| commandFound = true; | |
| } else { | |
| // Treat as project path | |
| options.projectPath = path.resolve(arg); | |
| } | |
| } | |
| } | |
| return options; | |
| } | |
| // Show help information | |
| function showHelp() { | |
| console.log(` | |
| Smart Roadmap - AI-Powered Development Roadmap Generator | |
| Version: 1.0.0 | |
| USAGE: | |
| smart-roadmap [command] [path] [options] | |
| COMMANDS: | |
| scan Scan project and generate roadmap (default) | |
| analyze Detailed project analysis | |
| help Show this help message | |
| ARGUMENTS: | |
| path Path to project directory (default: current directory) | |
| OPTIONS: | |
| -v, --verbose Show detailed output during scan | |
| -d, --dry-run Preview without saving files | |
| -o, --output <dir> Output directory (default: docs/) | |
| --format <type> Output format: json, md, html, all (default: all) | |
| -h, --help Show this help message | |
| --version Show version number | |
| EXAMPLES: | |
| smart-roadmap scan # Scan current directory | |
| smart-roadmap scan ./my-project # Scan specific project | |
| smart-roadmap analyze --verbose # Detailed analysis | |
| smart-roadmap scan -o ./reports # Custom output directory | |
| smart-roadmap --help # Show help | |
| OUTPUT FILES: | |
| - project-analysis.json Machine-readable data | |
| - DEVELOPMENT_ROADMAP.md Prioritized development plan | |
| - PROJECT_ANALYSIS.md Detailed analysis report | |
| For more information, visit: | |
| https://github.com/chahuadev-com/Chahuadev-smart-roadmap | |
| `); | |
| } | |
| // Show version | |
| function showVersion() { | |
| const packagePath = path.join(__dirname, 'package.json'); | |
| try { | |
| const pkg = JSON.parse(fs.readFileSync(packagePath, 'utf8')); | |
| console.log(`Smart Roadmap v${pkg.version}`); | |
| console.log(`Author: ${pkg.author.name || pkg.author}`); | |
| } catch (error) { | |
| console.log('Smart Roadmap v1.0.0'); | |
| console.log('Author: Chahua Development Co., Ltd.'); | |
| } | |
| } | |
| // Main CLI function | |
| async function main() { | |
| const args = process.argv.slice(2); | |
| const options = parseArguments(args); | |
| // Show help or version | |
| if (options.help || args.includes('help')) { | |
| showHelp(); | |
| return; | |
| } | |
| if (options.version) { | |
| showVersion(); | |
| return; | |
| } | |
| // Validate project path | |
| if (!fs.existsSync(options.projectPath)) { | |
| console.error(`[ERROR] Project path not found: ${options.projectPath}`); | |
| process.exit(1); | |
| } | |
| console.log('Smart Roadmap v1.0.0'); | |
| console.log('='.repeat(70)); | |
| console.log(`Command: ${options.command}`); | |
| console.log(`Project: ${path.relative(process.cwd(), options.projectPath) || '.'}`); | |
| console.log(`Output: ${options.outputDir}`); | |
| if (options.dryRun) { | |
| console.log('[DRY RUN] No files will be saved'); | |
| } | |
| console.log(''); | |
| try { | |
| // Create scanner instance | |
| const scanner = new SmartRoadmapScanner({ | |
| projectPath: options.projectPath, | |
| outputDir: options.outputDir, | |
| verbose: options.verbose | |
| }); | |
| // Execute command | |
| if (options.command === 'scan' || options.command === 'analyze') { | |
| const analysis = await scanner.scan(); | |
| if (!options.dryRun) { | |
| // Save analysis results | |
| const outputPath = path.join(options.projectPath, options.outputDir); | |
| // Create output directory if it doesn't exist | |
| if (!fs.existsSync(outputPath)) { | |
| fs.mkdirSync(outputPath, { recursive: true }); | |
| } | |
| // Save JSON | |
| const jsonPath = path.join(options.projectPath, 'project-analysis.json'); | |
| fs.writeFileSync(jsonPath, JSON.stringify(analysis, null, 2), 'utf8'); | |
| console.log(`[SUCCESS] Analysis saved: ${path.relative(process.cwd(), jsonPath)}`); | |
| // Future: Generate Markdown and HTML reports here | |
| console.log('[INFO] Roadmap generation will be implemented in next version'); | |
| } | |
| console.log('\n[SUCCESS] Scan completed!'); | |
| if (options.dryRun) { | |
| console.log('[INFO] Use without --dry-run to save reports'); | |
| } | |
| } else { | |
| console.error(`[ERROR] Unknown command: ${options.command}`); | |
| console.log('Use --help to see available commands'); | |
| process.exit(1); | |
| } | |
| } catch (error) { | |
| console.error(`\n[ERROR] ${error.message}`); | |
| if (options.verbose) { | |
| console.error(error.stack); | |
| } | |
| process.exit(1); | |
| } | |
| } | |
| // Run CLI if executed directly | |
| if (require.main === module) { | |
| main().catch(error => { | |
| console.error(`[FATAL] ${error.message}`); | |
| process.exit(1); | |
| }); | |
| } | |
| module.exports = { main, parseArguments, showHelp, showVersion }; | |