-
Notifications
You must be signed in to change notification settings - Fork 69
chore(tmp-toolkit-helpers): formatStackDiff and formatSecurityDiff moved to tmp-toolkit-helpers
#278
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
chore(tmp-toolkit-helpers): formatStackDiff and formatSecurityDiff moved to tmp-toolkit-helpers
#278
Conversation
| try { | ||
| // must output the stack name if there are differences, even if quiet | ||
| if (stackName && (!quiet || !diff.isEmpty)) { | ||
| stream.write(format('Stack %s\n', chalk.bold(stackName))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
welp, these prints don't work yet and im worried im not doing the right thing here:
format and chalk don't exist in this context and i'm not sure how to replicate them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
import { format } from 'node:util'l;
import * as chalk from 'chalk';There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But format you can also just replace with string literals:
`Stack ${chalk.bold(stackName)}\n`There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i guess a better question to ask was: are we certain we want it in tmp-toolkit-helpers and not imported here like a lot of other heavy duty imports.
but it sounds like your answer also answers that question too
formatStackDiff and formatSecurityDiff moved to tmp-toolkit-helpesrformatStackDiff and formatSecurityDiff moved to tmp-toolkit-helpers
| [nestedStackLogicalId: string]: NestedStackTemplates; | ||
| }; | ||
| } | ||
| export { NestedStackTemplates } from '../../../../@aws-cdk/tmp-toolkit-helpers/src/api'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is it reasonable to both export and import NestedStackTemplate here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, it's just going to annoy me when I do the move :D
| await cdkToolkit.deploy({ | ||
| selector: { patterns: ['Test-Stack-A-Display-Name'] }, | ||
| requireApproval: RequireApproval.Never, | ||
| requireApproval: RequireApproval.NEVER, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is kind of silly but also a breaking change right? what should i have done instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why is it breaking?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i suppose its not because the CLI users have no access to this..
| ], | ||
| deps: [ | ||
| cloudAssemblySchema.name, | ||
| cloudFormationDiff, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
elsewhere we are depending on cloudformationDiff.customizeReference({ versionType: 'exact' }), and i'm not sure why. just thought i'd flag
| export function formatStackDiff( | ||
| ioHelper: IoHelper, | ||
| oldTemplate: any, | ||
| newTemplate: cxapi.CloudFormationStackArtifact, | ||
| strict: boolean, | ||
| context: number, | ||
| quiet: boolean, | ||
| stackName?: string, | ||
| changeSet?: DescribeChangeSetOutput, | ||
| isImport?: boolean, | ||
| nestedStackTemplates?: { [nestedStackLogicalId: string]: NestedStackTemplates }): FormatStackDiffOutput { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i agree that this sucks and should be part of a class with formatSecurityDiff. but i don't wanna do it in this PR, it's already too complicated.
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #278 +/- ##
==========================================
+ Coverage 85.22% 85.39% +0.16%
==========================================
Files 221 222 +1
Lines 36764 36761 -3
Branches 4457 4471 +14
==========================================
+ Hits 31333 31391 +58
+ Misses 5331 5273 -58
+ Partials 100 97 -3
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:
|
Signed-off-by: github-actions <[email protected]>
Signed-off-by: github-actions <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AI disclosure: this file was originally intended to be full AI generated and started off as such but it insisted on mocking @aws-cdk/cloudformation-diff functions and I really didn't want it to. So I spent twice as much time bashing the code into what I wanted. At the end of the day this is <50% AI generated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are much easier ways to achieve the same mocking results you were after. Check some other files for inspirations.
Specifically all calls end up in an IoHost, so all the helpers could just stay real.
Signed-off-by: github-actions <[email protected]>
| }); | ||
| } | ||
| } | ||
| export { formatStackDiff, formatSecurityDiff, RequireApproval } from '../../../@aws-cdk/tmp-toolkit-helpers/src/api'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's fine. But you also could have updated any imports.
moves two functions that are relevant to diff into
tmp-toolkit-helpers. this will facilitate the adoption ofdiffin the programmatic toolkit as it will now be able to reuse these functions.existing tests pass to ensure no breakage. additional tests have been added to
tmp-toolkit-helpersto testformatXxxDiff, which were previously not directly tested.By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license