@@ -54,9 +54,7 @@ describe('CLI binary help output', () => {
5454 it ( 'should display help without plugins' , async ( ) => {
5555 const output = await executeBin ( [ 'openapi' , '--help' ] ) ;
5656 expect ( output ) . toMatchInlineSnapshot ( `
57- "ℹ ✨ OpenAPI Qraft 2.15.0-beta.0
58-
59- Usage: qraft openapi [input] [options]
57+ "Usage: qraft openapi [input] [options]
6058
6159 Arguments:
6260 input Input OpenAPI Document file path, URL (json, yml) (default: null)
@@ -91,9 +89,7 @@ describe('CLI binary help output', () => {
9189 '--help' ,
9290 ] ) ;
9391 expect ( output ) . toMatchInlineSnapshot ( `
94- "ℹ ✨ OpenAPI Qraft 2.15.0-beta.0
95-
96- Usage: qraft openapi --plugin tanstack-query-react [input] [options]
92+ "Usage: qraft openapi --plugin tanstack-query-react [input] [options]
9793
9894 Generate a TanStack Query React client from OpenAPI Document
9995
@@ -136,9 +132,7 @@ describe('CLI binary help output', () => {
136132 '--help' ,
137133 ] ) ;
138134 expect ( output ) . toMatchInlineSnapshot ( `
139- "ℹ ✨ OpenAPI Qraft 2.15.0-beta.0
140-
141- Usage: qraft openapi --plugin openapi-typescript [input] [options]
135+ "Usage: qraft openapi --plugin openapi-typescript [input] [options]
142136
143137 Generate a type-safe TanStack Query client for React from an OpenAPI Document.
144138
@@ -192,9 +186,7 @@ describe('CLI binary help output', () => {
192186 '--help' ,
193187 ] ) ;
194188 expect ( output ) . toMatchInlineSnapshot ( `
195- "ℹ ✨ OpenAPI Qraft 2.15.0-beta.0
196-
197- Usage: qraft openapi --plugin tanstack-query-react --plugin openapi-typescript [input] [options]
189+ "Usage: qraft openapi --plugin tanstack-query-react --plugin openapi-typescript [input] [options]
198190
199191 Generate a type-safe TanStack Query client for React from an OpenAPI Document.
200192
@@ -250,9 +242,7 @@ describe('CLI binary help output', () => {
250242 it ( 'should display help without plugins' , async ( ) => {
251243 const output = await executeBin ( [ 'asyncapi' , '--help' ] ) ;
252244 expect ( output ) . toMatchInlineSnapshot ( `
253- "ℹ ✨ AsyncAPI Qraft 1.0.0
254-
255- Usage: qraft asyncapi [input] [options]
245+ "Usage: qraft asyncapi [input] [options]
256246
257247 Arguments:
258248 input Input AsyncAPI Document file path, URL
@@ -296,9 +286,7 @@ describe('CLI binary help output', () => {
296286 '--help' ,
297287 ] ) ;
298288 expect ( output ) . toMatchInlineSnapshot ( `
299- "ℹ ✨ AsyncAPI Qraft 1.0.0
300-
301- Usage: qraft asyncapi --plugin asyncapi-typescript [input] [options]
289+ "Usage: qraft asyncapi --plugin asyncapi-typescript [input] [options]
302290
303291 Generate TypeScript types from an AsyncAPI Document.
304292
@@ -360,6 +348,21 @@ function stripAnsiCodes(str: string): string {
360348 ) ;
361349}
362350
351+ function stripVersionLine ( str : string ) : string {
352+ const lines = str . split ( '\n' ) ;
353+ if (
354+ lines . length > 0 &&
355+ / ℹ \s * ✨ \s * ( O p e n A P I | A s y n c A P I ) \s + Q r a f t \s + [ \d . ] + / . test ( lines [ 0 ] )
356+ ) {
357+ const remaining = lines . slice ( 1 ) ;
358+ if ( remaining . length > 0 && remaining [ 0 ] . trim ( ) === '' ) {
359+ return remaining . slice ( 1 ) . join ( '\n' ) ;
360+ }
361+ return remaining . join ( '\n' ) ;
362+ }
363+ return str ;
364+ }
365+
363366async function executeBin ( args : string [ ] ) : Promise < string > {
364367 const command = `node ${ binPath } ${ args . join ( ' ' ) } ` ;
365368 try {
@@ -368,12 +371,12 @@ async function executeBin(args: string[]): Promise<string> {
368371 encoding : 'utf-8' ,
369372 } ) ;
370373 const output = ( stderr ? stderr + '\n' : '' ) + ( stdout || '' ) ;
371- return stripAnsiCodes ( output . trimEnd ( ) ) ;
374+ return stripVersionLine ( stripAnsiCodes ( output . trimEnd ( ) ) ) ;
372375 } catch ( error : any ) {
373376 const output =
374377 ( error . stderr ? error . stderr + '\n' : '' ) +
375378 ( error . stdout || '' ) +
376379 ( error . message || '' ) ;
377- return stripAnsiCodes ( output . trimEnd ( ) ) ;
380+ return stripVersionLine ( stripAnsiCodes ( output . trimEnd ( ) ) ) ;
378381 }
379382}
0 commit comments