@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 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
- for (const table of tables) {
1192
- console.info(`\u751F\u6210 Nest.js ${table.variableName} \u6A21\u5757`);
1193
- const routePath = toKebabCase(table.variableName);
1194
- const moduleDir = (0, import_path.join)(options.moduleOutputDir, routePath);
1195
- if ((0, import_fs.existsSync)(moduleDir)) {
1196
- console.info(`Nest.js \u6A21\u5757 ${routePath} \u5DF2\u5B58\u5728\uFF0C\u8DF3\u8FC7\u751F\u6210\u4EE3\u7801`);
1197
- continue;
1198
- }
1199
- const dto = generateDTO(table);
1200
- const controller = generateController(table);
1201
- const service = generateService(table);
1202
- const moduleFilePath = (0, import_path.join)(moduleDir, `${routePath}.module.ts`);
1203
- const module2 = generateModule(table);
1204
- try {
1205
- await (0, import_promises.mkdir)(moduleDir, {
1206
- recursive: true
1207
- });
1208
- await (0, import_promises.mkdir)((0, import_path.join)(moduleDir, "dtos"), {
1209
- recursive: true
1210
- });
1211
- await (0, import_promises.writeFile)((0, import_path.join)(moduleDir, "dtos", `${routePath}.dto.ts`), dto);
1212
- await (0, import_promises.writeFile)((0, import_path.join)(moduleDir, `${routePath}.controller.ts`), controller);
1213
- await (0, import_promises.writeFile)((0, import_path.join)(moduleDir, `${routePath}.service.ts`), service);
1214
- await (0, import_promises.writeFile)(moduleFilePath, module2);
1215
- } catch (err) {
1216
- console.error(`\u751F\u6210 Nest.js ${routePath} \u6A21\u5757\u5931\u8D25: ${err.message}`);
1217
- await (0, import_promises.rm)(moduleDir, {
1218
- recursive: true
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");