@@ -334,7 +334,13 @@ function readBatchStepFailure(error: Record<string, unknown> | undefined): strin
334334function writeCommandCliOutput (
335335 command : string ,
336336 positionals : string [ ] ,
337- flags : { json ?: boolean ; verbose ?: boolean ; snapshotRaw ?: boolean ; snapshotInteractiveOnly ?: boolean ; reportJunit ?: string } ,
337+ flags : {
338+ json ?: boolean ;
339+ verbose ?: boolean ;
340+ snapshotRaw ?: boolean ;
341+ snapshotInteractiveOnly ?: boolean ;
342+ reportJunit ?: string ;
343+ } ,
338344 data : Record < string , unknown > ,
339345) : number {
340346 if ( flags . json ) {
@@ -350,10 +356,12 @@ function writeCommandCliOutput(
350356 }
351357
352358 if ( command === 'snapshot' ) {
353- process . stdout . write ( formatSnapshotText ( data , {
354- raw : flags . snapshotRaw ,
355- flatten : flags . snapshotInteractiveOnly ,
356- } ) ) ;
359+ process . stdout . write (
360+ formatSnapshotText ( data , {
361+ raw : flags . snapshotRaw ,
362+ flatten : flags . snapshotInteractiveOnly ,
363+ } ) ,
364+ ) ;
357365 return 0 ;
358366 }
359367 if ( command === 'test' ) {
@@ -369,13 +377,28 @@ function writeCommandCliOutput(
369377 }
370378 if ( command === 'get' ) {
371379 const sub = positionals [ 0 ] ;
372- if ( sub === 'text' ) { process . stdout . write ( `${ ( data as any ) ?. text ?? '' } \n` ) ; return 0 ; }
373- if ( sub === 'attrs' ) { process . stdout . write ( `${ JSON . stringify ( ( data as any ) ?. node ?? { } , null , 2 ) } \n` ) ; return 0 ; }
380+ if ( sub === 'text' ) {
381+ process . stdout . write ( `${ ( data as any ) ?. text ?? '' } \n` ) ;
382+ return 0 ;
383+ }
384+ if ( sub === 'attrs' ) {
385+ process . stdout . write ( `${ JSON . stringify ( ( data as any ) ?. node ?? { } , null , 2 ) } \n` ) ;
386+ return 0 ;
387+ }
374388 }
375389 if ( command === 'find' ) {
376- if ( typeof ( data as any ) ?. text === 'string' ) { process . stdout . write ( `${ ( data as any ) . text } \n` ) ; return 0 ; }
377- if ( typeof ( data as any ) ?. found === 'boolean' ) { process . stdout . write ( `Found: ${ ( data as any ) . found } \n` ) ; return 0 ; }
378- if ( ( data as any ) ?. node ) { process . stdout . write ( `${ JSON . stringify ( ( data as any ) . node , null , 2 ) } \n` ) ; return 0 ; }
390+ if ( typeof ( data as any ) ?. text === 'string' ) {
391+ process . stdout . write ( `${ ( data as any ) . text } \n` ) ;
392+ return 0 ;
393+ }
394+ if ( typeof ( data as any ) ?. found === 'boolean' ) {
395+ process . stdout . write ( `Found: ${ ( data as any ) . found } \n` ) ;
396+ return 0 ;
397+ }
398+ if ( ( data as any ) ?. node ) {
399+ process . stdout . write ( `${ JSON . stringify ( ( data as any ) . node , null , 2 ) } \n` ) ;
400+ return 0 ;
401+ }
379402 }
380403 if ( command === 'is' ) {
381404 process . stdout . write ( `Passed: is ${ ( data as any ) ?. predicate ?? 'assertion' } \n` ) ;
@@ -412,9 +435,17 @@ function writeCommandCliOutput(
412435 return 0 ;
413436 }
414437 if ( command === 'clipboard' ) {
415- const action = ( positionals [ 0 ] ?? ( typeof data ?. action === 'string' ? data . action : '' ) ) . toLowerCase ( ) ;
416- if ( action === 'read' ) { process . stdout . write ( `${ typeof data ?. text === 'string' ? data . text : '' } \n` ) ; return 0 ; }
417- if ( action === 'write' ) { process . stdout . write ( 'Clipboard updated\n' ) ; return 0 ; }
438+ const action = (
439+ positionals [ 0 ] ?? ( typeof data ?. action === 'string' ? data . action : '' )
440+ ) . toLowerCase ( ) ;
441+ if ( action === 'read' ) {
442+ process . stdout . write ( `${ typeof data ?. text === 'string' ? data . text : '' } \n` ) ;
443+ return 0 ;
444+ }
445+ if ( action === 'write' ) {
446+ process . stdout . write ( 'Clipboard updated\n' ) ;
447+ return 0 ;
448+ }
418449 }
419450 if ( command === 'network' ) {
420451 writeNetworkCliOutput ( data ) ;
@@ -431,36 +462,47 @@ function writeCommandCliOutput(
431462 }
432463 if ( command === 'devices' ) {
433464 const devices = Array . isArray ( ( data as any ) . devices ) ? ( data as any ) . devices : [ ] ;
434- process . stdout . write ( `${ devices . map ( ( d : any ) => {
435- const name = d ?. name ?? d ?. id ?? 'unknown' ;
436- const platform = d ?. platform ?? 'unknown' ;
437- const kind = d ?. kind ? ` ${ d . kind } ` : '' ;
438- const target = d ?. target ? ` target=${ d . target } ` : '' ;
439- const booted = typeof d ?. booted === 'boolean' ? ` booted=${ d . booted } ` : '' ;
440- return `${ name } (${ platform } ${ kind } ${ target } )${ booted } ` ;
441- } ) . join ( '\n' ) } \n`) ;
465+ process . stdout . write (
466+ `${ devices
467+ . map ( ( d : any ) => {
468+ const name = d ?. name ?? d ?. id ?? 'unknown' ;
469+ const platform = d ?. platform ?? 'unknown' ;
470+ const kind = d ?. kind ? ` ${ d . kind } ` : '' ;
471+ const target = d ?. target ? ` target=${ d . target } ` : '' ;
472+ const booted = typeof d ?. booted === 'boolean' ? ` booted=${ d . booted } ` : '' ;
473+ return `${ name } (${ platform } ${ kind } ${ target } )${ booted } ` ;
474+ } )
475+ . join ( '\n' ) } \n`,
476+ ) ;
442477 return 0 ;
443478 }
444479 if ( command === 'apps' ) {
445480 const apps = Array . isArray ( ( data as any ) . apps ) ? ( data as any ) . apps : [ ] ;
446- process . stdout . write ( `${ apps . map ( ( app : any ) => {
447- if ( typeof app === 'string' ) return app ;
448- if ( app && typeof app === 'object' ) {
449- const bundleId = app . bundleId ?? app . package ;
450- const name = app . name ?? app . label ;
451- if ( name && bundleId ) return `${ name } (${ bundleId } )` ;
452- if ( bundleId ) return String ( bundleId ) ;
453- return JSON . stringify ( app ) ;
454- }
455- return String ( app ) ;
456- } ) . join ( '\n' ) } \n`) ;
481+ process . stdout . write (
482+ `${ apps
483+ . map ( ( app : any ) => {
484+ if ( typeof app === 'string' ) return app ;
485+ if ( app && typeof app === 'object' ) {
486+ const bundleId = app . bundleId ?? app . package ;
487+ const name = app . name ?? app . label ;
488+ if ( name && bundleId ) return `${ name } (${ bundleId } )` ;
489+ if ( bundleId ) return String ( bundleId ) ;
490+ return JSON . stringify ( app ) ;
491+ }
492+ return String ( app ) ;
493+ } )
494+ . join ( '\n' ) } \n`,
495+ ) ;
457496 return 0 ;
458497 }
459498 if ( command === 'appstate' ) {
460499 const platform = ( data as any ) ?. platform ;
461500 if ( platform === 'ios' ) {
462- process . stdout . write ( `Foreground app: ${ ( data as any ) ?. appName ?? ( data as any ) ?. appBundleId ?? 'unknown' } \n` ) ;
463- if ( ( data as any ) ?. appBundleId ) process . stdout . write ( `Bundle: ${ ( data as any ) . appBundleId } \n` ) ;
501+ process . stdout . write (
502+ `Foreground app: ${ ( data as any ) ?. appName ?? ( data as any ) ?. appBundleId ?? 'unknown' } \n` ,
503+ ) ;
504+ if ( ( data as any ) ?. appBundleId )
505+ process . stdout . write ( `Bundle: ${ ( data as any ) . appBundleId } \n` ) ;
464506 if ( ( data as any ) ?. source ) process . stdout . write ( `Source: ${ ( data as any ) . source } \n` ) ;
465507 return 0 ;
466508 }
@@ -494,11 +536,18 @@ function writeLogsCliOutput(data: Record<string, unknown>, flags: { json?: boole
494536 . filter ( Boolean )
495537 . join ( ' ' ) ;
496538 if ( meta && ! flags . json ) process . stderr . write ( `${ meta } \n` ) ;
497- const actionFields = [ 'started' , 'stopped' , 'marked' , 'cleared' , 'restarted' , 'removedRotatedFiles' ] as const ;
539+ const actionFields = [
540+ 'started' ,
541+ 'stopped' ,
542+ 'marked' ,
543+ 'cleared' ,
544+ 'restarted' ,
545+ 'removedRotatedFiles' ,
546+ ] as const ;
498547 const actionMeta = actionFields
499548 . map ( ( key ) => {
500549 const v = data [ key ] ;
501- return v === true ? `${ key } =true` : ( typeof v === 'number' ? `${ key } =${ v } ` : '' ) ;
550+ return v === true ? `${ key } =true` : typeof v === 'number' ? `${ key } =${ v } ` : '' ;
502551 } )
503552 . filter ( Boolean )
504553 . join ( ' ' ) ;
@@ -523,14 +572,24 @@ function writeNetworkCliOutput(data: Record<string, unknown>): void {
523572 const url = typeof entry . url === 'string' ? entry . url : '<unknown-url>' ;
524573 const status = typeof entry . status === 'number' ? ` status=${ entry . status } ` : '' ;
525574 const timestamp = typeof entry . timestamp === 'string' ? `${ entry . timestamp } ` : '' ;
526- const durationMs = typeof entry . durationMs === 'number' ? ` durationMs=${ entry . durationMs } ` : '' ;
575+ const durationMs =
576+ typeof entry . durationMs === 'number' ? ` durationMs=${ entry . durationMs } ` : '' ;
527577 process . stdout . write ( `${ timestamp } ${ method } ${ url } ${ status } ${ durationMs } \n` ) ;
528578 if ( typeof entry . headers === 'string' ) process . stdout . write ( ` headers: ${ entry . headers } \n` ) ;
529- if ( typeof entry . requestBody === 'string' ) process . stdout . write ( ` request: ${ entry . requestBody } \n` ) ;
530- if ( typeof entry . responseBody === 'string' ) process . stdout . write ( ` response: ${ entry . responseBody } \n` ) ;
579+ if ( typeof entry . requestBody === 'string' )
580+ process . stdout . write ( ` request: ${ entry . requestBody } \n` ) ;
581+ if ( typeof entry . responseBody === 'string' )
582+ process . stdout . write ( ` response: ${ entry . responseBody } \n` ) ;
531583 }
532584 }
533- const networkMetaFields = [ 'active' , 'state' , 'backend' , 'include' , 'scannedLines' , 'matchedLines' ] as const ;
585+ const networkMetaFields = [
586+ 'active' ,
587+ 'state' ,
588+ 'backend' ,
589+ 'include' ,
590+ 'scannedLines' ,
591+ 'matchedLines' ,
592+ ] as const ;
534593 const meta = networkMetaFields
535594 . map ( ( key ) => ( data [ key ] !== undefined && data [ key ] !== null ? `${ key } =${ data [ key ] } ` : '' ) )
536595 . filter ( Boolean )
0 commit comments