'use strict' ; import { UserInputUtil } from '../commands/UserInputUtil' ; import { VSCodeBlockchainOutputAdapter } from '../logging/VSCodeBlockchainOutputAdapter' ; import { LogType } from 'ibm-blockchain-platform-common' ; export class YeomanAdapter { public log : any ; public aborted : boolean = false ; constructor ( ) { const logger = ( ... str ) : any => { const msg = str . join ( '' ) ; VSCodeBlockchainOutputAdapter . instance ( ) . log ( LogType . YEOMAN , undefined , msg ) ; } ; this . log = logger ; [ 'write' , 'writeln' , 'ok' , 'error' , 'skip' , 'force' , 'create' , 'invoke' , 'conflict' , 'identical' , 'info' , 'table' ] . forEach ( function ( methodName ) : void { this . log [ methodName ] = logger ; } , this ) ; } async prompt ( prompts , cb ) { const result = { } ; for ( const prompt of prompts ) { if ( prompt . when && ! prompt . when ( ) ) { continue ; } const userOption = await UserInputUtil . showGeneratorOptions ( prompt . message ) ; let answer ; switch ( userOption ) { case UserInputUtil . OVERWRITE_FILE : answer = 'write' ; break ; case UserInputUtil . SKIP_FILE : answer = 'skip' ; break ; case UserInputUtil . FORCE_FILES : answer = 'force' ; break ; case UserInputUtil . ABORT_GENERATOR : answer = 'abort' ; break ; } result [ prompt . name ] = answer ; } if ( cb ) { try { cb ( result ) ; } catch ( error ) { } } return result ; } }