@hz-9/a5-core 0.2.0-alpha.1
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/LICENSE +21 -0
- package/README.md +15 -0
- package/dist/all.d.ts +676 -0
- package/dist/const/index.d.ts +38 -0
- package/dist/const/index.js +46 -0
- package/dist/core/__import-reflect-metadata.d.ts +1 -0
- package/dist/core/__import-reflect-metadata.js +4 -0
- package/dist/core/a5-application.d.ts +154 -0
- package/dist/core/a5-application.js +315 -0
- package/dist/core/a5-console-logger.d.ts +163 -0
- package/dist/core/a5-console-logger.js +354 -0
- package/dist/core/a5-factory.d.ts +21 -0
- package/dist/core/a5-factory.js +49 -0
- package/dist/core/index.d.ts +3 -0
- package/dist/core/index.js +20 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +24 -0
- package/dist/interface/base.d.ts +18 -0
- package/dist/interface/base.js +3 -0
- package/dist/interface/http.d.ts +16 -0
- package/dist/interface/http.js +3 -0
- package/dist/interface/index.d.ts +3 -0
- package/dist/interface/index.js +20 -0
- package/dist/interface/provide-token.d.ts +21 -0
- package/dist/interface/provide-token.js +3 -0
- package/dist/middleware/a5-console-logger.middleware.d.ts +9 -0
- package/dist/middleware/a5-console-logger.middleware.js +58 -0
- package/dist/middleware/index.d.ts +1 -0
- package/dist/middleware/index.js +18 -0
- package/dist/module/config/index.d.ts +18 -0
- package/dist/module/config/index.js +36 -0
- package/dist/module/config/interface.d.ts +9 -0
- package/dist/module/config/interface.js +15 -0
- package/dist/module/index.d.ts +2 -0
- package/dist/module/index.js +19 -0
- package/dist/module/log/index.d.ts +18 -0
- package/dist/module/log/index.js +44 -0
- package/dist/module/log/interface.d.ts +9 -0
- package/dist/module/log/interface.js +15 -0
- package/dist/plugins/index.d.ts +1 -0
- package/dist/plugins/index.js +18 -0
- package/dist/plugins/nanoid.d.ts +1 -0
- package/dist/plugins/nanoid.js +6 -0
- package/dist/test/integration/core/a5-factory.integration.spec.d.ts +1 -0
- package/dist/test/integration/core/a5-factory.integration.spec.js +99 -0
- package/dist/test/integration/core/with-logger-module.integration.spec.d.ts +1 -0
- package/dist/test/integration/core/with-logger-module.integration.spec.js +401 -0
- package/dist/test/unit/core/a5-application.unit.spec.d.ts +1 -0
- package/dist/test/unit/core/a5-application.unit.spec.js +450 -0
- package/dist/test/unit/core/a5-console-logger.unit.spec.d.ts +1 -0
- package/dist/test/unit/core/a5-console-logger.unit.spec.js +998 -0
- package/dist/test/unit/middleware/a5-console-logger.middleware.unit.spec.d.ts +1 -0
- package/dist/test/unit/middleware/a5-console-logger.middleware.unit.spec.js +379 -0
- package/dist/test/unit/util/a5.util.unit.spec.d.ts +1 -0
- package/dist/test/unit/util/a5.util.unit.spec.js +109 -0
- package/dist/test/unit/util/color.util.unit.spec.d.ts +1 -0
- package/dist/test/unit/util/color.util.unit.spec.js +277 -0
- package/dist/test/unit/util/logo.util.unit.spec.d.ts +1 -0
- package/dist/test/unit/util/logo.util.unit.spec.js +202 -0
- package/dist/test/unit/util/run-env.util.unit.spec.d.ts +1 -0
- package/dist/test/unit/util/run-env.util.unit.spec.js +183 -0
- package/dist/util/a5.util.d.ts +27 -0
- package/dist/util/a5.util.js +41 -0
- package/dist/util/color.util.d.ts +26 -0
- package/dist/util/color.util.js +62 -0
- package/dist/util/index.d.ts +5 -0
- package/dist/util/index.js +22 -0
- package/dist/util/load-package.util.d.ts +29 -0
- package/dist/util/load-package.util.js +71 -0
- package/dist/util/logo.util.d.ts +31 -0
- package/dist/util/logo.util.js +59 -0
- package/dist/util/run-env.util.d.ts +28 -0
- package/dist/util/run-env.util.js +48 -0
- package/logo +7 -0
- package/package.json +96 -0
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*
|
|
3
|
+
* @public
|
|
4
|
+
*
|
|
5
|
+
* 通用工具类
|
|
6
|
+
*
|
|
7
|
+
*/
|
|
8
|
+
export declare class A5Util {
|
|
9
|
+
/**
|
|
10
|
+
*
|
|
11
|
+
* 睡眠。
|
|
12
|
+
*
|
|
13
|
+
* @param t - 时间。单位:毫秒
|
|
14
|
+
*/
|
|
15
|
+
static sleep(t: number): Promise<void>;
|
|
16
|
+
/**
|
|
17
|
+
* @public
|
|
18
|
+
*
|
|
19
|
+
* 如果不是绝对路径,则进行拼接
|
|
20
|
+
*
|
|
21
|
+
* @param sourcePath - 资源路径
|
|
22
|
+
* @param basePath - 基础路径
|
|
23
|
+
*
|
|
24
|
+
* @returns 资源路径的绝对路径。
|
|
25
|
+
*/
|
|
26
|
+
static tryWithAbsolutePath(sourcePath: string, basePath: string): string;
|
|
27
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.A5Util = void 0;
|
|
4
|
+
const upath_1 = require("upath");
|
|
5
|
+
/**
|
|
6
|
+
*
|
|
7
|
+
* @public
|
|
8
|
+
*
|
|
9
|
+
* 通用工具类
|
|
10
|
+
*
|
|
11
|
+
*/
|
|
12
|
+
class A5Util {
|
|
13
|
+
/**
|
|
14
|
+
*
|
|
15
|
+
* 睡眠。
|
|
16
|
+
*
|
|
17
|
+
* @param t - 时间。单位:毫秒
|
|
18
|
+
*/
|
|
19
|
+
static async sleep(t) {
|
|
20
|
+
return new Promise((resolve) => {
|
|
21
|
+
setTimeout(resolve, t);
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* @public
|
|
26
|
+
*
|
|
27
|
+
* 如果不是绝对路径,则进行拼接
|
|
28
|
+
*
|
|
29
|
+
* @param sourcePath - 资源路径
|
|
30
|
+
* @param basePath - 基础路径
|
|
31
|
+
*
|
|
32
|
+
* @returns 资源路径的绝对路径。
|
|
33
|
+
*/
|
|
34
|
+
static tryWithAbsolutePath(sourcePath, basePath) {
|
|
35
|
+
return (0, upath_1.isAbsolute)((0, upath_1.normalize)(sourcePath))
|
|
36
|
+
? (0, upath_1.normalize)(sourcePath)
|
|
37
|
+
: (0, upath_1.resolve)((0, upath_1.normalize)(basePath), (0, upath_1.normalize)(sourcePath));
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
exports.A5Util = A5Util;
|
|
41
|
+
//# sourceMappingURL=a5.util.js.map
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @public
|
|
3
|
+
*/
|
|
4
|
+
export declare class ColorUtil {
|
|
5
|
+
static get isColorAllowed(): boolean;
|
|
6
|
+
static bold(text: string): string;
|
|
7
|
+
static red(text: string): string;
|
|
8
|
+
static green(text: string): string;
|
|
9
|
+
static yellow(text: string): string;
|
|
10
|
+
static blue(text: string): string;
|
|
11
|
+
static magenta(text: string): string;
|
|
12
|
+
static cyan(text: string): string;
|
|
13
|
+
static redBright(text: string): string;
|
|
14
|
+
static greenBright(text: string): string;
|
|
15
|
+
static yellowBright(text: string): string;
|
|
16
|
+
static blueBright(text: string): string;
|
|
17
|
+
static magentaBright(text: string): string;
|
|
18
|
+
static cyanBright(text: string): string;
|
|
19
|
+
/**
|
|
20
|
+
* 移除 ANSI 颜色代码
|
|
21
|
+
*
|
|
22
|
+
* @param text - text to clear
|
|
23
|
+
* @returns cleaned text
|
|
24
|
+
*/
|
|
25
|
+
static clear(text: string): string;
|
|
26
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ColorUtil = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* @public
|
|
6
|
+
*/
|
|
7
|
+
class ColorUtil {
|
|
8
|
+
static get isColorAllowed() {
|
|
9
|
+
return !('NO_COLOR' in process.env && (!!process.env.NO_COLOR || process.env.NO_COLOR === ''));
|
|
10
|
+
}
|
|
11
|
+
static bold(text) {
|
|
12
|
+
return ColorUtil.isColorAllowed ? `\x1B[1m${text}\x1B[0m` : text;
|
|
13
|
+
}
|
|
14
|
+
static red(text) {
|
|
15
|
+
return ColorUtil.isColorAllowed ? `\x1B[31m${text}\x1B[39m` : text;
|
|
16
|
+
}
|
|
17
|
+
static green(text) {
|
|
18
|
+
return ColorUtil.isColorAllowed ? `\x1B[32m${text}\x1B[39m` : text;
|
|
19
|
+
}
|
|
20
|
+
static yellow(text) {
|
|
21
|
+
return ColorUtil.isColorAllowed ? `\x1B[33m${text}\x1B[39m` : text;
|
|
22
|
+
}
|
|
23
|
+
static blue(text) {
|
|
24
|
+
return ColorUtil.isColorAllowed ? `\x1B[34m${text}\x1B[39m` : text;
|
|
25
|
+
}
|
|
26
|
+
static magenta(text) {
|
|
27
|
+
return ColorUtil.isColorAllowed ? `\x1B[35m${text}\x1B[39m` : text;
|
|
28
|
+
}
|
|
29
|
+
static cyan(text) {
|
|
30
|
+
return ColorUtil.isColorAllowed ? `\x1B[36m${text}\x1B[39m` : text;
|
|
31
|
+
}
|
|
32
|
+
static redBright(text) {
|
|
33
|
+
return ColorUtil.isColorAllowed ? `\x1B[91m${text}\x1B[39m` : text;
|
|
34
|
+
}
|
|
35
|
+
static greenBright(text) {
|
|
36
|
+
return ColorUtil.isColorAllowed ? `\x1B[92m${text}\x1B[39m` : text;
|
|
37
|
+
}
|
|
38
|
+
static yellowBright(text) {
|
|
39
|
+
return ColorUtil.isColorAllowed ? `\x1B[93m${text}\x1B[39m` : text;
|
|
40
|
+
}
|
|
41
|
+
static blueBright(text) {
|
|
42
|
+
return ColorUtil.isColorAllowed ? `\x1B[94m${text}\x1B[39m` : text;
|
|
43
|
+
}
|
|
44
|
+
static magentaBright(text) {
|
|
45
|
+
return ColorUtil.isColorAllowed ? `\x1B[95m${text}\x1B[39m` : text;
|
|
46
|
+
}
|
|
47
|
+
static cyanBright(text) {
|
|
48
|
+
return ColorUtil.isColorAllowed ? `\x1B[96m${text}\x1B[39m` : text;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* 移除 ANSI 颜色代码
|
|
52
|
+
*
|
|
53
|
+
* @param text - text to clear
|
|
54
|
+
* @returns cleaned text
|
|
55
|
+
*/
|
|
56
|
+
static clear(text) {
|
|
57
|
+
// eslint-disable-next-line no-control-regex
|
|
58
|
+
return text.replace(/\x1B\[[0-9;]*[A-Za-z]/g, '');
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
exports.ColorUtil = ColorUtil;
|
|
62
|
+
//# sourceMappingURL=color.util.js.map
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./a5.util"), exports);
|
|
18
|
+
__exportStar(require("./color.util"), exports);
|
|
19
|
+
__exportStar(require("./load-package.util"), exports);
|
|
20
|
+
__exportStar(require("./logo.util"), exports);
|
|
21
|
+
__exportStar(require("./run-env.util"), exports);
|
|
22
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 包加载工具类
|
|
3
|
+
* 用于统一处理可选依赖的动态导入
|
|
4
|
+
* @public
|
|
5
|
+
*/
|
|
6
|
+
export declare class LoadPackageUtil {
|
|
7
|
+
/**
|
|
8
|
+
* 动态加载包
|
|
9
|
+
* @param packageName - 包名
|
|
10
|
+
* @returns 加载的包模块
|
|
11
|
+
* @throws 当包加载失败时抛出错误
|
|
12
|
+
*/
|
|
13
|
+
static loadPackage<T = unknown>(packageName: string): Promise<T>;
|
|
14
|
+
/**
|
|
15
|
+
* 安全地动态加载包
|
|
16
|
+
* @param packageName - 包名
|
|
17
|
+
* @returns 加载的包模块,如果失败则返回 null
|
|
18
|
+
*/
|
|
19
|
+
static loadPackageSafe<T = unknown>(packageName: string): Promise<T | null>;
|
|
20
|
+
/**
|
|
21
|
+
* 带重试的动态加载包
|
|
22
|
+
* @param packageName - 包名
|
|
23
|
+
* @param retries - 重试次数,默认为 3
|
|
24
|
+
* @param retryDelay - 重试间隔(毫秒),默认为 100
|
|
25
|
+
* @returns 加载的包模块
|
|
26
|
+
* @throws 当所有重试都失败时抛出错误
|
|
27
|
+
*/
|
|
28
|
+
static loadPackageWithRetry<T = unknown>(packageName: string, retries?: number, retryDelay?: number): Promise<T>;
|
|
29
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.LoadPackageUtil = void 0;
|
|
4
|
+
const a5_util_1 = require("./a5.util");
|
|
5
|
+
// TODO 当前文件,并未编写单元测试
|
|
6
|
+
/**
|
|
7
|
+
* 包加载工具类
|
|
8
|
+
* 用于统一处理可选依赖的动态导入
|
|
9
|
+
* @public
|
|
10
|
+
*/
|
|
11
|
+
class LoadPackageUtil {
|
|
12
|
+
/**
|
|
13
|
+
* 动态加载包
|
|
14
|
+
* @param packageName - 包名
|
|
15
|
+
* @returns 加载的包模块
|
|
16
|
+
* @throws 当包加载失败时抛出错误
|
|
17
|
+
*/
|
|
18
|
+
static async loadPackage(packageName) {
|
|
19
|
+
try {
|
|
20
|
+
// 使用 Dynimic_import 引入模块,仍会显示 ERR_VM_DYNAMIC_IMPORT_CALLBACK_MISSING_FLAG 报错,
|
|
21
|
+
// 使用 require 进行动态引入;
|
|
22
|
+
// const module = await import(packageName)
|
|
23
|
+
// eslint-disable-next-line global-require, import/no-dynamic-require
|
|
24
|
+
const module = require(packageName);
|
|
25
|
+
return module;
|
|
26
|
+
}
|
|
27
|
+
catch (error) {
|
|
28
|
+
// TODO 优化报错显示
|
|
29
|
+
throw new Error(`Failed to load package "${packageName}": ${error instanceof Error ? error.message : String(error)}`);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* 安全地动态加载包
|
|
34
|
+
* @param packageName - 包名
|
|
35
|
+
* @returns 加载的包模块,如果失败则返回 null
|
|
36
|
+
*/
|
|
37
|
+
static async loadPackageSafe(packageName) {
|
|
38
|
+
try {
|
|
39
|
+
return await LoadPackageUtil.loadPackage(packageName);
|
|
40
|
+
}
|
|
41
|
+
catch {
|
|
42
|
+
return null;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* 带重试的动态加载包
|
|
47
|
+
* @param packageName - 包名
|
|
48
|
+
* @param retries - 重试次数,默认为 3
|
|
49
|
+
* @param retryDelay - 重试间隔(毫秒),默认为 100
|
|
50
|
+
* @returns 加载的包模块
|
|
51
|
+
* @throws 当所有重试都失败时抛出错误
|
|
52
|
+
*/
|
|
53
|
+
static async loadPackageWithRetry(packageName, retries = 3, retryDelay = 100) {
|
|
54
|
+
let lastError = null;
|
|
55
|
+
for (let i = 0; i <= retries; i += 1) {
|
|
56
|
+
try {
|
|
57
|
+
return await LoadPackageUtil.loadPackage(packageName);
|
|
58
|
+
}
|
|
59
|
+
catch (error) {
|
|
60
|
+
lastError = error instanceof Error ? error : new Error(String(error));
|
|
61
|
+
if (i < retries) {
|
|
62
|
+
// 等待重试间隔
|
|
63
|
+
await a5_util_1.A5Util.sleep(retryDelay);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
throw lastError || new Error(`Failed to load package "${packageName}" after ${retries + 1} attempts`);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
exports.LoadPackageUtil = LoadPackageUtil;
|
|
71
|
+
//# sourceMappingURL=load-package.util.js.map
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 因 `logo` 字符串特殊字符过多,不应直接存放当前文件。
|
|
3
|
+
*
|
|
4
|
+
* 进行 base64 编码并存放。
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
*
|
|
8
|
+
* @public
|
|
9
|
+
*
|
|
10
|
+
* 打印 Logo。
|
|
11
|
+
*
|
|
12
|
+
* logo 是在 http://patorjk.com/software/taag/#p=display&f=Big&t=a5 进行制作的。
|
|
13
|
+
*
|
|
14
|
+
*/
|
|
15
|
+
export declare class LogoUtil {
|
|
16
|
+
private static _content;
|
|
17
|
+
/**
|
|
18
|
+
* Logo 的文本信息。
|
|
19
|
+
*/
|
|
20
|
+
static get content(): string;
|
|
21
|
+
/**
|
|
22
|
+
*
|
|
23
|
+
* 打印 A5 的 Logo 及版本信息。
|
|
24
|
+
*
|
|
25
|
+
* 使用 `console.log` 输出信息,不会写入到日志文件中。
|
|
26
|
+
*
|
|
27
|
+
* @param onlyLogo - 仅打印 Logo,不包含版本信息。可选。默认为 false
|
|
28
|
+
*
|
|
29
|
+
*/
|
|
30
|
+
static print(onlyLogo?: boolean): void;
|
|
31
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.LogoUtil = void 0;
|
|
7
|
+
const node_console_1 = __importDefault(require("node:console"));
|
|
8
|
+
const node_fs_1 = __importDefault(require("node:fs"));
|
|
9
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
10
|
+
const color_util_1 = require("./color.util");
|
|
11
|
+
/**
|
|
12
|
+
* 因 `logo` 字符串特殊字符过多,不应直接存放当前文件。
|
|
13
|
+
*
|
|
14
|
+
* 进行 base64 编码并存放。
|
|
15
|
+
*/
|
|
16
|
+
/**
|
|
17
|
+
*
|
|
18
|
+
* @public
|
|
19
|
+
*
|
|
20
|
+
* 打印 Logo。
|
|
21
|
+
*
|
|
22
|
+
* logo 是在 http://patorjk.com/software/taag/#p=display&f=Big&t=a5 进行制作的。
|
|
23
|
+
*
|
|
24
|
+
*/
|
|
25
|
+
class LogoUtil {
|
|
26
|
+
/**
|
|
27
|
+
* Logo 的文本信息。
|
|
28
|
+
*/
|
|
29
|
+
static get content() {
|
|
30
|
+
if (!this._content) {
|
|
31
|
+
this._content = node_fs_1.default.readFileSync(node_path_1.default.resolve(__dirname, '../../logo'), { encoding: 'utf8' });
|
|
32
|
+
}
|
|
33
|
+
return this._content;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
*
|
|
37
|
+
* 打印 A5 的 Logo 及版本信息。
|
|
38
|
+
*
|
|
39
|
+
* 使用 `console.log` 输出信息,不会写入到日志文件中。
|
|
40
|
+
*
|
|
41
|
+
* @param onlyLogo - 仅打印 Logo,不包含版本信息。可选。默认为 false
|
|
42
|
+
*
|
|
43
|
+
*/
|
|
44
|
+
static print(onlyLogo = false) {
|
|
45
|
+
const logoLines = this.content.split('\n');
|
|
46
|
+
const packageInfo = node_fs_1.default.readFileSync(node_path_1.default.resolve(__dirname, '../../package.json'), { encoding: 'utf8' });
|
|
47
|
+
const { version } = JSON.parse(packageInfo);
|
|
48
|
+
if (!onlyLogo) {
|
|
49
|
+
// logoLines[1] = `${logoLines[1]}`
|
|
50
|
+
logoLines[logoLines.length - 2] = `${logoLines[logoLines.length - 2]} ${version}`;
|
|
51
|
+
}
|
|
52
|
+
node_console_1.default.log('');
|
|
53
|
+
node_console_1.default.log(color_util_1.ColorUtil.magenta(logoLines.join('\n')));
|
|
54
|
+
node_console_1.default.log('');
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
exports.LogoUtil = LogoUtil;
|
|
58
|
+
LogoUtil._content = undefined;
|
|
59
|
+
//# sourceMappingURL=logo.util.js.map
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @public
|
|
3
|
+
*
|
|
4
|
+
* 当前运行环境。
|
|
5
|
+
*
|
|
6
|
+
*/
|
|
7
|
+
export declare class RunEnvUtil {
|
|
8
|
+
/**
|
|
9
|
+
* 是否处于开发环境.
|
|
10
|
+
*/
|
|
11
|
+
static get isDev(): boolean;
|
|
12
|
+
/**
|
|
13
|
+
* 是否处于生产环境.
|
|
14
|
+
*/
|
|
15
|
+
static get isProd(): boolean;
|
|
16
|
+
/**
|
|
17
|
+
* 是否处于 PKG 打包后的环境。
|
|
18
|
+
*/
|
|
19
|
+
static get inPKG(): boolean;
|
|
20
|
+
/**
|
|
21
|
+
* 是否处于 `VS Code` 的 `Debugger` 模式下。
|
|
22
|
+
*/
|
|
23
|
+
static get inVSCodeDebugger(): boolean;
|
|
24
|
+
/**
|
|
25
|
+
* 是否处于 `Jest` 的单元测试环境下。
|
|
26
|
+
*/
|
|
27
|
+
static get inJest(): boolean;
|
|
28
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RunEnvUtil = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* @public
|
|
6
|
+
*
|
|
7
|
+
* 当前运行环境。
|
|
8
|
+
*
|
|
9
|
+
*/
|
|
10
|
+
class RunEnvUtil {
|
|
11
|
+
/**
|
|
12
|
+
* 是否处于开发环境.
|
|
13
|
+
*/
|
|
14
|
+
static get isDev() {
|
|
15
|
+
/**
|
|
16
|
+
* 自动修正 NODE_ENV
|
|
17
|
+
*/
|
|
18
|
+
if (!('NODE_ENV' in process.env))
|
|
19
|
+
process.env.NODE_ENV = 'development';
|
|
20
|
+
return process.env.NODE_ENV === 'development' || process.env.NODE_ENV === 'dev';
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* 是否处于生产环境.
|
|
24
|
+
*/
|
|
25
|
+
static get isProd() {
|
|
26
|
+
return process.env.NODE_ENV === 'production' || process.env.NODE_ENV === 'prod';
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* 是否处于 PKG 打包后的环境。
|
|
30
|
+
*/
|
|
31
|
+
static get inPKG() {
|
|
32
|
+
return 'pkg' in process && typeof process.pkg === 'object' && process.pkg !== null;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* 是否处于 `VS Code` 的 `Debugger` 模式下。
|
|
36
|
+
*/
|
|
37
|
+
static get inVSCodeDebugger() {
|
|
38
|
+
return 'VSCODE_INSPECTOR_OPTIONS' in process.env && process.env.VSCODE_INSPECTOR_OPTIONS !== undefined;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* 是否处于 `Jest` 的单元测试环境下。
|
|
42
|
+
*/
|
|
43
|
+
static get inJest() {
|
|
44
|
+
return 'JEST_WORKER_ID' in process.env && process.env.JEST_WORKER_ID !== undefined;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
exports.RunEnvUtil = RunEnvUtil;
|
|
48
|
+
//# sourceMappingURL=run-env.util.js.map
|
package/logo
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@hz-9/a5-core",
|
|
3
|
+
"version": "0.2.0-alpha.1",
|
|
4
|
+
"description": "The core library for the `@hz-9/a5-*` series of repositories.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"nest",
|
|
7
|
+
"a5",
|
|
8
|
+
"a5-core"
|
|
9
|
+
],
|
|
10
|
+
"homepage": "https://hz-9.github.io/a5/guide/a5-core",
|
|
11
|
+
"bugs": {
|
|
12
|
+
"url": "https://github.com/hz-9/a5/issues"
|
|
13
|
+
},
|
|
14
|
+
"repository": {
|
|
15
|
+
"type": "git",
|
|
16
|
+
"url": "https://github.com/hz-9/a5.git",
|
|
17
|
+
"directory": "library/core"
|
|
18
|
+
},
|
|
19
|
+
"license": "MIT",
|
|
20
|
+
"author": "Chen Zhen <heavenzhen999@163.com>",
|
|
21
|
+
"exports": {
|
|
22
|
+
".": {
|
|
23
|
+
"require": "./dist/index.js",
|
|
24
|
+
"types": "./dist/index.d.ts"
|
|
25
|
+
},
|
|
26
|
+
"./*": {
|
|
27
|
+
"require": "./dist/*.js",
|
|
28
|
+
"types": "./dist/*.d.ts"
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
"main": "./dist/index.js",
|
|
32
|
+
"types": "./dist/index.d.ts",
|
|
33
|
+
"files": [
|
|
34
|
+
"dist/**/*.{d.ts,js}",
|
|
35
|
+
"CHANGELOG.md",
|
|
36
|
+
"public",
|
|
37
|
+
"logo"
|
|
38
|
+
],
|
|
39
|
+
"dependencies": {
|
|
40
|
+
"@nestjs/platform-fastify": "^10.0.0",
|
|
41
|
+
"fastify": "4.28.1",
|
|
42
|
+
"@types/fs-extra": "~11.0.3",
|
|
43
|
+
"@types/heft-jest": "~1.0.3",
|
|
44
|
+
"@types/lodash": "~4.17.4",
|
|
45
|
+
"@types/node": "~20.3.1",
|
|
46
|
+
"@types/pug": "~2.0.10",
|
|
47
|
+
"@types/uuid": "~9.0.8",
|
|
48
|
+
"@type-challenges/utils": "~0.1.1",
|
|
49
|
+
"axios": "~1.7.2",
|
|
50
|
+
"body-parser": "~1.20.2",
|
|
51
|
+
"dayjs": "~1.11.10",
|
|
52
|
+
"fs-extra": "~11.1.1",
|
|
53
|
+
"lodash": "~4.17.21",
|
|
54
|
+
"nanoid": "^3.3.7",
|
|
55
|
+
"pug": "~3.0.3",
|
|
56
|
+
"type-fest": "~4.20.0",
|
|
57
|
+
"upath": "~2.0.1",
|
|
58
|
+
"ua-parser-js": "~1.0.38"
|
|
59
|
+
},
|
|
60
|
+
"devDependencies": {
|
|
61
|
+
"@hz-9/eslint-config-airbnb-ts": "~0.6.0",
|
|
62
|
+
"@nestjs/cli": "^10.0.0",
|
|
63
|
+
"@nestjs/common": "^10.0.0",
|
|
64
|
+
"@nestjs/core": "^10.0.0",
|
|
65
|
+
"@nestjs/swagger": "~7.1.14",
|
|
66
|
+
"@nestjs/testing": "^10.0.0",
|
|
67
|
+
"@rushstack/heft": "0.66.1",
|
|
68
|
+
"@types/body-parser": "~1.19.5",
|
|
69
|
+
"@types/supertest": "~6.0.2",
|
|
70
|
+
"@types/ua-parser-js": "~0.7.39",
|
|
71
|
+
"eslint": "^8.2.0",
|
|
72
|
+
"reflect-metadata": "^0.1.13",
|
|
73
|
+
"rxjs": "^7.8.1",
|
|
74
|
+
"typescript": ">=5.0.0 <5.4.0",
|
|
75
|
+
"supertest": "~7.0.0",
|
|
76
|
+
"@hz-9/heft-nest-rig": "0.1.2"
|
|
77
|
+
},
|
|
78
|
+
"peerDependencies": {
|
|
79
|
+
"@nestjs/common": "^10.0.0",
|
|
80
|
+
"@nestjs/core": "^10.0.0",
|
|
81
|
+
"reflect-metadata": "^0.1.13",
|
|
82
|
+
"rxjs": "^7.8.1"
|
|
83
|
+
},
|
|
84
|
+
"publishConfig": {
|
|
85
|
+
"access": "public"
|
|
86
|
+
},
|
|
87
|
+
"scripts": {
|
|
88
|
+
"build": "heft test-all --clean",
|
|
89
|
+
"build:sync": "npm run build && node ./.utils/repair.js && node ./.utils/sync-dist.js",
|
|
90
|
+
"lint": "heft lint",
|
|
91
|
+
"test": "heft test --clean",
|
|
92
|
+
"test:watch": "heft test-watch",
|
|
93
|
+
"test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand",
|
|
94
|
+
"test:e2e": "jest --config ./test/jest-e2e.json"
|
|
95
|
+
}
|
|
96
|
+
}
|