forked from growthbook/growthbook
-
Notifications
You must be signed in to change notification settings - Fork 0
/
plopfile.js
90 lines (84 loc) · 2.51 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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
module.exports = function (plop) {
// region Back-end
plop.setGenerator("router", {
description: "[back-end] Generates a router and controller",
prompts: [
{
type: "input",
name: "resource",
message:
"What is the name of the resource? Use the singular form, e.g. event for API GET /event",
},
],
actions: [
{
type: "add",
skipIfExists: true,
path:
"./packages/back-end/src/routers/{{kebabCase resource}}/{{kebabCase resource}}.router.ts",
templateFile: "./plop-templates/back-end/router.hbs",
},
{
type: "add",
skipIfExists: true,
path:
"./packages/back-end/src/routers/{{kebabCase resource}}/{{kebabCase resource}}.controller.ts",
templateFile: "./plop-templates/back-end/controller.hbs",
},
],
});
// endregion Back-end
// region Front-end
plop.setGenerator("component", {
description: "[front-end] Generates a component and a Storybook story",
prompts: [
{
type: "input",
name: "component",
message: "What should the name of the component be?",
},
],
actions: [
{
type: "add",
skipIfExists: true,
path:
"./packages/front-end/components/{{pascalCase component}}/{{pascalCase component}}.tsx",
templateFile: "./plop-templates/front-end/component.hbs",
},
{
type: "add",
skipIfExists: true,
path:
"./packages/front-end/components/{{pascalCase component}}/{{pascalCase component}}.stories.tsx",
templateFile: "./plop-templates/front-end/component-story.hbs",
},
],
});
plop.setGenerator("next-page", {
description: "[front-end] Generates a Next.js page",
prompts: [
{
type: "input",
name: "route",
message:
"What is the path this should live? e.g. settings/webhooks/[eventwebhookid] if you want to create the file settings/webhooks/[eventwebhookid].tsx",
},
{
type: "input",
name: "pageName",
message:
"What is the name of this page? This is used internally in the file and will have a `Page` suffix, e.g. EventWebHookDetail will be EventWebHookDetailPage",
},
],
actions: [
{
type: "add",
skipIfExists: true,
path: "./packages/front-end/pages/{{route}}.tsx",
templateFile: "./plop-templates/front-end/next-page.hbs",
},
],
});
// endregion Front-end
};