I don't know the correct term for what I need, so I will try to explain it as clear as possible.
In CLIs like sequelize-cli
you can run either sequelize db:create
or sequelize db:drop
. I want to create two schematics whose first part is a command in itself, but if you add a second part it will execute a different schematic.
Specifically, I want to :
- Run
mySchematic:migration
and create a lot of files. - Run
mySchematic:migration:express
and it will only create migrations for express. - Run
mySchematic:migration:hapi
and it will only create migrations for hapi.
I know how to achieve the functionality, but I am not able to get it to execute the different commands. When I run mySchematic:migration:hapi
, the schematic that is executed is always mySchematic:migration
.
This is my 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"
},
}
Changing the order of the schematics does not work either.
I have also tried this, but it didn't work either:
{
"$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"
}
}
}
}