import { CodegenFramework } from '@neo-one/cli-common' ; import _ from 'lodash' ; import { ContractPaths } from '../type' ; import { getRelativeImport } from '../utils' ; const createExport = ( generatedPath , importPath ) => `export * from '${ getRelativeImport ( generatedPath , importPath ) }';` ; const createNewLineExport = ( generatedPath , importPath ) => `\n${ createExport ( generatedPath , importPath ) }` ; export const genGenerated = ( { contractsPaths , contractsPath , reactPath , angularPath , vuePath , clientPath , generatedPath , framework , } ) => ( { ts : `
${ createExport ( generatedPath , contractsPath ) }${ framework === 'react' ? createNewLineExport ( generatedPath , reactPath ) : '' }${ framework === 'angular' ? createNewLineExport ( generatedPath , angularPath ) : '' }${ framework === 'vue' ? createNewLineExport ( generatedPath , vuePath ) : '' }
${ createExport ( generatedPath , clientPath ) }
${ _ . flatMap ( contractsPaths , ( { createContractPath , typesPath , manifestPath } ) => [ createContractPath , typesPath , manifestPath , ] ) . map ( ( importPath ) => createExport ( generatedPath , importPath ) ) . join ( '\n' ) }
` , js : `
${ framework === 'react' ? createNewLineExport ( generatedPath , reactPath ) : '' }${ framework === 'angular' ? createNewLineExport ( generatedPath , angularPath ) : '' }${ framework === 'vue' ? createNewLineExport ( generatedPath , vuePath ) : '' }
${ createExport ( generatedPath , clientPath ) }
${ _ . flatMap ( contractsPaths , ( { createContractPath , manifestPath } ) => [ createContractPath , manifestPath ] ) . map ( ( importPath ) => createExport ( generatedPath , importPath ) ) . join ( '\n' ) }
` } ) ;