-
Notifications
You must be signed in to change notification settings - Fork 2
/
plopfile.mjs
48 lines (48 loc) · 1.46 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
export default function (plop) {
// controller generator
plop.setGenerator("component-boiler-plate", {
description: "Set up component boiler plate code",
prompts: [
{
type: "input",
name: "main-component-name",
message: "Enter the main component name in PascalCase. E.g. Accordion",
filter: value => plop.getHelper('pascalCase')(value),
},
],
actions: [
{
type: "add",
path: "src/components/{{main-component-name}}/index.ts",
templateFile: "plop-templates/index.hbs"
},
{
type: "add",
path: "src/components/{{main-component-name}}/sgds-{{kebabCase main-component-name}}.ts",
templateFile: "plop-templates/component.hbs"
},
{
type: "add",
path: "stories/templates/{{main-component-name}}/basic.js",
templateFile: "plop-templates/basic.hbs"
},
{
type: "add",
path: "test/{{kebabCase main-component-name}}.test.ts",
templateFile: "plop-templates/test.hbs"
},
{
type: 'modify',
path: 'src/components/index.ts',
pattern: /(\/\/ COMPONENT EXPORTS)/g,
template: 'export * from "./{{main-component-name}}/sgds-{{kebabCase main-component-name}}";\n$1',
},
{
type: 'modify',
path: 'src/index.ts',
pattern: /(\/\/ COMPONENT IMPORTS)/g,
template: 'import "./components/{{main-component-name}}";\n$1',
},
]
});
}