@cenk1cenk2/oclif-common 3.5.2 → 3.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/hooks/index.js +13 -12
- package/dist/hooks/not-found.hook.js +7 -4
- package/dist/hooks/store.hook.js +13 -12
- package/dist/index.d.ts +55 -17
- package/dist/index.js +54 -39
- package/package.json +1 -1
package/dist/hooks/index.js
CHANGED
|
@@ -108,10 +108,13 @@ var Logger = class {
|
|
|
108
108
|
return this.parseMessage("TRACE" /* TRACE */, data, args);
|
|
109
109
|
}
|
|
110
110
|
run(data, ...args) {
|
|
111
|
-
return this.parseMessage("INFO" /* INFO */, data, args, { status: "
|
|
111
|
+
return this.parseMessage("INFO" /* INFO */, data, args, { status: "run" /* RUN */ });
|
|
112
112
|
}
|
|
113
113
|
end(data, ...args) {
|
|
114
|
-
return this.parseMessage("INFO" /* INFO */, data, args, { status: "
|
|
114
|
+
return this.parseMessage("INFO" /* INFO */, data, args, { status: "end" /* END */ });
|
|
115
|
+
}
|
|
116
|
+
stage(data, ...args) {
|
|
117
|
+
return this.parseMessage("TRACE" /* TRACE */, data, args, { status: "stage" /* STAGE */ });
|
|
115
118
|
}
|
|
116
119
|
initiateLogger() {
|
|
117
120
|
const logFormat = import_winston.format.printf(({ level, message, context, status }) => {
|
|
@@ -188,7 +191,7 @@ var Logger = class {
|
|
|
188
191
|
case "VERBOSE" /* VERBOSE */:
|
|
189
192
|
coloring = color.dim;
|
|
190
193
|
if (this.options?.useIcons) {
|
|
191
|
-
icon =
|
|
194
|
+
icon = "\u2607";
|
|
192
195
|
}
|
|
193
196
|
break;
|
|
194
197
|
case "DEBUG" /* DEBUG */:
|
|
@@ -202,7 +205,7 @@ var Logger = class {
|
|
|
202
205
|
coloring = color.magenta;
|
|
203
206
|
msgColoring = color.dim;
|
|
204
207
|
if (this.options?.useIcons) {
|
|
205
|
-
icon = "\
|
|
208
|
+
icon = "\u26B1";
|
|
206
209
|
}
|
|
207
210
|
break;
|
|
208
211
|
}
|
|
@@ -270,13 +273,12 @@ var CLI_FLAGS = {
|
|
|
270
273
|
// src/lib/parser/json-parser.service.ts
|
|
271
274
|
var _JsonParser = class {
|
|
272
275
|
constructor() {
|
|
273
|
-
this.logger = new Logger(this.constructor.name);
|
|
274
276
|
if (_JsonParser.instance) {
|
|
275
277
|
return _JsonParser.instance;
|
|
276
|
-
} else {
|
|
277
|
-
_JsonParser.instance = this;
|
|
278
|
-
this.logger.trace("Created a new instance.");
|
|
279
278
|
}
|
|
279
|
+
_JsonParser.instance = this;
|
|
280
|
+
this.logger = new Logger(this.constructor.name);
|
|
281
|
+
this.logger.trace("Created a new instance.");
|
|
280
282
|
}
|
|
281
283
|
parse(data) {
|
|
282
284
|
try {
|
|
@@ -298,13 +300,12 @@ JsonParser.extensions = ["json"];
|
|
|
298
300
|
var import_yaml = require("yaml");
|
|
299
301
|
var _YamlParser = class {
|
|
300
302
|
constructor() {
|
|
301
|
-
this.logger = new Logger(this.constructor.name);
|
|
302
303
|
if (_YamlParser.instance) {
|
|
303
304
|
return _YamlParser.instance;
|
|
304
|
-
} else {
|
|
305
|
-
_YamlParser.instance = this;
|
|
306
|
-
this.logger.trace("Created a new instance.");
|
|
307
305
|
}
|
|
306
|
+
_YamlParser.instance = this;
|
|
307
|
+
this.logger = new Logger(this.constructor.name);
|
|
308
|
+
this.logger.trace("Created a new instance.");
|
|
308
309
|
}
|
|
309
310
|
parse(data) {
|
|
310
311
|
try {
|
|
@@ -104,10 +104,13 @@ var Logger = class {
|
|
|
104
104
|
return this.parseMessage("TRACE" /* TRACE */, data, args);
|
|
105
105
|
}
|
|
106
106
|
run(data, ...args) {
|
|
107
|
-
return this.parseMessage("INFO" /* INFO */, data, args, { status: "
|
|
107
|
+
return this.parseMessage("INFO" /* INFO */, data, args, { status: "run" /* RUN */ });
|
|
108
108
|
}
|
|
109
109
|
end(data, ...args) {
|
|
110
|
-
return this.parseMessage("INFO" /* INFO */, data, args, { status: "
|
|
110
|
+
return this.parseMessage("INFO" /* INFO */, data, args, { status: "end" /* END */ });
|
|
111
|
+
}
|
|
112
|
+
stage(data, ...args) {
|
|
113
|
+
return this.parseMessage("TRACE" /* TRACE */, data, args, { status: "stage" /* STAGE */ });
|
|
111
114
|
}
|
|
112
115
|
initiateLogger() {
|
|
113
116
|
const logFormat = import_winston.format.printf(({ level, message, context, status }) => {
|
|
@@ -184,7 +187,7 @@ var Logger = class {
|
|
|
184
187
|
case "VERBOSE" /* VERBOSE */:
|
|
185
188
|
coloring = color.dim;
|
|
186
189
|
if (this.options?.useIcons) {
|
|
187
|
-
icon =
|
|
190
|
+
icon = "\u2607";
|
|
188
191
|
}
|
|
189
192
|
break;
|
|
190
193
|
case "DEBUG" /* DEBUG */:
|
|
@@ -198,7 +201,7 @@ var Logger = class {
|
|
|
198
201
|
coloring = color.magenta;
|
|
199
202
|
msgColoring = color.dim;
|
|
200
203
|
if (this.options?.useIcons) {
|
|
201
|
-
icon = "\
|
|
204
|
+
icon = "\u26B1";
|
|
202
205
|
}
|
|
203
206
|
break;
|
|
204
207
|
}
|
package/dist/hooks/store.hook.js
CHANGED
|
@@ -110,10 +110,13 @@ var Logger = class {
|
|
|
110
110
|
return this.parseMessage("TRACE" /* TRACE */, data, args);
|
|
111
111
|
}
|
|
112
112
|
run(data, ...args) {
|
|
113
|
-
return this.parseMessage("INFO" /* INFO */, data, args, { status: "
|
|
113
|
+
return this.parseMessage("INFO" /* INFO */, data, args, { status: "run" /* RUN */ });
|
|
114
114
|
}
|
|
115
115
|
end(data, ...args) {
|
|
116
|
-
return this.parseMessage("INFO" /* INFO */, data, args, { status: "
|
|
116
|
+
return this.parseMessage("INFO" /* INFO */, data, args, { status: "end" /* END */ });
|
|
117
|
+
}
|
|
118
|
+
stage(data, ...args) {
|
|
119
|
+
return this.parseMessage("TRACE" /* TRACE */, data, args, { status: "stage" /* STAGE */ });
|
|
117
120
|
}
|
|
118
121
|
initiateLogger() {
|
|
119
122
|
const logFormat = import_winston.format.printf(({ level, message, context, status }) => {
|
|
@@ -190,7 +193,7 @@ var Logger = class {
|
|
|
190
193
|
case "VERBOSE" /* VERBOSE */:
|
|
191
194
|
coloring = color.dim;
|
|
192
195
|
if (this.options?.useIcons) {
|
|
193
|
-
icon =
|
|
196
|
+
icon = "\u2607";
|
|
194
197
|
}
|
|
195
198
|
break;
|
|
196
199
|
case "DEBUG" /* DEBUG */:
|
|
@@ -204,7 +207,7 @@ var Logger = class {
|
|
|
204
207
|
coloring = color.magenta;
|
|
205
208
|
msgColoring = color.dim;
|
|
206
209
|
if (this.options?.useIcons) {
|
|
207
|
-
icon = "\
|
|
210
|
+
icon = "\u26B1";
|
|
208
211
|
}
|
|
209
212
|
break;
|
|
210
213
|
}
|
|
@@ -249,13 +252,12 @@ var CLI_FLAGS = {
|
|
|
249
252
|
// src/lib/parser/json-parser.service.ts
|
|
250
253
|
var _JsonParser = class {
|
|
251
254
|
constructor() {
|
|
252
|
-
this.logger = new Logger(this.constructor.name);
|
|
253
255
|
if (_JsonParser.instance) {
|
|
254
256
|
return _JsonParser.instance;
|
|
255
|
-
} else {
|
|
256
|
-
_JsonParser.instance = this;
|
|
257
|
-
this.logger.trace("Created a new instance.");
|
|
258
257
|
}
|
|
258
|
+
_JsonParser.instance = this;
|
|
259
|
+
this.logger = new Logger(this.constructor.name);
|
|
260
|
+
this.logger.trace("Created a new instance.");
|
|
259
261
|
}
|
|
260
262
|
parse(data) {
|
|
261
263
|
try {
|
|
@@ -277,13 +279,12 @@ JsonParser.extensions = ["json"];
|
|
|
277
279
|
var import_yaml = require("yaml");
|
|
278
280
|
var _YamlParser = class {
|
|
279
281
|
constructor() {
|
|
280
|
-
this.logger = new Logger(this.constructor.name);
|
|
281
282
|
if (_YamlParser.instance) {
|
|
282
283
|
return _YamlParser.instance;
|
|
283
|
-
} else {
|
|
284
|
-
_YamlParser.instance = this;
|
|
285
|
-
this.logger.trace("Created a new instance.");
|
|
286
284
|
}
|
|
285
|
+
_YamlParser.instance = this;
|
|
286
|
+
this.logger = new Logger(this.constructor.name);
|
|
287
|
+
this.logger.trace("Created a new instance.");
|
|
287
288
|
}
|
|
288
289
|
parse(data) {
|
|
289
290
|
try {
|
package/dist/index.d.ts
CHANGED
|
@@ -10,6 +10,13 @@ import { ClassTransformOptions } from 'class-transformer';
|
|
|
10
10
|
import { ValidatorOptions } from 'class-validator';
|
|
11
11
|
import { InferredFlags, FlagInput } from '@oclif/core/lib/interfaces';
|
|
12
12
|
export { Arg, ArgInput, Flag, FlagInput, InferredFlags } from '@oclif/core/lib/interfaces';
|
|
13
|
+
import * as _oclif_core_lib_cli_ux_styled_progress from '@oclif/core/lib/cli-ux/styled/progress';
|
|
14
|
+
import * as _oclif_core_lib_cli_ux_open from '@oclif/core/lib/cli-ux/open';
|
|
15
|
+
import * as _oclif_core_lib_cli_ux_styled_tree from '@oclif/core/lib/cli-ux/styled/tree';
|
|
16
|
+
import * as _oclif_core_lib_cli_ux_styled_json from '@oclif/core/lib/cli-ux/styled/json';
|
|
17
|
+
import * as _oclif_core_lib_cli_ux_styled_header from '@oclif/core/lib/cli-ux/styled/header';
|
|
18
|
+
import * as _oclif_core_lib_cli_ux_prompt from '@oclif/core/lib/cli-ux/prompt';
|
|
19
|
+
import * as _oclif_core_lib_errors from '@oclif/core/lib/errors';
|
|
13
20
|
export { notFoundHook } from './hooks/not-found.hook.js';
|
|
14
21
|
export { updateNotifierHook } from './hooks/update-notifier.hook.js';
|
|
15
22
|
import { ExecaChildProcess } from 'execa';
|
|
@@ -29,8 +36,11 @@ declare enum LogLevels {
|
|
|
29
36
|
TRACE = "TRACE"
|
|
30
37
|
}
|
|
31
38
|
declare enum LogFieldStatus {
|
|
32
|
-
RUN = "
|
|
33
|
-
END = "
|
|
39
|
+
RUN = "run",
|
|
40
|
+
END = "end",
|
|
41
|
+
STAGE = "stage",
|
|
42
|
+
EXIT = "exit",
|
|
43
|
+
TERMINATE = "terminate"
|
|
34
44
|
}
|
|
35
45
|
|
|
36
46
|
interface LoggerOptions {
|
|
@@ -65,6 +75,7 @@ declare class Logger {
|
|
|
65
75
|
trace(data: string | Buffer, ...args: any): void;
|
|
66
76
|
run(data: string | Buffer, ...args: any): void;
|
|
67
77
|
end(data: string | Buffer, ...args: any): void;
|
|
78
|
+
stage(data: string | Buffer, ...args: any): void;
|
|
68
79
|
private initiateLogger;
|
|
69
80
|
private parseMessage;
|
|
70
81
|
private logColoring;
|
|
@@ -168,9 +179,9 @@ declare class LockerService<LockFile extends LockableData = LockableData> {
|
|
|
168
179
|
private root?;
|
|
169
180
|
private toLock;
|
|
170
181
|
private toUnlock;
|
|
171
|
-
private
|
|
172
|
-
private
|
|
173
|
-
constructor(file: string, parser: GenericParser, root?: string);
|
|
182
|
+
private logger;
|
|
183
|
+
private fs;
|
|
184
|
+
constructor(file: string, parser: GenericParser, root?: string, context?: string);
|
|
174
185
|
hasLock(): boolean;
|
|
175
186
|
hasUnlock(): boolean;
|
|
176
187
|
addLock<T extends LockableData = LockableData>(...data: LockData<T>[]): void;
|
|
@@ -190,8 +201,8 @@ declare class LockerService<LockFile extends LockableData = LockableData> {
|
|
|
190
201
|
declare class ParserService {
|
|
191
202
|
private static instance;
|
|
192
203
|
parsers: ClassType<GenericParser>[];
|
|
193
|
-
private
|
|
194
|
-
private
|
|
204
|
+
private logger;
|
|
205
|
+
private fs;
|
|
195
206
|
constructor(parsers?: ClassType<GenericParser>[]);
|
|
196
207
|
getParser(file: string): GenericParser;
|
|
197
208
|
setParsers(...parsers: ClassType<GenericParser>[]): void;
|
|
@@ -215,7 +226,7 @@ declare class ConfigService implements GlobalConfig {
|
|
|
215
226
|
isSilent: boolean;
|
|
216
227
|
ci: boolean;
|
|
217
228
|
json: boolean;
|
|
218
|
-
private
|
|
229
|
+
private logger;
|
|
219
230
|
constructor(oclif: Command['config'], command: Command['ctor'], config: Omit<GlobalConfig, 'isVerbose' | 'isDebug' | 'isSilent'>);
|
|
220
231
|
read<T extends LockableData = LockableData>(path: string): Promise<T>;
|
|
221
232
|
extend<T extends LockableData = LockableData>(paths: (string | Partial<T>)[], strategy?: MergeStrategy): Promise<T>;
|
|
@@ -227,7 +238,7 @@ declare class ConfigService implements GlobalConfig {
|
|
|
227
238
|
|
|
228
239
|
declare class FileSystemService {
|
|
229
240
|
private static instance;
|
|
230
|
-
private
|
|
241
|
+
private logger;
|
|
231
242
|
constructor();
|
|
232
243
|
exists(path: string): boolean;
|
|
233
244
|
stats(path: string): fs.Stats;
|
|
@@ -250,7 +261,7 @@ declare class FileSystemService {
|
|
|
250
261
|
declare class YamlParser implements GenericParser {
|
|
251
262
|
static extensions: string[];
|
|
252
263
|
private static instance;
|
|
253
|
-
private
|
|
264
|
+
private logger;
|
|
254
265
|
constructor();
|
|
255
266
|
parse<T = unknown>(data: string | Buffer): T;
|
|
256
267
|
stringify<T = any>(data: T): string;
|
|
@@ -259,7 +270,7 @@ declare class YamlParser implements GenericParser {
|
|
|
259
270
|
declare class JsonParser implements GenericParser {
|
|
260
271
|
static extensions: string[];
|
|
261
272
|
private static instance;
|
|
262
|
-
private
|
|
273
|
+
private logger;
|
|
263
274
|
constructor();
|
|
264
275
|
parse<T = unknown>(data: string | Buffer): T;
|
|
265
276
|
stringify<T = any>(data: T): string;
|
|
@@ -272,10 +283,11 @@ interface ValidatorServiceOptions {
|
|
|
272
283
|
|
|
273
284
|
declare class ValidatorService {
|
|
274
285
|
options?: ValidatorServiceOptions;
|
|
275
|
-
private
|
|
286
|
+
private static instance;
|
|
287
|
+
private logger;
|
|
276
288
|
constructor(options?: ValidatorServiceOptions);
|
|
277
|
-
validate<T extends Record<PropertyKey, any>>(classType: ClassType<T>, object: T): Promise<T>;
|
|
278
|
-
validateSync<T extends Record<PropertyKey, any>>(classType: ClassType<T>, object: T): T;
|
|
289
|
+
validate<T extends Record<PropertyKey, any>>(classType: ClassType<T>, object: T, options?: ValidatorServiceOptions): Promise<T>;
|
|
290
|
+
validateSync<T extends Record<PropertyKey, any>>(classType: ClassType<T>, object: T, options?: ValidatorServiceOptions): T;
|
|
279
291
|
private logValidationError;
|
|
280
292
|
}
|
|
281
293
|
|
|
@@ -339,11 +351,37 @@ declare class ConfigCommand<CommandChoices extends string = string, LockFile = a
|
|
|
339
351
|
static globalFlags: object;
|
|
340
352
|
choices: ConfigCommandChoices<CommandChoices>;
|
|
341
353
|
locker: LockerService<LockFile>;
|
|
342
|
-
|
|
354
|
+
protected ux: {
|
|
355
|
+
config: CliUx.Config;
|
|
356
|
+
warn: typeof _oclif_core_lib_errors.warn;
|
|
357
|
+
error: typeof _oclif_core_lib_errors.error;
|
|
358
|
+
exit: typeof _oclif_core_lib_errors.exit;
|
|
359
|
+
readonly prompt: typeof _oclif_core_lib_cli_ux_prompt.prompt;
|
|
360
|
+
readonly anykey: typeof _oclif_core_lib_cli_ux_prompt.anykey;
|
|
361
|
+
readonly confirm: typeof _oclif_core_lib_cli_ux_prompt.confirm;
|
|
362
|
+
readonly action: CliUx.ActionBase;
|
|
363
|
+
readonly prideAction: CliUx.ActionBase;
|
|
364
|
+
styledObject(obj: any, keys?: string[]): void;
|
|
365
|
+
readonly styledHeader: typeof _oclif_core_lib_cli_ux_styled_header.default;
|
|
366
|
+
readonly styledJSON: typeof _oclif_core_lib_cli_ux_styled_json.default;
|
|
367
|
+
readonly table: typeof CliUx.Table.table;
|
|
368
|
+
readonly tree: typeof _oclif_core_lib_cli_ux_styled_tree.default;
|
|
369
|
+
readonly open: typeof _oclif_core_lib_cli_ux_open.default;
|
|
370
|
+
readonly wait: (ms?: number) => Promise<unknown>;
|
|
371
|
+
readonly progress: typeof _oclif_core_lib_cli_ux_styled_progress.default;
|
|
372
|
+
done(): Promise<void>;
|
|
373
|
+
trace(format: string, ...args: string[]): void;
|
|
374
|
+
debug(format: string, ...args: string[]): void;
|
|
375
|
+
info(format: string, ...args: string[]): void;
|
|
376
|
+
log(format?: string, ...args: string[]): void;
|
|
377
|
+
url(text: string, uri: string, params?: {}): void;
|
|
378
|
+
annotation(text: string, annotation: string): void;
|
|
379
|
+
flush(ms?: number): Promise<void>;
|
|
380
|
+
};
|
|
343
381
|
run(): Promise<void>;
|
|
344
|
-
|
|
382
|
+
setup(): ConfigCommandSetup<CommandChoices, LockFile> | Promise<ConfigCommandSetup<CommandChoices, LockFile>>;
|
|
345
383
|
protected table(...options: Parameters<typeof CliUx.ux.table>): void;
|
|
346
|
-
|
|
384
|
+
protected select(): Promise<string>;
|
|
347
385
|
}
|
|
348
386
|
|
|
349
387
|
declare enum FileConstants {
|
package/dist/index.js
CHANGED
|
@@ -106,8 +106,11 @@ var LogLevels = /* @__PURE__ */ ((LogLevels2) => {
|
|
|
106
106
|
return LogLevels2;
|
|
107
107
|
})(LogLevels || {});
|
|
108
108
|
var LogFieldStatus = /* @__PURE__ */ ((LogFieldStatus2) => {
|
|
109
|
-
LogFieldStatus2["RUN"] = "
|
|
110
|
-
LogFieldStatus2["END"] = "
|
|
109
|
+
LogFieldStatus2["RUN"] = "run";
|
|
110
|
+
LogFieldStatus2["END"] = "end";
|
|
111
|
+
LogFieldStatus2["STAGE"] = "stage";
|
|
112
|
+
LogFieldStatus2["EXIT"] = "exit";
|
|
113
|
+
LogFieldStatus2["TERMINATE"] = "terminate";
|
|
111
114
|
return LogFieldStatus2;
|
|
112
115
|
})(LogFieldStatus || {});
|
|
113
116
|
|
|
@@ -162,10 +165,13 @@ var Logger = class {
|
|
|
162
165
|
return this.parseMessage("TRACE" /* TRACE */, data, args);
|
|
163
166
|
}
|
|
164
167
|
run(data, ...args) {
|
|
165
|
-
return this.parseMessage("INFO" /* INFO */, data, args, { status: "
|
|
168
|
+
return this.parseMessage("INFO" /* INFO */, data, args, { status: "run" /* RUN */ });
|
|
166
169
|
}
|
|
167
170
|
end(data, ...args) {
|
|
168
|
-
return this.parseMessage("INFO" /* INFO */, data, args, { status: "
|
|
171
|
+
return this.parseMessage("INFO" /* INFO */, data, args, { status: "end" /* END */ });
|
|
172
|
+
}
|
|
173
|
+
stage(data, ...args) {
|
|
174
|
+
return this.parseMessage("TRACE" /* TRACE */, data, args, { status: "stage" /* STAGE */ });
|
|
169
175
|
}
|
|
170
176
|
initiateLogger() {
|
|
171
177
|
const logFormat = import_winston.format.printf(({ level, message, context, status }) => {
|
|
@@ -242,7 +248,7 @@ var Logger = class {
|
|
|
242
248
|
case "VERBOSE" /* VERBOSE */:
|
|
243
249
|
coloring = color.dim;
|
|
244
250
|
if (this.options?.useIcons) {
|
|
245
|
-
icon =
|
|
251
|
+
icon = "\u2607";
|
|
246
252
|
}
|
|
247
253
|
break;
|
|
248
254
|
case "DEBUG" /* DEBUG */:
|
|
@@ -256,7 +262,7 @@ var Logger = class {
|
|
|
256
262
|
coloring = color.magenta;
|
|
257
263
|
msgColoring = color.dim;
|
|
258
264
|
if (this.options?.useIcons) {
|
|
259
|
-
icon = "\
|
|
265
|
+
icon = "\u26B1";
|
|
260
266
|
}
|
|
261
267
|
break;
|
|
262
268
|
}
|
|
@@ -392,13 +398,12 @@ var import_path2 = require("path");
|
|
|
392
398
|
// src/lib/parser/json-parser.service.ts
|
|
393
399
|
var _JsonParser = class {
|
|
394
400
|
constructor() {
|
|
395
|
-
this.logger = new Logger(this.constructor.name);
|
|
396
401
|
if (_JsonParser.instance) {
|
|
397
402
|
return _JsonParser.instance;
|
|
398
|
-
} else {
|
|
399
|
-
_JsonParser.instance = this;
|
|
400
|
-
this.logger.trace("Created a new instance.");
|
|
401
403
|
}
|
|
404
|
+
_JsonParser.instance = this;
|
|
405
|
+
this.logger = new Logger(this.constructor.name);
|
|
406
|
+
this.logger.trace("Created a new instance.");
|
|
402
407
|
}
|
|
403
408
|
parse(data) {
|
|
404
409
|
try {
|
|
@@ -420,13 +425,12 @@ JsonParser.extensions = ["json"];
|
|
|
420
425
|
var import_yaml = require("yaml");
|
|
421
426
|
var _YamlParser = class {
|
|
422
427
|
constructor() {
|
|
423
|
-
this.logger = new Logger(this.constructor.name);
|
|
424
428
|
if (_YamlParser.instance) {
|
|
425
429
|
return _YamlParser.instance;
|
|
426
|
-
} else {
|
|
427
|
-
_YamlParser.instance = this;
|
|
428
|
-
this.logger.trace("Created a new instance.");
|
|
429
430
|
}
|
|
431
|
+
_YamlParser.instance = this;
|
|
432
|
+
this.logger = new Logger(this.constructor.name);
|
|
433
|
+
this.logger.trace("Created a new instance.");
|
|
430
434
|
}
|
|
431
435
|
parse(data) {
|
|
432
436
|
try {
|
|
@@ -449,11 +453,11 @@ var import_fs_extra = __toESM(require("fs-extra"));
|
|
|
449
453
|
var import_path = require("path");
|
|
450
454
|
var FileSystemService = class {
|
|
451
455
|
constructor() {
|
|
452
|
-
this.logger = new Logger(this.constructor.name);
|
|
453
456
|
if (FileSystemService.instance) {
|
|
454
457
|
return FileSystemService.instance;
|
|
455
458
|
} else {
|
|
456
459
|
FileSystemService.instance = this;
|
|
460
|
+
this.logger = new Logger(this.constructor.name);
|
|
457
461
|
this.logger.trace("Created a new instance.");
|
|
458
462
|
}
|
|
459
463
|
}
|
|
@@ -562,14 +566,14 @@ __name(FileSystemService, "FileSystemService");
|
|
|
562
566
|
var ParserService = class {
|
|
563
567
|
constructor(parsers) {
|
|
564
568
|
this.parsers = [YamlParser, JsonParser];
|
|
565
|
-
this.logger = new Logger(this.constructor.name);
|
|
566
|
-
this.fs = new FileSystemService();
|
|
567
569
|
if (ParserService.instance) {
|
|
568
570
|
return ParserService.instance;
|
|
569
571
|
} else {
|
|
570
572
|
if (parsers) {
|
|
571
573
|
this.parsers = parsers;
|
|
572
574
|
}
|
|
575
|
+
this.logger = new Logger(this.constructor.name);
|
|
576
|
+
this.fs = new FileSystemService();
|
|
573
577
|
ParserService.instance = this;
|
|
574
578
|
this.logger.trace("Created a new instance.");
|
|
575
579
|
}
|
|
@@ -799,13 +803,13 @@ __name(ConfigService, "ConfigService");
|
|
|
799
803
|
// src/lib/locker/locker.service.ts
|
|
800
804
|
var import_object_path_immutable2 = __toESM(require("object-path-immutable"));
|
|
801
805
|
var LockerService = class {
|
|
802
|
-
constructor(file, parser, root) {
|
|
806
|
+
constructor(file, parser, root, context) {
|
|
803
807
|
this.file = file;
|
|
804
808
|
this.parser = parser;
|
|
805
809
|
this.root = root;
|
|
806
810
|
this.toLock = [];
|
|
807
811
|
this.toUnlock = [];
|
|
808
|
-
this.logger = new Logger(this.constructor.name);
|
|
812
|
+
this.logger = new Logger(context ?? this.constructor.name);
|
|
809
813
|
this.fs = new FileSystemService();
|
|
810
814
|
}
|
|
811
815
|
hasLock() {
|
|
@@ -855,10 +859,10 @@ var LockerService = class {
|
|
|
855
859
|
parsed = d.data;
|
|
856
860
|
}
|
|
857
861
|
lock = import_object_path_immutable2.default.set(lock, path, parsed);
|
|
858
|
-
this.logger.verbose("Merge lock: %s", path);
|
|
862
|
+
this.logger.verbose("Merge lock: %s -> %o", path, parsed);
|
|
859
863
|
} else {
|
|
860
864
|
lock = import_object_path_immutable2.default.set(lock, path, d.data);
|
|
861
|
-
this.logger.verbose("Override lock: %s", path);
|
|
865
|
+
this.logger.verbose("Override lock: %s -> %o", path, d.data);
|
|
862
866
|
}
|
|
863
867
|
})
|
|
864
868
|
);
|
|
@@ -878,12 +882,12 @@ var LockerService = class {
|
|
|
878
882
|
}
|
|
879
883
|
const path = this.buildPath(d);
|
|
880
884
|
lock = import_object_path_immutable2.default.del(lock, path);
|
|
881
|
-
this.logger.verbose("Unlocked: %s", path
|
|
885
|
+
this.logger.verbose("Unlocked: %s", path);
|
|
882
886
|
})
|
|
883
887
|
);
|
|
884
888
|
} else {
|
|
885
889
|
lock = import_object_path_immutable2.default.del(lock, this.root);
|
|
886
|
-
this.logger.verbose("Unlocked module: %s", this.root
|
|
890
|
+
this.logger.verbose("Unlocked module: %s", this.root);
|
|
887
891
|
}
|
|
888
892
|
await this.write(lock);
|
|
889
893
|
}
|
|
@@ -946,7 +950,9 @@ var import_class_validator = require("class-validator");
|
|
|
946
950
|
var ValidatorService = class {
|
|
947
951
|
constructor(options) {
|
|
948
952
|
this.options = options;
|
|
949
|
-
|
|
953
|
+
if (ValidatorService.instance) {
|
|
954
|
+
return ValidatorService.instance;
|
|
955
|
+
}
|
|
950
956
|
this.options = {
|
|
951
957
|
validator: {
|
|
952
958
|
skipMissingProperties: true,
|
|
@@ -957,10 +963,13 @@ var ValidatorService = class {
|
|
|
957
963
|
transformer: { enableImplicitConversion: true },
|
|
958
964
|
...options ?? {}
|
|
959
965
|
};
|
|
966
|
+
this.logger = new Logger(this.constructor.name);
|
|
967
|
+
ValidatorService.instance = this;
|
|
968
|
+
this.logger.trace("Created a new instance.");
|
|
960
969
|
}
|
|
961
|
-
async validate(classType, object) {
|
|
962
|
-
const classObject = (0, import_class_transformer.plainToClass)(classType, object, this.options.transformer);
|
|
963
|
-
const errors = await (0, import_class_validator.validate)(classObject, this.options.validator);
|
|
970
|
+
async validate(classType, object, options) {
|
|
971
|
+
const classObject = (0, import_class_transformer.plainToClass)(classType, object, { ...this.options.transformer, ...options.transformer ?? {} });
|
|
972
|
+
const errors = await (0, import_class_validator.validate)(classObject, { ...this.options.validator, ...options.validator ?? {} });
|
|
964
973
|
if (errors.length) {
|
|
965
974
|
errors.forEach((error) => {
|
|
966
975
|
this.logValidationError(error);
|
|
@@ -969,9 +978,9 @@ var ValidatorService = class {
|
|
|
969
978
|
}
|
|
970
979
|
return classObject;
|
|
971
980
|
}
|
|
972
|
-
validateSync(classType, object) {
|
|
973
|
-
const classObject = (0, import_class_transformer.plainToClass)(classType, object, this.options.transformer);
|
|
974
|
-
const errors = (0, import_class_validator.validateSync)(classObject, this.options.validator);
|
|
981
|
+
validateSync(classType, object, options) {
|
|
982
|
+
const classObject = (0, import_class_transformer.plainToClass)(classType, object, { ...this.options.transformer, ...options.transformer ?? {} });
|
|
983
|
+
const errors = (0, import_class_validator.validateSync)(classObject, { ...this.options.validator, ...options.validator ?? {} });
|
|
975
984
|
if (errors.length) {
|
|
976
985
|
errors.forEach((error) => {
|
|
977
986
|
this.logValidationError(error);
|
|
@@ -1025,7 +1034,6 @@ __name(setup, "setup");
|
|
|
1025
1034
|
var Command = class extends import_core3.Command {
|
|
1026
1035
|
constructor() {
|
|
1027
1036
|
super(...arguments);
|
|
1028
|
-
this.store = new StoreService();
|
|
1029
1037
|
this.flags = {};
|
|
1030
1038
|
this.args = {};
|
|
1031
1039
|
}
|
|
@@ -1045,11 +1053,12 @@ var Command = class extends import_core3.Command {
|
|
|
1045
1053
|
});
|
|
1046
1054
|
const context = this.cs.command.id ? this.cs.command.id : this.cs.command.name;
|
|
1047
1055
|
this.logger = new Logger(context, { level: this.cs.logLevel });
|
|
1056
|
+
this.store = new StoreService();
|
|
1048
1057
|
this.greet();
|
|
1049
1058
|
if (err) {
|
|
1050
1059
|
throw err;
|
|
1051
1060
|
}
|
|
1052
|
-
this.logger.
|
|
1061
|
+
this.logger.stage("Initiating services.");
|
|
1053
1062
|
this.parser = new ParserService();
|
|
1054
1063
|
this.fs = new FileSystemService();
|
|
1055
1064
|
this.validator = new ValidatorService();
|
|
@@ -1073,11 +1082,12 @@ var Command = class extends import_core3.Command {
|
|
|
1073
1082
|
});
|
|
1074
1083
|
}
|
|
1075
1084
|
process.on("SIGINT", () => {
|
|
1076
|
-
this.logger.fatal("Caught terminate signal.", {
|
|
1085
|
+
this.logger.fatal("Caught terminate signal.", { status: "terminate" /* TERMINATE */ });
|
|
1077
1086
|
process.exit(1);
|
|
1078
1087
|
});
|
|
1079
|
-
this.logger.
|
|
1088
|
+
this.logger.stage("Running shouldRunBefore.");
|
|
1080
1089
|
await this.shouldRunBefore();
|
|
1090
|
+
this.logger.stage("Finished shouldRunBefore.");
|
|
1081
1091
|
}
|
|
1082
1092
|
shouldRunBefore() {
|
|
1083
1093
|
}
|
|
@@ -1087,10 +1097,12 @@ var Command = class extends import_core3.Command {
|
|
|
1087
1097
|
throw new Error("The command should have a run function to do something!");
|
|
1088
1098
|
}
|
|
1089
1099
|
async finally() {
|
|
1090
|
-
this.logger.
|
|
1100
|
+
this.logger.stage("Running tasks.");
|
|
1091
1101
|
const ctx = await this.runTasks();
|
|
1092
|
-
this.logger.
|
|
1102
|
+
this.logger.stage("Finished tasks.");
|
|
1103
|
+
this.logger.stage("Running shouldRunAfter.");
|
|
1093
1104
|
await this.shouldRunAfter(ctx);
|
|
1105
|
+
this.logger.stage("Finished shouldRunAfter.");
|
|
1094
1106
|
return { ctx };
|
|
1095
1107
|
}
|
|
1096
1108
|
catch(e) {
|
|
@@ -1100,7 +1112,7 @@ var Command = class extends import_core3.Command {
|
|
|
1100
1112
|
return;
|
|
1101
1113
|
}
|
|
1102
1114
|
exit(code) {
|
|
1103
|
-
this.logger.trace("
|
|
1115
|
+
this.logger.trace("Code -> %d", code, { status: "exit" /* EXIT */ });
|
|
1104
1116
|
process.exit(code ?? 0);
|
|
1105
1117
|
}
|
|
1106
1118
|
runTasks() {
|
|
@@ -1143,13 +1155,16 @@ var ConfigCommand = class extends Command {
|
|
|
1143
1155
|
this.ux = import_core2.CliUx.ux;
|
|
1144
1156
|
}
|
|
1145
1157
|
async run() {
|
|
1146
|
-
|
|
1158
|
+
this.logger.stage("Setting up config command.");
|
|
1159
|
+
const setup2 = await this.setup();
|
|
1147
1160
|
this.choices = setup2.choices;
|
|
1148
1161
|
this.locker = setup2.locker;
|
|
1162
|
+
this.logger.stage("User selection for configuration.");
|
|
1149
1163
|
const response = await this.select();
|
|
1164
|
+
this.logger.stage("Will run selection: %s", response);
|
|
1150
1165
|
return this.choices[response].bind(this)();
|
|
1151
1166
|
}
|
|
1152
|
-
|
|
1167
|
+
setup() {
|
|
1153
1168
|
throw new Error("The command should be setup first!");
|
|
1154
1169
|
}
|
|
1155
1170
|
table(...options) {
|