fix(registry): handle universal registry items with no files (#8420)

* fix(registry): handle universal registry items with no files

Allow registry items with registryDependencies but no files to be
considered universal registry items. Previously the function required
files.length to be truthy, which excluded valid items with only
registryDependencies.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

* test

---------

Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: shadcn <m@shadcn.com>
This commit is contained in:
Ziad Beyens
2025-10-14 15:14:05 +02:00
committed by GitHub
parent 89ebfdce47
commit 40c3ff513a
3 changed files with 19 additions and 11 deletions

View File

@@ -0,0 +1,5 @@
---
"shadcn": patch
---
Fix support for universal registry items that only have dependencies without files

View File

@@ -216,16 +216,16 @@ describe("isUniversalRegistryItem", () => {
expect(isUniversalRegistryItem(registryItem)).toBe(false)
})
it("should return false when files array is empty", () => {
it("should return true when files array is empty", () => {
const registryItem = {
files: [],
}
expect(isUniversalRegistryItem(registryItem)).toBe(false)
expect(isUniversalRegistryItem(registryItem)).toBe(true)
})
it("should return false when files is undefined", () => {
it("should return true when files is undefined", () => {
const registryItem = {}
expect(isUniversalRegistryItem(registryItem)).toBe(false)
expect(isUniversalRegistryItem(registryItem)).toBe(true)
})
it("should return false when registryItem is null", () => {

View File

@@ -278,13 +278,16 @@ export function isUniversalRegistryItem(
| null
| undefined
): boolean {
return (
!!registryItem?.files?.length &&
registryItem.files.every(
(file) =>
!!file.target &&
(file.type === "registry:file" || file.type === "registry:item")
)
if (!registryItem) {
return false
}
const files = registryItem.files ?? []
return files.every(
(file) =>
!!file.target &&
(file.type === "registry:file" || file.type === "registry:item")
)
}