SlideShare a Scribd company logo
Everything You Should Know About the New Angular CLI
Everything You Should Know About the New Angular CLI
Everything You Should Know About the New Angular CLI
Challenges
Support
Starter kit
Sharing code
Angular 42
4
@ahasall
Frontend Software Engineer
Amadou Sall
GDG Toulouse / February 2019
Everything You Should Know
About the New Angular CLI
www.amadousall.com
!
Workspaces
Libraries
Architects
Schematics
...
Overview
Workspaces
What is a Workspace?
Angular apps are developed in the context of a
workspace.
Mono-repo or multi-repo.
8
Types of Projects in Workspace
application
library
9
Workspace Files
.
├── .editorconfig
├── .gitignore
├── README.md
├── angular.json
├── package.json
├── tsconfig.json
└── tslint.json
10
Workspace Configuration/angular.json
{
"version": 1,
"newProjectRoot": "projects",
"projects": {
"first-app": {...},
"first-app-e2e": {...},
"second-app": {...},
"second-app-e2e": {...}
},
"defaultProject": "first-app"
}
11
Project Configuration
{
"projects": {
"first-app": {
"root": "projects/first-app/",
"sourceRoot": "projects/first-app/src",
"projectType": "application",
"prefix": "app",
"schematics": {...},
"architect": {...}
}
}
}
12
Everything You Should Know About the New Angular CLI
Tips and Tricks
By default, the workspace is “multi-repo”
ng new <workspace_name>
14
Tips and Tricks
If you want to use the “mono-repo” approach
ng new <workspace_name> -–create-application=false
15
Libraries
Library Support
17
Generating a Library
ng generate library <library_name>
Scaffolds a library
Updates our tsconfig.json file to add paths mapping
18
Building a Library
ng build <library_name>
Outputs the build artifacts to dist/<library_name>
19
Using Your Library
import { MakeItAwesomeModule } from 'make-it-awesome';
First it looks in the tsconfig paths
Then it looks in the node_modules folder
20
Publishing Your Library
ng build <library_name>
cd dist/<library_name>
npm adduser
npm publish –-access=public
Let’s share the library with the world
21
Everything You Should Know About the New Angular CLI
Tips and Tricks
Use the watch flag to always rebuild your library
ng b <library_name> --watch
23
TheDifferentTypesofAngularCLI
Commands
Native, Architect, Schematics
Native Commands
ng version
ng config
ng doc
ng help
25
Architect Commands
ng serve
ng build
ng lint
ng test
ng e2e
ng xi18n
ng run
26
Schematics Commands
ng new
ng generate
ng add
ng update
27
Architects
Architect Commands
ng serve
ng build
ng lint
ng test
ng e2e
ng xi18n
ng run
29
The ng run Command to Rule Them All
ng run <project>:<target>[:configuration]
Runs an Architect target
30
The ng run command
Predefined Commands
ng build <project>
ng test <project>
ng lint <project>
...
Using ng run
ng run <project>:build
ng run <project>:test
ng run <project>:lint
...
31
Project Configuration
"make-it-awesome": {
"root": "projects/make-it-awesome",
"sourceRoot": "projects/make-it-awesome/src",
"projectType": "library",
"prefix": "lib",
"architect": {
"build": {...},
"test": {...},
"lint": {...}
}
}
32
Target configuration
"test": {
"builder": "@angular-devkit/build-angular:karma",
"options": {
"main": "projects/make-it-awesome/src/test.ts",
"tsConfig": "projects/make-it-awesome/tsconfig.spec.json",
"karmaConfig": "projects/make-it-awesome/karma.conf.js"
},
"configurations": {
"ci": {
"browsers": "ChromeHeadlessCI",
"codeCoverage": true
}
}
}
33
Everything You Should Know About the New Angular CLI
Tips and Tricks
Define your configuration inside the angular.json file
35
Schematics
What Can Schematics do?
scaffold a new Angular application
ng new
generate code via predefined blueprints
ng generate
37
What Can Schematics do?
add framework support
ng add
update your dependencies/migrate existing code
ng update
38
What are Schematics?
A generic tool that helps with:
• Code generation
• Code transformations
The goal is to make developers more productive
39
CreatingYourOwnSchematics
Why Create Our Custom Schematics
Our starter kit can be replaced by a single command
Building solid foundations
Enforcing best practices across the company
Startup mode
Automate all things!
41
Getting Started
> yarn global add @angular-devkit/schematics-cli
> schematics blank –name=simple
> schematics schematic –name=advanced
42
Getting Started
> schematics blank --name=first
CREATE /first/README.md (639 bytes)
CREATE /first/.gitignore (191 bytes)
CREATE /first/.npmignore (64 bytes)
CREATE /first/package.json (533 bytes)
CREATE /first/tsconfig.json (656 bytes)
CREATE /first/src/collection.json (214 bytes)
CREATE /first/src/first/index.ts (313 bytes)
CREATE /first/src/first/index_spec.ts (462 bytes)
43
Getting Started
.
├── README.md
├── package-lock.json
├── package.json
├── src
│ ├── collection.json
│ └── first
│ ├── index.ts
│ └── index_spec.ts
└── tsconfig.json
44
package.json
{
"name": "@ahasall/schematics",
"version": "0.0.0",
"schematics": "./collection.json",
"dependencies": {
"@angular-devkit/core": "^7.3.1",
"@angular-devkit/schematics": "^7.3.1",
"typescript": "~3.2.2",
"@types/node": "^8.0.31",
"rxjs": "6.3.3"
}
}
45
collection.json
{
"$schema": "/path/to/schema.json",
"schematics": {
"first": {
"description": "A first schematic",
"factory": "./first"
},
"second": {
"description": "A second schematic.",
"factory": "./second",
"schema": "./second/schema.json"
}
}
}
46
Rule Factory
Takes in options from
the CLI
Creates a RuleThe entry point of a
schematic
47
Rule Factory
export function tap(options: any): Rule {
return (tree: Tree, context: SchematicContext) => {
return tree;
};
}
48
Rule
export function tap(options: any): Rule {
return (tree: Tree, context: SchematicContext) => {
return tree;
};
}
49
Rule
Takes in a Tree and
outputs a modified
Tree
Applies actions to a
Tree
50
Tree
A staging area for
changes
Contains:
• a file system,
• and a list of changes
to apply to it
51
Working on a Tree
function do(tree: Tree, context: SchematicContext) {
tree.create('hello.txt', 'Bonjour GDG Toulouse’);
tree.read('file.txt');
tree.rename('hello.txt’, 'salut.txt');
tree.delete('salut.txt');
return tree;
}
52
Running a Schematic
> ng generate @ahasall/schematics:first <name>
> schematics @ahasall/schematics:first <name>
53
Chain Rules
function (tree: Tree, context: SchematicContext) {
return chain([
schematic('workspace', workspaceOptions),
schematic('application', applicationOptions),
...
])
}
54
Templating Engine
{
"name": "<%= utils.dasherize(name) %>",
...
"dependencies": {
"@angular/core": "<%= latestVersions.Angular %>",
"@angular/forms": "<%= latestVersions.Angular %>",
...
}
}
55
SchematicsUseCases
Theming your Angular Material applications
ng generate application –theme=klm
57
The Container-Component pattern
ng generate container-component flight
58
Setting up the Continuous Integration
ng add @airfrance/angular-toolkit
59
Nobody wants to read the docs
ng new –collection=@airfrance/schematics my-app
60
OtherNewFeatures
Budgets
Let’s make some savings
62
Differential Serving
Don’t make your users pay for Internet Explorer
63
Workspaces
Libraries
Architects
Schematics
...
Summary
@ahasall
Frontend Software Engineer
Amadou Sall
GDG Toulouse / February 2019
Thank You!
www.amadousall.com
!

More Related Content

PDF
Architecture for Massively Parallel HDL Simulations
PDF
Runtime surgery
PDF
The 2016 Android Developer Toolbox [MOBILIZATION]
PDF
Android Wear Essentials
PPTX
Using openCV 3.2.0 with CodeBlocks
PDF
Facebook Glow Compiler のソースコードをグダグダ語る会
PDF
Using Android Things to Detect & Exterminate Reptilians
Architecture for Massively Parallel HDL Simulations
Runtime surgery
The 2016 Android Developer Toolbox [MOBILIZATION]
Android Wear Essentials
Using openCV 3.2.0 with CodeBlocks
Facebook Glow Compiler のソースコードをグダグダ語る会
Using Android Things to Detect & Exterminate Reptilians

What's hot (20)

PDF
Apple Templates Considered Harmful
PDF
openCV with python
PDF
Reactive, component 그리고 angular2
KEY
Groovy Ecosystem - JFokus 2011 - Guillaume Laforge
PDF
Riga Dev Day 2016 - Having fun with Javassist
PPT
Real world cross-platform testing
PDF
FalsyValues. Dmitry Soshnikov - ECMAScript 6
PPTX
Install, Compile, Setup, Setting OpenCV 3.2, Visual C++ 2015, Win 64bit,
PDF
Workshop 10: ECMAScript 6
PDF
TensorFlow XLA RPC
PDF
iOS Behavior-Driven Development
PDF
TVM VTA (TSIM)
PPTX
Getting started with open cv in raspberry pi
PDF
GeeCON 2017 - TestContainers. Integration testing without the hassle
PPTX
Annotation processing tool
PDF
Aplicações assíncronas no Android com
Coroutines & Jetpack
PDF
Voxxed Days Vilnius 2015 - Having fun with Javassist
KEY
連邦の白いヤツ 「Objective-C」
PPTX
Angular 1 + es6
PPTX
Developing web-apps like it's 2013
Apple Templates Considered Harmful
openCV with python
Reactive, component 그리고 angular2
Groovy Ecosystem - JFokus 2011 - Guillaume Laforge
Riga Dev Day 2016 - Having fun with Javassist
Real world cross-platform testing
FalsyValues. Dmitry Soshnikov - ECMAScript 6
Install, Compile, Setup, Setting OpenCV 3.2, Visual C++ 2015, Win 64bit,
Workshop 10: ECMAScript 6
TensorFlow XLA RPC
iOS Behavior-Driven Development
TVM VTA (TSIM)
Getting started with open cv in raspberry pi
GeeCON 2017 - TestContainers. Integration testing without the hassle
Annotation processing tool
Aplicações assíncronas no Android com
Coroutines & Jetpack
Voxxed Days Vilnius 2015 - Having fun with Javassist
連邦の白いヤツ 「Objective-C」
Angular 1 + es6
Developing web-apps like it's 2013
Ad

Similar to Everything You Should Know About the New Angular CLI (20)

PDF
Angular Schematics
PDF
A Gentle Introduction to Angular Schematics - Angular SF 2019
PPTX
JS Fest 2019/Autumn. Maciej Treder. Angular Schematics - Develop for developers
PDF
Use Angular Schematics to Simplify Your Life - Develop Denver 2019
PDF
A Gentle Introduction to Angular Schematics - Devoxx Belgium 2019
PPTX
PDF
Angular based enterprise level frontend architecture
PPTX
Talentica - JS Meetup - Angular Schematics
PDF
Quick introduction to Angular 4 for AngularJS 1.5 developers
PPTX
Angular4 getting started
PPTX
PDF
Angular - Chapter 1 - Introduction
PDF
Angular Notes.pdf
PPTX
Angular CLI : HelloWorld
PDF
Angular JS2 Training Session #1
PPTX
Advanced angular
PDF
The Angular road from 1.x to 2.0
PDF
How to Implement Micro Frontend Architecture using Angular Framework
PPTX
4 Anguadasdfasdasdfasdfsdfasdfaslar (1).pptx
PDF
Getting Started with the Angular 2 CLI
Angular Schematics
A Gentle Introduction to Angular Schematics - Angular SF 2019
JS Fest 2019/Autumn. Maciej Treder. Angular Schematics - Develop for developers
Use Angular Schematics to Simplify Your Life - Develop Denver 2019
A Gentle Introduction to Angular Schematics - Devoxx Belgium 2019
Angular based enterprise level frontend architecture
Talentica - JS Meetup - Angular Schematics
Quick introduction to Angular 4 for AngularJS 1.5 developers
Angular4 getting started
Angular - Chapter 1 - Introduction
Angular Notes.pdf
Angular CLI : HelloWorld
Angular JS2 Training Session #1
Advanced angular
The Angular road from 1.x to 2.0
How to Implement Micro Frontend Architecture using Angular Framework
4 Anguadasdfasdasdfasdfsdfasdfaslar (1).pptx
Getting Started with the Angular 2 CLI
Ad

Recently uploaded (20)

PPTX
CHAPTER 2 - PM Management and IT Context
PDF
Navsoft: AI-Powered Business Solutions & Custom Software Development
PDF
Softaken Excel to vCard Converter Software.pdf
PDF
Understanding Forklifts - TECH EHS Solution
PDF
Digital Strategies for Manufacturing Companies
PDF
AI in Product Development-omnex systems
PDF
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
PDF
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
PDF
2025 Textile ERP Trends: SAP, Odoo & Oracle
PPTX
history of c programming in notes for students .pptx
PPTX
Transform Your Business with a Software ERP System
PDF
System and Network Administration Chapter 2
PDF
Wondershare Filmora 15 Crack With Activation Key [2025
PDF
Design an Analysis of Algorithms II-SECS-1021-03
PDF
medical staffing services at VALiNTRY
PDF
top salesforce developer skills in 2025.pdf
PDF
Audit Checklist Design Aligning with ISO, IATF, and Industry Standards — Omne...
PPTX
L1 - Introduction to python Backend.pptx
PPTX
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
PPTX
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
CHAPTER 2 - PM Management and IT Context
Navsoft: AI-Powered Business Solutions & Custom Software Development
Softaken Excel to vCard Converter Software.pdf
Understanding Forklifts - TECH EHS Solution
Digital Strategies for Manufacturing Companies
AI in Product Development-omnex systems
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
2025 Textile ERP Trends: SAP, Odoo & Oracle
history of c programming in notes for students .pptx
Transform Your Business with a Software ERP System
System and Network Administration Chapter 2
Wondershare Filmora 15 Crack With Activation Key [2025
Design an Analysis of Algorithms II-SECS-1021-03
medical staffing services at VALiNTRY
top salesforce developer skills in 2025.pdf
Audit Checklist Design Aligning with ISO, IATF, and Industry Standards — Omne...
L1 - Introduction to python Backend.pptx
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises

Everything You Should Know About the New Angular CLI