Blame view
plop-templates/component/prompt.js
1.17 KB
d7d9c38c2 auto commit the c... |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
const { notEmpty } = require('../utils.js') module.exports = { description: 'generate vue component', prompts: [{ type: 'input', name: 'name', message: 'component name please', validate: notEmpty('name') }, { type: 'checkbox', name: 'blocks', message: 'Blocks:', choices: [{ name: '<template>', value: 'template', checked: true }, { name: '<script>', value: 'script', checked: true }, { name: 'style', value: 'style', checked: true } ], validate(value) { if (value.indexOf('script') === -1 && value.indexOf('template') === -1) { return 'Components require at least a <script> or <template> tag.' } return true } } ], actions: data => { const name = '{{properCase name}}' const actions = [{ type: 'add', path: `src/components/${name}/index.vue`, templateFile: 'plop-templates/component/index.hbs', data: { name: name, template: data.blocks.includes('template'), script: data.blocks.includes('script'), style: data.blocks.includes('style') } }] return actions } } |