@cenk1cenk2/oclif-common 6.3.29 → 6.3.30
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/dist/chunk-DzC9Nte8.js +31 -0
- package/dist/index.d.ts +361 -324
- package/dist/index.js +1278 -1796
- package/dist/source-map-support-CuBekda-.js +2435 -0
- package/package.json +11 -11
package/dist/index.js
CHANGED
|
@@ -1,1881 +1,1363 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
4
|
-
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
5
|
-
|
|
6
|
-
// src/index.ts
|
|
7
|
-
import { Inject as Inject3 } from "@nestjs/common";
|
|
8
|
-
|
|
9
|
-
// src/commands/base.command.ts
|
|
1
|
+
import { __commonJS, __toDynamicImportESM, __toESM } from "./chunk-DzC9Nte8.js";
|
|
2
|
+
import { Global, Inject, Inject as Inject$1, Injectable, Module, Scope } from "@nestjs/common";
|
|
10
3
|
import { Manager } from "@listr2/manager";
|
|
11
|
-
import { Command as
|
|
4
|
+
import { Args, Command as Command$1, Flags, Flags as Flags$1, Help, ux } from "@oclif/core";
|
|
12
5
|
import { createInterface } from "readline";
|
|
6
|
+
import op from "object-path-immutable";
|
|
7
|
+
import { dirname, extname, join } from "path";
|
|
8
|
+
import { Writable } from "stream";
|
|
9
|
+
import { color, figures, splat } from "listr2";
|
|
10
|
+
import { EOL } from "os";
|
|
11
|
+
import winston, { format, transports } from "winston";
|
|
12
|
+
import deepmerge from "deepmerge";
|
|
13
|
+
import fs from "fs-extra";
|
|
14
|
+
import { parse, stringify } from "yaml";
|
|
15
|
+
import { plainToClass } from "class-transformer";
|
|
16
|
+
import { validate, validateSync } from "class-validator";
|
|
17
|
+
import { NestFactory } from "@nestjs/core";
|
|
18
|
+
import "reflect-metadata";
|
|
13
19
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
20
|
+
//#region src/constants/file.constants.ts
|
|
21
|
+
let FileConstants = /* @__PURE__ */ function(FileConstants$1) {
|
|
22
|
+
FileConstants$1["CONFIG_SERVICE_DEFAULTS_DIR"] = "config";
|
|
23
|
+
return FileConstants$1;
|
|
18
24
|
}({});
|
|
19
25
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
26
|
+
//#endregion
|
|
27
|
+
//#region src/constants/help-groups.constants.ts
|
|
28
|
+
let HelpGroups = /* @__PURE__ */ function(HelpGroups$1) {
|
|
29
|
+
HelpGroups$1["CLI"] = "CLI";
|
|
30
|
+
return HelpGroups$1;
|
|
24
31
|
}({});
|
|
25
32
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
ConfigEnvKeys2["PARSER"] = "__format";
|
|
35
|
-
ConfigEnvKeys2["ELEMENT"] = "__element";
|
|
36
|
-
ConfigEnvKeys2["ELEMENT_REPLACER"] = "${i}";
|
|
37
|
-
return ConfigEnvKeys2;
|
|
33
|
+
//#endregion
|
|
34
|
+
//#region src/lib/config/config.constants.ts
|
|
35
|
+
let ConfigEnvKeys = /* @__PURE__ */ function(ConfigEnvKeys$1) {
|
|
36
|
+
ConfigEnvKeys$1["NAME"] = "__name";
|
|
37
|
+
ConfigEnvKeys$1["PARSER"] = "__format";
|
|
38
|
+
ConfigEnvKeys$1["ELEMENT"] = "__element";
|
|
39
|
+
ConfigEnvKeys$1["ELEMENT_REPLACER"] = "${i}";
|
|
40
|
+
return ConfigEnvKeys$1;
|
|
38
41
|
}({});
|
|
39
|
-
|
|
42
|
+
const TOKEN_CONFIG_MODULE_OPTIONS = Symbol("TOKEN_CONFIG_MODULE_OPTIONS");
|
|
40
43
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
44
|
+
//#endregion
|
|
45
|
+
//#region src/utils/defaults.ts
|
|
46
|
+
function setCtxDefaults(ctx, ...defaults) {
|
|
47
|
+
defaults?.forEach((i) => {
|
|
48
|
+
if (typeof i === "object" && !Array.isArray(i)) Object.assign(ctx, i);
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
function setCtxAssign(ctx, ...assigns) {
|
|
52
|
+
assigns.forEach((assign) => {
|
|
53
|
+
assign?.keys.forEach((i) => {
|
|
54
|
+
if (assign.from[i]) ctx[i] = assign.from[i];
|
|
55
|
+
});
|
|
56
|
+
});
|
|
46
57
|
}
|
|
47
|
-
__name(pipeProcessThroughListr, "pipeProcessThroughListr");
|
|
48
58
|
|
|
49
|
-
|
|
50
|
-
|
|
59
|
+
//#endregion
|
|
60
|
+
//#region src/lib/logger/pipe/pipe-process-to-listr.ts
|
|
61
|
+
function pipeProcessThroughListr(task, instance) {
|
|
62
|
+
instance.stdout.pipe(task.stdout());
|
|
63
|
+
instance.stderr.pipe(task.stdout());
|
|
64
|
+
return instance;
|
|
65
|
+
}
|
|
51
66
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
67
|
+
//#endregion
|
|
68
|
+
//#region src/lib/logger/logger.constants.ts
|
|
69
|
+
let LogLevels = /* @__PURE__ */ function(LogLevels$1) {
|
|
70
|
+
LogLevels$1["SILENT"] = "SILENT";
|
|
71
|
+
LogLevels$1["DIRECT"] = "DIRECT";
|
|
72
|
+
LogLevels$1["FATAL"] = "FATAL";
|
|
73
|
+
LogLevels$1["ERROR"] = "ERROR";
|
|
74
|
+
LogLevels$1["WARN"] = "WARN";
|
|
75
|
+
LogLevels$1["INFO"] = "INFO";
|
|
76
|
+
LogLevels$1["VERBOSE"] = "VERBOSE";
|
|
77
|
+
LogLevels$1["DEBUG"] = "DEBUG";
|
|
78
|
+
LogLevels$1["TRACE"] = "TRACE";
|
|
79
|
+
return LogLevels$1;
|
|
64
80
|
}({});
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
81
|
+
let LogFieldStatus = /* @__PURE__ */ function(LogFieldStatus$1) {
|
|
82
|
+
LogFieldStatus$1["RUN"] = "run";
|
|
83
|
+
LogFieldStatus$1["END"] = "end";
|
|
84
|
+
LogFieldStatus$1["STAGE"] = "stage";
|
|
85
|
+
LogFieldStatus$1["EXIT"] = "exit";
|
|
86
|
+
LogFieldStatus$1["TERMINATE"] = "terminate";
|
|
87
|
+
return LogFieldStatus$1;
|
|
72
88
|
}({});
|
|
73
89
|
|
|
74
|
-
|
|
90
|
+
//#endregion
|
|
91
|
+
//#region src/lib/logger/pipe/pipe-process-to-logger.ts
|
|
92
|
+
/**
|
|
93
|
+
* Given the instance it will pipe process output through the logger to append prefixes such as the application name.
|
|
94
|
+
*/
|
|
75
95
|
function pipeProcessToLogger(logger, instance, options) {
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
});
|
|
119
|
-
}
|
|
120
|
-
if (options?.callback) {
|
|
121
|
-
options.callback();
|
|
122
|
-
}
|
|
123
|
-
});
|
|
124
|
-
void instance.on("error", (error) => {
|
|
125
|
-
logger.fatal(error.message, {
|
|
126
|
-
context: options.context
|
|
127
|
-
});
|
|
128
|
-
logger.debug(error.stack, {
|
|
129
|
-
context: options.context
|
|
130
|
-
});
|
|
131
|
-
if (options?.callback) {
|
|
132
|
-
options.callback(error);
|
|
133
|
-
}
|
|
134
|
-
});
|
|
135
|
-
return instance;
|
|
96
|
+
options = {
|
|
97
|
+
start: LogLevels.INFO,
|
|
98
|
+
end: LogLevels.INFO,
|
|
99
|
+
stdout: LogLevels.INFO,
|
|
100
|
+
stderr: LogLevels.WARN,
|
|
101
|
+
...options
|
|
102
|
+
};
|
|
103
|
+
if (options.start) logger.run(instance.spawnargs.join(" "), {
|
|
104
|
+
level: options.start,
|
|
105
|
+
context: options.context
|
|
106
|
+
});
|
|
107
|
+
if (instance.stdout) {
|
|
108
|
+
const writable = new Writable();
|
|
109
|
+
writable.write = (chunk) => {
|
|
110
|
+
logger.log(options.stdout, chunk, { context: options.context });
|
|
111
|
+
return true;
|
|
112
|
+
};
|
|
113
|
+
instance.stdout.pipe(writable);
|
|
114
|
+
}
|
|
115
|
+
if (instance.stderr) {
|
|
116
|
+
const writable = new Writable();
|
|
117
|
+
writable.write = (chunk) => {
|
|
118
|
+
logger.log(options.stderr, chunk, { context: options.context });
|
|
119
|
+
return true;
|
|
120
|
+
};
|
|
121
|
+
instance.stderr.pipe(writable);
|
|
122
|
+
}
|
|
123
|
+
instance.on("exit", (code, signal) => {
|
|
124
|
+
const message = `Process ended with code ${code}${signal ? ` and signal ${signal}` : ""}.`;
|
|
125
|
+
logger.debug(message, { context: options.context });
|
|
126
|
+
if (options.end) logger.end(instance.spawnargs.join(" "), {
|
|
127
|
+
level: options.end,
|
|
128
|
+
context: options.context
|
|
129
|
+
});
|
|
130
|
+
if (options?.callback) options.callback();
|
|
131
|
+
});
|
|
132
|
+
instance.on("error", (error) => {
|
|
133
|
+
logger.fatal(error.message, { context: options.context });
|
|
134
|
+
logger.debug(error.stack, { context: options.context });
|
|
135
|
+
if (options?.callback) options.callback(error);
|
|
136
|
+
});
|
|
137
|
+
return instance;
|
|
136
138
|
}
|
|
137
|
-
__name(pipeProcessToLogger, "pipeProcessToLogger");
|
|
138
|
-
|
|
139
|
-
// src/lib/logger/logger.module.ts
|
|
140
|
-
import { Global, Module } from "@nestjs/common";
|
|
141
139
|
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
140
|
+
//#endregion
|
|
141
|
+
//#region ../../node_modules/.pnpm/@oxc-project+runtime@0.77.2/node_modules/@oxc-project/runtime/src/helpers/typeof.js
|
|
142
|
+
var require_typeof = __commonJS({ "../../node_modules/.pnpm/@oxc-project+runtime@0.77.2/node_modules/@oxc-project/runtime/src/helpers/typeof.js"(exports, module) {
|
|
143
|
+
function _typeof$2(o) {
|
|
144
|
+
"@babel/helpers - typeof";
|
|
145
|
+
return module.exports = _typeof$2 = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o$1) {
|
|
146
|
+
return typeof o$1;
|
|
147
|
+
} : function(o$1) {
|
|
148
|
+
return o$1 && "function" == typeof Symbol && o$1.constructor === Symbol && o$1 !== Symbol.prototype ? "symbol" : typeof o$1;
|
|
149
|
+
}, module.exports.__esModule = true, module.exports["default"] = module.exports, _typeof$2(o);
|
|
150
|
+
}
|
|
151
|
+
module.exports = _typeof$2, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
152
|
+
} });
|
|
145
153
|
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
function _ts_param(paramIndex, decorator) {
|
|
163
|
-
return function(target, key) {
|
|
164
|
-
decorator(target, key, paramIndex);
|
|
165
|
-
};
|
|
166
|
-
}
|
|
167
|
-
__name(_ts_param, "_ts_param");
|
|
168
|
-
var _WinstonService = class _WinstonService {
|
|
169
|
-
constructor(options) {
|
|
170
|
-
__publicField(this, "options");
|
|
171
|
-
__publicField(this, "instance");
|
|
172
|
-
this.options = options;
|
|
173
|
-
this.instance = this.initiateLogger();
|
|
174
|
-
}
|
|
175
|
-
initiateLogger() {
|
|
176
|
-
const logFormat = format.printf(({ level, message, context, status }) => {
|
|
177
|
-
return message.split(EOL).filter((msg) => !msg || msg.trim() !== "").map((msg) => {
|
|
178
|
-
return this.logColoring({
|
|
179
|
-
level,
|
|
180
|
-
message: msg,
|
|
181
|
-
context,
|
|
182
|
-
status
|
|
183
|
-
});
|
|
184
|
-
}).join(EOL);
|
|
185
|
-
});
|
|
186
|
-
const logger = winston.createLogger({
|
|
187
|
-
level: this.options.config.logLevel,
|
|
188
|
-
format: format.combine(format.splat(), format.json({
|
|
189
|
-
space: 2
|
|
190
|
-
}), format.prettyPrint(), logFormat),
|
|
191
|
-
levels: Object.fromEntries(Object.values(LogLevels).map((level, i) => {
|
|
192
|
-
return [
|
|
193
|
-
level,
|
|
194
|
-
i
|
|
195
|
-
];
|
|
196
|
-
})),
|
|
197
|
-
silent: this.options.config.logLevel === LogLevels.SILENT || this.options.config.isJson,
|
|
198
|
-
transports: [
|
|
199
|
-
new transports.Console({
|
|
200
|
-
stderrLevels: [
|
|
201
|
-
LogLevels.FATAL,
|
|
202
|
-
LogLevels.ERROR
|
|
203
|
-
]
|
|
204
|
-
})
|
|
205
|
-
]
|
|
206
|
-
});
|
|
207
|
-
logger.log(LogLevels.TRACE, "Initiated new winston with level: %s", this.options.config.logLevel, {
|
|
208
|
-
context: this.constructor.name
|
|
209
|
-
});
|
|
210
|
-
return logger;
|
|
211
|
-
}
|
|
212
|
-
logColoring({ level, message, context, status }) {
|
|
213
|
-
let icon;
|
|
214
|
-
let coloring = /* @__PURE__ */ __name((input) => {
|
|
215
|
-
return input;
|
|
216
|
-
}, "coloring");
|
|
217
|
-
let msgColoring = /* @__PURE__ */ __name((input) => {
|
|
218
|
-
return input;
|
|
219
|
-
}, "msgColoring");
|
|
220
|
-
switch (level) {
|
|
221
|
-
case LogLevels.DIRECT:
|
|
222
|
-
return message;
|
|
223
|
-
case LogLevels.FATAL:
|
|
224
|
-
coloring = color.red;
|
|
225
|
-
msgColoring = color.red;
|
|
226
|
-
break;
|
|
227
|
-
case LogLevels.ERROR:
|
|
228
|
-
coloring = color.red;
|
|
229
|
-
icon = figures.cross;
|
|
230
|
-
break;
|
|
231
|
-
case LogLevels.WARN:
|
|
232
|
-
coloring = color.yellow;
|
|
233
|
-
icon = figures.warning;
|
|
234
|
-
break;
|
|
235
|
-
case LogLevels.INFO:
|
|
236
|
-
coloring = color.green;
|
|
237
|
-
icon = figures.pointerSmall;
|
|
238
|
-
break;
|
|
239
|
-
case LogLevels.VERBOSE:
|
|
240
|
-
coloring = color.dim;
|
|
241
|
-
break;
|
|
242
|
-
case LogLevels.DEBUG:
|
|
243
|
-
coloring = color.cyan;
|
|
244
|
-
msgColoring = color.dim;
|
|
245
|
-
break;
|
|
246
|
-
case LogLevels.TRACE:
|
|
247
|
-
coloring = color.magenta;
|
|
248
|
-
msgColoring = color.dim;
|
|
249
|
-
break;
|
|
250
|
-
}
|
|
251
|
-
if (!icon) {
|
|
252
|
-
icon = `[${level.at(0).toUpperCase()}]`;
|
|
253
|
-
}
|
|
254
|
-
return `${coloring(icon)}${context ? " " + coloring(`[${context}]`) : ""}${status ? " " + coloring(`[${status}]`) : ""} ${msgColoring(message)}`;
|
|
255
|
-
}
|
|
256
|
-
};
|
|
257
|
-
__name(_WinstonService, "WinstonService");
|
|
258
|
-
var WinstonService = _WinstonService;
|
|
259
|
-
WinstonService = _ts_decorate([
|
|
260
|
-
Injectable(),
|
|
261
|
-
_ts_param(0, Inject(TOKEN_CONFIG_MODULE_OPTIONS)),
|
|
262
|
-
_ts_metadata("design:type", Function),
|
|
263
|
-
_ts_metadata("design:paramtypes", [
|
|
264
|
-
typeof ConfigModuleOptions === "undefined" ? Object : ConfigModuleOptions
|
|
265
|
-
])
|
|
266
|
-
], WinstonService);
|
|
154
|
+
//#endregion
|
|
155
|
+
//#region ../../node_modules/.pnpm/@oxc-project+runtime@0.77.2/node_modules/@oxc-project/runtime/src/helpers/toPrimitive.js
|
|
156
|
+
var require_toPrimitive = __commonJS({ "../../node_modules/.pnpm/@oxc-project+runtime@0.77.2/node_modules/@oxc-project/runtime/src/helpers/toPrimitive.js"(exports, module) {
|
|
157
|
+
var _typeof$1 = require_typeof()["default"];
|
|
158
|
+
function toPrimitive$1(t, r) {
|
|
159
|
+
if ("object" != _typeof$1(t) || !t) return t;
|
|
160
|
+
var e = t[Symbol.toPrimitive];
|
|
161
|
+
if (void 0 !== e) {
|
|
162
|
+
var i = e.call(t, r || "default");
|
|
163
|
+
if ("object" != _typeof$1(i)) return i;
|
|
164
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
165
|
+
}
|
|
166
|
+
return ("string" === r ? String : Number)(t);
|
|
167
|
+
}
|
|
168
|
+
module.exports = toPrimitive$1, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
169
|
+
} });
|
|
267
170
|
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
}
|
|
279
|
-
__name(_ts_metadata2, "_ts_metadata");
|
|
280
|
-
var _LoggerService = class _LoggerService {
|
|
281
|
-
constructor(winston2) {
|
|
282
|
-
__publicField(this, "winston");
|
|
283
|
-
__publicField(this, "context");
|
|
284
|
-
this.winston = winston2;
|
|
285
|
-
}
|
|
286
|
-
setup(context) {
|
|
287
|
-
this.context = context;
|
|
288
|
-
return this;
|
|
289
|
-
}
|
|
290
|
-
log(level, data, ...args) {
|
|
291
|
-
return this.parseMessage(level, data, args);
|
|
292
|
-
}
|
|
293
|
-
direct(data, ...args) {
|
|
294
|
-
return this.parseMessage(LogLevels.DIRECT, data, args);
|
|
295
|
-
}
|
|
296
|
-
fatal(data, ...args) {
|
|
297
|
-
return this.parseMessage(LogLevels.FATAL, data, args);
|
|
298
|
-
}
|
|
299
|
-
error(data, ...args) {
|
|
300
|
-
return this.parseMessage(LogLevels.ERROR, data, args);
|
|
301
|
-
}
|
|
302
|
-
warn(data, ...args) {
|
|
303
|
-
return this.parseMessage(LogLevels.WARN, data, args);
|
|
304
|
-
}
|
|
305
|
-
info(data, ...args) {
|
|
306
|
-
return this.parseMessage(LogLevels.INFO, data, args);
|
|
307
|
-
}
|
|
308
|
-
verbose(data, ...args) {
|
|
309
|
-
return this.parseMessage(LogLevels.VERBOSE, data, args);
|
|
310
|
-
}
|
|
311
|
-
debug(data, ...args) {
|
|
312
|
-
return this.parseMessage(LogLevels.DEBUG, data, args);
|
|
313
|
-
}
|
|
314
|
-
trace(data, ...args) {
|
|
315
|
-
return this.parseMessage(LogLevels.TRACE, data, args);
|
|
316
|
-
}
|
|
317
|
-
// status levels
|
|
318
|
-
run(data, ...args) {
|
|
319
|
-
return this.parseMessage(LogLevels.INFO, data, args, {
|
|
320
|
-
status: LogFieldStatus.RUN
|
|
321
|
-
});
|
|
322
|
-
}
|
|
323
|
-
end(data, ...args) {
|
|
324
|
-
return this.parseMessage(LogLevels.INFO, data, args, {
|
|
325
|
-
status: LogFieldStatus.END
|
|
326
|
-
});
|
|
327
|
-
}
|
|
328
|
-
stage(data, ...args) {
|
|
329
|
-
return this.parseMessage(LogLevels.TRACE, data, args, {
|
|
330
|
-
status: LogFieldStatus.STAGE
|
|
331
|
-
});
|
|
332
|
-
}
|
|
333
|
-
splat(...args) {
|
|
334
|
-
const message = args.shift();
|
|
335
|
-
if (typeof message === "undefined") {
|
|
336
|
-
return "";
|
|
337
|
-
}
|
|
338
|
-
if (args.length === 0) {
|
|
339
|
-
return message;
|
|
340
|
-
}
|
|
341
|
-
return splat(message, args);
|
|
342
|
-
}
|
|
343
|
-
parseMessage(level, data, args, format2) {
|
|
344
|
-
this.winston.instance.log(level, data.toString(), ...args ?? [], {
|
|
345
|
-
context: this.context,
|
|
346
|
-
...format2 ?? {}
|
|
347
|
-
});
|
|
348
|
-
}
|
|
349
|
-
};
|
|
350
|
-
__name(_LoggerService, "LoggerService");
|
|
351
|
-
var LoggerService = _LoggerService;
|
|
352
|
-
LoggerService = _ts_decorate2([
|
|
353
|
-
Injectable2({
|
|
354
|
-
scope: Scope.TRANSIENT
|
|
355
|
-
}),
|
|
356
|
-
_ts_metadata2("design:type", Function),
|
|
357
|
-
_ts_metadata2("design:paramtypes", [
|
|
358
|
-
typeof WinstonService === "undefined" ? Object : WinstonService
|
|
359
|
-
])
|
|
360
|
-
], LoggerService);
|
|
171
|
+
//#endregion
|
|
172
|
+
//#region ../../node_modules/.pnpm/@oxc-project+runtime@0.77.2/node_modules/@oxc-project/runtime/src/helpers/toPropertyKey.js
|
|
173
|
+
var require_toPropertyKey = __commonJS({ "../../node_modules/.pnpm/@oxc-project+runtime@0.77.2/node_modules/@oxc-project/runtime/src/helpers/toPropertyKey.js"(exports, module) {
|
|
174
|
+
var _typeof = require_typeof()["default"];
|
|
175
|
+
var toPrimitive = require_toPrimitive();
|
|
176
|
+
function toPropertyKey$1(t) {
|
|
177
|
+
var i = toPrimitive(t, "string");
|
|
178
|
+
return "symbol" == _typeof(i) ? i : i + "";
|
|
179
|
+
}
|
|
180
|
+
module.exports = toPropertyKey$1, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
181
|
+
} });
|
|
361
182
|
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
Module({
|
|
377
|
-
providers: [
|
|
378
|
-
WinstonService,
|
|
379
|
-
LoggerService
|
|
380
|
-
],
|
|
381
|
-
exports: [
|
|
382
|
-
LoggerService
|
|
383
|
-
]
|
|
384
|
-
})
|
|
385
|
-
], LoggerModule);
|
|
183
|
+
//#endregion
|
|
184
|
+
//#region ../../node_modules/.pnpm/@oxc-project+runtime@0.77.2/node_modules/@oxc-project/runtime/src/helpers/defineProperty.js
|
|
185
|
+
var require_defineProperty = __commonJS({ "../../node_modules/.pnpm/@oxc-project+runtime@0.77.2/node_modules/@oxc-project/runtime/src/helpers/defineProperty.js"(exports, module) {
|
|
186
|
+
var toPropertyKey = require_toPropertyKey();
|
|
187
|
+
function _defineProperty$12(e, r, t) {
|
|
188
|
+
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
189
|
+
value: t,
|
|
190
|
+
enumerable: !0,
|
|
191
|
+
configurable: !0,
|
|
192
|
+
writable: !0
|
|
193
|
+
}) : e[r] = t, e;
|
|
194
|
+
}
|
|
195
|
+
module.exports = _defineProperty$12, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
196
|
+
} });
|
|
386
197
|
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
198
|
+
//#endregion
|
|
199
|
+
//#region ../../node_modules/.pnpm/@oxc-project+runtime@0.77.2/node_modules/@oxc-project/runtime/src/helpers/decorate.js
|
|
200
|
+
var require_decorate = __commonJS({ "../../node_modules/.pnpm/@oxc-project+runtime@0.77.2/node_modules/@oxc-project/runtime/src/helpers/decorate.js"(exports, module) {
|
|
201
|
+
function __decorate(decorators, target, key, desc) {
|
|
202
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
203
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
204
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
205
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
206
|
+
}
|
|
207
|
+
module.exports = __decorate, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
208
|
+
} });
|
|
390
209
|
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
}
|
|
453
|
-
}
|
|
454
|
-
writeSync(file, data, options = {}) {
|
|
455
|
-
try {
|
|
456
|
-
this.extra.writeFileSync(file, data, typeof options === "object" ? {
|
|
457
|
-
encoding: "utf-8",
|
|
458
|
-
...options
|
|
459
|
-
} : options);
|
|
460
|
-
} catch (e) {
|
|
461
|
-
throw new Error(`Error while writing file to "${file}": ${e.message}`);
|
|
462
|
-
}
|
|
463
|
-
}
|
|
464
|
-
async append(file, data, options) {
|
|
465
|
-
try {
|
|
466
|
-
await this.extra.appendFile(file, data, options);
|
|
467
|
-
} catch (e) {
|
|
468
|
-
throw new Error(`Error while appending to file "${file}": ${e.message}`);
|
|
469
|
-
}
|
|
470
|
-
}
|
|
471
|
-
appendSync(file, data) {
|
|
472
|
-
try {
|
|
473
|
-
this.extra.appendFileSync(file, data);
|
|
474
|
-
} catch (e) {
|
|
475
|
-
throw new Error(`Error while appending to file "${file}": ${e.message}`);
|
|
476
|
-
}
|
|
477
|
-
}
|
|
478
|
-
async remove(file, options) {
|
|
479
|
-
try {
|
|
480
|
-
await this.extra.rm(file, options);
|
|
481
|
-
} catch (e) {
|
|
482
|
-
throw new Error(`Error while deleting the file "${file}": ${e.message}`);
|
|
483
|
-
}
|
|
484
|
-
}
|
|
485
|
-
removeSync(file, options) {
|
|
486
|
-
try {
|
|
487
|
-
this.extra.rmSync(file, options);
|
|
488
|
-
} catch (e) {
|
|
489
|
-
throw new Error(`Error while deleting the file "${file}": ${e.message}`);
|
|
490
|
-
}
|
|
491
|
-
}
|
|
492
|
-
async emptyDir(directory) {
|
|
493
|
-
try {
|
|
494
|
-
await this.extra.emptyDir(directory);
|
|
495
|
-
} catch (e) {
|
|
496
|
-
throw new Error(`Error while emptying the directory "${directory}": ${e.message}`);
|
|
497
|
-
}
|
|
498
|
-
}
|
|
499
|
-
emptyDirSync(directory) {
|
|
500
|
-
try {
|
|
501
|
-
this.extra.emptyDirSync(directory);
|
|
502
|
-
} catch (e) {
|
|
503
|
-
throw new Error(`Error while emptying the directory "${directory}": ${e.message}`);
|
|
504
|
-
}
|
|
505
|
-
}
|
|
506
|
-
async removeDir(directory) {
|
|
507
|
-
try {
|
|
508
|
-
await this.extra.rmdir(directory);
|
|
509
|
-
} catch (e) {
|
|
510
|
-
throw new Error(`Error while removing the directory "${directory}": ${e.message}`);
|
|
511
|
-
}
|
|
512
|
-
}
|
|
513
|
-
removeDirSync(directory) {
|
|
514
|
-
try {
|
|
515
|
-
this.extra.rmdirSync(directory);
|
|
516
|
-
} catch (e) {
|
|
517
|
-
throw new Error(`Error while removing the directory "${directory}": ${e.message}`);
|
|
518
|
-
}
|
|
519
|
-
}
|
|
520
|
-
async mkdir(directory) {
|
|
521
|
-
try {
|
|
522
|
-
await this.extra.mkdirp(directory);
|
|
523
|
-
} catch (e) {
|
|
524
|
-
throw new Error(`Error while creating the directory "${directory}": ${e.message}`);
|
|
525
|
-
}
|
|
526
|
-
}
|
|
527
|
-
mkdirSync(directory) {
|
|
528
|
-
try {
|
|
529
|
-
this.extra.mkdirpSync(directory);
|
|
530
|
-
} catch (e) {
|
|
531
|
-
throw new Error(`Error while creating the directory "${directory}": ${e.message}`);
|
|
532
|
-
}
|
|
533
|
-
}
|
|
210
|
+
//#endregion
|
|
211
|
+
//#region src/lib/logger/logger.service.ts
|
|
212
|
+
var import_defineProperty$11 = __toESM(require_defineProperty(), 1);
|
|
213
|
+
var import_decorate$17 = __toESM(require_decorate(), 1);
|
|
214
|
+
let LoggerService = class LoggerService$1 {
|
|
215
|
+
constructor(winston$1) {
|
|
216
|
+
this.winston = winston$1;
|
|
217
|
+
(0, import_defineProperty$11.default)(this, "context", void 0);
|
|
218
|
+
}
|
|
219
|
+
setup(context) {
|
|
220
|
+
this.context = context;
|
|
221
|
+
return this;
|
|
222
|
+
}
|
|
223
|
+
log(level, data, ...args) {
|
|
224
|
+
return this.parseMessage(level, data, args);
|
|
225
|
+
}
|
|
226
|
+
direct(data, ...args) {
|
|
227
|
+
return this.parseMessage(LogLevels.DIRECT, data, args);
|
|
228
|
+
}
|
|
229
|
+
fatal(data, ...args) {
|
|
230
|
+
return this.parseMessage(LogLevels.FATAL, data, args);
|
|
231
|
+
}
|
|
232
|
+
error(data, ...args) {
|
|
233
|
+
return this.parseMessage(LogLevels.ERROR, data, args);
|
|
234
|
+
}
|
|
235
|
+
warn(data, ...args) {
|
|
236
|
+
return this.parseMessage(LogLevels.WARN, data, args);
|
|
237
|
+
}
|
|
238
|
+
info(data, ...args) {
|
|
239
|
+
return this.parseMessage(LogLevels.INFO, data, args);
|
|
240
|
+
}
|
|
241
|
+
verbose(data, ...args) {
|
|
242
|
+
return this.parseMessage(LogLevels.VERBOSE, data, args);
|
|
243
|
+
}
|
|
244
|
+
debug(data, ...args) {
|
|
245
|
+
return this.parseMessage(LogLevels.DEBUG, data, args);
|
|
246
|
+
}
|
|
247
|
+
trace(data, ...args) {
|
|
248
|
+
return this.parseMessage(LogLevels.TRACE, data, args);
|
|
249
|
+
}
|
|
250
|
+
run(data, ...args) {
|
|
251
|
+
return this.parseMessage(LogLevels.INFO, data, args, { status: LogFieldStatus.RUN });
|
|
252
|
+
}
|
|
253
|
+
end(data, ...args) {
|
|
254
|
+
return this.parseMessage(LogLevels.INFO, data, args, { status: LogFieldStatus.END });
|
|
255
|
+
}
|
|
256
|
+
stage(data, ...args) {
|
|
257
|
+
return this.parseMessage(LogLevels.TRACE, data, args, { status: LogFieldStatus.STAGE });
|
|
258
|
+
}
|
|
259
|
+
splat(...args) {
|
|
260
|
+
const message = args.shift();
|
|
261
|
+
if (typeof message === "undefined") return "";
|
|
262
|
+
if (args.length === 0) return message;
|
|
263
|
+
return splat(message, args);
|
|
264
|
+
}
|
|
265
|
+
parseMessage(level, data, args, format$1) {
|
|
266
|
+
this.winston.instance.log(level, data.toString(), ...args ?? [], {
|
|
267
|
+
context: this.context,
|
|
268
|
+
...format$1 ?? {}
|
|
269
|
+
});
|
|
270
|
+
}
|
|
534
271
|
};
|
|
535
|
-
|
|
536
|
-
var FileSystemService = _FileSystemService;
|
|
537
|
-
FileSystemService = _ts_decorate4([
|
|
538
|
-
Injectable3(),
|
|
539
|
-
_ts_metadata3("design:type", Function),
|
|
540
|
-
_ts_metadata3("design:paramtypes", [
|
|
541
|
-
typeof LoggerService === "undefined" ? Object : LoggerService
|
|
542
|
-
])
|
|
543
|
-
], FileSystemService);
|
|
272
|
+
LoggerService = (0, import_decorate$17.default)([Injectable({ scope: Scope.TRANSIENT })], LoggerService);
|
|
544
273
|
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
}
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
};
|
|
556
|
-
__name(_FilesystemModule, "FilesystemModule");
|
|
557
|
-
var FilesystemModule = _FilesystemModule;
|
|
558
|
-
FilesystemModule = _ts_decorate5([
|
|
559
|
-
Global2(),
|
|
560
|
-
Module2({
|
|
561
|
-
providers: [
|
|
562
|
-
FileSystemService
|
|
563
|
-
],
|
|
564
|
-
exports: [
|
|
565
|
-
FileSystemService
|
|
566
|
-
]
|
|
567
|
-
})
|
|
568
|
-
], FilesystemModule);
|
|
274
|
+
//#endregion
|
|
275
|
+
//#region ../../node_modules/.pnpm/@oxc-project+runtime@0.77.2/node_modules/@oxc-project/runtime/src/helpers/decorateParam.js
|
|
276
|
+
var require_decorateParam = __commonJS({ "../../node_modules/.pnpm/@oxc-project+runtime@0.77.2/node_modules/@oxc-project/runtime/src/helpers/decorateParam.js"(exports, module) {
|
|
277
|
+
function __decorateParam(paramIndex, decorator) {
|
|
278
|
+
return function(target, key) {
|
|
279
|
+
decorator(target, key, paramIndex);
|
|
280
|
+
};
|
|
281
|
+
}
|
|
282
|
+
module.exports = __decorateParam, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
283
|
+
} });
|
|
569
284
|
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
285
|
+
//#endregion
|
|
286
|
+
//#region src/lib/logger/winston.service.ts
|
|
287
|
+
var import_defineProperty$10 = __toESM(require_defineProperty(), 1);
|
|
288
|
+
var import_decorateParam$1 = __toESM(require_decorateParam(), 1);
|
|
289
|
+
var import_decorate$16 = __toESM(require_decorate(), 1);
|
|
290
|
+
let WinstonService = class WinstonService$1 {
|
|
291
|
+
constructor(options) {
|
|
292
|
+
this.options = options;
|
|
293
|
+
(0, import_defineProperty$10.default)(this, "instance", this.initiateLogger());
|
|
294
|
+
}
|
|
295
|
+
initiateLogger() {
|
|
296
|
+
const logFormat = format.printf(({ level, message, context, status }) => {
|
|
297
|
+
return message.split(EOL).filter((msg) => !msg || msg.trim() !== "").map((msg) => {
|
|
298
|
+
return this.logColoring({
|
|
299
|
+
level,
|
|
300
|
+
message: msg,
|
|
301
|
+
context,
|
|
302
|
+
status
|
|
303
|
+
});
|
|
304
|
+
}).join(EOL);
|
|
305
|
+
});
|
|
306
|
+
const logger = winston.createLogger({
|
|
307
|
+
level: this.options.config.logLevel,
|
|
308
|
+
format: format.combine(format.splat(), format.json({ space: 2 }), format.prettyPrint(), logFormat),
|
|
309
|
+
levels: Object.fromEntries(Object.values(LogLevels).map((level, i) => {
|
|
310
|
+
return [level, i];
|
|
311
|
+
})),
|
|
312
|
+
silent: this.options.config.logLevel === LogLevels.SILENT || this.options.config.isJson,
|
|
313
|
+
transports: [new transports.Console({ stderrLevels: [LogLevels.FATAL, LogLevels.ERROR] })]
|
|
314
|
+
});
|
|
315
|
+
logger.log(LogLevels.TRACE, "Initiated new winston with level: %s", this.options.config.logLevel, { context: this.constructor.name });
|
|
316
|
+
return logger;
|
|
317
|
+
}
|
|
318
|
+
logColoring({ level, message, context, status }) {
|
|
319
|
+
let icon;
|
|
320
|
+
let coloring = (input) => {
|
|
321
|
+
return input;
|
|
322
|
+
};
|
|
323
|
+
let msgColoring = (input) => {
|
|
324
|
+
return input;
|
|
325
|
+
};
|
|
326
|
+
switch (level) {
|
|
327
|
+
case LogLevels.DIRECT: return message;
|
|
328
|
+
case LogLevels.FATAL:
|
|
329
|
+
coloring = color.red;
|
|
330
|
+
msgColoring = color.red;
|
|
331
|
+
break;
|
|
332
|
+
case LogLevels.ERROR:
|
|
333
|
+
coloring = color.red;
|
|
334
|
+
icon = figures.cross;
|
|
335
|
+
break;
|
|
336
|
+
case LogLevels.WARN:
|
|
337
|
+
coloring = color.yellow;
|
|
338
|
+
icon = figures.warning;
|
|
339
|
+
break;
|
|
340
|
+
case LogLevels.INFO:
|
|
341
|
+
coloring = color.green;
|
|
342
|
+
icon = figures.pointerSmall;
|
|
343
|
+
break;
|
|
344
|
+
case LogLevels.VERBOSE:
|
|
345
|
+
coloring = color.dim;
|
|
346
|
+
break;
|
|
347
|
+
case LogLevels.DEBUG:
|
|
348
|
+
coloring = color.cyan;
|
|
349
|
+
msgColoring = color.dim;
|
|
350
|
+
break;
|
|
351
|
+
case LogLevels.TRACE:
|
|
352
|
+
coloring = color.magenta;
|
|
353
|
+
msgColoring = color.dim;
|
|
354
|
+
break;
|
|
355
|
+
}
|
|
356
|
+
if (!icon) icon = `[${level.at(0).toUpperCase()}]`;
|
|
357
|
+
return `${coloring(icon)}${context ? " " + coloring(`[${context}]`) : ""}${status ? " " + coloring(`[${status}]`) : ""} ${msgColoring(message)}`;
|
|
358
|
+
}
|
|
644
359
|
};
|
|
645
|
-
|
|
646
|
-
var ParserService = _ParserService;
|
|
647
|
-
ParserService = _ts_decorate6([
|
|
648
|
-
Injectable4(),
|
|
649
|
-
_ts_metadata4("design:type", Function),
|
|
650
|
-
_ts_metadata4("design:paramtypes", [
|
|
651
|
-
typeof ModuleRef === "undefined" ? Object : ModuleRef,
|
|
652
|
-
typeof FileSystemService === "undefined" ? Object : FileSystemService,
|
|
653
|
-
typeof LoggerService === "undefined" ? Object : LoggerService
|
|
654
|
-
])
|
|
655
|
-
], ParserService);
|
|
360
|
+
WinstonService = (0, import_decorate$16.default)([Injectable(), (0, import_decorateParam$1.default)(0, Inject$1(TOKEN_CONFIG_MODULE_OPTIONS))], WinstonService);
|
|
656
361
|
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
}
|
|
665
|
-
__name(setCtxDefaults, "setCtxDefaults");
|
|
666
|
-
function setCtxAssign(ctx, ...assigns) {
|
|
667
|
-
assigns.forEach((assign) => {
|
|
668
|
-
assign?.keys.forEach((i) => {
|
|
669
|
-
if (assign.from[i]) {
|
|
670
|
-
ctx[i] = assign.from[i];
|
|
671
|
-
}
|
|
672
|
-
});
|
|
673
|
-
});
|
|
674
|
-
}
|
|
675
|
-
__name(setCtxAssign, "setCtxAssign");
|
|
362
|
+
//#endregion
|
|
363
|
+
//#region src/lib/logger/logger.module.ts
|
|
364
|
+
var import_decorate$15 = __toESM(require_decorate(), 1);
|
|
365
|
+
let LoggerModule = class LoggerModule$1 {};
|
|
366
|
+
LoggerModule = (0, import_decorate$15.default)([Global(), Module({
|
|
367
|
+
providers: [WinstonService, LoggerService],
|
|
368
|
+
exports: [LoggerService]
|
|
369
|
+
})], LoggerModule);
|
|
676
370
|
|
|
677
|
-
|
|
371
|
+
//#endregion
|
|
372
|
+
//#region src/utils/environment.ts
|
|
678
373
|
function isVerbose(logLevel) {
|
|
679
|
-
|
|
374
|
+
return logLevel === LogLevels.VERBOSE;
|
|
680
375
|
}
|
|
681
|
-
__name(isVerbose, "isVerbose");
|
|
682
376
|
function isDebug(logLevel) {
|
|
683
|
-
|
|
684
|
-
LogLevels.DEBUG,
|
|
685
|
-
LogLevels.TRACE
|
|
686
|
-
].includes(logLevel);
|
|
377
|
+
return [LogLevels.DEBUG, LogLevels.TRACE].includes(logLevel);
|
|
687
378
|
}
|
|
688
|
-
__name(isDebug, "isDebug");
|
|
689
379
|
function isSilent(logLevel) {
|
|
690
|
-
|
|
380
|
+
return logLevel === LogLevels.SILENT;
|
|
691
381
|
}
|
|
692
|
-
__name(isSilent, "isSilent");
|
|
693
382
|
|
|
694
|
-
|
|
383
|
+
//#endregion
|
|
384
|
+
//#region src/utils/guards.ts
|
|
695
385
|
function isHookedWithShouldRunBefore(command) {
|
|
696
|
-
|
|
386
|
+
return typeof command.shouldRunBefore === "function";
|
|
697
387
|
}
|
|
698
|
-
__name(isHookedWithShouldRunBefore, "isHookedWithShouldRunBefore");
|
|
699
388
|
function isHookedWithShouldRunAfter(command) {
|
|
700
|
-
|
|
389
|
+
return typeof command.shouldRunAfter === "function";
|
|
701
390
|
}
|
|
702
|
-
__name(isHookedWithShouldRunAfter, "isHookedWithShouldRunAfter");
|
|
703
391
|
function isHookedWithRegister(command) {
|
|
704
|
-
|
|
392
|
+
return typeof command.register === "function";
|
|
705
393
|
}
|
|
706
|
-
__name(isHookedWithRegister, "isHookedWithRegister");
|
|
707
394
|
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
395
|
+
//#endregion
|
|
396
|
+
//#region src/utils/merge.constants.ts
|
|
397
|
+
let MergeStrategy = /* @__PURE__ */ function(MergeStrategy$1) {
|
|
398
|
+
MergeStrategy$1["OVERWRITE"] = "OVERWRITE";
|
|
399
|
+
MergeStrategy$1["EXTEND"] = "EXTEND";
|
|
400
|
+
return MergeStrategy$1;
|
|
713
401
|
}({});
|
|
714
402
|
|
|
715
|
-
|
|
716
|
-
|
|
403
|
+
//#endregion
|
|
404
|
+
//#region src/utils/merge.ts
|
|
405
|
+
/** Merge objects deep from overwriting the properties from source to target.
|
|
406
|
+
* Does not mutate the object */
|
|
717
407
|
function merge(strategy, ...source) {
|
|
718
|
-
|
|
719
|
-
arrayMerge: strategy === MergeStrategy.EXTEND ? (dest, src) => [
|
|
720
|
-
...dest,
|
|
721
|
-
...src
|
|
722
|
-
].filter(uniqueArrayFilter) : (_, src) => src
|
|
723
|
-
});
|
|
408
|
+
return deepmerge.all(source, { arrayMerge: strategy === MergeStrategy.EXTEND ? (dest, src) => [...dest, ...src].filter(uniqueArrayFilter) : (_, src) => src });
|
|
724
409
|
}
|
|
725
|
-
__name(merge, "merge");
|
|
726
410
|
function uniqueArrayFilter(value, index, self) {
|
|
727
|
-
|
|
411
|
+
return self.indexOf(value) === index;
|
|
728
412
|
}
|
|
729
|
-
__name(uniqueArrayFilter, "uniqueArrayFilter");
|
|
730
|
-
|
|
731
|
-
// src/utils/index.ts
|
|
732
|
-
import { ux } from "@oclif/core";
|
|
733
413
|
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
let data;
|
|
863
|
-
data = process.env[variable.env];
|
|
864
|
-
if (data) {
|
|
865
|
-
config = cb(config, variable, data);
|
|
866
|
-
}
|
|
867
|
-
if (variable.extensions && variable.extensions.length > 0) {
|
|
868
|
-
const timeout = 6e4;
|
|
869
|
-
const startedAt = Date.now();
|
|
870
|
-
for (let i = 0; i < Infinity; i++) {
|
|
871
|
-
if (Date.now() - startedAt > timeout) {
|
|
872
|
-
throw new Error(`Timed-out in ${timeout}ms while looking for element environment variables.`);
|
|
873
|
-
}
|
|
874
|
-
const extensions = variable.extensions.map((extension) => {
|
|
875
|
-
const clone = JSON.parse(JSON.stringify(extension));
|
|
876
|
-
clone.env = clone.env.replace(ConfigEnvKeys.ELEMENT_REPLACER, i.toString());
|
|
877
|
-
clone.key[clone.key.findIndex((value) => value === ConfigEnvKeys.ELEMENT)] = i.toString();
|
|
878
|
-
data = process.env[clone.env];
|
|
879
|
-
if (!data) {
|
|
880
|
-
this.logger.trace("No extension for environment variable: %s -> %s", clone.key.join("."), clone.env);
|
|
881
|
-
return;
|
|
882
|
-
}
|
|
883
|
-
config = cb(config, clone, data);
|
|
884
|
-
return true;
|
|
885
|
-
}).filter(Boolean);
|
|
886
|
-
if (extensions.length === 0) {
|
|
887
|
-
this.logger.trace("No more extensions for environment variables: %s -> %d", variable.key.join("."), i);
|
|
888
|
-
break;
|
|
889
|
-
}
|
|
890
|
-
}
|
|
891
|
-
}
|
|
892
|
-
});
|
|
893
|
-
return config;
|
|
894
|
-
}
|
|
895
|
-
async write(path, data) {
|
|
896
|
-
return this.parser.write(path, data);
|
|
897
|
-
}
|
|
414
|
+
//#endregion
|
|
415
|
+
//#region src/lib/config/config.service.ts
|
|
416
|
+
var import_defineProperty$9 = __toESM(require_defineProperty(), 1);
|
|
417
|
+
var import_decorateParam = __toESM(require_decorateParam(), 1);
|
|
418
|
+
var import_decorate$14 = __toESM(require_decorate(), 1);
|
|
419
|
+
let ConfigService = class ConfigService$1 {
|
|
420
|
+
constructor(parser, logger, options) {
|
|
421
|
+
this.parser = parser;
|
|
422
|
+
this.logger = logger;
|
|
423
|
+
(0, import_defineProperty$9.default)(this, "defaults", void 0);
|
|
424
|
+
(0, import_defineProperty$9.default)(this, "root", void 0);
|
|
425
|
+
(0, import_defineProperty$9.default)(this, "config", void 0);
|
|
426
|
+
(0, import_defineProperty$9.default)(this, "oclif", void 0);
|
|
427
|
+
(0, import_defineProperty$9.default)(this, "command", void 0);
|
|
428
|
+
this.root = options.oclif.root;
|
|
429
|
+
this.defaults = join(options.oclif.root, FileConstants.CONFIG_SERVICE_DEFAULTS_DIR);
|
|
430
|
+
this.oclif = options.oclif;
|
|
431
|
+
this.config = options.config;
|
|
432
|
+
this.command = options.command;
|
|
433
|
+
this.logger.setup(this.constructor.name);
|
|
434
|
+
}
|
|
435
|
+
get isVerbose() {
|
|
436
|
+
return isVerbose(this.config.logLevel);
|
|
437
|
+
}
|
|
438
|
+
get isDebug() {
|
|
439
|
+
return isDebug(this.config.logLevel);
|
|
440
|
+
}
|
|
441
|
+
get isSilent() {
|
|
442
|
+
return isSilent(this.config.logLevel);
|
|
443
|
+
}
|
|
444
|
+
get isJson() {
|
|
445
|
+
return this.config.isJson;
|
|
446
|
+
}
|
|
447
|
+
async read(path) {
|
|
448
|
+
const config = await this.parser.read(path);
|
|
449
|
+
this.logger.trace("Read config from: %s", path);
|
|
450
|
+
return config;
|
|
451
|
+
}
|
|
452
|
+
async extend(paths, strategy = MergeStrategy.OVERWRITE) {
|
|
453
|
+
this.logger.trace("Will generate config from: %o with %s", paths, strategy);
|
|
454
|
+
const configs = (await Promise.all(paths.map(async (path) => {
|
|
455
|
+
try {
|
|
456
|
+
const config = typeof path === "string" ? await this.parser.read(path) : path;
|
|
457
|
+
this.logger.trace("Extending config from: %s", path);
|
|
458
|
+
return config;
|
|
459
|
+
} catch (e) {
|
|
460
|
+
this.logger.trace("Failed to extend config from: %s", e.message);
|
|
461
|
+
}
|
|
462
|
+
}))).filter(Boolean);
|
|
463
|
+
return this.merge(configs, strategy);
|
|
464
|
+
}
|
|
465
|
+
merge(configs, strategy = MergeStrategy.OVERWRITE) {
|
|
466
|
+
if (configs.length === 0) throw new Error("Nothing to merge, configuration files are empty.");
|
|
467
|
+
return merge(strategy, ...configs);
|
|
468
|
+
}
|
|
469
|
+
async env(definition, config) {
|
|
470
|
+
const env = typeof definition === "string" ? await this.parser.read(definition) : definition;
|
|
471
|
+
this.logger.trace("Environment variable extensions read: %o", definition);
|
|
472
|
+
const iter = async (obj, parent) => {
|
|
473
|
+
const data = await Promise.all(Object.entries(obj).map(async ([key, value]) => {
|
|
474
|
+
const location = [...parent ?? [], key];
|
|
475
|
+
if (typeof value === "string") return [{
|
|
476
|
+
key: location,
|
|
477
|
+
env: value
|
|
478
|
+
}];
|
|
479
|
+
else if (typeof value === "object") {
|
|
480
|
+
let extensions;
|
|
481
|
+
if (ConfigEnvKeys.ELEMENT in value) {
|
|
482
|
+
extensions = await iter(value[ConfigEnvKeys.ELEMENT], [...location, ConfigEnvKeys.ELEMENT]);
|
|
483
|
+
this.logger.trace("Expanding location to elements: %s -> %s", location, extensions.map((extension) => extension.key.join(".")).join(", "));
|
|
484
|
+
}
|
|
485
|
+
if (ConfigEnvKeys.NAME in value && ConfigEnvKeys.PARSER in value) {
|
|
486
|
+
const variable = [{
|
|
487
|
+
key: location,
|
|
488
|
+
env: value[ConfigEnvKeys.NAME],
|
|
489
|
+
parser: value[ConfigEnvKeys.PARSER],
|
|
490
|
+
extensions
|
|
491
|
+
}];
|
|
492
|
+
return variable;
|
|
493
|
+
} else return iter(value, location);
|
|
494
|
+
}
|
|
495
|
+
}));
|
|
496
|
+
return data.flatMap((d) => d).filter(Boolean);
|
|
497
|
+
};
|
|
498
|
+
const parsed = await iter(env);
|
|
499
|
+
const cb = (config$1, variable, data) => {
|
|
500
|
+
if (variable.parser) try {
|
|
501
|
+
data = this.parser.parse(variable.parser, data);
|
|
502
|
+
} catch (e) {
|
|
503
|
+
this.logger.trace("Can not parse environment environment variable for config: %s -> %s with %s", variable.key.join("."), variable.env, variable.parser);
|
|
504
|
+
throw e;
|
|
505
|
+
}
|
|
506
|
+
this.logger.trace("Overwriting config with environment variable: %s -> %s", variable.key.join("."), variable.env);
|
|
507
|
+
return op.set(config$1, variable.key, data);
|
|
508
|
+
};
|
|
509
|
+
parsed.forEach((variable) => {
|
|
510
|
+
let data;
|
|
511
|
+
data = process.env[variable.env];
|
|
512
|
+
if (data) config = cb(config, variable, data);
|
|
513
|
+
if (variable.extensions && variable.extensions.length > 0) {
|
|
514
|
+
const timeout = 6e4;
|
|
515
|
+
const startedAt = Date.now();
|
|
516
|
+
for (let i = 0; i < Infinity; i++) {
|
|
517
|
+
if (Date.now() - startedAt > timeout) throw new Error(`Timed-out in ${timeout}ms while looking for element environment variables.`);
|
|
518
|
+
const extensions = variable.extensions.map((extension) => {
|
|
519
|
+
const clone = JSON.parse(JSON.stringify(extension));
|
|
520
|
+
clone.env = clone.env.replace(ConfigEnvKeys.ELEMENT_REPLACER, i.toString());
|
|
521
|
+
clone.key[clone.key.findIndex((value) => value === ConfigEnvKeys.ELEMENT)] = i.toString();
|
|
522
|
+
data = process.env[clone.env];
|
|
523
|
+
if (!data) {
|
|
524
|
+
this.logger.trace("No extension for environment variable: %s -> %s", clone.key.join("."), clone.env);
|
|
525
|
+
return;
|
|
526
|
+
}
|
|
527
|
+
config = cb(config, clone, data);
|
|
528
|
+
return true;
|
|
529
|
+
}).filter(Boolean);
|
|
530
|
+
if (extensions.length === 0) {
|
|
531
|
+
this.logger.trace("No more extensions for environment variables: %s -> %d", variable.key.join("."), i);
|
|
532
|
+
break;
|
|
533
|
+
}
|
|
534
|
+
}
|
|
535
|
+
}
|
|
536
|
+
});
|
|
537
|
+
return config;
|
|
538
|
+
}
|
|
539
|
+
async write(path, data) {
|
|
540
|
+
return this.parser.write(path, data);
|
|
541
|
+
}
|
|
898
542
|
};
|
|
899
|
-
|
|
900
|
-
var ConfigService = _ConfigService;
|
|
901
|
-
ConfigService = _ts_decorate7([
|
|
902
|
-
Injectable5(),
|
|
903
|
-
_ts_param2(2, Inject2(TOKEN_CONFIG_MODULE_OPTIONS)),
|
|
904
|
-
_ts_metadata5("design:type", Function),
|
|
905
|
-
_ts_metadata5("design:paramtypes", [
|
|
906
|
-
typeof ParserService === "undefined" ? Object : ParserService,
|
|
907
|
-
typeof LoggerService === "undefined" ? Object : LoggerService,
|
|
908
|
-
typeof ConfigModuleOptions === "undefined" ? Object : ConfigModuleOptions
|
|
909
|
-
])
|
|
910
|
-
], ConfigService);
|
|
543
|
+
ConfigService = (0, import_decorate$14.default)([Injectable(), (0, import_decorateParam.default)(2, Inject$1(TOKEN_CONFIG_MODULE_OPTIONS))], ConfigService);
|
|
911
544
|
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
545
|
+
//#endregion
|
|
546
|
+
//#region src/lib/parser/parser.service.ts
|
|
547
|
+
var import_defineProperty$8 = __toESM(require_defineProperty(), 1);
|
|
548
|
+
var import_decorate$13 = __toESM(require_decorate(), 1);
|
|
549
|
+
let ParserService = class ParserService$1 {
|
|
550
|
+
constructor(moduleRef, fs$1, logger) {
|
|
551
|
+
this.moduleRef = moduleRef;
|
|
552
|
+
this.fs = fs$1;
|
|
553
|
+
this.logger = logger;
|
|
554
|
+
(0, import_defineProperty$8.default)(this, "instances", []);
|
|
555
|
+
this.logger.setup(this.constructor.name);
|
|
556
|
+
}
|
|
557
|
+
byFt(file) {
|
|
558
|
+
const ext = (file.includes(".") ? this.fs.extname(file) : file).replace(/^\./, "");
|
|
559
|
+
const Parser = this.instances.find((parser) => parser.extensions.includes(ext));
|
|
560
|
+
if (!Parser) throw new Error(`Parser for the extension is not configured: ${ext}`);
|
|
561
|
+
return Parser;
|
|
562
|
+
}
|
|
563
|
+
fetch(Parser) {
|
|
564
|
+
const parser = this.instances.find((instance) => instance instanceof Parser);
|
|
565
|
+
if (!parser) throw new Error(`Specified parser has not been initiated: ${Parser.name}`);
|
|
566
|
+
return parser;
|
|
567
|
+
}
|
|
568
|
+
async inject(Parser) {
|
|
569
|
+
const parser = await this.moduleRef.create(Parser);
|
|
570
|
+
this.instances.push(parser);
|
|
571
|
+
return parser;
|
|
572
|
+
}
|
|
573
|
+
async register(...parsers) {
|
|
574
|
+
await Promise.all(parsers.map(async (parser) => this.inject(parser)));
|
|
575
|
+
this.logger.trace("Registered parsers: %o", parsers.map((p) => p.name));
|
|
576
|
+
}
|
|
577
|
+
async read(file) {
|
|
578
|
+
return this.parse(file, await this.fs.read(file));
|
|
579
|
+
}
|
|
580
|
+
async write(file, data) {
|
|
581
|
+
return this.fs.write(file, this.stringify(file, data));
|
|
582
|
+
}
|
|
583
|
+
parse(file, data) {
|
|
584
|
+
const parser = this.byFt(file);
|
|
585
|
+
this.logger.trace("Parsing file: %s -> %s", file, parser.constructor.name);
|
|
586
|
+
return parser.parse(data);
|
|
587
|
+
}
|
|
588
|
+
parseWith(Parser, data) {
|
|
589
|
+
const parser = this.fetch(Parser);
|
|
590
|
+
this.logger.trace("Parsing data with: %s", parser.constructor.name);
|
|
591
|
+
return parser.parse(data);
|
|
592
|
+
}
|
|
593
|
+
stringify(file, data) {
|
|
594
|
+
const parser = this.byFt(file);
|
|
595
|
+
this.logger.trace("Stringifying file: %s -> %s", file, parser.constructor.name);
|
|
596
|
+
return parser.stringify(data);
|
|
597
|
+
}
|
|
598
|
+
stringifyWith(Parser, data) {
|
|
599
|
+
const parser = this.fetch(Parser);
|
|
600
|
+
this.logger.trace("Stringifying data: %s", parser.constructor.name);
|
|
601
|
+
return parser.stringify(data);
|
|
602
|
+
}
|
|
925
603
|
};
|
|
926
|
-
|
|
927
|
-
var ParserModule = _ParserModule;
|
|
928
|
-
ParserModule = _ts_decorate8([
|
|
929
|
-
Global3(),
|
|
930
|
-
Module3({
|
|
931
|
-
imports: [
|
|
932
|
-
FilesystemModule
|
|
933
|
-
],
|
|
934
|
-
providers: [
|
|
935
|
-
ParserService
|
|
936
|
-
],
|
|
937
|
-
exports: [
|
|
938
|
-
ParserService
|
|
939
|
-
]
|
|
940
|
-
})
|
|
941
|
-
], ParserModule);
|
|
604
|
+
ParserService = (0, import_decorate$13.default)([Injectable()], ParserService);
|
|
942
605
|
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
606
|
+
//#endregion
|
|
607
|
+
//#region src/lib/fs/filesystem.service.ts
|
|
608
|
+
var import_defineProperty$7 = __toESM(require_defineProperty(), 1);
|
|
609
|
+
var import_decorate$12 = __toESM(require_decorate(), 1);
|
|
610
|
+
let FileSystemService = class FileSystemService$1 {
|
|
611
|
+
constructor(logger) {
|
|
612
|
+
this.logger = logger;
|
|
613
|
+
(0, import_defineProperty$7.default)(this, "extra", fs);
|
|
614
|
+
this.logger.setup(this.constructor.name);
|
|
615
|
+
}
|
|
616
|
+
exists(path) {
|
|
617
|
+
return this.extra.existsSync(path);
|
|
618
|
+
}
|
|
619
|
+
stats(path) {
|
|
620
|
+
return this.extra.statSync(path, { throwIfNoEntry: true });
|
|
621
|
+
}
|
|
622
|
+
dirname(path) {
|
|
623
|
+
return dirname(path);
|
|
624
|
+
}
|
|
625
|
+
extname(path) {
|
|
626
|
+
return extname(path);
|
|
627
|
+
}
|
|
628
|
+
async read(file) {
|
|
629
|
+
try {
|
|
630
|
+
const raw = await this.extra.readFile(file, "utf-8");
|
|
631
|
+
return raw;
|
|
632
|
+
} catch (e) {
|
|
633
|
+
throw new Error(`Error while reading file from "${file}": ${e.message}`);
|
|
634
|
+
}
|
|
635
|
+
}
|
|
636
|
+
readSync(file) {
|
|
637
|
+
try {
|
|
638
|
+
const raw = this.extra.readFileSync(file, "utf-8");
|
|
639
|
+
return raw;
|
|
640
|
+
} catch (e) {
|
|
641
|
+
throw new Error(`Error while reading file from "${file}": ${e.message}`);
|
|
642
|
+
}
|
|
643
|
+
}
|
|
644
|
+
async write(file, data, options = {}) {
|
|
645
|
+
try {
|
|
646
|
+
await this.extra.writeFile(file, data, typeof options === "object" ? {
|
|
647
|
+
encoding: "utf-8",
|
|
648
|
+
...options
|
|
649
|
+
} : options);
|
|
650
|
+
} catch (e) {
|
|
651
|
+
throw new Error(`Error while writing file to "${file}": ${e.message}`);
|
|
652
|
+
}
|
|
653
|
+
}
|
|
654
|
+
writeSync(file, data, options = {}) {
|
|
655
|
+
try {
|
|
656
|
+
this.extra.writeFileSync(file, data, typeof options === "object" ? {
|
|
657
|
+
encoding: "utf-8",
|
|
658
|
+
...options
|
|
659
|
+
} : options);
|
|
660
|
+
} catch (e) {
|
|
661
|
+
throw new Error(`Error while writing file to "${file}": ${e.message}`);
|
|
662
|
+
}
|
|
663
|
+
}
|
|
664
|
+
async append(file, data, options) {
|
|
665
|
+
try {
|
|
666
|
+
await this.extra.appendFile(file, data, options);
|
|
667
|
+
} catch (e) {
|
|
668
|
+
throw new Error(`Error while appending to file "${file}": ${e.message}`);
|
|
669
|
+
}
|
|
670
|
+
}
|
|
671
|
+
appendSync(file, data) {
|
|
672
|
+
try {
|
|
673
|
+
this.extra.appendFileSync(file, data);
|
|
674
|
+
} catch (e) {
|
|
675
|
+
throw new Error(`Error while appending to file "${file}": ${e.message}`);
|
|
676
|
+
}
|
|
677
|
+
}
|
|
678
|
+
async remove(file, options) {
|
|
679
|
+
try {
|
|
680
|
+
await this.extra.rm(file, options);
|
|
681
|
+
} catch (e) {
|
|
682
|
+
throw new Error(`Error while deleting the file "${file}": ${e.message}`);
|
|
683
|
+
}
|
|
684
|
+
}
|
|
685
|
+
removeSync(file, options) {
|
|
686
|
+
try {
|
|
687
|
+
this.extra.rmSync(file, options);
|
|
688
|
+
} catch (e) {
|
|
689
|
+
throw new Error(`Error while deleting the file "${file}": ${e.message}`);
|
|
690
|
+
}
|
|
691
|
+
}
|
|
692
|
+
async emptyDir(directory) {
|
|
693
|
+
try {
|
|
694
|
+
await this.extra.emptyDir(directory);
|
|
695
|
+
} catch (e) {
|
|
696
|
+
throw new Error(`Error while emptying the directory "${directory}": ${e.message}`);
|
|
697
|
+
}
|
|
698
|
+
}
|
|
699
|
+
emptyDirSync(directory) {
|
|
700
|
+
try {
|
|
701
|
+
this.extra.emptyDirSync(directory);
|
|
702
|
+
} catch (e) {
|
|
703
|
+
throw new Error(`Error while emptying the directory "${directory}": ${e.message}`);
|
|
704
|
+
}
|
|
705
|
+
}
|
|
706
|
+
async removeDir(directory) {
|
|
707
|
+
try {
|
|
708
|
+
await this.extra.rmdir(directory);
|
|
709
|
+
} catch (e) {
|
|
710
|
+
throw new Error(`Error while removing the directory "${directory}": ${e.message}`);
|
|
711
|
+
}
|
|
712
|
+
}
|
|
713
|
+
removeDirSync(directory) {
|
|
714
|
+
try {
|
|
715
|
+
this.extra.rmdirSync(directory);
|
|
716
|
+
} catch (e) {
|
|
717
|
+
throw new Error(`Error while removing the directory "${directory}": ${e.message}`);
|
|
718
|
+
}
|
|
719
|
+
}
|
|
720
|
+
async mkdir(directory) {
|
|
721
|
+
try {
|
|
722
|
+
await this.extra.mkdirp(directory);
|
|
723
|
+
} catch (e) {
|
|
724
|
+
throw new Error(`Error while creating the directory "${directory}": ${e.message}`);
|
|
725
|
+
}
|
|
726
|
+
}
|
|
727
|
+
mkdirSync(directory) {
|
|
728
|
+
try {
|
|
729
|
+
this.extra.mkdirpSync(directory);
|
|
730
|
+
} catch (e) {
|
|
731
|
+
throw new Error(`Error while creating the directory "${directory}": ${e.message}`);
|
|
732
|
+
}
|
|
733
|
+
}
|
|
952
734
|
};
|
|
953
|
-
|
|
954
|
-
var ConfigModule = _ConfigModule;
|
|
955
|
-
ConfigModule = _ts_decorate9([
|
|
956
|
-
Global4(),
|
|
957
|
-
Module4({
|
|
958
|
-
imports: [
|
|
959
|
-
ParserModule
|
|
960
|
-
],
|
|
961
|
-
providers: [
|
|
962
|
-
ConfigService
|
|
963
|
-
],
|
|
964
|
-
exports: [
|
|
965
|
-
ConfigService
|
|
966
|
-
]
|
|
967
|
-
})
|
|
968
|
-
], ConfigModule);
|
|
735
|
+
FileSystemService = (0, import_decorate$12.default)([Injectable()], FileSystemService);
|
|
969
736
|
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
737
|
+
//#endregion
|
|
738
|
+
//#region src/lib/fs/filesystem.module.ts
|
|
739
|
+
var import_decorate$11 = __toESM(require_decorate(), 1);
|
|
740
|
+
let FilesystemModule = class FilesystemModule$1 {};
|
|
741
|
+
FilesystemModule = (0, import_decorate$11.default)([Global(), Module({
|
|
742
|
+
providers: [FileSystemService],
|
|
743
|
+
exports: [FileSystemService]
|
|
744
|
+
})], FilesystemModule);
|
|
973
745
|
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
}
|
|
983
|
-
__name(_ts_decorate10, "_ts_decorate");
|
|
984
|
-
function _ts_metadata6(k, v) {
|
|
985
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
986
|
-
}
|
|
987
|
-
__name(_ts_metadata6, "_ts_metadata");
|
|
988
|
-
var _EnvironmentVariableParser = class _EnvironmentVariableParser {
|
|
989
|
-
constructor(logger) {
|
|
990
|
-
__publicField(this, "logger");
|
|
991
|
-
__publicField(this, "extensions");
|
|
992
|
-
__publicField(this, "LINE");
|
|
993
|
-
this.logger = logger;
|
|
994
|
-
this.extensions = [
|
|
995
|
-
"env"
|
|
996
|
-
];
|
|
997
|
-
this.LINE = /(?:^|^)\s*(?:export\s+)?([\w.-]+)(?:\s*=\s*?|:\s+?)(\s*'(?:\\'|[^'])*'|\s*"(?:\\"|[^"])*"|\s*`(?:\\`|[^`])*`|[^#\r\n]+)?\s*(?:#.*)?(?:$|$)/gm;
|
|
998
|
-
this.logger.setup(this.constructor.name);
|
|
999
|
-
}
|
|
1000
|
-
parse(data) {
|
|
1001
|
-
try {
|
|
1002
|
-
return data.toString().split(EOL2).reduce((o, line) => {
|
|
1003
|
-
const match = this.LINE.exec(line);
|
|
1004
|
-
const key = match[1];
|
|
1005
|
-
const value = match[2] ?? "";
|
|
1006
|
-
return {
|
|
1007
|
-
...o,
|
|
1008
|
-
[key]: value
|
|
1009
|
-
};
|
|
1010
|
-
}, {});
|
|
1011
|
-
} catch (e) {
|
|
1012
|
-
this.logger.trace("Error during parsing environment file: %s", e.message);
|
|
1013
|
-
throw e;
|
|
1014
|
-
}
|
|
1015
|
-
}
|
|
1016
|
-
stringify(data) {
|
|
1017
|
-
return Object.entries(data).map(([k, v]) => `${k}=${v}`).join(EOL2) + EOL2;
|
|
1018
|
-
}
|
|
1019
|
-
};
|
|
1020
|
-
__name(_EnvironmentVariableParser, "EnvironmentVariableParser");
|
|
1021
|
-
var EnvironmentVariableParser = _EnvironmentVariableParser;
|
|
1022
|
-
EnvironmentVariableParser = _ts_decorate10([
|
|
1023
|
-
Injectable6(),
|
|
1024
|
-
_ts_metadata6("design:type", Function),
|
|
1025
|
-
_ts_metadata6("design:paramtypes", [
|
|
1026
|
-
typeof LoggerService === "undefined" ? Object : LoggerService
|
|
1027
|
-
])
|
|
1028
|
-
], EnvironmentVariableParser);
|
|
746
|
+
//#endregion
|
|
747
|
+
//#region src/lib/parser/parser.module.ts
|
|
748
|
+
var import_decorate$10 = __toESM(require_decorate(), 1);
|
|
749
|
+
let ParserModule = class ParserModule$1 {};
|
|
750
|
+
ParserModule = (0, import_decorate$10.default)([Global(), Module({
|
|
751
|
+
imports: [FilesystemModule],
|
|
752
|
+
providers: [ParserService],
|
|
753
|
+
exports: [ParserService]
|
|
754
|
+
})], ParserModule);
|
|
1029
755
|
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
function _ts_metadata7(k, v) {
|
|
1040
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
1041
|
-
}
|
|
1042
|
-
__name(_ts_metadata7, "_ts_metadata");
|
|
1043
|
-
var _JsonParser = class _JsonParser {
|
|
1044
|
-
constructor(logger) {
|
|
1045
|
-
__publicField(this, "logger");
|
|
1046
|
-
__publicField(this, "extensions");
|
|
1047
|
-
this.logger = logger;
|
|
1048
|
-
this.extensions = [
|
|
1049
|
-
"json"
|
|
1050
|
-
];
|
|
1051
|
-
this.logger.setup(this.constructor.name);
|
|
1052
|
-
}
|
|
1053
|
-
parse(data) {
|
|
1054
|
-
try {
|
|
1055
|
-
return JSON.parse(data.toString());
|
|
1056
|
-
} catch (e) {
|
|
1057
|
-
this.logger.trace("Error during parsing JSON file: %s", e.message);
|
|
1058
|
-
throw e;
|
|
1059
|
-
}
|
|
1060
|
-
}
|
|
1061
|
-
stringify(data) {
|
|
1062
|
-
return JSON.stringify(data, null, 2);
|
|
1063
|
-
}
|
|
1064
|
-
};
|
|
1065
|
-
__name(_JsonParser, "JsonParser");
|
|
1066
|
-
var JsonParser = _JsonParser;
|
|
1067
|
-
JsonParser = _ts_decorate11([
|
|
1068
|
-
Injectable7(),
|
|
1069
|
-
_ts_metadata7("design:type", Function),
|
|
1070
|
-
_ts_metadata7("design:paramtypes", [
|
|
1071
|
-
typeof LoggerService === "undefined" ? Object : LoggerService
|
|
1072
|
-
])
|
|
1073
|
-
], JsonParser);
|
|
756
|
+
//#endregion
|
|
757
|
+
//#region src/lib/config/config.module.ts
|
|
758
|
+
var import_decorate$9 = __toESM(require_decorate(), 1);
|
|
759
|
+
let ConfigModule = class ConfigModule$1 {};
|
|
760
|
+
ConfigModule = (0, import_decorate$9.default)([Global(), Module({
|
|
761
|
+
imports: [ParserModule],
|
|
762
|
+
providers: [ConfigService],
|
|
763
|
+
exports: [ConfigService]
|
|
764
|
+
})], ConfigModule);
|
|
1074
765
|
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
766
|
+
//#endregion
|
|
767
|
+
//#region src/lib/locker/locker.service.ts
|
|
768
|
+
var import_defineProperty$6 = __toESM(require_defineProperty(), 1);
|
|
769
|
+
var import_decorate$8 = __toESM(require_decorate(), 1);
|
|
770
|
+
let LockerService = class LockerService$1 {
|
|
771
|
+
constructor(logger, fs$1, parser, options) {
|
|
772
|
+
this.logger = logger;
|
|
773
|
+
this.fs = fs$1;
|
|
774
|
+
this.parser = parser;
|
|
775
|
+
this.options = options;
|
|
776
|
+
(0, import_defineProperty$6.default)(this, "op", op);
|
|
777
|
+
(0, import_defineProperty$6.default)(this, "toLock", []);
|
|
778
|
+
(0, import_defineProperty$6.default)(this, "toUnlock", []);
|
|
779
|
+
this.logger.setup(this.constructor.name);
|
|
780
|
+
}
|
|
781
|
+
hasLock() {
|
|
782
|
+
return this.toLock.length > 0;
|
|
783
|
+
}
|
|
784
|
+
hasUnlock() {
|
|
785
|
+
return this.toUnlock.length > 0;
|
|
786
|
+
}
|
|
787
|
+
addLock(...data) {
|
|
788
|
+
this.toLock.push(...data);
|
|
789
|
+
}
|
|
790
|
+
addUnlock(...data) {
|
|
791
|
+
this.toUnlock.push(...data);
|
|
792
|
+
}
|
|
793
|
+
async applyLockAll(lock) {
|
|
794
|
+
if (this.hasLock()) return this.applyLock(lock, ...this.toLock);
|
|
795
|
+
return lock;
|
|
796
|
+
}
|
|
797
|
+
async lockAll() {
|
|
798
|
+
if (this.hasLock()) {
|
|
799
|
+
await this.lock(...this.toLock);
|
|
800
|
+
this.toLock = [];
|
|
801
|
+
}
|
|
802
|
+
}
|
|
803
|
+
async applyUnlockAll(lock) {
|
|
804
|
+
if (this.hasUnlock()) return this.applyUnlock(lock, ...this.toUnlock);
|
|
805
|
+
return lock;
|
|
806
|
+
}
|
|
807
|
+
async unlockAll() {
|
|
808
|
+
if (this.hasUnlock()) {
|
|
809
|
+
await this.unlock(...this.toUnlock);
|
|
810
|
+
this.toUnlock = [];
|
|
811
|
+
}
|
|
812
|
+
}
|
|
813
|
+
async all() {
|
|
814
|
+
await this.unlockAll();
|
|
815
|
+
await this.lockAll();
|
|
816
|
+
}
|
|
817
|
+
async applyAll(lock) {
|
|
818
|
+
lock = await this.applyUnlockAll(lock);
|
|
819
|
+
lock = await this.applyLockAll(lock);
|
|
820
|
+
return lock;
|
|
821
|
+
}
|
|
822
|
+
async applyLock(lock, ...data) {
|
|
823
|
+
data.forEach((d) => {
|
|
824
|
+
if (d?.enabled === false) return;
|
|
825
|
+
else if (!d?.data || Array.isArray(d?.data) && d.data.length === 0 || typeof d?.data === "object" && Object.keys(d.data).length === 0) return;
|
|
826
|
+
const path = this.buildPath(d);
|
|
827
|
+
if (d?.merge) {
|
|
828
|
+
let parsed;
|
|
829
|
+
if (typeof d.data === "object") parsed = merge(d.merge, this.op.get(lock, path, Array.isArray(d.data) ? [] : {}), d.data);
|
|
830
|
+
else {
|
|
831
|
+
this.logger.warn("\"%s\" path with type \"%s\" is not mergeable.", path, typeof d.data);
|
|
832
|
+
parsed = d.data;
|
|
833
|
+
}
|
|
834
|
+
lock = this.op.set(lock, path, parsed);
|
|
835
|
+
this.logger.verbose("Merge lock: %s -> %o", path, d.data);
|
|
836
|
+
return;
|
|
837
|
+
}
|
|
838
|
+
lock = this.op.set(lock, path, d.data);
|
|
839
|
+
this.logger.verbose("Override lock: %s -> %o", path, d.data);
|
|
840
|
+
});
|
|
841
|
+
return lock;
|
|
842
|
+
}
|
|
843
|
+
async lock(...data) {
|
|
844
|
+
const lock = await this.applyLock(await this.tryRead() ?? {}, ...data);
|
|
845
|
+
await this.write(lock);
|
|
846
|
+
return lock;
|
|
847
|
+
}
|
|
848
|
+
async applyUnlock(lock, ...data) {
|
|
849
|
+
if (data.length > 0) {
|
|
850
|
+
data.forEach((d) => {
|
|
851
|
+
if (d?.enabled === false) return;
|
|
852
|
+
const path = this.buildPath(d);
|
|
853
|
+
lock = op.del(lock, path);
|
|
854
|
+
this.logger.verbose("Unlocked: %s", path);
|
|
855
|
+
for (let i = path.length - 1; i >= 0; i--) {
|
|
856
|
+
const parentPath = path.slice(0, i);
|
|
857
|
+
const parent = this.op.get(lock, parentPath);
|
|
858
|
+
if (!parent || Array.isArray(parent) && parent.length === 0 || typeof parent === "object" && Object.keys(parent).length === 0) {
|
|
859
|
+
this.logger.verbose("Unlocked parent: %s -> %s", path, parentPath);
|
|
860
|
+
lock = op.del(lock, parentPath);
|
|
861
|
+
} else break;
|
|
862
|
+
}
|
|
863
|
+
});
|
|
864
|
+
return lock;
|
|
865
|
+
}
|
|
866
|
+
lock = op.del(lock, this.options.root);
|
|
867
|
+
this.logger.verbose("Unlocked module: %s", this.options.root);
|
|
868
|
+
return lock;
|
|
869
|
+
}
|
|
870
|
+
async unlock(...data) {
|
|
871
|
+
const state = await this.tryRead();
|
|
872
|
+
if (!state) {
|
|
873
|
+
this.logger.verbose("Lock file not found. Nothing to unlock.");
|
|
874
|
+
return;
|
|
875
|
+
}
|
|
876
|
+
const lock = await this.applyUnlock(state, ...data);
|
|
877
|
+
await this.write(lock);
|
|
878
|
+
return lock;
|
|
879
|
+
}
|
|
880
|
+
async read() {
|
|
881
|
+
return this.parser.fetch(this.options.parser).parse(await this.fs.read(this.options.file));
|
|
882
|
+
}
|
|
883
|
+
async tryRead() {
|
|
884
|
+
const lock = await this.fs.read(this.options.file).catch((err) => {
|
|
885
|
+
this.logger.trace("Can not read lockfile: %s -> %s", this.options.file, err.message);
|
|
886
|
+
});
|
|
887
|
+
if (!lock) return;
|
|
888
|
+
return this.parser.fetch(this.options.parser).parse(lock);
|
|
889
|
+
}
|
|
890
|
+
async tryRemove() {
|
|
891
|
+
return this.fs.remove(this.options.file).then(() => {
|
|
892
|
+
this.logger.trace("Removed lockfile: %s", this.options.file);
|
|
893
|
+
}).catch((err) => {
|
|
894
|
+
this.logger.trace("Can not remove lockfile: %s -> %s", this.options.file, err.message);
|
|
895
|
+
});
|
|
896
|
+
}
|
|
897
|
+
async write(data) {
|
|
898
|
+
if (!data || Array.isArray(data) && data.length === 0 || typeof data === "object" && Object.keys(data).length === 0) {
|
|
899
|
+
this.logger.trace("Trying to write empty lock file, deleting it instead: %s", this.options.file);
|
|
900
|
+
return this.fs.remove(this.options.file);
|
|
901
|
+
}
|
|
902
|
+
return this.fs.write(this.options.file, this.parser.fetch(this.options.parser).stringify(data));
|
|
903
|
+
}
|
|
904
|
+
buildPath(d) {
|
|
905
|
+
if (d?.root !== true && this.options.root?.length) return [...this.options.root, ...this.normalizePath(d.path)];
|
|
906
|
+
return this.normalizePath(d.path);
|
|
907
|
+
}
|
|
908
|
+
normalizePath(path) {
|
|
909
|
+
if (Array.isArray(path)) return path.map((p) => p.toString());
|
|
910
|
+
else if (typeof path === "string") return path.split(".");
|
|
911
|
+
return [];
|
|
912
|
+
}
|
|
1113
913
|
};
|
|
1114
|
-
|
|
1115
|
-
var YamlParser = _YamlParser;
|
|
1116
|
-
YamlParser = _ts_decorate12([
|
|
1117
|
-
Injectable8(),
|
|
1118
|
-
_ts_metadata8("design:type", Function),
|
|
1119
|
-
_ts_metadata8("design:paramtypes", [
|
|
1120
|
-
typeof LoggerService === "undefined" ? Object : LoggerService
|
|
1121
|
-
])
|
|
1122
|
-
], YamlParser);
|
|
914
|
+
LockerService = (0, import_decorate$8.default)([Injectable()], LockerService);
|
|
1123
915
|
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
}
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
hasLock() {
|
|
1155
|
-
return this.toLock.length > 0;
|
|
1156
|
-
}
|
|
1157
|
-
hasUnlock() {
|
|
1158
|
-
return this.toUnlock.length > 0;
|
|
1159
|
-
}
|
|
1160
|
-
addLock(...data) {
|
|
1161
|
-
this.toLock.push(...data);
|
|
1162
|
-
}
|
|
1163
|
-
addUnlock(...data) {
|
|
1164
|
-
this.toUnlock.push(...data);
|
|
1165
|
-
}
|
|
1166
|
-
async applyLockAll(lock) {
|
|
1167
|
-
if (this.hasLock()) {
|
|
1168
|
-
return this.applyLock(lock, ...this.toLock);
|
|
1169
|
-
}
|
|
1170
|
-
return lock;
|
|
1171
|
-
}
|
|
1172
|
-
async lockAll() {
|
|
1173
|
-
if (this.hasLock()) {
|
|
1174
|
-
await this.lock(...this.toLock);
|
|
1175
|
-
this.toLock = [];
|
|
1176
|
-
}
|
|
1177
|
-
}
|
|
1178
|
-
async applyUnlockAll(lock) {
|
|
1179
|
-
if (this.hasUnlock()) {
|
|
1180
|
-
return this.applyUnlock(lock, ...this.toUnlock);
|
|
1181
|
-
}
|
|
1182
|
-
return lock;
|
|
1183
|
-
}
|
|
1184
|
-
async unlockAll() {
|
|
1185
|
-
if (this.hasUnlock()) {
|
|
1186
|
-
await this.unlock(...this.toUnlock);
|
|
1187
|
-
this.toUnlock = [];
|
|
1188
|
-
}
|
|
1189
|
-
}
|
|
1190
|
-
async all() {
|
|
1191
|
-
await this.unlockAll();
|
|
1192
|
-
await this.lockAll();
|
|
1193
|
-
}
|
|
1194
|
-
async applyAll(lock) {
|
|
1195
|
-
lock = await this.applyUnlockAll(lock);
|
|
1196
|
-
lock = await this.applyLockAll(lock);
|
|
1197
|
-
return lock;
|
|
1198
|
-
}
|
|
1199
|
-
async applyLock(lock, ...data) {
|
|
1200
|
-
data.forEach((d) => {
|
|
1201
|
-
if (d?.enabled === false) {
|
|
1202
|
-
return;
|
|
1203
|
-
} else if (!d?.data || Array.isArray(d?.data) && d.data.length === 0 || typeof d?.data === "object" && Object.keys(d.data).length === 0) {
|
|
1204
|
-
return;
|
|
1205
|
-
}
|
|
1206
|
-
const path = this.buildPath(d);
|
|
1207
|
-
if (d?.merge) {
|
|
1208
|
-
let parsed;
|
|
1209
|
-
if (typeof d.data === "object") {
|
|
1210
|
-
parsed = merge(d.merge, this.op.get(lock, path, Array.isArray(d.data) ? [] : {}), d.data);
|
|
1211
|
-
} else {
|
|
1212
|
-
this.logger.warn('"%s" path with type "%s" is not mergeable.', path, typeof d.data);
|
|
1213
|
-
parsed = d.data;
|
|
1214
|
-
}
|
|
1215
|
-
lock = this.op.set(lock, path, parsed);
|
|
1216
|
-
this.logger.verbose("Merge lock: %s -> %o", path, d.data);
|
|
1217
|
-
return;
|
|
1218
|
-
}
|
|
1219
|
-
lock = this.op.set(lock, path, d.data);
|
|
1220
|
-
this.logger.verbose("Override lock: %s -> %o", path, d.data);
|
|
1221
|
-
});
|
|
1222
|
-
return lock;
|
|
1223
|
-
}
|
|
1224
|
-
async lock(...data) {
|
|
1225
|
-
const lock = await this.applyLock(await this.tryRead() ?? {}, ...data);
|
|
1226
|
-
await this.write(lock);
|
|
1227
|
-
return lock;
|
|
1228
|
-
}
|
|
1229
|
-
async applyUnlock(lock, ...data) {
|
|
1230
|
-
if (data.length > 0) {
|
|
1231
|
-
data.forEach((d) => {
|
|
1232
|
-
if (d?.enabled === false) {
|
|
1233
|
-
return;
|
|
1234
|
-
}
|
|
1235
|
-
const path = this.buildPath(d);
|
|
1236
|
-
lock = op2.del(lock, path);
|
|
1237
|
-
this.logger.verbose("Unlocked: %s", path);
|
|
1238
|
-
for (let i = path.length - 1; i >= 0; i--) {
|
|
1239
|
-
const parentPath = path.slice(0, i);
|
|
1240
|
-
const parent = this.op.get(lock, parentPath);
|
|
1241
|
-
if (!parent || Array.isArray(parent) && parent.length === 0 || typeof parent === "object" && Object.keys(parent).length === 0) {
|
|
1242
|
-
this.logger.verbose("Unlocked parent: %s -> %s", path, parentPath);
|
|
1243
|
-
lock = op2.del(lock, parentPath);
|
|
1244
|
-
} else {
|
|
1245
|
-
break;
|
|
1246
|
-
}
|
|
1247
|
-
}
|
|
1248
|
-
});
|
|
1249
|
-
return lock;
|
|
1250
|
-
}
|
|
1251
|
-
lock = op2.del(lock, this.options.root);
|
|
1252
|
-
this.logger.verbose("Unlocked module: %s", this.options.root);
|
|
1253
|
-
return lock;
|
|
1254
|
-
}
|
|
1255
|
-
async unlock(...data) {
|
|
1256
|
-
const state = await this.tryRead();
|
|
1257
|
-
if (!state) {
|
|
1258
|
-
this.logger.verbose("Lock file not found. Nothing to unlock.");
|
|
1259
|
-
return;
|
|
1260
|
-
}
|
|
1261
|
-
const lock = await this.applyUnlock(state, ...data);
|
|
1262
|
-
await this.write(lock);
|
|
1263
|
-
return lock;
|
|
1264
|
-
}
|
|
1265
|
-
async read() {
|
|
1266
|
-
return this.parser.fetch(this.options.parser).parse(await this.fs.read(this.options.file));
|
|
1267
|
-
}
|
|
1268
|
-
async tryRead() {
|
|
1269
|
-
const lock = await this.fs.read(this.options.file).catch((err) => {
|
|
1270
|
-
this.logger.trace("Can not read lockfile: %s -> %s", this.options.file, err.message);
|
|
1271
|
-
});
|
|
1272
|
-
if (!lock) {
|
|
1273
|
-
return;
|
|
1274
|
-
}
|
|
1275
|
-
return this.parser.fetch(this.options.parser).parse(lock);
|
|
1276
|
-
}
|
|
1277
|
-
async tryRemove() {
|
|
1278
|
-
return this.fs.remove(this.options.file).then(() => {
|
|
1279
|
-
this.logger.trace("Removed lockfile: %s", this.options.file);
|
|
1280
|
-
}).catch((err) => {
|
|
1281
|
-
this.logger.trace("Can not remove lockfile: %s -> %s", this.options.file, err.message);
|
|
1282
|
-
});
|
|
1283
|
-
}
|
|
1284
|
-
async write(data) {
|
|
1285
|
-
if (!data || Array.isArray(data) && data.length === 0 || typeof data === "object" && Object.keys(data).length === 0) {
|
|
1286
|
-
this.logger.trace("Trying to write empty lock file, deleting it instead: %s", this.options.file);
|
|
1287
|
-
return this.fs.remove(this.options.file);
|
|
1288
|
-
}
|
|
1289
|
-
return this.fs.write(this.options.file, this.parser.fetch(this.options.parser).stringify(data));
|
|
1290
|
-
}
|
|
1291
|
-
buildPath(d) {
|
|
1292
|
-
if (d?.root !== true && this.options.root?.length) {
|
|
1293
|
-
return [
|
|
1294
|
-
...this.options.root,
|
|
1295
|
-
...this.normalizePath(d.path)
|
|
1296
|
-
];
|
|
1297
|
-
}
|
|
1298
|
-
return this.normalizePath(d.path);
|
|
1299
|
-
}
|
|
1300
|
-
normalizePath(path) {
|
|
1301
|
-
if (Array.isArray(path)) {
|
|
1302
|
-
return path.map((p) => p.toString());
|
|
1303
|
-
} else if (typeof path === "string") {
|
|
1304
|
-
return path.split(".");
|
|
1305
|
-
}
|
|
1306
|
-
return [];
|
|
1307
|
-
}
|
|
916
|
+
//#endregion
|
|
917
|
+
//#region src/lib/parser/fts/env-parser.service.ts
|
|
918
|
+
var import_defineProperty$5 = __toESM(require_defineProperty(), 1);
|
|
919
|
+
var import_decorate$7 = __toESM(require_decorate(), 1);
|
|
920
|
+
let EnvironmentVariableParser = class EnvironmentVariableParser$1 {
|
|
921
|
+
constructor(logger) {
|
|
922
|
+
this.logger = logger;
|
|
923
|
+
(0, import_defineProperty$5.default)(this, "extensions", ["env"]);
|
|
924
|
+
(0, import_defineProperty$5.default)(this, "LINE", /(?:^|^)\s*(?:export\s+)?([\w.-]+)(?:\s*=\s*?|:\s+?)(\s*'(?:\\'|[^'])*'|\s*"(?:\\"|[^"])*"|\s*`(?:\\`|[^`])*`|[^#\r\n]+)?\s*(?:#.*)?(?:$|$)/gm);
|
|
925
|
+
this.logger.setup(this.constructor.name);
|
|
926
|
+
}
|
|
927
|
+
parse(data) {
|
|
928
|
+
try {
|
|
929
|
+
return data.toString().split(EOL).reduce((o, line) => {
|
|
930
|
+
const match = this.LINE.exec(line);
|
|
931
|
+
const key = match[1];
|
|
932
|
+
const value = match[2] ?? "";
|
|
933
|
+
return {
|
|
934
|
+
...o,
|
|
935
|
+
[key]: value
|
|
936
|
+
};
|
|
937
|
+
}, {});
|
|
938
|
+
} catch (e) {
|
|
939
|
+
this.logger.trace("Error during parsing environment file: %s", e.message);
|
|
940
|
+
throw e;
|
|
941
|
+
}
|
|
942
|
+
}
|
|
943
|
+
stringify(data) {
|
|
944
|
+
return Object.entries(data).map(([k, v]) => `${k}=${v}`).join(EOL) + EOL;
|
|
945
|
+
}
|
|
1308
946
|
};
|
|
1309
|
-
|
|
1310
|
-
var LockerService = _LockerService;
|
|
1311
|
-
LockerService = _ts_decorate13([
|
|
1312
|
-
Injectable9(),
|
|
1313
|
-
_ts_metadata9("design:type", Function),
|
|
1314
|
-
_ts_metadata9("design:paramtypes", [
|
|
1315
|
-
typeof LoggerService === "undefined" ? Object : LoggerService,
|
|
1316
|
-
typeof FileSystemService === "undefined" ? Object : FileSystemService,
|
|
1317
|
-
typeof ParserService === "undefined" ? Object : ParserService,
|
|
1318
|
-
typeof LockerServiceOptions === "undefined" ? Object : LockerServiceOptions
|
|
1319
|
-
])
|
|
1320
|
-
], LockerService);
|
|
947
|
+
EnvironmentVariableParser = (0, import_decorate$7.default)([Injectable()], EnvironmentVariableParser);
|
|
1321
948
|
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
ParserService
|
|
1344
|
-
]
|
|
1345
|
-
}
|
|
1346
|
-
]
|
|
1347
|
-
};
|
|
1348
|
-
}
|
|
949
|
+
//#endregion
|
|
950
|
+
//#region src/lib/parser/fts/json-parser.service.ts
|
|
951
|
+
var import_defineProperty$4 = __toESM(require_defineProperty(), 1);
|
|
952
|
+
var import_decorate$6 = __toESM(require_decorate(), 1);
|
|
953
|
+
let JsonParser = class JsonParser$1 {
|
|
954
|
+
constructor(logger) {
|
|
955
|
+
this.logger = logger;
|
|
956
|
+
(0, import_defineProperty$4.default)(this, "extensions", ["json"]);
|
|
957
|
+
this.logger.setup(this.constructor.name);
|
|
958
|
+
}
|
|
959
|
+
parse(data) {
|
|
960
|
+
try {
|
|
961
|
+
return JSON.parse(data.toString());
|
|
962
|
+
} catch (e) {
|
|
963
|
+
this.logger.trace("Error during parsing JSON file: %s", e.message);
|
|
964
|
+
throw e;
|
|
965
|
+
}
|
|
966
|
+
}
|
|
967
|
+
stringify(data) {
|
|
968
|
+
return JSON.stringify(data, null, 2);
|
|
969
|
+
}
|
|
1349
970
|
};
|
|
1350
|
-
|
|
1351
|
-
var LockerModule = _LockerModule;
|
|
1352
|
-
LockerModule = _ts_decorate14([
|
|
1353
|
-
Module5({})
|
|
1354
|
-
], LockerModule);
|
|
971
|
+
JsonParser = (0, import_decorate$6.default)([Injectable()], JsonParser);
|
|
1355
972
|
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
973
|
+
//#endregion
|
|
974
|
+
//#region src/lib/parser/fts/yaml-parser.service.ts
|
|
975
|
+
var import_defineProperty$3 = __toESM(require_defineProperty(), 1);
|
|
976
|
+
var import_decorate$5 = __toESM(require_decorate(), 1);
|
|
977
|
+
let YamlParser = class YamlParser$1 {
|
|
978
|
+
constructor(logger) {
|
|
979
|
+
this.logger = logger;
|
|
980
|
+
(0, import_defineProperty$3.default)(this, "extensions", ["yaml", "yml"]);
|
|
981
|
+
this.logger.setup(this.constructor.name);
|
|
982
|
+
}
|
|
983
|
+
parse(data) {
|
|
984
|
+
try {
|
|
985
|
+
return parse(data.toString());
|
|
986
|
+
} catch (e) {
|
|
987
|
+
this.logger.trace("Error during parsing YAML file: %s", e.message);
|
|
988
|
+
throw e;
|
|
989
|
+
}
|
|
990
|
+
}
|
|
991
|
+
stringify(data) {
|
|
992
|
+
return stringify(data, { prettyErrors: true });
|
|
993
|
+
}
|
|
994
|
+
};
|
|
995
|
+
YamlParser = (0, import_decorate$5.default)([Injectable()], YamlParser);
|
|
1361
996
|
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
try {
|
|
1383
|
-
this.generator = moduleRef.get(TOKEN_LOGO_GENERATOR, {
|
|
1384
|
-
strict: false
|
|
1385
|
-
});
|
|
1386
|
-
} catch {
|
|
1387
|
-
this.generator = function() {
|
|
1388
|
-
if (this.shouldBeSilent()) {
|
|
1389
|
-
return;
|
|
1390
|
-
}
|
|
1391
|
-
const logo = this.cs.oclif.name + " v" + this.cs.oclif.version;
|
|
1392
|
-
this.write(logo);
|
|
1393
|
-
this.write("-".repeat(logo.length));
|
|
1394
|
-
};
|
|
1395
|
-
}
|
|
1396
|
-
}
|
|
1397
|
-
generate() {
|
|
1398
|
-
return this.generator.call(this);
|
|
1399
|
-
}
|
|
1400
|
-
shouldBeSilent() {
|
|
1401
|
-
return this.cs.isJson || this.cs.isSilent;
|
|
1402
|
-
}
|
|
1403
|
-
write(...data) {
|
|
1404
|
-
process.stdout.write(data.join(" ") + EOL3);
|
|
1405
|
-
}
|
|
997
|
+
//#endregion
|
|
998
|
+
//#region src/lib/locker/locker.module.ts
|
|
999
|
+
var import_decorate$4 = __toESM(require_decorate(), 1);
|
|
1000
|
+
var _LockerModule;
|
|
1001
|
+
let LockerModule = _LockerModule = class LockerModule$1 {
|
|
1002
|
+
static forFeature(options) {
|
|
1003
|
+
const token = options.token ?? LockerService;
|
|
1004
|
+
return {
|
|
1005
|
+
module: _LockerModule,
|
|
1006
|
+
providers: [{
|
|
1007
|
+
provide: token,
|
|
1008
|
+
useFactory: (logger, fs$1, parser) => new LockerService(logger, fs$1, parser, options),
|
|
1009
|
+
inject: [
|
|
1010
|
+
LoggerService,
|
|
1011
|
+
FileSystemService,
|
|
1012
|
+
ParserService
|
|
1013
|
+
]
|
|
1014
|
+
}]
|
|
1015
|
+
};
|
|
1016
|
+
}
|
|
1406
1017
|
};
|
|
1407
|
-
|
|
1408
|
-
var LogoService = _LogoService;
|
|
1409
|
-
LogoService = _ts_decorate15([
|
|
1410
|
-
Injectable10(),
|
|
1411
|
-
_ts_metadata10("design:type", Function),
|
|
1412
|
-
_ts_metadata10("design:paramtypes", [
|
|
1413
|
-
typeof ConfigService === "undefined" ? Object : ConfigService,
|
|
1414
|
-
typeof ModuleRef2 === "undefined" ? Object : ModuleRef2
|
|
1415
|
-
])
|
|
1416
|
-
], LogoService);
|
|
1018
|
+
LockerModule = _LockerModule = (0, import_decorate$4.default)([Module({})], LockerModule);
|
|
1417
1019
|
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1020
|
+
//#endregion
|
|
1021
|
+
//#region src/lib/logo/logo.constants.ts
|
|
1022
|
+
const TOKEN_LOGO_GENERATOR = Symbol("TOKEN_LOGO_GENERATOR");
|
|
1023
|
+
|
|
1024
|
+
//#endregion
|
|
1025
|
+
//#region src/lib/logo/logo.service.ts
|
|
1026
|
+
var import_defineProperty$2 = __toESM(require_defineProperty(), 1);
|
|
1027
|
+
var import_decorate$3 = __toESM(require_decorate(), 1);
|
|
1028
|
+
let LogoService = class LogoService$1 {
|
|
1029
|
+
constructor(cs, moduleRef) {
|
|
1030
|
+
this.cs = cs;
|
|
1031
|
+
(0, import_defineProperty$2.default)(this, "generator", void 0);
|
|
1032
|
+
try {
|
|
1033
|
+
this.generator = moduleRef.get(TOKEN_LOGO_GENERATOR, { strict: false });
|
|
1034
|
+
} catch {
|
|
1035
|
+
this.generator = function() {
|
|
1036
|
+
if (this.shouldBeSilent()) return;
|
|
1037
|
+
const logo = this.cs.oclif.name + " v" + this.cs.oclif.version;
|
|
1038
|
+
this.write(logo);
|
|
1039
|
+
this.write("-".repeat(logo.length));
|
|
1040
|
+
};
|
|
1041
|
+
}
|
|
1042
|
+
}
|
|
1043
|
+
generate() {
|
|
1044
|
+
return this.generator.call(this);
|
|
1045
|
+
}
|
|
1046
|
+
shouldBeSilent() {
|
|
1047
|
+
return this.cs.isJson || this.cs.isSilent;
|
|
1048
|
+
}
|
|
1049
|
+
write(...data) {
|
|
1050
|
+
process.stdout.write(data.join(" ") + EOL);
|
|
1051
|
+
}
|
|
1427
1052
|
};
|
|
1428
|
-
|
|
1429
|
-
var LogoModule = _LogoModule;
|
|
1430
|
-
LogoModule = _ts_decorate16([
|
|
1431
|
-
Module6({
|
|
1432
|
-
providers: [
|
|
1433
|
-
LogoService
|
|
1434
|
-
],
|
|
1435
|
-
exports: [
|
|
1436
|
-
LogoService
|
|
1437
|
-
]
|
|
1438
|
-
})
|
|
1439
|
-
], LogoModule);
|
|
1053
|
+
LogoService = (0, import_decorate$3.default)([Injectable()], LogoService);
|
|
1440
1054
|
|
|
1441
|
-
|
|
1442
|
-
|
|
1055
|
+
//#endregion
|
|
1056
|
+
//#region src/lib/logo/logo.module.ts
|
|
1057
|
+
var import_decorate$2 = __toESM(require_decorate(), 1);
|
|
1058
|
+
let LogoModule = class LogoModule$1 {};
|
|
1059
|
+
LogoModule = (0, import_decorate$2.default)([Module({
|
|
1060
|
+
providers: [LogoService],
|
|
1061
|
+
exports: [LogoService]
|
|
1062
|
+
})], LogoModule);
|
|
1443
1063
|
|
|
1444
|
-
|
|
1445
|
-
|
|
1064
|
+
//#endregion
|
|
1065
|
+
//#region src/lib/validator/validator.constants.ts
|
|
1066
|
+
const TOKEN_VALIDATOR_SERVICE_OPTIONS = Symbol("TOKEN_VALIDATOR_SERVICE_OPTIONS");
|
|
1446
1067
|
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
}
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
});
|
|
1509
|
-
const errors = validateSync(classObject, {
|
|
1510
|
-
...this.options.validator,
|
|
1511
|
-
...options?.validator ?? {}
|
|
1512
|
-
});
|
|
1513
|
-
if (errors.length) {
|
|
1514
|
-
errors.forEach((error) => {
|
|
1515
|
-
this.logValidationError(error);
|
|
1516
|
-
});
|
|
1517
|
-
throw new Error("Validation failed.");
|
|
1518
|
-
}
|
|
1519
|
-
return classObject;
|
|
1520
|
-
}
|
|
1521
|
-
logValidationError(err) {
|
|
1522
|
-
this.logger.error('Field "%s" failed validation with value "%s": %o', err.property, err.value, err.constraints);
|
|
1523
|
-
if (err.children) {
|
|
1524
|
-
err.children.forEach((children) => this.logValidationError(children));
|
|
1525
|
-
}
|
|
1526
|
-
}
|
|
1068
|
+
//#endregion
|
|
1069
|
+
//#region src/lib/validator/validator.service.ts
|
|
1070
|
+
var import_defineProperty$1 = __toESM(require_defineProperty(), 1);
|
|
1071
|
+
var import_decorate$1 = __toESM(require_decorate(), 1);
|
|
1072
|
+
let ValidatorService = class ValidatorService$1 {
|
|
1073
|
+
constructor(logger, moduleRef) {
|
|
1074
|
+
this.logger = logger;
|
|
1075
|
+
(0, import_defineProperty$1.default)(this, "options", void 0);
|
|
1076
|
+
this.logger.setup(this.constructor.name);
|
|
1077
|
+
try {
|
|
1078
|
+
this.options = moduleRef.get(TOKEN_VALIDATOR_SERVICE_OPTIONS, { strict: false });
|
|
1079
|
+
} catch {
|
|
1080
|
+
this.options = {
|
|
1081
|
+
validator: {
|
|
1082
|
+
skipMissingProperties: true,
|
|
1083
|
+
whitelist: false,
|
|
1084
|
+
always: true,
|
|
1085
|
+
enableDebugMessages: true
|
|
1086
|
+
},
|
|
1087
|
+
transformer: { enableImplicitConversion: true }
|
|
1088
|
+
};
|
|
1089
|
+
}
|
|
1090
|
+
}
|
|
1091
|
+
async validate(classType, object, options) {
|
|
1092
|
+
const classObject = plainToClass(classType, object, {
|
|
1093
|
+
...this.options.transformer,
|
|
1094
|
+
...options?.transformer ?? {}
|
|
1095
|
+
});
|
|
1096
|
+
const errors = await validate(classObject, {
|
|
1097
|
+
...this.options.validator,
|
|
1098
|
+
...options?.validator ?? {}
|
|
1099
|
+
});
|
|
1100
|
+
if (errors.length) {
|
|
1101
|
+
errors.forEach((error) => {
|
|
1102
|
+
this.logValidationError(error);
|
|
1103
|
+
});
|
|
1104
|
+
throw new Error("Validation failed.");
|
|
1105
|
+
}
|
|
1106
|
+
return classObject;
|
|
1107
|
+
}
|
|
1108
|
+
validateSync(classType, object, options) {
|
|
1109
|
+
const classObject = plainToClass(classType, object, {
|
|
1110
|
+
...this.options.transformer,
|
|
1111
|
+
...options?.transformer ?? {}
|
|
1112
|
+
});
|
|
1113
|
+
const errors = validateSync(classObject, {
|
|
1114
|
+
...this.options.validator,
|
|
1115
|
+
...options?.validator ?? {}
|
|
1116
|
+
});
|
|
1117
|
+
if (errors.length) {
|
|
1118
|
+
errors.forEach((error) => {
|
|
1119
|
+
this.logValidationError(error);
|
|
1120
|
+
});
|
|
1121
|
+
throw new Error("Validation failed.");
|
|
1122
|
+
}
|
|
1123
|
+
return classObject;
|
|
1124
|
+
}
|
|
1125
|
+
logValidationError(err) {
|
|
1126
|
+
this.logger.error("Field \"%s\" failed validation with value \"%s\": %o", err.property, err.value, err.constraints);
|
|
1127
|
+
if (err.children) err.children.forEach((children) => this.logValidationError(children));
|
|
1128
|
+
}
|
|
1527
1129
|
};
|
|
1528
|
-
|
|
1529
|
-
var ValidatorService = _ValidatorService;
|
|
1530
|
-
ValidatorService = _ts_decorate17([
|
|
1531
|
-
Injectable11(),
|
|
1532
|
-
_ts_metadata11("design:type", Function),
|
|
1533
|
-
_ts_metadata11("design:paramtypes", [
|
|
1534
|
-
typeof LoggerService === "undefined" ? Object : LoggerService,
|
|
1535
|
-
typeof ModuleRef3 === "undefined" ? Object : ModuleRef3
|
|
1536
|
-
])
|
|
1537
|
-
], ValidatorService);
|
|
1130
|
+
ValidatorService = (0, import_decorate$1.default)([Injectable()], ValidatorService);
|
|
1538
1131
|
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
var _ValidatorModule = class _ValidatorModule {
|
|
1548
|
-
};
|
|
1549
|
-
__name(_ValidatorModule, "ValidatorModule");
|
|
1550
|
-
var ValidatorModule = _ValidatorModule;
|
|
1551
|
-
ValidatorModule = _ts_decorate18([
|
|
1552
|
-
Global5(),
|
|
1553
|
-
Module7({
|
|
1554
|
-
providers: [
|
|
1555
|
-
ValidatorService
|
|
1556
|
-
],
|
|
1557
|
-
exports: [
|
|
1558
|
-
ValidatorService
|
|
1559
|
-
]
|
|
1560
|
-
})
|
|
1561
|
-
], ValidatorModule);
|
|
1132
|
+
//#endregion
|
|
1133
|
+
//#region src/lib/validator/validator.module.ts
|
|
1134
|
+
var import_decorate = __toESM(require_decorate(), 1);
|
|
1135
|
+
let ValidatorModule = class ValidatorModule$1 {};
|
|
1136
|
+
ValidatorModule = (0, import_decorate.default)([Global(), Module({
|
|
1137
|
+
providers: [ValidatorService],
|
|
1138
|
+
exports: [ValidatorService]
|
|
1139
|
+
})], ValidatorModule);
|
|
1562
1140
|
|
|
1563
|
-
|
|
1141
|
+
//#endregion
|
|
1142
|
+
//#region src/lib/setup.ts
|
|
1564
1143
|
async function setup() {
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1144
|
+
const inspect = process.argv.indexOf("--inspect");
|
|
1145
|
+
if (inspect !== -1) {
|
|
1146
|
+
await import("inspector").then((mod) => mod.open());
|
|
1147
|
+
process.argv.splice(inspect, 1);
|
|
1148
|
+
}
|
|
1149
|
+
const sourceMaps = process.argv.indexOf("--source-map");
|
|
1150
|
+
if (sourceMaps !== -1) {
|
|
1151
|
+
await import("./source-map-support-CuBekda-.js").then(__toDynamicImportESM(1)).then((mod) => mod.install());
|
|
1152
|
+
process.argv.splice(sourceMaps, 1);
|
|
1153
|
+
}
|
|
1575
1154
|
}
|
|
1576
|
-
__name(setup, "setup");
|
|
1577
1155
|
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
var
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
}
|
|
1618
|
-
}
|
|
1619
|
-
}
|
|
1620
|
-
],
|
|
1621
|
-
exports: [
|
|
1622
|
-
TOKEN_CONFIG_MODULE_OPTIONS
|
|
1623
|
-
]
|
|
1624
|
-
};
|
|
1625
|
-
}
|
|
1626
|
-
static create(cls) {
|
|
1627
|
-
return NestFactory.createApplicationContext(cls, {
|
|
1628
|
-
logger: [
|
|
1629
|
-
"error"
|
|
1630
|
-
]
|
|
1631
|
-
});
|
|
1632
|
-
}
|
|
1156
|
+
//#endregion
|
|
1157
|
+
//#region src/lib/cli.module.ts
|
|
1158
|
+
var CliModule = class CliModule {
|
|
1159
|
+
static forRoot(options) {
|
|
1160
|
+
return {
|
|
1161
|
+
module: CliModule,
|
|
1162
|
+
global: true,
|
|
1163
|
+
imports: [
|
|
1164
|
+
ConfigModule,
|
|
1165
|
+
LoggerModule,
|
|
1166
|
+
FilesystemModule,
|
|
1167
|
+
ParserModule,
|
|
1168
|
+
LogoModule
|
|
1169
|
+
],
|
|
1170
|
+
providers: [{
|
|
1171
|
+
provide: TOKEN_CONFIG_MODULE_OPTIONS,
|
|
1172
|
+
useValue: options.config
|
|
1173
|
+
}],
|
|
1174
|
+
exports: [TOKEN_CONFIG_MODULE_OPTIONS]
|
|
1175
|
+
};
|
|
1176
|
+
}
|
|
1177
|
+
static forMinimum() {
|
|
1178
|
+
return {
|
|
1179
|
+
module: CliModule,
|
|
1180
|
+
global: true,
|
|
1181
|
+
imports: [LoggerModule],
|
|
1182
|
+
providers: [{
|
|
1183
|
+
provide: TOKEN_CONFIG_MODULE_OPTIONS,
|
|
1184
|
+
useValue: { config: {
|
|
1185
|
+
logLevel: LogLevels.INFO,
|
|
1186
|
+
isJson: false
|
|
1187
|
+
} }
|
|
1188
|
+
}],
|
|
1189
|
+
exports: [TOKEN_CONFIG_MODULE_OPTIONS]
|
|
1190
|
+
};
|
|
1191
|
+
}
|
|
1192
|
+
static create(cls) {
|
|
1193
|
+
return NestFactory.createApplicationContext(cls, { logger: ["error"] });
|
|
1194
|
+
}
|
|
1633
1195
|
};
|
|
1634
|
-
__name(_CliModule, "CliModule");
|
|
1635
|
-
var CliModule = _CliModule;
|
|
1636
1196
|
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
var
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
if (isHookedWithShouldRunAfter(this)) {
|
|
1755
|
-
this.logger.stage("Running hook should-run-after.");
|
|
1756
|
-
await this.shouldRunAfter(ctx);
|
|
1757
|
-
this.logger.stage("Finished hook should-run-after.");
|
|
1758
|
-
}
|
|
1759
|
-
return {
|
|
1760
|
-
ctx
|
|
1761
|
-
};
|
|
1762
|
-
}
|
|
1763
|
-
/** Catch any error occurred during command. */
|
|
1764
|
-
// catch all those errors, not verbose
|
|
1765
|
-
async catch(err) {
|
|
1766
|
-
process.exitCode = process.exitCode ?? err.exitCode ?? 1;
|
|
1767
|
-
if (!this.logger) {
|
|
1768
|
-
this.app = await CliModule.create(CliModule.forMinimum());
|
|
1769
|
-
this.logger = await this.app.resolve(LoggerService);
|
|
1770
|
-
}
|
|
1771
|
-
this.logger.fatal(err.message);
|
|
1772
|
-
this.logger.debug(err.stack, {
|
|
1773
|
-
context: "crash"
|
|
1774
|
-
});
|
|
1775
|
-
throw err;
|
|
1776
|
-
}
|
|
1197
|
+
//#endregion
|
|
1198
|
+
//#region src/commands/base.command.ts
|
|
1199
|
+
var import_defineProperty = __toESM(require_defineProperty(), 1);
|
|
1200
|
+
var Command = class extends Command$1 {
|
|
1201
|
+
constructor(..._args) {
|
|
1202
|
+
super(..._args);
|
|
1203
|
+
(0, import_defineProperty.default)(this, "logger", void 0);
|
|
1204
|
+
(0, import_defineProperty.default)(this, "tasks", void 0);
|
|
1205
|
+
(0, import_defineProperty.default)(this, "app", void 0);
|
|
1206
|
+
(0, import_defineProperty.default)(this, "flags", void 0);
|
|
1207
|
+
(0, import_defineProperty.default)(this, "args", void 0);
|
|
1208
|
+
}
|
|
1209
|
+
exit(code) {
|
|
1210
|
+
this.logger.trace("Code -> %d", code, { status: LogFieldStatus.EXIT });
|
|
1211
|
+
super.exit(code ?? 0);
|
|
1212
|
+
}
|
|
1213
|
+
/** Run all tasks from task manager. */
|
|
1214
|
+
runTasks() {
|
|
1215
|
+
return this.tasks.runAll();
|
|
1216
|
+
}
|
|
1217
|
+
setCtxDefaults(...defaults) {
|
|
1218
|
+
setCtxDefaults(this.tasks.options.ctx, ...defaults);
|
|
1219
|
+
this.logger.trace("Updated context with defaults: %o", this.tasks.options.ctx, { status: "ctx" });
|
|
1220
|
+
}
|
|
1221
|
+
setCtxAssign(...assigns) {
|
|
1222
|
+
setCtxAssign(this.tasks.options.ctx, ...assigns);
|
|
1223
|
+
this.logger.trace("Updated context with assign: %o", this.tasks.options.ctx, { status: "ctx" });
|
|
1224
|
+
}
|
|
1225
|
+
pipeProcessToLogger(instance, options) {
|
|
1226
|
+
return pipeProcessToLogger(this.logger, instance, options);
|
|
1227
|
+
}
|
|
1228
|
+
pipeProcessThroughListr(instance, task) {
|
|
1229
|
+
return pipeProcessThroughListr(task, instance);
|
|
1230
|
+
}
|
|
1231
|
+
/** Initial functions / constructor */
|
|
1232
|
+
async init() {
|
|
1233
|
+
await super.init();
|
|
1234
|
+
let err;
|
|
1235
|
+
try {
|
|
1236
|
+
const { args, flags } = await this.parse({
|
|
1237
|
+
flags: this.ctor.flags,
|
|
1238
|
+
baseFlags: super.ctor.baseFlags,
|
|
1239
|
+
enableJsonFlag: this.ctor.enableJsonFlag,
|
|
1240
|
+
args: this.ctor.args,
|
|
1241
|
+
strict: this.ctor.strict
|
|
1242
|
+
});
|
|
1243
|
+
this.flags = flags;
|
|
1244
|
+
this.args = args;
|
|
1245
|
+
} catch (e) {
|
|
1246
|
+
err = e;
|
|
1247
|
+
}
|
|
1248
|
+
const options = { config: {
|
|
1249
|
+
oclif: this.config,
|
|
1250
|
+
command: this.ctor,
|
|
1251
|
+
config: {
|
|
1252
|
+
logLevel: this.flags?.["log-level"] ?? LogLevels.INFO,
|
|
1253
|
+
isJson: this.flags?.json ?? false
|
|
1254
|
+
}
|
|
1255
|
+
} };
|
|
1256
|
+
const cli = CliModule.forRoot(options);
|
|
1257
|
+
this.app = await CliModule.create(!err && isHookedWithRegister(this) ? await this.register(cli, options) : cli);
|
|
1258
|
+
const cs = this.app.get(ConfigService);
|
|
1259
|
+
this.logger = await this.app.resolve(LoggerService);
|
|
1260
|
+
this.app.useLogger(this.logger);
|
|
1261
|
+
this.app.get(LogoService).generate();
|
|
1262
|
+
if (err) throw err;
|
|
1263
|
+
this.logger.stage("Created application context.");
|
|
1264
|
+
this.tasks = new Manager({
|
|
1265
|
+
fallbackRendererCondition: cs.isDebug,
|
|
1266
|
+
silentRendererCondition: cs.isSilent || cs.isJson,
|
|
1267
|
+
ctx: {}
|
|
1268
|
+
});
|
|
1269
|
+
if (cs.oclif.windows) createInterface({
|
|
1270
|
+
input: process.stdin,
|
|
1271
|
+
output: process.stdout
|
|
1272
|
+
}).on("SIGINT", () => {
|
|
1273
|
+
process.kill(process.pid, "SIGINT");
|
|
1274
|
+
});
|
|
1275
|
+
const terminate = () => {
|
|
1276
|
+
this.logger.fatal("Caught terminate signal.", { status: LogFieldStatus.TERMINATE });
|
|
1277
|
+
process.exit(1);
|
|
1278
|
+
};
|
|
1279
|
+
process.on("SIGINT", terminate);
|
|
1280
|
+
process.on("SIGTERM", terminate);
|
|
1281
|
+
if (isHookedWithShouldRunBefore(this)) {
|
|
1282
|
+
this.logger.stage("Running hook should-run-before.");
|
|
1283
|
+
await this.shouldRunBefore();
|
|
1284
|
+
this.logger.stage("Finished hook should-run-before.");
|
|
1285
|
+
}
|
|
1286
|
+
}
|
|
1287
|
+
/** Tasks to run before end of the command. */
|
|
1288
|
+
async finally(err) {
|
|
1289
|
+
let ctx;
|
|
1290
|
+
if (err) return { ctx };
|
|
1291
|
+
if (this.tasks?.tasks?.length > 0) {
|
|
1292
|
+
this.logger.stage("Running tasks.");
|
|
1293
|
+
ctx = await this.runTasks();
|
|
1294
|
+
this.logger.stage("Finished tasks.");
|
|
1295
|
+
}
|
|
1296
|
+
if (isHookedWithShouldRunAfter(this)) {
|
|
1297
|
+
this.logger.stage("Running hook should-run-after.");
|
|
1298
|
+
await this.shouldRunAfter(ctx);
|
|
1299
|
+
this.logger.stage("Finished hook should-run-after.");
|
|
1300
|
+
}
|
|
1301
|
+
return { ctx };
|
|
1302
|
+
}
|
|
1303
|
+
/** Catch any error occurred during command. */
|
|
1304
|
+
async catch(err) {
|
|
1305
|
+
process.exitCode = process.exitCode ?? err.exitCode ?? 1;
|
|
1306
|
+
if (!this.logger) {
|
|
1307
|
+
this.app = await CliModule.create(CliModule.forMinimum());
|
|
1308
|
+
this.logger = await this.app.resolve(LoggerService);
|
|
1309
|
+
}
|
|
1310
|
+
this.logger.fatal(err.message);
|
|
1311
|
+
this.logger.debug(err.stack, { context: "crash" });
|
|
1312
|
+
throw err;
|
|
1313
|
+
}
|
|
1777
1314
|
};
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
})
|
|
1315
|
+
(0, import_defineProperty.default)(Command, "baseFlags", {
|
|
1316
|
+
["log-level"]: Flags$1.string({
|
|
1317
|
+
default: LogLevels.INFO,
|
|
1318
|
+
env: "LOG_LEVEL",
|
|
1319
|
+
description: "Set the log level of the application.",
|
|
1320
|
+
options: Object.values(LogLevels).map((level) => level.toLowerCase()),
|
|
1321
|
+
helpGroup: HelpGroups.CLI,
|
|
1322
|
+
parse: async (input) => input?.toUpperCase()
|
|
1323
|
+
}),
|
|
1324
|
+
ci: Flags$1.boolean({
|
|
1325
|
+
default: false,
|
|
1326
|
+
hidden: true,
|
|
1327
|
+
env: "CI",
|
|
1328
|
+
description: "Instruct whether this is running the CI/CD configuration.",
|
|
1329
|
+
helpGroup: HelpGroups.CLI
|
|
1330
|
+
}),
|
|
1331
|
+
json: Flags$1.boolean({
|
|
1332
|
+
default: false,
|
|
1333
|
+
hidden: true,
|
|
1334
|
+
env: "JSON",
|
|
1335
|
+
description: "Put the CLI to respond in JSON.",
|
|
1336
|
+
helpGroup: HelpGroups.CLI
|
|
1337
|
+
})
|
|
1802
1338
|
});
|
|
1803
|
-
var Command = _Command;
|
|
1804
|
-
|
|
1805
|
-
// src/hooks/not-found.hook.ts
|
|
1806
|
-
import { Help } from "@oclif/core";
|
|
1807
|
-
var notFoundHook = /* @__PURE__ */ __name(async (opts) => {
|
|
1808
|
-
const app = await CliModule.create(CliModule.forMinimum());
|
|
1809
|
-
const logger = await app.resolve(LoggerService);
|
|
1810
|
-
logger.error("Command not found. Take a look at help. You can also use --[h]elp flag for subcommands.");
|
|
1811
|
-
logger.direct("");
|
|
1812
|
-
const help = new Help(opts.config);
|
|
1813
|
-
await help.showHelp([
|
|
1814
|
-
"--all"
|
|
1815
|
-
]);
|
|
1816
|
-
opts.context.exit(127);
|
|
1817
|
-
}, "notFoundHook");
|
|
1818
1339
|
|
|
1819
|
-
|
|
1820
|
-
|
|
1821
|
-
|
|
1822
|
-
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
}, "updateNotifierHook");
|
|
1340
|
+
//#endregion
|
|
1341
|
+
//#region src/hooks/not-found.hook.ts
|
|
1342
|
+
const notFoundHook = async (opts) => {
|
|
1343
|
+
const app = await CliModule.create(CliModule.forMinimum());
|
|
1344
|
+
const logger = await app.resolve(LoggerService);
|
|
1345
|
+
logger.error("Command not found. Take a look at help. You can also use --[h]elp flag for subcommands.");
|
|
1346
|
+
logger.direct("");
|
|
1347
|
+
const help = new Help(opts.config);
|
|
1348
|
+
await help.showHelp(["--all"]);
|
|
1349
|
+
opts.context.exit(127);
|
|
1350
|
+
};
|
|
1831
1351
|
|
|
1832
|
-
|
|
1833
|
-
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
|
|
1838
|
-
|
|
1839
|
-
|
|
1840
|
-
EnvironmentVariableParser,
|
|
1841
|
-
FileConstants,
|
|
1842
|
-
FileSystemService,
|
|
1843
|
-
FilesystemModule,
|
|
1844
|
-
Flags2 as Flags,
|
|
1845
|
-
HelpGroups,
|
|
1846
|
-
Inject3 as Inject,
|
|
1847
|
-
JsonParser,
|
|
1848
|
-
LockerModule,
|
|
1849
|
-
LockerService,
|
|
1850
|
-
LogFieldStatus,
|
|
1851
|
-
LogLevels,
|
|
1852
|
-
LoggerModule,
|
|
1853
|
-
LoggerService,
|
|
1854
|
-
LogoModule,
|
|
1855
|
-
LogoService,
|
|
1856
|
-
MergeStrategy,
|
|
1857
|
-
ParserModule,
|
|
1858
|
-
ParserService,
|
|
1859
|
-
TOKEN_LOGO_GENERATOR,
|
|
1860
|
-
TOKEN_VALIDATOR_SERVICE_OPTIONS,
|
|
1861
|
-
ValidatorModule,
|
|
1862
|
-
ValidatorService,
|
|
1863
|
-
WinstonService,
|
|
1864
|
-
YamlParser,
|
|
1865
|
-
isDebug,
|
|
1866
|
-
isHookedWithRegister,
|
|
1867
|
-
isHookedWithShouldRunAfter,
|
|
1868
|
-
isHookedWithShouldRunBefore,
|
|
1869
|
-
isSilent,
|
|
1870
|
-
isVerbose,
|
|
1871
|
-
merge,
|
|
1872
|
-
notFoundHook,
|
|
1873
|
-
pipeProcessThroughListr,
|
|
1874
|
-
pipeProcessToLogger,
|
|
1875
|
-
setCtxAssign,
|
|
1876
|
-
setCtxDefaults,
|
|
1877
|
-
setup,
|
|
1878
|
-
uniqueArrayFilter,
|
|
1879
|
-
updateNotifierHook,
|
|
1880
|
-
ux
|
|
1352
|
+
//#endregion
|
|
1353
|
+
//#region src/hooks/update-notifier.hook.ts
|
|
1354
|
+
const updateNotifierHook = async (opts) => {
|
|
1355
|
+
const { default: notifier } = await import("update-notifier");
|
|
1356
|
+
notifier({ pkg: {
|
|
1357
|
+
name: opts.config.name,
|
|
1358
|
+
version: opts.config.version
|
|
1359
|
+
} }).notify({ isGlobal: true });
|
|
1881
1360
|
};
|
|
1361
|
+
|
|
1362
|
+
//#endregion
|
|
1363
|
+
export { Args, CliModule, Command, ConfigModule, ConfigService, EnvironmentVariableParser, FileConstants, FileSystemService, FilesystemModule, Flags, HelpGroups, Inject, JsonParser, LockerModule, LockerService, LogFieldStatus, LogLevels, LoggerModule, LoggerService, LogoModule, LogoService, MergeStrategy, ParserModule, ParserService, TOKEN_LOGO_GENERATOR, TOKEN_VALIDATOR_SERVICE_OPTIONS, ValidatorModule, ValidatorService, WinstonService, YamlParser, isDebug, isHookedWithRegister, isHookedWithShouldRunAfter, isHookedWithShouldRunBefore, isSilent, isVerbose, merge, notFoundHook, pipeProcessThroughListr, pipeProcessToLogger, setCtxAssign, setCtxDefaults, setup, uniqueArrayFilter, updateNotifierHook, ux };
|