Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/api/generate/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export async function POST(request: NextRequest) {

// // Repair the generated code using Benchify's API
const { repairedFiles, buildOutput } = await repairCode(validatedFiles);

const { sbxId, template, url } = await createSandbox({ files: generatedFiles });

console.log("Preview URL: ", url);
Expand Down
4 changes: 2 additions & 2 deletions lib/benchify.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ if (!BENCHIFY_API_KEY) {
export async function repairCode(files: z.infer<typeof benchifyFileSchema>): Promise<{ repairedFiles: z.infer<typeof benchifyFileSchema>, buildOutput: string }> {
try {
// Simple build command to verify syntax
const buildCmd = "npm run dev";
const buildCmd = "npx vite build";

// Validate request against Benchify API schema
const requestData = benchifyRequestSchema.parse({
Expand Down Expand Up @@ -71,7 +71,7 @@ export async function repairCode(files: z.infer<typeof benchifyFileSchema>): Pro
const parsedFiles = benchifyFileSchema.parse(files);
const repairedFiles = parsedFiles.map(file => {
if (result.diff) {
const patchResult = applyPatch(file.contents, result.diff);
const patchResult = applyPatch(file.content, result.diff);
return {
path: file.path,
content: typeof patchResult === 'string' ? patchResult : file.content
Expand Down
2 changes: 1 addition & 1 deletion lib/e2b.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export async function createSandbox({ files }: { files: z.infer<typeof benchifyF
const devDependencies = packageJson.devDependencies || {};

// Filter out pre-installed dependencies (vue, tailwindcss, etc.)
const preInstalled = ['vue', 'tailwindcss', 'autoprefixer', 'postcss', 'vite', '@vitejs/plugin-vue', '@vue/compiler-sfc'];
const preInstalled = ['vue', "typescript", 'tailwindcss', 'autoprefixer', 'postcss', 'vite', '@vitejs/plugin-vue', '@vue/compiler-sfc'];

// Get new deps that need to be installed
const newDeps = Object.keys(dependencies).filter(dep => !preInstalled.includes(dep));
Expand Down