@strapi/generators 0.0.0-next.f7babb775ed9a7e18d8351cb7f74c63e016323c4 → 0.0.0-next.f86041c89a8c1545c6437a881dc613e98bc52bd7

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 (195) hide show
  1. package/LICENSE +18 -3
  2. package/dist/index.d.ts +10 -5
  3. package/dist/index.d.ts.map +1 -0
  4. package/dist/index.js +92 -27
  5. package/dist/index.js.map +1 -1
  6. package/dist/index.mjs +94 -0
  7. package/dist/index.mjs.map +1 -0
  8. package/dist/plopfile.d.ts +2 -1
  9. package/dist/plopfile.d.ts.map +1 -0
  10. package/dist/plopfile.js +24 -26
  11. package/dist/plopfile.js.map +1 -1
  12. package/dist/plopfile.mjs +25 -0
  13. package/dist/plopfile.mjs.map +1 -0
  14. package/dist/plops/api.d.ts +2 -1
  15. package/dist/plops/api.d.ts.map +1 -0
  16. package/dist/plops/api.js +107 -37
  17. package/dist/plops/api.js.map +1 -1
  18. package/dist/plops/api.mjs +147 -0
  19. package/dist/plops/api.mjs.map +1 -0
  20. package/dist/plops/content-type.d.ts +2 -1
  21. package/dist/plops/content-type.d.ts.map +1 -0
  22. package/dist/plops/content-type.js +170 -83
  23. package/dist/plops/content-type.js.map +1 -1
  24. package/dist/plops/content-type.mjs +243 -0
  25. package/dist/plops/content-type.mjs.map +1 -0
  26. package/dist/plops/controller.d.ts +2 -1
  27. package/dist/plops/controller.d.ts.map +1 -0
  28. package/dist/plops/controller.js +54 -21
  29. package/dist/plops/controller.js.map +1 -1
  30. package/dist/plops/controller.mjs +71 -0
  31. package/dist/plops/controller.mjs.map +1 -0
  32. package/dist/plops/middleware.d.ts +2 -1
  33. package/dist/plops/middleware.d.ts.map +1 -0
  34. package/dist/plops/middleware.js +56 -21
  35. package/dist/plops/middleware.js.map +1 -1
  36. package/dist/plops/middleware.mjs +73 -0
  37. package/dist/plops/middleware.mjs.map +1 -0
  38. package/dist/plops/migration.d.ts +2 -1
  39. package/dist/plops/migration.d.ts.map +1 -0
  40. package/dist/plops/migration.js +19 -19
  41. package/dist/plops/migration.js.map +1 -1
  42. package/dist/plops/migration.mjs +33 -0
  43. package/dist/plops/migration.mjs.map +1 -0
  44. package/dist/plops/policy.d.ts +2 -1
  45. package/dist/plops/policy.d.ts.map +1 -0
  46. package/dist/plops/policy.js +56 -21
  47. package/dist/plops/policy.js.map +1 -1
  48. package/dist/plops/policy.mjs +73 -0
  49. package/dist/plops/policy.mjs.map +1 -0
  50. package/dist/plops/prompts/bootstrap-api-prompts.d.ts +7 -2
  51. package/dist/plops/prompts/bootstrap-api-prompts.d.ts.map +1 -0
  52. package/dist/plops/prompts/bootstrap-api-prompts.js +7 -6
  53. package/dist/plops/prompts/bootstrap-api-prompts.js.map +1 -1
  54. package/dist/plops/prompts/bootstrap-api-prompts.mjs +11 -0
  55. package/dist/plops/prompts/bootstrap-api-prompts.mjs.map +1 -0
  56. package/dist/plops/prompts/ct-names-prompts.d.ts +19 -2
  57. package/dist/plops/prompts/ct-names-prompts.d.ts.map +1 -0
  58. package/dist/plops/prompts/ct-names-prompts.js +19 -43
  59. package/dist/plops/prompts/ct-names-prompts.js.map +1 -1
  60. package/dist/plops/prompts/ct-names-prompts.mjs +42 -0
  61. package/dist/plops/prompts/ct-names-prompts.mjs.map +1 -0
  62. package/dist/plops/prompts/get-attributes-prompts.d.ts +9 -2
  63. package/dist/plops/prompts/get-attributes-prompts.d.ts.map +1 -0
  64. package/dist/plops/prompts/get-attributes-prompts.js +36 -30
  65. package/dist/plops/prompts/get-attributes-prompts.js.map +1 -1
  66. package/dist/plops/prompts/get-attributes-prompts.mjs +99 -0
  67. package/dist/plops/prompts/get-attributes-prompts.mjs.map +1 -0
  68. package/dist/plops/prompts/get-destination-prompts.d.ts +25 -2
  69. package/dist/plops/prompts/get-destination-prompts.d.ts.map +1 -0
  70. package/dist/plops/prompts/get-destination-prompts.js +47 -41
  71. package/dist/plops/prompts/get-destination-prompts.js.map +1 -1
  72. package/dist/plops/prompts/get-destination-prompts.mjs +76 -0
  73. package/dist/plops/prompts/get-destination-prompts.mjs.map +1 -0
  74. package/dist/plops/prompts/kind-prompts.d.ts +12 -2
  75. package/dist/plops/prompts/kind-prompts.d.ts.map +1 -0
  76. package/dist/plops/prompts/kind-prompts.js +17 -12
  77. package/dist/plops/prompts/kind-prompts.js.map +1 -1
  78. package/dist/plops/prompts/kind-prompts.mjs +24 -0
  79. package/dist/plops/prompts/kind-prompts.mjs.map +1 -0
  80. package/dist/plops/service.d.ts +2 -1
  81. package/dist/plops/service.d.ts.map +1 -0
  82. package/dist/plops/service.js +53 -20
  83. package/dist/plops/service.js.map +1 -1
  84. package/dist/plops/service.mjs +69 -0
  85. package/dist/plops/service.mjs.map +1 -0
  86. package/dist/plops/utils/extend-plugin-index-files.d.ts +8 -0
  87. package/dist/plops/utils/extend-plugin-index-files.d.ts.map +1 -0
  88. package/dist/plops/utils/extend-plugin-index-files.js +356 -0
  89. package/dist/plops/utils/extend-plugin-index-files.js.map +1 -0
  90. package/dist/plops/utils/extend-plugin-index-files.mjs +335 -0
  91. package/dist/plops/utils/extend-plugin-index-files.mjs.map +1 -0
  92. package/dist/plops/utils/get-file-path.d.ts +2 -1
  93. package/dist/plops/utils/get-file-path.d.ts.map +1 -0
  94. package/dist/plops/utils/get-file-path.js +9 -7
  95. package/dist/plops/utils/get-file-path.js.map +1 -1
  96. package/dist/plops/utils/get-file-path.mjs +15 -0
  97. package/dist/plops/utils/get-file-path.mjs.map +1 -0
  98. package/dist/plops/utils/get-formatted-date.d.ts +1 -0
  99. package/dist/plops/utils/get-formatted-date.d.ts.map +1 -0
  100. package/dist/plops/utils/get-formatted-date.js +8 -9
  101. package/dist/plops/utils/get-formatted-date.js.map +1 -1
  102. package/dist/plops/utils/get-formatted-date.mjs +6 -0
  103. package/dist/plops/utils/get-formatted-date.mjs.map +1 -0
  104. package/dist/plops/utils/validate-attribute-input.d.ts +1 -0
  105. package/dist/plops/utils/validate-attribute-input.d.ts.map +1 -0
  106. package/dist/plops/utils/validate-attribute-input.js +7 -5
  107. package/dist/plops/utils/validate-attribute-input.js.map +1 -1
  108. package/dist/plops/utils/validate-attribute-input.mjs +10 -0
  109. package/dist/plops/utils/validate-attribute-input.mjs.map +1 -0
  110. package/dist/plops/utils/validate-file-name-input.d.ts +1 -0
  111. package/dist/plops/utils/validate-file-name-input.d.ts.map +1 -0
  112. package/dist/plops/utils/validate-file-name-input.js +7 -5
  113. package/dist/plops/utils/validate-file-name-input.js.map +1 -1
  114. package/dist/plops/utils/validate-file-name-input.mjs +10 -0
  115. package/dist/plops/utils/validate-file-name-input.mjs.map +1 -0
  116. package/dist/plops/utils/validate-input.d.ts +1 -0
  117. package/dist/plops/utils/validate-input.d.ts.map +1 -0
  118. package/dist/plops/utils/validate-input.js +7 -5
  119. package/dist/plops/utils/validate-input.js.map +1 -1
  120. package/dist/plops/utils/validate-input.mjs +10 -0
  121. package/dist/plops/utils/validate-input.mjs.map +1 -0
  122. package/dist/templates/js/content-type.schema.json.hbs +0 -1
  123. package/dist/templates/js/plugin/plugin.routes.index.js.hbs +12 -0
  124. package/dist/templates/js/plugin/plugin.routes.type.index.js.hbs +6 -0
  125. package/dist/templates/ts/content-type.schema.json.hbs +0 -1
  126. package/dist/templates/ts/core-controller.ts.hbs +1 -1
  127. package/dist/templates/ts/middleware.ts.hbs +2 -2
  128. package/dist/templates/ts/plugin/plugin.routes.index.ts.hbs +9 -0
  129. package/dist/templates/ts/plugin/plugin.routes.type.index.ts.hbs +4 -0
  130. package/package.json +25 -17
  131. package/dist/files/js/plugin/.editorconfig +0 -7
  132. package/dist/files/js/plugin/.gitattributes +0 -103
  133. package/dist/files/js/plugin/admin/src/components/Initializer/index.js +0 -26
  134. package/dist/files/js/plugin/admin/src/components/PluginIcon/index.js +0 -12
  135. package/dist/files/js/plugin/admin/src/index.js +0 -63
  136. package/dist/files/js/plugin/admin/src/pages/App/index.js +0 -25
  137. package/dist/files/js/plugin/admin/src/pages/HomePage/index.js +0 -20
  138. package/dist/files/js/plugin/admin/src/pluginId.js +0 -5
  139. package/dist/files/js/plugin/admin/src/translations/en.json +0 -1
  140. package/dist/files/js/plugin/admin/src/translations/fr.json +0 -1
  141. package/dist/files/js/plugin/admin/src/utils/getTrad.js +0 -5
  142. package/dist/files/js/plugin/server/bootstrap.js +0 -5
  143. package/dist/files/js/plugin/server/config/index.js +0 -6
  144. package/dist/files/js/plugin/server/controllers/index.js +0 -7
  145. package/dist/files/js/plugin/server/controllers/my-controller.js.hbs +0 -10
  146. package/dist/files/js/plugin/server/destroy.js +0 -5
  147. package/dist/files/js/plugin/server/index.js +0 -25
  148. package/dist/files/js/plugin/server/middlewares/index.js +0 -3
  149. package/dist/files/js/plugin/server/policies/index.js +0 -3
  150. package/dist/files/js/plugin/server/register.js +0 -5
  151. package/dist/files/js/plugin/server/routes/index.js +0 -10
  152. package/dist/files/js/plugin/server/services/index.js +0 -7
  153. package/dist/files/js/plugin/server/services/my-service.js +0 -7
  154. package/dist/files/js/plugin/strapi-admin.js +0 -3
  155. package/dist/files/js/plugin/strapi-server.js +0 -3
  156. package/dist/files/ts/plugin/.editorconfig +0 -7
  157. package/dist/files/ts/plugin/.gitattributes +0 -103
  158. package/dist/files/ts/plugin/admin/src/components/Initializer/index.tsx +0 -24
  159. package/dist/files/ts/plugin/admin/src/components/PluginIcon/index.tsx +0 -12
  160. package/dist/files/ts/plugin/admin/src/index.tsx +0 -67
  161. package/dist/files/ts/plugin/admin/src/pages/App/index.tsx +0 -25
  162. package/dist/files/ts/plugin/admin/src/pages/HomePage/index.tsx +0 -19
  163. package/dist/files/ts/plugin/admin/src/pluginId.ts +0 -5
  164. package/dist/files/ts/plugin/admin/src/translations/en.json +0 -1
  165. package/dist/files/ts/plugin/admin/src/translations/fr.json +0 -1
  166. package/dist/files/ts/plugin/admin/src/utils/getTrad.ts +0 -5
  167. package/dist/files/ts/plugin/custom.d.ts +0 -5
  168. package/dist/files/ts/plugin/server/bootstrap.ts +0 -5
  169. package/dist/files/ts/plugin/server/config/index.ts +0 -4
  170. package/dist/files/ts/plugin/server/controllers/index.ts +0 -5
  171. package/dist/files/ts/plugin/server/controllers/my-controller.ts.hbs +0 -10
  172. package/dist/files/ts/plugin/server/destroy.ts +0 -5
  173. package/dist/files/ts/plugin/server/index.ts +0 -23
  174. package/dist/files/ts/plugin/server/middlewares/index.ts +0 -1
  175. package/dist/files/ts/plugin/server/policies/index.ts +0 -1
  176. package/dist/files/ts/plugin/server/register.ts +0 -5
  177. package/dist/files/ts/plugin/server/routes/index.ts +0 -10
  178. package/dist/files/ts/plugin/server/services/index.ts +0 -5
  179. package/dist/files/ts/plugin/server/services/my-service.ts +0 -7
  180. package/dist/files/ts/plugin/strapi-admin.js +0 -3
  181. package/dist/files/ts/plugin/strapi-server.js +0 -3
  182. package/dist/files/ts/plugin/tsconfig.json +0 -20
  183. package/dist/files/ts/plugin/tsconfig.server.json +0 -25
  184. package/dist/plops/plugin.d.ts +0 -3
  185. package/dist/plops/plugin.js +0 -107
  186. package/dist/plops/plugin.js.map +0 -1
  187. package/dist/plops/prompts/draft-and-publish-prompts.d.ts +0 -3
  188. package/dist/plops/prompts/draft-and-publish-prompts.js +0 -12
  189. package/dist/plops/prompts/draft-and-publish-prompts.js.map +0 -1
  190. package/dist/templates/js/README.md.hbs +0 -3
  191. package/dist/templates/js/plugin-package.json.hbs +0 -42
  192. package/dist/templates/ts/README.md.hbs +0 -3
  193. package/dist/templates/ts/plugin-package.json.hbs +0 -51
  194. /package/dist/{files/js/plugin/server/content-types/index.js → templates/js/plugin/plugin.index.js.hbs} +0 -0
  195. /package/dist/{files/ts/plugin/server/content-types/index.ts → templates/ts/plugin/plugin.index.ts.hbs} +0 -0
