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
Set the package.json pulumi name even if PluginName isn't set #10088
Conversation
Please view the results of the Downstream Codegen Tests Here |
This will not completely fix #10087, but it will consistently set: "pulumi": {
"name": <plugin name>
} in the generated |
Please view the results of the Downstream Codegen Tests Here |
Please view the results of the Downstream Codegen Tests Here |
@@ -2135,6 +2135,13 @@ func genNPMPackageMetadata(pkg *schema.Package, info NodePackageInfo) string { | |||
scriptVersion = pluginVersion | |||
} | |||
|
|||
pluginName := info.PluginName | |||
// Default to the pulumi package name if PluginName isn't set by the user. This is different to the npm |
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.
Note we could be a bit smarter here and only set name if needed. A lot of "@pulumi" packages would work even without name set here because we strip it off the npm name. That is a plugin "azure" with a npm package name of "@pulumi/azure" doesn't need the plugin name explicitly set. Similarly if the plugin name == the npm package name then this doesn't need to be set.
That would reduce the diff of this change a bit because all the test packages would fit this style, and also means things like actual azure codegen won't change from this.
But then maybe it's better to just be simple and explicit.
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'm happy to take the bigger diff if we get simpler logic.
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'm assuming the test failure is unrelated.
Looks it |
Description
Related to #10087
Currently the nodejs runtime will use "pulumi.name" from package.json as the plugin name, if it's not set it falls back to the npm package name (i.e. "name" in package.json). This is nearly always wrong as npm names look like "@pulumiverse/sentry" while the pulumi package name (and thus plugin name) would be something like "sentry".
This changes nodejs codegen to always set "pulumi.name" to either the user given "PluginName", or if that is not set to the pulumi package name. This should mean most users don't even need to set "PluginName".
Checklist