-
Notifications
You must be signed in to change notification settings - Fork 1
/
plopfile.js
112 lines (109 loc) · 3.05 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
const fileName = '{{kebabCase name}}'
module.exports = (plop) => {
plop.setGenerator('component', {
description: 'Custom component',
prompts: [
{
type: 'input',
name: 'name',
message: 'What is your component name?',
},
],
actions: [
{
type: 'add',
path: `packages/components/src/${fileName}/${fileName}.tsx`,
templateFile: 'templates/component/component.tsx.hbs',
},
{
type: 'add',
path: 'packages/components/src/{{kebabCase name}}/{{kebabCase name}}.css',
templateFile: 'templates/component/component.css.hbs',
},
{
type: 'add',
path: 'packages/components/src/{{kebabCase name}}/index.ts',
templateFile: 'templates/component/index.ts.hbs',
},
{
type: 'add',
path: 'packages/components/src/{{kebabCase name}}/stories/{{kebabCase name}}.stories.tsx',
templateFile: 'templates/component/stories/component.stories.tsx.hbs',
},
{
type: 'add',
path: 'packages/components/src/{{kebabCase name}}/tests/{{kebabCase name}}.test.tsx',
templateFile: 'templates/component/tests/component.test.tsx.hbs',
},
{
type: 'append',
path: 'packages/components/src/index.ts',
pattern: '/* PLOP_INJECT_EXPORT */',
template: `export * from './{{kebabCase name}}'`,
},
],
})
plop.setGenerator('icon', {
description: 'Custom icon',
prompts: [
{
type: 'input',
name: 'name',
message: 'What is your icon name?',
},
],
actions: [
{
type: 'add',
path: `packages/icons/src/${fileName}/${fileName}.tsx`,
templateFile: 'templates/icon/icon.tsx.hbs',
},
{
type: 'add',
path: `packages/icons/src/${fileName}/index.ts`,
templateFile: 'templates/icon/index.ts.hbs',
},
{
type: 'append',
path: `packages/icons/src/${fileName}/index.ts`,
pattern: '/* PLOP_INJECT_EXPORT */',
template: `export * from './{{kebabCase name}}'`,
},
{
type: 'append',
path: 'packages/icons/src/icons.ts',
pattern: '/* PLOP_INJECT_EXPORT */',
template: `export * from './{{kebabCase name}}'`,
},
],
})
plop.setGenerator('icon-variant', {
description: 'Custom icon',
prompts: [
{
type: 'input',
name: 'name',
message: 'What is your icon name?',
},
{
type: 'list',
name: 'variant',
message: 'Choose an icon variant',
choices: ['Small', 'Fill'],
},
],
actions: [
{
type: 'add',
path: `packages/icons/src/${fileName}/${fileName}-{{lowerCase variant}}.tsx`,
templateFile: 'templates/icon/icon-variant.tsx.hbs',
},
{
type: 'append',
path: `packages/icons/src/${fileName}/index.ts`,
pattern: '/* PLOP_INJECT_EXPORT */',
template: `export * from './{{kebabCase name}}-{{lowerCase variant}}'`,
},
],
})
}