In a session at ng-conf 2016, Mike Brocchi gave developers a better look at the Angular CLI (Command Line Interface) tool and it's capabilities. He said that, among developers he's talked to, 26% of them said that the Angular 2 environment setup was a barrier to entry while 22% said it was too complicated. The CLI was made to ease this pain.
To reduce the time it takes to get a project started, Angular CLI has a number of features to "Get started fast":
ng new project-name
- Create a new project, sets default configurationng build
- Build/compile the appng test
- Run unit tests.ng e2e
- Run end-to-end testsng serve
- Spin up a small web server and host the appng deploy
- Out of the box, deploy to GitHub pages or Firebase
All of the configuration needed by these steps is done by the tool.
Beyond setting up a new app, the tool also lets developers run commands to build up pieces of an app such as Components and Routes.
ng generate component my-comp
- Generates a new Component, along with its test spec and its HTML/CSSng generate directive my-directive
- Generates a new Directiveng generate pipe my-pipe
- Generates a new Pipeng generate service my-service
- Generates a new Serviceng generate route my-route
- Generates a new Routeng generate class my-class
- Creates a simple model class
For each of these generation commands, the files are placed in the right location based on the official Angular style guide.
Unfortunately, the tool is made for Angular 2, not for 1.X. Now in Beta, the team behind Angular CLI hopes to add offline template compilation, lazy loading routes, and extensibility.
The idea is not novel. In the Angular world, the Platypi framework used a CLI tool called PlatypusCLI to create app fragments such as models and services. The non-Angular project Ember has its own Ember CLI that assists developers with tasks such as running tests and compiling assets.
The full video of Brocchi's session is available on YouTube.