-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathplopfile.js
109 lines (105 loc) · 3.26 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
109
module.exports = function(plop) {
plop.setGenerator("React Component", {
description: "Create a new React component",
prompts: [
{
type: "prompt",
name: "componentName",
message: "Name of your component:"
},
{
type: "confirm",
name: "connectToRedux",
message: "Do you want the component to be connected to Redux?",
default: true
},
{
type: "confirm",
name: "useFlow",
message: "Do you want Flow to be added to your component?",
default: true
}
],
actions: answers => {
const actions = [
{
type: "add",
path:
"./src/shared/components/{{properCase componentName}}/{{properCase componentName}}.js",
templateFile: "./config/plop/component/component.js.plop"
},
{
type: "add",
path:
"./src/shared/components/{{properCase componentName}}/{{properCase componentName}}.test.js",
templateFile: "./config/plop/component/component.test.js.plop"
}
];
if (answers.connectToRedux) {
actions.push({
type: "add",
path: "./src/shared/components/{{properCase componentName}}/index.js",
templateFile: "./config/plop/component/index.connected.js.plop"
});
} else {
actions.push({
type: "add",
path: "./src/shared/components/{{properCase componentName}}/index.js",
templateFile: "./config/plop/component/index.unconnected.js.plop"
});
}
return actions;
}
});
plop.setGenerator("Redux Reducer", {
description: "Generate a new Redux reducer (reducer, actions, selectors …)",
prompts: [
{
type: "prompt",
name: "reducerName",
message: 'Name of your reducer (e.g. "Calendar Event" or "Vehicle")'
}
],
actions: () => {
const actions = [
{
type: "add",
path: "./src/shared/store/{{camelCase reducerName}}/actions.js",
templateFile: "./config/plop/reducer/actions.js.plop"
},
{
type: "add",
path: "./src/shared/store/{{camelCase reducerName}}/actions.test.js",
templateFile: "./config/plop/reducer/actions.test.js.plop"
},
{
type: "add",
path: "./src/shared/store/{{camelCase reducerName}}/reducer.js",
templateFile: "./config/plop/reducer/reducer.js.plop"
},
{
type: "add",
path: "./src/shared/store/{{camelCase reducerName}}/reducer.test.js",
templateFile: "./config/plop/reducer/reducer.test.js.plop"
},
{
type: "add",
path: "./src/shared/store/{{camelCase reducerName}}/selectors.js",
templateFile: "./config/plop/reducer/selectors.js.plop"
},
{
type: "add",
path:
"./src/shared/store/{{camelCase reducerName}}/selectors.test.js",
templateFile: "./config/plop/reducer/selectors.test.js.plop"
},
{
type: "add",
path: "./src/shared/store/{{camelCase reducerName}}/types.js",
templateFile: "./config/plop/reducer/types.js.plop"
}
];
return actions;
}
});
};