@lark-apaas/devtool-kits 1.2.2 → 1.2.4
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 +7 -3
- package/dist/index.cjs +25 -16
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +25 -16
- package/dist/index.js.map +1 -1
- package/package.json +2 -1
package/dist/error.html
CHANGED
|
@@ -171,15 +171,19 @@
|
|
|
171
171
|
// 获取父窗口 origin
|
|
172
172
|
function getPreviewParentOrigin() {
|
|
173
173
|
const { origin } = window.location;
|
|
174
|
-
//
|
|
174
|
+
// force BOE环境
|
|
175
|
+
if (origin.includes('force.byted.org')) {
|
|
176
|
+
return 'https://force.feishu-boe.cn';
|
|
177
|
+
}
|
|
178
|
+
// MIAODA 线上环境
|
|
175
179
|
if (origin.includes('feishuapp.cn') || origin.includes('miaoda.feishuapp.net')) {
|
|
176
180
|
return 'https://miaoda.feishu.cn';
|
|
177
181
|
}
|
|
178
|
-
// PRE 环境
|
|
182
|
+
// MIAODA PRE 环境
|
|
179
183
|
if (origin.includes('fsapp.kundou.cn') || origin.includes('miaoda-pre.feishuapp.net')) {
|
|
180
184
|
return 'https://miaoda.feishu-pre.cn';
|
|
181
185
|
}
|
|
182
|
-
// BOE 环境
|
|
186
|
+
// MIAODA BOE 环境
|
|
183
187
|
return 'https://miaoda.feishu-boe.cn';
|
|
184
188
|
}
|
|
185
189
|
|
package/dist/index.cjs
CHANGED
|
@@ -555,6 +555,9 @@ function postprocessDrizzleSchema(targetPath) {
|
|
|
555
555
|
}
|
|
556
556
|
__name(postprocessDrizzleSchema, "postprocessDrizzleSchema");
|
|
557
557
|
|
|
558
|
+
// src/helpers/gen-nest-resource/generator.ts
|
|
559
|
+
var import_inflection = require("inflection");
|
|
560
|
+
|
|
558
561
|
// src/helpers/gen-nest-resource/utils.ts
|
|
559
562
|
function mapDrizzleTypeToTS(field) {
|
|
560
563
|
const typeMap = {
|
|
@@ -632,6 +635,10 @@ function toKebabCase(str) {
|
|
|
632
635
|
return str.replace(/([a-z])([A-Z])/g, "$1-$2").toLowerCase().replace(/[_\s]/g, "-");
|
|
633
636
|
}
|
|
634
637
|
__name(toKebabCase, "toKebabCase");
|
|
638
|
+
function toSnakeCase(str) {
|
|
639
|
+
return str.replace(/([a-z])([A-Z])/g, "$1_$2").toLowerCase().replace(/[-\s]/g, "_");
|
|
640
|
+
}
|
|
641
|
+
__name(toSnakeCase, "toSnakeCase");
|
|
635
642
|
|
|
636
643
|
// src/helpers/gen-nest-resource/generator.ts
|
|
637
644
|
function generateDTO(table) {
|
|
@@ -761,7 +768,8 @@ function generateValidationDecorators(field, { isUpdate = false, isResponse = fa
|
|
|
761
768
|
__name(generateValidationDecorators, "generateValidationDecorators");
|
|
762
769
|
function generateController(table) {
|
|
763
770
|
const className = toPascalCase(table.variableName);
|
|
764
|
-
const routePath = toKebabCase(table.variableName);
|
|
771
|
+
const routePath = toKebabCase((0, import_inflection.pluralize)(table.variableName));
|
|
772
|
+
const filePath = toSnakeCase(table.variableName);
|
|
765
773
|
const pkField = table.fields.find((f) => f.isPrimaryKey);
|
|
766
774
|
const pkType = pkField ? mapDrizzleTypeToTS(pkField) : "string";
|
|
767
775
|
const pkName = pkField ? pkField.name : "id";
|
|
@@ -787,8 +795,8 @@ import {
|
|
|
787
795
|
Create${className}Dto,
|
|
788
796
|
Update${className}Dto,
|
|
789
797
|
${className}ResponseDto
|
|
790
|
-
} from './dtos/${
|
|
791
|
-
import { ${className}Service } from './${
|
|
798
|
+
} from './dtos/${filePath}.dto';
|
|
799
|
+
import { ${className}Service } from './${filePath}.service';
|
|
792
800
|
|
|
793
801
|
@ApiTags('${toPascalCase(table.variableName)}')
|
|
794
802
|
@Controller('api/${routePath}')
|
|
@@ -861,7 +869,7 @@ export class ${className}Controller {
|
|
|
861
869
|
__name(generateController, "generateController");
|
|
862
870
|
function generateService(table) {
|
|
863
871
|
const className = toPascalCase(table.variableName);
|
|
864
|
-
const
|
|
872
|
+
const filePath = toSnakeCase(table.variableName);
|
|
865
873
|
const pkField = table.fields.find((f) => f.isPrimaryKey);
|
|
866
874
|
const pkType = pkField ? mapDrizzleTypeToTS(pkField) : "string";
|
|
867
875
|
const pkName = pkField ? pkField.name : "id";
|
|
@@ -875,7 +883,7 @@ import {
|
|
|
875
883
|
Create${className}Dto,
|
|
876
884
|
Update${className}Dto,
|
|
877
885
|
${className}ResponseDto
|
|
878
|
-
} from './dtos/${
|
|
886
|
+
} from './dtos/${filePath}.dto';
|
|
879
887
|
|
|
880
888
|
@Injectable()
|
|
881
889
|
export class ${className}Service {
|
|
@@ -952,11 +960,11 @@ export class ${className}Service {
|
|
|
952
960
|
__name(generateService, "generateService");
|
|
953
961
|
function generateModule(table) {
|
|
954
962
|
const className = toPascalCase(table.variableName);
|
|
955
|
-
const
|
|
963
|
+
const filePath = toSnakeCase(table.variableName);
|
|
956
964
|
const module2 = `
|
|
957
965
|
import { Module } from '@nestjs/common';
|
|
958
|
-
import { ${className}Controller } from './${
|
|
959
|
-
import { ${className}Service } from './${
|
|
966
|
+
import { ${className}Controller } from './${filePath}.controller';
|
|
967
|
+
import { ${className}Service } from './${filePath}.service';
|
|
960
968
|
|
|
961
969
|
@Module({
|
|
962
970
|
controllers: [${className}Controller],
|
|
@@ -1192,18 +1200,19 @@ async function parseAndGenerateNestResourceTemplate(options) {
|
|
|
1192
1200
|
console.warn("\u672A\u89E3\u6790\u5230\u4EFB\u4F55\u6570\u636E\u5E93\u8868\uFF0C\u65E0\u9700\u751F\u6210 Nest.js \u6A21\u5757\u6A21\u677F");
|
|
1193
1201
|
return;
|
|
1194
1202
|
}
|
|
1203
|
+
tables.sort((a, b) => b.variableName.length - a.variableName.length);
|
|
1195
1204
|
const table = tables[0];
|
|
1196
1205
|
console.info(`\u751F\u6210 Nest.js ${table.variableName} \u6A21\u5757`);
|
|
1197
|
-
const
|
|
1198
|
-
const moduleDir = (0, import_path.join)(options.moduleOutputDir,
|
|
1206
|
+
const filePath = toSnakeCase(table.variableName);
|
|
1207
|
+
const moduleDir = (0, import_path.join)(options.moduleOutputDir, filePath);
|
|
1199
1208
|
if ((0, import_fs.existsSync)(moduleDir)) {
|
|
1200
|
-
console.info(`Nest.js \u6A21\u5757 ${
|
|
1209
|
+
console.info(`Nest.js \u6A21\u5757 ${filePath} \u5DF2\u5B58\u5728\uFF0C\u8DF3\u8FC7\u751F\u6210\u4EE3\u7801`);
|
|
1201
1210
|
return;
|
|
1202
1211
|
}
|
|
1203
1212
|
const dto = generateDTO(table);
|
|
1204
1213
|
const controller = generateController(table);
|
|
1205
1214
|
const service = generateService(table);
|
|
1206
|
-
const moduleFilePath = (0, import_path.join)(moduleDir, `${
|
|
1215
|
+
const moduleFilePath = (0, import_path.join)(moduleDir, `${filePath}.module.ts`);
|
|
1207
1216
|
const module2 = generateModule(table);
|
|
1208
1217
|
try {
|
|
1209
1218
|
await (0, import_promises.mkdir)(moduleDir, {
|
|
@@ -1212,12 +1221,12 @@ async function parseAndGenerateNestResourceTemplate(options) {
|
|
|
1212
1221
|
await (0, import_promises.mkdir)((0, import_path.join)(moduleDir, "dtos"), {
|
|
1213
1222
|
recursive: true
|
|
1214
1223
|
});
|
|
1215
|
-
await (0, import_promises.writeFile)((0, import_path.join)(moduleDir, "dtos", `${
|
|
1216
|
-
await (0, import_promises.writeFile)((0, import_path.join)(moduleDir, `${
|
|
1217
|
-
await (0, import_promises.writeFile)((0, import_path.join)(moduleDir, `${
|
|
1224
|
+
await (0, import_promises.writeFile)((0, import_path.join)(moduleDir, "dtos", `${filePath}.dto.ts`), dto);
|
|
1225
|
+
await (0, import_promises.writeFile)((0, import_path.join)(moduleDir, `${filePath}.controller.ts`), controller);
|
|
1226
|
+
await (0, import_promises.writeFile)((0, import_path.join)(moduleDir, `${filePath}.service.ts`), service);
|
|
1218
1227
|
await (0, import_promises.writeFile)(moduleFilePath, module2);
|
|
1219
1228
|
} catch (err) {
|
|
1220
|
-
console.error(`\u751F\u6210 Nest.js ${
|
|
1229
|
+
console.error(`\u751F\u6210 Nest.js ${filePath} \u6A21\u5757\u5931\u8D25: ${err.message}`);
|
|
1221
1230
|
await (0, import_promises.rm)(moduleDir, {
|
|
1222
1231
|
recursive: true
|
|
1223
1232
|
});
|