newModule.js 841 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. const PAGE_PATH = 'src/views/'
  2. const toUpperCase = (str) => str.charAt(0).toUpperCase() + str.slice(1)
  3. module.exports = {
  4. description: 'Create a new Module',
  5. prompts: [
  6. {
  7. type: 'input',
  8. name: 'pagePath',
  9. message: 'What is the path to the page?'
  10. },
  11. {
  12. type: 'input',
  13. name: 'moduleName',
  14. message: 'What is the name of the module?'
  15. }
  16. ],
  17. actions: (data) => {
  18. const { pagePath, moduleName } = data
  19. const upperFirstName = toUpperCase(moduleName)
  20. const actions = []
  21. if (moduleName) {
  22. actions.push({
  23. type: 'add',
  24. path: `${PAGE_PATH}${pagePath}/${moduleName}/index.vue`,
  25. templateFile: 'plop/template/newModule/index.hbs',
  26. data: {
  27. name: moduleName,
  28. upperFirstName
  29. }
  30. })
  31. }
  32. return actions
  33. }
  34. }