-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathplopfile.mjs
48 lines (47 loc) · 1.37 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
/** @param {import('plop').NodePlopAPI} plop */
export default function (plop) {
plop.setHelper('formatPath', (directory, subdirectory) => {
if (subdirectory) {
return `${directory}/${subdirectory}`;
}
return directory;
});
plop.setGenerator('component', {
description: 'Create a component',
prompts: [
{
type: 'input',
name: 'name',
message: 'Component name',
},
{
type: 'list',
name: 'directory',
message: 'Select the target directory',
choices: ['components/base', 'components/features'],
},
{
type: 'input',
name: 'subdirectory',
message: 'Enter a subdirectory path (options)',
},
],
actions: [
{
type: 'add',
path: 'src/{{formatPath directory subdirectory}}/{{pascalCase name}}/{{pascalCase name}}.tsx',
templateFile: 'plop-templates/Component.tsx.hbs',
},
{
type: 'add',
path: 'src/{{formatPath directory subdirectory}}/{{pascalCase name}}/{{pascalCase name}}.stories.tsx',
templateFile: 'plop-templates/Component.stories.tsx.hbs',
},
{
type: 'add',
path: 'src/{{formatPath directory subdirectory}}/{{pascalCase name}}/{{pascalCase name}}.module.css',
templateFile: 'plop-templates/Component.module.css.hbs',
},
],
});
}