Starting my first schematic
Goals for this tutorial
Create our first Schematics project.
Set up basic configurations to use our first schematic.
Create our first schematic.
Prerequisites
NodeJS 20+.
Install
npm i -g @builder/cli
or usenpx @pbuilder/cli
.
Create a schematic project
Execute:
builder new <library-name> [author]
Note
builder new --help
Builder-add schematic
The CLI already create a schematics called: builder-add
. After you publish your package and the any user execute: builder add [your-package-name]
, the library will be installed and then builder-add
schematic will be called.
Create the first schematic
1. To create a schematic, execute this:
builder exec @pbuilder/sm sc --name="my-schematic"
2. We are ready to test our first schematic, run:
npm run build
3. To test it we can run:
schematics ./dist/collection.json:my-schematic
Congratulations! 🚀 You’ve successfully run your first schematic!
Please check the fully schematic documentation: https://schematics.pbuilder.dev/
Subscribe to my newsletter
Read articles from Daniel Barrientos directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
Daniel Barrientos
Daniel Barrientos
I am deeply passionate about front-end development, particularly within the JavaScript ecosystem. For this reason, I enjoy working on the front end with Angular, React, and Astro, on the back end with NestJS, and designing UI with Figma ♥️. In my spare time, I focus on Project Builder, a tool that aids developers by automating code generation with schematics to create complete and complex projects with just a single command line instruction. Find more information at Schematic Docs and follow my insights on Blogs.