Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit ff03827

Browse filesBrowse files
committed
fix(@angular/cli): respect registry in RC when running update through yarn
This commit fixes an issue where when `ng update` was ran using `yarn` (`yarn ng update`) the registry was always being overridden to `https://registry.yarnpkg.com`. This is because yarn will set the `npm_config_registry` env variable to `https://registry.yarnpkg.com` even when an RC file is present with a different repository. (cherry picked from commit 0dcb199)
1 parent fc82e3b commit ff03827
Copy full SHA for ff03827

File tree

Expand file treeCollapse file tree

2 files changed

+24
-1
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+24
-1
lines changed

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

Copy file name to clipboardExpand all lines: packages/angular/cli/src/utilities/package-metadata.ts
+12Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,18 @@ function readOptions(
139139
continue;
140140
}
141141

142+
if (
143+
normalizedName === 'registry' &&
144+
rcOptions['registry'] &&
145+
value === 'https://registry.yarnpkg.com' &&
146+
process.env['npm_config_user_agent']?.includes('yarn')
147+
) {
148+
// When running `ng update` using yarn (`yarn ng update`), yarn will set the `npm_config_registry` env variable to `https://registry.yarnpkg.com`
149+
// even when an RC file is present with a different repository.
150+
// This causes the registry specified in the RC to always be overridden with the below logic.
151+
continue;
152+
}
153+
142154
normalizedName = normalizedName.replace(/(?!^)_/g, '-'); // don't replace _ at the start of the key.s
143155
envVariablesOptions[normalizedName] = value;
144156
}

‎tests/legacy-cli/e2e/tests/update/update-secure-registry.ts

Copy file name to clipboardExpand all lines: tests/legacy-cli/e2e/tests/update/update-secure-registry.ts
+12-1Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1-
import { ng } from '../../utils/process';
1+
import { exec, ng } from '../../utils/process';
22
import { createNpmConfigForAuthentication } from '../../utils/registry';
33
import { expectToFail } from '../../utils/utils';
44
import { isPrereleaseCli } from '../../utils/project';
5+
import { getActivePackageManager } from '../../utils/packages';
6+
import assert from 'node:assert';
57

68
export default async function () {
79
// The environment variable has priority over the .npmrc
@@ -32,4 +34,13 @@ export default async function () {
3234

3335
await createNpmConfigForAuthentication(true, true);
3436
await expectToFail(() => ng('update', ...extraArgs));
37+
38+
if (getActivePackageManager() === 'yarn') {
39+
// When running `ng update` using yarn (`yarn ng update`), yarn will set the `npm_config_registry` env variable to `https://registry.yarnpkg.com`
40+
// Validate the the registry in the RC is used.
41+
await createNpmConfigForAuthentication(true, true);
42+
43+
const error = await expectToFail(() => exec('yarn', 'ng', 'update', ...extraArgs));
44+
assert.match(error.message, /not allowed to access package/);
45+
}
3546
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.