@biuxiu/codegen 0.2.5 → 0.2.7
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/code/nest.js +57 -91
- package/dist/compile.js +8 -32
- package/dist/config.js +5 -32
- package/dist/format/api.js +4 -28
- package/dist/format/base.js +2 -26
- package/dist/format/dto.js +4 -28
- package/dist/format/entity.js +4 -28
- package/dist/format/service.js +4 -28
- package/dist/gen-type.js +19 -43
- package/dist/index.js +11 -36
- package/dist/libs/index.js +2 -26
- package/dist/libs/nest-lib.js +6 -30
- package/dist/libs/vue-lib.js +2 -26
- package/dist/render.js +7 -27
- package/dist/types.js +0 -16
- package/dist/util.js +9 -34
- package/package.json +4 -7
- package/lua/bin/linux/luac +0 -0
- package/lua/bin/mac/luac +0 -0
- package/lua/bin/win/luac.exe +0 -0
- package/sources/base-type.txt +0 -6
- package/sources/controller.btpl +0 -8
- package/sources/create-dto.btpl +0 -4
- package/sources/entity.btpl +0 -8
- package/sources/module.btpl +0 -13
- package/sources/nest-type.txt +0 -88
- package/sources/service.btpl +0 -11
- package/sources/update-dto.btpl +0 -4
- package/sources/vue-type.txt +0 -27
package/dist/code/nest.js
CHANGED
@@ -1,47 +1,14 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
};
|
12
|
-
var __copyProps = (to, from, except, desc) => {
|
13
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
14
|
-
for (let key of __getOwnPropNames(from))
|
15
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
16
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
17
|
-
}
|
18
|
-
return to;
|
19
|
-
};
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
26
|
-
mod
|
27
|
-
));
|
28
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
29
|
-
var nest_exports = {};
|
30
|
-
__export(nest_exports, {
|
31
|
-
RenderNest: () => RenderNest
|
32
|
-
});
|
33
|
-
module.exports = __toCommonJS(nest_exports);
|
34
|
-
var import_render = __toESM(require("../render"));
|
35
|
-
var import_path = require("path");
|
36
|
-
var import_util = require("../util");
|
37
|
-
var import_fs = require("fs");
|
38
|
-
var import_dto = require("../format/dto");
|
39
|
-
var import_entity = require("../format/entity");
|
40
|
-
var import_api = require("../format/api");
|
41
|
-
var import_service = require("../format/service");
|
42
|
-
var import_config = require("../config");
|
43
|
-
var import_ts_morph = require("ts-morph");
|
44
|
-
var import_shelljs = require("shelljs");
|
1
|
+
import xiu from "../render";
|
2
|
+
import { join } from "path";
|
3
|
+
import { reFromatFile, writeFormatFile } from "../util";
|
4
|
+
import { existsSync, mkdirSync } from "fs";
|
5
|
+
import { DTOFromat } from "../format/dto";
|
6
|
+
import { EntityFormat } from "../format/entity";
|
7
|
+
import { ApiFormat } from "../format/api";
|
8
|
+
import { ServiceFormat } from "../format/service";
|
9
|
+
import { getApiDir } from "../config";
|
10
|
+
import { Project, SyntaxKind } from "ts-morph";
|
11
|
+
import { exec } from "shelljs";
|
45
12
|
const editFileQueue = [];
|
46
13
|
let isRunning = false;
|
47
14
|
const runEditTask = async () => {
|
@@ -64,47 +31,47 @@ class RenderNest {
|
|
64
31
|
constructor(name, path) {
|
65
32
|
this.#path = path ? path.endsWith("/") ? `${this.#formatPath(path)}/${name}` : this.#formatPath(path) : name;
|
66
33
|
let basePath = "";
|
67
|
-
const apiDir =
|
34
|
+
const apiDir = getApiDir();
|
68
35
|
if (this.#path.includes("/")) {
|
69
36
|
const pathArr = this.#path.split("/");
|
70
37
|
for (let i = 0; i < pathArr.length; i++) {
|
71
38
|
const curPath = pathArr[i];
|
72
39
|
if (i === 0) {
|
73
|
-
basePath =
|
40
|
+
basePath = join(apiDir, curPath);
|
74
41
|
} else {
|
75
|
-
basePath =
|
42
|
+
basePath = join(basePath, curPath);
|
76
43
|
}
|
77
|
-
if (!
|
78
|
-
|
44
|
+
if (!existsSync(basePath)) {
|
45
|
+
mkdirSync(basePath);
|
79
46
|
}
|
80
47
|
}
|
81
48
|
} else {
|
82
|
-
basePath =
|
83
|
-
if (!
|
84
|
-
|
49
|
+
basePath = join(apiDir, this.#path);
|
50
|
+
if (!existsSync(basePath)) {
|
51
|
+
mkdirSync(basePath);
|
85
52
|
}
|
86
53
|
}
|
87
54
|
this.#name = name;
|
88
55
|
this.#moduleDir = basePath;
|
89
56
|
}
|
90
57
|
remove() {
|
91
|
-
if (
|
92
|
-
|
58
|
+
if (existsSync(this.#moduleDir)) {
|
59
|
+
exec(`rm -rf ${this.#moduleDir}`);
|
93
60
|
}
|
94
61
|
this.editAppModule(true);
|
95
62
|
}
|
96
63
|
editAppModule(isDelete = false) {
|
97
64
|
editFileQueue.push(async () => {
|
98
65
|
const moudleName = `${this.#name[0].toUpperCase() + this.#name.slice(1)}Module`;
|
99
|
-
const appModuleFile =
|
100
|
-
if (
|
101
|
-
const source = new
|
66
|
+
const appModuleFile = join(getApiDir(), "app.module.ts");
|
67
|
+
if (existsSync(appModuleFile)) {
|
68
|
+
const source = new Project().addSourceFileAtPath(appModuleFile);
|
102
69
|
const moduleImport = source.getImportDeclaration(
|
103
70
|
`./${this.#path}/${this.#name}.module`
|
104
71
|
);
|
105
72
|
const appModuleClass = source.getClassOrThrow("AppModule");
|
106
|
-
const importsArray = appModuleClass.getDecoratorOrThrow("Module").getArguments()[0].asKindOrThrow(
|
107
|
-
|
73
|
+
const importsArray = appModuleClass.getDecoratorOrThrow("Module").getArguments()[0].asKindOrThrow(SyntaxKind.ObjectLiteralExpression).getPropertyOrThrow("imports").getFirstChildByKindOrThrow(
|
74
|
+
SyntaxKind.ArrayLiteralExpression
|
108
75
|
);
|
109
76
|
const consumerStatement = appModuleClass.getMethodOrThrow("configure").getStatements()[0];
|
110
77
|
if (isDelete) {
|
@@ -150,80 +117,79 @@ class RenderNest {
|
|
150
117
|
}
|
151
118
|
}
|
152
119
|
await source.save();
|
153
|
-
await
|
120
|
+
await reFromatFile(appModuleFile);
|
154
121
|
}
|
155
122
|
});
|
156
123
|
runEditTask();
|
157
124
|
}
|
158
125
|
async genModule() {
|
159
|
-
const modulePath =
|
160
|
-
const moduleStr = await
|
161
|
-
|
126
|
+
const modulePath = join(this.#moduleDir, `${this.#name}.module.ts`);
|
127
|
+
const moduleStr = await xiu.render("module", { name: this.#name });
|
128
|
+
writeFormatFile(modulePath, moduleStr);
|
162
129
|
}
|
163
130
|
async genApiService(apiService) {
|
164
|
-
const controllerPath =
|
131
|
+
const controllerPath = join(
|
165
132
|
this.#moduleDir,
|
166
133
|
`${this.#name}.controller.ts`
|
167
134
|
);
|
168
|
-
const servicePath =
|
169
|
-
const [apiImport, apiContent] = new
|
135
|
+
const servicePath = join(this.#moduleDir, `${this.#name}.service.ts`);
|
136
|
+
const [apiImport, apiContent] = new ApiFormat(
|
170
137
|
this.#name,
|
171
138
|
apiService
|
172
139
|
).format();
|
173
|
-
|
140
|
+
xiu.render("controller", {
|
174
141
|
name: this.#name,
|
175
142
|
importInfo: apiImport,
|
176
143
|
content: apiContent
|
177
144
|
}).then((controllerStr) => {
|
178
|
-
|
145
|
+
writeFormatFile(controllerPath, controllerStr);
|
179
146
|
});
|
180
|
-
const [serviceImport, serviceContent] = new
|
147
|
+
const [serviceImport, serviceContent] = new ServiceFormat(
|
181
148
|
this.#name,
|
182
149
|
apiService
|
183
150
|
).format();
|
184
|
-
|
151
|
+
xiu.render("service", {
|
185
152
|
name: this.#name,
|
186
153
|
content: serviceContent,
|
187
154
|
importInfo: serviceImport
|
188
155
|
}).then((serviceStr) => {
|
189
|
-
|
156
|
+
writeFormatFile(servicePath, serviceStr);
|
190
157
|
});
|
191
158
|
}
|
192
159
|
async genEntity(entity) {
|
193
|
-
const entityDir =
|
194
|
-
if (!
|
195
|
-
|
160
|
+
const entityDir = join(this.#moduleDir, "entities");
|
161
|
+
if (!existsSync(entityDir)) {
|
162
|
+
mkdirSync(entityDir);
|
196
163
|
}
|
197
|
-
const entityPath =
|
198
|
-
const [importInfo, content] = new
|
199
|
-
const entityStr = await
|
164
|
+
const entityPath = join(entityDir, `${this.#name}.entity.ts`);
|
165
|
+
const [importInfo, content] = new EntityFormat(entity).format();
|
166
|
+
const entityStr = await xiu.render("entity", {
|
200
167
|
name: this.#name,
|
201
168
|
importInfo,
|
202
169
|
content
|
203
170
|
});
|
204
|
-
|
171
|
+
writeFormatFile(entityPath, entityStr);
|
205
172
|
}
|
206
173
|
async genDto(dto) {
|
207
|
-
const dtoPath =
|
208
|
-
if (!
|
209
|
-
|
174
|
+
const dtoPath = join(this.#moduleDir, "dto");
|
175
|
+
if (!existsSync(dtoPath)) {
|
176
|
+
mkdirSync(dtoPath);
|
210
177
|
}
|
211
|
-
const createDtoPath =
|
212
|
-
const updateDtoPath =
|
213
|
-
const [importInfo, content] = new
|
214
|
-
const createDtoStr = await
|
178
|
+
const createDtoPath = join(dtoPath, `create-${this.#name}.dto.ts`);
|
179
|
+
const updateDtoPath = join(dtoPath, `update-${this.#name}.dto.ts`);
|
180
|
+
const [importInfo, content] = new DTOFromat(dto).format();
|
181
|
+
const createDtoStr = await xiu.render("create-dto", {
|
215
182
|
importInfo,
|
216
183
|
name: this.#name,
|
217
184
|
content
|
218
185
|
});
|
219
|
-
const updateDtoStr = await
|
186
|
+
const updateDtoStr = await xiu.render("update-dto", {
|
220
187
|
name: this.#name
|
221
188
|
});
|
222
|
-
|
223
|
-
|
189
|
+
writeFormatFile(createDtoPath, createDtoStr);
|
190
|
+
writeFormatFile(updateDtoPath, updateDtoStr);
|
224
191
|
}
|
225
192
|
}
|
226
|
-
|
227
|
-
0 && (module.exports = {
|
193
|
+
export {
|
228
194
|
RenderNest
|
229
|
-
}
|
195
|
+
};
|
package/dist/compile.js
CHANGED
@@ -1,31 +1,8 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
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 compile_exports = {};
|
20
|
-
__export(compile_exports, {
|
21
|
-
compileToByte: () => compileToByte
|
22
|
-
});
|
23
|
-
module.exports = __toCommonJS(compile_exports);
|
24
|
-
var import_shelljs = require("shelljs");
|
25
|
-
var import_path = require("path");
|
26
|
-
var import_os = require("os");
|
1
|
+
import { exec } from "shelljs";
|
2
|
+
import { resolve } from "path";
|
3
|
+
import { platform } from "os";
|
27
4
|
const getPathName = () => {
|
28
|
-
switch (
|
5
|
+
switch (platform()) {
|
29
6
|
case "win32":
|
30
7
|
return "win/luac.exe";
|
31
8
|
case "linux":
|
@@ -37,9 +14,9 @@ const getPathName = () => {
|
|
37
14
|
}
|
38
15
|
};
|
39
16
|
function compileToByte(filePath) {
|
40
|
-
const bin =
|
17
|
+
const bin = resolve(__dirname, "../lua/bin", getPathName());
|
41
18
|
return new Promise((resolve2, reject) => {
|
42
|
-
|
19
|
+
exec(
|
43
20
|
`${bin} -s -o - ${filePath}`,
|
44
21
|
{ silent: true, encoding: "buffer" },
|
45
22
|
(code, out, err) => {
|
@@ -52,7 +29,6 @@ function compileToByte(filePath) {
|
|
52
29
|
);
|
53
30
|
});
|
54
31
|
}
|
55
|
-
|
56
|
-
0 && (module.exports = {
|
32
|
+
export {
|
57
33
|
compileToByte
|
58
|
-
}
|
34
|
+
};
|
package/dist/config.js
CHANGED
@@ -1,33 +1,7 @@
|
|
1
|
-
|
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 config_exports = {};
|
20
|
-
__export(config_exports, {
|
21
|
-
getApiDir: () => getApiDir,
|
22
|
-
getWebDir: () => getWebDir,
|
23
|
-
isReverse: () => isReverse,
|
24
|
-
setConfig: () => setConfig
|
25
|
-
});
|
26
|
-
module.exports = __toCommonJS(config_exports);
|
27
|
-
var import_path = require("path");
|
1
|
+
import { resolve } from "path";
|
28
2
|
const CodegenConfig = {
|
29
|
-
webDir:
|
30
|
-
apiDir:
|
3
|
+
webDir: resolve(__dirname, ".."),
|
4
|
+
apiDir: resolve(__dirname, ".."),
|
31
5
|
reverse: false
|
32
6
|
};
|
33
7
|
function setConfig(config) {
|
@@ -44,10 +18,9 @@ function setConfig(config) {
|
|
44
18
|
const getWebDir = () => CodegenConfig.webDir;
|
45
19
|
const getApiDir = () => CodegenConfig.apiDir;
|
46
20
|
const isReverse = () => CodegenConfig.reverse;
|
47
|
-
|
48
|
-
0 && (module.exports = {
|
21
|
+
export {
|
49
22
|
getApiDir,
|
50
23
|
getWebDir,
|
51
24
|
isReverse,
|
52
25
|
setConfig
|
53
|
-
}
|
26
|
+
};
|
package/dist/format/api.js
CHANGED
@@ -1,28 +1,5 @@
|
|
1
|
-
|
2
|
-
|
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 api_exports = {};
|
20
|
-
__export(api_exports, {
|
21
|
-
ApiFormat: () => ApiFormat
|
22
|
-
});
|
23
|
-
module.exports = __toCommonJS(api_exports);
|
24
|
-
var import_base = require("./base");
|
25
|
-
class ApiFormat extends import_base.BaseFormat {
|
1
|
+
import { BaseFormat } from "./base";
|
2
|
+
class ApiFormat extends BaseFormat {
|
26
3
|
#hasInterceptor = false;
|
27
4
|
#moudleName;
|
28
5
|
#upperName;
|
@@ -116,7 +93,6 @@ class ApiFormat extends import_base.BaseFormat {
|
|
116
93
|
`;
|
117
94
|
}
|
118
95
|
}
|
119
|
-
|
120
|
-
0 && (module.exports = {
|
96
|
+
export {
|
121
97
|
ApiFormat
|
122
|
-
}
|
98
|
+
};
|
package/dist/format/base.js
CHANGED
@@ -1,26 +1,3 @@
|
|
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 base_exports = {};
|
20
|
-
__export(base_exports, {
|
21
|
-
BaseFormat: () => BaseFormat
|
22
|
-
});
|
23
|
-
module.exports = __toCommonJS(base_exports);
|
24
1
|
class BaseFormat {
|
25
2
|
importInfo;
|
26
3
|
content;
|
@@ -50,7 +27,6 @@ class BaseFormat {
|
|
50
27
|
return [this.importInfo, this.content];
|
51
28
|
}
|
52
29
|
}
|
53
|
-
|
54
|
-
0 && (module.exports = {
|
30
|
+
export {
|
55
31
|
BaseFormat
|
56
|
-
}
|
32
|
+
};
|
package/dist/format/dto.js
CHANGED
@@ -1,28 +1,5 @@
|
|
1
|
-
|
2
|
-
|
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 {
|
1
|
+
import { BaseFormat } from "./base";
|
2
|
+
class DTOFromat extends BaseFormat {
|
26
3
|
constructor(dto) {
|
27
4
|
super(dto);
|
28
5
|
}
|
@@ -110,7 +87,6 @@ class DTOFromat extends import_base.BaseFormat {
|
|
110
87
|
}
|
111
88
|
}
|
112
89
|
}
|
113
|
-
|
114
|
-
0 && (module.exports = {
|
90
|
+
export {
|
115
91
|
DTOFromat
|
116
|
-
}
|
92
|
+
};
|
package/dist/format/entity.js
CHANGED
@@ -1,28 +1,5 @@
|
|
1
|
-
|
2
|
-
|
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 {
|
1
|
+
import { BaseFormat } from "./base";
|
2
|
+
class EntityFormat extends BaseFormat {
|
26
3
|
#columnStr = "";
|
27
4
|
constructor(entity) {
|
28
5
|
super(entity);
|
@@ -62,7 +39,6 @@ class EntityFormat extends import_base.BaseFormat {
|
|
62
39
|
`;
|
63
40
|
}
|
64
41
|
}
|
65
|
-
|
66
|
-
0 && (module.exports = {
|
42
|
+
export {
|
67
43
|
EntityFormat
|
68
|
-
}
|
44
|
+
};
|
package/dist/format/service.js
CHANGED
@@ -1,28 +1,5 @@
|
|
1
|
-
|
2
|
-
|
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 {
|
1
|
+
import { BaseFormat } from "./base";
|
2
|
+
class ServiceFormat extends BaseFormat {
|
26
3
|
#moudleName;
|
27
4
|
#upperName;
|
28
5
|
#serviceMap = {};
|
@@ -87,7 +64,6 @@ class ServiceFormat extends import_base.BaseFormat {
|
|
87
64
|
}
|
88
65
|
}
|
89
66
|
}
|
90
|
-
|
91
|
-
0 && (module.exports = {
|
67
|
+
export {
|
92
68
|
ServiceFormat
|
93
|
-
}
|
69
|
+
};
|
package/dist/gen-type.js
CHANGED
@@ -1,59 +1,36 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
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");
|
1
|
+
import { join, resolve } from "path";
|
2
|
+
import { writeFormatFile } from "./util";
|
3
|
+
import { existsSync, mkdirSync } from "fs";
|
4
|
+
import { readFile, writeFile } from "fs/promises";
|
28
5
|
const genLuaTypes = async (path) => {
|
29
6
|
const types = ["base", "nest", "vue"];
|
30
|
-
const vscodePath =
|
31
|
-
if (!
|
32
|
-
|
7
|
+
const vscodePath = join(path, ".vscode");
|
8
|
+
if (!existsSync(vscodePath)) {
|
9
|
+
mkdirSync(vscodePath);
|
33
10
|
}
|
34
11
|
const moveList = types.map((t) => ({
|
35
|
-
writePath:
|
36
|
-
readPath:
|
12
|
+
writePath: join(vscodePath, `${t}-type.lua`),
|
13
|
+
readPath: resolve(__dirname, `../sources/${t}-type.txt`)
|
37
14
|
}));
|
38
15
|
moveList.forEach((m) => {
|
39
|
-
if (!
|
40
|
-
|
41
|
-
|
16
|
+
if (!existsSync(m.writePath)) {
|
17
|
+
readFile(m.readPath, "utf-8").then((content) => {
|
18
|
+
writeFile(m.writePath, content);
|
42
19
|
});
|
43
20
|
}
|
44
21
|
});
|
45
|
-
const settingPath =
|
46
|
-
if (
|
47
|
-
const content = await
|
22
|
+
const settingPath = join(vscodePath, "settings.json");
|
23
|
+
if (existsSync(settingPath)) {
|
24
|
+
const content = await readFile(settingPath, "utf-8");
|
48
25
|
if (content.length > 0) {
|
49
26
|
const settionObj = JSON.parse(content);
|
50
27
|
settionObj["Lua.workspace.library"] = types.map(
|
51
28
|
(t) => `.vscode/${t}-type.lua`
|
52
29
|
);
|
53
|
-
|
30
|
+
writeFormatFile(settingPath, JSON.stringify(settionObj), true);
|
54
31
|
}
|
55
32
|
} else {
|
56
|
-
|
33
|
+
writeFormatFile(
|
57
34
|
settingPath,
|
58
35
|
JSON.stringify({
|
59
36
|
"Lua.workspace.library": types.map((t) => `./${t}-type.lua`)
|
@@ -62,7 +39,6 @@ const genLuaTypes = async (path) => {
|
|
62
39
|
);
|
63
40
|
}
|
64
41
|
};
|
65
|
-
|
66
|
-
0 && (module.exports = {
|
42
|
+
export {
|
67
43
|
genLuaTypes
|
68
|
-
}
|
44
|
+
};
|
package/dist/index.js
CHANGED
@@ -1,38 +1,14 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
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 src_exports = {};
|
20
|
-
__export(src_exports, {
|
21
|
-
genLuaTypes: () => import_gen_type.genLuaTypes,
|
22
|
-
startRun: () => startRun
|
23
|
-
});
|
24
|
-
module.exports = __toCommonJS(src_exports);
|
25
|
-
var import_compile = require("./compile");
|
26
|
-
var import_fs = require("fs");
|
27
|
-
var import_lua_codegen = require("./lua_codegen");
|
28
|
-
var import_gen_type = require("./gen-type");
|
29
|
-
var import_config = require("./config");
|
1
|
+
import { compileToByte } from "./compile";
|
2
|
+
import { existsSync } from "fs";
|
3
|
+
import { genLuaTypes } from "./gen-type";
|
4
|
+
import { setConfig } from "./config";
|
30
5
|
async function startRun(filePath, config) {
|
31
|
-
if (config)
|
32
|
-
if (
|
6
|
+
if (config) setConfig(config);
|
7
|
+
if (existsSync(filePath)) {
|
33
8
|
try {
|
34
|
-
const data = await
|
35
|
-
|
9
|
+
const data = await compileToByte(filePath);
|
10
|
+
const { run } = await import("./lua_codegen");
|
11
|
+
run(new Uint8Array(data), filePath);
|
36
12
|
} catch (error) {
|
37
13
|
return Promise.reject(error);
|
38
14
|
}
|
@@ -40,8 +16,7 @@ async function startRun(filePath, config) {
|
|
40
16
|
return Promise.reject(`${filePath}\u6587\u4EF6\u5B58\u5728`);
|
41
17
|
}
|
42
18
|
}
|
43
|
-
|
44
|
-
0 && (module.exports = {
|
19
|
+
export {
|
45
20
|
genLuaTypes,
|
46
21
|
startRun
|
47
|
-
}
|
22
|
+
};
|
package/dist/libs/index.js
CHANGED
@@ -1,30 +1,6 @@
|
|
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
1
|
function printToNode(info) {
|
25
2
|
console.log(info);
|
26
3
|
}
|
27
|
-
|
28
|
-
0 && (module.exports = {
|
4
|
+
export {
|
29
5
|
printToNode
|
30
|
-
}
|
6
|
+
};
|
package/dist/libs/nest-lib.js
CHANGED
@@ -1,31 +1,8 @@
|
|
1
|
-
|
2
|
-
|
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");
|
1
|
+
import { RenderNest } from "../code/nest";
|
2
|
+
import { isReverse } from "../config";
|
26
3
|
function renderNestCode(config, dto, entity, apiService) {
|
27
|
-
const api = new
|
28
|
-
if (
|
4
|
+
const api = new RenderNest(config.name, config.path);
|
5
|
+
if (isReverse()) {
|
29
6
|
api.remove();
|
30
7
|
return;
|
31
8
|
}
|
@@ -35,7 +12,6 @@ function renderNestCode(config, dto, entity, apiService) {
|
|
35
12
|
api.genEntity(entity);
|
36
13
|
api.genApiService(apiService);
|
37
14
|
}
|
38
|
-
|
39
|
-
0 && (module.exports = {
|
15
|
+
export {
|
40
16
|
renderNestCode
|
41
|
-
}
|
17
|
+
};
|
package/dist/libs/vue-lib.js
CHANGED
@@ -1,30 +1,6 @@
|
|
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
1
|
function genWebCode(name, val) {
|
25
2
|
console.log("name=", name, ",value=", val);
|
26
3
|
}
|
27
|
-
|
28
|
-
0 && (module.exports = {
|
4
|
+
export {
|
29
5
|
genWebCode
|
30
|
-
}
|
6
|
+
};
|
package/dist/render.js
CHANGED
@@ -1,32 +1,12 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
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);
|
1
|
+
import { XiuTemplate } from "@biuxiu/template";
|
2
|
+
import { resolve } from "path";
|
3
|
+
const basePath = resolve(__dirname, "..");
|
4
|
+
const xiu = new XiuTemplate(basePath);
|
28
5
|
xiu.install(() => ({
|
29
6
|
name: "up",
|
30
7
|
fn: (val) => val[0].toUpperCase() + val.slice(1)
|
31
8
|
}));
|
32
9
|
var render_default = xiu;
|
10
|
+
export {
|
11
|
+
render_default as default
|
12
|
+
};
|
package/dist/types.js
CHANGED
@@ -1,16 +0,0 @@
|
|
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.js
CHANGED
@@ -1,48 +1,23 @@
|
|
1
|
-
|
2
|
-
|
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");
|
1
|
+
import { readFile, writeFile } from "fs/promises";
|
2
|
+
import { format, resolveConfig, resolveConfigFile } from "prettier";
|
27
3
|
const reFromatFile = async (filePath) => {
|
28
|
-
const content = await
|
4
|
+
const content = await readFile(filePath, "utf-8");
|
29
5
|
await writeFormatFile(filePath, content);
|
30
6
|
};
|
31
7
|
const writeFormatFile = async (filePath, content, isJson = false) => {
|
32
8
|
try {
|
33
|
-
const file = await
|
34
|
-
const config = file ? await
|
35
|
-
const formatText = await
|
9
|
+
const file = await resolveConfigFile(filePath);
|
10
|
+
const config = file ? await resolveConfig(file) : {};
|
11
|
+
const formatText = await format(content, {
|
36
12
|
...config,
|
37
13
|
parser: isJson ? "json" : "typescript"
|
38
14
|
});
|
39
|
-
await
|
15
|
+
await writeFile(filePath, formatText);
|
40
16
|
} catch (error) {
|
41
17
|
console.log(error);
|
42
18
|
}
|
43
19
|
};
|
44
|
-
|
45
|
-
0 && (module.exports = {
|
20
|
+
export {
|
46
21
|
reFromatFile,
|
47
22
|
writeFormatFile
|
48
|
-
}
|
23
|
+
};
|
package/package.json
CHANGED
@@ -1,20 +1,17 @@
|
|
1
1
|
{
|
2
2
|
"name": "@biuxiu/codegen",
|
3
|
-
"version": "0.2.
|
3
|
+
"version": "0.2.7",
|
4
4
|
"description": "代码生成工具",
|
5
5
|
"main": "dist/index.js",
|
6
6
|
"scripts": {
|
7
|
+
"build": "tsx scripts/build.ts",
|
7
8
|
"test:dev": "tsx scripts/dev.ts",
|
8
|
-
"test:
|
9
|
-
"test:prod": "node scripts/prod.js",
|
10
|
-
"build:script": "tsx scripts/build.ts",
|
9
|
+
"test:move": "tsx scripts/dev.ts -d",
|
11
10
|
"build:wasm": "wasm-pack build --target nodejs --release",
|
12
|
-
"publish:x": "xiu -o -c -
|
11
|
+
"publish:x": "xiu -o -c -b -n"
|
13
12
|
},
|
14
13
|
"files": [
|
15
|
-
"lua/bin",
|
16
14
|
"dist",
|
17
|
-
"sources",
|
18
15
|
"README.md"
|
19
16
|
],
|
20
17
|
"keywords": [],
|
package/lua/bin/linux/luac
DELETED
Binary file
|
package/lua/bin/mac/luac
DELETED
Binary file
|
package/lua/bin/win/luac.exe
DELETED
Binary file
|
package/sources/base-type.txt
DELETED
package/sources/controller.btpl
DELETED
package/sources/create-dto.btpl
DELETED
package/sources/entity.btpl
DELETED
package/sources/module.btpl
DELETED
@@ -1,13 +0,0 @@
|
|
1
|
-
import { Module } from '@nestjs/common'
|
2
|
-
import { {%up@name%}Service } from './{%name%}.service'
|
3
|
-
import { {%up@name%}Controller } from './{%name%}.controller'
|
4
|
-
import { TypeOrmModule } from '@nestjs/typeorm'
|
5
|
-
import { {%up@name%}Entity } from './entities/{%name%}.entity'
|
6
|
-
|
7
|
-
@Module({
|
8
|
-
imports: [TypeOrmModule.forFeature([{%up@name%}Entity])],
|
9
|
-
controllers: [{%up@name%}Controller],
|
10
|
-
providers: [{%up@name%}Service],
|
11
|
-
exports: [{%up@name%}Service]
|
12
|
-
})
|
13
|
-
export class {%up@name%}Module {}
|
package/sources/nest-type.txt
DELETED
@@ -1,88 +0,0 @@
|
|
1
|
-
--- @meta NestJs
|
2
|
-
|
3
|
-
--- @class NestJs
|
4
|
-
NestJs = {}
|
5
|
-
|
6
|
-
--- @alias SetTblFn fun(tbl: table)
|
7
|
-
|
8
|
-
--- 生成限制规则
|
9
|
-
---
|
10
|
-
--- @param msg string 消息提示
|
11
|
-
--- @param min number | nil 最小值
|
12
|
-
--- @param max number | nil 最大值
|
13
|
-
--- @return SetTblFn
|
14
|
-
function NestJs.createLimitRule(msg, min, max) end
|
15
|
-
|
16
|
-
--- @alias SimpleRuleType 'isOptional' | 'notEmpty' | 'isInt' | 'isNumber'
|
17
|
-
|
18
|
-
--- 生成简单规则
|
19
|
-
---
|
20
|
-
--- @param key SimpleRuleType 规则类型
|
21
|
-
--- @param msg string | true 消息提示
|
22
|
-
--- @return SetTblFn
|
23
|
-
function NestJs.createSimpleRule(key, msg) end
|
24
|
-
|
25
|
-
--- @class DtoField
|
26
|
-
--- @field key string
|
27
|
-
--- @field type FieldType
|
28
|
-
|
29
|
-
--- 生成DTO字段信息
|
30
|
-
---
|
31
|
-
--- @param key string 字段名
|
32
|
-
--- @param type FieldType 字段类型
|
33
|
-
--- @param ... SetTblFn 字段规则函数
|
34
|
-
--- @return DtoField
|
35
|
-
function NestJs.creteDtoField(key, type, ...) end
|
36
|
-
|
37
|
-
--- @alias SimpleColumnType 'isExclude' | 'comment' | 'length' | 'nullable' | 'name'
|
38
|
-
|
39
|
-
--- 创建数据表字段特征
|
40
|
-
---
|
41
|
-
--- @param key SimpleColumnType 特征名
|
42
|
-
--- @param value number | string | true 字段值
|
43
|
-
--- @return SetTblFn
|
44
|
-
function NestJs.createSimpleColumn(key, value) end
|
45
|
-
|
46
|
-
--- 创建字段表类型
|
47
|
-
---
|
48
|
-
--- @param type 'int' | 'datetime' | 'varchar' | 'tinyint' 表类型
|
49
|
-
--- @return SetTblFn
|
50
|
-
function NestJs.creteColumnType(type) end
|
51
|
-
|
52
|
-
--- @class EntityField
|
53
|
-
--- @field key string
|
54
|
-
--- @field type FieldType
|
55
|
-
--- @field column number
|
56
|
-
|
57
|
-
--- 生成Entity字段信息
|
58
|
-
---
|
59
|
-
--- @param key string 字段名
|
60
|
-
--- @param type FieldType 字段类型
|
61
|
-
--- @param ... SetTblFn 字段数据库类型
|
62
|
-
--- @return EntityField
|
63
|
-
function NestJs.creteEntityField(key, type, ...) end
|
64
|
-
|
65
|
-
--- @alias ApiServiceFieldKey 'get' | 'all' | 'delete' | 'update' | 'add'
|
66
|
-
|
67
|
-
--- @class ApiServiceField
|
68
|
-
--- @field key ApiServiceFieldKey
|
69
|
-
--- @field interceptor true
|
70
|
-
|
71
|
-
--- 创建请求API和服务结构体
|
72
|
-
---
|
73
|
-
--- @param key ApiServiceFieldKey
|
74
|
-
--- @param interceptor true | nil
|
75
|
-
--- @return ApiServiceField
|
76
|
-
function NestJs.createApiService(key, interceptor) end
|
77
|
-
|
78
|
-
--- @class RenderConfig
|
79
|
-
--- @field name string
|
80
|
-
--- @field path? string
|
81
|
-
|
82
|
-
--- 创建后端代码
|
83
|
-
---
|
84
|
-
--- @param config RenderConfig 模块名
|
85
|
-
--- @param dto DtoField[] dto数据结构
|
86
|
-
--- @param entity EntityField[] entity数据结构
|
87
|
-
--- @param apiService ApiServiceField[] entity数据结构
|
88
|
-
function NestJs.renderToCode(config, dto, entity, apiService) end
|
package/sources/service.btpl
DELETED
@@ -1,11 +0,0 @@
|
|
1
|
-
import { Injectable } from '@nestjs/common'
|
2
|
-
import { InjectRepository } from '@nestjs/typeorm'
|
3
|
-
import { Repository } from 'typeorm'
|
4
|
-
{%importInfo%}import { {%up@name%}Entity } from './entities/{%name%}.entity'
|
5
|
-
|
6
|
-
@Injectable()
|
7
|
-
export class {%up@name%}Service {
|
8
|
-
constructor(@InjectRepository({%up@name%}Entity) private readonly {%name%}Repository: Repository<{%up@name%}Entity>) {}
|
9
|
-
|
10
|
-
{%content%}
|
11
|
-
}
|
package/sources/update-dto.btpl
DELETED
package/sources/vue-type.txt
DELETED
@@ -1,27 +0,0 @@
|
|
1
|
-
---@meta VueJs
|
2
|
-
|
3
|
-
--- @class VueJs
|
4
|
-
VueJs = {}
|
5
|
-
|
6
|
-
--- @class WebRoute 前端路由信息
|
7
|
-
--- @field path string 路由路径
|
8
|
-
--- @field name string 路由名
|
9
|
-
--- @field title string 路由标题
|
10
|
-
--- @field icon string 路由图标
|
11
|
-
|
12
|
-
--- @class WebTable 前端表格信息
|
13
|
-
|
14
|
-
--- @class WebForm 前端表单信息
|
15
|
-
|
16
|
-
--[[
|
17
|
-
--- 接收路由信息,并生成前端代码
|
18
|
-
---
|
19
|
-
--- @param route WebRoute 路由信息
|
20
|
-
--- @param tbl WebTable 表展示数据
|
21
|
-
--- @param form WebForm 表单展示数据
|
22
|
-
--- @param name string 模块名,使用`.`分隔上下级模块
|
23
|
-
]]
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
function VueJs.genWebCode(route, tbl) end
|