import React, { ReactNode, useState } from "react"; import { Newline, render, Text, Box } from "ink"; import init from "./util/init"; import Intro from "./components/Intro"; import Docker from "./components/docker/Docker"; import IsPeriphery from "./components/IsPeriphery"; import Confirm from "./components/Confirm"; import { createUseConfig, createUseSequence } from "./util/state"; import { Config } from "./types"; import Mongo from "./components/deployment-config/Mongo"; import CoreOrPeriphery from "./components/core-or-periphery/CoreOrPeriphery"; import { bound } from "./util/helpers/general"; import Setup from "./components/Setup"; import Restart from "./components/Restart"; type Page = { title: string; view: ReactNode; }; export const useMainSequence = createUseSequence(); export const useConfig = createUseConfig({}); init().then(({ flags, dockerInstalled }) => { const App = () => { const { current } = useMainSequence(); const [periphery, setPeriphery] = useState( flags.core ? false : flags.periphery ? true : undefined ); if (flags.restart || flags.restartDefault) { return ( Monitor CLI{" "} restart {`(1 of 1)`} ); } const corePages: Page[] = [ { title: "mongo config", view: , }, { title: "monitor core config", view: , }, ]; const peripheryPages: Page[] = [ { title: "periphery config", view: , }, ]; const pages = [ { title: "intro", view: , }, dockerInstalled ? false : { title: "docker intro", view: , }, { title: "restart", view: , }, !flags.core && !flags.periphery ? { title: "core or periphery", view: , } : false, periphery === true && peripheryPages, periphery === false && corePages, { title: "confirm config", view: , }, { title: "setup", view: , }, ] .filter((val) => (val ? true : false)) .flat(); const { title, view } = pages[bound(current, 0, pages.length - 1)] as Page; return ( Monitor CLI{" "} {title} {`(${current + 1} of ${pages.length})`} {view} ); }; render(); });