diff --git a/src/hooks/useIsProjectPreviewable.ts b/src/hooks/useIsProjectPreviewable.ts index e3c919ae..eb84ea35 100644 --- a/src/hooks/useIsProjectPreviewable.ts +++ b/src/hooks/useIsProjectPreviewable.ts @@ -13,12 +13,9 @@ export function useIsProjectPreviewable(projectId: string) { queryFn: async () => { try { // Check for required files - const [hasIndexHtml, hasPackageJson] = await Promise.all([ - projectsManager.fileExists(projectId, 'index.html'), - projectsManager.fileExists(projectId, 'package.json'), - ]); + const hasIndexHtml = await projectsManager.fileExists(projectId, 'index.html'); - return hasIndexHtml && hasPackageJson; + return hasIndexHtml; } catch (error) { console.error('Failed to check if project is previewable:', error); return false; diff --git a/src/lib/build/index.ts b/src/lib/build/index.ts index 23ceea44..77833cf0 100644 --- a/src/lib/build/index.ts +++ b/src/lib/build/index.ts @@ -32,11 +32,16 @@ async function bundle( ); // Read package.json - const packageJsonText = await fs.readFile( - `${projectPath}/package.json`, - "utf8", - ); - const packageJson = JSON.parse(packageJsonText); + let packageJson; + try { + const packageJsonText = await fs.readFile( + `${projectPath}/package.json`, + "utf8", + ); + packageJson = JSON.parse(packageJsonText); + } catch { + packageJson = {}; + } // Try to read tsconfig.json let tsconfig; @@ -187,13 +192,6 @@ export async function buildProject(options: BuildProjectOptions): Promise<{ }> { const { fs, projectPath, outputPath = `${projectPath}/dist` } = options; - // Check if we're in a valid project directory - try { - await fs.readFile(`${projectPath}/package.json`, "utf8"); - } catch { - throw new Error(`❌ Could not find package.json at ${projectPath}. Make sure you're in a valid project directory.`); - } - // Check if index.html exists try { await fs.readFile(`${projectPath}/index.html`, "utf8");