@cenk1cenk2/oclif-common 3.7.1 → 3.8.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.
@@ -33,14 +33,14 @@ __export(hooks_exports, {
33
33
  module.exports = __toCommonJS(hooks_exports);
34
34
 
35
35
  // src/hooks/not-found.hook.ts
36
- var import_core = require("@oclif/core");
36
+ var import_core3 = require("@oclif/core");
37
37
 
38
38
  // src/utils/logger/listr-logger.ts
39
39
  var import_listr22 = require("listr2");
40
40
 
41
41
  // src/utils/logger/logger.ts
42
42
  var import_listr2 = require("listr2");
43
- var import_os = require("os");
43
+ var import_os2 = require("os");
44
44
  var import_winston = __toESM(require("winston"));
45
45
 
46
46
  // src/utils/logger/logger.constants.ts
@@ -57,10 +57,511 @@ var LogLevels = /* @__PURE__ */ ((LogLevels2) => {
57
57
  return LogLevels2;
58
58
  })(LogLevels || {});
59
59
 
60
+ // src/lib/config/config.service.ts
61
+ var import_object_path_immutable = __toESM(require("object-path-immutable"));
62
+ var import_path2 = require("path");
63
+
64
+ // src/interfaces/oclif.interface.ts
65
+ var import_core = require("@oclif/core");
66
+
67
+ // src/constants/global-flags.constants.ts
68
+ var CLI_FLAGS = {
69
+ ["log-level"]: import_core.Flags.enum({
70
+ default: "INFO" /* INFO */,
71
+ env: "LOG_LEVEL",
72
+ description: "Set the log level of the application.",
73
+ options: [...Object.values(LogLevels), ...Object.values(LogLevels).map((level) => level.toLowerCase())],
74
+ helpGroup: "CLI" /* CLI */,
75
+ parse: async (input) => input?.toUpperCase()
76
+ }),
77
+ ci: import_core.Flags.boolean({
78
+ default: false,
79
+ env: "CI",
80
+ description: "Instruct whether this is running the CI/CD configuration.",
81
+ helpGroup: "CLI" /* CLI */
82
+ }),
83
+ json: import_core.Flags.boolean({
84
+ default: false,
85
+ env: "JSON",
86
+ description: "Put the CLI to respond in JSON.",
87
+ helpGroup: "CLI" /* CLI */
88
+ })
89
+ };
90
+
91
+ // src/lib/parser/env-parser.service.ts
92
+ var import_os = require("os");
93
+ var _EnvironmentVariableParser = class {
94
+ constructor() {
95
+ this.LINE = /(?:^|^)\s*(?:export\s+)?([\w.-]+)(?:\s*=\s*?|:\s+?)(\s*'(?:\\'|[^'])*'|\s*"(?:\\"|[^"])*"|\s*`(?:\\`|[^`])*`|[^#\r\n]+)?\s*(?:#.*)?(?:$|$)/gm;
96
+ if (_EnvironmentVariableParser.instance) {
97
+ return _EnvironmentVariableParser.instance;
98
+ }
99
+ _EnvironmentVariableParser.instance = this;
100
+ this.logger = new Logger(this.constructor.name);
101
+ this.logger.trace("Created a new instance.");
102
+ }
103
+ parse(data) {
104
+ try {
105
+ return data.toString().split(import_os.EOL).reduce((o, line) => {
106
+ const match = this.LINE.exec(line);
107
+ const key = match[1];
108
+ const value = match[2] ?? "";
109
+ return {
110
+ ...o,
111
+ [key]: value
112
+ };
113
+ }, {});
114
+ } catch (e) {
115
+ this.logger.trace("Error during parsing environment file: %s", e.message);
116
+ throw e;
117
+ }
118
+ }
119
+ stringify(data) {
120
+ return Object.entries(data).map(([k, v]) => `${k}=${v}`).join(import_os.EOL) + import_os.EOL;
121
+ }
122
+ };
123
+ var EnvironmentVariableParser = _EnvironmentVariableParser;
124
+ __name(EnvironmentVariableParser, "EnvironmentVariableParser");
125
+ EnvironmentVariableParser.extensions = ["env"];
126
+
127
+ // src/lib/parser/json-parser.service.ts
128
+ var _JsonParser = class {
129
+ constructor() {
130
+ if (_JsonParser.instance) {
131
+ return _JsonParser.instance;
132
+ }
133
+ _JsonParser.instance = this;
134
+ this.logger = new Logger(this.constructor.name);
135
+ this.logger.trace("Created a new instance.");
136
+ }
137
+ parse(data) {
138
+ try {
139
+ return JSON.parse(data.toString());
140
+ } catch (e) {
141
+ this.logger.trace("Error during parsing JSON file: %s", e.message);
142
+ throw e;
143
+ }
144
+ }
145
+ stringify(data) {
146
+ return JSON.stringify(data, null, 2);
147
+ }
148
+ };
149
+ var JsonParser = _JsonParser;
150
+ __name(JsonParser, "JsonParser");
151
+ JsonParser.extensions = ["json"];
152
+
153
+ // src/lib/parser/yaml-parser.service.ts
154
+ var import_yaml = require("yaml");
155
+ var _YamlParser = class {
156
+ constructor() {
157
+ if (_YamlParser.instance) {
158
+ return _YamlParser.instance;
159
+ }
160
+ _YamlParser.instance = this;
161
+ this.logger = new Logger(this.constructor.name);
162
+ this.logger.trace("Created a new instance.");
163
+ }
164
+ parse(data) {
165
+ try {
166
+ return (0, import_yaml.parse)(data.toString());
167
+ } catch (e) {
168
+ this.logger.trace("Error during parsing YAML file: %s", e.message);
169
+ throw e;
170
+ }
171
+ }
172
+ stringify(data) {
173
+ return (0, import_yaml.stringify)(data, { prettyErrors: true });
174
+ }
175
+ };
176
+ var YamlParser = _YamlParser;
177
+ __name(YamlParser, "YamlParser");
178
+ YamlParser.extensions = ["yaml", "yml"];
179
+
180
+ // src/lib/fs/filesystem.service.ts
181
+ var import_fs_extra = __toESM(require("fs-extra"));
182
+ var import_path = require("path");
183
+ var FileSystemService = class {
184
+ constructor() {
185
+ if (FileSystemService.instance) {
186
+ return FileSystemService.instance;
187
+ } else {
188
+ FileSystemService.instance = this;
189
+ this.logger = new Logger(this.constructor.name);
190
+ this.logger.trace("Created a new instance.");
191
+ }
192
+ }
193
+ exists(path) {
194
+ return import_fs_extra.default.existsSync(path);
195
+ }
196
+ stats(path) {
197
+ return import_fs_extra.default.statSync(path, { throwIfNoEntry: true });
198
+ }
199
+ dirname(path) {
200
+ return (0, import_path.dirname)(path);
201
+ }
202
+ extname(path) {
203
+ return (0, import_path.extname)(path);
204
+ }
205
+ async read(file) {
206
+ try {
207
+ const raw = await import_fs_extra.default.readFile(file, "utf-8");
208
+ return raw;
209
+ } catch (e) {
210
+ throw new Error(`Error while reading file from "${file}": ${e.message}`);
211
+ }
212
+ }
213
+ readSync(file) {
214
+ try {
215
+ const raw = import_fs_extra.default.readFileSync(file, "utf-8");
216
+ return raw;
217
+ } catch (e) {
218
+ throw new Error(`Error while reading file from "${file}": ${e.message}`);
219
+ }
220
+ }
221
+ async write(file, data, options = {}) {
222
+ try {
223
+ await import_fs_extra.default.writeFile(file, data, { encoding: "utf-8", ...options });
224
+ } catch (e) {
225
+ throw new Error(`Error while writing file to "${file}": ${e.message}`);
226
+ }
227
+ }
228
+ writeSync(file, data, options = {}) {
229
+ try {
230
+ import_fs_extra.default.writeFileSync(file, data, { encoding: "utf-8", ...options });
231
+ } catch (e) {
232
+ throw new Error(`Error while writing file to "${file}": ${e.message}`);
233
+ }
234
+ }
235
+ async append(file, data, options) {
236
+ try {
237
+ await import_fs_extra.default.appendFile(file, data, options);
238
+ } catch (e) {
239
+ throw new Error(`Error while appending to file "${file}": ${e.message}`);
240
+ }
241
+ }
242
+ appendSync(file, data) {
243
+ try {
244
+ import_fs_extra.default.appendFileSync(file, data);
245
+ } catch (e) {
246
+ throw new Error(`Error while appending to file "${file}": ${e.message}`);
247
+ }
248
+ }
249
+ async remove(file, options) {
250
+ try {
251
+ await import_fs_extra.default.rm(file, options);
252
+ } catch (e) {
253
+ throw new Error(`Error while deleting the file "${file}": ${e.message}`);
254
+ }
255
+ }
256
+ removeSync(file, options) {
257
+ try {
258
+ import_fs_extra.default.rmSync(file, options);
259
+ } catch (e) {
260
+ throw new Error(`Error while deleting the file "${file}": ${e.message}`);
261
+ }
262
+ }
263
+ async emptyDir(directory) {
264
+ try {
265
+ await import_fs_extra.default.emptyDir(directory);
266
+ } catch (e) {
267
+ throw new Error(`Error while emptying the directory "${directory}": ${e.message}`);
268
+ }
269
+ }
270
+ emptyDirSync(directory) {
271
+ try {
272
+ import_fs_extra.default.emptyDirSync(directory);
273
+ } catch (e) {
274
+ throw new Error(`Error while emptying the directory "${directory}": ${e.message}`);
275
+ }
276
+ }
277
+ async removeDir(directory) {
278
+ try {
279
+ await import_fs_extra.default.rmdir(directory);
280
+ } catch (e) {
281
+ throw new Error(`Error while removing the directory "${directory}": ${e.message}`);
282
+ }
283
+ }
284
+ removeDirSync(directory) {
285
+ try {
286
+ import_fs_extra.default.rmdirSync(directory);
287
+ } catch (e) {
288
+ throw new Error(`Error while removing the directory "${directory}": ${e.message}`);
289
+ }
290
+ }
291
+ async mkdir(directory) {
292
+ try {
293
+ await import_fs_extra.default.mkdirp(directory);
294
+ } catch (e) {
295
+ throw new Error(`Error while creating the directory "${directory}": ${e.message}`);
296
+ }
297
+ }
298
+ mkdirSync(directory) {
299
+ try {
300
+ import_fs_extra.default.mkdirSync(directory);
301
+ } catch (e) {
302
+ throw new Error(`Error while creating the directory "${directory}": ${e.message}`);
303
+ }
304
+ }
305
+ };
306
+ __name(FileSystemService, "FileSystemService");
307
+
308
+ // src/lib/parser/parser.service.ts
309
+ var ParserService = class {
310
+ constructor(parsers) {
311
+ this.parsers = [YamlParser, JsonParser, EnvironmentVariableParser];
312
+ if (ParserService.instance) {
313
+ return ParserService.instance;
314
+ } else {
315
+ if (parsers) {
316
+ this.parsers = parsers;
317
+ }
318
+ this.logger = new Logger(this.constructor.name);
319
+ this.fs = new FileSystemService();
320
+ ParserService.instance = this;
321
+ this.logger.trace("Created a new instance.");
322
+ }
323
+ }
324
+ getParser(file) {
325
+ const ext = (file.includes(".") ? this.fs.extname(file) : file).replace(/^\./, "");
326
+ const Parser = this.parsers.find((parser) => parser.extensions.includes(ext));
327
+ if (!Parser) {
328
+ throw new Error(`Parser for the extension is not configured: ${ext}`);
329
+ }
330
+ return new Parser();
331
+ }
332
+ setParsers(...parsers) {
333
+ this.parsers = parsers;
334
+ this.logger.trace(
335
+ "Set parsers: %s",
336
+ this.parsers.map((p) => p.name)
337
+ );
338
+ }
339
+ addParsers(...parsers) {
340
+ this.parsers.push(...parsers);
341
+ this.logger.trace(
342
+ "Added parser, current parsers: %s",
343
+ this.parsers.map((p) => p.name)
344
+ );
345
+ }
346
+ async read(file) {
347
+ return this.parse(file, await this.fs.read(file));
348
+ }
349
+ async write(file, data) {
350
+ return this.fs.write(file, await this.stringify(file, data));
351
+ }
352
+ parse(file, data) {
353
+ const parser = this.getParser(file);
354
+ this.logger.trace("Parsing file: %s -> %s", file, parser.constructor.name);
355
+ return parser.parse(data);
356
+ }
357
+ stringify(file, data) {
358
+ const parser = this.getParser(file);
359
+ this.logger.trace("Stringifying file: %s -> %s", file, parser.constructor.name);
360
+ return parser.stringify(data);
361
+ }
362
+ };
363
+ __name(ParserService, "ParserService");
364
+
60
365
  // src/utils/color.ts
61
366
  var colorette = __toESM(require("colorette"));
62
367
  var color = colorette.createColors({ useColor: true });
63
368
 
369
+ // src/utils/environment.ts
370
+ function isVerbose(logLevel) {
371
+ return logLevel === "VERBOSE" /* VERBOSE */;
372
+ }
373
+ __name(isVerbose, "isVerbose");
374
+ function isDebug(logLevel) {
375
+ return ["DEBUG" /* DEBUG */, "TRACE" /* TRACE */].includes(logLevel);
376
+ }
377
+ __name(isDebug, "isDebug");
378
+ function isSilent(logLevel) {
379
+ return logLevel === "SILENT" /* SILENT */;
380
+ }
381
+ __name(isSilent, "isSilent");
382
+
383
+ // src/utils/merge.ts
384
+ var import_deepmerge = __toESM(require("deepmerge"));
385
+ function merge(strategy, ...source) {
386
+ return import_deepmerge.default.all(source, {
387
+ arrayMerge: strategy === "EXTEND" /* EXTEND */ ? (dest, src) => [...dest, ...src].filter(uniqueFilter) : (_, src) => src
388
+ });
389
+ }
390
+ __name(merge, "merge");
391
+ function uniqueFilter(value, index, self) {
392
+ return self.indexOf(value) === index;
393
+ }
394
+ __name(uniqueFilter, "uniqueFilter");
395
+
396
+ // src/utils/index.ts
397
+ var import_core2 = require("@oclif/core");
398
+
399
+ // src/lib/config/config.service.ts
400
+ var ConfigService = class {
401
+ constructor(oclif, command, config) {
402
+ this.oclif = oclif;
403
+ this.command = command;
404
+ if (ConfigService.instance) {
405
+ Object.assign(ConfigService.instance, config);
406
+ return ConfigService.instance;
407
+ } else {
408
+ ConfigService.instance = this;
409
+ }
410
+ this.root = this.oclif.root;
411
+ this.defaults = (0, import_path2.join)(this.oclif.root, "config" /* CONFIG_SERVICE_DEFAULTS_DIR */);
412
+ this.logger = new Logger(this.constructor.name, { level: config.logLevel });
413
+ this.parser = new ParserService();
414
+ Object.assign(ConfigService.instance, config);
415
+ this.recalculate();
416
+ this.logger.trace("Created a new instance.");
417
+ }
418
+ async read(path) {
419
+ const config = await this.parser.read(path);
420
+ this.logger.trace("Read config from: %s", path);
421
+ return config;
422
+ }
423
+ async extend(paths, strategy = "OVERWRITE" /* OVERWRITE */) {
424
+ this.logger.trace("Will generate config from: %o with %s", paths, strategy);
425
+ const configs = (await Promise.all(
426
+ paths.map(async (path) => {
427
+ try {
428
+ const config = typeof path === "string" ? await this.parser.read(path) : path;
429
+ this.logger.trace("Extending config from: %s", path);
430
+ return config;
431
+ } catch (e) {
432
+ this.logger.trace("Failed to extend config from: %s", e.message);
433
+ }
434
+ })
435
+ )).filter(Boolean);
436
+ return this.merge(configs, strategy);
437
+ }
438
+ merge(configs, strategy = "OVERWRITE" /* OVERWRITE */) {
439
+ if (configs.length === 0) {
440
+ throw new Error("Nothing to merge, configuration files are empty.");
441
+ }
442
+ return merge(strategy, ...configs);
443
+ }
444
+ async env(definition, config) {
445
+ const env = typeof definition === "string" ? await this.parser.read(definition) : definition;
446
+ this.logger.trace("Environment variable extensions read: %o", definition);
447
+ const iter = /* @__PURE__ */ __name(async (obj, parent) => {
448
+ const data = await Promise.all(
449
+ Object.entries(obj).map(async ([key, value]) => {
450
+ const location = [...parent ?? [], key];
451
+ if (typeof value === "string") {
452
+ return [{ key: location, env: value }];
453
+ } else if (typeof value === "object") {
454
+ let extensions;
455
+ if ("__element" /* ELEMENT */ in value) {
456
+ extensions = await iter(value["__element" /* ELEMENT */], [...location, "__element" /* ELEMENT */]);
457
+ this.logger.trace("Expanding location to elements: %s -> %s", location, extensions.map((extension) => extension.key.join(".")).join(", "));
458
+ }
459
+ if ("__name" /* NAME */ in value && "__format" /* PARSER */ in value) {
460
+ const variable = [
461
+ {
462
+ key: location,
463
+ env: value["__name" /* NAME */],
464
+ parser: value["__format" /* PARSER */],
465
+ extensions
466
+ }
467
+ ];
468
+ return variable;
469
+ } else {
470
+ return iter(value, location);
471
+ }
472
+ }
473
+ })
474
+ );
475
+ return data.flatMap((d) => d).filter(Boolean);
476
+ }, "iter");
477
+ const parsed = await iter(env);
478
+ const cb = /* @__PURE__ */ __name((config2, variable, data) => {
479
+ if (variable.parser) {
480
+ try {
481
+ data = this.parser.parse(variable.parser, data);
482
+ } catch (e) {
483
+ this.logger.trace("Can not parse environment environment variable for config: %s -> %s with %s", variable.key.join("."), variable.env, variable.parser);
484
+ throw e;
485
+ }
486
+ }
487
+ this.logger.trace("Overwriting config with environment variable: %s -> %s", variable.key.join("."), variable.env);
488
+ return import_object_path_immutable.default.set(config2, variable.key, data);
489
+ }, "cb");
490
+ parsed.forEach((variable) => {
491
+ let data;
492
+ data = process.env[variable.env];
493
+ if (data) {
494
+ config = cb(config, variable, data);
495
+ }
496
+ if (variable.extensions && variable.extensions.length > 0) {
497
+ const timeout = 6e4;
498
+ const startedAt = Date.now();
499
+ for (let i = 0; i < Infinity; i++) {
500
+ if (Date.now() - startedAt > timeout) {
501
+ throw new Error(`Timed-out in ${timeout}ms while looking for element environment variables.`);
502
+ }
503
+ const extensions = variable.extensions.map((extension) => {
504
+ const clone = JSON.parse(JSON.stringify(extension));
505
+ clone.env = clone.env.replace("${i}" /* ELEMENT_REPLACER */, i.toString());
506
+ clone.key[clone.key.findIndex((value) => value === "__element" /* ELEMENT */)] = i.toString();
507
+ data = process.env[clone.env];
508
+ if (!data) {
509
+ this.logger.trace("No extension for environment variable: %s -> %s", clone.key.join("."), clone.env);
510
+ return;
511
+ }
512
+ config = cb(config, clone, data);
513
+ return true;
514
+ }).filter(Boolean);
515
+ if (extensions.length === 0) {
516
+ this.logger.trace("No more extensions for environment variables: %s -> %d", variable.key.join("."), i);
517
+ break;
518
+ }
519
+ }
520
+ }
521
+ });
522
+ return config;
523
+ }
524
+ async write(path, data) {
525
+ return this.parser.write(path, data);
526
+ }
527
+ recalculate() {
528
+ this.isVerbose = isVerbose(this.logLevel);
529
+ this.isDebug = isDebug(this.logLevel);
530
+ this.isSilent = isSilent(this.logLevel);
531
+ }
532
+ };
533
+ __name(ConfigService, "ConfigService");
534
+
535
+ // src/lib/locker/locker.service.ts
536
+ var import_object_path_immutable2 = __toESM(require("object-path-immutable"));
537
+
538
+ // src/lib/store/store.service.ts
539
+ var StoreService = class {
540
+ constructor() {
541
+ this.store = {};
542
+ if (StoreService.instance) {
543
+ return StoreService.instance;
544
+ } else {
545
+ StoreService.instance = this;
546
+ }
547
+ }
548
+ has(key) {
549
+ return !!this.store[key];
550
+ }
551
+ get(key) {
552
+ return this.store[key];
553
+ }
554
+ set(key, data) {
555
+ this.store[key] = data;
556
+ return data;
557
+ }
558
+ };
559
+ __name(StoreService, "StoreService");
560
+
561
+ // src/lib/validator/validator.service.ts
562
+ var import_class_transformer = require("class-transformer");
563
+ var import_class_validator = require("class-validator");
564
+
64
565
  // src/utils/logger/logger.ts
65
566
  var Logger = class {
66
567
  constructor(context, options) {
@@ -75,8 +576,9 @@ var Logger = class {
75
576
  };
76
577
  if (Logger.instance) {
77
578
  this.logger = Logger.instance;
78
- } else {
579
+ } else if (context === ConfigService.name) {
79
580
  this.logger = this.initiateLogger();
581
+ this.trace("Logger singleton initiated from context: %s", context);
80
582
  Logger.instance = this.logger;
81
583
  }
82
584
  }
@@ -119,7 +621,7 @@ var Logger = class {
119
621
  initiateLogger() {
120
622
  const logFormat = import_winston.format.printf(({ level, message, context, status }) => {
121
623
  let multiLineMessage;
122
- multiLineMessage = message.split(import_os.EOL);
624
+ multiLineMessage = message.split(import_os2.EOL);
123
625
  multiLineMessage = multiLineMessage.filter((msg) => msg.trim() !== "").filter(Boolean);
124
626
  multiLineMessage = multiLineMessage.map((msg) => {
125
627
  return this.logColoring({
@@ -129,7 +631,7 @@ var Logger = class {
129
631
  status
130
632
  });
131
633
  });
132
- return multiLineMessage.join(import_os.EOL);
634
+ return multiLineMessage.join(import_os2.EOL);
133
635
  });
134
636
  const logger = import_winston.default.createLogger({
135
637
  level: this.options.level,
@@ -151,6 +653,11 @@ var Logger = class {
151
653
  return logger;
152
654
  }
153
655
  parseMessage(level, data, args, format2) {
656
+ if (!this.logger && !Logger.instance) {
657
+ return;
658
+ } else if (Logger.instance) {
659
+ this.logger = Logger.instance;
660
+ }
154
661
  this.logger.log(level, data.toString(), ...args ?? [], { context: this.context, ...format2 ?? {} });
155
662
  }
156
663
  logColoring({ level, message, context, status }) {
@@ -228,7 +735,7 @@ var notFoundHook = /* @__PURE__ */ __name(async (opts) => {
228
735
  const logger = new Logger(opts.config.name);
229
736
  logger.fatal("Command not found. Take a look at help. You can also use --[h]elp flag for subcommands.", { custom: opts.config.name });
230
737
  logger.direct("");
231
- const help = new import_core.Help(opts.config);
738
+ const help = new import_core3.Help(opts.config);
232
739
  await help.showHelp(["--all"]);
233
740
  process.exit(127);
234
741
  }, "notFoundHook");
@@ -239,130 +746,6 @@ var updateNotifierHook = /* @__PURE__ */ __name(async (opts) => {
239
746
  (0, import_update_notifier.default)({ pkg: { name: opts.config.name, version: opts.config.version } }).notify({ isGlobal: true });
240
747
  }, "updateNotifierHook");
241
748
 
242
- // src/lib/config/config.service.ts
243
- var import_object_path_immutable = __toESM(require("object-path-immutable"));
244
- var import_path2 = require("path");
245
-
246
- // src/interfaces/oclif.interface.ts
247
- var import_core2 = require("@oclif/core");
248
-
249
- // src/constants/global-flags.constants.ts
250
- var CLI_FLAGS = {
251
- ["log-level"]: import_core2.Flags.enum({
252
- default: "INFO" /* INFO */,
253
- env: "LOG_LEVEL",
254
- description: "Set the log level of the application.",
255
- options: [...Object.values(LogLevels), ...Object.values(LogLevels).map((level) => level.toLowerCase())],
256
- helpGroup: "CLI" /* CLI */,
257
- parse: async (input) => input?.toUpperCase()
258
- }),
259
- ci: import_core2.Flags.boolean({
260
- default: false,
261
- env: "CI",
262
- description: "Instruct whether this is running the CI/CD configuration.",
263
- helpGroup: "CLI" /* CLI */
264
- }),
265
- json: import_core2.Flags.boolean({
266
- default: false,
267
- env: "JSON",
268
- description: "Put the CLI to respond in JSON.",
269
- helpGroup: "CLI" /* CLI */
270
- })
271
- };
272
-
273
- // src/lib/parser/json-parser.service.ts
274
- var _JsonParser = class {
275
- constructor() {
276
- if (_JsonParser.instance) {
277
- return _JsonParser.instance;
278
- }
279
- _JsonParser.instance = this;
280
- this.logger = new Logger(this.constructor.name);
281
- this.logger.trace("Created a new instance.");
282
- }
283
- parse(data) {
284
- try {
285
- return JSON.parse(data.toString());
286
- } catch (e) {
287
- this.logger.trace("Error during parsing JSON file: %s", e.message);
288
- throw e;
289
- }
290
- }
291
- stringify(data) {
292
- return JSON.stringify(data, null, 2);
293
- }
294
- };
295
- var JsonParser = _JsonParser;
296
- __name(JsonParser, "JsonParser");
297
- JsonParser.extensions = ["json"];
298
-
299
- // src/lib/parser/yaml-parser.service.ts
300
- var import_yaml = require("yaml");
301
- var _YamlParser = class {
302
- constructor() {
303
- if (_YamlParser.instance) {
304
- return _YamlParser.instance;
305
- }
306
- _YamlParser.instance = this;
307
- this.logger = new Logger(this.constructor.name);
308
- this.logger.trace("Created a new instance.");
309
- }
310
- parse(data) {
311
- try {
312
- return (0, import_yaml.parse)(data.toString());
313
- } catch (e) {
314
- this.logger.trace("Error during parsing YAML file: %s", e.message);
315
- throw e;
316
- }
317
- }
318
- stringify(data) {
319
- return (0, import_yaml.stringify)(data, { prettyErrors: true });
320
- }
321
- };
322
- var YamlParser = _YamlParser;
323
- __name(YamlParser, "YamlParser");
324
- YamlParser.extensions = ["yaml", "yml"];
325
-
326
- // src/lib/fs/filesystem.service.ts
327
- var import_fs_extra = __toESM(require("fs-extra"));
328
- var import_path = require("path");
329
-
330
- // src/utils/merge.ts
331
- var import_deepmerge = __toESM(require("deepmerge"));
332
-
333
- // src/utils/index.ts
334
- var import_core3 = require("@oclif/core");
335
-
336
- // src/lib/locker/locker.service.ts
337
- var import_object_path_immutable2 = __toESM(require("object-path-immutable"));
338
-
339
- // src/lib/store/store.service.ts
340
- var StoreService = class {
341
- constructor() {
342
- this.store = {};
343
- if (StoreService.instance) {
344
- return StoreService.instance;
345
- } else {
346
- StoreService.instance = this;
347
- }
348
- }
349
- has(key) {
350
- return !!this.store[key];
351
- }
352
- get(key) {
353
- return this.store[key];
354
- }
355
- set(key, data) {
356
- this.store[key] = data;
357
- return data;
358
- }
359
- };
360
- __name(StoreService, "StoreService");
361
-
362
- // src/lib/validator/validator.service.ts
363
- var import_class_transformer = require("class-transformer");
364
- var import_class_validator = require("class-validator");
365
-
366
749
  // src/hooks/store.hook.ts
367
750
  var storeHook = /* @__PURE__ */ __name((cb) => async (opts) => {
368
751
  cb(opts, new StoreService());