-
Notifications
You must be signed in to change notification settings - Fork 45
/
plopfile.mjs
47 lines (45 loc) · 1.19 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
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: "Name your resource: ",
},
], // array of inquirer prompts
actions: [
{
type: "add",
path: "src/model/{{snakeCase name}}.model.ts",
templateFile: "templates/model.template.hbs",
},
{
type: "add",
path: "src/service/{{snakeCase name}}.service.ts",
templateFile: "templates/service.template.hbs",
},
{
type: "add",
path: "src/controller/{{snakeCase name}}.controller.ts",
templateFile: "templates/controller.template.hbs",
},
], // array of actions
});
plop.setHelper("titleCase", (str) => {
return str.replace(/\w\S*/g, function (txt) {
return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();
});
});
plop.setHelper("snakeCase", (str) => {
return str
.replace(/\W+/g, " ")
.split(/ |\B(?=[A-Z])/)
.map((word) => word.toLowerCase())
.join("_");
});
}