@ingenyus/swarm-wasp 1.0.3 → 1.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.
- package/README.md +14 -0
- package/dist/.tsbuildinfo +1 -1
- package/dist/common/index.d.ts +1 -0
- package/dist/common/index.d.ts.map +1 -1
- package/dist/common/index.js +81 -0
- package/dist/common/wasp-compatibility.d.ts +10 -0
- package/dist/common/wasp-compatibility.d.ts.map +1 -0
- package/dist/common/wasp-compatibility.js +82 -0
- package/dist/generators/action/action-generator.d.ts.map +1 -1
- package/dist/generators/action/action-generator.js +102 -13
- package/dist/generators/action/index.js +102 -13
- package/dist/generators/action/schema.js +7 -0
- package/dist/generators/api/api-generator.d.ts.map +1 -1
- package/dist/generators/api/api-generator.js +104 -15
- package/dist/generators/api/index.js +104 -15
- package/dist/generators/api/schema.js +7 -0
- package/dist/generators/api-namespace/api-namespace-generator.d.ts.map +1 -1
- package/dist/generators/api-namespace/api-namespace-generator.js +104 -15
- package/dist/generators/api-namespace/index.js +104 -15
- package/dist/generators/api-namespace/schema.js +7 -0
- package/dist/generators/base/component-generator.base.js +101 -13
- package/dist/generators/base/index.js +101 -13
- package/dist/generators/base/operation-generator.base.js +101 -13
- package/dist/generators/base/wasp-generator.base.d.ts +5 -0
- package/dist/generators/base/wasp-generator.base.d.ts.map +1 -1
- package/dist/generators/base/wasp-generator.base.js +93 -6
- package/dist/generators/config/index.js +11 -4
- package/dist/generators/config/wasp-config-generator.js +11 -4
- package/dist/generators/crud/crud-generator.d.ts.map +1 -1
- package/dist/generators/crud/crud-generator.js +102 -13
- package/dist/generators/crud/index.js +102 -13
- package/dist/generators/crud/schema.js +7 -0
- package/dist/generators/feature/feature-generator.d.ts.map +1 -1
- package/dist/generators/feature/feature-generator.js +98 -10
- package/dist/generators/feature/index.js +98 -10
- package/dist/generators/feature/schema.js +7 -0
- package/dist/generators/index.js +112 -17
- package/dist/generators/job/index.js +102 -13
- package/dist/generators/job/job-generator.d.ts.map +1 -1
- package/dist/generators/job/job-generator.js +102 -13
- package/dist/generators/job/schema.js +7 -0
- package/dist/generators/query/index.js +102 -13
- package/dist/generators/query/query-generator.d.ts.map +1 -1
- package/dist/generators/query/query-generator.js +102 -13
- package/dist/generators/query/schema.js +7 -0
- package/dist/generators/route/index.js +102 -13
- package/dist/generators/route/route-generator.d.ts.map +1 -1
- package/dist/generators/route/route-generator.js +102 -13
- package/dist/generators/route/schema.js +7 -0
- package/dist/index.js +120 -25
- package/package.json +11 -6
|
@@ -230,22 +230,102 @@ var TemplateUtility = class {
|
|
|
230
230
|
}
|
|
231
231
|
};
|
|
232
232
|
|
|
233
|
+
// src/common/wasp-compatibility.ts
|
|
234
|
+
import { findPackageJson, getVersion } from "@ingenyus/swarm";
|
|
235
|
+
import { execSync } from "child_process";
|
|
236
|
+
import path4 from "path";
|
|
237
|
+
import { fileURLToPath } from "url";
|
|
238
|
+
import * as semver from "semver";
|
|
239
|
+
var cachedSupportedRange = null;
|
|
240
|
+
function getWaspSupportedRange() {
|
|
241
|
+
if (cachedSupportedRange) {
|
|
242
|
+
return cachedSupportedRange;
|
|
243
|
+
}
|
|
244
|
+
const currentFile = fileURLToPath(import.meta.url);
|
|
245
|
+
const currentDir = path4.dirname(currentFile);
|
|
246
|
+
const result = findPackageJson(currentDir, {
|
|
247
|
+
packageName: "@ingenyus/swarm-wasp"
|
|
248
|
+
});
|
|
249
|
+
if (!result) {
|
|
250
|
+
throw new Error(
|
|
251
|
+
"Unable to find package.json for @ingenyus/swarm-wasp. Wasp supported version range must be specified in swarm.wasp field."
|
|
252
|
+
);
|
|
253
|
+
}
|
|
254
|
+
const swarm = result.packageJson.swarm;
|
|
255
|
+
const waspRange = swarm?.wasp;
|
|
256
|
+
if (!waspRange) {
|
|
257
|
+
throw new Error(
|
|
258
|
+
`Wasp supported version range not found in package.json. Please specify swarm.wasp field in @ingenyus/swarm-wasp package.json (e.g., "swarm": { "wasp": ">=0.18.0 <0.20.0" }).`
|
|
259
|
+
);
|
|
260
|
+
}
|
|
261
|
+
cachedSupportedRange = waspRange;
|
|
262
|
+
return cachedSupportedRange;
|
|
263
|
+
}
|
|
264
|
+
function getInstalledWaspVersion(logger) {
|
|
265
|
+
try {
|
|
266
|
+
const output = execSync("wasp version", {
|
|
267
|
+
encoding: "utf8",
|
|
268
|
+
stdio: "pipe"
|
|
269
|
+
});
|
|
270
|
+
const firstLine = output.split("\n")[0]?.trim();
|
|
271
|
+
if (!firstLine) {
|
|
272
|
+
logger.error(
|
|
273
|
+
"Unable to parse Wasp version from command output. Expected version number on first line."
|
|
274
|
+
);
|
|
275
|
+
throw new Error("Unable to parse Wasp version from command output");
|
|
276
|
+
}
|
|
277
|
+
if (!semver.valid(firstLine)) {
|
|
278
|
+
logger.error(
|
|
279
|
+
`Invalid Wasp version format: "${firstLine}". Expected a valid semver version (e.g., "0.18.2").`
|
|
280
|
+
);
|
|
281
|
+
throw new Error("Invalid Wasp version format");
|
|
282
|
+
}
|
|
283
|
+
return firstLine;
|
|
284
|
+
} catch (error) {
|
|
285
|
+
if (error.code === "ENOENT" || error.message?.includes("wasp")) {
|
|
286
|
+
logger.error(
|
|
287
|
+
"Wasp CLI not found. Install using: curl -sSL https://get.wasp.sh/installer.sh | sh -s"
|
|
288
|
+
);
|
|
289
|
+
throw new Error("Wasp CLI not found");
|
|
290
|
+
}
|
|
291
|
+
throw new Error("Unable to determine installed Wasp version");
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
function isTestEnvironment() {
|
|
295
|
+
return process.env.NODE_ENV === "test" || process.env.VITEST === "true" || typeof process.env.VITEST !== "undefined";
|
|
296
|
+
}
|
|
297
|
+
function assertWaspCompatible(logger) {
|
|
298
|
+
if (isTestEnvironment()) {
|
|
299
|
+
return;
|
|
300
|
+
}
|
|
301
|
+
const version = getInstalledWaspVersion(logger);
|
|
302
|
+
const supportedRange = getWaspSupportedRange();
|
|
303
|
+
if (!semver.satisfies(version, supportedRange)) {
|
|
304
|
+
const startDir = path4.dirname(fileURLToPath(import.meta.url));
|
|
305
|
+
const packageVersion = getVersion("@ingenyus/swarm-wasp", startDir);
|
|
306
|
+
logger.error(
|
|
307
|
+
`Incompatible Wasp version detected: ${version}. @ingenyus/swarm-wasp@${packageVersion} supports Wasp ${supportedRange}.`
|
|
308
|
+
);
|
|
309
|
+
throw new Error("Incompatible Wasp version");
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
|
|
233
313
|
// src/generators/base/component-generator.base.ts
|
|
234
314
|
import {
|
|
235
315
|
hasHelperMethodCall,
|
|
236
316
|
toKebabCase as toKebabCase2
|
|
237
317
|
} from "@ingenyus/swarm";
|
|
238
|
-
import
|
|
318
|
+
import path7 from "path";
|
|
239
319
|
|
|
240
320
|
// src/generators/feature/feature-generator.ts
|
|
241
321
|
import { handleFatalError as handleFatalError2 } from "@ingenyus/swarm";
|
|
242
|
-
import
|
|
322
|
+
import path6 from "path";
|
|
243
323
|
|
|
244
324
|
// src/generators/base/wasp-generator.base.ts
|
|
245
325
|
import {
|
|
246
326
|
GeneratorBase,
|
|
247
|
-
|
|
248
|
-
|
|
327
|
+
TemplateResolver,
|
|
328
|
+
getConfigManager
|
|
249
329
|
} from "@ingenyus/swarm";
|
|
250
330
|
|
|
251
331
|
// src/generators/config/wasp-config-generator.ts
|
|
@@ -254,14 +334,14 @@ import {
|
|
|
254
334
|
handleFatalError,
|
|
255
335
|
parseHelperMethodDefinition
|
|
256
336
|
} from "@ingenyus/swarm";
|
|
257
|
-
import
|
|
337
|
+
import path5 from "path";
|
|
258
338
|
var WaspConfigGenerator = class {
|
|
259
339
|
constructor(logger = getCLILogger(), fileSystem = realFileSystem) {
|
|
260
340
|
this.logger = logger;
|
|
261
341
|
this.fileSystem = fileSystem;
|
|
262
342
|
this.templateUtility = new TemplateUtility(fileSystem);
|
|
263
343
|
}
|
|
264
|
-
path =
|
|
344
|
+
path = path5;
|
|
265
345
|
templateUtility;
|
|
266
346
|
/**
|
|
267
347
|
* Gets the template path for feature config templates.
|
|
@@ -290,7 +370,7 @@ var WaspConfigGenerator = class {
|
|
|
290
370
|
this.logger.error(`Template not found: ${templatePath}`);
|
|
291
371
|
return;
|
|
292
372
|
}
|
|
293
|
-
const configFilePath =
|
|
373
|
+
const configFilePath = path5.join(featureDir, `feature.wasp.ts`);
|
|
294
374
|
if (this.fileSystem.existsSync(configFilePath)) {
|
|
295
375
|
this.logger.warn(`Feature config already exists: ${configFilePath}`);
|
|
296
376
|
return;
|
|
@@ -306,7 +386,7 @@ var WaspConfigGenerator = class {
|
|
|
306
386
|
*/
|
|
307
387
|
update(featurePath, declaration) {
|
|
308
388
|
const configDir = getFeatureDir(this.fileSystem, featurePath);
|
|
309
|
-
const configFilePath =
|
|
389
|
+
const configFilePath = path5.join(configDir, `feature.wasp.ts`);
|
|
310
390
|
if (!this.fileSystem.existsSync(configFilePath)) {
|
|
311
391
|
const templatePath = this.getTemplatePath("feature.wasp.eta");
|
|
312
392
|
if (!this.fileSystem.existsSync(templatePath)) {
|
|
@@ -702,6 +782,13 @@ var WaspGeneratorBase = class extends GeneratorBase {
|
|
|
702
782
|
this.templateUtility = new TemplateUtility(this.fileSystem);
|
|
703
783
|
this.templateResolver = new TemplateResolver(this.fileSystem);
|
|
704
784
|
}
|
|
785
|
+
/**
|
|
786
|
+
* Ensures that the installed Wasp version is compatible with this package.
|
|
787
|
+
* Should be called at the start of generator execution.
|
|
788
|
+
*/
|
|
789
|
+
ensureWaspCompatible() {
|
|
790
|
+
assertWaspCompatible(this.logger);
|
|
791
|
+
}
|
|
705
792
|
async loadConfig() {
|
|
706
793
|
if (this.configLoaded) return;
|
|
707
794
|
const configManager = getConfigManager();
|
|
@@ -818,21 +905,22 @@ var FeatureGenerator = class extends WaspGeneratorBase {
|
|
|
818
905
|
* @param target - The target path of the generated directory
|
|
819
906
|
*/
|
|
820
907
|
async generate(args) {
|
|
908
|
+
this.ensureWaspCompatible();
|
|
821
909
|
const { target } = args;
|
|
822
910
|
const segments = validateFeaturePath(target);
|
|
823
911
|
const normalisedPath = normaliseFeaturePath(target);
|
|
824
|
-
const sourceRoot =
|
|
912
|
+
const sourceRoot = path6.join(findWaspRoot(this.fileSystem), "src");
|
|
825
913
|
if (segments.length > 1) {
|
|
826
914
|
const parentPath = segments.slice(0, -1).join("/");
|
|
827
915
|
const parentNormalisedPath = normaliseFeaturePath(parentPath);
|
|
828
|
-
const parentFeatureDir =
|
|
916
|
+
const parentFeatureDir = path6.join(sourceRoot, parentNormalisedPath);
|
|
829
917
|
if (!this.fileSystem.existsSync(parentFeatureDir)) {
|
|
830
918
|
handleFatalError2(
|
|
831
919
|
`Parent feature '${parentPath}' does not exist. Please create it first.`
|
|
832
920
|
);
|
|
833
921
|
}
|
|
834
922
|
}
|
|
835
|
-
const featureDir =
|
|
923
|
+
const featureDir = path6.join(sourceRoot, normalisedPath);
|
|
836
924
|
this.fileSystem.mkdirSync(featureDir, { recursive: true });
|
|
837
925
|
this.configGenerator.generate(normalisedPath);
|
|
838
926
|
this.logger.success(`Generated feature: ${normalisedPath}`);
|
|
@@ -867,7 +955,7 @@ var ComponentGeneratorBase = class extends WaspGeneratorBase {
|
|
|
867
955
|
const currentPath = pathSegments.join("/");
|
|
868
956
|
const featureName = pathSegments[pathSegments.length - 1];
|
|
869
957
|
const featureDir = getFeatureDir(this.fileSystem, currentPath);
|
|
870
|
-
const configPath =
|
|
958
|
+
const configPath = path7.join(featureDir, `feature.wasp.ts`);
|
|
871
959
|
if (this.fileSystem.existsSync(configPath)) {
|
|
872
960
|
return configPath;
|
|
873
961
|
}
|
|
@@ -939,7 +1027,7 @@ var ComponentGeneratorBase = class extends WaspGeneratorBase {
|
|
|
939
1027
|
const featureDir = getFeatureDir(this.fileSystem, normalisedPath);
|
|
940
1028
|
const typeKey = type.toLowerCase();
|
|
941
1029
|
const typeDirectory = TYPE_DIRECTORIES[typeKey];
|
|
942
|
-
const targetDirectory =
|
|
1030
|
+
const targetDirectory = path7.join(featureDir, typeDirectory);
|
|
943
1031
|
const importDirectory = `@src/${normalisedPath}/${typeDirectory}`;
|
|
944
1032
|
return { targetDirectory, importDirectory };
|
|
945
1033
|
}
|
|
@@ -1022,6 +1110,7 @@ var RouteGenerator = class extends ComponentGeneratorBase {
|
|
|
1022
1110
|
this.componentType,
|
|
1023
1111
|
routeName,
|
|
1024
1112
|
async () => {
|
|
1113
|
+
this.ensureWaspCompatible();
|
|
1025
1114
|
const configPath = this.validateFeatureConfig(feature);
|
|
1026
1115
|
const { targetDirectory } = this.ensureTargetDirectory(feature, "page");
|
|
1027
1116
|
const targetFile = `${targetDirectory}/${fileName}`;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"route-generator.d.ts","sourceRoot":"","sources":["../../../src/generators/route/route-generator.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"route-generator.d.ts","sourceRoot":"","sources":["../../../src/generators/route/route-generator.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,iBAAiB,EACjB,GAAG,EAGJ,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,YAAY,EAAwB,MAAM,cAAc,CAAC;AAClE,OAAO,EAAE,sBAAsB,EAAE,MAAM,SAAS,CAAC;AACjD,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC,qBAAa,cAAe,SAAQ,sBAAsB,CACxD,OAAO,MAAM,EACb,OAAO,YAAY,CAAC,KAAK,CAC1B;IACC,SAAS,KAAK,aAAa,YAE1B;IAED,WAAW,SAAqC;IAChD,MAAM;;;;;;qCAAU;gBAEJ,QAAQ,EAAE,iBAAiB;IAIjC,QAAQ,CAAC,IAAI,EAAE,GAAG,CAAC,OAAO,MAAM,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;YAsBzC,gBAAgB;IAoB9B,OAAO,CAAC,gBAAgB;IAwBxB;;OAEG;IACH,aAAa,CACX,SAAS,EAAE,MAAM,EACjB,SAAS,EAAE,MAAM,EACjB,WAAW,EAAE,MAAM,EACnB,IAAI,UAAQ,GACX,MAAM;CAUV"}
|
|
@@ -230,22 +230,102 @@ var TemplateUtility = class {
|
|
|
230
230
|
}
|
|
231
231
|
};
|
|
232
232
|
|
|
233
|
+
// src/common/wasp-compatibility.ts
|
|
234
|
+
import { findPackageJson, getVersion } from "@ingenyus/swarm";
|
|
235
|
+
import { execSync } from "child_process";
|
|
236
|
+
import path4 from "path";
|
|
237
|
+
import { fileURLToPath } from "url";
|
|
238
|
+
import * as semver from "semver";
|
|
239
|
+
var cachedSupportedRange = null;
|
|
240
|
+
function getWaspSupportedRange() {
|
|
241
|
+
if (cachedSupportedRange) {
|
|
242
|
+
return cachedSupportedRange;
|
|
243
|
+
}
|
|
244
|
+
const currentFile = fileURLToPath(import.meta.url);
|
|
245
|
+
const currentDir = path4.dirname(currentFile);
|
|
246
|
+
const result = findPackageJson(currentDir, {
|
|
247
|
+
packageName: "@ingenyus/swarm-wasp"
|
|
248
|
+
});
|
|
249
|
+
if (!result) {
|
|
250
|
+
throw new Error(
|
|
251
|
+
"Unable to find package.json for @ingenyus/swarm-wasp. Wasp supported version range must be specified in swarm.wasp field."
|
|
252
|
+
);
|
|
253
|
+
}
|
|
254
|
+
const swarm = result.packageJson.swarm;
|
|
255
|
+
const waspRange = swarm?.wasp;
|
|
256
|
+
if (!waspRange) {
|
|
257
|
+
throw new Error(
|
|
258
|
+
`Wasp supported version range not found in package.json. Please specify swarm.wasp field in @ingenyus/swarm-wasp package.json (e.g., "swarm": { "wasp": ">=0.18.0 <0.20.0" }).`
|
|
259
|
+
);
|
|
260
|
+
}
|
|
261
|
+
cachedSupportedRange = waspRange;
|
|
262
|
+
return cachedSupportedRange;
|
|
263
|
+
}
|
|
264
|
+
function getInstalledWaspVersion(logger) {
|
|
265
|
+
try {
|
|
266
|
+
const output = execSync("wasp version", {
|
|
267
|
+
encoding: "utf8",
|
|
268
|
+
stdio: "pipe"
|
|
269
|
+
});
|
|
270
|
+
const firstLine = output.split("\n")[0]?.trim();
|
|
271
|
+
if (!firstLine) {
|
|
272
|
+
logger.error(
|
|
273
|
+
"Unable to parse Wasp version from command output. Expected version number on first line."
|
|
274
|
+
);
|
|
275
|
+
throw new Error("Unable to parse Wasp version from command output");
|
|
276
|
+
}
|
|
277
|
+
if (!semver.valid(firstLine)) {
|
|
278
|
+
logger.error(
|
|
279
|
+
`Invalid Wasp version format: "${firstLine}". Expected a valid semver version (e.g., "0.18.2").`
|
|
280
|
+
);
|
|
281
|
+
throw new Error("Invalid Wasp version format");
|
|
282
|
+
}
|
|
283
|
+
return firstLine;
|
|
284
|
+
} catch (error) {
|
|
285
|
+
if (error.code === "ENOENT" || error.message?.includes("wasp")) {
|
|
286
|
+
logger.error(
|
|
287
|
+
"Wasp CLI not found. Install using: curl -sSL https://get.wasp.sh/installer.sh | sh -s"
|
|
288
|
+
);
|
|
289
|
+
throw new Error("Wasp CLI not found");
|
|
290
|
+
}
|
|
291
|
+
throw new Error("Unable to determine installed Wasp version");
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
function isTestEnvironment() {
|
|
295
|
+
return process.env.NODE_ENV === "test" || process.env.VITEST === "true" || typeof process.env.VITEST !== "undefined";
|
|
296
|
+
}
|
|
297
|
+
function assertWaspCompatible(logger) {
|
|
298
|
+
if (isTestEnvironment()) {
|
|
299
|
+
return;
|
|
300
|
+
}
|
|
301
|
+
const version = getInstalledWaspVersion(logger);
|
|
302
|
+
const supportedRange = getWaspSupportedRange();
|
|
303
|
+
if (!semver.satisfies(version, supportedRange)) {
|
|
304
|
+
const startDir = path4.dirname(fileURLToPath(import.meta.url));
|
|
305
|
+
const packageVersion = getVersion("@ingenyus/swarm-wasp", startDir);
|
|
306
|
+
logger.error(
|
|
307
|
+
`Incompatible Wasp version detected: ${version}. @ingenyus/swarm-wasp@${packageVersion} supports Wasp ${supportedRange}.`
|
|
308
|
+
);
|
|
309
|
+
throw new Error("Incompatible Wasp version");
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
|
|
233
313
|
// src/generators/base/component-generator.base.ts
|
|
234
314
|
import {
|
|
235
315
|
hasHelperMethodCall,
|
|
236
316
|
toKebabCase as toKebabCase2
|
|
237
317
|
} from "@ingenyus/swarm";
|
|
238
|
-
import
|
|
318
|
+
import path7 from "path";
|
|
239
319
|
|
|
240
320
|
// src/generators/feature/feature-generator.ts
|
|
241
321
|
import { handleFatalError as handleFatalError2 } from "@ingenyus/swarm";
|
|
242
|
-
import
|
|
322
|
+
import path6 from "path";
|
|
243
323
|
|
|
244
324
|
// src/generators/base/wasp-generator.base.ts
|
|
245
325
|
import {
|
|
246
326
|
GeneratorBase,
|
|
247
|
-
|
|
248
|
-
|
|
327
|
+
TemplateResolver,
|
|
328
|
+
getConfigManager
|
|
249
329
|
} from "@ingenyus/swarm";
|
|
250
330
|
|
|
251
331
|
// src/generators/config/wasp-config-generator.ts
|
|
@@ -254,14 +334,14 @@ import {
|
|
|
254
334
|
handleFatalError,
|
|
255
335
|
parseHelperMethodDefinition
|
|
256
336
|
} from "@ingenyus/swarm";
|
|
257
|
-
import
|
|
337
|
+
import path5 from "path";
|
|
258
338
|
var WaspConfigGenerator = class {
|
|
259
339
|
constructor(logger = getCLILogger(), fileSystem = realFileSystem) {
|
|
260
340
|
this.logger = logger;
|
|
261
341
|
this.fileSystem = fileSystem;
|
|
262
342
|
this.templateUtility = new TemplateUtility(fileSystem);
|
|
263
343
|
}
|
|
264
|
-
path =
|
|
344
|
+
path = path5;
|
|
265
345
|
templateUtility;
|
|
266
346
|
/**
|
|
267
347
|
* Gets the template path for feature config templates.
|
|
@@ -290,7 +370,7 @@ var WaspConfigGenerator = class {
|
|
|
290
370
|
this.logger.error(`Template not found: ${templatePath}`);
|
|
291
371
|
return;
|
|
292
372
|
}
|
|
293
|
-
const configFilePath =
|
|
373
|
+
const configFilePath = path5.join(featureDir, `feature.wasp.ts`);
|
|
294
374
|
if (this.fileSystem.existsSync(configFilePath)) {
|
|
295
375
|
this.logger.warn(`Feature config already exists: ${configFilePath}`);
|
|
296
376
|
return;
|
|
@@ -306,7 +386,7 @@ var WaspConfigGenerator = class {
|
|
|
306
386
|
*/
|
|
307
387
|
update(featurePath, declaration) {
|
|
308
388
|
const configDir = getFeatureDir(this.fileSystem, featurePath);
|
|
309
|
-
const configFilePath =
|
|
389
|
+
const configFilePath = path5.join(configDir, `feature.wasp.ts`);
|
|
310
390
|
if (!this.fileSystem.existsSync(configFilePath)) {
|
|
311
391
|
const templatePath = this.getTemplatePath("feature.wasp.eta");
|
|
312
392
|
if (!this.fileSystem.existsSync(templatePath)) {
|
|
@@ -702,6 +782,13 @@ var WaspGeneratorBase = class extends GeneratorBase {
|
|
|
702
782
|
this.templateUtility = new TemplateUtility(this.fileSystem);
|
|
703
783
|
this.templateResolver = new TemplateResolver(this.fileSystem);
|
|
704
784
|
}
|
|
785
|
+
/**
|
|
786
|
+
* Ensures that the installed Wasp version is compatible with this package.
|
|
787
|
+
* Should be called at the start of generator execution.
|
|
788
|
+
*/
|
|
789
|
+
ensureWaspCompatible() {
|
|
790
|
+
assertWaspCompatible(this.logger);
|
|
791
|
+
}
|
|
705
792
|
async loadConfig() {
|
|
706
793
|
if (this.configLoaded) return;
|
|
707
794
|
const configManager = getConfigManager();
|
|
@@ -818,21 +905,22 @@ var FeatureGenerator = class extends WaspGeneratorBase {
|
|
|
818
905
|
* @param target - The target path of the generated directory
|
|
819
906
|
*/
|
|
820
907
|
async generate(args) {
|
|
908
|
+
this.ensureWaspCompatible();
|
|
821
909
|
const { target } = args;
|
|
822
910
|
const segments = validateFeaturePath(target);
|
|
823
911
|
const normalisedPath = normaliseFeaturePath(target);
|
|
824
|
-
const sourceRoot =
|
|
912
|
+
const sourceRoot = path6.join(findWaspRoot(this.fileSystem), "src");
|
|
825
913
|
if (segments.length > 1) {
|
|
826
914
|
const parentPath = segments.slice(0, -1).join("/");
|
|
827
915
|
const parentNormalisedPath = normaliseFeaturePath(parentPath);
|
|
828
|
-
const parentFeatureDir =
|
|
916
|
+
const parentFeatureDir = path6.join(sourceRoot, parentNormalisedPath);
|
|
829
917
|
if (!this.fileSystem.existsSync(parentFeatureDir)) {
|
|
830
918
|
handleFatalError2(
|
|
831
919
|
`Parent feature '${parentPath}' does not exist. Please create it first.`
|
|
832
920
|
);
|
|
833
921
|
}
|
|
834
922
|
}
|
|
835
|
-
const featureDir =
|
|
923
|
+
const featureDir = path6.join(sourceRoot, normalisedPath);
|
|
836
924
|
this.fileSystem.mkdirSync(featureDir, { recursive: true });
|
|
837
925
|
this.configGenerator.generate(normalisedPath);
|
|
838
926
|
this.logger.success(`Generated feature: ${normalisedPath}`);
|
|
@@ -867,7 +955,7 @@ var ComponentGeneratorBase = class extends WaspGeneratorBase {
|
|
|
867
955
|
const currentPath = pathSegments.join("/");
|
|
868
956
|
const featureName = pathSegments[pathSegments.length - 1];
|
|
869
957
|
const featureDir = getFeatureDir(this.fileSystem, currentPath);
|
|
870
|
-
const configPath =
|
|
958
|
+
const configPath = path7.join(featureDir, `feature.wasp.ts`);
|
|
871
959
|
if (this.fileSystem.existsSync(configPath)) {
|
|
872
960
|
return configPath;
|
|
873
961
|
}
|
|
@@ -939,7 +1027,7 @@ var ComponentGeneratorBase = class extends WaspGeneratorBase {
|
|
|
939
1027
|
const featureDir = getFeatureDir(this.fileSystem, normalisedPath);
|
|
940
1028
|
const typeKey = type.toLowerCase();
|
|
941
1029
|
const typeDirectory = TYPE_DIRECTORIES[typeKey];
|
|
942
|
-
const targetDirectory =
|
|
1030
|
+
const targetDirectory = path7.join(featureDir, typeDirectory);
|
|
943
1031
|
const importDirectory = `@src/${normalisedPath}/${typeDirectory}`;
|
|
944
1032
|
return { targetDirectory, importDirectory };
|
|
945
1033
|
}
|
|
@@ -1022,6 +1110,7 @@ var RouteGenerator = class extends ComponentGeneratorBase {
|
|
|
1022
1110
|
this.componentType,
|
|
1023
1111
|
routeName,
|
|
1024
1112
|
async () => {
|
|
1113
|
+
this.ensureWaspCompatible();
|
|
1025
1114
|
const configPath = this.validateFeatureConfig(feature);
|
|
1026
1115
|
const { targetDirectory } = this.ensureTargetDirectory(feature, "page");
|
|
1027
1116
|
const targetFile = `${targetDirectory}/${fileName}`;
|
|
@@ -104,6 +104,13 @@ var commonFieldMetadata = {
|
|
|
104
104
|
import { toKebabCase } from "@ingenyus/swarm";
|
|
105
105
|
import { Eta } from "eta";
|
|
106
106
|
|
|
107
|
+
// src/common/wasp-compatibility.ts
|
|
108
|
+
import { findPackageJson, getVersion } from "@ingenyus/swarm";
|
|
109
|
+
import { execSync } from "child_process";
|
|
110
|
+
import path2 from "path";
|
|
111
|
+
import { fileURLToPath } from "url";
|
|
112
|
+
import * as semver from "semver";
|
|
113
|
+
|
|
107
114
|
// src/generators/route/schema.ts
|
|
108
115
|
var baseSchema = z2.object({
|
|
109
116
|
feature: commonSchemas.feature,
|