Skip to content

feat: diff shows moved resources #708

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 19 commits into from
Jul 15, 2025
Merged

Conversation

otaviomacedo
Copy link
Contributor

@otaviomacedo otaviomacedo commented Jul 11, 2025

When a resource is moved from one location to another, the diff command will show two entries: an addition and a removal. This PR augments those entries to show where they moved to and from, respectively:

Drawing 2025-07-15 14 35 02 excalidraw

This information is not shown by default. To enable it, the user has to pass --include-moves to the CLI, and includeMoves: true to the toolkit.

Closes #362

Depends on #679.


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

otaviomacedo and others added 14 commits June 27, 2025 14:02
Signed-off-by: github-actions <github-actions@github.com>
Show both mappings and ambiguities;
Signed-off-by: github-actions <github-actions@github.com>
…rides

# Conflicts:
#	packages/@aws-cdk/toolkit-lib/lib/toolkit/toolkit.ts
Signed-off-by: github-actions <github-actions@github.com>
# Conflicts:
#	packages/@aws-cdk/toolkit-lib/lib/actions/refactor/index.ts
#	packages/@aws-cdk/toolkit-lib/lib/api/refactoring/context.ts
#	packages/@aws-cdk/toolkit-lib/lib/api/refactoring/index.ts
#	packages/@aws-cdk/toolkit-lib/lib/toolkit/toolkit.ts
#	packages/@aws-cdk/toolkit-lib/test/_fixtures/stack-with-two-buckets/index.ts
#	packages/@aws-cdk/toolkit-lib/test/actions/refactor.test.ts
#	packages/aws-cdk/README.md
#	packages/aws-cdk/lib/cli/cdk-toolkit.ts
#	packages/aws-cdk/lib/cli/cli-config.ts
#	packages/aws-cdk/lib/cli/cli-type-registry.json
#	packages/aws-cdk/lib/cli/cli.ts
#	packages/aws-cdk/lib/cli/convert-to-user-input.ts
#	packages/aws-cdk/lib/cli/parse-command-line-arguments.ts
#	packages/aws-cdk/lib/cli/user-input.ts
@github-actions github-actions bot added the p2 label Jul 11, 2025
@aws-cdk-automation aws-cdk-automation requested a review from a team July 11, 2025 12:53
Copy link
Contributor

@rix0rrr rix0rrr left a comment

Choose a reason for hiding this comment

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

Conditionally approved, give my comments a thought

@@ -239,6 +246,10 @@ export class Formatter {
}
}

private formatMove(move?: Move): string {
return !move ? '' : chalk.gray('(OR', chalk.italic(chalk.bold('move')), `${move.direction} ${move.stackName}.${move.resourceLogicalId} via refactoring)`);
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 make this slightly more visible than grey? Maybe yellow or orange or something?

});
return {
environment: context.environment,
mappings: Object.fromEntries(
Copy link
Contributor

Choose a reason for hiding this comment

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

Rather than splatting down the object to a string here, aren't we better off maintaining the object and rendering it later when it comes time to present the diff?

@otaviomacedo otaviomacedo added this pull request to the merge queue Jul 15, 2025
Merged via the queue into main with commit 6beac2b Jul 15, 2025
27 checks passed
@otaviomacedo otaviomacedo deleted the otaviom/add-moves-to-diff branch July 15, 2025 15:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add refactoring information to the diff command
3 participants