-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathplopfile.js
125 lines (125 loc) · 3.16 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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
module.exports = (plop) => {
plop.setGenerator('init', {
description: 'initial setup',
prompts: [
{
type: 'input',
name: 'name',
message: 'press any key to continue...',
},
],
actions: [
{
type: 'add',
path: './src/app.js',
templateFile: 'plop_templates/app.hbs',
},
{
type: 'add',
path: './src/index.js',
templateFile: 'plop_templates/index.hbs',
},
{
type: 'add',
path: './src/.env',
templateFile: 'plop_templates/config.hbs',
},
{
type: 'add',
path: './src/routes/index.js',
templateFile: 'plop_templates/routeIndex.hbs',
},
{
type: 'add',
path: './src/middlewares/error.js',
templateFile: 'plop_templates/error.hbs',
},
{
type: 'add',
path: './src/middlewares/validate.js',
templateFile: 'plop_templates/validateMiddleware.hbs',
},
{
type: 'add',
path: './src/utils/ApiError.js',
templateFile: 'plop_templates/apiError.hbs',
},
{
type: 'add',
path: './src/utils/config.js',
templateFile: 'plop_templates/utilsConfig.hbs',
},
{
type: 'add',
path: './src/utils/deleteFile.js',
templateFile: 'plop_templates/deleteFile.hbs',
},
{
type: 'add',
path: './src/utils/fileUpload.js',
templateFile: 'plop_templates/fileUpload.hbs',
},
{
type: 'add',
path: './src/utils/logger.js',
templateFile: 'plop_templates/logger.hbs',
},
{
type: 'add',
path: './src/utils/toJSON.js',
templateFile: 'plop_templates/toJSON.hbs',
},
],
});
plop.setGenerator('model', {
description:
'generating models with route + controller + service + validator',
prompts: [
{
type: 'input',
name: 'name',
message: 'type name of model',
},
],
actions: [
{
type: 'add',
path: './src/models/{{name}}.model.js',
templateFile: 'plop_templates/schema.hbs',
},
{
type: 'add',
path: './src/controllers/{{name}}.controller.js',
templateFile: 'plop_templates/controller.hbs',
},
{
type: 'add',
path: './src/routes/{{name}}.route.js',
templateFile: 'plop_templates/routes.hbs',
},
{
type: 'add',
path: './src/services/{{name}}.service.js',
templateFile: 'plop_templates/service.hbs',
},
{
type: 'add',
path: './src/validations/{{name}}.validation.js',
templateFile: 'plop_templates/validate.hbs',
},
{
type: 'append',
path: './src/routes/index.js',
templateFile: 'plop_templates/appendRoute.hbs',
pattern: 'Routes_Appending',
},
{
type: 'append',
path: './src/routes/index.js',
templateFile: 'plop_templates/appendRequireRouteFile.hbs',
pattern: 'File_Appending',
},
],
});
plop.setHelper('camel', (txt) => txt.charAt(0).toUpperCase() + txt.slice(1));
};