@strapi/generators 0.0.0-next.ff946d2c25a3e577b47132a357cac2932eb8e635 → 0.0.0-next.ffc36acb308febe288f1a31b62cbbb75b286585c

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 (184) 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 +93 -27
  5. package/dist/index.js.map +1 -1
  6. package/dist/index.mjs +95 -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 +33 -31
  17. package/dist/plops/api.js.map +1 -1
  18. package/dist/plops/api.mjs +79 -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 +73 -59
  23. package/dist/plops/content-type.js.map +1 -1
  24. package/dist/plops/content-type.mjs +147 -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 +20 -20
  29. package/dist/plops/controller.js.map +1 -1
  30. package/dist/plops/controller.mjs +38 -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 +22 -20
  35. package/dist/plops/middleware.js.map +1 -1
  36. package/dist/plops/middleware.mjs +40 -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 +22 -20
  47. package/dist/plops/policy.js.map +1 -1
  48. package/dist/plops/policy.mjs +40 -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 -20
  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 +19 -19
  83. package/dist/plops/service.js.map +1 -1
  84. package/dist/plops/service.mjs +36 -0
  85. package/dist/plops/service.mjs.map +1 -0
  86. package/dist/plops/utils/get-file-path.d.ts +2 -1
  87. package/dist/plops/utils/get-file-path.d.ts.map +1 -0
  88. package/dist/plops/utils/get-file-path.js +7 -5
  89. package/dist/plops/utils/get-file-path.js.map +1 -1
  90. package/dist/plops/utils/get-file-path.mjs +15 -0
  91. package/dist/plops/utils/get-file-path.mjs.map +1 -0
  92. package/dist/plops/utils/get-formatted-date.d.ts +1 -0
  93. package/dist/plops/utils/get-formatted-date.d.ts.map +1 -0
  94. package/dist/plops/utils/get-formatted-date.js +8 -9
  95. package/dist/plops/utils/get-formatted-date.js.map +1 -1
  96. package/dist/plops/utils/get-formatted-date.mjs +6 -0
  97. package/dist/plops/utils/get-formatted-date.mjs.map +1 -0
  98. package/dist/plops/utils/validate-attribute-input.d.ts +1 -0
  99. package/dist/plops/utils/validate-attribute-input.d.ts.map +1 -0
  100. package/dist/plops/utils/validate-attribute-input.js +7 -5
  101. package/dist/plops/utils/validate-attribute-input.js.map +1 -1
  102. package/dist/plops/utils/validate-attribute-input.mjs +10 -0
  103. package/dist/plops/utils/validate-attribute-input.mjs.map +1 -0
  104. package/dist/plops/utils/validate-file-name-input.d.ts +1 -0
  105. package/dist/plops/utils/validate-file-name-input.d.ts.map +1 -0
  106. package/dist/plops/utils/validate-file-name-input.js +7 -5
  107. package/dist/plops/utils/validate-file-name-input.js.map +1 -1
  108. package/dist/plops/utils/validate-file-name-input.mjs +10 -0
  109. package/dist/plops/utils/validate-file-name-input.mjs.map +1 -0
  110. package/dist/plops/utils/validate-input.d.ts +1 -0
  111. package/dist/plops/utils/validate-input.d.ts.map +1 -0
  112. package/dist/plops/utils/validate-input.js +7 -5
  113. package/dist/plops/utils/validate-input.js.map +1 -1
  114. package/dist/plops/utils/validate-input.mjs +10 -0
  115. package/dist/plops/utils/validate-input.mjs.map +1 -0
  116. package/dist/templates/js/content-type.schema.json.hbs +0 -1
  117. package/dist/templates/ts/content-type.schema.json.hbs +0 -1
  118. package/dist/templates/ts/middleware.ts.hbs +2 -2
  119. package/package.json +21 -17
  120. package/dist/files/js/plugin/.editorconfig +0 -7
  121. package/dist/files/js/plugin/.gitattributes +0 -103
  122. package/dist/files/js/plugin/admin/src/components/Initializer/index.js +0 -26
  123. package/dist/files/js/plugin/admin/src/components/PluginIcon/index.js +0 -12
  124. package/dist/files/js/plugin/admin/src/index.js +0 -63
  125. package/dist/files/js/plugin/admin/src/pages/App/index.js +0 -25
  126. package/dist/files/js/plugin/admin/src/pages/HomePage/index.js +0 -20
  127. package/dist/files/js/plugin/admin/src/pluginId.js +0 -5
  128. package/dist/files/js/plugin/admin/src/translations/en.json +0 -1
  129. package/dist/files/js/plugin/admin/src/translations/fr.json +0 -1
  130. package/dist/files/js/plugin/admin/src/utils/getTrad.js +0 -5
  131. package/dist/files/js/plugin/server/bootstrap.js +0 -5
  132. package/dist/files/js/plugin/server/config/index.js +0 -6
  133. package/dist/files/js/plugin/server/content-types/index.js +0 -3
  134. package/dist/files/js/plugin/server/controllers/index.js +0 -7
  135. package/dist/files/js/plugin/server/controllers/my-controller.js.hbs +0 -10
  136. package/dist/files/js/plugin/server/destroy.js +0 -5
  137. package/dist/files/js/plugin/server/index.js +0 -25
  138. package/dist/files/js/plugin/server/middlewares/index.js +0 -3
  139. package/dist/files/js/plugin/server/policies/index.js +0 -3
  140. package/dist/files/js/plugin/server/register.js +0 -5
  141. package/dist/files/js/plugin/server/routes/index.js +0 -10
  142. package/dist/files/js/plugin/server/services/index.js +0 -7
  143. package/dist/files/js/plugin/server/services/my-service.js +0 -7
  144. package/dist/files/js/plugin/strapi-admin.js +0 -3
  145. package/dist/files/js/plugin/strapi-server.js +0 -3
  146. package/dist/files/ts/plugin/.editorconfig +0 -7
  147. package/dist/files/ts/plugin/.gitattributes +0 -103
  148. package/dist/files/ts/plugin/admin/src/components/Initializer/index.tsx +0 -24
  149. package/dist/files/ts/plugin/admin/src/components/PluginIcon/index.tsx +0 -12
  150. package/dist/files/ts/plugin/admin/src/index.tsx +0 -67
  151. package/dist/files/ts/plugin/admin/src/pages/App/index.tsx +0 -25
  152. package/dist/files/ts/plugin/admin/src/pages/HomePage/index.tsx +0 -19
  153. package/dist/files/ts/plugin/admin/src/pluginId.ts +0 -5
  154. package/dist/files/ts/plugin/admin/src/translations/en.json +0 -1
  155. package/dist/files/ts/plugin/admin/src/translations/fr.json +0 -1
  156. package/dist/files/ts/plugin/admin/src/utils/getTrad.ts +0 -5
  157. package/dist/files/ts/plugin/custom.d.ts +0 -5
  158. package/dist/files/ts/plugin/server/bootstrap.ts +0 -5
  159. package/dist/files/ts/plugin/server/config/index.ts +0 -4
  160. package/dist/files/ts/plugin/server/content-types/index.ts +0 -1
  161. package/dist/files/ts/plugin/server/controllers/index.ts +0 -5
  162. package/dist/files/ts/plugin/server/controllers/my-controller.ts.hbs +0 -10
  163. package/dist/files/ts/plugin/server/destroy.ts +0 -5
  164. package/dist/files/ts/plugin/server/index.ts +0 -23
  165. package/dist/files/ts/plugin/server/middlewares/index.ts +0 -1
  166. package/dist/files/ts/plugin/server/policies/index.ts +0 -1
  167. package/dist/files/ts/plugin/server/register.ts +0 -5
  168. package/dist/files/ts/plugin/server/routes/index.ts +0 -10
  169. package/dist/files/ts/plugin/server/services/index.ts +0 -5
  170. package/dist/files/ts/plugin/server/services/my-service.ts +0 -7
  171. package/dist/files/ts/plugin/strapi-admin.js +0 -3
  172. package/dist/files/ts/plugin/strapi-server.js +0 -3
  173. package/dist/files/ts/plugin/tsconfig.json +0 -20
  174. package/dist/files/ts/plugin/tsconfig.server.json +0 -25
  175. package/dist/plops/plugin.d.ts +0 -3
  176. package/dist/plops/plugin.js +0 -84
  177. package/dist/plops/plugin.js.map +0 -1
  178. package/dist/plops/prompts/draft-and-publish-prompts.d.ts +0 -3
  179. package/dist/plops/prompts/draft-and-publish-prompts.js +0 -12
  180. package/dist/plops/prompts/draft-and-publish-prompts.js.map +0 -1
  181. package/dist/templates/js/README.md.hbs +0 -3
  182. package/dist/templates/js/plugin-package.json.hbs +0 -42
  183. package/dist/templates/ts/README.md.hbs +0 -3
  184. package/dist/templates/ts/plugin-package.json.hbs +0 -51
