UNPKG

@neurolint/cli

Version:

NeuroLint CLI for React/Next.js modernization with advanced 6-layer orchestration and intelligent AST transformations

237 lines (214 loc) 7.4 kB
#!/usr/bin/env node import { Command } from "commander"; import chalk from "chalk"; import ora from "ora"; import inquirer from "inquirer"; import { analyzeCommand } from "./commands/analyze-fixed"; import { fixCommand } from "./commands/fix-fixed"; import { configCommand } from "./commands/config"; import { initCommand } from "./commands/init"; import { statusCommand } from "./commands/status"; import { loginCommand, logoutCommand } from "./commands/login"; const program = new Command(); program .name("neurolint") .description("NeuroLint CLI - React & Next.js Modernization Platform") .version("1.1.0"); // Welcome message console.log(chalk.white.bold("NeuroLint CLI")); console.log(chalk.gray("React & Next.js Modernization Platform\n")); console.log(chalk.cyan("Free tier: Unlimited scanning & 500 upgrades/month (Layer 1)")); console.log(chalk.gray("Premium: Full layer access, unlimited fixes & team collaboration")); console.log(chalk.yellow("TIP: Try individual layer CLIs: neurolint-config, neurolint-hydration, etc.\n")); // Initialize project command program .command("init") .description("Initialize NeuroLint in your project") .option("-f, --force", "Overwrite existing configuration") .action(initCommand); // Authentication commands program .command("login") .description("Authenticate with NeuroLint service") .option("--api-key <key>", "API key for authentication") .option("--url <url>", "API server URL") .action(loginCommand); program .command("logout") .description("Clear authentication credentials") .action(logoutCommand); // Analysis command program .command("analyze [files...]") .alias("scan") .description("Analyze React/Next.js codebase for modernization opportunities") .option("-l, --layers <layers>", "Specify layers to run (1-6)", "1,2,3,4") .option( "-o, --output <format>", "Output format (json|table|summary)", "table", ) .option("-r, --recursive", "Analyze files recursively") .option("--include <patterns>", "Include file patterns (comma-separated)") .option("--exclude <patterns>", "Exclude file patterns (comma-separated)") .option("--config <path>", "Configuration file path") .action(analyzeCommand); // Fix command program .command("fix [files...]") .description("Apply modernization fixes (Premium feature - requires authentication)") .option("-l, --layers <layers>", "Specify layers to run (1-6)", "1,2,3,4") .option("-r, --recursive", "Fix files recursively") .option("--dry-run", "Preview changes without applying them") .option("--backup", "Create backup files before fixing") .option("--include <patterns>", "Include file patterns (comma-separated)") .option("--exclude <patterns>", "Exclude file patterns (comma-separated)") .option("--config <path>", "Configuration file path") .action(fixCommand); // Status command program .command("status") .description("Show modernization readiness and legacy code analysis") .option("--detailed", "Show detailed statistics") .action(statusCommand); // Configuration management program .command("config") .description("Manage NeuroLint configuration") .option("--set <key=value>", "Set configuration value") .option("--get <key>", "Get configuration value") .option("--list", "List all configuration") .option("--reset", "Reset to default configuration") .action(configCommand); // Interactive mode program .command("interactive") .alias("i") .description("Run NeuroLint in interactive mode") .action(async () => { console.log(chalk.white("NeuroLint Interactive Mode\n")); const answers = await inquirer.prompt([ { type: "list", name: "action", message: "What would you like to do?", choices: [ "Analyze code files", "Fix code issues", "View project status", "Configure settings", "Exit", ], }, ]); switch (answers.action) { case "Analyze code files": console.log(chalk.white("Starting code analysis...")); await analyzeCommand([], {}); break; case "Fix code issues": console.log(chalk.white("Starting code fixes...")); await fixCommand([], {}); break; case "View project status": await statusCommand({}); break; case "Configure settings": await configCommand({}); break; default: console.log(chalk.white("Goodbye")); process.exit(0); } }); // Help command program .command("help") .description("Show help and examples") .action(() => { console.log(chalk.white.bold("\nNeuroLint CLI - React & Next.js Modernization\n")); console.log(chalk.white("Free Tier (No Authentication Required):")); console.log( chalk.gray( " neurolint init # Initialize modernization config", ), ); console.log( chalk.gray(" neurolint analyze src/ # Free modernization analysis"), ); console.log( chalk.gray(" neurolint status # Check modernization readiness"), ); console.log(); console.log(chalk.white("Modernization Analysis (Free):")); console.log( chalk.gray(" neurolint analyze src/ # Scan for legacy patterns"), ); console.log( chalk.gray(" neurolint analyze --layers=1,2,3 # Focus on specific areas"), ); console.log( chalk.gray(" neurolint analyze --output=json # Export modernization report"), ); console.log(); console.log(chalk.white("Premium Features (Requires Authentication):")); console.log( chalk.gray(" neurolint login # Authenticate for premium"), ); console.log( chalk.gray(" neurolint fix src/ # Apply modernization fixes"), ); console.log( chalk.gray(" neurolint fix --dry-run # Preview migration changes"), ); console.log( chalk.gray(" neurolint fix --backup # Safe migration with backups"), ); console.log(); console.log( chalk.white("Modernization Layers (Free Analysis, Premium Fixes):"), ); console.log( chalk.gray( " Layer 1: Config Modernization (try: neurolint-config)", ), ); console.log( chalk.gray( " Layer 2: Content Standardization (try: neurolint-content)", ), ); console.log( chalk.gray( " Layer 3: Component Intelligence (try: neurolint-components)", ), ); console.log( chalk.gray(" Layer 4: Hydration Mastery (try: neurolint-hydration)"), ); console.log( chalk.gray( " Layer 5: App Router Optimization (try: neurolint-approuter)", ), ); console.log( chalk.gray( " Layer 6: Quality Enforcement (try: neurolint-quality)", ), ); console.log(); console.log( chalk.cyan("\nFree modernization analysis - no signup required!"), ); console.log( chalk.yellow("Individual layer CLIs: npm i -g neurolint-hydration neurolint-config"), ); console.log( chalk.cyan("Premium migrations & team features: https://neurolint.dev (from $9/month)"), ); }); // Default help if no command if (process.argv.length <= 2) { program.help(); } program.parse();