Skip to content

refactor(spec2cdk): relocate cfn-prop-mixins builder and detangle gen.ts orchestration#37204

Merged
mergify[bot] merged 2 commits intomainfrom
mrgrain/chore/move-spec2mixins
Mar 9, 2026
Merged

refactor(spec2cdk): relocate cfn-prop-mixins builder and detangle gen.ts orchestration#37204
mergify[bot] merged 2 commits intomainfrom
mrgrain/chore/move-spec2mixins

Conversation

@mrgrain
Copy link
Copy Markdown
Contributor

@mrgrain mrgrain commented Mar 9, 2026

Reason for this change

The spec2mixins code in mixins-preview/scripts/ was tightly coupled to @aws-cdk/spec2cdk internals, importing directly from deep paths like @aws-cdk/spec2cdk/lib/cdk/resource-decider. Since this code is fundamentally a spec2cdk builder (extending LibraryBuilder), it belongs in the spec2cdk package itself. Similarly, the gen.ts orchestration script contained shared utilities (mergeModuleMaps, ensureFileContains, writeJsiiModuleMetadata) and hardcoded knowledge about each generator's output files, making it difficult to add new generators without modifying the orchestrator.

Description of changes

The cfn-prop-mixins builder, its generate function, helpers, and tests are relocated from packages/@aws-cdk/mixins-preview/scripts/spec2mixins/ to tools/@aws-cdk/spec2cdk/lib/cfn-prop-mixins/. The generateAll function now accepts packageBases as a parameter instead of importing MIXINS_PREVIEW_BASE_NAMES directly, making it reusable for other packages.

A thin wrapper remains in mixins-preview/scripts/spec2mixins/index.ts that re-exports MixinsBuilder and MixinsBuilderProps, and provides a generateAll() that passes the mixins-preview-specific package base names. This preserves the existing API for consumers within the mixins-preview package.

The gen.ts orchestration is detangled by introducing a SubmoduleContribution interface and GeneratorResult type in spec2cdk. Each generator now declares what barrel files and export lines it contributes, rather than the orchestrator hardcoding this knowledge. The shared utilities mergeModuleMaps, ensureFileContains, and writeJsiiModuleMetadata are moved to spec2cdk where they operate on spec2cdk types (ModuleMap, ModuleDefinition).

The logs-delivery.test.ts is updated to import LogsDeliveryBuilderProps from its own package instead of borrowing MixinsBuilderProps from spec2mixins.

Describe any new or updated permissions being added

No new permissions.

Description of how you validated changes

Both @aws-cdk/spec2cdk and @aws-cdk/mixins-preview build successfully, including full codegen of all 274 service modules.

Checklist


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license

@github-actions github-actions bot added the p2 label Mar 9, 2026
@aws-cdk-automation aws-cdk-automation requested a review from a team March 9, 2026 12:40
@mergify mergify bot added the contribution/core This is a PR that came from AWS. label Mar 9, 2026
@mergify mergify bot temporarily deployed to automation March 9, 2026 12:40 Inactive
@mergify mergify bot temporarily deployed to automation March 9, 2026 12:40 Inactive
@mrgrain mrgrain changed the title chore: move spec2mixins to spec2cdk refactor(spec2cdk): relocate cfn-prop-mixins builder and detangle gen.ts orchestration Mar 9, 2026
@mrgrain mrgrain force-pushed the mrgrain/chore/move-spec2mixins branch from 8838e8e to 2724709 Compare March 9, 2026 13:57
@mrgrain mrgrain marked this pull request as ready for review March 9, 2026 14:02
mrgrain added 2 commits March 9, 2026 14:07
…ributions

Each generator now declares its submodule contributions (barrel file,
export lines, jsiirc namespace) via a GeneratorResult type. The gen.ts
orchestrator consumes these contributions dynamically instead of
hardcoding generator-specific logic.

Extract shared writeJsiiRc and ensureFileContains utilities into
lib/util/submodule-files.ts. Refactor cfn2ts/submodules.ts to use
writeJsiiRc instead of inline jsiirc construction. Move
mergeModuleMaps to module-topology.ts.
@mrgrain mrgrain force-pushed the mrgrain/chore/move-spec2mixins branch from 2724709 to 1382eb2 Compare March 9, 2026 14:07
@mergify
Copy link
Copy Markdown
Contributor

mergify bot commented Mar 9, 2026

Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@mergify mergify bot merged commit 04b58c4 into main Mar 9, 2026
21 of 22 checks passed
@mergify mergify bot deleted the mrgrain/chore/move-spec2mixins branch March 9, 2026 14:51
@mergify
Copy link
Copy Markdown
Contributor

mergify bot commented Mar 9, 2026

Merge Queue Status

  • Entered queue2026-03-09 14:51 UTC · Rule: default-squash
  • Checks passed · in-place
  • Merged2026-03-09 14:51 UTC · at 1382eb28276beaec8f35926298de21d0f2ccd720

This pull request spent 10 seconds in the queue, including 1 second running CI.

Required conditions to merge

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 9, 2026

Comments on closed issues and PRs are hard for our team to see.
If you need help, please open a new issue that references this one.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 9, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

contribution/core This is a PR that came from AWS. p2

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants