nestjs / nest-cli

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

Provide option for creating a new library #213

Closed iangregsondev closed 5 years ago

iangregsondev commented 5 years ago

[ ] Regression 
[ ] Bug report
[x] Feature request
[x] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.

Current behavior

Would be nice to be able to create a library using the cli.. NG CLI does something similar but you need to run it inside an already created application and thus creates a subdirectory called projects with the library inside.

What I would I suggest is not required to run inside an already nest created app but to be completely independent. As something like this https://github.com/nestjs/typeorm

That way, we can publish these to NPM and it has its own git repository.

Right now what I am doing is creating a new nest app and stripping out the majority of things like nodemon as its a library and not needed. e2e tests as it's not needed. main.ts as it's not needed.

removing npm scripts for e2e tests, start and other related scripts.. Basically just leaving the test, build, lint etc

So I am able to do this manually but it would be nice if the cli had a generate / new command for this.

ltciro commented 5 years ago

I think you can run nest g library mylibrary in =^ 5.6.0 version

iangregsondev commented 5 years ago

Just tested it! That's exactly what I needed - thanks @ltciro

Would be nice to be able to get this documented here https://docs.nestjs.com/cli/usages - as I didn't know it existed.

Maybe leaving this open to update the documentation?

kamilmysliwiec commented 5 years ago

See #189

adriano-di-giovanni commented 4 years ago

Is there any way to create a standalone library?

kamilmysliwiec commented 4 years ago

@adriano-di-giovanni for standalone libraries (publishable to NPM), you can simply create a new Nest project and remove the main.ts file :)

adriano-di-giovanni commented 4 years ago

Thanks, @kamilmysliwiec I'm currently using tsdx.

smitssjors commented 2 years ago

Sorry for necrobumping but I don’t think that opening a new issue would be better idea.

I think that with the rise of build caching tools like Nx and Turborepo an option to generate a standalone library would be nice.