generated from flatlogic/react-native-starter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
plopfile.js
93 lines (90 loc) · 2.73 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
/* eslint-disable max-len */
module.exports = function(plop) {
plop.setGenerator('module', {
description: 'Generates new module with or without redux connection',
prompts: [
{
type: 'input',
name: 'name',
message: 'Module name (Casing will be modified)'
},
{
type: 'list',
name: 'type',
message: 'Choose Module type',
choices: ['statefull', 'stateless']
}
],
actions(data) {
const actions = [
{
type: 'add',
path: 'src/modules/{{camelCase name}}/{{properCase name}}View.js',
templateFile: 'generators/module/ModuleView.js.hbs'
},
{
type: 'add',
path:
'src/modules/{{camelCase name}}/{{properCase name}}ViewContainer.js',
templateFile: 'generators/module/ModuleViewContainer.js.hbs'
}
];
if (data.type === 'statefull') {
actions.push({
type: 'add',
path: 'src/modules/{{camelCase name}}/{{properCase name}}State.js',
templateFile: 'generators/module/ModuleState.js.hbs'
});
actions.push({
type: 'modify',
path: 'src/redux/reducer.js',
pattern: /\/\/ ## Generator Reducer Imports/gi,
template:
"// ## Generator Reducer Imports\r\nimport {{camelCase name}} from '../modules/{{camelCase name}}/{{properCase name}}State';"
});
actions.push({
type: 'modify',
path: 'src/redux/reducer.js',
pattern: /\/\/ ## Generator Reducers/gi,
template: '// ## Generator Reducers\r\n {{camelCase name}},'
});
}
return actions;
}
});
plop.setGenerator('component', {
description: 'Generates new component',
prompts: [
{
type: 'input',
name: 'name',
message: 'Component name (Casing will be modified)'
}
],
actions: [
{
type: 'add',
path: 'src/components/{{properCase name}}.js',
templateFile: 'generators/component/Component.js.hbs'
},
{
type: 'add',
path: 'src/components/__tests__/{{properCase name}}.spec.js',
templateFile: 'generators/component/Component.spec.js.hbs'
},
{
type: 'modify',
path: 'src/components/index.js',
pattern: /\/\/ ## Generator Components Imports/gi,
template:
"// ## Generator Components Imports\r\nimport {{properCase name}} from './{{properCase name}}';"
},
{
type: 'modify',
path: 'src/components/index.js',
pattern: /\/\/ ## Generator Components Exports/gi,
template: '// ## Generator Components Exports\r\n {{properCase name}},'
}
]
});
};