forked from web3ui/web3uikit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
plopfile.js
81 lines (81 loc) · 2.84 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
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: 'list',
name: 'subDirectory',
message: '🧙 : What subdirectory is the component in?',
choices: [
{ name: '1.Core', value: 'core' },
{ name: '2.Web3', value: 'web3' },
],
},
{
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);
const basePath = `.plop/plop-templates/${
data.isBlank ? 'with-no-code-examples' : 'with-code-examples'
}/`;
return [
{
type: 'addMany',
destination:
'packages/{{ subDirectory }}/src/lib/{{ name }}',
base: basePath,
templateFiles: `${basePath}/**`,
},
{
type: 'append',
path: 'packages/{{ subDirectory }}/src/lib/index.ts',
pattern: '/* PLOP_INJECT_EXPORT */',
template: "export * from './{{ name }}';",
},
];
},
});
plop.setHelper('getInterface', (name) => `I${name}Props`);
plop.setHelper('getSubDirectoryPath', (subDirectory) => {
if (subDirectory) return `/${subDirectory}`;
});
plop.setHelper('getPackage', (name, subDirectory) => {
if (subDirectory === 'web3') return `@web3uikit/core`;
else return `../${name}`;
});
};