@@ -0,0 +1,99 @@
1
+ import validateAttributeInput from '../utils/validate-attribute-input.mjs';
2
+
3
+ const DEFAULT_TYPES = [
4
+ // advanced types
5
+ 'media',
6
+ // scalar types
7
+ 'string',
8
+ 'text',
9
+ 'richtext',
10
+ 'json',
11
+ 'enumeration',
12
+ 'password',
13
+ 'email',
14
+ 'integer',
15
+ 'biginteger',
16
+ 'float',
17
+ 'decimal',
18
+ 'date',
19
+ 'time',
20
+ 'datetime',
21
+ 'timestamp',
22
+ 'boolean'
23
+ ];
24
+ const getAttributesPrompts = async (inquirer)=>{
25
+ const { addAttributes } = await inquirer.prompt([
26
+ {
27
+ type: 'confirm',
28
+ name: 'addAttributes',
29
+ message: 'Do you want to add attributes?'
30
+ }
31
+ ]);
32
+ const attributes = [];
33
+ /**
34
+ * @param {import('inquirer').Inquirer} inquirer
35
+ * @returns {Promise<void>}
36
+ */ const createNewAttributes = async (inquirer)=>{
37
+ const answers = await inquirer.prompt([
38
+ {
39
+ type: 'input',
40
+ name: 'attributeName',
41
+ message: 'Name of attribute',
42
+ validate: (input)=>validateAttributeInput(input)
43
+ },
44
+ {
45
+ type: 'list',
46
+ name: 'attributeType',
47
+ message: 'What type of attribute',
48
+ pageSize: DEFAULT_TYPES.length,
49
+ choices: DEFAULT_TYPES.map((type)=>{
50
+ return {
51
+ name: type,
52
+ value: type
53
+ };
54
+ })
55
+ },
56
+ {
57
+ when: (answers)=>answers.attributeType === 'enumeration',
58
+ type: 'input',
59
+ name: 'enum',
60
+ message: 'Add values separated by a comma'
61
+ },
62
+ {
63
+ when: (answers)=>answers.attributeType === 'media',
64
+ type: 'list',
65
+ name: 'multiple',
66
+ message: 'Choose media type',
67
+ choices: [
68
+ {
69
+ name: 'Multiple',
70
+ value: true
71
+ },
72
+ {
73
+ name: 'Single',
74
+ value: false
75
+ }
76
+ ]
77
+ },
78
+ {
79
+ type: 'confirm',
80
+ name: 'addAttributes',
81
+ message: 'Do you want to add another attribute?'
82
+ }
83
+ ]);
84
+ attributes.push(answers);
85
+ if (!answers.addAttributes) {
86
+ return;
87
+ }
88
+ await createNewAttributes(inquirer);
89
+ };
90
+ if (addAttributes) {
91
+ await createNewAttributes(inquirer);
92
+ } else {
93
+ console.warn(`You won't be able to manage entries from the admin, you can still add attributes later from the content type builder.`);
94
+ }
95
+ return attributes;
96
+ };
97
+
98
+ export { getAttributesPrompts as default };
99
+ //# sourceMappingURL=get-attributes-prompts.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-attributes-prompts.mjs","sources":["../../../src/plops/prompts/get-attributes-prompts.ts"],"sourcesContent":["import validateAttributeInput from '../utils/validate-attribute-input';\n\ninterface AttributeAnswer {\n attributeName: string;\n attributeType: (typeof DEFAULT_TYPES)[number];\n enum?: string;\n multiple?: boolean;\n}\n\nconst DEFAULT_TYPES = [\n // advanced types\n 'media',\n\n // scalar types\n 'string',\n 'text',\n 'richtext',\n 'json',\n 'enumeration',\n 'password',\n 'email',\n 'integer',\n 'biginteger',\n 'float',\n 'decimal',\n 'date',\n 'time',\n 'datetime',\n 'timestamp',\n 'boolean',\n] as const;\n\nconst getAttributesPrompts = async (inquirer: any) => {\n const { addAttributes } = await inquirer.prompt([\n {\n type: 'confirm',\n name: 'addAttributes',\n message: 'Do you want to add attributes?',\n },\n ]);\n\n const attributes: Array<AttributeAnswer> = [];\n\n /**\n * @param {import('inquirer').Inquirer} inquirer\n * @returns {Promise<void>}\n */\n const createNewAttributes = async (inquirer: any) => {\n const answers = await inquirer.prompt([\n {\n type: 'input',\n name: 'attributeName',\n message: 'Name of attribute',\n validate: (input: string) => validateAttributeInput(input),\n },\n {\n type: 'list',\n name: 'attributeType',\n message: 'What type of attribute',\n pageSize: DEFAULT_TYPES.length,\n choices: DEFAULT_TYPES.map((type) => {\n return { name: type, value: type };\n }),\n },\n {\n when: (answers: AttributeAnswer) => answers.attributeType === 'enumeration',\n type: 'input',\n name: 'enum',\n message: 'Add values separated by a comma',\n },\n {\n when: (answers: AttributeAnswer) => answers.attributeType === 'media',\n type: 'list',\n name: 'multiple',\n message: 'Choose media type',\n choices: [\n { name: 'Multiple', value: true },\n { name: 'Single', value: false },\n ],\n },\n {\n type: 'confirm',\n name: 'addAttributes',\n message: 'Do you want to add another attribute?',\n },\n ]);\n\n attributes.push(answers);\n\n if (!answers.addAttributes) {\n return;\n }\n\n await createNewAttributes(inquirer);\n };\n\n if (addAttributes) {\n await createNewAttributes(inquirer);\n } else {\n console.warn(\n `You won't be able to manage entries from the admin, you can still add attributes later from the content type builder.`\n );\n }\n\n return attributes;\n};\n\nexport default getAttributesPrompts;\n"],"names":["DEFAULT_TYPES","getAttributesPrompts","inquirer","addAttributes","prompt","type","name","message","attributes","createNewAttributes","answers","validate","input","validateAttributeInput","pageSize","length","choices","map","value","when","attributeType","push","console","warn"],"mappings":";;AASA,MAAMA,aAAgB,GAAA;;AAEpB,IAAA,OAAA;;AAGA,IAAA,QAAA;AACA,IAAA,MAAA;AACA,IAAA,UAAA;AACA,IAAA,MAAA;AACA,IAAA,aAAA;AACA,IAAA,UAAA;AACA,IAAA,OAAA;AACA,IAAA,SAAA;AACA,IAAA,YAAA;AACA,IAAA,OAAA;AACA,IAAA,SAAA;AACA,IAAA,MAAA;AACA,IAAA,MAAA;AACA,IAAA,UAAA;AACA,IAAA,WAAA;AACA,IAAA;AACD,CAAA;AAED,MAAMC,uBAAuB,OAAOC,QAAAA,GAAAA;AAClC,IAAA,MAAM,EAAEC,aAAa,EAAE,GAAG,MAAMD,QAAAA,CAASE,MAAM,CAAC;AAC9C,QAAA;YACEC,IAAM,EAAA,SAAA;YACNC,IAAM,EAAA,eAAA;YACNC,OAAS,EAAA;AACX;AACD,KAAA,CAAA;AAED,IAAA,MAAMC,aAAqC,EAAE;AAE7C;;;MAIA,MAAMC,sBAAsB,OAAOP,QAAAA,GAAAA;AACjC,QAAA,MAAMQ,OAAU,GAAA,MAAMR,QAASE,CAAAA,MAAM,CAAC;AACpC,YAAA;gBACEC,IAAM,EAAA,OAAA;gBACNC,IAAM,EAAA,eAAA;gBACNC,OAAS,EAAA,mBAAA;gBACTI,QAAU,EAAA,CAACC,QAAkBC,sBAAuBD,CAAAA,KAAAA;AACtD,aAAA;AACA,YAAA;gBACEP,IAAM,EAAA,MA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AC,CAAA;AAE3H;IAEA,OAAOf,UAAAA;AACT;;;;"}
@@ -1,5 +1,28 @@
1
- import type { PromptQuestion } from 'node-plop';
1
+ /// <reference types="node" />
2
+ import fs from 'fs-extra';
2
3
  declare const _default: (action: string, basePath: string, { rootFolder }?: {
3
4
  rootFolder?: boolean | undefined;
4
- }) => Array<PromptQuestion>;
5
+ }) => ({
6
+ type: string;
7
+ name: string;
8
+ message: string;
9
+ choices: {
10
+ name: string;
11
+ value: string;
12
+ }[];
13
+ when?: undefined;
14
+ } | {
15
+ when: (answers: any) => boolean;
16
+ type: string;
17
+ message: string;
18
+ name: string;
19
+ choices(): Promise<fs.Dirent<string>[]>;
20
+ } | {
21
+ when: (answers: any) => boolean;
22
+ type: string;
23
+ message: string;
24
+ name: string;
25
+ choices(): Promise<string[]>;
26
+ })[];
5
27
  export default _default;
