@strapi/generators 4.10.1 → 4.10.2-alpha.0

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 (172) hide show
  1. package/dist/files/js/plugin/.editorconfig +7 -0
  2. package/dist/files/js/plugin/.gitattributes +103 -0
  3. package/dist/files/ts/plugin/.editorconfig +7 -0
  4. package/dist/files/ts/plugin/.gitattributes +103 -0
  5. package/dist/index.d.ts +5 -0
  6. package/dist/index.js +32 -0
  7. package/dist/index.js.map +1 -0
  8. package/dist/plopfile.d.ts +3 -0
  9. package/dist/plopfile.js +29 -0
  10. package/dist/plopfile.js.map +1 -0
  11. package/dist/plops/api.d.ts +3 -0
  12. package/dist/plops/api.js +79 -0
  13. package/dist/plops/api.js.map +1 -0
  14. package/dist/plops/content-type.d.ts +3 -0
  15. package/dist/plops/content-type.js +135 -0
  16. package/dist/plops/content-type.js.map +1 -0
  17. package/dist/plops/controller.d.ts +3 -0
  18. package/dist/plops/controller.js +40 -0
  19. package/dist/plops/controller.js.map +1 -0
  20. package/dist/plops/middleware.d.ts +3 -0
  21. package/dist/plops/middleware.js +40 -0
  22. package/dist/plops/middleware.js.map +1 -0
  23. package/dist/plops/migration.d.ts +3 -0
  24. package/dist/plops/migration.js +35 -0
  25. package/dist/plops/migration.js.map +1 -0
  26. package/dist/plops/plugin.d.ts +3 -0
  27. package/dist/plops/plugin.js +84 -0
  28. package/dist/plops/plugin.js.map +1 -0
  29. package/dist/plops/policy.d.ts +3 -0
  30. package/dist/plops/policy.js +40 -0
  31. package/dist/plops/policy.js.map +1 -0
  32. package/dist/plops/prompts/bootstrap-api-prompts.d.ts +3 -0
  33. package/dist/plops/prompts/bootstrap-api-prompts.js +12 -0
  34. package/dist/plops/prompts/bootstrap-api-prompts.js.map +1 -0
  35. package/dist/plops/prompts/ct-names-prompts.d.ts +3 -0
  36. package/dist/plops/prompts/ct-names-prompts.js +45 -0
  37. package/dist/plops/prompts/ct-names-prompts.js.map +1 -0
  38. package/dist/plops/prompts/draft-and-publish-prompts.d.ts +3 -0
  39. package/dist/plops/prompts/draft-and-publish-prompts.js +12 -0
  40. package/dist/plops/prompts/draft-and-publish-prompts.js.map +1 -0
  41. package/dist/plops/prompts/get-attributes-prompts.d.ts +3 -0
  42. package/dist/plops/prompts/get-attributes-prompts.js +95 -0
  43. package/dist/plops/prompts/get-attributes-prompts.js.map +1 -0
  44. package/dist/plops/prompts/get-destination-prompts.d.ts +5 -0
  45. package/dist/plops/prompts/get-destination-prompts.js +72 -0
  46. package/dist/plops/prompts/get-destination-prompts.js.map +1 -0
  47. package/dist/plops/prompts/kind-prompts.d.ts +3 -0
  48. package/dist/plops/prompts/kind-prompts.js +21 -0
  49. package/dist/plops/prompts/kind-prompts.js.map +1 -0
  50. package/dist/plops/service.d.ts +3 -0
  51. package/dist/plops/service.js +38 -0
  52. package/dist/plops/service.js.map +1 -0
  53. package/dist/plops/utils/get-file-path.d.ts +2 -0
  54. package/dist/plops/utils/get-file-path.js +15 -0
  55. package/dist/plops/utils/get-file-path.js.map +1 -0
  56. package/dist/plops/utils/get-formatted-date.d.ts +2 -0
  57. package/dist/plops/utils/get-formatted-date.js +9 -0
  58. package/dist/plops/utils/get-formatted-date.js.map +1 -0
  59. package/dist/plops/utils/validate-attribute-input.d.ts +2 -0
  60. package/dist/plops/utils/validate-attribute-input.js +10 -0
  61. package/dist/plops/utils/validate-attribute-input.js.map +1 -0
  62. package/dist/plops/utils/validate-file-name-input.d.ts +2 -0
  63. package/dist/plops/utils/validate-file-name-input.js +10 -0
  64. package/dist/plops/utils/validate-file-name-input.js.map +1 -0
  65. package/dist/plops/utils/validate-input.d.ts +2 -0
  66. package/dist/plops/utils/validate-input.js +10 -0
  67. package/dist/plops/utils/validate-input.js.map +1 -0
  68. package/package.json +22 -5
  69. package/.eslintignore +0 -3
  70. package/.eslintrc.js +0 -4
  71. package/lib/index.js +0 -37
  72. package/lib/plopfile.js +0 -28
  73. package/lib/plops/__tests__/content-type.test.js +0 -179
  74. package/lib/plops/api.js +0 -82
  75. package/lib/plops/content-type.js +0 -148
  76. package/lib/plops/controller.js +0 -36
  77. package/lib/plops/middleware.js +0 -36
  78. package/lib/plops/migration.js +0 -33
  79. package/lib/plops/plugin.js +0 -91
  80. package/lib/plops/policy.js +0 -36
  81. package/lib/plops/prompts/bootstrap-api-prompts.js +0 -10
  82. package/lib/plops/prompts/ct-names-prompts.js +0 -44
  83. package/lib/plops/prompts/draft-and-publish-prompts.js +0 -10
  84. package/lib/plops/prompts/get-attributes-prompts.js +0 -105
  85. package/lib/plops/prompts/get-destination-prompts.js +0 -79
  86. package/lib/plops/prompts/kind-prompts.js +0 -17
  87. package/lib/plops/service.js +0 -34
  88. package/lib/plops/utils/__tests__/get-file-path.test.js +0 -25
  89. package/lib/plops/utils/get-file-path.js +0 -17
  90. package/lib/plops/utils/get-formatted-date.js +0 -8
  91. package/lib/plops/utils/validate-attribute-input.js +0 -11
  92. package/lib/plops/utils/validate-file-name-input.js +0 -11
  93. package/lib/plops/utils/validate-input.js +0 -11
  94. /package/{lib → dist}/files/js/plugin/admin/src/components/Initializer/index.js +0 -0
  95. /package/{lib → dist}/files/js/plugin/admin/src/components/PluginIcon/index.js +0 -0
  96. /package/{lib → dist}/files/js/plugin/admin/src/index.js +0 -0
  97. /package/{lib → dist}/files/js/plugin/admin/src/pages/App/index.js +0 -0
  98. /package/{lib → dist}/files/js/plugin/admin/src/pages/HomePage/index.js +0 -0
  99. /package/{lib → dist}/files/js/plugin/admin/src/pluginId.js +0 -0
  100. /package/{lib → dist}/files/js/plugin/admin/src/translations/en.json +0 -0
  101. /package/{lib → dist}/files/js/plugin/admin/src/translations/fr.json +0 -0
  102. /package/{lib → dist}/files/js/plugin/admin/src/utils/getTrad.js +0 -0
  103. /package/{lib → dist}/files/js/plugin/server/bootstrap.js +0 -0
  104. /package/{lib → dist}/files/js/plugin/server/config/index.js +0 -0
  105. /package/{lib → dist}/files/js/plugin/server/content-types/index.js +0 -0
  106. /package/{lib → dist}/files/js/plugin/server/controllers/index.js +0 -0
  107. /package/{lib → dist}/files/js/plugin/server/controllers/my-controller.js.hbs +0 -0
  108. /package/{lib → dist}/files/js/plugin/server/destroy.js +0 -0
  109. /package/{lib → dist}/files/js/plugin/server/index.js +0 -0
  110. /package/{lib → dist}/files/js/plugin/server/middlewares/index.js +0 -0
  111. /package/{lib → dist}/files/js/plugin/server/policies/index.js +0 -0
  112. /package/{lib → dist}/files/js/plugin/server/register.js +0 -0
  113. /package/{lib → dist}/files/js/plugin/server/routes/index.js +0 -0
  114. /package/{lib → dist}/files/js/plugin/server/services/index.js +0 -0
  115. /package/{lib → dist}/files/js/plugin/server/services/my-service.js +0 -0
  116. /package/{lib → dist}/files/js/plugin/strapi-admin.js +0 -0
  117. /package/{lib → dist}/files/js/plugin/strapi-server.js +0 -0
  118. /package/{lib → dist}/files/ts/plugin/admin/src/components/Initializer/index.tsx +0 -0
  119. /package/{lib → dist}/files/ts/plugin/admin/src/components/PluginIcon/index.tsx +0 -0
  120. /package/{lib → dist}/files/ts/plugin/admin/src/index.tsx +0 -0
  121. /package/{lib → dist}/files/ts/plugin/admin/src/pages/App/index.tsx +0 -0
  122. /package/{lib → dist}/files/ts/plugin/admin/src/pages/HomePage/index.tsx +0 -0
  123. /package/{lib → dist}/files/ts/plugin/admin/src/pluginId.ts +0 -0
  124. /package/{lib → dist}/files/ts/plugin/admin/src/translations/en.json +0 -0
  125. /package/{lib → dist}/files/ts/plugin/admin/src/translations/fr.json +0 -0
  126. /package/{lib → dist}/files/ts/plugin/admin/src/utils/getTrad.ts +0 -0
  127. /package/{lib → dist}/files/ts/plugin/custom.d.ts +0 -0
  128. /package/{lib → dist}/files/ts/plugin/server/bootstrap.ts +0 -0
  129. /package/{lib → dist}/files/ts/plugin/server/config/index.ts +0 -0
  130. /package/{lib → dist}/files/ts/plugin/server/content-types/index.ts +0 -0
  131. /package/{lib → dist}/files/ts/plugin/server/controllers/index.ts +0 -0
  132. /package/{lib → dist}/files/ts/plugin/server/controllers/my-controller.ts.hbs +0 -0
  133. /package/{lib → dist}/files/ts/plugin/server/destroy.ts +0 -0
  134. /package/{lib → dist}/files/ts/plugin/server/index.ts +0 -0
  135. /package/{lib → dist}/files/ts/plugin/server/middlewares/index.ts +0 -0
  136. /package/{lib → dist}/files/ts/plugin/server/policies/index.ts +0 -0
  137. /package/{lib → dist}/files/ts/plugin/server/register.ts +0 -0
  138. /package/{lib → dist}/files/ts/plugin/server/routes/index.ts +0 -0
  139. /package/{lib → dist}/files/ts/plugin/server/services/index.ts +0 -0
  140. /package/{lib → dist}/files/ts/plugin/server/services/my-service.ts +0 -0
  141. /package/{lib → dist}/files/ts/plugin/strapi-admin.js +0 -0
  142. /package/{lib → dist}/files/ts/plugin/strapi-server.js +0 -0
  143. /package/{lib → dist}/files/ts/plugin/tsconfig.json +0 -0
  144. /package/{lib → dist}/files/ts/plugin/tsconfig.server.json +0 -0
  145. /package/{lib → dist}/templates/js/README.md.hbs +0 -0
  146. /package/{lib → dist}/templates/js/collection-type-routes.js.hbs +0 -0
  147. /package/{lib → dist}/templates/js/content-type.schema.json.hbs +0 -0
  148. /package/{lib → dist}/templates/js/controller.js.hbs +0 -0
  149. /package/{lib → dist}/templates/js/core-controller.js.hbs +0 -0
  150. /package/{lib → dist}/templates/js/core-router.js.hbs +0 -0
  151. /package/{lib → dist}/templates/js/core-service.js.hbs +0 -0
  152. /package/{lib → dist}/templates/js/middleware.js.hbs +0 -0
  153. /package/{lib → dist}/templates/js/migration.js.hbs +0 -0
  154. /package/{lib → dist}/templates/js/plugin-package.json.hbs +0 -0
  155. /package/{lib → dist}/templates/js/policy.js.hbs +0 -0
  156. /package/{lib → dist}/templates/js/service.js.hbs +0 -0
  157. /package/{lib → dist}/templates/js/single-route.js.hbs +0 -0
  158. /package/{lib → dist}/templates/js/single-type-routes.js.hbs +0 -0
  159. /package/{lib → dist}/templates/ts/README.md.hbs +0 -0
  160. /package/{lib → dist}/templates/ts/collection-type-routes.ts.hbs +0 -0
  161. /package/{lib → dist}/templates/ts/content-type.schema.json.hbs +0 -0
  162. /package/{lib → dist}/templates/ts/controller.ts.hbs +0 -0
  163. /package/{lib → dist}/templates/ts/core-controller.ts.hbs +0 -0
  164. /package/{lib → dist}/templates/ts/core-router.ts.hbs +0 -0
  165. /package/{lib → dist}/templates/ts/core-service.ts.hbs +0 -0
  166. /package/{lib → dist}/templates/ts/middleware.ts.hbs +0 -0
  167. /package/{lib → dist}/templates/ts/migration.ts.hbs +0 -0
  168. /package/{lib → dist}/templates/ts/plugin-package.json.hbs +0 -0
  169. /package/{lib → dist}/templates/ts/policy.ts.hbs +0 -0
  170. /package/{lib → dist}/templates/ts/service.ts.hbs +0 -0
  171. /package/{lib → dist}/templates/ts/single-route.ts.hbs +0 -0
  172. /package/{lib → dist}/templates/ts/single-type-routes.ts.hbs +0 -0
