@ingenyus/swarm-wasp 0.2.0 → 0.2.2

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 (47) hide show
  1. package/dist/.tsbuildinfo +1 -1
  2. package/dist/common/index.d.ts +0 -1
  3. package/dist/common/index.d.ts.map +1 -1
  4. package/dist/common/index.js +9 -34
  5. package/dist/generators/action/action-generator.js +50 -58
  6. package/dist/generators/action/index.js +50 -58
  7. package/dist/generators/action/schema.js +1 -5
  8. package/dist/generators/api/api-generator.js +51 -59
  9. package/dist/generators/api/index.js +51 -59
  10. package/dist/generators/api/schema.js +1 -5
  11. package/dist/generators/api-namespace/api-namespace-generator.js +51 -59
  12. package/dist/generators/api-namespace/index.js +51 -59
  13. package/dist/generators/api-namespace/schema.js +1 -5
  14. package/dist/generators/base/component-generator.base.d.ts +4 -7
  15. package/dist/generators/base/component-generator.base.d.ts.map +1 -1
  16. package/dist/generators/base/component-generator.base.js +49 -57
  17. package/dist/generators/base/index.js +50 -58
  18. package/dist/generators/base/operation-generator.base.js +50 -58
  19. package/dist/generators/base/wasp-generator.base.d.ts +3 -5
  20. package/dist/generators/base/wasp-generator.base.d.ts.map +1 -1
  21. package/dist/generators/base/wasp-generator.base.js +22 -26
  22. package/dist/generators/config/index.js +12 -16
  23. package/dist/generators/config/wasp-config-generator.js +12 -16
  24. package/dist/generators/crud/crud-generator.js +50 -58
  25. package/dist/generators/crud/index.js +50 -58
  26. package/dist/generators/crud/schema.js +1 -5
  27. package/dist/generators/feature/feature-generator.d.ts +2 -4
  28. package/dist/generators/feature/feature-generator.d.ts.map +1 -1
  29. package/dist/generators/feature/feature-generator.js +32 -42
  30. package/dist/generators/feature/index.js +32 -42
  31. package/dist/generators/feature/schema.js +1 -5
  32. package/dist/generators/index.js +54 -62
  33. package/dist/generators/job/index.js +49 -57
  34. package/dist/generators/job/job-generator.js +49 -57
  35. package/dist/generators/job/schema.js +1 -5
  36. package/dist/generators/query/index.js +50 -58
  37. package/dist/generators/query/query-generator.js +50 -58
  38. package/dist/generators/query/schema.js +1 -5
  39. package/dist/generators/route/index.js +49 -57
  40. package/dist/generators/route/route-generator.js +49 -57
  41. package/dist/generators/route/schema.js +1 -5
  42. package/dist/index.js +60 -90
  43. package/dist/plugins/wasp.d.ts.map +1 -1
  44. package/package.json +2 -2
  45. package/dist/common/plugin.d.ts +0 -2
  46. package/dist/common/plugin.d.ts.map +0 -1
  47. package/dist/common/plugin.js +0 -41
@@ -105,19 +105,15 @@ function getFeatureImportPath(featurePath) {
105
105
  return segments.join("/");
106
106
  }
107
107
 
108
- // src/common/plugin.ts
109
- import path2 from "path";
110
- import { fileURLToPath } from "url";
111
-
112
108
  // src/common/prisma.ts
113
109
  import {
114
110
  getSchema
115
111
  } from "@mrleebo/prisma-ast";
116
112
  import fs2 from "fs";