@@ -0,0 +1,38 @@
1
+ import tsUtils from '@strapi/typescript-utils';
2
+ import getDestinationPrompts from './prompts/get-destination-prompts.mjs';
3
+ import getFilePath from './utils/get-file-path.mjs';
4
+ import validateInput from './utils/validate-input.mjs';
5
+
6
+ var generateController = ((plop)=>{
7
+ // Controller generator
8
+ plop.setGenerator('controller', {
9
+ description: 'Generate a controller for an API',
10
+ prompts: [
11
+ {
12
+ type: 'input',
13
+ name: 'id',
14
+ message: 'Controller name',
15
+ validate: (input)=>validateInput(input)
16
+ },
17
+ ...getDestinationPrompts('controller', plop.getDestBasePath())
18
+ ],
19
+ actions (answers) {
20
+ if (!answers) {
21
+ return [];
22
+ }
23
+ const filePath = getFilePath(answers.destination);
24
+ const currentDir = process.cwd();
25
+ const language = tsUtils.isUsingTypeScriptSync(currentDir) ? 'ts' : 'js';
26
+ return [
27
+ {
28
+ type: 'add',
29
+ path: `${filePath}/controllers/{{ id }}.${language}`,
30
+ templateFile: `templates/${language}/controller.${language}.hbs`
31
+ }
32
+ ];
33
+ }
34
+ });
35
+ });
36
+
37
+ export { generateController as default };
38
+ //# sourceMappingURL=controller.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"controller.mjs","sources":["../../src/plops/controller.ts"],"sourcesContent":["import type { NodePlopAPI } from 'plop';\nimport tsUtils from '@strapi/typescript-utils';\n\nimport getDestinationPrompts from './prompts/get-destination-prompts';\nimport getFilePath from './utils/get-file-path';\nimport validateInput from './utils/validate-input';\n\nexport default (plop: NodePlopAPI) => {\n // Controller generator\n plop.setGenerator('controller', {\n description: 'Generate a controller for an API',\n prompts: [\n {\n type: 'input',\n name: 'id',\n message: 'Controller name',\n validate: (input) => validateInput(input),\n },\n ...getDestinationPrompts('controller', 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 const language = tsUtils.isUsingTypeScriptSync(currentDir) ? 'ts' : 'js';\n\n return [\n {\n type: 'add',\n path: `${filePath}/controllers/{{ id }}.${language}`,\n templateFile: `templates/${language}/controller.${language}.hbs`,\n },\n ];\n },\n });\n};\n"],"names":["plop","setGenerator","description","prompts","type","name","message","validate","input","validateInput","getDestinationPrompts","getDestBasePath","actions","answers","filePath","getFilePath","destination","currentDir","process","cwd","language","tsUtils","isUsingTypeScriptSync","path","templateFile"],"mappings":";;;;;AAOA,yBAAe,CAAA,CAACA,IAAAA,GAAAA;;IAEdA,IAAKC,CAAAA,YAAY,CAAC,YAAc,EAAA;QAC9BC,WAAa,EAAA,kCAAA;QACbC,OAAS,EAAA;AACP,YAAA;gBACEC,IAAM,EAAA,OAAA;gBACNC,IAAM,EAAA,IAAA;gBACNC,OAAS,EAAA,iBAAA;gBACTC,QAAU,EAAA,CAACC,QAAUC,aAAcD,CAAAA,KAAAA;AACrC,aAAA;eACGE,qBAAsB,CAAA,YAAA,EAAcV,KAAKW,eAAe,EAAA;AAC5D,SAAA;AACDC,QAAAA,OAAAA,CAAAA,CAAQC,OAAO,EAAA;AACb,YAAA,IAAI,CAACA,OAAS,EAAA;AACZ,gBAAA,OAAO,EAAE;AACX;YAEA,MAAMC,QAAAA,GAAWC,WAAYF,CAAAA,OAAAA,CAAQG,WAAW,CAAA;YAChD,MAAMC,UAAAA,GAAaC,QAAQC,GAAG,EAAA;AAC9B,YAAA,MAAMC,QAAWC,GAAAA,OAAAA,CAAQC,qBAAqB,CAACL,cAAc,IAAO,GAAA,IAAA;YAEpE,OAAO;AACL,gBAAA;oBACEb,IAAM,EAAA,KAAA;AACNmB,oBAAAA,IAAAA,EAAM,CAAC,EAAET,QAAAA,CAAS,sBAAsB,EAAEM,SAAS,CAAC;oBACpDI,YAAc,EAAA,CAAC,UAAU,EAAEJ,QAAAA,CAAS,YAAY,EAAEA,QAAAA,CAAS,IAAI;AACjE;AACD,aAAA;AACH;AACF,KAAA,CAAA;AACF,CAAA;;;;"}
@@ -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=middleware.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"middleware.d.ts","sourceRoot":"","sources":["../../src/plops/middleware.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,MAAM,CAAC;+BAOlB,WAAW;AAAjC,wBA+BE"}
@@ -1,13 +1,11 @@
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 validate_input_1 = __importDefault(require("./utils/validate-input"));
9
- const get_file_path_1 = __importDefault(require("./utils/get-file-path"));
10
- exports.default = (plop) => {
1
+ 'use strict';
2
+
3
+ var tsUtils = require('@strapi/typescript-utils');
4
+ var getDestinationPrompts = require('./prompts/get-destination-prompts.js');
5
+ var validateInput = require('./utils/validate-input.js');
6
+ var getFilePath = require('./utils/get-file-path.js');
7
+
8
+ var generateMiddleware = ((plop)=>{
11
9
  // middleware generator
12
10
  plop.setGenerator('middleware', {
13
11
  description: 'Generate a middleware for an API',
@@ -16,25 +14,29 @@ exports.default = (plop) => {
16
14
  type: 'input',
17
15
  name: 'name',
18
16
  message: 'Middleware name',
19
- validate: (input) => (0, validate_input_1.default)(input),
17
+ validate: (input)=>validateInput(input)
20
18
  },
21
- ...(0, get_destination_prompts_1.default)('middleware', plop.getDestBasePath(), { rootFolder: true }),
19
+ ...getDestinationPrompts('middleware', plop.getDestBasePath(), {
20
+ rootFolder: true
21
+ })
22
22
  ],
23
- actions(answers) {
23
+ actions (answers) {
24
24
  if (!answers) {
25
25
  return [];
26
26
  }
27
- const filePath = (0, get_file_path_1.default)(answers.destination);
27
+ const filePath = getFilePath(answers.destination);
28
28
  const currentDir = process.cwd();
29
- const language = typescript_utils_1.default.isUsingTypeScriptSync(currentDir) ? 'ts' : 'js';
29
+ const language = tsUtils.isUsingTypeScriptSync(currentDir) ? 'ts' : 'js';
30
30
  return [
31
31
  {
32
32
  type: 'add',
33
33
  path: `${filePath}/middlewares/{{ name }}.${language}`,
34
- templateFile: `templates/${language}/middleware.${language}.hbs`,
35
- },
34
+ templateFile: `templates/${language}/middleware.${language}.hbs`
35
+ }
36
36
  ];
37
- },
37
+ }
38
38
  });
39
- };
40
- //# sourceMappingURL=middleware.js.map
39
+ });
40
+
41
+ module.exports = generateMiddleware;
42
+ //# sourceMappingURL=middleware.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"middleware.js","sourceRoot":"","sources":["../../src/plops/middleware.ts"],"names":[],"mappings":";;;;;AACA,gFAA+C;AAE/C,gGAAsE;AACtE,4EAAmD;AACnD,0EAAgD;AAEhD,kBAAe,CAAC,IAAiB,EAAE,EAAE;IACnC,uBAAuB;IACvB,IAAI,CAAC,YAAY,CAAC,YAAY,EAAE;QAC9B,WAAW,EAAE,kCAAkC;QAC/C,OAAO,EAAE;YACP;gBACE,IAAI,EAAE,OAAO;gBACb,IAAI,EAAE,MAAM;gBACZ,OAAO,EAAE,iBAAiB;gBAC1B,QAAQ,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,IAAA,wBAAa,EAAC,KAAK,CAAC;aAC1C;YACD,GAAG,IAAA,iCAAqB,EAAC,YAAY,EAAE,IAAI,CAAC,eAAe,EAAE,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC;SACrF;QACD,OAAO,CAAC,OAAO;YACb,IAAI,CAAC,OAAO,EAAE;gBACZ,OAAO,EAAE,CAAC;aACX;YAED,MAAM,QAAQ,GAAG,IAAA,uBAAW,EAAC,OAAO,CAAC,WAAW,CAAC,CAAC;YAClD,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,2BAA2B,QAAQ,EAAE;oBACtD,YAAY,EAAE,aAAa,QAAQ,eAAe,QAAQ,MAAM;iBACjE;aACF,CAAC;QACJ,CAAC;KACF,CAAC,CAAC;AACL,CAAC,CAAC"}
1
+ {"version":3,"file":"middleware.js","sources":["../../src/plops/middleware.ts"],"sourcesContent":["import type { NodePlopAPI } from 'plop';\nimport tsUtils from '@strapi/typescript-utils';\n\nimport getDestinationPrompts from './prompts/get-destination-prompts';\nimport validateInput from './utils/validate-input';\nimport getFilePath from './utils/get-file-path';\n\nexport default (plop: NodePlopAPI) => {\n // middleware generator\n plop.setGenerator('middleware', {\n description: 'Generate a middleware for an API',\n prompts: [\n {\n type: 'input',\n name: 'name',\n message: 'Middleware name',\n validate: (input) => validateInput(input),\n },\n ...getDestinationPrompts('middleware', plop.getDestBasePath(), { rootFolder: true }),\n ],\n actions(answers) {\n if (!answers) {\n return [];\n }\n\n const filePath = getFilePath(answers.destination);\n const currentDir = process.cwd();\n const language = tsUtils.isUsingTypeScriptSync(currentDir) ? 'ts' : 'js';\n\n return [\n {\n type: 'add',\n path: `${filePath}/middlewares/{{ name }}.${language}`,\n templateFile: `templates/${language}/middleware.${language}.hbs`,\n },\n ];\n },\n });\n};\n"],"names":["plop","setGenerator","description","prompts","type","name","message","validate","input","validateInput","getDestinationPrompts","getDestBasePath","rootFolder","actions","answers","filePath","getFilePath","destination","currentDir","process","cwd","language","tsUtils","isUsingTypeScriptSync","path","templateFile"],"mappings":";;;;;;;AAOA,yBAAe,CAAA,CAACA,IAAAA,GAAAA;;IAEdA,IAAKC,CAAAA,YAAY,CAAC,YAAc,EAAA;QAC9BC,WAAa,EAAA,kCAAA;QACbC,OAAS,EAAA;AACP,YAAA;gBACEC,IAAM,EAAA,OAAA;gBACNC,IAAM,EAAA,MAAA;gBACNC,OAAS,EAAA,iBAAA;gBACTC,QAAU,EAAA,CAACC,QAAUC,aAAcD,CAAAA,KAAAA;AACrC,aAAA;eACGE,qBAAsB,CAAA,YAAA,EAAcV,IAAKW,CAAAA,eAAe,EAAI,EAAA;gBAAEC,UAAY,EAAA;AAAK,aAAA;AACnF,SAAA;AACDC,QAAAA,OAAAA,CAAAA,CAAQC,OAAO,EAAA;AACb,YAAA,IAAI,CAACA,OAAS,EAAA;AACZ,gBAAA,OAAO,EAAE;AACX;YAEA,MAAMC,QAAAA,GAAWC,WAAYF,CAAAA,OAAAA,CAAQG,WAAW,CAAA;YAChD,MAAMC,UAAAA,GAAaC,QAAQC,GAAG,EAAA;AAC9B,YAAA,MAAMC,QAAWC,GAAAA,OAAAA,CAAQC,qBAAqB,CAACL,cAAc,IAAO,GAAA,IAAA;YAEpE,OAAO;AACL,gBAAA;oBACEd,IAAM,EAAA,KAAA;AACNoB,oBAAAA,IAAAA,EAAM,CAAC,EAAET,QAAAA,CAAS,wBAAwB,EAAEM,SAAS,CAAC;oBACtDI,YAAc,EAAA,CAAC,UAAU,EAAEJ,QAAAA,CAAS,YAAY,EAAEA,QAAAA,CAAS,IAAI;AACjE;AACD,aAAA;AACH;AACF,KAAA,CAAA;AACF,CAAA;;;;"}
@@ -0,0 +1,40 @@
1
+ import tsUtils from '@strapi/typescript-utils';
2
+ import getDestinationPrompts from './prompts/get-destination-prompts.mjs';
3
+ import validateInput from './utils/validate-input.mjs';
4
+ import getFilePath from './utils/get-file-path.mjs';
5
+
6
+ var generateMiddleware = ((plop)=>{
7
+ // middleware generator
8
+ plop.setGenerator('middleware', {
9
+ description: 'Generate a middleware for an API',
10
+ prompts: [
11
+ {
12
+ type: 'input',
13
+ name: 'name',
14
+ message: 'Middleware name',
15
+ validate: (input)=>validateInput(input)
16
+ },
17
+ ...getDestinationPrompts('middleware', plop.getDestBasePath(), {
18
+ rootFolder: true
19
+ })
20
+ ],
21
+ actions (answers) {
22
+ if (!answers) {
23
+ return [];
24
+ }
25
+ const filePath = getFilePath(answers.destination);
26
+ const currentDir = process.cwd();
27
+ const language = tsUtils.isUsingTypeScriptSync(currentDir) ? 'ts' : 'js';
28
+ return [
29
+ {
30
+ type: 'add',
31
+ path: `${filePath}/middlewares/{{ name }}.${language}`,
32
+ templateFile: `templates/${language}/middleware.${language}.hbs`
33
+ }
34
+ ];
35
+ }
36
+ });
37
+ });
38
+
39
+ export { generateMiddleware as default };
40
+ //# sourceMappingURL=middleware.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"middleware.mjs","sources":["../../src/plops/middleware.ts"],"sourcesContent":["import type { NodePlopAPI } from 'plop';\nimport tsUtils from '@strapi/typescript-utils';\n\nimport getDestinationPrompts from './prompts/get-destination-prompts';\nimport validateInput from './utils/validate-input';\nimport getFilePath from './utils/get-file-path';\n\nexport default (plop: NodePlopAPI) => {\n // middleware generator\n plop.setGenerator('middleware', {\n description: 'Generate a middleware for an API',\n prompts: [\n {\n type: 'input',\n name: 'name',\n message: 'Middleware name',\n validate: (input) => validateInput(input),\n },\n ...getDestinationPrompts('middleware', plop.getDestBasePath(), { rootFolder: true }),\n ],\n actions(answers) {\n if (!answers) {\n return [];\n }\n\n const filePath = getFilePath(answers.destination);\n const currentDir = process.cwd();\n const language = tsUtils.isUsingTypeScriptSync(currentDir) ? 'ts' : 'js';\n\n return [\n {\n type: 'add',\n path: `${filePath}/middlewares/{{ name }}.${language}`,\n templateFile: `templates/${language}/middleware.${language}.hbs`,\n },\n ];\n },\n });\n};\n"],"names":["plop","setGenerator","description","prompts","type","name","message","validate","input","validateInput","getDestinationPrompts","getDestBasePath","rootFolder","actions","answers","filePath","getFilePath","destination","currentDir","process","cwd","language","tsUtils","isUsingTypeScriptSync","path","templateFile"],"mappings":";;;;;AAOA,yBAAe,CAAA,CAACA,IAAAA,GAAAA;;IAEdA,IAAKC,CAAAA,YAAY,CAAC,YAAc,EAAA;QAC9BC,WAAa,EAAA,kCAAA;QACbC,OAAS,EAAA;AACP,YAAA;gBACEC,IAAM,EAAA,OAAA;gBACNC,IAAM,EAAA,MAAA;gBACNC,OAAS,EAAA,iBAAA;gBACTC,QAAU,EAAA,CAACC,QAAUC,aAAcD,CAAAA,KAAAA;AACrC,aAAA;eACGE,qBAAsB,CAAA,YAAA,EAAcV,IAAKW,CAAAA,eAAe,EAAI,EAAA;gBAAEC,UAAY,EAAA;AAAK,aAAA;AACnF,SAAA;AACDC,QAAAA,OAAAA,CAAAA,CAAQC,OAAO,EAAA;AACb,YAAA,IAAI,CAACA,OAAS,EAAA;AACZ,gBAAA,OAAO,EAAE;AACX;YAEA,MAAMC,QAAAA,GAAWC,WAAYF,CAAAA,OAAAA,CAAQG,WAAW,CAAA;YAChD,MAAMC,UAAAA,GAAaC,QAAQC,GAAG,EAAA;AAC9B,YAAA,MAAMC,QAAWC,GAAAA,OAAAA,CAAQC,qBAAqB,CAACL,cAAc,IAAO,GAAA,IAAA;YAEpE,OAAO;AACL,gBAAA;oBACEd,IAAM,EAAA,KAAA;AACNoB,oBAAAA,IAAAA,EAAM,CAAC,EAAET,QAAAA,CAAS,wBAAwB,EAAEM,SAAS,CAAC;oBACtDI,YAAc,EAAA,CAAC,UAAU,EAAEJ,QAAAA,CAAS,YAAY,EAAEA,QAAAA,CAAS,IAAI;AACjE;AACD,aAAA;AACH;AACF,KAAA,CAAA;AACF,CAAA;;;;"}
@@ -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=migration.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"migration.d.ts","sourceRoot":"","sources":["../../src/plops/migration.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,MAAM,CAAC;+BAKlB,WAAW;AAAjC,wBA0BE"}
@@ -1,12 +1,10 @@
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 validate_file_name_input_1 = __importDefault(require("./utils/validate-file-name-input"));
8
- const get_formatted_date_1 = __importDefault(require("./utils/get-formatted-date"));
9
- exports.default = (plop) => {
1
+ 'use strict';
2
+
3
+ var tsUtils = require('@strapi/typescript-utils');
4
+ var validateFileNameInput = require('./utils/validate-file-name-input.js');
5
+ var getFormattedDate = require('./utils/get-formatted-date.js');
6
+
7
+ var generateMigration = ((plop)=>{
10
8
  // Migration generator
11
9
  plop.setGenerator('migration', {
12
10
  description: 'Generate a migration',
@@ -15,21 +13,23 @@ exports.default = (plop) => {
15
13
  type: 'input',
16
14
  name: 'name',
17
15
  message: 'Migration name',
18
- validate: (input) => (0, validate_file_name_input_1.default)(input),
19
- },
16
+ validate: (input)=>validateFileNameInput(input)
17
+ }
20
18
  ],
21
- actions() {
19
+ actions () {
22
20
  const currentDir = process.cwd();
23
- const language = typescript_utils_1.default.isUsingTypeScriptSync(currentDir) ? 'ts' : 'js';
24
- const timestamp = (0, get_formatted_date_1.default)();
21
+ const language = tsUtils.isUsingTypeScriptSync(currentDir) ? 'ts' : 'js';
22
+ const timestamp = getFormattedDate();
25
23
  return [
26
24
  {
27
25
  type: 'add',
28
26
  path: `${currentDir}/database/migrations/${timestamp}.{{ name }}.${language}`,
29
- templateFile: `templates/${language}/migration.${language}.hbs`,
30
- },
27
+ templateFile: `templates/${language}/migration.${language}.hbs`
28
+ }
31
29
  ];
32
- },
30
+ }
33
31
  });
