upload-npm : support authToken argument

Support setting authToken to use a token for upload rather than
username/password.

This is "based" on Id0c47d088d6e8febbae3c96caecc81ebe247754e which
does the same for pypi.  There we run a test by uploading to the test
pypi server, I'm not aware of a similar thing for npm.

Change-Id: Ie8610bdfaa33b2120a61802c12e6ba534fe55464
This commit is contained in:
Ian Wienand 2022-09-07 13:23:41 +10:00
parent 1f78388328
commit 1520fb6474
3 changed files with 18 additions and 1 deletions

View File

@ -17,6 +17,13 @@ Upload javascript packages to npm
Password to use to log in to npm.
.. zuul:rolevar:: authToken
An auth token (issued from the npm server) to authenticate with.
This is required if you are using two-factor authentication. If
specifying an authToken you should not specify ```username`` and
``password``.
.. zuul:rolevar:: email
Email associated with the npm account.

View File

@ -1,3 +1,10 @@
- name: Validate password/token combo
fail:
msg: 'Specify either username/password or authToken'
when: >
(npm_credentials.authToken is defined) and
((npm_credentials.username is defined) or (npm_credentials.password is defined))
# This is not optimized, but allows for getting a version of node in the
# home dir.
- name: Create .npmrc configuration file

View File

@ -4,7 +4,10 @@ init.author.url={{ npm_credentials.author_url }}
tag-version-prefix=
sign-git-tag=true
{% if npm_credentials.username is defined %}
//registry.npmjs.org/:username={{ npm_credentials.username }}
//registry.npmjs.org/:_password={{ npm_credentials.password }}
{% else %}
//registry.npmjs.org/:_authToken={{ npm_credentials.authToken }}
{% endif %}
//registry.npmjs.org/:email={{ npm_credentials.author_email }}