Skip to content

fix(@angular/cli): fallback to local package.json for schematic detection on first run#33285

Open
clydin wants to merge 1 commit into
angular:mainfrom
clydin:fix/add-registry-stripped-metadata
Open

fix(@angular/cli): fallback to local package.json for schematic detection on first run#33285
clydin wants to merge 1 commit into
angular:mainfrom
clydin:fix/add-registry-stripped-metadata

Conversation

@clydin
Copy link
Copy Markdown
Member

@clydin clydin commented Jun 1, 2026

Private package registries frequently strip out custom non-npm metadata properties such as "schematics" or "ng-add" from their remote API responses. This causes ng add to bypass executing schematics on the first run.

This fix adds a fallback check immediately after package installation: if the registry did not report hasSchematics as true, the CLI falls back to resolving and reading the physically installed package's package.json on disk as the single source of truth.

Additionally, if the local manifest specifies ng-add.save: false (but it was persistently installed due to registry omissions), it programmatically prunes the package from dependencies or devDependencies post-execution, and executes a silent packageManager.install() to cleanly remove the physical package files and update the lockfile.

Fixes #33060

@clydin clydin force-pushed the fix/add-registry-stripped-metadata branch 2 times, most recently from b4d8924 to 8e6ff20 Compare June 2, 2026 15:12
@clydin clydin marked this pull request as ready for review June 2, 2026 15:13
Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request adds support for detecting and cleaning up temporary dependencies during ng add when the package's package.json specifies ng-add.save = false, even if the registry metadata is stripped. It also includes an E2E test to verify this behavior. The reviewer suggested wrapping the cleanup logic in a try...catch block to ensure that any cleanup failure does not fail the entire command, and appending a trailing newline when writing back package.json to prevent formatting issues.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread packages/angular/cli/src/commands/add/cli.ts
…tion on first run

Private package registries frequently strip out
custom non-npm metadata properties such as "schematics" or "ng-add" from
their remote API responses. This causes `ng add` to bypass executing
schematics on the first run.

This fix adds a fallback check immediately after package installation: if
the registry did not report `hasSchematics` as `true`, the CLI falls back
to resolving and reading the physically installed package's `package.json`
on disk as the single source of truth.

Additionally, if the local manifest specifies `ng-add.save: false` (but it
was persistently installed due to registry omissions), it programmatically
prunes the package from `dependencies` or `devDependencies` post-execution,
and executes a silent `packageManager.install()` to cleanly remove the
physical package files and update the lockfile.

Fixes angular#33060
@clydin clydin force-pushed the fix/add-registry-stripped-metadata branch from 8e6ff20 to e27048a Compare June 2, 2026 15:31
@clydin clydin requested a review from alan-agius4 June 3, 2026 11:04
@clydin clydin added action: review The PR is still awaiting reviews from at least one requested reviewer target: patch This PR is targeted for the next patch release labels Jun 3, 2026
@alan-agius4 alan-agius4 added action: merge The PR is ready for merge by the caretaker and removed action: review The PR is still awaiting reviews from at least one requested reviewer labels Jun 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

action: merge The PR is ready for merge by the caretaker area: @angular/cli target: patch This PR is targeted for the next patch release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ng add fails to detect schematics on first run with private package registries

2 participants