From e6bdd04cf00156eb507651dac2e7f8f43752c2c2 Mon Sep 17 00:00:00 2001 From: Calvin Combs Date: Thu, 20 Jan 2022 15:35:03 -0800 Subject: [PATCH 1/2] file deletion --- .../cloudformation-diff/lib/format.ts | 2 + .../lib/api/cloudformation-deployments.ts | 148 +++- .../aws-cdk/lib/api/hotswap-deployments.ts | 1 - packages/aws-cdk/lib/cdk-toolkit.ts | 4 +- .../api/cloudformation-deployments.test.ts | 731 +++++++++++++++++- ...utput-one-param-stack.nested.template.json | 20 + ...ource-one-stack-stack.nested.template.json | 16 + .../one-resource-stack.nested.template.json | 10 + ...urce-two-stacks-stack.nested.template.json | 22 + packages/aws-cdk/test/diff.test.ts | 322 +++++--- packages/aws-cdk/test/util.ts | 20 + 11 files changed, 1180 insertions(+), 116 deletions(-) create mode 100644 packages/aws-cdk/test/diff-nested-stacks-templates/one-output-one-param-stack.nested.template.json create mode 100644 packages/aws-cdk/test/diff-nested-stacks-templates/one-resource-one-stack-stack.nested.template.json create mode 100644 packages/aws-cdk/test/diff-nested-stacks-templates/one-resource-stack.nested.template.json create mode 100644 packages/aws-cdk/test/diff-nested-stacks-templates/one-resource-two-stacks-stack.nested.template.json diff --git a/packages/@aws-cdk/cloudformation-diff/lib/format.ts b/packages/@aws-cdk/cloudformation-diff/lib/format.ts index 3dee563f8cf36..570c670e2d381 100644 --- a/packages/@aws-cdk/cloudformation-diff/lib/format.ts +++ b/packages/@aws-cdk/cloudformation-diff/lib/format.ts @@ -272,8 +272,10 @@ class Formatter { this.formatObjectDiff(oldValue, newValue, `${linePrefix} ${key === lastKey ? ' ' : '│'}`); } else if (oldValue !== undefined /* && newValue === undefined */) { this.print('%s %s─ %s Removed: %s', linePrefix, treePrefix, REMOVAL, chalk.blue(`.${key}`)); + this.formatObjectDiff(oldValue, newValue, `${linePrefix} ${key === lastKey ? ' ' : '│'}`); } else /* if (oldValue === undefined && newValue !== undefined */ { this.print('%s %s─ %s Added: %s', linePrefix, treePrefix, ADDITION, chalk.blue(`.${key}`)); + this.formatObjectDiff(oldValue, newValue, `${linePrefix} ${key === lastKey ? ' ' : '│'}`); } } } diff --git a/packages/aws-cdk/lib/api/cloudformation-deployments.ts b/packages/aws-cdk/lib/api/cloudformation-deployments.ts index a4438ff0ca8f7..21933c955b3b8 100644 --- a/packages/aws-cdk/lib/api/cloudformation-deployments.ts +++ b/packages/aws-cdk/lib/api/cloudformation-deployments.ts @@ -1,5 +1,8 @@ +import * as path from 'path'; import * as cxapi from '@aws-cdk/cx-api'; import { AssetManifest } from 'cdk-assets'; +import * as fs from 'fs-extra'; +import { LazyListStackResources, ListStackResources } from '../api/evaluate-cloudformation-template'; import { Tag } from '../cdk-toolkit'; import { debug, warning } from '../logging'; import { publishAssets } from '../util/asset-publishing'; @@ -293,25 +296,20 @@ export class CloudFormationDeployments { this.sdkProvider = props.sdkProvider; } - public async readCurrentTemplate(stackArtifact: cxapi.CloudFormationStackArtifact): Promise