@biuxiu/codegen 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +11 -0
- package/dist/code/nest.d.ts +11 -0
- package/dist/code/nest.js +229 -0
- package/dist/compile.d.ts +1 -0
- package/dist/compile.js +58 -0
- package/dist/config.d.ts +11 -0
- package/dist/config.js +53 -0
- package/dist/format/api.d.ts +8 -0
- package/dist/format/api.js +122 -0
- package/dist/format/base.d.ts +10 -0
- package/dist/format/base.js +56 -0
- package/dist/format/dto.d.ts +8 -0
- package/dist/format/dto.js +116 -0
- package/dist/format/entity.d.ts +7 -0
- package/dist/format/entity.js +68 -0
- package/dist/format/service.d.ts +8 -0
- package/dist/format/service.js +93 -0
- package/dist/gen-type.d.ts +1 -0
- package/dist/gen-type.js +66 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +48 -0
- package/dist/libs/index.d.ts +1 -0
- package/dist/libs/index.js +30 -0
- package/dist/libs/nest-lib.d.ts +5 -0
- package/dist/libs/nest-lib.js +41 -0
- package/dist/libs/vue-lib.d.ts +1 -0
- package/dist/libs/vue-lib.js +30 -0
- package/dist/render.d.ts +3 -0
- package/dist/render.js +32 -0
- package/dist/types.d.ts +28 -0
- package/dist/types.js +16 -0
- package/dist/util.d.ts +2 -0
- package/dist/util.js +48 -0
- package/package.json +39 -0
- package/pkg/README.md +11 -0
- package/sources/base-type.txt +6 -0
- package/sources/controller.btpl +8 -0
- package/sources/create-dto.btpl +4 -0
- package/sources/entity.btpl +8 -0
- package/sources/module.btpl +13 -0
- package/sources/nest-type.txt +88 -0
- package/sources/service.btpl +11 -0
- package/sources/update-dto.btpl +4 -0
- package/sources/vue-type.txt +27 -0
@@ -0,0 +1,116 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __defProp = Object.defineProperty;
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
6
|
+
var __export = (target, all) => {
|
7
|
+
for (var name in all)
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
9
|
+
};
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
12
|
+
for (let key of __getOwnPropNames(from))
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
15
|
+
}
|
16
|
+
return to;
|
17
|
+
};
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
19
|
+
var dto_exports = {};
|
20
|
+
__export(dto_exports, {
|
21
|
+
DTOFromat: () => DTOFromat
|
22
|
+
});
|
23
|
+
module.exports = __toCommonJS(dto_exports);
|
24
|
+
var import_base = require("./base");
|
25
|
+
class DTOFromat extends import_base.BaseFormat {
|
26
|
+
constructor(dto) {
|
27
|
+
super(dto);
|
28
|
+
}
|
29
|
+
#formatType() {
|
30
|
+
const curSchema = this.getCurSchema();
|
31
|
+
this.content += `readonly ${curSchema.key}:${curSchema.type}
|
32
|
+
|
33
|
+
`;
|
34
|
+
}
|
35
|
+
#setSimpleRule(key, val) {
|
36
|
+
if (!this.importInfo.includes(`${key},`)) {
|
37
|
+
this.importInfo += `${key},`;
|
38
|
+
}
|
39
|
+
this.content += val ? `@${key}({ message: '${val}' })
|
40
|
+
` : `@${key}()
|
41
|
+
`;
|
42
|
+
}
|
43
|
+
#max(max, msg, type) {
|
44
|
+
if (type === "number") {
|
45
|
+
if (!this.importInfo.includes("Max,")) {
|
46
|
+
this.importInfo += "Max,";
|
47
|
+
}
|
48
|
+
this.content += `@Max(${max}, { message: '${msg}' })
|
49
|
+
`;
|
50
|
+
} else if (type === "string") {
|
51
|
+
if (!this.importInfo.includes("MaxLength,")) {
|
52
|
+
this.importInfo += "MaxLength,";
|
53
|
+
}
|
54
|
+
this.content += `@MaxLength(${max}, { message: '${msg}' })
|
55
|
+
`;
|
56
|
+
}
|
57
|
+
}
|
58
|
+
#min(min, msg, type) {
|
59
|
+
if (type === "number") {
|
60
|
+
if (!this.importInfo.includes("Min,")) {
|
61
|
+
this.importInfo += "Min,";
|
62
|
+
}
|
63
|
+
this.content += `@Min(${min}, { message: '${msg}' })
|
64
|
+
`;
|
65
|
+
} else if (type === "string") {
|
66
|
+
if (!this.importInfo.includes("MinLength,")) {
|
67
|
+
this.importInfo += "MinLength,";
|
68
|
+
}
|
69
|
+
this.content += `@MinLength(${min}, { message: '${msg}' })
|
70
|
+
`;
|
71
|
+
}
|
72
|
+
}
|
73
|
+
#limit(max, min, msg, type) {
|
74
|
+
if (type === "number") {
|
75
|
+
this.#max(max, msg, type);
|
76
|
+
this.#min(min, msg, type);
|
77
|
+
} else if (type === "string") {
|
78
|
+
if (!this.importInfo.includes("Length,")) {
|
79
|
+
this.importInfo += "Length,";
|
80
|
+
}
|
81
|
+
this.content += `@Length(${min}, ${max}, { message: '${msg}' })
|
82
|
+
`;
|
83
|
+
}
|
84
|
+
}
|
85
|
+
#formatRule() {
|
86
|
+
const { type, isInt, isOptional, isNumber, notEmpty, limit } = this.getCurSchema();
|
87
|
+
if (isOptional) this.#setSimpleRule("IsOptional");
|
88
|
+
if (notEmpty) this.#setSimpleRule("IsNotEmpty", notEmpty);
|
89
|
+
if (isInt) this.#setSimpleRule("IsInt", isInt);
|
90
|
+
if (isNumber) this.#setSimpleRule("IsNumber", isNumber);
|
91
|
+
if (limit) {
|
92
|
+
const { max, min, msg } = limit;
|
93
|
+
if (max !== void 0 && min !== void 0) {
|
94
|
+
this.#limit(max, min, msg, type);
|
95
|
+
} else if (max !== void 0) {
|
96
|
+
this.#max(max, msg, type);
|
97
|
+
} else if (min !== void 0) {
|
98
|
+
this.#min(min, msg, type);
|
99
|
+
}
|
100
|
+
}
|
101
|
+
}
|
102
|
+
formatOnceStep() {
|
103
|
+
this.#formatRule();
|
104
|
+
this.#formatType();
|
105
|
+
}
|
106
|
+
formatEnd() {
|
107
|
+
if (this.importInfo) {
|
108
|
+
this.importInfo = `import { ${this.importInfo.slice(0, this.importInfo.length - 1)} } from 'class-validator'
|
109
|
+
`;
|
110
|
+
}
|
111
|
+
}
|
112
|
+
}
|
113
|
+
// Annotate the CommonJS export names for ESM import in node:
|
114
|
+
0 && (module.exports = {
|
115
|
+
DTOFromat
|
116
|
+
});
|
@@ -0,0 +1,68 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __defProp = Object.defineProperty;
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
6
|
+
var __export = (target, all) => {
|
7
|
+
for (var name in all)
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
9
|
+
};
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
12
|
+
for (let key of __getOwnPropNames(from))
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
15
|
+
}
|
16
|
+
return to;
|
17
|
+
};
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
19
|
+
var entity_exports = {};
|
20
|
+
__export(entity_exports, {
|
21
|
+
EntityFormat: () => EntityFormat
|
22
|
+
});
|
23
|
+
module.exports = __toCommonJS(entity_exports);
|
24
|
+
var import_base = require("./base");
|
25
|
+
class EntityFormat extends import_base.BaseFormat {
|
26
|
+
#columnStr = "";
|
27
|
+
constructor(entity) {
|
28
|
+
super(entity);
|
29
|
+
}
|
30
|
+
formatOnceStep() {
|
31
|
+
const {
|
32
|
+
key,
|
33
|
+
type,
|
34
|
+
isExclude,
|
35
|
+
comment,
|
36
|
+
nullable,
|
37
|
+
dataType,
|
38
|
+
name,
|
39
|
+
length
|
40
|
+
} = this.getCurSchema();
|
41
|
+
if (isExclude) {
|
42
|
+
if (!this.importInfo) {
|
43
|
+
this.importInfo += "import { Exclude } from 'class-transformer'\n";
|
44
|
+
}
|
45
|
+
this.content += "@Exclude()\n";
|
46
|
+
}
|
47
|
+
if (name) this.#columnStr += `name: '${name}',`;
|
48
|
+
if (comment) this.#columnStr += `comment: '${comment}',`;
|
49
|
+
if (nullable) this.#columnStr += `nullable: true,`;
|
50
|
+
if (dataType) this.#columnStr += `type: '${dataType}',`;
|
51
|
+
if (length) this.#columnStr += `length: '${length}',`;
|
52
|
+
if (this.#columnStr) {
|
53
|
+
this.content += `@Column({ ${this.#columnStr.slice(0, this.#columnStr.length - 1)} })
|
54
|
+
`;
|
55
|
+
} else {
|
56
|
+
this.content += `@Column()
|
57
|
+
`;
|
58
|
+
}
|
59
|
+
this.#columnStr = "";
|
60
|
+
this.content += `${key}:${type}
|
61
|
+
|
62
|
+
`;
|
63
|
+
}
|
64
|
+
}
|
65
|
+
// Annotate the CommonJS export names for ESM import in node:
|
66
|
+
0 && (module.exports = {
|
67
|
+
EntityFormat
|
68
|
+
});
|
@@ -0,0 +1,8 @@
|
|
1
|
+
import { ApiServiceField } from '@/types';
|
2
|
+
import { BaseFormat } from './base';
|
3
|
+
export declare class ServiceFormat extends BaseFormat<ApiServiceField> {
|
4
|
+
#private;
|
5
|
+
constructor(moduleName: string, apiService: ApiServiceField[]);
|
6
|
+
protected formatOnceStep(): void;
|
7
|
+
protected formatEnd(): void;
|
8
|
+
}
|
@@ -0,0 +1,93 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __defProp = Object.defineProperty;
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
6
|
+
var __export = (target, all) => {
|
7
|
+
for (var name in all)
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
9
|
+
};
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
12
|
+
for (let key of __getOwnPropNames(from))
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
15
|
+
}
|
16
|
+
return to;
|
17
|
+
};
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
19
|
+
var service_exports = {};
|
20
|
+
__export(service_exports, {
|
21
|
+
ServiceFormat: () => ServiceFormat
|
22
|
+
});
|
23
|
+
module.exports = __toCommonJS(service_exports);
|
24
|
+
var import_base = require("./base");
|
25
|
+
class ServiceFormat extends import_base.BaseFormat {
|
26
|
+
#moudleName;
|
27
|
+
#upperName;
|
28
|
+
#serviceMap = {};
|
29
|
+
constructor(moduleName, apiService) {
|
30
|
+
super(apiService);
|
31
|
+
this.#moudleName = moduleName;
|
32
|
+
this.#upperName = moduleName[0].toUpperCase() + moduleName.slice(1);
|
33
|
+
}
|
34
|
+
formatOnceStep() {
|
35
|
+
const { key } = this.getCurSchema();
|
36
|
+
if (this.#serviceMap[key]) {
|
37
|
+
return;
|
38
|
+
}
|
39
|
+
this.#serviceMap[key] = true;
|
40
|
+
if (key === "get") {
|
41
|
+
this.content += `
|
42
|
+
query(id: number) {
|
43
|
+
return this.${this.#moudleName}Repository.findOneBy({ id })
|
44
|
+
}
|
45
|
+
`;
|
46
|
+
} else if (key === "all") {
|
47
|
+
this.content += `
|
48
|
+
async table(skip?: number, take?: number, search?: string) {
|
49
|
+
if (skip === undefined || take === undefined) return this.${this.#moudleName}Repository.find()
|
50
|
+
|
51
|
+
let queryBuilder = this.${this.#moudleName}Repository.createQueryBuilder('${this.#moudleName}')
|
52
|
+
if (search) {
|
53
|
+
queryBuilder = queryBuilder.where('${this.#moudleName}.id like :search', { search: \`%\${search}%\` })
|
54
|
+
}
|
55
|
+
const [list, total] = await queryBuilder.skip(skip).take(take).getManyAndCount()
|
56
|
+
return { list, total }
|
57
|
+
}
|
58
|
+
`;
|
59
|
+
} else if (key === "delete") {
|
60
|
+
this.content += `
|
61
|
+
delete(id: number) {
|
62
|
+
return this.${this.#moudleName}Repository.softDelete(id)
|
63
|
+
}
|
64
|
+
`;
|
65
|
+
} else if (key === "update") {
|
66
|
+
this.content += `
|
67
|
+
update(id: number, update${this.#upperName}Dto: Update${this.#upperName}Dto) {
|
68
|
+
return this.${this.#moudleName}Repository.update(id, update${this.#upperName}Dto)
|
69
|
+
}
|
70
|
+
`;
|
71
|
+
} else if (key === "add") {
|
72
|
+
this.content += `
|
73
|
+
create(create${this.#upperName}Dto: Create${this.#upperName}Dto) {
|
74
|
+
return this.${this.#moudleName}Repository.save(create${this.#upperName}Dto)
|
75
|
+
}
|
76
|
+
`;
|
77
|
+
}
|
78
|
+
}
|
79
|
+
formatEnd() {
|
80
|
+
if (this.#serviceMap["add"]) {
|
81
|
+
this.importInfo += `import { Create${this.#upperName}Dto } from './dto/create-${this.#upperName}.dto'
|
82
|
+
`;
|
83
|
+
}
|
84
|
+
if (this.#serviceMap["update"]) {
|
85
|
+
this.importInfo += `import { Update${this.#upperName}Dto } from './dto/update-${this.#upperName}.dto'
|
86
|
+
`;
|
87
|
+
}
|
88
|
+
}
|
89
|
+
}
|
90
|
+
// Annotate the CommonJS export names for ESM import in node:
|
91
|
+
0 && (module.exports = {
|
92
|
+
ServiceFormat
|
93
|
+
});
|
@@ -0,0 +1 @@
|
|
1
|
+
export declare const genLuaTypes: (path: string) => Promise<void>;
|
package/dist/gen-type.js
ADDED
@@ -0,0 +1,66 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __defProp = Object.defineProperty;
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
6
|
+
var __export = (target, all) => {
|
7
|
+
for (var name in all)
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
9
|
+
};
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
12
|
+
for (let key of __getOwnPropNames(from))
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
15
|
+
}
|
16
|
+
return to;
|
17
|
+
};
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
19
|
+
var gen_type_exports = {};
|
20
|
+
__export(gen_type_exports, {
|
21
|
+
genLuaTypes: () => genLuaTypes
|
22
|
+
});
|
23
|
+
module.exports = __toCommonJS(gen_type_exports);
|
24
|
+
var import_path = require("path");
|
25
|
+
var import_util = require("./util");
|
26
|
+
var import_fs = require("fs");
|
27
|
+
var import_promises = require("fs/promises");
|
28
|
+
const genLuaTypes = async (path) => {
|
29
|
+
const types = ["base", "nest", "vue"];
|
30
|
+
const vscodePath = (0, import_path.join)(path, ".vscode");
|
31
|
+
if (!(0, import_fs.existsSync)(vscodePath)) {
|
32
|
+
(0, import_fs.mkdirSync)(vscodePath);
|
33
|
+
}
|
34
|
+
const moveList = types.map((t) => ({
|
35
|
+
writePath: (0, import_path.join)(vscodePath, `${t}-type.lua`),
|
36
|
+
readPath: (0, import_path.resolve)(__dirname, `../sources/${t}-type.txt`)
|
37
|
+
}));
|
38
|
+
moveList.forEach((m) => {
|
39
|
+
(0, import_promises.readFile)(m.readPath, "utf-8").then((content) => {
|
40
|
+
(0, import_promises.writeFile)(m.writePath, content);
|
41
|
+
});
|
42
|
+
});
|
43
|
+
const settingPath = (0, import_path.join)(vscodePath, "settings.json");
|
44
|
+
if ((0, import_fs.existsSync)(settingPath)) {
|
45
|
+
const content = await (0, import_promises.readFile)(settingPath, "utf-8");
|
46
|
+
if (content.length > 0) {
|
47
|
+
const settionObj = JSON.parse(content);
|
48
|
+
settionObj["Lua.workspace.library"] = types.map(
|
49
|
+
(t) => `./${t}-type.lua`
|
50
|
+
);
|
51
|
+
(0, import_util.writeFormatFile)(settingPath, JSON.stringify(settionObj), true);
|
52
|
+
}
|
53
|
+
} else {
|
54
|
+
(0, import_util.writeFormatFile)(
|
55
|
+
settingPath,
|
56
|
+
JSON.stringify({
|
57
|
+
"Lua.workspace.library": types.map((t) => `./${t}-type.lua`)
|
58
|
+
}),
|
59
|
+
true
|
60
|
+
);
|
61
|
+
}
|
62
|
+
};
|
63
|
+
// Annotate the CommonJS export names for ESM import in node:
|
64
|
+
0 && (module.exports = {
|
65
|
+
genLuaTypes
|
66
|
+
});
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
require('module-alias/register');require('module-alias').addAliases({'@': require('path').resolve(__dirname)});
|
2
|
+
"use strict";
|
3
|
+
var __defProp = Object.defineProperty;
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
7
|
+
var __export = (target, all) => {
|
8
|
+
for (var name in all)
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
10
|
+
};
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
13
|
+
for (let key of __getOwnPropNames(from))
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
16
|
+
}
|
17
|
+
return to;
|
18
|
+
};
|
19
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
20
|
+
var src_exports = {};
|
21
|
+
__export(src_exports, {
|
22
|
+
genLuaTypes: () => import_gen_type.genLuaTypes,
|
23
|
+
startRun: () => startRun
|
24
|
+
});
|
25
|
+
module.exports = __toCommonJS(src_exports);
|
26
|
+
var import_compile = require("./compile");
|
27
|
+
var import_fs = require("fs");
|
28
|
+
var import_lua_codegen = require("../pkg/lua_codegen");
|
29
|
+
var import_gen_type = require("./gen-type");
|
30
|
+
var import_config = require("./config");
|
31
|
+
async function startRun(filePath, config) {
|
32
|
+
if (config) (0, import_config.setConfig)(config);
|
33
|
+
if ((0, import_fs.existsSync)(filePath)) {
|
34
|
+
try {
|
35
|
+
const data = await (0, import_compile.compileToByte)(filePath);
|
36
|
+
(0, import_lua_codegen.run)(new Uint8Array(data), filePath);
|
37
|
+
} catch (error) {
|
38
|
+
console.error(error);
|
39
|
+
}
|
40
|
+
} else {
|
41
|
+
console.error(`${filePath}\u6587\u4EF6\u5B58\u5728`);
|
42
|
+
}
|
43
|
+
}
|
44
|
+
// Annotate the CommonJS export names for ESM import in node:
|
45
|
+
0 && (module.exports = {
|
46
|
+
genLuaTypes,
|
47
|
+
startRun
|
48
|
+
});
|
@@ -0,0 +1 @@
|
|
1
|
+
export declare function printToNode(info: any): void;
|
@@ -0,0 +1,30 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __defProp = Object.defineProperty;
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
6
|
+
var __export = (target, all) => {
|
7
|
+
for (var name in all)
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
9
|
+
};
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
12
|
+
for (let key of __getOwnPropNames(from))
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
15
|
+
}
|
16
|
+
return to;
|
17
|
+
};
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
19
|
+
var libs_exports = {};
|
20
|
+
__export(libs_exports, {
|
21
|
+
printToNode: () => printToNode
|
22
|
+
});
|
23
|
+
module.exports = __toCommonJS(libs_exports);
|
24
|
+
function printToNode(info) {
|
25
|
+
console.log(info);
|
26
|
+
}
|
27
|
+
// Annotate the CommonJS export names for ESM import in node:
|
28
|
+
0 && (module.exports = {
|
29
|
+
printToNode
|
30
|
+
});
|
@@ -0,0 +1,41 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __defProp = Object.defineProperty;
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
6
|
+
var __export = (target, all) => {
|
7
|
+
for (var name in all)
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
9
|
+
};
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
12
|
+
for (let key of __getOwnPropNames(from))
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
15
|
+
}
|
16
|
+
return to;
|
17
|
+
};
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
19
|
+
var nest_lib_exports = {};
|
20
|
+
__export(nest_lib_exports, {
|
21
|
+
renderNestCode: () => renderNestCode
|
22
|
+
});
|
23
|
+
module.exports = __toCommonJS(nest_lib_exports);
|
24
|
+
var import_nest = require("@/code/nest");
|
25
|
+
var import_config = require("@/config");
|
26
|
+
function renderNestCode(config, dto, entity, apiService) {
|
27
|
+
const api = new import_nest.RenderNest(config.name, config.path);
|
28
|
+
if ((0, import_config.isReverse)()) {
|
29
|
+
api.remove();
|
30
|
+
return;
|
31
|
+
}
|
32
|
+
api.editAppModule();
|
33
|
+
api.genModule();
|
34
|
+
api.genDto(dto);
|
35
|
+
api.genEntity(entity);
|
36
|
+
api.genApiService(apiService);
|
37
|
+
}
|
38
|
+
// Annotate the CommonJS export names for ESM import in node:
|
39
|
+
0 && (module.exports = {
|
40
|
+
renderNestCode
|
41
|
+
});
|
@@ -0,0 +1 @@
|
|
1
|
+
export declare function genWebCode(name: string, val: any): void;
|
@@ -0,0 +1,30 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __defProp = Object.defineProperty;
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
6
|
+
var __export = (target, all) => {
|
7
|
+
for (var name in all)
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
9
|
+
};
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
12
|
+
for (let key of __getOwnPropNames(from))
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
15
|
+
}
|
16
|
+
return to;
|
17
|
+
};
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
19
|
+
var vue_lib_exports = {};
|
20
|
+
__export(vue_lib_exports, {
|
21
|
+
genWebCode: () => genWebCode
|
22
|
+
});
|
23
|
+
module.exports = __toCommonJS(vue_lib_exports);
|
24
|
+
function genWebCode(name, val) {
|
25
|
+
console.log("name=", name, ",value=", val);
|
26
|
+
}
|
27
|
+
// Annotate the CommonJS export names for ESM import in node:
|
28
|
+
0 && (module.exports = {
|
29
|
+
genWebCode
|
30
|
+
});
|
package/dist/render.d.ts
ADDED
package/dist/render.js
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __defProp = Object.defineProperty;
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
6
|
+
var __export = (target, all) => {
|
7
|
+
for (var name in all)
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
9
|
+
};
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
12
|
+
for (let key of __getOwnPropNames(from))
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
15
|
+
}
|
16
|
+
return to;
|
17
|
+
};
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
19
|
+
var render_exports = {};
|
20
|
+
__export(render_exports, {
|
21
|
+
default: () => render_default
|
22
|
+
});
|
23
|
+
module.exports = __toCommonJS(render_exports);
|
24
|
+
var import_template = require("@biuxiu/template");
|
25
|
+
var import_path = require("path");
|
26
|
+
const basePath = (0, import_path.resolve)(__dirname, "..");
|
27
|
+
const xiu = new import_template.XiuTemplate(basePath);
|
28
|
+
xiu.install(() => ({
|
29
|
+
name: "up",
|
30
|
+
fn: (val) => val[0].toUpperCase() + val.slice(1)
|
31
|
+
}));
|
32
|
+
var render_default = xiu;
|
package/dist/types.d.ts
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
type FieldSchema = {
|
2
|
+
key: string;
|
3
|
+
type: 'string' | 'number' | 'bool';
|
4
|
+
};
|
5
|
+
export type DtoField = FieldSchema & {
|
6
|
+
isOptional?: boolean;
|
7
|
+
limit?: {
|
8
|
+
max?: number;
|
9
|
+
min?: number;
|
10
|
+
msg: string;
|
11
|
+
};
|
12
|
+
notEmpty?: string;
|
13
|
+
isInt?: string;
|
14
|
+
isNumber?: string;
|
15
|
+
};
|
16
|
+
export type EntityField = FieldSchema & {
|
17
|
+
isExclude?: true;
|
18
|
+
comment?: string;
|
19
|
+
length?: number;
|
20
|
+
nullable?: true;
|
21
|
+
name?: string;
|
22
|
+
dataType?: 'int' | 'datetime' | 'varchar' | 'tinyint';
|
23
|
+
};
|
24
|
+
export type ApiServiceField = {
|
25
|
+
key: 'get' | 'all' | 'delete' | 'update' | 'add';
|
26
|
+
interceptor?: true;
|
27
|
+
};
|
28
|
+
export {};
|
package/dist/types.js
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __defProp = Object.defineProperty;
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
6
|
+
var __copyProps = (to, from, except, desc) => {
|
7
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
8
|
+
for (let key of __getOwnPropNames(from))
|
9
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
10
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
11
|
+
}
|
12
|
+
return to;
|
13
|
+
};
|
14
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
15
|
+
var types_exports = {};
|
16
|
+
module.exports = __toCommonJS(types_exports);
|
package/dist/util.d.ts
ADDED
package/dist/util.js
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __defProp = Object.defineProperty;
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
6
|
+
var __export = (target, all) => {
|
7
|
+
for (var name in all)
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
9
|
+
};
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
12
|
+
for (let key of __getOwnPropNames(from))
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
15
|
+
}
|
16
|
+
return to;
|
17
|
+
};
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
19
|
+
var util_exports = {};
|
20
|
+
__export(util_exports, {
|
21
|
+
reFromatFile: () => reFromatFile,
|
22
|
+
writeFormatFile: () => writeFormatFile
|
23
|
+
});
|
24
|
+
module.exports = __toCommonJS(util_exports);
|
25
|
+
var import_promises = require("fs/promises");
|
26
|
+
var import_prettier = require("prettier");
|
27
|
+
const reFromatFile = async (filePath) => {
|
28
|
+
const content = await (0, import_promises.readFile)(filePath, "utf-8");
|
29
|
+
await writeFormatFile(filePath, content);
|
30
|
+
};
|
31
|
+
const writeFormatFile = async (filePath, content, isJson = false) => {
|
32
|
+
try {
|
33
|
+
const file = await (0, import_prettier.resolveConfigFile)(filePath);
|
34
|
+
const config = file ? await (0, import_prettier.resolveConfig)(file) : {};
|
35
|
+
const formatText = await (0, import_prettier.format)(content, {
|
36
|
+
...config,
|
37
|
+
parser: isJson ? "json" : "typescript"
|
38
|
+
});
|
39
|
+
await (0, import_promises.writeFile)(filePath, formatText);
|
40
|
+
} catch (error) {
|
41
|
+
console.log(error);
|
42
|
+
}
|
43
|
+
};
|
44
|
+
// Annotate the CommonJS export names for ESM import in node:
|
45
|
+
0 && (module.exports = {
|
46
|
+
reFromatFile,
|
47
|
+
writeFormatFile
|
48
|
+
});
|