node_modules ignore

This commit is contained in:
2025-05-08 23:43:47 +02:00
parent e19d52f172
commit 4574544c9f
65041 changed files with 10593536 additions and 0 deletions

View File

@@ -0,0 +1,6 @@
export declare const runCLI: () => Promise<void>;
export declare const generate: <T extends Record<string, any>>(generatorName: string, options: T, { dir, plopFile }?: {
dir?: string | undefined;
plopFile?: string | undefined;
}) => Promise<void>;
//# sourceMappingURL=index.d.ts.map

View File

@@ -0,0 +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"}

38
server/node_modules/@strapi/generators/dist/index.js generated vendored Normal file
View File

@@ -0,0 +1,38 @@
'use strict';
var node_path = require('node:path');
var nodePlop = require('node-plop');
// Starts the Plop CLI programmatically
const runCLI = async ()=>{
const { Plop, run } = await import('plop');
Plop.prepare({
configPath: node_path.join(__dirname, 'plopfile.js')
}, (env)=>{
const argv = process.argv.slice(2); // Extract command-line arguments
Plop.execute(env, argv, (env, argv)=>{
const options = {
...env,
dest: node_path.join(process.cwd(), 'src')
};
return run(options, argv, true); // Pass the third argument 'true' for passArgsBeforeDashes
});
});
};
// Runs a generator programmatically without prompts
const generate = async (generatorName, options, { dir = process.cwd(), plopFile = 'plopfile.js' } = {})=>{
const plop = nodePlop(node_path.join(__dirname, plopFile), {
destBasePath: node_path.join(dir, 'src'),
force: false
});
const generator = plop.getGenerator(generatorName);
await generator.runActions(options, {
onSuccess () {},
onFailure () {},
onComment () {}
});
};
exports.generate = generate;
exports.runCLI = runCLI;
//# sourceMappingURL=index.js.map

View File

@@ -0,0 +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":["runCLI","Plop","run","prepare","configPath","join","__dirname","env","argv","process","slice","execute","options","dest","cwd","generate","generatorName","dir","plopFile","plop","nodePlop","destBasePath","force","generator","getGenerator","runActions","onSuccess","onFailure","onComment"],"mappings":";;;;;AAGA;MACaA,MAAS,GAAA,UAAA;IACpB,MAAM,EAAEC,IAAI,EAAEC,GAAG,EAAE,GAAG,MAAM,OAAO,MAAA,CAAA;AAEnCD,IAAAA,IAAAA,CAAKE,OAAO,CACV;AACEC,QAAAA,UAAAA,EAAYC,eAAKC,SAAW,EAAA,aAAA;AAC9B,KAAA,EACA,CAACC,GAAAA,GAAAA;AACC,QAAA,MAAMC,OAAOC,OAAQD,CAAAA,IAAI,CAACE,KAAK,CAAC;AAChCT,QAAAA,IAAAA,CAAKU,OAAO,CAACJ,GAAKC,EAAAA,IAAAA,EAAM,CAACD,GAAKC,EAAAA,IAAAA,GAAAA;AAC5B,YAAA,MAAMI,OAAU,GAAA;AACd,gBAAA,GAAGL,GAAG;gBACNM,IAAMR,EAAAA,cAAAA,CAAKI,OAAQK,CAAAA,GAAG,EAAI,EAAA,KAAA;AAC5B,aAAA;AACA,YAAA,OAAOZ,GAAIU,CAAAA,OAAAA,EAASJ,IAAM,EAAA,IAAA,CAAA,CAAA;AAC5B,SAAA,CAAA;AACF,KAAA,CAAA;AAEJ;AAEA;MACaO,QAAW,GAAA,OACtBC,aACAJ,EAAAA,OAAAA,EACA,EAAEK,GAAMR,GAAAA,OAAAA,CAAQK,GAAG,EAAE,EAAEI,QAAW,GAAA,aAAa,EAAE,GAAG,EAAE,GAAA;AAEtD,IAAA,MAAMC,IAAOC,GAAAA,QAAAA,CAASf,cAAKC,CAAAA,SAAAA,EAAWY,QAAW,CAAA,EAAA;AAC/CG,QAAAA,YAAAA,EAAchB,eAAKY,GAAK,EAAA,KAAA,CAAA;QACxBK,KAAO,EAAA;AACT,KAAA,CAAA;IAEA,MAAMC,SAAAA,GAAYJ,IAAKK,CAAAA,YAAY,CAACR,aAAAA,CAAAA;IACpC,MAAMO,SAAAA,CAAUE,UAAU,CAACb,OAAqB,EAAA;QAC9Cc,SAAa,CAAA,GAAA,EAAA;QACbC,SAAa,CAAA,GAAA,EAAA;QACbC,SAAa,CAAA,GAAA;AACf,KAAA,CAAA;AACF;;;;;"}

35
server/node_modules/@strapi/generators/dist/index.mjs generated vendored Normal file
View File

@@ -0,0 +1,35 @@
import { join } from 'node:path';
import nodePlop from 'node-plop';
// Starts the Plop CLI programmatically
const runCLI = async ()=>{
const { Plop, run } = await import('plop');
Plop.prepare({
configPath: join(__dirname, 'plopfile.js')
}, (env)=>{
const argv = process.argv.slice(2); // Extract command-line arguments
Plop.execute(env, argv, (env, argv)=>{
const options = {
...env,
dest: join(process.cwd(), 'src')
};
return run(options, argv, true); // Pass the third argument 'true' for passArgsBeforeDashes
});
});
};
// Runs a generator programmatically without prompts
const generate = async (generatorName, options, { dir = process.cwd(), plopFile = 'plopfile.js' } = {})=>{
const plop = nodePlop(join(__dirname, plopFile), {
destBasePath: join(dir, 'src'),
force: false
});
const generator = plop.getGenerator(generatorName);
await generator.runActions(options, {
onSuccess () {},
onFailure () {},
onComment () {}
});
};
export { generate, runCLI };
//# sourceMappingURL=index.mjs.map

View File

@@ -0,0 +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":["runCLI","Plop","run","prepare","configPath","join","__dirname","env","argv","process","slice","execute","options","dest","cwd","generate","generatorName","dir","plopFile","plop","nodePlop","destBasePath","force","generator","getGenerator","runActions","onSuccess","onFailure","onComment"],"mappings":";;;AAGA;MACaA,MAAS,GAAA,UAAA;IACpB,MAAM,EAAEC,IAAI,EAAEC,GAAG,EAAE,GAAG,MAAM,OAAO,MAAA,CAAA;AAEnCD,IAAAA,IAAAA,CAAKE,OAAO,CACV;AACEC,QAAAA,UAAAA,EAAYC,KAAKC,SAAW,EAAA,aAAA;AAC9B,KAAA,EACA,CAACC,GAAAA,GAAAA;AACC,QAAA,MAAMC,OAAOC,OAAQD,CAAAA,IAAI,CAACE,KAAK,CAAC;AAChCT,QAAAA,IAAAA,CAAKU,OAAO,CAACJ,GAAKC,EAAAA,IAAAA,EAAM,CAACD,GAAKC,EAAAA,IAAAA,GAAAA;AAC5B,YAAA,MAAMI,OAAU,GAAA;AACd,gBAAA,GAAGL,GAAG;gBACNM,IAAMR,EAAAA,IAAAA,CAAKI,OAAQK,CAAAA,GAAG,EAAI,EAAA,KAAA;AAC5B,aAAA;AACA,YAAA,OAAOZ,GAAIU,CAAAA,OAAAA,EAASJ,IAAM,EAAA,IAAA,CAAA,CAAA;AAC5B,SAAA,CAAA;AACF,KAAA,CAAA;AAEJ;AAEA;MACaO,QAAW,GAAA,OACtBC,aACAJ,EAAAA,OAAAA,EACA,EAAEK,GAAMR,GAAAA,OAAAA,CAAQK,GAAG,EAAE,EAAEI,QAAW,GAAA,aAAa,EAAE,GAAG,EAAE,GAAA;AAEtD,IAAA,MAAMC,IAAOC,GAAAA,QAAAA,CAASf,IAAKC,CAAAA,SAAAA,EAAWY,QAAW,CAAA,EAAA;AAC/CG,QAAAA,YAAAA,EAAchB,KAAKY,GAAK,EAAA,KAAA,CAAA;QACxBK,KAAO,EAAA;AACT,KAAA,CAAA;IAEA,MAAMC,SAAAA,GAAYJ,IAAKK,CAAAA,YAAY,CAACR,aAAAA,CAAAA;IACpC,MAAMO,SAAAA,CAAUE,UAAU,CAACb,OAAqB,EAAA;QAC9Cc,SAAa,CAAA,GAAA,EAAA;QACbC,SAAa,CAAA,GAAA,EAAA;QACbC,SAAa,CAAA,GAAA;AACf,KAAA,CAAA;AACF;;;;"}

View File

@@ -0,0 +1,4 @@
import type { NodePlopAPI } from 'plop';
declare const _default: (plop: NodePlopAPI) => void;
export default _default;
//# sourceMappingURL=plopfile.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"plopfile.d.ts","sourceRoot":"","sources":["../src/plopfile.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,MAAM,CAAC;+BAUlB,WAAW;AAAjC,wBAaE"}

View File

@@ -0,0 +1,27 @@
'use strict';
var pluralize = require('pluralize');
var api = require('./plops/api.js');
var controller = require('./plops/controller.js');
var contentType = require('./plops/content-type.js');
var policy = require('./plops/policy.js');
var middleware = require('./plops/middleware.js');
var migration = require('./plops/migration.js');
var service = require('./plops/service.js');
var plopfile = ((plop)=>{
// Plop config
plop.setWelcomeMessage('Strapi Generators');
plop.setHelper('pluralize', (text)=>pluralize(text));
// Generators
api(plop);
controller(plop);
contentType(plop);
policy(plop);
middleware(plop);
migration(plop);
service(plop);
});
module.exports = plopfile;
//# sourceMappingURL=plopfile.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"plopfile.js","sources":["../src/plopfile.ts"],"sourcesContent":["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":["plop","setWelcomeMessage","setHelper","text","pluralize","generateApi","generateController","generateContentType","generatePolicy","generateMiddleware","generateMigration","generateService"],"mappings":";;;;;;;;;;;AAWA,eAAe,CAAA,CAACA,IAAAA,GAAAA;;AAEdA,IAAAA,IAAAA,CAAKC,iBAAiB,CAAC,mBAAA,CAAA;AACvBD,IAAAA,IAAAA,CAAKE,SAAS,CAAC,WAAa,EAAA,CAACC,OAAiBC,SAAUD,CAAAA,IAAAA,CAAAA,CAAAA;;IAGxDE,GAAYL,CAAAA,IAAAA,CAAAA;IACZM,UAAmBN,CAAAA,IAAAA,CAAAA;IACnBO,WAAoBP,CAAAA,IAAAA,CAAAA;IACpBQ,MAAeR,CAAAA,IAAAA,CAAAA;IACfS,UAAmBT,CAAAA,IAAAA,CAAAA;IACnBU,SAAkBV,CAAAA,IAAAA,CAAAA;IAClBW,OAAgBX,CAAAA,IAAAA,CAAAA;AAClB,CAAA;;;;"}

View File

@@ -0,0 +1,25 @@
import pluralize from 'pluralize';
import generateApi from './plops/api.mjs';
import generateController from './plops/controller.mjs';
import generateContentType from './plops/content-type.mjs';
import generatePolicy from './plops/policy.mjs';
import generateMiddleware from './plops/middleware.mjs';
import generateMigration from './plops/migration.mjs';
import generateService from './plops/service.mjs';
var plopfile = ((plop)=>{
// Plop config
plop.setWelcomeMessage('Strapi Generators');
plop.setHelper('pluralize', (text)=>pluralize(text));
// Generators
generateApi(plop);
generateController(plop);
generateContentType(plop);
generatePolicy(plop);
generateMiddleware(plop);
generateMigration(plop);
generateService(plop);
});
export { plopfile as default };
//# sourceMappingURL=plopfile.mjs.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"plopfile.mjs","sources":["../src/plopfile.ts"],"sourcesContent":["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":["plop","setWelcomeMessage","setHelper","text","pluralize","generateApi","generateController","generateContentType","generatePolicy","generateMiddleware","generateMigration","generateService"],"mappings":";;;;;;;;;AAWA,eAAe,CAAA,CAACA,IAAAA,GAAAA;;AAEdA,IAAAA,IAAAA,CAAKC,iBAAiB,CAAC,mBAAA,CAAA;AACvBD,IAAAA,IAAAA,CAAKE,SAAS,CAAC,WAAa,EAAA,CAACC,OAAiBC,SAAUD,CAAAA,IAAAA,CAAAA,CAAAA;;IAGxDE,WAAYL,CAAAA,IAAAA,CAAAA;IACZM,kBAAmBN,CAAAA,IAAAA,CAAAA;IACnBO,mBAAoBP,CAAAA,IAAAA,CAAAA;IACpBQ,cAAeR,CAAAA,IAAAA,CAAAA;IACfS,kBAAmBT,CAAAA,IAAAA,CAAAA;IACnBU,iBAAkBV,CAAAA,IAAAA,CAAAA;IAClBW,eAAgBX,CAAAA,IAAAA,CAAAA;AAClB,CAAA;;;;"}

View File

@@ -0,0 +1,4 @@
import type { NodePlopAPI } from 'plop';
declare const _default: (plop: NodePlopAPI) => void;
export default _default;
//# sourceMappingURL=api.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../src/plops/api.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,MAAM,CAAC;+BAMlB,WAAW;AAAjC,wBA4EE"}

View File

