drone-plugins / drone-npm

Drone plugin for publishing packages to NPM
http://plugins.drone.io/drone-plugins/drone-npm
Apache License 2.0
20 stars 18 forks source link

Feature Request: pull npm email from package.json #27

Closed jasonkarns closed 4 years ago

jasonkarns commented 7 years ago

We just discovered that our package has been publishing with an outdated email address for some time because the email information must be duplicated between package.json and .drone.yml.

I propose that the npm email default (when not provided) to the author email provided in package.json, as is conventional for npm packages.

donny-dont commented 7 years ago

It appears that email is optional and additionally it can all be jammed into a string.

https://docs.npmjs.com/files/package.json#people-fields-author-contributors

I'm kinda on the fence as to whether this is a good idea. @bradrydzewski you have any thoughts?

jasonkarns commented 7 years ago

Unsure what the easiest way to incorporate this into the plugin might be... But npm normalizes the author into its constituent fields, and is exposed via env vars (as everything else in package.json).

So in the context of an npm script, $npm_package_author_email is guaranteed to contain just the email, regardless if the package.json has email as author.email object or via the formatted author string. (It could still be empty string, but I'm assuming the plugin would grab the email from package.json before doing the existing validation for non-empty email.)

Since drone isn't running in the context of an npm script, the way that npm normalizes the package.json is available via normalize-package-data.

Alternatively, with the new npx module now bundled in npm (also available standalone if running npm <5), one could run any arbitrary shell command in the context of npm: npx -c 'echo $npm_package_author_email.

Unsure if any of those options are acceptable or could work into the plugin flow...

donny-dont commented 4 years ago

Its been 3 years. Open to PRs if someone else has this issue.