You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fixes#302
In #264, we capture the output of
the Formatter into a stream, and that is then converted to a string.
This diff only gets printed if the diff isn't empty, but by some quirk
`formatStackDiff` used to print the stack name _outside_ of the stream,
thus creating the (correct) behavior. #264 made sure that `format`
doesn't print, so we need to make sure that the consumer of
`formatStackDiff` prints the relevant info.
This PR makes sure that the stack name is returned as the formatted diff
even if the actual diff is empty. We will print the right information
when we print the formatted diff now.
I also made similar modifications to `formatSecurityDiff`, as we should
move away from `format` methods printing anything at all.
BEFORE (cdk 2.1006.0):
<img width="326" alt="Screenshot 2025-04-02 at 9 04 04 AM"
src="https://github.com/user-attachments/assets/03b92517-e475-4c27-a4c1-52217be824c8"
/>
AFTER (my local cdk):
<img width="322" alt="Screenshot 2025-04-02 at 9 03 11 AM"
src="https://github.com/user-attachments/assets/53a7d3e0-2e62-45ca-898b-93c923028346"
/>
---
By submitting this pull request, I confirm that my contribution is made
under the terms of the Apache-2.0 license
---------
Signed-off-by: github-actions <[email protected]>
Co-authored-by: github-actions <[email protected]>
@@ -239,20 +239,19 @@ export class DiffFormatter {
239
239
...logicalIdMapFromTemplate(this.oldTemplate),
240
240
...buildLogicalToPathMap(this.newTemplate),
241
241
},options.context);
242
-
243
-
// store the stream containing a formatted stack diff
244
-
formattedDiff=stream.toString();
245
242
}elseif(!options.quiet){
246
-
options.ioDefaultHelper.info(chalk.green('There were no differences'));
243
+
stream.write(chalk.green('There were no differences\n'));
244
+
}
245
+
246
+
if(filteredChangesCount>0){
247
+
stream.write(chalk.yellow(`Omitted ${filteredChangesCount} changes because they are likely mangled non-ASCII characters. Use --strict to print them.\n`));
247
248
}
248
249
}finally{
250
+
// store the stream containing a formatted stack diff
251
+
formattedDiff=stream.toString();
249
252
stream.end();
250
253
}
251
254
252
-
if(filteredChangesCount>0){
253
-
options.ioDefaultHelper.info(chalk.yellow(`Omitted ${filteredChangesCount} changes because they are likely mangled non-ASCII characters. Use --strict to print them.`));
ioDefaultHelper.warning(`This deployment will make potentially sensitive changes according to your current security approval level (--require-approval ${options.requireApproval}).`);
292
-
ioDefaultHelper.warning('Please confirm you intend to make the following modifications:\n');
293
-
294
287
// The security diff is formatted via `Formatter`, which takes in a stream
295
288
// and sends its output directly to that stream. To faciliate use of the
296
289
// global CliIoHost, we create our own stream to capture the output of
297
290
// `Formatter` and return the output as a string for the consumer of
298
291
// `formatSecurityDiff` to decide what to do with it.
ioDefaultHelper.warning(`This deployment will make potentially sensitive changes according to your current security approval level (--require-approval ${options.requireApproval}).`);
298
+
ioDefaultHelper.warning('Please confirm you intend to make the following modifications:\n');
300
299
try{
301
300
// formatSecurityChanges updates the stream with the formatted security diff
0 commit comments