In ngxs cli documentation there is an option to use plopfile. I played with it for a while but couldn't figure out how to make it work.
Does anybody know how to use plop
with ngxs
?
NGXS has it's own plopfile
it uses for the CLI commands it offers. They have allowed developers to use their own plopfile
to extend these templates.
Using the basic example as per the plopjs website, create a plopfile
in your root, and call it whatever: custom-plopfile.js
:
module.exports = function (plop) {
// controller generator
plop.setGenerator('controller', {
description: 'application controller logic',
prompts: [{
type: 'input',
name: 'name',
message: 'controller name please'
}],
actions: [{
type: 'add',
path: 'src/{{name}}.js',
templateFile: 'plop-templates/controller.hbs'
}]
});
};
To execute this, you could run: ngxs --plopfile ./custom-plopfile.js GreetingController
and it will use the custom plopfile and template, to generate a new controller for you as src/GreetingController.js
.