Skip to content

chore: make all L2 Constructs property injectable during release #34328

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
May 6, 2025

Conversation

pcheungamz
Copy link
Contributor

Issue # (if applicable)

This is a followup to #33887.

DO NOT merge this PR until after 33887 is merged.

Reason for this change

In the original Property Injection PR, we enabled 122 Constructs for Property Injections, but we want to make this feature available for all L2 Constructs.

Description of changes

Add logic to Constructs ConstructsUpdater to if a Construct already have PROPERTY_INJECTION_ID property. If not, it will:

  • Add PROPERTY_INJECTION_ID with value that is calculated from path and class name
  • Import aws-cdk-lib/core/lib/prop-injectable
  • Add class decorator @propertyInjectable

Describe any new or updated permissions being added

No permission change.

Description of how you validated changes

  • Added unit tests and ran npm test
  • Ran ./bin/update-construct-metadata locally and manually verified a few random files.

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 May 1, 2025
@aws-cdk-automation aws-cdk-automation requested a review from a team May 1, 2025 13:40
@github-actions github-actions bot added the beginning-contributor [Pilot] contributed between 0-2 PRs to the CDK label May 1, 2025
Copy link
Collaborator

@aws-cdk-automation aws-cdk-automation left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(This review is outdated)

@pcheungamz pcheungamz changed the title feat: make all L2 Constructs property injectable chose: make all L2 Constructs property injectable during release May 1, 2025
@pcheungamz pcheungamz changed the title chose: make all L2 Constructs property injectable during release chore: make all L2 Constructs property injectable during release May 1, 2025
@aws-cdk-automation aws-cdk-automation dismissed their stale review May 1, 2025 14:00

✅ Updated pull request passes all PRLinter validations. Dismissing previous PRLinter review.

@aws-cdk-automation aws-cdk-automation added the pr/needs-community-review This PR needs a review from a Trusted Community Member or Core Team Member. label May 1, 2025
GavinZZ
GavinZZ previously requested changes May 1, 2025
Copy link
Contributor

@GavinZZ GavinZZ left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some minor changes requested

if (parts.length < 2) {
throw new Error(`Could not build PROPERTY_INJECTION_ID for ${filePath} ${className}`);
}
return `'aws-cdk-lib.${parts[0]}.${className}'`;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about alpha modules?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I am not familiar with alpha modules. Can you give me some examples and I can add them to the unit tests.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Modules in packages/@aws-cdk/ are alpha modules (aka experimental modules). The constructs in these modules should also be property injectable.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I updated the logic to handle /packages/@awsk-cdk/...

/**
* This adds import of prop-injectable to the file.
*/
private importPropertyInjectable(sourceFile: SourceFile, filePath: string) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we group this method and the below addImportAndMetadataStatement's import part together into a function and make the function generic to handle different import statement input?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make sense. Let me combine them.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

addImportAndMetadataStatementn and makeConstructsPropInjectable both use importCoreLibFile

@aws-cdk-automation aws-cdk-automation removed the pr/needs-community-review This PR needs a review from a Trusted Community Member or Core Team Member. label May 1, 2025
@mergify mergify bot dismissed GavinZZ’s stale review May 2, 2025 14:40

Pull request has been modified.

@aws-cdk-automation aws-cdk-automation added the pr/needs-community-review This PR needs a review from a Trusted Community Member or Core Team Member. label May 2, 2025
@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildv2Project1C6BFA3F-wQm2hXv2jqQv
  • Commit ID: 273544b
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

Copy link
Contributor

@GavinZZ GavinZZ left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thank you!

Copy link
Contributor

mergify bot commented May 6, 2025

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 b99f241 into aws:main May 6, 2025
15 of 16 checks passed
Copy link
Contributor

github-actions bot commented May 6, 2025

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 May 6, 2025
@aws-cdk-automation aws-cdk-automation removed the pr/needs-community-review This PR needs a review from a Trusted Community Member or Core Team Member. label May 6, 2025
@pcheungamz pcheungamz deleted the all-constructs branch May 6, 2025 12:47
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
beginning-contributor [Pilot] contributed between 0-2 PRs to the CDK p2
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants