@strapi/generators 0.0.0-next.f0a0bc26f5ef0693aaea2a616bc6b816cfee54b6 → 0.0.0-next.f0f36e3df4b18f167036dcbca529dcb933bf4e1d

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.
Files changed (109) hide show
  1. package/dist/index.d.ts +8 -4
  2. package/dist/index.d.ts.map +1 -1
  3. package/dist/index.js +89 -50
  4. package/dist/index.js.map +1 -1
  5. package/dist/index.mjs +89 -29
  6. package/dist/index.mjs.map +1 -1
  7. package/dist/plopfile.js +25 -584
  8. package/dist/plopfile.js.map +1 -1
  9. package/dist/plopfile.mjs +24 -581
  10. package/dist/plopfile.mjs.map +1 -1
  11. package/dist/plops/api.d.ts.map +1 -1
  12. package/dist/plops/api.js +149 -0
  13. package/dist/plops/api.js.map +1 -0
  14. package/dist/plops/api.mjs +147 -0
  15. package/dist/plops/api.mjs.map +1 -0
  16. package/dist/plops/content-type.d.ts.map +1 -1
  17. package/dist/plops/content-type.js +245 -0
  18. package/dist/plops/content-type.js.map +1 -0
  19. package/dist/plops/content-type.mjs +243 -0
  20. package/dist/plops/content-type.mjs.map +1 -0
  21. package/dist/plops/controller.d.ts.map +1 -1
  22. package/dist/plops/controller.js +73 -0
  23. package/dist/plops/controller.js.map +1 -0
  24. package/dist/plops/controller.mjs +71 -0
  25. package/dist/plops/controller.mjs.map +1 -0
  26. package/dist/plops/middleware.d.ts.map +1 -1
  27. package/dist/plops/middleware.js +75 -0
  28. package/dist/plops/middleware.js.map +1 -0
  29. package/dist/plops/middleware.mjs +73 -0
  30. package/dist/plops/middleware.mjs.map +1 -0
  31. package/dist/plops/migration.js +35 -0
  32. package/dist/plops/migration.js.map +1 -0
  33. package/dist/plops/migration.mjs +33 -0
  34. package/dist/plops/migration.mjs.map +1 -0
  35. package/dist/plops/policy.d.ts.map +1 -1
  36. package/dist/plops/policy.js +75 -0
  37. package/dist/plops/policy.js.map +1 -0
  38. package/dist/plops/policy.mjs +73 -0
  39. package/dist/plops/policy.mjs.map +1 -0
  40. package/dist/plops/prompts/bootstrap-api-prompts.d.ts +6 -2
  41. package/dist/plops/prompts/bootstrap-api-prompts.d.ts.map +1 -1
  42. package/dist/plops/prompts/bootstrap-api-prompts.js +13 -0
  43. package/dist/plops/prompts/bootstrap-api-prompts.js.map +1 -0
  44. package/dist/plops/prompts/bootstrap-api-prompts.mjs +11 -0
  45. package/dist/plops/prompts/bootstrap-api-prompts.mjs.map +1 -0
  46. package/dist/plops/prompts/ct-names-prompts.d.ts +18 -2
  47. package/dist/plops/prompts/ct-names-prompts.d.ts.map +1 -1
  48. package/dist/plops/prompts/ct-names-prompts.js +44 -0
  49. package/dist/plops/prompts/ct-names-prompts.js.map +1 -0
  50. package/dist/plops/prompts/ct-names-prompts.mjs +42 -0
  51. package/dist/plops/prompts/ct-names-prompts.mjs.map +1 -0
  52. package/dist/plops/prompts/get-attributes-prompts.d.ts +8 -2
  53. package/dist/plops/prompts/get-attributes-prompts.d.ts.map +1 -1
  54. package/dist/plops/prompts/get-attributes-prompts.js +101 -0
  55. package/dist/plops/prompts/get-attributes-prompts.js.map +1 -0
  56. package/dist/plops/prompts/get-attributes-prompts.mjs +99 -0
  57. package/dist/plops/prompts/get-attributes-prompts.mjs.map +1 -0
  58. package/dist/plops/prompts/get-destination-prompts.d.ts +24 -2
  59. package/dist/plops/prompts/get-destination-prompts.d.ts.map +1 -1
  60. package/dist/plops/prompts/get-destination-prompts.js +78 -0
  61. package/dist/plops/prompts/get-destination-prompts.js.map +1 -0
  62. package/dist/plops/prompts/get-destination-prompts.mjs +76 -0
  63. package/dist/plops/prompts/get-destination-prompts.mjs.map +1 -0
  64. package/dist/plops/prompts/kind-prompts.d.ts +11 -2
  65. package/dist/plops/prompts/kind-prompts.d.ts.map +1 -1
  66. package/dist/plops/prompts/kind-prompts.js +26 -0
  67. package/dist/plops/prompts/kind-prompts.js.map +1 -0
  68. package/dist/plops/prompts/kind-prompts.mjs +24 -0
  69. package/dist/plops/prompts/kind-prompts.mjs.map +1 -0
  70. package/dist/plops/service.d.ts.map +1 -1
  71. package/dist/plops/service.js +71 -0
  72. package/dist/plops/service.js.map +1 -0
  73. package/dist/plops/service.mjs +69 -0
  74. package/dist/plops/service.mjs.map +1 -0
  75. package/dist/plops/utils/extend-plugin-index-files.d.ts +8 -0
  76. package/dist/plops/utils/extend-plugin-index-files.d.ts.map +1 -0
  77. package/dist/plops/utils/extend-plugin-index-files.js +356 -0
  78. package/dist/plops/utils/extend-plugin-index-files.js.map +1 -0
  79. package/dist/plops/utils/extend-plugin-index-files.mjs +335 -0
  80. package/dist/plops/utils/extend-plugin-index-files.mjs.map +1 -0
  81. package/dist/plops/utils/get-file-path.d.ts +1 -1
  82. package/dist/plops/utils/get-file-path.js +17 -0
  83. package/dist/plops/utils/get-file-path.js.map +1 -0
  84. package/dist/plops/utils/get-file-path.mjs +15 -0
  85. package/dist/plops/utils/get-file-path.mjs.map +1 -0
  86. package/dist/plops/utils/get-formatted-date.js +8 -0
  87. package/dist/plops/utils/get-formatted-date.js.map +1 -0
  88. package/dist/plops/utils/get-formatted-date.mjs +6 -0
  89. package/dist/plops/utils/get-formatted-date.mjs.map +1 -0
  90. package/dist/plops/utils/validate-attribute-input.js +12 -0
  91. package/dist/plops/utils/validate-attribute-input.js.map +1 -0
  92. package/dist/plops/utils/validate-attribute-input.mjs +10 -0
  93. package/dist/plops/utils/validate-attribute-input.mjs.map +1 -0
  94. package/dist/plops/utils/validate-file-name-input.js +12 -0
  95. package/dist/plops/utils/validate-file-name-input.js.map +1 -0
  96. package/dist/plops/utils/validate-file-name-input.mjs +10 -0
  97. package/dist/plops/utils/validate-file-name-input.mjs.map +1 -0
  98. package/dist/plops/utils/validate-input.js +12 -0
  99. package/dist/plops/utils/validate-input.js.map +1 -0
  100. package/dist/plops/utils/validate-input.mjs +10 -0
  101. package/dist/plops/utils/validate-input.mjs.map +1 -0
  102. package/dist/templates/js/plugin/plugin.index.js.hbs +3 -0
  103. package/dist/templates/js/plugin/plugin.routes.index.js.hbs +12 -0
  104. package/dist/templates/js/plugin/plugin.routes.type.index.js.hbs +6 -0
  105. package/dist/templates/ts/core-controller.ts.hbs +1 -1
  106. package/dist/templates/ts/plugin/plugin.index.ts.hbs +1 -0
  107. package/dist/templates/ts/plugin/plugin.routes.index.ts.hbs +9 -0
  108. package/dist/templates/ts/plugin/plugin.routes.type.index.ts.hbs +4 -0
  109. package/package.json +17 -12
