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