import { readFileSync } from 'fs' ; import { join } from 'path' ; import { parse as parseEnvFile } from 'dotenv' ; import prompts , { PromptObject } from 'prompts' ; export interface IntegrationInfo { integration : string ; airnodeType : 'aws' | 'local' | 'gcp' ; accessKeyId : string ; secretKey : string ; network : 'rinkeby' | 'localhost' ; mnemonic : string ; providerUrl : string ; gcpProjectId ? : string ; } returns export const readIntegrationInfo = ( ) : IntegrationInfo => JSON . parse ( readFileSync ( join ( __dirname , '../integration-info.json' ) ) . toString ( ) ) ; returns export const readAwsSecrets = ( ) => parseEnvFile ( readFileSync ( join ( __dirname , '../aws.env' ) ) ) ; returns export const readAirnodeSecrets = ( ) => { const integrationInfo = readIntegrationInfo ( ) ; return parseEnvFile ( readFileSync ( join ( __dirname , `../integrations/${ integrationInfo . integration }/secrets.env` ) ) ) ; } ; returns export const readConfig = ( ) => { const integrationInfo = readIntegrationInfo ( ) ; const config = JSON . parse ( readFileSync ( join ( __dirname , `../integrations/${ integrationInfo . integration }/config.json` ) ) . toString ( ) ) ; return config ; } ; param secrets returns export const formatSecrets = ( secrets ) => secrets . join ( '\n' ) + '\n' ; param filename returns export const removeExtension = ( filename ) => filename . split ( '.' ) [ 0 ] ; export const promptQuestions = ( questions ) => prompts ( questions , { onCancel : ( ) => { throw new Error ( 'Aborted by the user' ) ; } , } ) ; export const setMaxPromiseTimeout = < T > ( promise , timeoutMs ) : Promise < T > => Promise . race ( [ promise , new Promise < never > ( ( _ , reject ) => setTimeout ( ( ) => reject ( 'Timeout exceeded!' ) , timeoutMs ) ) ] ) ;