prompt.cjs 791 B

12345678910111213141516171819202122232425262728293031323334353637
  1. const toUpperCase = (str) => str.charAt(0).toUpperCase() + str.slice(1)
  2. module.exports = {
  3. description: 'Create vue view',
  4. prompts: [
  5. {
  6. type: 'input',
  7. name: 'path',
  8. message: '请输入路径(Please enter a path)',
  9. default: 'views'
  10. },
  11. {
  12. type: 'input',
  13. name: 'name',
  14. message: '请输入模块名称(Please enter module name)'
  15. }
  16. ],
  17. actions: (data) => {
  18. const { name, path } = data
  19. const upperFirstName = toUpperCase(name)
  20. const actions = []
  21. if (name) {
  22. actions.push({
  23. type: 'add',
  24. path: `./src/${path}/${upperFirstName}.vue`,
  25. templateFile: './plop/view/view.hbs',
  26. data: {
  27. name,
  28. upperFirstName
  29. }
  30. })
  31. }
  32. return actions
  33. }
  34. }