forked from saleor/saleor-storefront
-
Notifications
You must be signed in to change notification settings - Fork 0
/
plopfile.js
52 lines (51 loc) · 1.43 KB
/
plopfile.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
const { readdirSync } = require("fs");
const getDirectories = source =>
readdirSync(source, { withFileTypes: true })
.filter(dirent => dirent.isDirectory())
.map(dirent => {
return { name: dirent.name, value: dirent.name };
});
module.exports = plop => {
plop.setGenerator("component", {
description: "Create a component",
prompts: [
{
type: "list",
name: "componentType",
message: "Choose component type",
choices: getDirectories("src/@next/components"),
},
{
type: "input",
name: "name",
message: "Enter component name",
},
],
actions: data => {
const path = `src/@next/components/${data.componentType}/`;
return [
{
type: "add",
path: `${path}{{pascalCase name}}/{{pascalCase name}}.tsx`,
templateFile: "plop-templates/Component/Component.tsx.hbs",
},
{
type: "add",
path: `${path}{{pascalCase name}}/index.tsx`,
templateFile: "plop-templates/Component/index.ts.hbs",
},
{
type: "add",
path: `${path}{{pascalCase name}}/stories.tsx`,
templateFile: "plop-templates/Component/stories.tsx.hbs",
},
{
type: "append",
path: `${path}index.ts`,
separator: "",
templateFile: "plop-templates/Component/exportAll.ts.hbs",
},
];
},
});
};