mirror of
https://github.com/shadcn-ui/ui.git
synced 2026-06-30 08:04:18 +00:00
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:
5
.changeset/fix-universal-registry-item-empty-files.md
Normal file
5
.changeset/fix-universal-registry-item-empty-files.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"shadcn": patch
|
||||
---
|
||||
|
||||
Fix support for universal registry items that only have dependencies without files
|
||||
@@ -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", () => {
|
||||
|
||||
@@ -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")
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user