Skip to content

Commit cc1eb78

Browse files
ShadowCat567aws-amplify-botgithub-actions[bot]
authored
fix: rendering vended log diffs (#2243)
When the data source for vended logs gets updated and a new diff is generated we would previously see the diff for `LogTypes` in the place of both `LogTypes` and `Destinations`. This looks odd and masks any changes that may have happened to `destinations` when the diff is rendered. Added logic to ensure that `logTypes` and `destinations` are displayed correctly also adjusted several variable names. --------- Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: aws-amplify-bot <[email protected]> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
1 parent 49eaf82 commit cc1eb78

File tree

1 file changed

+8
-7
lines changed
  • packages/@aws-cdk/service-spec-importers/src

1 file changed

+8
-7
lines changed

packages/@aws-cdk/service-spec-importers/src/diff-fmt.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -373,14 +373,15 @@ export class DiffFormatter {
373373

374374
private renderVendedLogListDiff(diff: ScalarDiff<VendedLog | undefined>, tree: PrintableTree[], diffShown: string) {
375375
if (diff.old && diff.new) {
376-
const oldList = new Set(diff.old.logTypes);
377-
const newList = new Set(diff.new.logTypes);
378-
const addedTypes = [...newList].filter((t) => !oldList.has(t));
379-
const removedTypes = [...oldList].filter((t) => !newList.has(t));
380-
if (addedTypes.length > 0 || removedTypes.length > 0) {
376+
// the array should correspond to the value of diffShown
377+
const oldList = new Set(diffShown === 'logTypes' ? diff.new.logTypes : diff.new.destinations);
378+
const newList = new Set(diffShown === 'logTypes' ? diff.new.logTypes : diff.new.destinations);
379+
const added = [...newList].filter((t) => !oldList.has(t));
380+
const removed = [...oldList].filter((t) => !newList.has(t));
381+
if (added.length > 0 || removed.length > 0) {
381382
const bullets: PrintableTree[] = [];
382-
removedTypes.forEach((type) => bullets.push(new PrintableTree(`- ${type}`).colorize(chalk.red)));
383-
addedTypes.forEach((type) => bullets.push(new PrintableTree(`+ ${type}`).colorize(chalk.green)));
383+
removed.forEach((obj) => bullets.push(new PrintableTree(`- ${obj}`).colorize(chalk.red)));
384+
added.forEach((obj) => bullets.push(new PrintableTree(`+ ${obj}`).colorize(chalk.green)));
384385
tree.push(new PrintableTree(`${diffShown}:`).addBullets(bullets));
385386
}
386387
}

0 commit comments

Comments
 (0)