Skip to content
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

Please support repository authentication for Yarn 3+ #115

Open
4 of 9 tasks
DannyMeister opened this issue Mar 1, 2023 · 3 comments
Open
4 of 9 tasks

Please support repository authentication for Yarn 3+ #115

DannyMeister opened this issue Mar 1, 2023 · 3 comments

Comments

@DannyMeister
Copy link

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

@DannyMeister
Copy link
Author

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"

@sandorfr
Copy link
Member

sandorfr commented Mar 2, 2023

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.

#103 (comment)

I'm also happy to look at a PR to improve this in the meantime.

@DannyMeister
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants