| #!/usr/bin/env node
|
|
|
|
|
|
|
|
|
| const SmartRoadmapScanner = require('./src/index');
|
| const path = require('path');
|
| const fs = require('fs');
|
|
|
|
|
| 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('-')) {
|
|
|
| if (!commandFound && validCommands.includes(arg)) {
|
| options.command = arg;
|
| commandFound = true;
|
| } else {
|
|
|
| options.projectPath = path.resolve(arg);
|
| }
|
| }
|
| }
|
|
|
| return options;
|
| }
|
|
|
|
|
| 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
|
| `);
|
| }
|
|
|
|
|
| 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.');
|
| }
|
| }
|
|
|
|
|
| async function main() {
|
| const args = process.argv.slice(2);
|
| const options = parseArguments(args);
|
|
|
|
|
| if (options.help || args.includes('help')) {
|
| showHelp();
|
| return;
|
| }
|
|
|
| if (options.version) {
|
| showVersion();
|
| return;
|
| }
|
|
|
|
|
| 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 {
|
|
|
| const scanner = new SmartRoadmapScanner({
|
| projectPath: options.projectPath,
|
| outputDir: options.outputDir,
|
| verbose: options.verbose
|
| });
|
|
|
|
|
| if (options.command === 'scan' || options.command === 'analyze') {
|
| const analysis = await scanner.scan();
|
|
|
| if (!options.dryRun) {
|
|
|
| const outputPath = path.join(options.projectPath, options.outputDir);
|
|
|
|
|
| if (!fs.existsSync(outputPath)) {
|
| fs.mkdirSync(outputPath, { recursive: true });
|
| }
|
|
|
|
|
| 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)}`);
|
|
|
|
|
| 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);
|
| }
|
| }
|
|
|
|
|
| if (require.main === module) {
|
| main().catch(error => {
|
| console.error(`[FATAL] ${error.message}`);
|
| process.exit(1);
|
| });
|
| }
|
|
|
| module.exports = { main, parseArguments, showHelp, showVersion };
|
|
|