@@ -0,0 +1,81 @@
'use strict';
var path = require('path');
var fs = require('fs-extra');
var tsUtils = require('@strapi/typescript-utils');
var validateInput = require('./utils/validate-input.js');
var generateApi = ((plop)=>{
// API generator
plop.setGenerator('api', {
description: 'Generate a basic API',
prompts: [
{
type: 'input',
name: 'id',
message: 'API name',
validate: (input)=>validateInput(input)
},
{
type: 'confirm',
name: 'isPluginApi',
message: 'Is this API for a plugin?'
},
{
when: (answers)=>answers.isPluginApi,
type: 'list',
name: 'plugin',
message: 'Plugin name',
async choices () {
const pluginsPath = path.join(plop.getDestBasePath(), 'plugins');
const exists = await fs.pathExists(pluginsPath);
if (!exists) {
throw Error('Couldn\'t find a "plugins" directory');
}
const pluginsDir = await fs.readdir(pluginsPath, {
withFileTypes: true
});
const pluginsDirContent = pluginsDir.filter((fd)=>fd.isDirectory());
if (pluginsDirContent.length === 0) {
throw Error('The "plugins" directory is empty');
}
return pluginsDirContent;
}
}
],
actions (answers) {
if (!answers) {
return [];
}
const filePath = answers.isPluginApi && answers.plugin ? 'plugins/{{ plugin }}/server' : 'api/{{ id }}';
const currentDir = process.cwd();
const language = tsUtils.isUsingTypeScriptSync(currentDir) ? 'ts' : 'js';
const baseActions = [
{
type: 'add',
path: `${filePath}/controllers/{{ id }}.${language}`,
templateFile: `templates/${language}/controller.${language}.hbs`
},
{
type: 'add',
path: `${filePath}/services/{{ id }}.${language}`,
templateFile: `templates/${language}/service.${language}.hbs`
}
];
if (answers.isPluginApi) {
return baseActions;
}
return [
{
type: 'add',
path: `${filePath}/routes/{{ id }}.${language}`,
templateFile: `templates/${language}/single-route.${language}.hbs`
},
...baseActions
];
}
});
});
module.exports = generateApi;
//# sourceMappingURL=api.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,79 @@
import { join } from 'path';
import fs from 'fs-extra';
import tsUtils from '@strapi/typescript-utils';
import validateInput from './utils/validate-input.mjs';
var generateApi = ((plop)=>{
// API generator
plop.setGenerator('api', {
description: 'Generate a basic API',
prompts: [
{
type: 'input',
name: 'id',
message: 'API name',
validate: (input)=>validateInput(input)
},
{
type: 'confirm',
name: 'isPluginApi',
message: 'Is this API for a plugin?'
},
{
when: (answers)=>answers.isPluginApi,
type: 'list',
name: 'plugin',
message: 'Plugin name',
async choices () {
const pluginsPath = join(plop.getDestBasePath(), 'plugins');
const exists = await fs.pathExists(pluginsPath);
if (!exists) {
throw Error('Couldn\'t find a "plugins" directory');
}
const pluginsDir = await fs.readdir(pluginsPath, {
withFileTypes: true
});
const pluginsDirContent = pluginsDir.filter((fd)=>fd.isDirectory());
if (pluginsDirContent.length === 0) {
throw Error('The "plugins" directory is empty');
}
return pluginsDirContent;
}
}
],
actions (answers) {
if (!answers) {
return [];
}
const filePath = answers.isPluginApi && answers.plugin ? 'plugins/{{ plugin }}/server' : 'api/{{ id }}';
const currentDir = process.cwd();
const language = tsUtils.isUsingTypeScriptSync(currentDir) ? 'ts' : 'js';
const baseActions = [
{
type: 'add',
path: `${filePath}/controllers/{{ id }}.${language}`,
templateFile: `templates/${language}/controller.${language}.hbs`
},
{
type: 'add',
path: `${filePath}/services/{{ id }}.${language}`,
templateFile: `templates/${language}/service.${language}.hbs`
}
];
if (answers.isPluginApi) {
return baseActions;
}
return [
{
type: 'add',
path: `${filePath}/routes/{{ id }}.${language}`,
templateFile: `templates/${language}/single-route.${language}.hbs`
},
...baseActions
];
}
});
});
export { generateApi as default };
//# sourceMappingURL=api.mjs.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,4 @@
import type { NodePlopAPI } from 'plop';
declare const _default: (plop: NodePlopAPI) => void;
export default _default;
//# sourceMappingURL=content-type.d.ts.map

View File

@@ -0,0 +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"}

View File

@@ -0,0 +1,150 @@
'use strict';
var path = require('path');
var slugify = require('@sindresorhus/slugify');
var fs = require('fs-extra');
var utils = require('@strapi/utils');
var tsUtils = require('@strapi/typescript-utils');
var getDestinationPrompts = require('./prompts/get-destination-prompts.js');
var getFilePath = require('./utils/get-file-path.js');
var ctNamesPrompts = require('./prompts/ct-names-prompts.js');
var kindPrompts = require('./prompts/kind-prompts.js');
var getAttributesPrompts = require('./prompts/get-attributes-prompts.js');
var bootstrapApiPrompts = require('./prompts/bootstrap-api-prompts.js');
var generateContentType = ((plop)=>{
// Model generator
plop.setGenerator('content-type', {
description: 'Generate a content type for an API',
async prompts (inquirer) {
const config = await inquirer.prompt([
...ctNamesPrompts,
...kindPrompts
]);
// @ts-expect-error issue with deprecated inquirer.prompts attribute to fix with ugprade to inquirer
const attributes = await getAttributesPrompts(inquirer);
const api = await inquirer.prompt([
...getDestinationPrompts('model', plop.getDestBasePath()),
{
when: (answers)=>answers.destination === 'new',
type: 'input',
name: 'id',
default: config.singularName,
message: 'Name of the new API?',
async validate (input) {
if (!utils.strings.isKebabCase(input)) {
return 'Value must be in kebab-case';
}
const apiPath = path.join(plop.getDestBasePath(), 'api');
const exists = await fs.pathExists(apiPath);
if (!exists) {
return true;
}
const apiDir = await fs.readdir(apiPath, {
withFileTypes: true
});
const apiDirContent = apiDir.filter((fd)=>fd.isDirectory());
if (apiDirContent.findIndex((dir)=>dir.name === input) !== -1) {
throw new Error('This name is already taken.');
}
return true;
}
},
...bootstrapApiPrompts
]);
return {
...config,
...api,
attributes
};
},
actions (answers) {
if (!answers) {
return [];
}
const attributes = answers.attributes.reduce((object, answer)=>{
const val = {
type: answer.attributeType
};
if (answer.attributeType === 'enumeration') {
val.enum = answer.enum.split(',').map((item)=>item.trim());
}
if (answer.attributeType === 'media') {
val.allowedTypes = [
'images',
'files',
'videos',
'audios'
];
val.multiple = answer.multiple;
}
return Object.assign(object, {
[answer.attributeName]: val
}, {});
}, {});
const filePath = getFilePath(answers.destination);
const currentDir = process.cwd();
const language = tsUtils.isUsingTypeScriptSync(currentDir) ? 'ts' : 'js';
const baseActions = [
{
type: 'add',
path: `${filePath}/content-types/{{ singularName }}/schema.json`,
templateFile: `templates/${language}/content-type.schema.json.hbs`,
data: {
collectionName: slugify(answers.pluralName, {
separator: '_'
})
}
}
];
if (Object.entries(attributes).length > 0) {
baseActions.push({
type: 'modify',
path: `${filePath}/content-types/{{ singularName }}/schema.json`,
transform (template) {
const parsedTemplate = JSON.parse(template);
parsedTemplate.attributes = attributes;
return JSON.stringify(parsedTemplate, null, 2);
}
});
}
if (answers.bootstrapApi) {
const { singularName } = answers;
let uid;
if (answers.destination === 'new') {
uid = `api::${answers.id}.${singularName}`;
} else if (answers.api) {
uid = `api::${answers.api}.${singularName}`;
} else if (answers.plugin) {
uid = `plugin::${answers.plugin}.${singularName}`;
}
baseActions.push({
type: 'add',
path: `${filePath}/controllers/{{ singularName }}.${language}`,
templateFile: `templates/${language}/core-controller.${language}.hbs`,
data: {
uid
}
}, {
type: 'add',
path: `${filePath}/services/{{ singularName }}.${language}`,
templateFile: `templates/${language}/core-service.${language}.hbs`,
data: {
uid
}
}, {
type: 'add',
path: `${filePath}/routes/{{ singularName }}.${language}`,
templateFile: `templates/${language}/core-router.${language}.hbs`,
data: {
uid
}
});
}
return baseActions;
}
});
});
module.exports = generateContentType;
//# sourceMappingURL=content-type.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,148 @@
import { join } from 'path';
import slugify from '@sindresorhus/slugify';
import fs from 'fs-extra';
import { strings } from '@strapi/utils';
import tsUtils from '@strapi/typescript-utils';
import getDestinationPrompts from './prompts/get-destination-prompts.mjs';
import getFilePath from './utils/get-file-path.mjs';
import questions from './prompts/ct-names-prompts.mjs';
import questions$1 from './prompts/kind-prompts.mjs';
import getAttributesPrompts from './prompts/get-attributes-prompts.mjs';
import questions$2 from './prompts/bootstrap-api-prompts.mjs';
var generateContentType = ((plop)=>{
// Model generator
plop.setGenerator('content-type', {
description: 'Generate a content type for an API',
async prompts (inquirer) {
const config = await inquirer.prompt([
...questions,
...questions$1
]);
// @ts-expect-error issue with deprecated inquirer.prompts attribute to fix with ugprade to inquirer
const attributes = await getAttributesPrompts(inquirer);
const api = await inquirer.prompt([
...getDestinationPrompts('model', plop.getDestBasePath()),
{
when: (answers)=>answers.destination === 'new',
type: 'input',
name: 'id',
default: config.singularName,
message: 'Name of the new API?',
async validate (input) {
if (!strings.isKebabCase(input)) {
return 'Value must be in kebab-case';
}
const apiPath = join(plop.getDestBasePath(), 'api');
const exists = await fs.pathExists(apiPath);
if (!exists) {
return true;
}
const apiDir = await fs.readdir(apiPath, {
withFileTypes: true
});
const apiDirContent = apiDir.filter((fd)=>fd.isDirectory());
if (apiDirContent.findIndex((dir)=>dir.name === input) !== -1) {
throw new Error('This name is already taken.');
}
return true;
}
},
...questions$2
]);
return {
...config,
...api,
attributes
};
},
actions (answers) {
if (!answers) {
return [];
}
const attributes = answers.attributes.reduce((object, answer)=>{
const val = {
type: answer.attributeType
};
if (answer.attributeType === 'enumeration') {
val.enum = answer.enum.split(',').map((item)=>item.trim());
}
if (answer.attributeType === 'media') {
val.allowedTypes = [
'images',
'files',
'videos',
'audios'
];
val.multiple = answer.multiple;
}
return Object.assign(object, {
[answer.attributeName]: val
}, {});
}, {});
const filePath = getFilePath(answers.destination);
const currentDir = process.cwd();
const language = tsUtils.isUsingTypeScriptSync(currentDir) ? 'ts' : 'js';
const baseActions = [
{
type: 'add',
path: `${filePath}/content-types/{{ singularName }}/schema.json`,
templateFile: `templates/${language}/content-type.schema.json.hbs`,
data: {
collectionName: slugify(answers.pluralName, {
separator: '_'
})
}
}
];
if (Object.entries(attributes).length > 0) {
baseActions.push({
type: 'modify',
path: `${filePath}/content-types/{{ singularName }}/schema.json`,
transform (template) {
const parsedTemplate = JSON.parse(template);
parsedTemplate.attributes = attributes;
return JSON.stringify(parsedTemplate, null, 2);
}
});
}
if (answers.bootstrapApi) {
const { singularName } = answers;
let uid;
if (answers.destination === 'new') {
uid = `api::${answers.id}.${singularName}`;
} else if (answers.api) {
uid = `api::${answers.api}.${singularName}`;
} else if (answers.plugin) {
uid = `plugin::${answers.plugin}.${singularName}`;
}
baseActions.push({
type: 'add',
path: `${filePath}/controllers/{{ singularName }}.${language}`,
templateFile: `templates/${language}/core-controller.${language}.hbs`,
data: {
uid
}
}, {
type: 'add',
path: `${filePath}/services/{{ singularName }}.${language}`,
templateFile: `templates/${language}/core-service.${language}.hbs`,
data: {
uid
}
}, {
type: 'add',
path: `${filePath}/routes/{{ singularName }}.${language}`,
templateFile: `templates/${language}/core-router.${language}.hbs`,
data: {
uid
}
});
}
return baseActions;
}
});
});
export { generateContentType as default };
//# sourceMappingURL=content-type.mjs.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,4 @@
import type { NodePlopAPI } from 'plop';
declare const _default: (plop: NodePlopAPI) => void;
export default _default;
//# sourceMappingURL=controller.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"controller.d.ts","sourceRoot":"","sources":["../../src/plops/controller.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,MAAM,CAAC;+BAOlB,WAAW;AAAjC,wBA+BE"}

View File

@@ -0,0 +1,40 @@
'use strict';
var tsUtils = require('@strapi/typescript-utils');
var getDestinationPrompts = require('./prompts/get-destination-prompts.js');
var getFilePath = require('./utils/get-file-path.js');
var validateInput = require('./utils/validate-input.js');
var generateController = ((plop)=>{
// Controller generator
plop.setGenerator('controller', {
description: 'Generate a controller for an API',
prompts: [
{
type: 'input',
name: 'id',
message: 'Controller name',
validate: (input)=>validateInput(input)
},
...getDestinationPrompts('controller', plop.getDestBasePath())
],
actions (answers) {
if (!answers) {
return [];
}
const filePath = getFilePath(answers.destination);
const currentDir = process.cwd();
const language = tsUtils.isUsingTypeScriptSync(currentDir) ? 'ts' : 'js';
return [
{
type: 'add',
path: `${filePath}/controllers/{{ id }}.${language}`,
templateFile: `templates/${language}/controller.${language}.hbs`
}
];
}
});
});
module.exports = generateController;
//# sourceMappingURL=controller.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"controller.js","sources":["../../src/plops/controller.ts"],"sourcesContent":["import type { NodePlopAPI } from 'plop';\nimport tsUtils from '@strapi/typescript-utils';\n\nimport getDestinationPrompts from './prompts/get-destination-prompts';\nimport getFilePath from './utils/get-file-path';\nimport validateInput from './utils/validate-input';\n\nexport default (plop: NodePlopAPI) => {\n // Controller generator\n plop.setGenerator('controller', {\n description: 'Generate a controller for an API',\n prompts: [\n {\n type: 'input',\n name: 'id',\n message: 'Controller name',\n validate: (input) => validateInput(input),\n },\n ...getDestinationPrompts('controller', plop.getDestBasePath()),\n ],\n actions(answers) {\n if (!answers) {\n return [];\n }\n\n const filePath = getFilePath(answers.destination);\n const currentDir = process.cwd();\n const language = tsUtils.isUsingTypeScriptSync(currentDir) ? 'ts' : 'js';\n\n return [\n {\n type: 'add',\n path: `${filePath}/controllers/{{ id }}.${language}`,\n templateFile: `templates/${language}/controller.${language}.hbs`,\n },\n ];\n },\n });\n};\n"],"names":["plop","setGenerator","description","prompts","type","name","message","validate","input","validateInput","getDestinationPrompts","getDestBasePath","actions","answers","filePath","getFilePath","destination","currentDir","process","cwd","language","tsUtils","isUsingTypeScriptSync","path","templateFile"],"mappings":";;;;;;;AAOA,yBAAe,CAAA,CAACA,IAAAA,GAAAA;;IAEdA,IAAKC,CAAAA,YAAY,CAAC,YAAc,EAAA;QAC9BC,WAAa,EAAA,kCAAA;QACbC,OAAS,EAAA;AACP,YAAA;gBACEC,IAAM,EAAA,OAAA;gBACNC,IAAM,EAAA,IAAA;gBACNC,OAAS,EAAA,iBAAA;gBACTC,QAAU,EAAA,CAACC,QAAUC,aAAcD,CAAAA,KAAAA;AACrC,aAAA;eACGE,qBAAsB,CAAA,YAAA,EAAcV,KAAKW,eAAe,EAAA;AAC5D,SAAA;AACDC,QAAAA,OAAAA,CAAAA,CAAQC,OAAO,EAAA;AACb,YAAA,IAAI,CAACA,OAAS,EAAA;AACZ,gBAAA,OAAO,EAAE;AACX;YAEA,MAAMC,QAAAA,GAAWC,WAAYF,CAAAA,OAAAA,CAAQG,WAAW,CAAA;YAChD,MAAMC,UAAAA,GAAaC,QAAQC,GAAG,EAAA;AAC9B,YAAA,MAAMC,QAAWC,GAAAA,OAAAA,CAAQC,qBAAqB,CAACL,cAAc,IAAO,GAAA,IAAA;YAEpE,OAAO;AACL,gBAAA;oBACEb,IAAM,EAAA,KAAA;AACNmB,oBAAAA,IAAAA,EAAM,CAAC,EAAET,QAAAA,CAAS,sBAAsB,EAAEM,SAAS,CAAC;oBACpDI,YAAc,EAAA,CAAC,UAAU,EAAEJ,QAAAA,CAAS,YAAY,EAAEA,QAAAA,CAAS,IAAI;AACjE;AACD,aAAA;AACH;AACF,KAAA,CAAA;AACF,CAAA;;;;"}

