-
Notifications
You must be signed in to change notification settings - Fork 2
/
plopfile.mjs
63 lines (63 loc) · 2 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
53
54
55
56
57
58
59
60
61
62
63
// eslint-disable-next-line import/no-default-export
export default function (plop) {
plop.setGenerator("component", {
description: "Scaffold out a new component",
prompts: [
{
type: "input",
name: "name",
message: "What do you want to name this component?",
},
{
type: "input",
name: "description",
message: "What is the description for this component?",
},
{
type: "confirm",
name: "styles",
message: "Do you want to add a file for styles?",
},
],
actions: [
{
type: "add",
path: "packages/components/src/components/{{dashCase name}}/index.ts",
templateFile: ".plop-templates/component/index.ts.hbs",
skipIfExists: true,
},
{
type: "add",
path: "packages/components/src/components/{{dashCase name}}/src/index.tsx",
templateFile: ".plop-templates/component/src/index.tsx.hbs",
skipIfExists: true,
},
{
type: "add",
path: "packages/components/src/components/{{dashCase name}}/__tests__/{{dashCase name}}.test.tsx",
templateFile: ".plop-templates/component/__tests__/test.tsx.hbs",
skipIfExists: true,
},
{
type: "add",
path: "packages/components/src/components/{{dashCase name}}/stories/index.stories.tsx",
templateFile: ".plop-templates/component/stories/index.tsx.hbs",
skipIfExists: true,
},
{
type: "add",
path: "packages/components/src/components/{{dashCase name}}/src/styles.ts",
templateFile: ".plop-templates/component/src/styles.ts.hbs",
skip: (data) => (data.styles ? undefined : "Does not need styles file"),
skipIfExists: true,
},
{
type: "modify",
path: "packages/components/src/index.ts",
pattern: /(\/\/ COMPONENT EXPORTS)/g,
template: 'export * from "./components/{{dashCase name}}";\n$1',
unique: true,
},
],
});
}