This repository has been archived by the owner on Oct 27, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
plopfile.js
94 lines (88 loc) · 2.55 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
module.exports = function buildGenerators(plop) {
/** Set the Component Type */
const componentTypePrompts = {
type : 'list',
name : 'type',
message: 'Component Type',
choices: [ 'collections', 'elements', 'modules', 'widget' ]
};
/** Set the Component Extras */
const componentExtras = [
{
type : 'confirm',
name : 'couldHaveChildren',
message: 'This component could have declared children?'
},
{
type : 'confirm',
name : 'couldChangeElementType',
message: 'This component could change its default ElementType?'
},
{
type : 'confirm',
name : 'hasStateClasses',
message: 'This components could has component state classes, like primary/danger etc?'
}
];
/* --------
* Build Generators
* -------- */
plop.setGenerator('component', {
description: 'React Bucket Component',
prompts : [
componentTypePrompts,
{
type : 'input',
name : 'componentName',
message: 'The Component Name'
},
...componentExtras
],
actions : [
{
type : 'add',
path : 'src/react/{{ type }}/{{ pascalCase componentName }}/{{ pascalCase componentName }}.tsx',
templateFile: 'templates/component.hbs'
},
{
type : 'add',
path : 'src/react/{{ type }}/{{ pascalCase componentName }}/{{ pascalCase componentName }}.types.ts',
templateFile: 'templates/component.types.hbs'
},
{
type : 'add',
path : 'src/react/{{ type }}/{{ pascalCase componentName }}/index.ts',
templateFile: 'templates/component.index.hbs'
}
]
});
plop.setGenerator('subcomponent', {
description: 'React Bucket Sub Component',
prompts : [
componentTypePrompts,
{
type : 'input',
name : 'parentComponentName',
message: 'Parent Component Name'
},
{
type : 'input',
name : 'componentName',
message: 'Component Name'
},
...componentExtras
],
actions : [
{
type : 'add',
path : 'src/react/{{ type }}/{{ pascalCase parentComponentName }}/{{ pascalCase componentName }}.tsx',
templateFile: 'templates/component.hbs'
},
{
type : 'add',
path : 'src/react/{{ type }}/{{ pascalCase parentComponentName }}/{{ pascalCase componentName }}.types.ts',
templateFile: 'templates/component.types.hbs'
}
]
});
};