From 8965ff1e391fdaeff744b3cd4f2e240965ce9951 Mon Sep 17 00:00:00 2001 From: jero Date: Mon, 29 Apr 2019 12:10:44 +0300 Subject: [PATCH] chore(plop): add component's role option --- plopfile.js | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/plopfile.js b/plopfile.js index 3fe45e4a..65385129 100644 --- a/plopfile.js +++ b/plopfile.js @@ -20,6 +20,17 @@ module.exports = function(plop) { 'functional', ] }, + { + type: 'list', + name: 'componentRole', + message: 'Choose component\'s role', + choices: [ + 'base', + 'core', + 'shared' + ], + default: 'shared', + }, { type: 'confirm', name: 'connectToRedux', @@ -28,23 +39,24 @@ module.exports = function(plop) { when: ({ componentType }) => !isFunctional(componentType), }, ], - actions({ componentType }) { + actions({ componentType, componentRole }) { const prefix = isFunctional(componentType) ? 'functional-' : 'class-'; + const role = componentRole; const actions = [ { type: 'add', - path: `${components}/shared/{{properCase componentName}}/{{properCase componentName}}.js`, + path: `${components}/${role}/{{properCase componentName}}/{{properCase componentName}}.js`, templateFile: `./config/plop/component/${prefix}component.js.plop`, }, { type: 'add', - path: `${components}/shared/{{properCase componentName}}/{{properCase componentName}}.scss`, + path: `${components}/${role}/{{properCase componentName}}/{{properCase componentName}}.scss`, templateFile: './config/plop/component/component.scss.plop', }, { type: 'add', - path: `${components}/shared/{{properCase componentName}}/{{properCase componentName}}.test.js`, + path: `${components}/${role}/{{properCase componentName}}/{{properCase componentName}}.test.js`, templateFile: './config/plop/component/component.test.js.plop', }, ];