Skip to content

Commit 4105f71

Browse files
committed
fix(schema): derive rawConfigSchemaDeepPartial from rawConfigSchema
Address Copilot review feedback by deriving rawConfigSchemaDeepPartial from rawConfigSchema using .extend() instead of duplicating fields. This fixes the missing rtl field and prevents future drift between the two schemas. - Add test case for rtl field acceptance - Remove misleading comment about config source
1 parent e048499 commit 4105f71

File tree

2 files changed

+20
-13
lines changed

2 files changed

+20
-13
lines changed

packages/shadcn/src/registry/schema.test.ts

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,23 @@ describe("rawConfigSchemaDeepPartial", () => {
117117
expect(result.success).toBe(true)
118118
})
119119

120+
it("should accept config with rtl field", () => {
121+
const configWithRtl = {
122+
style: "vega",
123+
rtl: true,
124+
tailwind: {
125+
baseColor: "neutral",
126+
},
127+
}
128+
129+
const result = rawConfigSchemaDeepPartial.safeParse(configWithRtl)
130+
expect(result.success).toBe(true)
131+
if (result.success) {
132+
expect(result.data.rtl).toBe(true)
133+
}
134+
})
135+
120136
it("should validate real-world registry:base config", () => {
121-
// Example from apps/v4/registry/config.ts
122137
const realWorldConfig = {
123138
style: "radix-vega",
124139
iconLibrary: "lucide",

packages/shadcn/src/registry/schema.ts

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -58,22 +58,14 @@ export const rawConfigSchema = z
5858
})
5959
.strict()
6060

61-
// Deep partial version for registry:base config field
62-
export const rawConfigSchemaDeepPartial = z
63-
.object({
64-
$schema: z.string().optional(),
65-
style: z.string(),
66-
rsc: z.coerce.boolean().default(false),
67-
tsx: z.coerce.boolean().default(true),
61+
// Deep partial version for registry:base config field.
62+
// Derived from rawConfigSchema to prevent field drift.
63+
export const rawConfigSchemaDeepPartial = rawConfigSchema
64+
.extend({
6865
tailwind: tailwindConfigSchema.partial(),
69-
iconLibrary: z.string().optional(),
70-
menuColor: z.enum(["default", "inverted"]).default("default").optional(),
71-
menuAccent: z.enum(["subtle", "bold"]).default("subtle").optional(),
7266
aliases: aliasesSchema.partial(),
73-
registries: registryConfigSchema.optional(),
7467
})
7568
.partial()
76-
.strict()
7769

7870
export const configSchema = rawConfigSchema.extend({
7971
resolvedPaths: z.object({

0 commit comments

Comments
 (0)