@strapi/generators 5.17.0 → 5.18.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +8 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +72 -12
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +73 -13
- package/dist/index.mjs.map +1 -1
- package/dist/plops/content-type.d.ts.map +1 -1
- package/dist/plops/content-type.js +0 -1
- package/dist/plops/content-type.js.map +1 -1
- package/dist/plops/content-type.mjs +0 -1
- package/dist/plops/content-type.mjs.map +1 -1
- package/dist/plops/prompts/bootstrap-api-prompts.d.ts +6 -2
- package/dist/plops/prompts/bootstrap-api-prompts.d.ts.map +1 -1
- package/dist/plops/prompts/bootstrap-api-prompts.js.map +1 -1
- package/dist/plops/prompts/bootstrap-api-prompts.mjs.map +1 -1
- package/dist/plops/prompts/ct-names-prompts.d.ts +18 -2
- package/dist/plops/prompts/ct-names-prompts.d.ts.map +1 -1
- package/dist/plops/prompts/ct-names-prompts.js.map +1 -1
- package/dist/plops/prompts/ct-names-prompts.mjs.map +1 -1
- package/dist/plops/prompts/get-attributes-prompts.d.ts +8 -2
- package/dist/plops/prompts/get-attributes-prompts.d.ts.map +1 -1
- package/dist/plops/prompts/get-attributes-prompts.js.map +1 -1
- package/dist/plops/prompts/get-attributes-prompts.mjs.map +1 -1
- package/dist/plops/prompts/get-destination-prompts.d.ts +24 -2
- package/dist/plops/prompts/get-destination-prompts.d.ts.map +1 -1
- package/dist/plops/prompts/get-destination-prompts.js.map +1 -1
- package/dist/plops/prompts/get-destination-prompts.mjs.map +1 -1
- package/dist/plops/prompts/kind-prompts.d.ts +11 -2
- package/dist/plops/prompts/kind-prompts.d.ts.map +1 -1
- package/dist/plops/prompts/kind-prompts.js.map +1 -1
- package/dist/plops/prompts/kind-prompts.mjs.map +1 -1
- package/package.json +6 -6
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
export declare const runCLI: () => Promise<void>;
|
|
2
|
-
|
|
3
|
-
dir?: string
|
|
4
|
-
plopFile?: string
|
|
5
|
-
}
|
|
2
|
+
type GenerateOptions = {
|
|
3
|
+
dir?: string;
|
|
4
|
+
plopFile?: string;
|
|
5
|
+
};
|
|
6
|
+
export declare const generate: <T extends Record<string, any>>(generatorName: string, options: T, { dir, plopFile }?: GenerateOptions) => Promise<{
|
|
7
|
+
success: boolean;
|
|
8
|
+
}>;
|
|
9
|
+
export {};
|
|
6
10
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,MAAM,qBAkBlB,CAAC;AAEF,KAAK,eAAe,GAAG;IACrB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AAUF,eAAO,MAAM,QAAQ,iDACJ,MAAM,WACZ,CAAC,sBACyC,eAAe;;EAkDnE,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var node_path = require('node:path');
|
|
4
|
-
var
|
|
4
|
+
var handlebars = require('handlebars');
|
|
5
|
+
var fs = require('fs-extra');
|
|
5
6
|
|
|
6
7
|
// Starts the Plop CLI programmatically
|
|
7
8
|
const runCLI = async ()=>{
|
|
@@ -19,18 +20,77 @@ const runCLI = async ()=>{
|
|
|
19
20
|
});
|
|
20
21
|
});
|
|
21
22
|
};
|
|
22
|
-
// Runs a generator programmatically without prompts
|
|
23
23
|
const generate = async (generatorName, options, { dir = process.cwd(), plopFile = 'plopfile.js' } = {})=>{
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
}
|
|
24
|
+
// Resolve the absolute path to the plopfile (generator definitions)
|
|
25
|
+
const plopfilePath = node_path.join(__dirname, plopFile);
|
|
26
|
+
// Dynamically require the plopfile module.
|
|
27
|
+
// Note: This allows loading either CommonJS or transpiled ESM plopfiles.
|
|
28
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
29
|
+
const plopModule = require(plopfilePath);
|
|
30
|
+
// Internal objects to store registered generators and helpers.
|
|
31
|
+
// These will be populated by the plopfile when it is executed.
|
|
32
|
+
const generators = {};
|
|
33
|
+
const helpers = {};
|
|
34
|
+
// Minimal mock Plop API implementation, exposing only the methods needed by our plopfile.
|
|
35
|
+
// This allows the plopfile to register generators and helpers as it would in a real Plop environment.
|
|
36
|
+
const plopApi = {
|
|
37
|
+
setGenerator (name, config) {
|
|
38
|
+
generators[name] = config;
|
|
39
|
+
},
|
|
40
|
+
setHelper (name, fn) {
|
|
41
|
+
helpers[name] = fn;
|
|
42
|
+
},
|
|
43
|
+
getDestBasePath () {
|
|
44
|
+
return node_path.join(dir, 'src');
|
|
45
|
+
},
|
|
46
|
+
setWelcomeMessage () {}
|
|
47
|
+
};
|
|
48
|
+
// Execute the plopfile, passing in our API.
|
|
49
|
+
// This will populate the `generators` and `helpers` objects.
|
|
50
|
+
// Support both CommonJS and ESM default exports.
|
|
51
|
+
if (typeof plopModule.default === 'function') {
|
|
52
|
+
plopModule.default(plopApi);
|
|
53
|
+
} else {
|
|
54
|
+
plopModule(plopApi);
|
|
55
|
+
}
|
|
56
|
+
const generator = generators[generatorName];
|
|
57
|
+
if (!generator) {
|
|
58
|
+
throw new Error(`Generator "${generatorName}" not found`);
|
|
59
|
+
}
|
|
60
|
+
registerHandlebarsHelpers(helpers);
|
|
61
|
+
const actions = typeof generator.actions === 'function' ? generator.actions(options) : generator.actions || [];
|
|
62
|
+
await executeActions(actions, options, dir);
|
|
63
|
+
return {
|
|
64
|
+
success: true
|
|
65
|
+
};
|
|
66
|
+
};
|
|
67
|
+
const registerHandlebarsHelpers = (helpers)=>{
|
|
68
|
+
Object.entries(helpers).forEach(([name, fn])=>handlebars.registerHelper(name, fn));
|
|
69
|
+
};
|
|
70
|
+
// Executes generator actions: add or modify files as specified
|
|
71
|
+
const executeActions = async (actions, options, dir)=>{
|
|
72
|
+
for (const action of actions){
|
|
73
|
+
const outputPath = handlebars.compile(action.path)(options);
|
|
74
|
+
const fullPath = node_path.join(dir, 'src', outputPath);
|
|
75
|
+
if (action.type === 'add' && action.templateFile) {
|
|
76
|
+
const templatePath = node_path.join(__dirname, action.templateFile);
|
|
77
|
+
const templateContent = await fs.readFile(templatePath, 'utf8');
|
|
78
|
+
const compiled = handlebars.compile(templateContent);
|
|
79
|
+
const output = compiled({
|
|
80
|
+
...options,
|
|
81
|
+
...action.data
|
|
82
|
+
});
|
|
83
|
+
await fs.ensureDir(node_path.dirname(fullPath));
|
|
84
|
+
await fs.writeFile(fullPath, output);
|
|
85
|
+
}
|
|
86
|
+
if (action.type === 'modify') {
|
|
87
|
+
if (await fs.pathExists(fullPath)) {
|
|
88
|
+
const content = await fs.readFile(fullPath, 'utf8');
|
|
89
|
+
const modified = action.transform ? action.transform(content) : content;
|
|
90
|
+
await fs.writeFile(fullPath, modified);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
34
94
|
};
|
|
35
95
|
|
|
36
96
|
exports.generate = generate;
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../src/index.ts"],"sourcesContent":["import { join } from 'node:path';\nimport
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../src/index.ts"],"sourcesContent":["import { join, dirname } from 'node:path';\nimport handlebars from 'handlebars';\nimport fs from 'fs-extra';\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\ntype GenerateOptions = {\n dir?: string;\n plopFile?: string;\n};\n\ntype GeneratorAction = {\n type: 'add' | 'modify';\n path: string;\n templateFile?: string;\n data?: Record<string, any>;\n transform?: (content: string) => string;\n};\n\nexport const generate = async <T extends Record<string, any>>(\n generatorName: string,\n options: T,\n { dir = process.cwd(), plopFile = 'plopfile.js' }: GenerateOptions = {}\n) => {\n // Resolve the absolute path to the plopfile (generator definitions)\n const plopfilePath = join(__dirname, plopFile);\n // Dynamically require the plopfile module.\n // Note: This allows loading either CommonJS or transpiled ESM plopfiles.\n // eslint-disable-next-line @typescript-eslint/no-var-requires\n const plopModule = require(plopfilePath);\n\n // Internal objects to store registered generators and helpers.\n // These will be populated by the plopfile when it is executed.\n const generators: Record<string, any> = {};\n const helpers: Record<string, any> = {};\n\n // Minimal mock Plop API implementation, exposing only the methods needed by our plopfile.\n // This allows the plopfile to register generators and helpers as it would in a real Plop environment.\n const plopApi = {\n setGenerator(name: string, config: any) {\n generators[name] = config;\n },\n setHelper(name: string, fn: any) {\n helpers[name] = fn;\n },\n getDestBasePath() {\n return join(dir, 'src');\n },\n setWelcomeMessage() {}, // no-op\n };\n\n // Execute the plopfile, passing in our API.\n // This will populate the `generators` and `helpers` objects.\n // Support both CommonJS and ESM default exports.\n if (typeof plopModule.default === 'function') {\n plopModule.default(plopApi);\n } else {\n plopModule(plopApi);\n }\n\n const generator = generators[generatorName];\n if (!generator) {\n throw new Error(`Generator \"${generatorName}\" not found`);\n }\n\n registerHandlebarsHelpers(helpers);\n const actions: GeneratorAction[] =\n typeof generator.actions === 'function' ? generator.actions(options) : generator.actions || [];\n\n await executeActions(actions, options, dir);\n\n return { success: true };\n};\n\nconst registerHandlebarsHelpers = (helpers: Record<string, any>) => {\n Object.entries(helpers).forEach(([name, fn]) => handlebars.registerHelper(name, fn));\n};\n\n// Executes generator actions: add or modify files as specified\nconst executeActions = async (\n actions: GeneratorAction[],\n options: Record<string, any>,\n dir: string\n) => {\n for (const action of actions) {\n const outputPath = handlebars.compile(action.path)(options);\n const fullPath = join(dir, 'src', outputPath);\n\n if (action.type === 'add' && action.templateFile) {\n const templatePath = join(__dirname, action.templateFile);\n const templateContent = await fs.readFile(templatePath, 'utf8');\n const compiled = handlebars.compile(templateContent);\n const output = compiled({ ...options, ...action.data });\n\n await fs.ensureDir(dirname(fullPath));\n await fs.writeFile(fullPath, output);\n }\n\n if (action.type === 'modify') {\n if (await fs.pathExists(fullPath)) {\n const content = await fs.readFile(fullPath, 'utf8');\n const modified = action.transform ? action.transform(content) : content;\n await fs.writeFile(fullPath, modified);\n }\n }\n }\n};\n"],"names":["runCLI","Plop","run","prepare","configPath","join","__dirname","env","argv","process","slice","execute","options","dest","cwd","generate","generatorName","dir","plopFile","plopfilePath","plopModule","require","generators","helpers","plopApi","setGenerator","name","config","setHelper","fn","getDestBasePath","setWelcomeMessage","default","generator","Error","registerHandlebarsHelpers","actions","executeActions","success","Object","entries","forEach","handlebars","registerHelper","action","outputPath","compile","path","fullPath","type","templateFile","templatePath","templateContent","fs","readFile","compiled","output","data","ensureDir","dirname","writeFile","pathExists","content","modified","transform"],"mappings":";;;;;;AAIA;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,KAA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KC,SAAWsC,EAAAA,MAAAA,CAAOM,YAAY,CAAA;AACxD,YAAA,MAAME,eAAkB,GAAA,MAAMC,EAAGC,CAAAA,QAAQ,CAACH,YAAc,EAAA,MAAA,CAAA;YACxD,MAAMI,QAAAA,GAAWb,UAAWI,CAAAA,OAAO,CAACM,eAAAA,CAAAA;AACpC,YAAA,MAAMI,SAASD,QAAS,CAAA;AAAE,gBAAA,GAAG3C,OAAO;AAAE,gBAAA,GAAGgC,OAAOa;AAAK,aAAA,CAAA;YAErD,MAAMJ,EAAAA,CAAGK,SAAS,CAACC,iBAAQX,CAAAA,QAAAA,CAAAA,CAAAA;YAC3B,MAAMK,EAAAA,CAAGO,SAAS,CAACZ,QAAUQ,EAAAA,MAAAA,CAAAA;AAC/B;QAEA,IAAIZ,MAAAA,CAAOK,IAAI,KAAK,QAAU,EAAA;AAC5B,YAAA,IAAI,MAAMI,EAAAA,CAAGQ,UAAU,CAACb,QAAW,CAAA,EAAA;AACjC,gBAAA,MAAMc,OAAU,GAAA,MAAMT,EAAGC,CAAAA,QAAQ,CAACN,QAAU,EAAA,MAAA,CAAA;AAC5C,gBAAA,MAAMe,WAAWnB,MAAOoB,CAAAA,SAAS,GAAGpB,MAAOoB,CAAAA,SAAS,CAACF,OAAWA,CAAAA,GAAAA,OAAAA;gBAChE,MAAMT,EAAAA,CAAGO,SAAS,CAACZ,QAAUe,EAAAA,QAAAA,CAAAA;AAC/B;AACF;AACF;AACF,CAAA;;;;;"}
|
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { join } from 'node:path';
|
|
2
|
-
import
|
|
1
|
+
import { join, dirname } from 'node:path';
|
|
2
|
+
import handlebars from 'handlebars';
|
|
3
|
+
import fs from 'fs-extra';
|
|
3
4
|
|
|
4
5
|
// Starts the Plop CLI programmatically
|
|
5
6
|
const runCLI = async ()=>{
|
|
@@ -17,18 +18,77 @@ const runCLI = async ()=>{
|
|
|
17
18
|
});
|
|
18
19
|
});
|
|
19
20
|
};
|
|
20
|
-
// Runs a generator programmatically without prompts
|
|
21
21
|
const generate = async (generatorName, options, { dir = process.cwd(), plopFile = 'plopfile.js' } = {})=>{
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
}
|
|
22
|
+
// Resolve the absolute path to the plopfile (generator definitions)
|
|
23
|
+
const plopfilePath = join(__dirname, plopFile);
|
|
24
|
+
// Dynamically require the plopfile module.
|
|
25
|
+
// Note: This allows loading either CommonJS or transpiled ESM plopfiles.
|
|
26
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
27
|
+
const plopModule = require(plopfilePath);
|
|
28
|
+
// Internal objects to store registered generators and helpers.
|
|
29
|
+
// These will be populated by the plopfile when it is executed.
|
|
30
|
+
const generators = {};
|
|
31
|
+
const helpers = {};
|
|
32
|
+
// Minimal mock Plop API implementation, exposing only the methods needed by our plopfile.
|
|
33
|
+
// This allows the plopfile to register generators and helpers as it would in a real Plop environment.
|
|
34
|
+
const plopApi = {
|
|
35
|
+
setGenerator (name, config) {
|
|
36
|
+
generators[name] = config;
|
|
37
|
+
},
|
|
38
|
+
setHelper (name, fn) {
|
|
39
|
+
helpers[name] = fn;
|
|
40
|
+
},
|
|
41
|
+
getDestBasePath () {
|
|
42
|
+
return join(dir, 'src');
|
|
43
|
+
},
|
|
44
|
+
setWelcomeMessage () {}
|
|
45
|
+
};
|
|
46
|
+
// Execute the plopfile, passing in our API.
|
|
47
|
+
// This will populate the `generators` and `helpers` objects.
|
|
48
|
+
// Support both CommonJS and ESM default exports.
|
|
49
|
+
if (typeof plopModule.default === 'function') {
|
|
50
|
+
plopModule.default(plopApi);
|
|
51
|
+
} else {
|
|
52
|
+
plopModule(plopApi);
|
|
53
|
+
}
|
|
54
|
+
const generator = generators[generatorName];
|
|
55
|
+
if (!generator) {
|
|
56
|
+
throw new Error(`Generator "${generatorName}" not found`);
|
|
57
|
+
}
|
|
58
|
+
registerHandlebarsHelpers(helpers);
|
|
59
|
+
const actions = typeof generator.actions === 'function' ? generator.actions(options) : generator.actions || [];
|
|
60
|
+
await executeActions(actions, options, dir);
|
|
61
|
+
return {
|
|
62
|
+
success: true
|
|
63
|
+
};
|
|
64
|
+
};
|
|
65
|
+
const registerHandlebarsHelpers = (helpers)=>{
|
|
66
|
+
Object.entries(helpers).forEach(([name, fn])=>handlebars.registerHelper(name, fn));
|
|
67
|
+
};
|
|
68
|
+
// Executes generator actions: add or modify files as specified
|
|
69
|
+
const executeActions = async (actions, options, dir)=>{
|
|
70
|
+
for (const action of actions){
|
|
71
|
+
const outputPath = handlebars.compile(action.path)(options);
|
|
72
|
+
const fullPath = join(dir, 'src', outputPath);
|
|
73
|
+
if (action.type === 'add' && action.templateFile) {
|
|
74
|
+
const templatePath = join(__dirname, action.templateFile);
|
|
75
|
+
const templateContent = await fs.readFile(templatePath, 'utf8');
|
|
76
|
+
const compiled = handlebars.compile(templateContent);
|
|
77
|
+
const output = compiled({
|
|
78
|
+
...options,
|
|
79
|
+
...action.data
|
|
80
|
+
});
|
|
81
|
+
await fs.ensureDir(dirname(fullPath));
|
|
82
|
+
await fs.writeFile(fullPath, output);
|
|
83
|
+
}
|
|
84
|
+
if (action.type === 'modify') {
|
|
85
|
+
if (await fs.pathExists(fullPath)) {
|
|
86
|
+
const content = await fs.readFile(fullPath, 'utf8');
|
|
87
|
+
const modified = action.transform ? action.transform(content) : content;
|
|
88
|
+
await fs.writeFile(fullPath, modified);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
32
92
|
};
|
|
33
93
|
|
|
34
94
|
export { generate, runCLI };
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sources":["../src/index.ts"],"sourcesContent":["import { join } from 'node:path';\nimport
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":["../src/index.ts"],"sourcesContent":["import { join, dirname } from 'node:path';\nimport handlebars from 'handlebars';\nimport fs from 'fs-extra';\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\ntype GenerateOptions = {\n dir?: string;\n plopFile?: string;\n};\n\ntype GeneratorAction = {\n type: 'add' | 'modify';\n path: string;\n templateFile?: string;\n data?: Record<string, any>;\n transform?: (content: string) => string;\n};\n\nexport const generate = async <T extends Record<string, any>>(\n generatorName: string,\n options: T,\n { dir = process.cwd(), plopFile = 'plopfile.js' }: GenerateOptions = {}\n) => {\n // Resolve the absolute path to the plopfile (generator definitions)\n const plopfilePath = join(__dirname, plopFile);\n // Dynamically require the plopfile module.\n // Note: This allows loading either CommonJS or transpiled ESM plopfiles.\n // eslint-disable-next-line @typescript-eslint/no-var-requires\n const plopModule = require(plopfilePath);\n\n // Internal objects to store registered generators and helpers.\n // These will be populated by the plopfile when it is executed.\n const generators: Record<string, any> = {};\n const helpers: Record<string, any> = {};\n\n // Minimal mock Plop API implementation, exposing only the methods needed by our plopfile.\n // This allows the plopfile to register generators and helpers as it would in a real Plop environment.\n const plopApi = {\n setGenerator(name: string, config: any) {\n generators[name] = config;\n },\n setHelper(name: string, fn: any) {\n helpers[name] = fn;\n },\n getDestBasePath() {\n return join(dir, 'src');\n },\n setWelcomeMessage() {}, // no-op\n };\n\n // Execute the plopfile, passing in our API.\n // This will populate the `generators` and `helpers` objects.\n // Support both CommonJS and ESM default exports.\n if (typeof plopModule.default === 'function') {\n plopModule.default(plopApi);\n } else {\n plopModule(plopApi);\n }\n\n const generator = generators[generatorName];\n if (!generator) {\n throw new Error(`Generator \"${generatorName}\" not found`);\n }\n\n registerHandlebarsHelpers(helpers);\n const actions: GeneratorAction[] =\n typeof generator.actions === 'function' ? generator.actions(options) : generator.actions || [];\n\n await executeActions(actions, options, dir);\n\n return { success: true };\n};\n\nconst registerHandlebarsHelpers = (helpers: Record<string, any>) => {\n Object.entries(helpers).forEach(([name, fn]) => handlebars.registerHelper(name, fn));\n};\n\n// Executes generator actions: add or modify files as specified\nconst executeActions = async (\n actions: GeneratorAction[],\n options: Record<string, any>,\n dir: string\n) => {\n for (const action of actions) {\n const outputPath = handlebars.compile(action.path)(options);\n const fullPath = join(dir, 'src', outputPath);\n\n if (action.type === 'add' && action.templateFile) {\n const templatePath = join(__dirname, action.templateFile);\n const templateContent = await fs.readFile(templatePath, 'utf8');\n const compiled = handlebars.compile(templateContent);\n const output = compiled({ ...options, ...action.data });\n\n await fs.ensureDir(dirname(fullPath));\n await fs.writeFile(fullPath, output);\n }\n\n if (action.type === 'modify') {\n if (await fs.pathExists(fullPath)) {\n const content = await fs.readFile(fullPath, 'utf8');\n const modified = action.transform ? action.transform(content) : content;\n await fs.writeFile(fullPath, modified);\n }\n }\n }\n};\n"],"names":["runCLI","Plop","run","prepare","configPath","join","__dirname","env","argv","process","slice","execute","options","dest","cwd","generate","generatorName","dir","plopFile","plopfilePath","plopModule","require","generators","helpers","plopApi","setGenerator","name","config","setHelper","fn","getDestBasePath","setWelcomeMessage","default","generator","Error","registerHandlebarsHelpers","actions","executeActions","success","Object","entries","forEach","handlebars","registerHelper","action","outputPath","compile","path","fullPath","type","templateFile","templatePath","templateContent","fs","readFile","compiled","output","data","ensureDir","dirname","writeFile","pathExists","content","modified","transform"],"mappings":";;;;AAIA;MACaA,MAAS,GAAA,UAAA;IACpB,MAAM,EAAEC,IAAI,EAAEC,GAAG,EAAE,GAAG,MAAM,OAAO,MAAA,CAAA;AAEnCD,IAAAA,IAAAA,CAAKE,OAAO,CACV;AACEC,QAAAA,UAAA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{"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,wBAmIE"}
|
|
@@ -21,7 +21,6 @@ var generateContentType = ((plop)=>{
|
|
|
21
21
|
...ctNamesPrompts,
|
|
22
22
|
...kindPrompts
|
|
23
23
|
]);
|
|
24
|
-
// @ts-expect-error issue with deprecated inquirer.prompts attribute to fix with ugprade to inquirer
|
|
25
24
|
const attributes = await getAttributesPrompts(inquirer);
|
|
26
25
|
const api = await inquirer.prompt([
|
|
27
26
|
...getDestinationPrompts('model', plop.getDestBasePath()),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"content-type.js","sources":["../../src/plops/content-type.ts"],"sourcesContent":["import { join } from 'path';\nimport type { NodePlopAPI, ActionType } from 'plop';\nimport slugify from '@sindresorhus/slugify';\nimport fs from 'fs-extra';\nimport { strings } from '@strapi/utils';\nimport tsUtils from '@strapi/typescript-utils';\n\nimport getDestinationPrompts from './prompts/get-destination-prompts';\nimport getFilePath from './utils/get-file-path';\nimport ctNamesPrompts from './prompts/ct-names-prompts';\nimport kindPrompts from './prompts/kind-prompts';\nimport getAttributesPrompts from './prompts/get-attributes-prompts';\nimport bootstrapApiPrompts from './prompts/bootstrap-api-prompts';\n\nexport default (plop: NodePlopAPI) => {\n // Model generator\n plop.setGenerator('content-type', {\n description: 'Generate a content type for an API',\n async prompts(inquirer) {\n const config = await inquirer.prompt([...ctNamesPrompts, ...kindPrompts]);\n // @ts-expect-error issue with deprecated inquirer.prompts attribute to fix with ugprade to inquirer\n const attributes = await getAttributesPrompts(inquirer);\n\n const api = await inquirer.prompt([\n ...getDestinationPrompts('model', plop.getDestBasePath()),\n {\n when: (answers) => answers.destination === 'new',\n type: 'input',\n name: 'id',\n default: config.singularName,\n message: 'Name of the new API?',\n async validate(input) {\n if (!strings.isKebabCase(input)) {\n return 'Value must be in kebab-case';\n }\n\n const apiPath = join(plop.getDestBasePath(), 'api');\n const exists = await fs.pathExists(apiPath);\n\n if (!exists) {\n return true;\n }\n\n const apiDir = await fs.readdir(apiPath, { withFileTypes: true });\n const apiDirContent = apiDir.filter((fd) => fd.isDirectory());\n\n if (apiDirContent.findIndex((dir) => dir.name === input) !== -1) {\n throw new Error('This name is already taken.');\n }\n\n return true;\n },\n },\n ...bootstrapApiPrompts,\n ]);\n\n return {\n ...config,\n ...api,\n attributes,\n };\n },\n actions(answers) {\n if (!answers) {\n return [];\n }\n\n const attributes = answers.attributes.reduce((object: any, answer: any) => {\n const val: any = { type: answer.attributeType };\n\n if (answer.attributeType === 'enumeration') {\n val.enum = answer.enum.split(',').map((item: string) => item.trim());\n }\n\n if (answer.attributeType === 'media') {\n val.allowedTypes = ['images', 'files', 'videos', 'audios'];\n val.multiple = answer.multiple;\n }\n\n return Object.assign(object, { [answer.attributeName]: val }, {});\n }, {});\n\n const filePath = getFilePath(answers.destination);\n const currentDir = process.cwd();\n const language = tsUtils.isUsingTypeScriptSync(currentDir) ? 'ts' : 'js';\n\n const baseActions: Array<ActionType> = [\n {\n type: 'add',\n path: `${filePath}/content-types/{{ singularName }}/schema.json`,\n templateFile: `templates/${language}/content-type.schema.json.hbs`,\n data: {\n collectionName: slugify(answers.pluralName, { separator: '_' }),\n },\n },\n ];\n\n if (Object.entries(attributes).length > 0) {\n baseActions.push({\n type: 'modify',\n path: `${filePath}/content-types/{{ singularName }}/schema.json`,\n transform(template: string) {\n const parsedTemplate = JSON.parse(template);\n parsedTemplate.attributes = attributes;\n return JSON.stringify(parsedTemplate, null, 2);\n },\n });\n }\n\n if (answers.bootstrapApi) {\n const { singularName } = answers;\n\n let uid;\n if (answers.destination === 'new') {\n uid = `api::${answers.id}.${singularName}`;\n } else if (answers.api) {\n uid = `api::${answers.api}.${singularName}`;\n } else if (answers.plugin) {\n uid = `plugin::${answers.plugin}.${singularName}`;\n }\n\n baseActions.push(\n {\n type: 'add',\n path: `${filePath}/controllers/{{ singularName }}.${language}`,\n templateFile: `templates/${language}/core-controller.${language}.hbs`,\n data: { uid },\n },\n {\n type: 'add',\n path: `${filePath}/services/{{ singularName }}.${language}`,\n templateFile: `templates/${language}/core-service.${language}.hbs`,\n data: { uid },\n },\n {\n type: 'add',\n path: `${filePath}/routes/{{ singularName }}.${language}`,\n templateFile: `templates/${language}/core-router.${language}.hbs`,\n data: { uid },\n }\n );\n }\n\n return baseActions;\n },\n });\n};\n"],"names":["plop","setGenerator","description","prompts","inquirer","config","prompt","ctNamesPrompts","kindPrompts","attributes","getAttributesPrompts","api","getDestinationPrompts","getDestBasePath","when","answers","destination","type","name","default","singularName","message","validate","input","strings","isKebabCase","apiPath","join","exists","fs","pathExists","apiDir","readdir","withFileTypes","apiDirContent","filter","fd","isDirectory","findIndex","dir","Error","bootstrapApiPrompts","actions","reduce","object","answer","val","attributeType","enum","split","map","item","trim","allowedTypes","multiple","Object","assign","attributeName","filePath","getFilePath","currentDir","process","cwd","language","tsUtils","isUsingTypeScriptSync","baseActions","path","templateFile","data","collectionName","slugify","pluralName","separator","entries","length","push","transform","template","parsedTemplate","JSON","parse","stringify","bootstrapApi","uid","id","plugin"],"mappings":";;;;;;;;;;;;;;AAcA,0BAAe,CAAA,CAACA,IAAAA,GAAAA;;IAEdA,IAAKC,CAAAA,YAAY,CAAC,cAAgB,EAAA;QAChCC,WAAa,EAAA,oCAAA;AACb,QAAA,MAAMC,SAAQC,QAAQ,EAAA;AACpB,YAAA,MAAMC,MAAS,GAAA,MAAMD,QAASE,CAAAA,MAAM,CAAC;AAAIC,gBAAAA,GAAAA,cAAAA;AAAmBC,gBAAAA,GAAAA;AAAY,aAAA,CAAA;;YAExE,MAAMC,UAAAA,GAAa,MAAMC,oBAAqBN,CAAAA,QAAAA,CAAAA;AAE9C,YAAA,MAAMO,GAAM,GAAA,MAAMP,QAASE,CAAAA,MAAM,CAAC;mBAC7BM,qBAAsB,CAAA,OAAA,EAASZ,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AAQ,EAAErE,OAAAA,CAAQuE,MAAM,CAAC,CAAC,EAAElE,YAAAA,CAAa,CAAC;AACnD;AAEA8C,gBAAAA,WAAAA,CAAYU,IAAI,CACd;oBACE3D,IAAM,EAAA,KAAA;AACNkD,oBAAAA,IAAAA,EAAM,CAAC,EAAET,QAAAA,CAAS,gCAAgC,EAAEK,SAAS,CAAC;oBAC9DK,YAAc,EAAA,CAAC,UAAU,EAAEL,QAAAA,CAAS,iBAAiB,EAAEA,QAAAA,CAAS,IAAI,CAAC;oBACrEM,IAAM,EAAA;AAAEe,wBAAAA;AAAI;iBAEd,EAAA;oBACEnE,IAAM,EAAA,KAAA;AACNkD,oBAAAA,IAAAA,EAAM,CAAC,EAAET,QAAAA,CAAS,6BAA6B,EAAEK,SAAS,CAAC;oBAC3DK,YAAc,EAAA,CAAC,UAAU,EAAEL,QAAAA,CAAS,cAAc,EAAEA,QAAAA,CAAS,IAAI,CAAC;oBAClEM,IAAM,EAAA;AAAEe,wBAAAA;AAAI;iBAEd,EAAA;oBACEnE,IAAM,EAAA,KAAA;AACNkD,oBAAAA,IAAAA,EAAM,CAAC,EAAET,QAAAA,CAAS,2BAA2B,EAAEK,SAAS,CAAC;oBACzDK,YAAc,EAAA,CAAC,UAAU,EAAEL,QAAAA,CAAS,aAAa,EAAEA,QAAAA,CAAS,IAAI,CAAC;oBACjEM,IAAM,EAAA;AAAEe,wBAAAA;AAAI;AACd,iBAAA,CAAA;AAEJ;YAEA,OAAOlB,WAAAA;AACT;AACF,KAAA,CAAA;AACF,CAAA;;;;"}
|
|
1
|
+
{"version":3,"file":"content-type.js","sources":["../../src/plops/content-type.ts"],"sourcesContent":["import { join } from 'path';\nimport type { NodePlopAPI, ActionType } from 'plop';\nimport slugify from '@sindresorhus/slugify';\nimport fs from 'fs-extra';\nimport { strings } from '@strapi/utils';\nimport tsUtils from '@strapi/typescript-utils';\n\nimport getDestinationPrompts from './prompts/get-destination-prompts';\nimport getFilePath from './utils/get-file-path';\nimport ctNamesPrompts from './prompts/ct-names-prompts';\nimport kindPrompts from './prompts/kind-prompts';\nimport getAttributesPrompts from './prompts/get-attributes-prompts';\nimport bootstrapApiPrompts from './prompts/bootstrap-api-prompts';\n\nexport default (plop: NodePlopAPI) => {\n // Model generator\n plop.setGenerator('content-type', {\n description: 'Generate a content type for an API',\n async prompts(inquirer) {\n const config = await inquirer.prompt([...ctNamesPrompts, ...kindPrompts]);\n const attributes = await getAttributesPrompts(inquirer);\n\n const api = await inquirer.prompt([\n ...getDestinationPrompts('model', plop.getDestBasePath()),\n {\n when: (answers) => answers.destination === 'new',\n type: 'input',\n name: 'id',\n default: config.singularName,\n message: 'Name of the new API?',\n async validate(input) {\n if (!strings.isKebabCase(input)) {\n return 'Value must be in kebab-case';\n }\n\n const apiPath = join(plop.getDestBasePath(), 'api');\n const exists = await fs.pathExists(apiPath);\n\n if (!exists) {\n return true;\n }\n\n const apiDir = await fs.readdir(apiPath, { withFileTypes: true });\n const apiDirContent = apiDir.filter((fd) => fd.isDirectory());\n\n if (apiDirContent.findIndex((dir) => dir.name === input) !== -1) {\n throw new Error('This name is already taken.');\n }\n\n return true;\n },\n },\n ...bootstrapApiPrompts,\n ]);\n\n return {\n ...config,\n ...api,\n attributes,\n };\n },\n actions(answers) {\n if (!answers) {\n return [];\n }\n\n const attributes = answers.attributes.reduce((object: any, answer: any) => {\n const val: any = { type: answer.attributeType };\n\n if (answer.attributeType === 'enumeration') {\n val.enum = answer.enum.split(',').map((item: string) => item.trim());\n }\n\n if (answer.attributeType === 'media') {\n val.allowedTypes = ['images', 'files', 'videos', 'audios'];\n val.multiple = answer.multiple;\n }\n\n return Object.assign(object, { [answer.attributeName]: val }, {});\n }, {});\n\n const filePath = getFilePath(answers.destination);\n const currentDir = process.cwd();\n const language = tsUtils.isUsingTypeScriptSync(currentDir) ? 'ts' : 'js';\n\n const baseActions: Array<ActionType> = [\n {\n type: 'add',\n path: `${filePath}/content-types/{{ singularName }}/schema.json`,\n templateFile: `templates/${language}/content-type.schema.json.hbs`,\n data: {\n collectionName: slugify(answers.pluralName, { separator: '_' }),\n },\n },\n ];\n\n if (Object.entries(attributes).length > 0) {\n baseActions.push({\n type: 'modify',\n path: `${filePath}/content-types/{{ singularName }}/schema.json`,\n transform(template: string) {\n const parsedTemplate = JSON.parse(template);\n parsedTemplate.attributes = attributes;\n return JSON.stringify(parsedTemplate, null, 2);\n },\n });\n }\n\n if (answers.bootstrapApi) {\n const { singularName } = answers;\n\n let uid;\n if (answers.destination === 'new') {\n uid = `api::${answers.id}.${singularName}`;\n } else if (answers.api) {\n uid = `api::${answers.api}.${singularName}`;\n } else if (answers.plugin) {\n uid = `plugin::${answers.plugin}.${singularName}`;\n }\n\n baseActions.push(\n {\n type: 'add',\n path: `${filePath}/controllers/{{ singularName }}.${language}`,\n templateFile: `templates/${language}/core-controller.${language}.hbs`,\n data: { uid },\n },\n {\n type: 'add',\n path: `${filePath}/services/{{ singularName }}.${language}`,\n templateFile: `templates/${language}/core-service.${language}.hbs`,\n data: { uid },\n },\n {\n type: 'add',\n path: `${filePath}/routes/{{ singularName }}.${language}`,\n templateFile: `templates/${language}/core-router.${language}.hbs`,\n data: { uid },\n }\n );\n }\n\n return baseActions;\n },\n });\n};\n"],"names":["plop","setGenerator","description","prompts","inquirer","config","prompt","ctNamesPrompts","kindPrompts","attributes","getAttributesPrompts","api","getDestinationPrompts","getDestBasePath","when","answers","destination","type","name","default","singularName","message","validate","input","strings","isKebabCase","apiPath","join","exists","fs","pathExists","apiDir","readdir","withFileTypes","apiDirContent","filter","fd","isDirectory","findIndex","dir","Error","bootstrapApiPrompts","actions","reduce","object","answer","val","attributeType","enum","split","map","item","trim","allowedTypes","multiple","Object","assign","attributeName","filePath","getFilePath","currentDir","process","cwd","language","tsUtils","isUsingTypeScriptSync","baseActions","path","templateFile","data","collectionName","slugify","pluralName","separator","entries","length","push","transform","template","parsedTemplate","JSON","parse","stringify","bootstrapApi","uid","id","plugin"],"mappings":";;;;;;;;;;;;;;A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EAAEL,QAAAA,CAAS,aAAa,EAAEA,QAAAA,CAAS,IAAI,CAAC;oBACjEM,IAAM,EAAA;AAAEe,wBAAAA;AAAI;AACd,iBAAA,CAAA;AAEJ;YAEA,OAAOlB,WAAAA;AACT;AACF,KAAA,CAAA;AACF,CAAA;;;;"}
|
|
@@ -19,7 +19,6 @@ var generateContentType = ((plop)=>{
|
|
|
19
19
|
...questions,
|
|
20
20
|
...questions$1
|
|
21
21
|
]);
|
|
22
|
-
// @ts-expect-error issue with deprecated inquirer.prompts attribute to fix with ugprade to inquirer
|
|
23
22
|
const attributes = await getAttributesPrompts(inquirer);
|
|
24
23
|
const api = await inquirer.prompt([
|
|
25
24
|
...getDestinationPrompts('model', plop.getDestBasePath()),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"content-type.mjs","sources":["../../src/plops/content-type.ts"],"sourcesContent":["import { join } from 'path';\nimport type { NodePlopAPI, ActionType } from 'plop';\nimport slugify from '@sindresorhus/slugify';\nimport fs from 'fs-extra';\nimport { strings } from '@strapi/utils';\nimport tsUtils from '@strapi/typescript-utils';\n\nimport getDestinationPrompts from './prompts/get-destination-prompts';\nimport getFilePath from './utils/get-file-path';\nimport ctNamesPrompts from './prompts/ct-names-prompts';\nimport kindPrompts from './prompts/kind-prompts';\nimport getAttributesPrompts from './prompts/get-attributes-prompts';\nimport bootstrapApiPrompts from './prompts/bootstrap-api-prompts';\n\nexport default (plop: NodePlopAPI) => {\n // Model generator\n plop.setGenerator('content-type', {\n description: 'Generate a content type for an API',\n async prompts(inquirer) {\n const config = await inquirer.prompt([...ctNamesPrompts, ...kindPrompts]);\n // @ts-expect-error issue with deprecated inquirer.prompts attribute to fix with ugprade to inquirer\n const attributes = await getAttributesPrompts(inquirer);\n\n const api = await inquirer.prompt([\n ...getDestinationPrompts('model', plop.getDestBasePath()),\n {\n when: (answers) => answers.destination === 'new',\n type: 'input',\n name: 'id',\n default: config.singularName,\n message: 'Name of the new API?',\n async validate(input) {\n if (!strings.isKebabCase(input)) {\n return 'Value must be in kebab-case';\n }\n\n const apiPath = join(plop.getDestBasePath(), 'api');\n const exists = await fs.pathExists(apiPath);\n\n if (!exists) {\n return true;\n }\n\n const apiDir = await fs.readdir(apiPath, { withFileTypes: true });\n const apiDirContent = apiDir.filter((fd) => fd.isDirectory());\n\n if (apiDirContent.findIndex((dir) => dir.name === input) !== -1) {\n throw new Error('This name is already taken.');\n }\n\n return true;\n },\n },\n ...bootstrapApiPrompts,\n ]);\n\n return {\n ...config,\n ...api,\n attributes,\n };\n },\n actions(answers) {\n if (!answers) {\n return [];\n }\n\n const attributes = answers.attributes.reduce((object: any, answer: any) => {\n const val: any = { type: answer.attributeType };\n\n if (answer.attributeType === 'enumeration') {\n val.enum = answer.enum.split(',').map((item: string) => item.trim());\n }\n\n if (answer.attributeType === 'media') {\n val.allowedTypes = ['images', 'files', 'videos', 'audios'];\n val.multiple = answer.multiple;\n }\n\n return Object.assign(object, { [answer.attributeName]: val }, {});\n }, {});\n\n const filePath = getFilePath(answers.destination);\n const currentDir = process.cwd();\n const language = tsUtils.isUsingTypeScriptSync(currentDir) ? 'ts' : 'js';\n\n const baseActions: Array<ActionType> = [\n {\n type: 'add',\n path: `${filePath}/content-types/{{ singularName }}/schema.json`,\n templateFile: `templates/${language}/content-type.schema.json.hbs`,\n data: {\n collectionName: slugify(answers.pluralName, { separator: '_' }),\n },\n },\n ];\n\n if (Object.entries(attributes).length > 0) {\n baseActions.push({\n type: 'modify',\n path: `${filePath}/content-types/{{ singularName }}/schema.json`,\n transform(template: string) {\n const parsedTemplate = JSON.parse(template);\n parsedTemplate.attributes = attributes;\n return JSON.stringify(parsedTemplate, null, 2);\n },\n });\n }\n\n if (answers.bootstrapApi) {\n const { singularName } = answers;\n\n let uid;\n if (answers.destination === 'new') {\n uid = `api::${answers.id}.${singularName}`;\n } else if (answers.api) {\n uid = `api::${answers.api}.${singularName}`;\n } else if (answers.plugin) {\n uid = `plugin::${answers.plugin}.${singularName}`;\n }\n\n baseActions.push(\n {\n type: 'add',\n path: `${filePath}/controllers/{{ singularName }}.${language}`,\n templateFile: `templates/${language}/core-controller.${language}.hbs`,\n data: { uid },\n },\n {\n type: 'add',\n path: `${filePath}/services/{{ singularName }}.${language}`,\n templateFile: `templates/${language}/core-service.${language}.hbs`,\n data: { uid },\n },\n {\n type: 'add',\n path: `${filePath}/routes/{{ singularName }}.${language}`,\n templateFile: `templates/${language}/core-router.${language}.hbs`,\n data: { uid },\n }\n );\n }\n\n return baseActions;\n },\n });\n};\n"],"names":["plop","setGenerator","description","prompts","inquirer","config","prompt","ctNamesPrompts","kindPrompts","attributes","getAttributesPrompts","api","getDestinationPrompts","getDestBasePath","when","answers","destination","type","name","default","singularName","message","validate","input","strings","isKebabCase","apiPath","join","exists","fs","pathExists","apiDir","readdir","withFileTypes","apiDirContent","filter","fd","isDirectory","findIndex","dir","Error","bootstrapApiPrompts","actions","reduce","object","answer","val","attributeType","enum","split","map","item","trim","allowedTypes","multiple","Object","assign","attributeName","filePath","getFilePath","currentDir","process","cwd","language","tsUtils","isUsingTypeScriptSync","baseActions","path","templateFile","data","collectionName","slugify","pluralName","separator","entries","length","push","transform","template","parsedTemplate","JSON","parse","stringify","bootstrapApi","uid","id","plugin"],"mappings":";;;;;;;;;;;;AAcA,0BAAe,CAAA,CAACA,IAAAA,GAAAA;;IAEdA,IAAKC,CAAAA,YAAY,CAAC,cAAgB,EAAA;QAChCC,WAAa,EAAA,oCAAA;AACb,QAAA,MAAMC,SAAQC,QAAQ,EAAA;AACpB,YAAA,MAAMC,MAAS,GAAA,MAAMD,QAASE,CAAAA,MAAM,CAAC;AAAIC,gBAAAA,GAAAA,SAAAA;AAAmBC,gBAAAA,GAAAA;AAAY,aAAA,CAAA;;YAExE,MAAMC,UAAAA,GAAa,MAAMC,oBAAqBN,CAAAA,QAAAA,CAAAA;AAE9C,YAAA,MAAMO,GAAM,GAAA,MAAMP,QAASE,CAAAA,MAAM,CAAC;mBAC7BM,qBAAs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F,GAAM,GAAA,CAAC,QAAQ,EAAErE,OAAAA,CAAQuE,MAAM,CAAC,CAAC,EAAElE,YAAAA,CAAa,CAAC;AACnD;AAEA8C,gBAAAA,WAAAA,CAAYU,IAAI,CACd;oBACE3D,IAAM,EAAA,KAAA;AACNkD,oBAAAA,IAAAA,EAAM,CAAC,EAAET,QAAAA,CAAS,gCAAgC,EAAEK,SAAS,CAAC;oBAC9DK,YAAc,EAAA,CAAC,UAAU,EAAEL,QAAAA,CAAS,iBAAiB,EAAEA,QAAAA,CAAS,IAAI,CAAC;oBACrEM,IAAM,EAAA;AAAEe,wBAAAA;AAAI;iBAEd,EAAA;oBACEnE,IAAM,EAAA,KAAA;AACNkD,oBAAAA,IAAAA,EAAM,CAAC,EAAET,QAAAA,CAAS,6BAA6B,EAAEK,SAAS,CAAC;oBAC3DK,YAAc,EAAA,CAAC,UAAU,EAAEL,QAAAA,CAAS,cAAc,EAAEA,QAAAA,CAAS,IAAI,CAAC;oBAClEM,IAAM,EAAA;AAAEe,wBAAAA;AAAI;iBAEd,EAAA;oBACEnE,IAAM,EAAA,KAAA;AACNkD,oBAAAA,IAAAA,EAAM,CAAC,EAAET,QAAAA,CAAS,2BAA2B,EAAEK,SAAS,CAAC;oBACzDK,YAAc,EAAA,CAAC,UAAU,EAAEL,QAAAA,CAAS,aAAa,EAAEA,QAAAA,CAAS,IAAI,CAAC;oBACjEM,IAAM,EAAA;AAAEe,wBAAAA;AAAI;AACd,iBAAA,CAAA;AAEJ;YAEA,OAAOlB,WAAAA;AACT;AACF,KAAA,CAAA;AACF,CAAA;;;;"}
|
|
1
|
+
{"version":3,"file":"content-type.mjs","sources":["../../src/plops/content-type.ts"],"sourcesContent":["import { join } from 'path';\nimport type { NodePlopAPI, ActionType } from 'plop';\nimport slugify from '@sindresorhus/slugify';\nimport fs from 'fs-extra';\nimport { strings } from '@strapi/utils';\nimport tsUtils from '@strapi/typescript-utils';\n\nimport getDestinationPrompts from './prompts/get-destination-prompts';\nimport getFilePath from './utils/get-file-path';\nimport ctNamesPrompts from './prompts/ct-names-prompts';\nimport kindPrompts from './prompts/kind-prompts';\nimport getAttributesPrompts from './prompts/get-attributes-prompts';\nimport bootstrapApiPrompts from './prompts/bootstrap-api-prompts';\n\nexport default (plop: NodePlopAPI) => {\n // Model generator\n plop.setGenerator('content-type', {\n description: 'Generate a content type for an API',\n async prompts(inquirer) {\n const config = await inquirer.prompt([...ctNamesPrompts, ...kindPrompts]);\n const attributes = await getAttributesPrompts(inquirer);\n\n const api = await inquirer.prompt([\n ...getDestinationPrompts('model', plop.getDestBasePath()),\n {\n when: (answers) => answers.destination === 'new',\n type: 'input',\n name: 'id',\n default: config.singularName,\n message: 'Name of the new API?',\n async validate(input) {\n if (!strings.isKebabCase(input)) {\n return 'Value must be in kebab-case';\n }\n\n const apiPath = join(plop.getDestBasePath(), 'api');\n const exists = await fs.pathExists(apiPath);\n\n if (!exists) {\n return true;\n }\n\n const apiDir = await fs.readdir(apiPath, { withFileTypes: true });\n const apiDirContent = apiDir.filter((fd) => fd.isDirectory());\n\n if (apiDirContent.findIndex((dir) => dir.name === input) !== -1) {\n throw new Error('This name is already taken.');\n }\n\n return true;\n },\n },\n ...bootstrapApiPrompts,\n ]);\n\n return {\n ...config,\n ...api,\n attributes,\n };\n },\n actions(answers) {\n if (!answers) {\n return [];\n }\n\n const attributes = answers.attributes.reduce((object: any, answer: any) => {\n const val: any = { type: answer.attributeType };\n\n if (answer.attributeType === 'enumeration') {\n val.enum = answer.enum.split(',').map((item: string) => item.trim());\n }\n\n if (answer.attributeType === 'media') {\n val.allowedTypes = ['images', 'files', 'videos', 'audios'];\n val.multiple = answer.multiple;\n }\n\n return Object.assign(object, { [answer.attributeName]: val }, {});\n }, {});\n\n const filePath = getFilePath(answers.destination);\n const currentDir = process.cwd();\n const language = tsUtils.isUsingTypeScriptSync(currentDir) ? 'ts' : 'js';\n\n const baseActions: Array<ActionType> = [\n {\n type: 'add',\n path: `${filePath}/content-types/{{ singularName }}/schema.json`,\n templateFile: `templates/${language}/content-type.schema.json.hbs`,\n data: {\n collectionName: slugify(answers.pluralName, { separator: '_' }),\n },\n },\n ];\n\n if (Object.entries(attributes).length > 0) {\n baseActions.push({\n type: 'modify',\n path: `${filePath}/content-types/{{ singularName }}/schema.json`,\n transform(template: string) {\n const parsedTemplate = JSON.parse(template);\n parsedTemplate.attributes = attributes;\n return JSON.stringify(parsedTemplate, null, 2);\n },\n });\n }\n\n if (answers.bootstrapApi) {\n const { singularName } = answers;\n\n let uid;\n if (answers.destination === 'new') {\n uid = `api::${answers.id}.${singularName}`;\n } else if (answers.api) {\n uid = `api::${answers.api}.${singularName}`;\n } else if (answers.plugin) {\n uid = `plugin::${answers.plugin}.${singularName}`;\n }\n\n baseActions.push(\n {\n type: 'add',\n path: `${filePath}/controllers/{{ singularName }}.${language}`,\n templateFile: `templates/${language}/core-controller.${language}.hbs`,\n data: { uid },\n },\n {\n type: 'add',\n path: `${filePath}/services/{{ singularName }}.${language}`,\n templateFile: `templates/${language}/core-service.${language}.hbs`,\n data: { uid },\n },\n {\n type: 'add',\n path: `${filePath}/routes/{{ singularName }}.${language}`,\n templateFile: `templates/${language}/core-router.${language}.hbs`,\n data: { uid },\n }\n );\n }\n\n return baseActions;\n },\n });\n};\n"],"names":["plop","setGenerator","description","prompts","inquirer","config","prompt","ctNamesPrompts","kindPrompts","attributes","getAttributesPrompts","api","getDestinationPrompts","getDestBasePath","when","answers","destination","type","name","default","singularName","message","validate","input","strings","isKebabCase","apiPath","join","exists","fs","pathExists","apiDir","readdir","withFileTypes","apiDirContent","filter","fd","isDirectory","findIndex","dir","Error","bootstrapApiPrompts","actions","reduce","object","answer","val","attributeType","enum","split","map","item","trim","allowedTypes","multiple","Object","assign","attributeName","filePath","getFilePath","currentDir","process","cwd","language","tsUtils","isUsingTypeScriptSync","baseActions","path","templateFile","data","collectionName","slugify","pluralName","separator","entries","length","push","transform","template","parsedTemplate","JSON","parse","stringify","bootstrapApi","uid","id","plugin"],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Ac,EAAA,CAAC,UAAU,EAAEL,QAAAA,CAAS,aAAa,EAAEA,QAAAA,CAAS,IAAI,CAAC;oBACjEM,IAAM,EAAA;AAAEe,wBAAAA;AAAI;AACd,iBAAA,CAAA;AAEJ;YAEA,OAAOlB,WAAAA;AACT;AACF,KAAA,CAAA;AACF,CAAA;;;;"}
|
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
declare const questions: {
|
|
2
|
+
type: string;
|
|
3
|
+
name: string;
|
|
4
|
+
default: boolean;
|
|
5
|
+
message: string;
|
|
6
|
+
}[];
|
|
3
7
|
export default questions;
|
|
4
8
|
//# sourceMappingURL=bootstrap-api-prompts.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bootstrap-api-prompts.d.ts","sourceRoot":"","sources":["../../../src/plops/prompts/bootstrap-api-prompts.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"bootstrap-api-prompts.d.ts","sourceRoot":"","sources":["../../../src/plops/prompts/bootstrap-api-prompts.ts"],"names":[],"mappings":"AAAA,QAAA,MAAM,SAAS;;;;;GAOd,CAAC;AAEF,eAAe,SAAS,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bootstrap-api-prompts.js","sources":["../../../src/plops/prompts/bootstrap-api-prompts.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"file":"bootstrap-api-prompts.js","sources":["../../../src/plops/prompts/bootstrap-api-prompts.ts"],"sourcesContent":["const questions = [\n {\n type: 'confirm',\n name: 'bootstrapApi',\n default: true,\n message: 'Bootstrap API related files?',\n },\n];\n\nexport default questions;\n"],"names":["questions","type","name","default","message"],"mappings":";;AAAA,MAAMA,SAAY,GAAA;AAChB,IAAA;QACEC,IAAM,EAAA,SAAA;QACNC,IAAM,EAAA,cAAA;QACNC,OAAS,EAAA,IAAA;QACTC,OAAS,EAAA;AACX;AACD;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bootstrap-api-prompts.mjs","sources":["../../../src/plops/prompts/bootstrap-api-prompts.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"file":"bootstrap-api-prompts.mjs","sources":["../../../src/plops/prompts/bootstrap-api-prompts.ts"],"sourcesContent":["const questions = [\n {\n type: 'confirm',\n name: 'bootstrapApi',\n default: true,\n message: 'Bootstrap API related files?',\n },\n];\n\nexport default questions;\n"],"names":["questions","type","name","default","message"],"mappings":"AAAA,MAAMA,SAAY,GAAA;AAChB,IAAA;QACEC,IAAM,EAAA,SAAA;QACNC,IAAM,EAAA,cAAA;QACNC,OAAS,EAAA,IAAA;QACTC,OAAS,EAAA;AACX;AACD;;;;"}
|
|
@@ -1,4 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
interface Answers {
|
|
2
|
+
displayName: string;
|
|
3
|
+
singularName: string;
|
|
4
|
+
pluralName: string;
|
|
5
|
+
}
|
|
6
|
+
declare const questions: ({
|
|
7
|
+
type: string;
|
|
8
|
+
name: string;
|
|
9
|
+
message: string;
|
|
10
|
+
validate: (input: string) => boolean;
|
|
11
|
+
default?: undefined;
|
|
12
|
+
} | {
|
|
13
|
+
type: string;
|
|
14
|
+
name: string;
|
|
15
|
+
message: string;
|
|
16
|
+
default: (answers: Answers) => any;
|
|
17
|
+
validate(input: string, answers: Answers): true | "Singular and plural names cannot be the same" | "Value must be in kebab-case";
|
|
18
|
+
})[];
|
|
3
19
|
export default questions;
|
|
4
20
|
//# sourceMappingURL=ct-names-prompts.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ct-names-prompts.d.ts","sourceRoot":"","sources":["../../../src/plops/prompts/ct-names-prompts.ts"],"names":[],"mappings":"AAIA,OAAO,
|
|
1
|
+
{"version":3,"file":"ct-names-prompts.d.ts","sourceRoot":"","sources":["../../../src/plops/prompts/ct-names-prompts.ts"],"names":[],"mappings":"AAIA,UAAU,OAAO;IACf,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,QAAA,MAAM,SAAS;;;;sBAKO,MAAM;;;;;;uBAmBL,OAAO;oBACV,MAAM,WAAW,OAAO;IAY3C,CAAC;AAEF,eAAe,SAAS,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ct-names-prompts.js","sources":["../../../src/plops/prompts/ct-names-prompts.ts"],"sourcesContent":["import pluralize from 'pluralize';\nimport slugify from '@sindresorhus/slugify';\nimport { strings } from '@strapi/utils';\n\
|
|
1
|
+
{"version":3,"file":"ct-names-prompts.js","sources":["../../../src/plops/prompts/ct-names-prompts.ts"],"sourcesContent":["import pluralize from 'pluralize';\nimport slugify from '@sindresorhus/slugify';\nimport { strings } from '@strapi/utils';\n\ninterface Answers {\n displayName: string;\n singularName: string;\n pluralName: string;\n}\n\nconst questions = [\n {\n type: 'input',\n name: 'displayName',\n message: 'Content type display name',\n validate: (input: string) => !!input,\n },\n {\n type: 'input',\n name: 'singularName',\n message: 'Content type singular name',\n default: (answers: Answers) => slugify(answers.displayName),\n validate(input: string) {\n if (!strings.isKebabCase(input)) {\n return 'Value must be in kebab-case';\n }\n\n return true;\n },\n },\n {\n type: 'input',\n name: 'pluralName',\n message: 'Content type plural name',\n default: (answers: Answers) => pluralize(answers.singularName),\n validate(input: string, answers: Answers) {\n if (answers.singularName === input) {\n return 'Singular and plural names cannot be the same';\n }\n\n if (!strings.isKebabCase(input)) {\n return 'Value must be in kebab-case';\n }\n\n return true;\n },\n },\n];\n\nexport default questions;\n"],"names":["questions","type","name","message","validate","input","default","answers","slugify","displayName","strings","isKebabCase","pluralize","singularName"],"mappings":";;;;;;AAUA,MAAMA,SAAY,GAAA;AAChB,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,KAAa,EAAA;AACpB,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;;;;"}
|
|
@@ -1 +1 @@
|
|
|
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\
|
|
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\ninterface Answers {\n displayName: string;\n singularName: string;\n pluralName: string;\n}\n\nconst questions = [\n {\n type: 'input',\n name: 'displayName',\n message: 'Content type display name',\n validate: (input: string) => !!input,\n },\n {\n type: 'input',\n name: 'singularName',\n message: 'Content type singular name',\n default: (answers: Answers) => slugify(answers.displayName),\n validate(input: string) {\n if (!strings.isKebabCase(input)) {\n return 'Value must be in kebab-case';\n }\n\n return true;\n },\n },\n {\n type: 'input',\n name: 'pluralName',\n message: 'Content type plural name',\n default: (answers: Answers) => pluralize(answers.singularName),\n validate(input: string, answers: Answers) {\n if (answers.singularName === input) {\n return 'Singular and plural names cannot be the same';\n }\n\n if (!strings.isKebabCase(input)) {\n return 'Value must be in kebab-case';\n }\n\n return true;\n },\n },\n];\n\nexport default questions;\n"],"names":["questions","type","name","message","validate","input","default","answers","slugify","displayName","strings","isKebabCase","pluralize","singularName"],"mappings":";;;;AAUA,MAAMA,SAAY,GAAA;AAChB,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,KAAa,EAAA;AACpB,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;;;;"}
|
|
@@ -1,4 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
interface AttributeAnswer {
|
|
2
|
+
attributeName: string;
|
|
3
|
+
attributeType: (typeof DEFAULT_TYPES)[number];
|
|
4
|
+
enum?: string;
|
|
5
|
+
multiple?: boolean;
|
|
6
|
+
}
|
|
7
|
+
declare const DEFAULT_TYPES: readonly ["media", "string", "text", "richtext", "json", "enumeration", "password", "email", "integer", "biginteger", "float", "decimal", "date", "time", "datetime", "timestamp", "boolean"];
|
|
8
|
+
declare const getAttributesPrompts: (inquirer: any) => Promise<AttributeAnswer[]>;
|
|
3
9
|
export default getAttributesPrompts;
|
|
4
10
|
//# sourceMappingURL=get-attributes-prompts.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-attributes-prompts.d.ts","sourceRoot":"","sources":["../../../src/plops/prompts/get-attributes-prompts.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"get-attributes-prompts.d.ts","sourceRoot":"","sources":["../../../src/plops/prompts/get-attributes-prompts.ts"],"names":[],"mappings":"AAEA,UAAU,eAAe;IACvB,aAAa,EAAE,MAAM,CAAC;IACtB,aAAa,EAAE,CAAC,OAAO,aAAa,CAAC,CAAC,MAAM,CAAC,CAAC;IAC9C,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,QAAA,MAAM,aAAa,+LAqBT,CAAC;AAEX,QAAA,MAAM,oBAAoB,aAAoB,GAAG,+BAyEhD,CAAC;AAEF,eAAe,oBAAoB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-attributes-prompts.js","sources":["../../../src/plops/prompts/get-attributes-prompts.ts"],"sourcesContent":["import
|
|
1
|
+
{"version":3,"file":"get-attributes-prompts.js","sources":["../../../src/plops/prompts/get-attributes-prompts.ts"],"sourcesContent":["import validateAttributeInput from '../utils/validate-attribute-input';\n\ninterface AttributeAnswer {\n attributeName: string;\n attributeType: (typeof DEFAULT_TYPES)[number];\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 = async (inquirer: any) => {\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: any) => {\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: AttributeAnswer) => answers.attributeType === 'enumeration',\n type: 'input',\n name: 'enum',\n message: 'Add values separated by a comma',\n },\n {\n when: (answers: AttributeAnswer) => 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":";;;;AASA,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,uBAAuB,OAAOC,QAAAA,GAAAA;AAClC,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,EAA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"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-attributes-prompts.mjs","sources":["../../../src/plops/prompts/get-attributes-prompts.ts"],"sourcesContent":["import
|
|
1
|
+
{"version":3,"file":"get-attributes-prompts.mjs","sources":["../../../src/plops/prompts/get-attributes-prompts.ts"],"sourcesContent":["import validateAttributeInput from '../utils/validate-attribute-input';\n\ninterface AttributeAnswer {\n attributeName: string;\n attributeType: (typeof DEFAULT_TYPES)[number];\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 = async (inquirer: any) => {\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: any) => {\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: AttributeAnswer) => answers.attributeType === 'enumeration',\n type: 'input',\n name: 'enum',\n message: 'Add values separated by a comma',\n },\n {\n when: (answers: AttributeAnswer) => 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":";;AASA,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,uBAAuB,OAAOC,QAAAA,GAAAA;AAClC,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,IA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3H;IAEA,OAAOf,UAAAA;AACT;;;;"}
|
|
@@ -1,6 +1,28 @@
|
|
|
1
|
-
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import fs from 'fs-extra';
|
|
2
3
|
declare const _default: (action: string, basePath: string, { rootFolder }?: {
|
|
3
4
|
rootFolder?: boolean | undefined;
|
|
4
|
-
}) =>
|
|
5
|
+
}) => ({
|
|
6
|
+
type: string;
|
|
7
|
+
name: string;
|
|
8
|
+
message: string;
|
|
9
|
+
choices: {
|
|
10
|
+
name: string;
|
|
11
|
+
value: string;
|
|
12
|
+
}[];
|
|
13
|
+
when?: undefined;
|
|
14
|
+
} | {
|
|
15
|
+
when: (answers: any) => boolean;
|
|
16
|
+
type: string;
|
|
17
|
+
message: string;
|
|
18
|
+
name: string;
|
|
19
|
+
choices(): Promise<fs.Dirent[]>;
|
|
20
|
+
} | {
|
|
21
|
+
when: (answers: any) => boolean;
|
|
22
|
+
type: string;
|
|
23
|
+
message: string;
|
|
24
|
+
name: string;
|
|
25
|
+
choices(): Promise<string[]>;
|
|
26
|
+
})[];
|
|
5
27
|
export default _default;
|
|
6
28
|
//# sourceMappingURL=get-destination-prompts.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-destination-prompts.d.ts","sourceRoot":"","sources":["../../../src/plops/prompts/get-destination-prompts.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"get-destination-prompts.d.ts","sourceRoot":"","sources":["../../../src/plops/prompts/get-destination-prompts.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,MAAM,UAAU,CAAC;iCAEF,MAAM,YAAY,MAAM;;;;;;;;;;;;oBAyB1B,GAAG;;;;;;oBAuBH,GAAG;;;;;;AAhDzB,wBAyEE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-destination-prompts.js","sources":["../../../src/plops/prompts/get-destination-prompts.ts"],"sourcesContent":["import { join } from 'path';\nimport fs from 'fs-extra';\n\
|
|
1
|
+
{"version":3,"file":"get-destination-prompts.js","sources":["../../../src/plops/prompts/get-destination-prompts.ts"],"sourcesContent":["import { join } from 'path';\nimport fs from 'fs-extra';\n\nexport default (action: string, basePath: string, { rootFolder = false } = {}) => {\n return [\n {\n type: 'list',\n name: 'destination',\n message: `Where do you want to add this ${action}?`,\n choices: [\n ...(rootFolder\n ? [\n {\n name: `Add ${action} to root of project`,\n value: 'root',\n },\n ]\n : [\n {\n name: `Add ${action} to new API`,\n value: 'new',\n },\n ]),\n { name: `Add ${action} to an existing API`, value: 'api' },\n { name: `Add ${action} to an existing plugin`, value: 'plugin' },\n ],\n },\n {\n when: (answers: any) => answers.destination === 'api',\n type: 'list',\n message: 'Which API is this for?',\n name: 'api',\n async choices() {\n const apiPath = join(basePath, 'api');\n const exists = await fs.pathExists(apiPath);\n\n if (!exists) {\n throw Error('Couldn\\'t find an \"api\" directory');\n }\n\n const apiDir = await fs.readdir(apiPath, { withFileTypes: true });\n const apiDirContent = apiDir.filter((fd) => fd.isDirectory());\n\n if (apiDirContent.length === 0) {\n throw Error('The \"api\" directory is empty');\n }\n\n return apiDirContent;\n },\n },\n {\n when: (answers: any) => answers.destination === 'plugin',\n type: 'list',\n message: 'Which plugin is this for?',\n name: 'plugin',\n async choices() {\n const pluginsPath = join(basePath, 'plugins');\n const exists = await fs.pathExists(pluginsPath);\n\n if (!exists) {\n throw Error('Couldn\\'t find a \"plugins\" directory');\n }\n\n const pluginsDir = await fs.readdir(pluginsPath);\n const pluginsDirContent = pluginsDir.filter((api) =>\n fs.lstatSync(join(pluginsPath, api)).isDirectory()\n );\n\n if (pluginsDirContent.length === 0) {\n throw Error('The \"plugins\" directory is empty');\n }\n\n return pluginsDirContent;\n },\n },\n ];\n};\n"],"names":["action","basePath","rootFolder","type","name","message","choices","value","when","answers","destination","apiPath","join","exists","fs","pathExists","Error","apiDir","readdir","withFileTypes","apiDirContent","filter","fd","isDirectory","length","pluginsPath","pluginsDir","pluginsDirContent","api","lstatSync"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
|
@@ -1 +1 @@
|
|
|
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\
|
|
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\nexport default (action: string, basePath: string, { rootFolder = false } = {}) => {\n return [\n {\n type: 'list',\n name: 'destination',\n message: `Where do you want to add this ${action}?`,\n choices: [\n ...(rootFolder\n ? [\n {\n name: `Add ${action} to root of project`,\n value: 'root',\n },\n ]\n : [\n {\n name: `Add ${action} to new API`,\n value: 'new',\n },\n ]),\n { name: `Add ${action} to an existing API`, value: 'api' },\n { name: `Add ${action} to an existing plugin`, value: 'plugin' },\n ],\n },\n {\n when: (answers: any) => answers.destination === 'api',\n type: 'list',\n message: 'Which API is this for?',\n name: 'api',\n async choices() {\n const apiPath = join(basePath, 'api');\n const exists = await fs.pathExists(apiPath);\n\n if (!exists) {\n throw Error('Couldn\\'t find an \"api\" directory');\n }\n\n const apiDir = await fs.readdir(apiPath, { withFileTypes: true });\n const apiDirContent = apiDir.filter((fd) => fd.isDirectory());\n\n if (apiDirContent.length === 0) {\n throw Error('The \"api\" directory is empty');\n }\n\n return apiDirContent;\n },\n },\n {\n when: (answers: any) => answers.destination === 'plugin',\n type: 'list',\n message: 'Which plugin is this for?',\n name: 'plugin',\n async choices() {\n const pluginsPath = join(basePath, 'plugins');\n const exists = await fs.pathExists(pluginsPath);\n\n if (!exists) {\n throw Error('Couldn\\'t find a \"plugins\" directory');\n }\n\n const pluginsDir = await fs.readdir(pluginsPath);\n const pluginsDirContent = pluginsDir.filter((api) =>\n fs.lstatSync(join(pluginsPath, api)).isDirectory()\n );\n\n if (pluginsDirContent.length === 0) {\n throw Error('The \"plugins\" directory is empty');\n }\n\n return pluginsDirContent;\n },\n },\n ];\n};\n"],"names":["action","basePath","rootFolder","type","name","message","choices","value","when","answers","destination","apiPath","join","exists","fs","pathExists","Error","apiDir","readdir","withFileTypes","apiDirContent","filter","fd","isDirectory","length","pluginsPath","pluginsDir","pluginsDirContent","api","lstatSync"],"mappings":";;;AAGA,4BAAe,CAAA,CAACA,MAAAA,EAAgBC,QAAkB,EAAA,EAAEC,aAAa,KAAK,EAAE,GAAG,EAAE,GAAA;IAC3E,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,GAAiBA,OAAQC,CAAAA,WAAW,KAAK,KAAA;YAChDP,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,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kBH,MAAM,KAAK,CAAG,EAAA;AAClC,oBAAA,MAAMR,KAAM,CAAA,kCAAA,CAAA;AACd;gBAEA,OAAOW,iBAAAA;AACT;AACF;AACD,KAAA;AACH,CAAA;;;;"}
|
|
@@ -1,4 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
declare const questions: {
|
|
2
|
+
type: string;
|
|
3
|
+
name: string;
|
|
4
|
+
message: string;
|
|
5
|
+
default: string;
|
|
6
|
+
choices: {
|
|
7
|
+
name: string;
|
|
8
|
+
value: string;
|
|
9
|
+
}[];
|
|
10
|
+
validate: (input: string) => true | "You must provide an input" | "Please use only letters, '-' and no spaces";
|
|
11
|
+
}[];
|
|
3
12
|
export default questions;
|
|
4
13
|
//# sourceMappingURL=kind-prompts.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"kind-prompts.d.ts","sourceRoot":"","sources":["../../../src/plops/prompts/kind-prompts.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"kind-prompts.d.ts","sourceRoot":"","sources":["../../../src/plops/prompts/kind-prompts.ts"],"names":[],"mappings":"AAEA,QAAA,MAAM,SAAS;;;;;;;;;sBAUO,MAAM;GAE3B,CAAC;AAEF,eAAe,SAAS,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"kind-prompts.js","sources":["../../../src/plops/prompts/kind-prompts.ts"],"sourcesContent":["import
|
|
1
|
+
{"version":3,"file":"kind-prompts.js","sources":["../../../src/plops/prompts/kind-prompts.ts"],"sourcesContent":["import validateInput from '../utils/validate-input';\n\nconst questions = [\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":";;;;AAEA,MAAMA,SAAY,GAAA;AAChB,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;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"kind-prompts.mjs","sources":["../../../src/plops/prompts/kind-prompts.ts"],"sourcesContent":["import
|
|
1
|
+
{"version":3,"file":"kind-prompts.mjs","sources":["../../../src/plops/prompts/kind-prompts.ts"],"sourcesContent":["import validateInput from '../utils/validate-input';\n\nconst questions = [\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":";;AAEA,MAAMA,SAAY,GAAA;AAChB,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;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@strapi/generators",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.18.1",
|
|
4
4
|
"description": "Interactive API generator.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"strapi",
|
|
@@ -49,19 +49,19 @@
|
|
|
49
49
|
},
|
|
50
50
|
"dependencies": {
|
|
51
51
|
"@sindresorhus/slugify": "1.1.0",
|
|
52
|
-
"@strapi/typescript-utils": "5.
|
|
53
|
-
"@strapi/utils": "5.
|
|
52
|
+
"@strapi/typescript-utils": "5.18.1",
|
|
53
|
+
"@strapi/utils": "5.18.1",
|
|
54
54
|
"chalk": "4.1.2",
|
|
55
55
|
"copyfiles": "2.4.1",
|
|
56
56
|
"fs-extra": "11.2.0",
|
|
57
|
-
"
|
|
57
|
+
"handlebars": "4.7.7",
|
|
58
58
|
"plop": "4.0.1",
|
|
59
59
|
"pluralize": "8.0.0"
|
|
60
60
|
},
|
|
61
61
|
"devDependencies": {
|
|
62
62
|
"@types/fs-extra": "11.0.4",
|
|
63
|
-
"eslint-config-custom": "5.
|
|
64
|
-
"tsconfig": "5.
|
|
63
|
+
"eslint-config-custom": "5.18.1",
|
|
64
|
+
"tsconfig": "5.18.1"
|
|
65
65
|
},
|
|
66
66
|
"engines": {
|
|
67
67
|
"node": ">=18.0.0 <=22.x.x",
|