Skip to content
Open
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
20 changes: 14 additions & 6 deletions packages/angular/cli/src/commands/add/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -489,12 +489,9 @@ export default class AddCommandModule

let manifest;
try {
manifest = await this.context.packageManager.getManifest(
context.packageIdentifier.toString(),
{
registry,
},
);
manifest = await this.context.packageManager.getManifest(context.packageIdentifier, {
registry,
});
} catch (e) {
assertIsError(e);
throw new CommandError(
Expand All @@ -508,6 +505,17 @@ export default class AddCommandModule
);
}

// Avoid fully resolving the package version from the registry again in later steps
if (context.packageIdentifier.registry) {
assert(context.packageIdentifier.name, 'Registry package identifier must have a name');
context.packageIdentifier = npa.resolve(
context.packageIdentifier.name,
// `save-prefix` option is ignored by some package managers so the caret is needed to ensure
// that the value in the project package.json is correct.
'^' + manifest.version,
);
}

context.hasSchematics = !!manifest.schematics;
context.savePackage = manifest['ng-add']?.save;
context.collectionName = manifest.name;
Expand Down