@strapi/generators 4.0.0-beta.0 → 4.0.0-beta.1
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/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/plops/api.js +1 -1
- package/lib/plops/content-type.js +1 -1
- package/lib/plops/plugin.js +31 -22
- package/lib/templates/README.md.hbs +2 -2
- package/lib/templates/{model.schema.json.hbs → content-type.schema.json.hbs} +0 -0
- package/lib/templates/plugin-package.json.hbs +6 -9
- package/package.json +3 -2
- package/lib/templates/plugin-routes.json.hbs +0 -12
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const register = require('./register');
|
|
4
|
+
const bootstrap = require('./bootstrap');
|
|
5
|
+
const destroy = require('./destroy');
|
|
6
|
+
const config = require('./config');
|
|
7
|
+
const controllers = require('./controllers');
|
|
8
|
+
const routes = require('./routes');
|
|
9
|
+
const services = require('./services');
|
|
10
|
+
|
|
11
|
+
module.exports = {
|
|
12
|
+
register,
|
|
13
|
+
bootstrap,
|
|
14
|
+
destroy,
|
|
15
|
+
config,
|
|
16
|
+
controllers,
|
|
17
|
+
routes,
|
|
18
|
+
services,
|
|
19
|
+
contentTypes: {},
|
|
20
|
+
policies: {},
|
|
21
|
+
middlewares: {},
|
|
22
|
+
};
|
package/lib/plops/api.js
CHANGED
|
@@ -157,7 +157,7 @@ module.exports = plop => {
|
|
|
157
157
|
{
|
|
158
158
|
type: 'add',
|
|
159
159
|
path: `${filePath}/content-types/{{id}}/schema.json`,
|
|
160
|
-
templateFile: 'templates/
|
|
160
|
+
templateFile: 'templates/content-type.schema.json.hbs',
|
|
161
161
|
},
|
|
162
162
|
{
|
|
163
163
|
type: 'modify',
|
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
|
});
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
# Strapi plugin {{
|
|
1
|
+
# Strapi plugin {{ pluginName }}
|
|
2
2
|
|
|
3
|
-
A quick description of {{
|
|
3
|
+
A quick description of {{ pluginName }}.
|
|
File without changes
|
|
@@ -1,23 +1,20 @@
|
|
|
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": "{{
|
|
6
|
+
"name": "{{ pluginName }}",
|
|
7
7
|
"icon": "plug",
|
|
8
|
-
"description": "Description of {{
|
|
8
|
+
"description": "Description of {{ pluginName }} plugin",
|
|
9
|
+
"kind": "plugin"
|
|
9
10
|
},
|
|
10
11
|
"dependencies": {},
|
|
11
12
|
"author": {
|
|
12
|
-
"name": "A Strapi developer"
|
|
13
|
-
"email": "",
|
|
14
|
-
"url": ""
|
|
13
|
+
"name": "A Strapi developer"
|
|
15
14
|
},
|
|
16
15
|
"maintainers": [
|
|
17
16
|
{
|
|
18
|
-
"name": "A Strapi developer"
|
|
19
|
-
"email": "",
|
|
20
|
-
"url": ""
|
|
17
|
+
"name": "A Strapi developer"
|
|
21
18
|
}
|
|
22
19
|
],
|
|
23
20
|
"engines": {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@strapi/generators",
|
|
3
|
-
"version": "4.0.0-beta.
|
|
3
|
+
"version": "4.0.0-beta.1",
|
|
4
4
|
"description": "Interactive API generator.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"strapi",
|
|
@@ -29,6 +29,7 @@
|
|
|
29
29
|
],
|
|
30
30
|
"main": "lib/index.js",
|
|
31
31
|
"dependencies": {
|
|
32
|
+
"chalk": "4.1.2",
|
|
32
33
|
"fs-extra": "10.0.0",
|
|
33
34
|
"node-plop": "0.26.2",
|
|
34
35
|
"plop": "2.7.4",
|
|
@@ -38,5 +39,5 @@
|
|
|
38
39
|
"node": ">=12.x.x <=16.x.x",
|
|
39
40
|
"npm": ">=6.0.0"
|
|
40
41
|
},
|
|
41
|
-
"gitHead": "
|
|
42
|
+
"gitHead": "5e341674da4f2ef1b99a910e92128674658a80de"
|
|
42
43
|
}
|