Skip to main content
Glama
migrate_templates.ts1.55 kB
import fs from "fs/promises"; import path from "path"; import { fileURLToPath } from "url"; const __filename = fileURLToPath(import.meta.url); const __dirname = path.dirname(__filename); const TEMPLATES_DIR = path.resolve(__dirname, "../src/data/templates"); async function migrate() { console.log(`Scanning ${TEMPLATES_DIR}...`); // Helper to recurse async function scan(dir: string) { const entries = await fs.readdir(dir, { withFileTypes: true }); for (const entry of entries) { const fullPath = path.join(dir, entry.name); if (entry.isDirectory()) { await scan(fullPath); } else if (entry.isFile() && entry.name.endsWith(".ts")) { await convert(fullPath); } } } async function convert(filePath: string) { try { const content = await fs.readFile(filePath, "utf-8"); // Just wrap the entire file content in a markdown code block // This supports both "string exports" (if properly formatted) and raw code files const newContent = "```typescript\n" + content + "\n```"; const newPath = filePath.replace(/\.ts$/, ".md"); await fs.writeFile(newPath, newContent, "utf-8"); console.log( `Converted: ${path.relative(TEMPLATES_DIR, filePath)} -> .md`, ); // Optional: Delete original // await fs.unlink(filePath); } catch (err) { console.error(`Error converting ${filePath}:`, err); } } await scan(TEMPLATES_DIR); console.log("Migration complete."); } migrate().catch(console.error);

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/millsydotdev/Code-MCP'

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