@ingenyus/swarm-wasp 0.1.0 → 0.2.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.
Files changed (126) hide show
  1. package/README.md +229 -21
  2. package/dist/.tsbuildinfo +1 -1
  3. package/dist/common/filesystem.d.ts +0 -14
  4. package/dist/common/filesystem.d.ts.map +1 -1
  5. package/dist/common/filesystem.js +123 -0
  6. package/dist/common/index.d.ts +0 -1
  7. package/dist/common/index.d.ts.map +1 -1
  8. package/dist/common/index.js +366 -0
  9. package/dist/common/prisma.js +140 -0
  10. package/dist/common/schemas.d.ts +8 -42
  11. package/dist/common/schemas.d.ts.map +1 -1
  12. package/dist/common/schemas.js +54 -0
  13. package/dist/common/templates.js +52 -0
  14. package/dist/generators/action/action-generator.d.ts +16 -29
  15. package/dist/generators/action/action-generator.d.ts.map +1 -1
  16. package/dist/generators/action/action-generator.js +1425 -0
  17. package/dist/generators/action/index.js +1425 -0
  18. package/dist/generators/action/schema.d.ts +11 -23
  19. package/dist/generators/action/schema.d.ts.map +1 -1
  20. package/dist/generators/action/schema.js +115 -0
  21. package/dist/generators/api/api-generator.d.ts +19 -26
  22. package/dist/generators/api/api-generator.d.ts.map +1 -1
  23. package/dist/generators/api/api-generator.js +1104 -0
  24. package/dist/generators/api/index.js +1104 -0
  25. package/dist/generators/api/schema.d.ts +13 -21
  26. package/dist/generators/api/schema.d.ts.map +1 -1
  27. package/dist/generators/api/schema.js +117 -0
  28. package/dist/generators/api-namespace/api-namespace-generator.d.ts +10 -17
  29. package/dist/generators/api-namespace/api-namespace-generator.d.ts.map +1 -1
  30. package/dist/generators/api-namespace/api-namespace-generator.js +1028 -0
  31. package/dist/generators/api-namespace/index.js +1028 -0
  32. package/dist/generators/api-namespace/schema.d.ts +4 -12
  33. package/dist/generators/api-namespace/schema.d.ts.map +1 -1
  34. package/dist/generators/api-namespace/schema.js +89 -0
  35. package/dist/generators/base/{entity-generator.base.d.ts → component-generator.base.d.ts} +9 -9
  36. package/dist/generators/base/component-generator.base.d.ts.map +1 -0
  37. package/dist/generators/base/component-generator.base.js +931 -0
  38. package/dist/generators/base/index.d.ts +1 -1
  39. package/dist/generators/base/index.d.ts.map +1 -1
  40. package/dist/generators/base/index.js +1330 -0
  41. package/dist/generators/base/operation-generator.base.d.ts +12 -3
  42. package/dist/generators/base/operation-generator.base.d.ts.map +1 -1
  43. package/dist/generators/base/operation-generator.base.js +1331 -0
  44. package/dist/generators/base/wasp-generator.base.d.ts +2 -1
  45. package/dist/generators/base/wasp-generator.base.d.ts.map +1 -1
  46. package/dist/generators/base/wasp-generator.base.js +706 -0
  47. package/dist/generators/config/config-generator.d.ts +7 -4
  48. package/dist/generators/config/config-generator.d.ts.map +1 -1
  49. package/dist/generators/config/config-generator.js +0 -0
  50. package/dist/generators/config/index.js +596 -0
  51. package/dist/generators/config/wasp-config-generator.d.ts +1 -1
  52. package/dist/generators/config/wasp-config-generator.d.ts.map +1 -1
  53. package/dist/generators/config/wasp-config-generator.js +596 -0
  54. package/dist/generators/crud/crud-generator.d.ts +34 -22
  55. package/dist/generators/crud/crud-generator.d.ts.map +1 -1
  56. package/dist/generators/crud/crud-generator.js +1550 -0
  57. package/dist/generators/crud/index.js +1550 -0
  58. package/dist/generators/crud/schema.d.ts +25 -18
  59. package/dist/generators/crud/schema.d.ts.map +1 -1
  60. package/dist/generators/crud/schema.js +133 -0
  61. package/dist/generators/feature/feature-generator.d.ts +20 -0
  62. package/dist/generators/feature/feature-generator.d.ts.map +1 -0
  63. package/dist/generators/feature/feature-generator.js +765 -0
  64. package/dist/generators/feature/index.d.ts +2 -0
  65. package/dist/generators/feature/index.d.ts.map +1 -0
  66. package/dist/generators/feature/index.js +765 -0
  67. package/dist/generators/feature/schema.d.ts +5 -0
  68. package/dist/generators/feature/schema.d.ts.map +1 -0
  69. package/dist/generators/feature/schema.js +86 -0
  70. package/dist/generators/index.d.ts +1 -1
  71. package/dist/generators/index.d.ts.map +1 -1
  72. package/dist/generators/index.js +2211 -0
  73. package/dist/generators/job/index.js +1099 -0
  74. package/dist/generators/job/job-generator.d.ts +12 -23
  75. package/dist/generators/job/job-generator.d.ts.map +1 -1
  76. package/dist/generators/job/job-generator.js +1099 -0
  77. package/dist/generators/job/schema.d.ts +6 -18
  78. package/dist/generators/job/schema.d.ts.map +1 -1
  79. package/dist/generators/job/schema.js +152 -0
  80. package/dist/generators/query/index.js +1425 -0
  81. package/dist/generators/query/query-generator.d.ts +16 -29
  82. package/dist/generators/query/query-generator.d.ts.map +1 -1
  83. package/dist/generators/query/query-generator.js +1425 -0
  84. package/dist/generators/query/schema.d.ts +11 -23
  85. package/dist/generators/query/schema.d.ts.map +1 -1
  86. package/dist/generators/query/schema.js +115 -0
  87. package/dist/generators/route/index.js +1038 -0
  88. package/dist/generators/route/route-generator.d.ts +11 -20
  89. package/dist/generators/route/route-generator.d.ts.map +1 -1
  90. package/dist/generators/route/route-generator.js +1038 -0
  91. package/dist/generators/route/schema.d.ts +5 -15
  92. package/dist/generators/route/schema.d.ts.map +1 -1
  93. package/dist/generators/route/schema.js +90 -0
  94. package/dist/index.d.ts +2 -10
  95. package/dist/index.d.ts.map +1 -1
  96. package/dist/index.js +1980 -2115
  97. package/dist/plugins/index.d.ts +2 -0
  98. package/dist/plugins/index.d.ts.map +1 -0
  99. package/dist/plugins/wasp.d.ts +3 -0
  100. package/dist/plugins/wasp.d.ts.map +1 -0
  101. package/dist/types/constants.d.ts +4 -22
  102. package/dist/types/constants.d.ts.map +1 -1
  103. package/dist/types/constants.js +8 -2
  104. package/dist/types/index.d.ts +2 -2
  105. package/dist/types/index.d.ts.map +1 -1
  106. package/dist/types/index.js +8 -2
  107. package/dist/wasp-config/app.d.ts +2 -1
  108. package/dist/wasp-config/app.d.ts.map +1 -1
  109. package/dist/wasp-config/app.js +357 -0
  110. package/dist/wasp-config/index.js +357 -0
  111. package/dist/wasp-config/stubs/index.js +48 -0
  112. package/package.json +5 -14
  113. package/dist/common/plugin.d.ts +0 -2
  114. package/dist/common/plugin.d.ts.map +0 -1
  115. package/dist/generators/args.types.d.ts +0 -85
  116. package/dist/generators/args.types.d.ts.map +0 -1
  117. package/dist/generators/base/entity-generator.base.d.ts.map +0 -1
  118. package/dist/generators/feature-directory/feature-directory-generator.d.ts +0 -18
  119. package/dist/generators/feature-directory/feature-directory-generator.d.ts.map +0 -1
  120. package/dist/generators/feature-directory/index.d.ts +0 -2
  121. package/dist/generators/feature-directory/index.d.ts.map +0 -1
  122. package/dist/generators/feature-directory/schema.d.ts +0 -8
  123. package/dist/generators/feature-directory/schema.d.ts.map +0 -1
  124. package/dist/plugin.d.ts +0 -6
  125. package/dist/plugin.d.ts.map +0 -1
  126. /package/dist/generators/{feature-directory → feature}/templates/feature.wasp.eta +0 -0
