2

我构建了一个简单的 Angular Schematics,名为:my-schematics。

我能够将(使用 angular cli)我的原理图添加到某个项目中。

运行时ng update my-schematics出现错误的问题是: Not found : my-schematic.

我不确定为什么。这是我的collection.json

    "schematics": {
      "update": {
        "description": "Updates version test",
        "factory": "./ng-update/index#update"
      }
    }
4

3 回答 3

2

在 collection.json 中,您的原理图被命名为“更新”而不是我的原理图。

如果你想运行你的原理图,你应该

ng g update

而不是 ng update my-schematics

collection.json 在 angular.json 中,您可以为原理图添加默认集合:

"cli": {
  "defaultCollection": "<path-to-your-collection>/collection.json",
}

如果您的收藏不是默认收藏,您应该通过以下方式运行它

ng g <your-collection>:<your-schematic-name>

查看https://blog.angular.io/schematics-an-introduction-dc1dfbc2a2b2了解有关原理图的更多信息

于 2018-11-20T16:07:51.463 回答
1

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
  }
}
于 2019-06-26T16:12:24.877 回答
0

问题是你必须先安装你的原理图,所以它会在你的node_modules文件夹下。我通过npm install在构建它之后运行来做到这一点。

看看这个博客: https ://medium.com/swlh/automate-your-teams-boilerplates-by-building-your-own-schematics-640949001d46?source=friends_link&sk=4b90f9ecc092b598e75c5bbbd6e473a1

它几乎涵盖了它。

于 2019-07-29T15:02:39.270 回答