Reputation: 21
I build a simple Angular Schematics called: my-schematics.
I able to add (using angular cli) my-schematics to some project.
The problem when I run ng update my-schematics
I got an error says:
Not found : my-schematic
.
I'm not sure why. this is my collection.json
:
"schematics": {
"update": {
"description": "Updates version test",
"factory": "./ng-update/index#update"
}
}
Upvotes: 2
Views: 2051
Reputation: 1040
The problem is that you have to install your schematics first, so it will be under your node_modules
folder. I do that by running npm install
after I build it.
take a look at this blog: https://medium.com/swlh/automate-your-teams-boilerplates-by-building-your-own-schematics-640949001d46?source=friends_link&sk=4b90f9ecc092b598e75c5bbbd6e473a1
it pretty much covers it.
Upvotes: 0
Reputation: 11
Try to rename your "update" to "ng-update", and you need to define the schema.json
"schematics": {
"ng-update": {
"description": "Updates version test",
"factory": "./ng-update/index#update",
"schema": "./ng-update/schema.json" // schema.json to add
}
}
Upvotes: 1
Reputation: 2717
In the collection.json your schematic is named 'update' instead of my-schematics.
If you want to run your schematic you should
ng g update
Instead of ng update my-schematics
collection.json Within angular.json you could add the default collection for your schematics:
"cli": {
"defaultCollection": "<path-to-your-collection>/collection.json",
}
If you collection is not the default collection, you should run it by
ng g <your-collection>:<your-schematic-name>
Have a look at https://blog.angular.io/schematics-an-introduction-dc1dfbc2a2b2 to learn more about schematics
Upvotes: 2