28
+ //# sourceMappingURL=get-destination-prompts.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-destination-prompts.d.ts","sourceRoot":"","sources":["../../../src/plops/prompts/get-destination-prompts.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,MAAM,UAAU,CAAC;iCAEF,MAAM,YAAY,MAAM;;;;;;;;;;;;oBAyB1B,GAAG;;;;;;oBAuBH,GAAG;;;;;;AAhDzB,wBAyEE"}
@@ -1,72 +1,78 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const path_1 = require("path");
7
- const fs_extra_1 = __importDefault(require("fs-extra"));
8
- exports.default = (action, basePath, { rootFolder = false } = {}) => {
1
+ 'use strict';
2
+
3
+ var path = require('path');
4
+ var fs = require('fs-extra');
5
+
6
+ var getDestinationPrompts = ((action, basePath, { rootFolder = false } = {})=>{
9
7
  return [
10
8
  {
11
9
  type: 'list',
12
10
  name: 'destination',
13
11
  message: `Where do you want to add this ${action}?`,
14
12
  choices: [
15
- ...(rootFolder
16
- ? [
17
- {
18
- name: `Add ${action} to root of project`,
19
- value: 'root',
20
- },
21
- ]
22
- : [
23
- {
24
- name: `Add ${action} to new API`,
25
- value: 'new',
26
- },
27
- ]),
28
- { name: `Add ${action} to an existing API`, value: 'api' },
29
- { name: `Add ${action} to an existing plugin`, value: 'plugin' },
30
- ],
13
+ ...rootFolder ? [
14
+ {
15
+ name: `Add ${action} to root of project`,
16
+ value: 'root'
17
+ }
18
+ ] : [
19
+ {
20
+ name: `Add ${action} to new API`,
21
+ value: 'new'
22
+ }
23
+ ],
24
+ {
25
+ name: `Add ${action} to an existing API`,
26
+ value: 'api'
27
+ },
28
+ {
29
+ name: `Add ${action} to an existing plugin`,
30
+ value: 'plugin'
31
+ }
32
+ ]
31
33
  },
32
34
  {
33
- when: (answers) => answers.destination === 'api',
35
+ when: (answers)=>answers.destination === 'api',
34
36
  type: 'list',
35
37
  message: 'Which API is this for?',
36
38
  name: 'api',
37
- async choices() {
38
- const apiPath = (0, path_1.join)(basePath, 'api');
39
- const exists = await fs_extra_1.default.pathExists(apiPath);
39
+ async choices () {
40
+ const apiPath = path.join(basePath, 'api');
41
+ const exists = await fs.pathExists(apiPath);
40
42
  if (!exists) {
41
43
  throw Error('Couldn\'t find an "api" directory');
42
44
  }
43
- const apiDir = await fs_extra_1.default.readdir(apiPath, { withFileTypes: true });
44
- const apiDirContent = apiDir.filter((fd) => fd.isDirectory());
45
+ const apiDir = await fs.readdir(apiPath, {
46
+ withFileTypes: true
47
+ });
48
+ const apiDirContent = apiDir.filter((fd)=>fd.isDirectory());
45
49
  if (apiDirContent.length === 0) {
46
50
  throw Error('The "api" directory is empty');
47
51
  }
48
52
  return apiDirContent;
49
- },
53
+ }
50
54
  },
51
55
  {
52
- when: (answers) => answers.destination === 'plugin',
56
+ when: (answers)=>answers.destination === 'plugin',
53
57
  type: 'list',
54
58
  message: 'Which plugin is this for?',
55
59
  name: 'plugin',
56
- async choices() {
57
- const pluginsPath = (0, path_1.join)(basePath, 'plugins');
58
- const exists = await fs_extra_1.default.pathExists(pluginsPath);
60
+ async choices () {
61
+ const pluginsPath = path.join(basePath, 'plugins');
62
+ const exists = await fs.pathExists(pluginsPath);
59
63
  if (!exists) {
60
64
  throw Error('Couldn\'t find a "plugins" directory');
61
65
  }
62
- const pluginsDir = await fs_extra_1.default.readdir(pluginsPath);
63
- const pluginsDirContent = pluginsDir.filter((api) => fs_extra_1.default.lstatSync((0, path_1.join)(pluginsPath, api)).isDirectory());
66
+ const pluginsDir = await fs.readdir(pluginsPath);
67
+ const pluginsDirContent = pluginsDir.filter((api)=>fs.lstatSync(path.join(pluginsPath, api)).isDirectory());
64
68
  if (pluginsDirContent.length === 0) {
65
69
  throw Error('The "plugins" directory is empty');
66
70
  }
67
71
  return pluginsDirContent;
68
- },
69
- },
72
+ }
73
+ }
70
74
  ];
71
- };
72
- //# sourceMappingURL=get-destination-prompts.js.map
75
+ });
76
+
77
+ module.exports = getDestinationPrompts;
78
+ //# sourceMappingURL=get-destination-prompts.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"get-destination-prompts.js","sourceRoot":"","sources":["../../../src/plops/prompts/get-destination-prompts.ts"],"names":[],"mappings":";;;;;AAAA,+BAA4B;AAC5B,wDAA0B;AAI1B,kBAAe,CACb,MAAc,EACd,QAAgB,EAChB,EAAE,UAAU,GAAG,KAAK,EAAE,GAAG,EAAE,EACJ,EAAE;IACzB,OAAO;QACL;YACE,IAAI,EAAE,MAAM;YACZ,IAAI,EAAE,aAAa;YACnB,OAAO,EAAE,iCAAiC,MAAM,GAAG;YACnD,OAAO,EAAE;gBACP,GAAG,CAAC,UAAU;oBACZ,CAAC,CAAC;wBACE;4BACE,IAAI,EAAE,OAAO,MAAM,qBAAqB;4BACxC,KAAK,EAAE,MAAM;yBACd;qBACF;oBACH,CAAC,CAAC;wBACE;4BACE,IAAI,EAAE,OAAO,MAAM,aAAa;4BAChC,KAAK,EAAE,KAAK;yBACb;qBACF,CAAC;gBACN,EA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,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC;gBAEhD,IAAI,CAAC,MAAM,EAAE;oBACX,MAAM,KAAK,CAAC,sCAAsC,CAAC,CAAC;iBACrD;gBAED,MAAM,UAAU,GAAG,MAAM,kBAAE,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;gBACjD,MAAM,iBAAiB,GAAG,UAAU,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,EAAE,CAClD,kBAAE,CAAC,SAAS,CAAC,IAAA,WAAI,EAAC,WAAW,EAAE,GAAG,CAAC,CAAC,CAAC,WAAW,EAAE,CACnD,CAAC;gBAEF,IAAI,iBAAiB,CAAC,MAAM,KAAK,CAAC,EAAE;oBAClC,MAAM,KAAK,CAAC,kCAAkC,CAAC,CAAC;iBACjD;gBAED,OAAO,iBAAiB,CAAC;YAC3B,CAAC;SACF;KACF,CAAC;AACJ,CAAC,CAAC"}
1
+ {"version":3,"file":"get-destination-prompts.js","sources":["../../../src/plops/prompts/get-destination-prompts.ts"],"sourcesContent":["import { join } from 'path';\nimport fs from 'fs-extra';\n\nexport default (action: string, basePath: string, { rootFolder = false } = {}) => {\n return [\n {\n type: 'list',\n name: 'destination',\n message: `Where do you want to add this ${action}?`,\n choices: [\n ...(rootFolder\n ? [\n {\n name: `Add ${action} to root of project`,\n value: 'root',\n },\n ]\n : [\n {\n name: `Add ${action} to new API`,\n value: 'new',\n },\n ]),\n { name: `Add ${action} to an existing API`, value: 'api' },\n { name: `Add ${action} to an existing plugin`, value: 'plugin' },\n ],\n },\n {\n when: (answers: any) => answers.destination === 'api',\n type: 'list',\n message: 'Which API is this for?',\n name: 'api',\n async choices() {\n const apiPath = join(basePath, 'api');\n const exists = await fs.pathExists(apiPath);\n\n if (!exists) {\n throw Error('Couldn\\'t find an \"api\" directory');\n }\n\n const apiDir = await fs.readdir(apiPath, { withFileTypes: true });\n const apiDirContent = apiDir.filter((fd) => fd.isDirectory());\n\n if (apiDirContent.length === 0) {\n throw Error('The \"api\" directory is empty');\n }\n\n return apiDirContent;\n },\n },\n {\n when: (answers: any) => answers.destination === 'plugin',\n type: 'list',\n message: 'Which plugin is this for?',\n name: 'plugin',\n async choices() {\n const pluginsPath = join(basePath, 'plugins');\n const exists = await fs.pathExists(pluginsPath);\n\n if (!exists) {\n throw Error('Couldn\\'t find a \"plugins\" directory');\n }\n\n const pluginsDir = await fs.readdir(pluginsPath);\n const pluginsDirContent = pluginsDir.filter((api) =>\n fs.lstatSync(join(pluginsPath, api)).isDirectory()\n );\n\n if (pluginsDirContent.length === 0) {\n throw Error('The \"plugins\" directory is empty');\n }\n\n return pluginsDirContent;\n },\n },\n ];\n};\n"],"names":["action","basePath","rootFolder","type","name","message","choices","value","when","answers","destination","apiPath","join","exists","fs","pathExists","Error","apiDir","readdir","withFileTypes","apiDirContent","filter","fd","isDirectory","length","pluginsPath","pluginsDir","pluginsDirContent","api","lstatSync"],"mappings":";;;;;AAGA,4BAAe,CAAA,CAACA,MAAAA,EAAgBC,QAAkB,EAAA,EAAEC,aAAa,KAAK,EAAE,GAAG,EAAE,GAAA;IAC3E,OAAO;AACL,QAAA;YACEC,IAAM,EAAA,MAAA;YACNC,IAAM,EAAA,aAAA;AACNC,YAAAA,OAAAA,EAAS,CAAC,8BAA8B,EAAEL,MAAAA,CAAO,CAAC,CAAC;YACnDM,OAAS,EAAA;mBACHJ,UACA,GAAA;AACE,oBAAA;AACEE,wBAAAA,IAAAA,EAAM,CAAC,IAAI,EAAEJ,MAAAA,CAAO,mBAAmB,CAAC;wBACxCO,KAAO,EAAA;AACT;iBACD,GACD;AACE,oBAAA;AACEH,wBAAAA,IAAAA,EAAM,CAAC,IAAI,EAAEJ,MAAAA,CAAO,WAAW,CAAC;wBAChCO,KAAO,EAAA;AACT;AACD,iBAAA;AACL,gBAAA;AAAEH,oBAAAA,IAAAA,EAAM,CAAC,IAAI,EAAEJ,MAAAA,CAAO,mBAAmB,CAAC;oBAAEO,KAAO,EAAA;AAAM,iBAAA;AACzD,gBAAA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,UAAU,CAACU,WAAAA,CAAAA;AAEnC,gBAAA,IAAI,CAACZ,MAAQ,EAAA;AACX,oBAAA,MAAMG,KAAM,CAAA,sCAAA,CAAA;AACd;AAEA,gBAAA,MAAMU,UAAa,GAAA,MAAMZ,EAAGI,CAAAA,OAAO,CAACO,WAAAA,CAAAA;AACpC,gBAAA,MAAME,iBAAoBD,GAAAA,UAAAA,CAAWL,MAAM,CAAC,CAACO,GAAAA,GAC3Cd,EAAGe,CAAAA,SAAS,CAACjB,SAAAA,CAAKa,WAAaG,EAAAA,GAAAA,CAAAA,CAAAA,CAAML,WAAW,EAAA,CAAA;gBAGlD,IAAII,iBAAAA,CAAkBH,MAAM,KAAK,CAAG,EAAA;AAClC,oBAAA,MAAMR,KAAM,CAAA,kCAAA,CAAA;AACd;gBAEA,OAAOW,iBAAAA;AACT;AACF;AACD,KAAA;AACH,CAAA;;;;"}
@@ -0,0 +1,76 @@
1
+ import { join } from 'path';
2
+ import fs from 'fs-extra';
3
+
4
+ var getDestinationPrompts = ((action, basePath, { rootFolder = false } = {})=>{
5
+ return [
6
+ {
7
+ type: 'list',
8
+ name: 'destination',
9
+ message: `Where do you want to add this ${action}?`,
10
+ choices: [
11
+ ...rootFolder ? [
12
+ {
13
+ name: `Add ${action} to root of project`,
14
+ value: 'root'
15
+ }
16
+ ] : [
17
+ {
18
+ name: `Add ${action} to new API`,
19
+ value: 'new'
20
+ }
21
+ ],
22
+ {
23
+ name: `Add ${action} to an existing API`,
24
+ value: 'api'
25
+ },
26
+ {
27
+ name: `Add ${action} to an existing plugin`,
28
+ value: 'plugin'
29
+ }
30
+ ]
31
+ },
32
+ {
33
+ when: (answers)=>answers.destination === 'api',
34
+ type: 'list',
35
+ message: 'Which API is this for?',
36
+ name: 'api',
37
+ async choices () {
38
+ const apiPath = join(basePath, 'api');
39
+ const exists = await fs.pathExists(apiPath);
40
+ if (!exists) {
41
+ throw Error('Couldn\'t find an "api" directory');
42
+ }
43
+ const apiDir = await fs.readdir(apiPath, {
44
+ withFileTypes: true
45
+ });
46
+ const apiDirContent = apiDir.filter((fd)=>fd.isDirectory());
47
+ if (apiDirContent.length === 0) {
48
+ throw Error('The "api" directory is empty');
49
+ }
50
+ return apiDirContent;
51
+ }
52
+ },
53
+ {
54
+ when: (answers)=>answers.destination === 'plugin',
55
+ type: 'list',
56
+ message: 'Which plugin is this for?',
57
+ name: 'plugin',
58
+ async choices () {
59
+ const pluginsPath = join(basePath, 'plugins');
60
+ const exists = await fs.pathExists(pluginsPath);
61
+ if (!exists) {
62
+ throw Error('Couldn\'t find a "plugins" directory');
63
+ }
64
+ const pluginsDir = await fs.readdir(pluginsPath);
65
+ const pluginsDirContent = pluginsDir.filter((api)=>fs.lstatSync(join(pluginsPath, api)).isDirectory());
66
+ if (pluginsDirContent.length === 0) {
67
+ throw Error('The "plugins" directory is empty');
68
+ }
69
+ return pluginsDirContent;
70
+ }
71
+ }
72
+ ];
73
+ });
74
+
75
+ export { getDestinationPrompts as default };
76
+ //# sourceMappingURL=get-destination-prompts.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-destination-prompts.mjs","sources":["../../../src/plops/prompts/get-destination-prompts.ts"],"sourcesContent":["import { join } from 'path';\nimport fs from 'fs-extra';\n\nexport default (action: string, basePath: string, { rootFolder = false } = {}) => {\n return [\n {\n type: 'list',\n name: 'destination',\n message: `Where do you want to add this ${action}?`,\n choices: [\n ...(rootFolder\n ? [\n {\n name: `Add ${action} to root of project`,\n value: 'root',\n },\n ]\n : [\n {\n name: `Add ${action} to new API`,\n value: 'new',\n },\n ]),\n { name: `Add ${action} to an existing API`, value: 'api' },\n { name: `Add ${action} to an existing plugin`, value: 'plugin' },\n ],\n },\n {\n when: (answers: any) => answers.destination === 'api',\n type: 'list',\n message: 'Which API is this for?',\n name: 'api',\n async choices() {\n const apiPath = join(basePath, 'api');\n const exists = await fs.pathExists(apiPath);\n\n if (!exists) {\n throw Error('Couldn\\'t find an \"api\" directory');\n }\n\n const apiDir = await fs.readdir(apiPath, { withFileTypes: true });\n const apiDirContent = apiDir.filter((fd) => fd.isDirectory());\n\n if (apiDirContent.length === 0) {\n throw Error('The \"api\" directory is empty');\n }\n\n return apiDirContent;\n },\n },\n {\n when: (answers: any) => answers.destination === 'plugin',\n type: 'list',\n message: 'Which plugin is this for?',\n name: 'plugin',\n async choices() {\n const pluginsPath = join(basePath, 'plugins');\n const exists = await fs.pathExists(pluginsPath);\n\n if (!exists) {\n throw Error('Couldn\\'t find a \"plugins\" directory');\n }\n\n const pluginsDir = await fs.readdir(pluginsPath);\n const pluginsDirContent = pluginsDir.filter((api) =>\n fs.lstatSync(join(pluginsPath, api)).isDirectory()\n );\n\n if (pluginsDirContent.length === 0) {\n throw Error('The \"plugins\" directory is empty');\n }\n\n return pluginsDirContent;\n },\n },\n ];\n};\n"],"names":["action","basePath","rootFolder","type","name","message","choices","value","when","answers","destination","apiPath","join","exists","fs","pathExists","Error","apiDir","readdir","withFileTypes","apiDirContent","filter","fd","isDirectory","length","pluginsPath","pluginsDir","pluginsDirContent","api","lstatSync"],"mappings":";;;AAGA,4BAAe,CAAA,CAACA,MAAAA,EAAgBC,QAAkB,EAAA,EAAEC,aAAa,KAAK,EAAE,GAAG,EAAE,GAAA;IAC3E,OAAO;AACL,QAAA;YACEC,IAAM,EAAA,MAAA;YACNC,IAAM,EAAA,aAAA;AACNC,YAAAA,OAAAA,EAAS,CAAC,8BAA8B,EAAEL,MAAAA,CAAO,CAAC,CAAC;YACnDM,OAAS,EAAA;mBACHJ,UACA,GAAA;AACE,oBAAA;AACEE,wBAAAA,IAAAA,EAAM,CAAC,IAAI,EAAEJ,MAAAA,CAAO,mBAAmB,CAAC;wBACxCO,KAAO,EAAA;AACT;iBACD,GACD;AACE,oBAAA;AACEH,wBAAAA,IAAAA,EAAM,CAAC,IAAI,EAAEJ,MAAAA,CAAO,WAAW,CAAC;wBAChCO,KAAO,EAAA;AACT;AACD,iBAAA;AACL,gBAAA;AAAEH,oBAAAA,IAAA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mB,WAAAA,GAAcb,KAAKX,QAAU,EAAA,SAAA,CAAA;AACnC,gBAAA,MAAMY,MAAS,GAAA,MAAMC,EAAGC,CAAAA,UAAU,CAACU,WAAAA,CAAAA;AAEnC,gBAAA,IAAI,CAACZ,MAAQ,EAAA;AACX,oBAAA,MAAMG,KAAM,CAAA,sCAAA,CAAA;AACd;AAEA,gBAAA,MAAMU,UAAa,GAAA,MAAMZ,EAAGI,CAAAA,OAAO,CAACO,WAAAA,CAAAA;AACpC,gBAAA,MAAME,iBAAoBD,GAAAA,UAAAA,CAAWL,MAAM,CAAC,CAACO,GAAAA,GAC3Cd,EAAGe,CAAAA,SAAS,CAACjB,IAAAA,CAAKa,WAAaG,EAAAA,GAAAA,CAAAA,CAAAA,CAAML,WAAW,EAAA,CAAA;gBAGlD,IAAII,iBAAAA,CAAkBH,MAAM,KAAK,CAAG,EAAA;AAClC,oBAAA,MAAMR,KAAM,CAAA,kCAAA,CAAA;AACd;gBAEA,OAAOW,iBAAAA;AACT;AACF;AACD,KAAA;AACH,CAAA;;;;"}
@@ -1,3 +1,13 @@
1
- import type { PromptQuestion } from 'node-plop';
2
- declare const questions: Array<PromptQuestion>;
1
+ declare const questions: {
2
+ type: string;
3
+ name: string;
4
+ message: string;
5
+ default: string;
6
+ choices: {
7
+ name: string;
8
+ value: string;
9
+ }[];
10
+ validate: (input: string) => true | "You must provide an input" | "Please use only letters, '-' and no spaces";
11
+ }[];
3
12
  export default questions;
