@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
|
@@ -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
|
|
113
|
+
import path2 from "path";
|
|
118
114
|
async function getEntityMetadata(modelName) {
|
|
119
115
|
try {
|
|
120
|
-
const schemaPath =
|
|
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
|
|
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 =
|
|
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 =
|
|
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 =
|
|
329
|
-
const currentFileName =
|
|
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 :
|
|
332
|
-
return
|
|
327
|
+
const startDir = isInstalledPackage ? currentFileDir : path3.dirname(path3.dirname(currentFileDir));
|
|
328
|
+
return path3.join(
|
|
333
329
|
startDir,
|
|
334
330
|
"generators",
|
|
335
331
|
generatorDirName,
|
|
@@ -347,7 +343,7 @@ import {
|
|
|
347
343
|
toKebabCase as toKebabCase2,
|
|
348
344
|
validateFeaturePath as validateFeaturePath3
|
|
349
345
|
} from "@ingenyus/swarm";
|
|
350
|
-
import
|
|
346
|
+
import path6 from "path";
|
|
351
347
|
|
|
352
348
|
// src/generators/feature/feature-generator.ts
|
|
353
349
|
import {
|
|
@@ -355,7 +351,7 @@ import {
|
|
|
355
351
|
logger as singletonLogger3,
|
|
356
352
|
validateFeaturePath as validateFeaturePath2
|
|
357
353
|
} from "@ingenyus/swarm";
|
|
358
|
-
import
|
|
354
|
+
import path5 from "path";
|
|
359
355
|
|
|
360
356
|
// src/generators/base/wasp-generator.base.ts
|
|
361
357
|
import {
|
|
@@ -371,14 +367,14 @@ import {
|
|
|
371
367
|
parseHelperMethodDefinition,
|
|
372
368
|
logger as singletonLogger
|
|
373
369
|
} from "@ingenyus/swarm";
|
|
374
|
-
import
|
|
370
|
+
import path4 from "path";
|
|
375
371
|
var WaspConfigGenerator = class {
|
|
376
372
|
constructor(logger = singletonLogger, fileSystem = realFileSystem) {
|
|
377
373
|
this.logger = logger;
|
|
378
374
|
this.fileSystem = fileSystem;
|
|
379
375
|
this.templateUtility = new TemplateUtility(fileSystem);
|
|
380
376
|
}
|
|
381
|
-
path =
|
|
377
|
+
path = path4;
|
|
382
378
|
templateUtility;
|
|
383
379
|
/**
|
|
384
380
|
* Gets the template path for feature config templates.
|
|
@@ -407,7 +403,7 @@ var WaspConfigGenerator = class {
|
|
|
407
403
|
this.logger.error(`Template not found: ${templatePath}`);
|
|
408
404
|
return;
|
|
409
405
|
}
|
|
410
|
-
const configFilePath =
|
|
406
|
+
const configFilePath = path4.join(featureDir, `feature.wasp.ts`);
|
|
411
407
|
if (this.fileSystem.existsSync(configFilePath)) {
|
|
412
408
|
this.logger.warn(`Feature config already exists: ${configFilePath}`);
|
|
413
409
|
return;
|
|
@@ -423,7 +419,7 @@ var WaspConfigGenerator = class {
|
|
|
423
419
|
*/
|
|
424
420
|
update(featurePath, declaration) {
|
|
425
421
|
const configDir = getFeatureDir(this.fileSystem, featurePath);
|
|
426
|
-
const configFilePath =
|
|
422
|
+
const configFilePath = path4.join(configDir, `feature.wasp.ts`);
|
|
427
423
|
if (!this.fileSystem.existsSync(configFilePath)) {
|
|
428
424
|
const templatePath = this.getTemplatePath("feature.wasp.eta");
|
|
429
425
|
if (!this.fileSystem.existsSync(templatePath)) {
|
|
@@ -933,18 +929,18 @@ var FeatureGenerator = class extends WaspGeneratorBase {
|
|
|
933
929
|
const { target } = args;
|
|
934
930
|
const segments = validateFeaturePath2(target);
|
|
935
931
|
const normalisedPath = normaliseFeaturePath(target);
|
|
936
|
-
const sourceRoot =
|
|
932
|
+
const sourceRoot = path5.join(findWaspRoot(this.fileSystem), "src");
|
|
937
933
|
if (segments.length > 1) {
|
|
938
934
|
const parentPath = segments.slice(0, -1).join("/");
|
|
939
935
|
const parentNormalisedPath = normaliseFeaturePath(parentPath);
|
|
940
|
-
const parentFeatureDir =
|
|
936
|
+
const parentFeatureDir = path5.join(sourceRoot, parentNormalisedPath);
|
|
941
937
|
if (!this.fileSystem.existsSync(parentFeatureDir)) {
|
|
942
938
|
handleFatalError2(
|
|
943
939
|
`Parent feature '${parentPath}' does not exist. Please create it first.`
|
|
944
940
|
);
|
|
945
941
|
}
|
|
946
942
|
}
|
|
947
|
-
const featureDir =
|
|
943
|
+
const featureDir = path5.join(sourceRoot, normalisedPath);
|
|
948
944
|
this.fileSystem.mkdirSync(featureDir, { recursive: true });
|
|
949
945
|
this.configGenerator.generate(normalisedPath);
|
|
950
946
|
this.logger.success(`Generated feature: ${normalisedPath}`);
|
|
@@ -981,7 +977,7 @@ var ComponentGeneratorBase = class extends WaspGeneratorBase {
|
|
|
981
977
|
const currentPath = pathSegments.join("/");
|
|
982
978
|
const featureName = pathSegments[pathSegments.length - 1];
|
|
983
979
|
const featureDir = getFeatureDir(this.fileSystem, currentPath);
|
|
984
|
-
const configPath =
|
|
980
|
+
const configPath = path6.join(featureDir, `feature.wasp.ts`);
|
|
985
981
|
if (this.fileSystem.existsSync(configPath)) {
|
|
986
982
|
return configPath;
|
|
987
983
|
}
|
|
@@ -1054,7 +1050,7 @@ var ComponentGeneratorBase = class extends WaspGeneratorBase {
|
|
|
1054
1050
|
const featureDir = getFeatureDir(fileSystem, normalisedPath);
|
|
1055
1051
|
const typeKey = type.toLowerCase();
|
|
1056
1052
|
const typeDirectory = TYPE_DIRECTORIES[typeKey];
|
|
1057
|
-
const targetDirectory =
|
|
1053
|
+
const targetDirectory = path6.join(featureDir, typeDirectory);
|
|
1058
1054
|
const importDirectory = `@src/${normalisedPath}/${typeDirectory}`;
|
|
1059
1055
|
return { targetDirectory, importDirectory };
|
|
1060
1056
|
}
|
|
@@ -58,16 +58,12 @@ function getFeatureDir(fileSystem, featureName) {
|
|
|
58
58
|
return path.join(waspRoot, "src", normalisedPath);
|
|
59
59
|
}
|
|
60
60
|
|
|
61
|
-
// src/common/plugin.ts
|
|
62
|
-
import path2 from "path";
|
|
63
|
-
import { fileURLToPath } from "url";
|
|
64
|
-
|
|
65
61
|
// src/common/prisma.ts
|
|
66
62
|
import {
|
|
67
63
|
getSchema
|
|
68
64
|
} from "@mrleebo/prisma-ast";
|
|
69
65
|
import fs2 from "fs";
|
|
70
|
-
import
|
|
66
|
+
import path2 from "path";
|
|
71
67
|
|
|
72
68
|
// src/common/schemas.ts
|
|
73
69
|
import { commandRegistry } from "@ingenyus/swarm";
|
|
@@ -124,7 +120,7 @@ var commonSchemas = {
|
|
|
124
120
|
// src/common/templates.ts
|
|
125
121
|
import { toKebabCase } from "@ingenyus/swarm";
|
|
126
122
|
import { Eta } from "eta";
|
|
127
|
-
import
|
|
123
|
+
import path3 from "path";
|
|
128
124
|
var TemplateUtility = class {
|
|
129
125
|
constructor(fileSystem) {
|
|
130
126
|
this.fileSystem = fileSystem;
|
|
@@ -132,14 +128,14 @@ var TemplateUtility = class {
|
|
|
132
128
|
processTemplate(templatePath, replacements) {
|
|
133
129
|
const declarations = Object.keys(replacements).map((key) => `${key}=it.${key}`).join(", ");
|
|
134
130
|
const functionHeader = declarations ? `const ${declarations};` : void 0;
|
|
135
|
-
const templateDir =
|
|
131
|
+
const templateDir = path3.dirname(templatePath);
|
|
136
132
|
const eta = new Eta({
|
|
137
133
|
autoTrim: false,
|
|
138
134
|
autoEscape: false,
|
|
139
135
|
views: templateDir,
|
|
140
136
|
functionHeader
|
|
141
137
|
});
|
|
142
|
-
const templateName =
|
|
138
|
+
const templateName = path3.basename(templatePath).replace(/\.eta$/, "");
|
|
143
139
|
if (this.fileSystem.existsSync(templatePath)) {
|
|
144
140
|
return eta.render(templateName, replacements);
|
|
145
141
|
} else {
|
|
@@ -157,11 +153,11 @@ var TemplateUtility = class {
|
|
|
157
153
|
resolveTemplatePath(relativePath, generatorName, currentFileUrl) {
|
|
158
154
|
const generatorDirName = toKebabCase(generatorName);
|
|
159
155
|
const currentFilePath = new URL(currentFileUrl).pathname;
|
|
160
|
-
const currentFileDir =
|
|
161
|
-
const currentFileName =
|
|
156
|
+
const currentFileDir = path3.dirname(currentFilePath);
|
|
157
|
+
const currentFileName = path3.basename(currentFilePath);
|
|
162
158
|
const isInstalledPackage = currentFileDir.includes("node_modules") && currentFileDir.endsWith("/dist") && currentFileName === "index.js";
|
|
163
|
-
const startDir = isInstalledPackage ? currentFileDir :
|
|
164
|
-
return
|
|
159
|
+
const startDir = isInstalledPackage ? currentFileDir : path3.dirname(path3.dirname(currentFileDir));
|
|
160
|
+
return path3.join(
|
|
165
161
|
startDir,
|
|
166
162
|
"generators",
|
|
167
163
|
generatorDirName,
|
|
@@ -177,14 +173,14 @@ import {
|
|
|
177
173
|
parseHelperMethodDefinition,
|
|
178
174
|
logger as singletonLogger
|
|
179
175
|
} from "@ingenyus/swarm";
|
|
180
|
-
import
|
|
176
|
+
import path4 from "path";
|
|
181
177
|
var WaspConfigGenerator = class {
|
|
182
178
|
constructor(logger = singletonLogger, fileSystem = realFileSystem) {
|
|
183
179
|
this.logger = logger;
|
|
184
180
|
this.fileSystem = fileSystem;
|
|
185
181
|
this.templateUtility = new TemplateUtility(fileSystem);
|
|
186
182
|
}
|
|
187
|
-
path =
|
|
183
|
+
path = path4;
|
|
188
184
|
templateUtility;
|
|
189
185
|
/**
|
|
190
186
|
* Gets the template path for feature config templates.
|
|
@@ -213,7 +209,7 @@ var WaspConfigGenerator = class {
|
|
|
213
209
|
this.logger.error(`Template not found: ${templatePath}`);
|
|
214
210
|
return;
|
|
215
211
|
}
|
|
216
|
-
const configFilePath =
|
|
212
|
+
const configFilePath = path4.join(featureDir, `feature.wasp.ts`);
|
|
217
213
|
if (this.fileSystem.existsSync(configFilePath)) {
|
|
218
214
|
this.logger.warn(`Feature config already exists: ${configFilePath}`);
|
|
219
215
|
return;
|
|
@@ -229,7 +225,7 @@ var WaspConfigGenerator = class {
|
|
|
229
225
|
*/
|
|
230
226
|
update(featurePath, declaration) {
|
|
231
227
|
const configDir = getFeatureDir(this.fileSystem, featurePath);
|
|
232
|
-
const configFilePath =
|
|
228
|
+
const configFilePath = path4.join(configDir, `feature.wasp.ts`);
|
|
233
229
|
if (!this.fileSystem.existsSync(configFilePath)) {
|
|
234
230
|
const templatePath = this.getTemplatePath("feature.wasp.eta");
|
|
235
231
|
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
|
|
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
|
|
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
|
|
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 =
|
|
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 =
|
|
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 =
|
|
156
|
-
const currentFileName =
|
|
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 :
|
|
159
|
-
return
|
|
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 =
|
|
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 =
|
|
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 =
|
|
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
|
|
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
|
|
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
|
|
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 =
|
|
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 =
|
|
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 =
|
|
156
|
-
const currentFileName =
|
|
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 :
|
|
159
|
-
return
|
|
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 =
|
|
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 =
|
|
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 =
|
|
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)) {
|
|
@@ -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,
|
|
@@ -358,7 +354,7 @@ import {
|
|
|
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
360
|
import {
|
|
@@ -366,7 +362,7 @@ import {
|
|
|
366
362
|
logger as singletonLogger3,
|
|
367
363
|
validateFeaturePath as validateFeaturePath2
|
|
368
364
|
} from "@ingenyus/swarm";
|
|
369
|
-
import
|
|
365
|
+
import path5 from "path";
|
|
370
366
|
|
|
371
367
|
// src/generators/base/wasp-generator.base.ts
|
|
372
368
|
import {
|
|
@@ -382,14 +378,14 @@ import {
|
|
|
382
378
|
parseHelperMethodDefinition,
|
|
383
379
|
logger as singletonLogger
|
|
384
380
|
} from "@ingenyus/swarm";
|
|
385
|
-
import
|
|
381
|
+
import path4 from "path";
|
|
386
382
|
var WaspConfigGenerator = class {
|
|
387
383
|
constructor(logger = singletonLogger, fileSystem = realFileSystem) {
|
|
388
384
|
this.logger = logger;
|
|
389
385
|
this.fileSystem = fileSystem;
|
|
390
386
|
this.templateUtility = new TemplateUtility(fileSystem);
|
|
391
387
|
}
|
|
392
|
-
path =
|
|
388
|
+
path = path4;
|
|
393
389
|
templateUtility;
|
|
394
390
|
/**
|
|
395
391
|
* Gets the template path for feature config templates.
|
|
@@ -418,7 +414,7 @@ var WaspConfigGenerator = class {
|
|
|
418
414
|
this.logger.error(`Template not found: ${templatePath}`);
|
|
419
415
|
return;
|
|
420
416
|
}
|
|
421
|
-
const configFilePath =
|
|
417
|
+
const configFilePath = path4.join(featureDir, `feature.wasp.ts`);
|
|
422
418
|
if (this.fileSystem.existsSync(configFilePath)) {
|
|
423
419
|
this.logger.warn(`Feature config already exists: ${configFilePath}`);
|
|
424
420
|
return;
|
|
@@ -434,7 +430,7 @@ var WaspConfigGenerator = class {
|
|
|
434
430
|
*/
|
|
435
431
|
update(featurePath, declaration) {
|
|
436
432
|
const configDir = getFeatureDir(this.fileSystem, featurePath);
|
|
437
|
-
const configFilePath =
|
|
433
|
+
const configFilePath = path4.join(configDir, `feature.wasp.ts`);
|
|
438
434
|
if (!this.fileSystem.existsSync(configFilePath)) {
|
|
439
435
|
const templatePath = this.getTemplatePath("feature.wasp.eta");
|
|
440
436
|
if (!this.fileSystem.existsSync(templatePath)) {
|
|
@@ -944,18 +940,18 @@ var FeatureGenerator = class extends WaspGeneratorBase {
|
|
|
944
940
|
const { target } = args;
|
|
945
941
|
const segments = validateFeaturePath2(target);
|
|
946
942
|
const normalisedPath = normaliseFeaturePath(target);
|
|
947
|
-
const sourceRoot =
|
|
943
|
+
const sourceRoot = path5.join(findWaspRoot(this.fileSystem), "src");
|
|
948
944
|
if (segments.length > 1) {
|
|
949
945
|
const parentPath = segments.slice(0, -1).join("/");
|
|
950
946
|
const parentNormalisedPath = normaliseFeaturePath(parentPath);
|
|
951
|
-
const parentFeatureDir =
|
|
947
|
+
const parentFeatureDir = path5.join(sourceRoot, parentNormalisedPath);
|
|
952
948
|
if (!this.fileSystem.existsSync(parentFeatureDir)) {
|
|
953
949
|
handleFatalError2(
|
|
954
950
|
`Parent feature '${parentPath}' does not exist. Please create it first.`
|
|
955
951
|
);
|
|
956
952
|
}
|
|
957
953
|
}
|
|
958
|
-
const featureDir =
|
|
954
|
+
const featureDir = path5.join(sourceRoot, normalisedPath);
|
|
959
955
|
this.fileSystem.mkdirSync(featureDir, { recursive: true });
|
|
960
956
|
this.configGenerator.generate(normalisedPath);
|
|
961
957
|
this.logger.success(`Generated feature: ${normalisedPath}`);
|
|
@@ -992,7 +988,7 @@ var ComponentGeneratorBase = class extends WaspGeneratorBase {
|
|
|
992
988
|
const currentPath = pathSegments.join("/");
|
|
993
989
|
const featureName = pathSegments[pathSegments.length - 1];
|
|
994
990
|
const featureDir = getFeatureDir(this.fileSystem, currentPath);
|
|
995
|
-
const configPath =
|
|
991
|
+
const configPath = path6.join(featureDir, `feature.wasp.ts`);
|
|
996
992
|
if (this.fileSystem.existsSync(configPath)) {
|
|
997
993
|
return configPath;
|
|
998
994
|
}
|
|
@@ -1065,7 +1061,7 @@ var ComponentGeneratorBase = class extends WaspGeneratorBase {
|
|
|
1065
1061
|
const featureDir = getFeatureDir(fileSystem, normalisedPath);
|
|
1066
1062
|
const typeKey = type.toLowerCase();
|
|
1067
1063
|
const typeDirectory = TYPE_DIRECTORIES[typeKey];
|
|
1068
|
-
const targetDirectory =
|
|
1064
|
+
const targetDirectory = path6.join(featureDir, typeDirectory);
|
|
1069
1065
|
const importDirectory = `@src/${normalisedPath}/${typeDirectory}`;
|
|
1070
1066
|
return { targetDirectory, importDirectory };
|
|
1071
1067
|
}
|