@ingenyus/swarm-wasp 0.1.0 → 0.2.0

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