-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplopfile.js
118 lines (114 loc) · 4.21 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
module.exports = (plop) => {
const isNotEmptyFor = (name) => {
return (value) => {
if ((/.+/).test(value)) { return true; }
return name + ' is required';
}
}
plop.addPrompt('directory', require('inquirer-directory'));
plop.setGenerator('service', {
description: 'Create a new service',
prompts: [
{
type: 'input',
name: 'name',
message: 'What is your service name?',
validate: isNotEmptyFor('name')
}
],
actions: [
{
type: 'add',
path: './src/app/common/{{properCase name}}//{{properCase name}}.js',
templateFile: './plopTemplates/service/service.js'
},
{
type: 'add',
path: './src/app/common/{{properCase name}}//{{properCase name}}.service.js',
templateFile: './plopTemplates/service/service.service.js'
}
]
});
plop.setGenerator('component', {
description: 'Create a new component',
prompts: [
{
type: 'input',
name: 'name',
message: 'What is your component name?',
validate: isNotEmptyFor('name')
}
],
actions: [
{
type: 'add',
path: './src/app/components/{{camelCase name}}//{{camelCase name}}.js',
templateFile: './plopTemplates/component/component.js'
},
{
type: 'add',
path: './src/app/components/{{camelCase name}}//{{camelCase name}}.component.js',
templateFile: './plopTemplates/component/component.component.js'
},
{
type: 'add',
path: './src/app/components/{{camelCase name}}//{{camelCase name}}.html',
templateFile: './plopTemplates/component/component.html'
},
{
type: 'add',
path: './src/app/components/{{camelCase name}}//{{camelCase name}}.controller.js',
templateFile: './plopTemplates/component/component.controller.js'
},
{
type: 'add',
path: './src/app/components/{{camelCase name}}//{{camelCase name}}.spec.js',
templateFile: './plopTemplates/component/component.spec.js'
}
]
});
plop.setGenerator('componentWithService', {
description: 'Create a new component with an injected service',
prompts: [
{
type: 'input',
name: 'name',
message: 'What is your component name?',
validate: isNotEmptyFor('name')
},
{
type: 'input',
name: 'serviceName',
message: 'What is your service name?',
validate: isNotEmptyFor('serviceName')
}
],
actions: [
{
type: 'add',
path: './src/app/components/{{camelCase name}}//{{camelCase name}}.js',
templateFile: './plopTemplates/component/component.js'
},
{
type: 'add',
path: './src/app/components/{{camelCase name}}//{{camelCase name}}.component.js',
templateFile: './plopTemplates/component/component.component.js'
},
{
type: 'add',
path: './src/app/components/{{camelCase name}}//{{camelCase name}}.html',
templateFile: './plopTemplates/component/component.html'
},
{
type: 'add',
path: './src/app/components/{{camelCase name}}//{{camelCase name}}.controller.js',
templateFile: './plopTemplates/componentWithService/componentWithService.controller.js'
},
{
type: 'add',
path: './src/app/components/{{camelCase name}}//{{camelCase name}}.spec.js',
templateFile: './plopTemplates/componentWithService/componentWithService.spec.js'
}
]
});
};