prompt.js 615 B

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