Skip to main content
Glama
reuvenaor

Shadcn Registry manager

by reuvenaor
update-app-index.ts856 B
import fs from "fs/promises" import path from "path" import { getRegistryItem } from "@/src/registry/api" import { Config } from "@/src/utils/get-config" export async function updateAppIndex(component: string, config: Config) { const indexPath = path.join(config.resolvedPaths.cwd, "app/page.tsx") if (!(await fs.stat(indexPath)).isFile()) { return } const registryItem = await getRegistryItem(component, config.style) if ( !registryItem?.meta?.importSpecifier || !registryItem?.meta?.moduleSpecifier ) { return } // Overwrite the index file with the new import. const content = `import { ${registryItem?.meta?.importSpecifier} } from "${registryItem.meta.moduleSpecifier}"\n\nexport default function Page() {\n return <${registryItem?.meta?.importSpecifier} />\n}` await fs.writeFile(indexPath, content, "utf8") }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/reuvenaor/shadcn-registry-manager'

If you have feedback or need assistance with the MCP directory API, please join our Discord server