feat(refactor): support for stack filtering#410
Merged
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #410 +/- ##
==========================================
- Coverage 80.94% 79.98% -0.96%
==========================================
Files 66 66
Lines 6879 6894 +15
Branches 791 791
==========================================
- Hits 5568 5514 -54
- Misses 1291 1358 +67
- Partials 20 22 +2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
--- By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license
`requireApproval` is deprecated and has been moved to the `CliIoHost`. this PR removes the last place where `requireApproval` was necessary in `tmp-toolkit-helpers`, in `formatSecurityDiff`. `formatSecurityDiff` now makes no _decisions_ on what to print; it returns the diff and a `permissionChangeType` for the `IoHost` to interpret. this is a slight behavior change, so all consumers of `formatSecurityDiff have been updated accordingly (`deploy` and `diff` in `toolkit-lib` and in the CLI). `requireApproval` is now a vestigial structure only in use in the CLI. --- By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license --------- Co-authored-by: Momo Kornher <kornherm@amazon.co.uk>
There was a problem hiding this comment.
Pull Request Overview
This PR adds a new refactor command to support resource stack filtering while refactoring. Key changes include:
- Defining and integrating a new "refactor" command in the CLI, configuration, and user input structures.
- Updating tests to verify stack filtering behavior and refining resource movements and mappings accordingly.
- Adjusting the toolkit logic to process filtered stacks for refactoring.
Reviewed Changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| packages/aws-cdk/test/cli/cli-arguments.test.ts | Added verification for the new refactor command in the CLI arguments test. |
| packages/aws-cdk/test/api/refactoring/refactoring.test.ts | Added tests for stack filtering and updated expectations in resource mapping. |
| packages/aws-cdk/lib/cli/user-input.ts | Extended the user input interface with a new refactor option. |
| packages/aws-cdk/lib/cli/user-configuration.ts | Included the REFACTOR command in the CLI command list. |
| packages/aws-cdk/lib/cli/parse-command-line-arguments.ts | Integrated the refactor command with [STACKS..] and dry-run options. |
| packages/aws-cdk/lib/cli/convert-to-user-input.ts | Added conversion logic for refactor command CLI arguments. |
| packages/aws-cdk/lib/cli/cli-config.ts | Updated the CLI configuration with the refactor command details. |
| packages/aws-cdk/lib/cli/cdk-toolkit.ts | Adjusted logic to filter stacks based on user selection for refactoring. |
| packages/@aws-cdk/toolkit-lib/test/actions/refactor.test.ts | Updated tests to validate stack filtering scenarios for the refactor action. |
| packages/@aws-cdk/toolkit-lib/lib/toolkit/toolkit.ts | Revised the refactor command handling to process filtered stacks. |
| packages/@aws-cdk/tmp-toolkit-helpers/src/api/refactoring/index.ts | Expanded resourceMappings to optionally filter mappings by selected stacks. |
Comments suppressed due to low confidence (1)
packages/@aws-cdk/toolkit-lib/lib/toolkit/toolkit.ts:967
- There is a typo in the error message: 'Too see' should be 'To see'.
throw new ToolkitError('Refactor is not available yet. Too see the proposed changes, use the --dry-run flag.');
rix0rrr
approved these changes
Apr 25, 2025
…' into otaviom/refactor-stack-filtering
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Users can now pass the stacks they want to be considered for refactoring:
The result will include any mapping that contains at least one of the selected stacks. If no pattern is passed, all stacks are considered.
In this PR I also included the
refactorcommand in the command line parsing list, which was missing. It was already working without it, but the command wouldn't show up in the help page, and it wouldn't recognize positional arguments. But the command itself (and its options) could be already used.Closes #363.
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license