@domain.js/main 0.1.3 → 0.1.5
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/.husky/pre-commit +1 -1
- package/dist/cli/index.js +4 -4
- package/dist/cli/schema2ts.d.ts +1 -0
- package/dist/cli/schema2ts.js +37 -0
- package/dist/dm/index.d.ts +1 -1
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.js +2 -0
- package/package.json +6 -3
package/.husky/pre-commit
CHANGED
package/dist/cli/index.js
CHANGED
|
@@ -79,7 +79,7 @@ const checkHookExport = (_dir) => {
|
|
|
79
79
|
const loadDeps = async (rootDir = process.cwd(), ext = "js") => {
|
|
80
80
|
const isTS = ext === "ts";
|
|
81
81
|
const modules = [];
|
|
82
|
-
const dir = path.resolve(rootDir, "
|
|
82
|
+
const dir = path.resolve(rootDir, "./");
|
|
83
83
|
for (const x of fs.readdirSync(dir)) {
|
|
84
84
|
// 忽略隐藏目录
|
|
85
85
|
if (x[0] === ".")
|
|
@@ -93,7 +93,7 @@ const loadDeps = async (rootDir = process.cwd(), ext = "js") => {
|
|
|
93
93
|
modules.push(x);
|
|
94
94
|
}
|
|
95
95
|
// 按字典排序,后续有变动的时候不容易冲突
|
|
96
|
-
const targetFile = path.resolve(rootDir,
|
|
96
|
+
const targetFile = path.resolve(rootDir, `./defines.${ext}`);
|
|
97
97
|
await makeDefineFile(modules.sort(), targetFile, isTS);
|
|
98
98
|
};
|
|
99
99
|
const checkService = (_dir) => {
|
|
@@ -106,7 +106,7 @@ const checkService = (_dir) => {
|
|
|
106
106
|
const loadServices = async (rootDir = process.cwd(), ext = "js") => {
|
|
107
107
|
const isTS = ext === "ts";
|
|
108
108
|
const modules = [];
|
|
109
|
-
const dir = path.resolve(rootDir, "
|
|
109
|
+
const dir = path.resolve(rootDir, "domain/services/");
|
|
110
110
|
for (const x of fs.readdirSync(dir)) {
|
|
111
111
|
// 忽略隐藏目录, 忽略私有目录
|
|
112
112
|
if (x[0] === "." || x[0] === "_")
|
|
@@ -120,7 +120,7 @@ const loadServices = async (rootDir = process.cwd(), ext = "js") => {
|
|
|
120
120
|
modules.push(x);
|
|
121
121
|
}
|
|
122
122
|
// 按字典排序,后续有变动的时候不容易冲突
|
|
123
|
-
const targetFile = path.resolve(rootDir, `
|
|
123
|
+
const targetFile = path.resolve(rootDir, `domain/services/defines.${ext}`);
|
|
124
124
|
await makeDefineFile(modules.sort(), targetFile, isTS);
|
|
125
125
|
};
|
|
126
126
|
const deepLoadDir = (root, parent, files = []) => {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const path = require("path");
|
|
4
|
+
const fs = require("fs");
|
|
5
|
+
const json_schema_to_typescript_1 = require("json-schema-to-typescript");
|
|
6
|
+
const _require = require;
|
|
7
|
+
async function main(file, single = false, name = "Params") {
|
|
8
|
+
const stats = fs.statSync(file);
|
|
9
|
+
if (stats.isFile()) {
|
|
10
|
+
const arr = file.split(".");
|
|
11
|
+
if (arr.pop() !== "js")
|
|
12
|
+
return;
|
|
13
|
+
const obj = _require(file);
|
|
14
|
+
if (!single) {
|
|
15
|
+
if (!Array.isArray(obj))
|
|
16
|
+
return;
|
|
17
|
+
if (typeof obj[1] !== "object")
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
try {
|
|
21
|
+
const ts = await (0, json_schema_to_typescript_1.compile)(single ? obj : obj[1], name);
|
|
22
|
+
arr.push("d.ts");
|
|
23
|
+
fs.writeFileSync(arr.join("."), ts);
|
|
24
|
+
}
|
|
25
|
+
catch (e) {
|
|
26
|
+
console.error(file, e);
|
|
27
|
+
}
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
const files = fs.readdirSync(file);
|
|
31
|
+
for await (const x of files) {
|
|
32
|
+
if (x === "." || x === "..")
|
|
33
|
+
continue;
|
|
34
|
+
await main(path.resolve(file, x), single, name);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
main(process.argv[2], process.argv[3] === "single", process.argv[4]);
|
package/dist/dm/index.d.ts
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare type ReadonlyArray2union<T extends ReadonlyArray<any>> = T extends ReadonlyArray<infer A> ? A : never;
|
package/package.json
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@domain.js/main",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.5",
|
|
4
4
|
"description": "DDD framework",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
|
-
"bin":
|
|
6
|
+
"bin": {
|
|
7
|
+
"domain-cli": "dist/cli/index.js"
|
|
8
|
+
},
|
|
7
9
|
"scripts": {
|
|
8
10
|
"build": "tsc",
|
|
9
11
|
"test": "export NODE_ENV=test && jest ./src --coverage",
|
|
@@ -66,13 +68,14 @@
|
|
|
66
68
|
"csv-stringify": "^6.0.2",
|
|
67
69
|
"human-interval": "^2.0.1",
|
|
68
70
|
"ioredis": "^4.28.0",
|
|
71
|
+
"json-schema-to-typescript": "^10.1.5",
|
|
69
72
|
"lodash": "^4.17.21",
|
|
70
73
|
"lru-cache": "^6.0.0",
|
|
71
74
|
"moment": "^2.29.1",
|
|
72
75
|
"mysql2": "^2.3.3",
|
|
73
76
|
"restify": "^8.6.0",
|
|
74
77
|
"restify-errors": "^8.0.2",
|
|
75
|
-
"sequelize": "
|
|
78
|
+
"sequelize": "6.12.1",
|
|
76
79
|
"swagger-ui-restify": "^3.0.8",
|
|
77
80
|
"type-fest": "^2.8.0",
|
|
78
81
|
"uuid": "^8.3.2",
|