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

docs(private-packages): add a note about Yarn 2+ #11692

Merged
merged 2 commits into from Sep 12, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 6 additions & 0 deletions docs/usage/getting-started/private-packages.md
Expand Up @@ -259,6 +259,12 @@ However be aware that if your `.npmrc` is too big to encrypt then the above comm
}
```

#### Yarn 2+

Renovate doesn't support reading `npmRegistries` and `npmScopes` from `.yarnrc.yml`, so `hostRules` (or `npmToken`) and `npmrc` should be configured like above.
Renovate updates `npmRegistries` in `.yarnrc.yml` with resolved `hostRules` before running Yarn.
For Renovate to overwrite existing `npmRegistries` entry, the key should match the `matchHost` without the protocol (`http:` or `https:`) and with the trailing slash.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rarkins Are we sure about this behavior?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't double check it but assumed @ylemkimon checked the source :)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've verified, this won't work for npm datasource. The hostrule won't applied, as it's not a url or a hostname.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we're talking about different things here.

renovate/lib/util/url.ts

Lines 49 to 55 in 62a540c

export function validateUrl(url?: string, httpOnly = true): boolean {
if (!url) {
return false;
}
try {
const { protocol } = new URL(url);
return httpOnly ? !!protocol.startsWith('http') : !!protocol;
let uri = hostRule.matchHost;
uri = validateUrl(uri) ? uri.replace(/^https?:/, '') : `//${uri}/`;

I meant following Renovate configuration:

{
  "hostRules": [
    {
      "matchHost": "https://npm.pkg.github.com/",
      "hostType": "npm",
      "encrypted": {
        "token": "<Encrypted PAT token>"
      }
    }
  ]
}

will update .yarnrc.yml as following:

npmRegistries:
  //npm.pkg.github.com/:
    npmAuthToken: <Decrypted PAT token>

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So without needs to be with https? prefix. I think the sample should be added too.

@ylemkimon can you create a new PR for it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've opened #11696.


### nuget

For each known NuGet registry, Renovate searches for `hostRules` with `hostType=nuget` and matching host.
Expand Down