UNPKG

arela

Version:

AI-powered CTO with multi-agent orchestration, code summarization, visual testing (web + mobile) for blazing fast development.

173 lines โ€ข 5.41 kB
/** * Generate descriptive slice names from file patterns */ /** * Suggest a name for a slice based on its files */ export function suggestSliceName(files) { if (files.length === 0) { return "feature"; } // Extract directory names (first component of path) const dirCounts = new Map(); for (const file of files) { const parts = file.split("/"); const dir = parts[0]; if (dir && dir !== "." && !dir.startsWith(".")) { dirCounts.set(dir, (dirCounts.get(dir) || 0) + 1); } } // Get most common directory let mostCommonDir = ""; let maxCount = 0; for (const [dir, count] of dirCounts) { if (count > maxCount) { maxCount = count; mostCommonDir = dir; } } // Try common patterns const commonPatterns = { auth: "๐Ÿ” authentication", user: "๐Ÿ‘ค user", workout: "๐Ÿ’ช workout", exercise: "๐Ÿ‹๏ธ exercise", nutrition: "๐Ÿฅ— nutrition", meal: "๐Ÿฝ๏ธ meals", social: "๐Ÿ‘ฅ social", feed: "๐Ÿ“ฐ feed", friend: "๐Ÿ‘ซ friends", message: "๐Ÿ’ฌ messaging", chat: "๐Ÿ’ฌ chat", payment: "๐Ÿ’ณ billing", billing: "๐Ÿ’ฐ payments", admin: "โš™๏ธ admin", account: "๐Ÿ”‘ account", settings: "โš™๏ธ settings", profile: "๐Ÿ‘ค profile", search: "๐Ÿ” search", api: "๐Ÿ”Œ api", service: "๐Ÿ”ง service", util: "๐Ÿ› ๏ธ utilities", component: "๐ŸŽจ components", layout: "๐Ÿ“ layout", theme: "๐ŸŽจ theme", style: "๐Ÿ’„ styling", test: "๐Ÿงช testing", spec: "๐Ÿ“ specs", config: "โš™๏ธ config", env: "๐Ÿ”ง environment", db: "๐Ÿ’พ database", store: "๐Ÿ’พ storage", cache: "โšก cache", queue: "๐Ÿ“ฆ queue", job: "โฐ jobs", worker: "๐Ÿ”„ workers", hook: "๐Ÿช hooks", middleware: "๐Ÿ”— middleware", guard: "๐Ÿ›ก๏ธ guards", interceptor: "๐Ÿ”€ interceptors", directive: "๐Ÿ“ directives", filter: "๐Ÿงน filters", pipe: "๐Ÿ’จ pipes", resolver: "๐Ÿ” resolvers", gateway: "๐Ÿšช gateway", controller: "๐ŸŽฎ controllers", handler: "๐Ÿ“ handlers", listener: "๐Ÿ‘‚ listeners", event: "๐Ÿ“ข events", command: "โŒจ๏ธ commands", query: "โ“ queries", mutation: "โœ๏ธ mutations", subscription: "๐Ÿ“ก subscriptions", }; // Check for pattern matches in file names const fileContent = files.join(" ").toLowerCase(); for (const [pattern, name] of Object.entries(commonPatterns)) { if (fileContent.includes(pattern)) { return name; } } // Use most common directory if found if (mostCommonDir && mostCommonDir in commonPatterns) { return commonPatterns[mostCommonDir]; } // Fallback to directory name if (mostCommonDir) { return formatSliceName(mostCommonDir); } return "feature"; } /** * Format a slice name from raw input */ function formatSliceName(name) { // Convert snake_case, kebab-case, camelCase to title case const formatted = name .replace(/([a-z])([A-Z])/g, "$1 $2") // camelCase .replace(/[-_]/g, " ") // kebab-case, snake_case .toLowerCase() .trim(); return formatted.charAt(0).toUpperCase() + formatted.slice(1); } /** * Get emoji for a feature type */ export function getFeatureEmoji(sliceName) { const emojis = { "๐Ÿ” authentication": "๐Ÿ”", "๐Ÿ‘ค user": "๐Ÿ‘ค", "๐Ÿ’ช workout": "๐Ÿ’ช", "๐Ÿ‹๏ธ exercise": "๐Ÿ‹๏ธ", "๐Ÿฅ— nutrition": "๐Ÿฅ—", "๐Ÿฝ๏ธ meals": "๐Ÿฝ๏ธ", "๐Ÿ‘ฅ social": "๐Ÿ‘ฅ", "๐Ÿ“ฐ feed": "๐Ÿ“ฐ", "๐Ÿ‘ซ friends": "๐Ÿ‘ซ", "๐Ÿ’ฌ messaging": "๐Ÿ’ฌ", "๐Ÿ’ฌ chat": "๐Ÿ’ฌ", "๐Ÿ’ณ billing": "๐Ÿ’ณ", "๐Ÿ’ฐ payments": "๐Ÿ’ฐ", "โš™๏ธ admin": "โš™๏ธ", "๐Ÿ”‘ account": "๐Ÿ”‘", "โš™๏ธ settings": "โš™๏ธ", "๐Ÿ‘ค profile": "๐Ÿ‘ค", "๐Ÿ” search": "๐Ÿ”", "๐Ÿ”Œ api": "๐Ÿ”Œ", "๐Ÿ”ง service": "๐Ÿ”ง", "๐Ÿ› ๏ธ utilities": "๐Ÿ› ๏ธ", "๐ŸŽจ components": "๐ŸŽจ", "๐Ÿ“ layout": "๐Ÿ“", "๐ŸŽจ theme": "๐ŸŽจ", "๐Ÿ’„ styling": "๐Ÿ’„", "๐Ÿงช testing": "๐Ÿงช", "๐Ÿ“ specs": "๐Ÿ“", "โš™๏ธ config": "โš™๏ธ", "๐Ÿ”ง environment": "๐Ÿ”ง", "๐Ÿ’พ database": "๐Ÿ’พ", "๐Ÿ’พ storage": "๐Ÿ’พ", "โšก cache": "โšก", "๐Ÿ“ฆ queue": "๐Ÿ“ฆ", "โฐ jobs": "โฐ", "๐Ÿ”„ workers": "๐Ÿ”„", "๐Ÿช hooks": "๐Ÿช", "๐Ÿ”— middleware": "๐Ÿ”—", "๐Ÿ›ก๏ธ guards": "๐Ÿ›ก๏ธ", "๐Ÿ”€ interceptors": "๐Ÿ”€", "๐Ÿ“ directives": "๐Ÿ“", "๐Ÿงน filters": "๐Ÿงน", "๐Ÿ’จ pipes": "๐Ÿ’จ", "๐Ÿ” resolvers": "๐Ÿ”", "๐Ÿšช gateway": "๐Ÿšช", "๐ŸŽฎ controllers": "๐ŸŽฎ", "๐Ÿ“ handlers": "๐Ÿ“", "๐Ÿ‘‚ listeners": "๐Ÿ‘‚", "๐Ÿ“ข events": "๐Ÿ“ข", "โŒจ๏ธ commands": "โŒจ๏ธ", "โ“ queries": "โ“", "โœ๏ธ mutations": "โœ๏ธ", "๐Ÿ“ก subscriptions": "๐Ÿ“ก", }; return emojis[sliceName] || "โœจ"; } //# sourceMappingURL=slice-namer.js.map