diff --git a/packages/cli/package.json b/packages/cli/package.json index a499840c6..c21092c9c 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -59,7 +59,7 @@ "tsup": "^8.0.0", "type-fest": "^3.13.1", "typescript": "^5.0.0", - "valibot": "^0.30.0", + "valibot": "^0.36.0", "vitest": "^0.34.6" } } diff --git a/packages/cli/src/commands/add.ts b/packages/cli/src/commands/add.ts index 93cd116c5..708b1096e 100644 --- a/packages/cli/src/commands/add.ts +++ b/packages/cli/src/commands/add.ts @@ -33,7 +33,7 @@ const addOptionsSchema = v.object({ proxy: v.optional(v.string()), }); -type AddOptions = v.Output; +type AddOptions = v.InferOutput; export const add = new Command() .command("add") diff --git a/packages/cli/src/commands/update.ts b/packages/cli/src/commands/update.ts index fb175c9bd..ac887e9b4 100644 --- a/packages/cli/src/commands/update.ts +++ b/packages/cli/src/commands/update.ts @@ -25,7 +25,7 @@ const updateOptionsSchema = v.object({ yes: v.boolean(), }); -type UpdateOptions = v.Output; +type UpdateOptions = v.InferOutput; export const update = new Command() .command("update") diff --git a/packages/cli/src/utils/get-config.ts b/packages/cli/src/utils/get-config.ts index 5449b8851..859ff4e0a 100644 --- a/packages/cli/src/utils/get-config.ts +++ b/packages/cli/src/utils/get-config.ts @@ -27,27 +27,33 @@ export const rawConfigSchema = v.object({ // cssVariables: v.boolean().default(true) }), aliases: v.object({ - components: v.transform(v.string(), (v) => v.replace(/[\u{0080}-\u{FFFF}]/gu, "")), - utils: v.transform(v.string(), (v) => v.replace(/[\u{0080}-\u{FFFF}]/gu, "")), + components: v.pipe( + v.string(), + v.transform((v) => v.replace(/[\u{0080}-\u{FFFF}]/gu, "")) + ), + utils: v.pipe( + v.string(), + v.transform((v) => v.replace(/[\u{0080}-\u{FFFF}]/gu, "")) + ), }), typescript: v.optional(v.boolean(), true), }); -export type RawConfig = v.Output; +export type RawConfig = v.InferOutput; -export const configSchema = v.merge([ - rawConfigSchema, - v.object({ +export const configSchema = v.object({ + ...rawConfigSchema.entries, + ...v.object({ resolvedPaths: v.object({ tailwindConfig: v.string(), tailwindCss: v.string(), utils: v.string(), components: v.string(), }), - }), -]); + }).entries, +}); -export type Config = v.Output; +export type Config = v.InferOutput; export async function getConfig(cwd: string) { const config = await getRawConfig(cwd); diff --git a/packages/cli/src/utils/registry/index.ts b/packages/cli/src/utils/registry/index.ts index f88dd8010..a1cd2d09f 100644 --- a/packages/cli/src/utils/registry/index.ts +++ b/packages/cli/src/utils/registry/index.ts @@ -10,7 +10,7 @@ import * as schemas from "./schema.js"; const baseUrl = process.env.COMPONENTS_REGISTRY_URL ?? "https://shadcn-svelte.com"; -export type RegistryItem = v.Output; +export type RegistryItem = v.InferOutput; export async function getRegistryIndex() { try { @@ -70,7 +70,7 @@ export async function getRegistryBaseColor(baseColor: string) { } } -type RegistryIndex = v.Output; +type RegistryIndex = v.InferOutput; export async function resolveTree(index: RegistryIndex, names: string[], includeRegDeps = true) { const tree: RegistryIndex = []; @@ -108,7 +108,7 @@ export async function fetchTree(config: Config, tree: RegistryIndex) { export function getItemTargetPath( config: Config, - item: Pick, "type">, + item: Pick, "type">, override?: string ) { // Allow overrides for all items but ui. diff --git a/packages/cli/src/utils/registry/schema.ts b/packages/cli/src/utils/registry/schema.ts index 361735342..cd5ee822c 100644 --- a/packages/cli/src/utils/registry/schema.ts +++ b/packages/cli/src/utils/registry/schema.ts @@ -10,17 +10,17 @@ export const registryItemSchema = v.object({ export const registryIndexSchema = v.array(registryItemSchema); -export const registryItemWithContentSchema = v.merge([ - registryItemSchema, - v.object({ +export const registryItemWithContentSchema = v.object({ + ...registryItemSchema.entries, + ...v.object({ files: v.array( v.object({ name: v.string(), content: v.string(), }) ), - }), -]); + }).entries, +}); export const registryWithContentSchema = v.array(registryItemWithContentSchema); diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index bfe4ee7e7..1b3908306 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -385,8 +385,8 @@ importers: specifier: ^5.0.0 version: 5.3.3 valibot: - specifier: ^0.30.0 - version: 0.30.0 + specifier: ^0.36.0 + version: 0.36.0 vitest: specifier: ^0.34.6 version: 0.34.6 @@ -9148,6 +9148,13 @@ packages: /valibot@0.30.0: resolution: {integrity: sha512-5POBdbSkM+3nvJ6ZlyQHsggisfRtyT4tVTo1EIIShs6qCdXJnyWU5TJ68vr8iTg5zpOLjXLRiBqNx+9zwZz/rA==} + requiresBuild: true + dev: false + optional: true + + /valibot@0.36.0: + resolution: {integrity: sha512-CjF1XN4sUce8sBK9TixrDqFM7RwNkuXdJu174/AwmQUB62QbCQADg5lLe8ldBalFgtj1uKj+pKwDJiNo4Mn+eQ==} + dev: true /validate-npm-package-license@3.0.4: resolution: {integrity: sha512-DpKm2Ui/xN7/HQKCtpZxoRWBhZ9Z0kqtygG8XCgNQ8ZlDnxuQmWhj566j8fN4Cu3/JmbhsDo7fcAJq4s9h27Ew==}