-
Notifications
You must be signed in to change notification settings - Fork 3.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(aws-s3-assets): support asset url with two extension name like tar.gz #20874
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I could create a method that checks for double extensions and returns an extension string? This will replace path.extname(this.sourcePath)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks fantastic.
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.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 #12699
All Submissions:
Adding new Unconventional Dependencies:
New Features
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