@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
|
@@ -26,16 +26,12 @@ var realFileSystem = {
|
|
|
26
26
|
statSync: fs.statSync
|
|
27
27
|
};
|
|
28
28
|
|
|
29
|
-
// src/common/plugin.ts
|
|
30
|
-
import path from "path";
|
|
31
|
-
import { fileURLToPath } from "url";
|
|
32
|
-
|
|
33
29
|
// src/common/prisma.ts
|
|
34
30
|
import {
|
|
35
31
|
getSchema
|
|
36
32
|
} from "@mrleebo/prisma-ast";
|
|
37
33
|
import fs2 from "fs";
|
|
38
|
-
import
|
|
34
|
+
import path from "path";
|
|
39
35
|
|
|
40
36
|
// src/common/schemas.ts
|
|
41
37
|
import { commandRegistry } from "@ingenyus/swarm";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// src/generators/api-namespace/api-namespace-generator.ts
|
|
2
2
|
import { toCamelCase as toCamelCase2 } from "@ingenyus/swarm";
|
|
3
|
-
import
|
|
3
|
+
import path7 from "path";
|
|
4
4
|
|
|
5
5
|
// src/types/constants.ts
|
|
6
6
|
var PLUGIN_NAME = "wasp";
|
|
@@ -36,7 +36,7 @@ import {
|
|
|
36
36
|
toKebabCase as toKebabCase2,
|
|
37
37
|
validateFeaturePath as validateFeaturePath3
|
|
38
38
|
} from "@ingenyus/swarm";
|
|
39
|
-
import
|
|
39
|
+
import path6 from "path";
|
|
40
40
|
|
|
41
41
|
// src/common/filesystem.ts
|
|
42
42
|
import { toPascalCase, validateFeaturePath } from "@ingenyus/swarm";
|
|
@@ -90,16 +90,12 @@ function getFeatureDir(fileSystem, featureName) {
|
|
|
90
90
|
return path.join(waspRoot, "src", normalisedPath);
|
|
91
91
|
}
|
|
92
92
|
|
|
93
|
-
// src/common/plugin.ts
|
|
94
|
-
import path2 from "path";
|
|
95
|
-
import { fileURLToPath } from "url";
|
|
96
|
-
|
|
97
93
|
// src/common/prisma.ts
|
|
98
94
|
import {
|
|
99
95
|
getSchema
|
|
100
96
|
} from "@mrleebo/prisma-ast";
|
|
101
97
|
import fs2 from "fs";
|
|
102
|
-
import
|
|
98
|
+
import path2 from "path";
|
|
103
99
|
|
|
104
100
|
// src/common/schemas.ts
|
|
105
101
|
import { commandRegistry } from "@ingenyus/swarm";
|
|
@@ -156,7 +152,7 @@ var commonSchemas = {
|
|
|
156
152
|
// src/common/templates.ts
|
|
157
153
|
import { toKebabCase } from "@ingenyus/swarm";
|
|
158
154
|
import { Eta } from "eta";
|
|
159
|
-
import
|
|
155
|
+
import path3 from "path";
|
|
160
156
|
var TemplateUtility = class {
|
|
161
157
|
constructor(fileSystem) {
|
|
162
158
|
this.fileSystem = fileSystem;
|
|
@@ -164,14 +160,14 @@ var TemplateUtility = class {
|
|
|
164
160
|
processTemplate(templatePath, replacements) {
|
|
165
161
|
const declarations = Object.keys(replacements).map((key) => `${key}=it.${key}`).join(", ");
|
|
166
162
|
const functionHeader = declarations ? `const ${declarations};` : void 0;
|
|
167
|
-
const templateDir =
|
|
163
|
+
const templateDir = path3.dirname(templatePath);
|
|
168
164
|
const eta = new Eta({
|
|
169
165
|
autoTrim: false,
|
|
170
166
|
autoEscape: false,
|
|
171
167
|
views: templateDir,
|
|
172
168
|
functionHeader
|
|
173
169
|
});
|
|
174
|
-
const templateName =
|
|
170
|
+
const templateName = path3.basename(templatePath).replace(/\.eta$/, "");
|
|
175
171
|
if (this.fileSystem.existsSync(templatePath)) {
|
|
176
172
|
return eta.render(templateName, replacements);
|
|
177
173
|
} else {
|
|
@@ -189,11 +185,11 @@ var TemplateUtility = class {
|
|
|
189
185
|
resolveTemplatePath(relativePath, generatorName, currentFileUrl) {
|
|
190
186
|
const generatorDirName = toKebabCase(generatorName);
|
|
191
187
|
const currentFilePath = new URL(currentFileUrl).pathname;
|
|
192
|
-
const currentFileDir =
|
|
193
|
-
const currentFileName =
|
|
188
|
+
const currentFileDir = path3.dirname(currentFilePath);
|
|
189
|
+
const currentFileName = path3.basename(currentFilePath);
|
|
194
190
|
const isInstalledPackage = currentFileDir.includes("node_modules") && currentFileDir.endsWith("/dist") && currentFileName === "index.js";
|
|
195
|
-
const startDir = isInstalledPackage ? currentFileDir :
|
|
196
|
-
return
|
|
191
|
+
const startDir = isInstalledPackage ? currentFileDir : path3.dirname(path3.dirname(currentFileDir));
|
|
192
|
+
return path3.join(
|
|
197
193
|
startDir,
|
|
198
194
|
"generators",
|
|
199
195
|
generatorDirName,
|
|
@@ -209,7 +205,7 @@ import {
|
|
|
209
205
|
logger as singletonLogger3,
|
|
210
206
|
validateFeaturePath as validateFeaturePath2
|
|
211
207
|
} from "@ingenyus/swarm";
|
|
212
|
-
import
|
|
208
|
+
import path5 from "path";
|
|
213
209
|
|
|
214
210
|
// src/generators/base/wasp-generator.base.ts
|
|
215
211
|
import {
|
|
@@ -225,14 +221,14 @@ import {
|
|
|
225
221
|
parseHelperMethodDefinition,
|
|
226
222
|
logger as singletonLogger
|
|
227
223
|
} from "@ingenyus/swarm";
|
|
228
|
-
import
|
|
224
|
+
import path4 from "path";
|
|
229
225
|
var WaspConfigGenerator = class {
|
|
230
226
|
constructor(logger = singletonLogger, fileSystem = realFileSystem) {
|
|
231
227
|
this.logger = logger;
|
|
232
228
|
this.fileSystem = fileSystem;
|
|
233
229
|
this.templateUtility = new TemplateUtility(fileSystem);
|
|
234
230
|
}
|
|
235
|
-
path =
|
|
231
|
+
path = path4;
|
|
236
232
|
templateUtility;
|
|
237
233
|
/**
|
|
238
234
|
* Gets the template path for feature config templates.
|
|
@@ -261,7 +257,7 @@ var WaspConfigGenerator = class {
|
|
|
261
257
|
this.logger.error(`Template not found: ${templatePath}`);
|
|
262
258
|
return;
|
|
263
259
|
}
|
|
264
|
-
const configFilePath =
|
|
260
|
+
const configFilePath = path4.join(featureDir, `feature.wasp.ts`);
|
|
265
261
|
if (this.fileSystem.existsSync(configFilePath)) {
|
|
266
262
|
this.logger.warn(`Feature config already exists: ${configFilePath}`);
|
|
267
263
|
return;
|
|
@@ -277,7 +273,7 @@ var WaspConfigGenerator = class {
|
|
|
277
273
|
*/
|
|
278
274
|
update(featurePath, declaration) {
|
|
279
275
|
const configDir = getFeatureDir(this.fileSystem, featurePath);
|
|
280
|
-
const configFilePath =
|
|
276
|
+
const configFilePath = path4.join(configDir, `feature.wasp.ts`);
|
|
281
277
|
if (!this.fileSystem.existsSync(configFilePath)) {
|
|
282
278
|
const templatePath = this.getTemplatePath("feature.wasp.eta");
|
|
283
279
|
if (!this.fileSystem.existsSync(templatePath)) {
|
|
@@ -787,18 +783,18 @@ var FeatureGenerator = class extends WaspGeneratorBase {
|
|
|
787
783
|
const { target } = args;
|
|
788
784
|
const segments = validateFeaturePath2(target);
|
|
789
785
|
const normalisedPath = normaliseFeaturePath(target);
|
|
790
|
-
const sourceRoot =
|
|
786
|
+
const sourceRoot = path5.join(findWaspRoot(this.fileSystem), "src");
|
|
791
787
|
if (segments.length > 1) {
|
|
792
788
|
const parentPath = segments.slice(0, -1).join("/");
|
|
793
789
|
const parentNormalisedPath = normaliseFeaturePath(parentPath);
|
|
794
|
-
const parentFeatureDir =
|
|
790
|
+
const parentFeatureDir = path5.join(sourceRoot, parentNormalisedPath);
|
|
795
791
|
if (!this.fileSystem.existsSync(parentFeatureDir)) {
|
|
796
792
|
handleFatalError2(
|
|
797
793
|
`Parent feature '${parentPath}' does not exist. Please create it first.`
|
|
798
794
|
);
|
|
799
795
|
}
|
|
800
796
|
}
|
|
801
|
-
const featureDir =
|
|
797
|
+
const featureDir = path5.join(sourceRoot, normalisedPath);
|
|
802
798
|
this.fileSystem.mkdirSync(featureDir, { recursive: true });
|
|
803
799
|
this.configGenerator.generate(normalisedPath);
|
|
804
800
|
this.logger.success(`Generated feature: ${normalisedPath}`);
|
|
@@ -835,7 +831,7 @@ var ComponentGeneratorBase = class extends WaspGeneratorBase {
|
|
|
835
831
|
const currentPath = pathSegments.join("/");
|
|
836
832
|
const featureName = pathSegments[pathSegments.length - 1];
|
|
837
833
|
const featureDir = getFeatureDir(this.fileSystem, currentPath);
|
|
838
|
-
const configPath =
|
|
834
|
+
const configPath = path6.join(featureDir, `feature.wasp.ts`);
|
|
839
835
|
if (this.fileSystem.existsSync(configPath)) {
|
|
840
836
|
return configPath;
|
|
841
837
|
}
|
|
@@ -908,7 +904,7 @@ var ComponentGeneratorBase = class extends WaspGeneratorBase {
|
|
|
908
904
|
const featureDir = getFeatureDir(fileSystem, normalisedPath);
|
|
909
905
|
const typeKey = type.toLowerCase();
|
|
910
906
|
const typeDirectory = TYPE_DIRECTORIES[typeKey];
|
|
911
|
-
const targetDirectory =
|
|
907
|
+
const targetDirectory = path6.join(featureDir, typeDirectory);
|
|
912
908
|
const importDirectory = `@src/${normalisedPath}/${typeDirectory}`;
|
|
913
909
|
return { targetDirectory, importDirectory };
|
|
914
910
|
}
|
|
@@ -996,7 +992,7 @@ var ApiNamespaceGenerator = class extends ComponentGeneratorBase {
|
|
|
996
992
|
}
|
|
997
993
|
async updateConfigFile(namespaceName, importDirectory, namespacePath, args, configFilePath) {
|
|
998
994
|
const { force = false } = args;
|
|
999
|
-
const importPath =
|
|
995
|
+
const importPath = path7.join(importDirectory, namespaceName);
|
|
1000
996
|
const definition = await this.getDefinition(
|
|
1001
997
|
namespaceName,
|
|
1002
998
|
importPath,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// src/generators/api-namespace/api-namespace-generator.ts
|
|
2
2
|
import { toCamelCase as toCamelCase2 } from "@ingenyus/swarm";
|
|
3
|
-
import
|
|
3
|
+
import path7 from "path";
|
|
4
4
|
|
|
5
5
|
// src/types/constants.ts
|
|
6
6
|
var PLUGIN_NAME = "wasp";
|
|
@@ -36,7 +36,7 @@ import {
|
|
|
36
36
|
toKebabCase as toKebabCase2,
|
|
37
37
|
validateFeaturePath as validateFeaturePath3
|
|
38
38
|
} from "@ingenyus/swarm";
|
|
39
|
-
import
|
|
39
|
+
import path6 from "path";
|
|
40
40
|
|
|
41
41
|
// src/common/filesystem.ts
|
|
42
42
|
import { toPascalCase, validateFeaturePath } from "@ingenyus/swarm";
|
|
@@ -90,16 +90,12 @@ function getFeatureDir(fileSystem, featureName) {
|
|
|
90
90
|
return path.join(waspRoot, "src", normalisedPath);
|
|
91
91
|
}
|
|
92
92
|
|
|
93
|
-
// src/common/plugin.ts
|
|
94
|
-
import path2 from "path";
|
|
95
|
-
import { fileURLToPath } from "url";
|
|
96
|
-
|
|
97
93
|
// src/common/prisma.ts
|
|
98
94
|
import {
|
|
99
95
|
getSchema
|
|
100
96
|
} from "@mrleebo/prisma-ast";
|
|
101
97
|
import fs2 from "fs";
|
|
102
|
-
import
|
|
98
|
+
import path2 from "path";
|
|
103
99
|
|
|
104
100
|
// src/common/schemas.ts
|
|
105
101
|
import { commandRegistry } from "@ingenyus/swarm";
|
|
@@ -156,7 +152,7 @@ var commonSchemas = {
|
|
|
156
152
|
// src/common/templates.ts
|
|
157
153
|
import { toKebabCase } from "@ingenyus/swarm";
|
|
158
154
|
import { Eta } from "eta";
|
|
159
|
-
import
|
|
155
|
+
import path3 from "path";
|
|
160
156
|
var TemplateUtility = class {
|
|
161
157
|
constructor(fileSystem) {
|
|
162
158
|
this.fileSystem = fileSystem;
|
|
@@ -164,14 +160,14 @@ var TemplateUtility = class {
|
|
|
164
160
|
processTemplate(templatePath, replacements) {
|
|
165
161
|
const declarations = Object.keys(replacements).map((key) => `${key}=it.${key}`).join(", ");
|
|
166
162
|
const functionHeader = declarations ? `const ${declarations};` : void 0;
|
|
167
|
-
const templateDir =
|
|
163
|
+
const templateDir = path3.dirname(templatePath);
|
|
168
164
|
const eta = new Eta({
|
|
169
165
|
autoTrim: false,
|
|
170
166
|
autoEscape: false,
|
|
171
167
|
views: templateDir,
|
|
172
168
|
functionHeader
|
|
173
169
|
});
|
|
174
|
-
const templateName =
|
|
170
|
+
const templateName = path3.basename(templatePath).replace(/\.eta$/, "");
|
|
175
171
|
if (this.fileSystem.existsSync(templatePath)) {
|
|
176
172
|
return eta.render(templateName, replacements);
|
|
177
173
|
} else {
|
|
@@ -189,11 +185,11 @@ var TemplateUtility = class {
|
|
|
189
185
|
resolveTemplatePath(relativePath, generatorName, currentFileUrl) {
|
|
190
186
|
const generatorDirName = toKebabCase(generatorName);
|
|
191
187
|
const currentFilePath = new URL(currentFileUrl).pathname;
|
|
192
|
-
const currentFileDir =
|
|
193
|
-
const currentFileName =
|
|
188
|
+
const currentFileDir = path3.dirname(currentFilePath);
|
|
189
|
+
const currentFileName = path3.basename(currentFilePath);
|
|
194
190
|
const isInstalledPackage = currentFileDir.includes("node_modules") && currentFileDir.endsWith("/dist") && currentFileName === "index.js";
|
|
195
|
-
const startDir = isInstalledPackage ? currentFileDir :
|
|
196
|
-
return
|
|
191
|
+
const startDir = isInstalledPackage ? currentFileDir : path3.dirname(path3.dirname(currentFileDir));
|
|
192
|
+
return path3.join(
|
|
197
193
|
startDir,
|
|
198
194
|
"generators",
|
|
199
195
|
generatorDirName,
|
|
@@ -209,7 +205,7 @@ import {
|
|
|
209
205
|
logger as singletonLogger3,
|
|
210
206
|
validateFeaturePath as validateFeaturePath2
|
|
211
207
|
} from "@ingenyus/swarm";
|
|
212
|
-
import
|
|
208
|
+
import path5 from "path";
|
|
213
209
|
|
|
214
210
|
// src/generators/base/wasp-generator.base.ts
|
|
215
211
|
import {
|
|
@@ -225,14 +221,14 @@ import {
|
|
|
225
221
|
parseHelperMethodDefinition,
|
|
226
222
|
logger as singletonLogger
|
|
227
223
|
} from "@ingenyus/swarm";
|
|
228
|
-
import
|
|
224
|
+
import path4 from "path";
|
|
229
225
|
var WaspConfigGenerator = class {
|
|
230
226
|
constructor(logger = singletonLogger, fileSystem = realFileSystem) {
|
|
231
227
|
this.logger = logger;
|
|
232
228
|
this.fileSystem = fileSystem;
|
|
233
229
|
this.templateUtility = new TemplateUtility(fileSystem);
|
|
234
230
|
}
|
|
235
|
-
path =
|
|
231
|
+
path = path4;
|
|
236
232
|
templateUtility;
|
|
237
233
|
/**
|
|
238
234
|
* Gets the template path for feature config templates.
|
|
@@ -261,7 +257,7 @@ var WaspConfigGenerator = class {
|
|
|
261
257
|
this.logger.error(`Template not found: ${templatePath}`);
|
|
262
258
|
return;
|
|
263
259
|
}
|
|
264
|
-
const configFilePath =
|
|
260
|
+
const configFilePath = path4.join(featureDir, `feature.wasp.ts`);
|
|
265
261
|
if (this.fileSystem.existsSync(configFilePath)) {
|
|
266
262
|
this.logger.warn(`Feature config already exists: ${configFilePath}`);
|
|
267
263
|
return;
|
|
@@ -277,7 +273,7 @@ var WaspConfigGenerator = class {
|
|
|
277
273
|
*/
|
|
278
274
|
update(featurePath, declaration) {
|
|
279
275
|
const configDir = getFeatureDir(this.fileSystem, featurePath);
|
|
280
|
-
const configFilePath =
|
|
276
|
+
const configFilePath = path4.join(configDir, `feature.wasp.ts`);
|
|
281
277
|
if (!this.fileSystem.existsSync(configFilePath)) {
|
|
282
278
|
const templatePath = this.getTemplatePath("feature.wasp.eta");
|
|
283
279
|
if (!this.fileSystem.existsSync(templatePath)) {
|
|
@@ -787,18 +783,18 @@ var FeatureGenerator = class extends WaspGeneratorBase {
|
|
|
787
783
|
const { target } = args;
|
|
788
784
|
const segments = validateFeaturePath2(target);
|
|
789
785
|
const normalisedPath = normaliseFeaturePath(target);
|
|
790
|
-
const sourceRoot =
|
|
786
|
+
const sourceRoot = path5.join(findWaspRoot(this.fileSystem), "src");
|
|
791
787
|
if (segments.length > 1) {
|
|
792
788
|
const parentPath = segments.slice(0, -1).join("/");
|
|
793
789
|
const parentNormalisedPath = normaliseFeaturePath(parentPath);
|
|
794
|
-
const parentFeatureDir =
|
|
790
|
+
const parentFeatureDir = path5.join(sourceRoot, parentNormalisedPath);
|
|
795
791
|
if (!this.fileSystem.existsSync(parentFeatureDir)) {
|
|
796
792
|
handleFatalError2(
|
|
797
793
|
`Parent feature '${parentPath}' does not exist. Please create it first.`
|
|
798
794
|
);
|
|
799
795
|
}
|
|
800
796
|
}
|
|
801
|
-
const featureDir =
|
|
797
|
+
const featureDir = path5.join(sourceRoot, normalisedPath);
|
|
802
798
|
this.fileSystem.mkdirSync(featureDir, { recursive: true });
|
|
803
799
|
this.configGenerator.generate(normalisedPath);
|
|
804
800
|
this.logger.success(`Generated feature: ${normalisedPath}`);
|
|
@@ -835,7 +831,7 @@ var ComponentGeneratorBase = class extends WaspGeneratorBase {
|
|
|
835
831
|
const currentPath = pathSegments.join("/");
|
|
836
832
|
const featureName = pathSegments[pathSegments.length - 1];
|
|
837
833
|
const featureDir = getFeatureDir(this.fileSystem, currentPath);
|
|
838
|
-
const configPath =
|
|
834
|
+
const configPath = path6.join(featureDir, `feature.wasp.ts`);
|
|
839
835
|
if (this.fileSystem.existsSync(configPath)) {
|
|
840
836
|
return configPath;
|
|
841
837
|
}
|
|
@@ -908,7 +904,7 @@ var ComponentGeneratorBase = class extends WaspGeneratorBase {
|
|
|
908
904
|
const featureDir = getFeatureDir(fileSystem, normalisedPath);
|
|
909
905
|
const typeKey = type.toLowerCase();
|
|
910
906
|
const typeDirectory = TYPE_DIRECTORIES[typeKey];
|
|
911
|
-
const targetDirectory =
|
|
907
|
+
const targetDirectory = path6.join(featureDir, typeDirectory);
|
|
912
908
|
const importDirectory = `@src/${normalisedPath}/${typeDirectory}`;
|
|
913
909
|
return { targetDirectory, importDirectory };
|
|
914
910
|
}
|
|
@@ -996,7 +992,7 @@ var ApiNamespaceGenerator = class extends ComponentGeneratorBase {
|
|
|
996
992
|
}
|
|
997
993
|
async updateConfigFile(namespaceName, importDirectory, namespacePath, args, configFilePath) {
|
|
998
994
|
const { force = false } = args;
|
|
999
|
-
const importPath =
|
|
995
|
+
const importPath = path7.join(importDirectory, namespaceName);
|
|
1000
996
|
const definition = await this.getDefinition(
|
|
1001
997
|
namespaceName,
|
|
1002
998
|
importPath,
|
|
@@ -14,16 +14,12 @@ var realFileSystem = {
|
|
|
14
14
|
statSync: fs.statSync
|
|
15
15
|
};
|
|
16
16
|
|
|
17
|
-
// src/common/plugin.ts
|
|
18
|
-
import path from "path";
|
|
19
|
-
import { fileURLToPath } from "url";
|
|
20
|
-
|
|
21
17
|
// src/common/prisma.ts
|
|
22
18
|
import {
|
|
23
19
|
getSchema
|
|
24
20
|
} from "@mrleebo/prisma-ast";
|
|
25
21
|
import fs2 from "fs";
|
|
26
|
-
import
|
|
22
|
+
import path from "path";
|
|
27
23
|
|
|
28
24
|
// src/common/schemas.ts
|
|
29
25
|
import { commandRegistry } from "@ingenyus/swarm";
|
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
toKebabCase as toKebabCase2,
|
|
7
7
|
validateFeaturePath as validateFeaturePath3
|
|
8
8
|
} from "@ingenyus/swarm";
|
|
9
|
-
import
|
|
9
|
+
import path6 from "path";
|
|
10
10
|
|
|
11
11
|
// src/common/filesystem.ts
|
|
12
12
|
import { toPascalCase, validateFeaturePath } from "@ingenyus/swarm";
|
|
@@ -79,16 +79,12 @@ function getFeatureDir(fileSystem, featureName) {
|
|
|
79
79
|
return path.join(waspRoot, "src", normalisedPath);
|
|
80
80
|
}
|
|
81
81
|
|
|
82
|
-
// src/common/plugin.ts
|
|
83
|
-
import path2 from "path";
|
|
84
|
-
import { fileURLToPath } from "url";
|
|
85
|
-
|
|
86
82
|
// src/common/prisma.ts
|
|
87
83
|
import {
|
|
88
84
|
getSchema
|
|
89
85
|
} from "@mrleebo/prisma-ast";
|
|
90
86
|
import fs2 from "fs";
|
|
91
|
-
import
|
|
87
|
+
import path2 from "path";
|
|
92
88
|
|
|
93
89
|
// src/common/schemas.ts
|
|
94
90
|
import { commandRegistry } from "@ingenyus/swarm";
|
|
@@ -145,7 +141,7 @@ var commonSchemas = {
|
|
|
145
141
|
// src/common/templates.ts
|
|
146
142
|
import { toKebabCase } from "@ingenyus/swarm";
|
|
147
143
|
import { Eta } from "eta";
|
|
148
|
-
import
|
|
144
|
+
import path3 from "path";
|
|
149
145
|
var TemplateUtility = class {
|
|
150
146
|
constructor(fileSystem) {
|
|
151
147
|
this.fileSystem = fileSystem;
|
|
@@ -153,14 +149,14 @@ var TemplateUtility = class {
|
|
|
153
149
|
processTemplate(templatePath, replacements) {
|
|
154
150
|
const declarations = Object.keys(replacements).map((key) => `${key}=it.${key}`).join(", ");
|
|
155
151
|
const functionHeader = declarations ? `const ${declarations};` : void 0;
|
|
156
|
-
const templateDir =
|
|
152
|
+
const templateDir = path3.dirname(templatePath);
|
|
157
153
|
const eta = new Eta({
|
|
158
154
|
autoTrim: false,
|
|
159
155
|
autoEscape: false,
|
|
160
156
|
views: templateDir,
|
|
161
157
|
functionHeader
|
|
162
158
|
});
|
|
163
|
-
const templateName =
|
|
159
|
+
const templateName = path3.basename(templatePath).replace(/\.eta$/, "");
|
|
164
160
|
if (this.fileSystem.existsSync(templatePath)) {
|
|
165
161
|
return eta.render(templateName, replacements);
|
|
166
162
|
} else {
|
|
@@ -178,11 +174,11 @@ var TemplateUtility = class {
|
|
|
178
174
|
resolveTemplatePath(relativePath, generatorName, currentFileUrl) {
|
|
179
175
|
const generatorDirName = toKebabCase(generatorName);
|
|
180
176
|
const currentFilePath = new URL(currentFileUrl).pathname;
|
|
181
|
-
const currentFileDir =
|
|
182
|
-
const currentFileName =
|
|
177
|
+
const currentFileDir = path3.dirname(currentFilePath);
|
|
178
|
+
const currentFileName = path3.basename(currentFilePath);
|
|
183
179
|
const isInstalledPackage = currentFileDir.includes("node_modules") && currentFileDir.endsWith("/dist") && currentFileName === "index.js";
|
|
184
|
-
const startDir = isInstalledPackage ? currentFileDir :
|
|
185
|
-
return
|
|
180
|
+
const startDir = isInstalledPackage ? currentFileDir : path3.dirname(path3.dirname(currentFileDir));
|
|
181
|
+
return path3.join(
|
|
186
182
|
startDir,
|
|
187
183
|
"generators",
|
|
188
184
|
generatorDirName,
|
|
@@ -198,7 +194,7 @@ import {
|
|
|
198
194
|
logger as singletonLogger3,
|
|
199
195
|
validateFeaturePath as validateFeaturePath2
|
|
200
196
|
} from "@ingenyus/swarm";
|
|
201
|
-
import
|
|
197
|
+
import path5 from "path";
|
|
202
198
|
|
|
203
199
|
// src/generators/base/wasp-generator.base.ts
|
|
204
200
|
import {
|
|
@@ -214,14 +210,14 @@ import {
|
|
|
214
210
|
parseHelperMethodDefinition,
|
|
215
211
|
logger as singletonLogger
|
|
216
212
|
} from "@ingenyus/swarm";
|
|
217
|
-
import
|
|
213
|
+
import path4 from "path";
|
|
218
214
|
var WaspConfigGenerator = class {
|
|
219
215
|
constructor(logger = singletonLogger, fileSystem = realFileSystem) {
|
|
220
216
|
this.logger = logger;
|
|
221
217
|
this.fileSystem = fileSystem;
|
|
222
218
|
this.templateUtility = new TemplateUtility(fileSystem);
|
|
223
219
|
}
|
|
224
|
-
path =
|
|
220
|
+
path = path4;
|
|
225
221
|
templateUtility;
|
|
226
222
|
/**
|
|
227
223
|
* Gets the template path for feature config templates.
|
|
@@ -250,7 +246,7 @@ var WaspConfigGenerator = class {
|
|
|
250
246
|
this.logger.error(`Template not found: ${templatePath}`);
|
|
251
247
|
return;
|
|
252
248
|
}
|
|
253
|
-
const configFilePath =
|
|
249
|
+
const configFilePath = path4.join(featureDir, `feature.wasp.ts`);
|
|
254
250
|
if (this.fileSystem.existsSync(configFilePath)) {
|
|
255
251
|
this.logger.warn(`Feature config already exists: ${configFilePath}`);
|
|
256
252
|
return;
|
|
@@ -266,7 +262,7 @@ var WaspConfigGenerator = class {
|
|
|
266
262
|
*/
|
|
267
263
|
update(featurePath, declaration) {
|
|
268
264
|
const configDir = getFeatureDir(this.fileSystem, featurePath);
|
|
269
|
-
const configFilePath =
|
|
265
|
+
const configFilePath = path4.join(configDir, `feature.wasp.ts`);
|
|
270
266
|
if (!this.fileSystem.existsSync(configFilePath)) {
|
|
271
267
|
const templatePath = this.getTemplatePath("feature.wasp.eta");
|
|
272
268
|
if (!this.fileSystem.existsSync(templatePath)) {
|
|
@@ -776,18 +772,18 @@ var FeatureGenerator = class extends WaspGeneratorBase {
|
|
|
776
772
|
const { target } = args;
|
|
777
773
|
const segments = validateFeaturePath2(target);
|
|
778
774
|
const normalisedPath = normaliseFeaturePath(target);
|
|
779
|
-
const sourceRoot =
|
|
775
|
+
const sourceRoot = path5.join(findWaspRoot(this.fileSystem), "src");
|
|
780
776
|
if (segments.length > 1) {
|
|
781
777
|
const parentPath = segments.slice(0, -1).join("/");
|
|
782
778
|
const parentNormalisedPath = normaliseFeaturePath(parentPath);
|
|
783
|
-
const parentFeatureDir =
|
|
779
|
+
const parentFeatureDir = path5.join(sourceRoot, parentNormalisedPath);
|
|
784
780
|
if (!this.fileSystem.existsSync(parentFeatureDir)) {
|
|
785
781
|
handleFatalError2(
|
|
786
782
|
`Parent feature '${parentPath}' does not exist. Please create it first.`
|
|
787
783
|
);
|
|
788
784
|
}
|
|
789
785
|
}
|
|
790
|
-
const featureDir =
|
|
786
|
+
const featureDir = path5.join(sourceRoot, normalisedPath);
|
|
791
787
|
this.fileSystem.mkdirSync(featureDir, { recursive: true });
|
|
792
788
|
this.configGenerator.generate(normalisedPath);
|
|
793
789
|
this.logger.success(`Generated feature: ${normalisedPath}`);
|
|
@@ -824,7 +820,7 @@ var ComponentGeneratorBase = class extends WaspGeneratorBase {
|
|
|
824
820
|
const currentPath = pathSegments.join("/");
|
|
825
821
|
const featureName = pathSegments[pathSegments.length - 1];
|
|
826
822
|
const featureDir = getFeatureDir(this.fileSystem, currentPath);
|
|
827
|
-
const configPath =
|
|
823
|
+
const configPath = path6.join(featureDir, `feature.wasp.ts`);
|
|
828
824
|
if (this.fileSystem.existsSync(configPath)) {
|
|
829
825
|
return configPath;
|
|
830
826
|
}
|
|
@@ -897,7 +893,7 @@ var ComponentGeneratorBase = class extends WaspGeneratorBase {
|
|
|
897
893
|
const featureDir = getFeatureDir(fileSystem, normalisedPath);
|
|
898
894
|
const typeKey = type.toLowerCase();
|
|
899
895
|
const typeDirectory = TYPE_DIRECTORIES[typeKey];
|
|
900
|
-
const targetDirectory =
|
|
896
|
+
const targetDirectory = path6.join(featureDir, typeDirectory);
|
|
901
897
|
const importDirectory = `@src/${normalisedPath}/${typeDirectory}`;
|
|
902
898
|
return { targetDirectory, importDirectory };
|
|
903
899
|
}
|
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
toKebabCase as toKebabCase2,
|
|
7
7
|
validateFeaturePath as validateFeaturePath3
|
|
8
8
|
} from "@ingenyus/swarm";
|
|
9
|
-
import
|
|
9
|
+
import path6 from "path";
|
|
10
10
|
|
|
11
11
|
// src/common/filesystem.ts
|
|
12
12
|
import { toPascalCase, validateFeaturePath } from "@ingenyus/swarm";
|
|
@@ -107,19 +107,15 @@ function getFeatureImportPath(featurePath) {
|
|
|
107
107
|
return segments.join("/");
|
|
108
108
|
}
|
|
109
109
|
|
|
110
|
-
// src/common/plugin.ts
|
|
111
|
-
import path2 from "path";
|
|
112
|
-
import { fileURLToPath } from "url";
|
|
113
|
-
|
|
114
110
|
// src/common/prisma.ts
|
|
115
111
|
import {
|
|
116
112
|
getSchema
|
|
117
113
|
} from "@mrleebo/prisma-ast";
|
|
118
114
|
import fs2 from "fs";
|
|
119
|
-
import
|
|
115
|
+
import path2 from "path";
|
|
120
116
|
async function getEntityMetadata(modelName) {
|
|
121
117
|
try {
|
|
122
|
-
const schemaPath =
|
|
118
|
+
const schemaPath = path2.join(process.cwd(), "schema.prisma");
|
|
123
119
|
const schemaContent = fs2.readFileSync(schemaPath, "utf8");
|
|
124
120
|
const schema2 = getSchema(schemaContent);
|
|
125
121
|
const model = schema2.list?.find(
|
|
@@ -294,7 +290,7 @@ var commonSchemas = {
|
|
|
294
290
|
// src/common/templates.ts
|
|
295
291
|
import { toKebabCase } from "@ingenyus/swarm";
|
|
296
292
|
import { Eta } from "eta";
|
|
297
|
-
import
|
|
293
|
+
import path3 from "path";
|
|
298
294
|
var TemplateUtility = class {
|
|
299
295
|
constructor(fileSystem) {
|
|
300
296
|
this.fileSystem = fileSystem;
|
|
@@ -302,14 +298,14 @@ var TemplateUtility = class {
|
|
|
302
298
|
processTemplate(templatePath, replacements) {
|
|
303
299
|
const declarations = Object.keys(replacements).map((key) => `${key}=it.${key}`).join(", ");
|
|
304
300
|
const functionHeader = declarations ? `const ${declarations};` : void 0;
|
|
305
|
-
const templateDir =
|
|
301
|
+
const templateDir = path3.dirname(templatePath);
|
|
306
302
|
const eta = new Eta({
|
|
307
303
|
autoTrim: false,
|
|
308
304
|
autoEscape: false,
|
|
309
305
|
views: templateDir,
|
|
310
306
|
functionHeader
|
|
311
307
|
});
|
|
312
|
-
const templateName =
|
|
308
|
+
const templateName = path3.basename(templatePath).replace(/\.eta$/, "");
|
|
313
309
|
if (this.fileSystem.existsSync(templatePath)) {
|
|
314
310
|
return eta.render(templateName, replacements);
|
|
315
311
|
} else {
|
|
@@ -327,11 +323,11 @@ var TemplateUtility = class {
|
|
|
327
323
|
resolveTemplatePath(relativePath, generatorName, currentFileUrl) {
|
|
328
324
|
const generatorDirName = toKebabCase(generatorName);
|
|
329
325
|
const currentFilePath = new URL(currentFileUrl).pathname;
|
|
330
|
-
const currentFileDir =
|
|
331
|
-
const currentFileName =
|
|
326
|
+
const currentFileDir = path3.dirname(currentFilePath);
|
|
327
|
+
const currentFileName = path3.basename(currentFilePath);
|
|
332
328
|
const isInstalledPackage = currentFileDir.includes("node_modules") && currentFileDir.endsWith("/dist") && currentFileName === "index.js";
|
|
333
|
-
const startDir = isInstalledPackage ? currentFileDir :
|
|
334
|
-
return
|
|
329
|
+
const startDir = isInstalledPackage ? currentFileDir : path3.dirname(path3.dirname(currentFileDir));
|
|
330
|
+
return path3.join(
|
|
335
331
|
startDir,
|
|
336
332
|
"generators",
|
|
337
333
|
generatorDirName,
|
|
@@ -347,7 +343,7 @@ import {
|
|
|
347
343
|
logger as singletonLogger3,
|
|
348
344
|
validateFeaturePath as validateFeaturePath2
|
|
349
345
|
} from "@ingenyus/swarm";
|
|
350
|
-
import
|
|
346
|
+
import path5 from "path";
|
|
351
347
|
|
|
352
348
|
// src/generators/base/wasp-generator.base.ts
|
|
353
349
|
import {
|
|
@@ -363,14 +359,14 @@ import {
|
|
|
363
359
|
parseHelperMethodDefinition,
|
|
364
360
|
logger as singletonLogger
|
|
365
361
|
} from "@ingenyus/swarm";
|
|
366
|
-
import
|
|
362
|
+
import path4 from "path";
|
|
367
363
|
var WaspConfigGenerator = class {
|
|
368
364
|
constructor(logger = singletonLogger, fileSystem = realFileSystem) {
|
|
369
365
|
this.logger = logger;
|
|
370
366
|
this.fileSystem = fileSystem;
|
|
371
367
|
this.templateUtility = new TemplateUtility(fileSystem);
|
|
372
368
|
}
|
|
373
|
-
path =
|
|
369
|
+
path = path4;
|
|
374
370
|
templateUtility;
|
|
375
371
|
/**
|
|
376
372
|
* Gets the template path for feature config templates.
|
|
@@ -399,7 +395,7 @@ var WaspConfigGenerator = class {
|
|
|
399
395
|
this.logger.error(`Template not found: ${templatePath}`);
|
|
400
396
|
return;
|
|
401
397
|
}
|
|
402
|
-
const configFilePath =
|
|
398
|
+
const configFilePath = path4.join(featureDir, `feature.wasp.ts`);
|
|
403
399
|
if (this.fileSystem.existsSync(configFilePath)) {
|
|
404
400
|
this.logger.warn(`Feature config already exists: ${configFilePath}`);
|
|
405
401
|
return;
|
|
@@ -415,7 +411,7 @@ var WaspConfigGenerator = class {
|
|
|
415
411
|
*/
|
|
416
412
|
update(featurePath, declaration) {
|
|
417
413
|
const configDir = getFeatureDir(this.fileSystem, featurePath);
|
|
418
|
-
const configFilePath =
|
|
414
|
+
const configFilePath = path4.join(configDir, `feature.wasp.ts`);
|
|
419
415
|
if (!this.fileSystem.existsSync(configFilePath)) {
|
|
420
416
|
const templatePath = this.getTemplatePath("feature.wasp.eta");
|
|
421
417
|
if (!this.fileSystem.existsSync(templatePath)) {
|
|
@@ -925,18 +921,18 @@ var FeatureGenerator = class extends WaspGeneratorBase {
|
|
|
925
921
|
const { target } = args;
|
|
926
922
|
const segments = validateFeaturePath2(target);
|
|
927
923
|
const normalisedPath = normaliseFeaturePath(target);
|
|
928
|
-
const sourceRoot =
|
|
924
|
+
const sourceRoot = path5.join(findWaspRoot(this.fileSystem), "src");
|
|
929
925
|
if (segments.length > 1) {
|
|
930
926
|
const parentPath = segments.slice(0, -1).join("/");
|
|
931
927
|
const parentNormalisedPath = normaliseFeaturePath(parentPath);
|
|
932
|
-
const parentFeatureDir =
|
|
928
|
+
const parentFeatureDir = path5.join(sourceRoot, parentNormalisedPath);
|
|
933
929
|
if (!this.fileSystem.existsSync(parentFeatureDir)) {
|
|
934
930
|
handleFatalError2(
|
|
935
931
|
`Parent feature '${parentPath}' does not exist. Please create it first.`
|
|
936
932
|
);
|
|
937
933
|
}
|
|
938
934
|
}
|
|
939
|
-
const featureDir =
|
|
935
|
+
const featureDir = path5.join(sourceRoot, normalisedPath);
|
|
940
936
|
this.fileSystem.mkdirSync(featureDir, { recursive: true });
|
|
941
937
|
this.configGenerator.generate(normalisedPath);
|
|
942
938
|
this.logger.success(`Generated feature: ${normalisedPath}`);
|
|
@@ -973,7 +969,7 @@ var ComponentGeneratorBase = class extends WaspGeneratorBase {
|
|
|
973
969
|
const currentPath = pathSegments.join("/");
|
|
974
970
|
const featureName = pathSegments[pathSegments.length - 1];
|
|
975
971
|
const featureDir = getFeatureDir(this.fileSystem, currentPath);
|
|
976
|
-
const configPath =
|
|
972
|
+
const configPath = path6.join(featureDir, `feature.wasp.ts`);
|
|
977
973
|
if (this.fileSystem.existsSync(configPath)) {
|
|
978
974
|
return configPath;
|
|
979
975
|
}
|
|
@@ -1046,7 +1042,7 @@ var ComponentGeneratorBase = class extends WaspGeneratorBase {
|
|
|
1046
1042
|
const featureDir = getFeatureDir(fileSystem, normalisedPath);
|
|
1047
1043
|
const typeKey = type.toLowerCase();
|
|
1048
1044
|
const typeDirectory = TYPE_DIRECTORIES[typeKey];
|
|
1049
|
-
const targetDirectory =
|
|
1045
|
+
const targetDirectory = path6.join(featureDir, typeDirectory);
|
|
1050
1046
|
const importDirectory = `@src/${normalisedPath}/${typeDirectory}`;
|
|
1051
1047
|
return { targetDirectory, importDirectory };
|
|
1052
1048
|
}
|