@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
|
@@ -35,7 +35,7 @@ import {
|
|
|
35
35
|
toKebabCase as toKebabCase2,
|
|
36
36
|
validateFeaturePath as validateFeaturePath3
|
|
37
37
|
} from "@ingenyus/swarm";
|
|
38
|
-
import
|
|
38
|
+
import path6 from "path";
|
|
39
39
|
|
|
40
40
|
// src/common/filesystem.ts
|
|
41
41
|
import { toPascalCase, validateFeaturePath } from "@ingenyus/swarm";
|
|
@@ -89,16 +89,12 @@ function getFeatureDir(fileSystem, featureName) {
|
|
|
89
89
|
return path.join(waspRoot, "src", normalisedPath);
|
|
90
90
|
}
|
|
91
91
|
|
|
92
|
-
// src/common/plugin.ts
|
|
93
|
-
import path2 from "path";
|
|
94
|
-
import { fileURLToPath } from "url";
|
|
95
|
-
|
|
96
92
|
// src/common/prisma.ts
|
|
97
93
|
import {
|
|
98
94
|
getSchema
|
|
99
95
|
} from "@mrleebo/prisma-ast";
|
|
100
96
|
import fs2 from "fs";
|
|
101
|
-
import
|
|
97
|
+
import path2 from "path";
|
|
102
98
|
|
|
103
99
|
// src/common/schemas.ts
|
|
104
100
|
import { commandRegistry } from "@ingenyus/swarm";
|
|
@@ -155,7 +151,7 @@ var commonSchemas = {
|
|
|
155
151
|
// src/common/templates.ts
|
|
156
152
|
import { toKebabCase } from "@ingenyus/swarm";
|
|
157
153
|
import { Eta } from "eta";
|
|
158
|
-
import
|
|
154
|
+
import path3 from "path";
|
|
159
155
|
var TemplateUtility = class {
|
|
160
156
|
constructor(fileSystem) {
|
|
161
157
|
this.fileSystem = fileSystem;
|
|
@@ -163,14 +159,14 @@ var TemplateUtility = class {
|
|
|
163
159
|
processTemplate(templatePath, replacements) {
|
|
164
160
|
const declarations = Object.keys(replacements).map((key) => `${key}=it.${key}`).join(", ");
|
|
165
161
|
const functionHeader = declarations ? `const ${declarations};` : void 0;
|
|
166
|
-
const templateDir =
|
|
162
|
+
const templateDir = path3.dirname(templatePath);
|
|
167
163
|
const eta = new Eta({
|
|
168
164
|
autoTrim: false,
|
|
169
165
|
autoEscape: false,
|
|
170
166
|
views: templateDir,
|
|
171
167
|
functionHeader
|
|
172
168
|
});
|
|
173
|
-
const templateName =
|
|
169
|
+
const templateName = path3.basename(templatePath).replace(/\.eta$/, "");
|
|
174
170
|
if (this.fileSystem.existsSync(templatePath)) {
|
|
175
171
|
return eta.render(templateName, replacements);
|
|
176
172
|
} else {
|
|
@@ -188,11 +184,11 @@ var TemplateUtility = class {
|
|
|
188
184
|
resolveTemplatePath(relativePath, generatorName, currentFileUrl) {
|
|
189
185
|
const generatorDirName = toKebabCase(generatorName);
|
|
190
186
|
const currentFilePath = new URL(currentFileUrl).pathname;
|
|
191
|
-
const currentFileDir =
|
|
192
|
-
const currentFileName =
|
|
187
|
+
const currentFileDir = path3.dirname(currentFilePath);
|
|
188
|
+
const currentFileName = path3.basename(currentFilePath);
|
|
193
189
|
const isInstalledPackage = currentFileDir.includes("node_modules") && currentFileDir.endsWith("/dist") && currentFileName === "index.js";
|
|
194
|
-
const startDir = isInstalledPackage ? currentFileDir :
|
|
195
|
-
return
|
|
190
|
+
const startDir = isInstalledPackage ? currentFileDir : path3.dirname(path3.dirname(currentFileDir));
|
|
191
|
+
return path3.join(
|
|
196
192
|
startDir,
|
|
197
193
|
"generators",
|
|
198
194
|
generatorDirName,
|
|
@@ -208,7 +204,7 @@ import {
|
|
|
208
204
|
logger as singletonLogger3,
|
|
209
205
|
validateFeaturePath as validateFeaturePath2
|
|
210
206
|
} from "@ingenyus/swarm";
|
|
211
|
-
import
|
|
207
|
+
import path5 from "path";
|
|
212
208
|
|
|
213
209
|
// src/generators/base/wasp-generator.base.ts
|
|
214
210
|
import {
|
|
@@ -224,14 +220,14 @@ import {
|
|
|
224
220
|
parseHelperMethodDefinition,
|
|
225
221
|
logger as singletonLogger
|
|
226
222
|
} from "@ingenyus/swarm";
|
|
227
|
-
import
|
|
223
|
+
import path4 from "path";
|
|
228
224
|
var WaspConfigGenerator = class {
|
|
229
225
|
constructor(logger = singletonLogger, fileSystem = realFileSystem) {
|
|
230
226
|
this.logger = logger;
|
|
231
227
|
this.fileSystem = fileSystem;
|
|
232
228
|
this.templateUtility = new TemplateUtility(fileSystem);
|
|
233
229
|
}
|
|
234
|
-
path =
|
|
230
|
+
path = path4;
|
|
235
231
|
templateUtility;
|
|
236
232
|
/**
|
|
237
233
|
* Gets the template path for feature config templates.
|
|
@@ -260,7 +256,7 @@ var WaspConfigGenerator = class {
|
|
|
260
256
|
this.logger.error(`Template not found: ${templatePath}`);
|
|
261
257
|
return;
|
|
262
258
|
}
|
|
263
|
-
const configFilePath =
|
|
259
|
+
const configFilePath = path4.join(featureDir, `feature.wasp.ts`);
|
|
264
260
|
if (this.fileSystem.existsSync(configFilePath)) {
|
|
265
261
|
this.logger.warn(`Feature config already exists: ${configFilePath}`);
|
|
266
262
|
return;
|
|
@@ -276,7 +272,7 @@ var WaspConfigGenerator = class {
|
|
|
276
272
|
*/
|
|
277
273
|
update(featurePath, declaration) {
|
|
278
274
|
const configDir = getFeatureDir(this.fileSystem, featurePath);
|
|
279
|
-
const configFilePath =
|
|
275
|
+
const configFilePath = path4.join(configDir, `feature.wasp.ts`);
|
|
280
276
|
if (!this.fileSystem.existsSync(configFilePath)) {
|
|
281
277
|
const templatePath = this.getTemplatePath("feature.wasp.eta");
|
|
282
278
|
if (!this.fileSystem.existsSync(templatePath)) {
|
|
@@ -786,18 +782,18 @@ var FeatureGenerator = class extends WaspGeneratorBase {
|
|
|
786
782
|
const { target } = args;
|
|
787
783
|
const segments = validateFeaturePath2(target);
|
|
788
784
|
const normalisedPath = normaliseFeaturePath(target);
|
|
789
|
-
const sourceRoot =
|
|
785
|
+
const sourceRoot = path5.join(findWaspRoot(this.fileSystem), "src");
|
|
790
786
|
if (segments.length > 1) {
|
|
791
787
|
const parentPath = segments.slice(0, -1).join("/");
|
|
792
788
|
const parentNormalisedPath = normaliseFeaturePath(parentPath);
|
|
793
|
-
const parentFeatureDir =
|
|
789
|
+
const parentFeatureDir = path5.join(sourceRoot, parentNormalisedPath);
|
|
794
790
|
if (!this.fileSystem.existsSync(parentFeatureDir)) {
|
|
795
791
|
handleFatalError2(
|
|
796
792
|
`Parent feature '${parentPath}' does not exist. Please create it first.`
|
|
797
793
|
);
|
|
798
794
|
}
|
|
799
795
|
}
|
|
800
|
-
const featureDir =
|
|
796
|
+
const featureDir = path5.join(sourceRoot, normalisedPath);
|
|
801
797
|
this.fileSystem.mkdirSync(featureDir, { recursive: true });
|
|
802
798
|
this.configGenerator.generate(normalisedPath);
|
|
803
799
|
this.logger.success(`Generated feature: ${normalisedPath}`);
|
|
@@ -834,7 +830,7 @@ var ComponentGeneratorBase = class extends WaspGeneratorBase {
|
|
|
834
830
|
const currentPath = pathSegments.join("/");
|
|
835
831
|
const featureName = pathSegments[pathSegments.length - 1];
|
|
836
832
|
const featureDir = getFeatureDir(this.fileSystem, currentPath);
|
|
837
|
-
const configPath =
|
|
833
|
+
const configPath = path6.join(featureDir, `feature.wasp.ts`);
|
|
838
834
|
if (this.fileSystem.existsSync(configPath)) {
|
|
839
835
|
return configPath;
|
|
840
836
|
}
|
|
@@ -907,7 +903,7 @@ var ComponentGeneratorBase = class extends WaspGeneratorBase {
|
|
|
907
903
|
const featureDir = getFeatureDir(fileSystem, normalisedPath);
|
|
908
904
|
const typeKey = type.toLowerCase();
|
|
909
905
|
const typeDirectory = TYPE_DIRECTORIES[typeKey];
|
|
910
|
-
const targetDirectory =
|
|
906
|
+
const targetDirectory = path6.join(featureDir, typeDirectory);
|
|
911
907
|
const importDirectory = `@src/${normalisedPath}/${typeDirectory}`;
|
|
912
908
|
return { targetDirectory, importDirectory };
|
|
913
909
|
}
|
|
@@ -35,7 +35,7 @@ import {
|
|
|
35
35
|
toKebabCase as toKebabCase2,
|
|
36
36
|
validateFeaturePath as validateFeaturePath3
|
|
37
37
|
} from "@ingenyus/swarm";
|
|
38
|
-
import
|
|
38
|
+
import path6 from "path";
|
|
39
39
|
|
|
40
40
|
// src/common/filesystem.ts
|
|
41
41
|
import { toPascalCase, validateFeaturePath } from "@ingenyus/swarm";
|
|
@@ -89,16 +89,12 @@ function getFeatureDir(fileSystem, featureName) {
|
|
|
89
89
|
return path.join(waspRoot, "src", normalisedPath);
|
|
90
90
|
}
|
|
91
91
|
|
|
92
|
-
// src/common/plugin.ts
|
|
93
|
-
import path2 from "path";
|
|
94
|
-
import { fileURLToPath } from "url";
|
|
95
|
-
|
|
96
92
|
// src/common/prisma.ts
|
|
97
93
|
import {
|
|
98
94
|
getSchema
|
|
99
95
|
} from "@mrleebo/prisma-ast";
|
|
100
96
|
import fs2 from "fs";
|
|
101
|
-
import
|
|
97
|
+
import path2 from "path";
|
|
102
98
|
|
|
103
99
|
// src/common/schemas.ts
|
|
104
100
|
import { commandRegistry } from "@ingenyus/swarm";
|
|
@@ -155,7 +151,7 @@ var commonSchemas = {
|
|
|
155
151
|
// src/common/templates.ts
|
|
156
152
|
import { toKebabCase } from "@ingenyus/swarm";
|
|
157
153
|
import { Eta } from "eta";
|
|
158
|
-
import
|
|
154
|
+
import path3 from "path";
|
|
159
155
|
var TemplateUtility = class {
|
|
160
156
|
constructor(fileSystem) {
|
|
161
157
|
this.fileSystem = fileSystem;
|
|
@@ -163,14 +159,14 @@ var TemplateUtility = class {
|
|
|
163
159
|
processTemplate(templatePath, replacements) {
|
|
164
160
|
const declarations = Object.keys(replacements).map((key) => `${key}=it.${key}`).join(", ");
|
|
165
161
|
const functionHeader = declarations ? `const ${declarations};` : void 0;
|
|
166
|
-
const templateDir =
|
|
162
|
+
const templateDir = path3.dirname(templatePath);
|
|
167
163
|
const eta = new Eta({
|
|
168
164
|
autoTrim: false,
|
|
169
165
|
autoEscape: false,
|
|
170
166
|
views: templateDir,
|
|
171
167
|
functionHeader
|
|
172
168
|
});
|
|
173
|
-
const templateName =
|
|
169
|
+
const templateName = path3.basename(templatePath).replace(/\.eta$/, "");
|
|
174
170
|
if (this.fileSystem.existsSync(templatePath)) {
|
|
175
171
|
return eta.render(templateName, replacements);
|
|
176
172
|
} else {
|
|
@@ -188,11 +184,11 @@ var TemplateUtility = class {
|
|
|
188
184
|
resolveTemplatePath(relativePath, generatorName, currentFileUrl) {
|
|
189
185
|
const generatorDirName = toKebabCase(generatorName);
|
|
190
186
|
const currentFilePath = new URL(currentFileUrl).pathname;
|
|
191
|
-
const currentFileDir =
|
|
192
|
-
const currentFileName =
|
|
187
|
+
const currentFileDir = path3.dirname(currentFilePath);
|
|
188
|
+
const currentFileName = path3.basename(currentFilePath);
|
|
193
189
|
const isInstalledPackage = currentFileDir.includes("node_modules") && currentFileDir.endsWith("/dist") && currentFileName === "index.js";
|
|
194
|
-
const startDir = isInstalledPackage ? currentFileDir :
|
|
195
|
-
return
|
|
190
|
+
const startDir = isInstalledPackage ? currentFileDir : path3.dirname(path3.dirname(currentFileDir));
|
|
191
|
+
return path3.join(
|
|
196
192
|
startDir,
|
|
197
193
|
"generators",
|
|
198
194
|
generatorDirName,
|
|
@@ -208,7 +204,7 @@ import {
|
|
|
208
204
|
logger as singletonLogger3,
|
|
209
205
|
validateFeaturePath as validateFeaturePath2
|
|
210
206
|
} from "@ingenyus/swarm";
|
|
211
|
-
import
|
|
207
|
+
import path5 from "path";
|
|
212
208
|
|
|
213
209
|
// src/generators/base/wasp-generator.base.ts
|
|
214
210
|
import {
|
|
@@ -224,14 +220,14 @@ import {
|
|
|
224
220
|
parseHelperMethodDefinition,
|
|
225
221
|
logger as singletonLogger
|
|
226
222
|
} from "@ingenyus/swarm";
|
|
227
|
-
import
|
|
223
|
+
import path4 from "path";
|
|
228
224
|
var WaspConfigGenerator = class {
|
|
229
225
|
constructor(logger = singletonLogger, fileSystem = realFileSystem) {
|
|
230
226
|
this.logger = logger;
|
|
231
227
|
this.fileSystem = fileSystem;
|
|
232
228
|
this.templateUtility = new TemplateUtility(fileSystem);
|
|
233
229
|
}
|
|
234
|
-
path =
|
|
230
|
+
path = path4;
|
|
235
231
|
templateUtility;
|
|
236
232
|
/**
|
|
237
233
|
* Gets the template path for feature config templates.
|
|
@@ -260,7 +256,7 @@ var WaspConfigGenerator = class {
|
|
|
260
256
|
this.logger.error(`Template not found: ${templatePath}`);
|
|
261
257
|
return;
|
|
262
258
|
}
|
|
263
|
-
const configFilePath =
|
|
259
|
+
const configFilePath = path4.join(featureDir, `feature.wasp.ts`);
|
|
264
260
|
if (this.fileSystem.existsSync(configFilePath)) {
|
|
265
261
|
this.logger.warn(`Feature config already exists: ${configFilePath}`);
|
|
266
262
|
return;
|
|
@@ -276,7 +272,7 @@ var WaspConfigGenerator = class {
|
|
|
276
272
|
*/
|
|
277
273
|
update(featurePath, declaration) {
|
|
278
274
|
const configDir = getFeatureDir(this.fileSystem, featurePath);
|
|
279
|
-
const configFilePath =
|
|
275
|
+
const configFilePath = path4.join(configDir, `feature.wasp.ts`);
|
|
280
276
|
if (!this.fileSystem.existsSync(configFilePath)) {
|
|
281
277
|
const templatePath = this.getTemplatePath("feature.wasp.eta");
|
|
282
278
|
if (!this.fileSystem.existsSync(templatePath)) {
|
|
@@ -786,18 +782,18 @@ var FeatureGenerator = class extends WaspGeneratorBase {
|
|
|
786
782
|
const { target } = args;
|
|
787
783
|
const segments = validateFeaturePath2(target);
|
|
788
784
|
const normalisedPath = normaliseFeaturePath(target);
|
|
789
|
-
const sourceRoot =
|
|
785
|
+
const sourceRoot = path5.join(findWaspRoot(this.fileSystem), "src");
|
|
790
786
|
if (segments.length > 1) {
|
|
791
787
|
const parentPath = segments.slice(0, -1).join("/");
|
|
792
788
|
const parentNormalisedPath = normaliseFeaturePath(parentPath);
|
|
793
|
-
const parentFeatureDir =
|
|
789
|
+
const parentFeatureDir = path5.join(sourceRoot, parentNormalisedPath);
|
|
794
790
|
if (!this.fileSystem.existsSync(parentFeatureDir)) {
|
|
795
791
|
handleFatalError2(
|
|
796
792
|
`Parent feature '${parentPath}' does not exist. Please create it first.`
|
|
797
793
|
);
|
|
798
794
|
}
|
|
799
795
|
}
|
|
800
|
-
const featureDir =
|
|
796
|
+
const featureDir = path5.join(sourceRoot, normalisedPath);
|
|
801
797
|
this.fileSystem.mkdirSync(featureDir, { recursive: true });
|
|
802
798
|
this.configGenerator.generate(normalisedPath);
|
|
803
799
|
this.logger.success(`Generated feature: ${normalisedPath}`);
|
|
@@ -834,7 +830,7 @@ var ComponentGeneratorBase = class extends WaspGeneratorBase {
|
|
|
834
830
|
const currentPath = pathSegments.join("/");
|
|
835
831
|
const featureName = pathSegments[pathSegments.length - 1];
|
|
836
832
|
const featureDir = getFeatureDir(this.fileSystem, currentPath);
|
|
837
|
-
const configPath =
|
|
833
|
+
const configPath = path6.join(featureDir, `feature.wasp.ts`);
|
|
838
834
|
if (this.fileSystem.existsSync(configPath)) {
|
|
839
835
|
return configPath;
|
|
840
836
|
}
|
|
@@ -907,7 +903,7 @@ var ComponentGeneratorBase = class extends WaspGeneratorBase {
|
|
|
907
903
|
const featureDir = getFeatureDir(fileSystem, normalisedPath);
|
|
908
904
|
const typeKey = type.toLowerCase();
|
|
909
905
|
const typeDirectory = TYPE_DIRECTORIES[typeKey];
|
|
910
|
-
const targetDirectory =
|
|
906
|
+
const targetDirectory = path6.join(featureDir, typeDirectory);
|
|
911
907
|
const importDirectory = `@src/${normalisedPath}/${typeDirectory}`;
|
|
912
908
|
return { targetDirectory, importDirectory };
|
|
913
909
|
}
|
|
@@ -15,16 +15,12 @@ var realFileSystem = {
|
|
|
15
15
|
statSync: fs.statSync
|
|
16
16
|
};
|
|
17
17
|
|
|
18
|
-
// src/common/plugin.ts
|
|
19
|
-
import path from "path";
|
|
20
|
-
import { fileURLToPath } from "url";
|
|
21
|
-
|
|
22
18
|
// src/common/prisma.ts
|
|
23
19
|
import {
|
|
24
20
|
getSchema
|
|
25
21
|
} from "@mrleebo/prisma-ast";
|
|
26
22
|
import fs2 from "fs";
|
|
27
|
-
import
|
|
23
|
+
import path from "path";
|
|
28
24
|
|
|
29
25
|
// src/common/schemas.ts
|
|
30
26
|
import { commandRegistry } from "@ingenyus/swarm";
|
|
@@ -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";
|