We use the command for convenience to build and execute a Schematic " "execute": "npm run build && schematics .:page --dry-run=false"
This repository is a basic Schematic implementation that serves as a starting point to create and publish Schematics to NPM.
To see some examples of Angular schematics install @schematics/angular and check in node_modules
npm i @schematics/angularFor a great example on how to use Schematics see this page: https://github.com/BottleRocketStudios/ng-momentum/blob/master/src/scaffold/index.ts#L217-L219
To create a new Schematic collection run outside a schematic folder.
schematics blank --name=hello-worldTo add a new Schematic to an existing collection run inside a schematic folder the same command already inside a project.
schematics blank --name=hello-world- To use this project in another first link this project to npm by linking in the same level as the package.json in with the link command.
npm link- Then in the project that you want to link this collection of schematic to, run:
(sudo?) npm link dre-schematicsThen use the schematic with the generate command.
ng generate dre-schematics:page ng generate dre-schematics:lazy-module To run all the available '.spec.ts' test files, run:
npm tTo test locally, install @angular-devkit/schematics-cli globally and use the schematics command line tool. That tool acts the same as the generate command of the Angular CLI, but also has a debug mode.
Check the documentation with
schematics --helpnpm run test will run the unit tests, using Jasmine as a runner and test framework.
To publish, simply do:
npm run build
npm publishThat's it!