From 0fbd5f0b84a159699b8dcd8ea4e75416a7e2b2a0 Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Sun, 20 Jul 2025 17:03:48 -0500 Subject: [PATCH] Add missing FS methods needed by isomorphic-git --- src/components/Shakespeare/ChatPane.tsx | 2 ++ src/lib/JSRuntime.ts | 2 ++ src/lib/LightningFSAdapter.ts | 12 ++++++++++-- src/lib/WebContainerAdapter.ts | 14 ++++++++++++-- 4 files changed, 26 insertions(+), 4 deletions(-) diff --git a/src/components/Shakespeare/ChatPane.tsx b/src/components/Shakespeare/ChatPane.tsx index 3fafc19c..b235f1a1 100644 --- a/src/components/Shakespeare/ChatPane.tsx +++ b/src/components/Shakespeare/ChatPane.tsx @@ -45,6 +45,8 @@ export function ChatPane({ projectId, projectName }: ChatPaneProps) { }; const runBuild = async () => { + console.log('Running build for project:', projectId); + // Copy project files to runtime filesystem const projectPath = `/projects/${projectId}`; try { diff --git a/src/lib/JSRuntime.ts b/src/lib/JSRuntime.ts index f5cc2c80..cbb6f70e 100644 --- a/src/lib/JSRuntime.ts +++ b/src/lib/JSRuntime.ts @@ -45,6 +45,8 @@ export interface JSRuntimeFS { unlink(path: string): Promise; rmdir(path: string): Promise; rename(oldPath: string, newPath: string): Promise; + readlink(path: string): Promise; + symlink(target: string, path: string): Promise; } /** diff --git a/src/lib/LightningFSAdapter.ts b/src/lib/LightningFSAdapter.ts index 72419f65..77dfedfb 100644 --- a/src/lib/LightningFSAdapter.ts +++ b/src/lib/LightningFSAdapter.ts @@ -35,8 +35,8 @@ export class LightningFSAdapter implements JSRuntimeFS { const stat = await this.lightningFS.stat(itemPath); entries.push({ name: item, - isDirectory: stat.isDirectory.bind(stat), - isFile: stat.isFile.bind(stat), + isDirectory: () => stat.isDirectory(), + isFile: () => stat.isFile(), }); } catch { // If stat fails, assume it's a file @@ -102,4 +102,12 @@ export class LightningFSAdapter implements JSRuntimeFS { async rename(oldPath: string, newPath: string): Promise { return this.lightningFS.rename(oldPath, newPath); } + + async readlink(path: string): Promise { + return this.lightningFS.readlink(path); + } + + async symlink(target: string, path: string): Promise { + return this.lightningFS.symlink(target, path); + } } \ No newline at end of file diff --git a/src/lib/WebContainerAdapter.ts b/src/lib/WebContainerAdapter.ts index 9baaa888..413f0f9a 100644 --- a/src/lib/WebContainerAdapter.ts +++ b/src/lib/WebContainerAdapter.ts @@ -77,9 +77,9 @@ class WebContainerFSAdapter implements JSRuntimeFS { async readdir(path: string, options?: { withFileTypes?: boolean }): Promise; async readdir(path: string, options?: { withFileTypes?: boolean }): Promise { if (options?.withFileTypes) { - return this.webcontainer.fs.readdir(path, { withFileTypes: true }) as Promise; + return this.webcontainer.fs.readdir(path, { withFileTypes: true }); } else { - return this.webcontainer.fs.readdir(path) as Promise; + return this.webcontainer.fs.readdir(path); } } @@ -156,4 +156,14 @@ class WebContainerFSAdapter implements JSRuntimeFS { // Note: We can't delete the old file since WebContainer doesn't expose unlink console.warn('WebContainer rename: copied file but could not delete original'); } + + async readlink(_path: string): Promise { + // WebContainer doesn't support symlinks, so we'll throw an error + throw new Error('readlink operation not supported in WebContainer'); + } + + async symlink(_target: string, _path: string): Promise { + // WebContainer doesn't support symlinks, so we'll throw an error + throw new Error('symlink operation not supported in WebContainer'); + } } \ No newline at end of file