@cenk1cenk2/oclif-common 3.5.1 → 3.5.3

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.
@@ -113,6 +113,9 @@ var Logger = class {
113
113
  end(data, ...args) {
114
114
  return this.parseMessage("INFO" /* INFO */, data, args, { status: "END" /* END */ });
115
115
  }
116
+ stage(data, ...args) {
117
+ return this.parseMessage("TRACE" /* TRACE */, data, args, { status: "STAGE" /* STAGE */ });
118
+ }
116
119
  initiateLogger() {
117
120
  const logFormat = import_winston.format.printf(({ level, message, context, status }) => {
118
121
  let multiLineMessage;
@@ -109,6 +109,9 @@ var Logger = class {
109
109
  end(data, ...args) {
110
110
  return this.parseMessage("INFO" /* INFO */, data, args, { status: "END" /* END */ });
111
111
  }
112
+ stage(data, ...args) {
113
+ return this.parseMessage("TRACE" /* TRACE */, data, args, { status: "STAGE" /* STAGE */ });
114
+ }
112
115
  initiateLogger() {
113
116
  const logFormat = import_winston.format.printf(({ level, message, context, status }) => {
114
117
  let multiLineMessage;
@@ -115,6 +115,9 @@ var Logger = class {
115
115
  end(data, ...args) {
116
116
  return this.parseMessage("INFO" /* INFO */, data, args, { status: "END" /* END */ });
117
117
  }
118
+ stage(data, ...args) {
119
+ return this.parseMessage("TRACE" /* TRACE */, data, args, { status: "STAGE" /* STAGE */ });
120
+ }
118
121
  initiateLogger() {
119
122
  const logFormat = import_winston.format.printf(({ level, message, context, status }) => {
120
123
  let multiLineMessage;
package/dist/index.d.ts CHANGED
@@ -10,6 +10,13 @@ import { ClassTransformOptions } from 'class-transformer';
10
10
  import { ValidatorOptions } from 'class-validator';
11
11
  import { InferredFlags, FlagInput } from '@oclif/core/lib/interfaces';
12
12
  export { Arg, ArgInput, Flag, FlagInput, InferredFlags } from '@oclif/core/lib/interfaces';
13
+ import * as _oclif_core_lib_cli_ux_styled_progress from '@oclif/core/lib/cli-ux/styled/progress';
14
+ import * as _oclif_core_lib_cli_ux_open from '@oclif/core/lib/cli-ux/open';
15
+ import * as _oclif_core_lib_cli_ux_styled_tree from '@oclif/core/lib/cli-ux/styled/tree';
16
+ import * as _oclif_core_lib_cli_ux_styled_json from '@oclif/core/lib/cli-ux/styled/json';
17
+ import * as _oclif_core_lib_cli_ux_styled_header from '@oclif/core/lib/cli-ux/styled/header';
18
+ import * as _oclif_core_lib_cli_ux_prompt from '@oclif/core/lib/cli-ux/prompt';
19
+ import * as _oclif_core_lib_errors from '@oclif/core/lib/errors';
13
20
  export { notFoundHook } from './hooks/not-found.hook.js';
14
21
  export { updateNotifierHook } from './hooks/update-notifier.hook.js';
15
22
  import { ExecaChildProcess } from 'execa';
@@ -30,7 +37,10 @@ declare enum LogLevels {
30
37
  }
31
38
  declare enum LogFieldStatus {
32
39
  RUN = "RUN",
33
- END = "END"
40
+ END = "END",
41
+ STAGE = "STAGE",
42
+ EXIT = "EXIT",
43
+ TERMINATE = "TERMINATE"
34
44
  }
35
45
 
36
46
  interface LoggerOptions {
@@ -65,6 +75,7 @@ declare class Logger {
65
75
  trace(data: string | Buffer, ...args: any): void;
66
76
  run(data: string | Buffer, ...args: any): void;
67
77
  end(data: string | Buffer, ...args: any): void;
78
+ stage(data: string | Buffer, ...args: any): void;
68
79
  private initiateLogger;
69
80
  private parseMessage;
70
81
  private logColoring;
@@ -298,7 +309,7 @@ declare type DeepPartial<T> = {
298
309
  };
299
310
 
300
311
  declare class Command<Ctx extends ListrContext = ListrContext, Flags extends Record<PropertyKey, any> = InferFlags<typeof Command>, Args extends Record<PropertyKey, any> = InferArgs<typeof Command>, Store extends Record<PropertyKey, any> = Record<PropertyKey, any>> extends Command$1 {
301
- static globalFlags: FlagInput;
312
+ static globalFlags: object;
302
313
  logger: Logger;
303
314
  tasks: Manager<Ctx, 'default' | 'verbose' | 'silent' | 'simple'>;
304
315
  validator: ValidatorService;
@@ -336,13 +347,40 @@ declare class Command<Ctx extends ListrContext = ListrContext, Flags extends Rec
336
347
  }
337
348
 
338
349
  declare class ConfigCommand<CommandChoices extends string = string, LockFile = any, Ctx extends ListrContext = ListrContext, Flags extends Record<PropertyKey, any> = InferFlags<typeof ConfigCommand>, Args extends Record<PropertyKey, any> = InferArgs<typeof ConfigCommand>, Store extends Record<PropertyKey, any> = Record<PropertyKey, any>> extends Command<Ctx, Flags, Args, Store> {
339
- static globalFlags: FlagInput;
350
+ static globalFlags: object;
340
351
  choices: ConfigCommandChoices<CommandChoices>;
341
352
  locker: LockerService<LockFile>;
353
+ protected ux: {
354
+ config: CliUx.Config;
355
+ warn: typeof _oclif_core_lib_errors.warn;
356
+ error: typeof _oclif_core_lib_errors.error;
357
+ exit: typeof _oclif_core_lib_errors.exit;
358
+ readonly prompt: typeof _oclif_core_lib_cli_ux_prompt.prompt;
359
+ readonly anykey: typeof _oclif_core_lib_cli_ux_prompt.anykey;
360
+ readonly confirm: typeof _oclif_core_lib_cli_ux_prompt.confirm;
361
+ readonly action: CliUx.ActionBase;
362
+ readonly prideAction: CliUx.ActionBase;
363
+ styledObject(obj: any, keys?: string[]): void;
364
+ readonly styledHeader: typeof _oclif_core_lib_cli_ux_styled_header.default;
365
+ readonly styledJSON: typeof _oclif_core_lib_cli_ux_styled_json.default;
366
+ readonly table: typeof CliUx.Table.table;
367
+ readonly tree: typeof _oclif_core_lib_cli_ux_styled_tree.default;
368
+ readonly open: typeof _oclif_core_lib_cli_ux_open.default;
369
+ readonly wait: (ms?: number) => Promise<unknown>;
370
+ readonly progress: typeof _oclif_core_lib_cli_ux_styled_progress.default;
371
+ done(): Promise<void>;
372
+ trace(format: string, ...args: string[]): void;
373
+ debug(format: string, ...args: string[]): void;
374
+ info(format: string, ...args: string[]): void;
375
+ log(format?: string, ...args: string[]): void;
376
+ url(text: string, uri: string, params?: {}): void;
377
+ annotation(text: string, annotation: string): void;
378
+ flush(ms?: number): Promise<void>;
379
+ };
342
380
  run(): Promise<void>;
343
381
  setup(): ConfigCommandSetup<CommandChoices, LockFile> | Promise<ConfigCommandSetup<CommandChoices, LockFile>>;
344
382
  protected table(...options: Parameters<typeof CliUx.ux.table>): void;
345
- private generate;
383
+ protected select(): Promise<string>;
346
384
  }
347
385
 
348
386
  declare enum FileConstants {
package/dist/index.js CHANGED
@@ -108,6 +108,9 @@ var LogLevels = /* @__PURE__ */ ((LogLevels2) => {
108
108
  var LogFieldStatus = /* @__PURE__ */ ((LogFieldStatus2) => {
109
109
  LogFieldStatus2["RUN"] = "RUN";
110
110
  LogFieldStatus2["END"] = "END";
111
+ LogFieldStatus2["STAGE"] = "STAGE";
112
+ LogFieldStatus2["EXIT"] = "EXIT";
113
+ LogFieldStatus2["TERMINATE"] = "TERMINATE";
111
114
  return LogFieldStatus2;
112
115
  })(LogFieldStatus || {});
113
116
 
@@ -167,6 +170,9 @@ var Logger = class {
167
170
  end(data, ...args) {
168
171
  return this.parseMessage("INFO" /* INFO */, data, args, { status: "END" /* END */ });
169
172
  }
173
+ stage(data, ...args) {
174
+ return this.parseMessage("TRACE" /* TRACE */, data, args, { status: "STAGE" /* STAGE */ });
175
+ }
170
176
  initiateLogger() {
171
177
  const logFormat = import_winston.format.printf(({ level, message, context, status }) => {
172
178
  let multiLineMessage;
@@ -1049,7 +1055,7 @@ var Command = class extends import_core3.Command {
1049
1055
  if (err) {
1050
1056
  throw err;
1051
1057
  }
1052
- this.logger.trace("init", { status: "stage" });
1058
+ this.logger.stage("Initiating services.");
1053
1059
  this.parser = new ParserService();
1054
1060
  this.fs = new FileSystemService();
1055
1061
  this.validator = new ValidatorService();
@@ -1073,24 +1079,27 @@ var Command = class extends import_core3.Command {
1073
1079
  });
1074
1080
  }
1075
1081
  process.on("SIGINT", () => {
1076
- this.logger.fatal("Caught terminate signal.", { context: "exit" });
1082
+ this.logger.fatal("Caught terminate signal.", { status: "TERMINATE" /* TERMINATE */ });
1077
1083
  process.exit(1);
1078
1084
  });
1079
- this.logger.trace("should run before", { status: "stage" });
1085
+ this.logger.stage("Running shouldRunBefore.");
1080
1086
  await this.shouldRunBefore();
1087
+ this.logger.stage("Finished shouldRunBefore.");
1081
1088
  }
1082
1089
  shouldRunBefore() {
1083
1090
  }
1084
1091
  shouldRunAfter(_ctx) {
1085
1092
  }
1086
1093
  run() {
1087
- return;
1094
+ throw new Error("The command should have a run function to do something!");
1088
1095
  }
1089
1096
  async finally() {
1090
- this.logger.trace("tasks", { status: "stage" });
1097
+ this.logger.stage("Running tasks.");
1091
1098
  const ctx = await this.runTasks();
1092
- this.logger.trace("should run after", { status: "stage" });
1099
+ this.logger.stage("Finished tasks.");
1100
+ this.logger.stage("Running shouldRunAfter.");
1093
1101
  await this.shouldRunAfter(ctx);
1102
+ this.logger.stage("Finished shouldRunAfter.");
1094
1103
  return { ctx };
1095
1104
  }
1096
1105
  catch(e) {
@@ -1100,7 +1109,7 @@ var Command = class extends import_core3.Command {
1100
1109
  return;
1101
1110
  }
1102
1111
  exit(code) {
1103
- this.logger.trace("Exitting with code: %d", code);
1112
+ this.logger.trace("Code -> %d", code, { status: "EXIT" /* EXIT */ });
1104
1113
  process.exit(code ?? 0);
1105
1114
  }
1106
1115
  runTasks() {
@@ -1138,25 +1147,33 @@ Command.globalFlags = CLI_FLAGS;
1138
1147
 
1139
1148
  // src/commands/config.command.ts
1140
1149
  var ConfigCommand = class extends Command {
1150
+ constructor() {
1151
+ super(...arguments);
1152
+ this.ux = import_core2.CliUx.ux;
1153
+ }
1141
1154
  async run() {
1155
+ this.logger.stage("Setting up config command.");
1142
1156
  const setup2 = await this.setup();
1143
1157
  this.choices = setup2.choices;
1144
1158
  this.locker = setup2.locker;
1145
- await this.generate();
1159
+ this.logger.stage("User selection for configuration.");
1160
+ const response = await this.select();
1161
+ this.logger.stage("Will run selection: %s", response);
1162
+ return this.choices[response]();
1146
1163
  }
1147
1164
  setup() {
1148
1165
  throw new Error("The command should be setup first!");
1149
1166
  }
1150
1167
  table(...options) {
1151
- import_core2.CliUx.ux.table(...options);
1168
+ this.ux.table(...options);
1152
1169
  }
1153
- async generate() {
1170
+ async select() {
1154
1171
  const response = await this.prompt({
1155
1172
  type: "Select",
1156
1173
  message: "Please select what to do with the configuration.",
1157
1174
  choices: Object.keys(this.choices)
1158
1175
  });
1159
- return this.choices[response].bind(this)();
1176
+ return response;
1160
1177
  }
1161
1178
  };
1162
1179
  __name(ConfigCommand, "ConfigCommand");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cenk1cenk2/oclif-common",
3
- "version": "3.5.1",
3
+ "version": "3.5.3",
4
4
  "description": "Oclif common package for oclif2 projects.",
5
5
  "repository": "https://gitlab.kilic.dev/libraries/oclif-tools",
6
6
  "author": {