fix(@angular/cli): fallback to local package.json for schematic detection on first run#33285
fix(@angular/cli): fallback to local package.json for schematic detection on first run#33285clydin wants to merge 1 commit into
Conversation
b4d8924 to
8e6ff20
Compare
There was a problem hiding this comment.
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.
…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
8e6ff20 to
e27048a
Compare
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 addto bypass executing schematics on the first run.This fix adds a fallback check immediately after package installation: if the registry did not report
hasSchematicsastrue, the CLI falls back to resolving and reading the physically installed package'spackage.jsonon 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 fromdependenciesordevDependenciespost-execution, and executes a silentpackageManager.install()to cleanly remove the physical package files and update the lockfile.Fixes #33060