config.ts 900 B

12345678910111213141516171819202122232425262728293031
  1. import type { PlopTypes } from "@turbo/gen";
  2. // Learn more about Turborepo Generators at https://turbo.build/repo/docs/core-concepts/monorepos/code-generation
  3. export default function generator(plop: PlopTypes.NodePlopAPI): void {
  4. // A simple generator to add a new React component to the internal UI library
  5. plop.setGenerator("react-component", {
  6. description: "Adds a new react component",
  7. prompts: [
  8. {
  9. type: "input",
  10. name: "name",
  11. message: "What is the name of the component?",
  12. },
  13. ],
  14. actions: [
  15. {
  16. type: "add",
  17. path: "src/{{kebabCase name}}.tsx",
  18. templateFile: "templates/component.hbs",
  19. },
  20. {
  21. type: "append",
  22. path: "package.json",
  23. pattern: /"exports": {(?<insertion>)/g,
  24. template: ' "./{{kebabCase name}}": "./src/{{kebabCase name}}.tsx",',
  25. },
  26. ],
  27. });
  28. }