UNPKG

@reliverse/rse

Version:

@reliverse/rse is your all-in-one companion for bootstrapping and improving any kind of projects (especially web apps built with frameworks like Next.js) — whether you're kicking off something new or upgrading an existing app. It is also a little AI-power

73 lines (72 loc) 2.24 kB
import { detectProjectsWithRseConfig } from "@reliverse/cfg"; import path from "@reliverse/pathkit"; import { re } from "@reliverse/relico"; import fs from "@reliverse/relifso"; import { isBunPM, isBunRuntime } from "@reliverse/runtime"; import { cliJsrPath } from "../../../../../constants.js"; export async function getMainMenuOptions(cwd, isDev, mrse) { const multiConfigMsg = mrse.length > 0 ? re.dim(`multi-config mode with ${mrse.length} projects`) : ""; const rseSearchPath = isDev ? path.join(cwd, "tests-runtime") : cwd; let detectedCount = 0; if (await fs.pathExists(rseSearchPath)) { const detectedProjects = await detectProjectsWithRseConfig( rseSearchPath, isDev ); detectedCount = detectedProjects.length; } const detectedHint = detectedCount > 0 ? `Detected: ${detectedCount}` : ""; const options = [ { label: "\u{1F4BB} Open rse web ui", hint: "experimental", value: "web-ui" }, { label: "\u2728 Create a project in terminal", hint: multiConfigMsg, value: "create" }, { label: "\u{1F52C} Create/edit project manually", // Inject "Detected: N" near the manual creation if we found any hint: [multiConfigMsg, detectedHint].filter(Boolean).join(" | "), value: "manual" }, { label: "\u{1F9F1} Clone an existing repository", hint: multiConfigMsg, value: "clone" }, { label: "\u{1F4AC} Chat with Reliverse AI", value: "ai" }, { label: "\u{1F9F0} Open developer toolkit", value: "isDevTools" }, { label: "\u{1F448} Exit", value: "exit", hint: re.dim("ctrl+c anywhere") } ]; const isBun = await isBunPM(); if (isBun && !isBunRuntime) { const isNativeInstalled = await fs.pathExists(cliJsrPath); let msg = "Use"; if (isNativeInstalled && isBunRuntime) { msg = "Configure"; } options.push({ label: `\u{1F680} ${msg} Bun-native @rse`, value: "native-cli" }); } if (detectedCount > 0) { options.splice(1, 0, { label: "\u{1F4DD} Manage project (deprecated)", value: "detected-projects", hint: re.dim(`Detected: ${detectedCount}`) }); } return options; }