@strapi/generators 5.48.1 → 5.50.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 (46) hide show
  1. package/dist/index.d.ts.map +1 -1
  2. package/dist/index.js +14 -9
  3. package/dist/index.js.map +1 -1
  4. package/dist/plopfile.d.ts.map +1 -1
  5. package/dist/plopfile.js +5 -1
  6. package/dist/plopfile.js.map +1 -1
  7. package/dist/plops/api.d.ts.map +1 -1
  8. package/dist/plops/api.js +13 -8
  9. package/dist/plops/api.js.map +1 -1
  10. package/dist/plops/api.mjs +1 -1
  11. package/dist/plops/api.mjs.map +1 -1
  12. package/dist/plops/content-type.d.ts.map +1 -1
  13. package/dist/plops/content-type.js +15 -9
  14. package/dist/plops/content-type.js.map +1 -1
  15. package/dist/plops/controller.d.ts.map +1 -1
  16. package/dist/plops/controller.js +8 -3
  17. package/dist/plops/controller.js.map +1 -1
  18. package/dist/plops/middleware.d.ts.map +1 -1
  19. package/dist/plops/middleware.js +8 -3
  20. package/dist/plops/middleware.js.map +1 -1
  21. package/dist/plops/migration.d.ts.map +1 -1
  22. package/dist/plops/migration.js +5 -1
  23. package/dist/plops/migration.js.map +1 -1
  24. package/dist/plops/policy.d.ts.map +1 -1
  25. package/dist/plops/policy.js +8 -3
  26. package/dist/plops/policy.js.map +1 -1
  27. package/dist/plops/prompts/ct-names-prompts.js +7 -2
  28. package/dist/plops/prompts/ct-names-prompts.js.map +1 -1
  29. package/dist/plops/prompts/get-attributes-prompts.d.ts.map +1 -1
  30. package/dist/plops/prompts/get-destination-prompts.d.ts +0 -1
  31. package/dist/plops/prompts/get-destination-prompts.d.ts.map +1 -1
  32. package/dist/plops/prompts/get-destination-prompts.js +9 -5
  33. package/dist/plops/prompts/get-destination-prompts.js.map +1 -1
  34. package/dist/plops/service.d.ts.map +1 -1
  35. package/dist/plops/service.js +8 -3
  36. package/dist/plops/service.js.map +1 -1
  37. package/dist/plops/utils/extend-plugin-index-files.d.ts.map +1 -1
  38. package/dist/plops/utils/extend-plugin-index-files.js +10 -6
  39. package/dist/plops/utils/extend-plugin-index-files.js.map +1 -1
  40. package/dist/plops/utils/extend-plugin-index-files.mjs.map +1 -1
  41. package/dist/plops/utils/get-file-path.d.ts.map +1 -1
  42. package/dist/plops/utils/get-formatted-date.d.ts.map +1 -1
  43. package/dist/plops/utils/validate-attribute-input.d.ts.map +1 -1
  44. package/dist/plops/utils/validate-file-name-input.d.ts.map +1 -1
  45. package/dist/plops/utils/validate-input.d.ts.map +1 -1
  46. package/package.json +5 -5
