@cenk1cenk2/oclif-common 3.9.5 → 3.9.7

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.
Files changed (111) hide show
  1. package/dist/base.command-d3038122.d.ts +77 -0
  2. package/dist/commands/base.command.d.ts +24 -0
  3. package/dist/commands/base.command.js +174 -0
  4. package/dist/commands/config.command.d.ts +71 -0
  5. package/dist/commands/config.command.js +60 -0
  6. package/dist/commands/index.d.ts +34 -0
  7. package/dist/commands/index.js +18 -0
  8. package/dist/constants/file.constants.d.ts +5 -0
  9. package/dist/constants/file.constants.js +30 -0
  10. package/dist/constants/global-flags.constants.d.ts +5 -0
  11. package/dist/constants/global-flags.constants.js +53 -0
  12. package/dist/constants/help-groups.constants.d.ts +5 -0
  13. package/dist/constants/help-groups.constants.js +30 -0
  14. package/dist/constants/index.d.ts +4 -0
  15. package/dist/constants/index.js +19 -0
  16. package/dist/hooks/index.d.ts +3 -1
  17. package/dist/hooks/index.js +4 -746
  18. package/dist/hooks/not-found.hook.js +4 -688
  19. package/dist/hooks/store.hook.d.ts +7 -2
  20. package/dist/hooks/store.hook.js +3 -710
  21. package/dist/hooks/update-notifier.hook.js +1 -3
  22. package/dist/index.d.ts +52 -405
  23. package/dist/index.js +7 -1339
  24. package/dist/interfaces/class.interface.d.ts +3 -0
  25. package/dist/interfaces/class.interface.js +15 -0
  26. package/dist/interfaces/config-command.interface.d.ts +12 -0
  27. package/dist/interfaces/config-command.interface.js +15 -0
  28. package/dist/interfaces/index.d.ts +10 -0
  29. package/dist/interfaces/index.js +20 -0
  30. package/dist/interfaces/oclif.interface.d.ts +9 -0
  31. package/dist/interfaces/oclif.interface.js +27 -0
  32. package/dist/interfaces/type-helper.interface.d.ts +8 -0
  33. package/dist/interfaces/type-helper.interface.js +15 -0
  34. package/dist/lib/config/config.constants.d.ts +8 -0
  35. package/dist/lib/config/config.constants.js +33 -0
  36. package/dist/lib/config/config.interface.d.ts +15 -0
  37. package/dist/lib/config/config.interface.js +15 -0
  38. package/dist/lib/config/config.service.d.ts +24 -0
  39. package/dist/lib/config/config.service.js +172 -0
  40. package/dist/lib/config/index.d.ts +24 -0
  41. package/dist/lib/config/index.js +18 -0
  42. package/dist/lib/fs/filesystem.service.d.ts +28 -0
  43. package/dist/lib/fs/filesystem.service.js +162 -0
  44. package/dist/lib/fs/index.d.ts +2 -0
  45. package/dist/lib/fs/index.js +17 -0
  46. package/dist/lib/index.d.ts +29 -0
  47. package/dist/lib/index.js +23 -0
  48. package/dist/lib/locker/index.d.ts +4 -0
  49. package/dist/lib/locker/index.js +18 -0
  50. package/dist/lib/locker/locker.interface.d.ts +17 -0
  51. package/dist/lib/locker/locker.interface.js +15 -0
  52. package/dist/lib/locker/locker.service.d.ts +30 -0
  53. package/dist/lib/locker/locker.service.js +170 -0
  54. package/dist/lib/parser/env-parser.service.d.ts +13 -0
  55. package/dist/lib/parser/env-parser.service.js +62 -0
  56. package/dist/lib/parser/index.d.ts +8 -0
  57. package/dist/lib/parser/index.js +21 -0
  58. package/dist/lib/parser/json-parser.service.d.ts +12 -0
  59. package/dist/lib/parser/json-parser.service.js +52 -0
  60. package/dist/lib/parser/parser.interface.d.ts +7 -0
  61. package/dist/lib/parser/parser.interface.js +15 -0
  62. package/dist/lib/parser/parser.service.d.ts +21 -0
  63. package/dist/lib/parser/parser.service.js +87 -0
  64. package/dist/lib/parser/yaml-parser.service.d.ts +12 -0
  65. package/dist/lib/parser/yaml-parser.service.js +53 -0
  66. package/dist/lib/setup.d.ts +3 -0
  67. package/dist/lib/setup.js +60 -0
  68. package/dist/lib/store/index.d.ts +2 -0
  69. package/dist/lib/store/index.js +18 -0
  70. package/dist/lib/store/store.interface.d.ts +5 -0
  71. package/dist/lib/store/store.interface.js +15 -0
  72. package/dist/lib/store/store.service.d.ts +12 -0
  73. package/dist/lib/store/store.service.js +48 -0
  74. package/dist/lib/validator/index.d.ts +5 -0
  75. package/dist/lib/validator/index.js +18 -0
  76. package/dist/lib/validator/validator.interface.d.ts +9 -0
  77. package/dist/lib/validator/validator.interface.js +15 -0
  78. package/dist/lib/validator/validator.service.d.ts +16 -0
  79. package/dist/lib/validator/validator.service.js +77 -0
  80. package/dist/utils/color.d.ts +5 -0
  81. package/dist/utils/color.js +34 -0
  82. package/dist/utils/defaults.d.ts +11 -0
  83. package/dist/utils/defaults.js +47 -0
  84. package/dist/utils/environment.d.ts +7 -0
  85. package/dist/utils/environment.js +44 -0
  86. package/dist/utils/index.d.ts +17 -0
  87. package/dist/utils/index.js +34 -0
  88. package/dist/utils/logger/index.d.ts +10 -0
  89. package/dist/utils/logger/index.js +21 -0
  90. package/dist/utils/logger/listr-logger.d.ts +20 -0
  91. package/dist/utils/logger/listr-logger.js +60 -0
  92. package/dist/utils/logger/logger.constants.d.ts +20 -0
  93. package/dist/utils/logger/logger.constants.js +48 -0
  94. package/dist/utils/logger/logger.d.ts +31 -0
  95. package/dist/utils/logger/logger.interface.d.ts +16 -0
  96. package/dist/utils/logger/logger.interface.js +15 -0
  97. package/dist/utils/logger/logger.js +200 -0
  98. package/dist/utils/logger/pipe/index.d.ts +9 -0
  99. package/dist/utils/logger/pipe/index.js +19 -0
  100. package/dist/utils/logger/pipe/pipe-process-to-listr.d.ts +6 -0
  101. package/dist/utils/logger/pipe/pipe-process-to-listr.js +43 -0
  102. package/dist/utils/logger/pipe/pipe-process-to-logger.d.ts +13 -0
  103. package/dist/utils/logger/pipe/pipe-process-to-logger.interface.d.ts +16 -0
  104. package/dist/utils/logger/pipe/pipe-process-to-logger.interface.js +15 -0
  105. package/dist/utils/logger/pipe/pipe-process-to-logger.js +80 -0
  106. package/dist/utils/merge.constants.d.ts +6 -0
  107. package/dist/utils/merge.constants.js +31 -0
  108. package/dist/utils/merge.d.ts +8 -0
  109. package/dist/utils/merge.js +47 -0
  110. package/package.json +7 -7
  111. package/dist/store.hook-519df5f8.d.ts +0 -18
package/dist/index.js CHANGED
@@ -1,14 +1,7 @@
1
- var __create = Object.create;
2
1
  var __defProp = Object.defineProperty;
3
2
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
3
  var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf;
6
4
  var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
8
- var __export = (target, all) => {
9
- for (var name in all)
10
- __defProp(target, name, { get: all[name], enumerable: true });
11
- };
12
5
  var __copyProps = (to, from, except, desc) => {
13
6
  if (from && typeof from === "object" || typeof from === "function") {
14
7
  for (let key of __getOwnPropNames(from))
@@ -17,1338 +10,13 @@ var __copyProps = (to, from, except, desc) => {
17
10
  }
18
11
  return to;
19
12
  };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
22
- mod
23
- ));
13
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
24
14
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
25
-
26
- // src/index.ts
27
15
  var src_exports = {};
28
- __export(src_exports, {
29
- CLI_FLAGS: () => CLI_FLAGS,
30
- CliUx: () => import_core2.CliUx,
31
- Command: () => Command,
32
- ConfigCommand: () => ConfigCommand,
33
- ConfigService: () => ConfigService,
34
- EnvironmentVariableParser: () => EnvironmentVariableParser,
35
- FileConstants: () => FileConstants,
36
- FileSystemService: () => FileSystemService,
37
- Flags: () => import_core.Flags,
38
- HelpGroups: () => HelpGroups,
39
- JsonParser: () => JsonParser,
40
- ListrLogger: () => ListrLogger,
41
- LockerService: () => LockerService,
42
- LogFieldStatus: () => LogFieldStatus,
43
- LogLevels: () => LogLevels,
44
- Logger: () => Logger,
45
- MergeStrategy: () => MergeStrategy,
46
- ParserService: () => ParserService,
47
- StoreService: () => StoreService,
48
- ValidatorService: () => ValidatorService,
49
- YamlParser: () => YamlParser,
50
- color: () => color,
51
- fs: () => import_fs_extra.default,
52
- isDebug: () => isDebug,
53
- isSilent: () => isSilent,
54
- isVerbose: () => isVerbose,
55
- merge: () => merge,
56
- notFoundHook: () => notFoundHook,
57
- pipeProcessThroughListr: () => pipeProcessThroughListr,
58
- pipeProcessToLogger: () => pipeProcessToLogger,
59
- setCtxAssign: () => setCtxAssign,
60
- setCtxDefaults: () => setCtxDefaults,
61
- setup: () => setup,
62
- storeHook: () => storeHook,
63
- uniqueFilter: () => uniqueFilter,
64
- updateNotifierHook: () => updateNotifierHook
65
- });
66
16
  module.exports = __toCommonJS(src_exports);