View File

@@ -0,0 +1,38 @@
import tsUtils from '@strapi/typescript-utils';
import getDestinationPrompts from './prompts/get-destination-prompts.mjs';
import getFilePath from './utils/get-file-path.mjs';
import validateInput from './utils/validate-input.mjs';
var generateController = ((plop)=>{
// Controller generator
plop.setGenerator('controller', {
description: 'Generate a controller for an API',
prompts: [
{
type: 'input',
name: 'id',
message: 'Controller name',
validate: (input)=>validateInput(input)
},
...getDestinationPrompts('controller', plop.getDestBasePath())
],
actions (answers) {
if (!answers) {
return [];
}
const filePath = getFilePath(answers.destination);
const currentDir = process.cwd();
const language = tsUtils.isUsingTypeScriptSync(currentDir) ? 'ts' : 'js';
return [
{
type: 'add',
path: `${filePath}/controllers/{{ id }}.${language}`,
templateFile: `templates/${language}/controller.${language}.hbs`
}
];
}
});
});
export { generateController as default };
//# sourceMappingURL=controller.mjs.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"controller.mjs","sources":["../../src/plops/controller.ts"],"sourcesContent":["import type { NodePlopAPI } from 'plop';\nimport tsUtils from '@strapi/typescript-utils';\n\nimport getDestinationPrompts from './prompts/get-destination-prompts';\nimport getFilePath from './utils/get-file-path';\nimport validateInput from './utils/validate-input';\n\nexport default (plop: NodePlopAPI) => {\n // Controller generator\n plop.setGenerator('controller', {\n description: 'Generate a controller for an API',\n prompts: [\n {\n type: 'input',\n name: 'id',\n message: 'Controller name',\n validate: (input) => validateInput(input),\n },\n ...getDestinationPrompts('controller', plop.getDestBasePath()),\n ],\n actions(answers) {\n if (!answers) {\n return [];\n }\n\n const filePath = getFilePath(answers.destination);\n const currentDir = process.cwd();\n const language = tsUtils.isUsingTypeScriptSync(currentDir) ? 'ts' : 'js';\n\n return [\n {\n type: 'add',\n path: `${filePath}/controllers/{{ id }}.${language}`,\n templateFile: `templates/${language}/controller.${language}.hbs`,\n },\n ];\n },\n });\n};\n"],"names":["plop","setGenerator","description","prompts","type","name","message","validate","input","validateInput","getDestinationPrompts","getDestBasePath","actions","answers","filePath","getFilePath","destination","currentDir","process","cwd","language","tsUtils","isUsingTypeScriptSync","path","templateFile"],"mappings":";;;;;AAOA,yBAAe,CAAA,CAACA,IAAAA,GAAAA;;IAEdA,IAAKC,CAAAA,YAAY,CAAC,YAAc,EAAA;QAC9BC,WAAa,EAAA,kCAAA;QACbC,OAAS,EAAA;AACP,YAAA;gBACEC,IAAM,EAAA,OAAA;gBACNC,IAAM,EAAA,IAAA;gBACNC,OAAS,EAAA,iBAAA;gBACTC,QAAU,EAAA,CAACC,QAAUC,aAAcD,CAAAA,KAAAA;AACrC,aAAA;eACGE,qBAAsB,CAAA,YAAA,EAAcV,KAAKW,eAAe,EAAA;AAC5D,SAAA;AACDC,QAAAA,OAAAA,CAAAA,CAAQC,OAAO,EAAA;AACb,YAAA,IAAI,CAACA,OAAS,EAAA;AACZ,gBAAA,OAAO,EAAE;AACX;YAEA,MAAMC,QAAAA,GAAWC,WAAYF,CAAAA,OAAAA,CAAQG,WAAW,CAAA;YAChD,MAAMC,UAAAA,GAAaC,QAAQC,GAAG,EAAA;AAC9B,YAAA,MAAMC,QAAWC,GAAAA,OAAAA,CAAQC,qBAAqB,CAACL,cAAc,IAAO,GAAA,IAAA;YAEpE,OAAO;AACL,gBAAA;oBACEb,IAAM,EAAA,KAAA;AACNmB,oBAAAA,IAAAA,EAAM,CAAC,EAAET,QAAAA,CAAS,sBAAsB,EAAEM,SAAS,CAAC;oBACpDI,YAAc,EAAA,CAAC,UAAU,EAAEJ,QAAAA,CAAS,YAAY,EAAEA,QAAAA,CAAS,IAAI;AACjE;AACD,aAAA;AACH;AACF,KAAA,CAAA;AACF,CAAA;;;;"}

View File

@@ -0,0 +1,4 @@
import type { NodePlopAPI } from 'plop';
declare const _default: (plop: NodePlopAPI) => void;
export default _default;
//# sourceMappingURL=middleware.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"middleware.d.ts","sourceRoot":"","sources":["../../src/plops/middleware.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,MAAM,CAAC;+BAOlB,WAAW;AAAjC,wBA+BE"}

View File

@@ -0,0 +1,42 @@
'use strict';
var tsUtils = require('@strapi/typescript-utils');
var getDestinationPrompts = require('./prompts/get-destination-prompts.js');
var validateInput = require('./utils/validate-input.js');
var getFilePath = require('./utils/get-file-path.js');
var generateMiddleware = ((plop)=>{
// middleware generator
plop.setGenerator('middleware', {
description: 'Generate a middleware for an API',
prompts: [
{
type: 'input',
name: 'name',
message: 'Middleware name',
validate: (input)=>validateInput(input)
},
...getDestinationPrompts('middleware', plop.getDestBasePath(), {
rootFolder: true
})
],
actions (answers) {
if (!answers) {
return [];
}
const filePath = getFilePath(answers.destination);
const currentDir = process.cwd();
const language = tsUtils.isUsingTypeScriptSync(currentDir) ? 'ts' : 'js';
return [
{
type: 'add',
path: `${filePath}/middlewares/{{ name }}.${language}`,
templateFile: `templates/${language}/middleware.${language}.hbs`
}
];
}
});
});
module.exports = generateMiddleware;
//# sourceMappingURL=middleware.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"middleware.js","sources":["../../src/plops/middleware.ts"],"sourcesContent":["import type { NodePlopAPI } from 'plop';\nimport tsUtils from '@strapi/typescript-utils';\n\nimport getDestinationPrompts from './prompts/get-destination-prompts';\nimport validateInput from './utils/validate-input';\nimport getFilePath from './utils/get-file-path';\n\nexport default (plop: NodePlopAPI) => {\n // middleware generator\n plop.setGenerator('middleware', {\n description: 'Generate a middleware for an API',\n prompts: [\n {\n type: 'input',\n name: 'name',\n message: 'Middleware name',\n validate: (input) => validateInput(input),\n },\n ...getDestinationPrompts('middleware', plop.getDestBasePath(), { rootFolder: true }),\n ],\n actions(answers) {\n if (!answers) {\n return [];\n }\n\n const filePath = getFilePath(answers.destination);\n const currentDir = process.cwd();\n const language = tsUtils.isUsingTypeScriptSync(currentDir) ? 'ts' : 'js';\n\n return [\n {\n type: 'add',\n path: `${filePath}/middlewares/{{ name }}.${language}`,\n templateFile: `templates/${language}/middleware.${language}.hbs`,\n },\n ];\n },\n });\n};\n"],"names":["plop","setGenerator","description","prompts","type","name","message","validate","input","validateInput","getDestinationPrompts","getDestBasePath","rootFolder","actions","answers","filePath","getFilePath","destination","currentDir","process","cwd","language","tsUtils","isUsingTypeScriptSync","path","templateFile"],"mappings":";;;;;;;AAOA,yBAAe,CAAA,CAACA,IAAAA,GAAAA;;IAEdA,IAAKC,CAAAA,YAAY,CAAC,YAAc,EAAA;QAC9BC,WAAa,EAAA,kCAAA;QACbC,OAAS,EAAA;AACP,YAAA;gBACEC,IAAM,EAAA,OAAA;gBACNC,IAAM,EAAA,MAAA;gBACNC,OAAS,EAAA,iBAAA;gBACTC,QAAU,EAAA,CAACC,QAAUC,aAAcD,CAAAA,KAAAA;AACrC,aAAA;eACGE,qBAAsB,CAAA,YAAA,EAAcV,IAAKW,CAAAA,eAAe,EAAI,EAAA;gBAAEC,UAAY,EAAA;AAAK,aAAA;AACnF,SAAA;AACDC,QAAAA,OAAAA,CAAAA,CAAQC,OAAO,EAAA;AACb,YAAA,IAAI,CAACA,OAAS,EAAA;AACZ,gBAAA,OAAO,EAAE;AACX;YAEA,MAAMC,QAAAA,GAAWC,WAAYF,CAAAA,OAAAA,CAAQG,WAAW,CAAA;YAChD,MAAMC,UAAAA,GAAaC,QAAQC,GAAG,EAAA;AAC9B,YAAA,MAAMC,QAAWC,GAAAA,OAAAA,CAAQC,qBAAqB,CAACL,cAAc,IAAO,GAAA,IAAA;YAEpE,OAAO;AACL,gBAAA;oBACEd,IAAM,EAAA,KAAA;AACNoB,oBAAAA,IAAAA,EAAM,CAAC,EAAET,QAAAA,CAAS,wBAAwB,EAAEM,SAAS,CAAC;oBACtDI,YAAc,EAAA,CAAC,UAAU,EAAEJ,QAAAA,CAAS,YAAY,EAAEA,QAAAA,CAAS,IAAI;AACjE;AACD,aAAA;AACH;AACF,KAAA,CAAA;AACF,CAAA;;;;"}

View File

@@ -0,0 +1,40 @@
import tsUtils from '@strapi/typescript-utils';
import getDestinationPrompts from './prompts/get-destination-prompts.mjs';
import validateInput from './utils/validate-input.mjs';
import getFilePath from './utils/get-file-path.mjs';
var generateMiddleware = ((plop)=>{
// middleware generator
plop.setGenerator('middleware', {
description: 'Generate a middleware for an API',
prompts: [
{
type: 'input',
name: 'name',
message: 'Middleware name',
validate: (input)=>validateInput(input)
},
...getDestinationPrompts('middleware', plop.getDestBasePath(), {
rootFolder: true
})
],
actions (answers) {
if (!answers) {
return [];
}
const filePath = getFilePath(answers.destination);
const currentDir = process.cwd();
const language = tsUtils.isUsingTypeScriptSync(currentDir) ? 'ts' : 'js';
return [
{
type: 'add',
path: `${filePath}/middlewares/{{ name }}.${language}`,
templateFile: `templates/${language}/middleware.${language}.hbs`
}
];
}
});
});
export { generateMiddleware as default };
//# sourceMappingURL=middleware.mjs.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"middleware.mjs","sources":["../../src/plops/middleware.ts"],"sourcesContent":["import type { NodePlopAPI } from 'plop';\nimport tsUtils from '@strapi/typescript-utils';\n\nimport getDestinationPrompts from './prompts/get-destination-prompts';\nimport validateInput from './utils/validate-input';\nimport getFilePath from './utils/get-file-path';\n\nexport default (plop: NodePlopAPI) => {\n // middleware generator\n plop.setGenerator('middleware', {\n description: 'Generate a middleware for an API',\n prompts: [\n {\n type: 'input',\n name: 'name',\n message: 'Middleware name',\n validate: (input) => validateInput(input),\n },\n ...getDestinationPrompts('middleware', plop.getDestBasePath(), { rootFolder: true }),\n ],\n actions(answers) {\n if (!answers) {\n return [];\n }\n\n const filePath = getFilePath(answers.destination);\n const currentDir = process.cwd();\n const language = tsUtils.isUsingTypeScriptSync(currentDir) ? 'ts' : 'js';\n\n return [\n {\n type: 'add',\n path: `${filePath}/middlewares/{{ name }}.${language}`,\n templateFile: `templates/${language}/middleware.${language}.hbs`,\n },\n ];\n },\n });\n};\n"],"names":["plop","setGenerator","description","prompts","type","name","message","validate","input","validateInput","getDestinationPrompts","getDestBasePath","rootFolder","actions","answers","filePath","getFilePath","destination","currentDir","process","cwd","language","tsUtils","isUsingTypeScriptSync","path","templateFile"],"mappings":";;;;;AAOA,yBAAe,CAAA,CAACA,IAAAA,GAAAA;;IAEdA,IAAKC,CAAAA,YAAY,CAAC,YAAc,EAAA;QAC9BC,WAAa,EAAA,kCAAA;QACbC,OAAS,EAAA;AACP,YAAA;gBACEC,IAAM,EAAA,OAAA;gBACNC,IAAM,EAAA,MAAA;gBACNC,OAAS,EAAA,iBAAA;gBACTC,QAAU,EAAA,CAACC,QAAUC,aAAcD,CAAAA,KAAAA;AACrC,aAAA;eACGE,qBAAsB,CAAA,YAAA,EAAcV,IAAKW,CAAAA,eAAe,EAAI,EAAA;gBAAEC,UAAY,EAAA;AAAK,aAAA;AACnF,SAAA;AACDC,QAAAA,OAAAA,CAAAA,CAAQC,OAAO,EAAA;AACb,YAAA,IAAI,CAACA,OAAS,EAAA;AACZ,gBAAA,OAAO,EAAE;AACX;YAEA,MAAMC,QAAAA,GAAWC,WAAYF,CAAAA,OAAAA,CAAQG,WAAW,CAAA;YAChD,MAAMC,UAAAA,GAAaC,QAAQC,GAAG,EAAA;AAC9B,YAAA,MAAMC,QAAWC,GAAAA,OAAAA,CAAQC,qBAAqB,CAACL,cAAc,IAAO,GAAA,IAAA;YAEpE,OAAO;AACL,gBAAA;oBACEd,IAAM,EAAA,KAAA;AACNoB,oBAAAA,IAAAA,EAAM,CAAC,EAAET,QAAAA,CAAS,wBAAwB,EAAEM,SAAS,CAAC;oBACtDI,YAAc,EAAA,CAAC,UAAU,EAAEJ,QAAAA,CAAS,YAAY,EAAEA,QAAAA,CAAS,IAAI;AACjE;AACD,aAAA;AACH;AACF,KAAA,CAAA;AACF,CAAA;;;;"}

