@lark-apaas/devtool-kits 1.2.0 → 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/error.html +23 -194
- package/dist/index.cjs +38 -42
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +38 -42
- 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");
|
|
@@ -1356,17 +1359,10 @@ function checkForErrors(logs) {
|
|
|
1356
1359
|
return false;
|
|
1357
1360
|
}
|
|
1358
1361
|
__name(checkForErrors, "checkForErrors");
|
|
1359
|
-
function
|
|
1360
|
-
|
|
1361
|
-
if (errorLogs.length > 0) {
|
|
1362
|
-
logsText = errorLogs.join("\n");
|
|
1363
|
-
} else {
|
|
1364
|
-
logsText = "\u672A\u627E\u5230\u76F8\u5173\u9519\u8BEF\u65E5\u5FD7";
|
|
1365
|
-
}
|
|
1366
|
-
return template.replace("{{.errorData.message}}", `\u670D\u52A1\u542F\u52A8\u5F02\u5E38\uFF0C\u8BF7\u6839\u636E\u65E5\u5FD7\u4FEE\u590D\u76F8\u5173\u95EE\u9898
|
|
1367
|
-
${JSON.stringify(logsText)}`).replace("{{.clientBasePath}}", clientBasePath);
|
|
1362
|
+
function injectTemplateData(template, clientBasePath) {
|
|
1363
|
+
return template.replace("{{.clientBasePath}}", clientBasePath);
|
|
1368
1364
|
}
|
|
1369
|
-
__name(
|
|
1365
|
+
__name(injectTemplateData, "injectTemplateData");
|
|
1370
1366
|
function handleDevProxyError(err, req, res, options) {
|
|
1371
1367
|
const { logDir = path3.join(process.cwd(), "logs"), maxErrorLogs = 100, logFileName = "server.log", retryTimeout = 5e3, retryInterval = 500, target = `http://localhost:${process.env.SERVER_PORT || 3e3}`, clientBasePath = process.env.CLIENT_BASE_PATH || "/" } = options || {};
|
|
1372
1368
|
const clientBasePathWithoutSlash = normalizeBasePath(clientBasePath);
|
|
@@ -1378,7 +1374,7 @@ function handleDevProxyError(err, req, res, options) {
|
|
|
1378
1374
|
(async () => {
|
|
1379
1375
|
try {
|
|
1380
1376
|
const isConnError = isConnectionError(err);
|
|
1381
|
-
const {
|
|
1377
|
+
const { hasCompileError } = await readRecentErrorLogs(logDir, maxErrorLogs, logFileName);
|
|
1382
1378
|
if (isConnError && !hasCompileError) {
|
|
1383
1379
|
console.log("[Proxy Error]: Connection error without compile errors, possibly server restarting...");
|
|
1384
1380
|
try {
|
|
@@ -1402,7 +1398,7 @@ function handleDevProxyError(err, req, res, options) {
|
|
|
1402
1398
|
console.log("[Proxy Error]: Compile error or non-connection error, showing error page");
|
|
1403
1399
|
}
|
|
1404
1400
|
const template = getErrorHtmlTemplate();
|
|
1405
|
-
const html =
|
|
1401
|
+
const html = injectTemplateData(template, clientBasePathWithoutSlash);
|
|
1406
1402
|
res.writeHead(200, {
|
|
1407
1403
|
"Content-Type": "text/html; charset=utf-8",
|
|
1408
1404
|
"Cache-Control": "no-cache, no-store, must-revalidate",
|