@kokkisajee
In a nutshell
Communities
Social Developer
Recognitions
Cloud Solution Architect @Microsoft
First GDE,MCT and MVP from SL
Top stackoverflow contributor
@sajeetharan
@kokkisajee
@sajeetharan
@sajeetharan
Be like MENDIS
Scalability
Performance
Flexibility
Versatility
Developer tools
Angular for mobile
Development kit
Angular elements
@kokkisajee
@kokkisajee
@kokkisajee
Over 30 annual Angular conferences
7 new events in 2019
800+ Meetups
@kokkisajee
Angular CLI & Schematics
Material & CDK
Angular Elements
Angular IVY
Bazel
@kokkisajee
A library that is part of the angular devkit that is used to scaffold and generate files.
Collection: Set of schematics (Rules)
@ngrx/schematics
Schematic (Rule): set of actions
ng new, ng update
Action: transform of the file tree
collection.json — Where schematics are grouped together
index.ts — The actual Schematic code
schema.json — The Schematic variable definition(options)
schema.d.ts — Typedefinition of your schema.json
files/ — The template files to replicate
Source
Output
Action
Source
Output
Action
Source
Output
Action
Source
Output
Action
a
b
c
c'
Download
Install
https://nodejs.org/en/download/
npm install -g @angular-devkit/schematics-cli
app/my.component.ts
schematics blank --name=basic
cd basic
npm run build
npm run test
npm link
> usr/local/lib/node_modules/basic -> <path>/basic
schematics --help
schematics .:basic --dry-run=false
schematics --list-schematics
app/my.component.ts
export function basic(options: any): Rule {
return (tree: Tree, _context: SchematicContext) => {
tree.create("hello-devfest.html", `<h1>Hello ${options.name} 👋</h1>`);
return tree;
};
}
app/my.component.ts
$ npm run build
$ schematics .:basic --name="Angular Community" --dry-run
CREATE /hello-devfest.html (37 bytes)
app/my.component.ts
ng new test-basic
cd test-basic
npm link basic
> /test-basic/node_modules/basic
-> usr/local/lib/node_modules/basic
-> /basic
ng config cli.defaultCollection basic
ng g basic
schematics basic:basic
app/my.component.ts
const collectionPath = path.join(__dirname, "../collection.json");
describe("hello-devfest", () => {
it("works", () => {
const runner = new SchematicTestRunner("schematics", collectionPath);
const tree = runner.runSchematic("hello-devfest", {}, Tree.empty());
expect(tree.files.length).toEqual(1);
});
});
- Explore more on Angular Schematics
- Ask @kokkisajee
- Be a part of Ng-SriLanka 2020
- Rate my talk
@kokkisajee
@kokkisajee
@kokkisajee