34
- };
35
- //# sourceMappingURL=migration.js.map
32
+ });
33
+
34
+ module.exports = generateMigration;
35
+ //# sourceMappingURL=migration.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"migration.js","sourceRoot":"","sources":["../../src/plops/migration.ts"],"names":[],"mappings":";;;;;AACA,gFAA+C;AAC/C,gGAAqE;AACrE,oFAA0D;AAE1D,kBAAe,CAAC,IAAiB,EAAE,EAAE;IACnC,sBAAsB;IACtB,IAAI,CAAC,YAAY,CAAC,WAAW,EAAE;QAC7B,WAAW,EAAE,sBAAsB;QACnC,OAAO,EAAE;YACP;gBACE,IAAI,EAAE,OAAO;gBACb,IAAI,EAAE,MAAM;gBACZ,OAAO,EAAE,gBAAgB;gBACzB,QAAQ,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,IAAA,kCAAqB,EAAC,KAAK,CAAC;aAClD;SACF;QACD,OAAO;YACL,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;YACzE,MAAM,SAAS,GAAG,IAAA,4BAAgB,GAAE,CAAC;YAErC,OAAO;gBACL;oBACE,IAAI,EAAE,KAAK;oBACX,IAAI,EAAE,GAAG,UAAU,wBAAwB,SAAS,eAAe,QAAQ,EAAE;oBAC7E,YAAY,EAAE,aAAa,QAAQ,cAAc,QAAQ,MAAM;iBAChE;aACF,CAAC;QACJ,CAAC;KACF,CAAC,CAAC;AACL,CAAC,CAAC"}
1
+ {"version":3,"file":"migration.js","sources":["../../src/plops/migration.ts"],"sourcesContent":["import type { NodePlopAPI } from 'plop';\nimport tsUtils from '@strapi/typescript-utils';\nimport validateFileNameInput from './utils/validate-file-name-input';\nimport getFormattedDate from './utils/get-formatted-date';\n\nexport default (plop: NodePlopAPI) => {\n // Migration generator\n plop.setGenerator('migration', {\n description: 'Generate a migration',\n prompts: [\n {\n type: 'input',\n name: 'name',\n message: 'Migration name',\n validate: (input) => validateFileNameInput(input),\n },\n ],\n actions() {\n const currentDir = process.cwd();\n const language = tsUtils.isUsingTypeScriptSync(currentDir) ? 'ts' : 'js';\n const timestamp = getFormattedDate();\n\n return [\n {\n type: 'add',\n path: `${currentDir}/database/migrations/${timestamp}.{{ name }}.${language}`,\n templateFile: `templates/${language}/migration.${language}.hbs`,\n },\n ];\n },\n });\n};\n"],"names":["plop","setGenerator","description","prompts","type","name","message","validate","input","validateFileNameInput","actions","currentDir","process","cwd","language","tsUtils","isUsingTypeScriptSync","timestamp","getFormattedDate","path","templateFile"],"mappings":";;;;;;AAKA,wBAAe,CAAA,CAACA,IAAAA,GAAAA;;IAEdA,IAAKC,CAAAA,YAAY,CAAC,WAAa,EAAA;QAC7BC,WAAa,EAAA,sBAAA;QACbC,OAAS,EAAA;AACP,YAAA;gBACEC,IAAM,EAAA,OAAA;gBACNC,IAAM,EAAA,MAAA;gBACNC,OAAS,EAAA,gBAAA;gBACTC,QAAU,EAAA,CAACC,QAAUC,qBAAsBD,CAAAA,KAAAA;AAC7C;AACD,SAAA;AACDE,QAAAA,OAAAA,CAAAA,GAAAA;YACE,MAAMC,UAAAA,GAAaC,QAAQC,GAAG,EAAA;AAC9B,YAAA,MAAMC,QAAWC,GAAAA,OAAAA,CAAQC,qBAAqB,CAACL,cAAc,IAAO,GAAA,IAAA;AACpE,YAAA,MAAMM,SAAYC,GAAAA,gBAAAA,EAAAA;YAElB,OAAO;AACL,gBAAA;oBACEd,IAAM,EAAA,KAAA;oBACNe,IAAM,EAAA,CAAC,EAAER,UAAW,CAAA,qBAAqB,EAAEM,SAAU,CAAA,YAAY,EAAEH,QAAAA,CAAS,CAAC;oBAC7EM,YAAc,EAAA,CAAC,UAAU,EAAEN,QAAAA,CAAS,WAAW,EAAEA,QAAAA,CAAS,IAAI;AAChE;AACD,aAAA;AACH;AACF,KAAA,CAAA;AACF,CAAA;;;;"}
@@ -0,0 +1,33 @@
1
+ import tsUtils from '@strapi/typescript-utils';
2
+ import validateFileNameInput from './utils/validate-file-name-input.mjs';
3
+ import getFormattedDate from './utils/get-formatted-date.mjs';
4
+
5
+ var generateMigration = ((plop)=>{
6
+ // Migration generator
7
+ plop.setGenerator('migration', {
8
+ description: 'Generate a migration',
9
+ prompts: [
10
+ {
11
+ type: 'input',
12
+ name: 'name',
13
+ message: 'Migration name',
14
+ validate: (input)=>validateFileNameInput(input)
15
+ }
16
+ ],
17
+ actions () {
18
+ const currentDir = process.cwd();
19
+ const language = tsUtils.isUsingTypeScriptSync(currentDir) ? 'ts' : 'js';
20
+ const timestamp = getFormattedDate();
21
+ return [
22
+ {
23
+ type: 'add',
24
+ path: `${currentDir}/database/migrations/${timestamp}.{{ name }}.${language}`,
25
+ templateFile: `templates/${language}/migration.${language}.hbs`
26
+ }
27
+ ];
28
+ }
29
+ });
30
+ });
31
+
32
+ export { generateMigration as default };
33
+ //# sourceMappingURL=migration.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"migration.mjs","sources":["../../src/plops/migration.ts"],"sourcesContent":["import type { NodePlopAPI } from 'plop';\nimport tsUtils from '@strapi/typescript-utils';\nimport validateFileNameInput from './utils/validate-file-name-input';\nimport getFormattedDate from './utils/get-formatted-date';\n\nexport default (plop: NodePlopAPI) => {\n // Migration generator\n plop.setGenerator('migration', {\n description: 'Generate a migration',\n prompts: [\n {\n type: 'input',\n name: 'name',\n message: 'Migration name',\n validate: (input) => validateFileNameInput(input),\n },\n ],\n actions() {\n const currentDir = process.cwd();\n const language = tsUtils.isUsingTypeScriptSync(currentDir) ? 'ts' : 'js';\n const timestamp = getFormattedDate();\n\n return [\n {\n type: 'add',\n path: `${currentDir}/database/migrations/${timestamp}.{{ name }}.${language}`,\n templateFile: `templates/${language}/migration.${language}.hbs`,\n },\n ];\n },\n });\n};\n"],"names":["plop","setGenerator","description","prompts","type","name","message","validate","input","validateFileNameInput","actions","currentDir","process","cwd","language","tsUtils","isUsingTypeScriptSync","timestamp","getFormattedDate","path","templateFile"],"mappings":";;;;AAKA,wBAAe,CAAA,CAACA,IAAAA,GAAAA;;IAEdA,IAAKC,CAAAA,YAAY,CAAC,WAAa,EAAA;QAC7BC,WAAa,EAAA,sBAAA;QACbC,OAAS,EAAA;AACP,YAAA;gBACEC,IAAM,EAAA,OAAA;gBACNC,IAAM,EAAA,MAAA;gBACNC,OAAS,EAAA,gBAAA;gBACTC,QAAU,EAAA,CAACC,QAAUC,qBAAsBD,CAAAA,KAAAA;AAC7C;AACD,SAAA;AACDE,QAAAA,OAAAA,CAAAA,GAAAA;YACE,MAAMC,UAAAA,GAAaC,QAAQC,GAAG,EAAA;AAC9B,YAAA,MAAMC,QAAWC,GAAAA,OAAAA,CAAQC,qBAAqB,CAACL,cAAc,IAAO,GAAA,IAAA;AACpE,YAAA,MAAMM,SAAYC,GAAAA,gBAAAA,EAAAA;YAElB,OAAO;AACL,gBAAA;oBACEd,IAAM,EAAA,KAAA;oBACNe,IAAM,EAAA,CAAC,EAAER,UAAW,CAAA,qBAAqB,EAAEM,SAAU,CAAA,YAAY,EAAEH,QAAAA,CAAS,CAAC;oBAC7EM,YAAc,EAAA,CAAC,UAAU,EAAEN,QAAAA,CAAS,WAAW,EAAEA,QAAAA,CAAS,IAAI;AAChE;AACD,aAAA;AACH;AACF,KAAA,CAAA;AACF,CAAA;;;;"}
@@ -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=policy.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"policy.d.ts","sourceRoot":"","sources":["../../src/plops/policy.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,MAAM,CAAC;+BAOlB,WAAW;AAAjC,wBA+BE"}
@@ -1,13 +1,11 @@
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 validate_input_1 = __importDefault(require("./utils/validate-input"));
9
- const get_file_path_1 = __importDefault(require("./utils/get-file-path"));
10
- exports.default = (plop) => {
1
+ 'use strict';
2
+
3
+ var tsUtils = require('@strapi/typescript-utils');
4
+ var getDestinationPrompts = require('./prompts/get-destination-prompts.js');
5
+ var validateInput = require('./utils/validate-input.js');
6
+ var getFilePath = require('./utils/get-file-path.js');
7
+
8
+ var generatePolicy = ((plop)=>{
11
9
  // Policy generator
12
10
  plop.setGenerator('policy', {
13
11
  description: 'Generate a policy for an API',
@@ -16,25 +14,29 @@ exports.default = (plop) => {
16
14
  type: 'input',
17
15
  name: 'id',
18
16
  message: 'Policy name',
19
- validate: (input) => (0, validate_input_1.default)(input),
17
+ validate: (input)=>validateInput(input)
20
18
  },
21
- ...(0, get_destination_prompts_1.default)('policy', plop.getDestBasePath(), { rootFolder: true }),
19
+ ...getDestinationPrompts('policy', plop.getDestBasePath(), {
20
+ rootFolder: true
21
+ })
22
22
  ],
23
- actions(answers) {
23
+ actions (answers) {
24
24
  if (!answers) {
25
25
  return [];
26
26
  }
27
- const filePath = (0, get_file_path_1.default)(answers.destination);
28
27
  const currentDir = process.cwd();
29
- const language = typescript_utils_1.default.isUsingTypeScriptSync(currentDir) ? 'ts' : 'js';
28
+ const filePath = getFilePath(answers.destination);
29
+ const language = tsUtils.isUsingTypeScriptSync(currentDir) ? 'ts' : 'js';
30
30
  return [
31
31
  {
32
32
  type: 'add',
33
33
  path: `${filePath}/policies/{{ id }}.${language}`,
34
- templateFile: `templates/${language}/policy.${language}.hbs`,
35
- },
34
+ templateFile: `templates/${language}/policy.${language}.hbs`
35
+ }
36
36
  ];
37
- },
37
+ }
38
38
  });
39
- };
40
- //# sourceMappingURL=policy.js.map
39
+ });
40
+
41
+ module.exports = generatePolicy;
42
+ //# sourceMappingURL=policy.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"policy.js","sourceRoot":"","sources":["../../src/plops/policy.ts"],"names":[],"mappings":";;;;;AACA,gFAA+C;AAE/C,gGAAsE;AACtE,4EAAmD;AACnD,0EAAgD;AAEhD,kBAAe,CAAC,IAAiB,EAAE,EAAE;IACnC,mBAAmB;IACnB,IAAI,CAAC,YAAY,CAAC,QAAQ,EAAE;QAC1B,WAAW,EAAE,8BAA8B;QAC3C,OAAO,EAAE;YACP;gBACE,IAAI,EAAE,OAAO;gBACb,IAAI,EAAE,IAAI;gBACV,OAAO,EAAE,aAAa;gBACtB,QAAQ,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,IAAA,wBAAa,EAAC,KAAK,CAAC;aAC1C;YACD,GAAG,IAAA,iCAAqB,EAAC,QAAQ,EAAE,IAAI,CAAC,eAAe,EAAE,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC;SACjF;QACD,OAAO,CAAC,OAAO;YACb,IAAI,CAAC,OAAO,EAAE;gBACZ,OAAO,EAAE,CAAC;aACX;YAED,MAAM,QAAQ,GAAG,IAAA,uBAAW,EAAC,OAAO,CAAC,WAAW,CAAC,CAAC;YAClD,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,WAAW,QAAQ,MAAM;iBAC7D;aACF,CAAC;QACJ,CAAC;KACF,CAAC,CAAC;AACL,CAAC,CAAC"}
1
+ {"version":3,"file":"policy.js","sources":["../../src/plops/policy.ts"],"sourcesContent":["import type { NodePlopAPI } from 'plop';\nimport tsUtils from '@strapi/typescript-utils';\n\nimport getDestinationPrompts from './prompts/get-destination-prompts';\nimport validateInput from './utils/validate-input';\nimport getFilePath from './utils/get-file-path';\n\nexport default (plop: NodePlopAPI) => {\n // Policy generator\n plop.setGenerator('policy', {\n description: 'Generate a policy for an API',\n prompts: [\n {\n type: 'input',\n name: 'id',\n message: 'Policy name',\n validate: (input) => validateInput(input),\n },\n ...getDestinationPrompts('policy', plop.getDestBasePath(), { rootFolder: true }),\n ],\n actions(answers) {\n if (!answers) {\n return [];\n }\n\n const currentDir = process.cwd();\n const filePath = getFilePath(answers.destination);\n const language = tsUtils.isUsingTypeScriptSync(currentDir) ? 'ts' : 'js';\n\n return [\n {\n type: 'add',\n path: `${filePath}/policies/{{ id }}.${language}`,\n templateFile: `templates/${language}/policy.${language}.hbs`,\n },\n ];\n },\n });\n};\n"],"names":["plop","setGenerator","description","prompts","type","name","message","validate","input","validateInput","getDestinationPrompts","getDestBasePath","rootFolder","actions","answers","currentDir","process","cwd","filePath","getFilePath","destination","language","tsUtils","isUsingTypeScriptSync","path","templateFile"],"mappings":";;;;;;;AAOA,qBAAe,CAAA,CAACA,IAAAA,GAAAA;;IAEdA,IAAKC,CAAAA,YAAY,CAAC,QAAU,EAAA;QAC1BC,WAAa,EAAA,8BAAA;QACbC,OAAS,EAAA;AACP,YAAA;gBACEC,IAAM,EAAA,OAAA;gBACNC,IAAM,EAAA,IAAA;gBACNC,OAAS,EAAA,aAAA;gBACTC,QAAU,EAAA,CAACC,QAAUC,aAAcD,CAAAA,KAAAA;AACrC,aAAA;eACGE,qBAAsB,CAAA,QAAA,EAAUV,IAAKW,CAAAA,eAAe,EAAI,EAAA;gBAAEC,UAAY,EAAA;AAAK,aAAA;AAC/E,SAAA;AACDC,QAAAA,OAAAA,CAAAA,CAAQC,OAAO,EAAA;AACb,YAAA,IAAI,CAACA,OAAS,EAAA;AACZ,gBAAA,OAAO,EAAE;AACX;YAEA,MAAMC,UAAAA,GAAaC,QAAQC,GAAG,EAAA;YAC9B,MAAMC,QAAAA,GAAWC,WAAYL,CAAAA,OAAAA,CAAQM,WAAW,CAAA;AAChD,YAAA,MAAMC,QAAWC,GAAAA,OAAAA,CAAQC,qBAAqB,CAACR,cAAc,IAAO,GAAA,IAAA;YAEpE,OAAO;AACL,gBAAA;oBACEX,IAAM,EAAA,KAAA;AACNoB,oBAAAA,IAAAA,EAAM,CAAC,EAAEN,QAAAA,CAAS,mBAAmB,EAAEG,SAAS,CAAC;oBACjDI,YAAc,EAAA,CAAC,UAAU,EAAEJ,QAAAA,CAAS,QAAQ,EAAEA,QAAAA,CAAS,IAAI;AAC7D;AACD,aAAA;AACH;AACF,KAAA,CAAA;AACF,CAAA;;;;"}
@@ -0,0 +1,40 @@
1
+ import tsUtils from '@strapi/typescript-utils';
2
+ import getDestinationPrompts from './prompts/get-destination-prompts.mjs';
3
+ import validateInput from './utils/validate-input.mjs';
4
+ import getFilePath from './utils/get-file-path.mjs';
5
+
6
+ var generatePolicy = ((plop)=>{
7
+ // Policy generator
8
+ plop.setGenerator('policy', {
9
+ description: 'Generate a policy for an API',
10
+ prompts: [
11
+ {
12
+ type: 'input',
13
+ name: 'id',
14
+ message: 'Policy name',
15
+ validate: (input)=>validateInput(input)
16
+ },
17
+ ...getDestinationPrompts('policy', plop.getDestBasePath(), {
18
+ rootFolder: true
19
+ })
20
+ ],
21
+ actions (answers) {
22
+ if (!answers) {
23
+ return [];
24
+ }
25
+ const currentDir = process.cwd();
26
+ const filePath = getFilePath(answers.destination);
27
+ const language = tsUtils.isUsingTypeScriptSync(currentDir) ? 'ts' : 'js';
28
+ return [
29
+ {
30
+ type: 'add',
31
+ path: `${filePath}/policies/{{ id }}.${language}`,
32
+ templateFile: `templates/${language}/policy.${language}.hbs`
33
+ }
34
+ ];
35
+ }
36
+ });
37
+ });
38
+
39
+ export { generatePolicy as default };
40
+ //# sourceMappingURL=policy.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"policy.mjs","sources":["../../src/plops/policy.ts"],"sourcesContent":["import type { NodePlopAPI } from 'plop';\nimport tsUtils from '@strapi/typescript-utils';\n\nimport getDestinationPrompts from './prompts/get-destination-prompts';\nimport validateInput from './utils/validate-input';\nimport getFilePath from './utils/get-file-path';\n\nexport default (plop: NodePlopAPI) => {\n // Policy generator\n plop.setGenerator('policy', {\n description: 'Generate a policy for an API',\n prompts: [\n {\n type: 'input',\n name: 'id',\n message: 'Policy name',\n validate: (input) => validateInput(input),\n },\n ...getDestinationPrompts('policy', plop.getDestBasePath(), { rootFolder: true }),\n ],\n actions(answers) {\n if (!answers) {\n return [];\n }\n\n const currentDir = process.cwd();\n const filePath = getFilePath(answers.destination);\n const language = tsUtils.isUsingTypeScriptSync(currentDir) ? 'ts' : 'js';\n\n return [\n {\n type: 'add',\n path: `${filePath}/policies/{{ id }}.${language}`,\n templateFile: `templates/${language}/policy.${language}.hbs`,\n },\n ];\n },\n });\n};\n"],"names":["plop","setGenerator","description","prompts","type","name","message","validate","input","validateInput","getDestinationPrompts","getDestBasePath","rootFolder","actions","answers","currentDir","process","cwd","filePath","getFilePath","destination","language","tsUtils","isUsingTypeScriptSync","path","templateFile"],"mappings":";;;;;AAOA,qBAAe,CAAA,CAACA,IAAAA,GAAAA;;IAEdA,IAAKC,CAAAA,YAAY,CAAC,QAAU,EAAA;QAC1BC,WAAa,EAAA,8BAAA;QACbC,OAAS,EAAA;AACP,YAAA;gBACEC,IAAM,EAAA,OAAA;gBACNC,IAAM,EAAA,IAAA;gBACNC,OAAS,EAAA,aAAA;gBACTC,QAAU,EAAA,CAACC,QAAUC,aAAcD,CAAAA,KAAAA;AACrC,aAAA;eACGE,qBAAsB,CAAA,QAAA,EAAUV,IAAKW,CAAAA,eAAe,EAAI,EAAA;gBAAEC,UAAY,EAAA;AAAK,aAAA;AAC/E,SAAA;AACDC,QAAAA,OAAAA,CAAAA,CAAQC,OAAO,EAAA;AACb,YAAA,IAAI,CAACA,OAAS,EAAA;AACZ,gBAAA,OAAO,EAAE;AACX;YAEA,MAAMC,UAAAA,GAAaC,QAAQC,GAAG,EAAA;YAC9B,MAAMC,QAAAA,GAAWC,WAAYL,CAAAA,OAAAA,CAAQM,WAAW,CAAA;AAChD,YAAA,MAAMC,QAAWC,GAAAA,OAAAA,CAAQC,qBAAqB,CAACR,cAAc,IAAO,GAAA,IAAA;YAEpE,OAAO;AACL,gBAAA;oBACEX,IAAM,EAAA,KAAA;AACNoB,oBAAAA,IAAAA,EAAM,CAAC,EAAEN,QAAAA,CAAS,mBAAmB,EAAEG,SAAS,CAAC;oBACjDI,YAAc,EAAA,CAAC,UAAU,EAAEJ,QAAAA,CAAS,QAAQ,EAAEA,QAAAA,CAAS,IAAI;AAC7D;AACD,aAAA;AACH;AACF,KAAA,CAAA;AACF,CAAA;;;;"}
@@ -1,3 +1,8 @@
1
- import type { PromptQuestion } from 'node-plop';
2
- declare const questions: Array<PromptQuestion>;
1
+ declare const questions: {
2
+ type: string;
3
+ name: string;
4
+ default: boolean;
5
+ message: string;
6
+ }[];
3
7
  export default questions;