@@ -0,0 +1,1038 @@
1
+ // src/generators/route/route-generator.ts
2
+ import {
3
+ formatDisplayName,
4
+ toCamelCase as toCamelCase2,
5
+ toPascalCase as toPascalCase3
6
+ } from "@ingenyus/swarm";
7
+
8
+ // src/common/filesystem.ts
9
+ import { toPascalCase, validateFeaturePath } from "@ingenyus/swarm";
10
+ import fs from "fs";
11
+ import path from "path";
12
+
13
+ // src/types/constants.ts
14
+ var PLUGIN_NAME = "wasp";
15
+ var TYPE_DIRECTORIES = {
16
+ component: "client/components",
17
+ hook: "client/hooks",
18
+ layout: "client/layouts",
19
+ page: "client/pages",
20
+ util: "client/utils",
21
+ action: "server/actions",
22
+ query: "server/queries",
23
+ middleware: "server/middleware",
24
+ job: "server/jobs",
25
+ api: "server/apis",
26
+ crud: "server/cruds",
27
+ type: "types"
28
+ };
29
+ var CONFIG_TYPES = {
30
+ ROUTE: "Route",
31
+ QUERY: "Query",
32
+ ACTION: "Action",
33
+ JOB: "Job",
34
+ API: "Api",
35
+ API_NAMESPACE: "ApiNamespace",
36
+ CRUD: "Crud"
37
+ };
38
+
39
+ // src/common/filesystem.ts
40
+ var realFileSystem = {
41
+ readFileSync: fs.readFileSync,
42
+ writeFileSync: fs.writeFileSync,
43
+ existsSync: fs.existsSync,
44
+ copyFileSync: fs.copyFileSync,
45
+ mkdirSync: fs.mkdirSync,
46
+ readdirSync: fs.readdirSync,
47
+ statSync: fs.statSync
48
+ };
49
+ function findWaspRoot(fileSystem, startDir = process.cwd()) {
50
+ const startDirPath = path.resolve(startDir);
51
+ let currentDirPath = startDirPath;
52
+ const root = path.parse(currentDirPath).root;
53
+ while (currentDirPath !== root) {
54
+ const waspRootPath = path.join(currentDirPath, ".wasproot");
55
+ if (fileSystem.existsSync(waspRootPath)) {
56
+ return currentDirPath;
57
+ }
58
+ currentDirPath = path.dirname(currentDirPath);
59
+ }
60
+ throw new Error(
61
+ `Couldn't find Wasp application root from ${startDirPath}. Make sure you are running this command from within a Wasp project directory.`
62
+ );
63
+ }
64
+ function ensureDirectoryExists(fileSystem, dir) {
65
+ if (!fileSystem.existsSync(dir)) {
66
+ fileSystem.mkdirSync(dir, { recursive: true });
67
+ }
68
+ }
69
+ function normaliseFeaturePath(featurePath) {
70
+ const segments = validateFeaturePath(featurePath);
71
+ const normalisedSegments = [];
72
+ for (let i = 0; i < segments.length; i++) {
73
+ const segment = segments[i];
74
+ const previousSegment = normalisedSegments[normalisedSegments.length - 1];
75
+ if (previousSegment !== "features" && segment !== "features") {
76
+ normalisedSegments.push("features");
77
+ }
78
+ normalisedSegments.push(segment);
79
+ }
80
+ return normalisedSegments.join("/");
81
+ }
82
+ function getFeatureDir(fileSystem, featureName) {
83
+ const waspRoot = findWaspRoot(fileSystem);
84
+ const normalisedPath = normaliseFeaturePath(featureName);
85
+ return path.join(waspRoot, "src", normalisedPath);
86
+ }
87
+ function getRouteNameFromPath(routePath) {
88
+ const lastSegment = routePath.split("/").filter(Boolean).pop() || "index";
89
+ const cleanSegment = lastSegment.replace(/[:*]/g, "");
90
+ return `${toPascalCase(cleanSegment)}Page`;
91
+ }
92
+
93
+ // src/common/prisma.ts
94
+ import {
95
+ getSchema
96
+ } from "@mrleebo/prisma-ast";
97
+ import fs2 from "fs";
98
+ import path2 from "path";
99
+
100
+ // src/common/schemas.ts
101
+ import { commandRegistry } from "@ingenyus/swarm";
102
+ import { z } from "zod";
103
+ var commonSchemas = {
104
+ feature: z.string().min(1, "Feature is required").meta({
105
+ description: "The feature directory this component will be generated in"
106
+ }).register(commandRegistry, {
107
+ shortName: "f",
108
+ examples: ["root", "auth", "dashboard/users"],
109
+ helpText: "Can be nested as a logical or relative path, e.g. 'dashboard/users' or 'features/dashboard/features/users'"
110
+ }),
111
+ name: z.string().min(1, "Name is required").meta({ description: "The name of the generated component" }).register(commandRegistry, {
112
+ shortName: "n",
113
+ examples: ["users", "task"],
114
+ helpText: "Will be used for generated files and configuration entries"
115
+ }),
116
+ target: z.string().min(1, "Target directory is required").meta({ description: "The target path of the generated directory" }).register(commandRegistry, {
117
+ shortName: "t",
118
+ examples: ["dashboard/users", "features/dashboard/features/users"],
119
+ helpText: "A logical or relative path, e.g. 'dashboard/users' or 'features/dashboard/features/users'"
120
+ }),
121
+ path: z.string().min(1, "Path is required").meta({ description: "The path that this component will be accessible at" }).register(commandRegistry, {
122
+ shortName: "p",
123
+ examples: ["/api/users/:id", "/api/products"],
124
+ helpText: "Supports Express-style placeholders, e.g. '/api/users/:id'"
125
+ }),
126
+ dataType: z.string().min(1, "Data type is required").meta({ description: "The data type/model name for this operation" }).register(commandRegistry, {
127
+ shortName: "d",
128
+ examples: ["User", "Product", "Task"],
129
+ helpText: "The Wasp entity or model name this operation will interact with"
130
+ }),
131
+ entities: z.array(z.string()).optional().meta({
132
+ description: "The Wasp entities that will be available to this component (optional)"
133
+ }).register(commandRegistry, {
134
+ shortName: "e",
135
+ examples: ["User", "User Task"],
136
+ helpText: "An array of Wasp entity names"
137
+ }),
138
+ force: z.boolean().optional().meta({
139
+ description: "Force overwrite of existing files and configuration entries (optional)"
140
+ }).register(commandRegistry, {
141
+ shortName: "F",
142
+ helpText: "CAUTION: Will overwrite existing files and configuration entries with current parameters"
143
+ }),
144
+ auth: z.boolean().optional().meta({
145
+ description: "Require authentication for this component (optional)"
146
+ }).register(commandRegistry, {
147
+ shortName: "a",
148
+ helpText: "Will generate authentication checks"
149
+ })
150
+ };
151
+
152
+ // src/common/templates.ts
153
+ import { toKebabCase } from "@ingenyus/swarm";
154
+ import { Eta } from "eta";
155
+ import path3 from "path";
156
+ var TemplateUtility = class {
157
+ constructor(fileSystem) {
158
+ this.fileSystem = fileSystem;
159
+ }
160
+ processTemplate(templatePath, replacements) {
161
+ const declarations = Object.keys(replacements).map((key) => `${key}=it.${key}`).join(", ");
162
+ const functionHeader = declarations ? `const ${declarations};` : void 0;
163
+ const templateDir = path3.dirname(templatePath);
164
+ const eta = new Eta({
165
+ autoTrim: false,
166
+ autoEscape: false,
167
+ views: templateDir,
168
+ functionHeader
169
+ });
170
+ const templateName = path3.basename(templatePath).replace(/\.eta$/, "");
171
+ if (this.fileSystem.existsSync(templatePath)) {
172
+ return eta.render(templateName, replacements);
173
+ } else {
174
+ const template = this.fileSystem.readFileSync(templatePath, "utf8");
175
+ return eta.renderString(template, replacements);
176
+ }
177
+ }
178
+ /**
179
+ * Helper method to resolve template paths for concrete generators
180
+ * @param relativePath - The relative path to the template file
181
+ * @param generatorName - The name of the generator (e.g., 'api', 'job')
182
+ * @param currentFileUrl - The import.meta.url from the concrete generator class
183
+ * @returns The full path to the template file
184
+ */
185
+ resolveTemplatePath(relativePath, generatorName, currentFileUrl) {
186
+ const generatorDirName = toKebabCase(generatorName);
187
+ const currentFilePath = new URL(currentFileUrl).pathname;
188
+ const currentFileDir = path3.dirname(currentFilePath);
189
+ const currentFileName = path3.basename(currentFilePath);
190
+ const isInstalledPackage = currentFileDir.includes("node_modules") && currentFileDir.endsWith("/dist") && currentFileName === "index.js";
191
+ const startDir = isInstalledPackage ? currentFileDir : path3.dirname(path3.dirname(currentFileDir));
192
+ return path3.join(
193
+ startDir,
194
+ "generators",
195
+ generatorDirName,
196
+ "templates",
197
+ relativePath
198
+ );
199
+ }
200
+ };
201
+
202
+ // src/generators/base/component-generator.base.ts
203
+ import {
204
+ hasHelperMethodCall,
205
+ logger as singletonLogger4,
206
+ toCamelCase,
207
+ toKebabCase as toKebabCase2,
208
+ validateFeaturePath as validateFeaturePath3
209
+ } from "@ingenyus/swarm";
210
+ import path6 from "path";
211
+
212
+ // src/generators/feature/feature-generator.ts
213
+ import {
214
+ handleFatalError as handleFatalError2,
215
+ logger as singletonLogger3,
216
+ validateFeaturePath as validateFeaturePath2
217
+ } from "@ingenyus/swarm";
218
+ import path5 from "path";
219
+
220
+ // src/generators/base/wasp-generator.base.ts
221
+ import {
222
+ GeneratorBase,
223
+ logger as singletonLogger2,
224
+ SwarmConfigManager,
225
+ TemplateResolver
226
+ } from "@ingenyus/swarm";
227
+
228
+ // src/generators/config/wasp-config-generator.ts
229
+ import {
230
+ handleFatalError,
231
+ parseHelperMethodDefinition,
232
+ logger as singletonLogger
233
+ } from "@ingenyus/swarm";
234
+ import path4 from "path";
235
+ var WaspConfigGenerator = class {
236
+ constructor(logger = singletonLogger, fileSystem = realFileSystem) {
237
+ this.logger = logger;
238
+ this.fileSystem = fileSystem;
239
+ this.templateUtility = new TemplateUtility(fileSystem);
240
+ }
241
+ path = path4;
242
+ templateUtility;
243
+ /**
244
+ * Gets the template path for feature config templates.
245
+ * Feature config templates are located in the feature generator's templates directory.
246
+ * @param templateName - The name of the template file (e.g., 'feature.wasp.eta')
247
+ * @returns The full path to the template file
248
+ */
249
+ getTemplatePath(templateName) {
250
+ return this.templateUtility.resolveTemplatePath(
251
+ templateName,
252
+ "feature",
253
+ import.meta.url
254
+ );
255
+ }
256
+ /**
257
+ * Generate a TypeScript Wasp config file in a feature directory
258
+ * @param featurePath - The feature directory path
259
+ */
260
+ generate(featurePath) {
261
+ const featureDir = getFeatureDir(this.fileSystem, featurePath);
262
+ if (!this.fileSystem.existsSync(featureDir)) {
263
+ this.fileSystem.mkdirSync(featureDir, { recursive: true });
264
+ }
265
+ const templatePath = this.getTemplatePath("feature.wasp.eta");
266
+ if (!this.fileSystem.existsSync(templatePath)) {
267
+ this.logger.error(`Template not found: ${templatePath}`);
268
+ return;
269
+ }
270
+ const configFilePath = path4.join(featureDir, `feature.wasp.ts`);
271
+ if (this.fileSystem.existsSync(configFilePath)) {
272
+ this.logger.warn(`Feature config already exists: ${configFilePath}`);
273
+ return;
274
+ }
275
+ this.fileSystem.copyFileSync(templatePath, configFilePath);
276
+ this.logger.success(`Generated feature config: ${configFilePath}`);
277
+ }
278
+ /**
279
+ * Updates or creates a feature configuration file with a pre-built declaration.
280
+ * @param featurePath - The path to the feature
281
+ * @param declaration - The pre-built declaration string to add or update
282
+ * @returns The updated feature configuration file
283
+ */
284
+ update(featurePath, declaration) {
285
+ const configDir = getFeatureDir(this.fileSystem, featurePath);
286
+ const configFilePath = path4.join(configDir, `feature.wasp.ts`);
287
+ if (!this.fileSystem.existsSync(configFilePath)) {
288
+ const templatePath = this.getTemplatePath("feature.wasp.eta");
289
+ if (!this.fileSystem.existsSync(templatePath)) {
290
+ handleFatalError(`Feature config template not found: ${templatePath}`);
291
+ }
292
+ this.fileSystem.copyFileSync(templatePath, configFilePath);
293
+ }
294
+ let content = this.fileSystem.readFileSync(configFilePath, "utf8");
295
+ content = this.normaliseSemicolons(content);
296
+ const parsed = parseHelperMethodDefinition(declaration);
297
+ if (!parsed) {
298
+ handleFatalError(`Could not parse definition: ${declaration}`);
299
+ return content;
300
+ }
301
+ const { methodName } = parsed;
302
+ const hadExistingDefinitions = this.hasExistingDefinitions(
303
+ content,
304
+ methodName
305
+ );
306
+ content = this.removeExistingDefinition(content, declaration);
307
+ const hasExistingDefinitions = this.hasExistingDefinitions(
308
+ content,
309
+ methodName
310
+ );
311
+ const lines = content.split("\n");
312
+ const configureFunctionStart = lines.findIndex(
313
+ (line) => line.trim().startsWith("export default function")
314
+ );
315
+ if (configureFunctionStart === -1) {
316
+ handleFatalError("Could not find configure function in feature config");
317
+ }
318
+ const appLineIndex = lines.findIndex(
319
+ (line, index) => index > configureFunctionStart && line.trim() === "app"
320
+ );
321
+ if (appLineIndex === -1) {
322
+ const insertIndex = configureFunctionStart + 1;
323
+ const itemsToInsert = [" app"];
324
+ const comment = this.getMethodComment(methodName);
325
+ itemsToInsert.push(` ${comment}`);
326
+ itemsToInsert.push(declaration.trimEnd());
327
+ lines.splice(insertIndex, 0, ...itemsToInsert);
328
+ } else {
329
+ const { insertIndex, addComment } = this.findGroupInsertionPoint(
330
+ lines,
331
+ methodName,
332
+ declaration,
333
+ hadExistingDefinitions || hasExistingDefinitions
334
+ );
335
+ const newLines = this.insertWithSpacing(
336
+ lines,
337
+ declaration,
338
+ insertIndex,
339
+ methodName,
340
+ addComment
341
+ );
342
+ const normalisedContent2 = this.normaliseSemicolons(newLines.join("\n"));
343
+ this.fileSystem.writeFileSync(configFilePath, normalisedContent2);
344
+ return configFilePath;
345
+ }
346
+ const normalisedContent = this.normaliseSemicolons(lines.join("\n"));
347
+ this.fileSystem.writeFileSync(configFilePath, normalisedContent);
348
+ return configFilePath;
349
+ }
350
+ /**
351
+ * Determines the insertion index for a method name based on alphabetical ordering
352
+ * of existing groups in the configuration file.
353
+ * @param groups - Object containing existing method groups
354
+ * @param methodName - The method name to find insertion index for
355
+ * @returns The insertion index for the method name
356
+ */
357
+ getInsertionIndexForMethod(groups, methodName) {
358
+ const existingMethods = Object.keys(groups).filter(
359
+ (method) => groups[method].length > 0
360
+ );
361
+ const allMethods = [...existingMethods, methodName].sort();
362
+ return allMethods.indexOf(methodName);
363
+ }
364
+ /**
365
+ * Gets the comment text for a method type.
366
+ * @param methodName The method name (e.g., 'addApi')
367
+ * @returns The comment text for the method type
368
+ */
369
+ getMethodComment(methodName) {
370
+ const entityName = methodName.startsWith("add") ? methodName.slice(3) : methodName;
371
+ return `// ${entityName} definitions`;
372
+ }
373
+ /**
374
+ * Finds the correct insertion point for a new configuration item.
375
+ * @param lines - Array of file lines
376
+ * @param methodName - The method name (e.g., 'addApi')
377
+ * @param definition - The definition string to parse for item name
378
+ * @returns Object with insertion index and whether to add a comment
379
+ */
380
+ findGroupInsertionPoint(lines, methodName, definition, hasExistingDefinitionsOfType) {
381
+ const appLineIndex = lines.findIndex((line) => line.trim() === "app");
382
+ if (appLineIndex === -1) {
383
+ return { insertIndex: appLineIndex + 1, addComment: false };
384
+ }
385
+ const methodCalls = [];
386
+ for (let i = appLineIndex + 1; i < lines.length; i++) {
387
+ const line = lines[i].trim();
388
+ if (line.startsWith(".") && line.includes("(")) {
389
+ let methodCallContent = line;
390
+ let j = i;
391
+ let closingParenCount = 0;
392
+ let foundClosingParen = false;
393
+ for (let k = 0; k < methodCallContent.length; k++) {
394
+ if (methodCallContent[k] === "(") closingParenCount++;
395
+ if (methodCallContent[k] === ")") closingParenCount--;
396
+ if (closingParenCount === 0 && methodCallContent[k] === ")") {
397
+ foundClosingParen = true;
398
+ break;
399
+ }
400
+ }
401
+ while (!foundClosingParen && j < lines.length - 1) {
402
+ j++;
403
+ methodCallContent += " " + lines[j].trim();
404
+ for (let k = 0; k < lines[j].length; k++) {
405
+ if (lines[j][k] === "(") closingParenCount++;
406
+ if (lines[j][k] === ")") closingParenCount--;
407
+ if (closingParenCount === 0 && lines[j][k] === ")") {
408
+ foundClosingParen = true;
409
+ break;
410
+ }
411
+ }
412
+ }
413
+ const match = methodCallContent.match(
414
+ /\.(\w+)\([^,]+,\s*['"`]([^'"`]+)['"`]/
415
+ );
416
+ if (match) {
417
+ methodCalls.push({
418
+ lineIndex: i,
419
+ endLineIndex: j,
420
+ methodName: match[1],
421
+ itemName: match[2]
422
+ });
423
+ }
424
+ }
425
+ }
426
+ const groups = {};
427
+ methodCalls.forEach((call) => {
428
+ if (!groups[call.methodName]) {
429
+ groups[call.methodName] = [];
430
+ }
431
+ groups[call.methodName].push({
432
+ lineIndex: call.lineIndex,
433
+ endLineIndex: call.endLineIndex,
434
+ itemName: call.itemName
435
+ });
436
+ });
437
+ const targetGroup = groups[methodName] || [];
438
+ if (targetGroup.length === 0) {
439
+ const targetGroupIndex = this.getInsertionIndexForMethod(
440
+ groups,
441
+ methodName
442
+ );
443
+ const existingMethods = Object.keys(groups).filter((method) => groups[method].length > 0).sort();
444
+ for (let i = targetGroupIndex; i < existingMethods.length; i++) {
445
+ const groupMethod = existingMethods[i];
446
+ if (groups[groupMethod] && groups[groupMethod].length > 0) {
447
+ const firstItem = groups[groupMethod][0];
448
+ let insertIndex = firstItem.lineIndex;
449
+ for (let j = firstItem.lineIndex - 1; j > appLineIndex; j--) {
450
+ const line = lines[j].trim();
451
+ if (line.startsWith("//") && line.includes("definitions")) {
452
+ insertIndex = j;
453
+ break;
454
+ } else if (line.startsWith(".") || line === "") {
455
+ continue;
456
+ } else {
457
+ break;
458
+ }
459
+ }
460
+ return { insertIndex, addComment: !hasExistingDefinitionsOfType };
461
+ }
462
+ }
463
+ for (let i = targetGroupIndex - 1; i >= 0; i--) {
464
+ const groupMethod = existingMethods[i];
465
+ if (groups[groupMethod] && groups[groupMethod].length > 0) {
466
+ const lastItem2 = groups[groupMethod][groups[groupMethod].length - 1];
467
+ return {
468
+ insertIndex: lastItem2.endLineIndex + 1,
469
+ addComment: !hasExistingDefinitionsOfType
470
+ };
471
+ }
472
+ }
473
+ return {
474
+ insertIndex: appLineIndex + 1,
475
+ addComment: !hasExistingDefinitionsOfType
476
+ };
477
+ }
478
+ const parsed = parseHelperMethodDefinition(definition);
479
+ if (!parsed) {
480
+ return { insertIndex: appLineIndex + 1, addComment: false };
481
+ }
482
+ const { firstParam: itemName } = parsed;
483
+ for (let i = 0; i < targetGroup.length; i++) {
484
+ if (itemName.localeCompare(targetGroup[i].itemName) < 0) {
485
+ return { insertIndex: targetGroup[i].lineIndex, addComment: false };
486
+ }
487
+ }
488
+ const lastItem = targetGroup[targetGroup.length - 1];
489
+ return { insertIndex: lastItem.endLineIndex + 1, addComment: false };
490
+ }
491
+ /**
492
+ * Inserts a definition with optional comment header.
493
+ * @param lines - Array of file lines
494
+ * @param declaration - The declaration to insert
495
+ * @param insertIndex - The index where to insert
496
+ * @param methodName - The method name for comment generation
497
+ * @param addComment - Whether to add a comment before the declaration
498
+ * @returns The modified lines array
499
+ */
500
+ insertWithSpacing(lines, declaration, insertIndex, methodName, addComment = false) {
501
+ const newLines = [...lines];
502
+ if (addComment) {
503
+ const comment = this.getMethodComment(methodName);
504
+ newLines.splice(insertIndex, 0, ` ${comment}`);
505
+ insertIndex += 1;
506
+ }
507
+ newLines.splice(insertIndex, 0, declaration.trimEnd());
508
+ return newLines;
509
+ }
510
+ /**
511
+ * Checks if there are any existing definitions of a specific type in the content.
512
+ * @param content - The file content to search
513
+ * @param methodName - The method name to check for (e.g., 'addJob', 'addApi')
514
+ * @returns true if there are existing definitions of this type, false otherwise
515
+ */
516
+ hasExistingDefinitions(content, methodName) {
517
+ const lines = content.split("\n");
518
+ for (const line of lines) {
519
+ if (line.trim().startsWith(`.${methodName}(`)) {
520
+ return true;
521
+ }
522
+ }
523
+ return false;
524
+ }
525
+ /**
526
+ * Removes an existing definition from the content by finding the helper method call
527
+ * and removing the entire method call block.
528
+ * @param content - The file content
529
+ * @param definition - The new definition to find the existing one from
530
+ * @returns The content with the existing definition removed
531
+ */
532
+ removeExistingDefinition(content, definition) {
533
+ const parsed = parseHelperMethodDefinition(definition);
534
+ if (!parsed) {
535
+ return content;
536
+ }
537
+ const { methodName, firstParam } = parsed;
538
+ let contentLines = content.split("\n");
539
+ let openingLineIndex = -1;
540
+ for (let i = 0; i < contentLines.length; i++) {
541
+ const line = contentLines[i];
542
+ if (line.trim().startsWith(`.${methodName}(`)) {
543
+ if (firstParam && line.includes(firstParam)) {
544
+ openingLineIndex = i;
545
+ break;
546
+ }
547
+ }
548
+ }
549
+ if (openingLineIndex === -1) {
550
+ return content;
551
+ }
552
+ let closingLineIndex = -1;
553
+ let parenCount = 0;
554
+ let braceCount = 0;
555
+ let foundOpening = false;
556
+ for (let i = openingLineIndex; i < contentLines.length; i++) {
557
+ const line = contentLines[i];
558
+ for (const char of line) {
559
+ if (char === "(") {
560
+ parenCount++;
561
+ foundOpening = true;
562
+ } else if (char === ")") {
563
+ parenCount--;
564
+ if (foundOpening && parenCount === 0 && braceCount === 0) {
565
+ closingLineIndex = i;
566
+ break;
567
+ }
568
+ } else if (char === "{") {
569
+ braceCount++;
570
+ } else if (char === "}") {
571
+ braceCount--;
572
+ }
573
+ }
574
+ if (closingLineIndex !== -1) {
575
+ break;
576
+ }
577
+ }
578
+ if (closingLineIndex === -1) {
579
+ this.logger.warn(
580
+ "Could not find closing parenthesis for existing definition"
581
+ );
582
+ return content;
583
+ }
584
+ contentLines.splice(
585
+ openingLineIndex,
586
+ closingLineIndex - openingLineIndex + 1
587
+ );
588
+ return contentLines.join("\n");
589
+ }
590
+ /**
591
+ * Adds a definition to the content by finding the appropriate place to insert it.
592
+ * @param content - The current file content
593
+ * @param definition - The definition to add
594
+ * @returns The updated content with the new definition
595
+ */
596
+ addDefinitionToContent(content, definition) {
597
+ const lines = content.split("\n");
598
+ const lastLineIndex = lines.length - 1;
599
+ let insertIndex = lastLineIndex;
600
+ for (let i = lastLineIndex; i >= 0; i--) {
601
+ const line = lines[i].trim();
602
+ if (line && !line.startsWith("}")) {
603
+ insertIndex = i;
604
+ break;
605
+ }
606
+ }
607
+ lines.splice(insertIndex + 1, 0, ` ${definition}`);
608
+ return lines.join("\n");
609
+ }
610
+ /**
611
+ * Normalises semicolons in the config file by removing them from method chain calls
612
+ * while preserving them in other contexts (imports, declarations, etc.).
613
+ * @param content - The file content to normalise
614
+ * @returns The normalised content
615
+ */
616
+ normaliseSemicolons(content) {
617
+ const lines = content.split("\n");
618
+ const configureFunctionStart = lines.findIndex(
619
+ (line) => line.trim().startsWith("export default function")
620
+ );
621
+ if (configureFunctionStart === -1) {
622
+ return content;
623
+ }
624
+ const appLineIndex = lines.findIndex(
625
+ (line, index) => index > configureFunctionStart && line.trim().startsWith("app")
626
+ );
627
+ if (appLineIndex === -1) {
628
+ return content;
629
+ }
630
+ let braceCount = 0;
631
+ let functionEndIndex = lines.length - 1;
632
+ for (let i = configureFunctionStart; i < lines.length; i++) {
633
+ const line = lines[i];
634
+ for (const char of line) {
635
+ if (char === "{") braceCount++;
636
+ if (char === "}") {
637
+ braceCount--;
638
+ if (braceCount === 0) {
639
+ functionEndIndex = i;
640
+ break;
641
+ }
642
+ }
643
+ }
644
+ if (braceCount === 0 && i > configureFunctionStart) {
645
+ break;
646
+ }
647
+ }
648
+ let lastMethodCallIndex = -1;
649
+ for (let i = appLineIndex + 1; i < functionEndIndex; i++) {
650
+ const line = lines[i];
651
+ const trimmed = line.trim();
652
+ if ((trimmed.endsWith(")") || trimmed.endsWith(");")) && !trimmed.startsWith("//")) {
653
+ lines[i] = line.replace(/;\s*$/, "");
654
+ lastMethodCallIndex = i;
655
+ }
656
+ }
657
+ if (lastMethodCallIndex !== -1 && !lines[lastMethodCallIndex].trim().endsWith(";")) {
658
+ lines[lastMethodCallIndex] = lines[lastMethodCallIndex] + ";";
659
+ }
660
+ return lines.join("\n");
661
+ }
662
+ };
663
+
664
+ // src/generators/base/wasp-generator.base.ts
665
+ var WaspGeneratorBase = class extends GeneratorBase {
666
+ constructor(fileSystem = realFileSystem, logger = singletonLogger2) {
667
+ super(fileSystem, logger);
668
+ this.fileSystem = fileSystem;
669
+ this.logger = logger;
670
+ this.configGenerator = new WaspConfigGenerator(logger, fileSystem);
671
+ this.templateUtility = new TemplateUtility(fileSystem);
672
+ this.templateResolver = new TemplateResolver(fileSystem);
673
+ }
674
+ configGenerator;
675
+ templateUtility;
676
+ templateResolver;
677
+ swarmConfig;
678
+ configLoaded = false;
679
+ // Plugin name from swarm.config.json
680
+ pluginName = PLUGIN_NAME;
681
+ async loadSwarmConfig() {
682
+ if (this.configLoaded) return;
683
+ const configManager = new SwarmConfigManager();
684
+ this.swarmConfig = await configManager.loadConfig();
685
+ this.configLoaded = true;
686
+ }
687
+ async getCustomTemplateDir() {
688
+ await this.loadSwarmConfig();
689
+ return this.swarmConfig?.templateDirectory;
690
+ }
691
+ /**
692
+ * Resolves template path with override support
693
+ */
694
+ async getTemplatePath(templateName) {
695
+ const defaultPath = this.getDefaultTemplatePath(templateName);
696
+ const customPath = await this.getCustomTemplateDir();
697
+ if (!customPath) {
698
+ return defaultPath;
699
+ }
700
+ const { path: resolvedPath, isCustom } = this.templateResolver.resolveTemplatePath(
701
+ this.pluginName,
702
+ this.name,
703
+ templateName,
704
+ defaultPath,
705
+ customPath
706
+ );
707
+ if (isCustom) {
708
+ this.logger.info(`Using custom template: ${resolvedPath}`);
709
+ }
710
+ return resolvedPath;
711
+ }
712
+ /**
713
+ * Processes a template and writes the result to a file
714
+ */
715
+ async renderTemplateToFile(templateName, replacements, outputPath, readableFileType, force) {
716
+ const templatePath = await this.getTemplatePath(templateName);
717
+ const fileExists = this.checkFileExists(
718
+ outputPath,
719
+ force,
720
+ readableFileType
721
+ );
722
+ const content = this.templateUtility.processTemplate(
723
+ templatePath,
724
+ replacements
725
+ );
726
+ this.writeFile(outputPath, content, readableFileType, fileExists);
727
+ return fileExists;
728
+ }
729
+ /**
730
+ * Generic existence check with force flag handling
731
+ * Consolidates the pattern used in both file and config checks
732
+ */
733
+ checkExistence(exists, itemDescription, force, errorMessage) {
734
+ if (exists && !force) {
735
+ this.logger.error(`${itemDescription}. Use --force to overwrite`);
736
+ throw new Error(errorMessage || itemDescription);
737
+ }
738
+ return exists;
739
+ }
740
+ /**
741
+ * Checks if a file exists and handles force flag logic
742
+ */
743
+ checkFileExists(filePath, force, fileType) {
744
+ const fileExists = this.fileSystem.existsSync(filePath);
745
+ return this.checkExistence(
746
+ fileExists,
747
+ `${fileType} already exists: ${filePath}`,
748
+ force,
749
+ `${fileType} already exists`
750
+ );
751
+ }
752
+ /**
753
+ * Safely writes a file with proper error handling and logging
754
+ */
755
+ writeFile(filePath, content, fileType, fileExists) {
756
+ this.fileSystem.writeFileSync(filePath, content);
757
+ this.logger.success(
758
+ `${fileExists ? "Overwrote" : "Generated"} ${fileType}: ${filePath}`
759
+ );
760
+ }
761
+ };
762
+
763
+ // src/generators/feature/schema.ts
764
+ import { z as z2 } from "zod";
765
+ var schema = z2.object({
766
+ target: commonSchemas.target
767
+ });
768
+
769
+ // src/generators/feature/feature-generator.ts
770
+ var FeatureGenerator = class extends WaspGeneratorBase {
771
+ constructor(logger = singletonLogger3, fileSystem = realFileSystem) {
772
+ super(fileSystem, logger);
773
+ this.logger = logger;
774
+ this.fileSystem = fileSystem;
775
+ this.name = "feature";
776
+ this.description = "Generates a feature directory containing a Wasp configuration file";
777
+ }
778
+ name;
779
+ description;
780
+ schema = schema;
781
+ getDefaultTemplatePath(templateName) {
782
+ return this.templateUtility.resolveTemplatePath(
783
+ templateName,
784
+ this.name,
785
+ import.meta.url
786
+ );
787
+ }
788
+ /**
789
+ * Generates a feature directory containing a Wasp configuration file
790
+ * @param target - The target path of the generated directory
791
+ */
792
+ async generate(args) {
793
+ const { target } = args;
794
+ const segments = validateFeaturePath2(target);
795
+ const normalisedPath = normaliseFeaturePath(target);
796
+ const sourceRoot = path5.join(findWaspRoot(this.fileSystem), "src");
797
+ if (segments.length > 1) {
798
+ const parentPath = segments.slice(0, -1).join("/");
799
+ const parentNormalisedPath = normaliseFeaturePath(parentPath);
800
+ const parentFeatureDir = path5.join(sourceRoot, parentNormalisedPath);
801
+ if (!this.fileSystem.existsSync(parentFeatureDir)) {
802
+ handleFatalError2(
803
+ `Parent feature '${parentPath}' does not exist. Please create it first.`
804
+ );
805
+ }
806
+ }
807
+ const featureDir = path5.join(sourceRoot, normalisedPath);
808
+ this.fileSystem.mkdirSync(featureDir, { recursive: true });
809
+ this.configGenerator.generate(normalisedPath);
810
+ this.logger.success(`Generated feature: ${normalisedPath}`);
811
+ }
812
+ };
813
+
814
+ // src/generators/base/component-generator.base.ts
815
+ var ComponentGeneratorBase = class extends WaspGeneratorBase {
816
+ constructor(logger = singletonLogger4, fileSystem = realFileSystem, featureDirectoryGenerator = new FeatureGenerator(logger, fileSystem)) {
817
+ super(fileSystem, logger);
818
+ this.logger = logger;
819
+ this.fileSystem = fileSystem;
820
+ this.featureDirectoryGenerator = featureDirectoryGenerator;
821
+ this.featureDirectoryGenerator = featureDirectoryGenerator;
822
+ }
823
+ getDefaultTemplatePath(templateName) {
824
+ return this.templateUtility.resolveTemplatePath(
825
+ templateName,
826
+ this.name,
827
+ import.meta.url
828
+ );
829
+ }
830
+ get name() {
831
+ return toKebabCase2(this.componentType);
832
+ }
833
+ /**
834
+ * Validates that the feature config file exists in the target or ancestor directories
835
+ */
836
+ validateFeatureConfig(featurePath) {
837
+ const normalisedPath = normaliseFeaturePath(featurePath);
838
+ const segments = normalisedPath.split("/");
839
+ for (let i = segments.length; i > 0; i--) {
840
+ const pathSegments = segments.slice(0, i);
841
+ const currentPath = pathSegments.join("/");
842
+ const featureName = pathSegments[pathSegments.length - 1];
843
+ const featureDir = getFeatureDir(this.fileSystem, currentPath);
844
+ const configPath = path6.join(featureDir, `feature.wasp.ts`);
845
+ if (this.fileSystem.existsSync(configPath)) {
846
+ return configPath;
847
+ }
848
+ }
849
+ this.logger.error(
850
+ `Feature config file not found in '${normalisedPath}' or any ancestor directories`
851
+ );
852
+ this.logger.error(
853
+ `Expected to find a feature.wasp.ts config file in one of the feature directories`
854
+ );
855
+ throw new Error("Feature config file not found");
856
+ }
857
+ /**
858
+ * Checks if a config item already exists in the feature config
859
+ */
860
+ checkConfigExists(configPath, methodName, itemName, force) {
861
+ const configContent = this.fileSystem.readFileSync(configPath, "utf8");
862
+ const configExists = hasHelperMethodCall(
863
+ configContent,
864
+ methodName,
865
+ itemName
866
+ );
867
+ return this.checkExistence(
868
+ configExists,
869
+ `${methodName} config already exists in ${configPath}`,
870
+ force,
871
+ `${methodName} config already exists`
872
+ );
873
+ }
874
+ /**
875
+ * Updates the feature config with a new definition
876
+ */
877
+ updateFeatureConfig(featurePath, definition, configPath, configExists, methodName) {
878
+ this.configGenerator.update(featurePath, definition);
879
+ this.logger.success(
880
+ `${configExists ? "Updated" : "Added"} ${methodName} config in: ${configPath}`
881
+ );
882
+ }
883
+ /**
884
+ * Consolidated helper for updating config files with existence check
885
+ * This replaces the duplicated updateConfigFile pattern in concrete generators
886
+ */
887
+ updateConfigWithCheck(configPath, methodName, entityName, definition, featurePath, force) {
888
+ const configExists = this.checkConfigExists(
889
+ configPath,
890
+ methodName,
891
+ entityName,
892
+ force
893
+ );
894
+ if (!configExists || force) {
895
+ this.updateFeatureConfig(
896
+ featurePath,
897
+ definition,
898
+ configPath,
899
+ configExists,
900
+ methodName
901
+ );
902
+ }
903
+ }
904
+ /**
905
+ * Gets the appropriate directory for a feature based on its path.
906
+ * @param fileSystem - The filesystem abstraction
907
+ * @param featurePath - The full feature path
908
+ * @param type - The type of file being generated
909
+ * @returns The target directory and import path
910
+ */
911
+ getFeatureTargetDir(fileSystem, featurePath, type) {
912
+ validateFeaturePath3(featurePath);
913
+ const normalisedPath = normaliseFeaturePath(featurePath);
914
+ const featureDir = getFeatureDir(fileSystem, normalisedPath);
915
+ const typeKey = type.toLowerCase();
916
+ const typeDirectory = TYPE_DIRECTORIES[typeKey];
917
+ const targetDirectory = path6.join(featureDir, typeDirectory);
918
+ const importDirectory = `@src/${normalisedPath}/${typeDirectory}`;
919
+ return { targetDirectory, importDirectory };
920
+ }
921
+ /**
922
+ * Ensures a target directory exists and returns its path
923
+ */
924
+ ensureTargetDirectory(featurePath, type) {
925
+ const { targetDirectory, importDirectory } = this.getFeatureTargetDir(
926
+ this.fileSystem,
927
+ featurePath,
928
+ type
929
+ );
930
+ ensureDirectoryExists(this.fileSystem, targetDirectory);
931
+ return { targetDirectory, importDirectory };
932
+ }
933
+ /**
934
+ * Generate middleware file for API or API namespace
935
+ */
936
+ async generateMiddlewareFile(targetFile, name, force) {
937
+ const replacements = {
938
+ name,
939
+ middlewareType: toCamelCase(this.componentType || "")
940
+ };
941
+ await this.renderTemplateToFile(
942
+ "middleware.eta",
943
+ replacements,
944
+ targetFile,
945
+ "Middleware file",
946
+ force
947
+ );
948
+ }
949
+ };
950
+
951
+ // src/generators/base/operation-generator.base.ts
952
+ import {
953
+ capitalise,
954
+ getPlural,
955
+ handleFatalError as handleFatalError3,
956
+ toPascalCase as toPascalCase2
957
+ } from "@ingenyus/swarm";
958
+
959
+ // src/generators/route/schema.ts
960
+ import { z as z3 } from "zod";
961
+ var schema2 = z3.object({
962
+ feature: commonSchemas.feature,
963
+ name: commonSchemas.name,
964
+ path: commonSchemas.path,
965
+ auth: commonSchemas.auth,
966
+ force: commonSchemas.force
967
+ });
968
+
969
+ // src/generators/route/route-generator.ts
970
+ var RouteGenerator = class extends ComponentGeneratorBase {
971
+ get componentType() {
972
+ return CONFIG_TYPES.ROUTE;
973
+ }
974
+ description = "Generates a Wasp Page and Route";
975
+ schema = schema2;
976
+ async generate(args) {
977
+ const { path: routePath, name, feature } = args;
978
+ const routeName = toCamelCase2(name || getRouteNameFromPath(routePath));
979
+ const componentName = toPascalCase3(routeName);
980
+ const fileName = `${componentName}.tsx`;
981
+ return this.handleGeneratorError(
982
+ this.componentType,
983
+ routeName,
984
+ async () => {
985
+ const configPath = this.validateFeatureConfig(feature);
986
+ const { targetDirectory } = this.ensureTargetDirectory(feature, "page");
987
+ const targetFile = `${targetDirectory}/${fileName}`;
988
+ await this.generatePageFile(targetFile, componentName, args);
989
+ this.updateConfigFile(feature, routeName, routePath, args, configPath);
990
+ }
991
+ );
992
+ }
993
+ async generatePageFile(targetFile, componentName, args) {
994
+ const templatePath = "files/client/page.eta";
995
+ const replacements = {
996
+ componentName,
997
+ displayName: formatDisplayName(componentName)
998
+ };
999
+ await this.renderTemplateToFile(
1000
+ "page.eta",
1001
+ replacements,
1002
+ targetFile,
1003
+ "Page file",
1004
+ args.force || false
1005
+ );
1006
+ }
1007
+ updateConfigFile(featurePath, routeName, routePath, args, configPath) {
1008
+ const definition = this.getDefinition(
1009
+ routeName,
1010
+ routePath,
1011
+ featurePath,
1012
+ args.auth
1013
+ );
1014
+ this.updateConfigWithCheck(
1015
+ configPath,
1016
+ "addRoute",
1017
+ routeName,
1018
+ definition,
1019
+ featurePath,
1020
+ args.force || false
1021
+ );
1022
+ }
1023
+ /**
1024
+ * Generates a route definition for the feature configuration.
1025
+ */
1026
+ getDefinition(routeName, routePath, featurePath, auth = false) {
1027
+ const templatePath = this.getDefaultTemplatePath("config/route.eta");
1028
+ return this.templateUtility.processTemplate(templatePath, {
1029
+ featureName: featurePath.split("/").pop() || featurePath,
1030
+ routeName,
1031
+ routePath,
1032
+ auth: String(auth)
1033
+ });
1034
+ }
1035
+ };
1036
+ export {
1037
+ RouteGenerator
1038
+ };