13
+ //# sourceMappingURL=kind-prompts.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"kind-prompts.d.ts","sourceRoot":"","sources":["../../../src/plops/prompts/kind-prompts.ts"],"names":[],"mappings":"AAEA,QAAA,MAAM,SAAS;;;;;;;;;sBAUO,MAAM;GAE3B,CAAC;AAEF,eAAe,SAAS,CAAC"}
@@ -1,9 +1,7 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const validate_input_1 = __importDefault(require("../utils/validate-input"));
1
+ 'use strict';
2
+
3
+ var validateInput = require('../utils/validate-input.js');
4
+
7
5
  const questions = [
8
6
  {
9
7
  type: 'list',
@@ -11,11 +9,18 @@ const questions = [
11
9
  message: 'Please choose the model type',
12
10
  default: 'collectionType',
13
11
  choices: [
14
- { name: 'Collection Type', value: 'collectionType' },
15
- { name: 'Single Type', value: 'singleType' },
12
+ {
13
+ name: 'Collection Type',
14
+ value: 'collectionType'
15
+ },
16
+ {
17
+ name: 'Single Type',
18
+ value: 'singleType'
19
+ }
16
20
  ],
17
- validate: (input) => (0, validate_input_1.default)(input),
18
- },
21
+ validate: (input)=>validateInput(input)
22
+ }
19
23
  ];