67
-
68
- // src/commands/base.command.ts
69
- var import_core3 = require("@oclif/core");
70
- var import_listr23 = require("listr2");
71
- var import_readline = require("readline");
72
- var import_reflect_metadata = require("reflect-metadata");
73
-
74
- // src/constants/file.constants.ts
75
- var FileConstants = /* @__PURE__ */ ((FileConstants2) => {
76
- FileConstants2["CONFIG_SERVICE_DEFAULTS_DIR"] = "config";
77
- return FileConstants2;
78
- })(FileConstants || {});
79
-
80
- // src/constants/help-groups.constants.ts
81
- var HelpGroups = /* @__PURE__ */ ((HelpGroups2) => {
82
- HelpGroups2["CLI"] = "CLI";
83
- return HelpGroups2;
84
- })(HelpGroups || {});
85
-
86
- // src/interfaces/oclif.interface.ts
87
- var import_core = require("@oclif/core");
88
-
89
- // src/utils/logger/listr-logger.ts
90
- var import_listr22 = require("listr2");
91
-
92
- // src/utils/logger/logger.ts
93
- var import_listr2 = require("listr2");
94
- var import_os2 = require("os");
95
- var import_winston = __toESM(require("winston"));
96
-
97
- // src/utils/logger/logger.constants.ts
98
- var LogLevels = /* @__PURE__ */ ((LogLevels2) => {
99
- LogLevels2["SILENT"] = "SILENT";
100
- LogLevels2["DIRECT"] = "DIRECT";
101
- LogLevels2["FATAL"] = "FATAL";
102
- LogLevels2["ERROR"] = "ERROR";
103
- LogLevels2["WARN"] = "WARN";
104
- LogLevels2["INFO"] = "INFO";
105
- LogLevels2["VERBOSE"] = "VERBOSE";
106
- LogLevels2["DEBUG"] = "DEBUG";
107
- LogLevels2["TRACE"] = "TRACE";
108
- return LogLevels2;
109
- })(LogLevels || {});
110
- var LogFieldStatus = /* @__PURE__ */ ((LogFieldStatus2) => {
111
- LogFieldStatus2["RUN"] = "run";
112
- LogFieldStatus2["END"] = "end";
113
- LogFieldStatus2["STAGE"] = "stage";
114
- LogFieldStatus2["EXIT"] = "exit";
115
- LogFieldStatus2["TERMINATE"] = "terminate";
116
- return LogFieldStatus2;
117
- })(LogFieldStatus || {});
118
-
119
- // src/lib/config/config.service.ts
120
- var import_object_path_immutable = __toESM(require("object-path-immutable"));
121
- var import_path2 = require("path");
122
-
123
- // src/lib/parser/env-parser.service.ts
124
- var import_os = require("os");
125
- var _EnvironmentVariableParser = class {
126
- constructor() {
127
- this.LINE = /(?:^|^)\s*(?:export\s+)?([\w.-]+)(?:\s*=\s*?|:\s+?)(\s*'(?:\\'|[^'])*'|\s*"(?:\\"|[^"])*"|\s*`(?:\\`|[^`])*`|[^#\r\n]+)?\s*(?:#.*)?(?:$|$)/gm;
128
- if (_EnvironmentVariableParser.instance) {
129
- return _EnvironmentVariableParser.instance;
130
- }
131
- _EnvironmentVariableParser.instance = this;
132
- this.logger = new Logger(this.constructor.name);
133
- this.logger.trace("Created a new instance.");
134
- }
135
- parse(data) {
136
- try {
137
- return data.toString().split(import_os.EOL).reduce((o, line) => {
138
- const match = this.LINE.exec(line);
139
- const key = match[1];
140
- const value = match[2] ?? "";
141
- return {
142
- ...o,
143
- [key]: value
144
- };
145
- }, {});
146
- } catch (e) {
147
- this.logger.trace("Error during parsing environment file: %s", e.message);
148
- throw e;
149
- }
150
- }
151
- stringify(data) {
152
- return Object.entries(data).map(([k, v]) => `${k}=${v}`).join(import_os.EOL) + import_os.EOL;
153
- }
154
- };
155
- var EnvironmentVariableParser = _EnvironmentVariableParser;
156
- __name(EnvironmentVariableParser, "EnvironmentVariableParser");
157
- EnvironmentVariableParser.extensions = ["env"];
158
-
159
- // src/lib/parser/json-parser.service.ts
160
- var _JsonParser = class {
161
- constructor() {
162
- if (_JsonParser.instance) {
163
- return _JsonParser.instance;
164
- }
165
- _JsonParser.instance = this;
166
- this.logger = new Logger(this.constructor.name);
167
- this.logger.trace("Created a new instance.");
168
- }
169
- parse(data) {
170
- try {
171
- return JSON.parse(data.toString());
172
- } catch (e) {
173
- this.logger.trace("Error during parsing JSON file: %s", e.message);
174
- throw e;
175
- }
176
- }
177
- stringify(data) {
178
- return JSON.stringify(data, null, 2);
179
- }
180
- };
181
- var JsonParser = _JsonParser;
182
- __name(JsonParser, "JsonParser");
183
- JsonParser.extensions = ["json"];
184
-
185
- // src/lib/parser/yaml-parser.service.ts
186
- var import_yaml = require("yaml");
187
- var _YamlParser = class {
188
- constructor() {
189
- if (_YamlParser.instance) {
190
- return _YamlParser.instance;
191
- }
192
- _YamlParser.instance = this;
193
- this.logger = new Logger(this.constructor.name);
194
- this.logger.trace("Created a new instance.");
195
- }
196
- parse(data) {
197
- try {
198
- return (0, import_yaml.parse)(data.toString());
199
- } catch (e) {
200
- this.logger.trace("Error during parsing YAML file: %s", e.message);
201
- throw e;
202
- }
203
- }
204
- stringify(data) {
205
- return (0, import_yaml.stringify)(data, { prettyErrors: true });
206
- }
207
- };
208
- var YamlParser = _YamlParser;
209
- __name(YamlParser, "YamlParser");
210
- YamlParser.extensions = ["yaml", "yml"];
211
-
212
- // src/lib/fs/filesystem.service.ts
213
- var import_fs_extra = __toESM(require("fs-extra"));
214
- var import_path = require("path");
215
- var FileSystemService = class {
216
- constructor() {
217
- if (FileSystemService.instance) {
218
- return FileSystemService.instance;
219
- } else {
220
- FileSystemService.instance = this;
221
- this.logger = new Logger(this.constructor.name);
222
- this.logger.trace("Created a new instance.");
223
- }
224
- }
225
- exists(path) {
226
- return import_fs_extra.default.existsSync(path);
227
- }
228
- stats(path) {
229
- return import_fs_extra.default.statSync(path, { throwIfNoEntry: true });
230
- }
231
- dirname(path) {
232
- return (0, import_path.dirname)(path);
233
- }
234
- extname(path) {
235
- return (0, import_path.extname)(path);
236
- }
237
- async read(file) {
238
- try {
239
- const raw = await import_fs_extra.default.readFile(file, "utf-8");
240
- return raw;
241
- } catch (e) {
242
- throw new Error(`Error while reading file from "${file}": ${e.message}`);
243
- }
244
- }
245
- readSync(file) {
246
- try {
247
- const raw = import_fs_extra.default.readFileSync(file, "utf-8");
248
- return raw;
249
- } catch (e) {
250
- throw new Error(`Error while reading file from "${file}": ${e.message}`);
251
- }
252
- }
253
- async write(file, data, options = {}) {
254
- try {
255
- await import_fs_extra.default.writeFile(file, data, { encoding: "utf-8", ...options });
256
- } catch (e) {
257
- throw new Error(`Error while writing file to "${file}": ${e.message}`);
258
- }
259
- }
260
- writeSync(file, data, options = {}) {
261
- try {
262
- import_fs_extra.default.writeFileSync(file, data, { encoding: "utf-8", ...options });
263
- } catch (e) {
264
- throw new Error(`Error while writing file to "${file}": ${e.message}`);
265
- }
266
- }
267
- async append(file, data, options) {
268
- try {
269
- await import_fs_extra.default.appendFile(file, data, options);
270
- } catch (e) {
271
- throw new Error(`Error while appending to file "${file}": ${e.message}`);
272
- }
273
- }
274
- appendSync(file, data) {
275
- try {
276
- import_fs_extra.default.appendFileSync(file, data);
277
- } catch (e) {
278
- throw new Error(`Error while appending to file "${file}": ${e.message}`);
279
- }
280
- }
281
- async remove(file, options) {
282
- try {
283
- await import_fs_extra.default.rm(file, options);
284
- } catch (e) {
285
- throw new Error(`Error while deleting the file "${file}": ${e.message}`);
286
- }
287
- }
288
- removeSync(file, options) {
289
- try {
290
- import_fs_extra.default.rmSync(file, options);
291
- } catch (e) {
292
- throw new Error(`Error while deleting the file "${file}": ${e.message}`);
293
- }
294
- }
295
- async emptyDir(directory) {
296
- try {
297
- await import_fs_extra.default.emptyDir(directory);
298
- } catch (e) {
299
- throw new Error(`Error while emptying the directory "${directory}": ${e.message}`);
300
- }
301
- }
302
- emptyDirSync(directory) {
303
- try {
304
- import_fs_extra.default.emptyDirSync(directory);
305
- } catch (e) {
306
- throw new Error(`Error while emptying the directory "${directory}": ${e.message}`);
307
- }
308
- }
309
- async removeDir(directory) {
310
- try {
311
- await import_fs_extra.default.rmdir(directory);
312
- } catch (e) {
313
- throw new Error(`Error while removing the directory "${directory}": ${e.message}`);
314
- }
315
- }
316
- removeDirSync(directory) {
317
- try {
318
- import_fs_extra.default.rmdirSync(directory);
319
- } catch (e) {
320
- throw new Error(`Error while removing the directory "${directory}": ${e.message}`);
321
- }
322
- }
323
- async mkdir(directory) {
324
- try {
325
- await import_fs_extra.default.mkdirp(directory);
326
- } catch (e) {
327
- throw new Error(`Error while creating the directory "${directory}": ${e.message}`);
328
- }
329
- }
330
- mkdirSync(directory) {
331
- try {
332
- import_fs_extra.default.mkdirSync(directory);
333
- } catch (e) {
334
- throw new Error(`Error while creating the directory "${directory}": ${e.message}`);
335
- }
336
- }
337
- };
338
- __name(FileSystemService, "FileSystemService");
339
-
340
- // src/lib/parser/parser.service.ts
341
- var ParserService = class {
342
- constructor(parsers) {
343
- this.parsers = [YamlParser, JsonParser, EnvironmentVariableParser];
344
- if (ParserService.instance) {
345
- return ParserService.instance;
346
- } else {
347
- if (parsers) {
348
- this.parsers = parsers;
349
- }
350
- this.logger = new Logger(this.constructor.name);
351
- this.fs = new FileSystemService();
352
- ParserService.instance = this;
353
- this.logger.trace("Created a new instance.");
354
- }
355
- }
356
- getParser(file) {
357
- const ext = (file.includes(".") ? this.fs.extname(file) : file).replace(/^\./, "");
358
- const Parser = this.parsers.find((parser) => parser.extensions.includes(ext));
359
- if (!Parser) {
360
- throw new Error(`Parser for the extension is not configured: ${ext}`);
361
- }
362
- return new Parser();
363
- }
364
- setParsers(...parsers) {
365
- this.parsers = parsers;
366
- this.logger.trace(
367
- "Set parsers: %s",
368
- this.parsers.map((p) => p.name)
369
- );
370
- }
371
- addParsers(...parsers) {
372
- this.parsers.push(...parsers);
373
- this.logger.trace(
374
- "Added parser, current parsers: %s",
375
- this.parsers.map((p) => p.name)
376
- );
377
- }
378
- async read(file) {
379
- return this.parse(file, await this.fs.read(file));
380
- }
381
- async write(file, data) {
382
- return this.fs.write(file, await this.stringify(file, data));
383
- }
384
- parse(file, data) {
385
- const parser = this.getParser(file);
386
- this.logger.trace("Parsing file: %s -> %s", file, parser.constructor.name);
387
- return parser.parse(data);
388
- }
389
- stringify(file, data) {
390
- const parser = this.getParser(file);
391
- this.logger.trace("Stringifying file: %s -> %s", file, parser.constructor.name);
392
- return parser.stringify(data);
393
- }
394
- };
395
- __name(ParserService, "ParserService");
396
-
397
- // src/utils/color.ts
398
- var colorette = __toESM(require("colorette"));
399
- var color = colorette.createColors({ useColor: true });
400
-
401
- // src/utils/environment.ts
402
- function isVerbose(logLevel) {
403
- return logLevel === "VERBOSE" /* VERBOSE */;
404
- }
405
- __name(isVerbose, "isVerbose");
406
- function isDebug(logLevel) {
407
- return ["DEBUG" /* DEBUG */, "TRACE" /* TRACE */].includes(logLevel);
408
- }
409
- __name(isDebug, "isDebug");
410
- function isSilent(logLevel) {
411
- return logLevel === "SILENT" /* SILENT */;
412
- }
413
- __name(isSilent, "isSilent");
414
-
415
- // src/utils/merge.constants.ts
416
- var MergeStrategy = /* @__PURE__ */ ((MergeStrategy2) => {
417
- MergeStrategy2["OVERWRITE"] = "OVERWRITE";
418
- MergeStrategy2["EXTEND"] = "EXTEND";
419
- return MergeStrategy2;
420
- })(MergeStrategy || {});
421
-
422
- // src/utils/merge.ts
423
- var import_deepmerge = __toESM(require("deepmerge"));
424
- function merge(strategy, ...source) {
425
- return import_deepmerge.default.all(source, {
426
- arrayMerge: strategy === "EXTEND" /* EXTEND */ ? (dest, src) => [...dest, ...src].filter(uniqueFilter) : (_, src) => src
427
- });
428
- }
429
- __name(merge, "merge");
430
- function uniqueFilter(value, index, self) {
431
- return self.indexOf(value) === index;
432
- }
433
- __name(uniqueFilter, "uniqueFilter");
434
-
435
- // src/utils/defaults.ts
436
- function setCtxDefaults(ctx, ...defaults) {
437
- defaults?.forEach((i) => {
438
- if (typeof i === "object" && !Array.isArray(i)) {
439
- Object.assign(ctx, i);
440
- }
441
- });
442
- }
443
- __name(setCtxDefaults, "setCtxDefaults");
444
- function setCtxAssign(ctx, ...assigns) {
445
- assigns.forEach((assign) => {
446
- assign?.keys.forEach((i) => {
447
- if (assign.from[i]) {
448
- ctx[i] = assign.from[i];
449
- }
450
- });
451
- });
452
- }
453
- __name(setCtxAssign, "setCtxAssign");
454
-
455
- // src/utils/index.ts
456
- var import_core2 = require("@oclif/core");
457
-
458
- // src/lib/config/config.service.ts
459
- var ConfigService = class {
460
- constructor(oclif, command, config) {
461
- this.oclif = oclif;
462
- this.command = command;
463
- if (ConfigService.instance) {
464
- if (Object.entries(config).some(([key, value]) => value !== ConfigService.instance[key])) {
465
- ConfigService.instance.recalculate(config);
466
- }
467
- return ConfigService.instance;
468
- }
469
- this.root = this.oclif.root;
470
- this.defaults = (0, import_path2.join)(this.oclif.root, "config" /* CONFIG_SERVICE_DEFAULTS_DIR */);
471
- this.logger = new Logger(this.constructor.name, { level: config.logLevel });
472
- this.parser = new ParserService();
473
- this.recalculate(config);
474
- ConfigService.instance = this;
475
- this.logger.trace("Created a new instance.");
476
- }
477
- async read(path) {
478
- const config = await this.parser.read(path);
479
- this.logger.trace("Read config from: %s", path);
480
- return config;
481
- }
482
- async extend(paths, strategy = "OVERWRITE" /* OVERWRITE */) {
483
- this.logger.trace("Will generate config from: %o with %s", paths, strategy);
484
- const configs = (await Promise.all(
485
- paths.map(async (path) => {
486
- try {
487
- const config = typeof path === "string" ? await this.parser.read(path) : path;
488
- this.logger.trace("Extending config from: %s", path);
489
- return config;
490
- } catch (e) {
491
- this.logger.trace("Failed to extend config from: %s", e.message);
492
- }
493
- })
494
- )).filter(Boolean);
495
- return this.merge(configs, strategy);
496
- }
497
- merge(configs, strategy = "OVERWRITE" /* OVERWRITE */) {
498
- if (configs.length === 0) {
499
- throw new Error("Nothing to merge, configuration files are empty.");
500
- }
501
- return merge(strategy, ...configs);
502
- }
503
- async env(definition, config) {
504
- const env = typeof definition === "string" ? await this.parser.read(definition) : definition;
505
- this.logger.trace("Environment variable extensions read: %o", definition);
506
- const iter = /* @__PURE__ */ __name(async (obj, parent) => {
507
- const data = await Promise.all(
508
- Object.entries(obj).map(async ([key, value]) => {
509
- const location = [...parent ?? [], key];
510
- if (typeof value === "string") {
511
- return [{ key: location, env: value }];
512
- } else if (typeof value === "object") {
513
- let extensions;
514
- if ("__element" /* ELEMENT */ in value) {
515
- extensions = await iter(value["__element" /* ELEMENT */], [...location, "__element" /* ELEMENT */]);
516
- this.logger.trace("Expanding location to elements: %s -> %s", location, extensions.map((extension) => extension.key.join(".")).join(", "));
517
- }
518
- if ("__name" /* NAME */ in value && "__format" /* PARSER */ in value) {
519
- const variable = [
520
- {
521
- key: location,
522
- env: value["__name" /* NAME */],
523
- parser: value["__format" /* PARSER */],
524
- extensions
525
- }
526
- ];
527
- return variable;
528
- } else {
529
- return iter(value, location);
530
- }
531
- }
532
- })
533
- );
534
- return data.flatMap((d) => d).filter(Boolean);
535
- }, "iter");
536
- const parsed = await iter(env);
537
- const cb = /* @__PURE__ */ __name((config2, variable, data) => {
538
- if (variable.parser) {
539
- try {
540
- data = this.parser.parse(variable.parser, data);
541
- } catch (e) {
542
- this.logger.trace("Can not parse environment environment variable for config: %s -> %s with %s", variable.key.join("."), variable.env, variable.parser);
543
- throw e;
544
- }
545
- }
546
- this.logger.trace("Overwriting config with environment variable: %s -> %s", variable.key.join("."), variable.env);
547
- return import_object_path_immutable.default.set(config2, variable.key, data);
548
- }, "cb");
549
- parsed.forEach((variable) => {
550
- let data;
551
- data = process.env[variable.env];
552
- if (data) {
553
- config = cb(config, variable, data);
554
- }
555
- if (variable.extensions && variable.extensions.length > 0) {
556
- const timeout = 6e4;
557
- const startedAt = Date.now();
558
- for (let i = 0; i < Infinity; i++) {
559
- if (Date.now() - startedAt > timeout) {
560
- throw new Error(`Timed-out in ${timeout}ms while looking for element environment variables.`);
561
- }
562
- const extensions = variable.extensions.map((extension) => {
563
- const clone = JSON.parse(JSON.stringify(extension));
564
- clone.env = clone.env.replace("${i}" /* ELEMENT_REPLACER */, i.toString());
565
- clone.key[clone.key.findIndex((value) => value === "__element" /* ELEMENT */)] = i.toString();
566
- data = process.env[clone.env];
567
- if (!data) {
568
- this.logger.trace("No extension for environment variable: %s -> %s", clone.key.join("."), clone.env);
569
- return;
570
- }
571
- config = cb(config, clone, data);
572
- return true;
573
- }).filter(Boolean);
574
- if (extensions.length === 0) {
575
- this.logger.trace("No more extensions for environment variables: %s -> %d", variable.key.join("."), i);
576
- break;
577
- }
578
- }
579
- }
580
- });
581
- return config;
582
- }
583
- async write(path, data) {
584
- return this.parser.write(path, data);
585
- }
586
- recalculate(config) {
587
- this.ci = config.ci;
588
- this.json = config.json;
589
- this.logLevel = config.logLevel;
590
- this.isVerbose = isVerbose(config.logLevel);
591
- this.isDebug = isDebug(config.logLevel);
592
- this.isSilent = isSilent(config.logLevel);
593
- }
594
- };
595
- __name(ConfigService, "ConfigService");
596
-
597
- // src/lib/locker/locker.service.ts
598
- var import_object_path_immutable2 = __toESM(require("object-path-immutable"));
599
- var LockerService = class {
600
- constructor(file, parser, root, context) {
601
- this.file = file;
602
- this.parser = parser;
603
- this.root = root;
604
- this.toLock = [];
605
- this.toUnlock = [];
606
- this.fs = new FileSystemService();
607
- this.logger = new Logger(context ?? this.constructor.name);
608
- if (!this.parser) {
609
- const parser2 = new ParserService();
610
- this.parser = parser2.getParser(file);
611
- }
612
- }
613
- hasLock() {
614
- return this.toLock.length > 0;
615
- }
616
- hasUnlock() {
617
- return this.toUnlock.length > 0;
618
- }
619
- addLock(...data) {
620
- this.toLock = [...this.toLock, ...data];
621
- }
622
- addUnlock(...data) {
623
- this.toUnlock = [...this.toUnlock, ...data];
624
- }
625
- async lockAll() {
626
- if (this.hasLock()) {
627
- await this.lock(...this.toLock);
628
- this.toLock = [];
629
- }
630
- }
631
- async unlockAll() {
632
- if (this.toUnlock.length > 0) {
633
- await this.unlock(...this.toUnlock);
634
- this.toUnlock = [];
635
- }
636
- }
637
- async all() {
638
- await this.unlockAll();
639
- await this.lockAll();
640
- }
641
- async lock(...data) {
642
- let lock = await this.tryRead() ?? {};
643
- data.forEach((d) => {
644
- if (d?.enabled === false) {
645
- return;
646
- } else if (!d?.data || Array.isArray(d?.data) && d.data.length === 0 || typeof d?.data === "object" && Object.keys(d.data).length === 0) {
647
- return;
648
- }
649
- const path = this.buildPath(d);
650
- if (d?.merge) {
651
- let parsed;
652
- if (typeof d.data === "object") {
653
- parsed = merge(d.merge, import_object_path_immutable2.default.get(lock, path, Array.isArray(d.data) ? [] : {}), d.data);
654
- } else {
655
- this.logger.warn('"%s" path with type "%s" is not mergeable.', path, typeof d.data);
656
- parsed = d.data;
657
- }
658
- lock = import_object_path_immutable2.default.set(lock, path, parsed);
659
- this.logger.verbose("Merge lock: %s -> %o", path, d.data);
660
- } else {
661
- lock = import_object_path_immutable2.default.set(lock, path, d.data);
662
- this.logger.verbose("Override lock: %s -> %o", path, d.data);
663
- }
664
- });
665
- await this.write(lock);
666
- }
667
- async unlock(...data) {
668
- let lock = await this.tryRead();
669
- if (!lock) {
670
- this.logger.verbose("Lock file not found. Nothing to unlock.");
671
- return;
672
- }
673
- if (data.length > 0) {
674
- data.forEach((d) => {
675
- if (d?.enabled === false) {
676
- return;
677
- }
678
- const path = this.buildPath(d);
679
- lock = import_object_path_immutable2.default.del(lock, path);
680
- this.logger.verbose("Unlocked: %s", path);
681
- for (let i = path.length - 1; i >= 0; i--) {
682
- const parentPath = path.slice(0, i);
683
- const parent = import_object_path_immutable2.default.get(lock, parentPath);
684
- if (!parent || Array.isArray(parent) && parent.length === 0 || typeof parent === "object" && Object.keys(parent).length === 0) {
685
- this.logger.verbose("Unlocked parent: %s -> %s", path, parentPath);
686
- lock = import_object_path_immutable2.default.del(lock, parentPath);
687
- } else {
688
- break;
689
- }
690
- }
691
- });
692
- } else {
693
- lock = import_object_path_immutable2.default.del(lock, this.root);
694
- this.logger.verbose("Unlocked module: %s", this.root);
695
- }
696
- await this.write(lock ?? {});
697
- }
698
- async read() {
699
- return this.parser.parse(await this.fs.read(this.file));
700
- }
701
- async tryRead() {
702
- try {
703
- return this.parser.parse(await this.fs.read(this.file));
704
- } catch {
705
- this.logger.trace("Can not read lockfile: %s", this.file);
706
- }
707
- }
708
- async write(data) {
709
- if (!data || Array.isArray(data) && data.length === 0 || typeof data === "object" && Object.keys(data).length === 0) {
710
- this.logger.trace("Trying to write empty lock file, deleting it instead: %s", this.file);
711
- return this.fs.remove(this.file);
712
- }
713
- return this.fs.write(this.file, this.parser.stringify(data));
714
- }
715
- buildPath(d) {
716
- if (d?.root !== true && this.root?.length) {
717
- return [...this.root, ...this.normalizePath(d.path)];
718
- }
719
- return this.normalizePath(d.path);
720
- }
721
- normalizePath(path) {
722
- if (Array.isArray(path)) {
723
- return path.map((p) => p.toString());
724
- } else if (typeof path === "string") {
725
- return path.split(".");
726
- }
727
- return [];
728
- }
729
- };
730
- __name(LockerService, "LockerService");
731
-
732
- // src/lib/store/store.service.ts
733
- var StoreService = class {
734
- constructor() {
735
- this.store = {};
736
- if (StoreService.instance) {
737
- return StoreService.instance;
738
- } else {
739
- StoreService.instance = this;
740
- }
741
- }
742
- has(key) {
743
- return !!this.store[key];
744
- }
745
- get(key) {
746
- return this.store[key];
747
- }
748
- set(key, data) {
749
- this.store[key] = data;
750
- return data;
751
- }
752
- };
753
- __name(StoreService, "StoreService");
754
-
755
- // src/lib/validator/validator.service.ts
756
- var import_class_transformer = require("class-transformer");
757
- var import_class_validator = require("class-validator");
758
- var ValidatorService = class {
759
- constructor(options) {
760
- this.options = options;
761
- if (ValidatorService.instance) {
762
- return ValidatorService.instance;
763
- }
764
- this.options = {
765
- validator: {
766
- skipMissingProperties: true,
767
- whitelist: false,
768
- always: true,
769
- enableDebugMessages: true
770
- },
771
- transformer: { enableImplicitConversion: true },
772
- ...options ?? {}
773
- };
774
- this.logger = new Logger(this.constructor.name);
775
- ValidatorService.instance = this;
776
- this.logger.trace("Created a new instance.");
777
- }
778
- async validate(classType, object, options) {
779
- const classObject = (0, import_class_transformer.plainToClass)(classType, object, { ...this.options.transformer, ...options?.transformer ?? {} });
780
- const errors = await (0, import_class_validator.validate)(classObject, { ...this.options.validator, ...options?.validator ?? {} });
781
- if (errors.length) {
782
- errors.forEach((error) => {
783
- this.logValidationError(error);
784
- });
785
- throw new Error("Validation failed.");
786
- }
787
- return classObject;
788
- }
789
- validateSync(classType, object, options) {
790
- const classObject = (0, import_class_transformer.plainToClass)(classType, object, { ...this.options.transformer, ...options?.transformer ?? {} });
791
- const errors = (0, import_class_validator.validateSync)(classObject, { ...this.options.validator, ...options?.validator ?? {} });
792
- if (errors.length) {
793
- errors.forEach((error) => {
794
- this.logValidationError(error);
795
- });
796
- throw new Error("Validation failed.");
797
- }
798
- return classObject;
799
- }
800
- logValidationError(err) {
801
- this.logger.error('Field "%s" failed validation with value "%s": %s', err.property, err.value, Object.values(err.constraints).join(", "));
802
- }
803
- };
804
- __name(ValidatorService, "ValidatorService");
805
-
806
- // src/lib/setup.ts
807
- function setup() {
808
- const inspect = process.argv.indexOf("--inspect");
809
- if (inspect !== -1) {
810
- require("inspector").open();
811
- process.argv.splice(inspect, 1);
812
- }
813
- const verbose = process.argv.indexOf("--verbose");
814
- if (verbose !== -1) {
815
- process.env.LOG_LEVEL = "verbose";
816
- process.argv.splice(verbose, 1);
817
- }
818
- const debug = process.argv.indexOf("--debug");
819
- if (debug !== -1) {
820
- process.env.LOG_LEVEL = "debug";
821
- process.argv.splice(debug, 1);
822
- }
823
- const trace = process.argv.indexOf("--trace");
824
- if (trace !== -1) {
825
- process.env.LOG_LEVEL = "trace";
826
- process.argv.splice(trace, 1);
827
- }
828
- const silent = process.argv.indexOf("--silent");
829
- if (silent !== -1) {
830
- process.env.LOG_LEVEL = "silent";
831
- process.argv.splice(silent, 1);
832
- }
833
- const sourceMaps = process.argv.indexOf("--source-map");
834
- if (sourceMaps !== -1) {
835
- require("source-map-support").install();
836
- process.argv.splice(sourceMaps, 1);
837
- }
838
- }
839
- __name(setup, "setup");
840
-
841
- // src/utils/logger/logger.ts
842
- var Logger = class {
843
- constructor(context, options) {
844
- this.context = context;
845
- this.options = options;
846
- const parsed = (process.env.LOG_LEVEL ?? options?.level ?? "INFO" /* INFO */).toUpperCase();
847
- const level = Object.values(LogLevels).includes(parsed) ? parsed : "INFO" /* INFO */;
848
- this.options = {
849
- useIcons: true,
850
- ...options,
851
- level
852
- };
853
- if (Logger.instance) {
854
- this.logger = Logger.instance;
855
- } else if (context === ConfigService.name) {
856
- this.logger = this.initiateLogger();
857
- this.trace("Logger singleton initiated from context: %s", context);
858
- Logger.instance = this.logger;
859
- }
860
- }
861
- log(level, data, ...args) {
862
- return this.parseMessage(level, data, args);
863
- }
864
- direct(data, ...args) {
865
- return this.parseMessage("DIRECT" /* DIRECT */, data, args);
866
- }
867
- fatal(data, ...args) {
868
- return this.parseMessage("FATAL" /* FATAL */, data, args);
869
- }
870
- error(data, ...args) {
871
- return this.parseMessage("ERROR" /* ERROR */, data, args);
872
- }
873
- warn(data, ...args) {
874
- return this.parseMessage("WARN" /* WARN */, data, args);
875
- }
876
- info(data, ...args) {
877
- return this.parseMessage("INFO" /* INFO */, data, args);
878
- }
879
- debug(data, ...args) {
880
- return this.parseMessage("DEBUG" /* DEBUG */, data, args);
881
- }
882
- verbose(data, ...args) {
883
- return this.parseMessage("VERBOSE" /* VERBOSE */, data, args);
884
- }
885
- trace(data, ...args) {
886
- return this.parseMessage("TRACE" /* TRACE */, data, args);
887
- }
888
- run(data, ...args) {
889
- return this.parseMessage("INFO" /* INFO */, data, args, { status: "run" /* RUN */ });
890
- }
891
- end(data, ...args) {
892
- return this.parseMessage("INFO" /* INFO */, data, args, { status: "end" /* END */ });
893
- }
894
- stage(data, ...args) {
895
- return this.parseMessage("TRACE" /* TRACE */, data, args, { status: "stage" /* STAGE */ });
896
- }
897
- initiateLogger() {
898
- const logFormat = import_winston.format.printf(({ level, message, context, status }) => {
899
- let multiLineMessage;
900
- multiLineMessage = message.split(import_os2.EOL);
901
- multiLineMessage = multiLineMessage.filter((msg) => msg.trim() !== "").filter(Boolean);
902
- multiLineMessage = multiLineMessage.map((msg) => {
903
- return this.logColoring({
904
- level,
905
- message: msg,
906
- context,
907
- status
908
- });
909
- });
910
- return multiLineMessage.join(import_os2.EOL);
911
- });
912
- const logger = import_winston.default.createLogger({
913
- level: this.options.level,
914
- format: import_winston.format.combine(import_winston.format.splat(), import_winston.format.json({ space: 2 }), import_winston.format.prettyPrint(), logFormat),
915
- levels: Object.values(LogLevels).reduce((o, level, i) => {
916
- return {
917
- ...o,
918
- [level]: i
919
- };
920
- }, {}),
921
- silent: this.options.level === "SILENT" /* SILENT */,
922
- transports: [
923
- new import_winston.transports.Console({
924
- stderrLevels: ["FATAL" /* FATAL */, "ERROR" /* ERROR */]
925
- })
926
- ]
927
- });
928
- logger.log("TRACE" /* TRACE */, "Initiated new logger with level: %s", this.options.level, { context: this.constructor.name });
929
- return logger;
930
- }
931
- parseMessage(level, data, args, format2) {
932
- if (!this.logger && !Logger.instance) {
933
- return;
934
- } else if (Logger.instance) {
935
- this.logger = Logger.instance;
936
- }
937
- this.logger.log(level, data.toString(), ...args ?? [], { context: this.context, ...format2 ?? {} });
938
- }
939
- logColoring({ level, message, context, status }) {
940
- let icon;
941
- let coloring = /* @__PURE__ */ __name((input) => {
942
- return input;
943
- }, "coloring");
944
- let msgColoring = /* @__PURE__ */ __name((input) => {
945
- return input;
946
- }, "msgColoring");
947
- switch (level) {
948
- case "DIRECT" /* DIRECT */:
949
- return message;
950
- case "FATAL" /* FATAL */:
951
- coloring = /* @__PURE__ */ __name((input) => color.red(input), "coloring");
952
- if (this.options?.useIcons) {
953
- icon = import_listr2.figures.checkboxOn;
954
- }
955
- break;
956
- case "ERROR" /* ERROR */:
957
- coloring = color.red;
958
- if (this.options?.useIcons) {
959
- icon = import_listr2.figures.cross;
960
- }
961
- break;
962
- case "WARN" /* WARN */:
963
- coloring = color.yellow;
964
- if (this.options?.useIcons) {
965
- icon = import_listr2.figures.warning;
966
- }
967
- break;
968
- case "INFO" /* INFO */:
969
- coloring = color.green;
970
- if (this.options?.useIcons) {
971
- icon = import_listr2.figures.pointerSmall;
972
- }
973
- break;
974
- case "VERBOSE" /* VERBOSE */:
975
- coloring = color.dim;
976
- if (this.options?.useIcons) {
977
- icon = "\u2607";
978
- }
979
- break;
980
- case "DEBUG" /* DEBUG */:
981
- coloring = color.cyan;
982
- msgColoring = color.dim;
983
- if (this.options?.useIcons) {
984
- icon = "\uF188";
985
- }
986
- break;
987
- case "TRACE" /* TRACE */:
988
- coloring = color.magenta;
989
- msgColoring = color.dim;
990
- if (this.options?.useIcons) {
991
- icon = "\u26B1";
992
- }
993
- break;
994
- }
995
- if (!icon) {
996
- icon = `[${level.at(0).toUpperCase()}]`;
997
- }
998
- return `${coloring(icon)}${context ? " " + coloring(`[${context}]`) : ""}${status ? " " + coloring(`[${status}]`) : ""} ${msgColoring(message)}`;
999
- }
1000
- };
1001
- __name(Logger, "Logger");
1002
-
1003
- // src/utils/logger/listr-logger.ts
1004
- var ListrLogger = class extends import_listr22.Logger {
1005
- constructor(context) {
1006
- super();
1007
- this.logger = new Logger(context);
1008
- }
1009
- fail(message) {
1010
- this.logger.error(message);
1011
- }
1012
- skip(message) {
1013
- this.logger.warn(message, { status: "skip" });
1014
- }
1015
- success(message) {
1016
- this.logger.info(message, { status: "end" });
1017
- }
1018
- data(message) {
1019
- this.logger.info(message);
1020
- }
1021
- start(message) {
1022
- this.logger.info(message, { status: "run" });
1023
- }
1024
- title(message) {
1025
- this.logger.info(message);
1026
- }
1027
- retry(message) {
1028
- this.logger.warn(message, { status: "retry" });
1029
- }
1030
- rollback(message) {
1031
- this.logger.error(message, { status: "rollback" });
1032
- }
1033
- };
1034
- __name(ListrLogger, "ListrLogger");
1035
-
1036
- // src/utils/logger/pipe/pipe-process-to-listr.ts
1037
- var import_through = __toESM(require("through"));
1038
- function pipeProcessThroughListr(task, instance) {
1039
- const logOut = (0, import_through.default)((chunk) => {
1040
- task.output = chunk?.toString("utf-8").trim();
1041
- });
1042
- instance.stdout.pipe(logOut);
1043
- instance.stderr.pipe(logOut);
1044
- return instance;
1045
- }
1046
- __name(pipeProcessThroughListr, "pipeProcessThroughListr");
1047
-
1048
- // src/utils/logger/pipe/pipe-process-to-logger.ts
1049
- var import_through2 = __toESM(require("through"));
1050
- function pipeProcessToLogger(logger, instance, options) {
1051
- options = {
1052
- start: "INFO" /* INFO */,
1053
- end: "INFO" /* INFO */,
1054
- stdout: "INFO" /* INFO */,
1055
- stderr: "WARN" /* WARN */,
1056
- ...options
1057
- };
1058
- if (options.start) {
1059
- logger.run(instance.spawnargs.join(" "), { level: options.start });
1060
- }
1061
- if (instance.stdout) {
1062
- instance.stdout.pipe(
1063
- (0, import_through2.default)((chunk) => {
1064
- logger.log(options.stdout, chunk);
1065
- })
1066
- );
1067
- }
1068
- if (instance.stderr) {
1069
- instance.stderr.pipe(
1070
- (0, import_through2.default)((chunk) => {
1071
- logger.log(options.stderr, chunk);
1072
- })
1073
- );
1074
- }
1075
- void instance.on("exit", (code, signal) => {
1076
- const message = `Process ended with code ${code}${signal ? ` and signal ${signal}` : ""}.`;
1077
- logger.debug(message);
1078
- if (options.end) {
1079
- logger.end(instance.spawnargs.join(" "), { level: options.end });
1080
- }
1081
- if (options?.callback) {
1082
- options.callback();
1083
- }
1084
- });
1085
- void instance.on("error", (error) => {
1086
- logger.fatal(error.message);
1087
- logger.debug(error.stack);
1088
- if (options?.callback) {
1089
- options.callback(error);
1090
- }
1091
- });
1092
- return instance;
1093
- }
1094
- __name(pipeProcessToLogger, "pipeProcessToLogger");
1095
-
1096
- // src/constants/global-flags.constants.ts
1097
- var CLI_FLAGS = {
1098
- ["log-level"]: import_core.Flags.enum({
1099
- default: "INFO" /* INFO */,
1100
- env: "LOG_LEVEL",
1101
- description: "Set the log level of the application.",
1102
- options: [...Object.values(LogLevels), ...Object.values(LogLevels).map((level) => level.toLowerCase())],
1103
- helpGroup: "CLI" /* CLI */,
1104
- parse: async (input) => input?.toUpperCase()
1105
- }),
1106
- ci: import_core.Flags.boolean({
1107
- default: false,
1108
- env: "CI",
1109
- description: "Instruct whether this is running the CI/CD configuration.",
1110
- helpGroup: "CLI" /* CLI */
1111
- }),
1112
- json: import_core.Flags.boolean({
1113
- default: false,
1114
- env: "JSON",
1115
- description: "Put the CLI to respond in JSON.",
1116
- helpGroup: "CLI" /* CLI */
1117
- })
1118
- };
1119
-
1120
- // src/commands/base.command.ts
1121
- var Command = class extends import_core3.Command {
1122
- constructor() {
1123
- super(...arguments);
1124
- this.flags = {};
1125
- this.args = {};
1126
- }
1127
- static get globalFlags() {
1128
- return { ...CLI_FLAGS, ...this._globalFlags };
1129
- }
1130
- static set globalFlags(flags) {
1131
- this._globalFlags = Object.assign({}, this.globalFlags, flags);
1132
- this.flags = {};
1133
- }
1134
- shouldRunBefore() {
1135
- }
1136
- shouldRunAfter(_ctx) {
1137
- }
1138
- run() {
1139
- throw new Error("The command should have a run function to do something!");
1140
- }
1141
- async _run() {
1142
- let result;
1143
- try {
1144
- delete process.env[this.config.scopedEnvVarKey("REDIRECTED")];
1145
- await this.init();
1146
- result = await this.run();
1147
- await this.finally();
1148
- } catch (error) {
1149
- await this.catch(error, 127);
1150
- }
1151
- if (result && this.jsonEnabled()) {
1152
- import_core2.CliUx.ux.styledJSON(this.toSuccessJson(result));
1153
- }
1154
- return result;
1155
- }
1156
- exit(code) {
1157
- this.logger.trace("Code -> %d", code, { status: "exit" /* EXIT */ });
1158
- process.exit(code ?? 0);
1159
- }
1160
- runTasks() {
1161
- return this.tasks.runAll();
1162
- }
1163
- prompt(options) {
1164
- return (0, import_listr23.createPrompt)(options, {
1165
- error: true,
1166
- stdout: process.stdout
1167
- });
1168
- }
1169
- setCtxDefaults(...defaults) {
1170
- setCtxDefaults(this.tasks.options.ctx, ...defaults);
1171
- this.logger.trace("Updated context with defaults: %o", this.tasks.options.ctx, { status: "ctx" });
1172
- }
1173
- setCtxAssign(...assigns) {
1174
- setCtxAssign(this.tasks.options.ctx, ...assigns);
1175
- this.logger.trace("Updated context with assign: %o", this.tasks.options.ctx, { status: "ctx" });
1176
- }
1177
- async init() {
1178
- await super.init();
1179
- let err;
1180
- try {
1181
- const { flags, args } = await this.parse();
1182
- this.flags = flags;
1183
- this.args = args;
1184
- } catch (e) {
1185
- err = e;
1186
- }
1187
- this.cs = new ConfigService(this.config, this.ctor, {
1188
- logLevel: this.flags["log-level"],
1189
- ci: this.flags.ci,
1190
- json: this.flags.json
1191
- });
1192
- const context = this.cs.command.id ? this.cs.command.id : this.cs.command.name;
1193
- this.logger = new Logger(null, { level: this.cs.logLevel });
1194
- this.store = new StoreService();
1195
- this.greet();
1196
- if (err) {
1197
- throw err;
1198
- }
1199
- this.logger.stage("Initiating services.");
1200
- this.parser = new ParserService();
1201
- this.fs = new FileSystemService();
1202
- this.validator = new ValidatorService();
1203
- this.tasks = new import_listr23.Manager({
1204
- rendererFallback: this.cs.isDebug,
1205
- rendererSilent: this.cs.isSilent,
1206
- nonTTYRendererOptions: {
1207
- logEmptyTitle: false,
1208
- logTitleChange: false,
1209
- logger: ListrLogger,
1210
- options: [context]
1211
- },
1212
- ctx: {}
1213
- });
1214
- if (this.cs.oclif.windows) {
1215
- (0, import_readline.createInterface)({
1216
- input: process.stdin,
1217
- output: process.stdout
1218
- }).on("SIGINT", () => {
1219
- process.kill(process.pid, "SIGINT");
1220
- });
1221
- }
1222
- const terminate = /* @__PURE__ */ __name(() => {
1223
- this.logger.fatal("Caught terminate signal.", { status: "terminate" /* TERMINATE */ });
1224
- process.exit(1);
1225
- }, "terminate");
1226
- process.on("SIGINT", terminate);
1227
- process.on("SIGTERM", terminate);
1228
- this.logger.stage("Running shouldRunBefore.");
1229
- await this.shouldRunBefore();
1230
- this.logger.stage("Finished shouldRunBefore.");
1231
- }
1232
- async finally() {
1233
- this.logger.stage("Running tasks.");
1234
- const ctx = await this.runTasks();
1235
- this.logger.stage("Finished tasks.");
1236
- this.logger.stage("Running shouldRunAfter.");
1237
- await this.shouldRunAfter(ctx);
1238
- this.logger.stage("Finished shouldRunAfter.");
1239
- return { ctx };
1240
- }
1241
- catch(e, exit) {
1242
- this.logger.fatal(e.message);
1243
- this.logger.debug(e.stack, { context: "crash" });
1244
- if (exit > 0) {
1245
- this.exit(exit);
1246
- }
1247
- return;
1248
- }
1249
- greet() {
1250
- if (this.cs.isSilent || this.cs.json) {
1251
- return;
1252
- }
1253
- const logo = this.store.get("logo") ?? `${this.cs.oclif.name} v${this.cs.oclif.version}`;
1254
- this.logger.direct(logo);
1255
- if (!this.store.has("logo")) {
1256
- this.logger.direct("-".repeat(logo.length));
1257
- }
1258
- }
1259
- };
1260
- __name(Command, "Command");
1261
-
1262
- // src/commands/config.command.ts
1263
- var ConfigCommand = class extends Command {
1264
- constructor() {
1265
- super(...arguments);
1266
- this.ux = import_core2.CliUx.ux;
1267
- }
1268
- async run() {
1269
- this.logger.stage("Setting up config command.");
1270
- const setup2 = await this.setup();
1271
- this.choices = setup2.choices;
1272
- this.locker = setup2.locker;
1273
- this.logger.stage("User selection for configuration.");
1274
- const response = await this.select();
1275
- this.logger.stage("Will run selection: %s", response);
1276
- return this.choices[response].bind(this)();
1277
- }
1278
- setup() {
1279
- throw new Error("The command should be setup first!");
1280
- }
1281
- table(...options) {
1282
- this.ux.table(...options);
1283
- }
1284
- async select() {
1285
- const response = await this.prompt({
1286
- type: "Select",
1287
- message: "Please select what to do with the configuration.",
1288
- choices: Object.keys(this.choices)
1289
- });
1290
- return response;
1291
- }
1292
- };
1293
- __name(ConfigCommand, "ConfigCommand");
1294
-
1295
- // src/hooks/not-found.hook.ts
1296
- var import_core4 = require("@oclif/core");
1297
- var notFoundHook = /* @__PURE__ */ __name(async (opts) => {
1298
- const logger = new Logger(opts.config.name);
1299
- logger.fatal("Command not found. Take a look at help. You can also use --[h]elp flag for subcommands.", { custom: opts.config.name });
1300
- logger.direct("");
1301
- const help = new import_core4.Help(opts.config);
1302
- await help.showHelp(["--all"]);
1303
- process.exit(127);
1304
- }, "notFoundHook");
1305
-
1306
- // src/hooks/update-notifier.hook.ts
1307
- var import_update_notifier = __toESM(require("update-notifier"));
1308
- var updateNotifierHook = /* @__PURE__ */ __name(async (opts) => {
1309
- (0, import_update_notifier.default)({ pkg: { name: opts.config.name, version: opts.config.version } }).notify({ isGlobal: true });
1310
- }, "updateNotifierHook");
1311
-
1312
- // src/hooks/store.hook.ts
1313
- var storeHook = /* @__PURE__ */ __name((cb) => async (opts) => {
1314
- cb(opts, new StoreService());
1315
- }, "storeHook");
1316
- // Annotate the CommonJS export names for ESM import in node:
1317
- 0 && (module.exports = {
1318
- CLI_FLAGS,
1319
- CliUx,
1320
- Command,
1321
- ConfigCommand,
1322
- ConfigService,
1323
- EnvironmentVariableParser,
1324
- FileConstants,
1325
- FileSystemService,
1326
- Flags,
1327
- HelpGroups,
1328
- JsonParser,
1329
- ListrLogger,
1330
- LockerService,
1331
- LogFieldStatus,
1332
- LogLevels,
1333
- Logger,
1334
- MergeStrategy,
1335
- ParserService,
1336
- StoreService,
1337
- ValidatorService,
1338
- YamlParser,
1339
- color,
1340
- fs,
1341
- isDebug,
1342
- isSilent,
1343
- isVerbose,
1344
- merge,
1345
- notFoundHook,
1346
- pipeProcessThroughListr,
1347
- pipeProcessToLogger,
1348
- setCtxAssign,
1349
- setCtxDefaults,
1350
- setup,
1351
- storeHook,
1352
- uniqueFilter,
1353
- updateNotifierHook
1354
- });
17
+ __reExport(src_exports, require("./commands"), module.exports);
18
+ __reExport(src_exports, require("./constants"), module.exports);
19
+ __reExport(src_exports, require("./hooks"), module.exports);
20
+ __reExport(src_exports, require("./interfaces"), module.exports);
21
+ __reExport(src_exports, require("./lib"), module.exports);
22
+ __reExport(src_exports, require("./utils"), module.exports);