plopfile.js 922 B

123456789101112131415161718192021222324252627282930313233343536
  1. export default plop => {
  2. plop.setGenerator('domain', {
  3. description: '生成一个领域',
  4. prompts: [
  5. {
  6. type: 'input',
  7. name: 'name',
  8. message: 'domain name: '
  9. }
  10. ],
  11. actions: [
  12. {
  13. type: 'add',
  14. path: 'src/views/{{name}}/{{properCase name}}.vue',
  15. templateFile: 'plop-template/view.hbs'
  16. },
  17. {
  18. type: 'add',
  19. path: 'src/domain/{{name}}/api.ts',
  20. templateFile: 'plop-template/api.hbs'
  21. },
  22. {
  23. type: 'add',
  24. path: 'src/domain/{{name}}/service.ts',
  25. templateFile: 'plop-template/service.hbs'
  26. },
  27. {
  28. type: 'append',
  29. pattern: /(?=(\/\/ -- APPEND HERE --))/gi,
  30. path: 'src/router/asyncRouter.ts',
  31. templateFile: 'plop-template/router.hbs'
  32. }
  33. ]
  34. })
  35. plop.setHelper('upperCase', string => string.charAt(0).toUpperCase() + string.slice(1))
  36. }