View File

@@ -0,0 +1,4 @@
import type { NodePlopAPI } from 'plop';
declare const _default: (plop: NodePlopAPI) => void;
export default _default;
//# sourceMappingURL=migration.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"migration.d.ts","sourceRoot":"","sources":["../../src/plops/migration.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,MAAM,CAAC;+BAKlB,WAAW;AAAjC,wBA0BE"}

View File

@@ -0,0 +1,35 @@
'use strict';
var tsUtils = require('@strapi/typescript-utils');
var validateFileNameInput = require('./utils/validate-file-name-input.js');
var getFormattedDate = require('./utils/get-formatted-date.js');
var generateMigration = ((plop)=>{
// Migration generator
plop.setGenerator('migration', {
description: 'Generate a migration',
prompts: [
{
type: 'input',
name: 'name',
message: 'Migration name',
validate: (input)=>validateFileNameInput(input)
}
],
actions () {
const currentDir = process.cwd();
const language = tsUtils.isUsingTypeScriptSync(currentDir) ? 'ts' : 'js';
const timestamp = getFormattedDate();
return [
{
type: 'add',
path: `${currentDir}/database/migrations/${timestamp}.{{ name }}.${language}`,
templateFile: `templates/${language}/migration.${language}.hbs`
}
];
}
});
});
module.exports = generateMigration;
//# sourceMappingURL=migration.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"migration.js","sources":["../../src/plops/migration.ts"],"sourcesContent":["import type { NodePlopAPI } from 'plop';\nimport tsUtils from '@strapi/typescript-utils';\nimport validateFileNameInput from './utils/validate-file-name-input';\nimport getFormattedDate from './utils/get-formatted-date';\n\nexport default (plop: NodePlopAPI) => {\n // Migration generator\n plop.setGenerator('migration', {\n description: 'Generate a migration',\n prompts: [\n {\n type: 'input',\n name: 'name',\n message: 'Migration name',\n validate: (input) => validateFileNameInput(input),\n },\n ],\n actions() {\n const currentDir = process.cwd();\n const language = tsUtils.isUsingTypeScriptSync(currentDir) ? 'ts' : 'js';\n const timestamp = getFormattedDate();\n\n return [\n {\n type: 'add',\n path: `${currentDir}/database/migrations/${timestamp}.{{ name }}.${language}`,\n templateFile: `templates/${language}/migration.${language}.hbs`,\n },\n ];\n },\n });\n};\n"],"names":["plop","setGenerator","description","prompts","type","name","message","validate","input","validateFileNameInput","actions","currentDir","process","cwd","language","tsUtils","isUsingTypeScriptSync","timestamp","getFormattedDate","path","templateFile"],"mappings":";;;;;;AAKA,wBAAe,CAAA,CAACA,IAAAA,GAAAA;;IAEdA,IAAKC,CAAAA,YAAY,CAAC,WAAa,EAAA;QAC7BC,WAAa,EAAA,sBAAA;QACbC,OAAS,EAAA;AACP,YAAA;gBACEC,IAAM,EAAA,OAAA;gBACNC,IAAM,EAAA,MAAA;gBACNC,OAAS,EAAA,gBAAA;gBACTC,QAAU,EAAA,CAACC,QAAUC,qBAAsBD,CAAAA,KAAAA;AAC7C;AACD,SAAA;AACDE,QAAAA,OAAAA,CAAAA,GAAAA;YACE,MAAMC,UAAAA,GAAaC,QAAQC,GAAG,EAAA;AAC9B,YAAA,MAAMC,QAAWC,GAAAA,OAAAA,CAAQC,qBAAqB,CAACL,cAAc,IAAO,GAAA,IAAA;AACpE,YAAA,MAAMM,SAAYC,GAAAA,gBAAAA,EAAAA;YAElB,OAAO;AACL,gBAAA;oBACEd,IAAM,EAAA,KAAA;oBACNe,IAAM,EAAA,CAAC,EAAER,UAAW,CAAA,qBAAqB,EAAEM,SAAU,CAAA,YAAY,EAAEH,QAAAA,CAAS,CAAC;oBAC7EM,YAAc,EAAA,CAAC,UAAU,EAAEN,QAAAA,CAAS,WAAW,EAAEA,QAAAA,CAAS,IAAI;AAChE;AACD,aAAA;AACH;AACF,KAAA,CAAA;AACF,CAAA;;;;"}

View File

@@ -0,0 +1,33 @@
import tsUtils from '@strapi/typescript-utils';
import validateFileNameInput from './utils/validate-file-name-input.mjs';
import getFormattedDate from './utils/get-formatted-date.mjs';
var generateMigration = ((plop)=>{
// Migration generator
plop.setGenerator('migration', {
description: 'Generate a migration',
prompts: [
{
type: 'input',
name: 'name',
message: 'Migration name',
validate: (input)=>validateFileNameInput(input)
}
],
actions () {
const currentDir = process.cwd();
const language = tsUtils.isUsingTypeScriptSync(currentDir) ? 'ts' : 'js';
const timestamp = getFormattedDate();
return [
{
type: 'add',
path: `${currentDir}/database/migrations/${timestamp}.{{ name }}.${language}`,
templateFile: `templates/${language}/migration.${language}.hbs`
}
];
}
});
});
export { generateMigration as default };
//# sourceMappingURL=migration.mjs.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"migration.mjs","sources":["../../src/plops/migration.ts"],"sourcesContent":["import type { NodePlopAPI } from 'plop';\nimport tsUtils from '@strapi/typescript-utils';\nimport validateFileNameInput from './utils/validate-file-name-input';\nimport getFormattedDate from './utils/get-formatted-date';\n\nexport default (plop: NodePlopAPI) => {\n // Migration generator\n plop.setGenerator('migration', {\n description: 'Generate a migration',\n prompts: [\n {\n type: 'input',\n name: 'name',\n message: 'Migration name',\n validate: (input) => validateFileNameInput(input),\n },\n ],\n actions() {\n const currentDir = process.cwd();\n const language = tsUtils.isUsingTypeScriptSync(currentDir) ? 'ts' : 'js';\n const timestamp = getFormattedDate();\n\n return [\n {\n type: 'add',\n path: `${currentDir}/database/migrations/${timestamp}.{{ name }}.${language}`,\n templateFile: `templates/${language}/migration.${language}.hbs`,\n },\n ];\n },\n });\n};\n"],"names":["plop","setGenerator","description","prompts","type","name","message","validate","input","validateFileNameInput","actions","currentDir","process","cwd","language","tsUtils","isUsingTypeScriptSync","timestamp","getFormattedDate","path","templateFile"],"mappings":";;;;AAKA,wBAAe,CAAA,CAACA,IAAAA,GAAAA;;IAEdA,IAAKC,CAAAA,YAAY,CAAC,WAAa,EAAA;QAC7BC,WAAa,EAAA,sBAAA;QACbC,OAAS,EAAA;AACP,YAAA;gBACEC,IAAM,EAAA,OAAA;gBACNC,IAAM,EAAA,MAAA;gBACNC,OAAS,EAAA,gBAAA;gBACTC,QAAU,EAAA,CAACC,QAAUC,qBAAsBD,CAAAA,KAAAA;AAC7C;AACD,SAAA;AACDE,QAAAA,OAAAA,CAAAA,GAAAA;YACE,MAAMC,UAAAA,GAAaC,QAAQC,GAAG,EAAA;AAC9B,YAAA,MAAMC,QAAWC,GAAAA,OAAAA,CAAQC,qBAAqB,CAACL,cAAc,IAAO,GAAA,IAAA;AACpE,YAAA,MAAMM,SAAYC,GAAAA,gBAAAA,EAAAA;YAElB,OAAO;AACL,gBAAA;oBACEd,IAAM,EAAA,KAAA;oBACNe,IAAM,EAAA,CAAC,EAAER,UAAW,CAAA,qBAAqB,EAAEM,SAAU,CAAA,YAAY,EAAEH,QAAAA,CAAS,CAAC;oBAC7EM,YAAc,EAAA,CAAC,UAAU,EAAEN,QAAAA,CAAS,WAAW,EAAEA,QAAAA,CAAS,IAAI;AAChE;AACD,aAAA;AACH;AACF,KAAA,CAAA;AACF,CAAA;;;;"}

View File

@@ -0,0 +1,4 @@
import type { NodePlopAPI } from 'plop';
declare const _default: (plop: NodePlopAPI) => void;
export default _default;
//# sourceMappingURL=policy.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"policy.d.ts","sourceRoot":"","sources":["../../src/plops/policy.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,MAAM,CAAC;+BAOlB,WAAW;AAAjC,wBA+BE"}

View File

@@ -0,0 +1,42 @@
'use strict';
var tsUtils = require('@strapi/typescript-utils');
var getDestinationPrompts = require('./prompts/get-destination-prompts.js');
var validateInput = require('./utils/validate-input.js');
var getFilePath = require('./utils/get-file-path.js');
var generatePolicy = ((plop)=>{
// Policy generator
plop.setGenerator('policy', {
description: 'Generate a policy for an API',
prompts: [
{
type: 'input',
name: 'id',
message: 'Policy name',
validate: (input)=>validateInput(input)
},
...getDestinationPrompts('policy', plop.getDestBasePath(), {
rootFolder: true
})
],
actions (answers) {
if (!answers) {
return [];
}
const currentDir = process.cwd();
const filePath = getFilePath(answers.destination);
const language = tsUtils.isUsingTypeScriptSync(currentDir) ? 'ts' : 'js';
return [
{
type: 'add',
path: `${filePath}/policies/{{ id }}.${language}`,
templateFile: `templates/${language}/policy.${language}.hbs`
}
];
}
});
});
module.exports = generatePolicy;
//# sourceMappingURL=policy.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"policy.js","sources":["../../src/plops/policy.ts"],"sourcesContent":["import type { NodePlopAPI } from 'plop';\nimport tsUtils from '@strapi/typescript-utils';\n\nimport getDestinationPrompts from './prompts/get-destination-prompts';\nimport validateInput from './utils/validate-input';\nimport getFilePath from './utils/get-file-path';\n\nexport default (plop: NodePlopAPI) => {\n // Policy generator\n plop.setGenerator('policy', {\n description: 'Generate a policy for an API',\n prompts: [\n {\n type: 'input',\n name: 'id',\n message: 'Policy name',\n validate: (input) => validateInput(input),\n },\n ...getDestinationPrompts('policy', plop.getDestBasePath(), { rootFolder: true }),\n ],\n actions(answers) {\n if (!answers) {\n return [];\n }\n\n const currentDir = process.cwd();\n const filePath = getFilePath(answers.destination);\n const language = tsUtils.isUsingTypeScriptSync(currentDir) ? 'ts' : 'js';\n\n return [\n {\n type: 'add',\n path: `${filePath}/policies/{{ id }}.${language}`,\n templateFile: `templates/${language}/policy.${language}.hbs`,\n },\n ];\n },\n });\n};\n"],"names":["plop","setGenerator","description","prompts","type","name","message","validate","input","validateInput","getDestinationPrompts","getDestBasePath","rootFolder","actions","answers","currentDir","process","cwd","filePath","getFilePath","destination","language","tsUtils","isUsingTypeScriptSync","path","templateFile"],"mappings":";;;;;;;AAOA,qBAAe,CAAA,CAACA,IAAAA,GAAAA;;IAEdA,IAAKC,CAAAA,YAAY,CAAC,QAAU,EAAA;QAC1BC,WAAa,EAAA,8BAAA;QACbC,OAAS,EAAA;AACP,YAAA;gBACEC,IAAM,EAAA,OAAA;gBACNC,IAAM,EAAA,IAAA;gBACNC,OAAS,EAAA,aAAA;gBACTC,QAAU,EAAA,CAACC,QAAUC,aAAcD,CAAAA,KAAAA;AACrC,aAAA;eACGE,qBAAsB,CAAA,QAAA,EAAUV,IAAKW,CAAAA,eAAe,EAAI,EAAA;gBAAEC,UAAY,EAAA;AAAK,aAAA;AAC/E,SAAA;AACDC,QAAAA,OAAAA,CAAAA,CAAQC,OAAO,EAAA;AACb,YAAA,IAAI,CAACA,OAAS,EAAA;AACZ,gBAAA,OAAO,EAAE;AACX;YAEA,MAAMC,UAAAA,GAAaC,QAAQC,GAAG,EAAA;YAC9B,MAAMC,QAAAA,GAAWC,WAAYL,CAAAA,OAAAA,CAAQM,WAAW,CAAA;AAChD,YAAA,MAAMC,QAAWC,GAAAA,OAAAA,CAAQC,qBAAqB,CAACR,cAAc,IAAO,GAAA,IAAA;YAEpE,OAAO;AACL,gBAAA;oBACEX,IAAM,EAAA,KAAA;AACNoB,oBAAAA,IAAAA,EAAM,CAAC,EAAEN,QAAAA,CAAS,mBAAmB,EAAEG,SAAS,CAAC;oBACjDI,YAAc,EAAA,CAAC,UAAU,EAAEJ,QAAAA,CAAS,QAAQ,EAAEA,QAAAA,CAAS,IAAI;AAC7D;AACD,aAAA;AACH;AACF,KAAA,CAAA;AACF,CAAA;;;;"}

View File

