@strapi/generators 4.0.0-next.9 → 4.0.3
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/plugin/admin/src/components/PluginIcon/index.js +12 -0
- package/lib/files/plugin/admin/src/index.js +2 -6
- package/lib/files/plugin/admin/src/utils/axiosInstance.js +40 -0
- package/lib/files/plugin/server/bootstrap.js +5 -0
- package/lib/files/plugin/server/config/index.js +6 -0
- package/lib/files/plugin/server/controllers/index.js +7 -0
- package/lib/files/plugin/server/controllers/my-controller.js.hbs +10 -0
- package/lib/files/plugin/server/destroy.js +5 -0
- package/lib/files/plugin/server/index.js +22 -0
- package/lib/files/plugin/server/register.js +5 -0
- package/lib/files/plugin/server/routes/index.js +10 -0
- package/lib/files/plugin/server/services/index.js +7 -0
- package/lib/files/plugin/server/services/my-service.js +7 -0
- package/lib/files/plugin/strapi-admin.js +3 -0
- package/lib/files/plugin/strapi-server.js +3 -0
- package/lib/index.js +5 -5
- package/lib/plopfile.js +4 -2
- package/lib/plops/__tests__/content-type.test.js +179 -0
- package/lib/plops/api.js +4 -35
- package/lib/plops/content-type.js +145 -0
- package/lib/plops/controller.js +3 -3
- package/lib/plops/middleware.js +36 -0
- package/lib/plops/plugin.js +31 -22
- package/lib/plops/policy.js +4 -4
- package/lib/plops/prompts/bootstrap-api-prompts.js +10 -0
- package/lib/plops/prompts/ct-names-prompts.js +44 -0
- package/lib/plops/prompts/draft-and-publish-prompts.js +10 -0
- package/lib/plops/prompts/get-attributes-prompts.js +102 -0
- package/lib/plops/{utils → prompts}/get-destination-prompts.js +4 -4
- package/lib/plops/prompts/kind-prompts.js +17 -0
- package/lib/plops/service.js +3 -3
- package/lib/plops/utils/get-file-path.js +3 -3
- package/lib/plops/utils/validate-input.js +1 -1
- package/lib/templates/README.md.hbs +2 -2
- package/lib/templates/collection-type-routes.js.hbs +5 -0
- package/lib/templates/content-type.schema.json.hbs +15 -0
- package/lib/templates/core-controller.js.hbs +9 -0
- package/lib/templates/core-router.js.hbs +9 -0
- package/lib/templates/core-service.js.hbs +9 -0
- package/lib/templates/middleware.js.hbs +14 -0
- package/lib/templates/plugin-package.json.hbs +6 -10
- package/lib/templates/policy.js.hbs +10 -4
- package/lib/templates/service.js.hbs +1 -1
- package/lib/templates/single-route.js.hbs +13 -0
- package/lib/templates/single-type-routes.js.hbs +4 -1
- package/package.json +11 -7
- package/lib/files/plugin/admin/src/containers/App/index.js +0 -25
- package/lib/files/plugin/admin/src/containers/HomePage/index.js +0 -20
- package/lib/files/plugin/admin/src/containers/Initializer/index.js +0 -26
- package/lib/plops/model.js +0 -174
- package/lib/templates/model.schema.json.hbs +0 -16
- package/lib/templates/plugin-routes.json.hbs +0 -12
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const getDestinationPrompts = require('./prompts/get-destination-prompts');
|
|
4
|
+
|
|
5
|
+
module.exports = plop => {
|
|
6
|
+
// middleware generator
|
|
7
|
+
plop.setGenerator('middleware', {
|
|
8
|
+
description: 'Generate a middleware for an API',
|
|
9
|
+
prompts: [
|
|
10
|
+
{
|
|
11
|
+
type: 'input',
|
|
12
|
+
name: 'name',
|
|
13
|
+
message: 'Middleware name',
|
|
14
|
+
},
|
|
15
|
+
...getDestinationPrompts('middleware', plop.getDestBasePath(), { rootFolder: true }),
|
|
16
|
+
],
|
|
17
|
+
actions(answers) {
|
|
18
|
+
let filePath;
|
|
19
|
+
if (answers.destination === 'api') {
|
|
20
|
+
filePath = `api/{{ api }}`;
|
|
21
|
+
} else if (answers.destination === 'plugin') {
|
|
22
|
+
filePath = `plugins/{{ plugin }}`;
|
|
23
|
+
} else {
|
|
24
|
+
filePath = `./`;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
return [
|
|
28
|
+
{
|
|
29
|
+
type: 'add',
|
|
30
|
+
path: `${filePath}/middlewares/{{ name }}.js`,
|
|
31
|
+
templateFile: 'templates/middleware.js.hbs',
|
|
32
|
+
},
|
|
33
|
+
];
|
|
34
|
+
},
|
|
35
|
+
});
|
|
36
|
+
};
|
package/lib/plops/plugin.js
CHANGED
|
@@ -1,5 +1,28 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
const chalk = require('chalk');
|
|
4
|
+
|
|
5
|
+
const logInstructions = pluginName => {
|
|
6
|
+
const maxLength = ` resolve: './src/plugins/${pluginName}'`.length;
|
|
7
|
+
const separator = Array(maxLength)
|
|
8
|
+
.fill('─')
|
|
9
|
+
.join('');
|
|
10
|
+
|
|
11
|
+
return `
|
|
12
|
+
You can now enable your plugin by adding the following in ${chalk.yellow('./config/plugins.js')}.
|
|
13
|
+
${separator}
|
|
14
|
+
module.exports = {
|
|
15
|
+
${chalk.gray('// ...')}
|
|
16
|
+
${chalk.green(`'${pluginName}'`)}: {
|
|
17
|
+
enabled: ${chalk.yellow(true)},
|
|
18
|
+
resolve: ${chalk.yellow(`'./src/plugins/${pluginName}'`)}
|
|
19
|
+
},
|
|
20
|
+
${chalk.gray('// ...')}
|
|
21
|
+
}
|
|
22
|
+
${separator}
|
|
23
|
+
`;
|
|
24
|
+
};
|
|
25
|
+
|
|
3
26
|
module.exports = plop => {
|
|
4
27
|
// Plugin generator
|
|
5
28
|
plop.setGenerator('plugin', {
|
|
@@ -7,43 +30,29 @@ module.exports = plop => {
|
|
|
7
30
|
prompts: [
|
|
8
31
|
{
|
|
9
32
|
type: 'input',
|
|
10
|
-
name: '
|
|
33
|
+
name: 'pluginName',
|
|
11
34
|
message: 'Plugin name',
|
|
12
35
|
},
|
|
13
36
|
],
|
|
14
|
-
actions
|
|
37
|
+
actions(answers) {
|
|
15
38
|
return [
|
|
16
39
|
{
|
|
17
40
|
type: 'addMany',
|
|
18
|
-
destination: 'plugins/{{
|
|
19
|
-
base: 'files/plugin
|
|
20
|
-
templateFiles: 'files/plugin
|
|
21
|
-
},
|
|
22
|
-
{
|
|
23
|
-
type: 'add',
|
|
24
|
-
path: 'plugins/{{id}}/services/{{id}}.js',
|
|
25
|
-
templateFile: 'templates/service.js.hbs',
|
|
26
|
-
},
|
|
27
|
-
{
|
|
28
|
-
type: 'add',
|
|
29
|
-
path: 'plugins/{{id}}/controllers/{{id}}.js',
|
|
30
|
-
templateFile: 'templates/controller.js.hbs',
|
|
31
|
-
},
|
|
32
|
-
{
|
|
33
|
-
type: 'add',
|
|
34
|
-
path: 'plugins/{{id}}/config/routes.json',
|
|
35
|
-
templateFile: 'templates/plugin-routes.json.hbs',
|
|
41
|
+
destination: 'plugins/{{ pluginName }}',
|
|
42
|
+
base: 'files/plugin',
|
|
43
|
+
templateFiles: 'files/plugin/**',
|
|
36
44
|
},
|
|
37
45
|
{
|
|
38
46
|
type: 'add',
|
|
39
|
-
path: 'plugins/{{
|
|
47
|
+
path: 'plugins/{{ pluginName }}/README.md',
|
|
40
48
|
templateFile: 'templates/README.md.hbs',
|
|
41
49
|
},
|
|
42
50
|
{
|
|
43
51
|
type: 'add',
|
|
44
|
-
path: 'plugins/{{
|
|
52
|
+
path: 'plugins/{{ pluginName }}/package.json',
|
|
45
53
|
templateFile: 'templates/plugin-package.json.hbs',
|
|
46
54
|
},
|
|
55
|
+
() => plop.renderString(logInstructions(answers.pluginName)),
|
|
47
56
|
];
|
|
48
57
|
},
|
|
49
58
|
});
|
package/lib/plops/policy.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const getDestinationPrompts = require('./
|
|
3
|
+
const getDestinationPrompts = require('./prompts/get-destination-prompts');
|
|
4
4
|
|
|
5
5
|
module.exports = plop => {
|
|
6
6
|
// Policy generator
|
|
@@ -12,9 +12,9 @@ module.exports = plop => {
|
|
|
12
12
|
name: 'id',
|
|
13
13
|
message: 'Policy name',
|
|
14
14
|
},
|
|
15
|
-
...getDestinationPrompts('policy', plop.getDestBasePath()),
|
|
15
|
+
...getDestinationPrompts('policy', plop.getDestBasePath(), { rootFolder: true }),
|
|
16
16
|
],
|
|
17
|
-
actions
|
|
17
|
+
actions(answers) {
|
|
18
18
|
let filePath;
|
|
19
19
|
if (answers.destination === 'api') {
|
|
20
20
|
filePath = `api/{{api}}`;
|
|
@@ -27,7 +27,7 @@ module.exports = plop => {
|
|
|
27
27
|
return [
|
|
28
28
|
{
|
|
29
29
|
type: 'add',
|
|
30
|
-
path: `${filePath}/
|
|
30
|
+
path: `${filePath}/policies/{{id}}.js`,
|
|
31
31
|
templateFile: 'templates/policy.js.hbs',
|
|
32
32
|
},
|
|
33
33
|
];
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const pluralize = require('pluralize');
|
|
4
|
+
const slugify = require('@sindresorhus/slugify');
|
|
5
|
+
const { isKebabCase } = require('@strapi/utils');
|
|
6
|
+
|
|
7
|
+
module.exports = [
|
|
8
|
+
{
|
|
9
|
+
type: 'input',
|
|
10
|
+
name: 'displayName',
|
|
11
|
+
message: 'Content type display name',
|
|
12
|
+
validate: input => !!input,
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
type: 'input',
|
|
16
|
+
name: 'singularName',
|
|
17
|
+
message: 'Content type singular name',
|
|
18
|
+
default: answers => slugify(answers.displayName),
|
|
19
|
+
validate(input) {
|
|
20
|
+
if (!isKebabCase(input)) {
|
|
21
|
+
return 'Value must be in kebab-case';
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
return true;
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
type: 'input',
|
|
29
|
+
name: 'pluralName',
|
|
30
|
+
message: 'Content type plural name',
|
|
31
|
+
default: answers => pluralize(answers.singularName),
|
|
32
|
+
validate(input, answers) {
|
|
33
|
+
if (answers.singularName === input) {
|
|
34
|
+
return 'Singular and plural names cannot be the same';
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
if (!isKebabCase(input)) {
|
|
38
|
+
return 'Value must be in kebab-case';
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
return true;
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
];
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const validateInput = require('../utils/validate-input');
|
|
4
|
+
|
|
5
|
+
const DEFAULT_TYPES = [
|
|
6
|
+
// advanced types
|
|
7
|
+
'media',
|
|
8
|
+
|
|
9
|
+
// scalar types
|
|
10
|
+
'string',
|
|
11
|
+
'text',
|
|
12
|
+
'richtext',
|
|
13
|
+
'json',
|
|
14
|
+
'enumeration',
|
|
15
|
+
'password',
|
|
16
|
+
'email',
|
|
17
|
+
'integer',
|
|
18
|
+
'biginteger',
|
|
19
|
+
'float',
|
|
20
|
+
'decimal',
|
|
21
|
+
'date',
|
|
22
|
+
'time',
|
|
23
|
+
'datetime',
|
|
24
|
+
'timestamp',
|
|
25
|
+
'boolean',
|
|
26
|
+
];
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* @param {import('inquirer').Inquirer} inquirer
|
|
30
|
+
* @returns {Promise<Record<string, string>[]>}
|
|
31
|
+
*/
|
|
32
|
+
module.exports = async inquirer => {
|
|
33
|
+
const { addAttributes } = await inquirer.prompt([
|
|
34
|
+
{
|
|
35
|
+
type: 'confirm',
|
|
36
|
+
name: 'addAttributes',
|
|
37
|
+
message: 'Do you want to add attributes?',
|
|
38
|
+
},
|
|
39
|
+
]);
|
|
40
|
+
|
|
41
|
+
const attributes = [];
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* @param {import('inquirer').Inquirer} inquirer
|
|
45
|
+
* @returns {Promise<void>}
|
|
46
|
+
*/
|
|
47
|
+
const createNewAttributes = async inquirer => {
|
|
48
|
+
const answers = await inquirer.prompt([
|
|
49
|
+
{
|
|
50
|
+
type: 'input',
|
|
51
|
+
name: 'attributeName',
|
|
52
|
+
message: 'Name of attribute',
|
|
53
|
+
validate: input => validateInput(input),
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
type: 'list',
|
|
57
|
+
name: 'attributeType',
|
|
58
|
+
message: 'What type of attribute',
|
|
59
|
+
pageSize: DEFAULT_TYPES.length,
|
|
60
|
+
choices: DEFAULT_TYPES.map(type => {
|
|
61
|
+
return { name: type, value: type };
|
|
62
|
+
}),
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
when: answers => answers.attributeType === 'enumeration',
|
|
66
|
+
type: 'input',
|
|
67
|
+
name: 'enum',
|
|
68
|
+
message: 'Add values separated by a comma',
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
when: answers => answers.attributeType === 'media',
|
|
72
|
+
type: 'list',
|
|
73
|
+
name: 'multiple',
|
|
74
|
+
message: 'Choose media type',
|
|
75
|
+
choices: [{ name: 'Multiple', value: true }, { name: 'Single', value: false }],
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
type: 'confirm',
|
|
79
|
+
name: 'addAttributes',
|
|
80
|
+
message: 'Do you want to add another attribute?',
|
|
81
|
+
},
|
|
82
|
+
]);
|
|
83
|
+
|
|
84
|
+
attributes.push(answers);
|
|
85
|
+
|
|
86
|
+
if (!answers.addAttributes) {
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
await createNewAttributes(inquirer);
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
if (addAttributes) {
|
|
94
|
+
await createNewAttributes(inquirer);
|
|
95
|
+
} else {
|
|
96
|
+
console.warn(
|
|
97
|
+
`You won't be able to manage entries from the admin, you can still add attributes later from the content type builder.`
|
|
98
|
+
);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
return attributes;
|
|
102
|
+
};
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
const { join } = require('path');
|
|
3
3
|
const fs = require('fs-extra');
|
|
4
4
|
|
|
5
|
-
module.exports = (action, basePath) => {
|
|
5
|
+
module.exports = (action, basePath, { rootFolder = false } = {}) => {
|
|
6
6
|
return [
|
|
7
7
|
{
|
|
8
8
|
type: 'list',
|
|
@@ -10,7 +10,7 @@ module.exports = (action, basePath) => {
|
|
|
10
10
|
message: `Where do you want to add this ${action}?`,
|
|
11
11
|
choices: [
|
|
12
12
|
{
|
|
13
|
-
name: `Add ${action} to ${
|
|
13
|
+
name: `Add ${action} to ${rootFolder ? 'root of project' : 'new API'}`,
|
|
14
14
|
value: 'new',
|
|
15
15
|
},
|
|
16
16
|
{ name: `Add ${action} to an existing API`, value: 'api' },
|
|
@@ -22,7 +22,7 @@ module.exports = (action, basePath) => {
|
|
|
22
22
|
type: 'list',
|
|
23
23
|
message: 'Which API is this for?',
|
|
24
24
|
name: 'api',
|
|
25
|
-
|
|
25
|
+
async choices() {
|
|
26
26
|
const apiPath = join(basePath, 'api');
|
|
27
27
|
const exists = await fs.pathExists(apiPath);
|
|
28
28
|
|
|
@@ -45,7 +45,7 @@ module.exports = (action, basePath) => {
|
|
|
45
45
|
type: 'list',
|
|
46
46
|
message: 'Which plugin is this for?',
|
|
47
47
|
name: 'plugin',
|
|
48
|
-
|
|
48
|
+
async choices() {
|
|
49
49
|
const pluginsPath = join(basePath, 'plugins');
|
|
50
50
|
const exists = await fs.pathExists(pluginsPath);
|
|
51
51
|
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const validateInput = require('../utils/validate-input');
|
|
4
|
+
|
|
5
|
+
module.exports = [
|
|
6
|
+
{
|
|
7
|
+
type: 'list',
|
|
8
|
+
name: 'kind',
|
|
9
|
+
message: 'Please choose the model type',
|
|
10
|
+
default: 'collectionType',
|
|
11
|
+
choices: [
|
|
12
|
+
{ name: 'Collection Type', value: 'collectionType' },
|
|
13
|
+
{ name: 'Single Type', value: 'singleType' },
|
|
14
|
+
],
|
|
15
|
+
validate: input => validateInput(input),
|
|
16
|
+
},
|
|
17
|
+
];
|
package/lib/plops/service.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const getDestinationPrompts = require('./
|
|
3
|
+
const getDestinationPrompts = require('./prompts/get-destination-prompts');
|
|
4
4
|
const getFilePath = require('./utils/get-file-path');
|
|
5
5
|
|
|
6
6
|
module.exports = plop => {
|
|
@@ -15,12 +15,12 @@ module.exports = plop => {
|
|
|
15
15
|
},
|
|
16
16
|
...getDestinationPrompts('service', plop.getDestBasePath()),
|
|
17
17
|
],
|
|
18
|
-
actions
|
|
18
|
+
actions(answers) {
|
|
19
19
|
const filePath = getFilePath(answers.destination);
|
|
20
20
|
return [
|
|
21
21
|
{
|
|
22
22
|
type: 'add',
|
|
23
|
-
path: `${filePath}/services/{{id}}.js`,
|
|
23
|
+
path: `${filePath}/services/{{ id }}.js`,
|
|
24
24
|
templateFile: 'templates/service.js.hbs',
|
|
25
25
|
},
|
|
26
26
|
];
|
|
@@ -2,12 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
module.exports = destination => {
|
|
4
4
|
if (destination === 'api') {
|
|
5
|
-
return `api/{{api}}`;
|
|
5
|
+
return `api/{{ api }}`;
|
|
6
6
|
}
|
|
7
7
|
|
|
8
8
|
if (destination === 'plugin') {
|
|
9
|
-
return `plugins/{{plugin}}`;
|
|
9
|
+
return `plugins/{{ plugin }}`;
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
-
return `api/{{id}}`;
|
|
12
|
+
return `api/{{ id }}`;
|
|
13
13
|
};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
# Strapi plugin {{
|
|
1
|
+
# Strapi plugin {{ pluginName }}
|
|
2
2
|
|
|
3
|
-
A quick description of {{
|
|
3
|
+
A quick description of {{ pluginName }}.
|
|
@@ -6,6 +6,7 @@ module.exports = {
|
|
|
6
6
|
handler: '{{id}}.find',
|
|
7
7
|
config: {
|
|
8
8
|
policies: [],
|
|
9
|
+
middlewares: [],
|
|
9
10
|
},
|
|
10
11
|
},
|
|
11
12
|
{
|
|
@@ -14,6 +15,7 @@ module.exports = {
|
|
|
14
15
|
handler: '{{id}}.findOne',
|
|
15
16
|
config: {
|
|
16
17
|
policies: [],
|
|
18
|
+
middlewares: [],
|
|
17
19
|
},
|
|
18
20
|
},
|
|
19
21
|
{
|
|
@@ -22,6 +24,7 @@ module.exports = {
|
|
|
22
24
|
handler: '{{id}}.create',
|
|
23
25
|
config: {
|
|
24
26
|
policies: [],
|
|
27
|
+
middlewares: [],
|
|
25
28
|
},
|
|
26
29
|
},
|
|
27
30
|
{
|
|
@@ -30,6 +33,7 @@ module.exports = {
|
|
|
30
33
|
handler: '{{id}}.update',
|
|
31
34
|
config: {
|
|
32
35
|
policies: [],
|
|
36
|
+
middlewares: [],
|
|
33
37
|
},
|
|
34
38
|
},
|
|
35
39
|
{
|
|
@@ -38,6 +42,7 @@ module.exports = {
|
|
|
38
42
|
handler: '{{id}}.delete',
|
|
39
43
|
config: {
|
|
40
44
|
policies: [],
|
|
45
|
+
middlewares: [],
|
|
41
46
|
},
|
|
42
47
|
},
|
|
43
48
|
],
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
|
|
2
|
+
{
|
|
3
|
+
"kind": "{{kind}}",
|
|
4
|
+
"collectionName": "{{ collectionName }}",
|
|
5
|
+
"info": {
|
|
6
|
+
"singularName": "{{ singularName }}",
|
|
7
|
+
"pluralName": "{{ pluralName }}",
|
|
8
|
+
"displayName": "{{ displayName }}"
|
|
9
|
+
},
|
|
10
|
+
"options": {
|
|
11
|
+
"draftAndPublish": {{ useDraftAndPublish }},
|
|
12
|
+
"comment": ""
|
|
13
|
+
},
|
|
14
|
+
"attributes": {}
|
|
15
|
+
}
|
|
@@ -1,23 +1,19 @@
|
|
|
1
1
|
{
|
|
2
|
-
"name": "
|
|
2
|
+
"name": "{{ pluginName }}",
|
|
3
3
|
"version": "0.0.0",
|
|
4
4
|
"description": "This is the description of the plugin.",
|
|
5
5
|
"strapi": {
|
|
6
|
-
"name": "{{
|
|
7
|
-
"
|
|
8
|
-
"
|
|
6
|
+
"name": "{{ pluginName }}",
|
|
7
|
+
"description": "Description of {{ pluginName }} plugin",
|
|
8
|
+
"kind": "plugin"
|
|
9
9
|
},
|
|
10
10
|
"dependencies": {},
|
|
11
11
|
"author": {
|
|
12
|
-
"name": "A Strapi developer"
|
|
13
|
-
"email": "",
|
|
14
|
-
"url": ""
|
|
12
|
+
"name": "A Strapi developer"
|
|
15
13
|
},
|
|
16
14
|
"maintainers": [
|
|
17
15
|
{
|
|
18
|
-
"name": "A Strapi developer"
|
|
19
|
-
"email": "",
|
|
20
|
-
"url": ""
|
|
16
|
+
"name": "A Strapi developer"
|
|
21
17
|
}
|
|
22
18
|
],
|
|
23
19
|
"engines": {
|
|
@@ -4,9 +4,15 @@
|
|
|
4
4
|
* `{{id}}` policy.
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
module.exports =
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
module.exports = (policyContext, config, { strapi }) => {
|
|
8
|
+
// Add your own logic here.
|
|
9
|
+
strapi.log.info('In {{id}} policy.');
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
const canDoSomething = true;
|
|
12
|
+
|
|
13
|
+
if (canDoSomething) {
|
|
14
|
+
return true;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
return false;
|
|
12
18
|
};
|
|
@@ -6,6 +6,7 @@ module.exports = {
|
|
|
6
6
|
handler: '{{id}}.find',
|
|
7
7
|
config: {
|
|
8
8
|
policies: [],
|
|
9
|
+
middlewares: [],
|
|
9
10
|
},
|
|
10
11
|
},
|
|
11
12
|
{
|
|
@@ -14,14 +15,16 @@ module.exports = {
|
|
|
14
15
|
handler: '{{id}}.update',
|
|
15
16
|
config: {
|
|
16
17
|
policies: [],
|
|
18
|
+
middlewares: [],
|
|
17
19
|
},
|
|
18
20
|
},
|
|
19
21
|
{
|
|
20
22
|
method: 'DELETE',
|
|
21
|
-
path: '/{{id}}
|
|
23
|
+
path: '/{{id}}',
|
|
22
24
|
handler: '{{id}}.delete',
|
|
23
25
|
config: {
|
|
24
26
|
policies: [],
|
|
27
|
+
middlewares: [],
|
|
25
28
|
},
|
|
26
29
|
},
|
|
27
30
|
],
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@strapi/generators",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.3",
|
|
4
4
|
"description": "Interactive API generator.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"strapi",
|
|
@@ -16,26 +16,30 @@
|
|
|
16
16
|
},
|
|
17
17
|
"license": "SEE LICENSE IN LICENSE",
|
|
18
18
|
"author": {
|
|
19
|
-
"name": "Strapi
|
|
19
|
+
"name": "Strapi Solutions SAS",
|
|
20
20
|
"email": "hi@strapi.io",
|
|
21
21
|
"url": "https://strapi.io"
|
|
22
22
|
},
|
|
23
23
|
"maintainers": [
|
|
24
24
|
{
|
|
25
|
-
"name": "Strapi
|
|
25
|
+
"name": "Strapi Solutions SAS",
|
|
26
26
|
"email": "hi@strapi.io",
|
|
27
27
|
"url": "https://strapi.io"
|
|
28
28
|
}
|
|
29
29
|
],
|
|
30
30
|
"main": "lib/index.js",
|
|
31
31
|
"dependencies": {
|
|
32
|
+
"@sindresorhus/slugify": "1.1.0",
|
|
33
|
+
"@strapi/utils": "4.0.3",
|
|
34
|
+
"chalk": "4.1.2",
|
|
32
35
|
"fs-extra": "10.0.0",
|
|
33
|
-
"node-plop": "0.26.
|
|
34
|
-
"plop": "2.7.
|
|
36
|
+
"node-plop": "0.26.3",
|
|
37
|
+
"plop": "2.7.6",
|
|
35
38
|
"pluralize": "8.0.0"
|
|
36
39
|
},
|
|
37
40
|
"engines": {
|
|
38
|
-
"node": ">=12.
|
|
41
|
+
"node": ">=12.22.0 <=16.x.x",
|
|
39
42
|
"npm": ">=6.0.0"
|
|
40
|
-
}
|
|
43
|
+
},
|
|
44
|
+
"gitHead": "48893ae3fc951b618fd8c4fdc6970e623d2c92db"
|
|
41
45
|
}
|