forked from web3ui/web3uikit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
plopfile.js
76 lines (76 loc) · 2.69 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
module.exports = (plop) => {
plop.setGenerator('create-new-component', {
description: 'new component generator',
prompts: [
{
type: 'input',
name: 'name',
message: '🧙 : What is the component name?',
pattern: 'properCase',
},
{
type: 'input',
name: 'subDirectory',
message:
'🧙 : What subdirectory is the component in? (optional)',
},
{
type: 'list',
name: 'category',
message:
'🧙 : What category is the component in? (displayed in StoryBook)',
choices: [
'1.Web3',
'2.Forms',
'3.Layout',
'4.UI',
'5.Popup',
'6.Graphic',
],
},
{
type: 'list',
name: 'isBlank',
message:
"🧙 : Do you want examples and annotations in the generated component's files?",
choices: [
{
name: 'Yes, I want examples and annotations inside',
value: false,
},
{
name: "No, I'm a PRO Mage, leave the files with min code needed for start",
value: true,
},
],
},
],
actions: (data) => {
data.name = plop.getHelper('properCase')(data.name);
data.subDirectory = plop.getHelper('properCase')(data.subDirectory);
const basePath = `.plop/plop-templates/${
data.isBlank ? 'with-no-code-examples' : 'with-code-examples'
}/`;
return [
{
type: 'addMany',
destination:
'src/components{{ getSubDirectoryPath subDirectory }}/{{ name }}',
base: basePath,
templateFiles: `${basePath}/**`,
},
{
type: 'append',
path: 'src/index.ts',
pattern: '/* PLOP_INJECT_EXPORT */',
template:
"export * from './components{{ getSubDirectoryPath subDirectory }}/{{ name }}';",
},
];
},
});
plop.setHelper('getInterface', (name) => `${name}Props`);
plop.setHelper('getSubDirectoryPath', (subDirectory) => {
if (subDirectory) return `/${subDirectory}`;
});
};