@@ -0,0 +1,40 @@
import tsUtils from '@strapi/typescript-utils';
import getDestinationPrompts from './prompts/get-destination-prompts.mjs';
import validateInput from './utils/validate-input.mjs';
import getFilePath from './utils/get-file-path.mjs';
var generatePolicy = ((plop)=>{
// Policy generator
plop.setGenerator('policy', {
description: 'Generate a policy for an API',
prompts: [
{
type: 'input',
name: 'id',
message: 'Policy name',
validate: (input)=>validateInput(input)
},
...getDestinationPrompts('policy', plop.getDestBasePath(), {
rootFolder: true
})
],
actions (answers) {
if (!answers) {
return [];
}
const currentDir = process.cwd();
const filePath = getFilePath(answers.destination);
const language = tsUtils.isUsingTypeScriptSync(currentDir) ? 'ts' : 'js';
return [
{
type: 'add',
path: `${filePath}/policies/{{ id }}.${language}`,
templateFile: `templates/${language}/policy.${language}.hbs`
}
];
}
});
});
export { generatePolicy as default };
//# sourceMappingURL=policy.mjs.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"policy.mjs","sources":["../../src/plops/policy.ts"],"sourcesContent":["import type { NodePlopAPI } from 'plop';\nimport tsUtils from '@strapi/typescript-utils';\n\nimport getDestinationPrompts from './prompts/get-destination-prompts';\nimport validateInput from './utils/validate-input';\nimport getFilePath from './utils/get-file-path';\n\nexport default (plop: NodePlopAPI) => {\n // Policy generator\n plop.setGenerator('policy', {\n description: 'Generate a policy for an API',\n prompts: [\n {\n type: 'input',\n name: 'id',\n message: 'Policy name',\n validate: (input) => validateInput(input),\n },\n ...getDestinationPrompts('policy', plop.getDestBasePath(), { rootFolder: true }),\n ],\n actions(answers) {\n if (!answers) {\n return [];\n }\n\n const currentDir = process.cwd();\n const filePath = getFilePath(answers.destination);\n const language = tsUtils.isUsingTypeScriptSync(currentDir) ? 'ts' : 'js';\n\n return [\n {\n type: 'add',\n path: `${filePath}/policies/{{ id }}.${language}`,\n templateFile: `templates/${language}/policy.${language}.hbs`,\n },\n ];\n },\n });\n};\n"],"names":["plop","setGenerator","description","prompts","type","name","message","validate","input","validateInput","getDestinationPrompts","getDestBasePath","rootFolder","actions","answers","currentDir","process","cwd","filePath","getFilePath","destination","language","tsUtils","isUsingTypeScriptSync","path","templateFile"],"mappings":";;;;;AAOA,qBAAe,CAAA,CAACA,IAAAA,GAAAA;;IAEdA,IAAKC,CAAAA,YAAY,CAAC,QAAU,EAAA;QAC1BC,WAAa,EAAA,8BAAA;QACbC,OAAS,EAAA;AACP,YAAA;gBACEC,IAAM,EAAA,OAAA;gBACNC,IAAM,EAAA,IAAA;gBACNC,OAAS,EAAA,aAAA;gBACTC,QAAU,EAAA,CAACC,QAAUC,aAAcD,CAAAA,KAAAA;AACrC,aAAA;eACGE,qBAAsB,CAAA,QAAA,EAAUV,IAAKW,CAAAA,eAAe,EAAI,EAAA;gBAAEC,UAAY,EAAA;AAAK,aAAA;AAC/E,SAAA;AACDC,QAAAA,OAAAA,CAAAA,CAAQC,OAAO,EAAA;AACb,YAAA,IAAI,CAACA,OAAS,EAAA;AACZ,gBAAA,OAAO,EAAE;AACX;YAEA,MAAMC,UAAAA,GAAaC,QAAQC,GAAG,EAAA;YAC9B,MAAMC,QAAAA,GAAWC,WAAYL,CAAAA,OAAAA,CAAQM,WAAW,CAAA;AAChD,YAAA,MAAMC,QAAWC,GAAAA,OAAAA,CAAQC,qBAAqB,CAACR,cAAc,IAAO,GAAA,IAAA;YAEpE,OAAO;AACL,gBAAA;oBACEX,IAAM,EAAA,KAAA;AACNoB,oBAAAA,IAAAA,EAAM,CAAC,EAAEN,QAAAA,CAAS,mBAAmB,EAAEG,SAAS,CAAC;oBACjDI,YAAc,EAAA,CAAC,UAAU,EAAEJ,QAAAA,CAAS,QAAQ,EAAEA,QAAAA,CAAS,IAAI;AAC7D;AACD,aAAA;AACH;AACF,KAAA,CAAA;AACF,CAAA;;;;"}

View File

@@ -0,0 +1,4 @@
import type { PromptQuestion } from 'node-plop';
declare const questions: Array<PromptQuestion>;
export default questions;
//# sourceMappingURL=bootstrap-api-prompts.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"bootstrap-api-prompts.d.ts","sourceRoot":"","sources":["../../../src/plops/prompts/bootstrap-api-prompts.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAEhD,QAAA,MAAM,SAAS,EAAE,KAAK,CAAC,cAAc,CAOpC,CAAC;AAEF,eAAe,SAAS,CAAC"}

View File

@@ -0,0 +1,13 @@
'use strict';
const questions = [
{
type: 'confirm',
name: 'bootstrapApi',
default: true,
message: 'Bootstrap API related files?'
}
];
module.exports = questions;
//# sourceMappingURL=bootstrap-api-prompts.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"bootstrap-api-prompts.js","sources":["../../../src/plops/prompts/bootstrap-api-prompts.ts"],"sourcesContent":["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"],"names":["questions","type","name","default","message"],"mappings":";;AAEA,MAAMA,SAAmC,GAAA;AACvC,IAAA;QACEC,IAAM,EAAA,SAAA;QACNC,IAAM,EAAA,cAAA;QACNC,OAAS,EAAA,IAAA;QACTC,OAAS,EAAA;AACX;AACD;;;;"}

View File

@@ -0,0 +1,11 @@
const questions = [
{
type: 'confirm',
name: 'bootstrapApi',
default: true,
message: 'Bootstrap API related files?'
}
];
export { questions as default };
//# sourceMappingURL=bootstrap-api-prompts.mjs.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"bootstrap-api-prompts.mjs","sources":["../../../src/plops/prompts/bootstrap-api-prompts.ts"],"sourcesContent":["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"],"names":["questions","type","name","default","message"],"mappings":"AAEA,MAAMA,SAAmC,GAAA;AACvC,IAAA;QACEC,IAAM,EAAA,SAAA;QACNC,IAAM,EAAA,cAAA;QACNC,OAAS,EAAA,IAAA;QACTC,OAAS,EAAA;AACX;AACD;;;;"}

View File

@@ -0,0 +1,4 @@
import type { PromptQuestion } from 'node-plop';
declare const questions: Array<PromptQuestion>;
export default questions;
//# sourceMappingURL=ct-names-prompts.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"ct-names-prompts.d.ts","sourceRoot":"","sources":["../../../src/plops/prompts/ct-names-prompts.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAQhD,QAAA,MAAM,SAAS,EAAE,KAAK,CAAC,cAAc,CAqCpC,CAAC;AAEF,eAAe,SAAS,CAAC"}

View File

@@ -0,0 +1,44 @@
'use strict';
var pluralize = require('pluralize');
var slugify = require('@sindresorhus/slugify');
var utils = require('@strapi/utils');
const questions = [
{
type: 'input',
name: 'displayName',
message: 'Content type display name',
validate: (input)=>!!input
},
{
type: 'input',
name: 'singularName',
message: 'Content type singular name',
default: (answers)=>slugify(answers.displayName),
validate (input) {
if (!utils.strings.isKebabCase(input)) {
return 'Value must be in kebab-case';
}
return true;
}
},
{
type: 'input',
name: 'pluralName',
message: 'Content type plural name',
default: (answers)=>pluralize(answers.singularName),
validate (input, answers) {
if (answers.singularName === input) {
return 'Singular and plural names cannot be the same';
}
if (!utils.strings.isKebabCase(input)) {
return 'Value must be in kebab-case';
}
return true;
}
}
];
module.exports = questions;
//# sourceMappingURL=ct-names-prompts.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"ct-names-prompts.js","sources":["../../../src/plops/prompts/ct-names-prompts.ts"],"sourcesContent":["import pluralize from 'pluralize';\nimport slugify from '@sindresorhus/slugify';\nimport { strings } from '@strapi/utils';\n\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"],"names":["questions","type","name","message","validate","input","default","answers","slugify","displayName","strings","isKebabCase","pluralize","singularName"],"mappings":";;;;;;AAYA,MAAMA,SAAmC,GAAA;AACvC,IAAA;QACEC,IAAM,EAAA,OAAA;QACNC,IAAM,EAAA,aAAA;QACNC,OAAS,EAAA,2BAAA;QACTC,QAAU,EAAA,CAACC,KAAkB,GAAA,CAAC,CAACA;AACjC,KAAA;AACA,IAAA;QACEJ,IAAM,EAAA,OAAA;QACNC,IAAM,EAAA,cAAA;QACNC,OAAS,EAAA,4BAAA;AACTG,QAAAA,OAAAA,EAAS,CAACC,OAAAA,GAAqBC,OAAQD,CAAAA,OAAAA,CAAQE,WAAW,CAAA;AAC1DL,QAAAA,QAAAA,CAAAA,CAASC,KAAK,EAAA;AACZ,YAAA,IAAI,CAACK,aAAAA,CAAQC,WAAW,CAACN,KAAQ,CAAA,EAAA;gBAC/B,OAAO,6BAAA;AACT;YAEA,OAAO,IAAA;AACT;AACF,KAAA;AACA,IAAA;QACEJ,IAAM,EAAA,OAAA;QACNC,IAAM,EAAA,YAAA;QACNC,OAAS,EAAA,0BAAA;AACTG,QAAAA,OAAAA,EAAS,CAACC,OAAAA,GAAqBK,SAAUL,CAAAA,OAAAA,CAAQM,YAAY,CAAA;QAC7DT,QAASC,CAAAA,CAAAA,KAAa,EAAEE,OAAgB,EAAA;YACtC,IAAIA,OAAAA,CAAQM,YAAY,KAAKR,KAAO,EAAA;gBAClC,OAAO,8CAAA;AACT;AAEA,YAAA,IAAI,CAACK,aAAAA,CAAQC,WAAW,CAACN,KAAQ,CAAA,EAAA;gBAC/B,OAAO,6BAAA;AACT;YAEA,OAAO,IAAA;AACT;AACF;AACD;;;;"}

View File

@@ -0,0 +1,42 @@
import pluralize from 'pluralize';
import slugify from '@sindresorhus/slugify';
import { strings } from '@strapi/utils';
const questions = [
{
type: 'input',
name: 'displayName',
message: 'Content type display name',
validate: (input)=>!!input
},
{
type: 'input',
name: 'singularName',
message: 'Content type singular name',
default: (answers)=>slugify(answers.displayName),
validate (input) {
if (!strings.isKebabCase(input)) {
return 'Value must be in kebab-case';
}
return true;
}
},
{
type: 'input',
name: 'pluralName',
message: 'Content type plural name',
default: (answers)=>pluralize(answers.singularName),
validate (input, answers) {
if (answers.singularName === input) {
return 'Singular and plural names cannot be the same';
}
if (!strings.isKebabCase(input)) {
return 'Value must be in kebab-case';
}
return true;
}
}
];
export { questions as default };
//# sourceMappingURL=ct-names-prompts.mjs.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"ct-names-prompts.mjs","sources":["../../../src/plops/prompts/ct-names-prompts.ts"],"sourcesContent":["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"],"names":["questions","type","name","message","validate","input","default","answers","slugify","displayName","strings","isKebabCase","pluralize","singularName"],"mappings":";;;;AAYA,MAAMA,SAAmC,GAAA;AACvC,IAAA;QACEC,IAAM,EAAA,OAAA;QACNC,IAAM,EAAA,aAAA;QACNC,OAAS,EAAA,2BAAA;QACTC,QAAU,EAAA,CAACC,KAAkB,GAAA,CAAC,CAACA;AACjC,KAAA;AACA,IAAA;QACEJ,IAAM,EAAA,OAAA;QACNC,IAAM,EAAA,cAAA;QACNC,OAAS,EAAA,4BAAA;AACTG,QAAAA,OAAAA,EAAS,CAACC,OAAAA,GAAqBC,OAAQD,CAAAA,OAAAA,CAAQE,WAAW,CAAA;AAC1DL,QAAAA,QAAAA,CAAAA,CAASC,KAAK,EAAA;AACZ,YAAA,IAAI,CAACK,OAAAA,CAAQC,WAAW,CAACN,KAAQ,CAAA,EAAA;gBAC/B,OAAO,6BAAA;AACT;YAEA,OAAO,IAAA;AACT;AACF,KAAA;AACA,IAAA;QACEJ,IAAM,EAAA,OAAA;QACNC,IAAM,EAAA,YAAA;QACNC,OAAS,EAAA,0BAAA;AACTG,QAAAA,OAAAA,EAAS,CAACC,OAAAA,GAAqBK,SAAUL,CAAAA,OAAAA,CAAQM,YAAY,CAAA;QAC7DT,QAASC,CAAAA,CAAAA,KAAa,EAAEE,OAAgB,EAAA;YACtC,IAAIA,OAAAA,CAAQM,YAAY,KAAKR,KAAO,EAAA;gBAClC,OAAO,8CAAA;AACT;AAEA,YAAA,IAAI,CAACK,OAAAA,CAAQC,WAAW,CAACN,KAAQ,CAAA,EAAA;gBAC/B,OAAO,6BAAA;AACT;YAEA,OAAO,IAAA;AACT;AACF;AACD;;;;"}

View File

@@ -0,0 +1,4 @@
import type { DynamicPromptsFunction } from 'node-plop';
declare const getAttributesPrompts: DynamicPromptsFunction;
export default getAttributesPrompts;
//# sourceMappingURL=get-attributes-prompts.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"get-attributes-prompts.d.ts","sourceRoot":"","sources":["../../../src/plops/prompts/get-attributes-prompts.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,WAAW,CAAC;AAkCxD,QAAA,MAAM,oBAAoB,EAAE,sBAyE3B,CAAC;AAEF,eAAe,oBAAoB,CAAC"}

View File

