#!/usr/bin/env node /** * TUI Demo Application * Demonstrates the TUI components we've built so far */ // Enable Babel for JSX support require("@babel/register"); const React = require("react"); async function runTuiDemo() { console.log("šŸš€ Starting TUI Demo..."); console.log("šŸ“‹ This will show the components we've built:"); console.log(" • Complete navigation system"); console.log(" • Configuration screen with validation"); console.log(" • Operation screen with progress tracking"); console.log(" • Reusable UI components"); console.log(""); console.log("šŸ’” Navigation:"); console.log(" • Use arrow keys to navigate menus"); console.log(" • Press Enter to select options"); console.log(" • Press Esc to go back"); console.log(" • Press Ctrl+C to exit"); console.log(""); console.log( "āš ļø Note: Backend services are not connected, so some operations" ); console.log(" will show mock data or error gracefully."); console.log(""); try { // Use dynamic import for Ink to handle ESM modules const { render } = await import("ink"); // Import our TUI application const TuiApplication = require("./src/tui/TuiApplication.jsx"); console.log("āœ… Loading TUI application...\n"); // Render the full TUI application const app = render(React.createElement(TuiApplication)); // Handle cleanup process.on("SIGINT", () => { console.log("\nšŸ‘‹ Exiting TUI Demo..."); app.unmount(); process.exit(0); }); // Handle any unhandled errors process.on("uncaughtException", (error) => { console.error("\nāŒ Error in TUI:", error.message); console.error("Stack:", error.stack); app.unmount(); process.exit(1); }); process.on("unhandledRejection", (reason, promise) => { console.error("\nāŒ Unhandled Rejection:", reason); app.unmount(); process.exit(1); }); } catch (error) { console.error("āŒ Error loading TUI application:", error.message); console.error("Stack:", error.stack); console.log("\nšŸ’” This might be due to:"); console.log(" • Missing component dependencies"); console.log(" • JSX compilation issues"); console.log(" • Module import conflicts"); console.log("\nšŸ”§ Try running the tests first: npm test"); process.exit(1); } } // Run the demo runTuiDemo().catch((error) => { console.error("āŒ Failed to start TUI demo:", error.message); console.error("Stack:", error.stack); process.exit(1); });