Just a whole lot of crap
This commit is contained in:
82
demo-tui.js
Normal file
82
demo-tui.js
Normal file
@@ -0,0 +1,82 @@
|
||||
#!/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);
|
||||
});
|
||||
Reference in New Issue
Block a user