-
Notifications
You must be signed in to change notification settings - Fork 0
/
plopfile.js
127 lines (127 loc) · 3.32 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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
module.exports = (plop) => {
plop.setGenerator('component', {
description: 'Tạo một component mới',
prompts: [
{
type: 'input',
name: 'name',
message: 'Tên của component:',
},
],
actions: [
{
type: 'add',
path: 'src/components/{{pascalCase name}}/index.tsx',
templateFile: 'plop-component/Component/index.tsx.hbs',
},
{
type: 'add',
path: 'src/components/{{pascalCase name}}/style.ts',
templateFile: 'plop-component/Component/styles.ts.hbs',
},
{
type: 'append',
path: 'src/components/index.ts',
pattern: `/* PLOP_INJECT_IMPORT */`,
template: `import {{pascalCase name}} from './{{pascalCase name}}';`,
},
{
type: 'append',
path: 'src/components/index.ts',
pattern: `/* PLOP_INJECT_EXPORT */`,
template: `\t, {{pascalCase name}}`,
},
],
});
plop.setGenerator('context', {
description: 'Tạo một context mới',
prompts: [
{
type: 'input',
name: 'name',
message: 'Tên của context:',
},
{
type: 'input',
name: 'provider',
message: 'Tên của provider:',
},
],
actions: [
{
type: 'add',
path: 'src/tools/{{pascalCase name}}/index.tsx',
templateFile: 'plop-component/Context/index.tsx.hbs',
},
{
type: 'add',
path: 'src/tools/{{pascalCase name}}/context.ts',
templateFile: 'plop-component/Context/context.ts.hbs',
},
{
type: 'add',
path: 'src/tools/{{pascalCase name}}/types.ts',
templateFile: 'plop-component/Context/types.ts.hbs',
},
{
type: 'add',
path: 'src/hooks/{{pascalCase provider}}.ts',
templateFile: 'plop-component/Hook/use-hook.ts.hbs',
},
{
type: 'append',
path: 'src/hooks/index.ts',
pattern: `/* PLOP_INJECT_EXPORT */`,
template: `export * from './{{pascalCase provider}}';`,
},
],
});
plop.setGenerator('screen', {
description: 'Tạo một screen mới',
prompts: [
{
type: 'input',
name: 'name',
message: 'Tên của Screen:',
},
{
type: 'input',
name: 'route',
message: 'Tên của Route:',
},
],
actions: [
{
type: 'add',
path: 'src/screens/{{pascalCase name}}/index.tsx',
templateFile: 'plop-component/Screen/index.tsx.hbs',
},
{
type: 'add',
path: 'src/screens/{{pascalCase name}}/types.ts',
templateFile: 'plop-component/Screen/types.ts.hbs',
},
{
type: 'add',
path: 'src/screens/{{pascalCase name}}/styles.ts',
templateFile: 'plop-component/Screen/styles.ts.hbs',
},
{
type: 'add',
path: 'src/screens/{{pascalCase name}}/component/.gitkeep',
},
{
type: 'append',
path: 'src/screens/index.ts',
pattern: `/* PLOP_INJECT_EXPORT */`,
template: `export * from './{{pascalCase name}}';`,
},
{
type: 'append',
path: 'src/stack/routes.ts',
pattern: `/* PLOP_INJECT_EXPORT */`,
template: `\t{{pascalCase route}} = '{{pascalCase name}}',`,
},
],
});
};