-
Notifications
You must be signed in to change notification settings - Fork 202
/
plopfile.js
87 lines (82 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
const prettier = require('prettier');
module.exports = (plop) => {
const prettierConfig = prettier.resolveConfig.sync(__dirname);
plop.load('plop-prettier', prettierConfig);
plop.setGenerator('React Component', {
description: 'Create a new React component',
prompts: [
{
type: 'prompt',
name: 'componentName',
message: 'Name of your component:',
},
],
actions: () => {
const actions = [
{
type: 'pretty-add',
path:
'./src/shared/components/{{properCase componentName}}/{{properCase componentName}}.tsx',
templateFile: './config/plop/component/component.tsx.plop',
},
{
type: 'pretty-add',
path:
'./src/shared/components/{{properCase componentName}}/{{properCase componentName}}.test.tsx',
templateFile: './config/plop/component/component.test.tsx.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: 'pretty-add',
path: './src/shared/store/{{camelCase reducerName}}/actions.ts',
templateFile: './config/plop/reducer/actions.ts.plop',
},
{
type: 'pretty-add',
path: './src/shared/store/{{camelCase reducerName}}/actions.test.ts',
templateFile: './config/plop/reducer/actions.test.js.plop',
},
{
type: 'pretty-add',
path: './src/shared/store/{{camelCase reducerName}}/reducer.ts',
templateFile: './config/plop/reducer/reducer.ts.plop',
},
{
type: 'pretty-add',
path: './src/shared/store/{{camelCase reducerName}}/reducer.test.ts',
templateFile: './config/plop/reducer/reducer.test.js.plop',
},
{
type: 'pretty-add',
path: './src/shared/store/{{camelCase reducerName}}/selectors.ts',
templateFile: './config/plop/reducer/selectors.ts.plop',
},
{
type: 'pretty-add',
path: './src/shared/store/{{camelCase reducerName}}/selectors.test.ts',
templateFile: './config/plop/reducer/selectors.test.js.plop',
},
{
type: 'pretty-add',
path: './src/shared/store/{{camelCase reducerName}}/types.ts',
templateFile: './config/plop/reducer/types.ts.plop',
},
];
return actions;
},
});
};