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

feat(npm): remove ~/.npmrc support #9400

Merged
merged 32 commits into from Apr 6, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
7a2d672
feat: remove RENOVATE_LEGACY_GIT_AUTHOR_EMAIL (#9389)
rarkins Apr 4, 2021
69ea8fc
feat: drop NPM_TOKEN support (#9391)
rarkins Apr 4, 2021
a5c785a
feat: remove logLevel support in config (#9390)
rarkins Apr 4, 2021
2eb962c
feat: split trustLevel into separate options (#9388)
rarkins Apr 4, 2021
2ee681f
feat(config): remove manager additionalBranchPrefix defaults (#9373)
rarkins Apr 4, 2021
ff15c91
feat: updateType=patch (#9393)
rarkins Apr 4, 2021
e5fc93e
feat(terraform): rework dep types (#9116)
secustor Apr 4, 2021
bb95d9e
docs: improve sentences (#9395)
HonkingGoose Apr 4, 2021
7504640
feat(npm): deprecate ~/.npmrc support
rarkins Apr 4, 2021
cd98c87
Merge remote-tracking branch 'origin/v25' into breaking/npmrc-home-dir
rarkins Apr 4, 2021
301fa13
update docs
rarkins Apr 4, 2021
8fd9af2
fix lint
rarkins Apr 4, 2021
229a835
feat: remove RENOVATE_LEGACY_GIT_AUTHOR_EMAIL (#9389)
rarkins Apr 4, 2021
49f08da
feat: drop NPM_TOKEN support (#9391)
rarkins Apr 4, 2021
07439a5
feat: remove logLevel support in config (#9390)
rarkins Apr 4, 2021
f9b9614
feat: split trustLevel into separate options (#9388)
rarkins Apr 4, 2021
8c19baf
feat(config): remove manager additionalBranchPrefix defaults (#9373)
rarkins Apr 4, 2021
d954ea7
feat: updateType=patch (#9393)
rarkins Apr 4, 2021
d723b58
feat(terraform): rework dep types (#9116)
secustor Apr 4, 2021
971ae10
docs: improve sentences (#9395)
HonkingGoose Apr 4, 2021
bf45146
Merge branch 'v25' into breaking/npmrc-home-dir
rarkins Apr 5, 2021
4cf313c
feat: remove RENOVATE_LEGACY_GIT_AUTHOR_EMAIL (#9389)
rarkins Apr 4, 2021
75aca40
feat: drop NPM_TOKEN support (#9391)
rarkins Apr 4, 2021
070136f
feat: remove logLevel support in config (#9390)
rarkins Apr 4, 2021
ed3595e
feat: split trustLevel into separate options (#9388)
rarkins Apr 4, 2021
91ba144
feat(config): remove manager additionalBranchPrefix defaults (#9373)
rarkins Apr 4, 2021
9a47d1e
feat: updateType=patch (#9393)
rarkins Apr 4, 2021
551cc79
feat(terraform): rework dep types (#9116)
secustor Apr 4, 2021
05b2ed1
docs: improve sentences (#9395)
HonkingGoose Apr 4, 2021
a0b46f4
Merge branch 'v25' into breaking/npmrc-home-dir
rarkins Apr 5, 2021
7b8ba89
Merge branch 'v25' into breaking/npmrc-home-dir
rarkins Apr 5, 2021
947903f
Merge remote-tracking branch 'origin/v25' into breaking/npmrc-home-dir
rarkins Apr 6, 2021
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
1 change: 0 additions & 1 deletion docs/development/local-development.md
Expand Up @@ -75,7 +75,6 @@ The Renovate project uses the [Yarn](https://github.com/yarnpkg/yarn) package ma

To ensure everything is working properly on your end, you must:

1. Make sure you don't have a local `.npmrc` file that overrides npm's default registry
1. Install all dependencies with `yarn install`
1. Make a build with `yarn build`, which should pass with no errors
1. Verify all tests pass and have 100% test coverage, by running `yarn test`
Expand Down
16 changes: 1 addition & 15 deletions docs/usage/private-modules.md
Expand Up @@ -33,8 +33,6 @@ The recommended approaches in order of preference are:

**Self-hosted hostRules**: Configure a hostRules entry in the bot's `config.js` with the `hostType`, `hostName` and `token` specified

**Self-hosted .npmrc**: copy an `.npmrc` file to the home dir of the bot.

**Renovate App with private modules from npmjs.org**: Add an encrypted `npmToken` to your Renovate config

**Renovate App with a private registry**: Add an unencrypted `npmrc` plus an encrypted `npmToken` in config
Expand Down Expand Up @@ -66,21 +64,9 @@ module.exports = {

**NOTE:** Do not use `NPM_TOKEN` as an environment variable.

### Commit .npmrc file into repository

One approach that many projects use for private repositories is to simply check in an authenticated `.npmrc` into the repository that is then shared between all developers.
Therefore anyone running `npm install` or `yarn install` from the project root will be automatically authenticated with npm without having to distribute npm logins to every developer and make sure they've run `npm login` first before installing.

The good news is that this works for Renovate too.
If Renovate detects a `.npmrc` or `.yarnrc` file then it will use it for its install.

Does not work if using binarySource=docker.
_This method will be deprecated soon_

### Add npmrc string to Renovate config

The above solution maybe have a downside that all users of the repository (e.g. developers) will also use any `.npmrc` that is checked into the repository, instead of their own one in `~/.npmrc`.
To avoid this, you can instead add your `.npmrc` authentication line to your Renovate config under the field `npmrc`. e.g. a `renovate.json` might look like this:
You can add an `.npmrc` authentication line to your Renovate config under the field `npmrc`. e.g. a `renovate.json` might look like this:

```json
{
Expand Down
2 changes: 1 addition & 1 deletion lib/datasource/npm/__snapshots__/index.spec.ts.snap
Expand Up @@ -522,7 +522,7 @@ Array [
exports[`datasource/npm/index should use default registry if missing from npmrc 1`] = `
Object {
"name": "foobar",
"registryUrl": "https://registry.npmjs.org",
"registryUrl": "https://registry.npmjs.org/",
"releases": Array [
Object {
"releaseTimestamp": "2018-05-06T05:21:53.000Z",
Expand Down
2 changes: 1 addition & 1 deletion lib/datasource/npm/index.spec.ts
Expand Up @@ -314,7 +314,7 @@ describe(getName(__filename), () => {
setNpmrc(npmrcContent);
setNpmrc(npmrcContent);
setNpmrc();
expect(getNpmrc()).toBeNull();
expect(getNpmrc()).toEqual({});
});

it('should use default registry if missing from npmrc', async () => {
Expand Down
2 changes: 1 addition & 1 deletion lib/datasource/npm/npmrc.spec.ts
Expand Up @@ -51,6 +51,6 @@ describe(getName(__filename), () => {
it('ignores localhost', () => {
setNpmrc(`registry=http://localhost`);
expect(sanitize.add).toHaveBeenCalledTimes(0);
expect(getNpmrc()).toBeNull();
expect(getNpmrc()).toEqual({});
});
});
10 changes: 5 additions & 5 deletions lib/datasource/npm/npmrc.ts
Expand Up @@ -9,8 +9,8 @@ import { logger } from '../../logger';
import { maskToken } from '../../util/mask';
import { add } from '../../util/sanitize';

let npmrc: Record<string, any> | null = null;
let npmrcRaw: string;
let npmrc: Record<string, any> = {};
let npmrcRaw = '';

export type Npmrc = Record<string, any>;

Expand Down Expand Up @@ -89,8 +89,8 @@ export function setNpmrc(input?: string): void {
}
} else if (npmrc) {
logger.debug('Resetting npmrc');
npmrc = null;
npmrcRaw = null;
npmrc = {};
npmrcRaw = '';
}
}

Expand All @@ -106,7 +106,7 @@ export function resolvePackage(packageName: string): PackageResolution {
try {
registryUrl = getRegistryUrl(scope, getNpmrc());
} catch (err) {
registryUrl = 'https://registry.npmjs.org';
registryUrl = 'https://registry.npmjs.org/';
}
const packageUrl = url.resolve(
registryUrl,
Expand Down