@@ -0,0 +1,35 @@
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) => {
10
+ // Migration generator
11
+ plop.setGenerator('migration', {
12
+ description: 'Generate a migration',
13
+ prompts: [
14
+ {
15
+ type: 'input',
16
+ name: 'name',
17
+ message: 'Migration name',
18
+ validate: (input) => (0, validate_file_name_input_1.default)(input),
19
+ },
20
+ ],
21
+ actions() {
22
+ const currentDir = process.cwd();
23
+ const language = typescript_utils_1.default.isUsingTypeScriptSync(currentDir) ? 'ts' : 'js';
24
+ const timestamp = (0, get_formatted_date_1.default)();
25
+ return [
26
+ {
27
+ type: 'add',
28
+ path: `${currentDir}/database/migrations/${timestamp}.{{ name }}.${language}`,
29
+ templateFile: `templates/${language}/migration.${language}.hbs`,
30
+ },
31
+ ];
32
+ },
33
+ });
34
+ };
35
+ //# sourceMappingURL=migration.js.map
@@ -0,0 +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"}
@@ -0,0 +1,3 @@
1
+ import { NodePlopAPI } from 'plop';
2
+ declare const _default: (plop: NodePlopAPI) => void;
3
+ export default _default;
@@ -0,0 +1,84 @@
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 chalk_1 = __importDefault(require("chalk"));
7
+ const typescript_utils_1 = __importDefault(require("@strapi/typescript-utils"));
8
+ const utils_1 = __importDefault(require("@strapi/utils"));
9
+ const validate_input_1 = __importDefault(require("./utils/validate-input"));
10
+ const LANGUAGES = {
11
+ javascript: 'JavaScript',
12
+ typescript: 'TypeScript',
13
+ };
14
+ const logInstructions = (pluginName, { language }) => {
15
+ const maxLength = ` resolve: './src/plugins/${pluginName}'`.length;
16
+ const separator = Array(maxLength).fill('─').join('');
17
+ const exportInstruction = language === 'js' ? 'module.exports =' : 'export default';
18
+ return `
19
+ You can now enable your plugin by adding the following in ${chalk_1.default.yellow(`./config/plugins.${language}`)}
20
+ ${separator}
21
+ ${exportInstruction} {
22
+ ${chalk_1.default.gray('// ...')}
23
+ ${chalk_1.default.green(`'${pluginName}'`)}: {
24
+ enabled: ${chalk_1.default.yellow(true)},
25
+ resolve: ${chalk_1.default.yellow(`'./src/plugins/${pluginName}'`)}
26
+ },
27
+ ${chalk_1.default.gray('// ...')}
28
+ }
29
+ ${separator}
30
+ `;
31
+ };
32
+ exports.default = (plop) => {
33
+ // Plugin generator
34
+ plop.setGenerator('plugin', {
35
+ description: 'Generate a basic plugin',
36
+ prompts: [
37
+ {
38
+ type: 'input',
39
+ name: 'pluginName',
40
+ message: 'Plugin name',
41
+ validate: (input) => (0, validate_input_1.default)(input),
42
+ },
43
+ {
44
+ type: 'list',
45
+ name: 'language',
46
+ message: 'Choose your preferred language',
47
+ choices: Object.values(LANGUAGES),
48
+ default: LANGUAGES.javascript,
49
+ },
50
+ ],
51
+ actions(answers) {
52
+ if (!answers) {
53
+ return [];
54
+ }
55
+ const isTypescript = answers.language === LANGUAGES.typescript;
56
+ const language = isTypescript ? 'ts' : 'js';
57
+ const projectLanguage = typescript_utils_1.default.isUsingTypeScriptSync(process.cwd()) ? 'ts' : 'js';
58
+ if (!utils_1.default.isKebabCase(answers.pluginName)) {
59
+ answers.pluginName = utils_1.default.toKebabCase(answers.pluginName);
60
+ console.log(chalk_1.default.yellow(`Strapi only supports kebab-cased names for plugins.\nYour plugin has been automatically renamed to "${answers.pluginName}".`));
61
+ }
62
+ return [
63
+ {
64
+ type: 'addMany',
65
+ destination: 'plugins/{{ pluginName }}',
66
+ base: `files/${language}/plugin`,
67
+ templateFiles: `files/${language}/plugin/**`,
68
+ },
69
+ {
70
+ type: 'add',
71
+ path: 'plugins/{{ pluginName }}/README.md',
72
+ templateFile: `templates/${language}/README.md.hbs`,
73
+ },
74
+ {
75
+ type: 'add',
76
+ path: 'plugins/{{ pluginName }}/package.json',
77
+ templateFile: `templates/${language}/plugin-package.json.hbs`,
78
+ },
79
+ () => plop.renderString(logInstructions(answers.pluginName, { language: projectLanguage }), null),
80
+ ];
81
+ },
82
+ });
83
+ };
84
+ //# sourceMappingURL=plugin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin.js","sourceRoot":"","sources":["../../src/plops/plugin.ts"],"names":[],"mappings":";;;;;AACA,kDAA0B;AAC1B,gFAA+C;AAC/C,0DAAkC;AAElC,4EAAmD;AAEnD,MAAM,SAAS,GAAG;IAChB,UAAU,EAAE,YAAY;IACxB,UAAU,EAAE,YAAY;CACzB,CAAC;AAEF,MAAM,eAAe,GAAG,CAAC,UAAkB,EAAE,EAAE,QAAQ,EAAwB,EAAE,EAAE;IACjF,MAAM,SAAS,GAAG,+BAA+B,UAAU,GAAG,CAAC,MAAM,CAAC;IACtE,MAAM,SAAS,GAAG,KAAK,CAAC,SAAS,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAEtD,MAAM,iBAAiB,GAAG,QAAQ,KAAK,IAAI,CAAC,CAAC,CAAC,kBAAkB,CAAC,CAAC,CAAC,gBAAgB,CAAC;IAEpF,OAAO;4DACmD,eAAK,CAAC,MAAM,CACpE,oBAAoB,QAAQ,EAAE,CAC/B;EACD,SAAS;EACT,iBAAiB;IACf,eAAK,CAAC,IAAI,CAAC,QAAQ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CAAC,WAAW,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;gBAC3D,OAAO,CAAC,GAAG,CACT,eAAK,CAAC,MAAM,CACV,uGAAuG,OAAO,CAAC,UAAU,IAAI,CAC9H,CACF,CAAC;aACH;YAED,OAAO;gBACL;oBACE,IAAI,EAAE,SAAS;oBACf,WAAW,EAAE,0BAA0B;oBACvC,IAAI,EAAE,SAAS,QAAQ,SAAS;oBAChC,aAAa,EAAE,SAAS,QAAQ,YAAY;iBAC7C;gBACD;oBACE,IAAI,EAAE,KAAK;oBACX,IAAI,EAAE,oCAAoC;oBAC1C,YAAY,EAAE,aAAa,QAAQ,gBAAgB;iBACpD;gBACD;oBACE,IAAI,EAAE,KAAK;oBACX,IAAI,EAAE,uCAAuC;oBAC7C,YAAY,EAAE,aAAa,QAAQ,0BAA0B;iBAC9D;gBACD,GAAG,EAAE,CACH,IAAI,CAAC,YAAY,CACf,eAAe,CAAC,OAAO,CAAC,UAAU,EAAE,EAAE,QAAQ,EAAE,eAAe,EAAE,CAAC,EAClE,IAAI,CACL;aACJ,CAAC;QACJ,CAAC;KACF,CAAC,CAAC;AACL,CAAC,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { NodePlopAPI } from 'plop';
2
+ declare const _default: (plop: NodePlopAPI) => void;
3
+ export default _default;
@@ -0,0 +1,40 @@
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) => {
11
+ // Policy generator
12
+ plop.setGenerator('policy', {
13
+ description: 'Generate a policy for an API',
14
+ prompts: [
15
+ {
16
+ type: 'input',
17
+ name: 'id',
18
+ message: 'Policy name',
19
+ validate: (input) => (0, validate_input_1.default)(input),
20
+ },
21
+ ...(0, get_destination_prompts_1.default)('policy', plop.getDestBasePath(), { rootFolder: true }),
22
+ ],
23
+ actions(answers) {
24
+ if (!answers) {
25
+ return [];
26
+ }
27
+ const filePath = (0, get_file_path_1.default)(answers.destination);
28
+ const currentDir = process.cwd();
29
+ const language = typescript_utils_1.default.isUsingTypeScriptSync(currentDir) ? 'ts' : 'js';
30
+ return [
31
+ {
32
+ type: 'add',
33
+ path: `${filePath}/policies/{{ id }}.${language}`,
34
+ templateFile: `templates/${language}/policy.${language}.hbs`,
35
+ },
36
+ ];
37
+ },
38
+ });
39
+ };
40
+ //# sourceMappingURL=policy.js.map
@@ -0,0 +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"}
@@ -0,0 +1,3 @@
1
+ import type { PromptQuestion } from 'node-plop';
2
+ declare const questions: Array<PromptQuestion>;
3
+ export default questions;
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const questions = [
4
+ {
5
+ type: 'confirm',
6
+ name: 'bootstrapApi',
7
+ default: true,
8
+ message: 'Bootstrap API related files?',
9
+ },
10
+ ];
11
+ exports.default = questions;
12
+ //# sourceMappingURL=bootstrap-api-prompts.js.map
@@ -0,0 +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"}
@@ -0,0 +1,3 @@
1
+ import type { PromptQuestion } from 'node-plop';
2
+ declare const questions: Array<PromptQuestion>;
3
+ export default questions;
@@ -0,0 +1,45 @@
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"));
9
+ const questions = [
10
+ {
11
+ type: 'input',
12
+ name: 'displayName',
13
+ message: 'Content type display name',
14
+ validate: (input) => !!input,
15
+ },
16
+ {
17
+ type: 'input',
18
+ name: 'singularName',
19
+ message: 'Content type singular name',
20
+ default: (answers) => (0, slugify_1.default)(answers.displayName),
21
+ validate(input) {
22
+ if (!utils_1.default.isKebabCase(input)) {
23
+ return 'Value must be in kebab-case';
24
+ }
25
+ return true;
26
+ },
27
+ },
28
+ {
29
+ type: 'input',
30
+ name: 'pluralName',
31
+ message: 'Content type plural name',
32
+ default: (answers) => (0, pluralize_1.default)(answers.singularName),
33
+ validate(input, answers) {
34
+ if (answers.singularName === input) {
35
+ return 'Singular and plural names cannot be the same';
36
+ }
37
+ if (!utils_1.default.isKebabCase(input)) {
38
+ return 'Value must be in kebab-case';
39
+ }
40
+ return true;
41
+ },
42
+ },
43
+ ];
44
+ exports.default = questions;
45
+ //# sourceMappingURL=ct-names-prompts.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ct-names-prompts.js","sourceRoot":"","sources":["../../../src/plops/prompts/ct-names-prompts.ts"],"names":[],"mappings":";;;;;AAAA,0DAAkC;AAClC,oEAA4C;AAC5C,0DAAkC;AAUlC,MAAM,SAAS,GAA0B;IACvC;QACE,IAAI,EAAE,OAAO;QACb,IAAI,EAAE,aAAa;QACnB,OAAO,EAAE,2BAA2B;QACpC,QAAQ,EAAE,CAAC,KAAa,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK;KACrC;IACD;QACE,IAAI,EAAE,OAAO;QACb,IAAI,EAAE,cAAc;QACpB,OAAO,EAAE,4BAA4B;QACrC,OAAO,EAAE,CAAC,OAAgB,EAAE,EAAE,CAAC,IAAA,iBAAO,EAAC,OAAO,CAAC,WAAW,CAAC;QAC3D,QAAQ,CAAC,KAAK;YACZ,IAAI,CAAC,eAAK,CAAC,WAAW,CAAC,KAAK,CAAC,EAAE;gBAC7B,OAAO,6BAA6B,CAAC;aACtC;YAED,OAAO,IAAI,CAAC;QACd,CAAC;KACF;IACD;QACE,IAAI,EAAE,OAAO;QACb,IAAI,EAAE,YAAY;QAClB,OAAO,EAAE,0BAA0B;QACnC,OAAO,EAAE,CAAC,OAAgB,EAAE,EAAE,CAAC,IAAA,mBAAS,EAAC,OAAO,CAAC,YAAY,CAAC;QAC9D,QAAQ,CAAC,KAAa,EAAE,OAAgB;YACtC,IAAI,OAAO,CAAC,YAAY,KAAK,KAAK,EAAE;gBAClC,OAAO,8CAA8C,CAAC;aACvD;YAED,IAAI,CAAC,eAAK,CAAC,WAAW,CAAC,KAAK,CAAC,EAAE;gBAC7B,OAAO,6BAA6B,CAAC;aACtC;YAED,OAAO,IAAI,CAAC;QACd,CAAC;KACF;CACF,CAAC;AAEF,kBAAe,SAAS,CAAC"}
@@ -0,0 +1,3 @@
1
+ import type { PromptQuestion } from 'node-plop';
2
+ declare const questions: Array<PromptQuestion>;
3
+ export default questions;
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const questions = [
4
+ {
5
+ type: 'confirm',
6
+ name: 'useDraftAndPublish',
7
+ default: false,
8
+ message: 'Use draft and publish?',
9
+ },
10
+ ];
11
+ exports.default = questions;
12
+ //# sourceMappingURL=draft-and-publish-prompts.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"draft-and-publish-prompts.js","sourceRoot":"","sources":["../../../src/plops/prompts/draft-and-publish-prompts.ts"],"names":[],"mappings":";;AAEA,MAAM,SAAS,GAA0B;IACvC;QACE,IAAI,EAAE,SAAS;QACf,IAAI,EAAE,oBAAoB;QAC1B,OAAO,EAAE,KAAK;QACd,OAAO,EAAE,wBAAwB;KAClC;CACF,CAAC;AAEF,kBAAe,SAAS,CAAC"}
@@ -0,0 +1,3 @@
1
+ import type { DynamicPromptsFunction } from 'node-plop';
2
+ declare const getAttributesPrompts: DynamicPromptsFunction;
3
+ export default getAttributesPrompts;
@@ -0,0 +1,95 @@
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_attribute_input_1 = __importDefault(require("../utils/validate-attribute-input"));
7
+ const DEFAULT_TYPES = [
8
+ // advanced types
9
+ 'media',
10
+ // scalar types
11
+ 'string',
12
+ 'text',
13
+ 'richtext',
14
+ 'json',
15
+ 'enumeration',
16
+ 'password',
17
+ 'email',
18
+ 'integer',
19
+ 'biginteger',
20
+ 'float',
21
+ 'decimal',
22
+ 'date',
23
+ 'time',
24
+ 'datetime',
25
+ 'timestamp',
26
+ 'boolean',
27
+ ];
28
+ const getAttributesPrompts = async (inquirer) => {
29
+ const { addAttributes } = await inquirer.prompt([
30
+ {
31
+ type: 'confirm',
32
+ name: 'addAttributes',
33
+ message: 'Do you want to add attributes?',
34
+ },
35
+ ]);
36
+ const attributes = [];
37
+ /**
38
+ * @param {import('inquirer').Inquirer} inquirer
39
+ * @returns {Promise<void>}
40
+ */
41
+ const createNewAttributes = async (inquirer) => {
42
+ const answers = await inquirer.prompt([
43
+ {
44
+ type: 'input',
45
+ name: 'attributeName',
46
+ message: 'Name of attribute',
47
+ validate: (input) => (0, validate_attribute_input_1.default)(input),
48
+ },
49
+ {
50
+ type: 'list',
51
+ name: 'attributeType',
52
+ message: 'What type of attribute',
53
+ pageSize: DEFAULT_TYPES.length,
54
+ choices: DEFAULT_TYPES.map((type) => {
55
+ return { name: type, value: type };
56
+ }),
57
+ },
58
+ {
59
+ when: (answers) => answers.attributeType === 'enumeration',
60
+ type: 'input',
61
+ name: 'enum',
62
+ message: 'Add values separated by a comma',
63
+ },
64
+ {
65
+ when: (answers) => answers.attributeType === 'media',
66
+ type: 'list',
67
+ name: 'multiple',
68
+ message: 'Choose media type',
69
+ choices: [
70
+ { name: 'Multiple', value: true },
71
+ { name: 'Single', value: false },
72
+ ],
73
+ },
74
+ {
75
+ type: 'confirm',
76
+ name: 'addAttributes',
77
+ message: 'Do you want to add another attribute?',
78
+ },
79
+ ]);
80
+ attributes.push(answers);
81
+ if (!answers.addAttributes) {
82
+ return;
83
+ }
84
+ await createNewAttributes(inquirer);
85
+ };
86
+ if (addAttributes) {
87
+ await createNewAttributes(inquirer);
88
+ }
89
+ else {
90
+ console.warn(`You won't be able to manage entries from the admin, you can still add attributes later from the content type builder.`);
91
+ }
92
+ return attributes;
93
+ };
94
+ exports.default = getAttributesPrompts;
95
+ //# sourceMappingURL=get-attributes-prompts.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-attributes-prompts.js","sourceRoot":"","sources":["../../../src/plops/prompts/get-attributes-prompts.ts"],"names":[],"mappings":";;;;;AAEA,iGAAuE;AASvE,MAAM,aAAa,GAAG;IACpB,iBAAiB;IACjB,OAAO;IAEP,eAAe;IACf,QAAQ;IACR,MAAM;IACN,UAAU;IACV,MAAM;IACN,aAAa;IACb,UAAU;IACV,OAAO;IACP,SAAS;IACT,YAAY;IACZ,OAAO;IACP,SAAS;IACT,MAAM;IACN,MAAM;IACN,UAAU;IACV,WAAW;IACX,SAAS;CACD,CAAC;AAEX,MAAM,oBAAoB,GAA2B,KAAK,EAAE,QAAQ,EAAE,EAAE;IACtE,MAAM,EAAE,aAAa,EAAE,GAAG,MAAM,QAAQ,CAAC,MAAM,CAAC;QAC9C;YACE,IAAI,EAAE,SAAS;YACf,IAAI,EAAE,eAAe;YACrB,OAAO,EAAE,gCAAgC;SAC1C;KACF,CAAC,CAAC;IAEH,MAAM,UAAU,GAA2B,EAAE,CAAC;IAE9C;;;OAGG;IACH,MAAM,mBAAmB,GAAG,KAAK,EAAE,QAA+C,EAAE,EAAE;QACpF,MAAM,OAAO,GAAG,MAAM,QAAQ,CAAC,MAAM,CAAC;YACpC;gBACE,IAAI,EAAE,OAAO;gBACb,IAAI,EAAE,eAAe;gBACrB,OAAO,EAAE,mBAAmB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CAAC,IAAI,CACV,uHAAuH,CACxH,CAAC;KACH;IAED,OAAO,UAAU,CAAC;AACpB,CAAC,CAAC;AAEF,kBAAe,oBAAoB,CAAC"}
@@ -0,0 +1,5 @@
1
+ import type { PromptQuestion } from 'node-plop';
2
+ declare const _default: (action: string, basePath: string, { rootFolder }?: {
3
+ rootFolder?: boolean | undefined;
4
+ }) => Array<PromptQuestion>;
5
+ export default _default;
@@ -0,0 +1,72 @@
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 } = {}) => {
9
+ return [
10
+ {
11
+ type: 'list',
12
+ name: 'destination',
13
+ message: `Where do you want to add this ${action}?`,
14
+ 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
+ ],
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 = (0, path_1.join)(basePath, 'api');
39
+ const exists = await fs_extra_1.default.pathExists(apiPath);
40
+ if (!exists) {
41
+ throw Error('Couldn\'t find an "api" directory');
42
+ }
43
+ const apiDir = await fs_extra_1.default.readdir(apiPath, { withFileTypes: true });
44
+ const apiDirContent = apiDir.filter((fd) => fd.isDirectory());
45
+ if (apiDirContent.length === 0) {
46
+ throw Error('The "api" directory is empty');
47
+ }
48
+ return apiDirContent;
49
+ },
50
+ },
51
+ {
52
+ when: (answers) => answers.destination === 'plugin',
53
+ type: 'list',
54
+ message: 'Which plugin is this for?',
55
+ name: 'plugin',
56
+ async choices() {
57
+ const pluginsPath = (0, path_1.join)(basePath, 'plugins');
58
+ const exists = await fs_extra_1.default.pathExists(pluginsPath);
59
+ if (!exists) {
60
+ throw Error('Couldn\'t find a "plugins" directory');
61
+ }
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());
64
+ if (pluginsDirContent.length === 0) {
65
+ throw Error('The "plugins" directory is empty');
66
+ }
67
+ return pluginsDirContent;
68
+ },
69
+ },
70
+ ];
71
+ };
72
+ //# sourceMappingURL=get-destination-prompts.js.map
@@ -0,0 +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,EAAE,IAAI,EAAE,OAAO,MAAM,qBAAqB,EAAE,KAAK,EAAE,KAAK,EAAE;gBAC1D,EAAE,IAAI,EAAE,OAAO,MAAM,wBAAwB,EAAE,KAAK,EAAE,QAAQ,EAAE;aACjE;SACF;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AE,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"}
@@ -0,0 +1,3 @@
1
+ import type { PromptQuestion } from 'node-plop';
2
+ declare const questions: Array<PromptQuestion>;
3
+ export default questions;
@@ -0,0 +1,21 @@
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"));
7
+ const questions = [
8
+ {
9
+ type: 'list',
10
+ name: 'kind',
11
+ message: 'Please choose the model type',
12
+ default: 'collectionType',
13
+ choices: [
14
+ { name: 'Collection Type', value: 'collectionType' },
15
+ { name: 'Single Type', value: 'singleType' },
16
+ ],
17
+ validate: (input) => (0, validate_input_1.default)(input),
18
+ },
19
+ ];
20
+ exports.default = questions;
21
+ //# sourceMappingURL=kind-prompts.js.map
@@ -0,0 +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"}
@@ -0,0 +1,3 @@
1
+ import { NodePlopAPI } from 'plop';
2
+ declare const _default: (plop: NodePlopAPI) => void;
3
+ export default _default;
@@ -0,0 +1,38 @@
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) => {
10
+ // Service generator
11
+ plop.setGenerator('service', {
12
+ description: 'Generate a service for an API',
13
+ prompts: [
14
+ {
15
+ type: 'input',
16
+ name: 'id',
17
+ message: 'Service name',
18
+ },
19
+ ...(0, get_destination_prompts_1.default)('service', plop.getDestBasePath()),
20
+ ],
21
+ actions(answers) {
22
+ if (!answers) {
23
+ return [];
24
+ }
25
+ const filePath = (0, get_file_path_1.default)(answers?.destination);
26
+ const currentDir = process.cwd();
27
+ const language = typescript_utils_1.default.isUsingTypeScriptSync(currentDir) ? 'ts' : 'js';
28
+ return [
29
+ {
30
+ type: 'add',
31
+ path: `${filePath}/services/{{ id }}.${language}`,
32
+ templateFile: `templates/${language}/service.${language}.hbs`,
33
+ },
34
+ ];
35
+ },
36
+ });
37
+ };
38
+ //# sourceMappingURL=service.js.map
@@ -0,0 +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"}
@@ -0,0 +1,2 @@
1
+ declare const _default: (destination: string) => "api/{{ id }}" | "api/{{ api }}" | "plugins/{{ plugin }}/server" | "./";
2
+ export default _default;
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = (destination) => {
4
+ if (destination === 'api') {
5
+ return `api/{{ api }}`;
6
+ }
7
+ if (destination === 'plugin') {
8
+ return `plugins/{{ plugin }}/server`;
9
+ }
10
+ if (destination === 'root') {
11
+ return './';
12
+ }
13
+ return `api/{{ id }}`;
14
+ };
15
+ //# sourceMappingURL=get-file-path.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-file-path.js","sourceRoot":"","sources":["../../../src/plops/utils/get-file-path.ts"],"names":[],"mappings":";;AAAA,kBAAe,CAAC,WAAmB,EAAE,EAAE;IACrC,IAAI,WAAW,KAAK,KAAK,EAAE;QACzB,OAAO,eAAe,CAAC;KACxB;IAED,IAAI,WAAW,KAAK,QAAQ,EAAE;QAC5B,OAAO,6BAA6B,CAAC;KACtC;IAED,IAAI,WAAW,KAAK,MAAM,EAAE;QAC1B,OAAO,IAAI,CAAC;KACb;IAED,OAAO,cAAc,CAAC;AACxB,CAAC,CAAC"}
@@ -0,0 +1,2 @@
1
+ declare const _default: (date?: Date) => string;
2
+ export default _default;
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = (date = new Date()) => {
4
+ return new Date(date.getTime() - date.getTimezoneOffset() * 60000)
5
+ .toJSON()
6
+ .replace(/[-:]/g, '.')
7
+ .replace(/\....Z/, '');
8
+ };
9
+ //# sourceMappingURL=get-formatted-date.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-formatted-date.js","sourceRoot":"","sources":["../../../src/plops/utils/get-formatted-date.ts"],"names":[],"mappings":";;AAAA,kBAAe,CAAC,OAAa,IAAI,IAAI,EAAE,EAAE,EAAE;IACzC,OAAO,IAAI,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC,iBAAiB,EAAE,GAAG,KAAK,CAAC;SAC/D,MAAM,EAAE;SACR,OAAO,CAAC,OAAO,EAAE,GAAG,CAAC;SACrB,OAAO,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;AAC3B,CAAC,CAAC"}
@@ -0,0 +1,2 @@
1
+ declare const _default: (input: string) => true | "You must provide an input" | "Please use only letters, '-', '_', and no spaces";
2
+ export default _default;
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = (input) => {
4
+ const regex = /^[A-Za-z-|_]+$/g;
5
+ if (!input) {
6
+ return 'You must provide an input';
7
+ }
8
+ return regex.test(input) || "Please use only letters, '-', '_', and no spaces";
9
+ };
10
+ //# sourceMappingURL=validate-attribute-input.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validate-attribute-input.js","sourceRoot":"","sources":["../../../src/plops/utils/validate-attribute-input.ts"],"names":[],"mappings":";;AAAA,kBAAe,CAAC,KAAa,EAAE,EAAE;IAC/B,MAAM,KAAK,GAAG,iBAAiB,CAAC;IAEhC,IAAI,CAAC,KAAK,EAAE;QACV,OAAO,2BAA2B,CAAC;KACpC;IAED,OAAO,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,mDAAmD,CAAC;AAClF,CAAC,CAAC"}
@@ -0,0 +1,2 @@
1
+ declare const _default: (input: string) => true | "You must provide an input" | "Please use only letters and number, '-' or '_' and no spaces";
2
+ export default _default;