8
+ //# sourceMappingURL=bootstrap-api-prompts.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bootstrap-api-prompts.d.ts","sourceRoot":"","sources":["../../../src/plops/prompts/bootstrap-api-prompts.ts"],"names":[],"mappings":"AAAA,QAAA,MAAM,SAAS;;;;;GAOd,CAAC;AAEF,eAAe,SAAS,CAAC"}
@@ -1,12 +1,13 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ 'use strict';
2
+
3
3
  const questions = [
4
4
  {
5
5
  type: 'confirm',
6
6
  name: 'bootstrapApi',
7
7
  default: true,
8
- message: 'Bootstrap API related files?',
9
- },
8
+ message: 'Bootstrap API related files?'
9
+ }
10
10
  ];
11
- exports.default = questions;
12
- //# sourceMappingURL=bootstrap-api-prompts.js.map
11
+
12
+ module.exports = questions;
13
+ //# sourceMappingURL=bootstrap-api-prompts.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"bootstrap-api-prompts.js","sourceRoot":"","sources":["../../../src/plops/prompts/bootstrap-api-prompts.ts"],"names":[],"mappings":";;AAEA,MAAM,SAAS,GAA0B;IACvC;QACE,IAAI,EAAE,SAAS;QACf,IAAI,EAAE,cAAc;QACpB,OAAO,EAAE,IAAI;QACb,OAAO,EAAE,8BAA8B;KACxC;CACF,CAAC;AAEF,kBAAe,SAAS,CAAC"}
1
+ {"version":3,"file":"bootstrap-api-prompts.js","sources":["../../../src/plops/prompts/bootstrap-api-prompts.ts"],"sourcesContent":["const questions = [\n {\n type: 'confirm',\n name: 'bootstrapApi',\n default: true,\n message: 'Bootstrap API related files?',\n },\n];\n\nexport default questions;\n"],"names":["questions","type","name","default","message"],"mappings":";;AAAA,MAAMA,SAAY,GAAA;AAChB,IAAA;QACEC,IAAM,EAAA,SAAA;QACNC,IAAM,EAAA,cAAA;QACNC,OAAS,EAAA,IAAA;QACTC,OAAS,EAAA;AACX;AACD;;;;"}
@@ -0,0 +1,11 @@
1
+ const questions = [
2
+ {
3
+ type: 'confirm',
4
+ name: 'bootstrapApi',
5
+ default: true,
6
+ message: 'Bootstrap API related files?'
7
+ }
8
+ ];
9
+
10
+ export { questions as default };
11
+ //# sourceMappingURL=bootstrap-api-prompts.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bootstrap-api-prompts.mjs","sources":["../../../src/plops/prompts/bootstrap-api-prompts.ts"],"sourcesContent":["const questions = [\n {\n type: 'confirm',\n name: 'bootstrapApi',\n default: true,\n message: 'Bootstrap API related files?',\n },\n];\n\nexport default questions;\n"],"names":["questions","type","name","default","message"],"mappings":"AAAA,MAAMA,SAAY,GAAA;AAChB,IAAA;QACEC,IAAM,EAAA,SAAA;QACNC,IAAM,EAAA,cAAA;QACNC,OAAS,EAAA,IAAA;QACTC,OAAS,EAAA;AACX;AACD;;;;"}
@@ -1,3 +1,20 @@
1
- import type { PromptQuestion } from 'node-plop';
2
- declare const questions: Array<PromptQuestion>;
1
+ interface Answers {
2
+ displayName: string;
3
+ singularName: string;
4
+ pluralName: string;
5
+ }
6
+ declare const questions: ({
7
+ type: string;
8
+ name: string;
9
+ message: string;
10
+ validate: (input: string) => boolean;
11
+ default?: undefined;
12
+ } | {
13
+ type: string;
14
+ name: string;
15
+ message: string;
16
+ default: (answers: Answers) => any;
17
+ validate(input: string, answers: Answers): true | "Singular and plural names cannot be the same" | "Value must be in kebab-case";
18
+ })[];
3
19
  export default questions;
