@strapi/generators 4.0.0-beta.13 → 4.0.0-beta.17

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.
@@ -3,7 +3,7 @@
3
3
  module.exports = {
4
4
  index(ctx) {
5
5
  ctx.body = strapi
6
- .plugin('{{ id }}')
6
+ .plugin('{{ pluginName }}')
7
7
  .service('myService')
8
8
  .getWelcomeMessage();
9
9
  },
@@ -3,6 +3,7 @@
3
3
  const { join } = require('path');
4
4
  const slugify = require('@sindresorhus/slugify');
5
5
  const fs = require('fs-extra');
6
+ const { isKebabCase } = require('@strapi/utils');
6
7
 
7
8
  const getDestinationPrompts = require('./prompts/get-destination-prompts');
8
9
  const getFilePath = require('./utils/get-file-path');
@@ -33,6 +34,10 @@ module.exports = plop => {
33
34
  default: config.singularName,
34
35
  message: 'Name of the new API?',
35
36
  async validate(input) {
37
+ if (!isKebabCase(input)) {
38
+ return 'Value must be in kebab-case';
39
+ }
40
+
36
41
  const apiPath = join(plop.getDestBasePath(), 'api');
37
42
  const exists = await fs.pathExists(apiPath);
38
43
 
@@ -101,21 +106,35 @@ module.exports = plop => {
101
106
  }
102
107
 
103
108
  if (answers.bootstrapApi) {
109
+ const { singularName } = answers;
110
+
111
+ let uid;
112
+ if (answers.destination === 'new') {
113
+ uid = `api::${answers.id}.${singularName}`;
114
+ } else if (answers.api) {
115
+ uid = `api::${answers.api}.${singularName}`;
116
+ } else if (answers.plugin) {
117
+ uid = `plugin::${answers.plugin}.${singularName}`;
118
+ }
119
+
104
120
  baseActions.push(
105
121
  {
106
122
  type: 'add',
107
123
  path: `${filePath}/controllers/{{singularName}}.js`,
108
- templateFile: 'templates/controller.js.hbs',
124
+ templateFile: 'templates/core-controller.js.hbs',
125
+ data: { uid },
109
126
  },
110
127
  {
111
128
  type: 'add',
112
129
  path: `${filePath}/services/{{singularName}}.js`,
113
- templateFile: 'templates/service.js.hbs',
130
+ templateFile: 'templates/core-service.js.hbs',
131
+ data: { uid },
114
132
  },
115
133
  {
116
134
  type: 'add',
117
135
  path: `${filePath}/routes/{{singularName}}.js`,
118
- templateFile: `templates/${slugify(answers.kind)}-routes.js.hbs`,
136
+ templateFile: `templates/core-router.js.hbs`,
137
+ data: { uid },
119
138
  }
120
139
  );
121
140
  }
@@ -92,6 +92,10 @@ module.exports = async inquirer => {
92
92
 
93
93
  if (addAttributes) {
94
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
+ );
95
99
  }
96
100
 
97
101
  return attributes;
@@ -0,0 +1,9 @@
1
+ 'use strict';
2
+
3
+ /**
4
+ * {{ id }} controller
5
+ */
6
+
7
+ const { createCoreController } = require('@strapi/strapi').factories;
8
+
9
+ module.exports = createCoreController('{{ uid }}');
@@ -0,0 +1,9 @@
1
+ 'use strict';
2
+
3
+ /**
4
+ * {{ id }} router.
5
+ */
6
+
7
+ const { createCoreRouter } = require('@strapi/strapi').factories;
8
+
9
+ module.exports = createCoreRouter('{{ uid }}');
@@ -0,0 +1,9 @@
1
+ 'use strict';
2
+
3
+ /**
4
+ * {{ id }} service.
5
+ */
6
+
7
+ const { createCoreService } = require('@strapi/strapi').factories;
8
+
9
+ module.exports = createCoreService('{{ uid }}');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@strapi/generators",
3
- "version": "4.0.0-beta.13",
3
+ "version": "4.0.0-beta.17",
4
4
  "description": "Interactive API generator.",
5
5
  "keywords": [
6
6
  "strapi",
@@ -30,7 +30,7 @@
30
30
  "main": "lib/index.js",
31
31
  "dependencies": {
32
32
  "@sindresorhus/slugify": "1.1.0",
33
- "@strapi/utils": "4.0.0-beta.13",
33
+ "@strapi/utils": "4.0.0-beta.17",
34
34
  "chalk": "4.1.2",
35
35
  "fs-extra": "10.0.0",
36
36
  "node-plop": "0.26.3",
@@ -41,5 +41,5 @@
41
41
  "node": ">=12.x.x <=16.x.x",
42
42
  "npm": ">=6.0.0"
43
43
  },
44
- "gitHead": "3a31a96067aa0a74cabf51282215820ba46dd447"
44
+ "gitHead": "8f9cf3803464d3dbfc8c1090c16bb5f53a60c6c3"
45
45
  }