20
- exports.default = questions;
21
- //# sourceMappingURL=kind-prompts.js.map
24
+
25
+ module.exports = questions;
26
+ //# sourceMappingURL=kind-prompts.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"kind-prompts.js","sourceRoot":"","sources":["../../../src/plops/prompts/kind-prompts.ts"],"names":[],"mappings":";;;;;AAEA,6EAAoD;AAEpD,MAAM,SAAS,GAA0B;IACvC;QACE,IAAI,EAAE,MAAM;QACZ,IAAI,EAAE,MAAM;QACZ,OAAO,EAAE,8BAA8B;QACvC,OAAO,EAAE,gBAAgB;QACzB,OAAO,EAAE;YACP,EAAE,IAAI,EAAE,iBAAiB,EAAE,KAAK,EAAE,gBAAgB,EAAE;YACpD,EAAE,IAAI,EAAE,aAAa,EAAE,KAAK,EAAE,YAAY,EAAE;SAC7C;QACD,QAAQ,EAAE,CAAC,KAAa,EAAE,EAAE,CAAC,IAAA,wBAAa,EAAC,KAAK,CAAC;KAClD;CACF,CAAC;AAEF,kBAAe,SAAS,CAAC"}
1
+ {"version":3,"file":"kind-prompts.js","sources":["../../../src/plops/prompts/kind-prompts.ts"],"sourcesContent":["import validateInput from '../utils/validate-input';\n\nconst questions = [\n {\n type: 'list',\n name: 'kind',\n message: 'Please choose the model type',\n default: 'collectionType',\n choices: [\n { name: 'Collection Type', value: 'collectionType' },\n { name: 'Single Type', value: 'singleType' },\n ],\n validate: (input: string) => validateInput(input),\n },\n];\n\nexport default questions;\n"],"names":["questions","type","name","message","default","choices","value","validate","input","validateInput"],"mappings":";;;;AAEA,MAAMA,SAAY,GAAA;AAChB,IAAA;QACEC,IAAM,EAAA,MAAA;QACNC,IAAM,EAAA,MAAA;QACNC,OAAS,EAAA,8BAAA;QACTC,OAAS,EAAA,gBAAA;QACTC,OAAS,EAAA;AACP,YAAA;gBAAEH,IAAM,EAAA,iBAAA;gBAAmBI,KAAO,EAAA;AAAiB,aAAA;AACnD,YAAA;gBAAEJ,IAAM,EAAA,aAAA;gBAAeI,KAAO,EAAA;AAAa;AAC5C,SAAA;QACDC,QAAU,EAAA,CAACC,QAAkBC,aAAcD,CAAAA,KAAAA;AAC7C;AACD;;;;"}
@@ -0,0 +1,24 @@
1
+ import validateInput from '../utils/validate-input.mjs';
2
+
3
+ const questions = [
4
+ {
5
+ type: 'list',
6
+ name: 'kind',
7
+ message: 'Please choose the model type',
8
+ default: 'collectionType',
9
+ choices: [
10
+ {
11
+ name: 'Collection Type',
12
+ value: 'collectionType'
13
+ },
14
+ {
15
+ name: 'Single Type',
16
+ value: 'singleType'
17
+ }
18
+ ],
19
+ validate: (input)=>validateInput(input)
20
+ }
21
+ ];
22
+
23
+ export { questions as default };
24
+ //# sourceMappingURL=kind-prompts.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"kind-prompts.mjs","sources":["../../../src/plops/prompts/kind-prompts.ts"],"sourcesContent":["import validateInput from '../utils/validate-input';\n\nconst questions = [\n {\n type: 'list',\n name: 'kind',\n message: 'Please choose the model type',\n default: 'collectionType',\n choices: [\n { name: 'Collection Type', value: 'collectionType' },\n { name: 'Single Type', value: 'singleType' },\n ],\n validate: (input: string) => validateInput(input),\n },\n];\n\nexport default questions;\n"],"names":["questions","type","name","message","default","choices","value","validate","input","validateInput"],"mappings":";;AAEA,MAAMA,SAAY,GAAA;AAChB,IAAA;QACEC,IAAM,EAAA,MAAA;QACNC,IAAM,EAAA,MAAA;QACNC,OAAS,EAAA,8BAAA;QACTC,OAAS,EAAA,gBAAA;QACTC,OAAS,EAAA;AACP,YAAA;gBAAEH,IAAM,EAAA,iBAAA;gBAAmBI,KAAO,EAAA;AAAiB,aAAA;AACnD,YAAA;gBAAEJ,IAAM,EAAA,aAAA;gBAAeI,KAAO,EAAA;AAAa;AAC5C,SAAA;QACDC,QAAU,EAAA,CAACC,QAAkBC,aAAcD,CAAAA,KAAAA;AAC7C;AACD;;;;"}
@@ -1,3 +1,4 @@
1
- import { NodePlopAPI } from 'plop';
1
+ import type { NodePlopAPI } from 'plop';
2
2
  declare const _default: (plop: NodePlopAPI) => void;
