From b720723883bfb5d6c2c3c1cfbe62854982695ad7 Mon Sep 17 00:00:00 2001 From: "yongen.loong" Date: Fri, 16 Aug 2024 14:25:55 +0800 Subject: [PATCH] log build result --- app/api/build/route.ts | 8 ++++++-- components/workspace/use-cli-commands.tsx | 1 + 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/app/api/build/route.ts b/app/api/build/route.ts index 43255b0..d19afe8 100644 --- a/app/api/build/route.ts +++ b/app/api/build/route.ts @@ -3,7 +3,7 @@ import { getBuildServerBaseUrl, getSolangBuildServerBaseUrl } from "@/lib/env"; import { fileContentToZip } from "@/lib/file-content-to-zip"; import { type NextRequest } from "next/server"; import { v4 as uuidv4 } from "uuid"; -import { strToU8 } from "fflate"; +import { strFromU8, strToU8 } from "fflate"; export async function POST(request: NextRequest) { const { files } = (await request.json()) as { files: FileContent[] }; @@ -61,7 +61,11 @@ export async function POST(request: NextRequest) { return Response.json({ error: message }, { status: response.status }); } - return Response.json({ dll: (await response.json()).compileResult }); + const { compileResult } = (await response.json()) || {}; + + const str = strFromU8(Buffer.from(compileResult, "base64")); + + return Response.json({ dll: str }); } else { return Response.json({ error: "Invalid input files" }, { status: 400 }); } diff --git a/components/workspace/use-cli-commands.tsx b/components/workspace/use-cli-commands.tsx index ebab42c..ea077ef 100644 --- a/components/workspace/use-cli-commands.tsx +++ b/components/workspace/use-cli-commands.tsx @@ -118,6 +118,7 @@ export function useCliCommands() { body: JSON.stringify({ files }), }); const { dll, error } = await res.json(); + console.log(dll, "-- build result"); if (typeof dll === "string" && !error) { await db.workspaces.update(id, { dll }); terminalContext.setBufferedContent(