@strapi/generators 4.3.4 → 4.4.0-alpha.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/lib/files/js/plugin/admin/src/index.js +1 -1
- package/lib/files/js/plugin/admin/src/utils/axiosInstance.js +4 -4
- package/lib/files/js/plugin/admin/src/utils/getTrad.js +1 -1
- package/lib/files/ts/plugin/server/bootstrap.ts +1 -1
- package/lib/files/ts/plugin/server/controllers/my-controller.ts.hbs +1 -1
- package/lib/files/ts/plugin/server/destroy.ts +1 -1
- package/lib/files/ts/plugin/server/register.ts +1 -1
- package/lib/files/ts/plugin/server/services/my-service.ts +1 -1
- package/lib/index.js +1 -1
- package/lib/plopfile.js +2 -2
- package/lib/plops/api.js +9 -8
- package/lib/plops/content-type.js +8 -8
- package/lib/plops/controller.js +2 -2
- package/lib/plops/middleware.js +2 -2
- package/lib/plops/plugin.js +3 -5
- package/lib/plops/policy.js +3 -3
- package/lib/plops/prompts/ct-names-prompts.js +3 -3
- package/lib/plops/prompts/get-attributes-prompts.js +6 -6
- package/lib/plops/prompts/get-destination-prompts.js +5 -4
- package/lib/plops/prompts/kind-prompts.js +1 -1
- package/lib/plops/service.js +1 -1
- package/lib/plops/utils/get-file-path.js +1 -1
- package/lib/plops/utils/validate-attribute-input.js +1 -1
- package/lib/plops/utils/validate-input.js +1 -1
- package/lib/templates/js/collection-type-routes.js.hbs +10 -10
- package/lib/templates/js/controller.js.hbs +1 -1
- package/lib/templates/js/core-controller.js.hbs +1 -1
- package/lib/templates/js/core-router.js.hbs +1 -1
- package/lib/templates/js/core-service.js.hbs +1 -1
- package/lib/templates/js/middleware.js.hbs +1 -1
- package/lib/templates/js/policy.js.hbs +2 -2
- package/lib/templates/js/service.js.hbs +1 -1
- package/lib/templates/js/single-route.js.hbs +2 -2
- package/lib/templates/js/single-type-routes.js.hbs +6 -6
- package/lib/templates/ts/collection-type-routes.ts.hbs +10 -10
- package/lib/templates/ts/controller.ts.hbs +1 -1
- package/lib/templates/ts/core-controller.ts.hbs +1 -1
- package/lib/templates/ts/core-router.ts.hbs +1 -1
- package/lib/templates/ts/core-service.ts.hbs +1 -1
- package/lib/templates/ts/middleware.ts.hbs +2 -2
- package/lib/templates/ts/plugin-package.json.hbs +2 -3
- package/lib/templates/ts/policy.ts.hbs +2 -2
- package/lib/templates/ts/service.ts.hbs +1 -1
- package/lib/templates/ts/single-route.ts.hbs +2 -2
- package/lib/templates/ts/single-type-routes.ts.hbs +6 -6
- package/package.json +4 -4
|
@@ -39,7 +39,7 @@ export default {
|
|
|
39
39
|
bootstrap(app) {},
|
|
40
40
|
async registerTrads({ locales }) {
|
|
41
41
|
const importedTrads = await Promise.all(
|
|
42
|
-
locales.map(locale => {
|
|
42
|
+
locales.map((locale) => {
|
|
43
43
|
return import(
|
|
44
44
|
/* webpackChunkName: "translation-[request]" */ `./translations/${locale}.json`
|
|
45
45
|
)
|
|
@@ -10,7 +10,7 @@ const instance = axios.create({
|
|
|
10
10
|
});
|
|
11
11
|
|
|
12
12
|
instance.interceptors.request.use(
|
|
13
|
-
async config => {
|
|
13
|
+
async (config) => {
|
|
14
14
|
config.headers = {
|
|
15
15
|
Authorization: `Bearer ${auth.getToken()}`,
|
|
16
16
|
Accept: 'application/json',
|
|
@@ -19,14 +19,14 @@ instance.interceptors.request.use(
|
|
|
19
19
|
|
|
20
20
|
return config;
|
|
21
21
|
},
|
|
22
|
-
error => {
|
|
22
|
+
(error) => {
|
|
23
23
|
Promise.reject(error);
|
|
24
24
|
}
|
|
25
25
|
);
|
|
26
26
|
|
|
27
27
|
instance.interceptors.response.use(
|
|
28
|
-
response => response,
|
|
29
|
-
error => {
|
|
28
|
+
(response) => response,
|
|
29
|
+
(error) => {
|
|
30
30
|
// whatever you want to do with the error
|
|
31
31
|
if (error.response?.status === 401) {
|
|
32
32
|
auth.clearAppStorage();
|
package/lib/index.js
CHANGED
|
@@ -8,7 +8,7 @@ const nodePlop = require('node-plop');
|
|
|
8
8
|
* Starts the Plop CLI programmatically
|
|
9
9
|
*/
|
|
10
10
|
const runCLI = () => {
|
|
11
|
-
Plop.launch({ configPath: join(__dirname, 'plopfile.js') }, env =>
|
|
11
|
+
Plop.launch({ configPath: join(__dirname, 'plopfile.js') }, (env) =>
|
|
12
12
|
run({ ...env, dest: join(process.cwd(), 'src') }, undefined, true)
|
|
13
13
|
);
|
|
14
14
|
};
|
package/lib/plopfile.js
CHANGED
|
@@ -10,10 +10,10 @@ const generatePolicy = require('./plops/policy');
|
|
|
10
10
|
const generateMiddleware = require('./plops/middleware');
|
|
11
11
|
const generateService = require('./plops/service');
|
|
12
12
|
|
|
13
|
-
module.exports = plop => {
|
|
13
|
+
module.exports = (plop) => {
|
|
14
14
|
// Plop config
|
|
15
15
|
plop.setWelcomeMessage('Strapi Generators');
|
|
16
|
-
plop.addHelper('pluralize', text => pluralize(text));
|
|
16
|
+
plop.addHelper('pluralize', (text) => pluralize(text));
|
|
17
17
|
|
|
18
18
|
// Generators
|
|
19
19
|
generateApi(plop);
|
package/lib/plops/api.js
CHANGED
|
@@ -6,7 +6,7 @@ const tsUtils = require('@strapi/typescript-utils');
|
|
|
6
6
|
|
|
7
7
|
const validateInput = require('./utils/validate-input');
|
|
8
8
|
|
|
9
|
-
module.exports = plop => {
|
|
9
|
+
module.exports = (plop) => {
|
|
10
10
|
// API generator
|
|
11
11
|
plop.setGenerator('api', {
|
|
12
12
|
description: 'Generate a basic API',
|
|
@@ -15,7 +15,7 @@ module.exports = plop => {
|
|
|
15
15
|
type: 'input',
|
|
16
16
|
name: 'id',
|
|
17
17
|
message: 'API name',
|
|
18
|
-
validate: input => validateInput(input),
|
|
18
|
+
validate: (input) => validateInput(input),
|
|
19
19
|
},
|
|
20
20
|
{
|
|
21
21
|
type: 'confirm',
|
|
@@ -23,7 +23,7 @@ module.exports = plop => {
|
|
|
23
23
|
message: 'Is this API for a plugin?',
|
|
24
24
|
},
|
|
25
25
|
{
|
|
26
|
-
when: answers => answers.isPluginApi,
|
|
26
|
+
when: (answers) => answers.isPluginApi,
|
|
27
27
|
type: 'list',
|
|
28
28
|
name: 'plugin',
|
|
29
29
|
message: 'Plugin name',
|
|
@@ -36,7 +36,7 @@ module.exports = plop => {
|
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
const pluginsDir = await fs.readdir(pluginsPath, { withFileTypes: true });
|
|
39
|
-
const pluginsDirContent = pluginsDir.filter(fd => fd.isDirectory());
|
|
39
|
+
const pluginsDirContent = pluginsDir.filter((fd) => fd.isDirectory());
|
|
40
40
|
|
|
41
41
|
if (pluginsDirContent.length === 0) {
|
|
42
42
|
throw Error('The "plugins" directory is empty');
|
|
@@ -47,19 +47,20 @@ module.exports = plop => {
|
|
|
47
47
|
},
|
|
48
48
|
],
|
|
49
49
|
actions(answers) {
|
|
50
|
-
const filePath =
|
|
50
|
+
const filePath =
|
|
51
|
+
answers.isPluginApi && answers.plugin ? 'plugins/{{ plugin }}' : 'api/{{ id }}';
|
|
51
52
|
const currentDir = process.cwd();
|
|
52
53
|
const language = tsUtils.isUsingTypeScriptSync(currentDir) ? 'ts' : 'js';
|
|
53
54
|
|
|
54
55
|
const baseActions = [
|
|
55
56
|
{
|
|
56
57
|
type: 'add',
|
|
57
|
-
path: `${filePath}/controllers/{{id}}.${language}`,
|
|
58
|
+
path: `${filePath}/controllers/{{ id }}.${language}`,
|
|
58
59
|
templateFile: `templates/${language}/controller.${language}.hbs`,
|
|
59
60
|
},
|
|
60
61
|
{
|
|
61
62
|
type: 'add',
|
|
62
|
-
path: `${filePath}/services/{{id}}.${language}`,
|
|
63
|
+
path: `${filePath}/services/{{ id }}.${language}`,
|
|
63
64
|
templateFile: `templates/${language}/service.${language}.hbs`,
|
|
64
65
|
},
|
|
65
66
|
];
|
|
@@ -71,7 +72,7 @@ module.exports = plop => {
|
|
|
71
72
|
return [
|
|
72
73
|
{
|
|
73
74
|
type: 'add',
|
|
74
|
-
path: `${filePath}/routes/{{id}}.${language}`,
|
|
75
|
+
path: `${filePath}/routes/{{ id }}.${language}`,
|
|
75
76
|
templateFile: `templates/${language}/single-route.${language}.hbs`,
|
|
76
77
|
},
|
|
77
78
|
...baseActions,
|
|
@@ -14,7 +14,7 @@ const draftAndPublishPrompts = require('./prompts/draft-and-publish-prompts');
|
|
|
14
14
|
const getAttributesPrompts = require('./prompts/get-attributes-prompts');
|
|
15
15
|
const bootstrapApiPrompts = require('./prompts/bootstrap-api-prompts');
|
|
16
16
|
|
|
17
|
-
module.exports = plop => {
|
|
17
|
+
module.exports = (plop) => {
|
|
18
18
|
// Model generator
|
|
19
19
|
plop.setGenerator('content-type', {
|
|
20
20
|
description: 'Generate a content type for an API',
|
|
@@ -29,7 +29,7 @@ module.exports = plop => {
|
|
|
29
29
|
const api = await inquirer.prompt([
|
|
30
30
|
...getDestinationPrompts('model', plop.getDestBasePath()),
|
|
31
31
|
{
|
|
32
|
-
when: answers => answers.destination === 'new',
|
|
32
|
+
when: (answers) => answers.destination === 'new',
|
|
33
33
|
type: 'input',
|
|
34
34
|
name: 'id',
|
|
35
35
|
default: config.singularName,
|
|
@@ -47,9 +47,9 @@ module.exports = plop => {
|
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
const apiDir = await fs.readdir(apiPath, { withFileTypes: true });
|
|
50
|
-
const apiDirContent = apiDir.filter(fd => fd.isDirectory());
|
|
50
|
+
const apiDirContent = apiDir.filter((fd) => fd.isDirectory());
|
|
51
51
|
|
|
52
|
-
if (apiDirContent.findIndex(api => api.name === input) !== -1) {
|
|
52
|
+
if (apiDirContent.findIndex((api) => api.name === input) !== -1) {
|
|
53
53
|
throw new Error('This name is already taken.');
|
|
54
54
|
}
|
|
55
55
|
|
|
@@ -70,7 +70,7 @@ module.exports = plop => {
|
|
|
70
70
|
const val = { type: answer.attributeType };
|
|
71
71
|
|
|
72
72
|
if (answer.attributeType === 'enumeration') {
|
|
73
|
-
val.enum = answer.enum.split(',').map(item => item.trim());
|
|
73
|
+
val.enum = answer.enum.split(',').map((item) => item.trim());
|
|
74
74
|
}
|
|
75
75
|
|
|
76
76
|
if (answer.attributeType === 'media') {
|
|
@@ -123,19 +123,19 @@ module.exports = plop => {
|
|
|
123
123
|
baseActions.push(
|
|
124
124
|
{
|
|
125
125
|
type: 'add',
|
|
126
|
-
path: `${filePath}/controllers/{{singularName}}.${language}`,
|
|
126
|
+
path: `${filePath}/controllers/{{ singularName }}.${language}`,
|
|
127
127
|
templateFile: `templates/${language}/core-controller.${language}.hbs`,
|
|
128
128
|
data: { uid },
|
|
129
129
|
},
|
|
130
130
|
{
|
|
131
131
|
type: 'add',
|
|
132
|
-
path: `${filePath}/services/{{singularName}}.${language}`,
|
|
132
|
+
path: `${filePath}/services/{{ singularName }}.${language}`,
|
|
133
133
|
templateFile: `templates/${language}/core-service.${language}.hbs`,
|
|
134
134
|
data: { uid },
|
|
135
135
|
},
|
|
136
136
|
{
|
|
137
137
|
type: 'add',
|
|
138
|
-
path: `${filePath}/routes/{{singularName}}.${language}`,
|
|
138
|
+
path: `${filePath}/routes/{{ singularName }}.${language}`,
|
|
139
139
|
templateFile: `templates/${language}/core-router.${language}.hbs`,
|
|
140
140
|
data: { uid },
|
|
141
141
|
}
|
package/lib/plops/controller.js
CHANGED
|
@@ -6,7 +6,7 @@ const getDestinationPrompts = require('./prompts/get-destination-prompts');
|
|
|
6
6
|
const getFilePath = require('./utils/get-file-path');
|
|
7
7
|
const validateInput = require('./utils/validate-input');
|
|
8
8
|
|
|
9
|
-
module.exports = plop => {
|
|
9
|
+
module.exports = (plop) => {
|
|
10
10
|
// Controller generator
|
|
11
11
|
plop.setGenerator('controller', {
|
|
12
12
|
description: 'Generate a controller for an API',
|
|
@@ -15,7 +15,7 @@ module.exports = plop => {
|
|
|
15
15
|
type: 'input',
|
|
16
16
|
name: 'id',
|
|
17
17
|
message: 'Controller name',
|
|
18
|
-
validate: input => validateInput(input),
|
|
18
|
+
validate: (input) => validateInput(input),
|
|
19
19
|
},
|
|
20
20
|
...getDestinationPrompts('controller', plop.getDestBasePath()),
|
|
21
21
|
],
|
package/lib/plops/middleware.js
CHANGED
|
@@ -6,7 +6,7 @@ const getDestinationPrompts = require('./prompts/get-destination-prompts');
|
|
|
6
6
|
const validateInput = require('./utils/validate-input');
|
|
7
7
|
const getFilePath = require('./utils/get-file-path');
|
|
8
8
|
|
|
9
|
-
module.exports = plop => {
|
|
9
|
+
module.exports = (plop) => {
|
|
10
10
|
// middleware generator
|
|
11
11
|
plop.setGenerator('middleware', {
|
|
12
12
|
description: 'Generate a middleware for an API',
|
|
@@ -15,7 +15,7 @@ module.exports = plop => {
|
|
|
15
15
|
type: 'input',
|
|
16
16
|
name: 'name',
|
|
17
17
|
message: 'Middleware name',
|
|
18
|
-
validate: input => validateInput(input),
|
|
18
|
+
validate: (input) => validateInput(input),
|
|
19
19
|
},
|
|
20
20
|
...getDestinationPrompts('middleware', plop.getDestBasePath(), { rootFolder: true }),
|
|
21
21
|
],
|
package/lib/plops/plugin.js
CHANGED
|
@@ -13,9 +13,7 @@ const LANGUAGES = {
|
|
|
13
13
|
|
|
14
14
|
const logInstructions = (pluginName, { language }) => {
|
|
15
15
|
const maxLength = ` resolve: './src/plugins/${pluginName}'`.length;
|
|
16
|
-
const separator = Array(maxLength)
|
|
17
|
-
.fill('─')
|
|
18
|
-
.join('');
|
|
16
|
+
const separator = Array(maxLength).fill('─').join('');
|
|
19
17
|
|
|
20
18
|
const exportInstruction = language === 'js' ? 'module.exports =' : 'export default';
|
|
21
19
|
|
|
@@ -36,7 +34,7 @@ ${separator}
|
|
|
36
34
|
`;
|
|
37
35
|
};
|
|
38
36
|
|
|
39
|
-
module.exports = plop => {
|
|
37
|
+
module.exports = (plop) => {
|
|
40
38
|
// Plugin generator
|
|
41
39
|
plop.setGenerator('plugin', {
|
|
42
40
|
description: 'Generate a basic plugin',
|
|
@@ -45,7 +43,7 @@ module.exports = plop => {
|
|
|
45
43
|
type: 'input',
|
|
46
44
|
name: 'pluginName',
|
|
47
45
|
message: 'Plugin name',
|
|
48
|
-
validate: input => validateInput(input),
|
|
46
|
+
validate: (input) => validateInput(input),
|
|
49
47
|
},
|
|
50
48
|
{
|
|
51
49
|
type: 'list',
|
package/lib/plops/policy.js
CHANGED
|
@@ -6,7 +6,7 @@ const getDestinationPrompts = require('./prompts/get-destination-prompts');
|
|
|
6
6
|
const validateInput = require('./utils/validate-input');
|
|
7
7
|
const getFilePath = require('./utils/get-file-path');
|
|
8
8
|
|
|
9
|
-
module.exports = plop => {
|
|
9
|
+
module.exports = (plop) => {
|
|
10
10
|
// Policy generator
|
|
11
11
|
plop.setGenerator('policy', {
|
|
12
12
|
description: 'Generate a policy for an API',
|
|
@@ -15,7 +15,7 @@ module.exports = plop => {
|
|
|
15
15
|
type: 'input',
|
|
16
16
|
name: 'id',
|
|
17
17
|
message: 'Policy name',
|
|
18
|
-
validate: input => validateInput(input),
|
|
18
|
+
validate: (input) => validateInput(input),
|
|
19
19
|
},
|
|
20
20
|
...getDestinationPrompts('policy', plop.getDestBasePath(), { rootFolder: true }),
|
|
21
21
|
],
|
|
@@ -27,7 +27,7 @@ module.exports = plop => {
|
|
|
27
27
|
return [
|
|
28
28
|
{
|
|
29
29
|
type: 'add',
|
|
30
|
-
path: `${filePath}/policies/{{id}}.${language}`,
|
|
30
|
+
path: `${filePath}/policies/{{ id }}.${language}`,
|
|
31
31
|
templateFile: `templates/${language}/policy.${language}.hbs`,
|
|
32
32
|
},
|
|
33
33
|
];
|
|
@@ -9,13 +9,13 @@ module.exports = [
|
|
|
9
9
|
type: 'input',
|
|
10
10
|
name: 'displayName',
|
|
11
11
|
message: 'Content type display name',
|
|
12
|
-
validate: input => !!input,
|
|
12
|
+
validate: (input) => !!input,
|
|
13
13
|
},
|
|
14
14
|
{
|
|
15
15
|
type: 'input',
|
|
16
16
|
name: 'singularName',
|
|
17
17
|
message: 'Content type singular name',
|
|
18
|
-
default: answers => slugify(answers.displayName),
|
|
18
|
+
default: (answers) => slugify(answers.displayName),
|
|
19
19
|
validate(input) {
|
|
20
20
|
if (!isKebabCase(input)) {
|
|
21
21
|
return 'Value must be in kebab-case';
|
|
@@ -28,7 +28,7 @@ module.exports = [
|
|
|
28
28
|
type: 'input',
|
|
29
29
|
name: 'pluralName',
|
|
30
30
|
message: 'Content type plural name',
|
|
31
|
-
default: answers => pluralize(answers.singularName),
|
|
31
|
+
default: (answers) => pluralize(answers.singularName),
|
|
32
32
|
validate(input, answers) {
|
|
33
33
|
if (answers.singularName === input) {
|
|
34
34
|
return 'Singular and plural names cannot be the same';
|
|
@@ -29,7 +29,7 @@ const DEFAULT_TYPES = [
|
|
|
29
29
|
* @param {import('inquirer').Inquirer} inquirer
|
|
30
30
|
* @returns {Promise<Record<string, string>[]>}
|
|
31
31
|
*/
|
|
32
|
-
module.exports = async inquirer => {
|
|
32
|
+
module.exports = async (inquirer) => {
|
|
33
33
|
const { addAttributes } = await inquirer.prompt([
|
|
34
34
|
{
|
|
35
35
|
type: 'confirm',
|
|
@@ -44,31 +44,31 @@ module.exports = async inquirer => {
|
|
|
44
44
|
* @param {import('inquirer').Inquirer} inquirer
|
|
45
45
|
* @returns {Promise<void>}
|
|
46
46
|
*/
|
|
47
|
-
const createNewAttributes = async inquirer => {
|
|
47
|
+
const createNewAttributes = async (inquirer) => {
|
|
48
48
|
const answers = await inquirer.prompt([
|
|
49
49
|
{
|
|
50
50
|
type: 'input',
|
|
51
51
|
name: 'attributeName',
|
|
52
52
|
message: 'Name of attribute',
|
|
53
|
-
validate: input => validateAttributeInput(input),
|
|
53
|
+
validate: (input) => validateAttributeInput(input),
|
|
54
54
|
},
|
|
55
55
|
{
|
|
56
56
|
type: 'list',
|
|
57
57
|
name: 'attributeType',
|
|
58
58
|
message: 'What type of attribute',
|
|
59
59
|
pageSize: DEFAULT_TYPES.length,
|
|
60
|
-
choices: DEFAULT_TYPES.map(type => {
|
|
60
|
+
choices: DEFAULT_TYPES.map((type) => {
|
|
61
61
|
return { name: type, value: type };
|
|
62
62
|
}),
|
|
63
63
|
},
|
|
64
64
|
{
|
|
65
|
-
when: answers => answers.attributeType === 'enumeration',
|
|
65
|
+
when: (answers) => answers.attributeType === 'enumeration',
|
|
66
66
|
type: 'input',
|
|
67
67
|
name: 'enum',
|
|
68
68
|
message: 'Add values separated by a comma',
|
|
69
69
|
},
|
|
70
70
|
{
|
|
71
|
-
when: answers => answers.attributeType === 'media',
|
|
71
|
+
when: (answers) => answers.attributeType === 'media',
|
|
72
72
|
type: 'list',
|
|
73
73
|
name: 'multiple',
|
|
74
74
|
message: 'Choose media type',
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
'use strict';
|
|
2
|
+
|
|
2
3
|
const { join } = require('path');
|
|
3
4
|
const fs = require('fs-extra');
|
|
4
5
|
|
|
@@ -27,7 +28,7 @@ module.exports = (action, basePath, { rootFolder = false } = {}) => {
|
|
|
27
28
|
],
|
|
28
29
|
},
|
|
29
30
|
{
|
|
30
|
-
when: answers => answers.destination === 'api',
|
|
31
|
+
when: (answers) => answers.destination === 'api',
|
|
31
32
|
type: 'list',
|
|
32
33
|
message: 'Which API is this for?',
|
|
33
34
|
name: 'api',
|
|
@@ -40,7 +41,7 @@ module.exports = (action, basePath, { rootFolder = false } = {}) => {
|
|
|
40
41
|
}
|
|
41
42
|
|
|
42
43
|
const apiDir = await fs.readdir(apiPath, { withFileTypes: true });
|
|
43
|
-
const apiDirContent = apiDir.filter(fd => fd.isDirectory());
|
|
44
|
+
const apiDirContent = apiDir.filter((fd) => fd.isDirectory());
|
|
44
45
|
|
|
45
46
|
if (apiDirContent.length === 0) {
|
|
46
47
|
throw Error('The "api" directory is empty');
|
|
@@ -50,7 +51,7 @@ module.exports = (action, basePath, { rootFolder = false } = {}) => {
|
|
|
50
51
|
},
|
|
51
52
|
},
|
|
52
53
|
{
|
|
53
|
-
when: answers => answers.destination === 'plugin',
|
|
54
|
+
when: (answers) => answers.destination === 'plugin',
|
|
54
55
|
type: 'list',
|
|
55
56
|
message: 'Which plugin is this for?',
|
|
56
57
|
name: 'plugin',
|
|
@@ -63,7 +64,7 @@ module.exports = (action, basePath, { rootFolder = false } = {}) => {
|
|
|
63
64
|
}
|
|
64
65
|
|
|
65
66
|
const pluginsDir = await fs.readdir(pluginsPath);
|
|
66
|
-
const pluginsDirContent = pluginsDir.filter(api =>
|
|
67
|
+
const pluginsDirContent = pluginsDir.filter((api) =>
|
|
67
68
|
fs.lstatSync(join(pluginsPath, api)).isDirectory()
|
|
68
69
|
);
|
|
69
70
|
|
package/lib/plops/service.js
CHANGED
|
@@ -5,7 +5,7 @@ const tsUtils = require('@strapi/typescript-utils');
|
|
|
5
5
|
const getDestinationPrompts = require('./prompts/get-destination-prompts');
|
|
6
6
|
const getFilePath = require('./utils/get-file-path');
|
|
7
7
|
|
|
8
|
-
module.exports = plop => {
|
|
8
|
+
module.exports = (plop) => {
|
|
9
9
|
// Service generator
|
|
10
10
|
plop.setGenerator('service', {
|
|
11
11
|
description: 'Generate a service for an API',
|
|
@@ -2,8 +2,8 @@ module.exports = {
|
|
|
2
2
|
routes: [
|
|
3
3
|
{
|
|
4
4
|
method: 'GET',
|
|
5
|
-
path: '/{{pluralize id}}',
|
|
6
|
-
handler: '{{id}}.find',
|
|
5
|
+
path: '/{{ pluralize id }}',
|
|
6
|
+
handler: '{{ id }}.find',
|
|
7
7
|
config: {
|
|
8
8
|
policies: [],
|
|
9
9
|
middlewares: [],
|
|
@@ -11,8 +11,8 @@ module.exports = {
|
|
|
11
11
|
},
|
|
12
12
|
{
|
|
13
13
|
method: 'GET',
|
|
14
|
-
path: '/{{pluralize id}}/:id',
|
|
15
|
-
handler: '{{id}}.findOne',
|
|
14
|
+
path: '/{{ pluralize id }}/:id',
|
|
15
|
+
handler: '{{ id }}.findOne',
|
|
16
16
|
config: {
|
|
17
17
|
policies: [],
|
|
18
18
|
middlewares: [],
|
|
@@ -20,8 +20,8 @@ module.exports = {
|
|
|
20
20
|
},
|
|
21
21
|
{
|
|
22
22
|
method: 'POST',
|
|
23
|
-
path: '/{{pluralize id}}',
|
|
24
|
-
handler: '{{id}}.create',
|
|
23
|
+
path: '/{{ pluralize id }}',
|
|
24
|
+
handler: '{{ id }}.create',
|
|
25
25
|
config: {
|
|
26
26
|
policies: [],
|
|
27
27
|
middlewares: [],
|
|
@@ -29,8 +29,8 @@ module.exports = {
|
|
|
29
29
|
},
|
|
30
30
|
{
|
|
31
31
|
method: 'PUT',
|
|
32
|
-
path: '/{{pluralize id}}/:id',
|
|
33
|
-
handler: '{{id}}.update',
|
|
32
|
+
path: '/{{ pluralize id }}/:id',
|
|
33
|
+
handler: '{{ id }}.update',
|
|
34
34
|
config: {
|
|
35
35
|
policies: [],
|
|
36
36
|
middlewares: [],
|
|
@@ -38,8 +38,8 @@ module.exports = {
|
|
|
38
38
|
},
|
|
39
39
|
{
|
|
40
40
|
method: 'DELETE',
|
|
41
|
-
path: '/{{pluralize id}}/:id',
|
|
42
|
-
handler: '{{id}}.delete',
|
|
41
|
+
path: '/{{ pluralize id }}/:id',
|
|
42
|
+
handler: '{{ id }}.delete',
|
|
43
43
|
config: {
|
|
44
44
|
policies: [],
|
|
45
45
|
middlewares: [],
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
* `{{id}}` policy
|
|
4
|
+
* `{{ id }}` policy
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
module.exports = (policyContext, config, { strapi }) => {
|
|
8
8
|
// Add your own logic here.
|
|
9
|
-
strapi.log.info('In {{id}} policy.');
|
|
9
|
+
strapi.log.info('In {{ id }} policy.');
|
|
10
10
|
|
|
11
11
|
const canDoSomething = true;
|
|
12
12
|
|
|
@@ -4,8 +4,8 @@ module.exports = {
|
|
|
4
4
|
routes: [
|
|
5
5
|
{
|
|
6
6
|
method: 'GET',
|
|
7
|
-
path: '/{{id}}',
|
|
8
|
-
handler: '{{id}}.find',
|
|
7
|
+
path: '/{{ id }}',
|
|
8
|
+
handler: '{{ id }}.find',
|
|
9
9
|
config: {
|
|
10
10
|
policies: [],
|
|
11
11
|
middlewares: [],
|
|
@@ -13,8 +13,8 @@ module.exports = {
|
|
|
13
13
|
},
|
|
14
14
|
{
|
|
15
15
|
method: 'PUT',
|
|
16
|
-
path: '/{{id}}',
|
|
17
|
-
handler: '{{id}}.update',
|
|
16
|
+
path: '/{{ id }}',
|
|
17
|
+
handler: '{{ id }}.update',
|
|
18
18
|
config: {
|
|
19
19
|
policies: [],
|
|
20
20
|
middlewares: [],
|
|
@@ -22,8 +22,8 @@ module.exports = {
|
|
|
22
22
|
},
|
|
23
23
|
{
|
|
24
24
|
method: 'DELETE',
|
|
25
|
-
path: '/{{id}}',
|
|
26
|
-
handler: '{{id}}.delete',
|
|
25
|
+
path: '/{{ id }}',
|
|
26
|
+
handler: '{{ id }}.delete',
|
|
27
27
|
config: {
|
|
28
28
|
policies: [],
|
|
29
29
|
middlewares: [],
|
|
@@ -2,8 +2,8 @@ export default {
|
|
|
2
2
|
routes: [
|
|
3
3
|
{
|
|
4
4
|
method: 'GET',
|
|
5
|
-
path: '/{{pluralize id}}',
|
|
6
|
-
handler: '{{id}}.find',
|
|
5
|
+
path: '/{{ pluralize id }}',
|
|
6
|
+
handler: '{{ id }}.find',
|
|
7
7
|
config: {
|
|
8
8
|
policies: [],
|
|
9
9
|
middlewares: [],
|
|
@@ -11,8 +11,8 @@ export default {
|
|
|
11
11
|
},
|
|
12
12
|
{
|
|
13
13
|
method: 'GET',
|
|
14
|
-
path: '/{{pluralize id}}/:id',
|
|
15
|
-
handler: '{{id}}.findOne',
|
|
14
|
+
path: '/{{ pluralize id }}/:id',
|
|
15
|
+
handler: '{{ id }}.findOne',
|
|
16
16
|
config: {
|
|
17
17
|
policies: [],
|
|
18
18
|
middlewares: [],
|
|
@@ -20,8 +20,8 @@ export default {
|
|
|
20
20
|
},
|
|
21
21
|
{
|
|
22
22
|
method: 'POST',
|
|
23
|
-
path: '/{{pluralize id}}',
|
|
24
|
-
handler: '{{id}}.create',
|
|
23
|
+
path: '/{{ pluralize id }}',
|
|
24
|
+
handler: '{{ id }}.create',
|
|
25
25
|
config: {
|
|
26
26
|
policies: [],
|
|
27
27
|
middlewares: [],
|
|
@@ -29,8 +29,8 @@ export default {
|
|
|
29
29
|
},
|
|
30
30
|
{
|
|
31
31
|
method: 'PUT',
|
|
32
|
-
path: '/{{pluralize id}}/:id',
|
|
33
|
-
handler: '{{id}}.update',
|
|
32
|
+
path: '/{{ pluralize id }}/:id',
|
|
33
|
+
handler: '{{ id }}.update',
|
|
34
34
|
config: {
|
|
35
35
|
policies: [],
|
|
36
36
|
middlewares: [],
|
|
@@ -38,8 +38,8 @@ export default {
|
|
|
38
38
|
},
|
|
39
39
|
{
|
|
40
40
|
method: 'DELETE',
|
|
41
|
-
path: '/{{pluralize id}}/:id',
|
|
42
|
-
handler: '{{id}}.delete',
|
|
41
|
+
path: '/{{ pluralize id }}/:id',
|
|
42
|
+
handler: '{{ id }}.delete',
|
|
43
43
|
config: {
|
|
44
44
|
policies: [],
|
|
45
45
|
middlewares: [],
|
|
@@ -9,8 +9,7 @@
|
|
|
9
9
|
},
|
|
10
10
|
"dependencies": {},
|
|
11
11
|
"devDependencies": {
|
|
12
|
-
"typescript": "4.6.3"
|
|
13
|
-
"@strapi/strapi": "4.1.8"
|
|
12
|
+
"typescript": "4.6.3"
|
|
14
13
|
},
|
|
15
14
|
"author": {
|
|
16
15
|
"name": "A Strapi developer"
|
|
@@ -21,7 +20,7 @@
|
|
|
21
20
|
}
|
|
22
21
|
],
|
|
23
22
|
"engines": {
|
|
24
|
-
"node": ">=
|
|
23
|
+
"node": ">=14.19.1 <=16.x.x",
|
|
25
24
|
"npm": ">=6.0.0"
|
|
26
25
|
},
|
|
27
26
|
"scripts": {
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* {{ id }} policy
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
5
|
export default (policyContext, config, { strapi }) => {
|
|
6
6
|
// Add your own logic here.
|
|
7
|
-
strapi.log.info('In {{id}} policy.');
|
|
7
|
+
strapi.log.info('In {{ id }} policy.');
|
|
8
8
|
|
|
9
9
|
const canDoSomething = true;
|
|
10
10
|
|
|
@@ -2,8 +2,8 @@ export default {
|
|
|
2
2
|
routes: [
|
|
3
3
|
{
|
|
4
4
|
method: 'GET',
|
|
5
|
-
path: '/{{id}}',
|
|
6
|
-
handler: '{{id}}.find',
|
|
5
|
+
path: '/{{ id }}',
|
|
6
|
+
handler: '{{ id }}.find',
|
|
7
7
|
config: {
|
|
8
8
|
policies: [],
|
|
9
9
|
middlewares: [],
|
|
@@ -11,8 +11,8 @@ export default {
|
|
|
11
11
|
},
|
|
12
12
|
{
|
|
13
13
|
method: 'PUT',
|
|
14
|
-
path: '/{{id}}',
|
|
15
|
-
handler: '{{id}}.update',
|
|
14
|
+
path: '/{{ id }}',
|
|
15
|
+
handler: '{{ id }}.update',
|
|
16
16
|
config: {
|
|
17
17
|
policies: [],
|
|
18
18
|
middlewares: [],
|
|
@@ -20,8 +20,8 @@ export default {
|
|
|
20
20
|
},
|
|
21
21
|
{
|
|
22
22
|
method: 'DELETE',
|
|
23
|
-
path: '/{{id}}',
|
|
24
|
-
handler: '{{id}}.delete',
|
|
23
|
+
path: '/{{ id }}',
|
|
24
|
+
handler: '{{ id }}.delete',
|
|
25
25
|
config: {
|
|
26
26
|
policies: [],
|
|
27
27
|
middlewares: [],
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@strapi/generators",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.4.0-alpha.0",
|
|
4
4
|
"description": "Interactive API generator.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"strapi",
|
|
@@ -30,8 +30,8 @@
|
|
|
30
30
|
"main": "lib/index.js",
|
|
31
31
|
"dependencies": {
|
|
32
32
|
"@sindresorhus/slugify": "1.1.0",
|
|
33
|
-
"@strapi/typescript-utils": "4.
|
|
34
|
-
"@strapi/utils": "4.
|
|
33
|
+
"@strapi/typescript-utils": "4.4.0-alpha.0",
|
|
34
|
+
"@strapi/utils": "4.4.0-alpha.0",
|
|
35
35
|
"chalk": "4.1.2",
|
|
36
36
|
"fs-extra": "10.0.0",
|
|
37
37
|
"node-plop": "0.26.3",
|
|
@@ -42,5 +42,5 @@
|
|
|
42
42
|
"node": ">=14.19.1 <=16.x.x",
|
|
43
43
|
"npm": ">=6.0.0"
|
|
44
44
|
},
|
|
45
|
-
"gitHead": "
|
|
45
|
+
"gitHead": "fc78298ae4f9b247d636beda568734d5f8ed7b3e"
|
|
46
46
|
}
|