20
+ //# sourceMappingURL=ct-names-prompts.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ct-names-prompts.d.ts","sourceRoot":"","sources":["../../../src/plops/prompts/ct-names-prompts.ts"],"names":[],"mappings":"AAIA,UAAU,OAAO;IACf,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,QAAA,MAAM,SAAS;;;;sBAKO,MAAM;;;;;;uBAmBL,OAAO;oBACV,MAAM,WAAW,OAAO;IAY3C,CAAC;AAEF,eAAe,SAAS,CAAC"}
@@ -1,45 +1,44 @@
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 pluralize_1 = __importDefault(require("pluralize"));
7
- const slugify_1 = __importDefault(require("@sindresorhus/slugify"));
8
- const utils_1 = __importDefault(require("@strapi/utils"));
1
+ 'use strict';
2
+
3
+ var pluralize = require('pluralize');
4
+ var slugify = require('@sindresorhus/slugify');
5
+ var utils = require('@strapi/utils');
6
+
9
7
  const questions = [
10
8
  {
11
9
  type: 'input',
12
10
  name: 'displayName',
13
11
  message: 'Content type display name',
14
- validate: (input) => !!input,
12
+ validate: (input)=>!!input
15
13
  },
16
14
  {
17
15
  type: 'input',
18
16
  name: 'singularName',
19
17
  message: 'Content type singular name',
20
- default: (answers) => (0, slugify_1.default)(answers.displayName),
21
- validate(input) {
22
- if (!utils_1.default.isKebabCase(input)) {
18
+ default: (answers)=>slugify(answers.displayName),
19
+ validate (input) {
20
+ if (!utils.strings.isKebabCase(input)) {
23
21
  return 'Value must be in kebab-case';
24
22
  }
25
23
  return true;
26
- },
24
+ }
27
25
  },
28
26
  {
29
27
  type: 'input',
30
28
  name: 'pluralName',
31
29
  message: 'Content type plural name',
32
- default: (answers) => (0, pluralize_1.default)(answers.singularName),
33
- validate(input, answers) {
30
+ default: (answers)=>pluralize(answers.singularName),
31
+ validate (input, answers) {
34
32
  if (answers.singularName === input) {
35
33
  return 'Singular and plural names cannot be the same';
36
34
  }
37
- if (!utils_1.default.isKebabCase(input)) {
35
+ if (!utils.strings.isKebabCase(input)) {
38
36
  return 'Value must be in kebab-case';
39
37
  }
40
38
  return true;
41
- },
42
- },
39
+ }
40
+ }
43
41
  ];
44
- exports.default = questions;
45
- //# sourceMappingURL=ct-names-prompts.js.map
42
+
43
+ module.exports = questions;
44
+ //# sourceMappingURL=ct-names-prompts.js.map