@strapi/generators 5.7.0-beta.0 → 5.8.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.
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,MAAM,qBAYlB,CAAC;AAGF,eAAO,MAAM,QAAQ,iDACJ,MAAM,WACZ,CAAC;;;mBAcX,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,MAAM,qBAkBlB,CAAC;AAGF,eAAO,MAAM,QAAQ,iDACJ,MAAM,WACZ,CAAC;;;mBAcX,CAAC"}
package/dist/index.js CHANGED
@@ -34,7 +34,14 @@ const runCLI = async () => {
34
34
  },
35
35
  (env) => {
36
36
  const argv = process.argv.slice(2);
37
- Plop.execute(env, argv, (env2, argv2) => run(env2, argv2, true));
37
+ Plop.execute(env, argv, (env2, argv2) => {
38
+ const options = {
39
+ ...env2,
40
+ dest: node_path.join(process.cwd(), "src")
41
+ // this will make the destination path to be based on the cwd when calling the wrapper
42
+ };
43
+ return run(options, argv2, true);
44
+ });
38
45
  }
39
46
  );
40
47
  };
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../src/index.ts"],"sourcesContent":["import { join } from 'node:path';\nimport nodePlop from 'node-plop';\n\n// Starts the Plop CLI programmatically\nexport const runCLI = async () => {\n const { Plop, run } = await import('plop');\n\n Plop.prepare(\n {\n configPath: join(__dirname, 'plopfile.js'),\n },\n (env) => {\n const argv = process.argv.slice(2); // Extract command-line arguments\n Plop.execute(env, argv, (env, argv) => run(env, argv, true)); // Pass the third argument 'true' for passArgsBeforeDashes\n }\n );\n};\n\n// Runs a generator programmatically without prompts\nexport const generate = async <T extends Record<string, any>>(\n generatorName: string,\n options: T,\n { dir = process.cwd(), plopFile = 'plopfile.js' } = {}\n) => {\n const plop = nodePlop(join(__dirname, plopFile), {\n destBasePath: join(dir, 'src'),\n force: false,\n });\n\n const generator = plop.getGenerator(generatorName);\n await generator.runActions(options satisfies T, {\n onSuccess() {},\n onFailure() {},\n onComment() {},\n });\n};\n"],"names":["join","env","argv","nodePlop"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIO,MAAM,SAAS,YAAY;AAChC,QAAM,EAAE,MAAM,QAAQ,MAAM,OAAO,MAAM;AAEpC,OAAA;AAAA,IACH;AAAA,MACE,YAAYA,UAAAA,KAAK,WAAW,aAAa;AAAA,IAC3C;AAAA,IACA,CAAC,QAAQ;AACP,YAAM,OAAO,QAAQ,KAAK,MAAM,CAAC;AAC5B,WAAA,QAAQ,KAAK,MAAM,CAACC,MAAKC,UAAS,IAAID,MAAKC,OAAM,IAAI,CAAC;AAAA,IAAA;AAAA,EAE/D;AACF;AAGO,MAAM,WAAW,OACtB,eACA,SACA,EAAE,MAAM,QAAQ,OAAO,WAAW,cAAc,IAAI,CAAA,MACjD;AACH,QAAM,OAAOC,kBAAA,QAASH,UAAK,KAAA,WAAW,QAAQ,GAAG;AAAA,IAC/C,cAAcA,UAAAA,KAAK,KAAK,KAAK;AAAA,IAC7B,OAAO;AAAA,EAAA,CACR;AAEK,QAAA,YAAY,KAAK,aAAa,aAAa;AAC3C,QAAA,UAAU,WAAW,SAAqB;AAAA,IAC9C,YAAY;AAAA,IAAC;AAAA,IACb,YAAY;AAAA,IAAC;AAAA,IACb,YAAY;AAAA,IAAA;AAAA,EAAC,CACd;AACH;;;"}
1
+ {"version":3,"file":"index.js","sources":["../src/index.ts"],"sourcesContent":["import { join } from 'node:path';\nimport nodePlop from 'node-plop';\n\n// Starts the Plop CLI programmatically\nexport const runCLI = async () => {\n const { Plop, run } = await import('plop');\n\n Plop.prepare(\n {\n configPath: join(__dirname, 'plopfile.js'),\n },\n (env) => {\n const argv = process.argv.slice(2); // Extract command-line arguments\n Plop.execute(env, argv, (env, argv) => {\n const options = {\n ...env,\n dest: join(process.cwd(), 'src'), // this will make the destination path to be based on the cwd when calling the wrapper\n };\n return run(options, argv, true); // Pass the third argument 'true' for passArgsBeforeDashes\n });\n }\n );\n};\n\n// Runs a generator programmatically without prompts\nexport const generate = async <T extends Record<string, any>>(\n generatorName: string,\n options: T,\n { dir = process.cwd(), plopFile = 'plopfile.js' } = {}\n) => {\n const plop = nodePlop(join(__dirname, plopFile), {\n destBasePath: join(dir, 'src'),\n force: false,\n });\n\n const generator = plop.getGenerator(generatorName);\n await generator.runActions(options satisfies T, {\n onSuccess() {},\n onFailure() {},\n onComment() {},\n });\n};\n"],"names":["join","env","argv","nodePlop"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIO,MAAM,SAAS,YAAY;AAChC,QAAM,EAAE,MAAM,QAAQ,MAAM,OAAO,MAAM;AAEpC,OAAA;AAAA,IACH;AAAA,MACE,YAAYA,UAAAA,KAAK,WAAW,aAAa;AAAA,IAC3C;AAAA,IACA,CAAC,QAAQ;AACP,YAAM,OAAO,QAAQ,KAAK,MAAM,CAAC;AACjC,WAAK,QAAQ,KAAK,MAAM,CAACC,MAAKC,UAAS;AACrC,cAAM,UAAU;AAAA,UACd,GAAGD;AAAAA,UACH,MAAMD,UAAA,KAAK,QAAQ,OAAO,KAAK;AAAA;AAAA,QACjC;AACO,eAAA,IAAI,SAASE,OAAM,IAAI;AAAA,MAAA,CAC/B;AAAA,IAAA;AAAA,EAEL;AACF;AAGO,MAAM,WAAW,OACtB,eACA,SACA,EAAE,MAAM,QAAQ,OAAO,WAAW,cAAc,IAAI,CAAA,MACjD;AACH,QAAM,OAAOC,kBAAA,QAASH,UAAK,KAAA,WAAW,QAAQ,GAAG;AAAA,IAC/C,cAAcA,UAAAA,KAAK,KAAK,KAAK;AAAA,IAC7B,OAAO;AAAA,EAAA,CACR;AAEK,QAAA,YAAY,KAAK,aAAa,aAAa;AAC3C,QAAA,UAAU,WAAW,SAAqB;AAAA,IAC9C,YAAY;AAAA,IAAC;AAAA,IACb,YAAY;AAAA,IAAC;AAAA,IACb,YAAY;AAAA,IAAA;AAAA,EAAC,CACd;AACH;;;"}
package/dist/index.mjs CHANGED
@@ -8,7 +8,14 @@ const runCLI = async () => {
8
8
  },
9
9
  (env) => {
10
10
  const argv = process.argv.slice(2);
11
- Plop.execute(env, argv, (env2, argv2) => run(env2, argv2, true));
11
+ Plop.execute(env, argv, (env2, argv2) => {
12
+ const options = {
13
+ ...env2,
14
+ dest: join(process.cwd(), "src")
15
+ // this will make the destination path to be based on the cwd when calling the wrapper
16
+ };
17
+ return run(options, argv2, true);
18
+ });
12
19
  }
13
20
  );
14
21
  };
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","sources":["../src/index.ts"],"sourcesContent":["import { join } from 'node:path';\nimport nodePlop from 'node-plop';\n\n// Starts the Plop CLI programmatically\nexport const runCLI = async () => {\n const { Plop, run } = await import('plop');\n\n Plop.prepare(\n {\n configPath: join(__dirname, 'plopfile.js'),\n },\n (env) => {\n const argv = process.argv.slice(2); // Extract command-line arguments\n Plop.execute(env, argv, (env, argv) => run(env, argv, true)); // Pass the third argument 'true' for passArgsBeforeDashes\n }\n );\n};\n\n// Runs a generator programmatically without prompts\nexport const generate = async <T extends Record<string, any>>(\n generatorName: string,\n options: T,\n { dir = process.cwd(), plopFile = 'plopfile.js' } = {}\n) => {\n const plop = nodePlop(join(__dirname, plopFile), {\n destBasePath: join(dir, 'src'),\n force: false,\n });\n\n const generator = plop.getGenerator(generatorName);\n await generator.runActions(options satisfies T, {\n onSuccess() {},\n onFailure() {},\n onComment() {},\n });\n};\n"],"names":["env","argv"],"mappings":";;AAIO,MAAM,SAAS,YAAY;AAChC,QAAM,EAAE,MAAM,QAAQ,MAAM,OAAO,MAAM;AAEpC,OAAA;AAAA,IACH;AAAA,MACE,YAAY,KAAK,WAAW,aAAa;AAAA,IAC3C;AAAA,IACA,CAAC,QAAQ;AACP,YAAM,OAAO,QAAQ,KAAK,MAAM,CAAC;AAC5B,WAAA,QAAQ,KAAK,MAAM,CAACA,MAAKC,UAAS,IAAID,MAAKC,OAAM,IAAI,CAAC;AAAA,IAAA;AAAA,EAE/D;AACF;AAGO,MAAM,WAAW,OACtB,eACA,SACA,EAAE,MAAM,QAAQ,OAAO,WAAW,cAAc,IAAI,CAAA,MACjD;AACH,QAAM,OAAO,SAAS,KAAK,WAAW,QAAQ,GAAG;AAAA,IAC/C,cAAc,KAAK,KAAK,KAAK;AAAA,IAC7B,OAAO;AAAA,EAAA,CACR;AAEK,QAAA,YAAY,KAAK,aAAa,aAAa;AAC3C,QAAA,UAAU,WAAW,SAAqB;AAAA,IAC9C,YAAY;AAAA,IAAC;AAAA,IACb,YAAY;AAAA,IAAC;AAAA,IACb,YAAY;AAAA,IAAA;AAAA,EAAC,CACd;AACH;"}
1
+ {"version":3,"file":"index.mjs","sources":["../src/index.ts"],"sourcesContent":["import { join } from 'node:path';\nimport nodePlop from 'node-plop';\n\n// Starts the Plop CLI programmatically\nexport const runCLI = async () => {\n const { Plop, run } = await import('plop');\n\n Plop.prepare(\n {\n configPath: join(__dirname, 'plopfile.js'),\n },\n (env) => {\n const argv = process.argv.slice(2); // Extract command-line arguments\n Plop.execute(env, argv, (env, argv) => {\n const options = {\n ...env,\n dest: join(process.cwd(), 'src'), // this will make the destination path to be based on the cwd when calling the wrapper\n };\n return run(options, argv, true); // Pass the third argument 'true' for passArgsBeforeDashes\n });\n }\n );\n};\n\n// Runs a generator programmatically without prompts\nexport const generate = async <T extends Record<string, any>>(\n generatorName: string,\n options: T,\n { dir = process.cwd(), plopFile = 'plopfile.js' } = {}\n) => {\n const plop = nodePlop(join(__dirname, plopFile), {\n destBasePath: join(dir, 'src'),\n force: false,\n });\n\n const generator = plop.getGenerator(generatorName);\n await generator.runActions(options satisfies T, {\n onSuccess() {},\n onFailure() {},\n onComment() {},\n });\n};\n"],"names":["env","argv"],"mappings":";;AAIO,MAAM,SAAS,YAAY;AAChC,QAAM,EAAE,MAAM,QAAQ,MAAM,OAAO,MAAM;AAEpC,OAAA;AAAA,IACH;AAAA,MACE,YAAY,KAAK,WAAW,aAAa;AAAA,IAC3C;AAAA,IACA,CAAC,QAAQ;AACP,YAAM,OAAO,QAAQ,KAAK,MAAM,CAAC;AACjC,WAAK,QAAQ,KAAK,MAAM,CAACA,MAAKC,UAAS;AACrC,cAAM,UAAU;AAAA,UACd,GAAGD;AAAAA,UACH,MAAM,KAAK,QAAQ,OAAO,KAAK;AAAA;AAAA,QACjC;AACO,eAAA,IAAI,SAASC,OAAM,IAAI;AAAA,MAAA,CAC/B;AAAA,IAAA;AAAA,EAEL;AACF;AAGO,MAAM,WAAW,OACtB,eACA,SACA,EAAE,MAAM,QAAQ,OAAO,WAAW,cAAc,IAAI,CAAA,MACjD;AACH,QAAM,OAAO,SAAS,KAAK,WAAW,QAAQ,GAAG;AAAA,IAC/C,cAAc,KAAK,KAAK,KAAK;AAAA,IAC7B,OAAO;AAAA,EAAA,CACR;AAEK,QAAA,YAAY,KAAK,aAAa,aAAa;AAC3C,QAAA,UAAU,WAAW,SAAqB;AAAA,IAC9C,YAAY;AAAA,IAAC;AAAA,IACb,YAAY;AAAA,IAAC;AAAA,IACb,YAAY;AAAA,IAAA;AAAA,EAAC,CACd;AACH;"}
package/dist/plopfile.js CHANGED
@@ -56,7 +56,7 @@ const generateApi = (plop) => {
56
56
  if (!answers) {
57
57
  return [];
58
58
  }
59
- const filePath = answers.isPluginApi && answers.plugin ? "plugins/{{ plugin }}" : "api/{{ id }}";
59
+ const filePath = answers.isPluginApi && answers.plugin ? "plugins/{{ plugin }}/server" : "api/{{ id }}";
60
60
  const currentDir = process.cwd();
61
61
  const language = tsUtils__default.default.isUsingTypeScriptSync(currentDir) ? "ts" : "js";
62
62
  const baseActions = [
@@ -466,8 +466,8 @@ const generatePolicy = (plop) => {
466
466
  if (!answers) {
467
467
  return [];
468
468
  }
469
- const filePath = getFilePath(answers.destination);
470
469
  const currentDir = process.cwd();
470
+ const filePath = getFilePath(answers.destination);
471
471
  const language = tsUtils__default.default.isUsingTypeScriptSync(currentDir) ? "ts" : "js";
472
472
  return [
473
473
  {
@@ -573,7 +573,7 @@ const generateService = (plop) => {
573
573
  };
574
574
  const plopfile = (plop) => {
575
575
  plop.setWelcomeMessage("Strapi Generators");
576
- plop.addHelper("pluralize", (text) => pluralize__default.default(text));
576
+ plop.setHelper("pluralize", (text) => pluralize__default.default(text));
577
577
  generateApi(plop);
578
578
  generateController(plop);
579
579
  generateContentType(plop);
@@ -1 +1 @@
1
- {"version":3,"file":"plopfile.js","sources":["../src/plops/utils/validate-input.ts","../src/plops/api.ts","../src/plops/prompts/get-destination-prompts.ts","../src/plops/utils/get-file-path.ts","../src/plops/controller.ts","../src/plops/prompts/ct-names-prompts.ts","../src/plops/prompts/kind-prompts.ts","../src/plops/utils/validate-attribute-input.ts","../src/plops/prompts/get-attributes-prompts.ts","../src/plops/prompts/bootstrap-api-prompts.ts","../src/plops/content-type.ts","../src/plops/policy.ts","../src/plops/middleware.ts","../src/plops/utils/validate-file-name-input.ts","../src/plops/utils/get-formatted-date.ts","../src/plops/migration.ts","../src/plops/service.ts","../src/plopfile.ts"],"sourcesContent":["export default (input: string) => {\n const regex = /^[A-Za-z-]+$/g;\n\n if (!input) {\n return 'You must provide an input';\n }\n\n return regex.test(input) || \"Please use only letters, '-' and no spaces\";\n};\n","import { join } from 'path';\nimport type { NodePlopAPI } from 'plop';\nimport fs from 'fs-extra';\nimport tsUtils from '@strapi/typescript-utils';\n\nimport validateInput from './utils/validate-input';\n\nexport default (plop: NodePlopAPI) => {\n // API generator\n plop.setGenerator('api', {\n description: 'Generate a basic API',\n prompts: [\n {\n type: 'input',\n name: 'id',\n message: 'API name',\n validate: (input) => validateInput(input),\n },\n {\n type: 'confirm',\n name: 'isPluginApi',\n message: 'Is this API for a plugin?',\n },\n {\n when: (answers) => answers.isPluginApi,\n type: 'list',\n name: 'plugin',\n message: 'Plugin name',\n async choices() {\n const pluginsPath = join(plop.getDestBasePath(), '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, { withFileTypes: true });\n const pluginsDirContent = pluginsDir.filter((fd) => fd.isDirectory());\n\n if (pluginsDirContent.length === 0) {\n throw Error('The \"plugins\" directory is empty');\n }\n\n return pluginsDirContent;\n },\n },\n ],\n actions(answers) {\n if (!answers) {\n return [];\n }\n\n const filePath =\n answers.isPluginApi && answers.plugin ? 'plugins/{{ plugin }}' : 'api/{{ id }}';\n const currentDir = process.cwd();\n const language = tsUtils.isUsingTypeScriptSync(currentDir) ? 'ts' : 'js';\n\n const baseActions = [\n {\n type: 'add',\n path: `${filePath}/controllers/{{ id }}.${language}`,\n templateFile: `templates/${language}/controller.${language}.hbs`,\n },\n {\n type: 'add',\n path: `${filePath}/services/{{ id }}.${language}`,\n templateFile: `templates/${language}/service.${language}.hbs`,\n },\n ];\n\n if (answers.isPluginApi) {\n return baseActions;\n }\n\n return [\n {\n type: 'add',\n path: `${filePath}/routes/{{ id }}.${language}`,\n templateFile: `templates/${language}/single-route.${language}.hbs`,\n },\n ...baseActions,\n ];\n },\n });\n};\n","import { join } from 'path';\nimport fs from 'fs-extra';\n\nimport type { PromptQuestion } from 'node-plop';\n\nexport default (\n action: string,\n basePath: string,\n { rootFolder = false } = {}\n): Array<PromptQuestion> => {\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) => 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) => 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","export default (destination: string) => {\n if (destination === 'api') {\n return `api/{{ api }}`;\n }\n\n if (destination === 'plugin') {\n return `plugins/{{ plugin }}/server`;\n }\n\n if (destination === 'root') {\n return './';\n }\n\n return `api/{{ id }}`;\n};\n","import type { NodePlopAPI } from 'plop';\nimport tsUtils from '@strapi/typescript-utils';\n\nimport getDestinationPrompts from './prompts/get-destination-prompts';\nimport getFilePath from './utils/get-file-path';\nimport validateInput from './utils/validate-input';\n\nexport default (plop: NodePlopAPI) => {\n // Controller generator\n plop.setGenerator('controller', {\n description: 'Generate a controller for an API',\n prompts: [\n {\n type: 'input',\n name: 'id',\n message: 'Controller name',\n validate: (input) => validateInput(input),\n },\n ...getDestinationPrompts('controller', plop.getDestBasePath()),\n ],\n actions(answers) {\n if (!answers) {\n return [];\n }\n\n const filePath = getFilePath(answers.destination);\n const currentDir = process.cwd();\n const language = tsUtils.isUsingTypeScriptSync(currentDir) ? 'ts' : 'js';\n\n return [\n {\n type: 'add',\n path: `${filePath}/controllers/{{ id }}.${language}`,\n templateFile: `templates/${language}/controller.${language}.hbs`,\n },\n ];\n },\n });\n};\n","import pluralize from 'pluralize';\nimport slugify from '@sindresorhus/slugify';\nimport { strings } from '@strapi/utils';\n\nimport type { PromptQuestion } from 'node-plop';\n\ninterface Answers {\n displayName: string;\n singularName: string;\n pluralName: string;\n}\n\nconst questions: Array<PromptQuestion> = [\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) {\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","import type { PromptQuestion } from 'node-plop';\n\nimport validateInput from '../utils/validate-input';\n\nconst questions: Array<PromptQuestion> = [\n {\n type: 'list',\n name: 'kind',\n message: 'Please choose the model type',\n default: 'collectionType',\n choices: [\n { name: 'Collection Type', value: 'collectionType' },\n { name: 'Single Type', value: 'singleType' },\n ],\n validate: (input: string) => validateInput(input),\n },\n];\n\nexport default questions;\n","export default (input: string) => {\n const regex = /^[A-Za-z-|_]+$/g;\n\n if (!input) {\n return 'You must provide an input';\n }\n\n return regex.test(input) || \"Please use only letters, '-', '_', and no spaces\";\n};\n","import type { DynamicPromptsFunction } from 'node-plop';\n\nimport validateAttributeInput from '../utils/validate-attribute-input';\n\ninterface AttributeAnswer {\n attributeName: string;\n attributeType: typeof DEFAULT_TYPES;\n enum?: string;\n multiple?: boolean;\n}\n\nconst DEFAULT_TYPES = [\n // advanced types\n 'media',\n\n // scalar types\n 'string',\n 'text',\n 'richtext',\n 'json',\n 'enumeration',\n 'password',\n 'email',\n 'integer',\n 'biginteger',\n 'float',\n 'decimal',\n 'date',\n 'time',\n 'datetime',\n 'timestamp',\n 'boolean',\n] as const;\n\nconst getAttributesPrompts: DynamicPromptsFunction = async (inquirer) => {\n const { addAttributes } = await inquirer.prompt([\n {\n type: 'confirm',\n name: 'addAttributes',\n message: 'Do you want to add attributes?',\n },\n ]);\n\n const attributes: Array<AttributeAnswer> = [];\n\n /**\n * @param {import('inquirer').Inquirer} inquirer\n * @returns {Promise<void>}\n */\n const createNewAttributes = async (inquirer: Parameters<DynamicPromptsFunction>[0]) => {\n const answers = await inquirer.prompt([\n {\n type: 'input',\n name: 'attributeName',\n message: 'Name of attribute',\n validate: (input: string) => validateAttributeInput(input),\n },\n {\n type: 'list',\n name: 'attributeType',\n message: 'What type of attribute',\n pageSize: DEFAULT_TYPES.length,\n choices: DEFAULT_TYPES.map((type) => {\n return { name: type, value: type };\n }),\n },\n {\n when: (answers) => answers.attributeType === 'enumeration',\n type: 'input',\n name: 'enum',\n message: 'Add values separated by a comma',\n },\n {\n when: (answers) => answers.attributeType === 'media',\n type: 'list',\n name: 'multiple',\n message: 'Choose media type',\n choices: [\n { name: 'Multiple', value: true },\n { name: 'Single', value: false },\n ],\n },\n {\n type: 'confirm',\n name: 'addAttributes',\n message: 'Do you want to add another attribute?',\n },\n ]);\n\n attributes.push(answers);\n\n if (!answers.addAttributes) {\n return;\n }\n\n await createNewAttributes(inquirer);\n };\n\n if (addAttributes) {\n await createNewAttributes(inquirer);\n } else {\n console.warn(\n `You won't be able to manage entries from the admin, you can still add attributes later from the content type builder.`\n );\n }\n\n return attributes;\n};\n\nexport default getAttributesPrompts;\n","import type { PromptQuestion } from 'node-plop';\n\nconst questions: Array<PromptQuestion> = [\n {\n type: 'confirm',\n name: 'bootstrapApi',\n default: true,\n message: 'Bootstrap API related files?',\n },\n];\n\nexport default questions;\n","import { join } from 'path';\nimport type { NodePlopAPI, ActionType } from 'plop';\nimport slugify from '@sindresorhus/slugify';\nimport fs from 'fs-extra';\nimport { strings } from '@strapi/utils';\nimport tsUtils from '@strapi/typescript-utils';\n\nimport getDestinationPrompts from './prompts/get-destination-prompts';\nimport getFilePath from './utils/get-file-path';\nimport ctNamesPrompts from './prompts/ct-names-prompts';\nimport kindPrompts from './prompts/kind-prompts';\nimport getAttributesPrompts from './prompts/get-attributes-prompts';\nimport bootstrapApiPrompts from './prompts/bootstrap-api-prompts';\n\nexport default (plop: NodePlopAPI) => {\n // Model generator\n plop.setGenerator('content-type', {\n description: 'Generate a content type for an API',\n async prompts(inquirer) {\n const config = await inquirer.prompt([...ctNamesPrompts, ...kindPrompts]);\n // @ts-expect-error issue with deprecated inquirer.prompts attribute to fix with ugprade to inquirer\n const attributes = await getAttributesPrompts(inquirer);\n\n const api = await inquirer.prompt([\n ...getDestinationPrompts('model', plop.getDestBasePath()),\n {\n when: (answers) => answers.destination === 'new',\n type: 'input',\n name: 'id',\n default: config.singularName,\n message: 'Name of the new API?',\n async validate(input) {\n if (!strings.isKebabCase(input)) {\n return 'Value must be in kebab-case';\n }\n\n const apiPath = join(plop.getDestBasePath(), 'api');\n const exists = await fs.pathExists(apiPath);\n\n if (!exists) {\n return true;\n }\n\n const apiDir = await fs.readdir(apiPath, { withFileTypes: true });\n const apiDirContent = apiDir.filter((fd) => fd.isDirectory());\n\n if (apiDirContent.findIndex((dir) => dir.name === input) !== -1) {\n throw new Error('This name is already taken.');\n }\n\n return true;\n },\n },\n ...bootstrapApiPrompts,\n ]);\n\n return {\n ...config,\n ...api,\n attributes,\n };\n },\n actions(answers) {\n if (!answers) {\n return [];\n }\n\n const attributes = answers.attributes.reduce((object: any, answer: any) => {\n const val: any = { type: answer.attributeType };\n\n if (answer.attributeType === 'enumeration') {\n val.enum = answer.enum.split(',').map((item: string) => item.trim());\n }\n\n if (answer.attributeType === 'media') {\n val.allowedTypes = ['images', 'files', 'videos', 'audios'];\n val.multiple = answer.multiple;\n }\n\n return Object.assign(object, { [answer.attributeName]: val }, {});\n }, {});\n\n const filePath = getFilePath(answers.destination);\n // TODO: use basePath instead\n const currentDir = process.cwd();\n const language = tsUtils.isUsingTypeScriptSync(currentDir) ? 'ts' : 'js';\n\n const baseActions: Array<ActionType> = [\n {\n type: 'add',\n path: `${filePath}/content-types/{{ singularName }}/schema.json`,\n templateFile: `templates/${language}/content-type.schema.json.hbs`,\n data: {\n collectionName: slugify(answers.pluralName, { separator: '_' }),\n },\n },\n ];\n\n if (Object.entries(attributes).length > 0) {\n baseActions.push({\n type: 'modify',\n path: `${filePath}/content-types/{{ singularName }}/schema.json`,\n transform(template: string) {\n const parsedTemplate = JSON.parse(template);\n parsedTemplate.attributes = attributes;\n return JSON.stringify(parsedTemplate, null, 2);\n },\n });\n }\n\n if (answers.bootstrapApi) {\n const { singularName } = answers;\n\n let uid;\n if (answers.destination === 'new') {\n uid = `api::${answers.id}.${singularName}`;\n } else if (answers.api) {\n uid = `api::${answers.api}.${singularName}`;\n } else if (answers.plugin) {\n uid = `plugin::${answers.plugin}.${singularName}`;\n }\n\n baseActions.push(\n {\n type: 'add',\n path: `${filePath}/controllers/{{ singularName }}.${language}`,\n templateFile: `templates/${language}/core-controller.${language}.hbs`,\n data: { uid },\n },\n {\n type: 'add',\n path: `${filePath}/services/{{ singularName }}.${language}`,\n templateFile: `templates/${language}/core-service.${language}.hbs`,\n data: { uid },\n },\n {\n type: 'add',\n path: `${filePath}/routes/{{ singularName }}.${language}`,\n templateFile: `templates/${language}/core-router.${language}.hbs`,\n data: { uid },\n }\n );\n }\n\n return baseActions;\n },\n });\n};\n","import type { NodePlopAPI } from 'plop';\nimport tsUtils from '@strapi/typescript-utils';\n\nimport getDestinationPrompts from './prompts/get-destination-prompts';\nimport validateInput from './utils/validate-input';\nimport getFilePath from './utils/get-file-path';\n\nexport default (plop: NodePlopAPI) => {\n // Policy generator\n plop.setGenerator('policy', {\n description: 'Generate a policy for an API',\n prompts: [\n {\n type: 'input',\n name: 'id',\n message: 'Policy name',\n validate: (input) => validateInput(input),\n },\n ...getDestinationPrompts('policy', plop.getDestBasePath(), { rootFolder: true }),\n ],\n actions(answers) {\n if (!answers) {\n return [];\n }\n\n const filePath = getFilePath(answers.destination);\n const currentDir = process.cwd();\n const language = tsUtils.isUsingTypeScriptSync(currentDir) ? 'ts' : 'js';\n\n return [\n {\n type: 'add',\n path: `${filePath}/policies/{{ id }}.${language}`,\n templateFile: `templates/${language}/policy.${language}.hbs`,\n },\n ];\n },\n });\n};\n","import type { NodePlopAPI } from 'plop';\nimport tsUtils from '@strapi/typescript-utils';\n\nimport getDestinationPrompts from './prompts/get-destination-prompts';\nimport validateInput from './utils/validate-input';\nimport getFilePath from './utils/get-file-path';\n\nexport default (plop: NodePlopAPI) => {\n // middleware generator\n plop.setGenerator('middleware', {\n description: 'Generate a middleware for an API',\n prompts: [\n {\n type: 'input',\n name: 'name',\n message: 'Middleware name',\n validate: (input) => validateInput(input),\n },\n ...getDestinationPrompts('middleware', plop.getDestBasePath(), { rootFolder: true }),\n ],\n actions(answers) {\n if (!answers) {\n return [];\n }\n\n const filePath = getFilePath(answers.destination);\n const currentDir = process.cwd();\n const language = tsUtils.isUsingTypeScriptSync(currentDir) ? 'ts' : 'js';\n\n return [\n {\n type: 'add',\n path: `${filePath}/middlewares/{{ name }}.${language}`,\n templateFile: `templates/${language}/middleware.${language}.hbs`,\n },\n ];\n },\n });\n};\n","export default (input: string) => {\n const regex = /^[A-Za-z-_0-9]+$/g;\n\n if (!input) {\n return 'You must provide an input';\n }\n\n return regex.test(input) || \"Please use only letters and number, '-' or '_' and no spaces\";\n};\n","export default (date: Date = new Date()) => {\n return new Date(date.getTime() - date.getTimezoneOffset() * 60000)\n .toJSON()\n .replace(/[-:]/g, '.')\n .replace(/\\....Z/, '');\n};\n","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","import type { NodePlopAPI } from 'plop';\nimport tsUtils from '@strapi/typescript-utils';\n\nimport getDestinationPrompts from './prompts/get-destination-prompts';\nimport getFilePath from './utils/get-file-path';\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 const language = tsUtils.isUsingTypeScriptSync(currentDir) ? 'ts' : 'js';\n\n return [\n {\n type: 'add',\n path: `${filePath}/services/{{ id }}.${language}`,\n templateFile: `templates/${language}/service.${language}.hbs`,\n },\n ];\n },\n });\n};\n","import pluralize from 'pluralize';\nimport type { NodePlopAPI } from 'plop';\n\nimport generateApi from './plops/api';\nimport generateController from './plops/controller';\nimport generateContentType from './plops/content-type';\nimport generatePolicy from './plops/policy';\nimport generateMiddleware from './plops/middleware';\nimport generateMigration from './plops/migration';\nimport generateService from './plops/service';\n\nexport default (plop: NodePlopAPI) => {\n // Plop config\n plop.setWelcomeMessage('Strapi Generators');\n plop.addHelper('pluralize', (text: string) => pluralize(text));\n\n // Generators\n generateApi(plop);\n generateController(plop);\n generateContentType(plop);\n generatePolicy(plop);\n generateMiddleware(plop);\n generateMigration(plop);\n generateService(plop);\n};\n"],"names":["join","fs","tsUtils","questions","slugify","strings","pluralize","inquirer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AU,wBAAwB,SAAS,eAAe,QAAQ;AAAA,UAC3E,cAAc,aAAa,QAAQ,cAAc,QAAQ;AAAA,QAAA;AAAA,MAE7D;AAAA,IAAA;AAAA,EACF,CACD;AACH;ACzBA,MAAe,kBAAA,CAAC,SAAsB;AAEpC,OAAK,aAAa,WAAW;AAAA,IAC3B,aAAa;AAAA,IACb,SAAS;AAAA,MACP;AAAA,QACE,MAAM;AAAA,QACN,MAAM;AAAA,QACN,SAAS;AAAA,MACX;AAAA,MACA,GAAG,sBAAsB,WAAW,KAAK,gBAAiB,CAAA;AAAA,IAC5D;AAAA,IACA,QAAQ,SAAS;AACf,UAAI,CAAC,SAAS;AACZ,eAAO,CAAC;AAAA,MAAA;AAGJ,YAAA,WAAW,YAAY,SAAS,WAAW;AAC3C,YAAA,aAAa,QAAQ,IAAI;AAC/B,YAAM,WAAWA,iBAAAA,QAAQ,sBAAsB,UAAU,IAAI,OAAO;AAE7D,aAAA;AAAA,QACL;AAAA,UACE,MAAM;AAAA,UACN,MAAM,GAAG,QAAQ,sBAAsB,QAAQ;AAAA,UAC/C,cAAc,aAAa,QAAQ,YAAY,QAAQ;AAAA,QAAA;AAAA,MAE3D;AAAA,IAAA;AAAA,EACF,CACD;AACH;ACzBA,MAAe,WAAA,CAAC,SAAsB;AAEpC,OAAK,kBAAkB,mBAAmB;AAC1C,OAAK,UAAU,aAAa,CAAC,SAAiBI,mBAAAA,QAAU,IAAI,CAAC;AAG7D,cAAY,IAAI;AAChB,qBAAmB,IAAI;AACvB,sBAAoB,IAAI;AACxB,iBAAe,IAAI;AACnB,qBAAmB,IAAI;AACvB,oBAAkB,IAAI;AACtB,kBAAgB,IAAI;AACtB;;"}
1
+ {"version":3,"file":"plopfile.js","sources":["../src/plops/utils/validate-input.ts","../src/plops/api.ts","../src/plops/prompts/get-destination-prompts.ts","../src/plops/utils/get-file-path.ts","../src/plops/controller.ts","../src/plops/prompts/ct-names-prompts.ts","../src/plops/prompts/kind-prompts.ts","../src/plops/utils/validate-attribute-input.ts","../src/plops/prompts/get-attributes-prompts.ts","../src/plops/prompts/bootstrap-api-prompts.ts","../src/plops/content-type.ts","../src/plops/policy.ts","../src/plops/middleware.ts","../src/plops/utils/validate-file-name-input.ts","../src/plops/utils/get-formatted-date.ts","../src/plops/migration.ts","../src/plops/service.ts","../src/plopfile.ts"],"sourcesContent":["export default (input: string) => {\n const regex = /^[A-Za-z-]+$/g;\n\n if (!input) {\n return 'You must provide an input';\n }\n\n return regex.test(input) || \"Please use only letters, '-' and no spaces\";\n};\n","import { join } from 'path';\nimport type { NodePlopAPI } from 'plop';\nimport fs from 'fs-extra';\nimport tsUtils from '@strapi/typescript-utils';\n\nimport validateInput from './utils/validate-input';\n\nexport default (plop: NodePlopAPI) => {\n // API generator\n plop.setGenerator('api', {\n description: 'Generate a basic API',\n prompts: [\n {\n type: 'input',\n name: 'id',\n message: 'API name',\n validate: (input) => validateInput(input),\n },\n {\n type: 'confirm',\n name: 'isPluginApi',\n message: 'Is this API for a plugin?',\n },\n {\n when: (answers) => answers.isPluginApi,\n type: 'list',\n name: 'plugin',\n message: 'Plugin name',\n async choices() {\n const pluginsPath = join(plop.getDestBasePath(), 'plugins');\n const exists = await fs.pathExists(pluginsPath);\n if (!exists) {\n throw Error('Couldn\\'t find a \"plugins\" directory');\n }\n\n const pluginsDir = await fs.readdir(pluginsPath, { withFileTypes: true });\n const pluginsDirContent = pluginsDir.filter((fd) => fd.isDirectory());\n\n if (pluginsDirContent.length === 0) {\n throw Error('The \"plugins\" directory is empty');\n }\n\n return pluginsDirContent;\n },\n },\n ],\n actions(answers) {\n if (!answers) {\n return [];\n }\n\n const filePath =\n answers.isPluginApi && answers.plugin ? 'plugins/{{ plugin }}/server' : 'api/{{ id }}';\n const currentDir = process.cwd();\n const language = tsUtils.isUsingTypeScriptSync(currentDir) ? 'ts' : 'js';\n\n const baseActions = [\n {\n type: 'add',\n path: `${filePath}/controllers/{{ id }}.${language}`,\n templateFile: `templates/${language}/controller.${language}.hbs`,\n },\n {\n type: 'add',\n path: `${filePath}/services/{{ id }}.${language}`,\n templateFile: `templates/${language}/service.${language}.hbs`,\n },\n ];\n\n if (answers.isPluginApi) {\n return baseActions;\n }\n\n return [\n {\n type: 'add',\n path: `${filePath}/routes/{{ id }}.${language}`,\n templateFile: `templates/${language}/single-route.${language}.hbs`,\n },\n ...baseActions,\n ];\n },\n });\n};\n","import { join } from 'path';\nimport fs from 'fs-extra';\n\nimport type { PromptQuestion } from 'node-plop';\n\nexport default (\n action: string,\n basePath: string,\n { rootFolder = false } = {}\n): Array<PromptQuestion> => {\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) => 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) => 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","export default (destination: string) => {\n if (destination === 'api') {\n return `api/{{ api }}`;\n }\n\n if (destination === 'plugin') {\n return `plugins/{{ plugin }}/server`;\n }\n\n if (destination === 'root') {\n return './';\n }\n\n return `api/{{ id }}`;\n};\n","import type { NodePlopAPI } from 'plop';\nimport tsUtils from '@strapi/typescript-utils';\n\nimport getDestinationPrompts from './prompts/get-destination-prompts';\nimport getFilePath from './utils/get-file-path';\nimport validateInput from './utils/validate-input';\n\nexport default (plop: NodePlopAPI) => {\n // Controller generator\n plop.setGenerator('controller', {\n description: 'Generate a controller for an API',\n prompts: [\n {\n type: 'input',\n name: 'id',\n message: 'Controller name',\n validate: (input) => validateInput(input),\n },\n ...getDestinationPrompts('controller', plop.getDestBasePath()),\n ],\n actions(answers) {\n if (!answers) {\n return [];\n }\n\n const filePath = getFilePath(answers.destination);\n const currentDir = process.cwd();\n const language = tsUtils.isUsingTypeScriptSync(currentDir) ? 'ts' : 'js';\n\n return [\n {\n type: 'add',\n path: `${filePath}/controllers/{{ id }}.${language}`,\n templateFile: `templates/${language}/controller.${language}.hbs`,\n },\n ];\n },\n });\n};\n","import pluralize from 'pluralize';\nimport slugify from '@sindresorhus/slugify';\nimport { strings } from '@strapi/utils';\n\nimport type { PromptQuestion } from 'node-plop';\n\ninterface Answers {\n displayName: string;\n singularName: string;\n pluralName: string;\n}\n\nconst questions: Array<PromptQuestion> = [\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) {\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","import type { PromptQuestion } from 'node-plop';\n\nimport validateInput from '../utils/validate-input';\n\nconst questions: Array<PromptQuestion> = [\n {\n type: 'list',\n name: 'kind',\n message: 'Please choose the model type',\n default: 'collectionType',\n choices: [\n { name: 'Collection Type', value: 'collectionType' },\n { name: 'Single Type', value: 'singleType' },\n ],\n validate: (input: string) => validateInput(input),\n },\n];\n\nexport default questions;\n","export default (input: string) => {\n const regex = /^[A-Za-z-|_]+$/g;\n\n if (!input) {\n return 'You must provide an input';\n }\n\n return regex.test(input) || \"Please use only letters, '-', '_', and no spaces\";\n};\n","import type { DynamicPromptsFunction } from 'node-plop';\n\nimport validateAttributeInput from '../utils/validate-attribute-input';\n\ninterface AttributeAnswer {\n attributeName: string;\n attributeType: typeof DEFAULT_TYPES;\n enum?: string;\n multiple?: boolean;\n}\n\nconst DEFAULT_TYPES = [\n // advanced types\n 'media',\n\n // scalar types\n 'string',\n 'text',\n 'richtext',\n 'json',\n 'enumeration',\n 'password',\n 'email',\n 'integer',\n 'biginteger',\n 'float',\n 'decimal',\n 'date',\n 'time',\n 'datetime',\n 'timestamp',\n 'boolean',\n] as const;\n\nconst getAttributesPrompts: DynamicPromptsFunction = async (inquirer) => {\n const { addAttributes } = await inquirer.prompt([\n {\n type: 'confirm',\n name: 'addAttributes',\n message: 'Do you want to add attributes?',\n },\n ]);\n\n const attributes: Array<AttributeAnswer> = [];\n\n /**\n * @param {import('inquirer').Inquirer} inquirer\n * @returns {Promise<void>}\n */\n const createNewAttributes = async (inquirer: Parameters<DynamicPromptsFunction>[0]) => {\n const answers = await inquirer.prompt([\n {\n type: 'input',\n name: 'attributeName',\n message: 'Name of attribute',\n validate: (input: string) => validateAttributeInput(input),\n },\n {\n type: 'list',\n name: 'attributeType',\n message: 'What type of attribute',\n pageSize: DEFAULT_TYPES.length,\n choices: DEFAULT_TYPES.map((type) => {\n return { name: type, value: type };\n }),\n },\n {\n when: (answers) => answers.attributeType === 'enumeration',\n type: 'input',\n name: 'enum',\n message: 'Add values separated by a comma',\n },\n {\n when: (answers) => answers.attributeType === 'media',\n type: 'list',\n name: 'multiple',\n message: 'Choose media type',\n choices: [\n { name: 'Multiple', value: true },\n { name: 'Single', value: false },\n ],\n },\n {\n type: 'confirm',\n name: 'addAttributes',\n message: 'Do you want to add another attribute?',\n },\n ]);\n\n attributes.push(answers);\n\n if (!answers.addAttributes) {\n return;\n }\n\n await createNewAttributes(inquirer);\n };\n\n if (addAttributes) {\n await createNewAttributes(inquirer);\n } else {\n console.warn(\n `You won't be able to manage entries from the admin, you can still add attributes later from the content type builder.`\n );\n }\n\n return attributes;\n};\n\nexport default getAttributesPrompts;\n","import type { PromptQuestion } from 'node-plop';\n\nconst questions: Array<PromptQuestion> = [\n {\n type: 'confirm',\n name: 'bootstrapApi',\n default: true,\n message: 'Bootstrap API related files?',\n },\n];\n\nexport default questions;\n","import { join } from 'path';\nimport type { NodePlopAPI, ActionType } from 'plop';\nimport slugify from '@sindresorhus/slugify';\nimport fs from 'fs-extra';\nimport { strings } from '@strapi/utils';\nimport tsUtils from '@strapi/typescript-utils';\n\nimport getDestinationPrompts from './prompts/get-destination-prompts';\nimport getFilePath from './utils/get-file-path';\nimport ctNamesPrompts from './prompts/ct-names-prompts';\nimport kindPrompts from './prompts/kind-prompts';\nimport getAttributesPrompts from './prompts/get-attributes-prompts';\nimport bootstrapApiPrompts from './prompts/bootstrap-api-prompts';\n\nexport default (plop: NodePlopAPI) => {\n // Model generator\n plop.setGenerator('content-type', {\n description: 'Generate a content type for an API',\n async prompts(inquirer) {\n const config = await inquirer.prompt([...ctNamesPrompts, ...kindPrompts]);\n // @ts-expect-error issue with deprecated inquirer.prompts attribute to fix with ugprade to inquirer\n const attributes = await getAttributesPrompts(inquirer);\n\n const api = await inquirer.prompt([\n ...getDestinationPrompts('model', plop.getDestBasePath()),\n {\n when: (answers) => answers.destination === 'new',\n type: 'input',\n name: 'id',\n default: config.singularName,\n message: 'Name of the new API?',\n async validate(input) {\n if (!strings.isKebabCase(input)) {\n return 'Value must be in kebab-case';\n }\n\n const apiPath = join(plop.getDestBasePath(), 'api');\n const exists = await fs.pathExists(apiPath);\n\n if (!exists) {\n return true;\n }\n\n const apiDir = await fs.readdir(apiPath, { withFileTypes: true });\n const apiDirContent = apiDir.filter((fd) => fd.isDirectory());\n\n if (apiDirContent.findIndex((dir) => dir.name === input) !== -1) {\n throw new Error('This name is already taken.');\n }\n\n return true;\n },\n },\n ...bootstrapApiPrompts,\n ]);\n\n return {\n ...config,\n ...api,\n attributes,\n };\n },\n actions(answers) {\n if (!answers) {\n return [];\n }\n\n const attributes = answers.attributes.reduce((object: any, answer: any) => {\n const val: any = { type: answer.attributeType };\n\n if (answer.attributeType === 'enumeration') {\n val.enum = answer.enum.split(',').map((item: string) => item.trim());\n }\n\n if (answer.attributeType === 'media') {\n val.allowedTypes = ['images', 'files', 'videos', 'audios'];\n val.multiple = answer.multiple;\n }\n\n return Object.assign(object, { [answer.attributeName]: val }, {});\n }, {});\n\n const filePath = getFilePath(answers.destination);\n const currentDir = process.cwd();\n const language = tsUtils.isUsingTypeScriptSync(currentDir) ? 'ts' : 'js';\n\n const baseActions: Array<ActionType> = [\n {\n type: 'add',\n path: `${filePath}/content-types/{{ singularName }}/schema.json`,\n templateFile: `templates/${language}/content-type.schema.json.hbs`,\n data: {\n collectionName: slugify(answers.pluralName, { separator: '_' }),\n },\n },\n ];\n\n if (Object.entries(attributes).length > 0) {\n baseActions.push({\n type: 'modify',\n path: `${filePath}/content-types/{{ singularName }}/schema.json`,\n transform(template: string) {\n const parsedTemplate = JSON.parse(template);\n parsedTemplate.attributes = attributes;\n return JSON.stringify(parsedTemplate, null, 2);\n },\n });\n }\n\n if (answers.bootstrapApi) {\n const { singularName } = answers;\n\n let uid;\n if (answers.destination === 'new') {\n uid = `api::${answers.id}.${singularName}`;\n } else if (answers.api) {\n uid = `api::${answers.api}.${singularName}`;\n } else if (answers.plugin) {\n uid = `plugin::${answers.plugin}.${singularName}`;\n }\n\n baseActions.push(\n {\n type: 'add',\n path: `${filePath}/controllers/{{ singularName }}.${language}`,\n templateFile: `templates/${language}/core-controller.${language}.hbs`,\n data: { uid },\n },\n {\n type: 'add',\n path: `${filePath}/services/{{ singularName }}.${language}`,\n templateFile: `templates/${language}/core-service.${language}.hbs`,\n data: { uid },\n },\n {\n type: 'add',\n path: `${filePath}/routes/{{ singularName }}.${language}`,\n templateFile: `templates/${language}/core-router.${language}.hbs`,\n data: { uid },\n }\n );\n }\n\n return baseActions;\n },\n });\n};\n","import type { NodePlopAPI } from 'plop';\nimport tsUtils from '@strapi/typescript-utils';\n\nimport getDestinationPrompts from './prompts/get-destination-prompts';\nimport validateInput from './utils/validate-input';\nimport getFilePath from './utils/get-file-path';\n\nexport default (plop: NodePlopAPI) => {\n // Policy generator\n plop.setGenerator('policy', {\n description: 'Generate a policy for an API',\n prompts: [\n {\n type: 'input',\n name: 'id',\n message: 'Policy name',\n validate: (input) => validateInput(input),\n },\n ...getDestinationPrompts('policy', plop.getDestBasePath(), { rootFolder: true }),\n ],\n actions(answers) {\n if (!answers) {\n return [];\n }\n\n const currentDir = process.cwd();\n const filePath = getFilePath(answers.destination);\n const language = tsUtils.isUsingTypeScriptSync(currentDir) ? 'ts' : 'js';\n\n return [\n {\n type: 'add',\n path: `${filePath}/policies/{{ id }}.${language}`,\n templateFile: `templates/${language}/policy.${language}.hbs`,\n },\n ];\n },\n });\n};\n","import type { NodePlopAPI } from 'plop';\nimport tsUtils from '@strapi/typescript-utils';\n\nimport getDestinationPrompts from './prompts/get-destination-prompts';\nimport validateInput from './utils/validate-input';\nimport getFilePath from './utils/get-file-path';\n\nexport default (plop: NodePlopAPI) => {\n // middleware generator\n plop.setGenerator('middleware', {\n description: 'Generate a middleware for an API',\n prompts: [\n {\n type: 'input',\n name: 'name',\n message: 'Middleware name',\n validate: (input) => validateInput(input),\n },\n ...getDestinationPrompts('middleware', plop.getDestBasePath(), { rootFolder: true }),\n ],\n actions(answers) {\n if (!answers) {\n return [];\n }\n\n const filePath = getFilePath(answers.destination);\n const currentDir = process.cwd();\n const language = tsUtils.isUsingTypeScriptSync(currentDir) ? 'ts' : 'js';\n\n return [\n {\n type: 'add',\n path: `${filePath}/middlewares/{{ name }}.${language}`,\n templateFile: `templates/${language}/middleware.${language}.hbs`,\n },\n ];\n },\n });\n};\n","export default (input: string) => {\n const regex = /^[A-Za-z-_0-9]+$/g;\n\n if (!input) {\n return 'You must provide an input';\n }\n\n return regex.test(input) || \"Please use only letters and number, '-' or '_' and no spaces\";\n};\n","export default (date: Date = new Date()) => {\n return new Date(date.getTime() - date.getTimezoneOffset() * 60000)\n .toJSON()\n .replace(/[-:]/g, '.')\n .replace(/\\....Z/, '');\n};\n","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","import type { NodePlopAPI } from 'plop';\nimport tsUtils from '@strapi/typescript-utils';\n\nimport getDestinationPrompts from './prompts/get-destination-prompts';\nimport getFilePath from './utils/get-file-path';\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 const language = tsUtils.isUsingTypeScriptSync(currentDir) ? 'ts' : 'js';\n\n return [\n {\n type: 'add',\n path: `${filePath}/services/{{ id }}.${language}`,\n templateFile: `templates/${language}/service.${language}.hbs`,\n },\n ];\n },\n });\n};\n","import pluralize from 'pluralize';\nimport type { NodePlopAPI } from 'plop';\n\nimport generateApi from './plops/api';\nimport generateController from './plops/controller';\nimport generateContentType from './plops/content-type';\nimport generatePolicy from './plops/policy';\nimport generateMiddleware from './plops/middleware';\nimport generateMigration from './plops/migration';\nimport generateService from './plops/service';\n\nexport default (plop: NodePlopAPI) => {\n // Plop config\n plop.setWelcomeMessage('Strapi Generators');\n plop.setHelper('pluralize', (text: string) => pluralize(text));\n\n // Generators\n generateApi(plop);\n generateController(plop);\n generateContentType(plop);\n generatePolicy(plop);\n generateMiddleware(plop);\n generateMigration(plop);\n generateService(plop);\n};\n"],"names":["join","fs","tsUtils","questions","slugify","strings","pluralize","inquirer","answers","ctNamesPrompts","kindPrompts","bootstrapApiPrompts"],"mappings":";;;;;;;;;;;;AAAA,MAAe,gBAAA,CAAC,UAAkB;AAChC,QAAM,QAAQ;AAEd,MAAI,CAAC,OAAO;AACH,WAAA;AAAA,EAAA;AAGF,SAAA,MAAM,KAAK,KAAK,KAAK;AAC9B;ACDA,MAAe,cAAA,CAAC,SAAsB;AAEpC,OAAK,aAAa,OAAO;AAAA,IACvB,aAAa;AAAA,IACb,SAAS;AAAA,MACP;AAAA,QACE,MAAM;AAAA,QACN,MAAM;AAAA,QACN,SAAS;AAAA,QACT,UAAU,CAAC,UAAU,cAAc,KAAK;AAAA,MAC1C;AAAA,MACA;AAAA,QACE,MAAM;AAAA,QACN,MAAM;AAAA,QACN,SAAS;AAAA,MACX;AAAA,MACA;AAAA,QACE,MAAM,CAAC,YAAY,QAAQ;AA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BAAAA,QAAQ,sBAAsB,UAAU,IAAI,OAAO;AAE7D,aAAA;AAAA,QACL;AAAA,UACE,MAAM;AAAA,UACN,MAAM,GAAG,QAAQ,sBAAsB,QAAQ;AAAA,UAC/C,cAAc,aAAa,QAAQ,YAAY,QAAQ;AAAA,QAAA;AAAA,MAE3D;AAAA,IAAA;AAAA,EACF,CACD;AACH;ACzBA,MAAe,WAAA,CAAC,SAAsB;AAEpC,OAAK,kBAAkB,mBAAmB;AAC1C,OAAK,UAAU,aAAa,CAAC,SAAiBI,mBAAAA,QAAU,IAAI,CAAC;AAG7D,cAAY,IAAI;AAChB,qBAAmB,IAAI;AACvB,sBAAoB,IAAI;AACxB,iBAAe,IAAI;AACnB,qBAAmB,IAAI;AACvB,oBAAkB,IAAI;AACtB,kBAAgB,IAAI;AACtB;;"}
package/dist/plopfile.mjs CHANGED
@@ -50,7 +50,7 @@ const generateApi = (plop) => {
50
50
  if (!answers) {
51
51
  return [];
52
52
  }
53
- const filePath = answers.isPluginApi && answers.plugin ? "plugins/{{ plugin }}" : "api/{{ id }}";
53
+ const filePath = answers.isPluginApi && answers.plugin ? "plugins/{{ plugin }}/server" : "api/{{ id }}";
54
54
  const currentDir = process.cwd();
55
55
  const language = tsUtils.isUsingTypeScriptSync(currentDir) ? "ts" : "js";
56
56
  const baseActions = [
@@ -460,8 +460,8 @@ const generatePolicy = (plop) => {
460
460
  if (!answers) {
461
461
  return [];
462
462
  }
463
- const filePath = getFilePath(answers.destination);
464
463
  const currentDir = process.cwd();
464
+ const filePath = getFilePath(answers.destination);
465
465
  const language = tsUtils.isUsingTypeScriptSync(currentDir) ? "ts" : "js";
466
466
  return [
467
467
  {
@@ -567,7 +567,7 @@ const generateService = (plop) => {
567
567
  };
568
568
  const plopfile = (plop) => {
569
569
  plop.setWelcomeMessage("Strapi Generators");
570
- plop.addHelper("pluralize", (text) => pluralize(text));
570
+ plop.setHelper("pluralize", (text) => pluralize(text));
571
571
  generateApi(plop);
572
572
  generateController(plop);
573
573
  generateContentType(plop);
@@ -1 +1 @@
1
- {"version":3,"file":"plopfile.mjs","sources":["../src/plops/utils/validate-input.ts","../src/plops/api.ts","../src/plops/prompts/get-destination-prompts.ts","../src/plops/utils/get-file-path.ts","../src/plops/controller.ts","../src/plops/prompts/ct-names-prompts.ts","../src/plops/prompts/kind-prompts.ts","../src/plops/utils/validate-attribute-input.ts","../src/plops/prompts/get-attributes-prompts.ts","../src/plops/prompts/bootstrap-api-prompts.ts","../src/plops/content-type.ts","../src/plops/policy.ts","../src/plops/middleware.ts","../src/plops/utils/validate-file-name-input.ts","../src/plops/utils/get-formatted-date.ts","../src/plops/migration.ts","../src/plops/service.ts","../src/plopfile.ts"],"sourcesContent":["export default (input: string) => {\n const regex = /^[A-Za-z-]+$/g;\n\n if (!input) {\n return 'You must provide an input';\n }\n\n return regex.test(input) || \"Please use only letters, '-' and no spaces\";\n};\n","import { join } from 'path';\nimport type { NodePlopAPI } from 'plop';\nimport fs from 'fs-extra';\nimport tsUtils from '@strapi/typescript-utils';\n\nimport validateInput from './utils/validate-input';\n\nexport default (plop: NodePlopAPI) => {\n // API generator\n plop.setGenerator('api', {\n description: 'Generate a basic API',\n prompts: [\n {\n type: 'input',\n name: 'id',\n message: 'API name',\n validate: (input) => validateInput(input),\n },\n {\n type: 'confirm',\n name: 'isPluginApi',\n message: 'Is this API for a plugin?',\n },\n {\n when: (answers) => answers.isPluginApi,\n type: 'list',\n name: 'plugin',\n message: 'Plugin name',\n async choices() {\n const pluginsPath = join(plop.getDestBasePath(), '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, { withFileTypes: true });\n const pluginsDirContent = pluginsDir.filter((fd) => fd.isDirectory());\n\n if (pluginsDirContent.length === 0) {\n throw Error('The \"plugins\" directory is empty');\n }\n\n return pluginsDirContent;\n },\n },\n ],\n actions(answers) {\n if (!answers) {\n return [];\n }\n\n const filePath =\n answers.isPluginApi && answers.plugin ? 'plugins/{{ plugin }}' : 'api/{{ id }}';\n const currentDir = process.cwd();\n const language = tsUtils.isUsingTypeScriptSync(currentDir) ? 'ts' : 'js';\n\n const baseActions = [\n {\n type: 'add',\n path: `${filePath}/controllers/{{ id }}.${language}`,\n templateFile: `templates/${language}/controller.${language}.hbs`,\n },\n {\n type: 'add',\n path: `${filePath}/services/{{ id }}.${language}`,\n templateFile: `templates/${language}/service.${language}.hbs`,\n },\n ];\n\n if (answers.isPluginApi) {\n return baseActions;\n }\n\n return [\n {\n type: 'add',\n path: `${filePath}/routes/{{ id }}.${language}`,\n templateFile: `templates/${language}/single-route.${language}.hbs`,\n },\n ...baseActions,\n ];\n },\n });\n};\n","import { join } from 'path';\nimport fs from 'fs-extra';\n\nimport type { PromptQuestion } from 'node-plop';\n\nexport default (\n action: string,\n basePath: string,\n { rootFolder = false } = {}\n): Array<PromptQuestion> => {\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) => 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) => 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","export default (destination: string) => {\n if (destination === 'api') {\n return `api/{{ api }}`;\n }\n\n if (destination === 'plugin') {\n return `plugins/{{ plugin }}/server`;\n }\n\n if (destination === 'root') {\n return './';\n }\n\n return `api/{{ id }}`;\n};\n","import type { NodePlopAPI } from 'plop';\nimport tsUtils from '@strapi/typescript-utils';\n\nimport getDestinationPrompts from './prompts/get-destination-prompts';\nimport getFilePath from './utils/get-file-path';\nimport validateInput from './utils/validate-input';\n\nexport default (plop: NodePlopAPI) => {\n // Controller generator\n plop.setGenerator('controller', {\n description: 'Generate a controller for an API',\n prompts: [\n {\n type: 'input',\n name: 'id',\n message: 'Controller name',\n validate: (input) => validateInput(input),\n },\n ...getDestinationPrompts('controller', plop.getDestBasePath()),\n ],\n actions(answers) {\n if (!answers) {\n return [];\n }\n\n const filePath = getFilePath(answers.destination);\n const currentDir = process.cwd();\n const language = tsUtils.isUsingTypeScriptSync(currentDir) ? 'ts' : 'js';\n\n return [\n {\n type: 'add',\n path: `${filePath}/controllers/{{ id }}.${language}`,\n templateFile: `templates/${language}/controller.${language}.hbs`,\n },\n ];\n },\n });\n};\n","import pluralize from 'pluralize';\nimport slugify from '@sindresorhus/slugify';\nimport { strings } from '@strapi/utils';\n\nimport type { PromptQuestion } from 'node-plop';\n\ninterface Answers {\n displayName: string;\n singularName: string;\n pluralName: string;\n}\n\nconst questions: Array<PromptQuestion> = [\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) {\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","import type { PromptQuestion } from 'node-plop';\n\nimport validateInput from '../utils/validate-input';\n\nconst questions: Array<PromptQuestion> = [\n {\n type: 'list',\n name: 'kind',\n message: 'Please choose the model type',\n default: 'collectionType',\n choices: [\n { name: 'Collection Type', value: 'collectionType' },\n { name: 'Single Type', value: 'singleType' },\n ],\n validate: (input: string) => validateInput(input),\n },\n];\n\nexport default questions;\n","export default (input: string) => {\n const regex = /^[A-Za-z-|_]+$/g;\n\n if (!input) {\n return 'You must provide an input';\n }\n\n return regex.test(input) || \"Please use only letters, '-', '_', and no spaces\";\n};\n","import type { DynamicPromptsFunction } from 'node-plop';\n\nimport validateAttributeInput from '../utils/validate-attribute-input';\n\ninterface AttributeAnswer {\n attributeName: string;\n attributeType: typeof DEFAULT_TYPES;\n enum?: string;\n multiple?: boolean;\n}\n\nconst DEFAULT_TYPES = [\n // advanced types\n 'media',\n\n // scalar types\n 'string',\n 'text',\n 'richtext',\n 'json',\n 'enumeration',\n 'password',\n 'email',\n 'integer',\n 'biginteger',\n 'float',\n 'decimal',\n 'date',\n 'time',\n 'datetime',\n 'timestamp',\n 'boolean',\n] as const;\n\nconst getAttributesPrompts: DynamicPromptsFunction = async (inquirer) => {\n const { addAttributes } = await inquirer.prompt([\n {\n type: 'confirm',\n name: 'addAttributes',\n message: 'Do you want to add attributes?',\n },\n ]);\n\n const attributes: Array<AttributeAnswer> = [];\n\n /**\n * @param {import('inquirer').Inquirer} inquirer\n * @returns {Promise<void>}\n */\n const createNewAttributes = async (inquirer: Parameters<DynamicPromptsFunction>[0]) => {\n const answers = await inquirer.prompt([\n {\n type: 'input',\n name: 'attributeName',\n message: 'Name of attribute',\n validate: (input: string) => validateAttributeInput(input),\n },\n {\n type: 'list',\n name: 'attributeType',\n message: 'What type of attribute',\n pageSize: DEFAULT_TYPES.length,\n choices: DEFAULT_TYPES.map((type) => {\n return { name: type, value: type };\n }),\n },\n {\n when: (answers) => answers.attributeType === 'enumeration',\n type: 'input',\n name: 'enum',\n message: 'Add values separated by a comma',\n },\n {\n when: (answers) => answers.attributeType === 'media',\n type: 'list',\n name: 'multiple',\n message: 'Choose media type',\n choices: [\n { name: 'Multiple', value: true },\n { name: 'Single', value: false },\n ],\n },\n {\n type: 'confirm',\n name: 'addAttributes',\n message: 'Do you want to add another attribute?',\n },\n ]);\n\n attributes.push(answers);\n\n if (!answers.addAttributes) {\n return;\n }\n\n await createNewAttributes(inquirer);\n };\n\n if (addAttributes) {\n await createNewAttributes(inquirer);\n } else {\n console.warn(\n `You won't be able to manage entries from the admin, you can still add attributes later from the content type builder.`\n );\n }\n\n return attributes;\n};\n\nexport default getAttributesPrompts;\n","import type { PromptQuestion } from 'node-plop';\n\nconst questions: Array<PromptQuestion> = [\n {\n type: 'confirm',\n name: 'bootstrapApi',\n default: true,\n message: 'Bootstrap API related files?',\n },\n];\n\nexport default questions;\n","import { join } from 'path';\nimport type { NodePlopAPI, ActionType } from 'plop';\nimport slugify from '@sindresorhus/slugify';\nimport fs from 'fs-extra';\nimport { strings } from '@strapi/utils';\nimport tsUtils from '@strapi/typescript-utils';\n\nimport getDestinationPrompts from './prompts/get-destination-prompts';\nimport getFilePath from './utils/get-file-path';\nimport ctNamesPrompts from './prompts/ct-names-prompts';\nimport kindPrompts from './prompts/kind-prompts';\nimport getAttributesPrompts from './prompts/get-attributes-prompts';\nimport bootstrapApiPrompts from './prompts/bootstrap-api-prompts';\n\nexport default (plop: NodePlopAPI) => {\n // Model generator\n plop.setGenerator('content-type', {\n description: 'Generate a content type for an API',\n async prompts(inquirer) {\n const config = await inquirer.prompt([...ctNamesPrompts, ...kindPrompts]);\n // @ts-expect-error issue with deprecated inquirer.prompts attribute to fix with ugprade to inquirer\n const attributes = await getAttributesPrompts(inquirer);\n\n const api = await inquirer.prompt([\n ...getDestinationPrompts('model', plop.getDestBasePath()),\n {\n when: (answers) => answers.destination === 'new',\n type: 'input',\n name: 'id',\n default: config.singularName,\n message: 'Name of the new API?',\n async validate(input) {\n if (!strings.isKebabCase(input)) {\n return 'Value must be in kebab-case';\n }\n\n const apiPath = join(plop.getDestBasePath(), 'api');\n const exists = await fs.pathExists(apiPath);\n\n if (!exists) {\n return true;\n }\n\n const apiDir = await fs.readdir(apiPath, { withFileTypes: true });\n const apiDirContent = apiDir.filter((fd) => fd.isDirectory());\n\n if (apiDirContent.findIndex((dir) => dir.name === input) !== -1) {\n throw new Error('This name is already taken.');\n }\n\n return true;\n },\n },\n ...bootstrapApiPrompts,\n ]);\n\n return {\n ...config,\n ...api,\n attributes,\n };\n },\n actions(answers) {\n if (!answers) {\n return [];\n }\n\n const attributes = answers.attributes.reduce((object: any, answer: any) => {\n const val: any = { type: answer.attributeType };\n\n if (answer.attributeType === 'enumeration') {\n val.enum = answer.enum.split(',').map((item: string) => item.trim());\n }\n\n if (answer.attributeType === 'media') {\n val.allowedTypes = ['images', 'files', 'videos', 'audios'];\n val.multiple = answer.multiple;\n }\n\n return Object.assign(object, { [answer.attributeName]: val }, {});\n }, {});\n\n const filePath = getFilePath(answers.destination);\n // TODO: use basePath instead\n const currentDir = process.cwd();\n const language = tsUtils.isUsingTypeScriptSync(currentDir) ? 'ts' : 'js';\n\n const baseActions: Array<ActionType> = [\n {\n type: 'add',\n path: `${filePath}/content-types/{{ singularName }}/schema.json`,\n templateFile: `templates/${language}/content-type.schema.json.hbs`,\n data: {\n collectionName: slugify(answers.pluralName, { separator: '_' }),\n },\n },\n ];\n\n if (Object.entries(attributes).length > 0) {\n baseActions.push({\n type: 'modify',\n path: `${filePath}/content-types/{{ singularName }}/schema.json`,\n transform(template: string) {\n const parsedTemplate = JSON.parse(template);\n parsedTemplate.attributes = attributes;\n return JSON.stringify(parsedTemplate, null, 2);\n },\n });\n }\n\n if (answers.bootstrapApi) {\n const { singularName } = answers;\n\n let uid;\n if (answers.destination === 'new') {\n uid = `api::${answers.id}.${singularName}`;\n } else if (answers.api) {\n uid = `api::${answers.api}.${singularName}`;\n } else if (answers.plugin) {\n uid = `plugin::${answers.plugin}.${singularName}`;\n }\n\n baseActions.push(\n {\n type: 'add',\n path: `${filePath}/controllers/{{ singularName }}.${language}`,\n templateFile: `templates/${language}/core-controller.${language}.hbs`,\n data: { uid },\n },\n {\n type: 'add',\n path: `${filePath}/services/{{ singularName }}.${language}`,\n templateFile: `templates/${language}/core-service.${language}.hbs`,\n data: { uid },\n },\n {\n type: 'add',\n path: `${filePath}/routes/{{ singularName }}.${language}`,\n templateFile: `templates/${language}/core-router.${language}.hbs`,\n data: { uid },\n }\n );\n }\n\n return baseActions;\n },\n });\n};\n","import type { NodePlopAPI } from 'plop';\nimport tsUtils from '@strapi/typescript-utils';\n\nimport getDestinationPrompts from './prompts/get-destination-prompts';\nimport validateInput from './utils/validate-input';\nimport getFilePath from './utils/get-file-path';\n\nexport default (plop: NodePlopAPI) => {\n // Policy generator\n plop.setGenerator('policy', {\n description: 'Generate a policy for an API',\n prompts: [\n {\n type: 'input',\n name: 'id',\n message: 'Policy name',\n validate: (input) => validateInput(input),\n },\n ...getDestinationPrompts('policy', plop.getDestBasePath(), { rootFolder: true }),\n ],\n actions(answers) {\n if (!answers) {\n return [];\n }\n\n const filePath = getFilePath(answers.destination);\n const currentDir = process.cwd();\n const language = tsUtils.isUsingTypeScriptSync(currentDir) ? 'ts' : 'js';\n\n return [\n {\n type: 'add',\n path: `${filePath}/policies/{{ id }}.${language}`,\n templateFile: `templates/${language}/policy.${language}.hbs`,\n },\n ];\n },\n });\n};\n","import type { NodePlopAPI } from 'plop';\nimport tsUtils from '@strapi/typescript-utils';\n\nimport getDestinationPrompts from './prompts/get-destination-prompts';\nimport validateInput from './utils/validate-input';\nimport getFilePath from './utils/get-file-path';\n\nexport default (plop: NodePlopAPI) => {\n // middleware generator\n plop.setGenerator('middleware', {\n description: 'Generate a middleware for an API',\n prompts: [\n {\n type: 'input',\n name: 'name',\n message: 'Middleware name',\n validate: (input) => validateInput(input),\n },\n ...getDestinationPrompts('middleware', plop.getDestBasePath(), { rootFolder: true }),\n ],\n actions(answers) {\n if (!answers) {\n return [];\n }\n\n const filePath = getFilePath(answers.destination);\n const currentDir = process.cwd();\n const language = tsUtils.isUsingTypeScriptSync(currentDir) ? 'ts' : 'js';\n\n return [\n {\n type: 'add',\n path: `${filePath}/middlewares/{{ name }}.${language}`,\n templateFile: `templates/${language}/middleware.${language}.hbs`,\n },\n ];\n },\n });\n};\n","export default (input: string) => {\n const regex = /^[A-Za-z-_0-9]+$/g;\n\n if (!input) {\n return 'You must provide an input';\n }\n\n return regex.test(input) || \"Please use only letters and number, '-' or '_' and no spaces\";\n};\n","export default (date: Date = new Date()) => {\n return new Date(date.getTime() - date.getTimezoneOffset() * 60000)\n .toJSON()\n .replace(/[-:]/g, '.')\n .replace(/\\....Z/, '');\n};\n","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","import type { NodePlopAPI } from 'plop';\nimport tsUtils from '@strapi/typescript-utils';\n\nimport getDestinationPrompts from './prompts/get-destination-prompts';\nimport getFilePath from './utils/get-file-path';\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 const language = tsUtils.isUsingTypeScriptSync(currentDir) ? 'ts' : 'js';\n\n return [\n {\n type: 'add',\n path: `${filePath}/services/{{ id }}.${language}`,\n templateFile: `templates/${language}/service.${language}.hbs`,\n },\n ];\n },\n });\n};\n","import pluralize from 'pluralize';\nimport type { NodePlopAPI } from 'plop';\n\nimport generateApi from './plops/api';\nimport generateController from './plops/controller';\nimport generateContentType from './plops/content-type';\nimport generatePolicy from './plops/policy';\nimport generateMiddleware from './plops/middleware';\nimport generateMigration from './plops/migration';\nimport generateService from './plops/service';\n\nexport default (plop: NodePlopAPI) => {\n // Plop config\n plop.setWelcomeMessage('Strapi Generators');\n plop.addHelper('pluralize', (text: string) => pluralize(text));\n\n // Generators\n generateApi(plop);\n generateController(plop);\n generateContentType(plop);\n generatePolicy(plop);\n generateMiddleware(plop);\n generateMigration(plop);\n generateService(plop);\n};\n"],"names":["questions","inquirer","answers","ctNamesPrompts","kindPrompts","bootstrapApiPrompts"],"mappings":";;;;;;AAAA,MAAe,gBAAA,CAAC,UAAkB;AAChC,QAAM,QAAQ;AAEd,MAAI,CAAC,OAAO;AACH,WAAA;AAAA,EAAA;AAGF,SAAA,MAAM,KAAK,KAAK,KAAK;AAC9B;ACDA,MAAe,cAAA,CAAC,SAAsB;AAEpC,OAAK,aAAa,OAAO;AAAA,IACvB,aAAa;AAAA,IACb,SAAS;AAAA,MACP;AAAA,QACE,MAAM;AAAA,Q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W;AAC3C,YAAA,aAAa,QAAQ,IAAI;AAC/B,YAAM,WAAW,QAAQ,sBAAsB,UAAU,IAAI,OAAO;AAE7D,aAAA;AAAA,QACL;AAAA,UACE,MAAM;AAAA,UACN,MAAM,GAAG,QAAQ,sBAAsB,QAAQ;AAAA,UAC/C,cAAc,aAAa,QAAQ,YAAY,QAAQ;AAAA,QAAA;AAAA,MAE3D;AAAA,IAAA;AAAA,EACF,CACD;AACH;ACzBA,MAAe,WAAA,CAAC,SAAsB;AAEpC,OAAK,kBAAkB,mBAAmB;AAC1C,OAAK,UAAU,aAAa,CAAC,SAAiB,UAAU,IAAI,CAAC;AAG7D,cAAY,IAAI;AAChB,qBAAmB,IAAI;AACvB,sBAAoB,IAAI;AACxB,iBAAe,IAAI;AACnB,qBAAmB,IAAI;AACvB,oBAAkB,IAAI;AACtB,kBAAgB,IAAI;AACtB;"}
1
+ {"version":3,"file":"plopfile.mjs","sources":["../src/plops/utils/validate-input.ts","../src/plops/api.ts","../src/plops/prompts/get-destination-prompts.ts","../src/plops/utils/get-file-path.ts","../src/plops/controller.ts","../src/plops/prompts/ct-names-prompts.ts","../src/plops/prompts/kind-prompts.ts","../src/plops/utils/validate-attribute-input.ts","../src/plops/prompts/get-attributes-prompts.ts","../src/plops/prompts/bootstrap-api-prompts.ts","../src/plops/content-type.ts","../src/plops/policy.ts","../src/plops/middleware.ts","../src/plops/utils/validate-file-name-input.ts","../src/plops/utils/get-formatted-date.ts","../src/plops/migration.ts","../src/plops/service.ts","../src/plopfile.ts"],"sourcesContent":["export default (input: string) => {\n const regex = /^[A-Za-z-]+$/g;\n\n if (!input) {\n return 'You must provide an input';\n }\n\n return regex.test(input) || \"Please use only letters, '-' and no spaces\";\n};\n","import { join } from 'path';\nimport type { NodePlopAPI } from 'plop';\nimport fs from 'fs-extra';\nimport tsUtils from '@strapi/typescript-utils';\n\nimport validateInput from './utils/validate-input';\n\nexport default (plop: NodePlopAPI) => {\n // API generator\n plop.setGenerator('api', {\n description: 'Generate a basic API',\n prompts: [\n {\n type: 'input',\n name: 'id',\n message: 'API name',\n validate: (input) => validateInput(input),\n },\n {\n type: 'confirm',\n name: 'isPluginApi',\n message: 'Is this API for a plugin?',\n },\n {\n when: (answers) => answers.isPluginApi,\n type: 'list',\n name: 'plugin',\n message: 'Plugin name',\n async choices() {\n const pluginsPath = join(plop.getDestBasePath(), 'plugins');\n const exists = await fs.pathExists(pluginsPath);\n if (!exists) {\n throw Error('Couldn\\'t find a \"plugins\" directory');\n }\n\n const pluginsDir = await fs.readdir(pluginsPath, { withFileTypes: true });\n const pluginsDirContent = pluginsDir.filter((fd) => fd.isDirectory());\n\n if (pluginsDirContent.length === 0) {\n throw Error('The \"plugins\" directory is empty');\n }\n\n return pluginsDirContent;\n },\n },\n ],\n actions(answers) {\n if (!answers) {\n return [];\n }\n\n const filePath =\n answers.isPluginApi && answers.plugin ? 'plugins/{{ plugin }}/server' : 'api/{{ id }}';\n const currentDir = process.cwd();\n const language = tsUtils.isUsingTypeScriptSync(currentDir) ? 'ts' : 'js';\n\n const baseActions = [\n {\n type: 'add',\n path: `${filePath}/controllers/{{ id }}.${language}`,\n templateFile: `templates/${language}/controller.${language}.hbs`,\n },\n {\n type: 'add',\n path: `${filePath}/services/{{ id }}.${language}`,\n templateFile: `templates/${language}/service.${language}.hbs`,\n },\n ];\n\n if (answers.isPluginApi) {\n return baseActions;\n }\n\n return [\n {\n type: 'add',\n path: `${filePath}/routes/{{ id }}.${language}`,\n templateFile: `templates/${language}/single-route.${language}.hbs`,\n },\n ...baseActions,\n ];\n },\n });\n};\n","import { join } from 'path';\nimport fs from 'fs-extra';\n\nimport type { PromptQuestion } from 'node-plop';\n\nexport default (\n action: string,\n basePath: string,\n { rootFolder = false } = {}\n): Array<PromptQuestion> => {\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) => 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) => 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","export default (destination: string) => {\n if (destination === 'api') {\n return `api/{{ api }}`;\n }\n\n if (destination === 'plugin') {\n return `plugins/{{ plugin }}/server`;\n }\n\n if (destination === 'root') {\n return './';\n }\n\n return `api/{{ id }}`;\n};\n","import type { NodePlopAPI } from 'plop';\nimport tsUtils from '@strapi/typescript-utils';\n\nimport getDestinationPrompts from './prompts/get-destination-prompts';\nimport getFilePath from './utils/get-file-path';\nimport validateInput from './utils/validate-input';\n\nexport default (plop: NodePlopAPI) => {\n // Controller generator\n plop.setGenerator('controller', {\n description: 'Generate a controller for an API',\n prompts: [\n {\n type: 'input',\n name: 'id',\n message: 'Controller name',\n validate: (input) => validateInput(input),\n },\n ...getDestinationPrompts('controller', plop.getDestBasePath()),\n ],\n actions(answers) {\n if (!answers) {\n return [];\n }\n\n const filePath = getFilePath(answers.destination);\n const currentDir = process.cwd();\n const language = tsUtils.isUsingTypeScriptSync(currentDir) ? 'ts' : 'js';\n\n return [\n {\n type: 'add',\n path: `${filePath}/controllers/{{ id }}.${language}`,\n templateFile: `templates/${language}/controller.${language}.hbs`,\n },\n ];\n },\n });\n};\n","import pluralize from 'pluralize';\nimport slugify from '@sindresorhus/slugify';\nimport { strings } from '@strapi/utils';\n\nimport type { PromptQuestion } from 'node-plop';\n\ninterface Answers {\n displayName: string;\n singularName: string;\n pluralName: string;\n}\n\nconst questions: Array<PromptQuestion> = [\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) {\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","import type { PromptQuestion } from 'node-plop';\n\nimport validateInput from '../utils/validate-input';\n\nconst questions: Array<PromptQuestion> = [\n {\n type: 'list',\n name: 'kind',\n message: 'Please choose the model type',\n default: 'collectionType',\n choices: [\n { name: 'Collection Type', value: 'collectionType' },\n { name: 'Single Type', value: 'singleType' },\n ],\n validate: (input: string) => validateInput(input),\n },\n];\n\nexport default questions;\n","export default (input: string) => {\n const regex = /^[A-Za-z-|_]+$/g;\n\n if (!input) {\n return 'You must provide an input';\n }\n\n return regex.test(input) || \"Please use only letters, '-', '_', and no spaces\";\n};\n","import type { DynamicPromptsFunction } from 'node-plop';\n\nimport validateAttributeInput from '../utils/validate-attribute-input';\n\ninterface AttributeAnswer {\n attributeName: string;\n attributeType: typeof DEFAULT_TYPES;\n enum?: string;\n multiple?: boolean;\n}\n\nconst DEFAULT_TYPES = [\n // advanced types\n 'media',\n\n // scalar types\n 'string',\n 'text',\n 'richtext',\n 'json',\n 'enumeration',\n 'password',\n 'email',\n 'integer',\n 'biginteger',\n 'float',\n 'decimal',\n 'date',\n 'time',\n 'datetime',\n 'timestamp',\n 'boolean',\n] as const;\n\nconst getAttributesPrompts: DynamicPromptsFunction = async (inquirer) => {\n const { addAttributes } = await inquirer.prompt([\n {\n type: 'confirm',\n name: 'addAttributes',\n message: 'Do you want to add attributes?',\n },\n ]);\n\n const attributes: Array<AttributeAnswer> = [];\n\n /**\n * @param {import('inquirer').Inquirer} inquirer\n * @returns {Promise<void>}\n */\n const createNewAttributes = async (inquirer: Parameters<DynamicPromptsFunction>[0]) => {\n const answers = await inquirer.prompt([\n {\n type: 'input',\n name: 'attributeName',\n message: 'Name of attribute',\n validate: (input: string) => validateAttributeInput(input),\n },\n {\n type: 'list',\n name: 'attributeType',\n message: 'What type of attribute',\n pageSize: DEFAULT_TYPES.length,\n choices: DEFAULT_TYPES.map((type) => {\n return { name: type, value: type };\n }),\n },\n {\n when: (answers) => answers.attributeType === 'enumeration',\n type: 'input',\n name: 'enum',\n message: 'Add values separated by a comma',\n },\n {\n when: (answers) => answers.attributeType === 'media',\n type: 'list',\n name: 'multiple',\n message: 'Choose media type',\n choices: [\n { name: 'Multiple', value: true },\n { name: 'Single', value: false },\n ],\n },\n {\n type: 'confirm',\n name: 'addAttributes',\n message: 'Do you want to add another attribute?',\n },\n ]);\n\n attributes.push(answers);\n\n if (!answers.addAttributes) {\n return;\n }\n\n await createNewAttributes(inquirer);\n };\n\n if (addAttributes) {\n await createNewAttributes(inquirer);\n } else {\n console.warn(\n `You won't be able to manage entries from the admin, you can still add attributes later from the content type builder.`\n );\n }\n\n return attributes;\n};\n\nexport default getAttributesPrompts;\n","import type { PromptQuestion } from 'node-plop';\n\nconst questions: Array<PromptQuestion> = [\n {\n type: 'confirm',\n name: 'bootstrapApi',\n default: true,\n message: 'Bootstrap API related files?',\n },\n];\n\nexport default questions;\n","import { join } from 'path';\nimport type { NodePlopAPI, ActionType } from 'plop';\nimport slugify from '@sindresorhus/slugify';\nimport fs from 'fs-extra';\nimport { strings } from '@strapi/utils';\nimport tsUtils from '@strapi/typescript-utils';\n\nimport getDestinationPrompts from './prompts/get-destination-prompts';\nimport getFilePath from './utils/get-file-path';\nimport ctNamesPrompts from './prompts/ct-names-prompts';\nimport kindPrompts from './prompts/kind-prompts';\nimport getAttributesPrompts from './prompts/get-attributes-prompts';\nimport bootstrapApiPrompts from './prompts/bootstrap-api-prompts';\n\nexport default (plop: NodePlopAPI) => {\n // Model generator\n plop.setGenerator('content-type', {\n description: 'Generate a content type for an API',\n async prompts(inquirer) {\n const config = await inquirer.prompt([...ctNamesPrompts, ...kindPrompts]);\n // @ts-expect-error issue with deprecated inquirer.prompts attribute to fix with ugprade to inquirer\n const attributes = await getAttributesPrompts(inquirer);\n\n const api = await inquirer.prompt([\n ...getDestinationPrompts('model', plop.getDestBasePath()),\n {\n when: (answers) => answers.destination === 'new',\n type: 'input',\n name: 'id',\n default: config.singularName,\n message: 'Name of the new API?',\n async validate(input) {\n if (!strings.isKebabCase(input)) {\n return 'Value must be in kebab-case';\n }\n\n const apiPath = join(plop.getDestBasePath(), 'api');\n const exists = await fs.pathExists(apiPath);\n\n if (!exists) {\n return true;\n }\n\n const apiDir = await fs.readdir(apiPath, { withFileTypes: true });\n const apiDirContent = apiDir.filter((fd) => fd.isDirectory());\n\n if (apiDirContent.findIndex((dir) => dir.name === input) !== -1) {\n throw new Error('This name is already taken.');\n }\n\n return true;\n },\n },\n ...bootstrapApiPrompts,\n ]);\n\n return {\n ...config,\n ...api,\n attributes,\n };\n },\n actions(answers) {\n if (!answers) {\n return [];\n }\n\n const attributes = answers.attributes.reduce((object: any, answer: any) => {\n const val: any = { type: answer.attributeType };\n\n if (answer.attributeType === 'enumeration') {\n val.enum = answer.enum.split(',').map((item: string) => item.trim());\n }\n\n if (answer.attributeType === 'media') {\n val.allowedTypes = ['images', 'files', 'videos', 'audios'];\n val.multiple = answer.multiple;\n }\n\n return Object.assign(object, { [answer.attributeName]: val }, {});\n }, {});\n\n const filePath = getFilePath(answers.destination);\n const currentDir = process.cwd();\n const language = tsUtils.isUsingTypeScriptSync(currentDir) ? 'ts' : 'js';\n\n const baseActions: Array<ActionType> = [\n {\n type: 'add',\n path: `${filePath}/content-types/{{ singularName }}/schema.json`,\n templateFile: `templates/${language}/content-type.schema.json.hbs`,\n data: {\n collectionName: slugify(answers.pluralName, { separator: '_' }),\n },\n },\n ];\n\n if (Object.entries(attributes).length > 0) {\n baseActions.push({\n type: 'modify',\n path: `${filePath}/content-types/{{ singularName }}/schema.json`,\n transform(template: string) {\n const parsedTemplate = JSON.parse(template);\n parsedTemplate.attributes = attributes;\n return JSON.stringify(parsedTemplate, null, 2);\n },\n });\n }\n\n if (answers.bootstrapApi) {\n const { singularName } = answers;\n\n let uid;\n if (answers.destination === 'new') {\n uid = `api::${answers.id}.${singularName}`;\n } else if (answers.api) {\n uid = `api::${answers.api}.${singularName}`;\n } else if (answers.plugin) {\n uid = `plugin::${answers.plugin}.${singularName}`;\n }\n\n baseActions.push(\n {\n type: 'add',\n path: `${filePath}/controllers/{{ singularName }}.${language}`,\n templateFile: `templates/${language}/core-controller.${language}.hbs`,\n data: { uid },\n },\n {\n type: 'add',\n path: `${filePath}/services/{{ singularName }}.${language}`,\n templateFile: `templates/${language}/core-service.${language}.hbs`,\n data: { uid },\n },\n {\n type: 'add',\n path: `${filePath}/routes/{{ singularName }}.${language}`,\n templateFile: `templates/${language}/core-router.${language}.hbs`,\n data: { uid },\n }\n );\n }\n\n return baseActions;\n },\n });\n};\n","import type { NodePlopAPI } from 'plop';\nimport tsUtils from '@strapi/typescript-utils';\n\nimport getDestinationPrompts from './prompts/get-destination-prompts';\nimport validateInput from './utils/validate-input';\nimport getFilePath from './utils/get-file-path';\n\nexport default (plop: NodePlopAPI) => {\n // Policy generator\n plop.setGenerator('policy', {\n description: 'Generate a policy for an API',\n prompts: [\n {\n type: 'input',\n name: 'id',\n message: 'Policy name',\n validate: (input) => validateInput(input),\n },\n ...getDestinationPrompts('policy', plop.getDestBasePath(), { rootFolder: true }),\n ],\n actions(answers) {\n if (!answers) {\n return [];\n }\n\n const currentDir = process.cwd();\n const filePath = getFilePath(answers.destination);\n const language = tsUtils.isUsingTypeScriptSync(currentDir) ? 'ts' : 'js';\n\n return [\n {\n type: 'add',\n path: `${filePath}/policies/{{ id }}.${language}`,\n templateFile: `templates/${language}/policy.${language}.hbs`,\n },\n ];\n },\n });\n};\n","import type { NodePlopAPI } from 'plop';\nimport tsUtils from '@strapi/typescript-utils';\n\nimport getDestinationPrompts from './prompts/get-destination-prompts';\nimport validateInput from './utils/validate-input';\nimport getFilePath from './utils/get-file-path';\n\nexport default (plop: NodePlopAPI) => {\n // middleware generator\n plop.setGenerator('middleware', {\n description: 'Generate a middleware for an API',\n prompts: [\n {\n type: 'input',\n name: 'name',\n message: 'Middleware name',\n validate: (input) => validateInput(input),\n },\n ...getDestinationPrompts('middleware', plop.getDestBasePath(), { rootFolder: true }),\n ],\n actions(answers) {\n if (!answers) {\n return [];\n }\n\n const filePath = getFilePath(answers.destination);\n const currentDir = process.cwd();\n const language = tsUtils.isUsingTypeScriptSync(currentDir) ? 'ts' : 'js';\n\n return [\n {\n type: 'add',\n path: `${filePath}/middlewares/{{ name }}.${language}`,\n templateFile: `templates/${language}/middleware.${language}.hbs`,\n },\n ];\n },\n });\n};\n","export default (input: string) => {\n const regex = /^[A-Za-z-_0-9]+$/g;\n\n if (!input) {\n return 'You must provide an input';\n }\n\n return regex.test(input) || \"Please use only letters and number, '-' or '_' and no spaces\";\n};\n","export default (date: Date = new Date()) => {\n return new Date(date.getTime() - date.getTimezoneOffset() * 60000)\n .toJSON()\n .replace(/[-:]/g, '.')\n .replace(/\\....Z/, '');\n};\n","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","import type { NodePlopAPI } from 'plop';\nimport tsUtils from '@strapi/typescript-utils';\n\nimport getDestinationPrompts from './prompts/get-destination-prompts';\nimport getFilePath from './utils/get-file-path';\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 const language = tsUtils.isUsingTypeScriptSync(currentDir) ? 'ts' : 'js';\n\n return [\n {\n type: 'add',\n path: `${filePath}/services/{{ id }}.${language}`,\n templateFile: `templates/${language}/service.${language}.hbs`,\n },\n ];\n },\n });\n};\n","import pluralize from 'pluralize';\nimport type { NodePlopAPI } from 'plop';\n\nimport generateApi from './plops/api';\nimport generateController from './plops/controller';\nimport generateContentType from './plops/content-type';\nimport generatePolicy from './plops/policy';\nimport generateMiddleware from './plops/middleware';\nimport generateMigration from './plops/migration';\nimport generateService from './plops/service';\n\nexport default (plop: NodePlopAPI) => {\n // Plop config\n plop.setWelcomeMessage('Strapi Generators');\n plop.setHelper('pluralize', (text: string) => pluralize(text));\n\n // Generators\n generateApi(plop);\n generateController(plop);\n generateContentType(plop);\n generatePolicy(plop);\n generateMiddleware(plop);\n generateMigration(plop);\n generateService(plop);\n};\n"],"names":["questions","inquirer","answers","ctNamesPrompts","kindPrompts","bootstrapApiPrompts"],"mappings":";;;;;;AAAA,MAAe,gBAAA,CAAC,UAAkB;AAChC,QAAM,QAAQ;AAEd,MAAI,CAAC,OAAO;AACH,WAAA;AAAA,EAAA;AAGF,SAAA,MAAM,KAAK,KAAK,KAAK;AAC9B;ACDA,MAAe,cAAA,CAAC,SAAsB;AAEpC,OAAK,aAAa,OAAO;AAAA,IACvB,aAAa;AAAA,IACb,SAAS;AAAA,MACP;AAAA,QACE,MAAM;AAAA,QACN,MAAM;AAAA,QACN,SAAS;AAAA,QACT,UAAU,CAAC,UAAU,cAAc,KAAK;AAAA,MAC1C;AAAA,MACA;AAAA,QACE,MAAM;AAAA,QACN,MAAM;AAAA,QACN,SAAS;AAAA,MACX;AAAA,MACA;AAAA,QACE,MAAM,CAAC,YAAY,QAAQ;AAAA,QAC3B,MAAM;AAAA,QACN,MAAM;AAAA,QACN,SAAS;AAAA,QACT,MAAM,UAAU;AACd,gBAAM,cAAc,KAAK,KAAK,gBAAA,GAAmB,SAAS;AAC1D,gBAAM,SAAS,MAAM,GAAG,WAAW,WAAW;AAC9C,cAAI,CAAC,QAAQ;AACX,kBAAM,MAAM,qCAAsC;AAAA,UAAA;AAG9C,gBAAA,aAAa,MAAM,GAAG,QAAQ,aAAa,EAAE,eAAe,MAAM;AACxE,gBAAM,oBAAoB,WAAW,OAAO,CAAC,OAAO,GAAG,aAAa;AAEhE,cAAA,kBAAkB,WAAW,GAAG;AAClC,kBAAM,MAAM,kCAAkC;AAAA,UAAA;AAGzC,iBAAA;AAAA,QAAA;AAAA,MACT;AAAA,IAEJ;AAAA,IACA,QAAQ,SAAS;AACf,UAAI,CAAC,SAAS;AACZ,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ts","sourceRoot":"","sources":["../../src/plops/api.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,MAAM,CAAC;+BAMlB,WAAW;AAAjC,wBA4EE"}
@@ -1 +1 @@
1
- {"version":3,"file":"content-type.d.ts","sourceRoot":"","sources":["../../src/plops/content-type.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAc,MAAM,MAAM,CAAC;+BAa9B,WAAW;AAAjC,wBAqIE"}
1
+ {"version":3,"file":"content-type.d.ts","sourceRoot":"","sources":["../../src/plops/content-type.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAc,MAAM,MAAM,CAAC;+BAa9B,WAAW;AAAjC,wBAoIE"}
@@ -1,3 +1,3 @@
1
- declare const _default: (destination: string) => "api/{{ id }}" | "api/{{ api }}" | "plugins/{{ plugin }}/server" | "./";
1
+ declare const _default: (destination: string) => "plugins/{{ plugin }}/server" | "api/{{ id }}" | "api/{{ api }}" | "./";
2
2
  export default _default;
3
3
  //# sourceMappingURL=get-file-path.d.ts.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@strapi/generators",
3
- "version": "5.7.0-beta.0",
3
+ "version": "5.8.0",
4
4
  "description": "Interactive API generator.",
5
5
  "keywords": [
6
6
  "strapi",
@@ -46,8 +46,8 @@
46
46
  },
47
47
  "dependencies": {
48
48
  "@sindresorhus/slugify": "1.1.0",
49
- "@strapi/typescript-utils": "5.7.0-beta.0",
50
- "@strapi/utils": "5.7.0-beta.0",
49
+ "@strapi/typescript-utils": "5.8.0",
50
+ "@strapi/utils": "5.8.0",
51
51
  "chalk": "4.1.2",
52
52
  "copyfiles": "2.4.1",
53
53
  "fs-extra": "11.2.0",
@@ -58,12 +58,11 @@
58
58
  "devDependencies": {
59
59
  "@strapi/pack-up": "5.0.2",
60
60
  "@types/fs-extra": "11.0.4",
61
- "eslint-config-custom": "5.7.0-beta.0",
62
- "tsconfig": "5.7.0-beta.0"
61
+ "eslint-config-custom": "5.8.0",
62
+ "tsconfig": "5.8.0"
63
63
  },
64
64
  "engines": {
65
65
  "node": ">=18.0.0 <=22.x.x",
66
66
  "npm": ">=6.0.0"
67
- },
68
- "gitHead": "7377311e89eef67196ddc5ae39f4f7d8e5fc8853"
67
+ }
69
68
  }