haoxiang-xu / surface-editor

WebCodeEditor+LLMs is a state-of-the-art web-based Code Editor that leverages the power of large language models to assist in coding. By utilizing a vector database, it establishes intricate relationships between files and code segments.
0 stars 0 forks source link

[Algorithm: Edit File Path for All subFiles or subFolders] #55

Closed haoxiang-xu closed 4 months ago

haoxiang-xu commented 9 months ago

Create new branch from dev new branch new should called "frontend_edit_filePathalgorithm[your name]" function should be wrote inside vecoder/frontend_application/src/COMPONENTs/explorer/explorer.js

Image

Given

  const EXPLORER_FILES = {
    fileName: "vecoder",
    fileType: "folder",
    filePath: "vecoder",
    fileExpend: true,
    files: [
      {
        fileName: "vecoder_sample",
        fileType: "folder",
        filePath: "vecoder/vecoder_sample",
        fileExpend: true,
        files: [
          {
            fileName: ".env",
            fileType: "file",
            filePath: "vecoder/vecoder_sample/.env",
            fileExpend: false,
            files: [],
          },
        ],
      },
    ],
  };

Create a JavaScript function that accepts a JSON object and a file path string as inputs. The function should edit all file paths. eg.

EXAMPLE 1.

INPUT

above json structure and

newPtah/newSubPath/

RETURN

{
    fileName: "vecoder",
    fileType: "folder",
    filePath: "newPtah/newSubPath/vecoder",
    fileExpend: true,
    files: [
      {
        fileName: "vecoder_sample",
        fileType: "folder",
        filePath: "newPtah/newSubPath/vecoder/vecoder_sample",
        fileExpend: true,
        files: [
          {
            fileName: ".env",
            fileType: "file",
            filePath: "newPtah/newSubPath/vecoder/vecoder_sample/.env",
            fileExpend: false,
            files: [],
          },
        ],
      },
    ],
  };