fix(aws-s3-assets): support asset url with two extension name like tar.gz#20874
fix(aws-s3-assets): support asset url with two extension name like tar.gz#20874mergify[bot] merged 18 commits intoaws:mainfrom
Conversation
| } else { | ||
| let extensionName: string = path.extname(this.sourcePath); | ||
| const sourceName: string = path.basename(this.sourcePath).replace(extensionName, ''); | ||
| const doubleArchive = ARCHIVE_EXTENSIONS.includes(path.extname(sourceName)) ? true : false; |
There was a problem hiding this comment.
Array.prototype.includes() already returns true or false. This ternary construction is unnecessary.
| const stagedPath = this.stagingDisabled | ||
| ? this.sourcePath | ||
| : path.resolve(this.assetOutdir, renderAssetFilename(assetHash, path.extname(this.sourcePath))); | ||
| let stagedPath: string; |
There was a problem hiding this comment.
Is it possible to refactor the implementation without using let and without the code becoming too difficult to read? You want to use const if at all possible.
There was a problem hiding this comment.
I could create a method that checks for double extensions and returns an extension string? This will replace path.extname(this.sourcePath)
kellertk
left a comment
There was a problem hiding this comment.
Instead of overloading ARCHIVE_EXTENSIONS, would it be possible to genericize the implementation? So you can use any arbitrary number of extensions on a file an they'd all be preserved.
The idea behind overloading |
|
Looks great! I would love to see a unit test or two for the new function just to make sure that it handles some common cases. A nitpick: one common extension for compressed tar archives is |
…two extension names
|
LGTM |
|
Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork). |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
|
Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork). |
…r.gz (aws#20874) using aws-s3-assets to upload data artifacts of extension `tar.gz` returns an uploaded asset renamed to `<random Id>.gz`. This PR proposes that the AssetStaging Object should be able to check if the uploaded artifact is a `tar.gz` or any other archive tar file with a compression extension and return the appropriate extension name as stagedPath. closes aws#12699 ### All Submissions: * [x] Have you followed the guidelines in our [Contributing guide?](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) ### Adding new Unconventional Dependencies: * [ ] This PR adds new unconventional dependencies following the process described [here](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md/#adding-new-unconventional-dependencies) ### New Features * [ ] Have you added the new feature to an [integration test](https://github.com/aws/aws-cdk/blob/main/INTEGRATION_TESTS.md)? * [ ] Did you use `yarn integ` to deploy the infrastructure and generate the snapshot (i.e. `yarn integ` without `--dry-run`)? *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
using aws-s3-assets to upload data artifacts of extension
tar.gzreturns an uploaded asset renamed to<random Id>.gz.This PR proposes that the AssetStaging Object should be able to check if the uploaded artifact is a
tar.gzor any other archive tar file with a compression extension and return the appropriate extension name as stagedPath.closes #12699
All Submissions:
Adding new Unconventional Dependencies:
New Features
yarn integto deploy the infrastructure and generate the snapshot (i.e.yarn integwithout--dry-run)?By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license