如何创建“链式”原理图?

时间:2019-09-09 14:44:28

标签: angular angular-schematics

我不知道我所需要的正确用语,所以我会尽力解释清楚。

sequelize-cli之类的CLI中,您可以运行sequelize db:createsequelize db:drop。我想创建两个原理图,其第一部分本身就是命令,但是如果添加第二部分,它将执行不同的原理图。

具体地说,我想:

  • 运行mySchematic:migration并创建许多文件。
  • 运行mySchematic:migration:express,它将只为express创建迁移。
  • 运行mySchematic:migration:hapi,它将只为hapi创建迁移。

我知道如何实现功能,但是我无法获得它来执行不同的命令。当我运行mySchematic:migration:hapi时,执行的原理图总是mySchematic:migration

这是我的collection.json

{
  "$schema": "../node_modules/@angular-devkit/schematics/collection-schema.json",
  "schematics": {
    "migration": {
      "description": "description.",
      "factory": "./migrations/index#migration",
      "schema": "./migrations/migration-schema.json"
    },
    "migration:express": {
      "description": "description.",
      "factory": "./migrations/index#express",
      "schema": "./migrations/express-schema.json"
    },
  },
  "migration:hapi": {
    "description": "description.",
    "factory": "./migrations/index#hapi",
    "schema": "./migrations/hapi-schema.json"
  },
}

更改原理图的顺序也不起作用。

我也尝试过这种方法,但是它也不起作用:

{
  "$schema": "../node_modules/@angular-devkit/schematics/collection-schema.json",
  "schematics": {
    "migration": {
      "description": "description.",
      "factory": "./migrations/index#migration",
      "schema": "./migrations/migration-schema.json",
      "express": {
        "description": "description.",
        "factory": "./migrations/index#express",
        "schema": "./migrations/express-schema.json"
      },
      "hapi": {
        "description": "description.",
        "factory": "./migrations/index#hapi",
        "schema": "./migrations/hapi-schema.json"
      }
    }
  }
}

0 个答案:

没有答案