From 91fc74238e38cfb8a9cdc1b12f8ff5e8ef5e1d7b Mon Sep 17 00:00:00 2001 From: Animesh Pathak Date: Tue, 29 Oct 2024 16:47:14 +0530 Subject: [PATCH 1/3] feat: submodule loading issue solved Signed-off-by: Animesh Pathak --- .gitmodules | 3 --- prebuild.sh | 6 ++++++ 2 files changed, 6 insertions(+), 3 deletions(-) delete mode 100644 .gitmodules create mode 100755 prebuild.sh diff --git a/.gitmodules b/.gitmodules deleted file mode 100644 index a152185b..00000000 --- a/.gitmodules +++ /dev/null @@ -1,3 +0,0 @@ -[submodule "components/atg/demo-projects"] - path = components/atg/demo-projects - url = https://github.com/keploy/demo-projects.git diff --git a/prebuild.sh b/prebuild.sh new file mode 100755 index 00000000..e71ba89e --- /dev/null +++ b/prebuild.sh @@ -0,0 +1,6 @@ +#!/bin/bash +git submodule deinit -f . +# Replace these with your actual submodule repositories and paths +git clone https://github.com/keploy/demo-projects.git --recurse-submodules ./components/atg/demo-projects +# Add more git clone commands for other submodules if needed +git submodule update --init --recursive --force \ No newline at end of file From 4b1aa9a79881a5e1dfb3fd3a0946f209c0457b7b Mon Sep 17 00:00:00 2001 From: Animesh Pathak Date: Tue, 29 Oct 2024 16:52:41 +0530 Subject: [PATCH 2/3] fix: file structure rendering fixed Signed-off-by: Animesh Pathak --- app/api/createFileStructure/route.ts | 25 +++++++++++++++++++++---- package.json | 1 + 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/app/api/createFileStructure/route.ts b/app/api/createFileStructure/route.ts index 510c1dc9..6c9bdc34 100644 --- a/app/api/createFileStructure/route.ts +++ b/app/api/createFileStructure/route.ts @@ -3,7 +3,8 @@ import { NextRequest, NextResponse } from 'next/server'; import { Directory } from '@/components/atg/Editor/utils/file-manager'; import { createFileStructure } from '@/components/atg/Editor/utils/File-Structure'; -import path from 'path'; +import { join } from 'path'; +import { existsSync } from 'fs'; interface ErrorResponse { message: string; @@ -26,13 +27,29 @@ export async function GET( return NextResponse.json({ message: 'Invalid or missing project key' }, { status: 400 }); } - const projectPath = path.join(process.cwd(), pathsMap[projectKey]); + const basePath = process.cwd(); + const projectPath = join(basePath, 'components', 'atg', 'demo-projects', 'projects', 'javaScript'); + + // Check if path exists before proceeding + if (!existsSync(projectPath)) { + console.error(`Path does not exist: ${projectPath}`); + return new NextResponse(JSON.stringify({ + error: 'Project path not found', + path: projectPath + }), { + status: 404, + headers: { 'Content-Type': 'application/json' } + }); + } try { const rootDir = createFileStructure(projectPath); return NextResponse.json(rootDir); } catch (error) { - console.error('Error generating file structure:', error); - return NextResponse.json({ message: 'Error generating file structure' }, { status: 500 }); + console.error('Error in createFileStructure:', error); + return new NextResponse(JSON.stringify({ error: 'Error in Generating Path' }), { + status: 500, + headers: { 'Content-Type': 'application/json' } + }); } } diff --git a/package.json b/package.json index 2d6adfef..372d0cb7 100644 --- a/package.json +++ b/package.json @@ -4,6 +4,7 @@ "private": true, "scripts": { "dev": "next dev", + "prebuild": "chmod +x prebuild.sh && ./prebuild.sh", "build": "next build", "start": "next start", "lint": "next lint" From c3c3091f0c9d11d7bfed79f0d1da0600f75caf87 Mon Sep 17 00:00:00 2001 From: Animesh Pathak Date: Tue, 29 Oct 2024 17:55:06 +0530 Subject: [PATCH 3/3] fix: file structure rendering fixed Signed-off-by: Animesh Pathak --- .gitmodules | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 .gitmodules diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 00000000..a152185b --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "components/atg/demo-projects"] + path = components/atg/demo-projects + url = https://github.com/keploy/demo-projects.git