I'm trying to create custom schematics for angular cli. So far I have figured out that "collection" has to be compiled, cli cannot read typescript. Which means you can not just clone https://github.com/angular/devkit/tree/master/packages/schematics/angular change whatever you need and publish it on npm, which means you need to clone the whole https://github.com/angular/devkit and use its you need to run it thru tsc, you can then publish those compiled files to npm and globally install with npm, for example npm run build
to create compiled schematics
npm i -g @thescrollbar/schematics
then I should have been able to do ng new --collection=@thescrollbar/schematics my-app
but surprisingly enough, it did not work and was throwing tree.branch is not a function
.
But if you copy this globally installed package to cli's module
/usr/local/bin/node_modules/@thescrollbar/schematics
-> /usr/local/bin/node_modules/@angular/cli/node_modules/@thescrollbar/schematics
it starts working and you can create a new app that is based on your schematics..
Now for the new problem I have no workaround for, when I try to generate a new components with
ng g c --collection=@thescrollbar/schematics logo
it creates it using @schematics/angular
template, instead of my collection, despite the fact that when I on purpose do
ng g shat --collection=@thescrollbar/schematics logo
it says
Schematic "shat" not found in collection "@thescrollbar/schematics".
which I think clearly indicates that it indeed is using my collection?
Anyone managed to get custom collections working? Globally and for generating components / modules?