Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 | 8x 8x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 8x | import * as fs from 'fs-extra'; 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: string): ModuleDefinition { const [moduleFamily, moduleBaseName] = (namespace === 'AWS::Serverless' ? 'AWS::SAM' : namespace).split('::'); const moduleName = `${moduleFamily}-${moduleBaseName.replace(/V\d+$/, '')}`.toLocaleLowerCase(); const lowcaseModuleName = moduleBaseName.toLocaleLowerCase(); const packageName = `@aws-cdk/${moduleName}`; // dotnet names const dotnetPackage = `Amazon.CDK.${moduleFamily}.${moduleBaseName}`; // java names const javaGroupId = 'software.amazon.awscdk'; const javaPackage = moduleFamily === 'AWS' ? `services.${lowcaseModuleName}` : `${moduleFamily.toLocaleLowerCase()}.${lowcaseModuleName}`; const javaArtifactId = moduleFamily === 'AWS' ? lowcaseModuleName : `${moduleFamily.toLocaleLowerCase()}-${lowcaseModuleName}`; // python names 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: string, readmePath: string) { const module = createModuleDefinitionFromCfnNamespace(namespace); await fs.writeFile(readmePath, [ `# ${namespace} Construct Library`, '<!--BEGIN STABILITY BANNER-->', '', '---', '', '', '', '> All classes with the `Cfn` prefix in this module ([CFN Resources]) are always stable and safe to use.', '>', '> [CFN Resources]: https://docs.aws.amazon.com/cdk/latest/guide/constructs.html#constructs_lib', '', '---', '', '<!--END STABILITY BANNER-->', '', 'This module is part of the [AWS Cloud Development Kit](https://github.com/aws/aws-cdk) project.', '', '```ts', `import ${module.moduleName.toLocaleLowerCase()} = require('${module.packageName}');`, '```', '', ].join('\n'), 'utf8'); } |