-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplopfile.js
More file actions
295 lines (287 loc) · 10.8 KB
/
plopfile.js
File metadata and controls
295 lines (287 loc) · 10.8 KB
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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
module.exports = plop => {
plop.setGenerator('component', {
description: 'Create a component',
// User input prompts provided as arguments to the template
prompts: [
{
// Raw text input
type: 'input',
// Variable name for this input
name: 'name',
// Prompt to display on command line
message: 'What is your component name?',
},
],
actions: [
{
// Add a new file
type: 'add',
// Path for the new file
path: 'src/shared/components/{{pascalCase name}}/index.ts',
// Handlebars template used to generate content of new file
templateFile: 'plop-templates/Component.index.js.hbs',
},
{
type: 'add',
path: 'src/shared/components/{{pascalCase name}}/{{pascalCase name}}.tsx',
templateFile: 'plop-templates/Component.js.hbs',
},
{
type: 'add',
path: 'src/shared/components/{{pascalCase name}}/{{pascalCase name}}.styles.ts',
templateFile: 'plop-templates/Component.styles.js.hbs',
},
],
})
plop.setGenerator('screen', {
description: 'Create a screen',
// User input prompts provided as arguments to the template
prompts: [
{
// Raw text input
type: 'input',
// Variable name for this input
name: 'name',
// Prompt to display on command line
message: 'What is your screen name?',
},
{
// Raw text input
type: 'input',
// Variable name for this input
name: 'module',
// Prompt to display on command line
message: 'What is your module name for your screen?',
},
],
actions: [
{
// Action type 'append' injects a template into an existing file
type: 'append',
path: 'src/services/navigation/index.tsx',
// Pattern tells plop where in the file to inject the template
pattern: `/* PLOP_INJECT_SCREEN */`,
templateFile: 'plop-templates/Screen.navigation.js.hbs',
},
{
// Action type 'append' injects a template into an existing file
type: 'append',
path: 'src/services/navigation/index.tsx',
// Pattern tells plop where in the file to inject the template
pattern: `/* PLOP_INJECT_SCREEN_PARAMS */`,
template: `[SCREENS.{{constantCase module}}_{{constantCase name}}]: undefined`,
},
{
// Action type 'append' injects a template into an existing file
type: 'append',
path: 'src/services/navigation/index.tsx',
// Pattern tells plop where in the file to inject the template
pattern: `/* PLOP_INJECT_SCREEN_IMPORT */`,
template: `import {{pascalCase name}} from '@ui/{{pascalCase module}}/screens/{{pascalCase name}}'`,
},
{
// Action type 'append' injects a template into an existing file
type: 'append',
path: 'src/services/navigation/Navigation.enums.ts',
// Pattern tells plop where in the file to inject the template
pattern: `/* PLOP_INJECT_SCREEN */`,
template: `{{constantCase module}}_{{constantCase name}} = '{{constantCase module}}_{{constantCase name}}',`,
},
{
// Add a new file
type: 'add',
// Path for the new file
path: 'src/ui/{{pascalCase module}}/screens/{{pascalCase name}}/index.ts',
// Handlebars template used to generate content of new file
template: `export { default } from './{{pascalCase name}}Screen'`,
},
{
// Add a new file
type: 'add',
// Path for the new file
path: 'src/ui/{{pascalCase module}}/screens/{{pascalCase name}}/{{pascalCase name}}Screen.tsx',
// Handlebars template used to generate content of new file
templateFile: 'plop-templates/Screen.js.hbs',
},
{
// Add a new file
type: 'add',
// Path for the new file
path: 'src/ui/{{pascalCase module}}/screens/{{pascalCase name}}/{{pascalCase name}}Screen.styles.ts',
// Handlebars template used to generate content of new file
templateFile: 'plop-templates/Screen.styles.js.hbs',
},
],
})
plop.setGenerator('stackNavigation', {
description: 'Create a new Stack of Screens',
// User input prompts provided as arguments to the template
prompts: [
{
// Raw text input
type: 'input',
// Variable name for this input
name: 'stack',
// Prompt to display on command line
message: 'What is your new Stack name?',
},
],
actions: [
{
// Add a new file
type: 'add',
// Path for the new file
path: 'src/services/navigation/Stacks/{{pascalCase stack}}/index.tsx',
// Handlebars template used to generate content of new file
templateFile: 'plop-templates/Stack.js.hbs',
},
{
// Add a new file
type: 'add',
// Path for the new file
path: 'src/services/navigation/Stacks/{{pascalCase stack}}/{{pascalCase stack}}.enums.ts',
// Handlebars template used to generate content of new file
template: `export enum SCREENS {
{{constantCase stack}}_HOME = '{{constantCase stack}}_HOME',
/* PLOP_INJECT_ENUM */
}`,
},
{
// Add a new file
type: 'add',
// Path for the new file
path: 'src/ui/{{pascalCase stack}}/screens/Home/index.ts',
// Handlebars template used to generate content of new file
template: `export { default } from './HomeScreen'`,
},
{
// Add a new file
type: 'add',
// Path for the new file
path: 'src/ui/{{pascalCase stack}}/screens/Home/HomeScreen.tsx',
// Handlebars template used to generate content of new file
templateFile: 'plop-templates/Screen.stack.js.hbs',
},
{
// Add a new file
type: 'add',
// Path for the new file
path: 'src/ui/{{pascalCase stack}}/screens/Home/HomeScreen.styles.ts',
// Handlebars template used to generate content of new file
templateFile: 'plop-templates/Screen.styles.js.hbs',
},
{
// Action type 'append' injects a template into an existing file
type: 'append',
path: 'src/services/navigation/index.tsx',
// Pattern tells plop where in the file to inject the template
pattern: `/* PLOP_INJECT_NAVIGATOR */`,
templateFile: 'plop-templates/Stack.navigation.js.hbs',
},
{
// Action type 'append' injects a template into an existing file
type: 'append',
path: 'src/services/navigation/index.tsx',
// Pattern tells plop where in the file to inject the template
pattern: `/* PLOP_INJECT_NAVIGATOR_IMPORT */`,
template: `import {{pascalCase stack}}Navigator from './Stacks/{{pascalCase stack}}'`,
},
{
// Action type 'append' injects a template into an existing file
type: 'append',
path: 'src/services/navigation/index.tsx',
// Pattern tells plop where in the file to inject the template
pattern: `/* PLOP_INJECT_NAVIGATOR_PARAMS */`,
template: `[SCREENS.{{constantCase stack}}_STACK]: undefined`,
},
{
// Action type 'append' injects a template into an existing file
type: 'append',
path: 'src/services/navigation/Navigation.enums.ts',
// Pattern tells plop where in the file to inject the template
pattern: `/* PLOP_INJECT_SCREEN */`,
template: `{{constantCase stack}}_STACK = '{{constantCase stack}}_STACK',`,
},
],
})
plop.setGenerator('screenByStack', {
description: 'Create a new screen by Stack',
// User input prompts provided as arguments to the template
prompts: [
{
// Raw text input
type: 'input',
// Variable name for this input
name: 'stack',
// Prompt to display on command line
message: 'What is your new Stack name?',
},
{
// Raw text input
type: 'input',
// Variable name for this input
name: 'screen',
// Prompt to display on command line
message: 'What is your new Screen name by stack?',
},
],
actions: [
{
// Add a new file
type: 'add',
// Path for the new file
path: 'src/ui/{{pascalCase stack}}/screens/{{pascalCase screen}}/index.ts',
// Handlebars template used to generate content of new file
template: `export { default } from './{{pascalCase screen}}Screen'`,
},
{
// Add a new file
type: 'add',
// Path for the new file
path: 'src/ui/{{pascalCase stack}}/screens/{{pascalCase screen}}/{{pascalCase screen}}Screen.tsx',
// Handlebars template used to generate content of new file
templateFile: 'plop-templates/Screen.js.hbs',
},
{
// Add a new file
type: 'add',
// Path for the new file
path: 'src/ui/{{pascalCase stack}}/screens/{{pascalCase screen}}/{{pascalCase screen}}Screen.styles.ts',
// Handlebars template used to generate content of new file
templateFile: 'plop-templates/Screen.styles.js.hbs',
},
{
// Action type 'append' injects a template into an existing file
type: 'append',
path: 'src/services/navigation/Stacks/{{pascalCase stack}}/index.tsx',
// Pattern tells plop where in the file to inject the template
pattern: `/* PLOP_INJECT_SCREEN */`,
templateFile: 'plop-templates/ScreenByStack.navigation.js.hbs',
},
{
// Action type 'append' injects a template into an existing file
type: 'append',
path: 'src/services/navigation/Stacks/{{pascalCase stack}}/index.tsx',
// Pattern tells plop where in the file to inject the template
pattern: `/* PLOP_INJECT_SCREEN_PARAMS */`,
template: `[SCREENS.{{constantCase stack}}_{{constantCase screen}}]: undefined`,
},
{
// Action type 'append' injects a template into an existing file
type: 'append',
path: 'src/services/navigation/index.tsx',
// Pattern tells plop where in the file to inject the template
pattern: `/* PLOP_INJECT_SCREEN_IMPORT */`,
template: `import {{pascalCase name}} from '@ui/{{pascalCase module}}/screens/{{pascalCase name}}'`,
},
{
// Action type 'append' injects a template into an existing file
type: 'append',
path: 'src/services/navigation/Navigation.enums.ts',
// Pattern tells plop where in the file to inject the template
pattern: `/* PLOP_INJECT_ENUM */`,
template: `{{constantCase module}}_{{constantCase name}} = '{{constantCase module}}_{{constantCase name}}',`,
},
],
})
}