Home / Function/ getFileContent() — ui Function Reference

getFileContent() — ui Function Reference

Architecture documentation for the getFileContent() function in registry.ts from the ui codebase.

Entity Profile

Dependency Diagram

graph TD
  40a8af4b_5790_4349_e8f7_061bc4fd234c["getFileContent()"]
  c2827044_b928_a1b2_3033_3282c0588350["registry.ts"]
  40a8af4b_5790_4349_e8f7_061bc4fd234c -->|defined in| c2827044_b928_a1b2_3033_3282c0588350
  9ad02a82_006c_477a_ceba_832cde81fa46["getRegistryItem()"]
  9ad02a82_006c_477a_ceba_832cde81fa46 -->|calls| 40a8af4b_5790_4349_e8f7_061bc4fd234c
  bdf372b3_9618_3a39_a49c_1ed772fa59e1["createTempSourceFile()"]
  40a8af4b_5790_4349_e8f7_061bc4fd234c -->|calls| bdf372b3_9618_3a39_a49c_1ed772fa59e1
  1b5a1233_6e2b_166f_0d28_d440ef8ccea6["removeVariable()"]
  40a8af4b_5790_4349_e8f7_061bc4fd234c -->|calls| 1b5a1233_6e2b_166f_0d28_d440ef8ccea6
  703e6e29_4a38_d9ee_1f63_d1fcb0267d54["fixImport()"]
  40a8af4b_5790_4349_e8f7_061bc4fd234c -->|calls| 703e6e29_4a38_d9ee_1f63_d1fcb0267d54
  style 40a8af4b_5790_4349_e8f7_061bc4fd234c fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

deprecated/www/lib/registry.ts lines 79–109

async function getFileContent(file: z.infer<typeof registryItemFileSchema>) {
  const raw = await fs.readFile(file.path, "utf-8")

  const project = new Project({
    compilerOptions: {},
  })

  const tempFile = await createTempSourceFile(file.path)
  const sourceFile = project.createSourceFile(tempFile, raw, {
    scriptKind: ScriptKind.TSX,
  })

  // Remove meta variables.
  removeVariable(sourceFile, "iframeHeight")
  removeVariable(sourceFile, "containerClassName")
  removeVariable(sourceFile, "description")

  let code = sourceFile.getFullText()

  // Some registry items uses default export.
  // We want to use named export instead.
  // TODO: do we really need this? - @shadcn.
  if (file.type !== "registry:page") {
    code = code.replaceAll("export default", "export")
  }

  // Fix imports.
  code = fixImport(code)

  return code
}

Subdomains

Called By

Frequently Asked Questions

What does getFileContent() do?
getFileContent() is a function in the ui codebase, defined in deprecated/www/lib/registry.ts.
Where is getFileContent() defined?
getFileContent() is defined in deprecated/www/lib/registry.ts at line 79.
What does getFileContent() call?
getFileContent() calls 3 function(s): createTempSourceFile, fixImport, removeVariable.
What calls getFileContent()?
getFileContent() is called by 1 function(s): getRegistryItem.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free