Skip to content

Commit

Permalink
fix(@angular/cli): handle unscoped authentication details in .npmrc
Browse files Browse the repository at this point in the history
… 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
  • Loading branch information
alan-agius4 authored and clydin committed Jun 16, 2021
1 parent e680aa1 commit 77c96f8
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
5 changes: 4 additions & 1 deletion packages/angular/cli/src/commands/update/schematic/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@ import { Rule, SchematicContext, SchematicsException, Tree } from '@angular-devk
import * as npa from 'npm-package-arg';
import * as semver from 'semver';
import { Dependency, JsonSchemaForNpmPackageJsonFiles } from '../../../../utilities/package-json';
import { NpmRepositoryPackageJson, getNpmPackageJson } from '../../../../utilities/package-metadata';
import {
NpmRepositoryPackageJson,
getNpmPackageJson,
} from '../../../../utilities/package-metadata';
import { Schema as UpdateSchema } from './schema';

type VersionRange = string & { __VERSION_RANGE: void };
Expand Down
13 changes: 13 additions & 0 deletions packages/angular/cli/utilities/package-metadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,19 @@ function readOptions(
}

switch (key) {
// 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
case '_authToken':
case 'token':
case 'username':
case 'password':
case '_auth':
case 'auth':
options['forceAuth'] ??= {};
options['forceAuth'][key] = substitutedValue;
break;
case 'noproxy':
case 'no-proxy':
options['noProxy'] = substitutedValue;
Expand Down

0 comments on commit 77c96f8

Please sign in to comment.