@strapi/generators 0.0.0-next.f0a0bc26f5ef0693aaea2a616bc6b816cfee54b6 → 0.0.0-next.f0f36e3df4b18f167036dcbca529dcb933bf4e1d

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (109) hide show
  1. package/dist/index.d.ts +8 -4
  2. package/dist/index.d.ts.map +1 -1
  3. package/dist/index.js +89 -50
  4. package/dist/index.js.map +1 -1
  5. package/dist/index.mjs +89 -29
  6. package/dist/index.mjs.map +1 -1
  7. package/dist/plopfile.js +25 -584
  8. package/dist/plopfile.js.map +1 -1
  9. package/dist/plopfile.mjs +24 -581
  10. package/dist/plopfile.mjs.map +1 -1
  11. package/dist/plops/api.d.ts.map +1 -1
  12. package/dist/plops/api.js +149 -0
  13. package/dist/plops/api.js.map +1 -0
  14. package/dist/plops/api.mjs +147 -0
  15. package/dist/plops/api.mjs.map +1 -0
  16. package/dist/plops/content-type.d.ts.map +1 -1
  17. package/dist/plops/content-type.js +245 -0
  18. package/dist/plops/content-type.js.map +1 -0
  19. package/dist/plops/content-type.mjs +243 -0
  20. package/dist/plops/content-type.mjs.map +1 -0
  21. package/dist/plops/controller.d.ts.map +1 -1
  22. package/dist/plops/controller.js +73 -0
  23. package/dist/plops/controller.js.map +1 -0
  24. package/dist/plops/controller.mjs +71 -0
  25. package/dist/plops/controller.mjs.map +1 -0
  26. package/dist/plops/middleware.d.ts.map +1 -1
  27. package/dist/plops/middleware.js +75 -0
  28. package/dist/plops/middleware.js.map +1 -0
  29. package/dist/plops/middleware.mjs +73 -0
  30. package/dist/plops/middleware.mjs.map +1 -0
  31. package/dist/plops/migration.js +35 -0
  32. package/dist/plops/migration.js.map +1 -0
  33. package/dist/plops/migration.mjs +33 -0
  34. package/dist/plops/migration.mjs.map +1 -0
  35. package/dist/plops/policy.d.ts.map +1 -1
  36. package/dist/plops/policy.js +75 -0
  37. package/dist/plops/policy.js.map +1 -0
  38. package/dist/plops/policy.mjs +73 -0
  39. package/dist/plops/policy.mjs.map +1 -0
  40. package/dist/plops/prompts/bootstrap-api-prompts.d.ts +6 -2
  41. package/dist/plops/prompts/bootstrap-api-prompts.d.ts.map +1 -1
  42. package/dist/plops/prompts/bootstrap-api-prompts.js +13 -0
  43. package/dist/plops/prompts/bootstrap-api-prompts.js.map +1 -0
  44. package/dist/plops/prompts/bootstrap-api-prompts.mjs +11 -0
  45. package/dist/plops/prompts/bootstrap-api-prompts.mjs.map +1 -0
  46. package/dist/plops/prompts/ct-names-prompts.d.ts +18 -2
  47. package/dist/plops/prompts/ct-names-prompts.d.ts.map +1 -1
  48. package/dist/plops/prompts/ct-names-prompts.js +44 -0
  49. package/dist/plops/prompts/ct-names-prompts.js.map +1 -0
  50. package/dist/plops/prompts/ct-names-prompts.mjs +42 -0
  51. package/dist/plops/prompts/ct-names-prompts.mjs.map +1 -0
  52. package/dist/plops/prompts/get-attributes-prompts.d.ts +8 -2
  53. package/dist/plops/prompts/get-attributes-prompts.d.ts.map +1 -1
  54. package/dist/plops/prompts/get-attributes-prompts.js +101 -0
  55. package/dist/plops/prompts/get-attributes-prompts.js.map +1 -0
  56. package/dist/plops/prompts/get-attributes-prompts.mjs +99 -0
  57. package/dist/plops/prompts/get-attributes-prompts.mjs.map +1 -0
  58. package/dist/plops/prompts/get-destination-prompts.d.ts +24 -2
  59. package/dist/plops/prompts/get-destination-prompts.d.ts.map +1 -1
  60. package/dist/plops/prompts/get-destination-prompts.js +78 -0
  61. package/dist/plops/prompts/get-destination-prompts.js.map +1 -0
  62. package/dist/plops/prompts/get-destination-prompts.mjs +76 -0
  63. package/dist/plops/prompts/get-destination-prompts.mjs.map +1 -0
  64. package/dist/plops/prompts/kind-prompts.d.ts +11 -2
  65. package/dist/plops/prompts/kind-prompts.d.ts.map +1 -1
  66. package/dist/plops/prompts/kind-prompts.js +26 -0
  67. package/dist/plops/prompts/kind-prompts.js.map +1 -0
  68. package/dist/plops/prompts/kind-prompts.mjs +24 -0
  69. package/dist/plops/prompts/kind-prompts.mjs.map +1 -0
  70. package/dist/plops/service.d.ts.map +1 -1
  71. package/dist/plops/service.js +71 -0
  72. package/dist/plops/service.js.map +1 -0
  73. package/dist/plops/service.mjs +69 -0
  74. package/dist/plops/service.mjs.map +1 -0
  75. package/dist/plops/utils/extend-plugin-index-files.d.ts +8 -0
  76. package/dist/plops/utils/extend-plugin-index-files.d.ts.map +1 -0
  77. package/dist/plops/utils/extend-plugin-index-files.js +356 -0
  78. package/dist/plops/utils/extend-plugin-index-files.js.map +1 -0
  79. package/dist/plops/utils/extend-plugin-index-files.mjs +335 -0
  80. package/dist/plops/utils/extend-plugin-index-files.mjs.map +1 -0
  81. package/dist/plops/utils/get-file-path.d.ts +1 -1
  82. package/dist/plops/utils/get-file-path.js +17 -0
  83. package/dist/plops/utils/get-file-path.js.map +1 -0
  84. package/dist/plops/utils/get-file-path.mjs +15 -0
  85. package/dist/plops/utils/get-file-path.mjs.map +1 -0
  86. package/dist/plops/utils/get-formatted-date.js +8 -0
  87. package/dist/plops/utils/get-formatted-date.js.map +1 -0
  88. package/dist/plops/utils/get-formatted-date.mjs +6 -0
  89. package/dist/plops/utils/get-formatted-date.mjs.map +1 -0
  90. package/dist/plops/utils/validate-attribute-input.js +12 -0
  91. package/dist/plops/utils/validate-attribute-input.js.map +1 -0
  92. package/dist/plops/utils/validate-attribute-input.mjs +10 -0
  93. package/dist/plops/utils/validate-attribute-input.mjs.map +1 -0
  94. package/dist/plops/utils/validate-file-name-input.js +12 -0
  95. package/dist/plops/utils/validate-file-name-input.js.map +1 -0
  96. package/dist/plops/utils/validate-file-name-input.mjs +10 -0
  97. package/dist/plops/utils/validate-file-name-input.mjs.map +1 -0
  98. package/dist/plops/utils/validate-input.js +12 -0
  99. package/dist/plops/utils/validate-input.js.map +1 -0
  100. package/dist/plops/utils/validate-input.mjs +10 -0
  101. package/dist/plops/utils/validate-input.mjs.map +1 -0
  102. package/dist/templates/js/plugin/plugin.index.js.hbs +3 -0
  103. package/dist/templates/js/plugin/plugin.routes.index.js.hbs +12 -0
  104. package/dist/templates/js/plugin/plugin.routes.type.index.js.hbs +6 -0
  105. package/dist/templates/ts/core-controller.ts.hbs +1 -1
  106. package/dist/templates/ts/plugin/plugin.index.ts.hbs +1 -0
  107. package/dist/templates/ts/plugin/plugin.routes.index.ts.hbs +9 -0
  108. package/dist/templates/ts/plugin/plugin.routes.type.index.ts.hbs +4 -0
  109. package/package.json +17 -12