3
3
  export default _default;
4
+ //# sourceMappingURL=service.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../../src/plops/service.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAc,WAAW,EAAE,MAAM,MAAM,CAAC;+BAS9B,WAAW;AAAjC,wBAmEE"}
@@ -1,12 +1,13 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const typescript_utils_1 = __importDefault(require("@strapi/typescript-utils"));
7
- const get_destination_prompts_1 = __importDefault(require("./prompts/get-destination-prompts"));
8
- const get_file_path_1 = __importDefault(require("./utils/get-file-path"));
9
- exports.default = (plop) => {
1
+ 'use strict';
2
+
3
+ var tsUtils = require('@strapi/typescript-utils');
4
+ var path = require('path');
5
+ var fs = require('fs');
6
+ var getDestinationPrompts = require('./prompts/get-destination-prompts.js');
7
+ var getFilePath = require('./utils/get-file-path.js');
8
+ var extendPluginIndexFiles = require('./utils/extend-plugin-index-files.js');
9
+
10
+ var generateService = ((plop)=>{
10
11
  // Service generator
11
12
  plop.setGenerator('service', {
12
13
  description: 'Generate a service for an API',
@@ -14,25 +15,57 @@ exports.default = (plop) => {
14
15
  {
15
16
  type: 'input',
16
17
  name: 'id',
17
- message: 'Service name',
18
+ message: 'Service name'
18
19
  },
19
- ...(0, get_destination_prompts_1.default)('service', plop.getDestBasePath()),
20
+ ...getDestinationPrompts('service', plop.getDestBasePath())
20
21
  ],
21
- actions(answers) {
22
+ actions (answers) {
22
23
  if (!answers) {
23
24
  return [];
24
25
  }
25
- const filePath = (0, get_file_path_1.default)(answers?.destination);
26
+ const filePath = getFilePath(answers?.destination);
26
27
  const currentDir = process.cwd();
27
- const language = typescript_utils_1.default.isUsingTypeScriptSync(currentDir) ? 'ts' : 'js';
28
- return [
28
+ let language = tsUtils.isUsingTypeScriptSync(currentDir) ? 'ts' : 'js';
29
+ if (answers.plugin) {
30
+ // The tsconfig in plugins is located just outside the server src, not in the root of the plugin.
31
+ const pluginServerDir = path.join(currentDir, 'src', filePath.replace('{{ plugin }}', answers.plugin), '../');
32
+ language = tsUtils.isUsingTypeScriptSync(pluginServerDir) ? 'ts' : 'js';
33
+ }
34
+ const baseActions = [
29
35
  {
30
36
  type: 'add',
31
37
  path: `${filePath}/services/{{ id }}.${language}`,
32
- templateFile: `templates/${language}/service.${language}.hbs`,
33
- },
38
+ templateFile: `templates/${language}/service.${language}.hbs`
39
+ }
34
40
  ];
35
- },
41
+ if (answers.plugin) {
42
+ const indexPath = path.join(plop.getDestBasePath(), `${filePath}/services/index.${language}`);
43
+ const exists = fs.existsSync(indexPath);
44
+ if (!exists) {
45
+ // Create index file if it doesn't exist
46
+ baseActions.push({
47
+ type: 'add',
48
+ path: `${filePath}/services/index.${language}`,
49
+ templateFile: `templates/${language}/plugin/plugin.index.${language}.hbs`,
50
+ skipIfExists: true
51
+ });
52
+ }
53
+ // Append the new service to the index.ts file
54
+ baseActions.push({
55
+ type: 'modify',
56
+ path: `${filePath}/services/index.${language}`,
57
+ transform (template) {
58
+ return extendPluginIndexFiles.appendToFile(template, {
59
+ type: 'index',
60
+ singularName: answers.id
61
+ });
62
+ }
63
+ });
64
+ }
65
+ return baseActions;
66
+ }
36
67
  });
37
- };
38
- //# sourceMappingURL=service.js.map
68
+ });
69
+
70
+ module.exports = generateService;
71
+ //# sourceMappingURL=service.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"service.js","sourceRoot":"","sources":["../../src/plops/service.ts"],"names":[],"mappings":";;;;;AACA,gFAA+C;AAE/C,gGAAsE;AACtE,0EAAgD;AAEhD,kBAAe,CAAC,IAAiB,EAAE,EAAE;IACnC,oBAAoB;IACpB,IAAI,CAAC,YAAY,CAAC,SAAS,EAAE;QAC3B,WAAW,EAAE,+BAA+B;QAC5C,OAAO,EAAE;YACP;gBACE,IAAI,EAAE,OAAO;gBACb,IAAI,EAAE,IAAI;gBACV,OAAO,EAAE,cAAc;aACxB;YACD,GAAG,IAAA,iCAAqB,EAAC,SAAS,EAAE,IAAI,CAAC,eAAe,EAAE,CAAC;SAC5D;QACD,OAAO,CAAC,OAAO;YACb,IAAI,CAAC,OAAO,EAAE;gBACZ,OAAO,EAAE,CAAC;aACX;YAED,MAAM,QAAQ,GAAG,IAAA,uBAAW,EAAC,OAAO,EAAE,WAAW,CAAC,CAAC;YACnD,MAAM,UAAU,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC;YACjC,MAAM,QAAQ,GAAG,0BAAO,CAAC,qBAAqB,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC;YAEzE,OAAO;gBACL;oBACE,IAAI,EAAE,KAAK;oBACX,IAAI,EAAE,GAAG,QAAQ,sBAAsB,QAAQ,EAAE;oBACjD,YAAY,EAAE,aAAa,QAAQ,YAAY,QAAQ,MAAM;iBAC9D;aACF,CAAC;QACJ,CAAC;KACF,CAAC,CAAC;AACL,CAAC,CAAC"}
1
+ {"version":3,"file":"service.js","sources":["../../src/plops/service.ts"],"sourcesContent":["import type { ActionType, NodePlopAPI } from 'plop';\nimport tsUtils from '@strapi/typescript-utils';\nimport { join } from 'path';\nimport fs from 'fs';\n\nimport getDestinationPrompts from './prompts/get-destination-prompts';\nimport getFilePath from './utils/get-file-path';\nimport { appendToFile } from './utils/extend-plugin-index-files';\n\nexport default (plop: NodePlopAPI) => {\n // Service generator\n plop.setGenerator('service', {\n description: 'Generate a service for an API',\n prompts: [\n {\n type: 'input',\n name: 'id',\n message: 'Service name',\n },\n ...getDestinationPrompts('service', plop.getDestBasePath()),\n ],\n actions(answers) {\n if (!answers) {\n return [];\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}/services/{{ id }}.${language}`,\n templateFile: `templates/${language}/service.${language}.hbs`,\n },\n ];\n\n if (answers.plugin) {\n const indexPath = join(plop.getDestBasePath(), `${filePath}/services/index.${language}`);\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}/services/index.${language}`,\n templateFile: `templates/${language}/plugin/plugin.index.${language}.hbs`,\n skipIfExists: true,\n });\n }\n\n // Append the new service to the index.ts file\n baseActions.push({\n type: 'modify',\n path: `${filePath}/services/index.${language}`,\n transform(template: string) {\n return appendToFile(template, { type: 'index', singularName: answers.id });\n },\n });\n }\n\n return baseActions;\n },\n });\n};\n"],"names":["plop","setGenerator","description","prompts","type","name","message","getDestinationPrompts","getDestBasePath","actions","answers","filePath","getFilePath","destination","currentDir","process","cwd","language","tsUtils","isUsingTypeScriptSync","plugin","pluginServerDir","join","replace","baseActions","path","templateFile","indexPath","exists","fs","existsSync","push","skipIfExists","transform","template","appendToFile","singularName","id"],"mappings":";;;;;;;;;AASA,sBAAe,CAAA,CAACA,IAAAA,GAAAA;;IAEdA,IAAKC,CAAAA,YAAY,CAAC,SAAW,EAAA;QAC3BC,WAAa,EAAA,+BAAA;QACbC,OAAS,EAAA;AACP,YAAA;gBACEC,IAAM,EAAA,OAAA;gBACNC,IAAM,EAAA,IAAA;gBACNC,OAAS,EAAA;AACX,aAAA;eACGC,qBAAsB,CAAA,SAAA,EAAWP,KAAKQ,eAAe,EAAA;AACzD,SAAA;AACDC,QAAAA,OAAAA,CAAAA,CAAQC,OAAO,EAAA;AACb,YAAA,IAAI,CAACA,OAAS,EAAA;AACZ,gBAAA,OAAO,EAAE;AACX;YAEA,MAAMC,QAAAA,GAAWC,YAAYF,OAASG,EAAAA,WAAAA,CAAAA;YACtC,MAAMC,UAAAA,GAAaC,QAAQC,GAAG,EAAA;AAC9B,YAAA,IAAIC,QAAWC,GAAAA,OAAAA,CAAQC,qBAAqB,CAACL,cAAc,IAAO,GAAA,IAAA;YAElE,IAAIJ,OAAAA,CAAQU,MAAM,EAAE;;gBAElB,MAAMC,eAAAA,GAAkBC,SACtBR,CAAAA,UAAAA,EACA,KACAH,EAAAA,QAAAA,CAASY,OAAO,CAAC,cAAA,EAAgBb,OAAQU,CAAAA,MAAM,CAC/C,EAAA,KAAA,CAAA;AAEFH,gBAAAA,QAAAA,GAAWC,OAAQC,CAAAA,qBAAqB,CAACE,eAAAA,CAAAA,GAAmB,IAAO,GAAA,IAAA;AACrE;AAEA,YAAA,MAAMG,WAAiC,GAAA;AACrC,gBAAA;oBACEpB,IAAM,EAAA,KAAA;AACNqB,oBAAAA,IAAAA,EAAM,CAAGd,EAAAA,QAAAA,CAAS,mBAAmB,EAAEM,QAAU,CAAA,CAAA;oBACjDS,YAAc,EAAA,CAAC,UAAU,EAAET,QAAAA,CAAS,SAAS,EAAEA,QAAAA,CAA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