feat(@angular-devkit/schematics-cli): auto detect package manager
PR Checklist
Please check to confirm your PR fulfills the following requirements:
- [x] The commit message follows our guidelines: https://github.com/angular/angular-cli/blob/main/CONTRIBUTING.md#-commit-message-guidelines
- [ ] Tests for the changes have been added (for bug fixes / features)
- [ ] Docs have been added / updated (for bug fixes / features)
PR Type
What kind of change does this PR introduce?
- [ ] Bugfix
- [x] Feature
- [ ] Code style update (formatting, local variables)
- [ ] Refactoring (no functional changes, no api changes)
- [ ] Build related changes
- [ ] CI related changes
- [ ] Documentation content changes
- [ ] Other... Please describe:
What is the current behavior?
Can't specify packageManager when running a schematic
Issue Number: N/A
What is the new behavior?
Detect packageManager by the lock file, and use the right package manager to install dependencies. Behave like ng generate <schematic>
Does this PR introduce a breaking change?
- [ ] Yes
- [x] No
Other information
This PR originates from https://github.com/nestjs/nest-cli/issues/1115
As I look into the problem, first I wanted to fix it in @nestjs/schematics
but then I checked Angular cli, and run the following command, it worked as excepted(using correct package manager).
ng new test --no-install
cd test
touch yarn.lock
ng g @nestjs/schematics:resource --name=users --no-dry-run --no-skip-import --language="ts" --source-root="src" --spec --no-flat
So I thought maybe it's better to fix it in schematics-cli to make it behave just like angular-cli.
I am a new contributor, plz let me know If I did anything wrong ;)