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:
- architect commands:
- and native commands:
Schematics commands are based on a tool called
Schematics that comes from the
Schematics is the underlying tool the Angular CLI uses to 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.
Learn how Air France-KLM is leveraging schematics in another blog post– The Angular CLI at Air France-KLM.
Architect commands are based on a tool called
Architect that is published under the
@angular-devkit/architect package name.
Architect helps the Angular CLI lint (
ng lint), test (
ng e2e), serve (
ng serve), and build (
ng build) our Angular applications and libraries. It's all about running complex tasks.
Architect tool, we can now create custom tasks for the Angular CLI. Previously, one would eject the Webpack configuration of the Angular CLI–using the now deprecated
ng eject command–to be able to tweak the build process. Now every customization can be done using
Architect. That's why, the
ng eject command was removed in Angular CLI v8.
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 of any specific tool.
In this article, we learned that they were three types of Angular CLI commands: native commands, schematics commands, and architect commands.
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.