@@ -1 +1 @@
1
- {"version":3,"file":"middleware.d.ts","sourceRoot":"","sources":["../../src/plops/middleware.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAc,WAAW,EAAE,MAAM,MAAM,CAAC;+BAU9B,WAAW;AAAjC,wBAoEE"}
1
+ {"version":3,"file":"middleware.d.ts","sourceRoot":"","sources":["../../src/plops/middleware.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAc,WAAW,EAAE,MAAM,MAAM,CAAC;yBAUpC,MAAM,WAAW;AAAjC,wBAoEE"}
@@ -8,6 +8,11 @@ var validateInput = require('./utils/validate-input.js');
8
8
  var getFilePath = require('./utils/get-file-path.js');
9
9
  var extendPluginIndexFiles = require('./utils/extend-plugin-index-files.js');
10
10
 
11
+ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
12
+
13
+ var tsUtils__default = /*#__PURE__*/_interopDefault(tsUtils);
14
+ var fs__default = /*#__PURE__*/_interopDefault(fs);
15
+
11
16
  var generateMiddleware = ((plop)=>{
12
17
  // middleware generator
13
18
  plop.setGenerator('middleware', {
@@ -29,11 +34,11 @@ var generateMiddleware = ((plop)=>{
29
34
  }
30
35
  const filePath = getFilePath(answers.destination);
31
36
  const currentDir = process.cwd();
32
- let language = tsUtils.isUsingTypeScriptSync(currentDir) ? 'ts' : 'js';
37
+ let language = tsUtils__default.default.isUsingTypeScriptSync(currentDir) ? 'ts' : 'js';
33
38
  if (answers.plugin) {
34
39
  // The tsconfig in plugins is located just outside the server src, not in the root of the plugin.
35
40
  const pluginServerDir = path.join(currentDir, 'src', filePath.replace('{{ plugin }}', answers.plugin), '../');
36
- language = tsUtils.isUsingTypeScriptSync(pluginServerDir) ? 'ts' : 'js';
41
+ language = tsUtils__default.default.isUsingTypeScriptSync(pluginServerDir) ? 'ts' : 'js';
37
42
  }
38
43
  const baseActions = [
39
44
  {
@@ -44,7 +49,7 @@ var generateMiddleware = ((plop)=>{
44
49
  ];
45
50
  if (answers.plugin) {
46
51
  const indexPath = path.join(plop.getDestBasePath(), `${filePath}/middlewares/index.${language}`);
47
- const exists = fs.existsSync(indexPath);
52
+ const exists = fs__default.default.existsSync(indexPath);
48
53
  if (!exists) {
49
54
  // Create index file if it doesn't exist
50
55
  baseActions.push({
@@ -1 +1 @@
1
- {"version":3,"file":"middleware.js","sources":["../../src/plops/middleware.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 validateInput from './utils/validate-input';\nimport getFilePath from './utils/get-file-path';\nimport { appendToFile } from './utils/extend-plugin-index-files';\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 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}/middlewares/{{ name }}.${language}`,\n templateFile: `templates/${language}/middleware.${language}.hbs`,\n },\n ];\n\n if (answers.plugin) {\n const indexPath = join(plop.getDestBasePath(), `${filePath}/middlewares/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}/middlewares/index.${language}`,\n templateFile: `templates/${language}/plugin/plugin.index.${language}.hbs`,\n skipIfExists: true,\n });\n }\n\n // Append the new middleware to the index.ts file\n baseActions.push({\n type: 'modify',\n path: `${filePath}/middlewares/index.${language}`,\n transform(template: string) {\n return appendToFile(template, { type: 'index', singularName: answers.name });\n },\n });\n }\n\n return baseActions;\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","plugin","pluginServerDir","join","replace","baseActions","path","templateFile","indexPath","exists","fs","existsSync","push","skipIfExists","transform","template","appendToFile","singularName"],"mappings":";;;;;;;;;;AAUA,yBAAe,CAAA,CAACA,IAAAA,GAAAA;;IAEdA,IAAAA,CAAKC,YAAY,CAAC,YAAA,EAAc;QAC9BC,WAAAA,EAAa,kCAAA;QACbC,OAAAA,EAAS;AACP,YAAA;gBACEC,IAAAA,EAAM,OAAA;gBACNC,IAAAA,EAAM,MAAA;gBACNC,OAAAA,EAAS,iBAAA;gBACTC,QAAAA,EAAU,CAACC,QAAUC,aAAAA,CAAcD,KAAAA;AACrC,aAAA;eACGE,qBAAAA,CAAsB,YAAA,EAAcV,IAAAA,CAAKW,eAAe,EAAA,EAAI;gBAAEC,UAAAA,EAAY;AAAK,aAAA;AACnF,SAAA;AACDC,QAAAA,OAAAA,CAAAA,CAAQC,OAAO,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EAAM,CAAA,EAAGd,QAAAA,CAAS,mBAAmB,EAAEM,QAAAA,CAAAA,CAAU;wBACjDS,YAAAA,EAAc,CAAC,UAAU,EAAET,QAAAA,CAAS,qBAAqB,EAAEA,QAAAA,CAAS,IAAI,CAAC;wBACzEe,YAAAA,EAAc;AAChB,qBAAA,CAAA;AACF,gBAAA;;AAGAR,gBAAAA,WAAAA,CAAYO,IAAI,CAAC;oBACf/B,IAAAA,EAAM,QAAA;AACNyB,oBAAAA,IAAAA,EAAM,CAAA,EAAGd,QAAAA,CAAS,mBAAmB,EAAEM,QAAAA,CAAAA,CAAU;AACjDgB,oBAAAA,SAAAA,CAAAA,CAAUC,QAAgB,EAAA;AACxB,wBAAA,OAAOC,oCAAaD,QAAAA,EAAU;4BAAElC,IAAAA,EAAM,OAAA;AAASoC,4BAAAA,YAAAA,EAAc1B,QAAQT;AAAK,yBAAA,CAAA;AAC5E,oBAAA;AACF,iBAAA,CAAA;AACF,YAAA;YAEA,OAAOuB,WAAAA;AACT,QAAA;AACF,KAAA,CAAA;AACF,CAAA;;;;"}
1
+ {"version":3,"file":"middleware.js","sources":["../../src/plops/middleware.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 validateInput from './utils/validate-input';\nimport getFilePath from './utils/get-file-path';\nimport { appendToFile } from './utils/extend-plugin-index-files';\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 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}/middlewares/{{ name }}.${language}`,\n templateFile: `templates/${language}/middleware.${language}.hbs`,\n },\n ];\n\n if (answers.plugin) {\n const indexPath = join(plop.getDestBasePath(), `${filePath}/middlewares/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}/middlewares/index.${language}`,\n templateFile: `templates/${language}/plugin/plugin.index.${language}.hbs`,\n skipIfExists: true,\n });\n }\n\n // Append the new middleware to the index.ts file\n baseActions.push({\n type: 'modify',\n path: `${filePath}/middlewares/index.${language}`,\n transform(template: string) {\n return appendToFile(template, { type: 'index', singularName: answers.name });\n },\n });\n }\n\n return baseActions;\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","plugin","pluginServerDir","join","replace","baseActions","path","templateFile","indexPath","exists","fs","existsSync","push","skipIfExists","transform","template","appendToFile","singularName"],"mappings":";;;;;;;;;;;;;;;AAUA,yBAAe,CAAA,CAACA,IAAAA,GAAAA;;IAEdA,IAAAA,CAAKC,YAAY,CAAC,YAAA,EAAc;QAC9BC,WAAAA,EAAa,kCAAA;QACbC,OAAAA,EAAS;AACP,YAAA;gBACEC,IAAAA,EAAM,OAAA;gBACNC,IAAAA,EAAM,MAAA;gBACNC,OAAAA,EAAS,iBAAA;gBACTC,QAAAA,EAAU,CAACC,QAAUC,aAAAA,CAAcD,KAAAA;AACrC,aAAA;eACGE,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,SAAAA,CAAAA;AAE7B,gBAAA,IAAI,CAACC,MAAAA,EAAQ;;AAEXJ,oBAAAA,WAAAA,CAAYO,IAAI,CAAC;wBACf/B,IAAAA,EAAM,KAAA;AACNyB,wBAAAA,IAAAA,EAAM,CAAA,EAAGd,QAAAA,CAAS,mBAAmB,EAAEM,QAAAA,CAAAA,CAAU;wBACjDS,YAAAA,EAAc,CAAC,UAAU,EAAET,QAAAA,CAAS,qBAAqB,EAAEA,QAAAA,CAAS,IAAI,CAAC;wBACzEe,YAAAA,EAAc;AAChB,qBAAA,CAAA;AACF,gBAAA;;AAGAR,gBAAAA,WAAAA,CAAYO,IAAI,CAAC;oBACf/B,IAAAA,EAAM,QAAA;AACNyB,oBAAAA,IAAAA,EAAM,CAAA,EAAGd,QAAAA,CAAS,mBAAmB,EAAEM,QAAAA,CAAAA,CAAU;AACjDgB,oBAAAA,SAAAA,CAAAA,CAAUC,QAAgB,EAAA;AACxB,wBAAA,OAAOC,oCAAaD,QAAAA,EAAU;4BAAElC,IAAAA,EAAM,OAAA;AAASoC,4BAAAA,YAAAA,EAAc1B,QAAQT;AAAK,yBAAA,CAAA;AAC5E,oBAAA;AACF,iBAAA,CAAA;AACF,YAAA;YAEA,OAAOuB,WAAAA;AACT,QAAA;AACF,KAAA,CAAA;AACF,CAAA;;;;"}
@@ -1 +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
+ {"version":3,"file":"migration.d.ts","sourceRoot":"","sources":["../../src/plops/migration.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,MAAM,CAAC;yBAKxB,MAAM,WAAW;AAAjC,wBA0BE"}
@@ -4,6 +4,10 @@ var tsUtils = require('@strapi/typescript-utils');
4
4
  var validateFileNameInput = require('./utils/validate-file-name-input.js');
5
5
  var getFormattedDate = require('./utils/get-formatted-date.js');
6
6
 
7
+ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
8
+
9
+ var tsUtils__default = /*#__PURE__*/_interopDefault(tsUtils);
10
+
7
11
  var generateMigration = ((plop)=>{
8
12
  // Migration generator
9
13
  plop.setGenerator('migration', {
@@ -18,7 +22,7 @@ var generateMigration = ((plop)=>{
18
22
  ],
19
23
  actions () {
20
24
  const currentDir = process.cwd();
21
- const language = tsUtils.isUsingTypeScriptSync(currentDir) ? 'ts' : 'js';
25
+ const language = tsUtils__default.default.isUsingTypeScriptSync(currentDir) ? 'ts' : 'js';
22
26
  const timestamp = getFormattedDate();
23
27
  return [
24
28
  {
@@ -1 +1 @@
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,IAAAA,CAAKC,YAAY,CAAC,WAAA,EAAa;QAC7BC,WAAAA,EAAa,sBAAA;QACbC,OAAAA,EAAS;AACP,YAAA;gBACEC,IAAAA,EAAM,OAAA;gBACNC,IAAAA,EAAM,MAAA;gBACNC,OAAAA,EAAS,gBAAA;gBACTC,QAAAA,EAAU,CAACC,QAAUC,qBAAAA,CAAsBD,KAAAA;AAC7C;AACD,SAAA;AACDE,QAAAA,OAAAA,CAAAA,GAAAA;YACE,MAAMC,UAAAA,GAAaC,QAAQC,GAAG,EAAA;AAC9B,YAAA,MAAMC,QAAAA,GAAWC,OAAAA,CAAQC,qBAAqB,CAACL,cAAc,IAAA,GAAO,IAAA;AACpE,YAAA,MAAMM,SAAAA,GAAYC,gBAAAA,EAAAA;YAElB,OAAO;AACL,gBAAA;oBACEd,IAAAA,EAAM,KAAA;AACNe,oBAAAA,IAAAA,EAAM,GAAGR,UAAAA,CAAW,qBAAqB,EAAEM,SAAAA,CAAU,YAAY,EAAEH,QAAAA,CAAAA,CAAU;oBAC7EM,YAAAA,EAAc,CAAC,UAAU,EAAEN,QAAAA,CAAS,WAAW,EAAEA,QAAAA,CAAS,IAAI;AAChE;AACD,aAAA;AACH,QAAA;AACF,KAAA,CAAA;AACF,CAAA;;;;"}
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,IAAAA,CAAKC,YAAY,CAAC,WAAA,EAAa;QAC7BC,WAAAA,EAAa,sBAAA;QACbC,OAAAA,EAAS;AACP,YAAA;gBACEC,IAAAA,EAAM,OAAA;gBACNC,IAAAA,EAAM,MAAA;gBACNC,OAAAA,EAAS,gBAAA;gBACTC,QAAAA,EAAU,CAACC,QAAUC,qBAAAA,CAAsBD,KAAAA;AAC7C;AACD,SAAA;AACDE,QAAAA,OAAAA,CAAAA,GAAAA;YACE,MAAMC,UAAAA,GAAaC,QAAQC,GAAG,EAAA;AAC9B,YAAA,MAAMC,QAAAA,GAAWC,wBAAAA,CAAQC,qBAAqB,CAACL,cAAc,IAAA,GAAO,IAAA;AACpE,YAAA,MAAMM,SAAAA,GAAYC,gBAAAA,EAAAA;YAElB,OAAO;AACL,gBAAA;oBACEd,IAAAA,EAAM,KAAA;AACNe,oBAAAA,IAAAA,EAAM,GAAGR,UAAAA,CAAW,qBAAqB,EAAEM,SAAAA,CAAU,YAAY,EAAEH,QAAAA,CAAAA,CAAU;oBAC7EM,YAAAA,EAAc,CAAC,UAAU,EAAEN,QAAAA,CAAS,WAAW,EAAEA,QAAAA,CAAS,IAAI;AAChE;AACD,aAAA;AACH,QAAA;AACF,KAAA,CAAA;AACF,CAAA;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"policy.d.ts","sourceRoot":"","sources":["../../src/plops/policy.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAc,WAAW,EAAE,MAAM,MAAM,CAAC;+BAU9B,WAAW;AAAjC,wBAoEE"}
1
+ {"version":3,"file":"policy.d.ts","sourceRoot":"","sources":["../../src/plops/policy.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAc,WAAW,EAAE,MAAM,MAAM,CAAC;yBAUpC,MAAM,WAAW;AAAjC,wBAoEE"}
@@ -8,6 +8,11 @@ var validateInput = require('./utils/validate-input.js');
8
8
  var getFilePath = require('./utils/get-file-path.js');
9
9
  var extendPluginIndexFiles = require('./utils/extend-plugin-index-files.js');
10
10
 
11
+ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
12
+
13
+ var tsUtils__default = /*#__PURE__*/_interopDefault(tsUtils);
14
+ var fs__default = /*#__PURE__*/_interopDefault(fs);
15
+
11
16
  var generatePolicy = ((plop)=>{
12
17
  // Policy generator
13
18
  plop.setGenerator('policy', {
@@ -29,11 +34,11 @@ var generatePolicy = ((plop)=>{
29
34
  }
30
35
  const currentDir = process.cwd();
31
36
  const filePath = getFilePath(answers.destination);
32
- let language = tsUtils.isUsingTypeScriptSync(currentDir) ? 'ts' : 'js';
37
+ let language = tsUtils__default.default.isUsingTypeScriptSync(currentDir) ? 'ts' : 'js';
33
38
  if (answers.plugin) {
34
39
  // The tsconfig in plugins is located just outside the server src, not in the root of the plugin.
35
40
  const pluginServerDir = path.join(currentDir, 'src', filePath.replace('{{ plugin }}', answers.plugin), '../');
36
- language = tsUtils.isUsingTypeScriptSync(pluginServerDir) ? 'ts' : 'js';
41
+ language = tsUtils__default.default.isUsingTypeScriptSync(pluginServerDir) ? 'ts' : 'js';
37
42
  }
38
43
  const baseActions = [
39
44
  {
@@ -44,7 +49,7 @@ var generatePolicy = ((plop)=>{
44
49
  ];
45
50
  if (answers.plugin) {
46
51
  const indexPath = path.join(plop.getDestBasePath(), `${filePath}/policies/index.${language}`);
47
- const exists = fs.existsSync(indexPath);
52
+ const exists = fs__default.default.existsSync(indexPath);
48
53
  if (!exists) {
49
54
  // Create index file if it doesn't exist
50
55
  baseActions.push({
@@ -1 +1 @@
1
- {"version":3,"file":"policy.js","sources":["../../src/plops/policy.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 validateInput from './utils/validate-input';\nimport getFilePath from './utils/get-file-path';\nimport { appendToFile } from './utils/extend-plugin-index-files';\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 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}/policies/{{ id }}.${language}`,\n templateFile: `templates/${language}/policy.${language}.hbs`,\n },\n ];\n\n if (answers.plugin) {\n const indexPath = join(plop.getDestBasePath(), `${filePath}/policies/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}/policies/index.${language}`,\n templateFile: `templates/${language}/plugin/plugin.index.${language}.hbs`,\n skipIfExists: true,\n });\n }\n\n // Append the new policy to the index.ts file\n baseActions.push({\n type: 'modify',\n path: `${filePath}/policies/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","validate","input","validateInput","getDestinationPrompts","getDestBasePath","rootFolder","actions","answers","currentDir","process","cwd","filePath","getFilePath","destination","language","tsUtils","isUsingTypeScriptSync","plugin","pluginServerDir","join","replace","baseActions","path","templateFile","indexPath","exists","fs","existsSync","push","skipIfExists","transform","template","appendToFile","singularName","id"],"mappings":";;;;;;;;;;AAUA,qBAAe,CAAA,CAACA,IAAAA,GAAAA;;IAEdA,IAAAA,CAAKC,YAAY,CAAC,QAAA,EAAU;QAC1BC,WAAAA,EAAa,8BAAA;QACbC,OAAAA,EAAS;AACP,YAAA;gBACEC,IAAAA,EAAM,OAAA;gBACNC,IAAAA,EAAM,IAAA;gBACNC,OAAAA,EAAS,aAAA;gBACTC,QAAAA,EAAU,CAACC,QAAUC,aAAAA,CAAcD,KAAAA;AACrC,aAAA;eACGE,qBAAAA,CAAsB,QAAA,EAAUV,IAAAA,CAAKW,eAAe,EAAA,EAAI;gBAAEC,UAAAA,EAAY;AAAK,aAAA;AAC/E,SAAA;AACDC,QAAAA,OAAAA,CAAAA,CAAQC,OAAO,EAAA;AACb,YAAA,IAAI,CAACA,OAAAA,EAAS;AACZ,gBAAA,OAAO,EAAE;AACX,YAAA;YAEA,MAAMC,UAAAA,GAAaC,QAAQC,GAAG,EAAA;YAC9B,MAAMC,QAAAA,GAAWC,WAAAA,CAAYL,OAAAA,CAAQM,WAAW,CAAA;AAChD,YAAA,IAAIC,QAAAA,GAAWC,OAAAA,CAAQC,qBAAqB,CAACR,cAAc,IAAA,GAAO,IAAA;YAElE,IAAID,OAAAA,CAAQU,MAAM,EAAE;;gBAElB,MAAMC,eAAAA,GAAkBC,SAAAA,CACtBX,UAAAA,EACA,KAAA,EACAG,QAAAA,CAASS,OAAO,CAAC,cAAA,EAAgBb,OAAAA,CAAQU,MAAM,CAAA,EAC/C,KAAA,CAAA;AAEFH,gBAAAA,QAAAA,GAAWC,OAAAA,CAAQC,qBAAqB,CAACE,eAAAA,CAAAA,GAAmB,IAAA,GAAO,IAAA;AACrE,YAAA;AAEA,YAAA,MAAMG,WAAAA,GAAiC;AACrC,gBAAA;oBACExB,IA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AA,CAAA;AACF,CAAA;;;;"}
1
+ {"version":3,"file":"policy.js","sources":["../../src/plops/policy.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 validateInput from './utils/validate-input';\nimport getFilePath from './utils/get-file-path';\nimport { appendToFile } from './utils/extend-plugin-index-files';\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 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}/policies/{{ id }}.${language}`,\n templateFile: `templates/${language}/policy.${language}.hbs`,\n },\n ];\n\n if (answers.plugin) {\n const indexPath = join(plop.getDestBasePath(), `${filePath}/policies/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}/policies/index.${language}`,\n templateFile: `templates/${language}/plugin/plugin.index.${language}.hbs`,\n skipIfExists: true,\n });\n }\n\n // Append the new policy to the index.ts file\n baseActions.push({\n type: 'modify',\n path: `${filePath}/policies/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","validate","input","validateInput","getDestinationPrompts","getDestBasePath","rootFolder","actions","answers","currentDir","process","cwd","filePath","getFilePath","destination","language","tsUtils","isUsingTypeScriptSync","plugin","pluginServerDir","join","replace","baseActions","path","templateFile","indexPath","exists","fs","existsSync","push","skipIfExists","transform","template","appendToFile","singularName","id"],"mappings":";;;;;;;;;;;;;;;AAUA,qBAAe,CAAA,CAACA,IAAAA,GAAAA;;IAEdA,IAAAA,CAAKC,YAAY,CAAC,QAAA,EAAU;QAC1BC,WAAAA,EAAa,8BAAA;QACbC,OAAAA,EAAS;AACP,YAAA;gBACEC,IAAAA,EAAM,OAAA;gBACNC,IAAAA,EAAM,IAAA;gBACNC,OAAAA,EAAS,aAAA;gBACTC,QAAAA,EAAU,CAACC,QAAUC,aAAAA,CAAcD,KAAAA;AACrC,aAAA;eACGE,qBAAAA,CAAsB,QAAA,EAAUV,IAAAA,CAAKW,eAAe,EAAA,EAAI;gBAAEC,UAAAA,EAAY;AAAK,aAAA;AAC/E,SAAA;AACDC,QAAAA,OAAAA,CAAAA,CAAQC,OAAO,EAAA;AACb,YAAA,IAAI,CAACA,OAAAA,EAAS;AACZ,gBAAA,OAAO,EAAE;AACX,YAAA;YAEA,MAAMC,UAAAA,GAAaC,QAAQC,GAAG,EAAA;YAC9B,MAAMC,QAAAA,GAAWC,WAAAA,CAAYL,OAAAA,CAAQM,WAAW,CAAA;AAChD,YAAA,IAAIC,QAAAA,GAAWC,wBAAAA,CAAQC,qBAAqB,CAACR,cAAc,IAAA,GAAO,IAAA;YAElE,IAAID,OAAAA,CAAQU,MAAM,EAAE;;gBAElB,MAAMC,eAAAA,GAAkBC,SAAAA,CACtBX,UAAAA,EACA,KAAA,EACAG,QAAAA,CAASS,OAAO,CAAC,cAAA,EAAgBb,OAAAA,CAAQU,MAAM,CAAA,EAC/C,KAAA,CAAA;AAEFH,gBAAAA,QAAAA,GAAWC,wB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C,4BAAAA,YAAAA,EAAc1B,QAAQ2B;AAAG,yBAAA,CAAA;AAC1E,oBAAA;AACF,iBAAA,CAAA;AACF,YAAA;YAEA,OAAOb,WAAAA;AACT,QAAA;AACF,KAAA,CAAA;AACF,CAAA;;;;"}
@@ -4,6 +4,11 @@ var pluralize = require('pluralize');
4
4
  var slugify = require('@sindresorhus/slugify');
5
5
  var utils = require('@strapi/utils');
6
6
 
7
+ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
8
+
9
+ var pluralize__default = /*#__PURE__*/_interopDefault(pluralize);
10
+ var slugify__default = /*#__PURE__*/_interopDefault(slugify);
11
+
7
12
  const questions = [
8
13
  {
9
14
  type: 'input',
@@ -15,7 +20,7 @@ const questions = [
15
20
  type: 'input',
16
21
  name: 'singularName',
17
22
  message: 'Content type singular name',
18
- default: (answers)=>slugify(answers.displayName),
23
+ default: (answers)=>slugify__default.default(answers.displayName),
19
24
  validate (input) {
20
25
  if (!utils.strings.isKebabCase(input)) {
21
26
  return 'Value must be in kebab-case';
@@ -27,7 +32,7 @@ const questions = [
27
32
  type: 'input',
28
33
  name: 'pluralName',
29
34
  message: 'Content type plural name',
30
- default: (answers)=>pluralize(answers.singularName),
35
+ default: (answers)=>pluralize__default.default(answers.singularName),
31
36
  validate (input, answers) {
32
37
  if (answers.singularName === input) {
33
38
  return 'Singular and plural names cannot be the same';
@@ -1 +1 @@
1
- {"version":3,"file":"ct-names-prompts.js","sources":["../../../src/plops/prompts/ct-names-prompts.ts"],"sourcesContent":["import pluralize from 'pluralize';\nimport slugify from '@sindresorhus/slugify';\nimport { strings } from '@strapi/utils';\n\ninterface Answers {\n displayName: string;\n singularName: string;\n pluralName: string;\n}\n\nconst questions = [\n {\n type: 'input',\n name: 'displayName',\n message: 'Content type display name',\n validate: (input: string) => !!input,\n },\n {\n type: 'input',\n name: 'singularName',\n message: 'Content type singular name',\n default: (answers: Answers) => slugify(answers.displayName),\n validate(input: string) {\n if (!strings.isKebabCase(input)) {\n return 'Value must be in kebab-case';\n }\n\n return true;\n },\n },\n {\n type: 'input',\n name: 'pluralName',\n message: 'Content type plural name',\n default: (answers: Answers) => pluralize(answers.singularName),\n validate(input: string, answers: Answers) {\n if (answers.singularName === input) {\n return 'Singular and plural names cannot be the same';\n }\n\n if (!strings.isKebabCase(input)) {\n return 'Value must be in kebab-case';\n }\n\n return true;\n },\n },\n];\n\nexport default questions;\n"],"names":["questions","type","name","message","validate","input","default","answers","slugify","displayName","strings","isKebabCase","pluralize","singularName"],"mappings":";;;;;;AAUA,MAAMA,SAAAA,GAAY;AAChB,IAAA;QACEC,IAAAA,EAAM,OAAA;QACNC,IAAAA,EAAM,aAAA;QACNC,OAAAA,EAAS,2BAAA;QACTC,QAAAA,EAAU,CAACC,KAAAA,GAAkB,CAAC,CAACA;AACjC,KAAA;AACA,IAAA;QACEJ,IAAAA,EAAM,OAAA;QACNC,IAAAA,EAAM,cAAA;QACNC,OAAAA,EAAS,4BAAA;AACTG,QAAAA,OAAAA,EAAS,CAACC,OAAAA,GAAqBC,OAAAA,CAAQD,OAAAA,CAAQE,WAAW,CAAA;AAC1DL,QAAAA,QAAAA,CAAAA,CAASC,KAAa,EAAA;AACpB,YAAA,IAAI,CAACK,aAAAA,CAAQC,WAAW,CAACN,KAAAA,CAAAA,EAAQ;gBAC/B,OAAO,6BAAA;AACT,YAAA;YAEA,OAAO,IAAA;AACT,QAAA;AACF,KAAA;AACA,IAAA;QACEJ,IAAAA,EAAM,OAAA;QACNC,IAAAA,EAAM,YAAA;QACNC,OAAAA,EAAS,0BAAA;AACTG,QAAAA,OAAAA,EAAS,CAACC,OAAAA,GAAqBK,SAAAA,CAAUL,OAAAA,CAAQM,YAAY,CAAA;QAC7DT,QAAAA,CAAAA,CAASC,KAAa,EAAEE,OAAgB,EAAA;YACtC,IAAIA,OAAAA,CAAQM,YAAY,KAAKR,KAAAA,EAAO;gBAClC,OAAO,8CAAA;AACT,YAAA;AAEA,YAAA,IAAI,CAACK,aAAAA,CAAQC,WAAW,CAACN,KAAAA,CAAAA,EAAQ;gBAC/B,OAAO,6BAAA;AACT,YAAA;YAEA,OAAO,IAAA;AACT,QAAA;AACF;AACD;;;;"}
1
+ {"version":3,"file":"ct-names-prompts.js","sources":["../../../src/plops/prompts/ct-names-prompts.ts"],"sourcesContent":["import pluralize from 'pluralize';\nimport slugify from '@sindresorhus/slugify';\nimport { strings } from '@strapi/utils';\n\ninterface Answers {\n displayName: string;\n singularName: string;\n pluralName: string;\n}\n\nconst questions = [\n {\n type: 'input',\n name: 'displayName',\n message: 'Content type display name',\n validate: (input: string) => !!input,\n },\n {\n type: 'input',\n name: 'singularName',\n message: 'Content type singular name',\n default: (answers: Answers) => slugify(answers.displayName),\n validate(input: string) {\n if (!strings.isKebabCase(input)) {\n return 'Value must be in kebab-case';\n }\n\n return true;\n },\n },\n {\n type: 'input',\n name: 'pluralName',\n message: 'Content type plural name',\n default: (answers: Answers) => pluralize(answers.singularName),\n validate(input: string, answers: Answers) {\n if (answers.singularName === input) {\n return 'Singular and plural names cannot be the same';\n }\n\n if (!strings.isKebabCase(input)) {\n return 'Value must be in kebab-case';\n }\n\n return true;\n },\n },\n];\n\nexport default questions;\n"],"names":["questions","type","name","message","validate","input","default","answers","slugify","displayName","strings","isKebabCase","pluralize","singularName"],"mappings":";;;;;;;;;;;AAUA,MAAMA,SAAAA,GAAY;AAChB,IAAA;QACEC,IAAAA,EAAM,OAAA;QACNC,IAAAA,EAAM,aAAA;QACNC,OAAAA,EAAS,2BAAA;QACTC,QAAAA,EAAU,CAACC,KAAAA,GAAkB,CAAC,CAACA;AACjC,KAAA;AACA,IAAA;QACEJ,IAAAA,EAAM,OAAA;QACNC,IAAAA,EAAM,cAAA;QACNC,OAAAA,EAAS,4BAAA;AACTG,QAAAA,OAAAA,EAAS,CAACC,OAAAA,GAAqBC,wBAAAA,CAAQD,OAAAA,CAAQE,WAAW,CAAA;AAC1DL,QAAAA,QAAAA,CAAAA,CAASC,KAAa,EAAA;AACpB,YAAA,IAAI,CAACK,aAAAA,CAAQC,WAAW,CAACN,KAAAA,CAAAA,EAAQ;gBAC/B,OAAO,6BAAA;AACT,YAAA;YAEA,OAAO,IAAA;AACT,QAAA;AACF,KAAA;AACA,IAAA;QACEJ,IAAAA,EAAM,OAAA;QACNC,IAAAA,EAAM,YAAA;QACNC,OAAAA,EAAS,0BAAA;AACTG,QAAAA,OAAAA,EAAS,CAACC,OAAAA,GAAqBK,0BAAAA,CAAUL,OAAAA,CAAQM,YAAY,CAAA;QAC7DT,QAAAA,CAAAA,CAASC,KAAa,EAAEE,OAAgB,EAAA;YACtC,IAAIA,OAAAA,CAAQM,YAAY,KAAKR,KAAAA,EAAO;gBAClC,OAAO,8CAAA;AACT,YAAA;AAEA,YAAA,IAAI,CAACK,aAAAA,CAAQC,WAAW,CAACN,KAAAA,CAAAA,EAAQ;gBAC/B,OAAO,6BAAA;AACT,YAAA;YAEA,OAAO,IAAA;AACT,QAAA;AACF;AACD;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"get-attributes-prompts.d.ts","sourceRoot":"","sources":["../../../src/plops/prompts/get-attributes-prompts.ts"],"names":[],"mappings":"AAEA,UAAU,eAAe;IACvB,aAAa,EAAE,MAAM,CAAC;IACtB,aAAa,EAAE,CAAC,OAAO,aAAa,CAAC,CAAC,MAAM,CAAC,CAAC;IAC9C,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,QAAA,MAAM,aAAa,+LAqBT,CAAC;AAEX,QAAA,MAAM,oBAAoB,aAAoB,GAAG,+BAyEhD,CAAC;AAEF,eAAe,oBAAoB,CAAC"}
1
+ {"version":3,"file":"get-attributes-prompts.d.ts","sourceRoot":"","sources":["../../../src/plops/prompts/get-attributes-prompts.ts"],"names":[],"mappings":"AAEA,UAAU,eAAe;IACvB,aAAa,EAAE,MAAM,CAAC;IACtB,aAAa,EAAE,CAAC,OAAO,aAAa,CAAC,CAAC,MAAM,CAAC,CAAC;IAC9C,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,QAAA,MAAM,aAAa,+LAqBT,CAAC;AAEX,QAAA,MAAM,oBAAoB,GAAU,UAAU,GAAG,+BAyEhD,CAAC;AAEF,eAAe,oBAAoB,CAAC"}
@@ -1,4 +1,3 @@
1
- /// <reference types="node" />
2
1
  import fs from 'fs-extra';
3
2
  declare const _default: (action: string, basePath: string, { rootFolder }?: {
4
3
  rootFolder?: boolean | undefined;
@@ -1 +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
+ {"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;yBAEV,QAAQ,MAAM,EAAE,UAAU,MAAM,EAAE;;CAA2B;;;;;;;;;;oBAyBvD,GAAG;;;;;;oBAuBH,GAAG;;;;;;AAhDzB,wBAyEE"}
@@ -3,6 +3,10 @@
3
3
  var path = require('path');
4
4
  var fs = require('fs-extra');
5
5
 
6
+ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
7
+
8
+ var fs__default = /*#__PURE__*/_interopDefault(fs);
9
+
6
10
  var getDestinationPrompts = ((action, basePath, { rootFolder = false } = {})=>{
7
11
  return [
8
12
  {
@@ -38,11 +42,11 @@ var getDestinationPrompts = ((action, basePath, { rootFolder = false } = {})=>{
38
42
  name: 'api',
39
43
  async choices () {
40
44
  const apiPath = path.join(basePath, 'api');
41
- const exists = await fs.pathExists(apiPath);
45
+ const exists = await fs__default.default.pathExists(apiPath);
42
46
  if (!exists) {
43
47
  throw Error('Couldn\'t find an "api" directory');
44
48
  }
45
- const apiDir = await fs.readdir(apiPath, {
49
+ const apiDir = await fs__default.default.readdir(apiPath, {
46
50
  withFileTypes: true
47
51
  });
48
52
  const apiDirContent = apiDir.filter((fd)=>fd.isDirectory());
@@ -59,12 +63,12 @@ var getDestinationPrompts = ((action, basePath, { rootFolder = false } = {})=>{
59
63
  name: 'plugin',
60
64
  async choices () {
61
65
  const pluginsPath = path.join(basePath, 'plugins');
62
- const exists = await fs.pathExists(pluginsPath);
66
+ const exists = await fs__default.default.pathExists(pluginsPath);
63
67
  if (!exists) {
64
68
  throw Error('Couldn\'t find a "plugins" directory');
65
69
  }
66
- const pluginsDir = await fs.readdir(pluginsPath);
67
- const pluginsDirContent = pluginsDir.filter((api)=>fs.lstatSync(path.join(pluginsPath, api)).isDirectory());
70
+ const pluginsDir = await fs__default.default.readdir(pluginsPath);
71
+ const pluginsDirContent = pluginsDir.filter((api)=>fs__default.default.lstatSync(path.join(pluginsPath, api)).isDirectory());
68
72
  if (pluginsDirContent.length === 0) {
69
73
  throw Error('The "plugins" directory is empty');
70
74
  }
@@ -1 +1 @@
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,QAAAA,EAAkB,EAAEC,aAAa,KAAK,EAAE,GAAG,EAAE,GAAA;IAC3E,OAAO;AACL,QAAA;YACEC,IAAAA,EAAM,MAAA;YACNC,IAAAA,EAAM,aAAA;AACNC,YAAAA,OAAAA,EAAS,CAAC,8BAA8B,EAAEL,MAAAA,CAAO,CAAC,CAAC;YACnDM,OAAAA,EAAS;mBACHJ,UAAAA,GACA;AACE,oBAAA;AACEE,wBAAAA,IAAAA,EAAM,CAAC,IAAI,EAAEJ,MAAAA,CAAO,mBAAmB,CAAC;wBACxCO,KAAAA,EAAO;AACT;iBACD,GACD;AACE,oBAAA;AACEH,wBAAAA,IAAAA,EAAM,CAAC,IAAI,EAAEJ,MAAAA,CAAO,WAAW,CAAC;wB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EAAM,MAAA;YACNE,OAAAA,EAAS,2BAAA;YACTD,IAAAA,EAAM,QAAA;YACN,MAAME,OAAAA,CAAAA,GAAAA;gBACJ,MAAMmB,WAAAA,GAAcb,UAAKX,QAAAA,EAAU,SAAA,CAAA;AACnC,gBAAA,MAAMY,MAAAA,GAAS,MAAMC,EAAAA,CAAGC,UAAU,CAACU,WAAAA,CAAAA;AAEnC,gBAAA,IAAI,CAACZ,MAAAA,EAAQ;AACX,oBAAA,MAAMG,KAAAA,CAAM,sCAAA,CAAA;AACd,gBAAA;AAEA,gBAAA,MAAMU,UAAAA,GAAa,MAAMZ,EAAAA,CAAGI,OAAO,CAACO,WAAAA,CAAAA;AACpC,gBAAA,MAAME,iBAAAA,GAAoBD,UAAAA,CAAWL,MAAM,CAAC,CAACO,GAAAA,GAC3Cd,EAAAA,CAAGe,SAAS,CAACjB,SAAAA,CAAKa,WAAAA,EAAaG,GAAAA,CAAAA,CAAAA,CAAML,WAAW,EAAA,CAAA;gBAGlD,IAAII,iBAAAA,CAAkBH,MAAM,KAAK,CAAA,EAAG;AAClC,oBAAA,MAAMR,KAAAA,CAAM,kCAAA,CAAA;AACd,gBAAA;gBAEA,OAAOW,iBAAAA;AACT,YAAA;AACF;AACD,KAAA;AACH,CAAA;;;;"}
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,QAAAA,EAAkB,EAAEC,aAAa,KAAK,EAAE,GAAG,EAAE,GAAA;IAC3E,OAAO;AACL,QAAA;YACEC,IAAAA,EAAM,MAAA;YACNC,IAAAA,EAAM,aAAA;AACNC,YAAAA,OAAAA,EAAS,CAAC,8BAA8B,EAAEL,MAAAA,CAAO,CAAC,CAAC;YACnDM,OAAAA,EAAS;mBACHJ,UAAAA,GACA;AACE,oBAAA;AACEE,wBAAAA,IAAAA,EAAM,CAAC,IAAI,EAAEJ,MAAAA,CAAO,mBAAmB,CAAC;wBACxCO,KAAAA,EAAO;AACT;iBACD,GACD;AACE,oBAAA;A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A,EAAM,CAACC,OAAAA,GAAiBA,OAAAA,CAAQC,WAAW,KAAK,QAAA;YAChDP,IAAAA,EAAM,MAAA;YACNE,OAAAA,EAAS,2BAAA;YACTD,IAAAA,EAAM,QAAA;YACN,MAAME,OAAAA,CAAAA,GAAAA;gBACJ,MAAMmB,WAAAA,GAAcb,UAAKX,QAAAA,EAAU,SAAA,CAAA;AACnC,gBAAA,MAAMY,MAAAA,GAAS,MAAMC,mBAAAA,CAAGC,UAAU,CAACU,WAAAA,CAAAA;AAEnC,gBAAA,IAAI,CAACZ,MAAAA,EAAQ;AACX,oBAAA,MAAMG,KAAAA,CAAM,sCAAA,CAAA;AACd,gBAAA;AAEA,gBAAA,MAAMU,UAAAA,GAAa,MAAMZ,mBAAAA,CAAGI,OAAO,CAACO,WAAAA,CAAAA;AACpC,gBAAA,MAAME,iBAAAA,GAAoBD,UAAAA,CAAWL,MAAM,CAAC,CAACO,GAAAA,GAC3Cd,mBAAAA,CAAGe,SAAS,CAACjB,SAAAA,CAAKa,WAAAA,EAAaG,GAAAA,CAAAA,CAAAA,CAAML,WAAW,EAAA,CAAA;gBAGlD,IAAII,iBAAAA,CAAkBH,MAAM,KAAK,CAAA,EAAG;AAClC,oBAAA,MAAMR,KAAAA,CAAM,kCAAA,CAAA;AACd,gBAAA;gBAEA,OAAOW,iBAAAA;AACT,YAAA;AACF;AACD,KAAA;AACH,CAAA;;;;"}
@@ -1 +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
+ {"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../../src/plops/service.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAc,WAAW,EAAE,MAAM,MAAM,CAAC;yBASpC,MAAM,WAAW;AAAjC,wBAmEE"}
@@ -7,6 +7,11 @@ var getDestinationPrompts = require('./prompts/get-destination-prompts.js');
7
7
  var getFilePath = require('./utils/get-file-path.js');
8
8
  var extendPluginIndexFiles = require('./utils/extend-plugin-index-files.js');
9
9
 
10
+ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
11
+
12
+ var tsUtils__default = /*#__PURE__*/_interopDefault(tsUtils);
13
+ var fs__default = /*#__PURE__*/_interopDefault(fs);
14
+
10
15
  var generateService = ((plop)=>{
11
16
  // Service generator
12
17
  plop.setGenerator('service', {
@@ -25,11 +30,11 @@ var generateService = ((plop)=>{
25
30
  }
26
31
  const filePath = getFilePath(answers?.destination);
27
32
  const currentDir = process.cwd();
28
- let language = tsUtils.isUsingTypeScriptSync(currentDir) ? 'ts' : 'js';
33
+ let language = tsUtils__default.default.isUsingTypeScriptSync(currentDir) ? 'ts' : 'js';
29
34
  if (answers.plugin) {
30
35
  // The tsconfig in plugins is located just outside the server src, not in the root of the plugin.
31
36
  const pluginServerDir = path.join(currentDir, 'src', filePath.replace('{{ plugin }}', answers.plugin), '../');
32
- language = tsUtils.isUsingTypeScriptSync(pluginServerDir) ? 'ts' : 'js';
37
+ language = tsUtils__default.default.isUsingTypeScriptSync(pluginServerDir) ? 'ts' : 'js';
33
38
  }
34
39
  const baseActions = [
35
40
  {
@@ -40,7 +45,7 @@ var generateService = ((plop)=>{
40
45
  ];
41
46
  if (answers.plugin) {
42
47
  const indexPath = path.join(plop.getDestBasePath(), `${filePath}/services/index.${language}`);
43
- const exists = fs.existsSync(indexPath);
48
+ const exists = fs__default.default.existsSync(indexPath);
44
49
  if (!exists) {
45
50
  // Create index file if it doesn't exist
46
51
  baseActions.push({
@@ -1 +1 @@
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,IAAA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e,IAAI,CAAA,EAAGG,QAAAA,CAAS,gBAAgB,EAAEM,QAAAA,CAAAA,CAAU,CAAA;gBACvF,MAAMW,MAAAA,GAASC,EAAAA,CAAGC,UAAU,CAACH,SAAAA,CAAAA;AAE7B,gBAAA,IAAI,CAACC,MAAAA,EAAQ;;AAEXJ,oBAAAA,WAAAA,CAAYO,IAAI,CAAC;wBACf3B,IAAAA,EAAM,KAAA;AACNqB,wBAAAA,IAAAA,EAAM,CAAA,EAAGd,QAAAA,CAAS,gBAAgB,EAAEM,QAAAA,CAAAA,CAAU;wBAC9CS,YAAAA,EAAc,CAAC,UAAU,EAAET,QAAAA,CAAS,qBAAqB,EAAEA,QAAAA,CAAS,IAAI,CAAC;wBACzEe,YAAAA,EAAc;AAChB,qBAAA,CAAA;AACF,gBAAA;;AAGAR,gBAAAA,WAAAA,CAAYO,IAAI,CAAC;oBACf3B,IAAAA,EAAM,QAAA;AACNqB,oBAAAA,IAAAA,EAAM,CAAA,EAAGd,QAAAA,CAAS,gBAAgB,EAAEM,QAAAA,CAAAA,CAAU;AAC9CgB,oBAAAA,SAAAA,CAAAA,CAAUC,QAAgB,EAAA;AACxB,wBAAA,OAAOC,oCAAaD,QAAAA,EAAU;4BAAE9B,IAAAA,EAAM,OAAA;AAASgC,4BAAAA,YAAAA,EAAc1B,QAAQ2B;AAAG,yBAAA,CAAA;AAC1E,oBAAA;AACF,iBAAA,CAAA;AACF,YAAA;YAEA,OAAOb,WAAAA;AACT,QAAA;AACF,KAAA,CAAA;AACF,CAAA;;;;"}
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,IAAAA,CAAKC,YAAY,CAAC,SAAA,EAAW;QAC3BC,WAAAA,EAAa,+BAAA;QACb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,CAAU,CAAA;gBACvF,MAAMW,MAAAA,GAASC,mBAAAA,CAAGC,UAAU,CAACH,SAAAA,CAAAA;AAE7B,gBAAA,IAAI,CAACC,MAAAA,EAAQ;;AAEXJ,oBAAAA,WAAAA,CAAYO,IAAI,CAAC;wBACf3B,IAAAA,EAAM,KAAA;AACNqB,wBAAAA,IAAAA,EAAM,CAAA,EAAGd,QAAAA,CAAS,gBAAgB,EAAEM,QAAAA,CAAAA,CAAU;wBAC9CS,YAAAA,EAAc,CAAC,UAAU,EAAET,QAAAA,CAAS,qBAAqB,EAAEA,QAAAA,CAAS,IAAI,CAAC;wBACzEe,YAAAA,EAAc;AAChB,qBAAA,CAAA;AACF,gBAAA;;AAGAR,gBAAAA,WAAAA,CAAYO,IAAI,CAAC;oBACf3B,IAAAA,EAAM,QAAA;AACNqB,oBAAAA,IAAAA,EAAM,CAAA,EAAGd,QAAAA,CAAS,gBAAgB,EAAEM,QAAAA,CAAAA,CAAU;AAC9CgB,oBAAAA,SAAAA,CAAAA,CAAUC,QAAgB,EAAA;AACxB,wBAAA,OAAOC,oCAAaD,QAAAA,EAAU;4BAAE9B,IAAAA,EAAM,OAAA;AAASgC,4BAAAA,YAAAA,EAAc1B,QAAQ2B;AAAG,yBAAA,CAAA;AAC1E,oBAAA;AACF,iBAAA,CAAA;AACF,YAAA;YAEA,OAAOb,WAAAA;AACT,QAAA;AACF,KAAA,CAAA;AACF,CAAA;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"extend-plugin-index-files.d.ts","sourceRoot":"","sources":["../../../src/plops/utils/extend-plugin-index-files.ts"],"names":[],"mappings":"AAKA,KAAK,UAAU,GAAG,cAAc,GAAG,OAAO,GAAG,QAAQ,CAAC;AAEtD,UAAU,YAAY;IACpB,IAAI,EAAE,UAAU,CAAC;IACjB,YAAY,EAAE,MAAM,CAAC;CACtB;AAsHD,eAAO,MAAM,YAAY,aAAc,MAAM,UAAU,YAAY,KAAG,MAuBrE,CAAC"}
1
+ {"version":3,"file":"extend-plugin-index-files.d.ts","sourceRoot":"","sources":["../../../src/plops/utils/extend-plugin-index-files.ts"],"names":[],"mappings":"AAKA,KAAK,UAAU,GAAG,cAAc,GAAG,OAAO,GAAG,QAAQ,CAAC;AAEtD,UAAU,YAAY;IACpB,IAAI,EAAE,UAAU,CAAC;IACjB,YAAY,EAAE,MAAM,CAAC;CACtB;AAsHD,eAAO,MAAM,YAAY,GAAI,UAAU,MAAM,EAAE,QAAQ,YAAY,KAAG,MAuBrE,CAAC"}
@@ -3,7 +3,10 @@
3
3
  var jscodeshift = require('jscodeshift');
4
4
  var camelCase = require('lodash/camelCase');
5
5
 
6
- function _interopNamespaceDefault(e) {
6
+ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
7
+
8
+ function _interopNamespace(e) {
9
+ if (e && e.__esModule) return e;
7
10
  var n = Object.create(null);
8
11
  if (e) {
9
12
  Object.keys(e).forEach(function (k) {
@@ -20,7 +23,8 @@ function _interopNamespaceDefault(e) {
20
23
  return Object.freeze(n);
21
24
  }
22
25
 
23
- var jscodeshift__namespace = /*#__PURE__*/_interopNamespaceDefault(jscodeshift);
26
+ var jscodeshift__namespace = /*#__PURE__*/_interopNamespace(jscodeshift);
27
+ var camelCase__default = /*#__PURE__*/_interopDefault(camelCase);
24
28
 
25
29
  const j = jscodeshift__namespace.withParser('tsx');
26
30
  // Helper to check if a string is a valid JavaScript identifier
@@ -30,7 +34,7 @@ const isValidIdentifier = (str)=>{
30
34
  // Helper to create the appropriate property based on type
31
35
  const createProperty = (config)=>{
32
36
  const { type, singularName } = config;
33
- const camelCaseName = camelCase(singularName);
37
+ const camelCaseName = camelCase__default.default(singularName);
34
38
  const varName = type === 'content-type' ? `${camelCaseName}Schema` : camelCaseName;
35
39
  // Use string literal for key only if singularName is not a valid identifier
36
40
  const keyNode = isValidIdentifier(singularName) ? j.identifier(singularName) : j.literal(singularName);
@@ -55,7 +59,7 @@ const hasExistingProperty = (obj, config)=>{
55
59
  if (!elements) return false;
56
60
  if (type === 'routes') {
57
61
  // Check for spread elements ...camelCaseName.routes
58
- const camelCaseName = camelCase(singularName);
62
+ const camelCaseName = camelCase__default.default(singularName);
59
63
  return elements.some((element)=>j.SpreadElement.check(element) && j.MemberExpression.check(element.argument) && j.Identifier.check(element.argument.object) && element.argument.object.name === camelCaseName && j.Identifier.check(element.argument.property) && element.argument.property.name === 'routes');
60
64
  }
61
65
  // For content-type and index, check for object property (both identifier and literal keys)
@@ -87,7 +91,7 @@ const handleRoutesArray = (obj, config)=>{
87
91
  // Helper to create routes array element (always returns SpreadElement for routes)
88
92
  const createRoutesElement = (config)=>{
89
93
  const { singularName } = config;
90
- const camelCaseName = camelCase(singularName);
94
+ const camelCaseName = camelCase__default.default(singularName);
91
95
  return j.spreadElement(j.memberExpression(j.identifier(camelCaseName), j.identifier('routes')));
92
96
  };
93
97
  // Helper to create new export for routes
@@ -108,7 +112,7 @@ const appendToFile = (template, config)=>{
108
112
  const root = normalizedTemplate ? j(normalizedTemplate) : j(j.program([]));
109
113
  const { type, singularName } = config;
110
114
  const isEsm = detectModuleFormat(normalizedTemplate) === 'esm';
111
- const camelCaseName = camelCase(singularName);
115
+ const camelCaseName = camelCase__default.default(singularName);
112
116
  const varName = type === 'content-type' ? `${camelCaseName}Schema` : camelCaseName;
113
117
  const source = type === 'content-type' ? `./${singularName}/schema.json` : `./${singularName}`;
114
118
  addImportIfMissing(root, varName, source, isEsm);