This repository has been archived by the owner on Jul 14, 2024. It is now read-only.
generated from GabrielGuedess/NestJs-Boilerplate
-
Notifications
You must be signed in to change notification settings - Fork 0
/
plopfile.js
68 lines (64 loc) · 2.32 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
module.exports = function (propTools) {
propTools.setHelper('camelCase', (name) => camelCaseString(name));
propTools.setGenerator('controller', {
description: 'application controller logic',
prompts: [
{
type: 'input',
name: 'entityName',
message: 'entity name please',
},
],
actions: [
{
type: 'add',
path: 'src/infra/database/prisma/services/prismaDTO/{{entityName}}PrismaDto.ts',
templateFile: 'prop-templates/PrismaTemplates/PrismaDTO/prismaDTO.template.hbs',
},
{
type: 'add',
path: 'src/infra/graphql/DTO/{{entityName}}GraphqlDto.ts',
templateFile: 'prop-templates/GraphqlTemplates/GraphqlDTO/graphqlDTO.template.hbs',
},
{
type: 'add',
path: 'src/infra/graphql/entities/{{entityName}}Graphql/{{entityName}}.input.ts',
templateFile: 'prop-templates/GraphqlTemplates/GraphqlEntity/input.template.hbs',
},
{
type: 'add',
path: 'src/infra/graphql/entities/{{entityName}}Graphql/{{entityName}}.model.ts',
templateFile: 'prop-templates/GraphqlTemplates/GraphqlEntity/model.template.hbs',
},
{
type: 'add',
path: 'src/infra/graphql/entities/{{entityName}}Graphql/{{entityName}}.module.ts',
templateFile: 'prop-templates/GraphqlTemplates/GraphqlEntity/module.template.hbs',
},
{
type: 'add',
path: 'src/infra/graphql/entities/{{entityName}}Graphql/{{entityName}}.resolver.ts',
templateFile: 'prop-templates/GraphqlTemplates/GraphqlEntity/resolver.template.hbs',
},
{
type: 'add',
path: 'src/domain/repositories/{{entityName}}.repository.ts',
templateFile: 'prop-templates/repositoryTemplate/repository.template.hbs',
},
{type: 'add',
path: 'src/infra/database/prisma/services/{{entityName}}.service.ts',
templateFile: 'prop-templates/PrismaTemplates/PrismaService/prisma-service.hbs'
}
],
});
}
function camelCaseString(inputString) {
if (inputString === '') {
return inputString;
}
const words = inputString.split(/(?=[A-Z])/);
const camelCaseString = words
.map((word, index) => (index === 0 ? word.toLowerCase() : word.charAt(0).toUpperCase() + word.slice(1).toLowerCase()))
.join('');
return camelCaseString;
}