@lark-apaas/devtool-kits 1.2.1 → 1.2.2
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/index.cjs +33 -30
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +33 -30
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1188,36 +1188,39 @@ async function parseAndGenerateNestResourceTemplate(options) {
|
|
|
1188
1188
|
tsConfigFilePath: options.tsConfigFilePath
|
|
1189
1189
|
});
|
|
1190
1190
|
const tables = parser.parseSchemaFile(options.schemaFilePath);
|
|
1191
|
-
|
|
1192
|
-
console.
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
}
|
|
1191
|
+
if (tables.length === 0) {
|
|
1192
|
+
console.warn("\u672A\u89E3\u6790\u5230\u4EFB\u4F55\u6570\u636E\u5E93\u8868\uFF0C\u65E0\u9700\u751F\u6210 Nest.js \u6A21\u5757\u6A21\u677F");
|
|
1193
|
+
return;
|
|
1194
|
+
}
|
|
1195
|
+
const table = tables[0];
|
|
1196
|
+
console.info(`\u751F\u6210 Nest.js ${table.variableName} \u6A21\u5757`);
|
|
1197
|
+
const routePath = toKebabCase(table.variableName);
|
|
1198
|
+
const moduleDir = (0, import_path.join)(options.moduleOutputDir, routePath);
|
|
1199
|
+
if ((0, import_fs.existsSync)(moduleDir)) {
|
|
1200
|
+
console.info(`Nest.js \u6A21\u5757 ${routePath} \u5DF2\u5B58\u5728\uFF0C\u8DF3\u8FC7\u751F\u6210\u4EE3\u7801`);
|
|
1201
|
+
return;
|
|
1202
|
+
}
|
|
1203
|
+
const dto = generateDTO(table);
|
|
1204
|
+
const controller = generateController(table);
|
|
1205
|
+
const service = generateService(table);
|
|
1206
|
+
const moduleFilePath = (0, import_path.join)(moduleDir, `${routePath}.module.ts`);
|
|
1207
|
+
const module2 = generateModule(table);
|
|
1208
|
+
try {
|
|
1209
|
+
await (0, import_promises.mkdir)(moduleDir, {
|
|
1210
|
+
recursive: true
|
|
1211
|
+
});
|
|
1212
|
+
await (0, import_promises.mkdir)((0, import_path.join)(moduleDir, "dtos"), {
|
|
1213
|
+
recursive: true
|
|
1214
|
+
});
|
|
1215
|
+
await (0, import_promises.writeFile)((0, import_path.join)(moduleDir, "dtos", `${routePath}.dto.ts`), dto);
|
|
1216
|
+
await (0, import_promises.writeFile)((0, import_path.join)(moduleDir, `${routePath}.controller.ts`), controller);
|
|
1217
|
+
await (0, import_promises.writeFile)((0, import_path.join)(moduleDir, `${routePath}.service.ts`), service);
|
|
1218
|
+
await (0, import_promises.writeFile)(moduleFilePath, module2);
|
|
1219
|
+
} catch (err) {
|
|
1220
|
+
console.error(`\u751F\u6210 Nest.js ${routePath} \u6A21\u5757\u5931\u8D25: ${err.message}`);
|
|
1221
|
+
await (0, import_promises.rm)(moduleDir, {
|
|
1222
|
+
recursive: true
|
|
1223
|
+
});
|
|
1221
1224
|
}
|
|
1222
1225
|
}
|
|
1223
1226
|
__name(parseAndGenerateNestResourceTemplate, "parseAndGenerateNestResourceTemplate");
|