import * as fs from 'fs-extra' ; import { cfnOnlyReadmeContents } from './readme-contents' ; export interface ModuleDefinition { readonly namespace : string ; readonly moduleName : string ; readonly moduleFamily : string ; readonly moduleBaseName : string ; readonly packageName : string ; readonly dotnetPackage : string ; readonly javaGroupId : string ; readonly javaPackage : string ; readonly javaArtifactId : string ; readonly pythonDistName : string ; readonly pythonModuleName : string ; } export function createModuleDefinitionFromCfnNamespace ( namespace ) { const [ moduleFamily , moduleBaseName ] = ( namespace === 'AWS::Serverless' ? 'AWS::SAM' : namespace ) . split ( '::' ) ; const moduleName = `${ moduleFamily }-${ moduleBaseName }` . toLocaleLowerCase ( ) ; const lowcaseModuleName = moduleBaseName . toLocaleLowerCase ( ) ; const packageName = `@aws-cdk/${ moduleName }` ; const dotnetPackage = `Amazon.CDK.${ moduleFamily }.${ moduleBaseName }` ; const javaGroupId = 'software.amazon.awscdk' ; const javaPackage = moduleFamily === 'AWS' ? `services.${ lowcaseModuleName }` : `${ moduleFamily . toLocaleLowerCase ( ) }.${ lowcaseModuleName }` ; const javaArtifactId = moduleFamily === 'AWS' ? lowcaseModuleName : `${ moduleFamily . toLocaleLowerCase ( ) }-${ lowcaseModuleName }` ; const pythonDistName = `aws-cdk.${ moduleName }` ; const pythonModuleName = pythonDistName . replace ( /-/g , '_' ) ; return { namespace , moduleName , moduleFamily , moduleBaseName , packageName , dotnetPackage , javaGroupId , javaPackage , javaArtifactId , pythonDistName , pythonModuleName , } ; } export async function createLibraryReadme ( namespace , readmePath , alphaPackageName ? ) { const module = createModuleDefinitionFromCfnNamespace ( namespace ) ; await fs . writeFile ( readmePath , cfnOnlyReadmeContents ( { cfnNamespace : namespace , packageName : module . packageName , alphaPackageName , } ) ) ; }