-
Notifications
You must be signed in to change notification settings - Fork 74
/
Copy pathplopfile.js
108 lines (105 loc) · 2.75 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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
module.exports = (plop) => {
plop.setGenerator("new", {
description: "Create a component",
prompts: [
{
type: "input",
name: "name",
message: "Component name(e.g. Input, InputNumber):",
validate: (name) => {
if (name === "") {
return "Please input component name or press `ctrl-c` to quit"
}
return true;
}
},
{
type: "rawlist",
name: "type",
message: "Which storybook type does the component belong:",
choices: [
{
name: "GENERAL, e.g. Button, Icon... ",
value: "GENERAL",
},
{
name: "LAYOUT, e.g. Grid, Space, Divider...",
value: "LAYOUT",
},
{
name: "DATA DISPLAY, e.g. List, Table, Tree...",
value: "DATA DISPLAY",
},
{
name: "DATA INPUT, e.g. Input, Form, Radio...",
value: "DATA INPUT",
},
{
name: "FEEDBACK, e.g. Progress, Message, Modal... ",
value: "FEEDBACK",
},
{
name: "NAVIGATION, e.g. Menu, Pagination...",
value: "NAVIGATION",
},
{
name: "OTHERS, e.g. Trigger, Affix...",
value: "OTHERS",
},
],
},
],
actions: [
{
type: "addMany",
destination: "packages/{{dashCase name}}",
base: "./plop-templates/component",
templateFiles: "./plop-templates/component/*/**",
globOptions: {
expandDirectories: false,
}
},
],
});
plop.setGenerator("new-icon", {
description: "Create a new icon",
prompts: [
{
type: "input",
name: "name",
message: "Icon name(e.g. EmptyState, FileWorld, NextDouble):",
validate: (name) => {
if (name === "") {
return "Please input icon name or press `ctrl-c` to quit"
}
return true;
}
},
],
actions: [
{
type: "add",
path: "packages/icon/src/icons/{{dashCase name}}.tsx",
templateFile: "./plop-templates/icon/icon.tsx"
},
{
type: "append",
pattern: new RegExp(/(?=\} from "..\/src")/),
path: "packages/icon/stories/icon.stories.tsx",
separator: "",
// put 2 space before
template: " {{properCase name}}Icon,\n"
},
{
type: "append",
path: "packages/icon/stories/icon.stories.tsx",
templateFile: "./plop-templates/icon/story.tsx"
},
{
type: "append",
path: "packages/icon/src/index.ts",
template: 'export * from "./icons/{{dashCase name}}"'
},
]
});
};