prompt.js 683 B

12345678910111213141516171819202122232425262728
  1. const { notEmpty } = require("../utils.js");
  2. let { templateFolder } = require("../../../src/config/settings.js");
  3. module.exports = {
  4. description: "创建view",
  5. prompts: [
  6. {
  7. type: "input",
  8. name: "name",
  9. message: "请输入view名称,勿与之前重复,然后点击回车",
  10. validate: notEmpty("name"),
  11. },
  12. ],
  13. actions: (data) => {
  14. const name = "{{name}}";
  15. const actions = [
  16. {
  17. type: "add",
  18. path: `src/views/${templateFolder || "project"}/${name}/index.vue`,
  19. templateFile: "node_modules/zx-templates/view/index.hbs",
  20. data: {
  21. name: name,
  22. },
  23. },
  24. ];
  25. return actions;
  26. },
  27. };