Skip to content

Commit f2f94fc

Browse files
committed
fix(@angular/cli): always install package during ng add to inspect manifest on disk for schematics
Private package registries such as GitHub Packages frequently strip out custom non-npm metadata properties (such as schematics and ng-add) from their remote API responses. Previously, ng add skipped confirming and installing a package if the registry metadata did not report hasSchematics, causing ng add to fail on first run. This commit removes the early skip condition based on registry metadata so ng add always installs the target package to inspect its physical manifest on disk. If no schematics are found after installation, the CLI cleanly removes the temporary dependency. Closes #33060
1 parent 825536c commit f2f94fc

1 file changed

Lines changed: 6 additions & 17 deletions

File tree

  • packages/angular/cli/src/commands/add

packages/angular/cli/src/commands/add/cli.ts

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -224,29 +224,12 @@ export default class AddCommandModule
224224
{
225225
title: 'Confirming installation',
226226
enabled: !skipConfirmation && !options.dryRun,
227-
skip: (context) => {
228-
if (context.hasSchematics) {
229-
return false;
230-
}
231-
232-
return `The ${color.blue(context.packageIdentifier.toString())} package does not provide \`ng add\` actions.`;
233-
},
234227
task: (context, task) => this.confirmInstallationTask(context, task),
235228
rendererOptions: { persistentOutput: true },
236229
},
237230
{
238231
title: 'Installing package',
239232
skip: (context) => {
240-
if (!context.hasSchematics) {
241-
const builtInSchematic =
242-
BUILT_IN_SCHEMATICS[
243-
context.packageIdentifier.name as keyof typeof BUILT_IN_SCHEMATICS
244-
];
245-
if (builtInSchematic) {
246-
return `Skipping package installation.`;
247-
}
248-
}
249-
250233
if (context.dryRun) {
251234
return `Skipping package installation. Would install package ${color.blue(
252235
context.packageIdentifier.toString(),
@@ -278,6 +261,9 @@ export default class AddCommandModule
278261
if (localManifest['ng-add']?.save === false) {
279262
shouldCleanUp = true;
280263
}
264+
} else {
265+
await this.cleanUpTemporaryDependency(result.collectionName);
266+
shouldCleanUp = false;
281267
}
282268
} catch {}
283269
}
@@ -305,6 +291,9 @@ export default class AddCommandModule
305291
const builtInSchematic =
306292
BUILT_IN_SCHEMATICS[packageName as keyof typeof BUILT_IN_SCHEMATICS];
307293
if (builtInSchematic) {
294+
logger.info(
295+
`The ${color.blue(packageName)} package does not provide \`ng add\` actions.`,
296+
);
308297
logger.info('The Angular CLI will use built-in actions to add it to your project.');
309298

310299
return this.executeSchematic({

0 commit comments

Comments
 (0)