-
Notifications
You must be signed in to change notification settings - Fork 0
/
plopfile.mjs
52 lines (51 loc) · 1.58 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
49
50
51
52
/* eslint-disable import/no-anonymous-default-export */
export default function (/** @type {import('plop').NodePlopAPI} */ plop) {
// create your generators here
plop.setGenerator('basics', {
description: 'this is a skeleton plopfile',
prompts: [
{
type: 'input',
name: 'name',
message: 'Component name: ',
},
], // array of inquirer prompts
actions: [
{
type: 'add',
path: 'src/components/{{pascalcase name}}/{{pascalcase name}}.tsx',
templateFile: 'templates/componentTSX.hbs',
},
{
type: 'add',
path: 'src/components/{{pascalcase name}}/{{pascalcase name}}.d.ts',
templateFile: 'templates/componentProps.hbs',
},
{
type: 'add',
path: 'src/components/{{pascalcase name}}/index.ts',
templateFile: 'templates/componentIndex.hbs',
},
{
type: 'add',
path: 'src/components/{{pascalcase name}}/{{pascalcase name}}.css',
templateFile: 'templates/componentCSS.hbs',
},
{
type: 'add',
path: 'src/components/{{pascalcase name}}/{{pascalcase name}}.test.tsx',
templateFile: 'templates/componentTest.hbs',
},
{
type: 'add',
path: 'src/components/{{pascalcase name}}/{{pascalcase name}}.stories.tsx',
templateFile: 'templates/componentStory.hbs',
},
], // array of actions
});
plop.setHelper('pascalcase', function (str) {
return (' ' + str).toLowerCase().replace(/[^a-zA-Z0-9]+(.)/g, (m, chr) => {
return chr.toUpperCase();
});
});
}