package/dist/index.d.ts CHANGED
@@ -1,6 +1,10 @@
1
1
  export declare const runCLI: () => Promise<void>;
2
- export declare const generate: <T extends Record<string, any>>(generatorName: string, options: T, { dir, plopFile }?: {
3
- dir?: string | undefined;
4
- plopFile?: string | undefined;
5
- }) => Promise<void>;
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
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,MAAM,qBAYlB,CAAC;AAGF,eAAO,MAAM,QAAQ,iDACJ,MAAM,WACZ,CAAC;;;mBAcX,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,MAAM,qBAiBlB,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,58 +1,97 @@
1
- "use strict";
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __copyProps = (to, from, except, desc) => {
9
- if (from && typeof from === "object" || typeof from === "function") {
10
- for (let key of __getOwnPropNames(from))
11
- if (!__hasOwnProp.call(to, key) && key !== except)
12
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
13
- }
14
- return to;
1
+ 'use strict';
2
+
3
+ var node_path = require('node:path');
4
+ var handlebars = require('handlebars');
5
+ var fs = require('fs-extra');
6
+
7
+ // Starts the Plop CLI programmatically
8
+ const runCLI = async ()=>{
9
+ const { Plop, run } = await import('plop');
10
+ Plop.prepare({
11
+ configPath: node_path.join(__dirname, 'plopfile.js')
12
+ }, (env)=>{
13
+ Plop.execute(env, [], (env, argv)=>{
14
+ const options = {
15
+ ...env,
16
+ dest: node_path.join(process.cwd(), 'src')
17
+ };
18
+ return run(options, argv, true); // Pass the third argument 'true' for passArgsBeforeDashes
19
+ });
20
+ });
15
21
  };
16
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
17
- // If the importer is in node compatibility mode or this is not an ESM
18
- // file that has been converted to a CommonJS file using a Babel-
19
- // compatible transform (i.e. "__esModule" has not been set), then set
20
- // "default" to the CommonJS "module.exports" for node compatibility.
21
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
22
- mod
23
- ));
24
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
25
- const node_path = require("node:path");
26
- const nodePlop = require("node-plop");
27
- const _interopDefault = (e) => e && e.__esModule ? e : { default: e };
28
- const nodePlop__default = /* @__PURE__ */ _interopDefault(nodePlop);
29
- const runCLI = async () => {
30
- const { Plop, run } = await import("plop");
31
- Plop.prepare(
32
- {
33
- configPath: node_path.join(__dirname, "plopfile.js")
34
- },
35
- (env) => {
36
- const argv = process.argv.slice(2);
37
- Plop.execute(env, argv, (env2, argv2) => run(env2, argv2, true));
22
+ const generate = async (generatorName, options, { dir = process.cwd(), plopFile = 'plopfile.js' } = {})=>{
23
+ // Resolve the absolute path to the plopfile (generator definitions)
24
+ const plopfilePath = node_path.join(__dirname, plopFile);
25
+ // Dynamically require the plopfile module.
26
+ // Note: This allows loading either CommonJS or transpiled ESM plopfiles.
27
+ // eslint-disable-next-line @typescript-eslint/no-var-requires
28
+ const plopModule = require(plopfilePath);
29
+ // Internal objects to store registered generators and helpers.
30
+ // These will be populated by the plopfile when it is executed.
31
+ const generators = {};
32
+ const helpers = {};
33
+ // Minimal mock Plop API implementation, exposing only the methods needed by our plopfile.
34
+ // This allows the plopfile to register generators and helpers as it would in a real Plop environment.
35
+ const plopApi = {
36
+ setGenerator (name, config) {
37
+ generators[name] = config;
38
+ },
39
+ setHelper (name, fn) {
40
+ helpers[name] = fn;
41
+ },
42
+ getDestBasePath () {
43
+ return node_path.join(dir, 'src');
44
+ },
45
+ setWelcomeMessage () {}
46
+ };
47
+ // Execute the plopfile, passing in our API.
48
+ // This will populate the `generators` and `helpers` objects.
49
+ // Support both CommonJS and ESM default exports.
50
+ if (typeof plopModule.default === 'function') {
51
+ plopModule.default(plopApi);
52
+ } else {
53
+ plopModule(plopApi);
38
54
  }
39
- );
55
+ const generator = generators[generatorName];
56
+ if (!generator) {
57
+ throw new Error(`Generator "${generatorName}" not found`);
58
+ }
59
+ registerHandlebarsHelpers(helpers);
60
+ const actions = typeof generator.actions === 'function' ? generator.actions(options) : generator.actions || [];
61
+ await executeActions(actions, options, dir);
62
+ return {
63
+ success: true
64
+ };
65
+ };
66
+ const registerHandlebarsHelpers = (helpers)=>{
67
+ Object.entries(helpers).forEach(([name, fn])=>handlebars.registerHelper(name, fn));
40
68
  };
41
- const generate = async (generatorName, options, { dir = process.cwd(), plopFile = "plopfile.js" } = {}) => {
42
- const plop = nodePlop__default.default(node_path.join(__dirname, plopFile), {
43
- destBasePath: node_path.join(dir, "src"),
44
- force: false
45
- });
46
- const generator = plop.getGenerator(generatorName);
47
- await generator.runActions(options, {
48
- onSuccess() {
49
- },
50
- onFailure() {
51
- },
52
- onComment() {
69
+ // Executes generator actions: add or modify files as specified
70
+ const executeActions = async (actions, options, dir)=>{
71
+ for (const action of actions){
72
+ const outputPath = handlebars.compile(action.path)(options);
73
+ const fullPath = node_path.join(dir, 'src', outputPath);
74
+ if (action.type === 'add' && action.templateFile) {
75
+ const templatePath = node_path.join(__dirname, action.templateFile);
76
+ const templateContent = await fs.readFile(templatePath, 'utf8');
77
+ const compiled = handlebars.compile(templateContent);
78
+ const output = compiled({
79
+ ...options,
80
+ ...action.data
81
+ });
82
+ await fs.ensureDir(node_path.dirname(fullPath));
83
+ await fs.writeFile(fullPath, output);
84
+ }
85
+ if (action.type === 'modify') {
86
+ if (await fs.pathExists(fullPath)) {
87
+ const content = await fs.readFile(fullPath, 'utf8');
88
+ const modified = action.transform ? action.transform(content) : content;
89
+ await fs.writeFile(fullPath, modified);
90
+ }
91
+ }
53
92
  }
54
- });
55
93
  };
94
+
56
95
  exports.generate = generate;
57
96
  exports.runCLI = runCLI;
58
97
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../src/index.ts"],"sourcesContent":["import { join } from 'node:path';\nimport nodePlop from 'node-plop';\n\n// Starts the Plop CLI programmatically\nexport const runCLI = async () => {\n const { Plop, run } = await import('plop');\n\n Plop.prepare(\n {\n configPath: join(__dirname, 'plopfile.js'),\n },\n (env) => {\n const argv = process.argv.slice(2); // Extract command-line arguments\n Plop.execute(env, argv, (env, argv) => run(env, argv, true)); // Pass the third argument 'true' for passArgsBeforeDashes\n }\n );\n};\n\n// Runs a generator programmatically without prompts\nexport const generate = async <T extends Record<string, any>>(\n generatorName: string,\n options: T,\n { dir = process.cwd(), plopFile = 'plopfile.js' } = {}\n) => {\n const plop = nodePlop(join(__dirname, plopFile), {\n destBasePath: join(dir, 'src'),\n force: false,\n });\n\n const generator = plop.getGenerator(generatorName);\n await generator.runActions(options satisfies T, {\n onSuccess() {},\n onFailure() {},\n onComment() {},\n });\n};\n"],"names":["join","env","argv","nodePlop"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIO,MAAM,SAAS,YAAY;AAChC,QAAM,EAAE,MAAM,IAAQ,IAAA,MAAM,OAAO,MAAM;AAEpC,OAAA;AAAA,IACH;AAAA,MACE,YAAYA,UAAAA,KAAK,WAAW,aAAa;AAAA,IAC3C;AAAA,IACA,CAAC,QAAQ;AACP,YAAM,OAAO,QAAQ,KAAK,MAAM,CAAC;AAC5B,WAAA,QAAQ,KAAK,MAAM,CAACC,MAAKC,UAAS,IAAID,MAAKC,OAAM,IAAI,CAAC;AAAA,IAC7D;AAAA,EAAA;AAEJ;AAGO,MAAM,WAAW,OACtB,eACA,SACA,EAAE,MAAM,QAAQ,OAAO,WAAW,cAAc,IAAI,CAAA,MACjD;AACH,QAAM,OAAOC,kBAAA,QAASH,UAAK,KAAA,WAAW,QAAQ,GAAG;AAAA,IAC/C,cAAcA,UAAAA,KAAK,KAAK,KAAK;AAAA,IAC7B,OAAO;AAAA,EAAA,CACR;AAEK,QAAA,YAAY,KAAK,aAAa,aAAa;AAC3C,QAAA,UAAU,WAAW,SAAqB;AAAA,IAC9C,YAAY;AAAA,IAAC;AAAA,IACb,YAAY;AAAA,IAAC;AAAA,IACb,YAAY;AAAA,IAAC;AAAA,EAAA,CACd;AACH;;;"}
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 Plop.execute(env, [], (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","execute","argv","options","dest","process","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;AACCN,QAAAA,IAAAA,CAAKO,OAAO,CAACD,GAAAA,EAAK,EAAE,EAAE,CAACA,GAAKE,EAAAA,IAAAA,GAAAA;AAC1B,YAAA,MAAMC,OAAU,GAAA;AACd,gBAAA,GAAGH,GAAG;gBACNI,IAAMN,EAAAA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AAAA,CAAAA;AACpC,YAAA,MAAMI,SAASD,QAAS,CAAA;AAAE,gBAAA,GAAG5C,OAAO;AAAE,gBAAA,GAAGiC,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,34 +1,94 @@
1
- import { join } from "node:path";
2
- import nodePlop from "node-plop";
3
- const runCLI = async () => {
4
- const { Plop, run } = await import("plop");
5
- Plop.prepare(
6
- {
7
- configPath: join(__dirname, "plopfile.js")
8
- },
9
- (env) => {
10
- const argv = process.argv.slice(2);
11
- Plop.execute(env, argv, (env2, argv2) => run(env2, argv2, true));
12
- }
13
- );
1
+ import { join, dirname } from 'node:path';
2
+ import handlebars from 'handlebars';
3
+ import fs from 'fs-extra';
4
+
5
+ // Starts the Plop CLI programmatically
6
+ const runCLI = async ()=>{
7
+ const { Plop, run } = await import('plop');
8
+ Plop.prepare({
9
+ configPath: join(__dirname, 'plopfile.js')
10
+ }, (env)=>{
11
+ Plop.execute(env, [], (env, argv)=>{
12
+ const options = {
13
+ ...env,
14
+ dest: join(process.cwd(), 'src')
15
+ };
16
+ return run(options, argv, true); // Pass the third argument 'true' for passArgsBeforeDashes
17
+ });
18
+ });
14
19
  };
15
- const generate = async (generatorName, options, { dir = process.cwd(), plopFile = "plopfile.js" } = {}) => {
16
- const plop = nodePlop(join(__dirname, plopFile), {
17
- destBasePath: join(dir, "src"),
18
- force: false
19
- });
20
- const generator = plop.getGenerator(generatorName);
21
- await generator.runActions(options, {
22
- onSuccess() {
23
- },
24
- onFailure() {
25
- },
26
- onComment() {
20
+ const generate = async (generatorName, options, { dir = process.cwd(), plopFile = 'plopfile.js' } = {})=>{
21
+ // Resolve the absolute path to the plopfile (generator definitions)
22
+ const plopfilePath = join(__dirname, plopFile);
23
+ // Dynamically require the plopfile module.
24
+ // Note: This allows loading either CommonJS or transpiled ESM plopfiles.
25
+ // eslint-disable-next-line @typescript-eslint/no-var-requires
26
+ const plopModule = require(plopfilePath);
27
+ // Internal objects to store registered generators and helpers.
28
+ // These will be populated by the plopfile when it is executed.
29
+ const generators = {};
30
+ const helpers = {};
31
+ // Minimal mock Plop API implementation, exposing only the methods needed by our plopfile.
32
+ // This allows the plopfile to register generators and helpers as it would in a real Plop environment.
33
+ const plopApi = {
34
+ setGenerator (name, config) {
35
+ generators[name] = config;
36
+ },
37
+ setHelper (name, fn) {
38
+ helpers[name] = fn;
39
+ },
40
+ getDestBasePath () {
41
+ return join(dir, 'src');
42
+ },
43
+ setWelcomeMessage () {}
44
+ };
45
+ // Execute the plopfile, passing in our API.
46
+ // This will populate the `generators` and `helpers` objects.
47
+ // Support both CommonJS and ESM default exports.
48
+ if (typeof plopModule.default === 'function') {
49
+ plopModule.default(plopApi);
50
+ } else {
51
+ plopModule(plopApi);
52
+ }
53
+ const generator = generators[generatorName];
54
+ if (!generator) {
55
+ throw new Error(`Generator "${generatorName}" not found`);
27
56
  }
28
- });
57
+ registerHandlebarsHelpers(helpers);
58
+ const actions = typeof generator.actions === 'function' ? generator.actions(options) : generator.actions || [];
59
+ await executeActions(actions, options, dir);
60
+ return {
61
+ success: true
62
+ };
29
63
  };
30
- export {
31
- generate,
32
- runCLI
64
+ const registerHandlebarsHelpers = (helpers)=>{
65
+ Object.entries(helpers).forEach(([name, fn])=>handlebars.registerHelper(name, fn));
66
+ };
67
+ // Executes generator actions: add or modify files as specified
68
+ const executeActions = async (actions, options, dir)=>{
69
+ for (const action of actions){
70
+ const outputPath = handlebars.compile(action.path)(options);
71
+ const fullPath = join(dir, 'src', outputPath);
72
+ if (action.type === 'add' && action.templateFile) {
73
+ const templatePath = join(__dirname, action.templateFile);
74
+ const templateContent = await fs.readFile(templatePath, 'utf8');
75
+ const compiled = handlebars.compile(templateContent);
76
+ const output = compiled({
77
+ ...options,
78
+ ...action.data
79
+ });
80
+ await fs.ensureDir(dirname(fullPath));
81
+ await fs.writeFile(fullPath, output);
82
+ }
83
+ if (action.type === 'modify') {
84
+ if (await fs.pathExists(fullPath)) {
85
+ const content = await fs.readFile(fullPath, 'utf8');
86
+ const modified = action.transform ? action.transform(content) : content;
87
+ await fs.writeFile(fullPath, modified);
88
+ }
89
+ }
90
+ }
33
91
  };
92
+
93
+ export { generate, runCLI };
34
94
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","sources":["../src/index.ts"],"sourcesContent":["import { join } from 'node:path';\nimport nodePlop from 'node-plop';\n\n// Starts the Plop CLI programmatically\nexport const runCLI = async () => {\n const { Plop, run } = await import('plop');\n\n Plop.prepare(\n {\n configPath: join(__dirname, 'plopfile.js'),\n },\n (env) => {\n const argv = process.argv.slice(2); // Extract command-line arguments\n Plop.execute(env, argv, (env, argv) => run(env, argv, true)); // Pass the third argument 'true' for passArgsBeforeDashes\n }\n );\n};\n\n// Runs a generator programmatically without prompts\nexport const generate = async <T extends Record<string, any>>(\n generatorName: string,\n options: T,\n { dir = process.cwd(), plopFile = 'plopfile.js' } = {}\n) => {\n const plop = nodePlop(join(__dirname, plopFile), {\n destBasePath: join(dir, 'src'),\n force: false,\n });\n\n const generator = plop.getGenerator(generatorName);\n await generator.runActions(options satisfies T, {\n onSuccess() {},\n onFailure() {},\n onComment() {},\n });\n};\n"],"names":["env","argv"],"mappings":";;AAIO,MAAM,SAAS,YAAY;AAChC,QAAM,EAAE,MAAM,IAAQ,IAAA,MAAM,OAAO,MAAM;AAEpC,OAAA;AAAA,IACH;AAAA,MACE,YAAY,KAAK,WAAW,aAAa;AAAA,IAC3C;AAAA,IACA,CAAC,QAAQ;AACP,YAAM,OAAO,QAAQ,KAAK,MAAM,CAAC;AAC5B,WAAA,QAAQ,KAAK,MAAM,CAACA,MAAKC,UAAS,IAAID,MAAKC,OAAM,IAAI,CAAC;AAAA,IAC7D;AAAA,EAAA;AAEJ;AAGO,MAAM,WAAW,OACtB,eACA,SACA,EAAE,MAAM,QAAQ,OAAO,WAAW,cAAc,IAAI,CAAA,MACjD;AACH,QAAM,OAAO,SAAS,KAAK,WAAW,QAAQ,GAAG;AAAA,IAC/C,cAAc,KAAK,KAAK,KAAK;AAAA,IAC7B,OAAO;AAAA,EAAA,CACR;AAEK,QAAA,YAAY,KAAK,aAAa,aAAa;AAC3C,QAAA,UAAU,WAAW,SAAqB;AAAA,IAC9C,YAAY;AAAA,IAAC;AAAA,IACb,YAAY;AAAA,IAAC;AAAA,IACb,YAAY;AAAA,IAAC;AAAA,EAAA,CACd;AACH;"}
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 Plop.execute(env, [], (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","execute","argv","options","dest","process","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,KAAKC,SAAW,EAAA,aAAA;AAC9B,KAAA,EACA,CAACC,GAAAA,GAAAA;AACCN,QAAAA,IAAAA,CAAKO,OAAO,CAACD,GAAAA,EAAK,EAAE,EAAE,CAACA,GAAKE,EAAAA,IAAAA,GAAAA;AAC1B,YAAA,MAAMC,OAAU,GAAA;AACd,gBAAA,GAAGH,GAAG;gBACNI,IAAMN,EAAAA,IAAAA,CAAKO,OAAQC,CAAAA,GAAG,EAAI,EAAA,KAAA;AAC5B,aAAA;AACA,YAAA,OAAOX,GAAIQ,CAAAA,OAAAA,EAASD,IAAM,E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