diff --git a/components/workspace/format-errors.tsx b/components/workspace/format-errors.tsx new file mode 100644 index 0000000..1feea70 --- /dev/null +++ b/components/workspace/format-errors.tsx @@ -0,0 +1,44 @@ +export function FormatErrors({ inputString }: { inputString: string }) { + // Detect and remove the dynamic path + const cleanedString = inputString.replace( + /\/tmp\/playground\/[a-f0-9\-]+\//g, + "" + ); + + // Regular expression to match lines containing errors and warnings + const errorMessages = cleanedString.match( + /(\w+\/[^\n]*): (error|warning) [^\n]*/g + ); + + // Print each error or warning message on a new line + if (errorMessages) { + return ( + + + + + + + + + {errorMessages.map((m) => ( + + ))} +
PathTypeDescription
+ ); + } else { + return null; + } +} + +function ErrorMessage({ message }: { message: string }) { + const [path, type, ...description] = message.split(":").map((i) => i.trim()); + + return ( + + {path} + {type} + {description.join(" ")} + + ); +} diff --git a/components/workspace/use-cli-commands.tsx b/components/workspace/use-cli-commands.tsx index e08e5eb..0fc2f56 100644 --- a/components/workspace/use-cli-commands.tsx +++ b/components/workspace/use-cli-commands.tsx @@ -12,6 +12,7 @@ import clsx from "clsx"; import { fileContentToZip } from "@/lib/file-content-to-zip"; import { saveAs } from "file-saver"; import { useSetSearchParams } from "@/lib/set-search-params"; +import { FormatErrors } from "./format-errors"; export function useCliCommands() { const terminalContext = useContext(TerminalContext); @@ -181,9 +182,7 @@ export function useCliCommands() { const { message } = await res.json(); terminalContext.setBufferedContent( - <> -

{message}

- + ); } catch (err) { if (err instanceof Error)