Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 17 additions & 8 deletions apps/registry/server/utils/registry-builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,17 @@ function parseImportsFromCode(code: string): string[] {
}
}

function extractRegistrySlug(modulePath: string, basePath: string): string {
if (!modulePath.startsWith(basePath))
return ''

const rest = modulePath.slice(basePath.length)
.split('/')
.filter(Boolean)

return rest[0] || ''
}

function analyzeDependencies(
imports: string[],
allowedDeps: Set<string>,
Expand Down Expand Up @@ -110,18 +121,16 @@ function analyzeDependencies(

// Handle shadcn-vue components
if (mod.startsWith('@/components/ui/')) {
const componentName = mod.split('/').pop() || ''
if (componentName) {
registryDependencies.add(componentName)
}
const slug = extractRegistrySlug(mod, '@/components/ui/')
if (slug)
registryDependencies.add(slug)
}

// Handle AI elements components
if (mod.startsWith('@/components/ai-elements/')) {
const componentName = mod.split('/').pop() || ''
if (componentName) {
registryDependencies.add(`/${componentName}.json`)
}
const slug = extractRegistrySlug(mod, '@/components/ai-elements/')
if (slug)
registryDependencies.add(slug)
}
}

Expand Down