-
Notifications
You must be signed in to change notification settings - Fork 246
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
feat(.net): embed package icon when configured #3676
Conversation
When an `iconUrl` is configured for a .NET target, attempt to download it for inclusion in the NuGet package with the `PackageIcon` attribute, as the `PackageIconUrl` attribute is deprecated. This feature can be opted out of by setting the `JSII_PACMAK_DOTNET_NO_DOWNLOAD_ICON` environment variable (no matter what value it has). If the download somehow fails, the previous behavior is preserved. The `PackageIconUrl` attribute is still emitted for backwards compatibility with tools that do not (yet) support `PackageIcon`.
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.
Just a few comments / questions
} | ||
break; | ||
default: | ||
// Nothing to do... |
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.
if it's not one of these, how can it be a valid icon? Shouldn't this be an error?
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.
The spec unfortunately does not specify what is a valid MIME type for the icon, and there are more image formats that I can't be bothered with (ico, heic, etc..)
// Attempt to download the package icon from the configured URL so we can use the non-deprecated PackageIcon | ||
// attribute. If this fails or is opted out (via $JSII_PACMAK_DOTNET_NO_DOWNLOAD_ICON being set), then only the | ||
// deprecated PackageIconUrl will be emitted. | ||
const iconFile = |
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 there a way for the user to pass this file without downloading it (eg if they already have the icon locally)?
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.
Not currently... That'd require they bundle the icon in their npm package, which I'm not sure is appropriate...
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.
LGTM!
Thank you for contributing! ❤️ I will now look into making sure the PR is up-to-date, then proceed to try and merge it! |
Merging (with squash)... |
1 similar comment
Merging (with squash)... |
…e-icon # Conflicts: # packages/jsii-calc/test/assembly.jsii
Merging (with squash)... |
Introduced in aws/jsii#3676 and released in `jsii@1.64.0`
When an
iconUrl
is configured for a .NET target, attempt to downloadit for inclusion in the NuGet package with the
PackageIcon
attribute,as the
PackageIconUrl
attribute is deprecated.This feature can be opted out of by setting the
JSII_PACMAK_DOTNET_NO_DOWNLOAD_ICON
environment variable (no matterwhat value it has).
If the download somehow fails, the previous behavior is preserved.
The
PackageIconUrl
attribute is still emitted for backwardscompatibility with tools that do not (yet) support
PackageIcon
.By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.