From a0606e56611b9ffd0d6583a32e229603fd86c2f3 Mon Sep 17 00:00:00 2001 From: fgrreloaded Date: Mon, 17 Feb 2025 21:16:41 +0530 Subject: [PATCH] added custom command view for flow --- .../app/(home)/_components/CommandDisplay.tsx | 37 +++++++++++++++++++ .../(home)/_components/CustomizableStack.tsx | 24 +++++++++++- 2 files changed, 59 insertions(+), 2 deletions(-) create mode 100644 apps/web/src/app/(home)/_components/CommandDisplay.tsx diff --git a/apps/web/src/app/(home)/_components/CommandDisplay.tsx b/apps/web/src/app/(home)/_components/CommandDisplay.tsx new file mode 100644 index 0000000..6ec4686 --- /dev/null +++ b/apps/web/src/app/(home)/_components/CommandDisplay.tsx @@ -0,0 +1,37 @@ +"use client"; + +import { Check, Copy } from "lucide-react"; +import { useState } from "react"; + +interface CommandDisplayProps { + command: string; +} + +export function CommandDisplay({ command }: CommandDisplayProps) { + const [copied, setCopied] = useState(false); + + const copyToClipboard = async () => { + await navigator.clipboard.writeText(command); + setCopied(true); + setTimeout(() => setCopied(false), 2000); + }; + + return ( +
+
+ +
{command}
+
+
+ ); +} diff --git a/apps/web/src/app/(home)/_components/CustomizableStack.tsx b/apps/web/src/app/(home)/_components/CustomizableStack.tsx index 5ac5993..d5ac571 100644 --- a/apps/web/src/app/(home)/_components/CustomizableStack.tsx +++ b/apps/web/src/app/(home)/_components/CustomizableStack.tsx @@ -12,6 +12,7 @@ import { useCallback, useState } from "react"; import { TechSelector } from "./TechSelector"; import "@xyflow/react/dist/style.css"; import { initialNodes } from "@/lib/constant"; +import { CommandDisplay } from "./CommandDisplay"; import { TechNodeComponent } from "./TechNodeComponent"; const initialEdges = [ @@ -136,10 +137,29 @@ const CustomizableStack = () => { [nodes, edges, setEdges, setNodes], ); + const generateCommand = useCallback(() => { + const flags: string[] = ["-y"]; + + if (activeNodes.database !== "libsql") { + flags.splice(flags.indexOf("-y"), 1); + flags.push(`--database ${activeNodes.database}`); + } + + if (activeNodes.auth !== "better-auth") { + flags.splice(flags.indexOf("-y"), 1); + flags.push("--no-auth"); + } + + return `npx create-better-t-stack my-app ${flags.join(" ")}`; + }, [activeNodes]); + return ( -
+
-
+
+ +
+
Select technologies from the left panel to customize your stack. The graph will automatically update connections.