-
Notifications
You must be signed in to change notification settings - Fork 0
/
plopfile.mjs
85 lines (80 loc) · 2.19 KB
/
plopfile.mjs
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
export default function (plop) {
plop.setGenerator('componente', {
description: 'Criar um novo componente',
prompts: [
{
type: 'input',
name: 'name',
message: 'Nome do componente',
},
{
type: 'confirm',
name: 'haveStyles',
message: 'O componente terá estilos?',
},
{
type: 'confirm',
name: 'haveTypes',
message: 'O componente terá tipagem?',
},
{
type: 'confirm',
name: 'haveStories',
message: 'O componente terá documentação?',
},
{
type: 'confirm',
name: 'haveTests',
message: 'O componente terá testes unitários?',
},
],
actions: ({
haveTypes = false,
haveStyles = true,
haveTests = false,
haveStories = false,
}) => {
const data = [
{
type: 'add',
path: 'src/shared/components/{{pascalCase name}}/{{pascalCase name}}.tsx',
templateFile: 'plop-templates/component.hbs',
},
{
type: 'add',
path: 'src/shared/components/{{pascalCase name}}/index.ts',
templateFile: 'plop-templates/component.index.hbs',
},
]
if (haveStories) {
data.push({
type: 'add',
path: 'src/shared/components/{{pascalCase name}}/{{pascalCase name}}.stories.ts',
templateFile: 'plop-templates/component.stories.hbs',
})
}
if (haveTests) {
data.push({
type: 'add',
path: 'src/shared/components/{{pascalCase name}}/{{pascalCase name}}.spec.tsx',
templateFile: 'plop-templates/component.spec.hbs',
})
}
if (haveTypes) {
data.push({
type: 'add',
path: 'src/shared/components/{{pascalCase name}}/{{pascalCase name}}.types.tsx',
templateFile: 'plop-templates/component.types.hbs',
})
}
if (haveStyles) {
data.push({
type: 'add',
path: 'src/shared/components/{{pascalCase name}}/{{pascalCase name}}.styles.ts',
templateFile: 'plop-templates/component.styles.hbs',
})
}
return data
},
})
}