117
- import path3 from "path";
113
+ import path2 from "path";
118
114
  async function getEntityMetadata(modelName) {
119
115
  try {
120
- const schemaPath = path3.join(process.cwd(), "schema.prisma");
116
+ const schemaPath = path2.join(process.cwd(), "schema.prisma");
121
117
  const schemaContent = fs2.readFileSync(schemaPath, "utf8");
122
118
  const schema2 = getSchema(schemaContent);
123
119
  const model = schema2.list?.find(
@@ -292,7 +288,7 @@ var commonSchemas = {
292
288
  // src/common/templates.ts
293
289
  import { toKebabCase } from "@ingenyus/swarm";
294
290
  import { Eta } from "eta";
295
- import path4 from "path";
291
+ import path3 from "path";
296
292
  var TemplateUtility = class {
297
293
  constructor(fileSystem) {
298
294
  this.fileSystem = fileSystem;
@@ -300,14 +296,14 @@ var TemplateUtility = class {
300
296
  processTemplate(templatePath, replacements) {
301
297
  const declarations = Object.keys(replacements).map((key) => `${key}=it.${key}`).join(", ");
302
298
  const functionHeader = declarations ? `const ${declarations};` : void 0;
303
- const templateDir = path4.dirname(templatePath);
299
+ const templateDir = path3.dirname(templatePath);
304
300
  const eta = new Eta({
305
301
  autoTrim: false,
306
302
  autoEscape: false,
307
303
  views: templateDir,
308
304
  functionHeader
309
305
  });
310
- const templateName = path4.basename(templatePath).replace(/\.eta$/, "");
306
+ const templateName = path3.basename(templatePath).replace(/\.eta$/, "");
311
307
  if (this.fileSystem.existsSync(templatePath)) {
312
308
  return eta.render(templateName, replacements);
313
309
  } else {
@@ -325,11 +321,11 @@ var TemplateUtility = class {
325
321
  resolveTemplatePath(relativePath, generatorName, currentFileUrl) {
326
322
  const generatorDirName = toKebabCase(generatorName);
327
323
  const currentFilePath = new URL(currentFileUrl).pathname;
328
- const currentFileDir = path4.dirname(currentFilePath);
329
- const currentFileName = path4.basename(currentFilePath);
324
+ const currentFileDir = path3.dirname(currentFilePath);
325
+ const currentFileName = path3.basename(currentFilePath);
330
326
  const isInstalledPackage = currentFileDir.includes("node_modules") && currentFileDir.endsWith("/dist") && currentFileName === "index.js";
331
- const startDir = isInstalledPackage ? currentFileDir : path4.dirname(path4.dirname(currentFileDir));
332
- return path4.join(
327
+ const startDir = isInstalledPackage ? currentFileDir : path3.dirname(path3.dirname(currentFileDir));
328
+ return path3.join(
333
329
  startDir,
334
330
  "generators",
335
331
  generatorDirName,
@@ -341,26 +337,21 @@ var TemplateUtility = class {
341
337
 
342
338
  // src/generators/base/component-generator.base.ts
343
339
  import {
340
+ GeneratorRuntime,
344
341
  hasHelperMethodCall,
345
- logger as singletonLogger4,
346
342
  toCamelCase,
347
343
  toKebabCase as toKebabCase2,
348
344
  validateFeaturePath as validateFeaturePath3
349
345
  } from "@ingenyus/swarm";
350
- import path7 from "path";
346
+ import path6 from "path";
351
347
 
352
348
  // src/generators/feature/feature-generator.ts
353
- import {
354
- handleFatalError as handleFatalError2,
355
- logger as singletonLogger3,
356
- validateFeaturePath as validateFeaturePath2
357
- } from "@ingenyus/swarm";
358
- import path6 from "path";
349
+ import { handleFatalError as handleFatalError2, validateFeaturePath as validateFeaturePath2 } from "@ingenyus/swarm";
350
+ import path5 from "path";
359
351
 
360
352
  // src/generators/base/wasp-generator.base.ts
361
353
  import {
362
354
  GeneratorBase,
363
- logger as singletonLogger2,
364
355
  SwarmConfigManager,
365
356
  TemplateResolver
366
357
  } from "@ingenyus/swarm";
@@ -371,14 +362,14 @@ import {
371
362
  parseHelperMethodDefinition,
372
363
  logger as singletonLogger
373
364
  } from "@ingenyus/swarm";
374
- import path5 from "path";
365
+ import path4 from "path";
375
366
  var WaspConfigGenerator = class {
376
367
  constructor(logger = singletonLogger, fileSystem = realFileSystem) {
377
368
  this.logger = logger;
378
369
  this.fileSystem = fileSystem;
379
370
  this.templateUtility = new TemplateUtility(fileSystem);
380
371
  }
381
- path = path5;
372
+ path = path4;
382
373
  templateUtility;
383
374
  /**
384
375
  * Gets the template path for feature config templates.
@@ -407,7 +398,7 @@ var WaspConfigGenerator = class {
407
398
  this.logger.error(`Template not found: ${templatePath}`);
408
399
  return;
409
400
  }
410
- const configFilePath = path5.join(featureDir, `feature.wasp.ts`);
401
+ const configFilePath = path4.join(featureDir, `feature.wasp.ts`);
411
402
  if (this.fileSystem.existsSync(configFilePath)) {
412
403
  this.logger.warn(`Feature config already exists: ${configFilePath}`);
413
404
  return;
@@ -423,7 +414,7 @@ var WaspConfigGenerator = class {
423
414
  */
424
415
  update(featurePath, declaration) {
425
416
  const configDir = getFeatureDir(this.fileSystem, featurePath);
426
- const configFilePath = path5.join(configDir, `feature.wasp.ts`);
417
+ const configFilePath = path4.join(configDir, `feature.wasp.ts`);
427
418
  if (!this.fileSystem.existsSync(configFilePath)) {
428
419
  const templatePath = this.getTemplatePath("feature.wasp.eta");
429
420
  if (!this.fileSystem.existsSync(templatePath)) {
@@ -803,14 +794,6 @@ var WaspConfigGenerator = class {
803
794
 
804
795
  // src/generators/base/wasp-generator.base.ts
805
796
  var WaspGeneratorBase = class extends GeneratorBase {
806
- constructor(fileSystem = realFileSystem, logger = singletonLogger2) {
807
- super(fileSystem, logger);
808
- this.fileSystem = fileSystem;
809
- this.logger = logger;
810
- this.configGenerator = new WaspConfigGenerator(logger, fileSystem);
811
- this.templateUtility = new TemplateUtility(fileSystem);
812
- this.templateResolver = new TemplateResolver(fileSystem);
813
- }
814
797
  configGenerator;
815
798
  templateUtility;
816
799
  templateResolver;
@@ -818,6 +801,15 @@ var WaspGeneratorBase = class extends GeneratorBase {
818
801
  configLoaded = false;
819
802
  // Plugin name from swarm.config.json
820
803
  pluginName = PLUGIN_NAME;
804
+ constructor() {
805
+ super();
806
+ this.configGenerator = new WaspConfigGenerator(
807
+ this.logger,
808
+ this.fileSystem
809
+ );
810
+ this.templateUtility = new TemplateUtility(this.fileSystem);
811
+ this.templateResolver = new TemplateResolver(this.fileSystem);
812
+ }
821
813
  async loadSwarmConfig() {
822
814
  if (this.configLoaded) return;
823
815
  const configManager = new SwarmConfigManager();
@@ -868,7 +860,7 @@ var WaspGeneratorBase = class extends GeneratorBase {
868
860
  }
869
861
  /**
870
862
  * Generic existence check with force flag handling
871
- * Consolidates the pattern used in both file and config checks
863
+ * Consolidates the pattern used in both file and config existence checks
872
864
  */
873
865
  checkExistence(exists, itemDescription, force, errorMessage) {
874
866
  if (exists && !force) {
@@ -908,16 +900,14 @@ var schema = z2.object({
908
900
 
909
901
  // src/generators/feature/feature-generator.ts
910
902
  var FeatureGenerator = class extends WaspGeneratorBase {
911
- constructor(logger = singletonLogger3, fileSystem = realFileSystem) {
912
- super(fileSystem, logger);
913
- this.logger = logger;
914
- this.fileSystem = fileSystem;
915
- this.name = "feature";
916
- this.description = "Generates a feature directory containing a Wasp configuration file";
917
- }
918
903
  name;
919
904
  description;
920
905
  schema = schema;
906
+ constructor() {
907
+ super();
908
+ this.name = "feature";
909
+ this.description = "Generates a feature directory containing a Wasp configuration file";
910
+ }
921
911
  getDefaultTemplatePath(templateName) {
922
912
  return this.templateUtility.resolveTemplatePath(
923
913
  templateName,
@@ -933,18 +923,18 @@ var FeatureGenerator = class extends WaspGeneratorBase {
933
923
  const { target } = args;
934
924
  const segments = validateFeaturePath2(target);
935
925
  const normalisedPath = normaliseFeaturePath(target);
936
- const sourceRoot = path6.join(findWaspRoot(this.fileSystem), "src");
926
+ const sourceRoot = path5.join(findWaspRoot(this.fileSystem), "src");
937
927
  if (segments.length > 1) {
938
928
  const parentPath = segments.slice(0, -1).join("/");
939
929
  const parentNormalisedPath = normaliseFeaturePath(parentPath);
940
- const parentFeatureDir = path6.join(sourceRoot, parentNormalisedPath);
930
+ const parentFeatureDir = path5.join(sourceRoot, parentNormalisedPath);
941
931
  if (!this.fileSystem.existsSync(parentFeatureDir)) {
942
932
  handleFatalError2(
943
933
  `Parent feature '${parentPath}' does not exist. Please create it first.`
944
934
  );
945
935
  }
946
936
  }
947
- const featureDir = path6.join(sourceRoot, normalisedPath);
937
+ const featureDir = path5.join(sourceRoot, normalisedPath);
948
938
  this.fileSystem.mkdirSync(featureDir, { recursive: true });
949
939
  this.configGenerator.generate(normalisedPath);
950
940
  this.logger.success(`Generated feature: ${normalisedPath}`);
@@ -953,13 +943,6 @@ var FeatureGenerator = class extends WaspGeneratorBase {
953
943
 
954
944
  // src/generators/base/component-generator.base.ts
955
945
  var ComponentGeneratorBase = class extends WaspGeneratorBase {
956
- constructor(logger = singletonLogger4, fileSystem = realFileSystem, featureDirectoryGenerator = new FeatureGenerator(logger, fileSystem)) {
957
- super(fileSystem, logger);
958
- this.logger = logger;
959
- this.fileSystem = fileSystem;
960
- this.featureDirectoryGenerator = featureDirectoryGenerator;
961
- this.featureDirectoryGenerator = featureDirectoryGenerator;
962
- }
963
946
  getDefaultTemplatePath(templateName) {
964
947
  return this.templateUtility.resolveTemplatePath(
965
948
  templateName,
@@ -967,6 +950,17 @@ var ComponentGeneratorBase = class extends WaspGeneratorBase {
967
950
  import.meta.url
968
951
  );
969
952
  }
953
+ featureDirectoryGenerator;
954
+ constructor() {
955
+ super();
956
+ const runtime = GeneratorRuntime.current();
957
+ if (runtime.featureGeneratorFactory) {
958
+ const factoryResult = runtime.featureGeneratorFactory(runtime);
959
+ this.featureDirectoryGenerator = factoryResult;
960
+ } else {
961
+ this.featureDirectoryGenerator = new FeatureGenerator();
962
+ }
963
+ }
970
964
  get name() {
971
965
  return toKebabCase2(this.componentType);
972
966
  }
@@ -981,7 +975,7 @@ var ComponentGeneratorBase = class extends WaspGeneratorBase {
981
975
  const currentPath = pathSegments.join("/");
982
976
  const featureName = pathSegments[pathSegments.length - 1];
983
977
  const featureDir = getFeatureDir(this.fileSystem, currentPath);
984
- const configPath = path7.join(featureDir, `feature.wasp.ts`);
978
+ const configPath = path6.join(featureDir, `feature.wasp.ts`);
985
979
  if (this.fileSystem.existsSync(configPath)) {
986
980
  return configPath;
987
981
  }
@@ -1043,18 +1037,17 @@ var ComponentGeneratorBase = class extends WaspGeneratorBase {
1043
1037
  }
1044
1038
  /**
1045
1039
  * Gets the appropriate directory for a feature based on its path.
1046
- * @param fileSystem - The filesystem abstraction
1047
1040
  * @param featurePath - The full feature path
1048
1041
  * @param type - The type of file being generated
1049
1042
  * @returns The target directory and import path
1050
1043
  */
1051
- getFeatureTargetDir(fileSystem, featurePath, type) {
1044
+ getFeatureTargetDir(featurePath, type) {
1052
1045
  validateFeaturePath3(featurePath);
1053
1046
  const normalisedPath = normaliseFeaturePath(featurePath);
1054
- const featureDir = getFeatureDir(fileSystem, normalisedPath);
1047
+ const featureDir = getFeatureDir(this.fileSystem, normalisedPath);
1055
1048
  const typeKey = type.toLowerCase();
1056
1049
  const typeDirectory = TYPE_DIRECTORIES[typeKey];
1057
- const targetDirectory = path7.join(featureDir, typeDirectory);
1050
+ const targetDirectory = path6.join(featureDir, typeDirectory);
1058
1051
  const importDirectory = `@src/${normalisedPath}/${typeDirectory}`;
1059
1052
  return { targetDirectory, importDirectory };
1060
1053
  }
@@ -1063,7 +1056,6 @@ var ComponentGeneratorBase = class extends WaspGeneratorBase {
1063
1056
  */
1064
1057
  ensureTargetDirectory(featurePath, type) {
1065
1058
  const { targetDirectory, importDirectory } = this.getFeatureTargetDir(
1066
- this.fileSystem,
1067
1059
  featurePath,
1068
1060
  type
1069
1061
  );
@@ -1,4 +1,4 @@
1
- import { FileSystem, GeneratorBase, Logger, TemplateResolver } from '@ingenyus/swarm';
1
+ import { GeneratorBase, TemplateResolver } from '@ingenyus/swarm';
2
2
  import { ZodType } from 'zod';
3
3
  import { TemplateUtility } from '../../common';
4
4
  import { WaspConfigGenerator } from '../config';
@@ -6,15 +6,13 @@ import { WaspConfigGenerator } from '../config';
6
6
  * Abstract base class for all Wasp generators
7
7
  */
8
8
  export declare abstract class WaspGeneratorBase<S extends ZodType> extends GeneratorBase<S> {
9
- fileSystem: FileSystem;
10
- logger: Logger;
11
9
  protected configGenerator: WaspConfigGenerator;
12
10
  protected templateUtility: TemplateUtility;
13
11
  protected templateResolver: TemplateResolver;
14
12
  private swarmConfig;
15
13
  private configLoaded;
16
14
  protected readonly pluginName: "wasp";
17
- constructor(fileSystem?: FileSystem, logger?: Logger);
15
+ constructor();
18
16
  private loadSwarmConfig;
19
17
  protected getCustomTemplateDir(): Promise<string | undefined>;
20
18
  /**
@@ -33,7 +31,7 @@ export declare abstract class WaspGeneratorBase<S extends ZodType> extends Gener
33
31
  protected renderTemplateToFile(templateName: string, replacements: Record<string, any>, outputPath: string, readableFileType: string, force: boolean): Promise<boolean>;
34
32
  /**
35
33
  * Generic existence check with force flag handling
36
- * Consolidates the pattern used in both file and config checks
34
+ * Consolidates the pattern used in both file and config existence checks
37
35
  */
38
36
  protected checkExistence(exists: boolean, itemDescription: string, force: boolean, errorMessage?: string): boolean;
39
37
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"wasp-generator.base.d.ts","sourceRoot":"","sources":["../../../src/generators/base/wasp-generator.base.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,aAAa,EACb,MAAM,EAKN,gBAAgB,EACjB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,OAAO,EAAE,MAAM,KAAK,CAAC;AAC9B,OAAO,EAAkB,eAAe,EAAE,MAAM,cAAc,CAAC;AAE/D,OAAO,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AAEh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EAAE,OAAO,EACf,eAAe,EAAE,MAAM,EACvB,KAAK,EAAE,OAAO,EACd,YAAY,CAAC,EAAE,MAAM,GACpB,OAAO;IAQV;;OAEG;IACH,SAAS,CAAC,eAAe,CACvB,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAE,OAAO,EACd,QAAQ,EAAE,MAAM,GACf,OAAO;IAUV;;OAEG;IACH,SAAS,CAAC,SAAS,CACjB,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,MAAM,EAChB,UAAU,EAAE,OAAO,GAClB,IAAI;CAMR"}
@@ -1,7 +1,6 @@
1
1
  // src/generators/base/wasp-generator.base.ts
2
2
  import {
3
3
  GeneratorBase,
4
- logger as singletonLogger2,
5
4
  SwarmConfigManager,
6
5
  TemplateResolver
7
6
  } from "@ingenyus/swarm";
@@ -58,16 +57,12 @@ function getFeatureDir(fileSystem, featureName) {
58
57
  return path.join(waspRoot, "src", normalisedPath);
59
58
  }
60
59
 
61
- // src/common/plugin.ts
62
- import path2 from "path";
63
- import { fileURLToPath } from "url";
64
-
65
60
  // src/common/prisma.ts
66
61
  import {
67
62
  getSchema
68
63
  } from "@mrleebo/prisma-ast";
69
64
  import fs2 from "fs";
70
- import path3 from "path";
65
+ import path2 from "path";
71
66
 
72
67
  // src/common/schemas.ts
73
68
  import { commandRegistry } from "@ingenyus/swarm";
@@ -124,7 +119,7 @@ var commonSchemas = {
124
119
  // src/common/templates.ts
125
120
  import { toKebabCase } from "@ingenyus/swarm";
126
121
  import { Eta } from "eta";
127
- import path4 from "path";
122
+ import path3 from "path";
128
123
  var TemplateUtility = class {
129
124
  constructor(fileSystem) {
130
125
  this.fileSystem = fileSystem;
@@ -132,14 +127,14 @@ var TemplateUtility = class {
132
127
  processTemplate(templatePath, replacements) {
133
128
  const declarations = Object.keys(replacements).map((key) => `${key}=it.${key}`).join(", ");
134
129
  const functionHeader = declarations ? `const ${declarations};` : void 0;
135
- const templateDir = path4.dirname(templatePath);
130
+ const templateDir = path3.dirname(templatePath);
136
131
  const eta = new Eta({
137
132
  autoTrim: false,
138
133
  autoEscape: false,
139
134
  views: templateDir,
140
135
  functionHeader
141
136
  });
142
- const templateName = path4.basename(templatePath).replace(/\.eta$/, "");
137
+ const templateName = path3.basename(templatePath).replace(/\.eta$/, "");
143
138
  if (this.fileSystem.existsSync(templatePath)) {
144
139
  return eta.render(templateName, replacements);
145
140
  } else {
@@ -157,11 +152,11 @@ var TemplateUtility = class {
157
152
  resolveTemplatePath(relativePath, generatorName, currentFileUrl) {
158
153
  const generatorDirName = toKebabCase(generatorName);
159
154
  const currentFilePath = new URL(currentFileUrl).pathname;
160
- const currentFileDir = path4.dirname(currentFilePath);
161
- const currentFileName = path4.basename(currentFilePath);
155
+ const currentFileDir = path3.dirname(currentFilePath);
156
+ const currentFileName = path3.basename(currentFilePath);
162
157
  const isInstalledPackage = currentFileDir.includes("node_modules") && currentFileDir.endsWith("/dist") && currentFileName === "index.js";
163
- const startDir = isInstalledPackage ? currentFileDir : path4.dirname(path4.dirname(currentFileDir));
164
- return path4.join(
158
+ const startDir = isInstalledPackage ? currentFileDir : path3.dirname(path3.dirname(currentFileDir));
159
+ return path3.join(
165
160
  startDir,
166
161
  "generators",
167
162
  generatorDirName,
@@ -177,14 +172,14 @@ import {
177
172
  parseHelperMethodDefinition,
178
173
  logger as singletonLogger
179
174
  } from "@ingenyus/swarm";
180
- import path5 from "path";
175
+ import path4 from "path";
181
176
  var WaspConfigGenerator = class {
182
177
  constructor(logger = singletonLogger, fileSystem = realFileSystem) {
183
178
  this.logger = logger;
184
179
  this.fileSystem = fileSystem;
185
180
  this.templateUtility = new TemplateUtility(fileSystem);
186
181
  }
187
- path = path5;
182
+ path = path4;
188
183
  templateUtility;
189
184
  /**
190
185
  * Gets the template path for feature config templates.
@@ -213,7 +208,7 @@ var WaspConfigGenerator = class {
213
208
  this.logger.error(`Template not found: ${templatePath}`);
214
209
  return;
215
210
  }
216
- const configFilePath = path5.join(featureDir, `feature.wasp.ts`);
211
+ const configFilePath = path4.join(featureDir, `feature.wasp.ts`);
217
212
  if (this.fileSystem.existsSync(configFilePath)) {
218
213
  this.logger.warn(`Feature config already exists: ${configFilePath}`);
219
214
  return;
@@ -229,7 +224,7 @@ var WaspConfigGenerator = class {
229
224
  */
230
225
  update(featurePath, declaration) {
231
226
  const configDir = getFeatureDir(this.fileSystem, featurePath);
232
- const configFilePath = path5.join(configDir, `feature.wasp.ts`);
227
+ const configFilePath = path4.join(configDir, `feature.wasp.ts`);
233
228
  if (!this.fileSystem.existsSync(configFilePath)) {
234
229
  const templatePath = this.getTemplatePath("feature.wasp.eta");
235
230
  if (!this.fileSystem.existsSync(templatePath)) {
@@ -609,14 +604,6 @@ var WaspConfigGenerator = class {
609
604
 
610
605
  // src/generators/base/wasp-generator.base.ts
611
606
  var WaspGeneratorBase = class extends GeneratorBase {
612
- constructor(fileSystem = realFileSystem, logger = singletonLogger2) {
613
- super(fileSystem, logger);
614
- this.fileSystem = fileSystem;
615
- this.logger = logger;
616
- this.configGenerator = new WaspConfigGenerator(logger, fileSystem);
617
- this.templateUtility = new TemplateUtility(fileSystem);
618
- this.templateResolver = new TemplateResolver(fileSystem);
619
- }
620
607
  configGenerator;
621
608
  templateUtility;
622
609
  templateResolver;
@@ -624,6 +611,15 @@ var WaspGeneratorBase = class extends GeneratorBase {
624
611
  configLoaded = false;
625
612
  // Plugin name from swarm.config.json
626
613
  pluginName = PLUGIN_NAME;
614
+ constructor() {
615
+ super();
616
+ this.configGenerator = new WaspConfigGenerator(
617
+ this.logger,
618
+ this.fileSystem
619
+ );
620
+ this.templateUtility = new TemplateUtility(this.fileSystem);
621
+ this.templateResolver = new TemplateResolver(this.fileSystem);
622
+ }
627
623
  async loadSwarmConfig() {
628
624
  if (this.configLoaded) return;
629
625
  const configManager = new SwarmConfigManager();
@@ -674,7 +670,7 @@ var WaspGeneratorBase = class extends GeneratorBase {
674
670
  }
675
671
  /**
676
672
  * Generic existence check with force flag handling
677
- * Consolidates the pattern used in both file and config checks
673
+ * Consolidates the pattern used in both file and config existence checks
678
674
  */
679
675
  checkExistence(exists, itemDescription, force, errorMessage) {
680
676
  if (exists && !force) {
@@ -4,7 +4,7 @@ import {
4
4
  parseHelperMethodDefinition,
5
5
  logger as singletonLogger
6
6
  } from "@ingenyus/swarm";
7
- import path5 from "path";
7
+ import path4 from "path";
8
8
 
9
9
  // src/common/filesystem.ts
10
10
  import { toPascalCase, validateFeaturePath } from "@ingenyus/swarm";
@@ -53,16 +53,12 @@ function getFeatureDir(fileSystem, featureName) {
53
53
  return path.join(waspRoot, "src", normalisedPath);
54
54
  }
55
55
 
56
- // src/common/plugin.ts
57
- import path2 from "path";
58
- import { fileURLToPath } from "url";
59
-
60
56
  // src/common/prisma.ts
61
57
  import {
62
58
  getSchema
63
59
  } from "@mrleebo/prisma-ast";
64
60
  import fs2 from "fs";
65
- import path3 from "path";
61
+ import path2 from "path";
66
62
 
67
63
  // src/common/schemas.ts
68
64
  import { commandRegistry } from "@ingenyus/swarm";
@@ -119,7 +115,7 @@ var commonSchemas = {
119
115
  // src/common/templates.ts
120
116
  import { toKebabCase } from "@ingenyus/swarm";
121
117
  import { Eta } from "eta";
122
- import path4 from "path";
118
+ import path3 from "path";
123
119
  var TemplateUtility = class {
124
120
  constructor(fileSystem) {
125
121
  this.fileSystem = fileSystem;
@@ -127,14 +123,14 @@ var TemplateUtility = class {
127
123
  processTemplate(templatePath, replacements) {
128
124
  const declarations = Object.keys(replacements).map((key) => `${key}=it.${key}`).join(", ");
129
125
  const functionHeader = declarations ? `const ${declarations};` : void 0;
130
- const templateDir = path4.dirname(templatePath);
126
+ const templateDir = path3.dirname(templatePath);
131
127
  const eta = new Eta({
132
128
  autoTrim: false,
133
129
  autoEscape: false,
134
130
  views: templateDir,
135
131
  functionHeader
136
132
  });
137
- const templateName = path4.basename(templatePath).replace(/\.eta$/, "");
133
+ const templateName = path3.basename(templatePath).replace(/\.eta$/, "");
138
134
  if (this.fileSystem.existsSync(templatePath)) {
139
135
  return eta.render(templateName, replacements);
140
136
  } else {
@@ -152,11 +148,11 @@ var TemplateUtility = class {
152
148
  resolveTemplatePath(relativePath, generatorName, currentFileUrl) {
153
149
  const generatorDirName = toKebabCase(generatorName);
154
150
  const currentFilePath = new URL(currentFileUrl).pathname;
155
- const currentFileDir = path4.dirname(currentFilePath);
156
- const currentFileName = path4.basename(currentFilePath);
151
+ const currentFileDir = path3.dirname(currentFilePath);
152
+ const currentFileName = path3.basename(currentFilePath);
157
153
  const isInstalledPackage = currentFileDir.includes("node_modules") && currentFileDir.endsWith("/dist") && currentFileName === "index.js";
158
- const startDir = isInstalledPackage ? currentFileDir : path4.dirname(path4.dirname(currentFileDir));
159
- return path4.join(
154
+ const startDir = isInstalledPackage ? currentFileDir : path3.dirname(path3.dirname(currentFileDir));
155
+ return path3.join(
160
156
  startDir,
161
157
  "generators",
162
158
  generatorDirName,
@@ -173,7 +169,7 @@ var WaspConfigGenerator = class {
173
169
  this.fileSystem = fileSystem;
174
170
  this.templateUtility = new TemplateUtility(fileSystem);
175
171
  }
176
- path = path5;
172
+ path = path4;
177
173
  templateUtility;
178
174
  /**
179
175
  * Gets the template path for feature config templates.
@@ -202,7 +198,7 @@ var WaspConfigGenerator = class {
202
198
  this.logger.error(`Template not found: ${templatePath}`);
203
199
  return;
204
200
  }
205
- const configFilePath = path5.join(featureDir, `feature.wasp.ts`);
201
+ const configFilePath = path4.join(featureDir, `feature.wasp.ts`);
206
202
  if (this.fileSystem.existsSync(configFilePath)) {
207
203
  this.logger.warn(`Feature config already exists: ${configFilePath}`);
208
204
  return;
@@ -218,7 +214,7 @@ var WaspConfigGenerator = class {
218
214
  */
219
215
  update(featurePath, declaration) {
220
216
  const configDir = getFeatureDir(this.fileSystem, featurePath);
221
- const configFilePath = path5.join(configDir, `feature.wasp.ts`);
217
+ const configFilePath = path4.join(configDir, `feature.wasp.ts`);
222
218
  if (!this.fileSystem.existsSync(configFilePath)) {
223
219
  const templatePath = this.getTemplatePath("feature.wasp.eta");
224
220
  if (!this.fileSystem.existsSync(templatePath)) {
@@ -4,7 +4,7 @@ import {
4
4
  parseHelperMethodDefinition,
5
5
  logger as singletonLogger
6
6
  } from "@ingenyus/swarm";
7
- import path5 from "path";
7
+ import path4 from "path";
8
8
 
9
9
  // src/common/filesystem.ts
10
10
  import { toPascalCase, validateFeaturePath } from "@ingenyus/swarm";
@@ -53,16 +53,12 @@ function getFeatureDir(fileSystem, featureName) {
53
53
  return path.join(waspRoot, "src", normalisedPath);
54
54
  }
55
55
 
56
- // src/common/plugin.ts
57
- import path2 from "path";
58
- import { fileURLToPath } from "url";
59
-
60
56
  // src/common/prisma.ts
61
57
  import {
62
58
  getSchema
63
59
  } from "@mrleebo/prisma-ast";
64
60
  import fs2 from "fs";
65
- import path3 from "path";
61
+ import path2 from "path";
66
62
 
67
63
  // src/common/schemas.ts
68
64
  import { commandRegistry } from "@ingenyus/swarm";
@@ -119,7 +115,7 @@ var commonSchemas = {
119
115
  // src/common/templates.ts
120
116
  import { toKebabCase } from "@ingenyus/swarm";
121
117
  import { Eta } from "eta";
122
- import path4 from "path";
118
+ import path3 from "path";
123
119
  var TemplateUtility = class {
124
120
  constructor(fileSystem) {
125
121
  this.fileSystem = fileSystem;
@@ -127,14 +123,14 @@ var TemplateUtility = class {
127
123
  processTemplate(templatePath, replacements) {
128
124
  const declarations = Object.keys(replacements).map((key) => `${key}=it.${key}`).join(", ");
129
125
  const functionHeader = declarations ? `const ${declarations};` : void 0;
130
- const templateDir = path4.dirname(templatePath);
126
+ const templateDir = path3.dirname(templatePath);
131
127
  const eta = new Eta({
132
128
  autoTrim: false,
133
129
  autoEscape: false,
134
130
  views: templateDir,
135
131
  functionHeader
136
132
  });
137
- const templateName = path4.basename(templatePath).replace(/\.eta$/, "");
133
+ const templateName = path3.basename(templatePath).replace(/\.eta$/, "");
138
134
  if (this.fileSystem.existsSync(templatePath)) {
139
135
  return eta.render(templateName, replacements);
140
136
  } else {
@@ -152,11 +148,11 @@ var TemplateUtility = class {
152
148
  resolveTemplatePath(relativePath, generatorName, currentFileUrl) {
153
149
  const generatorDirName = toKebabCase(generatorName);
154
150
  const currentFilePath = new URL(currentFileUrl).pathname;
155
- const currentFileDir = path4.dirname(currentFilePath);
156
- const currentFileName = path4.basename(currentFilePath);
151
+ const currentFileDir = path3.dirname(currentFilePath);
152
+ const currentFileName = path3.basename(currentFilePath);
157
153
  const isInstalledPackage = currentFileDir.includes("node_modules") && currentFileDir.endsWith("/dist") && currentFileName === "index.js";
158
- const startDir = isInstalledPackage ? currentFileDir : path4.dirname(path4.dirname(currentFileDir));
159
- return path4.join(
154
+ const startDir = isInstalledPackage ? currentFileDir : path3.dirname(path3.dirname(currentFileDir));
155
+ return path3.join(
160
156
  startDir,
161
157
  "generators",
162
158
  generatorDirName,
@@ -173,7 +169,7 @@ var WaspConfigGenerator = class {
173
169
  this.fileSystem = fileSystem;
174
170
  this.templateUtility = new TemplateUtility(fileSystem);
175
171
  }
176
- path = path5;
172
+ path = path4;
177
173
  templateUtility;
178
174
  /**
179
175
  * Gets the template path for feature config templates.
@@ -202,7 +198,7 @@ var WaspConfigGenerator = class {
202
198
  this.logger.error(`Template not found: ${templatePath}`);
203
199
  return;
204
200
  }
205
- const configFilePath = path5.join(featureDir, `feature.wasp.ts`);
201
+ const configFilePath = path4.join(featureDir, `feature.wasp.ts`);
206
202
  if (this.fileSystem.existsSync(configFilePath)) {
207
203
  this.logger.warn(`Feature config already exists: ${configFilePath}`);
208
204
  return;
@@ -218,7 +214,7 @@ var WaspConfigGenerator = class {
218
214
  */
219
215
  update(featurePath, declaration) {
220
216
  const configDir = getFeatureDir(this.fileSystem, featurePath);
221
- const configFilePath = path5.join(configDir, `feature.wasp.ts`);
217
+ const configFilePath = path4.join(configDir, `feature.wasp.ts`);
222
218
  if (!this.fileSystem.existsSync(configFilePath)) {
223
219
  const templatePath = this.getTemplatePath("feature.wasp.eta");
224
220
  if (!this.fileSystem.existsSync(templatePath)) {