@cenk1cenk2/oclif-common 1.9.0 → 1.10.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.
@@ -4,6 +4,7 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
5
5
  var __getProtoOf = Object.getPrototypeOf;
6
6
  var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
7
8
  var __export = (target, all) => {
8
9
  for (var name in all)
9
10
  __defProp(target, name, { get: all[name], enumerable: true });
@@ -157,17 +158,17 @@ var Logger = class {
157
158
  }
158
159
  logColoring({ level, message, context, status }) {
159
160
  let icon;
160
- let coloring = (input) => {
161
+ let coloring = /* @__PURE__ */ __name((input) => {
161
162
  return input;
162
- };
163
- let msgColoring = (input) => {
163
+ }, "coloring");
164
+ let msgColoring = /* @__PURE__ */ __name((input) => {
164
165
  return input;
165
- };
166
+ }, "msgColoring");
166
167
  switch (level) {
167
168
  case "DIRECT" /* DIRECT */:
168
169
  return message;
169
170
  case "FATAL" /* FATAL */:
170
- coloring = (input) => color.bgRed(color.white(input));
171
+ coloring = /* @__PURE__ */ __name((input) => color.bgRed(color.white(input)), "coloring");
171
172
  if (this.options?.useIcons) {
172
173
  icon = import_figures.default.cross;
173
174
  }
@@ -217,22 +218,23 @@ var Logger = class {
217
218
  return `${coloring(icon)}${context ? " " + coloring(`[${context}]`) : ""}${status ? " " + coloring(`[${status}]`) : ""} ${msgColoring(message)}`;
218
219
  }
219
220
  };
221
+ __name(Logger, "Logger");
220
222
 
221
223
  // src/hooks/not-found.hook.ts
222
- var notFoundHook = async (opts) => {
224
+ var notFoundHook = /* @__PURE__ */ __name(async (opts) => {
223
225
  const logger = new Logger(opts.config.name);
224
226
  logger.fatal("Command not found. Take a look at help. You can also use --[h]elp flag for subcommands.", { custom: opts.config.name });
225
227
  logger.direct("");
226
228
  const help = new import_core.Help(opts.config);
227
229
  await help.showHelp(["--all"]);
228
230
  process.exit(127);
229
- };
231
+ }, "notFoundHook");
230
232
 
231
233
  // src/hooks/update-notifier.hook.ts
232
234
  var import_update_notifier = __toESM(require("update-notifier"));
233
- var updateNotifierHook = async (opts) => {
235
+ var updateNotifierHook = /* @__PURE__ */ __name(async (opts) => {
234
236
  (0, import_update_notifier.default)({ pkg: { name: opts.config.name, version: opts.config.version } }).notify({ isGlobal: true });
235
- };
237
+ }, "updateNotifierHook");
236
238
  // Annotate the CommonJS export names for ESM import in node:
237
239
  0 && (module.exports = {
238
240
  notFoundHook,
@@ -4,6 +4,7 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
5
5
  var __getProtoOf = Object.getPrototypeOf;
6
6
  var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
7
8
  var __export = (target, all) => {
8
9
  for (var name in all)
9
10
  __defProp(target, name, { get: all[name], enumerable: true });
@@ -154,17 +155,17 @@ var Logger = class {
154
155
  }
155
156
  logColoring({ level, message, context, status }) {
156
157
  let icon;
157
- let coloring = (input) => {
158
+ let coloring = /* @__PURE__ */ __name((input) => {
158
159
  return input;
159
- };
160
- let msgColoring = (input) => {
160
+ }, "coloring");
161
+ let msgColoring = /* @__PURE__ */ __name((input) => {
161
162
  return input;
162
- };
163
+ }, "msgColoring");
163
164
  switch (level) {
164
165
  case "DIRECT" /* DIRECT */:
165
166
  return message;
166
167
  case "FATAL" /* FATAL */:
167
- coloring = (input) => color.bgRed(color.white(input));
168
+ coloring = /* @__PURE__ */ __name((input) => color.bgRed(color.white(input)), "coloring");
168
169
  if (this.options?.useIcons) {
169
170
  icon = import_figures.default.cross;
170
171
  }
@@ -214,16 +215,17 @@ var Logger = class {
214
215
  return `${coloring(icon)}${context ? " " + coloring(`[${context}]`) : ""}${status ? " " + coloring(`[${status}]`) : ""} ${msgColoring(message)}`;
215
216
  }
216
217
  };
218
+ __name(Logger, "Logger");
217
219
 
218
220
  // src/hooks/not-found.hook.ts
219
- var notFoundHook = async (opts) => {
221
+ var notFoundHook = /* @__PURE__ */ __name(async (opts) => {
220
222
  const logger = new Logger(opts.config.name);
221
223
  logger.fatal("Command not found. Take a look at help. You can also use --[h]elp flag for subcommands.", { custom: opts.config.name });
222
224
  logger.direct("");
223
225
  const help = new import_core.Help(opts.config);
224
226
  await help.showHelp(["--all"]);
225
227
  process.exit(127);
226
- };
228
+ }, "notFoundHook");
227
229
  // Annotate the CommonJS export names for ESM import in node:
228
230
  0 && (module.exports = {
229
231
  notFoundHook
@@ -4,6 +4,7 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
5
5
  var __getProtoOf = Object.getPrototypeOf;
6
6
  var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
7
8
  var __export = (target, all) => {
8
9
  for (var name in all)
9
10
  __defProp(target, name, { get: all[name], enumerable: true });
@@ -29,9 +30,9 @@ __export(update_notifier_hook_exports, {
29
30
  });
30
31
  module.exports = __toCommonJS(update_notifier_hook_exports);
31
32
  var import_update_notifier = __toESM(require("update-notifier"));
32
- var updateNotifierHook = async (opts) => {
33
+ var updateNotifierHook = /* @__PURE__ */ __name(async (opts) => {
33
34
  (0, import_update_notifier.default)({ pkg: { name: opts.config.name, version: opts.config.version } }).notify({ isGlobal: true });
34
- };
35
+ }, "updateNotifierHook");
35
36
  // Annotate the CommonJS export names for ESM import in node:
36
37
  0 && (module.exports = {
37
38
  updateNotifierHook
package/dist/index.d.ts CHANGED
@@ -10,7 +10,7 @@ export { updateNotifierHook } from './hooks/update-notifier.hook.js';
10
10
  import { ExecaChildProcess } from 'execa';
11
11
  import * as colorette from 'colorette';
12
12
  export { default as figures } from 'figures';
13
- export { default as config } from 'config';
13
+ export { util as config } from 'config';
14
14
 
15
15
  declare function pipeProcessThroughListr(task: ListrTaskWrapper<any, any>, instance: ExecaChildProcess): ExecaChildProcess;
16
16
 
@@ -269,14 +269,22 @@ declare class Command<Ctx extends ListrContext = ListrContext, Config extends Ba
269
269
  private greet;
270
270
  }
271
271
 
272
- declare enum FileConstants {
273
- CONFIG_SERVICE_DEFAULTS_DIR = "defaults"
274
- }
275
-
276
272
  declare type ConfigCommandChoices<T extends string> = Record<T, () => void | Promise<void>>;
277
273
  interface ConfigCommandSetup<T extends string> {
278
274
  choices: ConfigCommandChoices<T>;
279
275
  locker: LockerService;
280
276
  }
281
277
 
282
- export { BaseConfig, ClassType, Command, CommonLockerData, ConfigCommandChoices, ConfigCommandSetup, ConfigService, FileConstants, FileSystemService, GenericParser, LockData, LockableData, LockerService, LogFieldStatus, LogLevels, Logger, LoggerFormat, LoggerOptions, MergeStrategy, PipeProcessToLoggerOptions, UnlockData, ValidatorService, ValidatorServiceOptions, WINSTON_INSTANCE, Winston, YamlParser, color, isDebug, isSilent, isVerbose, merge, pipeProcessThroughListr, pipeProcessToLogger, setup };
278
+ declare abstract class ConfigCommand<CommandChoices extends string, Ctx extends ListrContext = ListrContext, Config extends BaseConfig = BaseConfig> extends Command<Ctx, Config> {
279
+ choices: ConfigCommandChoices<CommandChoices>;
280
+ locker: LockerService;
281
+ run(): Promise<void>;
282
+ private generate;
283
+ abstract setup(): ConfigCommandSetup<CommandChoices> | Promise<ConfigCommandSetup<CommandChoices>>;
284
+ }
285
+
286
+ declare enum FileConstants {
287
+ CONFIG_SERVICE_DEFAULTS_DIR = "defaults"
288
+ }
289
+
290
+ export { BaseConfig, ClassType, Command, CommonLockerData, ConfigCommand, ConfigCommandChoices, ConfigCommandSetup, ConfigService, FileConstants, FileSystemService, GenericParser, LockData, LockableData, LockerService, LogFieldStatus, LogLevels, Logger, LoggerFormat, LoggerOptions, MergeStrategy, PipeProcessToLoggerOptions, UnlockData, ValidatorService, ValidatorServiceOptions, WINSTON_INSTANCE, Winston, YamlParser, color, isDebug, isSilent, isVerbose, merge, pipeProcessThroughListr, pipeProcessToLogger, setup };
package/dist/index.js CHANGED
@@ -4,6 +4,7 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
5
5
  var __getProtoOf = Object.getPrototypeOf;
6
6
  var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
7
8
  var __esm = (fn, res) => function __init() {
8
9
  return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
9
10
  };
@@ -42,6 +43,7 @@ var import_through;
42
43
  var init_pipe_process_to_listr = __esm({
43
44
  "src/utils/logger/pipe/pipe-process-to-listr.ts"() {
44
45
  import_through = __toESM(require("through"));
46
+ __name(pipeProcessThroughListr, "pipeProcessThroughListr");
45
47
  }
46
48
  });
47
49
 
@@ -119,6 +121,7 @@ var init_pipe_process_to_logger = __esm({
119
121
  "src/utils/logger/pipe/pipe-process-to-logger.ts"() {
120
122
  import_through2 = __toESM(require("through"));
121
123
  init_logger_constants();
124
+ __name(pipeProcessToLogger, "pipeProcessToLogger");
122
125
  }
123
126
  });
124
127
 
@@ -261,17 +264,17 @@ var init_logger = __esm({
261
264
  }
262
265
  logColoring({ level, message, context, status }) {
263
266
  let icon;
264
- let coloring = (input) => {
267
+ let coloring = /* @__PURE__ */ __name((input) => {
265
268
  return input;
266
- };
267
- let msgColoring = (input) => {
269
+ }, "coloring");
270
+ let msgColoring = /* @__PURE__ */ __name((input) => {
268
271
  return input;
269
- };
272
+ }, "msgColoring");
270
273
  switch (level) {
271
274
  case "DIRECT" /* DIRECT */:
272
275
  return message;
273
276
  case "FATAL" /* FATAL */:
274
- coloring = (input) => color.bgRed(color.white(input));
277
+ coloring = /* @__PURE__ */ __name((input) => color.bgRed(color.white(input)), "coloring");
275
278
  if (this.options?.useIcons) {
276
279
  icon = import_figures.default.cross;
277
280
  }
@@ -321,6 +324,7 @@ var init_logger = __esm({
321
324
  return `${coloring(icon)}${context ? " " + coloring(`[${context}]`) : ""}${status ? " " + coloring(`[${status}]`) : ""} ${msgColoring(message)}`;
322
325
  }
323
326
  };
327
+ __name(Logger, "Logger");
324
328
  }
325
329
  });
326
330
 
@@ -369,6 +373,7 @@ var require_config_interface = __commonJS({
369
373
  var logger_1 = (init_logger2(), __toCommonJS(logger_exports));
370
374
  var BaseConfig2 = class {
371
375
  };
376
+ __name(BaseConfig2, "BaseConfig");
372
377
  __decorate([
373
378
  (0, class_transformer_1.Transform)((p) => p.value.toUpperCase()),
374
379
  (0, class_validator_1.IsEnum)(logger_1.LogLevels),
@@ -382,6 +387,7 @@ var require_config_interface = __commonJS({
382
387
  var src_exports = {};
383
388
  __export(src_exports, {
384
389
  Command: () => Command,
390
+ ConfigCommand: () => ConfigCommand,
385
391
  ConfigService: () => ConfigService,
386
392
  FileConstants: () => FileConstants,
387
393
  FileSystemService: () => FileSystemService,
@@ -394,7 +400,7 @@ __export(src_exports, {
394
400
  WINSTON_INSTANCE: () => WINSTON_INSTANCE,
395
401
  YamlParser: () => YamlParser,
396
402
  color: () => color,
397
- config: () => import_config.default,
403
+ config: () => import_config.util,
398
404
  figures: () => import_figures.default,
399
405
  fs: () => import_fs_extra.default,
400
406
  isDebug: () => isDebug,
@@ -423,7 +429,7 @@ __export(lib_exports, {
423
429
  LockerService: () => LockerService,
424
430
  ValidatorService: () => ValidatorService,
425
431
  YamlParser: () => YamlParser,
426
- config: () => import_config.default,
432
+ config: () => import_config.util,
427
433
  fs: () => import_fs_extra.default,
428
434
  setup: () => setup
429
435
  });
@@ -432,12 +438,12 @@ __export(lib_exports, {
432
438
  var config_exports = {};
433
439
  __export(config_exports, {
434
440
  ConfigService: () => ConfigService,
435
- config: () => import_config.default
441
+ config: () => import_config.util
436
442
  });
437
443
  __reExport(config_exports, __toESM(require_config_interface()));
438
444
 
439
445
  // src/lib/config/config.service.ts
440
- var import_config = __toESM(require("config"));
446
+ var import_config = require("config");
441
447
  var import_path2 = require("path");
442
448
 
443
449
  // src/constants/file.constants.ts
@@ -472,6 +478,7 @@ var _YamlParser = class {
472
478
  }
473
479
  };
474
480
  var YamlParser = _YamlParser;
481
+ __name(YamlParser, "YamlParser");
475
482
  YamlParser.extensions = ["yaml", "yml"];
476
483
 
477
484
  // src/lib/fs/filesystem.service.ts
@@ -587,6 +594,7 @@ var FileSystemService = class {
587
594
  }
588
595
  }
589
596
  };
597
+ __name(FileSystemService, "FileSystemService");
590
598
 
591
599
  // src/lib/parser/parser.service.ts
592
600
  init_logger2();
@@ -628,6 +636,7 @@ var _ParserService = class {
628
636
  }
629
637
  };
630
638
  var ParserService = _ParserService;
639
+ __name(ParserService, "ParserService");
631
640
  ParserService.extensions = [];
632
641
 
633
642
  // src/utils/index.ts
@@ -639,12 +648,15 @@ init_logger2();
639
648
  function isVerbose(config2) {
640
649
  return config2.loglevel === "VERBOSE" /* VERBOSE */;
641
650
  }
651
+ __name(isVerbose, "isVerbose");
642
652
  function isDebug(config2) {
643
653
  return ["DEBUG" /* DEBUG */, "TRACE" /* TRACE */].includes(config2.loglevel);
644
654
  }
655
+ __name(isDebug, "isDebug");
645
656
  function isSilent(config2) {
646
657
  return config2.loglevel === "SILENT" /* SILENT */;
647
658
  }
659
+ __name(isSilent, "isSilent");
648
660
 
649
661
  // src/utils/index.ts
650
662
  init_figures();
@@ -665,6 +677,7 @@ function merge(strategy, target, ...source) {
665
677
  });
666
678
  }, target);
667
679
  }
680
+ __name(merge, "merge");
668
681
 
669
682
  // src/lib/config/config.service.ts
670
683
  init_logger2();
@@ -679,7 +692,7 @@ var ConfigService = class {
679
692
  }
680
693
  this.command = command.ctor;
681
694
  this.oclif = command.config;
682
- this.config = import_config.default.util.loadFileConfigs(this.dir);
695
+ this.config = import_config.util.loadFileConfigs(this.dir);
683
696
  this.logger = new Logger(this.constructor.name, { level: this.config.loglevel });
684
697
  this.parser = new ParserService();
685
698
  this.logger.trace("Created a new instance.");
@@ -696,6 +709,7 @@ var ConfigService = class {
696
709
  return this.parser.write(path, data);
697
710
  }
698
711
  };
712
+ __name(ConfigService, "ConfigService");
699
713
 
700
714
  // src/lib/index.ts
701
715
  __reExport(lib_exports, config_exports);
@@ -807,6 +821,7 @@ var LockerService = class {
807
821
  return d.path;
808
822
  }
809
823
  };
824
+ __name(LockerService, "LockerService");
810
825
 
811
826
  // src/lib/validator/validator.service.ts
812
827
  var import_class_transformer = require("class-transformer");
@@ -853,6 +868,7 @@ var ValidatorService = class {
853
868
  this.logger.error('Field "%s" failed validation with value "%s": %s', err.property, err.value, Object.values(err.constraints).join(", "));
854
869
  }
855
870
  };
871
+ __name(ValidatorService, "ValidatorService");
856
872
 
857
873
  // src/lib/setup.ts
858
874
  function setup() {
@@ -888,6 +904,7 @@ function setup() {
888
904
  process.argv.splice(sourceMaps, 1);
889
905
  }
890
906
  }
907
+ __name(setup, "setup");
891
908
 
892
909
  // src/commands/base.command.ts
893
910
  var import_config2 = __toESM(require_config_interface());
@@ -976,30 +993,51 @@ var Command = class extends import_core.Command {
976
993
  this.logger.direct("-".repeat(logo.length));
977
994
  }
978
995
  };
996
+ __name(Command, "Command");
997
+
998
+ // src/commands/config.command.ts
999
+ var ConfigCommand = class extends Command {
1000
+ async run() {
1001
+ const setup2 = await this.setup();
1002
+ this.choices = setup2.choices;
1003
+ this.locker = setup2.locker;
1004
+ await this.generate();
1005
+ }
1006
+ async generate() {
1007
+ const response = await this.prompt({
1008
+ type: "Select",
1009
+ message: "Please select what to do with the configuration.",
1010
+ choices: Object.keys(this.choices)
1011
+ });
1012
+ return this.choices[response]();
1013
+ }
1014
+ };
1015
+ __name(ConfigCommand, "ConfigCommand");
979
1016
 
980
1017
  // src/hooks/not-found.hook.ts
981
1018
  var import_core2 = require("@oclif/core");
982
1019
  init_logger2();
983
- var notFoundHook = async (opts) => {
1020
+ var notFoundHook = /* @__PURE__ */ __name(async (opts) => {
984
1021
  const logger = new Logger(opts.config.name);
985
1022
  logger.fatal("Command not found. Take a look at help. You can also use --[h]elp flag for subcommands.", { custom: opts.config.name });
986
1023
  logger.direct("");
987
1024
  const help = new import_core2.Help(opts.config);
988
1025
  await help.showHelp(["--all"]);
989
1026
  process.exit(127);
990
- };
1027
+ }, "notFoundHook");
991
1028
 
992
1029
  // src/hooks/update-notifier.hook.ts
993
1030
  var import_update_notifier = __toESM(require("update-notifier"));
994
- var updateNotifierHook = async (opts) => {
1031
+ var updateNotifierHook = /* @__PURE__ */ __name(async (opts) => {
995
1032
  (0, import_update_notifier.default)({ pkg: { name: opts.config.name, version: opts.config.version } }).notify({ isGlobal: true });
996
- };
1033
+ }, "updateNotifierHook");
997
1034
 
998
1035
  // src/index.ts
999
1036
  __reExport(src_exports, lib_exports, module.exports);
1000
1037
  // Annotate the CommonJS export names for ESM import in node:
1001
1038
  0 && (module.exports = {
1002
1039
  Command,
1040
+ ConfigCommand,
1003
1041
  ConfigService,
1004
1042
  FileConstants,
1005
1043
  FileSystemService,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cenk1cenk2/oclif-common",
3
- "version": "1.9.0",
3
+ "version": "1.10.0",
4
4
  "description": "Oclif common package for oclif2 projects.",
5
5
  "repository": "https://gitlab.kilic.dev/libraries/oclif-tools",
6
6
  "author": {