@@ -0,0 +1,101 @@
'use strict';
var validateAttributeInput = require('../utils/validate-attribute-input.js');
const DEFAULT_TYPES = [
// advanced types
'media',
// scalar types
'string',
'text',
'richtext',
'json',
'enumeration',
'password',
'email',
'integer',
'biginteger',
'float',
'decimal',
'date',
'time',
'datetime',
'timestamp',
'boolean'
];
const getAttributesPrompts = async (inquirer)=>{
const { addAttributes } = await inquirer.prompt([
{
type: 'confirm',
name: 'addAttributes',
message: 'Do you want to add attributes?'
}
]);
const attributes = [];
/**
* @param {import('inquirer').Inquirer} inquirer
* @returns {Promise<void>}
*/ const createNewAttributes = async (inquirer)=>{
const answers = await inquirer.prompt([
{
type: 'input',
name: 'attributeName',
message: 'Name of attribute',
validate: (input)=>validateAttributeInput(input)
},
{
type: 'list',
name: 'attributeType',
message: 'What type of attribute',
pageSize: DEFAULT_TYPES.length,
choices: DEFAULT_TYPES.map((type)=>{
return {
name: type,
value: type
};
})
},
{
when: (answers)=>answers.attributeType === 'enumeration',
type: 'input',
name: 'enum',
message: 'Add values separated by a comma'
},
{
when: (answers)=>answers.attributeType === 'media',
type: 'list',
name: 'multiple',
message: 'Choose media type',
choices: [
{
name: 'Multiple',
value: true
},
{
name: 'Single',
value: false
}
]
},
{
type: 'confirm',
name: 'addAttributes',
message: 'Do you want to add another attribute?'
}
]);
attributes.push(answers);
if (!answers.addAttributes) {
return;
}
await createNewAttributes(inquirer);
};
if (addAttributes) {
await createNewAttributes(inquirer);
} else {
console.warn(`You won't be able to manage entries from the admin, you can still add attributes later from the content type builder.`);
}
return attributes;
};
module.exports = getAttributesPrompts;
//# sourceMappingURL=get-attributes-prompts.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"get-attributes-prompts.js","sources":["../../../src/plops/prompts/get-attributes-prompts.ts"],"sourcesContent":["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"],"names":["DEFAULT_TYPES","getAttributesPrompts","inquirer","addAttributes","prompt","type","name","message","attributes","createNewAttributes","answers","validate","input","validateAttributeInput","pageSize","length","choices","map","value","when","attributeType","push","console","warn"],"mappings":";;;;AAWA,MAAMA,aAAgB,GAAA;;AAEpB,IAAA,OAAA;;AAGA,IAAA,QAAA;AACA,IAAA,MAAA;AACA,IAAA,UAAA;AACA,IAAA,MAAA;AACA,IAAA,aAAA;AACA,IAAA,UAAA;AACA,IAAA,OAAA;AACA,IAAA,SAAA;AACA,IAAA,YAAA;AACA,IAAA,OAAA;AACA,IAAA,SAAA;AACA,IAAA,MAAA;AACA,IAAA,MAAA;AACA,IAAA,UAAA;AACA,IAAA,WAAA;AACA,IAAA;AACD,CAAA;AAED,MAAMC,uBAA+C,OAAOC,QAAAA,GAAAA;AAC1D,IAAA,MAAM,EAAEC,aAAa,EAAE,GAAG,MAAMD,QAAAA,CAASE,MAAM,CAAC;AAC9C,QAAA;YACEC,IAAM,EAAA,SAAA;YACNC,IAAM,EAAA,eAAA;YACNC,OAAS,EAAA;AACX;AACD,KAAA,CAAA;AAED,IAAA,MAAMC,aAAqC,EAAE;AAE7C;;;MAIA,MAAMC,sBAAsB,OAAOP,QAAAA,GAAAA;AACjC,QAAA,MAAMQ,OAAU,GAAA,MAAMR,QAASE,CAAAA,MAAM,CAAC;AACpC,YAAA;gBACEC,IAAM,EAAA,OAAA;gBACNC,IAAM,EAAA,eAAA;gBACNC,OAAS,EAAA,mBAAA;gBACTI,QAAU,EAAA,CAACC,QAAkBC,sBAAuBD,CAAAA,KAAAA;AACtD,aAAA;AACA,YAAA;gBACEP,IAAM,EAAA,MAAA;gBACNC,IAAM,EAAA,eAAA;gBACNC,OAAS,EAAA,wBAAA;AACTO,gBAAAA,QAAAA,EAAUd,cAAce,MAAM;gBAC9BC,OAAShB,EAAAA,aAAAA,CAAciB,GAAG,CAAC,CAACZ,IAAAA,GAAAA;oBAC1B,OAAO;wBAAEC,IAAMD,EAAAA,IAAAA;wBAAMa,KAAOb,EAAAA;AAAK,qBAAA;AACnC,iBAAA;AACF,aAAA;AACA,YAAA;AACEc,gBAAAA,IAAAA,EAAM,CAACT,OAAAA,GAAYA,OAAQU,CAAAA,aAAa,KAAK,aAAA;gBAC7Cf,IAAM,EAAA,OAAA;gBACNC,IAAM,EAAA,MAAA;gBACNC,OAAS,EAAA;AACX,aAAA;AACA,YAAA;AACEY,gBAAAA,IAAAA,EAAM,CAACT,OAAAA,GAAYA,OAAQU,CAAAA,aAAa,KAAK,OAAA;gBAC7Cf,IAAM,EAAA,MAAA;gBACNC,IAAM,EAAA,UAAA;gBACNC,OAAS,EAAA,mBAAA;gBACTS,OAAS,EAAA;AACP,oBAAA;wBAAEV,IAAM,EAAA,UAAA;wBAAYY,KAAO,EAAA;AAAK,qBAAA;AAChC,oBAAA;wBAAEZ,IAAM,EAAA,QAAA;wBAAUY,KAAO,EAAA;AAAM;AAChC;AACH,aAAA;AACA,YAAA;gBACEb,IAAM,EAAA,SAAA;gBACNC,IAAM,EAAA,eAAA;gBACNC,OAAS,EAAA;AACX;AACD,SAAA,CAAA;AAEDC,QAAAA,UAAAA,CAAWa,IAAI,CAACX,OAAAA,CAAAA;QAEhB,IAAI,CAACA,OAAQP,CAAAA,aAAa,EAAE;AAC1B,YAAA;AACF;AAEA,QAAA,MAAMM,mBAAoBP,CAAAA,QAAAA,CAAAA;AAC5B,KAAA;AAEA,IAAA,IAAIC,aAAe,EAAA;AACjB,QAAA,MAAMM,mBAAoBP,CAAAA,QAAAA,CAAAA;KACrB,MAAA;AACLoB,QAAAA,OAAAA,CAAQC,IAAI,CACV,CAAC,qHAAqH,CAAC,CAAA;AAE3H;IAEA,OAAOf,UAAAA;AACT;;;;"}

View File

@@ -0,0 +1,99 @@
import validateAttributeInput from '../utils/validate-attribute-input.mjs';
const DEFAULT_TYPES = [
// advanced types
'media',
// scalar types
'string',
'text',
'richtext',
'json',
'enumeration',
'password',
'email',
'integer',
'biginteger',
'float',
'decimal',
'date',
'time',
'datetime',
'timestamp',
'boolean'
];
const getAttributesPrompts = async (inquirer)=>{
const { addAttributes } = await inquirer.prompt([
{
type: 'confirm',
name: 'addAttributes',
message: 'Do you want to add attributes?'
}
]);
const attributes = [];
/**
* @param {import('inquirer').Inquirer} inquirer
* @returns {Promise<void>}
*/ const createNewAttributes = async (inquirer)=>{
const answers = await inquirer.prompt([
{
type: 'input',
name: 'attributeName',
message: 'Name of attribute',
validate: (input)=>validateAttributeInput(input)
},
{
type: 'list',
name: 'attributeType',
message: 'What type of attribute',
pageSize: DEFAULT_TYPES.length,
choices: DEFAULT_TYPES.map((type)=>{
return {
name: type,
value: type
};
})
},
{
when: (answers)=>answers.attributeType === 'enumeration',
type: 'input',
name: 'enum',
message: 'Add values separated by a comma'
},
{
when: (answers)=>answers.attributeType === 'media',
type: 'list',
name: 'multiple',
message: 'Choose media type',
choices: [
{
name: 'Multiple',
value: true
},
{
name: 'Single',
value: false
}
]
},
{
type: 'confirm',
name: 'addAttributes',
message: 'Do you want to add another attribute?'
}
]);
attributes.push(answers);
if (!answers.addAttributes) {
return;
}
await createNewAttributes(inquirer);
};
if (addAttributes) {
await createNewAttributes(inquirer);
} else {
console.warn(`You won't be able to manage entries from the admin, you can still add attributes later from the content type builder.`);
}
return attributes;
};
export { getAttributesPrompts as default };
//# sourceMappingURL=get-attributes-prompts.mjs.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"get-attributes-prompts.mjs","sources":["../../../src/plops/prompts/get-attributes-prompts.ts"],"sourcesContent":["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"],"names":["DEFAULT_TYPES","getAttributesPrompts","inquirer","addAttributes","prompt","type","name","message","attributes","createNewAttributes","answers","validate","input","validateAttributeInput","pageSize","length","choices","map","value","when","attributeType","push","console","warn"],"mappings":";;AAWA,MAAMA,aAAgB,GAAA;;AAEpB,IAAA,OAAA;;AAGA,IAAA,QAAA;AACA,IAAA,MAAA;AACA,IAAA,UAAA;AACA,IAAA,MAAA;AACA,IAAA,aAAA;AACA,IAAA,UAAA;AACA,IAAA,OAAA;AACA,IAAA,SAAA;AACA,IAAA,YAAA;AACA,IAAA,OAAA;AACA,IAAA,SAAA;AACA,IAAA,MAAA;AACA,IAAA,MAAA;AACA,IAAA,UAAA;AACA,IAAA,WAAA;AACA,IAAA;AACD,CAAA;AAED,MAAMC,uBAA+C,OAAOC,QAAAA,GAAAA;AAC1D,IAAA,MAAM,EAAEC,aAAa,EAAE,GAAG,MAAMD,QAAAA,CAASE,MAAM,CAAC;AAC9C,QAAA;YACEC,IAAM,EAAA,SAAA;YACNC,IAAM,EAAA,eAAA;YACNC,OAAS,EAAA;AACX;AACD,KAAA,CAAA;AAED,IAAA,MAAMC,aAAqC,EAAE;AAE7C;;;MAIA,MAAMC,sBAAsB,OAAOP,QAAAA,GAAAA;AACjC,QAAA,MAAMQ,OAAU,GAAA,MAAMR,QAASE,CAAAA,MAAM,CAAC;AACpC,YAAA;gBACEC,IAAM,EAAA,OAAA;gBACNC,IAAM,EAAA,eAAA;gBACNC,OAAS,EAAA,mBAAA;gBACTI,QAAU,EAAA,CAACC,QAAkBC,sBAAuBD,CAAAA,KAAAA;AACtD,aAAA;AACA,YAAA;gBACEP,IAAM,EAAA,MAAA;gBACNC,IAAM,EAAA,eAAA;gBACNC,OAAS,EAAA,wBAAA;AACTO,gBAAAA,QAAAA,EAAUd,cAAce,MAAM;gBAC9BC,OAAShB,EAAAA,aAAAA,CAAciB,GAAG,CAAC,CAACZ,IAAAA,GAAAA;oBAC1B,OAAO;wBAAEC,IAAMD,EAAAA,IAAAA;wBAAMa,KAAOb,EAAAA;AAAK,qBAAA;AACnC,iBAAA;AACF,aAAA;AACA,YAAA;AACEc,gBAAAA,IAAAA,EAAM,CAACT,OAAAA,GAAYA,OAAQU,CAAAA,aAAa,KAAK,aAAA;gBAC7Cf,IAAM,EAAA,OAAA;gBACNC,IAAM,EAAA,MAAA;gBACNC,OAAS,EAAA;AACX,aAAA;AACA,YAAA;AACEY,gBAAAA,IAAAA,EAAM,CAACT,OAAAA,GAAYA,OAAQU,CAAAA,aAAa,KAAK,OAAA;gBAC7Cf,IAAM,EAAA,MAAA;gBACNC,IAAM,EAAA,UAAA;gBACNC,OAAS,EAAA,mBAAA;gBACTS,OAAS,EAAA;AACP,oBAAA;wBAAEV,IAAM,EAAA,UAAA;wBAAYY,KAAO,EAAA;AAAK,qBAAA;AAChC,oBAAA;wBAAEZ,IAAM,EAAA,QAAA;wBAAUY,KAAO,EAAA;AAAM;AAChC;AACH,aAAA;AACA,YAAA;gBACEb,IAAM,EAAA,SAAA;gBACNC,IAAM,EAAA,eAAA;gBACNC,OAAS,EAAA;AACX;AACD,SAAA,CAAA;AAEDC,QAAAA,UAAAA,CAAWa,IAAI,CAACX,OAAAA,CAAAA;QAEhB,IAAI,CAACA,OAAQP,CAAAA,aAAa,EAAE;AAC1B,YAAA;AACF;AAEA,QAAA,MAAMM,mBAAoBP,CAAAA,QAAAA,CAAAA;AAC5B,KAAA;AAEA,IAAA,IAAIC,aAAe,EAAA;AACjB,QAAA,MAAMM,mBAAoBP,CAAAA,QAAAA,CAAAA;KACrB,MAAA;AACLoB,QAAAA,OAAAA,CAAQC,IAAI,CACV,CAAC,qHAAqH,CAAC,CAAA;AAE3H;IAEA,OAAOf,UAAAA;AACT;;;;"}

View File

@@ -0,0 +1,6 @@
import type { PromptQuestion } from 'node-plop';
declare const _default: (action: string, basePath: string, { rootFolder }?: {
rootFolder?: boolean | undefined;
}) => Array<PromptQuestion>;
export default _default;
//# sourceMappingURL=get-destination-prompts.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"get-destination-prompts.d.ts","sourceRoot":"","sources":["../../../src/plops/prompts/get-destination-prompts.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;iCAGtC,MAAM,YACJ,MAAM;;MAEf,MAAM,cAAc,CAAC;AAJxB,wBA6EE"}

View File

