@ingenyus/swarm-wasp 0.2.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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 +20 -24
- package/dist/generators/action/index.js +20 -24
- package/dist/generators/action/schema.js +1 -5
- package/dist/generators/api/api-generator.js +21 -25
- package/dist/generators/api/index.js +21 -25
- package/dist/generators/api/schema.js +1 -5
- package/dist/generators/api-namespace/api-namespace-generator.js +21 -25
- package/dist/generators/api-namespace/index.js +21 -25
- package/dist/generators/api-namespace/schema.js +1 -5
- package/dist/generators/base/component-generator.base.js +19 -23
- package/dist/generators/base/index.js +20 -24
- package/dist/generators/base/operation-generator.base.js +20 -24
- package/dist/generators/base/wasp-generator.base.js +12 -16
- 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 +20 -24
- package/dist/generators/crud/index.js +20 -24
- package/dist/generators/crud/schema.js +1 -5
- package/dist/generators/feature/feature-generator.js +16 -20
- package/dist/generators/feature/index.js +16 -20
- package/dist/generators/feature/schema.js +1 -5
- package/dist/generators/index.js +24 -28
- package/dist/generators/job/index.js +19 -23
- package/dist/generators/job/job-generator.js +19 -23
- package/dist/generators/job/schema.js +1 -5
- package/dist/generators/query/index.js +20 -24
- package/dist/generators/query/query-generator.js +20 -24
- package/dist/generators/query/schema.js +1 -5
- package/dist/generators/route/index.js +19 -23
- package/dist/generators/route/route-generator.js +19 -23
- package/dist/generators/route/schema.js +1 -5
- package/dist/index.js +30 -56
- 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
|
@@ -46,7 +46,7 @@ import {
|
|
|
46
46
|
toKebabCase as toKebabCase2,
|
|
47
47
|
validateFeaturePath as validateFeaturePath3
|
|
48
48
|
} from "@ingenyus/swarm";
|
|
49
|
-
import
|
|
49
|
+
import path6 from "path";
|
|
50
50
|
|
|
51
51
|
// src/common/filesystem.ts
|
|
52
52
|
import { toPascalCase, validateFeaturePath } from "@ingenyus/swarm";
|
|
@@ -119,19 +119,15 @@ function getFeatureImportPath(featurePath) {
|
|
|
119
119
|
return segments.join("/");
|
|
120
120
|
}
|
|
121
121
|
|
|
122
|
-
// src/common/plugin.ts
|
|
123
|
-
import path2 from "path";
|
|
124
|
-
import { fileURLToPath } from "url";
|
|
125
|
-
|
|
126
122
|
// src/common/prisma.ts
|
|
127
123
|
import {
|
|
128
124
|
getSchema
|
|
129
125
|
} from "@mrleebo/prisma-ast";
|
|
130
126
|
import fs2 from "fs";
|
|
131
|
-
import
|
|
127
|
+
import path2 from "path";
|
|
132
128
|
async function getEntityMetadata(modelName) {
|
|
133
129
|
try {
|
|
134
|
-
const schemaPath =
|
|
130
|
+
const schemaPath = path2.join(process.cwd(), "schema.prisma");
|
|
135
131
|
const schemaContent = fs2.readFileSync(schemaPath, "utf8");
|
|
136
132
|
const schema3 = getSchema(schemaContent);
|
|
137
133
|
const model = schema3.list?.find(
|
|
@@ -306,7 +302,7 @@ var commonSchemas = {
|
|
|
306
302
|
// src/common/templates.ts
|
|
307
303
|
import { toKebabCase } from "@ingenyus/swarm";
|
|
308
304
|
import { Eta } from "eta";
|
|
309
|
-
import
|
|
305
|
+
import path3 from "path";
|
|
310
306
|
var TemplateUtility = class {
|
|
311
307
|
constructor(fileSystem) {
|
|
312
308
|
this.fileSystem = fileSystem;
|
|
@@ -314,14 +310,14 @@ var TemplateUtility = class {
|
|
|
314
310
|
processTemplate(templatePath, replacements) {
|
|
315
311
|
const declarations = Object.keys(replacements).map((key) => `${key}=it.${key}`).join(", ");
|
|
316
312
|
const functionHeader = declarations ? `const ${declarations};` : void 0;
|
|
317
|
-
const templateDir =
|
|
313
|
+
const templateDir = path3.dirname(templatePath);
|
|
318
314
|
const eta = new Eta({
|
|
319
315
|
autoTrim: false,
|
|
320
316
|
autoEscape: false,
|
|
321
317
|
views: templateDir,
|
|
322
318
|
functionHeader
|
|
323
319
|
});
|
|
324
|
-
const templateName =
|
|
320
|
+
const templateName = path3.basename(templatePath).replace(/\.eta$/, "");
|
|
325
321
|
if (this.fileSystem.existsSync(templatePath)) {
|
|
326
322
|
return eta.render(templateName, replacements);
|
|
327
323
|
} else {
|
|
@@ -339,11 +335,11 @@ var TemplateUtility = class {
|
|
|
339
335
|
resolveTemplatePath(relativePath, generatorName, currentFileUrl) {
|
|
340
336
|
const generatorDirName = toKebabCase(generatorName);
|
|
341
337
|
const currentFilePath = new URL(currentFileUrl).pathname;
|
|
342
|
-
const currentFileDir =
|
|
343
|
-
const currentFileName =
|
|
338
|
+
const currentFileDir = path3.dirname(currentFilePath);
|
|
339
|
+
const currentFileName = path3.basename(currentFilePath);
|
|
344
340
|
const isInstalledPackage = currentFileDir.includes("node_modules") && currentFileDir.endsWith("/dist") && currentFileName === "index.js";
|
|
345
|
-
const startDir = isInstalledPackage ? currentFileDir :
|
|
346
|
-
return
|
|
341
|
+
const startDir = isInstalledPackage ? currentFileDir : path3.dirname(path3.dirname(currentFileDir));
|
|
342
|
+
return path3.join(
|
|
347
343
|
startDir,
|
|
348
344
|
"generators",
|
|
349
345
|
generatorDirName,
|
|
@@ -359,7 +355,7 @@ import {
|
|
|
359
355
|
logger as singletonLogger3,
|
|
360
356
|
validateFeaturePath as validateFeaturePath2
|
|
361
357
|
} from "@ingenyus/swarm";
|
|
362
|
-
import
|
|
358
|
+
import path5 from "path";
|
|
363
359
|
|
|
364
360
|
// src/generators/base/wasp-generator.base.ts
|
|
365
361
|
import {
|
|
@@ -375,14 +371,14 @@ import {
|
|
|
375
371
|
parseHelperMethodDefinition,
|
|
376
372
|
logger as singletonLogger
|
|
377
373
|
} from "@ingenyus/swarm";
|
|
378
|
-
import
|
|
374
|
+
import path4 from "path";
|
|
379
375
|
var WaspConfigGenerator = class {
|
|
380
376
|
constructor(logger = singletonLogger, fileSystem = realFileSystem) {
|
|
381
377
|
this.logger = logger;
|
|
382
378
|
this.fileSystem = fileSystem;
|
|
383
379
|
this.templateUtility = new TemplateUtility(fileSystem);
|
|
384
380
|
}
|
|
385
|
-
path =
|
|
381
|
+
path = path4;
|
|
386
382
|
templateUtility;
|
|
387
383
|
/**
|
|
388
384
|
* Gets the template path for feature config templates.
|
|
@@ -411,7 +407,7 @@ var WaspConfigGenerator = class {
|
|
|
411
407
|
this.logger.error(`Template not found: ${templatePath}`);
|
|
412
408
|
return;
|
|
413
409
|
}
|
|
414
|
-
const configFilePath =
|
|
410
|
+
const configFilePath = path4.join(featureDir, `feature.wasp.ts`);
|
|
415
411
|
if (this.fileSystem.existsSync(configFilePath)) {
|
|
416
412
|
this.logger.warn(`Feature config already exists: ${configFilePath}`);
|
|
417
413
|
return;
|
|
@@ -427,7 +423,7 @@ var WaspConfigGenerator = class {
|
|
|
427
423
|
*/
|
|
428
424
|
update(featurePath, declaration) {
|
|
429
425
|
const configDir = getFeatureDir(this.fileSystem, featurePath);
|
|
430
|
-
const configFilePath =
|
|
426
|
+
const configFilePath = path4.join(configDir, `feature.wasp.ts`);
|
|
431
427
|
if (!this.fileSystem.existsSync(configFilePath)) {
|
|
432
428
|
const templatePath = this.getTemplatePath("feature.wasp.eta");
|
|
433
429
|
if (!this.fileSystem.existsSync(templatePath)) {
|
|
@@ -937,18 +933,18 @@ var FeatureGenerator = class extends WaspGeneratorBase {
|
|
|
937
933
|
const { target } = args;
|
|
938
934
|
const segments = validateFeaturePath2(target);
|
|
939
935
|
const normalisedPath = normaliseFeaturePath(target);
|
|
940
|
-
const sourceRoot =
|
|
936
|
+
const sourceRoot = path5.join(findWaspRoot(this.fileSystem), "src");
|
|
941
937
|
if (segments.length > 1) {
|
|
942
938
|
const parentPath = segments.slice(0, -1).join("/");
|
|
943
939
|
const parentNormalisedPath = normaliseFeaturePath(parentPath);
|
|
944
|
-
const parentFeatureDir =
|
|
940
|
+
const parentFeatureDir = path5.join(sourceRoot, parentNormalisedPath);
|
|
945
941
|
if (!this.fileSystem.existsSync(parentFeatureDir)) {
|
|
946
942
|
handleFatalError2(
|
|
947
943
|
`Parent feature '${parentPath}' does not exist. Please create it first.`
|
|
948
944
|
);
|
|
949
945
|
}
|
|
950
946
|
}
|
|
951
|
-
const featureDir =
|
|
947
|
+
const featureDir = path5.join(sourceRoot, normalisedPath);
|
|
952
948
|
this.fileSystem.mkdirSync(featureDir, { recursive: true });
|
|
953
949
|
this.configGenerator.generate(normalisedPath);
|
|
954
950
|
this.logger.success(`Generated feature: ${normalisedPath}`);
|
|
@@ -985,7 +981,7 @@ var ComponentGeneratorBase = class extends WaspGeneratorBase {
|
|
|
985
981
|
const currentPath = pathSegments.join("/");
|
|
986
982
|
const featureName = pathSegments[pathSegments.length - 1];
|
|
987
983
|
const featureDir = getFeatureDir(this.fileSystem, currentPath);
|
|
988
|
-
const configPath =
|
|
984
|
+
const configPath = path6.join(featureDir, `feature.wasp.ts`);
|
|
989
985
|
if (this.fileSystem.existsSync(configPath)) {
|
|
990
986
|
return configPath;
|
|
991
987
|
}
|
|
@@ -1058,7 +1054,7 @@ var ComponentGeneratorBase = class extends WaspGeneratorBase {
|
|
|
1058
1054
|
const featureDir = getFeatureDir(fileSystem, normalisedPath);
|
|
1059
1055
|
const typeKey = type.toLowerCase();
|
|
1060
1056
|
const typeDirectory = TYPE_DIRECTORIES[typeKey];
|
|
1061
|
-
const targetDirectory =
|
|
1057
|
+
const targetDirectory = path6.join(featureDir, typeDirectory);
|
|
1062
1058
|
const importDirectory = `@src/${normalisedPath}/${typeDirectory}`;
|
|
1063
1059
|
return { targetDirectory, importDirectory };
|
|
1064
1060
|
}
|
|
@@ -46,7 +46,7 @@ import {
|
|
|
46
46
|
toKebabCase as toKebabCase2,
|
|
47
47
|
validateFeaturePath as validateFeaturePath3
|
|
48
48
|
} from "@ingenyus/swarm";
|
|
49
|
-
import
|
|
49
|
+
import path6 from "path";
|
|
50
50
|
|
|
51
51
|
// src/common/filesystem.ts
|
|
52
52
|
import { toPascalCase, validateFeaturePath } from "@ingenyus/swarm";
|
|
@@ -119,19 +119,15 @@ function getFeatureImportPath(featurePath) {
|
|
|
119
119
|
return segments.join("/");
|
|
120
120
|
}
|
|
121
121
|
|
|
122
|
-
// src/common/plugin.ts
|
|
123
|
-
import path2 from "path";
|
|
124
|
-
import { fileURLToPath } from "url";
|
|
125
|
-
|
|
126
122
|
// src/common/prisma.ts
|
|
127
123
|
import {
|
|
128
124
|
getSchema
|
|
129
125
|
} from "@mrleebo/prisma-ast";
|
|
130
126
|
import fs2 from "fs";
|
|
131
|
-
import
|
|
127
|
+
import path2 from "path";
|
|
132
128
|
async function getEntityMetadata(modelName) {
|
|
133
129
|
try {
|
|
134
|
-
const schemaPath =
|
|
130
|
+
const schemaPath = path2.join(process.cwd(), "schema.prisma");
|
|
135
131
|
const schemaContent = fs2.readFileSync(schemaPath, "utf8");
|
|
136
132
|
const schema3 = getSchema(schemaContent);
|
|
137
133
|
const model = schema3.list?.find(
|
|
@@ -306,7 +302,7 @@ var commonSchemas = {
|
|
|
306
302
|
// src/common/templates.ts
|
|
307
303
|
import { toKebabCase } from "@ingenyus/swarm";
|
|
308
304
|
import { Eta } from "eta";
|
|
309
|
-
import
|
|
305
|
+
import path3 from "path";
|
|
310
306
|
var TemplateUtility = class {
|
|
311
307
|
constructor(fileSystem) {
|
|
312
308
|
this.fileSystem = fileSystem;
|
|
@@ -314,14 +310,14 @@ var TemplateUtility = class {
|
|
|
314
310
|
processTemplate(templatePath, replacements) {
|
|
315
311
|
const declarations = Object.keys(replacements).map((key) => `${key}=it.${key}`).join(", ");
|
|
316
312
|
const functionHeader = declarations ? `const ${declarations};` : void 0;
|
|
317
|
-
const templateDir =
|
|
313
|
+
const templateDir = path3.dirname(templatePath);
|
|
318
314
|
const eta = new Eta({
|
|
319
315
|
autoTrim: false,
|
|
320
316
|
autoEscape: false,
|
|
321
317
|
views: templateDir,
|
|
322
318
|
functionHeader
|
|
323
319
|
});
|
|
324
|
-
const templateName =
|
|
320
|
+
const templateName = path3.basename(templatePath).replace(/\.eta$/, "");
|
|
325
321
|
if (this.fileSystem.existsSync(templatePath)) {
|
|
326
322
|
return eta.render(templateName, replacements);
|
|
327
323
|
} else {
|
|
@@ -339,11 +335,11 @@ var TemplateUtility = class {
|
|
|
339
335
|
resolveTemplatePath(relativePath, generatorName, currentFileUrl) {
|
|
340
336
|
const generatorDirName = toKebabCase(generatorName);
|
|
341
337
|
const currentFilePath = new URL(currentFileUrl).pathname;
|
|
342
|
-
const currentFileDir =
|
|
343
|
-
const currentFileName =
|
|
338
|
+
const currentFileDir = path3.dirname(currentFilePath);
|
|
339
|
+
const currentFileName = path3.basename(currentFilePath);
|
|
344
340
|
const isInstalledPackage = currentFileDir.includes("node_modules") && currentFileDir.endsWith("/dist") && currentFileName === "index.js";
|
|
345
|
-
const startDir = isInstalledPackage ? currentFileDir :
|
|
346
|
-
return
|
|
341
|
+
const startDir = isInstalledPackage ? currentFileDir : path3.dirname(path3.dirname(currentFileDir));
|
|
342
|
+
return path3.join(
|
|
347
343
|
startDir,
|
|
348
344
|
"generators",
|
|
349
345
|
generatorDirName,
|
|
@@ -359,7 +355,7 @@ import {
|
|
|
359
355
|
logger as singletonLogger3,
|
|
360
356
|
validateFeaturePath as validateFeaturePath2
|
|
361
357
|
} from "@ingenyus/swarm";
|
|
362
|
-
import
|
|
358
|
+
import path5 from "path";
|
|
363
359
|
|
|
364
360
|
// src/generators/base/wasp-generator.base.ts
|
|
365
361
|
import {
|
|
@@ -375,14 +371,14 @@ import {
|
|
|
375
371
|
parseHelperMethodDefinition,
|
|
376
372
|
logger as singletonLogger
|
|
377
373
|
} from "@ingenyus/swarm";
|
|
378
|
-
import
|
|
374
|
+
import path4 from "path";
|
|
379
375
|
var WaspConfigGenerator = class {
|
|
380
376
|
constructor(logger = singletonLogger, fileSystem = realFileSystem) {
|
|
381
377
|
this.logger = logger;
|
|
382
378
|
this.fileSystem = fileSystem;
|
|
383
379
|
this.templateUtility = new TemplateUtility(fileSystem);
|
|
384
380
|
}
|
|
385
|
-
path =
|
|
381
|
+
path = path4;
|
|
386
382
|
templateUtility;
|
|
387
383
|
/**
|
|
388
384
|
* Gets the template path for feature config templates.
|
|
@@ -411,7 +407,7 @@ var WaspConfigGenerator = class {
|
|
|
411
407
|
this.logger.error(`Template not found: ${templatePath}`);
|
|
412
408
|
return;
|
|
413
409
|
}
|
|
414
|
-
const configFilePath =
|
|
410
|
+
const configFilePath = path4.join(featureDir, `feature.wasp.ts`);
|
|
415
411
|
if (this.fileSystem.existsSync(configFilePath)) {
|
|
416
412
|
this.logger.warn(`Feature config already exists: ${configFilePath}`);
|
|
417
413
|
return;
|
|
@@ -427,7 +423,7 @@ var WaspConfigGenerator = class {
|
|
|
427
423
|
*/
|
|
428
424
|
update(featurePath, declaration) {
|
|
429
425
|
const configDir = getFeatureDir(this.fileSystem, featurePath);
|
|
430
|
-
const configFilePath =
|
|
426
|
+
const configFilePath = path4.join(configDir, `feature.wasp.ts`);
|
|
431
427
|
if (!this.fileSystem.existsSync(configFilePath)) {
|
|
432
428
|
const templatePath = this.getTemplatePath("feature.wasp.eta");
|
|
433
429
|
if (!this.fileSystem.existsSync(templatePath)) {
|
|
@@ -937,18 +933,18 @@ var FeatureGenerator = class extends WaspGeneratorBase {
|
|
|
937
933
|
const { target } = args;
|
|
938
934
|
const segments = validateFeaturePath2(target);
|
|
939
935
|
const normalisedPath = normaliseFeaturePath(target);
|
|
940
|
-
const sourceRoot =
|
|
936
|
+
const sourceRoot = path5.join(findWaspRoot(this.fileSystem), "src");
|
|
941
937
|
if (segments.length > 1) {
|
|
942
938
|
const parentPath = segments.slice(0, -1).join("/");
|
|
943
939
|
const parentNormalisedPath = normaliseFeaturePath(parentPath);
|
|
944
|
-
const parentFeatureDir =
|
|
940
|
+
const parentFeatureDir = path5.join(sourceRoot, parentNormalisedPath);
|
|
945
941
|
if (!this.fileSystem.existsSync(parentFeatureDir)) {
|
|
946
942
|
handleFatalError2(
|
|
947
943
|
`Parent feature '${parentPath}' does not exist. Please create it first.`
|
|
948
944
|
);
|
|
949
945
|
}
|
|
950
946
|
}
|
|
951
|
-
const featureDir =
|
|
947
|
+
const featureDir = path5.join(sourceRoot, normalisedPath);
|
|
952
948
|
this.fileSystem.mkdirSync(featureDir, { recursive: true });
|
|
953
949
|
this.configGenerator.generate(normalisedPath);
|
|
954
950
|
this.logger.success(`Generated feature: ${normalisedPath}`);
|
|
@@ -985,7 +981,7 @@ var ComponentGeneratorBase = class extends WaspGeneratorBase {
|
|
|
985
981
|
const currentPath = pathSegments.join("/");
|
|
986
982
|
const featureName = pathSegments[pathSegments.length - 1];
|
|
987
983
|
const featureDir = getFeatureDir(this.fileSystem, currentPath);
|
|
988
|
-
const configPath =
|
|
984
|
+
const configPath = path6.join(featureDir, `feature.wasp.ts`);
|
|
989
985
|
if (this.fileSystem.existsSync(configPath)) {
|
|
990
986
|
return configPath;
|
|
991
987
|
}
|
|
@@ -1058,7 +1054,7 @@ var ComponentGeneratorBase = class extends WaspGeneratorBase {
|
|
|
1058
1054
|
const featureDir = getFeatureDir(fileSystem, normalisedPath);
|
|
1059
1055
|
const typeKey = type.toLowerCase();
|
|
1060
1056
|
const typeDirectory = TYPE_DIRECTORIES[typeKey];
|
|
1061
|
-
const targetDirectory =
|
|
1057
|
+
const targetDirectory = path6.join(featureDir, typeDirectory);
|
|
1062
1058
|
const importDirectory = `@src/${normalisedPath}/${typeDirectory}`;
|
|
1063
1059
|
return { targetDirectory, importDirectory };
|
|
1064
1060
|
}
|
|
@@ -24,16 +24,12 @@ var realFileSystem = {
|
|
|
24
24
|
statSync: fs.statSync
|
|
25
25
|
};
|
|
26
26
|
|
|
27
|
-
// src/common/plugin.ts
|
|
28
|
-
import path from "path";
|
|
29
|
-
import { fileURLToPath } from "url";
|
|
30
|
-
|
|
31
27
|
// src/common/prisma.ts
|
|
32
28
|
import {
|
|
33
29
|
getSchema
|
|
34
30
|
} from "@mrleebo/prisma-ast";
|
|
35
31
|
import fs2 from "fs";
|
|
36
|
-
import
|
|
32
|
+
import path from "path";
|
|
37
33
|
|
|
38
34
|
// src/common/schemas.ts
|
|
39
35
|
import { commandRegistry } from "@ingenyus/swarm";
|
|
@@ -92,16 +92,12 @@ function getFeatureImportPath(featurePath) {
|
|
|
92
92
|
return segments.join("/");
|
|
93
93
|
}
|
|
94
94
|
|
|
95
|
-
// src/common/plugin.ts
|
|
96
|
-
import path2 from "path";
|
|
97
|
-
import { fileURLToPath } from "url";
|
|
98
|
-
|
|
99
95
|
// src/common/prisma.ts
|
|
100
96
|
import {
|
|
101
97
|
getSchema
|
|
102
98
|
} from "@mrleebo/prisma-ast";
|
|
103
99
|
import fs2 from "fs";
|
|
104
|
-
import
|
|
100
|
+
import path2 from "path";
|
|
105
101
|
|
|
106
102
|
// src/common/schemas.ts
|
|
107
103
|
import { commandRegistry } from "@ingenyus/swarm";
|
|
@@ -158,7 +154,7 @@ var commonSchemas = {
|
|
|
158
154
|
// src/common/templates.ts
|
|
159
155
|
import { toKebabCase } from "@ingenyus/swarm";
|
|
160
156
|
import { Eta } from "eta";
|
|
161
|
-
import
|
|
157
|
+
import path3 from "path";
|
|
162
158
|
var TemplateUtility = class {
|
|
163
159
|
constructor(fileSystem) {
|
|
164
160
|
this.fileSystem = fileSystem;
|
|
@@ -166,14 +162,14 @@ var TemplateUtility = class {
|
|
|
166
162
|
processTemplate(templatePath, replacements) {
|
|
167
163
|
const declarations = Object.keys(replacements).map((key) => `${key}=it.${key}`).join(", ");
|
|
168
164
|
const functionHeader = declarations ? `const ${declarations};` : void 0;
|
|
169
|
-
const templateDir =
|
|
165
|
+
const templateDir = path3.dirname(templatePath);
|
|
170
166
|
const eta = new Eta({
|
|
171
167
|
autoTrim: false,
|
|
172
168
|
autoEscape: false,
|
|
173
169
|
views: templateDir,
|
|
174
170
|
functionHeader
|
|
175
171
|
});
|
|
176
|
-
const templateName =
|
|
172
|
+
const templateName = path3.basename(templatePath).replace(/\.eta$/, "");
|
|
177
173
|
if (this.fileSystem.existsSync(templatePath)) {
|
|
178
174
|
return eta.render(templateName, replacements);
|
|
179
175
|
} else {
|
|
@@ -191,11 +187,11 @@ var TemplateUtility = class {
|
|
|
191
187
|
resolveTemplatePath(relativePath, generatorName, currentFileUrl) {
|
|
192
188
|
const generatorDirName = toKebabCase(generatorName);
|
|
193
189
|
const currentFilePath = new URL(currentFileUrl).pathname;
|
|
194
|
-
const currentFileDir =
|
|
195
|
-
const currentFileName =
|
|
190
|
+
const currentFileDir = path3.dirname(currentFilePath);
|
|
191
|
+
const currentFileName = path3.basename(currentFilePath);
|
|
196
192
|
const isInstalledPackage = currentFileDir.includes("node_modules") && currentFileDir.endsWith("/dist") && currentFileName === "index.js";
|
|
197
|
-
const startDir = isInstalledPackage ? currentFileDir :
|
|
198
|
-
return
|
|
193
|
+
const startDir = isInstalledPackage ? currentFileDir : path3.dirname(path3.dirname(currentFileDir));
|
|
194
|
+
return path3.join(
|
|
199
195
|
startDir,
|
|
200
196
|
"generators",
|
|
201
197
|
generatorDirName,
|
|
@@ -213,7 +209,7 @@ import {
|
|
|
213
209
|
toKebabCase as toKebabCase2,
|
|
214
210
|
validateFeaturePath as validateFeaturePath3
|
|
215
211
|
} from "@ingenyus/swarm";
|
|
216
|
-
import
|
|
212
|
+
import path6 from "path";
|
|
217
213
|
|
|
218
214
|
// src/generators/feature/feature-generator.ts
|
|
219
215
|
import {
|
|
@@ -221,7 +217,7 @@ import {
|
|
|
221
217
|
logger as singletonLogger3,
|
|
222
218
|
validateFeaturePath as validateFeaturePath2
|
|
223
219
|
} from "@ingenyus/swarm";
|
|
224
|
-
import
|
|
220
|
+
import path5 from "path";
|
|
225
221
|
|
|
226
222
|
// src/generators/base/wasp-generator.base.ts
|
|
227
223
|
import {
|
|
@@ -237,14 +233,14 @@ import {
|
|
|
237
233
|
parseHelperMethodDefinition,
|
|
238
234
|
logger as singletonLogger
|
|
239
235
|
} from "@ingenyus/swarm";
|
|
240
|
-
import
|
|
236
|
+
import path4 from "path";
|
|
241
237
|
var WaspConfigGenerator = class {
|
|
242
238
|
constructor(logger = singletonLogger, fileSystem = realFileSystem) {
|
|
243
239
|
this.logger = logger;
|
|
244
240
|
this.fileSystem = fileSystem;
|
|
245
241
|
this.templateUtility = new TemplateUtility(fileSystem);
|
|
246
242
|
}
|
|
247
|
-
path =
|
|
243
|
+
path = path4;
|
|
248
244
|
templateUtility;
|
|
249
245
|
/**
|
|
250
246
|
* Gets the template path for feature config templates.
|
|
@@ -273,7 +269,7 @@ var WaspConfigGenerator = class {
|
|
|
273
269
|
this.logger.error(`Template not found: ${templatePath}`);
|
|
274
270
|
return;
|
|
275
271
|
}
|
|
276
|
-
const configFilePath =
|
|
272
|
+
const configFilePath = path4.join(featureDir, `feature.wasp.ts`);
|
|
277
273
|
if (this.fileSystem.existsSync(configFilePath)) {
|
|
278
274
|
this.logger.warn(`Feature config already exists: ${configFilePath}`);
|
|
279
275
|
return;
|
|
@@ -289,7 +285,7 @@ var WaspConfigGenerator = class {
|
|
|
289
285
|
*/
|
|
290
286
|
update(featurePath, declaration) {
|
|
291
287
|
const configDir = getFeatureDir(this.fileSystem, featurePath);
|
|
292
|
-
const configFilePath =
|
|
288
|
+
const configFilePath = path4.join(configDir, `feature.wasp.ts`);
|
|
293
289
|
if (!this.fileSystem.existsSync(configFilePath)) {
|
|
294
290
|
const templatePath = this.getTemplatePath("feature.wasp.eta");
|
|
295
291
|
if (!this.fileSystem.existsSync(templatePath)) {
|
|
@@ -799,18 +795,18 @@ var FeatureGenerator = class extends WaspGeneratorBase {
|
|
|
799
795
|
const { target } = args;
|
|
800
796
|
const segments = validateFeaturePath2(target);
|
|
801
797
|
const normalisedPath = normaliseFeaturePath(target);
|
|
802
|
-
const sourceRoot =
|
|
798
|
+
const sourceRoot = path5.join(findWaspRoot(this.fileSystem), "src");
|
|
803
799
|
if (segments.length > 1) {
|
|
804
800
|
const parentPath = segments.slice(0, -1).join("/");
|
|
805
801
|
const parentNormalisedPath = normaliseFeaturePath(parentPath);
|
|
806
|
-
const parentFeatureDir =
|
|
802
|
+
const parentFeatureDir = path5.join(sourceRoot, parentNormalisedPath);
|
|
807
803
|
if (!this.fileSystem.existsSync(parentFeatureDir)) {
|
|
808
804
|
handleFatalError2(
|
|
809
805
|
`Parent feature '${parentPath}' does not exist. Please create it first.`
|
|
810
806
|
);
|
|
811
807
|
}
|
|
812
808
|
}
|
|
813
|
-
const featureDir =
|
|
809
|
+
const featureDir = path5.join(sourceRoot, normalisedPath);
|
|
814
810
|
this.fileSystem.mkdirSync(featureDir, { recursive: true });
|
|
815
811
|
this.configGenerator.generate(normalisedPath);
|
|
816
812
|
this.logger.success(`Generated feature: ${normalisedPath}`);
|
|
@@ -847,7 +843,7 @@ var ComponentGeneratorBase = class extends WaspGeneratorBase {
|
|
|
847
843
|
const currentPath = pathSegments.join("/");
|
|
848
844
|
const featureName = pathSegments[pathSegments.length - 1];
|
|
849
845
|
const featureDir = getFeatureDir(this.fileSystem, currentPath);
|
|
850
|
-
const configPath =
|
|
846
|
+
const configPath = path6.join(featureDir, `feature.wasp.ts`);
|
|
851
847
|
if (this.fileSystem.existsSync(configPath)) {
|
|
852
848
|
return configPath;
|
|
853
849
|
}
|
|
@@ -920,7 +916,7 @@ var ComponentGeneratorBase = class extends WaspGeneratorBase {
|
|
|
920
916
|
const featureDir = getFeatureDir(fileSystem, normalisedPath);
|
|
921
917
|
const typeKey = type.toLowerCase();
|
|
922
918
|
const typeDirectory = TYPE_DIRECTORIES[typeKey];
|
|
923
|
-
const targetDirectory =
|
|
919
|
+
const targetDirectory = path6.join(featureDir, typeDirectory);
|
|
924
920
|
const importDirectory = `@src/${normalisedPath}/${typeDirectory}`;
|
|
925
921
|
return { targetDirectory, importDirectory };
|
|
926
922
|
}
|
|
@@ -1040,7 +1036,7 @@ var ApiGenerator = class extends ComponentGeneratorBase {
|
|
|
1040
1036
|
force = false,
|
|
1041
1037
|
entities,
|
|
1042
1038
|
method,
|
|
1043
|
-
path:
|
|
1039
|
+
path: path7,
|
|
1044
1040
|
auth,
|
|
1045
1041
|
customMiddleware
|
|
1046
1042
|
} = args;
|
|
@@ -1050,7 +1046,7 @@ var ApiGenerator = class extends ComponentGeneratorBase {
|
|
|
1050
1046
|
feature,
|
|
1051
1047
|
Array.isArray(entities) ? entities : entities ? [entities] : [],
|
|
1052
1048
|
method,
|
|
1053
|
-
|
|
1049
|
+
path7,
|
|
1054
1050
|
apiFile,
|
|
1055
1051
|
auth,
|
|
1056
1052
|
importPath,
|
|
@@ -92,16 +92,12 @@ function getFeatureImportPath(featurePath) {
|
|
|
92
92
|
return segments.join("/");
|
|
93
93
|
}
|
|
94
94
|
|
|
95
|
-
// src/common/plugin.ts
|
|
96
|
-
import path2 from "path";
|
|
97
|
-
import { fileURLToPath } from "url";
|
|
98
|
-
|
|
99
95
|
// src/common/prisma.ts
|
|
100
96
|
import {
|
|
101
97
|
getSchema
|
|
102
98
|
} from "@mrleebo/prisma-ast";
|
|
103
99
|
import fs2 from "fs";
|
|
104
|
-
import
|
|
100
|
+
import path2 from "path";
|
|
105
101
|
|
|
106
102
|
// src/common/schemas.ts
|
|
107
103
|
import { commandRegistry } from "@ingenyus/swarm";
|
|
@@ -158,7 +154,7 @@ var commonSchemas = {
|
|
|
158
154
|
// src/common/templates.ts
|
|
159
155
|
import { toKebabCase } from "@ingenyus/swarm";
|
|
160
156
|
import { Eta } from "eta";
|
|
161
|
-
import
|
|
157
|
+
import path3 from "path";
|
|
162
158
|
var TemplateUtility = class {
|
|
163
159
|
constructor(fileSystem) {
|
|
164
160
|
this.fileSystem = fileSystem;
|
|
@@ -166,14 +162,14 @@ var TemplateUtility = class {
|
|
|
166
162
|
processTemplate(templatePath, replacements) {
|
|
167
163
|
const declarations = Object.keys(replacements).map((key) => `${key}=it.${key}`).join(", ");
|
|
168
164
|
const functionHeader = declarations ? `const ${declarations};` : void 0;
|
|
169
|
-
const templateDir =
|
|
165
|
+
const templateDir = path3.dirname(templatePath);
|
|
170
166
|
const eta = new Eta({
|
|
171
167
|
autoTrim: false,
|
|
172
168
|
autoEscape: false,
|
|
173
169
|
views: templateDir,
|
|
174
170
|
functionHeader
|
|
175
171
|
});
|
|
176
|
-
const templateName =
|
|
172
|
+
const templateName = path3.basename(templatePath).replace(/\.eta$/, "");
|
|
177
173
|
if (this.fileSystem.existsSync(templatePath)) {
|
|
178
174
|
return eta.render(templateName, replacements);
|
|
179
175
|
} else {
|
|
@@ -191,11 +187,11 @@ var TemplateUtility = class {
|
|
|
191
187
|
resolveTemplatePath(relativePath, generatorName, currentFileUrl) {
|
|
192
188
|
const generatorDirName = toKebabCase(generatorName);
|
|
193
189
|
const currentFilePath = new URL(currentFileUrl).pathname;
|
|
194
|
-
const currentFileDir =
|
|
195
|
-
const currentFileName =
|
|
190
|
+
const currentFileDir = path3.dirname(currentFilePath);
|
|
191
|
+
const currentFileName = path3.basename(currentFilePath);
|
|
196
192
|
const isInstalledPackage = currentFileDir.includes("node_modules") && currentFileDir.endsWith("/dist") && currentFileName === "index.js";
|
|
197
|
-
const startDir = isInstalledPackage ? currentFileDir :
|
|
198
|
-
return
|
|
193
|
+
const startDir = isInstalledPackage ? currentFileDir : path3.dirname(path3.dirname(currentFileDir));
|
|
194
|
+
return path3.join(
|
|
199
195
|
startDir,
|
|
200
196
|
"generators",
|
|
201
197
|
generatorDirName,
|
|
@@ -213,7 +209,7 @@ import {
|
|
|
213
209
|
toKebabCase as toKebabCase2,
|
|
214
210
|
validateFeaturePath as validateFeaturePath3
|
|
215
211
|
} from "@ingenyus/swarm";
|
|
216
|
-
import
|
|
212
|
+
import path6 from "path";
|
|
217
213
|
|
|
218
214
|
// src/generators/feature/feature-generator.ts
|
|
219
215
|
import {
|
|
@@ -221,7 +217,7 @@ import {
|
|
|
221
217
|
logger as singletonLogger3,
|
|
222
218
|
validateFeaturePath as validateFeaturePath2
|
|
223
219
|
} from "@ingenyus/swarm";
|
|
224
|
-
import
|
|
220
|
+
import path5 from "path";
|
|
225
221
|
|
|
226
222
|
// src/generators/base/wasp-generator.base.ts
|
|
227
223
|
import {
|
|
@@ -237,14 +233,14 @@ import {
|
|
|
237
233
|
parseHelperMethodDefinition,
|
|
238
234
|
logger as singletonLogger
|
|
239
235
|
} from "@ingenyus/swarm";
|
|
240
|
-
import
|
|
236
|
+
import path4 from "path";
|
|
241
237
|
var WaspConfigGenerator = class {
|
|
242
238
|
constructor(logger = singletonLogger, fileSystem = realFileSystem) {
|
|
243
239
|
this.logger = logger;
|
|
244
240
|
this.fileSystem = fileSystem;
|
|
245
241
|
this.templateUtility = new TemplateUtility(fileSystem);
|
|
246
242
|
}
|
|
247
|
-
path =
|
|
243
|
+
path = path4;
|
|
248
244
|
templateUtility;
|
|
249
245
|
/**
|
|
250
246
|
* Gets the template path for feature config templates.
|
|
@@ -273,7 +269,7 @@ var WaspConfigGenerator = class {
|
|
|
273
269
|
this.logger.error(`Template not found: ${templatePath}`);
|
|
274
270
|
return;
|
|
275
271
|
}
|
|
276
|
-
const configFilePath =
|
|
272
|
+
const configFilePath = path4.join(featureDir, `feature.wasp.ts`);
|
|
277
273
|
if (this.fileSystem.existsSync(configFilePath)) {
|
|
278
274
|
this.logger.warn(`Feature config already exists: ${configFilePath}`);
|
|
279
275
|
return;
|
|
@@ -289,7 +285,7 @@ var WaspConfigGenerator = class {
|
|
|
289
285
|
*/
|
|
290
286
|
update(featurePath, declaration) {
|
|
291
287
|
const configDir = getFeatureDir(this.fileSystem, featurePath);
|
|
292
|
-
const configFilePath =
|
|
288
|
+
const configFilePath = path4.join(configDir, `feature.wasp.ts`);
|
|
293
289
|
if (!this.fileSystem.existsSync(configFilePath)) {
|
|
294
290
|
const templatePath = this.getTemplatePath("feature.wasp.eta");
|
|
295
291
|
if (!this.fileSystem.existsSync(templatePath)) {
|
|
@@ -799,18 +795,18 @@ var FeatureGenerator = class extends WaspGeneratorBase {
|
|
|
799
795
|
const { target } = args;
|
|
800
796
|
const segments = validateFeaturePath2(target);
|
|
801
797
|
const normalisedPath = normaliseFeaturePath(target);
|
|
802
|
-
const sourceRoot =
|
|
798
|
+
const sourceRoot = path5.join(findWaspRoot(this.fileSystem), "src");
|
|
803
799
|
if (segments.length > 1) {
|
|
804
800
|
const parentPath = segments.slice(0, -1).join("/");
|
|
805
801
|
const parentNormalisedPath = normaliseFeaturePath(parentPath);
|
|
806
|
-
const parentFeatureDir =
|
|
802
|
+
const parentFeatureDir = path5.join(sourceRoot, parentNormalisedPath);
|
|
807
803
|
if (!this.fileSystem.existsSync(parentFeatureDir)) {
|
|
808
804
|
handleFatalError2(
|
|
809
805
|
`Parent feature '${parentPath}' does not exist. Please create it first.`
|
|
810
806
|
);
|
|
811
807
|
}
|
|
812
808
|
}
|
|
813
|
-
const featureDir =
|
|
809
|
+
const featureDir = path5.join(sourceRoot, normalisedPath);
|
|
814
810
|
this.fileSystem.mkdirSync(featureDir, { recursive: true });
|
|
815
811
|
this.configGenerator.generate(normalisedPath);
|
|
816
812
|
this.logger.success(`Generated feature: ${normalisedPath}`);
|
|
@@ -847,7 +843,7 @@ var ComponentGeneratorBase = class extends WaspGeneratorBase {
|
|
|
847
843
|
const currentPath = pathSegments.join("/");
|
|
848
844
|
const featureName = pathSegments[pathSegments.length - 1];
|
|
849
845
|
const featureDir = getFeatureDir(this.fileSystem, currentPath);
|
|
850
|
-
const configPath =
|
|
846
|
+
const configPath = path6.join(featureDir, `feature.wasp.ts`);
|
|
851
847
|
if (this.fileSystem.existsSync(configPath)) {
|
|
852
848
|
return configPath;
|
|
853
849
|
}
|
|
@@ -920,7 +916,7 @@ var ComponentGeneratorBase = class extends WaspGeneratorBase {
|
|
|
920
916
|
const featureDir = getFeatureDir(fileSystem, normalisedPath);
|
|
921
917
|
const typeKey = type.toLowerCase();
|
|
922
918
|
const typeDirectory = TYPE_DIRECTORIES[typeKey];
|
|
923
|
-
const targetDirectory =
|
|
919
|
+
const targetDirectory = path6.join(featureDir, typeDirectory);
|
|
924
920
|
const importDirectory = `@src/${normalisedPath}/${typeDirectory}`;
|
|
925
921
|
return { targetDirectory, importDirectory };
|
|
926
922
|
}
|
|
@@ -1040,7 +1036,7 @@ var ApiGenerator = class extends ComponentGeneratorBase {
|
|
|
1040
1036
|
force = false,
|
|
1041
1037
|
entities,
|
|
1042
1038
|
method,
|
|
1043
|
-
path:
|
|
1039
|
+
path: path7,
|
|
1044
1040
|
auth,
|
|
1045
1041
|
customMiddleware
|
|
1046
1042
|
} = args;
|
|
@@ -1050,7 +1046,7 @@ var ApiGenerator = class extends ComponentGeneratorBase {
|
|
|
1050
1046
|
feature,
|
|
1051
1047
|
Array.isArray(entities) ? entities : entities ? [entities] : [],
|
|
1052
1048
|
method,
|
|
1053
|
-
|
|
1049
|
+
path7,
|
|
1054
1050
|
apiFile,
|
|
1055
1051
|
auth,
|
|
1056
1052
|
importPath,
|