1- import { z } from 'zod'
1+ import { z } from 'zod/v4 '
22import { format } from './colors'
33import type { Command } from './types'
44
@@ -52,7 +52,7 @@ function showCommandHelp({
5252 console . log ( ` ${ command . description } ` )
5353
5454 if ( command . args instanceof z . ZodObject ) {
55- const shape = command . args . shape as z . AnyZodObject
55+ const shape = command . args . shape as z . ZodObject
5656 const entries = Object . entries ( shape )
5757
5858 if ( entries . length > 0 ) {
@@ -79,27 +79,38 @@ function showCommandHelp({
7979 }
8080}
8181
82- function getSchemaType ( schema : z . ZodTypeAny ) : string {
82+ type SupportedZodType =
83+ | z . ZodBoolean
84+ | z . ZodString
85+ | z . ZodNumber
86+ | z . ZodArray
87+ | z . ZodOptional
88+ | z . ZodDefault
89+
90+ function getSchemaType ( schema : SupportedZodType ) : string {
8391 if ( schema instanceof z . ZodBoolean ) return 'boolean'
8492 if ( schema instanceof z . ZodString ) return 'string'
8593 if ( schema instanceof z . ZodNumber ) return 'number'
8694 if ( schema instanceof z . ZodArray ) return 'array'
87- if ( schema instanceof z . ZodOptional ) return getSchemaType ( schema . unwrap ( ) )
88- if ( schema instanceof z . ZodDefault ) return getSchemaType ( schema . removeDefault ( ) )
95+ if ( schema instanceof z . ZodOptional ) return getSchemaType ( schema . def . innerType as SupportedZodType )
96+ if ( schema instanceof z . ZodDefault ) return getSchemaType ( schema . def . innerType as SupportedZodType )
8997 return 'value'
9098}
9199
92- function getSchemaDescription ( schema : z . ZodTypeAny ) : string | undefined {
93- if ( schema instanceof z . ZodOptional ) return getSchemaDescription ( schema . unwrap ( ) )
94- if ( schema instanceof z . ZodDefault ) return getSchemaDescription ( schema . removeDefault ( ) )
100+ function getSchemaDescription ( schema : SupportedZodType ) : string | undefined {
101+ if ( schema instanceof z . ZodOptional )
102+ return getSchemaDescription ( schema . def . innerType as SupportedZodType )
103+ if ( schema instanceof z . ZodDefault )
104+ return getSchemaDescription ( schema . def . innerType as SupportedZodType )
95105 return schema . description
96106}
97107
98- function getSchemaDefaultValue ( schema : z . ZodTypeAny ) : unknown {
108+ function getSchemaDefaultValue ( schema : SupportedZodType ) : unknown {
99109 if ( schema instanceof z . ZodDefault ) {
100- const defaultValue = schema . _def . defaultValue ( )
110+ const defaultValue = schema . def . defaultValue
101111 return defaultValue
102112 }
103- if ( schema instanceof z . ZodOptional ) return getSchemaDefaultValue ( schema . unwrap ( ) )
113+ if ( schema instanceof z . ZodOptional )
114+ return getSchemaDefaultValue ( schema . def . innerType as SupportedZodType )
104115 return undefined
105116}
0 commit comments