Skip to content

Commit 77c96f8

Browse files
alan-agius4clydin
authored andcommitted
fix(@angular/cli): handle unscoped authentication details in .npmrc files
Unless auth options are scope with the registry url it appears that npm-registry-fetch ignores them, even though they are documented. https://github.com/npm/npm-registry-fetch/blob/8954f61d8d703e5eb7f3d93c9b40488f8b1b62ac/README.md https://github.com/npm/npm-registry-fetch/blob/8954f61d8d703e5eb7f3d93c9b40488f8b1b62ac/auth.js#L45-L91
1 parent e680aa1 commit 77c96f8

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

packages/angular/cli/src/commands/update/schematic/index.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,10 @@ import { Rule, SchematicContext, SchematicsException, Tree } from '@angular-devk
1111
import * as npa from 'npm-package-arg';
1212
import * as semver from 'semver';
1313
import { Dependency, JsonSchemaForNpmPackageJsonFiles } from '../../../../utilities/package-json';
14-
import { NpmRepositoryPackageJson, getNpmPackageJson } from '../../../../utilities/package-metadata';
14+
import {
15+
NpmRepositoryPackageJson,
16+
getNpmPackageJson,
17+
} from '../../../../utilities/package-metadata';
1518
import { Schema as UpdateSchema } from './schema';
1619

1720
type VersionRange = string & { __VERSION_RANGE: void };

packages/angular/cli/utilities/package-metadata.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,19 @@ function readOptions(
149149
}
150150

151151
switch (key) {
152+
// Unless auth options are scope with the registry url it appears that npm-registry-fetch ignores them,
153+
// even though they are documented.
154+
// https://github.com/npm/npm-registry-fetch/blob/8954f61d8d703e5eb7f3d93c9b40488f8b1b62ac/README.md
155+
// https://github.com/npm/npm-registry-fetch/blob/8954f61d8d703e5eb7f3d93c9b40488f8b1b62ac/auth.js#L45-L91
156+
case '_authToken':
157+
case 'token':
158+
case 'username':
159+
case 'password':
160+
case '_auth':
161+
case 'auth':
162+
options['forceAuth'] ??= {};
163+
options['forceAuth'][key] = substitutedValue;
164+
break;
152165
case 'noproxy':
153166
case 'no-proxy':
154167
options['noProxy'] = substitutedValue;

0 commit comments

Comments
 (0)