@@ -0,0 +1,78 @@
'use strict';
var path = require('path');
var fs = require('fs-extra');
var getDestinationPrompts = ((action, basePath, { rootFolder = false } = {})=>{
return [
{
type: 'list',
name: 'destination',
message: `Where do you want to add this ${action}?`,
choices: [
...rootFolder ? [
{
name: `Add ${action} to root of project`,
value: 'root'
}
] : [
{
name: `Add ${action} to new API`,
value: 'new'
}
],
{
name: `Add ${action} to an existing API`,
value: 'api'
},
{
name: `Add ${action} to an existing plugin`,
value: 'plugin'
}
]
},
{
when: (answers)=>answers.destination === 'api',
type: 'list',
message: 'Which API is this for?',
name: 'api',
async choices () {
const apiPath = path.join(basePath, 'api');
const exists = await fs.pathExists(apiPath);
if (!exists) {
throw Error('Couldn\'t find an "api" directory');
}
const apiDir = await fs.readdir(apiPath, {
withFileTypes: true
});
const apiDirContent = apiDir.filter((fd)=>fd.isDirectory());
if (apiDirContent.length === 0) {
throw Error('The "api" directory is empty');
}
return apiDirContent;
}
},
{
when: (answers)=>answers.destination === 'plugin',
type: 'list',
message: 'Which plugin is this for?',
name: 'plugin',
async choices () {
const pluginsPath = path.join(basePath, 'plugins');
const exists = await fs.pathExists(pluginsPath);
if (!exists) {
throw Error('Couldn\'t find a "plugins" directory');
}
const pluginsDir = await fs.readdir(pluginsPath);
const pluginsDirContent = pluginsDir.filter((api)=>fs.lstatSync(path.join(pluginsPath, api)).isDirectory());
if (pluginsDirContent.length === 0) {
throw Error('The "plugins" directory is empty');
}
return pluginsDirContent;
}
}
];
});
module.exports = getDestinationPrompts;
//# sourceMappingURL=get-destination-prompts.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"get-destination-prompts.js","sources":["../../../src/plops/prompts/get-destination-prompts.ts"],"sourcesContent":["import { join } from 'path';\nimport fs from 'fs-extra';\n\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"],"names":["action","basePath","rootFolder","type","name","message","choices","value","when","answers","destination","apiPath","join","exists","fs","pathExists","Error","apiDir","readdir","withFileTypes","apiDirContent","filter","fd","isDirectory","length","pluginsPath","pluginsDir","pluginsDirContent","api","lstatSync"],"mappings":";;;;;AAKA,4BAAe,CAAA,CACbA,MAAAA,EACAC,QACA,EAAA,EAAEC,aAAa,KAAK,EAAE,GAAG,EAAE,GAAA;IAE3B,OAAO;AACL,QAAA;YACEC,IAAM,EAAA,MAAA;YACNC,IAAM,EAAA,aAAA;AACNC,YAAAA,OAAAA,EAAS,CAAC,8BAA8B,EAAEL,MAAAA,CAAO,CAAC,CAAC;YACnDM,OAAS,EAAA;mBACHJ,UACA,GAAA;AACE,oBAAA;AACEE,wBAAAA,IAAAA,EAAM,CAAC,IAAI,EAAEJ,MAAAA,CAAO,mBAAmB,CAAC;wBACxCO,KAAO,EAAA;AACT;iBACD,GACD;AACE,oBAAA;AACEH,wBAAAA,IAAAA,EAAM,CAAC,IAAI,EAAEJ,MAAAA,CAAO,WAAW,CAAC;wBAChCO,KAAO,EAAA;AACT;AACD,iBAAA;AACL,gBAAA;AAAEH,oBAAAA,IAAAA,EAAM,CAAC,IAAI,EAAEJ,MAAAA,CAAO,mBAAmB,CAAC;oBAAEO,KAAO,EAAA;AAAM,iBAAA;AACzD,gBAAA;AAAEH,oBAAAA,IAAAA,EAAM,CAAC,IAAI,EAAEJ,MAAAA,CAAO,sBAAsB,CAAC;oBAAEO,KAAO,EAAA;AAAS;AAChE;AACH,SAAA;AACA,QAAA;AACEC,YAAAA,IAAAA,EAAM,CAACC,OAAAA,GAAYA,OAAQC,CAAAA,WAAW,KAAK,KAAA;YAC3CP,IAAM,EAAA,MAAA;YACNE,OAAS,EAAA,wBAAA;YACTD,IAAM,EAAA,KAAA;YACN,MAAME,OAAAA,CAAAA,GAAAA;gBACJ,MAAMK,OAAAA,GAAUC,UAAKX,QAAU,EAAA,KAAA,CAAA;AAC/B,gBAAA,MAAMY,MAAS,GAAA,MAAMC,EAAGC,CAAAA,UAAU,CAACJ,OAAAA,CAAAA;AAEnC,gBAAA,IAAI,CAACE,MAAQ,EAAA;AACX,oBAAA,MAAMG,KAAM,CAAA,mCAAA,CAAA;AACd;AAEA,gBAAA,MAAMC,MAAS,GAAA,MAAMH,EAAGI,CAAAA,OAAO,CAACP,OAAS,EAAA;oBAAEQ,aAAe,EAAA;AAAK,iBAAA,CAAA;AAC/D,gBAAA,MAAMC,gBAAgBH,MAAOI,CAAAA,MAAM,CAAC,CAACC,EAAAA,GAAOA,GAAGC,WAAW,EAAA,CAAA;gBAE1D,IAAIH,aAAAA,CAAcI,MAAM,KAAK,CAAG,EAAA;AAC9B,oBAAA,MAAMR,KAAM,CAAA,8BAAA,CAAA;AACd;gBAEA,OAAOI,aAAAA;AACT;AACF,SAAA;AACA,QAAA;AACEZ,YAAAA,IAAAA,EAAM,CAACC,OAAAA,GAAYA,OAAQC,CAAAA,WAAW,KAAK,QAAA;YAC3CP,IAAM,EAAA,MAAA;YACNE,OAAS,EAAA,2BAAA;YACTD,IAAM,EAAA,QAAA;YACN,MAAME,OAAAA,CAAAA,GAAAA;gBACJ,MAAMmB,WAAAA,GAAcb,UAAKX,QAAU,EAAA,SAAA,CAAA;AACnC,gBAAA,MAAMY,MAAS,GAAA,MAAMC,EAAGC,CAAAA,UAAU,CAACU,WAAAA,CAAAA;AAEnC,gBAAA,IAAI,CAACZ,MAAQ,EAAA;AACX,oBAAA,MAAMG,KAAM,CAAA,sCAAA,CAAA;AACd;AAEA,gBAAA,MAAMU,UAAa,GAAA,MAAMZ,EAAGI,CAAAA,OAAO,CAACO,WAAAA,CAAAA;AACpC,gBAAA,MAAME,iBAAoBD,GAAAA,UAAAA,CAAWL,MAAM,CAAC,CAACO,GAAAA,GAC3Cd,EAAGe,CAAAA,SAAS,CAACjB,SAAAA,CAAKa,WAAaG,EAAAA,GAAAA,CAAAA,CAAAA,CAAML,WAAW,EAAA,CAAA;gBAGlD,IAAII,iBAAAA,CAAkBH,MAAM,KAAK,CAAG,EAAA;AAClC,oBAAA,MAAMR,KAAM,CAAA,kCAAA,CAAA;AACd;gBAEA,OAAOW,iBAAAA;AACT;AACF;AACD,KAAA;AACH,CAAA;;;;"}

View File

@@ -0,0 +1,76 @@
import { join } from 'path';
import fs from 'fs-extra';
var getDestinationPrompts = ((action, basePath, { rootFolder = false } = {})=>{
return [
{
type: 'list',
name: 'destination',
message: `Where do you want to add this ${action}?`,
choices: [
...rootFolder ? [
{
name: `Add ${action} to root of project`,
value: 'root'
}
] : [
{
name: `Add ${action} to new API`,
value: 'new'
}
],
{
name: `Add ${action} to an existing API`,
value: 'api'
},
{
name: `Add ${action} to an existing plugin`,
value: 'plugin'
}
]
},
{
when: (answers)=>answers.destination === 'api',
type: 'list',
message: 'Which API is this for?',
name: 'api',
async choices () {
const apiPath = join(basePath, 'api');
const exists = await fs.pathExists(apiPath);
if (!exists) {
throw Error('Couldn\'t find an "api" directory');
}
const apiDir = await fs.readdir(apiPath, {
withFileTypes: true
});
const apiDirContent = apiDir.filter((fd)=>fd.isDirectory());
if (apiDirContent.length === 0) {
throw Error('The "api" directory is empty');
}
return apiDirContent;
}
},
{
when: (answers)=>answers.destination === 'plugin',
type: 'list',
message: 'Which plugin is this for?',
name: 'plugin',
async choices () {
const pluginsPath = join(basePath, 'plugins');
const exists = await fs.pathExists(pluginsPath);
if (!exists) {
throw Error('Couldn\'t find a "plugins" directory');
}
const pluginsDir = await fs.readdir(pluginsPath);
const pluginsDirContent = pluginsDir.filter((api)=>fs.lstatSync(join(pluginsPath, api)).isDirectory());
if (pluginsDirContent.length === 0) {
throw Error('The "plugins" directory is empty');
}
return pluginsDirContent;
}
}
];
});
export { getDestinationPrompts as default };
//# sourceMappingURL=get-destination-prompts.mjs.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"get-destination-prompts.mjs","sources":["../../../src/plops/prompts/get-destination-prompts.ts"],"sourcesContent":["import { join } from 'path';\nimport fs from 'fs-extra';\n\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"],"names":["action","basePath","rootFolder","type","name","message","choices","value","when","answers","destination","apiPath","join","exists","fs","pathExists","Error","apiDir","readdir","withFileTypes","apiDirContent","filter","fd","isDirectory","length","pluginsPath","pluginsDir","pluginsDirContent","api","lstatSync"],"mappings":";;;AAKA,4BAAe,CAAA,CACbA,MAAAA,EACAC,QACA,EAAA,EAAEC,aAAa,KAAK,EAAE,GAAG,EAAE,GAAA;IAE3B,OAAO;AACL,QAAA;YACEC,IAAM,EAAA,MAAA;YACNC,IAAM,EAAA,aAAA;AACNC,YAAAA,OAAAA,EAAS,CAAC,8BAA8B,EAAEL,MAAAA,CAAO,CAAC,CAAC;YACnDM,OAAS,EAAA;mBACHJ,UACA,GAAA;AACE,oBAAA;AACEE,wBAAAA,IAAAA,EAAM,CAAC,IAAI,EAAEJ,MAAAA,CAAO,mBAAmB,CAAC;wBACxCO,KAAO,EAAA;AACT;iBACD,GACD;AACE,oBAAA;AACEH,wBAAAA,IAAAA,EAAM,CAAC,IAAI,EAAEJ,MAAAA,CAAO,WAAW,CAAC;wBAChCO,KAAO,EAAA;AACT;AACD,iBAAA;AACL,gBAAA;AAAEH,oBAAAA,IAAAA,EAAM,CAAC,IAAI,EAAEJ,MAAAA,CAAO,mBAAmB,CAAC;oBAAEO,KAAO,EAAA;AAAM,iBAAA;AACzD,gBAAA;AAAEH,oBAAAA,IAAAA,EAAM,CAAC,IAAI,EAAEJ,MAAAA,CAAO,sBAAsB,CAAC;oBAAEO,KAAO,EAAA;AAAS;AAChE;AACH,SAAA;AACA,QAAA;AACEC,YAAAA,IAAAA,EAAM,CAACC,OAAAA,GAAYA,OAAQC,CAAAA,WAAW,KAAK,KAAA;YAC3CP,IAAM,EAAA,MAAA;YACNE,OAAS,EAAA,wBAAA;YACTD,IAAM,EAAA,KAAA;YACN,MAAME,OAAAA,CAAAA,GAAAA;gBACJ,MAAMK,OAAAA,GAAUC,KAAKX,QAAU,EAAA,KAAA,CAAA;AAC/B,gBAAA,MAAMY,MAAS,GAAA,MAAMC,EAAGC,CAAAA,UAAU,CAACJ,OAAAA,CAAAA;AAEnC,gBAAA,IAAI,CAACE,MAAQ,EAAA;AACX,oBAAA,MAAMG,KAAM,CAAA,mCAAA,CAAA;AACd;AAEA,gBAAA,MAAMC,MAAS,GAAA,MAAMH,EAAGI,CAAAA,OAAO,CAACP,OAAS,EAAA;oBAAEQ,aAAe,EAAA;AAAK,iBAAA,CAAA;AAC/D,gBAAA,MAAMC,gBAAgBH,MAAOI,CAAAA,MAAM,CAAC,CAACC,EAAAA,GAAOA,GAAGC,WAAW,EAAA,CAAA;gBAE1D,IAAIH,aAAAA,CAAcI,MAAM,KAAK,CAAG,EAAA;AAC9B,oBAAA,MAAMR,KAAM,CAAA,8BAAA,CAAA;AACd;gBAEA,OAAOI,aAAAA;AACT;AACF,SAAA;AACA,QAAA;AACEZ,YAAAA,IAAAA,EAAM,CAACC,OAAAA,GAAYA,OAAQC,CAAAA,WAAW,KAAK,QAAA;YAC3CP,IAAM,EAAA,MAAA;YACNE,OAAS,EAAA,2BAAA;YACTD,IAAM,EAAA,QAAA;YACN,MAAME,OAAAA,CAAAA,GAAAA;gBACJ,MAAMmB,WAAAA,GAAcb,KAAKX,QAAU,EAAA,SAAA,CAAA;AACnC,gBAAA,MAAMY,MAAS,GAAA,MAAMC,EAAGC,CAAAA,UAAU,CAACU,WAAAA,CAAAA;AAEnC,gBAAA,IAAI,CAACZ,MAAQ,EAAA;AACX,oBAAA,MAAMG,KAAM,CAAA,sCAAA,CAAA;AACd;AAEA,gBAAA,MAAMU,UAAa,GAAA,MAAMZ,EAAGI,CAAAA,OAAO,CAACO,WAAAA,CAAAA;AACpC,gBAAA,MAAME,iBAAoBD,GAAAA,UAAAA,CAAWL,MAAM,CAAC,CAACO,GAAAA,GAC3Cd,EAAGe,CAAAA,SAAS,CAACjB,IAAAA,CAAKa,WAAaG,EAAAA,GAAAA,CAAAA,CAAAA,CAAML,WAAW,EAAA,CAAA;gBAGlD,IAAII,iBAAAA,CAAkBH,MAAM,KAAK,CAAG,EAAA;AAClC,oBAAA,MAAMR,KAAM,CAAA,kCAAA,CAAA;AACd;gBAEA,OAAOW,iBAAAA;AACT;AACF;AACD,KAAA;AACH,CAAA;;;;"}

View File

@@ -0,0 +1,4 @@
import type { PromptQuestion } from 'node-plop';
declare const questions: Array<PromptQuestion>;
export default questions;
//# sourceMappingURL=kind-prompts.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"kind-prompts.d.ts","sourceRoot":"","sources":["../../../src/plops/prompts/kind-prompts.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAIhD,QAAA,MAAM,SAAS,EAAE,KAAK,CAAC,cAAc,CAYpC,CAAC;AAEF,eAAe,SAAS,CAAC"}

View File

@@ -0,0 +1,26 @@
'use strict';
var validateInput = require('../utils/validate-input.js');
const questions = [
{
type: 'list',
name: 'kind',
message: 'Please choose the model type',
default: 'collectionType',
choices: [
{
name: 'Collection Type',
value: 'collectionType'
},
{
name: 'Single Type',
value: 'singleType'
}
],
validate: (input)=>validateInput(input)
}
];
module.exports = questions;
//# sourceMappingURL=kind-prompts.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"kind-prompts.js","sources":["../../../src/plops/prompts/kind-prompts.ts"],"sourcesContent":["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"],"names":["questions","type","name","message","default","choices","value","validate","input","validateInput"],"mappings":";;;;AAIA,MAAMA,SAAmC,GAAA;AACvC,IAAA;QACEC,IAAM,EAAA,MAAA;QACNC,IAAM,EAAA,MAAA;QACNC,OAAS,EAAA,8BAAA;QACTC,OAAS,EAAA,gBAAA;QACTC,OAAS,EAAA;AACP,YAAA;gBAAEH,IAAM,EAAA,iBAAA;gBAAmBI,KAAO,EAAA;AAAiB,aAAA;AACnD,YAAA;gBAAEJ,IAAM,EAAA,aAAA;gBAAeI,KAAO,EAAA;AAAa;AAC5C,SAAA;QACDC,QAAU,EAAA,CAACC,QAAkBC,aAAcD,CAAAA,KAAAA;AAC7C;AACD;;;;"}

View File

