"use client"; import { useState, useEffect, useRef } from "react"; import { Button } from "@/components/ui/button"; import { Play } from "lucide-react"; const scriptOutput = [ "DocuBook CLI Installer", "✔ Enter your project directory name: docubook", "? Choose a package manager:", "> npm", " pnpm", " yarn", " bun", "", ":: Cloning starter from GitLab...", "✔ Docubook project successfully created!", "Skipping rename postcss.config.js because Bun is not installed.", "", "[ DocuBook Version 1.8.0 ]", "", "Starting the installation process...", "Installation | ████████████████████████████████ | 100% 100/100", "", "Dependencies installed successfully using npm!", "", "┌────────────────────────────────────┐", "│ Next Steps: │", "│ │", "│ 1. Navigate to project directory: │", "│ cd docubook │", "│ │", "│ 2. Install dependencies: │", "│ npm install │", "│ │", "│ 3. Start the development server: │", "│ npm run dev │", "└────────────────────────────────────┘" ]; export function RuntimeSimulator() { const [logs, setLogs] = useState([]); const [running, setRunning] = useState(false); const terminalRef = useRef(null); useEffect(() => { if (running) { setLogs([]); scriptOutput.forEach((line, index) => { setTimeout(() => { setLogs((prev) => [...prev, line]); }, index * 500); }); } }, [running]); useEffect(() => { terminalRef.current?.scrollTo({ top: terminalRef.current.scrollHeight, behavior: "smooth" }); }, [logs]); return (
docubook@localhost
{logs.map((log, index) => (
{log}
))}
); } export default RuntimeSimulator;