From 1c9954e50ebdd4f2b290e91665c920fb504c9cb7 Mon Sep 17 00:00:00 2001 From: Tsuf Cohen <39455181+tsuf239@users.noreply.github.com> Date: Mon, 14 Aug 2023 19:11:09 +0300 Subject: [PATCH] fix(sdk): fix website source_hash (#3807) Fixing the source_hash in the sdk snapshots to be a string and not a path ## Checklist - [x] Title matches [Winglang's style guide](https://www.winglang.io/contributing/start-here/pull_requests#how-are-pull-request-titles-formatted) - [x] Description explains motivation and solution - [ ] Tests added (always) - [ ] Docs updated (only required for features) - [ ] Added `pr/e2e-full` label if this feature requires end-to-end testing *By submitting this pull request, I confirm that my contribution is made under the terms of the [Wing Cloud Contribution License](https://github.com/winglang/wing/blob/main/CONTRIBUTION_LICENSE.md)*. --- .../test/target-tf-aws/__snapshots__/website.test.ts.snap | 8 ++++---- libs/wingsdk/test/util.ts | 7 +++++++ 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/libs/wingsdk/test/target-tf-aws/__snapshots__/website.test.ts.snap b/libs/wingsdk/test/target-tf-aws/__snapshots__/website.test.ts.snap index ef32b8d9ff1..ca4868b4271 100644 --- a/libs/wingsdk/test/target-tf-aws/__snapshots__/website.test.ts.snap +++ b/libs/wingsdk/test/target-tf-aws/__snapshots__/website.test.ts.snap @@ -144,7 +144,7 @@ exports[`default website behavior 1`] = ` ], \\"key\\": \\"/b.html\\", \\"source\\": \\"\\", - \\"source_hash\\": \\"\${filemd5(\\\\\\"/home/runner/work/wing/wing/libs/wingsdk/test/target-tf-aws/website/b.html\\\\\\")}\\" + \\"source_hash\\": \\"\${filemd5()}\\" }, \\"Website_File--inner-folder--ahtml_7D20A7EF\\": { \\"bucket\\": \\"\${aws_s3_bucket.Website_WebsiteBucket_3C0321F0.bucket}\\", @@ -154,7 +154,7 @@ exports[`default website behavior 1`] = ` ], \\"key\\": \\"/inner-folder/a.html\\", \\"source\\": \\"\\", - \\"source_hash\\": \\"\${filemd5(\\\\\\"/home/runner/work/wing/wing/libs/wingsdk/test/target-tf-aws/website/inner-folder/a.html\\\\\\")}\\" + \\"source_hash\\": \\"\${filemd5()}\\" } } } @@ -480,7 +480,7 @@ exports[`website with add_json 1`] = ` ], \\"key\\": \\"/b.html\\", \\"source\\": \\"\\", - \\"source_hash\\": \\"\${filemd5(\\\\\\"/home/runner/work/wing/wing/libs/wingsdk/test/target-tf-aws/website/b.html\\\\\\")}\\" + \\"source_hash\\": \\"\${filemd5()}\\" }, \\"Website_File--inner-folder--ahtml_7D20A7EF\\": { \\"bucket\\": \\"\${aws_s3_bucket.Website_WebsiteBucket_3C0321F0.bucket}\\", @@ -490,7 +490,7 @@ exports[`website with add_json 1`] = ` ], \\"key\\": \\"/inner-folder/a.html\\", \\"source\\": \\"\\", - \\"source_hash\\": \\"\${filemd5(\\\\\\"/home/runner/work/wing/wing/libs/wingsdk/test/target-tf-aws/website/inner-folder/a.html\\\\\\")}\\" + \\"source_hash\\": \\"\${filemd5()}\\" }, \\"Website_File-configjson_1F1498B9\\": { \\"bucket\\": \\"\${aws_s3_bucket.Website_WebsiteBucket_3C0321F0.bucket}\\", diff --git a/libs/wingsdk/test/util.ts b/libs/wingsdk/test/util.ts index b721d2fd87d..9f0899877ec 100644 --- a/libs/wingsdk/test/util.ts +++ b/libs/wingsdk/test/util.ts @@ -107,6 +107,13 @@ export function tfSanitize(templateStr: string): string { ) { return ""; } + if ( + key === "source_hash" && + typeof value === "string" && + value.startsWith("${filemd5") + ) { + return "${filemd5()}"; + } return value; }, 2