@@ -0,0 +1,24 @@
import validateInput from '../utils/validate-input.mjs';
const questions = [
{
type: 'list',
name: 'kind',
message: 'Please choose the model type',
default: 'collectionType',
choices: [
{
name: 'Collection Type',
value: 'collectionType'
},
{
name: 'Single Type',
value: 'singleType'
}
],
validate: (input)=>validateInput(input)
}
];
export { questions as default };
//# sourceMappingURL=kind-prompts.mjs.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"kind-prompts.mjs","sources":["../../../src/plops/prompts/kind-prompts.ts"],"sourcesContent":["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"],"names":["questions","type","name","message","default","choices","value","validate","input","validateInput"],"mappings":";;AAIA,MAAMA,SAAmC,GAAA;AACvC,IAAA;QACEC,IAAM,EAAA,MAAA;QACNC,IAAM,EAAA,MAAA;QACNC,OAAS,EAAA,8BAAA;QACTC,OAAS,EAAA,gBAAA;QACTC,OAAS,EAAA;AACP,YAAA;gBAAEH,IAAM,EAAA,iBAAA;gBAAmBI,KAAO,EAAA;AAAiB,aAAA;AACnD,YAAA;gBAAEJ,IAAM,EAAA,aAAA;gBAAeI,KAAO,EAAA;AAAa;AAC5C,SAAA;QACDC,QAAU,EAAA,CAACC,QAAkBC,aAAcD,CAAAA,KAAAA;AAC7C;AACD;;;;"}

View File

@@ -0,0 +1,4 @@
import type { NodePlopAPI } from 'plop';
declare const _default: (plop: NodePlopAPI) => void;
export default _default;
//# sourceMappingURL=service.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../../src/plops/service.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,MAAM,CAAC;+BAMlB,WAAW;AAAjC,wBA8BE"}

View File

@@ -0,0 +1,38 @@
'use strict';
var tsUtils = require('@strapi/typescript-utils');
var getDestinationPrompts = require('./prompts/get-destination-prompts.js');
var getFilePath = require('./utils/get-file-path.js');
var generateService = ((plop)=>{
// Service generator
plop.setGenerator('service', {
description: 'Generate a service for an API',
prompts: [
{
type: 'input',
name: 'id',
message: 'Service name'
},
...getDestinationPrompts('service', plop.getDestBasePath())
],
actions (answers) {
if (!answers) {
return [];
}
const filePath = getFilePath(answers?.destination);
const currentDir = process.cwd();
const language = tsUtils.isUsingTypeScriptSync(currentDir) ? 'ts' : 'js';
return [
{
type: 'add',
path: `${filePath}/services/{{ id }}.${language}`,
templateFile: `templates/${language}/service.${language}.hbs`
}
];
}
});
});
module.exports = generateService;
//# sourceMappingURL=service.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"service.js","sources":["../../src/plops/service.ts"],"sourcesContent":["import type { NodePlopAPI } from 'plop';\nimport tsUtils from '@strapi/typescript-utils';\n\nimport getDestinationPrompts from './prompts/get-destination-prompts';\nimport getFilePath from './utils/get-file-path';\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"],"names":["plop","setGenerator","description","prompts","type","name","message","getDestinationPrompts","getDestBasePath","actions","answers","filePath","getFilePath","destination","currentDir","process","cwd","language","tsUtils","isUsingTypeScriptSync","path","templateFile"],"mappings":";;;;;;AAMA,sBAAe,CAAA,CAACA,IAAAA,GAAAA;;IAEdA,IAAKC,CAAAA,YAAY,CAAC,SAAW,EAAA;QAC3BC,WAAa,EAAA,+BAAA;QACbC,OAAS,EAAA;AACP,YAAA;gBACEC,IAAM,EAAA,OAAA;gBACNC,IAAM,EAAA,IAAA;gBACNC,OAAS,EAAA;AACX,aAAA;eACGC,qBAAsB,CAAA,SAAA,EAAWP,KAAKQ,eAAe,EAAA;AACzD,SAAA;AACDC,QAAAA,OAAAA,CAAAA,CAAQC,OAAO,EAAA;AACb,YAAA,IAAI,CAACA,OAAS,EAAA;AACZ,gBAAA,OAAO,EAAE;AACX;YAEA,MAAMC,QAAAA,GAAWC,YAAYF,OAASG,EAAAA,WAAAA,CAAAA;YACtC,MAAMC,UAAAA,GAAaC,QAAQC,GAAG,EAAA;AAC9B,YAAA,MAAMC,QAAWC,GAAAA,OAAAA,CAAQC,qBAAqB,CAACL,cAAc,IAAO,GAAA,IAAA;YAEpE,OAAO;AACL,gBAAA;oBACEV,IAAM,EAAA,KAAA;AACNgB,oBAAAA,IAAAA,EAAM,CAAC,EAAET,QAAAA,CAAS,mBAAmB,EAAEM,SAAS,CAAC;oBACjDI,YAAc,EAAA,CAAC,UAAU,EAAEJ,QAAAA,CAAS,SAAS,EAAEA,QAAAA,CAAS,IAAI;AAC9D;AACD,aAAA;AACH;AACF,KAAA,CAAA;AACF,CAAA;;;;"}

View File

@@ -0,0 +1,36 @@
import tsUtils from '@strapi/typescript-utils';
import getDestinationPrompts from './prompts/get-destination-prompts.mjs';
import getFilePath from './utils/get-file-path.mjs';
var generateService = ((plop)=>{
// Service generator
plop.setGenerator('service', {
description: 'Generate a service for an API',
prompts: [
{
type: 'input',
name: 'id',
message: 'Service name'
},
...getDestinationPrompts('service', plop.getDestBasePath())
],
actions (answers) {
if (!answers) {
return [];
}
const filePath = getFilePath(answers?.destination);
const currentDir = process.cwd();
const language = tsUtils.isUsingTypeScriptSync(currentDir) ? 'ts' : 'js';
return [
{
type: 'add',
path: `${filePath}/services/{{ id }}.${language}`,
templateFile: `templates/${language}/service.${language}.hbs`
}
];
}
});
});
export { generateService as default };
//# sourceMappingURL=service.mjs.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"service.mjs","sources":["../../src/plops/service.ts"],"sourcesContent":["import type { NodePlopAPI } from 'plop';\nimport tsUtils from '@strapi/typescript-utils';\n\nimport getDestinationPrompts from './prompts/get-destination-prompts';\nimport getFilePath from './utils/get-file-path';\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"],"names":["plop","setGenerator","description","prompts","type","name","message","getDestinationPrompts","getDestBasePath","actions","answers","filePath","getFilePath","destination","currentDir","process","cwd","language","tsUtils","isUsingTypeScriptSync","path","templateFile"],"mappings":";;;;AAMA,sBAAe,CAAA,CAACA,IAAAA,GAAAA;;IAEdA,IAAKC,CAAAA,YAAY,CAAC,SAAW,EAAA;QAC3BC,WAAa,EAAA,+BAAA;QACbC,OAAS,EAAA;AACP,YAAA;gBACEC,IAAM,EAAA,OAAA;gBACNC,IAAM,EAAA,IAAA;gBACNC,OAAS,EAAA;AACX,aAAA;eACGC,qBAAsB,CAAA,SAAA,EAAWP,KAAKQ,eAAe,EAAA;AACzD,SAAA;AACDC,QAAAA,OAAAA,CAAAA,CAAQC,OAAO,EAAA;AACb,YAAA,IAAI,CAACA,OAAS,EAAA;AACZ,gBAAA,OAAO,EAAE;AACX;YAEA,MAAMC,QAAAA,GAAWC,YAAYF,OAASG,EAAAA,WAAAA,CAAAA;YACtC,MAAMC,UAAAA,GAAaC,QAAQC,GAAG,EAAA;AAC9B,YAAA,MAAMC,QAAWC,GAAAA,OAAAA,CAAQC,qBAAqB,CAACL,cAAc,IAAO,GAAA,IAAA;YAEpE,OAAO;AACL,gBAAA;oBACEV,IAAM,EAAA,KAAA;AACNgB,oBAAAA,IAAAA,EAAM,CAAC,EAAET,QAAAA,CAAS,mBAAmB,EAAEM,SAAS,CAAC;oBACjDI,YAAc,EAAA,CAAC,UAAU,EAAEJ,QAAAA,CAAS,SAAS,EAAEA,QAAAA,CAAS,IAAI;AAC9D;AACD,aAAA;AACH;AACF,KAAA,CAAA;AACF,CAAA;;;;"}

View File

@@ -0,0 +1,3 @@
declare const _default: (destination: string) => "plugins/{{ plugin }}/server" | "api/{{ id }}" | "api/{{ api }}" | "./";
export default _default;
//# sourceMappingURL=get-file-path.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"get-file-path.d.ts","sourceRoot":"","sources":["../../../src/plops/utils/get-file-path.ts"],"names":[],"mappings":"sCAA6B,MAAM;AAAnC,wBAcE"}

View File

@@ -0,0 +1,17 @@
'use strict';
var getFilePath = ((destination)=>{
if (destination === 'api') {
return `api/{{ api }}`;
}
if (destination === 'plugin') {
return `plugins/{{ plugin }}/server`;
}
if (destination === 'root') {
return './';
}
return `api/{{ id }}`;
});
module.exports = getFilePath;
//# sourceMappingURL=get-file-path.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"get-file-path.js","sources":["../../../src/plops/utils/get-file-path.ts"],"sourcesContent":["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"],"names":["destination"],"mappings":";;AAAA,kBAAe,CAAA,CAACA,WAAAA,GAAAA;AACd,IAAA,IAAIA,gBAAgB,KAAO,EAAA;QACzB,OAAO,CAAC,aAAa,CAAC;AACxB;AAEA,IAAA,IAAIA,gBAAgB,QAAU,EAAA;QAC5B,OAAO,CAAC,2BAA2B,CAAC;AACtC;AAEA,IAAA,IAAIA,gBAAgB,MAAQ,EAAA;QAC1B,OAAO,IAAA;AACT;IAEA,OAAO,CAAC,YAAY,CAAC;AACvB,CAAA;;;;"}

View File

@@ -0,0 +1,15 @@
var getFilePath = ((destination)=>{
if (destination === 'api') {
return `api/{{ api }}`;
}
if (destination === 'plugin') {
return `plugins/{{ plugin }}/server`;
}
if (destination === 'root') {
return './';
}
return `api/{{ id }}`;
});
export { getFilePath as default };
//# sourceMappingURL=get-file-path.mjs.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"get-file-path.mjs","sources":["../../../src/plops/utils/get-file-path.ts"],"sourcesContent":["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"],"names":["destination"],"mappings":"AAAA,kBAAe,CAAA,CAACA,WAAAA,GAAAA;AACd,IAAA,IAAIA,gBAAgB,KAAO,EAAA;QACzB,OAAO,CAAC,aAAa,CAAC;AACxB;AAEA,IAAA,IAAIA,gBAAgB,QAAU,EAAA;QAC5B,OAAO,CAAC,2BAA2B,CAAC;AACtC;AAEA,IAAA,IAAIA,gBAAgB,MAAQ,EAAA;QAC1B,OAAO,IAAA;AACT;IAEA,OAAO,CAAC,YAAY,CAAC;AACvB,CAAA;;;;"}

View File

@@ -0,0 +1,3 @@
declare const _default: (date?: Date) => string;
export default _default;
//# sourceMappingURL=get-formatted-date.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"get-formatted-date.d.ts","sourceRoot":"","sources":["../../../src/plops/utils/get-formatted-date.ts"],"names":[],"mappings":"gCAAsB,IAAI;AAA1B,wBAKE"}

View File

@@ -0,0 +1,8 @@
'use strict';
var getFormattedDate = ((date = new Date())=>{
return new Date(date.getTime() - date.getTimezoneOffset() * 60000).toJSON().replace(/[-:]/g, '.').replace(/\....Z/, '');
});
module.exports = getFormattedDate;
//# sourceMappingURL=get-formatted-date.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"get-formatted-date.js","sources":["../../../src/plops/utils/get-formatted-date.ts"],"sourcesContent":["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"],"names":["date","Date","getTime","getTimezoneOffset","toJSON","replace"],"mappings":";;AAAA,uBAAe,CAAA,CAACA,IAAa,GAAA,IAAIC,IAAM,EAAA,GAAA;AACrC,IAAA,OAAO,IAAIA,IAAKD,CAAAA,IAAAA,CAAKE,OAAO,EAAA,GAAKF,KAAKG,iBAAiB,EAAA,GAAK,KACzDC,CAAAA,CAAAA,MAAM,GACNC,OAAO,CAAC,SAAS,GACjBA,CAAAA,CAAAA,OAAO,CAAC,QAAU,EAAA,EAAA,CAAA;AACvB,CAAA;;;;"}

View File

@@ -0,0 +1,6 @@
var getFormattedDate = ((date = new Date())=>{
return new Date(date.getTime() - date.getTimezoneOffset() * 60000).toJSON().replace(/[-:]/g, '.').replace(/\....Z/, '');
});
export { getFormattedDate as default };
//# sourceMappingURL=get-formatted-date.mjs.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"get-formatted-date.mjs","sources":["../../../src/plops/utils/get-formatted-date.ts"],"sourcesContent":["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"],"names":["date","Date","getTime","getTimezoneOffset","toJSON","replace"],"mappings":"AAAA,uBAAe,CAAA,CAACA,IAAa,GAAA,IAAIC,IAAM,EAAA,GAAA;AACrC,IAAA,OAAO,IAAIA,IAAKD,CAAAA,IAAAA,CAAKE,OAAO,EAAA,GAAKF,KAAKG,iBAAiB,EAAA,GAAK,KACzDC,CAAAA,CAAAA,MAAM,GACNC,OAAO,CAAC,SAAS,GACjBA,CAAAA,CAAAA,OAAO,CAAC,QAAU,EAAA,EAAA,CAAA;AACvB,CAAA;;;;"}

View File

@@ -0,0 +1,3 @@
declare const _default: (input: string) => true | "You must provide an input" | "Please use only letters, '-', '_', and no spaces";
export default _default;
//# sourceMappingURL=validate-attribute-input.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"validate-attribute-input.d.ts","sourceRoot":"","sources":["../../../src/plops/utils/validate-attribute-input.ts"],"names":[],"mappings":"gCAAuB,MAAM;AAA7B,wBAQE"}

View File

@@ -0,0 +1,12 @@
'use strict';
var validateAttributeInput = ((input)=>{
const regex = /^[A-Za-z-|_]+$/g;
if (!input) {
return 'You must provide an input';
}
return regex.test(input) || "Please use only letters, '-', '_', and no spaces";
});
module.exports = validateAttributeInput;
//# sourceMappingURL=validate-attribute-input.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"validate-attribute-input.js","sources":["../../../src/plops/utils/validate-attribute-input.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"],"names":["input","regex","test"],"mappings":";;AAAA,6BAAe,CAAA,CAACA,KAAAA,GAAAA;AACd,IAAA,MAAMC,KAAQ,GAAA,iBAAA;AAEd,IAAA,IAAI,CAACD,KAAO,EAAA;QACV,OAAO,2BAAA;AACT;IAEA,OAAOC,KAAAA,CAAMC,IAAI,CAACF,KAAU,CAAA,IAAA,mDAAA;AAC9B,CAAA;;;;"}

Some files were not shown because too many files have changed in this diff Show More