Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions packages/angular/cli/src/commands/update/schematic/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -804,6 +804,13 @@ function _formatVersion(version: string | undefined) {
* @throws When the specifier cannot be parsed.
*/
function isPkgFromRegistry(name: string, specifier: string): boolean {
// npm: aliases (e.g., "npm:real-package@^1.0.0") resolve as registry packages
// but the dependency key name differs from the actual package name, so registry
// lookups using the alias name would fail with a 404.
if (specifier.startsWith('npm:')) {
return false;
}

const result = npa.resolve(name, specifier);

return !!result.registry;
Comment on lines +807 to 816
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

Using the result of npa.resolve to detect aliases is more robust than a manual string prefix check. This approach handles edge cases like case-insensitivity (e.g., NPM:) and potential whitespace consistently with how the rest of the package resolution logic operates.

Suggested change
// npm: aliases (e.g., "npm:real-package@^1.0.0") resolve as registry packages
// but the dependency key name differs from the actual package name, so registry
// lookups using the alias name would fail with a 404.
if (specifier.startsWith('npm:')) {
return false;
}
const result = npa.resolve(name, specifier);
return !!result.registry;
// npm: aliases (e.g., "npm:real-package@^1.0.0") resolve as registry packages
// but the dependency key name differs from the actual package name, so registry
// lookups using the alias name would fail with a 404.
const result = npa.resolve(name, specifier);
return !!result.registry && result.type !== 'alias';

Expand Down Expand Up @@ -854,6 +861,12 @@ export default function (options: UpdateSchema): Rule {
registry: options.registry,
usingYarn,
verbose: options.verbose,
}).catch(() => {
// Package metadata could not be fetched (e.g. private registry, npm: alias,
// JSR package, or AWS CodeArtifact). Return a partial result so the reduce
// below can decide whether to warn or error based on whether it was explicitly
// requested.
return { requestedName: depName } as Partial<NpmRepositoryPackageJson>;
}),
),
);
Expand Down
Loading