wlmaker 1.2.11 → 1.2.12
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/cli.mjs +17 -27
- package/package.json +1 -1
package/dist/cli.mjs
CHANGED
|
@@ -1112,22 +1112,6 @@ function injectMethod(filePath, className, methodCode) {
|
|
|
1112
1112
|
const newContent = content.slice(0, classEnd) + "\n" + indentedMethod + "\n" + content.slice(classEnd);
|
|
1113
1113
|
fs8.writeFileSync(filePath, newContent);
|
|
1114
1114
|
}
|
|
1115
|
-
function injectImport(filePath, importLine) {
|
|
1116
|
-
const content = fs8.readFileSync(filePath, "utf8");
|
|
1117
|
-
if (content.includes(importLine.trim())) {
|
|
1118
|
-
return;
|
|
1119
|
-
}
|
|
1120
|
-
const importRegex = /^import\s+[^;]+;/gm;
|
|
1121
|
-
const imports = [...content.matchAll(importRegex)];
|
|
1122
|
-
if (imports.length > 0) {
|
|
1123
|
-
const lastImport = imports[imports.length - 1];
|
|
1124
|
-
const insertPos = lastImport.index + lastImport[0].length;
|
|
1125
|
-
const newContent = content.slice(0, insertPos) + "\n" + importLine + content.slice(insertPos);
|
|
1126
|
-
fs8.writeFileSync(filePath, newContent);
|
|
1127
|
-
} else {
|
|
1128
|
-
fs8.writeFileSync(filePath, importLine + "\n\n" + content);
|
|
1129
|
-
}
|
|
1130
|
-
}
|
|
1131
1115
|
function injectExport(filePath, exportLine) {
|
|
1132
1116
|
let content = "";
|
|
1133
1117
|
if (fs8.existsSync(filePath)) {
|
|
@@ -1199,8 +1183,6 @@ async function createEndpoint(options) {
|
|
|
1199
1183
|
modelType
|
|
1200
1184
|
);
|
|
1201
1185
|
injectMethod(bffPath, extractClassName(bffPath), method);
|
|
1202
|
-
const modelImport = `import 'package:${options.projectName}/data/models/${feature}/${useCaseSnake}_model.dart';`;
|
|
1203
|
-
injectImport(bffPath, modelImport);
|
|
1204
1186
|
} else {
|
|
1205
1187
|
console.log(chalk4.yellow(` \u26A0 BFF API file not found: ${bffPath}`));
|
|
1206
1188
|
}
|
|
@@ -1225,8 +1207,6 @@ async function createEndpoint(options) {
|
|
|
1225
1207
|
methodParamsForSignature
|
|
1226
1208
|
);
|
|
1227
1209
|
injectMethod(repoIfacePath, repositoryInterfaceName, ifaceMethod);
|
|
1228
|
-
const entityImport = `import 'package:${options.projectName}/domain/entities/${feature}/${useCaseSnake}_entity.dart';`;
|
|
1229
|
-
injectImport(repoIfacePath, entityImport);
|
|
1230
1210
|
} else {
|
|
1231
1211
|
console.log(chalk4.yellow(` \u26A0 Repository interface not found: ${repoIfacePath}`));
|
|
1232
1212
|
}
|
|
@@ -1655,13 +1635,23 @@ async function resolveEndpointProject() {
|
|
|
1655
1635
|
s.start("Finding BFF package...");
|
|
1656
1636
|
const monorepoRoot = findMonorepoRoot(process.cwd());
|
|
1657
1637
|
if (monorepoRoot) {
|
|
1658
|
-
const
|
|
1659
|
-
const
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1638
|
+
const packageBases = ["packages", "packages/features"];
|
|
1639
|
+
for (const base of packageBases) {
|
|
1640
|
+
const baseDir = path9.join(monorepoRoot, base);
|
|
1641
|
+
if (!fs10.existsSync(baseDir)) continue;
|
|
1642
|
+
const entries = fs10.readdirSync(baseDir, { withFileTypes: true });
|
|
1643
|
+
for (const entry of entries) {
|
|
1644
|
+
if (!entry.isDirectory()) continue;
|
|
1645
|
+
const candidate = path9.join(baseDir, entry.name);
|
|
1646
|
+
if (!fs10.existsSync(path9.join(candidate, "pubspec.yaml"))) continue;
|
|
1647
|
+
if (fs10.existsSync(path9.join(candidate, "lib", "data", "api", "bff"))) {
|
|
1648
|
+
const project = analyzeProject(candidate);
|
|
1649
|
+
if (project) {
|
|
1650
|
+
s.stop(`Using ${chalk5.green(project.projectName)}`);
|
|
1651
|
+
return project;
|
|
1652
|
+
}
|
|
1653
|
+
}
|
|
1654
|
+
}
|
|
1665
1655
|
}
|
|
1666
1656
|
}
|
|
1667
1657
|
const cwdProject = analyzeProject(process.cwd());
|