小说后台管理系统
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

56 regels
1.2 KiB

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