prompt.js 721 B

123456789101112131415161718192021222324252627282930313233343536
  1. const { notEmpty } = require('../utils.js');
  2. module.exports = {
  3. description: 'generate store',
  4. prompts: [
  5. {
  6. type: 'input',
  7. name: 'name',
  8. message: 'store name please',
  9. validate: notEmpty('name'),
  10. },
  11. ],
  12. actions(data) {
  13. const { name } = data;
  14. const actions = [
  15. {
  16. type: 'add',
  17. path: `src/store/modules/${name}/index.ts`,
  18. templateFile: 'plop-templates/store/index.hbs',
  19. data: {
  20. name,
  21. },
  22. },
  23. {
  24. type: 'add',
  25. path: `src/store/modules/${name}/types.ts`,
  26. templateFile: 'plop-templates/store/types.hbs',
  27. data: {
  28. name,
  29. },
  30. },
  31. ];
  32. return actions;
  33. },
  34. };