@e-mc/module 0.9.9 → 0.9.10
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 +10 -10
- package/README.md +401 -401
- package/index.js +35 -38
- package/package.json +31 -31
package/LICENSE
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
Copyright 2024 An Pham
|
|
2
|
-
|
|
3
|
-
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
|
4
|
-
|
|
5
|
-
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
|
6
|
-
|
|
7
|
-
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
|
8
|
-
|
|
9
|
-
3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
|
|
10
|
-
|
|
1
|
+
Copyright 2024 An Pham
|
|
2
|
+
|
|
3
|
+
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
|
4
|
+
|
|
5
|
+
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
|
6
|
+
|
|
7
|
+
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
|
8
|
+
|
|
9
|
+
3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
|
|
10
|
+
|
|
11
11
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
package/README.md
CHANGED
|
@@ -1,402 +1,402 @@
|
|
|
1
|
-
# @e-mc/module
|
|
2
|
-
|
|
3
|
-
* NodeJS 16
|
|
4
|
-
* ES2020
|
|
5
|
-
|
|
6
|
-
## General Usage
|
|
7
|
-
|
|
8
|
-
* [Read the Docs](https://e-mc.readthedocs.io)
|
|
9
|
-
|
|
10
|
-
## Interface
|
|
11
|
-
|
|
12
|
-
* [View Source](https://www.unpkg.com/@e-mc/types@0.9.
|
|
13
|
-
|
|
14
|
-
```typescript
|
|
15
|
-
import type { LogStatus } from "./squared";
|
|
16
|
-
|
|
17
|
-
import type { IHost } from "./index";
|
|
18
|
-
import type { IAbortComponent, IPermission } from "./core";
|
|
19
|
-
import type { LOG_TYPE, STATUS_TYPE, ExecCommand, LogArguments, LogComponent, LogDate, LogFailOptions, LogMessageOptions, LogOptions, LogProcessOptions, LogTime, LogType, LogValue, LoggerFormat, StatusType } from "./logger";
|
|
20
|
-
import type { AsHashOptions, CheckSemVerOptions, CopyDirOptions, CopyDirResult, CopyFileOptions, CreateDirOptions, DeleteFileOptions, GetTempDirOptions, MoveFileOptions, NormalizeFlags, ParseFunctionOptions, PermissionOptions, ProtocolType, ReadBufferOptions, ReadFileCallback, ReadFileOptions, ReadHashOptions, ReadTextOptions, RemoveDirOptions, WriteFileOptions } from "./module";
|
|
21
|
-
import type { Settings } from "./node";
|
|
22
|
-
import type { LoggerFormatSettings } from "/settings";
|
|
23
|
-
|
|
24
|
-
import type { SpawnOptions } from "child_process";
|
|
25
|
-
import type { BinaryLike } from "crypto";
|
|
26
|
-
import type { FileTypeResult } from "file-type";
|
|
27
|
-
import type { NoParamCallback } from "fs";
|
|
28
|
-
|
|
29
|
-
import type * as EventEmitter from "events";
|
|
30
|
-
|
|
31
|
-
type BufferView = Buffer | string | NodeJS.ArrayBufferView;
|
|
32
|
-
type CpuUsage = NodeJS.CpuUsage;
|
|
33
|
-
|
|
34
|
-
interface IModule extends EventEmitter, IAbortComponent {
|
|
35
|
-
readonly status: LogStatus<StatusType>[];
|
|
36
|
-
readonly errors: unknown[];
|
|
37
|
-
supported(major: number, minor?: number, patch?: number, lts?: boolean): boolean;
|
|
38
|
-
supports(name: string, value?: boolean): boolean;
|
|
39
|
-
getTempDir(options: GetTempDirOptions): string;
|
|
40
|
-
getTempDir(uuidDir: boolean, createDir: boolean): string;
|
|
41
|
-
getTempDir(pathname: string, createDir: boolean): string;
|
|
42
|
-
getTempDir(uuidDir: boolean, filename?: string, createDir?: boolean): string;
|
|
43
|
-
getTempDir(pathname?: string, filename?: string, createDir?: boolean): string;
|
|
44
|
-
canRead(uri: string, options?: PermissionOptions): boolean;
|
|
45
|
-
canWrite(uri: string, options?: PermissionOptions): boolean;
|
|
46
|
-
readFile(src: string): Buffer | undefined;
|
|
47
|
-
readFile(src: string, options?: ReadFileOptions): Promise<Buffer | string> | Buffer | string | undefined;
|
|
48
|
-
readFile(src: string, promises: true): Promise<Buffer | undefined>;
|
|
49
|
-
readFile(src: string, options: ReadFileOptions, promises: true): Promise<Buffer | string | undefined>;
|
|
50
|
-
readFile(src: string, callback: ReadFileCallback<Buffer | string>): Buffer | string | undefined;
|
|
51
|
-
readFile(src: string, options: ReadFileOptions, callback: ReadFileCallback<Buffer | string>): Buffer | string | undefined;
|
|
52
|
-
writeFile(src: string, data: BufferView, options?: WriteFileOptions): boolean;
|
|
53
|
-
writeFile(src: string, data: BufferView, promises: true): Promise<boolean>;
|
|
54
|
-
writeFile(src: string, data: BufferView, options: WriteFileOptions, promises: true): Promise<boolean>;
|
|
55
|
-
writeFile(src: string, data: BufferView, callback: NoParamCallback): void;
|
|
56
|
-
writeFile(src: string, data: BufferView, options: WriteFileOptions, callback: NoParamCallback): void;
|
|
57
|
-
deleteFile(src: string, options?: DeleteFileOptions): boolean;
|
|
58
|
-
deleteFile(src: string, promises: true): Promise<boolean>;
|
|
59
|
-
deleteFile(src: string, options: DeleteFileOptions, promises: true): Promise<boolean>;
|
|
60
|
-
deleteFile(src: string, callback: NoParamCallback): void;
|
|
61
|
-
deleteFile(src: string, options: DeleteFileOptions, callback: NoParamCallback): void;
|
|
62
|
-
copyFile(src: string, dest: string, options?: CopyFileOptions): boolean;
|
|
63
|
-
copyFile(src: string, dest: string, promises: true): Promise<boolean>;
|
|
64
|
-
copyFile(src: string, dest: string, options: CopyFileOptions, promises: true): Promise<boolean>;
|
|
65
|
-
copyFile(src: string, dest: string, callback: NoParamCallback): void;
|
|
66
|
-
copyFile(src: string, dest: string, options: CopyFileOptions, callback: NoParamCallback): void;
|
|
67
|
-
moveFile(src: string, dest: string, options?: MoveFileOptions): boolean;
|
|
68
|
-
moveFile(src: string, dest: string, promises: true): Promise<boolean>;
|
|
69
|
-
moveFile(src: string, dest: string, options: MoveFileOptions, promises: true): Promise<boolean>;
|
|
70
|
-
moveFile(src: string, dest: string, callback: NoParamCallback): void;
|
|
71
|
-
moveFile(src: string, dest: string, options: MoveFileOptions, callback: NoParamCallback): void;
|
|
72
|
-
createDir(src: string, options?: CreateDirOptions): boolean;
|
|
73
|
-
createDir(src: string, promises: true): Promise<boolean>;
|
|
74
|
-
createDir(src: string, options: CreateDirOptions, promises: true): Promise<boolean>;
|
|
75
|
-
createDir(src: string, callback: NoParamCallback): void;
|
|
76
|
-
createDir(src: string, options: CreateDirOptions, callback: NoParamCallback): void;
|
|
77
|
-
removeDir(src: string, options?: RemoveDirOptions): boolean;
|
|
78
|
-
removeDir(src: string, promises: true): Promise<boolean>;
|
|
79
|
-
removeDir(src: string, options: RemoveDirOptions, promises: true): Promise<boolean>;
|
|
80
|
-
removeDir(src: string, callback: NoParamCallback): void;
|
|
81
|
-
removeDir(src: string, options: RemoveDirOptions, callback: NoParamCallback): void;
|
|
82
|
-
allSettled(values: readonly PromiseLike<unknown>[], rejected?: LogValue, type?: LogType): Promise<PromiseFulfilledResult<unknown>[]>;
|
|
83
|
-
allSettled(values: readonly PromiseLike<unknown>[], rejected?: LogValue, options?: LogFailOptions): Promise<PromiseFulfilledResult<unknown>[]>;
|
|
84
|
-
formatMessage(type: LogType, title: string, value: LogValue, message?: unknown, options?: LogMessageOptions): void;
|
|
85
|
-
formatFail(type: LogType, title: string, value: LogValue, message?: unknown, options?: LogFailOptions): void;
|
|
86
|
-
writeFail(value: LogValue, message?: unknown, type?: LogType): void;
|
|
87
|
-
writeFail(value: LogValue, message?: unknown, options?: LogFailOptions): void;
|
|
88
|
-
writeTimeProcess(title: string, value: string, startTime: LogTime, options?: LogProcessOptions): void;
|
|
89
|
-
writeTimeElapsed(title: string, value: LogValue, startTime: LogTime, options?: LogMessageOptions): void;
|
|
90
|
-
checkPackage(err: unknown, name: string | undefined, type: LogType): boolean;
|
|
91
|
-
checkPackage(err: unknown, name: string | undefined, options: LogFailOptions): boolean;
|
|
92
|
-
checkPackage(err: unknown, name: string | undefined, value?: LogValue, options?: LogFailOptions | LogType): boolean;
|
|
93
|
-
checkFail(message: unknown, options: LogFailOptions): LogArguments | false | undefined;
|
|
94
|
-
writeLog(component: LogComponent, queue?: boolean): void;
|
|
95
|
-
writeLog(type: StatusType, value: unknown, options: LogOptions): void;
|
|
96
|
-
writeLog(type: StatusType, value: unknown, timeStamp?: LogDate, duration?: number): void;
|
|
97
|
-
addLog(component: LogComponent, queue?: boolean): void;
|
|
98
|
-
addLog(type: StatusType, value: unknown, options: LogOptions): void;
|
|
99
|
-
addLog(type: StatusType, value: unknown, from: string, source?: string): void;
|
|
100
|
-
addLog(type: StatusType, value: unknown, timeStamp?: LogDate, from?: string, source?: string): void;
|
|
101
|
-
addLog(type: StatusType, value: unknown, timeStamp?: LogDate, duration?: number, from?: string, source?: string): void;
|
|
102
|
-
getLog(...type: StatusType[]): LogStatus<StatusType>[];
|
|
103
|
-
flushLog(): void;
|
|
104
|
-
willAbort(value: unknown): boolean;
|
|
105
|
-
hasOwnPermission(): boolean;
|
|
106
|
-
isFatal(err?: unknown): boolean;
|
|
107
|
-
detach(): void;
|
|
108
|
-
reset(): void;
|
|
109
|
-
get moduleName(): string;
|
|
110
|
-
set host(value);
|
|
111
|
-
get host(): IHost | null;
|
|
112
|
-
set permission(value);
|
|
113
|
-
get permission(): IPermission | null;
|
|
114
|
-
get aborted(): boolean;
|
|
115
|
-
set abortable(value);
|
|
116
|
-
get abortable(): boolean;
|
|
117
|
-
get threadable(): boolean;
|
|
118
|
-
set sessionId(value);
|
|
119
|
-
get sessionId(): string;
|
|
120
|
-
set broadcastId(value);
|
|
121
|
-
get broadcastId(): string | string[];
|
|
122
|
-
get logType(): LOG_TYPE;
|
|
123
|
-
set logLevel(value: number | string);
|
|
124
|
-
get logLevel(): number;
|
|
125
|
-
get statusType(): STATUS_TYPE;
|
|
126
|
-
set tempDir(value);
|
|
127
|
-
get tempDir(): string;
|
|
128
|
-
|
|
129
|
-
/* EventEmitter */
|
|
130
|
-
on(event: "exec", listener: (command: ExecCommand, options?: SpawnOptions) => void): this;
|
|
131
|
-
on(event: "error", listener: (err: Error) => void): this;
|
|
132
|
-
on(event: "file:read", listener: (src: string, data: Buffer | string, options?: ReadFileOptions) => void): this;
|
|
133
|
-
on(event: "file:write", listener: (src: string, options?: WriteFileOptions) => void): this;
|
|
134
|
-
on(event: "file:delete", listener: (src: string, options?: DeleteFileOptions) => void): this;
|
|
135
|
-
on(event: "file:copy", listener: (dest: string, options?: CopyFileOptions) => void): this;
|
|
136
|
-
on(event: "file:move", listener: (dest: string, options?: MoveFileOptions) => void): this;
|
|
137
|
-
on(event: "dir:create", listener: (src: string, options?: CreateDirOptions) => void): this;
|
|
138
|
-
on(event: "dir:remove", listener: (src: string, options?: RemoveDirOptions) => void): this;
|
|
139
|
-
once(event: "exec", listener: (command: ExecCommand, options?: SpawnOptions) => void): this;
|
|
140
|
-
once(event: "error", listener: (err: Error) => void): this;
|
|
141
|
-
once(event: "file:read", listener: (src: string, data: Buffer | string, options?: ReadFileOptions) => void): this;
|
|
142
|
-
once(event: "file:write", listener: (src: string, options?: WriteFileOptions) => void): this;
|
|
143
|
-
once(event: "file:delete", listener: (src: string, options?: DeleteFileOptions) => void): this;
|
|
144
|
-
once(event: "file:copy", listener: (dest: string, options?: CopyFileOptions) => void): this;
|
|
145
|
-
once(event: "file:move", listener: (dest: string, options?: MoveFileOptions) => void): this;
|
|
146
|
-
once(event: "dir:create", listener: (src: string, options?: CreateDirOptions) => void): this;
|
|
147
|
-
once(event: "dir:remove", listener: (src: string, options?: RemoveDirOptions) => void): this;
|
|
148
|
-
emit(event: "exec", command: ExecCommand, options?: SpawnOptions): boolean;
|
|
149
|
-
emit(event: "error", err: Error): boolean;
|
|
150
|
-
emit(event: "file:read", src: string, data: Buffer | string, options?: ReadFileOptions): boolean;
|
|
151
|
-
emit(event: "file:write", src: string, options?: WriteFileOptions): boolean;
|
|
152
|
-
emit(event: "file:delete", src: string, options?: DeleteFileOptions): boolean;
|
|
153
|
-
emit(event: "file:copy", dest: string, options?: CopyFileOptions): boolean;
|
|
154
|
-
emit(event: "file:move", dest: string, options?: MoveFileOptions): boolean;
|
|
155
|
-
emit(event: "dir:create", src: string, options?: CreateDirOptions): boolean;
|
|
156
|
-
emit(event: "dir:remove", src: string, options?: RemoveDirOptions): boolean;
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
interface ModuleConstructor {
|
|
160
|
-
PROCESS_TIMEOUT: number;
|
|
161
|
-
LOG_STYLE_FAIL: LogMessageOptions;
|
|
162
|
-
LOG_STYLE_SUCCESS: LogMessageOptions;
|
|
163
|
-
LOG_STYLE_INFO: LogMessageOptions;
|
|
164
|
-
LOG_STYLE_WARN: LogMessageOptions;
|
|
165
|
-
LOG_STYLE_NOTICE: LogMessageOptions;
|
|
166
|
-
LOG_STYLE_REVERSE: LogMessageOptions;
|
|
167
|
-
readonly VERSION: string;
|
|
168
|
-
readonly LOG_TYPE: LOG_TYPE;
|
|
169
|
-
readonly LOG_FORMAT: LoggerFormatSettings<LoggerFormat<number>>;
|
|
170
|
-
readonly STATUS_TYPE: STATUS_TYPE;
|
|
171
|
-
readonly MAX_TIMEOUT: number;
|
|
172
|
-
readonly TEMP_DIR: string;
|
|
173
|
-
supported(major: number, minor?: number, patch?: number, lts?: boolean): boolean;
|
|
174
|
-
formatMessage(type: LogType, title: string, value: LogValue, message?: unknown, options?: LogMessageOptions): void;
|
|
175
|
-
writeFail(value: LogValue, message?: unknown, options?: LogFailOptions | LogType): void;
|
|
176
|
-
enabled(key: string, username?: string): boolean;
|
|
177
|
-
parseFunction(value: unknown, options?: ParseFunctionOptions): ((...args: unknown[]) => Promise<unknown> | unknown) | null;
|
|
178
|
-
parseFunction(value: unknown, absolute: boolean, sync?: boolean): ((...args: unknown[]) => Promise<unknown> | unknown) | null;
|
|
179
|
-
asString(value: unknown, cacheKey?: boolean | "throws"): string;
|
|
180
|
-
asHash(data: BinaryLike, options: AsHashOptions): string;
|
|
181
|
-
asHash(data: BinaryLike, algorithm?: unknown, digest?: unknown): string;
|
|
182
|
-
readHash(value: string | URL, options?: ReadHashOptions): Promise<string>;
|
|
183
|
-
toPosix(value: unknown, normalize: boolean): string;
|
|
184
|
-
toPosix(value: unknown, filename?: string, normalize?: boolean): string;
|
|
185
|
-
hasLogType(value: LogType): boolean;
|
|
186
|
-
isURL(value: string, ...exclude: string[]): boolean;
|
|
187
|
-
isFile(value: string | URL, type?: ProtocolType): boolean;
|
|
188
|
-
isDir(value: string | URL): boolean;
|
|
189
|
-
isPath(value: string | URL, type?: "unc" | "unc-exists"): boolean;
|
|
190
|
-
isPath(value: string | URL, isFile?: boolean): boolean;
|
|
191
|
-
isErrorCode(err: unknown, ...code: string[]): boolean;
|
|
192
|
-
fromLocalPath(value: string): string;
|
|
193
|
-
resolveFile(value: string): string;
|
|
194
|
-
resolvePath(value: string, base: string | URL): string;
|
|
195
|
-
joinPath(...values: [...paths: unknown[], normalize: boolean][]): string;
|
|
196
|
-
joinPath(...values: unknown[]): string;
|
|
197
|
-
normalizePath(value: unknown, flags?: boolean | NormalizeFlags): string;
|
|
198
|
-
createDir(value: string | URL, overwrite?: boolean): boolean;
|
|
199
|
-
removeDir(value: string | URL, sinceCreated: number, recursive?: boolean): boolean;
|
|
200
|
-
removeDir(value: string | URL, empty?: boolean, recursive?: boolean): boolean;
|
|
201
|
-
copyDir(src: string | URL, dest: string | URL, move?: boolean, recursive?: boolean): Promise<CopyDirResult>;
|
|
202
|
-
copyDir(src: string | URL, dest: string | URL, options?: CopyDirOptions): Promise<CopyDirResult>;
|
|
203
|
-
renameFile(src: string | URL, dest: string | URL, throws?: boolean): boolean;
|
|
204
|
-
streamFile(src: string, cache: boolean): Promise<Buffer | string>;
|
|
205
|
-
streamFile(src: string, options: ReadBufferOptions): Promise<Buffer | string>;
|
|
206
|
-
streamFile(src: string, cache?: boolean | ReadBufferOptions, options?: ReadBufferOptions): Promise<Buffer | string>;
|
|
207
|
-
readText(value: string | URL, cache: boolean): string;
|
|
208
|
-
readText(value: string | URL, options: ReadTextOptions): Promise<string> | string;
|
|
209
|
-
readText(value: string | URL, encoding?: BufferEncoding | ReadTextOptions, cache?: boolean): string;
|
|
210
|
-
readBuffer(value: string | URL, options: ReadBufferOptions): Promise<Buffer | null> | Buffer | null;
|
|
211
|
-
readBuffer(value: string | URL, cache?: boolean | ReadBufferOptions): Buffer | null;
|
|
212
|
-
resolveMime(data: string | Buffer | Uint8Array | ArrayBuffer): Promise<FileTypeResult | undefined>;
|
|
213
|
-
lookupMime(value: string, extension?: boolean): string;
|
|
214
|
-
initCpuUsage(instance?: IModule): CpuUsage;
|
|
215
|
-
getCpuUsage(start: CpuUsage, format: true): string;
|
|
216
|
-
getCpuUsage(start: CpuUsage, format?: boolean): number;
|
|
217
|
-
getMemUsage(format: true): string;
|
|
218
|
-
getMemUsage(format?: boolean): number;
|
|
219
|
-
formatCpuMem(start: CpuUsage, all?: boolean): string;
|
|
220
|
-
getPackageVersion(name: string | [string, string], startDir: string, baseDir?: string): string;
|
|
221
|
-
getPackageVersion(name: string | [string, string], unstable?: boolean, startDir?: string, baseDir?: string): string;
|
|
222
|
-
checkSemVer(name: string | [string, string], options: CheckSemVerOptions): boolean;
|
|
223
|
-
checkSemVer(name: string | [string, string], min: number | string, max?: number | string, unstable?: boolean, startDir?: string): boolean;
|
|
224
|
-
checkSemVer(name: string | [string, string], min: number | string, max: number | string, options?: CheckSemVerOptions): boolean;
|
|
225
|
-
sanitizeCmd(value: string): string;
|
|
226
|
-
sanitizeArgs(value: string, doubleQuote?: boolean): string;
|
|
227
|
-
sanitizeArgs(values: string[], doubleQuote?: boolean): string[];
|
|
228
|
-
purgeMemory(percent: number, parent: boolean): Promise<number>;
|
|
229
|
-
purgeMemory(percent: number, limit: number, parent?: boolean): Promise<number>;
|
|
230
|
-
purgeMemory(percent?: number, limit?: number | boolean, parent?: unknown): Promise<number>;
|
|
231
|
-
canWrite(name: "temp" | "home"): boolean;
|
|
232
|
-
loadSettings(settings: Settings, password?: string): boolean;
|
|
233
|
-
readonly prototype: IModule<IHost>;
|
|
234
|
-
new(): IModule<IHost>;
|
|
235
|
-
}
|
|
236
|
-
```
|
|
237
|
-
|
|
238
|
-
## Settings
|
|
239
|
-
|
|
240
|
-
```typescript
|
|
241
|
-
import type { LogMessageOptions, LogTypeValue, LoggerStatus } from "./logger";
|
|
242
|
-
import type { LoggerProcessSettings } from "./settings";
|
|
243
|
-
|
|
244
|
-
import type { BackgroundColor as IBackgroundColor, ForegroundColor as IForegroundColor } from "chalk";
|
|
245
|
-
import type { BinaryLike, CipherGCMTypes } from "crypto";
|
|
246
|
-
import type { SecureVersion } from "tls";
|
|
247
|
-
|
|
248
|
-
interface NodeModule {
|
|
249
|
-
process?: {
|
|
250
|
-
cpu_usage?: boolean;
|
|
251
|
-
memory_usage?: boolean;
|
|
252
|
-
inline?: boolean;
|
|
253
|
-
};
|
|
254
|
-
require?: {
|
|
255
|
-
ext?: string | string[] | boolean;
|
|
256
|
-
npm?: boolean;
|
|
257
|
-
inline?: boolean;
|
|
258
|
-
};
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
interface ProcessModule {
|
|
262
|
-
env?: {
|
|
263
|
-
apply?: boolean;
|
|
264
|
-
};
|
|
265
|
-
cipher?: {
|
|
266
|
-
algorithm?: CipherGCMTypes;
|
|
267
|
-
key?: BinaryLike;
|
|
268
|
-
iv?: BinaryLike;
|
|
269
|
-
};
|
|
270
|
-
password?: string;
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
interface MemoryModule {
|
|
274
|
-
settings?: {
|
|
275
|
-
users?: boolean | string[];
|
|
276
|
-
cache_disk?: {
|
|
277
|
-
enabled?: boolean;
|
|
278
|
-
min_size?: number | string;
|
|
279
|
-
max_size?: number | string;
|
|
280
|
-
include?: string[];
|
|
281
|
-
exclude?: string[];
|
|
282
|
-
expires?: number | string;
|
|
283
|
-
};
|
|
284
|
-
};
|
|
285
|
-
}
|
|
286
|
-
|
|
287
|
-
interface PermissionModule {
|
|
288
|
-
home_read?: boolean;
|
|
289
|
-
home_write?: boolean;
|
|
290
|
-
process_exec?: (string | ExecOptions)[];
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
interface ErrorModule {
|
|
294
|
-
out?: string | (err: Error, data: LogTypeValue, require?: NodeRequire) => void;
|
|
295
|
-
fatal?: boolean;
|
|
296
|
-
}
|
|
297
|
-
|
|
298
|
-
interface TempModule {
|
|
299
|
-
dir?: string;
|
|
300
|
-
write?: boolean;
|
|
301
|
-
}
|
|
302
|
-
|
|
303
|
-
interface LoggerModule {
|
|
304
|
-
enabled?: boolean;
|
|
305
|
-
level?: number,
|
|
306
|
-
production?: string[];
|
|
307
|
-
format?: {
|
|
308
|
-
title?: {
|
|
309
|
-
width?: number;
|
|
310
|
-
color?: ForegroundColor;
|
|
311
|
-
bg_color?: BackgroundColor;
|
|
312
|
-
bold?: boolean;
|
|
313
|
-
justify?: "left" | "center" | "right";
|
|
314
|
-
as?: StringMap;
|
|
315
|
-
};
|
|
316
|
-
value?: {
|
|
317
|
-
width?: number;
|
|
318
|
-
color?: ForegroundColor;
|
|
319
|
-
bg_color?: BackgroundColor;
|
|
320
|
-
bold?: boolean;
|
|
321
|
-
justify?: "left" | "center" | "right";
|
|
322
|
-
},
|
|
323
|
-
hint?: {
|
|
324
|
-
width?: number;
|
|
325
|
-
color?: ForegroundColor;
|
|
326
|
-
bg_color?: BackgroundColor;
|
|
327
|
-
bold?: boolean;
|
|
328
|
-
as?: StringMap;
|
|
329
|
-
unit?: "auto" | "s" | "ms";
|
|
330
|
-
};
|
|
331
|
-
message?: {
|
|
332
|
-
width?: number;
|
|
333
|
-
color?: ForegroundColor;
|
|
334
|
-
bg_color?: BackgroundColor;
|
|
335
|
-
bold?: boolean;
|
|
336
|
-
};
|
|
337
|
-
meter?: {
|
|
338
|
-
color?: ForegroundColor;
|
|
339
|
-
bg_color?: BackgroundColor;
|
|
340
|
-
bg_alt_color?: BackgroundColor;
|
|
341
|
-
bold?: boolean;
|
|
342
|
-
};
|
|
343
|
-
};
|
|
344
|
-
meter?: {
|
|
345
|
-
http?: number;
|
|
346
|
-
image?: number;
|
|
347
|
-
compress?: number;
|
|
348
|
-
process?: number;
|
|
349
|
-
};
|
|
350
|
-
broadcast?: {
|
|
351
|
-
enabled?: boolean;
|
|
352
|
-
out?: string | (value: string, options: LogMessageOptions, require?: NodeRequire) => void;
|
|
353
|
-
color?: boolean;
|
|
354
|
-
port?: number | number[];
|
|
355
|
-
secure?: {
|
|
356
|
-
port?: number | number[];
|
|
357
|
-
ca?: string;
|
|
358
|
-
key?: string;
|
|
359
|
-
cert?: string;
|
|
360
|
-
version?: SecureVersion
|
|
361
|
-
};
|
|
362
|
-
};
|
|
363
|
-
color?: boolean;
|
|
364
|
-
message?: boolean;
|
|
365
|
-
stdout?: boolean;
|
|
366
|
-
abort?: boolean;
|
|
367
|
-
status?: boolean | LoggerStatus;
|
|
368
|
-
unknown?: boolean | LoggerColor;
|
|
369
|
-
system?: boolean | LoggerColor;
|
|
370
|
-
process?: boolean | LoggerProcessSettings;
|
|
371
|
-
image?: boolean | LoggerColor;
|
|
372
|
-
compress?: boolean | LoggerColor;
|
|
373
|
-
watch?: boolean | LoggerColor;
|
|
374
|
-
file?: boolean | LoggerColor;
|
|
375
|
-
cloud?: boolean | LoggerColor;
|
|
376
|
-
db?: boolean | LoggerColor;
|
|
377
|
-
time_elapsed?: boolean | LoggerColor;
|
|
378
|
-
time_process?: boolean | LoggerColor;
|
|
379
|
-
exec?: boolean | LoggerColor;
|
|
380
|
-
http?: boolean | LoggerColor;
|
|
381
|
-
node?: boolean | LoggerColor;
|
|
382
|
-
session_id?: boolean | number;
|
|
383
|
-
stack_trace?: boolean | number;
|
|
384
|
-
}
|
|
385
|
-
|
|
386
|
-
type BackgroundColor = typeof IBackgroundColor | `#${string}`;
|
|
387
|
-
type ForegroundColor = typeof IForegroundColor | `#${string}`;
|
|
388
|
-
```
|
|
389
|
-
|
|
390
|
-
## References
|
|
391
|
-
|
|
392
|
-
- https://www.unpkg.com/@e-mc/types@0.9.
|
|
393
|
-
- https://www.unpkg.com/@e-mc/types@0.9.
|
|
394
|
-
- https://www.unpkg.com/@e-mc/types@0.9.
|
|
395
|
-
- https://www.unpkg.com/@e-mc/types@0.9.
|
|
396
|
-
- https://www.unpkg.com/@e-mc/types@0.9.
|
|
397
|
-
|
|
398
|
-
* https://www.npmjs.com/package/@types/node
|
|
399
|
-
|
|
400
|
-
## LICENSE
|
|
401
|
-
|
|
1
|
+
# @e-mc/module
|
|
2
|
+
|
|
3
|
+
* NodeJS 16
|
|
4
|
+
* ES2020
|
|
5
|
+
|
|
6
|
+
## General Usage
|
|
7
|
+
|
|
8
|
+
* [Read the Docs](https://e-mc.readthedocs.io)
|
|
9
|
+
|
|
10
|
+
## Interface
|
|
11
|
+
|
|
12
|
+
* [View Source](https://www.unpkg.com/@e-mc/types@0.9.10/lib/index.d.ts)
|
|
13
|
+
|
|
14
|
+
```typescript
|
|
15
|
+
import type { LogStatus } from "./squared";
|
|
16
|
+
|
|
17
|
+
import type { IHost } from "./index";
|
|
18
|
+
import type { IAbortComponent, IPermission } from "./core";
|
|
19
|
+
import type { LOG_TYPE, STATUS_TYPE, ExecCommand, LogArguments, LogComponent, LogDate, LogFailOptions, LogMessageOptions, LogOptions, LogProcessOptions, LogTime, LogType, LogValue, LoggerFormat, StatusType } from "./logger";
|
|
20
|
+
import type { AsHashOptions, CheckSemVerOptions, CopyDirOptions, CopyDirResult, CopyFileOptions, CreateDirOptions, DeleteFileOptions, GetTempDirOptions, MoveFileOptions, NormalizeFlags, ParseFunctionOptions, PermissionOptions, ProtocolType, ReadBufferOptions, ReadFileCallback, ReadFileOptions, ReadHashOptions, ReadTextOptions, RemoveDirOptions, WriteFileOptions } from "./module";
|
|
21
|
+
import type { Settings } from "./node";
|
|
22
|
+
import type { LoggerFormatSettings } from "/settings";
|
|
23
|
+
|
|
24
|
+
import type { SpawnOptions } from "child_process";
|
|
25
|
+
import type { BinaryLike } from "crypto";
|
|
26
|
+
import type { FileTypeResult } from "file-type";
|
|
27
|
+
import type { NoParamCallback } from "fs";
|
|
28
|
+
|
|
29
|
+
import type * as EventEmitter from "events";
|
|
30
|
+
|
|
31
|
+
type BufferView = Buffer | string | NodeJS.ArrayBufferView;
|
|
32
|
+
type CpuUsage = NodeJS.CpuUsage;
|
|
33
|
+
|
|
34
|
+
interface IModule extends EventEmitter, IAbortComponent {
|
|
35
|
+
readonly status: LogStatus<StatusType>[];
|
|
36
|
+
readonly errors: unknown[];
|
|
37
|
+
supported(major: number, minor?: number, patch?: number, lts?: boolean): boolean;
|
|
38
|
+
supports(name: string, value?: boolean): boolean;
|
|
39
|
+
getTempDir(options: GetTempDirOptions): string;
|
|
40
|
+
getTempDir(uuidDir: boolean, createDir: boolean): string;
|
|
41
|
+
getTempDir(pathname: string, createDir: boolean): string;
|
|
42
|
+
getTempDir(uuidDir: boolean, filename?: string, createDir?: boolean): string;
|
|
43
|
+
getTempDir(pathname?: string, filename?: string, createDir?: boolean): string;
|
|
44
|
+
canRead(uri: string, options?: PermissionOptions): boolean;
|
|
45
|
+
canWrite(uri: string, options?: PermissionOptions): boolean;
|
|
46
|
+
readFile(src: string): Buffer | undefined;
|
|
47
|
+
readFile(src: string, options?: ReadFileOptions): Promise<Buffer | string> | Buffer | string | undefined;
|
|
48
|
+
readFile(src: string, promises: true): Promise<Buffer | undefined>;
|
|
49
|
+
readFile(src: string, options: ReadFileOptions, promises: true): Promise<Buffer | string | undefined>;
|
|
50
|
+
readFile(src: string, callback: ReadFileCallback<Buffer | string>): Buffer | string | undefined;
|
|
51
|
+
readFile(src: string, options: ReadFileOptions, callback: ReadFileCallback<Buffer | string>): Buffer | string | undefined;
|
|
52
|
+
writeFile(src: string, data: BufferView, options?: WriteFileOptions): boolean;
|
|
53
|
+
writeFile(src: string, data: BufferView, promises: true): Promise<boolean>;
|
|
54
|
+
writeFile(src: string, data: BufferView, options: WriteFileOptions, promises: true): Promise<boolean>;
|
|
55
|
+
writeFile(src: string, data: BufferView, callback: NoParamCallback): void;
|
|
56
|
+
writeFile(src: string, data: BufferView, options: WriteFileOptions, callback: NoParamCallback): void;
|
|
57
|
+
deleteFile(src: string, options?: DeleteFileOptions): boolean;
|
|
58
|
+
deleteFile(src: string, promises: true): Promise<boolean>;
|
|
59
|
+
deleteFile(src: string, options: DeleteFileOptions, promises: true): Promise<boolean>;
|
|
60
|
+
deleteFile(src: string, callback: NoParamCallback): void;
|
|
61
|
+
deleteFile(src: string, options: DeleteFileOptions, callback: NoParamCallback): void;
|
|
62
|
+
copyFile(src: string, dest: string, options?: CopyFileOptions): boolean;
|
|
63
|
+
copyFile(src: string, dest: string, promises: true): Promise<boolean>;
|
|
64
|
+
copyFile(src: string, dest: string, options: CopyFileOptions, promises: true): Promise<boolean>;
|
|
65
|
+
copyFile(src: string, dest: string, callback: NoParamCallback): void;
|
|
66
|
+
copyFile(src: string, dest: string, options: CopyFileOptions, callback: NoParamCallback): void;
|
|
67
|
+
moveFile(src: string, dest: string, options?: MoveFileOptions): boolean;
|
|
68
|
+
moveFile(src: string, dest: string, promises: true): Promise<boolean>;
|
|
69
|
+
moveFile(src: string, dest: string, options: MoveFileOptions, promises: true): Promise<boolean>;
|
|
70
|
+
moveFile(src: string, dest: string, callback: NoParamCallback): void;
|
|
71
|
+
moveFile(src: string, dest: string, options: MoveFileOptions, callback: NoParamCallback): void;
|
|
72
|
+
createDir(src: string, options?: CreateDirOptions): boolean;
|
|
73
|
+
createDir(src: string, promises: true): Promise<boolean>;
|
|
74
|
+
createDir(src: string, options: CreateDirOptions, promises: true): Promise<boolean>;
|
|
75
|
+
createDir(src: string, callback: NoParamCallback): void;
|
|
76
|
+
createDir(src: string, options: CreateDirOptions, callback: NoParamCallback): void;
|
|
77
|
+
removeDir(src: string, options?: RemoveDirOptions): boolean;
|
|
78
|
+
removeDir(src: string, promises: true): Promise<boolean>;
|
|
79
|
+
removeDir(src: string, options: RemoveDirOptions, promises: true): Promise<boolean>;
|
|
80
|
+
removeDir(src: string, callback: NoParamCallback): void;
|
|
81
|
+
removeDir(src: string, options: RemoveDirOptions, callback: NoParamCallback): void;
|
|
82
|
+
allSettled(values: readonly PromiseLike<unknown>[], rejected?: LogValue, type?: LogType): Promise<PromiseFulfilledResult<unknown>[]>;
|
|
83
|
+
allSettled(values: readonly PromiseLike<unknown>[], rejected?: LogValue, options?: LogFailOptions): Promise<PromiseFulfilledResult<unknown>[]>;
|
|
84
|
+
formatMessage(type: LogType, title: string, value: LogValue, message?: unknown, options?: LogMessageOptions): void;
|
|
85
|
+
formatFail(type: LogType, title: string, value: LogValue, message?: unknown, options?: LogFailOptions): void;
|
|
86
|
+
writeFail(value: LogValue, message?: unknown, type?: LogType): void;
|
|
87
|
+
writeFail(value: LogValue, message?: unknown, options?: LogFailOptions): void;
|
|
88
|
+
writeTimeProcess(title: string, value: string, startTime: LogTime, options?: LogProcessOptions): void;
|
|
89
|
+
writeTimeElapsed(title: string, value: LogValue, startTime: LogTime, options?: LogMessageOptions): void;
|
|
90
|
+
checkPackage(err: unknown, name: string | undefined, type: LogType): boolean;
|
|
91
|
+
checkPackage(err: unknown, name: string | undefined, options: LogFailOptions): boolean;
|
|
92
|
+
checkPackage(err: unknown, name: string | undefined, value?: LogValue, options?: LogFailOptions | LogType): boolean;
|
|
93
|
+
checkFail(message: unknown, options: LogFailOptions): LogArguments | false | undefined;
|
|
94
|
+
writeLog(component: LogComponent, queue?: boolean): void;
|
|
95
|
+
writeLog(type: StatusType, value: unknown, options: LogOptions): void;
|
|
96
|
+
writeLog(type: StatusType, value: unknown, timeStamp?: LogDate, duration?: number): void;
|
|
97
|
+
addLog(component: LogComponent, queue?: boolean): void;
|
|
98
|
+
addLog(type: StatusType, value: unknown, options: LogOptions): void;
|
|
99
|
+
addLog(type: StatusType, value: unknown, from: string, source?: string): void;
|
|
100
|
+
addLog(type: StatusType, value: unknown, timeStamp?: LogDate, from?: string, source?: string): void;
|
|
101
|
+
addLog(type: StatusType, value: unknown, timeStamp?: LogDate, duration?: number, from?: string, source?: string): void;
|
|
102
|
+
getLog(...type: StatusType[]): LogStatus<StatusType>[];
|
|
103
|
+
flushLog(): void;
|
|
104
|
+
willAbort(value: unknown): boolean;
|
|
105
|
+
hasOwnPermission(): boolean;
|
|
106
|
+
isFatal(err?: unknown): boolean;
|
|
107
|
+
detach(): void;
|
|
108
|
+
reset(): void;
|
|
109
|
+
get moduleName(): string;
|
|
110
|
+
set host(value);
|
|
111
|
+
get host(): IHost | null;
|
|
112
|
+
set permission(value);
|
|
113
|
+
get permission(): IPermission | null;
|
|
114
|
+
get aborted(): boolean;
|
|
115
|
+
set abortable(value);
|
|
116
|
+
get abortable(): boolean;
|
|
117
|
+
get threadable(): boolean;
|
|
118
|
+
set sessionId(value);
|
|
119
|
+
get sessionId(): string;
|
|
120
|
+
set broadcastId(value);
|
|
121
|
+
get broadcastId(): string | string[];
|
|
122
|
+
get logType(): LOG_TYPE;
|
|
123
|
+
set logLevel(value: number | string);
|
|
124
|
+
get logLevel(): number;
|
|
125
|
+
get statusType(): STATUS_TYPE;
|
|
126
|
+
set tempDir(value);
|
|
127
|
+
get tempDir(): string;
|
|
128
|
+
|
|
129
|
+
/* EventEmitter */
|
|
130
|
+
on(event: "exec", listener: (command: ExecCommand, options?: SpawnOptions) => void): this;
|
|
131
|
+
on(event: "error", listener: (err: Error) => void): this;
|
|
132
|
+
on(event: "file:read", listener: (src: string, data: Buffer | string, options?: ReadFileOptions) => void): this;
|
|
133
|
+
on(event: "file:write", listener: (src: string, options?: WriteFileOptions) => void): this;
|
|
134
|
+
on(event: "file:delete", listener: (src: string, options?: DeleteFileOptions) => void): this;
|
|
135
|
+
on(event: "file:copy", listener: (dest: string, options?: CopyFileOptions) => void): this;
|
|
136
|
+
on(event: "file:move", listener: (dest: string, options?: MoveFileOptions) => void): this;
|
|
137
|
+
on(event: "dir:create", listener: (src: string, options?: CreateDirOptions) => void): this;
|
|
138
|
+
on(event: "dir:remove", listener: (src: string, options?: RemoveDirOptions) => void): this;
|
|
139
|
+
once(event: "exec", listener: (command: ExecCommand, options?: SpawnOptions) => void): this;
|
|
140
|
+
once(event: "error", listener: (err: Error) => void): this;
|
|
141
|
+
once(event: "file:read", listener: (src: string, data: Buffer | string, options?: ReadFileOptions) => void): this;
|
|
142
|
+
once(event: "file:write", listener: (src: string, options?: WriteFileOptions) => void): this;
|
|
143
|
+
once(event: "file:delete", listener: (src: string, options?: DeleteFileOptions) => void): this;
|
|
144
|
+
once(event: "file:copy", listener: (dest: string, options?: CopyFileOptions) => void): this;
|
|
145
|
+
once(event: "file:move", listener: (dest: string, options?: MoveFileOptions) => void): this;
|
|
146
|
+
once(event: "dir:create", listener: (src: string, options?: CreateDirOptions) => void): this;
|
|
147
|
+
once(event: "dir:remove", listener: (src: string, options?: RemoveDirOptions) => void): this;
|
|
148
|
+
emit(event: "exec", command: ExecCommand, options?: SpawnOptions): boolean;
|
|
149
|
+
emit(event: "error", err: Error): boolean;
|
|
150
|
+
emit(event: "file:read", src: string, data: Buffer | string, options?: ReadFileOptions): boolean;
|
|
151
|
+
emit(event: "file:write", src: string, options?: WriteFileOptions): boolean;
|
|
152
|
+
emit(event: "file:delete", src: string, options?: DeleteFileOptions): boolean;
|
|
153
|
+
emit(event: "file:copy", dest: string, options?: CopyFileOptions): boolean;
|
|
154
|
+
emit(event: "file:move", dest: string, options?: MoveFileOptions): boolean;
|
|
155
|
+
emit(event: "dir:create", src: string, options?: CreateDirOptions): boolean;
|
|
156
|
+
emit(event: "dir:remove", src: string, options?: RemoveDirOptions): boolean;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
interface ModuleConstructor {
|
|
160
|
+
PROCESS_TIMEOUT: number;
|
|
161
|
+
LOG_STYLE_FAIL: LogMessageOptions;
|
|
162
|
+
LOG_STYLE_SUCCESS: LogMessageOptions;
|
|
163
|
+
LOG_STYLE_INFO: LogMessageOptions;
|
|
164
|
+
LOG_STYLE_WARN: LogMessageOptions;
|
|
165
|
+
LOG_STYLE_NOTICE: LogMessageOptions;
|
|
166
|
+
LOG_STYLE_REVERSE: LogMessageOptions;
|
|
167
|
+
readonly VERSION: string;
|
|
168
|
+
readonly LOG_TYPE: LOG_TYPE;
|
|
169
|
+
readonly LOG_FORMAT: LoggerFormatSettings<LoggerFormat<number>>;
|
|
170
|
+
readonly STATUS_TYPE: STATUS_TYPE;
|
|
171
|
+
readonly MAX_TIMEOUT: number;
|
|
172
|
+
readonly TEMP_DIR: string;
|
|
173
|
+
supported(major: number, minor?: number, patch?: number, lts?: boolean): boolean;
|
|
174
|
+
formatMessage(type: LogType, title: string, value: LogValue, message?: unknown, options?: LogMessageOptions): void;
|
|
175
|
+
writeFail(value: LogValue, message?: unknown, options?: LogFailOptions | LogType): void;
|
|
176
|
+
enabled(key: string, username?: string): boolean;
|
|
177
|
+
parseFunction(value: unknown, options?: ParseFunctionOptions): ((...args: unknown[]) => Promise<unknown> | unknown) | null;
|
|
178
|
+
parseFunction(value: unknown, absolute: boolean, sync?: boolean): ((...args: unknown[]) => Promise<unknown> | unknown) | null;
|
|
179
|
+
asString(value: unknown, cacheKey?: boolean | "throws"): string;
|
|
180
|
+
asHash(data: BinaryLike, options: AsHashOptions): string;
|
|
181
|
+
asHash(data: BinaryLike, algorithm?: unknown, digest?: unknown): string;
|
|
182
|
+
readHash(value: string | URL, options?: ReadHashOptions): Promise<string>;
|
|
183
|
+
toPosix(value: unknown, normalize: boolean): string;
|
|
184
|
+
toPosix(value: unknown, filename?: string, normalize?: boolean): string;
|
|
185
|
+
hasLogType(value: LogType): boolean;
|
|
186
|
+
isURL(value: string, ...exclude: string[]): boolean;
|
|
187
|
+
isFile(value: string | URL, type?: ProtocolType): boolean;
|
|
188
|
+
isDir(value: string | URL): boolean;
|
|
189
|
+
isPath(value: string | URL, type?: "unc" | "unc-exists"): boolean;
|
|
190
|
+
isPath(value: string | URL, isFile?: boolean): boolean;
|
|
191
|
+
isErrorCode(err: unknown, ...code: string[]): boolean;
|
|
192
|
+
fromLocalPath(value: string): string;
|
|
193
|
+
resolveFile(value: string): string;
|
|
194
|
+
resolvePath(value: string, base: string | URL): string;
|
|
195
|
+
joinPath(...values: [...paths: unknown[], normalize: boolean][]): string;
|
|
196
|
+
joinPath(...values: unknown[]): string;
|
|
197
|
+
normalizePath(value: unknown, flags?: boolean | NormalizeFlags): string;
|
|
198
|
+
createDir(value: string | URL, overwrite?: boolean): boolean;
|
|
199
|
+
removeDir(value: string | URL, sinceCreated: number, recursive?: boolean): boolean;
|
|
200
|
+
removeDir(value: string | URL, empty?: boolean, recursive?: boolean): boolean;
|
|
201
|
+
copyDir(src: string | URL, dest: string | URL, move?: boolean, recursive?: boolean): Promise<CopyDirResult>;
|
|
202
|
+
copyDir(src: string | URL, dest: string | URL, options?: CopyDirOptions): Promise<CopyDirResult>;
|
|
203
|
+
renameFile(src: string | URL, dest: string | URL, throws?: boolean): boolean;
|
|
204
|
+
streamFile(src: string, cache: boolean): Promise<Buffer | string>;
|
|
205
|
+
streamFile(src: string, options: ReadBufferOptions): Promise<Buffer | string>;
|
|
206
|
+
streamFile(src: string, cache?: boolean | ReadBufferOptions, options?: ReadBufferOptions): Promise<Buffer | string>;
|
|
207
|
+
readText(value: string | URL, cache: boolean): string;
|
|
208
|
+
readText(value: string | URL, options: ReadTextOptions): Promise<string> | string;
|
|
209
|
+
readText(value: string | URL, encoding?: BufferEncoding | ReadTextOptions, cache?: boolean): string;
|
|
210
|
+
readBuffer(value: string | URL, options: ReadBufferOptions): Promise<Buffer | null> | Buffer | null;
|
|
211
|
+
readBuffer(value: string | URL, cache?: boolean | ReadBufferOptions): Buffer | null;
|
|
212
|
+
resolveMime(data: string | Buffer | Uint8Array | ArrayBuffer): Promise<FileTypeResult | undefined>;
|
|
213
|
+
lookupMime(value: string, extension?: boolean): string;
|
|
214
|
+
initCpuUsage(instance?: IModule): CpuUsage;
|
|
215
|
+
getCpuUsage(start: CpuUsage, format: true): string;
|
|
216
|
+
getCpuUsage(start: CpuUsage, format?: boolean): number;
|
|
217
|
+
getMemUsage(format: true): string;
|
|
218
|
+
getMemUsage(format?: boolean): number;
|
|
219
|
+
formatCpuMem(start: CpuUsage, all?: boolean): string;
|
|
220
|
+
getPackageVersion(name: string | [string, string], startDir: string, baseDir?: string): string;
|
|
221
|
+
getPackageVersion(name: string | [string, string], unstable?: boolean, startDir?: string, baseDir?: string): string;
|
|
222
|
+
checkSemVer(name: string | [string, string], options: CheckSemVerOptions): boolean;
|
|
223
|
+
checkSemVer(name: string | [string, string], min: number | string, max?: number | string, unstable?: boolean, startDir?: string): boolean;
|
|
224
|
+
checkSemVer(name: string | [string, string], min: number | string, max: number | string, options?: CheckSemVerOptions): boolean;
|
|
225
|
+
sanitizeCmd(value: string): string;
|
|
226
|
+
sanitizeArgs(value: string, doubleQuote?: boolean): string;
|
|
227
|
+
sanitizeArgs(values: string[], doubleQuote?: boolean): string[];
|
|
228
|
+
purgeMemory(percent: number, parent: boolean): Promise<number>;
|
|
229
|
+
purgeMemory(percent: number, limit: number, parent?: boolean): Promise<number>;
|
|
230
|
+
purgeMemory(percent?: number, limit?: number | boolean, parent?: unknown): Promise<number>;
|
|
231
|
+
canWrite(name: "temp" | "home"): boolean;
|
|
232
|
+
loadSettings(settings: Settings, password?: string): boolean;
|
|
233
|
+
readonly prototype: IModule<IHost>;
|
|
234
|
+
new(): IModule<IHost>;
|
|
235
|
+
}
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
## Settings
|
|
239
|
+
|
|
240
|
+
```typescript
|
|
241
|
+
import type { LogMessageOptions, LogTypeValue, LoggerStatus } from "./logger";
|
|
242
|
+
import type { LoggerProcessSettings } from "./settings";
|
|
243
|
+
|
|
244
|
+
import type { BackgroundColor as IBackgroundColor, ForegroundColor as IForegroundColor } from "chalk";
|
|
245
|
+
import type { BinaryLike, CipherGCMTypes } from "crypto";
|
|
246
|
+
import type { SecureVersion } from "tls";
|
|
247
|
+
|
|
248
|
+
interface NodeModule {
|
|
249
|
+
process?: {
|
|
250
|
+
cpu_usage?: boolean;
|
|
251
|
+
memory_usage?: boolean;
|
|
252
|
+
inline?: boolean;
|
|
253
|
+
};
|
|
254
|
+
require?: {
|
|
255
|
+
ext?: string | string[] | boolean;
|
|
256
|
+
npm?: boolean;
|
|
257
|
+
inline?: boolean;
|
|
258
|
+
};
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
interface ProcessModule {
|
|
262
|
+
env?: {
|
|
263
|
+
apply?: boolean;
|
|
264
|
+
};
|
|
265
|
+
cipher?: {
|
|
266
|
+
algorithm?: CipherGCMTypes;
|
|
267
|
+
key?: BinaryLike;
|
|
268
|
+
iv?: BinaryLike;
|
|
269
|
+
};
|
|
270
|
+
password?: string;
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
interface MemoryModule {
|
|
274
|
+
settings?: {
|
|
275
|
+
users?: boolean | string[];
|
|
276
|
+
cache_disk?: {
|
|
277
|
+
enabled?: boolean;
|
|
278
|
+
min_size?: number | string;
|
|
279
|
+
max_size?: number | string;
|
|
280
|
+
include?: string[];
|
|
281
|
+
exclude?: string[];
|
|
282
|
+
expires?: number | string;
|
|
283
|
+
};
|
|
284
|
+
};
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
interface PermissionModule {
|
|
288
|
+
home_read?: boolean;
|
|
289
|
+
home_write?: boolean;
|
|
290
|
+
process_exec?: (string | ExecOptions)[];
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
interface ErrorModule {
|
|
294
|
+
out?: string | (err: Error, data: LogTypeValue, require?: NodeRequire) => void;
|
|
295
|
+
fatal?: boolean;
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
interface TempModule {
|
|
299
|
+
dir?: string;
|
|
300
|
+
write?: boolean;
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
interface LoggerModule {
|
|
304
|
+
enabled?: boolean;
|
|
305
|
+
level?: number,
|
|
306
|
+
production?: string[];
|
|
307
|
+
format?: {
|
|
308
|
+
title?: {
|
|
309
|
+
width?: number;
|
|
310
|
+
color?: ForegroundColor;
|
|
311
|
+
bg_color?: BackgroundColor;
|
|
312
|
+
bold?: boolean;
|
|
313
|
+
justify?: "left" | "center" | "right";
|
|
314
|
+
as?: StringMap;
|
|
315
|
+
};
|
|
316
|
+
value?: {
|
|
317
|
+
width?: number;
|
|
318
|
+
color?: ForegroundColor;
|
|
319
|
+
bg_color?: BackgroundColor;
|
|
320
|
+
bold?: boolean;
|
|
321
|
+
justify?: "left" | "center" | "right";
|
|
322
|
+
},
|
|
323
|
+
hint?: {
|
|
324
|
+
width?: number;
|
|
325
|
+
color?: ForegroundColor;
|
|
326
|
+
bg_color?: BackgroundColor;
|
|
327
|
+
bold?: boolean;
|
|
328
|
+
as?: StringMap;
|
|
329
|
+
unit?: "auto" | "s" | "ms";
|
|
330
|
+
};
|
|
331
|
+
message?: {
|
|
332
|
+
width?: number;
|
|
333
|
+
color?: ForegroundColor;
|
|
334
|
+
bg_color?: BackgroundColor;
|
|
335
|
+
bold?: boolean;
|
|
336
|
+
};
|
|
337
|
+
meter?: {
|
|
338
|
+
color?: ForegroundColor;
|
|
339
|
+
bg_color?: BackgroundColor;
|
|
340
|
+
bg_alt_color?: BackgroundColor;
|
|
341
|
+
bold?: boolean;
|
|
342
|
+
};
|
|
343
|
+
};
|
|
344
|
+
meter?: {
|
|
345
|
+
http?: number;
|
|
346
|
+
image?: number;
|
|
347
|
+
compress?: number;
|
|
348
|
+
process?: number;
|
|
349
|
+
};
|
|
350
|
+
broadcast?: {
|
|
351
|
+
enabled?: boolean;
|
|
352
|
+
out?: string | (value: string, options: LogMessageOptions, require?: NodeRequire) => void;
|
|
353
|
+
color?: boolean;
|
|
354
|
+
port?: number | number[];
|
|
355
|
+
secure?: {
|
|
356
|
+
port?: number | number[];
|
|
357
|
+
ca?: string;
|
|
358
|
+
key?: string;
|
|
359
|
+
cert?: string;
|
|
360
|
+
version?: SecureVersion
|
|
361
|
+
};
|
|
362
|
+
};
|
|
363
|
+
color?: boolean;
|
|
364
|
+
message?: boolean;
|
|
365
|
+
stdout?: boolean;
|
|
366
|
+
abort?: boolean;
|
|
367
|
+
status?: boolean | LoggerStatus;
|
|
368
|
+
unknown?: boolean | LoggerColor;
|
|
369
|
+
system?: boolean | LoggerColor;
|
|
370
|
+
process?: boolean | LoggerProcessSettings;
|
|
371
|
+
image?: boolean | LoggerColor;
|
|
372
|
+
compress?: boolean | LoggerColor;
|
|
373
|
+
watch?: boolean | LoggerColor;
|
|
374
|
+
file?: boolean | LoggerColor;
|
|
375
|
+
cloud?: boolean | LoggerColor;
|
|
376
|
+
db?: boolean | LoggerColor;
|
|
377
|
+
time_elapsed?: boolean | LoggerColor;
|
|
378
|
+
time_process?: boolean | LoggerColor;
|
|
379
|
+
exec?: boolean | LoggerColor;
|
|
380
|
+
http?: boolean | LoggerColor;
|
|
381
|
+
node?: boolean | LoggerColor;
|
|
382
|
+
session_id?: boolean | number;
|
|
383
|
+
stack_trace?: boolean | number;
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
type BackgroundColor = typeof IBackgroundColor | `#${string}`;
|
|
387
|
+
type ForegroundColor = typeof IForegroundColor | `#${string}`;
|
|
388
|
+
```
|
|
389
|
+
|
|
390
|
+
## References
|
|
391
|
+
|
|
392
|
+
- https://www.unpkg.com/@e-mc/types@0.9.10/lib/core.d.ts
|
|
393
|
+
- https://www.unpkg.com/@e-mc/types@0.9.10/lib/logger.d.ts
|
|
394
|
+
- https://www.unpkg.com/@e-mc/types@0.9.10/lib/module.d.ts
|
|
395
|
+
- https://www.unpkg.com/@e-mc/types@0.9.10/lib/node.d.ts
|
|
396
|
+
- https://www.unpkg.com/@e-mc/types@0.9.10/lib/settings.d.ts
|
|
397
|
+
|
|
398
|
+
* https://www.npmjs.com/package/@types/node
|
|
399
|
+
|
|
400
|
+
## LICENSE
|
|
401
|
+
|
|
402
402
|
BSD 3-Clause
|
package/index.js
CHANGED
|
@@ -230,9 +230,8 @@ function setYarnVer() {
|
|
|
230
230
|
return YARN_VER;
|
|
231
231
|
}
|
|
232
232
|
function applyStyle(options, style) {
|
|
233
|
-
var _h;
|
|
234
233
|
for (const attr in style) {
|
|
235
|
-
|
|
234
|
+
options[attr] ??= style[attr];
|
|
236
235
|
}
|
|
237
236
|
return options;
|
|
238
237
|
}
|
|
@@ -242,51 +241,51 @@ function checkColorOptions(type, settings, options) {
|
|
|
242
241
|
}
|
|
243
242
|
let result = false;
|
|
244
243
|
if (settings.valueColor) {
|
|
245
|
-
options.valueColor
|
|
244
|
+
options.valueColor ||= settings.valueColor;
|
|
246
245
|
result = true;
|
|
247
246
|
}
|
|
248
247
|
if (settings.valueBgColor) {
|
|
249
|
-
options.valueBgColor
|
|
248
|
+
options.valueBgColor ||= settings.valueBgColor;
|
|
250
249
|
result = true;
|
|
251
250
|
}
|
|
252
251
|
if (typeof settings.valueBold === 'boolean') {
|
|
253
|
-
options.valueBold
|
|
252
|
+
options.valueBold ??= settings.valueBold;
|
|
254
253
|
}
|
|
255
254
|
if (settings.hintColor) {
|
|
256
|
-
options.hintColor
|
|
255
|
+
options.hintColor ||= settings.hintColor;
|
|
257
256
|
result = true;
|
|
258
257
|
}
|
|
259
258
|
if (settings.hintBgColor) {
|
|
260
|
-
options.hintBgColor
|
|
259
|
+
options.hintBgColor ||= settings.hintBgColor;
|
|
261
260
|
result = true;
|
|
262
261
|
}
|
|
263
262
|
if (typeof settings.hintBold === 'boolean') {
|
|
264
|
-
options.hintBold
|
|
263
|
+
options.hintBold ??= settings.hintBold;
|
|
265
264
|
}
|
|
266
265
|
if (type & types_1.LOG_TYPE.FAIL) {
|
|
267
266
|
return result;
|
|
268
267
|
}
|
|
269
268
|
if (settings.titleColor) {
|
|
270
|
-
options.titleColor
|
|
269
|
+
options.titleColor ||= settings.titleColor;
|
|
271
270
|
result = true;
|
|
272
271
|
}
|
|
273
272
|
if (settings.titleBgColor) {
|
|
274
|
-
options.titleBgColor
|
|
273
|
+
options.titleBgColor ||= settings.titleBgColor;
|
|
275
274
|
result = true;
|
|
276
275
|
}
|
|
277
276
|
if (typeof settings.titleBold === 'boolean') {
|
|
278
|
-
options.titleBold
|
|
277
|
+
options.titleBold ??= settings.titleBold;
|
|
279
278
|
}
|
|
280
279
|
if (settings.messageColor) {
|
|
281
|
-
options.messageColor
|
|
280
|
+
options.messageColor ||= settings.messageColor;
|
|
282
281
|
result = true;
|
|
283
282
|
}
|
|
284
283
|
if (settings.messageBgColor) {
|
|
285
|
-
options.messageBgColor
|
|
284
|
+
options.messageBgColor ||= settings.messageBgColor;
|
|
286
285
|
result = true;
|
|
287
286
|
}
|
|
288
287
|
if (typeof settings.messageBold === 'boolean') {
|
|
289
|
-
options.messageBold
|
|
288
|
+
options.messageBold ??= settings.messageBold;
|
|
290
289
|
}
|
|
291
290
|
return result;
|
|
292
291
|
}
|
|
@@ -557,12 +556,11 @@ function checkFunction(value) {
|
|
|
557
556
|
return null;
|
|
558
557
|
}
|
|
559
558
|
function encryptMessage(data, cipher, algorithm) {
|
|
560
|
-
var _h;
|
|
561
559
|
if (cipher?.key && cipher.iv) {
|
|
562
|
-
algorithm
|
|
560
|
+
algorithm ||= cipher.algorithm || 'aes-256-gcm';
|
|
563
561
|
const result = (0, types_1.encryptUTF8)(algorithm, cipher.key, cipher.iv, data);
|
|
564
562
|
if (result) {
|
|
565
|
-
VALUES[
|
|
563
|
+
VALUES["process.cipher.algorithm"] ||= algorithm;
|
|
566
564
|
return result;
|
|
567
565
|
}
|
|
568
566
|
}
|
|
@@ -647,7 +645,7 @@ function hasFileSystem(type, value, options, ignoreExists, overwrite) {
|
|
|
647
645
|
return result;
|
|
648
646
|
}
|
|
649
647
|
function applyLogId(options) {
|
|
650
|
-
options.sessionId
|
|
648
|
+
options.sessionId ??= this.sessionId;
|
|
651
649
|
let value = options.broadcastId;
|
|
652
650
|
if (value === undefined) {
|
|
653
651
|
if (value = this.broadcastId) {
|
|
@@ -722,7 +720,7 @@ class Module extends EventEmitter {
|
|
|
722
720
|
this[_f] = new AbortController();
|
|
723
721
|
this[_g] = null;
|
|
724
722
|
}
|
|
725
|
-
static get VERSION() { return "0.9.
|
|
723
|
+
static get VERSION() { return "0.9.10"; }
|
|
726
724
|
static get LOG_TYPE() { return types_1.LOG_TYPE; }
|
|
727
725
|
static get STATUS_TYPE() { return types_1.STATUS_TYPE; }
|
|
728
726
|
static get MAX_TIMEOUT() { return 2147483647; }
|
|
@@ -941,7 +939,7 @@ class Module extends EventEmitter {
|
|
|
941
939
|
else if (type & 2) {
|
|
942
940
|
if (!checkColorOptions(type, SETTINGS.node, options)) {
|
|
943
941
|
applyStyle(options, this.LOG_STYLE_REVERSE);
|
|
944
|
-
options.hintColor
|
|
942
|
+
options.hintColor ||= 'yellow';
|
|
945
943
|
}
|
|
946
944
|
titleJustify = 'center';
|
|
947
945
|
}
|
|
@@ -975,7 +973,7 @@ class Module extends EventEmitter {
|
|
|
975
973
|
}
|
|
976
974
|
if (type & 128) {
|
|
977
975
|
if (!checkColorOptions(type, SETTINGS.time_elapsed, options)) {
|
|
978
|
-
options.hintColor
|
|
976
|
+
options.hintColor ||= 'yellow';
|
|
979
977
|
}
|
|
980
978
|
if (options.titleBgColor) {
|
|
981
979
|
titleJustify = 'center';
|
|
@@ -983,7 +981,7 @@ class Module extends EventEmitter {
|
|
|
983
981
|
}
|
|
984
982
|
else if (type & 256) {
|
|
985
983
|
if (options.failed) {
|
|
986
|
-
options.messageBgColor
|
|
984
|
+
options.messageBgColor ||= 'bgGrey';
|
|
987
985
|
}
|
|
988
986
|
else {
|
|
989
987
|
const { color, bgColor, bold } = format.meter;
|
|
@@ -996,7 +994,7 @@ class Module extends EventEmitter {
|
|
|
996
994
|
}
|
|
997
995
|
}
|
|
998
996
|
if (bold) {
|
|
999
|
-
options.messageBold
|
|
997
|
+
options.messageBold ??= true;
|
|
1000
998
|
}
|
|
1001
999
|
}
|
|
1002
1000
|
}
|
|
@@ -1014,7 +1012,7 @@ class Module extends EventEmitter {
|
|
|
1014
1012
|
}
|
|
1015
1013
|
if (!hintColor && !hintBgColor) {
|
|
1016
1014
|
({ color: hintColor, bgColor: hintBgColor } = formatHint);
|
|
1017
|
-
hintBold
|
|
1015
|
+
hintBold ??= formatHint.bold;
|
|
1018
1016
|
}
|
|
1019
1017
|
value = getValue();
|
|
1020
1018
|
hint = coloring ? chalk.blackBright('[') + formatColumn(truncateEnd(hint, hintWidth), hintColor, hintBgColor, hintBold) + chalk.blackBright(']') : `[${truncateEnd(hint, hintWidth)}]`;
|
|
@@ -1034,7 +1032,7 @@ class Module extends EventEmitter {
|
|
|
1034
1032
|
}
|
|
1035
1033
|
if (!valueColor && !valueBgColor) {
|
|
1036
1034
|
({ color: valueColor, bgColor: valueBgColor } = formatValue);
|
|
1037
|
-
valueBold
|
|
1035
|
+
valueBold ??= formatValue.bold;
|
|
1038
1036
|
}
|
|
1039
1037
|
try {
|
|
1040
1038
|
let v = value, i = id, m = message;
|
|
@@ -1044,15 +1042,15 @@ class Module extends EventEmitter {
|
|
|
1044
1042
|
}
|
|
1045
1043
|
if ((m || unit) && SETTINGS.message !== false) {
|
|
1046
1044
|
if (error) {
|
|
1047
|
-
m
|
|
1045
|
+
m &&= chalk.redBright('{') + chalk.bgWhite.blackBright(m) + chalk.redBright('}');
|
|
1048
1046
|
}
|
|
1049
1047
|
else {
|
|
1050
1048
|
const formatMessage = format.message;
|
|
1051
1049
|
if (!messageColor && !messageBgColor) {
|
|
1052
1050
|
({ color: messageColor, bgColor: messageBgColor, bold: messageBold } = formatMessage);
|
|
1053
|
-
messageBold
|
|
1051
|
+
messageBold ??= formatMessage.bold;
|
|
1054
1052
|
}
|
|
1055
|
-
messageWidth
|
|
1053
|
+
messageWidth ??= formatMessage.width;
|
|
1056
1054
|
let u = unit;
|
|
1057
1055
|
if (u) {
|
|
1058
1056
|
if ((0, types_1.isObject)(SETTINGS.time_process)) {
|
|
@@ -1167,7 +1165,7 @@ class Module extends EventEmitter {
|
|
|
1167
1165
|
}
|
|
1168
1166
|
}
|
|
1169
1167
|
try {
|
|
1170
|
-
result
|
|
1168
|
+
result ||= (0, types_1.asFunction)(fs.readFileSync(pathname, 'utf-8'), sync);
|
|
1171
1169
|
}
|
|
1172
1170
|
catch (err) {
|
|
1173
1171
|
this.writeFail(["Unable to read file", value], err, 32);
|
|
@@ -2225,7 +2223,6 @@ class Module extends EventEmitter {
|
|
|
2225
2223
|
}
|
|
2226
2224
|
}
|
|
2227
2225
|
static loadSettings(settings, password) {
|
|
2228
|
-
var _h;
|
|
2229
2226
|
const current = VALUES["process.password"];
|
|
2230
2227
|
if (current) {
|
|
2231
2228
|
const proc = settings.process || {};
|
|
@@ -2287,7 +2284,7 @@ class Module extends EventEmitter {
|
|
|
2287
2284
|
VALUES["process.env.apply"] = env.apply;
|
|
2288
2285
|
}
|
|
2289
2286
|
if ((0, types_1.isString)(pwd)) {
|
|
2290
|
-
VALUES[
|
|
2287
|
+
VALUES["process.password"] ||= encryptMessage(pwd, cipher);
|
|
2291
2288
|
}
|
|
2292
2289
|
}
|
|
2293
2290
|
if ((0, types_1.isPlainObject)(memory?.settings)) {
|
|
@@ -2507,7 +2504,7 @@ class Module extends EventEmitter {
|
|
|
2507
2504
|
}
|
|
2508
2505
|
let dir = settings.temp_dir, write, modified;
|
|
2509
2506
|
if ((0, types_1.isPlainObject)(temp)) {
|
|
2510
|
-
dir
|
|
2507
|
+
dir ||= temp.dir;
|
|
2511
2508
|
write = temp.write;
|
|
2512
2509
|
}
|
|
2513
2510
|
if ((0, types_1.isString)(dir) && path.isAbsolute(dir = path.normalize(dir).replace(/[\\/]$/, ''))) {
|
|
@@ -2586,11 +2583,11 @@ class Module extends EventEmitter {
|
|
|
2586
2583
|
let result;
|
|
2587
2584
|
if ((0, types_1.isString)(pathname)) {
|
|
2588
2585
|
leading.push(pathname);
|
|
2589
|
-
createDir
|
|
2586
|
+
createDir ??= true;
|
|
2590
2587
|
}
|
|
2591
2588
|
if (uuidDir) {
|
|
2592
2589
|
leading.push((0, types_1.generateUUID)());
|
|
2593
|
-
createDir
|
|
2590
|
+
createDir ??= true;
|
|
2594
2591
|
}
|
|
2595
2592
|
if ((createDir || increment > 0) && !Module.isDir(result = path.join(...leading))) {
|
|
2596
2593
|
const [output] = tryIncrementDir(result, increment);
|
|
@@ -2689,7 +2686,7 @@ class Module extends EventEmitter {
|
|
|
2689
2686
|
}
|
|
2690
2687
|
}
|
|
2691
2688
|
if (cache) {
|
|
2692
|
-
result
|
|
2689
|
+
result ||= (encoding ? getCacheItem(CACHE_READTEXT, outSrc) : getCacheItem(CACHE_READBUFFER, outSrc));
|
|
2693
2690
|
}
|
|
2694
2691
|
try {
|
|
2695
2692
|
if (!isNaN(minStreamSize = (0, types_1.alignSize)(minStreamSize)) || promises && fs.statSync(outSrc).size >= 2097152000) {
|
|
@@ -3104,7 +3101,7 @@ class Module extends EventEmitter {
|
|
|
3104
3101
|
return false;
|
|
3105
3102
|
}
|
|
3106
3103
|
async allSettled(tasks, rejected, options) {
|
|
3107
|
-
rejected
|
|
3104
|
+
rejected ||= "Unknown";
|
|
3108
3105
|
return Promise.allSettled(tasks).then(result => {
|
|
3109
3106
|
const items = [];
|
|
3110
3107
|
for (const item of result) {
|
|
@@ -3199,7 +3196,7 @@ class Module extends EventEmitter {
|
|
|
3199
3196
|
message = value;
|
|
3200
3197
|
value = '';
|
|
3201
3198
|
}
|
|
3202
|
-
value
|
|
3199
|
+
value ||= isFailed(options) ? "Failed" : "Success";
|
|
3203
3200
|
const duration = getTimeOffset(startTime);
|
|
3204
3201
|
const args = [
|
|
3205
3202
|
(128 | type),
|
|
@@ -3260,7 +3257,7 @@ class Module extends EventEmitter {
|
|
|
3260
3257
|
if ((0, types_1.isPlainObject)(output)) {
|
|
3261
3258
|
output = { ...output };
|
|
3262
3259
|
if (Array.isArray(output.warn)) {
|
|
3263
|
-
(exec.warn
|
|
3260
|
+
(exec.warn ||= []).push(...output.warn);
|
|
3264
3261
|
}
|
|
3265
3262
|
delete output.command;
|
|
3266
3263
|
delete output.warn;
|
package/package.json
CHANGED
|
@@ -1,31 +1,31 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@e-mc/module",
|
|
3
|
-
"version": "0.9.
|
|
4
|
-
"description": "Module base class for E-mc.",
|
|
5
|
-
"main": "index.js",
|
|
6
|
-
"types": "index.d.ts",
|
|
7
|
-
"publishConfig": {
|
|
8
|
-
"access": "public"
|
|
9
|
-
},
|
|
10
|
-
"repository": {
|
|
11
|
-
"type": "git",
|
|
12
|
-
"url": "git+https://github.com/anpham6/e-mc.git",
|
|
13
|
-
"directory": "src/module"
|
|
14
|
-
},
|
|
15
|
-
"keywords": [
|
|
16
|
-
"squared",
|
|
17
|
-
"squared-functions"
|
|
18
|
-
],
|
|
19
|
-
"author": "An Pham <anpham6@gmail.com>",
|
|
20
|
-
"license": "BSD 3-Clause",
|
|
21
|
-
"homepage": "https://github.com/anpham6/e-mc#readme",
|
|
22
|
-
"dependencies": {
|
|
23
|
-
"@e-mc/types": "0.9.
|
|
24
|
-
"chalk": "4.1.2",
|
|
25
|
-
"file-type": "16.5.4",
|
|
26
|
-
"js-yaml": "^4.1.0",
|
|
27
|
-
"mime-types": "^2.1.35",
|
|
28
|
-
"picomatch": "^4.0.2",
|
|
29
|
-
"strip-ansi": "6.0.1"
|
|
30
|
-
}
|
|
31
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@e-mc/module",
|
|
3
|
+
"version": "0.9.10",
|
|
4
|
+
"description": "Module base class for E-mc.",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"types": "index.d.ts",
|
|
7
|
+
"publishConfig": {
|
|
8
|
+
"access": "public"
|
|
9
|
+
},
|
|
10
|
+
"repository": {
|
|
11
|
+
"type": "git",
|
|
12
|
+
"url": "git+https://github.com/anpham6/e-mc.git",
|
|
13
|
+
"directory": "src/module"
|
|
14
|
+
},
|
|
15
|
+
"keywords": [
|
|
16
|
+
"squared",
|
|
17
|
+
"squared-functions"
|
|
18
|
+
],
|
|
19
|
+
"author": "An Pham <anpham6@gmail.com>",
|
|
20
|
+
"license": "BSD 3-Clause",
|
|
21
|
+
"homepage": "https://github.com/anpham6/e-mc#readme",
|
|
22
|
+
"dependencies": {
|
|
23
|
+
"@e-mc/types": "0.9.10",
|
|
24
|
+
"chalk": "4.1.2",
|
|
25
|
+
"file-type": "16.5.4",
|
|
26
|
+
"js-yaml": "^4.1.0",
|
|
27
|
+
"mime-types": "^2.1.35",
|
|
28
|
+
"picomatch": "^4.0.2",
|
|
29
|
+
"strip-ansi": "6.0.1"
|
|
30
|
+
}
|
|
31
|
+
}
|