@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.js
CHANGED
|
@@ -1147,36 +1147,39 @@ async function parseAndGenerateNestResourceTemplate(options) {
|
|
|
1147
1147
|
tsConfigFilePath: options.tsConfigFilePath
|
|
1148
1148
|
});
|
|
1149
1149
|
const tables = parser.parseSchemaFile(options.schemaFilePath);
|
|
1150
|
-
|
|
1151
|
-
console.
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
}
|
|
1150
|
+
if (tables.length === 0) {
|
|
1151
|
+
console.warn("\u672A\u89E3\u6790\u5230\u4EFB\u4F55\u6570\u636E\u5E93\u8868\uFF0C\u65E0\u9700\u751F\u6210 Nest.js \u6A21\u5757\u6A21\u677F");
|
|
1152
|
+
return;
|
|
1153
|
+
}
|
|
1154
|
+
const table = tables[0];
|
|
1155
|
+
console.info(`\u751F\u6210 Nest.js ${table.variableName} \u6A21\u5757`);
|
|
1156
|
+
const routePath = toKebabCase(table.variableName);
|
|
1157
|
+
const moduleDir = join(options.moduleOutputDir, routePath);
|
|
1158
|
+
if (existsSync(moduleDir)) {
|
|
1159
|
+
console.info(`Nest.js \u6A21\u5757 ${routePath} \u5DF2\u5B58\u5728\uFF0C\u8DF3\u8FC7\u751F\u6210\u4EE3\u7801`);
|
|
1160
|
+
return;
|
|
1161
|
+
}
|
|
1162
|
+
const dto = generateDTO(table);
|
|
1163
|
+
const controller = generateController(table);
|
|
1164
|
+
const service = generateService(table);
|
|
1165
|
+
const moduleFilePath = join(moduleDir, `${routePath}.module.ts`);
|
|
1166
|
+
const module = generateModule(table);
|
|
1167
|
+
try {
|
|
1168
|
+
await mkdir(moduleDir, {
|
|
1169
|
+
recursive: true
|
|
1170
|
+
});
|
|
1171
|
+
await mkdir(join(moduleDir, "dtos"), {
|
|
1172
|
+
recursive: true
|
|
1173
|
+
});
|
|
1174
|
+
await writeFile(join(moduleDir, "dtos", `${routePath}.dto.ts`), dto);
|
|
1175
|
+
await writeFile(join(moduleDir, `${routePath}.controller.ts`), controller);
|
|
1176
|
+
await writeFile(join(moduleDir, `${routePath}.service.ts`), service);
|
|
1177
|
+
await writeFile(moduleFilePath, module);
|
|
1178
|
+
} catch (err) {
|
|
1179
|
+
console.error(`\u751F\u6210 Nest.js ${routePath} \u6A21\u5757\u5931\u8D25: ${err.message}`);
|
|
1180
|
+
await rm(moduleDir, {
|
|
1181
|
+
recursive: true
|
|
1182
|
+
});
|
|
1180
1183
|
}
|
|
1181
1184
|
}
|
|
1182
1185
|
__name(parseAndGenerateNestResourceTemplate, "parseAndGenerateNestResourceTemplate");
|