@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.
- package/dist/.tsbuildinfo +1 -1
- package/dist/common/index.d.ts +0 -1
- package/dist/common/index.d.ts.map +1 -1
- package/dist/common/index.js +9 -34
- package/dist/generators/action/action-generator.js +50 -58
- package/dist/generators/action/index.js +50 -58
- package/dist/generators/action/schema.js +1 -5
- package/dist/generators/api/api-generator.js +51 -59
- package/dist/generators/api/index.js +51 -59
- package/dist/generators/api/schema.js +1 -5
- package/dist/generators/api-namespace/api-namespace-generator.js +51 -59
- package/dist/generators/api-namespace/index.js +51 -59
- package/dist/generators/api-namespace/schema.js +1 -5
- package/dist/generators/base/component-generator.base.d.ts +4 -7
- package/dist/generators/base/component-generator.base.d.ts.map +1 -1
- package/dist/generators/base/component-generator.base.js +49 -57
- package/dist/generators/base/index.js +50 -58
- package/dist/generators/base/operation-generator.base.js +50 -58
- package/dist/generators/base/wasp-generator.base.d.ts +3 -5
- package/dist/generators/base/wasp-generator.base.d.ts.map +1 -1
- package/dist/generators/base/wasp-generator.base.js +22 -26
- package/dist/generators/config/index.js +12 -16
- package/dist/generators/config/wasp-config-generator.js +12 -16
- package/dist/generators/crud/crud-generator.js +50 -58
- package/dist/generators/crud/index.js +50 -58
- package/dist/generators/crud/schema.js +1 -5
- package/dist/generators/feature/feature-generator.d.ts +2 -4
- package/dist/generators/feature/feature-generator.d.ts.map +1 -1
- package/dist/generators/feature/feature-generator.js +32 -42
- package/dist/generators/feature/index.js +32 -42
- package/dist/generators/feature/schema.js +1 -5
- package/dist/generators/index.js +54 -62
- package/dist/generators/job/index.js +49 -57
- package/dist/generators/job/job-generator.js +49 -57
- package/dist/generators/job/schema.js +1 -5
- package/dist/generators/query/index.js +50 -58
- package/dist/generators/query/query-generator.js +50 -58
- package/dist/generators/query/schema.js +1 -5
- package/dist/generators/route/index.js +49 -57
- package/dist/generators/route/route-generator.js +49 -57
- package/dist/generators/route/schema.js +1 -5
- package/dist/index.js +60 -90
- package/dist/plugins/wasp.d.ts.map +1 -1
- package/package.json +2 -2
- package/dist/common/plugin.d.ts +0 -2
- package/dist/common/plugin.d.ts.map +0 -1
- package/dist/common/plugin.js +0 -41
|
@@ -116,19 +116,15 @@ function getFeatureImportPath(featurePath) {
|
|
|
116
116
|
return segments.join("/");
|
|
117
117
|
}
|
|
118
118
|
|
|
119
|
-
// src/common/plugin.ts
|
|
120
|
-
import path2 from "path";
|
|
121
|
-
import { fileURLToPath } from "url";
|
|
122
|
-
|
|
123
119
|
// src/common/prisma.ts
|
|
124
120
|
import {
|
|
125
121
|
getSchema
|
|
126
122
|
} from "@mrleebo/prisma-ast";
|
|
127
123
|
import fs2 from "fs";
|
|
128
|
-
import
|
|
124
|
+
import path2 from "path";
|
|
129
125
|
async function getEntityMetadata(modelName) {
|
|
130
126
|
try {
|
|
131
|
-
const schemaPath =
|
|
127
|
+
const schemaPath = path2.join(process.cwd(), "schema.prisma");
|
|
132
128
|
const schemaContent = fs2.readFileSync(schemaPath, "utf8");
|
|
133
129
|
const schema3 = getSchema(schemaContent);
|
|
134
130
|
const model = schema3.list?.find(
|
|
@@ -303,7 +299,7 @@ var commonSchemas = {
|
|
|
303
299
|
// src/common/templates.ts
|
|
304
300
|
import { toKebabCase } from "@ingenyus/swarm";
|
|
305
301
|
import { Eta } from "eta";
|
|
306
|
-
import
|
|
302
|
+
import path3 from "path";
|
|
307
303
|
var TemplateUtility = class {
|
|
308
304
|
constructor(fileSystem) {
|
|
309
305
|
this.fileSystem = fileSystem;
|
|
@@ -311,14 +307,14 @@ var TemplateUtility = class {
|
|
|
311
307
|
processTemplate(templatePath, replacements) {
|
|
312
308
|
const declarations = Object.keys(replacements).map((key) => `${key}=it.${key}`).join(", ");
|
|
313
309
|
const functionHeader = declarations ? `const ${declarations};` : void 0;
|
|
314
|
-
const templateDir =
|
|
310
|
+
const templateDir = path3.dirname(templatePath);
|
|
315
311
|
const eta = new Eta({
|
|
316
312
|
autoTrim: false,
|
|
317
313
|
autoEscape: false,
|
|
318
314
|
views: templateDir,
|
|
319
315
|
functionHeader
|
|
320
316
|
});
|
|
321
|
-
const templateName =
|
|
317
|
+
const templateName = path3.basename(templatePath).replace(/\.eta$/, "");
|
|
322
318
|
if (this.fileSystem.existsSync(templatePath)) {
|
|
323
319
|
return eta.render(templateName, replacements);
|
|
324
320
|
} else {
|
|
@@ -336,11 +332,11 @@ var TemplateUtility = class {
|
|
|
336
332
|
resolveTemplatePath(relativePath, generatorName, currentFileUrl) {
|
|
337
333
|
const generatorDirName = toKebabCase(generatorName);
|
|
338
334
|
const currentFilePath = new URL(currentFileUrl).pathname;
|
|
339
|
-
const currentFileDir =
|
|
340
|
-
const currentFileName =
|
|
335
|
+
const currentFileDir = path3.dirname(currentFilePath);
|
|
336
|
+
const currentFileName = path3.basename(currentFilePath);
|
|
341
337
|
const isInstalledPackage = currentFileDir.includes("node_modules") && currentFileDir.endsWith("/dist") && currentFileName === "index.js";
|
|
342
|
-
const startDir = isInstalledPackage ? currentFileDir :
|
|
343
|
-
return
|
|
338
|
+
const startDir = isInstalledPackage ? currentFileDir : path3.dirname(path3.dirname(currentFileDir));
|
|
339
|
+
return path3.join(
|
|
344
340
|
startDir,
|
|
345
341
|
"generators",
|
|
346
342
|
generatorDirName,
|
|
@@ -352,26 +348,21 @@ var TemplateUtility = class {
|
|
|
352
348
|
|
|
353
349
|
// src/generators/base/component-generator.base.ts
|
|
354
350
|
import {
|
|
351
|
+
GeneratorRuntime,
|
|
355
352
|
hasHelperMethodCall,
|
|
356
|
-
logger as singletonLogger4,
|
|
357
353
|
toCamelCase,
|
|
358
354
|
toKebabCase as toKebabCase2,
|
|
359
355
|
validateFeaturePath as validateFeaturePath3
|
|
360
356
|
} from "@ingenyus/swarm";
|
|
361
|
-
import
|
|
357
|
+
import path6 from "path";
|
|
362
358
|
|
|
363
359
|
// src/generators/feature/feature-generator.ts
|
|
364
|
-
import {
|
|
365
|
-
|
|
366
|
-
logger as singletonLogger3,
|
|
367
|
-
validateFeaturePath as validateFeaturePath2
|
|
368
|
-
} from "@ingenyus/swarm";
|
|
369
|
-
import path6 from "path";
|
|
360
|
+
import { handleFatalError as handleFatalError2, validateFeaturePath as validateFeaturePath2 } from "@ingenyus/swarm";
|
|
361
|
+
import path5 from "path";
|
|
370
362
|
|
|
371
363
|
// src/generators/base/wasp-generator.base.ts
|
|
372
364
|
import {
|
|
373
365
|
GeneratorBase,
|
|
374
|
-
logger as singletonLogger2,
|
|
375
366
|
SwarmConfigManager,
|
|
376
367
|
TemplateResolver
|
|
377
368
|
} from "@ingenyus/swarm";
|
|
@@ -382,14 +373,14 @@ import {
|
|
|
382
373
|
parseHelperMethodDefinition,
|
|
383
374
|
logger as singletonLogger
|
|
384
375
|
} from "@ingenyus/swarm";
|
|
385
|
-
import
|
|
376
|
+
import path4 from "path";
|
|
386
377
|
var WaspConfigGenerator = class {
|
|
387
378
|
constructor(logger = singletonLogger, fileSystem = realFileSystem) {
|
|
388
379
|
this.logger = logger;
|
|
389
380
|
this.fileSystem = fileSystem;
|
|
390
381
|
this.templateUtility = new TemplateUtility(fileSystem);
|
|
391
382
|
}
|
|
392
|
-
path =
|
|
383
|
+
path = path4;
|
|
393
384
|
templateUtility;
|
|
394
385
|
/**
|
|
395
386
|
* Gets the template path for feature config templates.
|
|
@@ -418,7 +409,7 @@ var WaspConfigGenerator = class {
|
|
|
418
409
|
this.logger.error(`Template not found: ${templatePath}`);
|
|
419
410
|
return;
|
|
420
411
|
}
|
|
421
|
-
const configFilePath =
|
|
412
|
+
const configFilePath = path4.join(featureDir, `feature.wasp.ts`);
|
|
422
413
|
if (this.fileSystem.existsSync(configFilePath)) {
|
|
423
414
|
this.logger.warn(`Feature config already exists: ${configFilePath}`);
|
|
424
415
|
return;
|
|
@@ -434,7 +425,7 @@ var WaspConfigGenerator = class {
|
|
|
434
425
|
*/
|
|
435
426
|
update(featurePath, declaration) {
|
|
436
427
|
const configDir = getFeatureDir(this.fileSystem, featurePath);
|
|
437
|
-
const configFilePath =
|
|
428
|
+
const configFilePath = path4.join(configDir, `feature.wasp.ts`);
|
|
438
429
|
if (!this.fileSystem.existsSync(configFilePath)) {
|
|
439
430
|
const templatePath = this.getTemplatePath("feature.wasp.eta");
|
|
440
431
|
if (!this.fileSystem.existsSync(templatePath)) {
|
|
@@ -814,14 +805,6 @@ var WaspConfigGenerator = class {
|
|
|
814
805
|
|
|
815
806
|
// src/generators/base/wasp-generator.base.ts
|
|
816
807
|
var WaspGeneratorBase = class extends GeneratorBase {
|
|
817
|
-
constructor(fileSystem = realFileSystem, logger = singletonLogger2) {
|
|
818
|
-
super(fileSystem, logger);
|
|
819
|
-
this.fileSystem = fileSystem;
|
|
820
|
-
this.logger = logger;
|
|
821
|
-
this.configGenerator = new WaspConfigGenerator(logger, fileSystem);
|
|
822
|
-
this.templateUtility = new TemplateUtility(fileSystem);
|
|
823
|
-
this.templateResolver = new TemplateResolver(fileSystem);
|
|
824
|
-
}
|
|
825
808
|
configGenerator;
|
|
826
809
|
templateUtility;
|
|
827
810
|
templateResolver;
|
|
@@ -829,6 +812,15 @@ var WaspGeneratorBase = class extends GeneratorBase {
|
|
|
829
812
|
configLoaded = false;
|
|
830
813
|
// Plugin name from swarm.config.json
|
|
831
814
|
pluginName = PLUGIN_NAME;
|
|
815
|
+
constructor() {
|
|
816
|
+
super();
|
|
817
|
+
this.configGenerator = new WaspConfigGenerator(
|
|
818
|
+
this.logger,
|
|
819
|
+
this.fileSystem
|
|
820
|
+
);
|
|
821
|
+
this.templateUtility = new TemplateUtility(this.fileSystem);
|
|
822
|
+
this.templateResolver = new TemplateResolver(this.fileSystem);
|
|
823
|
+
}
|
|
832
824
|
async loadSwarmConfig() {
|
|
833
825
|
if (this.configLoaded) return;
|
|
834
826
|
const configManager = new SwarmConfigManager();
|
|
@@ -879,7 +871,7 @@ var WaspGeneratorBase = class extends GeneratorBase {
|
|
|
879
871
|
}
|
|
880
872
|
/**
|
|
881
873
|
* Generic existence check with force flag handling
|
|
882
|
-
* Consolidates the pattern used in both file and config checks
|
|
874
|
+
* Consolidates the pattern used in both file and config existence checks
|
|
883
875
|
*/
|
|
884
876
|
checkExistence(exists, itemDescription, force, errorMessage) {
|
|
885
877
|
if (exists && !force) {
|
|
@@ -919,16 +911,14 @@ var schema = z2.object({
|
|
|
919
911
|
|
|
920
912
|
// src/generators/feature/feature-generator.ts
|
|
921
913
|
var FeatureGenerator = class extends WaspGeneratorBase {
|
|
922
|
-
constructor(logger = singletonLogger3, fileSystem = realFileSystem) {
|
|
923
|
-
super(fileSystem, logger);
|
|
924
|
-
this.logger = logger;
|
|
925
|
-
this.fileSystem = fileSystem;
|
|
926
|
-
this.name = "feature";
|
|
927
|
-
this.description = "Generates a feature directory containing a Wasp configuration file";
|
|
928
|
-
}
|
|
929
914
|
name;
|
|
930
915
|
description;
|
|
931
916
|
schema = schema;
|
|
917
|
+
constructor() {
|
|
918
|
+
super();
|
|
919
|
+
this.name = "feature";
|
|
920
|
+
this.description = "Generates a feature directory containing a Wasp configuration file";
|
|
921
|
+
}
|
|
932
922
|
getDefaultTemplatePath(templateName) {
|
|
933
923
|
return this.templateUtility.resolveTemplatePath(
|
|
934
924
|
templateName,
|
|
@@ -944,18 +934,18 @@ var FeatureGenerator = class extends WaspGeneratorBase {
|
|
|
944
934
|
const { target } = args;
|
|
945
935
|
const segments = validateFeaturePath2(target);
|
|
946
936
|
const normalisedPath = normaliseFeaturePath(target);
|
|
947
|
-
const sourceRoot =
|
|
937
|
+
const sourceRoot = path5.join(findWaspRoot(this.fileSystem), "src");
|
|
948
938
|
if (segments.length > 1) {
|
|
949
939
|
const parentPath = segments.slice(0, -1).join("/");
|
|
950
940
|
const parentNormalisedPath = normaliseFeaturePath(parentPath);
|
|
951
|
-
const parentFeatureDir =
|
|
941
|
+
const parentFeatureDir = path5.join(sourceRoot, parentNormalisedPath);
|
|
952
942
|
if (!this.fileSystem.existsSync(parentFeatureDir)) {
|
|
953
943
|
handleFatalError2(
|
|
954
944
|
`Parent feature '${parentPath}' does not exist. Please create it first.`
|
|
955
945
|
);
|
|
956
946
|
}
|
|
957
947
|
}
|
|
958
|
-
const featureDir =
|
|
948
|
+
const featureDir = path5.join(sourceRoot, normalisedPath);
|
|
959
949
|
this.fileSystem.mkdirSync(featureDir, { recursive: true });
|
|
960
950
|
this.configGenerator.generate(normalisedPath);
|
|
961
951
|
this.logger.success(`Generated feature: ${normalisedPath}`);
|
|
@@ -964,13 +954,6 @@ var FeatureGenerator = class extends WaspGeneratorBase {
|
|
|
964
954
|
|
|
965
955
|
// src/generators/base/component-generator.base.ts
|
|
966
956
|
var ComponentGeneratorBase = class extends WaspGeneratorBase {
|
|
967
|
-
constructor(logger = singletonLogger4, fileSystem = realFileSystem, featureDirectoryGenerator = new FeatureGenerator(logger, fileSystem)) {
|
|
968
|
-
super(fileSystem, logger);
|
|
969
|
-
this.logger = logger;
|
|
970
|
-
this.fileSystem = fileSystem;
|
|
971
|
-
this.featureDirectoryGenerator = featureDirectoryGenerator;
|
|
972
|
-
this.featureDirectoryGenerator = featureDirectoryGenerator;
|
|
973
|
-
}
|
|
974
957
|
getDefaultTemplatePath(templateName) {
|
|
975
958
|
return this.templateUtility.resolveTemplatePath(
|
|
976
959
|
templateName,
|
|
@@ -978,6 +961,17 @@ var ComponentGeneratorBase = class extends WaspGeneratorBase {
|
|
|
978
961
|
import.meta.url
|
|
979
962
|
);
|
|
980
963
|
}
|
|
964
|
+
featureDirectoryGenerator;
|
|
965
|
+
constructor() {
|
|
966
|
+
super();
|
|
967
|
+
const runtime = GeneratorRuntime.current();
|
|
968
|
+
if (runtime.featureGeneratorFactory) {
|
|
969
|
+
const factoryResult = runtime.featureGeneratorFactory(runtime);
|
|
970
|
+
this.featureDirectoryGenerator = factoryResult;
|
|
971
|
+
} else {
|
|
972
|
+
this.featureDirectoryGenerator = new FeatureGenerator();
|
|
973
|
+
}
|
|
974
|
+
}
|
|
981
975
|
get name() {
|
|
982
976
|
return toKebabCase2(this.componentType);
|
|
983
977
|
}
|
|
@@ -992,7 +986,7 @@ var ComponentGeneratorBase = class extends WaspGeneratorBase {
|
|
|
992
986
|
const currentPath = pathSegments.join("/");
|
|
993
987
|
const featureName = pathSegments[pathSegments.length - 1];
|
|
994
988
|
const featureDir = getFeatureDir(this.fileSystem, currentPath);
|
|
995
|
-
const configPath =
|
|
989
|
+
const configPath = path6.join(featureDir, `feature.wasp.ts`);
|
|
996
990
|
if (this.fileSystem.existsSync(configPath)) {
|
|
997
991
|
return configPath;
|
|
998
992
|
}
|
|
@@ -1054,18 +1048,17 @@ var ComponentGeneratorBase = class extends WaspGeneratorBase {
|
|
|
1054
1048
|
}
|
|
1055
1049
|
/**
|
|
1056
1050
|
* Gets the appropriate directory for a feature based on its path.
|
|
1057
|
-
* @param fileSystem - The filesystem abstraction
|
|
1058
1051
|
* @param featurePath - The full feature path
|
|
1059
1052
|
* @param type - The type of file being generated
|
|
1060
1053
|
* @returns The target directory and import path
|
|
1061
1054
|
*/
|
|
1062
|
-
getFeatureTargetDir(
|
|
1055
|
+
getFeatureTargetDir(featurePath, type) {
|
|
1063
1056
|
validateFeaturePath3(featurePath);
|
|
1064
1057
|
const normalisedPath = normaliseFeaturePath(featurePath);
|
|
1065
|
-
const featureDir = getFeatureDir(fileSystem, normalisedPath);
|
|
1058
|
+
const featureDir = getFeatureDir(this.fileSystem, normalisedPath);
|
|
1066
1059
|
const typeKey = type.toLowerCase();
|
|
1067
1060
|
const typeDirectory = TYPE_DIRECTORIES[typeKey];
|
|
1068
|
-
const targetDirectory =
|
|
1061
|
+
const targetDirectory = path6.join(featureDir, typeDirectory);
|
|
1069
1062
|
const importDirectory = `@src/${normalisedPath}/${typeDirectory}`;
|
|
1070
1063
|
return { targetDirectory, importDirectory };
|
|
1071
1064
|
}
|
|
@@ -1074,7 +1067,6 @@ var ComponentGeneratorBase = class extends WaspGeneratorBase {
|
|
|
1074
1067
|
*/
|
|
1075
1068
|
ensureTargetDirectory(featurePath, type) {
|
|
1076
1069
|
const { targetDirectory, importDirectory } = this.getFeatureTargetDir(
|
|
1077
|
-
this.fileSystem,
|
|
1078
1070
|
featurePath,
|
|
1079
1071
|
type
|
|
1080
1072
|
);
|
|
@@ -116,19 +116,15 @@ function getFeatureImportPath(featurePath) {
|
|
|
116
116
|
return segments.join("/");
|
|
117
117
|
}
|
|
118
118
|
|
|
119
|
-
// src/common/plugin.ts
|
|
120
|
-
import path2 from "path";
|
|
121
|
-
import { fileURLToPath } from "url";
|
|
122
|
-
|
|
123
119
|
// src/common/prisma.ts
|
|
124
120
|
import {
|
|
125
121
|
getSchema
|
|
126
122
|
} from "@mrleebo/prisma-ast";
|
|
127
123
|
import fs2 from "fs";
|
|
128
|
-
import
|
|
124
|
+
import path2 from "path";
|
|
129
125
|
async function getEntityMetadata(modelName) {
|
|
130
126
|
try {
|
|
131
|
-
const schemaPath =
|
|
127
|
+
const schemaPath = path2.join(process.cwd(), "schema.prisma");
|
|
132
128
|
const schemaContent = fs2.readFileSync(schemaPath, "utf8");
|
|
133
129
|
const schema3 = getSchema(schemaContent);
|
|
134
130
|
const model = schema3.list?.find(
|
|
@@ -303,7 +299,7 @@ var commonSchemas = {
|
|
|
303
299
|
// src/common/templates.ts
|
|
304
300
|
import { toKebabCase } from "@ingenyus/swarm";
|
|
305
301
|
import { Eta } from "eta";
|
|
306
|
-
import
|
|
302
|
+
import path3 from "path";
|
|
307
303
|
var TemplateUtility = class {
|
|
308
304
|
constructor(fileSystem) {
|
|
309
305
|
this.fileSystem = fileSystem;
|
|
@@ -311,14 +307,14 @@ var TemplateUtility = class {
|
|
|
311
307
|
processTemplate(templatePath, replacements) {
|
|
312
308
|
const declarations = Object.keys(replacements).map((key) => `${key}=it.${key}`).join(", ");
|
|
313
309
|
const functionHeader = declarations ? `const ${declarations};` : void 0;
|
|
314
|
-
const templateDir =
|
|
310
|
+
const templateDir = path3.dirname(templatePath);
|
|
315
311
|
const eta = new Eta({
|
|
316
312
|
autoTrim: false,
|
|
317
313
|
autoEscape: false,
|
|
318
314
|
views: templateDir,
|
|
319
315
|
functionHeader
|
|
320
316
|
});
|
|
321
|
-
const templateName =
|
|
317
|
+
const templateName = path3.basename(templatePath).replace(/\.eta$/, "");
|
|
322
318
|
if (this.fileSystem.existsSync(templatePath)) {
|
|
323
319
|
return eta.render(templateName, replacements);
|
|
324
320
|
} else {
|
|
@@ -336,11 +332,11 @@ var TemplateUtility = class {
|
|
|
336
332
|
resolveTemplatePath(relativePath, generatorName, currentFileUrl) {
|
|
337
333
|
const generatorDirName = toKebabCase(generatorName);
|
|
338
334
|
const currentFilePath = new URL(currentFileUrl).pathname;
|
|
339
|
-
const currentFileDir =
|
|
340
|
-
const currentFileName =
|
|
335
|
+
const currentFileDir = path3.dirname(currentFilePath);
|
|
336
|
+
const currentFileName = path3.basename(currentFilePath);
|
|
341
337
|
const isInstalledPackage = currentFileDir.includes("node_modules") && currentFileDir.endsWith("/dist") && currentFileName === "index.js";
|
|
342
|
-
const startDir = isInstalledPackage ? currentFileDir :
|
|
343
|
-
return
|
|
338
|
+
const startDir = isInstalledPackage ? currentFileDir : path3.dirname(path3.dirname(currentFileDir));
|
|
339
|
+
return path3.join(
|
|
344
340
|
startDir,
|
|
345
341
|
"generators",
|
|
346
342
|
generatorDirName,
|
|
@@ -352,26 +348,21 @@ var TemplateUtility = class {
|
|
|
352
348
|
|
|
353
349
|
// src/generators/base/component-generator.base.ts
|
|
354
350
|
import {
|
|
351
|
+
GeneratorRuntime,
|
|
355
352
|
hasHelperMethodCall,
|
|
356
|
-
logger as singletonLogger4,
|
|
357
353
|
toCamelCase,
|
|
358
354
|
toKebabCase as toKebabCase2,
|
|
359
355
|
validateFeaturePath as validateFeaturePath3
|
|
360
356
|
} from "@ingenyus/swarm";
|
|
361
|
-
import
|
|
357
|
+
import path6 from "path";
|
|
362
358
|
|
|
363
359
|
// src/generators/feature/feature-generator.ts
|
|
364
|
-
import {
|
|
365
|
-
|
|
366
|
-
logger as singletonLogger3,
|
|
367
|
-
validateFeaturePath as validateFeaturePath2
|
|
368
|
-
} from "@ingenyus/swarm";
|
|
369
|
-
import path6 from "path";
|
|
360
|
+
import { handleFatalError as handleFatalError2, validateFeaturePath as validateFeaturePath2 } from "@ingenyus/swarm";
|
|
361
|
+
import path5 from "path";
|
|
370
362
|
|
|
371
363
|
// src/generators/base/wasp-generator.base.ts
|
|
372
364
|
import {
|
|
373
365
|
GeneratorBase,
|
|
374
|
-
logger as singletonLogger2,
|
|
375
366
|
SwarmConfigManager,
|
|
376
367
|
TemplateResolver
|
|
377
368
|
} from "@ingenyus/swarm";
|
|
@@ -382,14 +373,14 @@ import {
|
|
|
382
373
|
parseHelperMethodDefinition,
|
|
383
374
|
logger as singletonLogger
|
|
384
375
|
} from "@ingenyus/swarm";
|
|
385
|
-
import
|
|
376
|
+
import path4 from "path";
|
|
386
377
|
var WaspConfigGenerator = class {
|
|
387
378
|
constructor(logger = singletonLogger, fileSystem = realFileSystem) {
|
|
388
379
|
this.logger = logger;
|
|
389
380
|
this.fileSystem = fileSystem;
|
|
390
381
|
this.templateUtility = new TemplateUtility(fileSystem);
|
|
391
382
|
}
|
|
392
|
-
path =
|
|
383
|
+
path = path4;
|
|
393
384
|
templateUtility;
|
|
394
385
|
/**
|
|
395
386
|
* Gets the template path for feature config templates.
|
|
@@ -418,7 +409,7 @@ var WaspConfigGenerator = class {
|
|
|
418
409
|
this.logger.error(`Template not found: ${templatePath}`);
|
|
419
410
|
return;
|
|
420
411
|
}
|
|
421
|
-
const configFilePath =
|
|
412
|
+
const configFilePath = path4.join(featureDir, `feature.wasp.ts`);
|
|
422
413
|
if (this.fileSystem.existsSync(configFilePath)) {
|
|
423
414
|
this.logger.warn(`Feature config already exists: ${configFilePath}`);
|
|
424
415
|
return;
|
|
@@ -434,7 +425,7 @@ var WaspConfigGenerator = class {
|
|
|
434
425
|
*/
|
|
435
426
|
update(featurePath, declaration) {
|
|
436
427
|
const configDir = getFeatureDir(this.fileSystem, featurePath);
|
|
437
|
-
const configFilePath =
|
|
428
|
+
const configFilePath = path4.join(configDir, `feature.wasp.ts`);
|
|
438
429
|
if (!this.fileSystem.existsSync(configFilePath)) {
|
|
439
430
|
const templatePath = this.getTemplatePath("feature.wasp.eta");
|
|
440
431
|
if (!this.fileSystem.existsSync(templatePath)) {
|
|
@@ -814,14 +805,6 @@ var WaspConfigGenerator = class {
|
|
|
814
805
|
|
|
815
806
|
// src/generators/base/wasp-generator.base.ts
|
|
816
807
|
var WaspGeneratorBase = class extends GeneratorBase {
|
|
817
|
-
constructor(fileSystem = realFileSystem, logger = singletonLogger2) {
|
|
818
|
-
super(fileSystem, logger);
|
|
819
|
-
this.fileSystem = fileSystem;
|
|
820
|
-
this.logger = logger;
|
|
821
|
-
this.configGenerator = new WaspConfigGenerator(logger, fileSystem);
|
|
822
|
-
this.templateUtility = new TemplateUtility(fileSystem);
|
|
823
|
-
this.templateResolver = new TemplateResolver(fileSystem);
|
|
824
|
-
}
|
|
825
808
|
configGenerator;
|
|
826
809
|
templateUtility;
|
|
827
810
|
templateResolver;
|
|
@@ -829,6 +812,15 @@ var WaspGeneratorBase = class extends GeneratorBase {
|
|
|
829
812
|
configLoaded = false;
|
|
830
813
|
// Plugin name from swarm.config.json
|
|
831
814
|
pluginName = PLUGIN_NAME;
|
|
815
|
+
constructor() {
|
|
816
|
+
super();
|
|
817
|
+
this.configGenerator = new WaspConfigGenerator(
|
|
818
|
+
this.logger,
|
|
819
|
+
this.fileSystem
|
|
820
|
+
);
|
|
821
|
+
this.templateUtility = new TemplateUtility(this.fileSystem);
|
|
822
|
+
this.templateResolver = new TemplateResolver(this.fileSystem);
|
|
823
|
+
}
|
|
832
824
|
async loadSwarmConfig() {
|
|
833
825
|
if (this.configLoaded) return;
|
|
834
826
|
const configManager = new SwarmConfigManager();
|
|
@@ -879,7 +871,7 @@ var WaspGeneratorBase = class extends GeneratorBase {
|
|
|
879
871
|
}
|
|
880
872
|
/**
|
|
881
873
|
* Generic existence check with force flag handling
|
|
882
|
-
* Consolidates the pattern used in both file and config checks
|
|
874
|
+
* Consolidates the pattern used in both file and config existence checks
|
|
883
875
|
*/
|
|
884
876
|
checkExistence(exists, itemDescription, force, errorMessage) {
|
|
885
877
|
if (exists && !force) {
|
|
@@ -919,16 +911,14 @@ var schema = z2.object({
|
|
|
919
911
|
|
|
920
912
|
// src/generators/feature/feature-generator.ts
|
|
921
913
|
var FeatureGenerator = class extends WaspGeneratorBase {
|
|
922
|
-
constructor(logger = singletonLogger3, fileSystem = realFileSystem) {
|
|
923
|
-
super(fileSystem, logger);
|
|
924
|
-
this.logger = logger;
|
|
925
|
-
this.fileSystem = fileSystem;
|
|
926
|
-
this.name = "feature";
|
|
927
|
-
this.description = "Generates a feature directory containing a Wasp configuration file";
|
|
928
|
-
}
|
|
929
914
|
name;
|
|
930
915
|
description;
|
|
931
916
|
schema = schema;
|
|
917
|
+
constructor() {
|
|
918
|
+
super();
|
|
919
|
+
this.name = "feature";
|
|
920
|
+
this.description = "Generates a feature directory containing a Wasp configuration file";
|
|
921
|
+
}
|
|
932
922
|
getDefaultTemplatePath(templateName) {
|
|
933
923
|
return this.templateUtility.resolveTemplatePath(
|
|
934
924
|
templateName,
|
|
@@ -944,18 +934,18 @@ var FeatureGenerator = class extends WaspGeneratorBase {
|
|
|
944
934
|
const { target } = args;
|
|
945
935
|
const segments = validateFeaturePath2(target);
|
|
946
936
|
const normalisedPath = normaliseFeaturePath(target);
|
|
947
|
-
const sourceRoot =
|
|
937
|
+
const sourceRoot = path5.join(findWaspRoot(this.fileSystem), "src");
|
|
948
938
|
if (segments.length > 1) {
|
|
949
939
|
const parentPath = segments.slice(0, -1).join("/");
|
|
950
940
|
const parentNormalisedPath = normaliseFeaturePath(parentPath);
|
|
951
|
-
const parentFeatureDir =
|
|
941
|
+
const parentFeatureDir = path5.join(sourceRoot, parentNormalisedPath);
|
|
952
942
|
if (!this.fileSystem.existsSync(parentFeatureDir)) {
|
|
953
943
|
handleFatalError2(
|
|
954
944
|
`Parent feature '${parentPath}' does not exist. Please create it first.`
|
|
955
945
|
);
|
|
956
946
|
}
|
|
957
947
|
}
|
|
958
|
-
const featureDir =
|
|
948
|
+
const featureDir = path5.join(sourceRoot, normalisedPath);
|
|
959
949
|
this.fileSystem.mkdirSync(featureDir, { recursive: true });
|
|
960
950
|
this.configGenerator.generate(normalisedPath);
|
|
961
951
|
this.logger.success(`Generated feature: ${normalisedPath}`);
|
|
@@ -964,13 +954,6 @@ var FeatureGenerator = class extends WaspGeneratorBase {
|
|
|
964
954
|
|
|
965
955
|
// src/generators/base/component-generator.base.ts
|
|
966
956
|
var ComponentGeneratorBase = class extends WaspGeneratorBase {
|
|
967
|
-
constructor(logger = singletonLogger4, fileSystem = realFileSystem, featureDirectoryGenerator = new FeatureGenerator(logger, fileSystem)) {
|
|
968
|
-
super(fileSystem, logger);
|
|
969
|
-
this.logger = logger;
|
|
970
|
-
this.fileSystem = fileSystem;
|
|
971
|
-
this.featureDirectoryGenerator = featureDirectoryGenerator;
|
|
972
|
-
this.featureDirectoryGenerator = featureDirectoryGenerator;
|
|
973
|
-
}
|
|
974
957
|
getDefaultTemplatePath(templateName) {
|
|
975
958
|
return this.templateUtility.resolveTemplatePath(
|
|
976
959
|
templateName,
|
|
@@ -978,6 +961,17 @@ var ComponentGeneratorBase = class extends WaspGeneratorBase {
|
|
|
978
961
|
import.meta.url
|
|
979
962
|
);
|
|
980
963
|
}
|
|
964
|
+
featureDirectoryGenerator;
|
|
965
|
+
constructor() {
|
|
966
|
+
super();
|
|
967
|
+
const runtime = GeneratorRuntime.current();
|
|
968
|
+
if (runtime.featureGeneratorFactory) {
|
|
969
|
+
const factoryResult = runtime.featureGeneratorFactory(runtime);
|
|
970
|
+
this.featureDirectoryGenerator = factoryResult;
|
|
971
|
+
} else {
|
|
972
|
+
this.featureDirectoryGenerator = new FeatureGenerator();
|
|
973
|
+
}
|
|
974
|
+
}
|
|
981
975
|
get name() {
|
|
982
976
|
return toKebabCase2(this.componentType);
|
|
983
977
|
}
|
|
@@ -992,7 +986,7 @@ var ComponentGeneratorBase = class extends WaspGeneratorBase {
|
|
|
992
986
|
const currentPath = pathSegments.join("/");
|
|
993
987
|
const featureName = pathSegments[pathSegments.length - 1];
|
|
994
988
|
const featureDir = getFeatureDir(this.fileSystem, currentPath);
|
|
995
|
-
const configPath =
|
|
989
|
+
const configPath = path6.join(featureDir, `feature.wasp.ts`);
|
|
996
990
|
if (this.fileSystem.existsSync(configPath)) {
|
|
997
991
|
return configPath;
|
|
998
992
|
}
|
|
@@ -1054,18 +1048,17 @@ var ComponentGeneratorBase = class extends WaspGeneratorBase {
|
|
|
1054
1048
|
}
|
|
1055
1049
|
/**
|
|
1056
1050
|
* Gets the appropriate directory for a feature based on its path.
|
|
1057
|
-
* @param fileSystem - The filesystem abstraction
|
|
1058
1051
|
* @param featurePath - The full feature path
|
|
1059
1052
|
* @param type - The type of file being generated
|
|
1060
1053
|
* @returns The target directory and import path
|
|
1061
1054
|
*/
|
|
1062
|
-
getFeatureTargetDir(
|
|
1055
|
+
getFeatureTargetDir(featurePath, type) {
|
|
1063
1056
|
validateFeaturePath3(featurePath);
|
|
1064
1057
|
const normalisedPath = normaliseFeaturePath(featurePath);
|
|
1065
|
-
const featureDir = getFeatureDir(fileSystem, normalisedPath);
|
|
1058
|
+
const featureDir = getFeatureDir(this.fileSystem, normalisedPath);
|
|
1066
1059
|
const typeKey = type.toLowerCase();
|
|
1067
1060
|
const typeDirectory = TYPE_DIRECTORIES[typeKey];
|
|
1068
|
-
const targetDirectory =
|
|
1061
|
+
const targetDirectory = path6.join(featureDir, typeDirectory);
|
|
1069
1062
|
const importDirectory = `@src/${normalisedPath}/${typeDirectory}`;
|
|
1070
1063
|
return { targetDirectory, importDirectory };
|
|
1071
1064
|
}
|
|
@@ -1074,7 +1067,6 @@ var ComponentGeneratorBase = class extends WaspGeneratorBase {
|
|
|
1074
1067
|
*/
|
|
1075
1068
|
ensureTargetDirectory(featurePath, type) {
|
|
1076
1069
|
const { targetDirectory, importDirectory } = this.getFeatureTargetDir(
|
|
1077
|
-
this.fileSystem,
|
|
1078
1070
|
featurePath,
|
|
1079
1071
|
type
|
|
1080
1072
|
);
|
|
@@ -26,16 +26,12 @@ var realFileSystem = {
|
|
|
26
26
|
statSync: fs.statSync
|
|
27
27
|
};
|
|
28
28
|
|
|
29
|
-
// src/common/plugin.ts
|
|
30
|
-
import path from "path";
|
|
31
|
-
import { fileURLToPath } from "url";
|
|
32
|
-
|
|
33
29
|
// src/common/prisma.ts
|
|
34
30
|
import {
|
|
35
31
|
getSchema
|
|
36
32
|
} from "@mrleebo/prisma-ast";
|
|
37
33
|
import fs2 from "fs";
|
|
38
|
-
import
|
|
34
|
+
import path from "path";
|
|
39
35
|
|
|
40
36
|
// src/common/schemas.ts
|
|
41
37
|
import { commandRegistry } from "@ingenyus/swarm";
|
|
@@ -1,15 +1,13 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Out } from '@ingenyus/swarm';
|
|
2
2
|
import { WaspGeneratorBase } from '../base/wasp-generator.base';
|
|
3
3
|
import { schema } from './schema';
|
|
4
4
|
export declare class FeatureGenerator extends WaspGeneratorBase<typeof schema> {
|
|
5
|
-
logger: Logger;
|
|
6
|
-
fileSystem: FileSystem;
|
|
7
5
|
name: string;
|
|
8
6
|
description: string;
|
|
9
7
|
schema: import("zod").ZodObject<{
|
|
10
8
|
target: import("zod").ZodString;
|
|
11
9
|
}, import("zod/v4/core").$strip>;
|
|
12
|
-
constructor(
|
|
10
|
+
constructor();
|
|
13
11
|
protected getDefaultTemplatePath(templateName: string): string;
|
|
14
12
|
/**
|
|
15
13
|
* Generates a feature directory containing a Wasp configuration file
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"feature-generator.d.ts","sourceRoot":"","sources":["../../../src/generators/feature/feature-generator.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"feature-generator.d.ts","sourceRoot":"","sources":["../../../src/generators/feature/feature-generator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoB,GAAG,EAAuB,MAAM,iBAAiB,CAAC;AAG7E,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC,qBAAa,gBAAiB,SAAQ,iBAAiB,CAAC,OAAO,MAAM,CAAC;IACpE,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM;;qCAAU;;IAShB,SAAS,CAAC,sBAAsB,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM;IAQ9D;;;OAGG;IACG,QAAQ,CAAC,IAAI,EAAE,GAAG,CAAC,OAAO,MAAM,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;CAyBxD"}
|