我不知道我所需要的正确用语,所以我会尽力解释清楚。
在sequelize-cli
之类的CLI中,您可以运行sequelize db:create
或sequelize 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"
}
}
}
}