-
Notifications
You must be signed in to change notification settings - Fork 2
/
plopfile.js
61 lines (59 loc) · 1.73 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
const prompts = [
{
type: 'list',
name: 'type',
message: 'What type would you like to generate?',
choices: [
'component',
'utility'
]
},
{
type: 'input',
name: 'name',
message: `How would you like to name it? (don't worry about casing)`
}
];
const actions = {
component: [
{
type: 'add',
path: 'src/components/{{pascalCase name}}/{{pascalCase name}}.tsx',
templateFile: 'config/plop/templates/component/component.hbs'
},
{
type: 'add',
path: 'src/components/{{pascalCase name}}/{{pascalCase name}}.test.tsx',
templateFile: 'config/plop/templates/component/test.hbs'
},
{
type: 'add',
path: 'src/components/{{pascalCase name}}/{{pascalCase name}}.stories.tsx',
templateFile: 'config/plop/templates/component/storybook.hbs'
},
{
type: 'add',
path: `src/components/{{pascalCase name}}/_{{dashCase name}}.scss`,
templateFile: 'config/plop/templates/component/scss.hbs'
}
],
utility: [
{
type: 'add',
path: `src/static/js/utils/{{camelCase name}}.ts`,
templateFile: 'config/plop/templates/utility/utility.hbs'
},
{
type: 'add',
path: `src/static/js/utils/{{camelCase name}}.test.ts`,
templateFile: 'config/plop/templates/utility/test.hbs'
}
]
};
module.exports = plop => {
plop.setGenerator('generate', {
description: `Generate a new component or utility`,
prompts,
actions: ({type}) => actions[type] || []
});
};