nestjs / nest

A progressive Node.js framework for building efficient, scalable, and enterprise-grade server-side applications with TypeScript/JavaScript 🚀
https://nestjs.com
MIT License
66.89k stars 7.56k forks source link

Suggestion: CLI Tools #15

Closed alexcorvi closed 7 years ago

alexcorvi commented 7 years ago

As per subject, a CLI tool can:

I can imagine that users of this project would have a background in angular (similar architecture, concepts, tooling) and those (me included!) use the angular CLI tool regularly.

So, in my humble opinion, a CLI tool should be the next logical step.

FieryCod commented 7 years ago

Could you specify what such a CLI should do? You mean it should have component, controller, basic project generating script?

lholznagel commented 7 years ago

Maybe like the angular cli create Controller / Services (Component)

KerryRitter commented 7 years ago

Definitely agree with this. Laravel's Artisan CMD is fantastic and would be a great tool to look at for inspiration.

thomrick commented 7 years ago

For the ones who want to develop the CLI tool look at Caporal.js !

https://github.com/mattallty/Caporal.js

I think this could be a great framework to expose the CLI actions

Mark-McCracken commented 7 years ago

totally agree, a CLI tool similar to ng-cli would be great. Do we need to get some core requirements down for what this should be able to do? Happy to help in any way, even if its just organising stuff

HeroBart commented 7 years ago

This project seems really promising. I'd love to see something like @angular/cli to start a new project and generate files to lower the bar to get started with this :D

Pinedo11 commented 7 years ago

I agree with @Mark-McCracken and @lholznagel. For scaffolding stuff, generate new components, controllers etc... we can do something similar as @angular/cli bearing in mind that the syntax is quite similar.

KerryRitter commented 7 years ago

So I talked with Kamil and I'm going to start working on the nest CLI. What are you guys' thoughts on this for starters?

example screenshot:

nest-cli-ex

examples commands:

nest create my-new-app 
// generates a new Nest application in the current folder (path is an optional second parameter)

nest g module users 
// generates users folder and users.module.ts

nest g controller UsersController ./users/users.controller.ts 
// creates the users/users.service.ts file, would be usersController.ts by default

nest g component UsersService ./users/users.service.ts
// creates the users/users.service.ts file, would be usersService.ts by default

nest serve --p 8090
// serves the nest app at port 8090, probably use 8080 by default

nest build
// compiles the typescript .. somewhere
Mark-McCracken commented 7 years ago

Absolutely 100% agree! Was going to post exactly this tomorrow afternoon. Totally agree with format and commands, should be able to have simple one liners to Generate new components/controllers/entire app Run the server. I think there should also be a nest test command, to run all of the tests, I think testability should have a reasonably strong focus in that there's a straightforward, standardised way to run tests, perhaps with Jasmine. Would love to contribute to this, shall I put together some requirements maybe? Think we need a new repo for this. Also think we can lean heavily on the work done by the angular cli team, as a lot of this will be fairly similar

KerryRitter commented 7 years ago

I'm using Caporal per @ThomRick's suggestion - it's fantastic to get rolling.

If you'd like to help, I could use a hand with a good build process on compiling the app and serving the app. I following Ionic's method of using git repos to initialize apps and will look at how Angular CLI does the asset generation.

I am planning on working with Kamil + other contributors to get a proper repo setup but i can make one on my account in the meantime.

joshwiens commented 7 years ago

@KerryRitter - I can give you a hand with the CI/CD related work, first decade in software was in devops.

thomrick commented 7 years ago

Hey @KerryRitter !

Fantastic command documentation ! The Nest-CLI repo has been created yet ? Where is it ? Can I bring my contribution on it ?

KerryRitter commented 7 years ago

There isn't one yet, but I can open up a repo tomorrow and push up what I have. Contributions are certainly welcome!

kamilmysliwiec commented 7 years ago

Hi guys! Thanks for your involvement. About CLI, I think we should consider those commands (@KerryRitter, I used your proposals) :

nest create my-new-app 
// generates a new Nest application in the current folder (path is an optional second parameter)

nest g module users 
// generates users folder and users.module.ts

nest g controller users ./users/users.controller.ts 
// creates the users/users.controller.ts file (UsersController class), would be users.controller.ts by default

