Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion packages/aws-cdk-lib/scripts/codegen.ts

This file was deleted.

21 changes: 5 additions & 16 deletions packages/aws-cdk-lib/scripts/gen.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import * as path from 'node:path';
import { naming, topo } from '@aws-cdk/spec2cdk';
import { generateAll } from '@aws-cdk/spec2cdk/lib/cfn2ts';
import * as fs from 'fs-extra';
import { generateAll, ModuleMap } from './codegen';
import submodulesGen from './submodules';

const awsCdkLibDir = path.join(__dirname, '..');
Expand All @@ -25,23 +26,11 @@ async function main() {
}));

await updateExportsAndEntryPoints(generated);
await writeScopeMap(generated);
await topo.writeModuleMap(generated);
await submodulesGen(generated, awsCdkLibDir);
}

async function writeScopeMap(modules: ModuleMap) {
const newScopeMap = Object.entries(modules)
.sort(([modA], [modB]) => modA.localeCompare(modB))
.reduce((scopeMap, [moduleName, { scopes }]) => {
return {
...scopeMap,
[moduleName]: scopes,
};
}, {});
await fs.writeJson(scopeMapPath, newScopeMap, { spaces: 2 });
}

async function updateExportsAndEntryPoints(modules: ModuleMap) {
async function updateExportsAndEntryPoints(modules: topo.ModuleMap) {
const pkgJson = await fs.readJson(pkgJsonPath);

const indexStatements = new Array<string>();
Expand All @@ -53,7 +42,7 @@ async function updateExportsAndEntryPoints(modules: ModuleMap) {
for (const [moduleName, { definition }] of Object.entries(modules)) {
const moduleConfig = {
name: definition?.moduleName ?? moduleName,
submodule: definition?.submoduleName ?? moduleName.replace(/-/g, '_'),
submodule: definition?.submoduleName ?? naming.submoduleSymbolFromName(moduleName),
};

const exportName = `./${moduleConfig.name}`;
Expand Down
Loading
Loading