@strapi/generators 5.9.0 → 5.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +33 -60
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +32 -38
- package/dist/index.mjs.map +1 -1
- package/dist/plopfile.js +622 -551
- package/dist/plopfile.js.map +1 -1
- package/dist/plopfile.mjs +621 -548
- package/dist/plopfile.mjs.map +1 -1
- package/package.json +9 -8
package/dist/plopfile.js
CHANGED
|
@@ -1,586 +1,657 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
const
|
|
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
|
-
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var pluralize = require('pluralize');
|
|
4
|
+
var path = require('path');
|
|
5
|
+
var fs = require('fs-extra');
|
|
6
|
+
var tsUtils = require('@strapi/typescript-utils');
|
|
7
|
+
var slugify = require('@sindresorhus/slugify');
|
|
8
|
+
var utils = require('@strapi/utils');
|
|
9
|
+
|
|
10
|
+
var validateInput = ((input)=>{
|
|
11
|
+
const regex = /^[A-Za-z-]+$/g;
|
|
12
|
+
if (!input) {
|
|
13
|
+
return 'You must provide an input';
|
|
14
|
+
}
|
|
15
|
+
return regex.test(input) || "Please use only letters, '-' and no spaces";
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
var generateApi = ((plop)=>{
|
|
19
|
+
// API generator
|
|
20
|
+
plop.setGenerator('api', {
|
|
21
|
+
description: 'Generate a basic API',
|
|
22
|
+
prompts: [
|
|
23
|
+
{
|
|
24
|
+
type: 'input',
|
|
25
|
+
name: 'id',
|
|
26
|
+
message: 'API name',
|
|
27
|
+
validate: (input)=>validateInput(input)
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
type: 'confirm',
|
|
31
|
+
name: 'isPluginApi',
|
|
32
|
+
message: 'Is this API for a plugin?'
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
when: (answers)=>answers.isPluginApi,
|
|
36
|
+
type: 'list',
|
|
37
|
+
name: 'plugin',
|
|
38
|
+
message: 'Plugin name',
|
|
39
|
+
async choices () {
|
|
40
|
+
const pluginsPath = path.join(plop.getDestBasePath(), 'plugins');
|
|
41
|
+
const exists = await fs.pathExists(pluginsPath);
|
|
42
|
+
if (!exists) {
|
|
43
|
+
throw Error('Couldn\'t find a "plugins" directory');
|
|
44
|
+
}
|
|
45
|
+
const pluginsDir = await fs.readdir(pluginsPath, {
|
|
46
|
+
withFileTypes: true
|
|
47
|
+
});
|
|
48
|
+
const pluginsDirContent = pluginsDir.filter((fd)=>fd.isDirectory());
|
|
49
|
+
if (pluginsDirContent.length === 0) {
|
|
50
|
+
throw Error('The "plugins" directory is empty');
|
|
51
|
+
}
|
|
52
|
+
return pluginsDirContent;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
],
|
|
56
|
+
actions (answers) {
|
|
57
|
+
if (!answers) {
|
|
58
|
+
return [];
|
|
59
|
+
}
|
|
60
|
+
const filePath = answers.isPluginApi && answers.plugin ? 'plugins/{{ plugin }}/server' : 'api/{{ id }}';
|
|
61
|
+
const currentDir = process.cwd();
|
|
62
|
+
const language = tsUtils.isUsingTypeScriptSync(currentDir) ? 'ts' : 'js';
|
|
63
|
+
const baseActions = [
|
|
64
|
+
{
|
|
65
|
+
type: 'add',
|
|
66
|
+
path: `${filePath}/controllers/{{ id }}.${language}`,
|
|
67
|
+
templateFile: `templates/${language}/controller.${language}.hbs`
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
type: 'add',
|
|
71
|
+
path: `${filePath}/services/{{ id }}.${language}`,
|
|
72
|
+
templateFile: `templates/${language}/service.${language}.hbs`
|
|
73
|
+
}
|
|
74
|
+
];
|
|
75
|
+
if (answers.isPluginApi) {
|
|
76
|
+
return baseActions;
|
|
77
|
+
}
|
|
78
|
+
return [
|
|
79
|
+
{
|
|
80
|
+
type: 'add',
|
|
81
|
+
path: `${filePath}/routes/{{ id }}.${language}`,
|
|
82
|
+
templateFile: `templates/${language}/single-route.${language}.hbs`
|
|
83
|
+
},
|
|
84
|
+
...baseActions
|
|
85
|
+
];
|
|
52
86
|
}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
}
|
|
59
|
-
const filePath = answers.isPluginApi && answers.plugin ? "plugins/{{ plugin }}/server" : "api/{{ id }}";
|
|
60
|
-
const currentDir = process.cwd();
|
|
61
|
-
const language = tsUtils__default.default.isUsingTypeScriptSync(currentDir) ? "ts" : "js";
|
|
62
|
-
const baseActions = [
|
|
87
|
+
});
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
var getDestinationPrompts = ((action, basePath, { rootFolder = false } = {})=>{
|
|
91
|
+
return [
|
|
63
92
|
{
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
93
|
+
type: 'list',
|
|
94
|
+
name: 'destination',
|
|
95
|
+
message: `Where do you want to add this ${action}?`,
|
|
96
|
+
choices: [
|
|
97
|
+
...rootFolder ? [
|
|
98
|
+
{
|
|
99
|
+
name: `Add ${action} to root of project`,
|
|
100
|
+
value: 'root'
|
|
101
|
+
}
|
|
102
|
+
] : [
|
|
103
|
+
{
|
|
104
|
+
name: `Add ${action} to new API`,
|
|
105
|
+
value: 'new'
|
|
106
|
+
}
|
|
107
|
+
],
|
|
108
|
+
{
|
|
109
|
+
name: `Add ${action} to an existing API`,
|
|
110
|
+
value: 'api'
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
name: `Add ${action} to an existing plugin`,
|
|
114
|
+
value: 'plugin'
|
|
115
|
+
}
|
|
116
|
+
]
|
|
67
117
|
},
|
|
68
118
|
{
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
119
|
+
when: (answers)=>answers.destination === 'api',
|
|
120
|
+
type: 'list',
|
|
121
|
+
message: 'Which API is this for?',
|
|
122
|
+
name: 'api',
|
|
123
|
+
async choices () {
|
|
124
|
+
const apiPath = path.join(basePath, 'api');
|
|
125
|
+
const exists = await fs.pathExists(apiPath);
|
|
126
|
+
if (!exists) {
|
|
127
|
+
throw Error('Couldn\'t find an "api" directory');
|
|
128
|
+
}
|
|
129
|
+
const apiDir = await fs.readdir(apiPath, {
|
|
130
|
+
withFileTypes: true
|
|
131
|
+
});
|
|
132
|
+
const apiDirContent = apiDir.filter((fd)=>fd.isDirectory());
|
|
133
|
+
if (apiDirContent.length === 0) {
|
|
134
|
+
throw Error('The "api" directory is empty');
|
|
135
|
+
}
|
|
136
|
+
return apiDirContent;
|
|
137
|
+
}
|
|
82
138
|
},
|
|
83
|
-
|
|
84
|
-
|
|
139
|
+
{
|
|
140
|
+
when: (answers)=>answers.destination === 'plugin',
|
|
141
|
+
type: 'list',
|
|
142
|
+
message: 'Which plugin is this for?',
|
|
143
|
+
name: 'plugin',
|
|
144
|
+
async choices () {
|
|
145
|
+
const pluginsPath = path.join(basePath, 'plugins');
|
|
146
|
+
const exists = await fs.pathExists(pluginsPath);
|
|
147
|
+
if (!exists) {
|
|
148
|
+
throw Error('Couldn\'t find a "plugins" directory');
|
|
149
|
+
}
|
|
150
|
+
const pluginsDir = await fs.readdir(pluginsPath);
|
|
151
|
+
const pluginsDirContent = pluginsDir.filter((api)=>fs.lstatSync(path.join(pluginsPath, api)).isDirectory());
|
|
152
|
+
if (pluginsDirContent.length === 0) {
|
|
153
|
+
throw Error('The "plugins" directory is empty');
|
|
154
|
+
}
|
|
155
|
+
return pluginsDirContent;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
];
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
var getFilePath = ((destination)=>{
|
|
162
|
+
if (destination === 'api') {
|
|
163
|
+
return `api/{{ api }}`;
|
|
85
164
|
}
|
|
86
|
-
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
165
|
+
if (destination === 'plugin') {
|
|
166
|
+
return `plugins/{{ plugin }}/server`;
|
|
167
|
+
}
|
|
168
|
+
if (destination === 'root') {
|
|
169
|
+
return './';
|
|
170
|
+
}
|
|
171
|
+
return `api/{{ id }}`;
|
|
172
|
+
});
|
|
173
|
+
|
|
174
|
+
var generateController = ((plop)=>{
|
|
175
|
+
// Controller generator
|
|
176
|
+
plop.setGenerator('controller', {
|
|
177
|
+
description: 'Generate a controller for an API',
|
|
178
|
+
prompts: [
|
|
179
|
+
{
|
|
180
|
+
type: 'input',
|
|
181
|
+
name: 'id',
|
|
182
|
+
message: 'Controller name',
|
|
183
|
+
validate: (input)=>validateInput(input)
|
|
184
|
+
},
|
|
185
|
+
...getDestinationPrompts('controller', plop.getDestBasePath())
|
|
105
186
|
],
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
187
|
+
actions (answers) {
|
|
188
|
+
if (!answers) {
|
|
189
|
+
return [];
|
|
190
|
+
}
|
|
191
|
+
const filePath = getFilePath(answers.destination);
|
|
192
|
+
const currentDir = process.cwd();
|
|
193
|
+
const language = tsUtils.isUsingTypeScriptSync(currentDir) ? 'ts' : 'js';
|
|
194
|
+
return [
|
|
195
|
+
{
|
|
196
|
+
type: 'add',
|
|
197
|
+
path: `${filePath}/controllers/{{ id }}.${language}`,
|
|
198
|
+
templateFile: `templates/${language}/controller.${language}.hbs`
|
|
199
|
+
}
|
|
200
|
+
];
|
|
201
|
+
}
|
|
202
|
+
});
|
|
203
|
+
});
|
|
204
|
+
|
|
205
|
+
const questions$2 = [
|
|
206
|
+
{
|
|
207
|
+
type: 'input',
|
|
208
|
+
name: 'displayName',
|
|
209
|
+
message: 'Content type display name',
|
|
210
|
+
validate: (input)=>!!input
|
|
109
211
|
},
|
|
110
212
|
{
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
}
|
|
121
|
-
const apiDir = await fs__default.default.readdir(apiPath, { withFileTypes: true });
|
|
122
|
-
const apiDirContent = apiDir.filter((fd) => fd.isDirectory());
|
|
123
|
-
if (apiDirContent.length === 0) {
|
|
124
|
-
throw Error('The "api" directory is empty');
|
|
213
|
+
type: 'input',
|
|
214
|
+
name: 'singularName',
|
|
215
|
+
message: 'Content type singular name',
|
|
216
|
+
default: (answers)=>slugify(answers.displayName),
|
|
217
|
+
validate (input) {
|
|
218
|
+
if (!utils.strings.isKebabCase(input)) {
|
|
219
|
+
return 'Value must be in kebab-case';
|
|
220
|
+
}
|
|
221
|
+
return true;
|
|
125
222
|
}
|
|
126
|
-
return apiDirContent;
|
|
127
|
-
}
|
|
128
223
|
},
|
|
129
224
|
{
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
(api) => fs__default.default.lstatSync(path.join(pluginsPath, api)).isDirectory()
|
|
143
|
-
);
|
|
144
|
-
if (pluginsDirContent.length === 0) {
|
|
145
|
-
throw Error('The "plugins" directory is empty');
|
|
146
|
-
}
|
|
147
|
-
return pluginsDirContent;
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
];
|
|
151
|
-
};
|
|
152
|
-
const getFilePath = (destination) => {
|
|
153
|
-
if (destination === "api") {
|
|
154
|
-
return `api/{{ api }}`;
|
|
155
|
-
}
|
|
156
|
-
if (destination === "plugin") {
|
|
157
|
-
return `plugins/{{ plugin }}/server`;
|
|
158
|
-
}
|
|
159
|
-
if (destination === "root") {
|
|
160
|
-
return "./";
|
|
161
|
-
}
|
|
162
|
-
return `api/{{ id }}`;
|
|
163
|
-
};
|
|
164
|
-
const generateController = (plop) => {
|
|
165
|
-
plop.setGenerator("controller", {
|
|
166
|
-
description: "Generate a controller for an API",
|
|
167
|
-
prompts: [
|
|
168
|
-
{
|
|
169
|
-
type: "input",
|
|
170
|
-
name: "id",
|
|
171
|
-
message: "Controller name",
|
|
172
|
-
validate: (input) => validateInput(input)
|
|
173
|
-
},
|
|
174
|
-
...getDestinationPrompts("controller", plop.getDestBasePath())
|
|
175
|
-
],
|
|
176
|
-
actions(answers) {
|
|
177
|
-
if (!answers) {
|
|
178
|
-
return [];
|
|
179
|
-
}
|
|
180
|
-
const filePath = getFilePath(answers.destination);
|
|
181
|
-
const currentDir = process.cwd();
|
|
182
|
-
const language = tsUtils__default.default.isUsingTypeScriptSync(currentDir) ? "ts" : "js";
|
|
183
|
-
return [
|
|
184
|
-
{
|
|
185
|
-
type: "add",
|
|
186
|
-
path: `${filePath}/controllers/{{ id }}.${language}`,
|
|
187
|
-
templateFile: `templates/${language}/controller.${language}.hbs`
|
|
225
|
+
type: 'input',
|
|
226
|
+
name: 'pluralName',
|
|
227
|
+
message: 'Content type plural name',
|
|
228
|
+
default: (answers)=>pluralize(answers.singularName),
|
|
229
|
+
validate (input, answers) {
|
|
230
|
+
if (answers.singularName === input) {
|
|
231
|
+
return 'Singular and plural names cannot be the same';
|
|
232
|
+
}
|
|
233
|
+
if (!utils.strings.isKebabCase(input)) {
|
|
234
|
+
return 'Value must be in kebab-case';
|
|
235
|
+
}
|
|
236
|
+
return true;
|
|
188
237
|
}
|
|
189
|
-
];
|
|
190
|
-
}
|
|
191
|
-
});
|
|
192
|
-
};
|
|
193
|
-
const questions$2 = [
|
|
194
|
-
{
|
|
195
|
-
type: "input",
|
|
196
|
-
name: "displayName",
|
|
197
|
-
message: "Content type display name",
|
|
198
|
-
validate: (input) => !!input
|
|
199
|
-
},
|
|
200
|
-
{
|
|
201
|
-
type: "input",
|
|
202
|
-
name: "singularName",
|
|
203
|
-
message: "Content type singular name",
|
|
204
|
-
default: (answers) => slugify__default.default(answers.displayName),
|
|
205
|
-
validate(input) {
|
|
206
|
-
if (!utils.strings.isKebabCase(input)) {
|
|
207
|
-
return "Value must be in kebab-case";
|
|
208
|
-
}
|
|
209
|
-
return true;
|
|
210
|
-
}
|
|
211
|
-
},
|
|
212
|
-
{
|
|
213
|
-
type: "input",
|
|
214
|
-
name: "pluralName",
|
|
215
|
-
message: "Content type plural name",
|
|
216
|
-
default: (answers) => pluralize__default.default(answers.singularName),
|
|
217
|
-
validate(input, answers) {
|
|
218
|
-
if (answers.singularName === input) {
|
|
219
|
-
return "Singular and plural names cannot be the same";
|
|
220
|
-
}
|
|
221
|
-
if (!utils.strings.isKebabCase(input)) {
|
|
222
|
-
return "Value must be in kebab-case";
|
|
223
|
-
}
|
|
224
|
-
return true;
|
|
225
238
|
}
|
|
226
|
-
}
|
|
227
239
|
];
|
|
240
|
+
|
|
228
241
|
const questions$1 = [
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
242
|
+
{
|
|
243
|
+
type: 'list',
|
|
244
|
+
name: 'kind',
|
|
245
|
+
message: 'Please choose the model type',
|
|
246
|
+
default: 'collectionType',
|
|
247
|
+
choices: [
|
|
248
|
+
{
|
|
249
|
+
name: 'Collection Type',
|
|
250
|
+
value: 'collectionType'
|
|
251
|
+
},
|
|
252
|
+
{
|
|
253
|
+
name: 'Single Type',
|
|
254
|
+
value: 'singleType'
|
|
255
|
+
}
|
|
256
|
+
],
|
|
257
|
+
validate: (input)=>validateInput(input)
|
|
258
|
+
}
|
|
240
259
|
];
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
260
|
+
|
|
261
|
+
var validateAttributeInput = ((input)=>{
|
|
262
|
+
const regex = /^[A-Za-z-|_]+$/g;
|
|
263
|
+
if (!input) {
|
|
264
|
+
return 'You must provide an input';
|
|
265
|
+
}
|
|
266
|
+
return regex.test(input) || "Please use only letters, '-', '_', and no spaces";
|
|
267
|
+
});
|
|
268
|
+
|
|
248
269
|
const DEFAULT_TYPES = [
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
270
|
+
// advanced types
|
|
271
|
+
'media',
|
|
272
|
+
// scalar types
|
|
273
|
+
'string',
|
|
274
|
+
'text',
|
|
275
|
+
'richtext',
|
|
276
|
+
'json',
|
|
277
|
+
'enumeration',
|
|
278
|
+
'password',
|
|
279
|
+
'email',
|
|
280
|
+
'integer',
|
|
281
|
+
'biginteger',
|
|
282
|
+
'float',
|
|
283
|
+
'decimal',
|
|
284
|
+
'date',
|
|
285
|
+
'time',
|
|
286
|
+
'datetime',
|
|
287
|
+
'timestamp',
|
|
288
|
+
'boolean'
|
|
268
289
|
];
|
|
269
|
-
const getAttributesPrompts = async (inquirer)
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
]);
|
|
277
|
-
const attributes = [];
|
|
278
|
-
const createNewAttributes = async (inquirer2) => {
|
|
279
|
-
const answers = await inquirer2.prompt([
|
|
280
|
-
{
|
|
281
|
-
type: "input",
|
|
282
|
-
name: "attributeName",
|
|
283
|
-
message: "Name of attribute",
|
|
284
|
-
validate: (input) => validateAttributeInput(input)
|
|
285
|
-
},
|
|
286
|
-
{
|
|
287
|
-
type: "list",
|
|
288
|
-
name: "attributeType",
|
|
289
|
-
message: "What type of attribute",
|
|
290
|
-
pageSize: DEFAULT_TYPES.length,
|
|
291
|
-
choices: DEFAULT_TYPES.map((type) => {
|
|
292
|
-
return { name: type, value: type };
|
|
293
|
-
})
|
|
294
|
-
},
|
|
295
|
-
{
|
|
296
|
-
when: (answers2) => answers2.attributeType === "enumeration",
|
|
297
|
-
type: "input",
|
|
298
|
-
name: "enum",
|
|
299
|
-
message: "Add values separated by a comma"
|
|
300
|
-
},
|
|
301
|
-
{
|
|
302
|
-
when: (answers2) => answers2.attributeType === "media",
|
|
303
|
-
type: "list",
|
|
304
|
-
name: "multiple",
|
|
305
|
-
message: "Choose media type",
|
|
306
|
-
choices: [
|
|
307
|
-
{ name: "Multiple", value: true },
|
|
308
|
-
{ name: "Single", value: false }
|
|
309
|
-
]
|
|
310
|
-
},
|
|
311
|
-
{
|
|
312
|
-
type: "confirm",
|
|
313
|
-
name: "addAttributes",
|
|
314
|
-
message: "Do you want to add another attribute?"
|
|
315
|
-
}
|
|
290
|
+
const getAttributesPrompts = async (inquirer)=>{
|
|
291
|
+
const { addAttributes } = await inquirer.prompt([
|
|
292
|
+
{
|
|
293
|
+
type: 'confirm',
|
|
294
|
+
name: 'addAttributes',
|
|
295
|
+
message: 'Do you want to add attributes?'
|
|
296
|
+
}
|
|
316
297
|
]);
|
|
317
|
-
attributes
|
|
318
|
-
|
|
319
|
-
|
|
298
|
+
const attributes = [];
|
|
299
|
+
/**
|
|
300
|
+
* @param {import('inquirer').Inquirer} inquirer
|
|
301
|
+
* @returns {Promise<void>}
|
|
302
|
+
*/ const createNewAttributes = async (inquirer)=>{
|
|
303
|
+
const answers = await inquirer.prompt([
|
|
304
|
+
{
|
|
305
|
+
type: 'input',
|
|
306
|
+
name: 'attributeName',
|
|
307
|
+
message: 'Name of attribute',
|
|
308
|
+
validate: (input)=>validateAttributeInput(input)
|
|
309
|
+
},
|
|
310
|
+
{
|
|
311
|
+
type: 'list',
|
|
312
|
+
name: 'attributeType',
|
|
313
|
+
message: 'What type of attribute',
|
|
314
|
+
pageSize: DEFAULT_TYPES.length,
|
|
315
|
+
choices: DEFAULT_TYPES.map((type)=>{
|
|
316
|
+
return {
|
|
317
|
+
name: type,
|
|
318
|
+
value: type
|
|
319
|
+
};
|
|
320
|
+
})
|
|
321
|
+
},
|
|
322
|
+
{
|
|
323
|
+
when: (answers)=>answers.attributeType === 'enumeration',
|
|
324
|
+
type: 'input',
|
|
325
|
+
name: 'enum',
|
|
326
|
+
message: 'Add values separated by a comma'
|
|
327
|
+
},
|
|
328
|
+
{
|
|
329
|
+
when: (answers)=>answers.attributeType === 'media',
|
|
330
|
+
type: 'list',
|
|
331
|
+
name: 'multiple',
|
|
332
|
+
message: 'Choose media type',
|
|
333
|
+
choices: [
|
|
334
|
+
{
|
|
335
|
+
name: 'Multiple',
|
|
336
|
+
value: true
|
|
337
|
+
},
|
|
338
|
+
{
|
|
339
|
+
name: 'Single',
|
|
340
|
+
value: false
|
|
341
|
+
}
|
|
342
|
+
]
|
|
343
|
+
},
|
|
344
|
+
{
|
|
345
|
+
type: 'confirm',
|
|
346
|
+
name: 'addAttributes',
|
|
347
|
+
message: 'Do you want to add another attribute?'
|
|
348
|
+
}
|
|
349
|
+
]);
|
|
350
|
+
attributes.push(answers);
|
|
351
|
+
if (!answers.addAttributes) {
|
|
352
|
+
return;
|
|
353
|
+
}
|
|
354
|
+
await createNewAttributes(inquirer);
|
|
355
|
+
};
|
|
356
|
+
if (addAttributes) {
|
|
357
|
+
await createNewAttributes(inquirer);
|
|
358
|
+
} else {
|
|
359
|
+
console.warn(`You won't be able to manage entries from the admin, you can still add attributes later from the content type builder.`);
|
|
320
360
|
}
|
|
321
|
-
|
|
322
|
-
};
|
|
323
|
-
if (addAttributes) {
|
|
324
|
-
await createNewAttributes(inquirer);
|
|
325
|
-
} else {
|
|
326
|
-
console.warn(
|
|
327
|
-
`You won't be able to manage entries from the admin, you can still add attributes later from the content type builder.`
|
|
328
|
-
);
|
|
329
|
-
}
|
|
330
|
-
return attributes;
|
|
361
|
+
return attributes;
|
|
331
362
|
};
|
|
363
|
+
|
|
332
364
|
const questions = [
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
365
|
+
{
|
|
366
|
+
type: 'confirm',
|
|
367
|
+
name: 'bootstrapApi',
|
|
368
|
+
default: true,
|
|
369
|
+
message: 'Bootstrap API related files?'
|
|
370
|
+
}
|
|
339
371
|
];
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
372
|
+
|
|
373
|
+
var generateContentType = ((plop)=>{
|
|
374
|
+
// Model generator
|
|
375
|
+
plop.setGenerator('content-type', {
|
|
376
|
+
description: 'Generate a content type for an API',
|
|
377
|
+
async prompts (inquirer) {
|
|
378
|
+
const config = await inquirer.prompt([
|
|
379
|
+
...questions$2,
|
|
380
|
+
...questions$1
|
|
381
|
+
]);
|
|
382
|
+
// @ts-expect-error issue with deprecated inquirer.prompts attribute to fix with ugprade to inquirer
|
|
383
|
+
const attributes = await getAttributesPrompts(inquirer);
|
|
384
|
+
const api = await inquirer.prompt([
|
|
385
|
+
...getDestinationPrompts('model', plop.getDestBasePath()),
|
|
386
|
+
{
|
|
387
|
+
when: (answers)=>answers.destination === 'new',
|
|
388
|
+
type: 'input',
|
|
389
|
+
name: 'id',
|
|
390
|
+
default: config.singularName,
|
|
391
|
+
message: 'Name of the new API?',
|
|
392
|
+
async validate (input) {
|
|
393
|
+
if (!utils.strings.isKebabCase(input)) {
|
|
394
|
+
return 'Value must be in kebab-case';
|
|
395
|
+
}
|
|
396
|
+
const apiPath = path.join(plop.getDestBasePath(), 'api');
|
|
397
|
+
const exists = await fs.pathExists(apiPath);
|
|
398
|
+
if (!exists) {
|
|
399
|
+
return true;
|
|
400
|
+
}
|
|
401
|
+
const apiDir = await fs.readdir(apiPath, {
|
|
402
|
+
withFileTypes: true
|
|
403
|
+
});
|
|
404
|
+
const apiDirContent = apiDir.filter((fd)=>fd.isDirectory());
|
|
405
|
+
if (apiDirContent.findIndex((dir)=>dir.name === input) !== -1) {
|
|
406
|
+
throw new Error('This name is already taken.');
|
|
407
|
+
}
|
|
408
|
+
return true;
|
|
409
|
+
}
|
|
410
|
+
},
|
|
411
|
+
...questions
|
|
412
|
+
]);
|
|
413
|
+
return {
|
|
414
|
+
...config,
|
|
415
|
+
...api,
|
|
416
|
+
attributes
|
|
417
|
+
};
|
|
418
|
+
},
|
|
419
|
+
actions (answers) {
|
|
420
|
+
if (!answers) {
|
|
421
|
+
return [];
|
|
357
422
|
}
|
|
358
|
-
const
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
423
|
+
const attributes = answers.attributes.reduce((object, answer)=>{
|
|
424
|
+
const val = {
|
|
425
|
+
type: answer.attributeType
|
|
426
|
+
};
|
|
427
|
+
if (answer.attributeType === 'enumeration') {
|
|
428
|
+
val.enum = answer.enum.split(',').map((item)=>item.trim());
|
|
429
|
+
}
|
|
430
|
+
if (answer.attributeType === 'media') {
|
|
431
|
+
val.allowedTypes = [
|
|
432
|
+
'images',
|
|
433
|
+
'files',
|
|
434
|
+
'videos',
|
|
435
|
+
'audios'
|
|
436
|
+
];
|
|
437
|
+
val.multiple = answer.multiple;
|
|
438
|
+
}
|
|
439
|
+
return Object.assign(object, {
|
|
440
|
+
[answer.attributeName]: val
|
|
441
|
+
}, {});
|
|
442
|
+
}, {});
|
|
443
|
+
const filePath = getFilePath(answers.destination);
|
|
444
|
+
const currentDir = process.cwd();
|
|
445
|
+
const language = tsUtils.isUsingTypeScriptSync(currentDir) ? 'ts' : 'js';
|
|
446
|
+
const baseActions = [
|
|
447
|
+
{
|
|
448
|
+
type: 'add',
|
|
449
|
+
path: `${filePath}/content-types/{{ singularName }}/schema.json`,
|
|
450
|
+
templateFile: `templates/${language}/content-type.schema.json.hbs`,
|
|
451
|
+
data: {
|
|
452
|
+
collectionName: slugify(answers.pluralName, {
|
|
453
|
+
separator: '_'
|
|
454
|
+
})
|
|
455
|
+
}
|
|
456
|
+
}
|
|
457
|
+
];
|
|
458
|
+
if (Object.entries(attributes).length > 0) {
|
|
459
|
+
baseActions.push({
|
|
460
|
+
type: 'modify',
|
|
461
|
+
path: `${filePath}/content-types/{{ singularName }}/schema.json`,
|
|
462
|
+
transform (template) {
|
|
463
|
+
const parsedTemplate = JSON.parse(template);
|
|
464
|
+
parsedTemplate.attributes = attributes;
|
|
465
|
+
return JSON.stringify(parsedTemplate, null, 2);
|
|
466
|
+
}
|
|
467
|
+
});
|
|
362
468
|
}
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
469
|
+
if (answers.bootstrapApi) {
|
|
470
|
+
const { singularName } = answers;
|
|
471
|
+
let uid;
|
|
472
|
+
if (answers.destination === 'new') {
|
|
473
|
+
uid = `api::${answers.id}.${singularName}`;
|
|
474
|
+
} else if (answers.api) {
|
|
475
|
+
uid = `api::${answers.api}.${singularName}`;
|
|
476
|
+
} else if (answers.plugin) {
|
|
477
|
+
uid = `plugin::${answers.plugin}.${singularName}`;
|
|
478
|
+
}
|
|
479
|
+
baseActions.push({
|
|
480
|
+
type: 'add',
|
|
481
|
+
path: `${filePath}/controllers/{{ singularName }}.${language}`,
|
|
482
|
+
templateFile: `templates/${language}/core-controller.${language}.hbs`,
|
|
483
|
+
data: {
|
|
484
|
+
uid
|
|
485
|
+
}
|
|
486
|
+
}, {
|
|
487
|
+
type: 'add',
|
|
488
|
+
path: `${filePath}/services/{{ singularName }}.${language}`,
|
|
489
|
+
templateFile: `templates/${language}/core-service.${language}.hbs`,
|
|
490
|
+
data: {
|
|
491
|
+
uid
|
|
492
|
+
}
|
|
493
|
+
}, {
|
|
494
|
+
type: 'add',
|
|
495
|
+
path: `${filePath}/routes/{{ singularName }}.${language}`,
|
|
496
|
+
templateFile: `templates/${language}/core-router.${language}.hbs`,
|
|
497
|
+
data: {
|
|
498
|
+
uid
|
|
499
|
+
}
|
|
500
|
+
});
|
|
367
501
|
}
|
|
368
|
-
return
|
|
369
|
-
}
|
|
370
|
-
},
|
|
371
|
-
...questions
|
|
372
|
-
]);
|
|
373
|
-
return {
|
|
374
|
-
...config,
|
|
375
|
-
...api,
|
|
376
|
-
attributes
|
|
377
|
-
};
|
|
378
|
-
},
|
|
379
|
-
actions(answers) {
|
|
380
|
-
if (!answers) {
|
|
381
|
-
return [];
|
|
382
|
-
}
|
|
383
|
-
const attributes = answers.attributes.reduce((object, answer) => {
|
|
384
|
-
const val = { type: answer.attributeType };
|
|
385
|
-
if (answer.attributeType === "enumeration") {
|
|
386
|
-
val.enum = answer.enum.split(",").map((item) => item.trim());
|
|
387
|
-
}
|
|
388
|
-
if (answer.attributeType === "media") {
|
|
389
|
-
val.allowedTypes = ["images", "files", "videos", "audios"];
|
|
390
|
-
val.multiple = answer.multiple;
|
|
502
|
+
return baseActions;
|
|
391
503
|
}
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
uid = `api::${answers.api}.${singularName}`;
|
|
425
|
-
} else if (answers.plugin) {
|
|
426
|
-
uid = `plugin::${answers.plugin}.${singularName}`;
|
|
427
|
-
}
|
|
428
|
-
baseActions.push(
|
|
429
|
-
{
|
|
430
|
-
type: "add",
|
|
431
|
-
path: `${filePath}/controllers/{{ singularName }}.${language}`,
|
|
432
|
-
templateFile: `templates/${language}/core-controller.${language}.hbs`,
|
|
433
|
-
data: { uid }
|
|
434
|
-
},
|
|
435
|
-
{
|
|
436
|
-
type: "add",
|
|
437
|
-
path: `${filePath}/services/{{ singularName }}.${language}`,
|
|
438
|
-
templateFile: `templates/${language}/core-service.${language}.hbs`,
|
|
439
|
-
data: { uid }
|
|
440
|
-
},
|
|
441
|
-
{
|
|
442
|
-
type: "add",
|
|
443
|
-
path: `${filePath}/routes/{{ singularName }}.${language}`,
|
|
444
|
-
templateFile: `templates/${language}/core-router.${language}.hbs`,
|
|
445
|
-
data: { uid }
|
|
446
|
-
}
|
|
447
|
-
);
|
|
448
|
-
}
|
|
449
|
-
return baseActions;
|
|
450
|
-
}
|
|
451
|
-
});
|
|
452
|
-
};
|
|
453
|
-
const generatePolicy = (plop) => {
|
|
454
|
-
plop.setGenerator("policy", {
|
|
455
|
-
description: "Generate a policy for an API",
|
|
456
|
-
prompts: [
|
|
457
|
-
{
|
|
458
|
-
type: "input",
|
|
459
|
-
name: "id",
|
|
460
|
-
message: "Policy name",
|
|
461
|
-
validate: (input) => validateInput(input)
|
|
462
|
-
},
|
|
463
|
-
...getDestinationPrompts("policy", plop.getDestBasePath(), { rootFolder: true })
|
|
464
|
-
],
|
|
465
|
-
actions(answers) {
|
|
466
|
-
if (!answers) {
|
|
467
|
-
return [];
|
|
468
|
-
}
|
|
469
|
-
const currentDir = process.cwd();
|
|
470
|
-
const filePath = getFilePath(answers.destination);
|
|
471
|
-
const language = tsUtils__default.default.isUsingTypeScriptSync(currentDir) ? "ts" : "js";
|
|
472
|
-
return [
|
|
473
|
-
{
|
|
474
|
-
type: "add",
|
|
475
|
-
path: `${filePath}/policies/{{ id }}.${language}`,
|
|
476
|
-
templateFile: `templates/${language}/policy.${language}.hbs`
|
|
504
|
+
});
|
|
505
|
+
});
|
|
506
|
+
|
|
507
|
+
var generatePolicy = ((plop)=>{
|
|
508
|
+
// Policy generator
|
|
509
|
+
plop.setGenerator('policy', {
|
|
510
|
+
description: 'Generate a policy for an API',
|
|
511
|
+
prompts: [
|
|
512
|
+
{
|
|
513
|
+
type: 'input',
|
|
514
|
+
name: 'id',
|
|
515
|
+
message: 'Policy name',
|
|
516
|
+
validate: (input)=>validateInput(input)
|
|
517
|
+
},
|
|
518
|
+
...getDestinationPrompts('policy', plop.getDestBasePath(), {
|
|
519
|
+
rootFolder: true
|
|
520
|
+
})
|
|
521
|
+
],
|
|
522
|
+
actions (answers) {
|
|
523
|
+
if (!answers) {
|
|
524
|
+
return [];
|
|
525
|
+
}
|
|
526
|
+
const currentDir = process.cwd();
|
|
527
|
+
const filePath = getFilePath(answers.destination);
|
|
528
|
+
const language = tsUtils.isUsingTypeScriptSync(currentDir) ? 'ts' : 'js';
|
|
529
|
+
return [
|
|
530
|
+
{
|
|
531
|
+
type: 'add',
|
|
532
|
+
path: `${filePath}/policies/{{ id }}.${language}`,
|
|
533
|
+
templateFile: `templates/${language}/policy.${language}.hbs`
|
|
534
|
+
}
|
|
535
|
+
];
|
|
477
536
|
}
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
537
|
+
});
|
|
538
|
+
});
|
|
539
|
+
|
|
540
|
+
var generateMiddleware = ((plop)=>{
|
|
541
|
+
// middleware generator
|
|
542
|
+
plop.setGenerator('middleware', {
|
|
543
|
+
description: 'Generate a middleware for an API',
|
|
544
|
+
prompts: [
|
|
545
|
+
{
|
|
546
|
+
type: 'input',
|
|
547
|
+
name: 'name',
|
|
548
|
+
message: 'Middleware name',
|
|
549
|
+
validate: (input)=>validateInput(input)
|
|
550
|
+
},
|
|
551
|
+
...getDestinationPrompts('middleware', plop.getDestBasePath(), {
|
|
552
|
+
rootFolder: true
|
|
553
|
+
})
|
|
554
|
+
],
|
|
555
|
+
actions (answers) {
|
|
556
|
+
if (!answers) {
|
|
557
|
+
return [];
|
|
558
|
+
}
|
|
559
|
+
const filePath = getFilePath(answers.destination);
|
|
560
|
+
const currentDir = process.cwd();
|
|
561
|
+
const language = tsUtils.isUsingTypeScriptSync(currentDir) ? 'ts' : 'js';
|
|
562
|
+
return [
|
|
563
|
+
{
|
|
564
|
+
type: 'add',
|
|
565
|
+
path: `${filePath}/middlewares/{{ name }}.${language}`,
|
|
566
|
+
templateFile: `templates/${language}/middleware.${language}.hbs`
|
|
567
|
+
}
|
|
568
|
+
];
|
|
506
569
|
}
|
|
507
|
-
|
|
570
|
+
});
|
|
571
|
+
});
|
|
572
|
+
|
|
573
|
+
var validateFileNameInput = ((input)=>{
|
|
574
|
+
const regex = /^[A-Za-z-_0-9]+$/g;
|
|
575
|
+
if (!input) {
|
|
576
|
+
return 'You must provide an input';
|
|
508
577
|
}
|
|
509
|
-
|
|
510
|
-
};
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
path: `${currentDir}/database/migrations/${timestamp}.{{ name }}.${language}`,
|
|
540
|
-
templateFile: `templates/${language}/migration.${language}.hbs`
|
|
578
|
+
return regex.test(input) || "Please use only letters and number, '-' or '_' and no spaces";
|
|
579
|
+
});
|
|
580
|
+
|
|
581
|
+
var getFormattedDate = ((date = new Date())=>{
|
|
582
|
+
return new Date(date.getTime() - date.getTimezoneOffset() * 60000).toJSON().replace(/[-:]/g, '.').replace(/\....Z/, '');
|
|
583
|
+
});
|
|
584
|
+
|
|
585
|
+
var generateMigration = ((plop)=>{
|
|
586
|
+
// Migration generator
|
|
587
|
+
plop.setGenerator('migration', {
|
|
588
|
+
description: 'Generate a migration',
|
|
589
|
+
prompts: [
|
|
590
|
+
{
|
|
591
|
+
type: 'input',
|
|
592
|
+
name: 'name',
|
|
593
|
+
message: 'Migration name',
|
|
594
|
+
validate: (input)=>validateFileNameInput(input)
|
|
595
|
+
}
|
|
596
|
+
],
|
|
597
|
+
actions () {
|
|
598
|
+
const currentDir = process.cwd();
|
|
599
|
+
const language = tsUtils.isUsingTypeScriptSync(currentDir) ? 'ts' : 'js';
|
|
600
|
+
const timestamp = getFormattedDate();
|
|
601
|
+
return [
|
|
602
|
+
{
|
|
603
|
+
type: 'add',
|
|
604
|
+
path: `${currentDir}/database/migrations/${timestamp}.{{ name }}.${language}`,
|
|
605
|
+
templateFile: `templates/${language}/migration.${language}.hbs`
|
|
606
|
+
}
|
|
607
|
+
];
|
|
541
608
|
}
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
609
|
+
});
|
|
610
|
+
});
|
|
611
|
+
|
|
612
|
+
var generateService = ((plop)=>{
|
|
613
|
+
// Service generator
|
|
614
|
+
plop.setGenerator('service', {
|
|
615
|
+
description: 'Generate a service for an API',
|
|
616
|
+
prompts: [
|
|
617
|
+
{
|
|
618
|
+
type: 'input',
|
|
619
|
+
name: 'id',
|
|
620
|
+
message: 'Service name'
|
|
621
|
+
},
|
|
622
|
+
...getDestinationPrompts('service', plop.getDestBasePath())
|
|
623
|
+
],
|
|
624
|
+
actions (answers) {
|
|
625
|
+
if (!answers) {
|
|
626
|
+
return [];
|
|
627
|
+
}
|
|
628
|
+
const filePath = getFilePath(answers?.destination);
|
|
629
|
+
const currentDir = process.cwd();
|
|
630
|
+
const language = tsUtils.isUsingTypeScriptSync(currentDir) ? 'ts' : 'js';
|
|
631
|
+
return [
|
|
632
|
+
{
|
|
633
|
+
type: 'add',
|
|
634
|
+
path: `${filePath}/services/{{ id }}.${language}`,
|
|
635
|
+
templateFile: `templates/${language}/service.${language}.hbs`
|
|
636
|
+
}
|
|
637
|
+
];
|
|
569
638
|
}
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
639
|
+
});
|
|
640
|
+
});
|
|
641
|
+
|
|
642
|
+
var plopfile = ((plop)=>{
|
|
643
|
+
// Plop config
|
|
644
|
+
plop.setWelcomeMessage('Strapi Generators');
|
|
645
|
+
plop.setHelper('pluralize', (text)=>pluralize(text));
|
|
646
|
+
// Generators
|
|
647
|
+
generateApi(plop);
|
|
648
|
+
generateController(plop);
|
|
649
|
+
generateContentType(plop);
|
|
650
|
+
generatePolicy(plop);
|
|
651
|
+
generateMiddleware(plop);
|
|
652
|
+
generateMigration(plop);
|
|
653
|
+
generateService(plop);
|
|
654
|
+
});
|
|
655
|
+
|
|
585
656
|
module.exports = plopfile;
|
|
586
657
|
//# sourceMappingURL=plopfile.js.map
|