nest g component UsersService ./users/users.service.ts
// creates the users/users.service.ts file (UsersService class), would be users.service.ts by default

nest g middleware users ./users/users.middleware.ts
// creates the users/users.middleware.ts file (UsersMiddleware), would be users.middleware by default

nest g gateway users ./users/users.gateway.ts
// creates the users/users.gateway.ts file (UsersGateway), would be users.gateway by default

nest g gateway-middleware users ./users/users.middleware.ts
// or maybe just nest g middleware with additional flag? (-g?)
// creates the users/users.middleware.ts file (UsersMiddleware), would be users.middleware by default

nest g filter users ./users/users.filter.ts
// creates the users/users.filter.ts file (UsersExceptionsFilter), would be users.filter by default

nest serve --p 8090
// serves the nest app at port 8090, probably use 8080 by default

nest build
// compiles the typescript .. somewhere

Also - we have to remember that someone might want to use Nest without TypeScript (so we need 2 ways of build, serve and create app). About testing framework - I agree that it should be a standardised way to run tests. From my point of view - jasmine could be a best choice. What do you think?

Mark-McCracken commented 7 years ago

Sounds great! Think everyone would be pretty happy with Jasmine, angular uses it as theirs, can't see anyone complaining. Personally, I don't think many people will want to use it without JavaScript, the Type system and experimental decorators are some of the biggest draws for me, but by all means if I'm wrong here, keep going with JS aspects.

I've been using tsc -w in one terminal window, and using nodemon index.js in another, and literally can't explain how awesome it is to quickly switch to postman and see your changes already implemented and run!

If anyone has made a start on this project, I think perhaps it might be a good idea to move it to an organisation repo like angulars. Just seen Kamil's post on the evangelism issue, so this seems like the go ahead method :)

KerryRitter commented 7 years ago

Ahh. Right. Es6. How should we do that? Suffix everything with "es" or "ts"? Perhaps a nest.config.json?

I agree with the proposal - all looks good to me.

Mark-McCracken commented 7 years ago

Made this. Think it could be nice looking for when we have a CLI tool. Think this could go in when we use nest -v, similar to angular? If so, any preferences on which one? (I prefer first one)

      ____        ___                       ___        ______   ___   ________
     /    \      /  /_______     ______  __/  /_      /  ____) /  /  (___  ___}
    /  /\  \    /  //  ___  \   /  ____)(__   __}    /  /     /  /      / /
   /  /  \  \  /  //  (___)  \ /  /___    /  /      /  /     /  /      / /
  /  /    \  \/  /(  ________/ \___   \  /  /      /  /     /  /      / /
 /  /      \    /  \ \______  ____/  /  /  /_     /  /___  /  /__  __/ /__ 
/__/        \__/    \_______}{______/   \____}    \______}/______}(_______}

______     ____                     ___        ______ ___      _______
|     \    |  |                  __|  |__     / _____)| |     (__  ___}
|  |\  \   |  |  ______   ______(__    __}   | /      | |        | |
|  | \  \  |  | /  ___ \ |  ____)  |  |      | |      | |        | |
|  |  \  \ |  ||  (___) \| (____   |  |      | |      | |        | |
|  |   \  \|  ||  ______/|____  |  |  |      | |      | |        | | 
|  |    \     ||  \____   ____) |  |  \___   | |_____ | |____  __| |__
|__|     \____| \______} {______/   \_____}   \______}|______}(_______}
Mark-McCracken commented 7 years ago

Does someone wanna set this up?

screen shot 2017-05-07 at 14 12 12
kamilmysliwiec commented 7 years ago

@Mark-McCracken, organization profile is already created @nestjs. I am a little bit busy right now, there is a lot of things to do so I'll update each informations when I am free. At the same time, I am working on simple page with urls to github profile & documentation.

KerryRitter commented 7 years ago

I created a repo here https://github.com/nestjs/nest-cli. Still very much a work in progress, but wanted to make it open.

I could use some help with the build/serve pieces of anyone is interested in that. I am working on the piece to create new projects and assets.

I think we can close this ticket and move discussion to the new repo.

kamilmysliwiec commented 7 years ago

Thanks @KerryRitter, can't wait to see more

lock[bot] commented 4 years ago

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.