@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.
@@ -0,0 +1,5 @@
1
+ 'use strict';
2
+
3
+ module.exports = ({ strapi }) => {
4
+ // bootstrap phase
5
+ };
@@ -0,0 +1,6 @@
1
+ 'use strict';
2
+
3
+ module.exports = {
4
+ default: {},
5
+ validator() {},
6
+ };
@@ -0,0 +1,7 @@
1
+ 'use strict';
2
+
3
+ const myController = require('./my-controller');
4
+
5
+ module.exports = {
6
+ myController,
7
+ };
@@ -0,0 +1,10 @@
1
+ 'use strict';
2
+
3
+ module.exports = {
4
+ index(ctx) {
5
+ ctx.body = strapi
6
+ .plugin('{{ id }}')
7
+ .service('myService')
8
+ .getWelcomeMessage();
9
+ },
10
+ };
@@ -0,0 +1,5 @@
1
+ 'use strict';
2
+
3
+ module.exports = ({ strapi }) => {
4
+ // destroy phase
5
+ };
@@ -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
+ };
@@ -0,0 +1,5 @@
1
+ 'use strict';
2
+
3
+ module.exports = ({ strapi }) => {
4
+ // registeration phase
5
+ };
@@ -0,0 +1,10 @@
1
+ module.exports = [
2
+ {
3
+ method: 'GET',
4
+ path: '/',
5
+ handler: 'myController.index',
6
+ config: {
7
+ policies: [],
8
+ },
9
+ },
10
+ ];
@@ -0,0 +1,7 @@
1
+ 'use strict';
2
+
3
+ const myService = require('./my-service');
4
+
5
+ module.exports = {
6
+ myService,
7
+ };
@@ -0,0 +1,7 @@
1
+ 'use strict';
2
+
3
+ module.exports = ({ strapi }) => ({
4
+ getWelcomeMessage() {
5
+ return 'Welcome to Strapi 🚀';
6
+ },
7
+ });
@@ -0,0 +1,3 @@
1
+ 'use strict';
2
+
3
+ module.exports = require('./admin/src').default;
@@ -0,0 +1,3 @@
1
+ 'use strict';
2
+
3
+ module.exports = require('./server');
package/lib/plops/api.js CHANGED
@@ -77,7 +77,7 @@ module.exports = plop => {
77
77
  {
78
78
  type: 'add',
79
79
  path: `${filePath}/content-types/{{id}}/schema.json`,
80
- templateFile: 'templates/model.schema.json.hbs',
80
+ templateFile: 'templates/content-type.schema.json.hbs',
81
81
  },
82
82
  {
83
83
  type: 'add',
@@ -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/model.schema.json.hbs',
160
+ templateFile: 'templates/content-type.schema.json.hbs',
161
161
  },
162
162
  {
163
163
  type: 'modify',
@@ -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: 'id',
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/{{id}}/admin',
19
- base: 'files/plugin/admin',
20
- templateFiles: 'files/plugin/admin/**',
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/{{id}}/README.md',
47
+ path: 'plugins/{{ pluginName }}/README.md',
40
48
  templateFile: 'templates/README.md.hbs',
41
49
  },
42
50
  {
43
51
  type: 'add',
44
- path: 'plugins/{{id}}/package.json',
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 {{id}}
1
+ # Strapi plugin {{ pluginName }}
2
2
 
3
- A quick description of {{id}}.
3
+ A quick description of {{ pluginName }}.
@@ -1,23 +1,20 @@
1
1
  {
2
- "name": "strapi-plugin-{{id}}",
2
+ "name": "{{ pluginName }}",
3
3
  "version": "0.0.0",
4
4
  "description": "This is the description of the plugin.",
5
5
  "strapi": {
6
- "name": "{{id}}",
6
+ "name": "{{ pluginName }}",
7
7
  "icon": "plug",
8
- "description": "Description of {{id}} plugin."
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.0",
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": "9807c78cb7ab6373b7abb46da5ecc4980a9ea56c"
42
+ "gitHead": "5e341674da4f2ef1b99a910e92128674658a80de"
42
43
  }
@@ -1,12 +0,0 @@
1
- {
2
- "routes": [
3
- {
4
- "method": "GET",
5
- "path": "/",
6
- "handler": "{{id}}.index",
7
- "config": {
8
- "policies": []
9
- }
10
- }
11
- ]
12
- }