In this article, we are going to learn what the different types of Angular CLI commands are, and the tools that power them. Let's get started.

There are three types of Angular CLI commands:

  • schematics commands:ng add,ng generate,ng new,ng update;
  • architect commands:ng build,ng e2e,ng lint,ng run,ng serve,ng test,ng xi18n;
  • and native commands:ng config,ng doc,ng version.

Schematics Commands

Schematics commands are commands that are based on a tool called Schematics that comes from the @angular-devkit/schematics package. Schematics helps the Angular CLI scaffold a new Angular workspace (ng new), generate blueprints (ng generate), update/migrate existing code (ng update), and add some frameworks support to an Angular application (ng add). It's all about code generation.

The nice thing about Schematics is that it allows us to extend the CLI's scaffolding capabilities.

Architect Commands

Architect commands are commands that are based on a tool called Architect that comes from the @angular-devkit/architect package. Architect helps the Angular CLI lint (ng lint), test (ng test, ng e2e), serve (ng serve), and build (ng build) our Angular applications and libraries. It's all about running complex tasks.

With the Architect tool, we can now create custom tasks for the Angular CLI. Previously one would eject the Webpack configuration of the Angular CLI - using ng eject -  to be able to tweak the build process. Now every customization can be done using Architect. That's why, the eject command will be removed in Angular CLI 8.0.

Native Commands

Native commands are general Angular CLI commands. They are native to the Angular CLI in the sense that they don't rely on other tools/packages to be executed. Displaying our packages' versions (ng version), opening the official documentation (ng doc), reading and setting some values in the angular.json file (ng config) do not require the use any specific tool.

Conclusion

In this article, we learned that they were 3 types of Angular CLI commands: native commands, schematics commands, and architect commands. Schematics and Architect are tools from the @angular-devkit package that make the Angular CLI generic, extensible, and so powerful.


If you enjoyed this article, follow @ahasall on Twitter for more content like this.