create-pangza 1.1.0 → 2.0.0
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/lib/generate.js +4 -8
- package/lib/modules.js +33 -34
- package/package.json +1 -1
package/lib/generate.js
CHANGED
|
@@ -31,11 +31,7 @@ function findProjectRoot(cwd = process.cwd()) {
|
|
|
31
31
|
...(json.dependencies || {}),
|
|
32
32
|
...(json.devDependencies || {}),
|
|
33
33
|
};
|
|
34
|
-
if (
|
|
35
|
-
deps["@pangza/express"] ||
|
|
36
|
-
deps["@pangza/application"] ||
|
|
37
|
-
deps["@pangza/core"]
|
|
38
|
-
) {
|
|
34
|
+
if (deps["@pangza/express"]) {
|
|
39
35
|
return dir;
|
|
40
36
|
}
|
|
41
37
|
} catch {
|
|
@@ -104,7 +100,7 @@ export default class ${Pascal}Mapper extends MapperType {}
|
|
|
104
100
|
}
|
|
105
101
|
|
|
106
102
|
function tplService({ Pascal, fileBase }) {
|
|
107
|
-
return `import { BaseService, Service } from "@pangza/
|
|
103
|
+
return `import { BaseService, Service } from "@pangza/express";
|
|
108
104
|
import ${Pascal}Mapper from "../mapper/${fileBase}";
|
|
109
105
|
|
|
110
106
|
@Service(${Pascal}Mapper)
|
|
@@ -121,8 +117,8 @@ function tplController({ Pascal, fileBase, apiPath, camel }) {
|
|
|
121
117
|
PutMapping,
|
|
122
118
|
RequestBody,
|
|
123
119
|
RequestPath,
|
|
124
|
-
|
|
125
|
-
|
|
120
|
+
Resource,
|
|
121
|
+
} from "@pangza/express";
|
|
126
122
|
import ${Pascal}Service from "../../service/${fileBase}";
|
|
127
123
|
|
|
128
124
|
@Controller("/api/${apiPath}")
|
package/lib/modules.js
CHANGED
|
@@ -1,41 +1,41 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
/**
|
|
3
|
+
/** ??????????????????????? */
|
|
4
4
|
const MODULES = [
|
|
5
5
|
{
|
|
6
6
|
id: "orm",
|
|
7
7
|
label: "ORM",
|
|
8
|
-
hint: "Db / Mapper / QueryWrapper /
|
|
8
|
+
hint: "Db / Mapper / QueryWrapper / ????",
|
|
9
9
|
},
|
|
10
10
|
{
|
|
11
11
|
id: "auth",
|
|
12
12
|
label: "Auth",
|
|
13
|
-
hint: "
|
|
13
|
+
hint: "????????????????? Redis?",
|
|
14
14
|
},
|
|
15
15
|
{
|
|
16
16
|
id: "redis",
|
|
17
17
|
label: "Redis",
|
|
18
|
-
hint: "
|
|
18
|
+
hint: "??????Auth token ??",
|
|
19
19
|
},
|
|
20
20
|
{
|
|
21
21
|
id: "log",
|
|
22
22
|
label: "Log",
|
|
23
|
-
hint: "
|
|
23
|
+
hint: "?????????",
|
|
24
24
|
},
|
|
25
25
|
{
|
|
26
26
|
id: "schedule",
|
|
27
27
|
label: "Schedule",
|
|
28
|
-
hint: "
|
|
28
|
+
hint: "???? (cron)",
|
|
29
29
|
},
|
|
30
30
|
{
|
|
31
31
|
id: "encrypt",
|
|
32
32
|
label: "Encrypt",
|
|
33
|
-
hint: "AES
|
|
33
|
+
hint: "AES ???????",
|
|
34
34
|
},
|
|
35
35
|
{
|
|
36
36
|
id: "validate",
|
|
37
37
|
label: "Validate",
|
|
38
|
-
hint: "
|
|
38
|
+
hint: "?????????? @pangza/express?",
|
|
39
39
|
},
|
|
40
40
|
];
|
|
41
41
|
|
|
@@ -81,8 +81,7 @@ const DB_ENV = {
|
|
|
81
81
|
/** @param {string[]} moduleIds @param {string} [dbType] */
|
|
82
82
|
function resolveDependencies(moduleIds, dbType = "mysql") {
|
|
83
83
|
const deps = {
|
|
84
|
-
"@pangza/
|
|
85
|
-
"@pangza/core": "^1.1.0",
|
|
84
|
+
"@pangza/express": "^2.0.0",
|
|
86
85
|
cors: "^2.8.5",
|
|
87
86
|
express: "^5.2.1",
|
|
88
87
|
inversify: "^8.2.3",
|
|
@@ -91,27 +90,27 @@ function resolveDependencies(moduleIds, dbType = "mysql") {
|
|
|
91
90
|
const set = new Set(moduleIds);
|
|
92
91
|
|
|
93
92
|
if (set.has("orm")) {
|
|
94
|
-
deps["@pangza/orm"] = "^
|
|
93
|
+
deps["@pangza/orm"] = "^2.0.0";
|
|
95
94
|
Object.assign(deps, DB_DEPS[dbType] || DB_DEPS.mysql);
|
|
96
95
|
}
|
|
97
96
|
if (set.has("redis") || set.has("auth")) {
|
|
98
|
-
deps["@pangza/redis"] = "^
|
|
97
|
+
deps["@pangza/redis"] = "^2.0.0";
|
|
99
98
|
deps.redis = "^6.2.1";
|
|
100
99
|
}
|
|
101
100
|
if (set.has("auth")) {
|
|
102
|
-
deps["@pangza/auth"] = "^
|
|
101
|
+
deps["@pangza/auth"] = "^2.0.0";
|
|
103
102
|
deps.jsonwebtoken = "^9.0.3";
|
|
104
103
|
deps.bcryptjs = "^3.0.3";
|
|
105
104
|
}
|
|
106
105
|
if (set.has("log")) {
|
|
107
|
-
deps["@pangza/log"] = "^
|
|
106
|
+
deps["@pangza/log"] = "^2.0.0";
|
|
108
107
|
}
|
|
109
108
|
if (set.has("schedule")) {
|
|
110
|
-
deps["@pangza/schedule"] = "^
|
|
109
|
+
deps["@pangza/schedule"] = "^2.0.0";
|
|
111
110
|
deps["node-cron"] = "^4.6.0";
|
|
112
111
|
}
|
|
113
112
|
if (set.has("encrypt")) {
|
|
114
|
-
deps["@pangza/encrypt"] = "^
|
|
113
|
+
deps["@pangza/encrypt"] = "^2.0.0";
|
|
115
114
|
}
|
|
116
115
|
|
|
117
116
|
return deps;
|
|
@@ -175,7 +174,7 @@ const DB_YAML = {
|
|
|
175
174
|
};
|
|
176
175
|
|
|
177
176
|
/**
|
|
178
|
-
*
|
|
177
|
+
* ?? application.yaml??? server.port=5270?
|
|
179
178
|
* @param {string[]} moduleIds
|
|
180
179
|
* @param {string} [dbType]
|
|
181
180
|
*/
|
|
@@ -183,7 +182,7 @@ function generateApplicationYaml(moduleIds, dbType = "mysql") {
|
|
|
183
182
|
const set = new Set(moduleIds);
|
|
184
183
|
const lines = [
|
|
185
184
|
"# Generated by create-pangza init",
|
|
186
|
-
"# profile: PANGZA_PROFILE / APP_ENV / NODE_ENV
|
|
185
|
+
"# profile: PANGZA_PROFILE / APP_ENV / NODE_ENV??? development",
|
|
187
186
|
"",
|
|
188
187
|
"server:",
|
|
189
188
|
" port: 5270",
|
|
@@ -196,9 +195,9 @@ function generateApplicationYaml(moduleIds, dbType = "mysql") {
|
|
|
196
195
|
"redis:",
|
|
197
196
|
" host: 127.0.0.1",
|
|
198
197
|
" port: 6379",
|
|
199
|
-
|
|
198
|
+
' password: ""',
|
|
200
199
|
" db: 0",
|
|
201
|
-
|
|
200
|
+
' keyPrefix: "pangza:"',
|
|
202
201
|
" mode: standalone",
|
|
203
202
|
);
|
|
204
203
|
}
|
|
@@ -213,7 +212,7 @@ function generateApplicationYaml(moduleIds, dbType = "mysql") {
|
|
|
213
212
|
" host: 127.0.0.1",
|
|
214
213
|
` port: ${db.port}`,
|
|
215
214
|
` user: ${db.user}`,
|
|
216
|
-
|
|
215
|
+
' password: ""',
|
|
217
216
|
` database: ${db.database}`,
|
|
218
217
|
" connectionLimit: 10",
|
|
219
218
|
"",
|
|
@@ -231,24 +230,21 @@ function generateApplicationYaml(moduleIds, dbType = "mysql") {
|
|
|
231
230
|
}
|
|
232
231
|
|
|
233
232
|
if (set.has("encrypt")) {
|
|
234
|
-
lines.push(
|
|
235
|
-
"",
|
|
236
|
-
"# encrypt: 密钥建议放代码或环境变量,勿提交生产密钥到仓库",
|
|
237
|
-
);
|
|
233
|
+
lines.push("", "# encrypt: ????????????????????");
|
|
238
234
|
}
|
|
239
235
|
|
|
240
236
|
if (set.has("schedule")) {
|
|
241
|
-
lines.push("", "# schedule:
|
|
237
|
+
lines.push("", "# schedule: ???? src/schedule?? Application.scan ??");
|
|
242
238
|
}
|
|
243
239
|
|
|
244
240
|
if (set.has("log")) {
|
|
245
|
-
lines.push("", "# log:
|
|
241
|
+
lines.push("", "# log: ?? registry(Log({ writer })) ??????");
|
|
246
242
|
}
|
|
247
243
|
|
|
248
244
|
if (set.has("auth")) {
|
|
249
245
|
lines.push(
|
|
250
246
|
"",
|
|
251
|
-
"# auth: jwtSecret
|
|
247
|
+
"# auth: jwtSecret ???? Auth({ ... }) ?????? yaml ????????",
|
|
252
248
|
);
|
|
253
249
|
}
|
|
254
250
|
|
|
@@ -257,7 +253,7 @@ function generateApplicationYaml(moduleIds, dbType = "mysql") {
|
|
|
257
253
|
}
|
|
258
254
|
|
|
259
255
|
/**
|
|
260
|
-
*
|
|
256
|
+
* ?????????? HTTP??? redis/orm ? Enable*????????
|
|
261
257
|
* @param {string[]} moduleIds
|
|
262
258
|
*/
|
|
263
259
|
function generateMainTs(moduleIds) {
|
|
@@ -267,8 +263,7 @@ function generateMainTs(moduleIds) {
|
|
|
267
263
|
'import "reflect-metadata";',
|
|
268
264
|
'import cors from "cors";',
|
|
269
265
|
'import { json } from "express";',
|
|
270
|
-
'import { Application } from "@pangza/
|
|
271
|
-
'import { Logger } from "@pangza/core";',
|
|
266
|
+
'import { Application, Logger } from "@pangza/express";',
|
|
272
267
|
];
|
|
273
268
|
|
|
274
269
|
if (set.has("orm")) {
|
|
@@ -286,13 +281,17 @@ function generateMainTs(moduleIds) {
|
|
|
286
281
|
|
|
287
282
|
const notes = [];
|
|
288
283
|
if (set.has("schedule")) {
|
|
289
|
-
notes.push(
|
|
284
|
+
notes.push(
|
|
285
|
+
"// Schedule: ? src/schedule ???????????@pangza/schedule?",
|
|
286
|
+
);
|
|
290
287
|
}
|
|
291
288
|
if (set.has("encrypt")) {
|
|
292
|
-
notes.push(
|
|
289
|
+
notes.push('// Encrypt: import { AESUtil } from "@pangza/encrypt"');
|
|
293
290
|
}
|
|
294
291
|
if (set.has("validate")) {
|
|
295
|
-
notes.push(
|
|
292
|
+
notes.push(
|
|
293
|
+
"// Validate: ? Controller ????? @pangza/express ?????",
|
|
294
|
+
);
|
|
296
295
|
}
|
|
297
296
|
|
|
298
297
|
const chain = [
|