nestjs / nest-cli

CLI tool for Nest applications 🍹
https://nestjs.com
Other
1.97k stars 394 forks source link

nest generate configuration is creating a 'undefined' directory for non-monorepo mode #2207

Closed micalevisk closed 1 year ago

micalevisk commented 1 year ago

Is there an existing issue for this?

Current behavior

when the app isn't in a monorepo mode, nest g config will create a file called undefined/nest-cli.json

Image

image

That's because the following IF is returning false. And the project option is not being equals to "." (as I expect) for this scenario

https://github.com/nestjs/nest-cli/blob/ddcaaa1f194a6f869b39c2f539ef43c2b82bbee2/actions/generate.action.ts#L77

Minimum reproduction code

https://github.com/nestjs/typescript-starter

Steps to reproduce

git clone https://github.com/nestjs/typescript-starter
cd typescript-starter
npm i
npx nest g config

Note that that project isn't in a monorepo mode

it generates the file undefined/nest-cli.json

Expected behavior

if we already has a nest-cli.json in our project, I'd see an error (from angular schematics). If not, a file nest-cli.json will be created. Basically, the options.project should be "." here: https://github.com/nestjs/schematics/blob/07be8d05ae1b78c46267a31bfca8e711e682214a/src/lib/configuration/configuration.factory.ts#L33

To easily fix that, we could just change that line to options.project || "." but I'm not sure if this seems correct from the schematics PoV

Package version

10.1.10

NestJS version

No response

Node.js version

No response

In which operating systems have you tested?

Other

No response

kamilmysliwiec commented 1 year ago

Would you like to create a PR for this issue?

To easily fix that, we could just change that line to options.project || "." but I'm not sure if this seems correct from the schematics PoV

Sounds reasonable