From 0fa7093461ff3067f36ca94d2fcca46a2fa1b21a Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Fri, 18 Jul 2025 14:47:47 -0500 Subject: [PATCH] Run build and install together (it works wtf!!!!) --- src/components/Shakespeare/ChatPane.tsx | 29 ++++++++++++------------- src/lib/fs.ts | 7 +++--- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/components/Shakespeare/ChatPane.tsx b/src/components/Shakespeare/ChatPane.tsx index 0fc0c0a7..52ea9082 100644 --- a/src/components/Shakespeare/ChatPane.tsx +++ b/src/components/Shakespeare/ChatPane.tsx @@ -77,18 +77,19 @@ export function ChatPane({ projectId, projectName }: ChatPaneProps) { const proc = await webcontainer.spawn('npm', ['i']); await proc.exit; - console.log(await webcontainer.fs.readdir('.')); + const proc2 = await webcontainer.spawn('npm', ['run', 'build']); + await proc2.exit; - // Copy "node_modules" out of the webcontainer back to the project directory - const copyNodeModules = async () => { + // Copy "dist" out of the webcontainer back to the project directory + const copyDist = async () => { try { - // Read the node_modules directory from webcontainer - const nodeModulesContents = await webcontainer.fs.readdir('node_modules', { withFileTypes: true }); + // Read the dist directory from webcontainer + const distContents = await webcontainer.fs.readdir('dist', { withFileTypes: true }); - // Create node_modules directory in project if it doesn't exist - const nodeModulesPath = `/projects/${projectId}/node_modules`; + // Create dist directory in project if it doesn't exist + const distPath = `/projects/${projectId}/dist`; try { - await fsManager.fs.promises.mkdir(nodeModulesPath); + await fsManager.fs.promises.mkdir(distPath); } catch { // Directory might already exist, that's fine } @@ -123,10 +124,10 @@ export function ChatPane({ projectId, projectName }: ChatPaneProps) { } }; - // Copy each package in node_modules - for (const item of nodeModulesContents) { - const sourcePath = `node_modules/${item.name}`; - const destPath = `${nodeModulesPath}/${item.name}`; + // Copy each package in dist + for (const item of distContents) { + const sourcePath = `dist/${item.name}`; + const destPath = `${distPath}/${item.name}`; try { if (item.isDirectory()) { @@ -149,9 +150,7 @@ export function ChatPane({ projectId, projectName }: ChatPaneProps) { } }; - await copyNodeModules(); - - // const buildProcess = await webcontainer.spawn('npm', ['run', 'build']); + await copyDist(); }; useEffect(() => { diff --git a/src/lib/fs.ts b/src/lib/fs.ts index 16371e25..67604de6 100644 --- a/src/lib/fs.ts +++ b/src/lib/fs.ts @@ -8,6 +8,9 @@ if (typeof window !== 'undefined') { (window as { Buffer?: typeof Buffer }).Buffer = Buffer; } +// const GIT_TEMPLATE_URL = 'https://relay.ngit.dev/npub1q3sle0kvfsehgsuexttt3ugjd8xdklxfwwkh559wxckmzddywnws6cd26p/mkstack.git'; +const GIT_TEMPLATE_URL = 'https://relay.ngit.dev/npub1q3sle0kvfsehgsuexttt3ugjd8xdklxfwwkh559wxckmzddywnws6cd26p/lovable-blank.git'; + export interface Project { id: string; name: string; @@ -60,14 +63,12 @@ export class FileSystemManager { } async cloneTemplate(projectPath: string) { - const templateUrl = 'https://relay.ngit.dev/npub1q3sle0kvfsehgsuexttt3ugjd8xdklxfwwkh559wxckmzddywnws6cd26p/mkstack.git'; - try { await git.clone({ fs: this.fs, http, dir: projectPath, - url: templateUrl, + url: GIT_TEMPLATE_URL, singleBranch: true, depth: 1, });