Please support repository authentication for Yarn 3+
DannyMeister opened this issue · comments
Are you reporting a bug or a feature request ?
- Bug
- Feature request
Description
Yarn 3 does not use .npmrc
, rather it uses .yarnrc.yml
. Though our ADO packages repository is specified in npmRegistryServer
, the Yarn@3 task does not update the .yarnrc.yml with an ident token for the repository.
Expected behavior
Running the install argument from Yarn task should update .yarnrc.yml
, adding npmAuthIdent
.
System information
VSTS or TFS:
- VSTS
- TFS
Agent:
- Hosted
- Custom
OS:
- Windows
- Mac
- Linux
Yarn version:
3.4.1
Node version:
16.17.0
My current workaround is to also include an .npmrc
file in my repo (having to dual maintain the registry URL in each file), use the npmAuthenticate
task to update .npmrc
with an auth token, then copy it to my .yarnrc.yml
file with a bash script.
- task: npmAuthenticate@0
inputs:
workingFile: .npmrc
- task: Bash@3
inputs:
targetType: "inline"
script: |
grep -m1 'npm/registry/:_authToken=' .npmrc | cut -f2- -d'=' | sed 's/\(.*\)/\nnpmAuthToken: \"\1\"/' >> .yarnrc.yml
displayName: "Copy .npmrc auth to .yarnrc.yml"
Out of curiosity with corepack what value does this task provide to you?
I'm asking this because I've been considering officially deprecating this and adding the following example in the homepage.
I'm also happy to look at a PR to improve this in the meantime.
I wasn't familiar with corepack, but after reading a bit, I think it's going to mostly help people to get the desired package manager installed. That's not really a problem I use the Yarn task for. Authentication was my main use for it, but the upgrade to Yarn 3 renders both the Yarn task and the npmAuthenticate task obsolete for authentication since they both only deal with .npmrc
.