@@ -0,0 +1,245 @@
1
+ 'use strict';
2
+
3
+ var path = require('path');
4
+ var slugify = require('@sindresorhus/slugify');
5
+ var fs = require('fs-extra');
6
+ var utils = require('@strapi/utils');
7
+ var tsUtils = require('@strapi/typescript-utils');
8
+ var getDestinationPrompts = require('./prompts/get-destination-prompts.js');
9
+ var getFilePath = require('./utils/get-file-path.js');
10
+ var ctNamesPrompts = require('./prompts/ct-names-prompts.js');
11
+ var kindPrompts = require('./prompts/kind-prompts.js');
12
+ var getAttributesPrompts = require('./prompts/get-attributes-prompts.js');
13
+ var bootstrapApiPrompts = require('./prompts/bootstrap-api-prompts.js');
14
+ var extendPluginIndexFiles = require('./utils/extend-plugin-index-files.js');
15
+
16
+ var generateContentType = ((plop)=>{
17
+ // Model generator
18
+ plop.setGenerator('content-type', {
19
+ description: 'Generate a content type for an API',
20
+ async prompts (inquirer) {
21
+ const config = await inquirer.prompt([
22
+ ...ctNamesPrompts,
23
+ ...kindPrompts
24
+ ]);
25
+ const attributes = await getAttributesPrompts(inquirer);
26
+ const api = await inquirer.prompt([
27
+ ...getDestinationPrompts('model', plop.getDestBasePath()),
28
+ {
29
+ when: (answers)=>answers.destination === 'new',
30
+ type: 'input',
31
+ name: 'id',
32
+ default: config.singularName,
33
+ message: 'Name of the new API?',
34
+ async validate (input) {
35
+ if (!utils.strings.isKebabCase(input)) {
36
+ return 'Value must be in kebab-case';
37
+ }
38
+ const apiPath = path.join(plop.getDestBasePath(), 'api');
39
+ const exists = await fs.pathExists(apiPath);
40
+ if (!exists) {
41
+ return true;
42
+ }
43
+ const apiDir = await fs.readdir(apiPath, {
44
+ withFileTypes: true
45
+ });
46
+ const apiDirContent = apiDir.filter((fd)=>fd.isDirectory());
47
+ if (apiDirContent.findIndex((dir)=>dir.name === input) !== -1) {
48
+ throw new Error('This name is already taken.');
49
+ }
50
+ return true;
51
+ }
52
+ },
53
+ ...bootstrapApiPrompts
54
+ ]);
55
+ return {
56
+ ...config,
57
+ ...api,
58
+ attributes
59
+ };
60
+ },
61
+ actions (answers) {
62
+ if (!answers) {
63
+ return [];
64
+ }
65
+ const attributes = answers.attributes.reduce((object, answer)=>{
66
+ const val = {
67
+ type: answer.attributeType
68
+ };
69
+ if (answer.attributeType === 'enumeration') {
70
+ val.enum = answer.enum.split(',').map((item)=>item.trim());
71
+ }
72
+ if (answer.attributeType === 'media') {
73
+ val.allowedTypes = [
74
+ 'images',
75
+ 'files',
76
+ 'videos',
77
+ 'audios'
78
+ ];
79
+ val.multiple = answer.multiple;
80
+ }
81
+ return Object.assign(object, {
82
+ [answer.attributeName]: val
83
+ }, {});
84
+ }, {});
85
+ const filePath = getFilePath(answers.destination);
86
+ const currentDir = process.cwd();
87
+ let language = tsUtils.isUsingTypeScriptSync(currentDir) ? 'ts' : 'js';
88
+ if (answers.plugin) {
89
+ // The tsconfig in plugins is located just outside the server src, not in the root of the plugin.
90
+ const pluginServerDir = path.join(currentDir, 'src', filePath.replace('{{ plugin }}', answers.plugin), '../');
91
+ language = tsUtils.isUsingTypeScriptSync(pluginServerDir) ? 'ts' : 'js';
92
+ }
93
+ const baseActions = [
94
+ {
95
+ type: 'add',
96
+ path: `${filePath}/content-types/{{ singularName }}/schema.json`,
97
+ templateFile: `templates/${language}/content-type.schema.json.hbs`,
98
+ data: {
99
+ collectionName: slugify(answers.pluralName, {
100
+ separator: '_'
101
+ })
102
+ }
103
+ }
104
+ ];
105
+ if (Object.entries(attributes).length > 0) {
106
+ baseActions.push({
107
+ type: 'modify',
108
+ path: `${filePath}/content-types/{{ singularName }}/schema.json`,
109
+ transform (template) {
110
+ const parsedTemplate = JSON.parse(template);
111
+ parsedTemplate.attributes = attributes;
112
+ return JSON.stringify(parsedTemplate, null, 2);
113
+ }
114
+ });
115
+ }
116
+ if (answers.plugin) {
117
+ const indexPath = path.join(plop.getDestBasePath(), `${filePath}/content-types/index.${language}`);
118
+ const exists = fs.existsSync(indexPath);
119
+ if (!exists) {
120
+ // Create index file if it doesn't exist
121
+ baseActions.push({
122
+ type: 'add',
123
+ path: `${filePath}/content-types/index.${language}`,
124
+ templateFile: `templates/${language}/plugin/plugin.index.${language}.hbs`,
125
+ skipIfExists: true
126
+ });
127
+ }
128
+ // Append the new content type to the index.ts file
129
+ baseActions.push({
130
+ type: 'modify',
131
+ path: `${filePath}/content-types/index.${language}`,
132
+ transform (template) {
133
+ return extendPluginIndexFiles.appendToFile(template, {
134
+ type: 'content-type',
135
+ singularName: answers.singularName
136
+ });
137
+ }
138
+ });
139
+ }
140
+ if (answers.bootstrapApi) {
141
+ const { singularName } = answers;
142
+ let uid;
143
+ if (answers.destination === 'new') {
144
+ uid = `api::${answers.id}.${singularName}`;
145
+ } else if (answers.api) {
146
+ uid = `api::${answers.api}.${singularName}`;
147
+ } else if (answers.plugin) {
148
+ uid = `plugin::${answers.plugin}.${singularName}`;
149
+ }
150
+ baseActions.push({
151
+ type: 'add',
152
+ path: `${filePath}/controllers/{{ singularName }}.${language}`,
153
+ templateFile: `templates/${language}/core-controller.${language}.hbs`,
154
+ data: {
155
+ uid
156
+ }
157
+ }, {
158
+ type: 'add',
159
+ path: `${filePath}/services/{{ singularName }}.${language}`,
160
+ templateFile: `templates/${language}/core-service.${language}.hbs`,
161
+ data: {
162
+ uid
163
+ }
164
+ }, {
165
+ type: 'add',
166
+ path: `${filePath}/routes/${answers.plugin ? 'content-api/' : ''}{{ singularName }}.${language}`,
167
+ templateFile: `templates/${language}/core-router.${language}.hbs`,
168
+ data: {
169
+ uid
170
+ }
171
+ });
172
+ if (answers.plugin) {
173
+ const indexFiles = [
174
+ 'controllers',
175
+ 'services',
176
+ 'routes'
177
+ ];
178
+ indexFiles.forEach((type)=>{
179
+ const indexPath = path.join(plop.getDestBasePath(), `${filePath}/${type}/index.${language}`);
180
+ const exists = fs.existsSync(indexPath);
181
+ if (!exists && type !== 'routes') {
182
+ baseActions.push({
183
+ type: 'add',
184
+ path: `${filePath}/${type}/index.${language}`,
185
+ templateFile: `templates/${language}/plugin/plugin.index.${language}.hbs`,
186
+ skipIfExists: true
187
+ });
188
+ }
189
+ if (type === 'routes') {
190
+ const indexPath = path.join(plop.getDestBasePath(), `${filePath}/${type}/index.${language}`);
191
+ const exists = fs.existsSync(indexPath);
192
+ if (!exists) {
193
+ baseActions.push({
194
+ type: 'add',
195
+ path: `${filePath}/${type}/index.${language}`,
196
+ templateFile: `templates/${language}/plugin/plugin.routes.index.${language}.hbs`,
197
+ skipIfExists: true
198
+ });
199
+ }
200
+ const routeIndexFiles = [
201
+ 'content-api',
202
+ 'admin'
203
+ ];
204
+ routeIndexFiles.forEach((routeType)=>{
205
+ const routeTypeIndexPath = path.join(plop.getDestBasePath(), `${filePath}/${type}/${routeType}/index.${language}`);
206
+ const routeTypeExists = fs.existsSync(routeTypeIndexPath);
207
+ if (!routeTypeExists) {
208
+ baseActions.push({
209
+ type: 'add',
210
+ path: `${filePath}/${type}/${routeType}/index.${language}`,
211
+ templateFile: `templates/${language}/plugin/plugin.routes.type.index.${language}.hbs`,
212
+ data: {
213
+ type: routeType
214
+ },
215
+ skipIfExists: true
216
+ });
217
+ }
218
+ });
219
+ }
220
+ baseActions.push({
221
+ type: 'modify',
222
+ path: `${filePath}/${type}/${type === 'routes' ? 'content-api/' : ''}index.${language}`,
223
+ transform (template) {
224
+ if (type === 'routes') {
225
+ return extendPluginIndexFiles.appendToFile(template, {
226
+ type: 'routes',
227
+ singularName: answers.singularName
228
+ });
229
+ }
230
+ return extendPluginIndexFiles.appendToFile(template, {
231
+ type: 'index',
232
+ singularName: answers.singularName
233
+ });
234
+ }
235
+ });
236
+ });
237
+ }
238
+ }
239
+ return baseActions;
240
+ }
241
+ });
242
+ });
243
+
244
+ module.exports = generateContentType;
245
+ //# sourceMappingURL=content-type.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"content-type.js","sources":["../../src/plops/content-type.ts"],"sourcesContent":["import { join } from 'path';\nimport type { NodePlopAPI, ActionType } from 'plop';\nimport slugify from '@sindresorhus/slugify';\nimport fs from 'fs-extra';\nimport { strings } from '@strapi/utils';\nimport tsUtils from '@strapi/typescript-utils';\n\nimport getDestinationPrompts from './prompts/get-destination-prompts';\nimport getFilePath from './utils/get-file-path';\nimport ctNamesPrompts from './prompts/ct-names-prompts';\nimport kindPrompts from './prompts/kind-prompts';\nimport getAttributesPrompts from './prompts/get-attributes-prompts';\nimport bootstrapApiPrompts from './prompts/bootstrap-api-prompts';\nimport { appendToFile } from './utils/extend-plugin-index-files';\n\nexport default (plop: NodePlopAPI) => {\n // Model generator\n plop.setGenerator('content-type', {\n description: 'Generate a content type for an API',\n async prompts(inquirer) {\n const config = await inquirer.prompt([...ctNamesPrompts, ...kindPrompts]);\n const attributes = await getAttributesPrompts(inquirer);\n\n const api = await inquirer.prompt([\n ...getDestinationPrompts('model', plop.getDestBasePath()),\n {\n when: (answers) => answers.destination === 'new',\n type: 'input',\n name: 'id',\n default: config.singularName,\n message: 'Name of the new API?',\n async validate(input) {\n if (!strings.isKebabCase(input)) {\n return 'Value must be in kebab-case';\n }\n\n const apiPath = join(plop.getDestBasePath(), 'api');\n const exists = await fs.pathExists(apiPath);\n\n if (!exists) {\n return true;\n }\n\n const apiDir = await fs.readdir(apiPath, { withFileTypes: true });\n const apiDirContent = apiDir.filter((fd) => fd.isDirectory());\n\n if (apiDirContent.findIndex((dir) => dir.name === input) !== -1) {\n throw new Error('This name is already taken.');\n }\n\n return true;\n },\n },\n ...bootstrapApiPrompts,\n ]);\n\n return {\n ...config,\n ...api,\n attributes,\n };\n },\n actions(answers) {\n if (!answers) {\n return [];\n }\n\n const attributes = answers.attributes.reduce((object: any, answer: any) => {\n const val: any = { type: answer.attributeType };\n\n if (answer.attributeType === 'enumeration') {\n val.enum = answer.enum.split(',').map((item: string) => item.trim());\n }\n\n if (answer.attributeType === 'media') {\n val.allowedTypes = ['images', 'files', 'videos', 'audios'];\n val.multiple = answer.multiple;\n }\n\n return Object.assign(object, { [answer.attributeName]: val }, {});\n }, {});\n\n const filePath = getFilePath(answers.destination);\n const currentDir = process.cwd();\n let language = tsUtils.isUsingTypeScriptSync(currentDir) ? 'ts' : 'js';\n\n if (answers.plugin) {\n // The tsconfig in plugins is located just outside the server src, not in the root of the plugin.\n const pluginServerDir = join(\n currentDir,\n 'src',\n filePath.replace('{{ plugin }}', answers.plugin),\n '../'\n );\n language = tsUtils.isUsingTypeScriptSync(pluginServerDir) ? 'ts' : 'js';\n }\n\n const baseActions: Array<ActionType> = [\n {\n type: 'add',\n path: `${filePath}/content-types/{{ singularName }}/schema.json`,\n templateFile: `templates/${language}/content-type.schema.json.hbs`,\n data: {\n collectionName: slugify(answers.pluralName, { separator: '_' }),\n },\n },\n ];\n\n if (Object.entries(attributes).length > 0) {\n baseActions.push({\n type: 'modify',\n path: `${filePath}/content-types/{{ singularName }}/schema.json`,\n transform(template: string) {\n const parsedTemplate = JSON.parse(template);\n parsedTemplate.attributes = attributes;\n return JSON.stringify(parsedTemplate, null, 2);\n },\n });\n }\n\n if (answers.plugin) {\n const indexPath = join(\n plop.getDestBasePath(),\n `${filePath}/content-types/index.${language}`\n );\n const exists = fs.existsSync(indexPath);\n\n if (!exists) {\n // Create index file if it doesn't exist\n baseActions.push({\n type: 'add',\n path: `${filePath}/content-types/index.${language}`,\n templateFile: `templates/${language}/plugin/plugin.index.${language}.hbs`,\n skipIfExists: true,\n });\n }\n\n // Append the new content type to the index.ts file\n baseActions.push({\n type: 'modify',\n path: `${filePath}/content-types/index.${language}`,\n transform(template: string) {\n return appendToFile(template, {\n type: 'content-type',\n singularName: answers.singularName,\n });\n },\n });\n }\n\n if (answers.bootstrapApi) {\n const { singularName } = answers;\n\n let uid;\n if (answers.destination === 'new') {\n uid = `api::${answers.id}.${singularName}`;\n } else if (answers.api) {\n uid = `api::${answers.api}.${singularName}`;\n } else if (answers.plugin) {\n uid = `plugin::${answers.plugin}.${singularName}`;\n }\n\n baseActions.push(\n {\n type: 'add',\n path: `${filePath}/controllers/{{ singularName }}.${language}`,\n templateFile: `templates/${language}/core-controller.${language}.hbs`,\n data: { uid },\n },\n {\n type: 'add',\n path: `${filePath}/services/{{ singularName }}.${language}`,\n templateFile: `templates/${language}/core-service.${language}.hbs`,\n data: { uid },\n },\n {\n type: 'add',\n path: `${filePath}/routes/${answers.plugin ? 'content-api/' : ''}{{ singularName }}.${language}`,\n templateFile: `templates/${language}/core-router.${language}.hbs`,\n data: { uid },\n }\n );\n\n if (answers.plugin) {\n const indexFiles = ['controllers', 'services', 'routes'];\n\n indexFiles.forEach((type) => {\n const indexPath = join(plop.getDestBasePath(), `${filePath}/${type}/index.${language}`);\n const exists = fs.existsSync(indexPath);\n\n if (!exists && type !== 'routes') {\n baseActions.push({\n type: 'add',\n path: `${filePath}/${type}/index.${language}`,\n templateFile: `templates/${language}/plugin/plugin.index.${language}.hbs`,\n skipIfExists: true,\n });\n }\n\n if (type === 'routes') {\n const indexPath = join(\n plop.getDestBasePath(),\n `${filePath}/${type}/index.${language}`\n );\n const exists = fs.existsSync(indexPath);\n\n if (!exists) {\n baseActions.push({\n type: 'add',\n path: `${filePath}/${type}/index.${language}`,\n templateFile: `templates/${language}/plugin/plugin.routes.index.${language}.hbs`,\n skipIfExists: true,\n });\n }\n\n const routeIndexFiles = ['content-api', 'admin'];\n\n routeIndexFiles.forEach((routeType) => {\n const routeTypeIndexPath = join(\n plop.getDestBasePath(),\n `${filePath}/${type}/${routeType}/index.${language}`\n );\n const routeTypeExists = fs.existsSync(routeTypeIndexPath);\n\n if (!routeTypeExists) {\n baseActions.push({\n type: 'add',\n path: `${filePath}/${type}/${routeType}/index.${language}`,\n templateFile: `templates/${language}/plugin/plugin.routes.type.index.${language}.hbs`,\n data: { type: routeType },\n skipIfExists: true,\n });\n }\n });\n }\n\n baseActions.push({\n type: 'modify',\n path: `${filePath}/${type}/${type === 'routes' ? 'content-api/' : ''}index.${language}`,\n transform(template: string) {\n if (type === 'routes') {\n return appendToFile(template, {\n type: 'routes',\n singularName: answers.singularName,\n });\n }\n\n return appendToFile(template, {\n type: 'index',\n singularName: answers.singularName,\n });\n },\n });\n });\n }\n }\n\n return baseActions;\n },\n });\n};\n"],"names":["plop","setGenerator","description","prompts","inquirer","config","prompt","ctNamesPrompts","kindPrompts","attributes","getAttributesPrompts","api","getDestinationPrompts","getDestBasePath","when","answers","destination","type","name","default","singularName","message","validate","input","strings","isKebabCase","apiPath","join","exists","fs","pathExists","apiDir","readdir","withFileTypes","apiDirContent","filter","fd","isDirectory","findIndex","dir","Error","bootstrapApiPrompts","actions","reduce","object","answer","val","attributeType","enum","split","map","item","trim","allowedTypes","multiple","Object","assign","attributeName","filePath","getFilePath","currentDir","process","cwd","language","tsUtils","isUsingTypeScriptSync","plugin","pluginServerDir","replace","baseActions","path","templateFile","data","collectionName","slugify","pluralName","separator","entries","length","push","transform","template","parsedTemplate","JSON","parse","stringify","indexPath","existsSync","skipIfExists","appendToFile","bootstrapApi","uid","id","indexFiles","forEach","routeIndexFiles","routeType","routeTypeIndexPath","routeTypeExists"],"mappings":";;;;;;;;;;;;;;;AAeA,0BAAe,CAAA,CAACA,IAAAA,GAAAA;;IAEdA,IAAKC,CAAAA,YAAY,CAAC,cAAgB,EAAA;QAChCC,WAAa,EAAA,oCAAA;AACb,QAAA,MAAMC,SAAQC,QAAQ,EAAA;AACpB,YAAA,MAAMC,MAAS,GAAA,MAAMD,QAASE,CAAAA,MAAM,CAAC;AAAIC,gBAAAA,GAAAA,cAAAA;AAAmBC,gBAAAA,GAAAA;AAAY,aAAA,CAAA;YACxE,MAAMC,UAAAA,GAAa,MAAMC,oBAA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,EAAG,CAAA,MAAM,EAAE8C,QAAU,CAAA,CAAA;AACvFiB,4BAAAA,SAAAA,CAAAA,CAAUC,QAAgB,EAAA;AACxB,gCAAA,IAAIhE,SAAS,QAAU,EAAA;AACrB,oCAAA,OAAOwE,oCAAaR,QAAU,EAAA;wCAC5BhE,IAAM,EAAA,QAAA;AACNG,wCAAAA,YAAAA,EAAcL,QAAQK;AACxB,qCAAA,CAAA;AACF;AAEA,gCAAA,OAAOqE,oCAAaR,QAAU,EAAA;oCAC5BhE,IAAM,EAAA,OAAA;AACNG,oCAAAA,YAAAA,EAAcL,QAAQK;AACxB,iCAAA,CAAA;AACF;AACF,yBAAA,CAAA;AACF,qBAAA,CAAA;AACF;AACF;YAEA,OAAOiD,WAAAA;AACT;AACF,KAAA,CAAA;AACF,CAAA;;;;"}
@@ -0,0 +1,243 @@
1
+ import { join } from 'path';
2
+ import slugify from '@sindresorhus/slugify';
3
+ import fs from 'fs-extra';
4
+ import { strings } from '@strapi/utils';
5
+ import tsUtils from '@strapi/typescript-utils';
6
+ import getDestinationPrompts from './prompts/get-destination-prompts.mjs';
7
+ import getFilePath from './utils/get-file-path.mjs';
8
+ import questions from './prompts/ct-names-prompts.mjs';
9
+ import questions$1 from './prompts/kind-prompts.mjs';
10
+ import getAttributesPrompts from './prompts/get-attributes-prompts.mjs';
11
+ import questions$2 from './prompts/bootstrap-api-prompts.mjs';
12
+ import { appendToFile } from './utils/extend-plugin-index-files.mjs';
13
+
14
+ var generateContentType = ((plop)=>{
15
+ // Model generator
16
+ plop.setGenerator('content-type', {
17
+ description: 'Generate a content type for an API',
18
+ async prompts (inquirer) {
19
+ const config = await inquirer.prompt([
20
+ ...questions,
21
+ ...questions$1
22
+ ]);
23
+ const attributes = await getAttributesPrompts(inquirer);
24
+ const api = await inquirer.prompt([
25
+ ...getDestinationPrompts('model', plop.getDestBasePath()),
26
+ {
27
+ when: (answers)=>answers.destination === 'new',
28
+ type: 'input',
29
+ name: 'id',
30
+ default: config.singularName,
31
+ message: 'Name of the new API?',
32
+ async validate (input) {
33
+ if (!strings.isKebabCase(input)) {
34
+ return 'Value must be in kebab-case';
35
+ }
36
+ const apiPath = join(plop.getDestBasePath(), 'api');
37
+ const exists = await fs.pathExists(apiPath);
38
+ if (!exists) {
39
+ return true;
40
+ }
41
+ const apiDir = await fs.readdir(apiPath, {
42
+ withFileTypes: true
43
+ });
44
+ const apiDirContent = apiDir.filter((fd)=>fd.isDirectory());
45
+ if (apiDirContent.findIndex((dir)=>dir.name === input) !== -1) {
46
+ throw new Error('This name is already taken.');
47
+ }
48
+ return true;
49
+ }
50
+ },
51
+ ...questions$2
52
+ ]);
53
+ return {
54
+ ...config,
55
+ ...api,
56
+ attributes
57
+ };
58
+ },
59
+ actions (answers) {
60
+ if (!answers) {
61
+ return [];
62
+ }
63
+ const attributes = answers.attributes.reduce((object, answer)=>{
64
+ const val = {
65
+ type: answer.attributeType
66
+ };
67
+ if (answer.attributeType === 'enumeration') {
68
+ val.enum = answer.enum.split(',').map((item)=>item.trim());
69
+ }
70
+ if (answer.attributeType === 'media') {
71
+ val.allowedTypes = [
72
+ 'images',
73
+ 'files',
74
+ 'videos',
75
+ 'audios'
76
+ ];
77
+ val.multiple = answer.multiple;
78
+ }
79
+ return Object.assign(object, {
80
+ [answer.attributeName]: val
81
+ }, {});
82
+ }, {});
83
+ const filePath = getFilePath(answers.destination);
84
+ const currentDir = process.cwd();
85
+ let language = tsUtils.isUsingTypeScriptSync(currentDir) ? 'ts' : 'js';
86
+ if (answers.plugin) {
87
+ // The tsconfig in plugins is located just outside the server src, not in the root of the plugin.
88
+ const pluginServerDir = join(currentDir, 'src', filePath.replace('{{ plugin }}', answers.plugin), '../');
89
+ language = tsUtils.isUsingTypeScriptSync(pluginServerDir) ? 'ts' : 'js';
90
+ }
91
+ const baseActions = [
92
+ {
93
+ type: 'add',
94
+ path: `${filePath}/content-types/{{ singularName }}/schema.json`,
95
+ templateFile: `templates/${language}/content-type.schema.json.hbs`,
96
+ data: {
97
+ collectionName: slugify(answers.pluralName, {
98
+ separator: '_'
99
+ })
100
+ }
101
+ }
102
+ ];
103
+ if (Object.entries(attributes).length > 0) {
104
+ baseActions.push({
105
+ type: 'modify',
106
+ path: `${filePath}/content-types/{{ singularName }}/schema.json`,
107
+ transform (template) {
108
+ const parsedTemplate = JSON.parse(template);
109
+ parsedTemplate.attributes = attributes;
110
+ return JSON.stringify(parsedTemplate, null, 2);
111
+ }
112
+ });
113
+ }
114
+ if (answers.plugin) {
115
+ const indexPath = join(plop.getDestBasePath(), `${filePath}/content-types/index.${language}`);
116
+ const exists = fs.existsSync(indexPath);
117
+ if (!exists) {
118
+ // Create index file if it doesn't exist
119
+ baseActions.push({
120
+ type: 'add',
121
+ path: `${filePath}/content-types/index.${language}`,
122
+ templateFile: `templates/${language}/plugin/plugin.index.${language}.hbs`,
123
+ skipIfExists: true
124
+ });
125
+ }
126
+ // Append the new content type to the index.ts file
127
+ baseActions.push({
128
+ type: 'modify',
129
+ path: `${filePath}/content-types/index.${language}`,
130
+ transform (template) {
131
+ return appendToFile(template, {
132
+ type: 'content-type',
133
+ singularName: answers.singularName
134
+ });
135
+ }
136
+ });
137
+ }
138
+ if (answers.bootstrapApi) {
139
+ const { singularName } = answers;
140
+ let uid;
141
+ if (answers.destination === 'new') {
142
+ uid = `api::${answers.id}.${singularName}`;
143
+ } else if (answers.api) {
144
+ uid = `api::${answers.api}.${singularName}`;
145
+ } else if (answers.plugin) {
146
+ uid = `plugin::${answers.plugin}.${singularName}`;
147
+ }
148
+ baseActions.push({
149
+ type: 'add',
150
+ path: `${filePath}/controllers/{{ singularName }}.${language}`,
151
+ templateFile: `templates/${language}/core-controller.${language}.hbs`,
152
+ data: {
153
+ uid
154
+ }
155
+ }, {
156
+ type: 'add',
157
+ path: `${filePath}/services/{{ singularName }}.${language}`,
158
+ templateFile: `templates/${language}/core-service.${language}.hbs`,
159
+ data: {
160
+ uid
161
+ }
162
+ }, {
163
+ type: 'add',
164
+ path: `${filePath}/routes/${answers.plugin ? 'content-api/' : ''}{{ singularName }}.${language}`,
165
+ templateFile: `templates/${language}/core-router.${language}.hbs`,
166
+ data: {
167
+ uid
168
+ }
169
+ });
170
+ if (answers.plugin) {
171
+ const indexFiles = [
172
+ 'controllers',
173
+ 'services',
174
+ 'routes'
175
+ ];
176
+ indexFiles.forEach((type)=>{
177
+ const indexPath = join(plop.getDestBasePath(), `${filePath}/${type}/index.${language}`);
178
+ const exists = fs.existsSync(indexPath);
179
+ if (!exists && type !== 'routes') {
180
+ baseActions.push({
181
+ type: 'add',
182
+ path: `${filePath}/${type}/index.${language}`,
183
+ templateFile: `templates/${language}/plugin/plugin.index.${language}.hbs`,
184
+ skipIfExists: true
185
+ });
186
+ }
187
+ if (type === 'routes') {
188
+ const indexPath = join(plop.getDestBasePath(), `${filePath}/${type}/index.${language}`);
189
+ const exists = fs.existsSync(indexPath);
190
+ if (!exists) {
191
+ baseActions.push({
192
+ type: 'add',
193
+ path: `${filePath}/${type}/index.${language}`,
194
+ templateFile: `templates/${language}/plugin/plugin.routes.index.${language}.hbs`,
195
+ skipIfExists: true
196
+ });
197
+ }
198
+ const routeIndexFiles = [
199
+ 'content-api',
200
+ 'admin'
201
+ ];
202
+ routeIndexFiles.forEach((routeType)=>{
203
+ const routeTypeIndexPath = join(plop.getDestBasePath(), `${filePath}/${type}/${routeType}/index.${language}`);
204
+ const routeTypeExists = fs.existsSync(routeTypeIndexPath);
205
+ if (!routeTypeExists) {
206
+ baseActions.push({
207
+ type: 'add',
208
+ path: `${filePath}/${type}/${routeType}/index.${language}`,
209
+ templateFile: `templates/${language}/plugin/plugin.routes.type.index.${language}.hbs`,
210
+ data: {
211
+ type: routeType
212
+ },
213
+ skipIfExists: true
214
+ });
215
+ }
216
+ });
217
+ }
218
+ baseActions.push({
219
+ type: 'modify',
220
+ path: `${filePath}/${type}/${type === 'routes' ? 'content-api/' : ''}index.${language}`,
221
+ transform (template) {
222
+ if (type === 'routes') {
223
+ return appendToFile(template, {
224
+ type: 'routes',
225
+ singularName: answers.singularName
226
+ });
227
+ }
228
+ return appendToFile(template, {
229
+ type: 'index',
230
+ singularName: answers.singularName
231
+ });
232
+ }
233
+ });
234
+ });
235
+ }
236
+ }
237
+ return baseActions;
238
+ }
239
+ });
240
+ });
241
+
242
+ export { generateContentType as default };
243
+ //# sourceMappingURL=content-type.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"content-type.mjs","sources":["../../src/plops/content-type.ts"],"sourcesContent":["import { join } from 'path';\nimport type { NodePlopAPI, ActionType } from 'plop';\nimport slugify from '@sindresorhus/slugify';\nimport fs from 'fs-extra';\nimport { strings } from '@strapi/utils';\nimport tsUtils from '@strapi/typescript-utils';\n\nimport getDestinationPrompts from './prompts/get-destination-prompts';\nimport getFilePath from './utils/get-file-path';\nimport ctNamesPrompts from './prompts/ct-names-prompts';\nimport kindPrompts from './prompts/kind-prompts';\nimport getAttributesPrompts from './prompts/get-attributes-prompts';\nimport bootstrapApiPrompts from './prompts/bootstrap-api-prompts';\nimport { appendToFile } from './utils/extend-plugin-index-files';\n\nexport default (plop: NodePlopAPI) => {\n // Model generator\n plop.setGenerator('content-type', {\n description: 'Generate a content type for an API',\n async prompts(inquirer) {\n const config = await inquirer.prompt([...ctNamesPrompts, ...kindPrompts]);\n const attributes = await getAttributesPrompts(inquirer);\n\n const api = await inquirer.prompt([\n ...getDestinationPrompts('model', plop.getDestBasePath()),\n {\n when: (answers) => answers.destination === 'new',\n type: 'input',\n name: 'id',\n default: config.singularName,\n message: 'Name of the new API?',\n async validate(input) {\n if (!strings.isKebabCase(input)) {\n return 'Value must be in kebab-case';\n }\n\n const apiPath = join(plop.getDestBasePath(), 'api');\n const exists = await fs.pathExists(apiPath);\n\n if (!exists) {\n return true;\n }\n\n const apiDir = await fs.readdir(apiPath, { withFileTypes: true });\n const apiDirContent = apiDir.filter((fd) => fd.isDirectory());\n\n if (apiDirContent.findIndex((dir) => dir.name === input) !== -1) {\n throw new Error('This name is already taken.');\n }\n\n return true;\n },\n },\n ...bootstrapApiPrompts,\n ]);\n\n return {\n ...config,\n ...api,\n attributes,\n };\n },\n actions(answers) {\n if (!answers) {\n return [];\n }\n\n const attributes = answers.attributes.reduce((object: any, answer: any) => {\n const val: any = { type: answer.attributeType };\n\n if (answer.attributeType === 'enumeration') {\n val.enum = answer.enum.split(',').map((item: string) => item.trim());\n }\n\n if (answer.attributeType === 'media') {\n val.allowedTypes = ['images', 'files', 'videos', 'audios'];\n val.multiple = answer.multiple;\n }\n\n return Object.assign(object, { [answer.attributeName]: val }, {});\n }, {});\n\n const filePath = getFilePath(answers.destination);\n const currentDir = process.cwd();\n let language = tsUtils.isUsingTypeScriptSync(currentDir) ? 'ts' : 'js';\n\n if (answers.plugin) {\n // The tsconfig in plugins is located just outside the server src, not in the root of the plugin.\n const pluginServerDir = join(\n currentDir,\n 'src',\n filePath.replace('{{ plugin }}', answers.plugin),\n '../'\n );\n language = tsUtils.isUsingTypeScriptSync(pluginServerDir) ? 'ts' : 'js';\n }\n\n const baseActions: Array<ActionType> = [\n {\n type: 'add',\n path: `${filePath}/content-types/{{ singularName }}/schema.json`,\n templateFile: `templates/${language}/content-type.schema.json.hbs`,\n data: {\n collectionName: slugify(answers.pluralName, { separator: '_' }),\n },\n },\n ];\n\n if (Object.entries(attributes).length > 0) {\n baseActions.push({\n type: 'modify',\n path: `${filePath}/content-types/{{ singularName }}/schema.json`,\n transform(template: string) {\n const parsedTemplate = JSON.parse(template);\n parsedTemplate.attributes = attributes;\n return JSON.stringify(parsedTemplate, null, 2);\n },\n });\n }\n\n if (answers.plugin) {\n const indexPath = join(\n plop.getDestBasePath(),\n `${filePath}/content-types/index.${language}`\n );\n const exists = fs.existsSync(indexPath);\n\n if (!exists) {\n // Create index file if it doesn't exist\n baseActions.push({\n type: 'add',\n path: `${filePath}/content-types/index.${language}`,\n templateFile: `templates/${language}/plugin/plugin.index.${language}.hbs`,\n skipIfExists: true,\n });\n }\n\n // Append the new content type to the index.ts file\n baseActions.push({\n type: 'modify',\n path: `${filePath}/content-types/index.${language}`,\n transform(template: string) {\n return appendToFile(template, {\n type: 'content-type',\n singularName: answers.singularName,\n });\n },\n });\n }\n\n if (answers.bootstrapApi) {\n const { singularName } = answers;\n\n let uid;\n if (answers.destination === 'new') {\n uid = `api::${answers.id}.${singularName}`;\n } else if (answers.api) {\n uid = `api::${answers.api}.${singularName}`;\n } else if (answers.plugin) {\n uid = `plugin::${answers.plugin}.${singularName}`;\n }\n\n baseActions.push(\n {\n type: 'add',\n path: `${filePath}/controllers/{{ singularName }}.${language}`,\n templateFile: `templates/${language}/core-controller.${language}.hbs`,\n data: { uid },\n },\n {\n type: 'add',\n path: `${filePath}/services/{{ singularName }}.${language}`,\n templateFile: `templates/${language}/core-service.${language}.hbs`,\n data: { uid },\n },\n {\n type: 'add',\n path: `${filePath}/routes/${answers.plugin ? 'content-api/' : ''}{{ singularName }}.${language}`,\n templateFile: `templates/${language}/core-router.${language}.hbs`,\n data: { uid },\n }\n );\n\n if (answers.plugin) {\n const indexFiles = ['controllers', 'services', 'routes'];\n\n indexFiles.forEach((type) => {\n const indexPath = join(plop.getDestBasePath(), `${filePath}/${type}/index.${language}`);\n const exists = fs.existsSync(indexPath);\n\n if (!exists && type !== 'routes') {\n baseActions.push({\n type: 'add',\n path: `${filePath}/${type}/index.${language}`,\n templateFile: `templates/${language}/plugin/plugin.index.${language}.hbs`,\n skipIfExists: true,\n });\n }\n\n if (type === 'routes') {\n const indexPath = join(\n plop.getDestBasePath(),\n `${filePath}/${type}/index.${language}`\n );\n const exists = fs.existsSync(indexPath);\n\n if (!exists) {\n baseActions.push({\n type: 'add',\n path: `${filePath}/${type}/index.${language}`,\n templateFile: `templates/${language}/plugin/plugin.routes.index.${language}.hbs`,\n skipIfExists: true,\n });\n }\n\n const routeIndexFiles = ['content-api', 'admin'];\n\n routeIndexFiles.forEach((routeType) => {\n const routeTypeIndexPath = join(\n plop.getDestBasePath(),\n `${filePath}/${type}/${routeType}/index.${language}`\n );\n const routeTypeExists = fs.existsSync(routeTypeIndexPath);\n\n if (!routeTypeExists) {\n baseActions.push({\n type: 'add',\n path: `${filePath}/${type}/${routeType}/index.${language}`,\n templateFile: `templates/${language}/plugin/plugin.routes.type.index.${language}.hbs`,\n data: { type: routeType },\n skipIfExists: true,\n });\n }\n });\n }\n\n baseActions.push({\n type: 'modify',\n path: `${filePath}/${type}/${type === 'routes' ? 'content-api/' : ''}index.${language}`,\n transform(template: string) {\n if (type === 'routes') {\n return appendToFile(template, {\n type: 'routes',\n singularName: answers.singularName,\n });\n }\n\n return appendToFile(template, {\n type: 'index',\n singularName: answers.singularName,\n });\n },\n });\n });\n }\n }\n\n return baseActions;\n },\n });\n};\n"],"names":["plop","setGenerator","description","prompts","inquirer","config","prompt","ctNamesPrompts","kindPrompts","attributes","getAttributesPrompts","api","getDestinationPrompts","getDestBasePath","when","answers","destination","type","name","default","singularName","message","validate","input","strings","isKebabCase","apiPath","join","exists","fs","pathExists","apiDir","readdir","withFileTypes","apiDirContent","filter","fd","isDirectory","findIndex","dir","Error","bootstrapApiPrompts","actions","reduce","object","answer","val","attributeType","enum","split","map","item","trim","allowedTypes","multiple","Object","assign","attributeName","filePath","getFilePath","currentDir","process","cwd","language","tsUtils","isUsingTypeScriptSync","plugin","pluginServerDir","replace","baseActions","path","templateFile","data","collectionName","slugify","pluralName","separator","entries","length","push","transform","template","parsedTemplate","JSON","parse","stringify","indexPath","existsSync","skipIfExists","appendToFile","bootstrapApi","uid","id","indexFiles","forEach","routeIndexFiles","routeType","routeTypeIndexPath","routeTypeExists"],"mappings":";;;;;;;;;;;;;AAeA,0BAAe,CAAA,CAACA,IAAAA,GAAAA;;IAEdA,IAAKC,CAAAA,YAAY,CAAC,cAAgB,EAAA;QAChCC,WAAa,EAAA,oCAAA;AACb,QAAA,MAAMC,SAAQC,QAAQ,EAAA;AACpB,YAAA,MAAMC,MAAS,GAAA,MAAMD,QAASE,CAAAA,MAAM,CAAC;AAAIC,gB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,EAAAA,QAAAA,CAAS,CAAC,EAAEzC,IAAK,CAAA,CAAC,EAAEA,IAAAA,KAAS,QAAW,GAAA,cAAA,GAAiB,EAAG,CAAA,MAAM,EAAE8C,QAAU,CAAA,CAAA;AACvFiB,4BAAAA,SAAAA,CAAAA,CAAUC,QAAgB,EAAA;AACxB,gCAAA,IAAIhE,SAAS,QAAU,EAAA;AACrB,oCAAA,OAAOwE,aAAaR,QAAU,EAAA;wCAC5BhE,IAAM,EAAA,QAAA;AACNG,wCAAAA,YAAAA,EAAcL,QAAQK;AACxB,qCAAA,CAAA;AACF;AAEA,gCAAA,OAAOqE,aAAaR,QAAU,EAAA;oCAC5BhE,IAAM,EAAA,OAAA;AACNG,oCAAAA,YAAAA,EAAcL,QAAQK;AACxB,iCAAA,CAAA;AACF;AACF,yBAAA,CAAA;AACF,qBAAA,CAAA;AACF;AACF;YAEA,OAAOiD,WAAAA;AACT;AACF,KAAA,CAAA;AACF,CAAA;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"controller.d.ts","sourceRoot":"","sources":["../../src/plops/controller.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,MAAM,CAAC;+BAOlB,WAAW;AAAjC,wBA+BE"}
1
+ {"version":3,"file":"controller.d.ts","sourceRoot":"","sources":["../../src/plops/controller.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAc,WAAW,EAAE,MAAM,MAAM,CAAC;+BAU9B,WAAW;AAAjC,wBAoEE"}