Skip to content

Conversation

@MarvinXu
Copy link

@MarvinXu MarvinXu commented Feb 1, 2023

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

[x] Bugfix
[ ] Feature
[ ] Code style update (formatting, local variables)
[ ] Refactoring (no functional changes, no api changes)
[ ] Build related changes
[ ] CI related changes
[ ] Other... Please describe:

What is the current behavior?

Issue Number: #1115

What is the new behavior?

Using the right package manager to install packages (detecting by lock files)
Snipaste_2023-02-01_15-15-57

Does this PR introduce a breaking change?

[ ] Yes
[x] No

Other information

As described in angular/angular-cli#24305, running the same schematic in angular-cli works correctly (using the right 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

nest g and ng g are basicly the same, so we can fix this problem in cli level just like angular-cli.

If you look into angular's codebase (https://github.com/angular/angular-cli/blob/489d4df0ed17481492728624735a235f25a418db/packages/angular/cli/src/command-builder/schematics-command-module.ts#L116), the packageManager option is predefined in angular-cli and passed into a NodeWorkflow.

In nest-cli, we directly use a binary file from @angular-devkit/schematics-cli to run our schematics.

'@angular-devkit/schematics-cli/bin/schematics.js',

So we just need to implement that auto-detecting logic in this file.

See PR: angular/angular-cli#24305

@MarvinXu MarvinXu changed the title fix(deps): update schematics-cli to 15.2.0-next.2 fix(deps): using the right package manager to install in nest generate Feb 1, 2023
@micalevisk
Copy link
Member

micalevisk commented Feb 3, 2023

well done!

I guess we can wait for the release of v15.2

@MarvinXu
Copy link
Author

MarvinXu commented Feb 3, 2023

@micalevisk BTW, did you test it, or just review the code? I want to know if there is a good way to test it.

@micalevisk
Copy link
Member

I didn't tested it

@kamilmysliwiec
Copy link
Member

dependabot will auto-create a PR with a new version once it's published by the Angular team

@micalevisk micalevisk mentioned this pull request Mar 17, 2023
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants