import Listr from 'listr' ; import { run } from '@osd/dev-utils' ; import { createTaskContext , ErrorReporter , parseConfigsTask , extractCollectorsTask , generateSchemasTask , writeToFileTask , } from '../tools/tasks' ; export function runTelemetryExtract ( ) { run ( async ( { flags : { } , log } ) => { const list = new Listr ( [ { title : 'Parsing .telemetryrc.json files' , task : ( ) => new Listr ( parseConfigsTask ( ) , { exitOnError : true } ) , } , { title : 'Extracting Telemetry Collectors' , task : ( context ) => new Listr ( extractCollectorsTask ( context ) , { exitOnError : true } ) , } , { title : 'Generating Schema files' , task : ( context ) => new Listr ( generateSchemasTask ( context ) , { exitOnError : true } ) , } , { title : 'Writing to file' , task : ( context ) => new Listr ( writeToFileTask ( context ) , { exitOnError : true } ) , } , ] ) ; try { const context = createTaskContext ( ) ; await list . run ( context ) ; } catch ( error ) { process . exitCode = 1 ; if ( error instanceof ErrorReporter ) { error . errors . forEach ( ( e ) => log . error ( e ) ) ; } else { log . error ( 'Unhandled exception' ) ; log . error ( error ) ; } } process . exit ( ) ; } , { flags : { allowUnexpected : true , guessTypesForUnexpectedFlags : true , } , } ) ; }