@cenk1cenk2/oclif-common 3.1.1 → 3.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/hooks/index.js +15 -9
- package/dist/hooks/not-found.hook.js +12 -9
- package/dist/hooks/store.hook.js +15 -9
- package/dist/index.d.ts +29 -53
- package/dist/index.js +142 -99
- package/package.json +5 -4
package/dist/hooks/index.js
CHANGED
|
@@ -35,11 +35,13 @@ module.exports = __toCommonJS(hooks_exports);
|
|
|
35
35
|
// src/hooks/not-found.hook.ts
|
|
36
36
|
var import_core = require("@oclif/core");
|
|
37
37
|
|
|
38
|
-
// src/utils/logger/
|
|
39
|
-
var
|
|
38
|
+
// src/utils/logger/listr-logger.ts
|
|
39
|
+
var import_listr22 = require("listr2");
|
|
40
40
|
|
|
41
|
-
// src/utils/logger/
|
|
42
|
-
var
|
|
41
|
+
// src/utils/logger/logger.ts
|
|
42
|
+
var import_listr2 = require("listr2");
|
|
43
|
+
var import_os = require("os");
|
|
44
|
+
var import_winston = __toESM(require("winston"));
|
|
43
45
|
|
|
44
46
|
// src/utils/logger/logger.constants.ts
|
|
45
47
|
var LogLevels = /* @__PURE__ */ ((LogLevels2) => {
|
|
@@ -55,11 +57,6 @@ var LogLevels = /* @__PURE__ */ ((LogLevels2) => {
|
|
|
55
57
|
return LogLevels2;
|
|
56
58
|
})(LogLevels || {});
|
|
57
59
|
|
|
58
|
-
// src/utils/logger/logger.ts
|
|
59
|
-
var import_listr2 = require("listr2");
|
|
60
|
-
var import_os = require("os");
|
|
61
|
-
var import_winston = __toESM(require("winston"));
|
|
62
|
-
|
|
63
60
|
// src/utils/color.ts
|
|
64
61
|
var colorette = __toESM(require("colorette"));
|
|
65
62
|
var color = colorette.createColors({ useColor: true });
|
|
@@ -216,6 +213,12 @@ var Logger = class {
|
|
|
216
213
|
};
|
|
217
214
|
__name(Logger, "Logger");
|
|
218
215
|
|
|
216
|
+
// src/utils/logger/pipe/pipe-process-to-listr.ts
|
|
217
|
+
var import_through = __toESM(require("through"));
|
|
218
|
+
|
|
219
|
+
// src/utils/logger/pipe/pipe-process-to-logger.ts
|
|
220
|
+
var import_through2 = __toESM(require("through"));
|
|
221
|
+
|
|
219
222
|
// src/hooks/not-found.hook.ts
|
|
220
223
|
var notFoundHook = /* @__PURE__ */ __name(async (opts) => {
|
|
221
224
|
const logger = new Logger(opts.config.name);
|
|
@@ -298,6 +301,9 @@ var import_path = require("path");
|
|
|
298
301
|
// src/utils/merge.ts
|
|
299
302
|
var import_deepmerge = __toESM(require("deepmerge"));
|
|
300
303
|
|
|
304
|
+
// src/utils/index.ts
|
|
305
|
+
var import_core2 = require("@oclif/core");
|
|
306
|
+
|
|
301
307
|
// src/lib/locker/locker.service.ts
|
|
302
308
|
var import_object_path_immutable2 = __toESM(require("object-path-immutable"));
|
|
303
309
|
|
|
@@ -31,11 +31,13 @@ __export(not_found_hook_exports, {
|
|
|
31
31
|
module.exports = __toCommonJS(not_found_hook_exports);
|
|
32
32
|
var import_core = require("@oclif/core");
|
|
33
33
|
|
|
34
|
-
// src/utils/logger/
|
|
35
|
-
var
|
|
34
|
+
// src/utils/logger/listr-logger.ts
|
|
35
|
+
var import_listr22 = require("listr2");
|
|
36
36
|
|
|
37
|
-
// src/utils/logger/
|
|
38
|
-
var
|
|
37
|
+
// src/utils/logger/logger.ts
|
|
38
|
+
var import_listr2 = require("listr2");
|
|
39
|
+
var import_os = require("os");
|
|
40
|
+
var import_winston = __toESM(require("winston"));
|
|
39
41
|
|
|
40
42
|
// src/utils/logger/logger.constants.ts
|
|
41
43
|
var LogLevels = /* @__PURE__ */ ((LogLevels2) => {
|
|
@@ -51,11 +53,6 @@ var LogLevels = /* @__PURE__ */ ((LogLevels2) => {
|
|
|
51
53
|
return LogLevels2;
|
|
52
54
|
})(LogLevels || {});
|
|
53
55
|
|
|
54
|
-
// src/utils/logger/logger.ts
|
|
55
|
-
var import_listr2 = require("listr2");
|
|
56
|
-
var import_os = require("os");
|
|
57
|
-
var import_winston = __toESM(require("winston"));
|
|
58
|
-
|
|
59
56
|
// src/utils/color.ts
|
|
60
57
|
var colorette = __toESM(require("colorette"));
|
|
61
58
|
var color = colorette.createColors({ useColor: true });
|
|
@@ -212,6 +209,12 @@ var Logger = class {
|
|
|
212
209
|
};
|
|
213
210
|
__name(Logger, "Logger");
|
|
214
211
|
|
|
212
|
+
// src/utils/logger/pipe/pipe-process-to-listr.ts
|
|
213
|
+
var import_through = __toESM(require("through"));
|
|
214
|
+
|
|
215
|
+
// src/utils/logger/pipe/pipe-process-to-logger.ts
|
|
216
|
+
var import_through2 = __toESM(require("through"));
|
|
217
|
+
|
|
215
218
|
// src/hooks/not-found.hook.ts
|
|
216
219
|
var notFoundHook = /* @__PURE__ */ __name(async (opts) => {
|
|
217
220
|
const logger = new Logger(opts.config.name);
|
package/dist/hooks/store.hook.js
CHANGED
|
@@ -34,11 +34,13 @@ module.exports = __toCommonJS(store_hook_exports);
|
|
|
34
34
|
var import_object_path_immutable = __toESM(require("object-path-immutable"));
|
|
35
35
|
var import_path2 = require("path");
|
|
36
36
|
|
|
37
|
-
// src/utils/logger/
|
|
38
|
-
var
|
|
37
|
+
// src/utils/logger/listr-logger.ts
|
|
38
|
+
var import_listr22 = require("listr2");
|
|
39
39
|
|
|
40
|
-
// src/utils/logger/
|
|
41
|
-
var
|
|
40
|
+
// src/utils/logger/logger.ts
|
|
41
|
+
var import_listr2 = require("listr2");
|
|
42
|
+
var import_os = require("os");
|
|
43
|
+
var import_winston = __toESM(require("winston"));
|
|
42
44
|
|
|
43
45
|
// src/utils/logger/logger.constants.ts
|
|
44
46
|
var LogLevels = /* @__PURE__ */ ((LogLevels2) => {
|
|
@@ -54,11 +56,6 @@ var LogLevels = /* @__PURE__ */ ((LogLevels2) => {
|
|
|
54
56
|
return LogLevels2;
|
|
55
57
|
})(LogLevels || {});
|
|
56
58
|
|
|
57
|
-
// src/utils/logger/logger.ts
|
|
58
|
-
var import_listr2 = require("listr2");
|
|
59
|
-
var import_os = require("os");
|
|
60
|
-
var import_winston = __toESM(require("winston"));
|
|
61
|
-
|
|
62
59
|
// src/utils/color.ts
|
|
63
60
|
var colorette = __toESM(require("colorette"));
|
|
64
61
|
var color = colorette.createColors({ useColor: true });
|
|
@@ -215,6 +212,12 @@ var Logger = class {
|
|
|
215
212
|
};
|
|
216
213
|
__name(Logger, "Logger");
|
|
217
214
|
|
|
215
|
+
// src/utils/logger/pipe/pipe-process-to-listr.ts
|
|
216
|
+
var import_through = __toESM(require("through"));
|
|
217
|
+
|
|
218
|
+
// src/utils/logger/pipe/pipe-process-to-logger.ts
|
|
219
|
+
var import_through2 = __toESM(require("through"));
|
|
220
|
+
|
|
218
221
|
// src/lib/parser/json-parser.service.ts
|
|
219
222
|
var _JsonParser = class {
|
|
220
223
|
constructor() {
|
|
@@ -277,6 +280,9 @@ var import_path = require("path");
|
|
|
277
280
|
// src/utils/merge.ts
|
|
278
281
|
var import_deepmerge = __toESM(require("deepmerge"));
|
|
279
282
|
|
|
283
|
+
// src/utils/index.ts
|
|
284
|
+
var import_core = require("@oclif/core");
|
|
285
|
+
|
|
280
286
|
// src/lib/locker/locker.service.ts
|
|
281
287
|
var import_object_path_immutable2 = __toESM(require("object-path-immutable"));
|
|
282
288
|
|
package/dist/index.d.ts
CHANGED
|
@@ -1,16 +1,9 @@
|
|
|
1
|
-
import * as _oclif_core_lib_cli_ux_styled_progress from '@oclif/core/lib/cli-ux/styled/progress';
|
|
2
|
-
import * as _oclif_core_lib_cli_ux_open from '@oclif/core/lib/cli-ux/open';
|
|
3
|
-
import * as _oclif_core_lib_cli_ux_styled_tree from '@oclif/core/lib/cli-ux/styled/tree';
|
|
4
|
-
import * as _oclif_core_lib_cli_ux_styled_json from '@oclif/core/lib/cli-ux/styled/json';
|
|
5
|
-
import * as _oclif_core_lib_cli_ux_styled_header from '@oclif/core/lib/cli-ux/styled/header';
|
|
6
|
-
import * as _oclif_core_lib_cli_ux_prompt from '@oclif/core/lib/cli-ux/prompt';
|
|
7
|
-
import * as _oclif_core_lib_errors from '@oclif/core/lib/errors';
|
|
8
|
-
import { Command as Command$1, CliUx } from '@oclif/core';
|
|
9
|
-
export { Flags } from '@oclif/core';
|
|
10
1
|
import * as _oclif_core_lib_interfaces from '@oclif/core/lib/interfaces';
|
|
11
2
|
import { InferredFlags, ArgInput } from '@oclif/core/lib/interfaces';
|
|
12
3
|
export { Arg, ArgInput, Flag, FlagInput, InferredFlags } from '@oclif/core/lib/interfaces';
|
|
13
|
-
import {
|
|
4
|
+
import { Command as Command$1, CliUx } from '@oclif/core';
|
|
5
|
+
export { CliUx, Flags } from '@oclif/core';
|
|
6
|
+
import { Logger as Logger$2, ListrTaskWrapper, ListrContext, Manager, PromptOptions } from 'listr2';
|
|
14
7
|
import { Logger as Logger$1, LeveledLogMethod } from 'winston';
|
|
15
8
|
import fs from 'fs-extra';
|
|
16
9
|
export { default as fs } from 'fs-extra';
|
|
@@ -25,8 +18,6 @@ import * as colorette from 'colorette';
|
|
|
25
18
|
|
|
26
19
|
declare type ClassType<T> = new (...args: any[]) => T;
|
|
27
20
|
|
|
28
|
-
declare function pipeProcessThroughListr(task: ListrTaskWrapper<any, any>, instance: ExecaChildProcess): ExecaChildProcess;
|
|
29
|
-
|
|
30
21
|
declare enum LogLevels {
|
|
31
22
|
SILENT = "SILENT",
|
|
32
23
|
DIRECT = "DIRECT",
|
|
@@ -80,6 +71,21 @@ declare class Logger {
|
|
|
80
71
|
private logColoring;
|
|
81
72
|
}
|
|
82
73
|
|
|
74
|
+
declare class ListrLogger extends Logger$2 {
|
|
75
|
+
logger: Logger;
|
|
76
|
+
constructor(context?: string);
|
|
77
|
+
fail(message: string): void;
|
|
78
|
+
skip(message: string): void;
|
|
79
|
+
success(message: string): void;
|
|
80
|
+
data(message: string): void;
|
|
81
|
+
start(message: string): void;
|
|
82
|
+
title(message: string): void;
|
|
83
|
+
retry(message: string): void;
|
|
84
|
+
rollback(message: string): void;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
declare function pipeProcessThroughListr(task: ListrTaskWrapper<any, any>, instance: ExecaChildProcess): ExecaChildProcess;
|
|
88
|
+
|
|
83
89
|
interface PipeProcessToLoggerOptions {
|
|
84
90
|
/** Will log the command when the process starts. */
|
|
85
91
|
start?: LogLevels;
|
|
@@ -277,7 +283,7 @@ declare function setup(): void;
|
|
|
277
283
|
declare type ConfigCommandChoices<T extends string> = Record<T, () => void | Promise<void>>;
|
|
278
284
|
interface ConfigCommandSetup<T extends string = string, LockFile = any> {
|
|
279
285
|
choices: ConfigCommandChoices<T>;
|
|
280
|
-
locker
|
|
286
|
+
locker?: LockerService<LockFile>;
|
|
281
287
|
}
|
|
282
288
|
|
|
283
289
|
declare type InferFlags<T extends typeof Command$1> = InferredFlags<T['globalFlags'] & T['flags']>;
|
|
@@ -290,14 +296,14 @@ declare type DeepPartial<T> = {
|
|
|
290
296
|
[P in keyof T]?: DeepPartial<T[P]>;
|
|
291
297
|
};
|
|
292
298
|
|
|
293
|
-
declare
|
|
299
|
+
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 {
|
|
294
300
|
static globalFlags: {
|
|
295
301
|
"log-level": _oclif_core_lib_interfaces.OptionFlag<string>;
|
|
296
302
|
ci: _oclif_core_lib_interfaces.BooleanFlag<boolean>;
|
|
297
303
|
};
|
|
298
304
|
static args: ArgInput;
|
|
299
305
|
logger: Logger;
|
|
300
|
-
tasks: Manager<Ctx, 'default'>;
|
|
306
|
+
tasks: Manager<Ctx, 'default' | 'verbose' | 'silent' | 'simple'>;
|
|
301
307
|
validator: ValidatorService;
|
|
302
308
|
cs: ConfigService;
|
|
303
309
|
parser: ParserService;
|
|
@@ -315,30 +321,30 @@ declare abstract class Command<Ctx extends ListrContext = ListrContext, Flags ex
|
|
|
315
321
|
* Deconstruct the class if you dont want to extend finally or catch.
|
|
316
322
|
*/
|
|
317
323
|
shouldRunAfter(_ctx?: Ctx): void | Promise<void>;
|
|
318
|
-
|
|
319
|
-
runTasks<C extends Ctx = Ctx>(): Promise<C>;
|
|
324
|
+
run(): Promise<void>;
|
|
320
325
|
/** Tasks to run before end of the command. */
|
|
321
326
|
finally<C extends Ctx = Ctx>(): Promise<{
|
|
322
327
|
ctx: C;
|
|
323
328
|
}>;
|
|
324
329
|
/** Catch any error occurred during command. */
|
|
325
330
|
catch(e: Error): Promise<void>;
|
|
331
|
+
exit(code?: number): void;
|
|
332
|
+
/** Run all tasks from task manager. */
|
|
333
|
+
runTasks<C extends Ctx = Ctx>(): Promise<C>;
|
|
326
334
|
/** Gets prompt from user. */
|
|
327
335
|
prompt<T = any>(options: PromptOptions): Promise<T>;
|
|
328
336
|
setCtxDefaults(...defaults: SetCtxDefaultsOptions<Ctx>[]): void;
|
|
329
337
|
setCtxAssign<K = Record<PropertyKey, any>>(...assigns: SetCtxAssignOptions<K>[]): void;
|
|
330
|
-
exit(code?: number): void;
|
|
331
338
|
private greet;
|
|
332
|
-
/** Every command needs to implement run for running the command itself. */
|
|
333
|
-
abstract run(): Promise<void>;
|
|
334
339
|
}
|
|
335
340
|
|
|
336
|
-
declare
|
|
341
|
+
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> {
|
|
337
342
|
choices: ConfigCommandChoices<CommandChoices>;
|
|
338
343
|
locker: LockerService<LockFile>;
|
|
339
344
|
run(): Promise<void>;
|
|
345
|
+
setup(): ConfigCommandSetup<CommandChoices, LockFile> | Promise<ConfigCommandSetup<CommandChoices, LockFile>>;
|
|
346
|
+
protected table(...options: Parameters<typeof CliUx.ux.table>): void;
|
|
340
347
|
private generate;
|
|
341
|
-
abstract setup(): ConfigCommandSetup<CommandChoices, LockFile> | Promise<ConfigCommandSetup<CommandChoices, LockFile>>;
|
|
342
348
|
}
|
|
343
349
|
|
|
344
350
|
declare enum FileConstants {
|
|
@@ -349,34 +355,4 @@ declare enum HelpGroups {
|
|
|
349
355
|
CLI = "CLI"
|
|
350
356
|
}
|
|
351
357
|
|
|
352
|
-
|
|
353
|
-
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
|
-
};
|
|
380
|
-
};
|
|
381
|
-
|
|
382
|
-
export { ClassType, Command, CommonLockerData, ConfigCommand, ConfigCommandChoices, ConfigCommandSetup, ConfigIterator, ConfigService, DeepPartial, FileConstants, FileSystemService, GenericParser, GlobalConfig, GlobalConfigInit, HelpGroups, InferArgs, InferFlags, JsonParser, LockData, LockableData, LockerService, LogFieldStatus, LogLevels, Logger, LoggerFormat, LoggerOptions, MergeStrategy, ParserService, PipeProcessToLoggerOptions, SetCtxAssignOptions, SetCtxDefaultsOptions, UnlockData, ValidatorService, ValidatorServiceOptions, Winston, YamlParser, color, _default as default, isDebug, isSilent, isVerbose, merge, pipeProcessThroughListr, pipeProcessToLogger, setCtxAssign, setCtxDefaults, setup };
|
|
358
|
+
export { ClassType, Command, CommonLockerData, ConfigCommand, ConfigCommandChoices, ConfigCommandSetup, ConfigIterator, ConfigService, DeepPartial, FileConstants, FileSystemService, GenericParser, GlobalConfig, GlobalConfigInit, HelpGroups, InferArgs, InferFlags, JsonParser, ListrLogger, LockData, LockableData, LockerService, LogFieldStatus, LogLevels, Logger, LoggerFormat, LoggerOptions, MergeStrategy, ParserService, PipeProcessToLoggerOptions, SetCtxAssignOptions, SetCtxDefaultsOptions, UnlockData, ValidatorService, ValidatorServiceOptions, Winston, YamlParser, color, isDebug, isSilent, isVerbose, merge, pipeProcessThroughListr, pipeProcessToLogger, setCtxAssign, setCtxDefaults, setup };
|
package/dist/index.js
CHANGED
|
@@ -26,14 +26,16 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
26
26
|
// src/index.ts
|
|
27
27
|
var src_exports = {};
|
|
28
28
|
__export(src_exports, {
|
|
29
|
+
CliUx: () => import_core.CliUx,
|
|
29
30
|
Command: () => Command,
|
|
30
31
|
ConfigCommand: () => ConfigCommand,
|
|
31
32
|
ConfigService: () => ConfigService,
|
|
32
33
|
FileConstants: () => FileConstants,
|
|
33
34
|
FileSystemService: () => FileSystemService,
|
|
34
|
-
Flags: () =>
|
|
35
|
+
Flags: () => import_core4.Flags,
|
|
35
36
|
HelpGroups: () => HelpGroups,
|
|
36
37
|
JsonParser: () => JsonParser,
|
|
38
|
+
ListrLogger: () => ListrLogger,
|
|
37
39
|
LockerService: () => LockerService,
|
|
38
40
|
LogFieldStatus: () => LogFieldStatus,
|
|
39
41
|
LogLevels: () => LogLevels,
|
|
@@ -44,7 +46,6 @@ __export(src_exports, {
|
|
|
44
46
|
ValidatorService: () => ValidatorService,
|
|
45
47
|
YamlParser: () => YamlParser,
|
|
46
48
|
color: () => color,
|
|
47
|
-
default: () => src_default,
|
|
48
49
|
fs: () => import_fs_extra.default,
|
|
49
50
|
isDebug: () => isDebug,
|
|
50
51
|
isSilent: () => isSilent,
|
|
@@ -60,11 +61,10 @@ __export(src_exports, {
|
|
|
60
61
|
updateNotifierHook: () => updateNotifierHook
|
|
61
62
|
});
|
|
62
63
|
module.exports = __toCommonJS(src_exports);
|
|
63
|
-
var import_core4 = require("@oclif/core");
|
|
64
64
|
|
|
65
65
|
// src/commands/base.command.ts
|
|
66
|
-
var
|
|
67
|
-
var
|
|
66
|
+
var import_core2 = require("@oclif/core");
|
|
67
|
+
var import_listr23 = require("listr2");
|
|
68
68
|
var import_readline = require("readline");
|
|
69
69
|
var import_reflect_metadata = require("reflect-metadata");
|
|
70
70
|
|
|
@@ -84,20 +84,13 @@ var HelpGroups = /* @__PURE__ */ ((HelpGroups2) => {
|
|
|
84
84
|
var import_object_path_immutable = __toESM(require("object-path-immutable"));
|
|
85
85
|
var import_path2 = require("path");
|
|
86
86
|
|
|
87
|
-
// src/utils/logger/
|
|
88
|
-
var
|
|
89
|
-
function pipeProcessThroughListr(task, instance) {
|
|
90
|
-
const logOut = (0, import_through.default)((chunk) => {
|
|
91
|
-
task.output = chunk?.toString("utf-8").trim();
|
|
92
|
-
});
|
|
93
|
-
instance.stdout.pipe(logOut);
|
|
94
|
-
instance.stderr.pipe(logOut);
|
|
95
|
-
return instance;
|
|
96
|
-
}
|
|
97
|
-
__name(pipeProcessThroughListr, "pipeProcessThroughListr");
|
|
87
|
+
// src/utils/logger/listr-logger.ts
|
|
88
|
+
var import_listr22 = require("listr2");
|
|
98
89
|
|
|
99
|
-
// src/utils/logger/
|
|
100
|
-
var
|
|
90
|
+
// src/utils/logger/logger.ts
|
|
91
|
+
var import_listr2 = require("listr2");
|
|
92
|
+
var import_os = require("os");
|
|
93
|
+
var import_winston = __toESM(require("winston"));
|
|
101
94
|
|
|
102
95
|
// src/utils/logger/logger.constants.ts
|
|
103
96
|
var LogLevels = /* @__PURE__ */ ((LogLevels2) => {
|
|
@@ -118,58 +111,6 @@ var LogFieldStatus = /* @__PURE__ */ ((LogFieldStatus2) => {
|
|
|
118
111
|
return LogFieldStatus2;
|
|
119
112
|
})(LogFieldStatus || {});
|
|
120
113
|
|
|
121
|
-
// src/utils/logger/pipe/pipe-process-to-logger.ts
|
|
122
|
-
function pipeProcessToLogger(logger, instance, options) {
|
|
123
|
-
options = {
|
|
124
|
-
start: "INFO" /* INFO */,
|
|
125
|
-
end: "INFO" /* INFO */,
|
|
126
|
-
stdout: "INFO" /* INFO */,
|
|
127
|
-
stderr: "WARN" /* WARN */,
|
|
128
|
-
...options
|
|
129
|
-
};
|
|
130
|
-
if (options.start) {
|
|
131
|
-
logger.run(instance.spawnargs.join(" "), { level: options.start });
|
|
132
|
-
}
|
|
133
|
-
if (instance.stdout) {
|
|
134
|
-
instance.stdout.pipe(
|
|
135
|
-
(0, import_through2.default)((chunk) => {
|
|
136
|
-
logger.log(options.stdout, chunk);
|
|
137
|
-
})
|
|
138
|
-
);
|
|
139
|
-
}
|
|
140
|
-
if (instance.stderr) {
|
|
141
|
-
instance.stderr.pipe(
|
|
142
|
-
(0, import_through2.default)((chunk) => {
|
|
143
|
-
logger.log(options.stderr, chunk);
|
|
144
|
-
})
|
|
145
|
-
);
|
|
146
|
-
}
|
|
147
|
-
void instance.on("exit", (code, signal) => {
|
|
148
|
-
const message = `Process ended with code ${code}${signal ? ` and signal ${signal}` : ""}.`;
|
|
149
|
-
logger.debug(message);
|
|
150
|
-
if (options.end) {
|
|
151
|
-
logger.end(instance.spawnargs.join(" "), { level: options.end });
|
|
152
|
-
}
|
|
153
|
-
if (options?.callback) {
|
|
154
|
-
options.callback();
|
|
155
|
-
}
|
|
156
|
-
});
|
|
157
|
-
void instance.on("error", (error) => {
|
|
158
|
-
logger.fatal(error.message);
|
|
159
|
-
logger.debug(error.stack);
|
|
160
|
-
if (options?.callback) {
|
|
161
|
-
options.callback(error);
|
|
162
|
-
}
|
|
163
|
-
});
|
|
164
|
-
return instance;
|
|
165
|
-
}
|
|
166
|
-
__name(pipeProcessToLogger, "pipeProcessToLogger");
|
|
167
|
-
|
|
168
|
-
// src/utils/logger/logger.ts
|
|
169
|
-
var import_listr2 = require("listr2");
|
|
170
|
-
var import_os = require("os");
|
|
171
|
-
var import_winston = __toESM(require("winston"));
|
|
172
|
-
|
|
173
114
|
// src/utils/color.ts
|
|
174
115
|
var colorette = __toESM(require("colorette"));
|
|
175
116
|
var color = colorette.createColors({ useColor: true });
|
|
@@ -326,6 +267,99 @@ var Logger = class {
|
|
|
326
267
|
};
|
|
327
268
|
__name(Logger, "Logger");
|
|
328
269
|
|
|
270
|
+
// src/utils/logger/listr-logger.ts
|
|
271
|
+
var ListrLogger = class extends import_listr22.Logger {
|
|
272
|
+
constructor(context) {
|
|
273
|
+
super();
|
|
274
|
+
this.logger = new Logger(context);
|
|
275
|
+
}
|
|
276
|
+
fail(message) {
|
|
277
|
+
this.logger.error(message);
|
|
278
|
+
}
|
|
279
|
+
skip(message) {
|
|
280
|
+
this.logger.warn(message, { status: "skip" });
|
|
281
|
+
}
|
|
282
|
+
success(message) {
|
|
283
|
+
this.logger.info(message, { status: "done" });
|
|
284
|
+
}
|
|
285
|
+
data(message) {
|
|
286
|
+
this.logger.info(message);
|
|
287
|
+
}
|
|
288
|
+
start(message) {
|
|
289
|
+
this.logger.info(message, { status: "run" });
|
|
290
|
+
}
|
|
291
|
+
title(message) {
|
|
292
|
+
this.logger.info(message);
|
|
293
|
+
}
|
|
294
|
+
retry(message) {
|
|
295
|
+
this.logger.warn(message, { status: "retry" });
|
|
296
|
+
}
|
|
297
|
+
rollback(message) {
|
|
298
|
+
this.logger.warn(message, { status: "rollback" });
|
|
299
|
+
}
|
|
300
|
+
};
|
|
301
|
+
__name(ListrLogger, "ListrLogger");
|
|
302
|
+
|
|
303
|
+
// src/utils/logger/pipe/pipe-process-to-listr.ts
|
|
304
|
+
var import_through = __toESM(require("through"));
|
|
305
|
+
function pipeProcessThroughListr(task, instance) {
|
|
306
|
+
const logOut = (0, import_through.default)((chunk) => {
|
|
307
|
+
task.output = chunk?.toString("utf-8").trim();
|
|
308
|
+
});
|
|
309
|
+
instance.stdout.pipe(logOut);
|
|
310
|
+
instance.stderr.pipe(logOut);
|
|
311
|
+
return instance;
|
|
312
|
+
}
|
|
313
|
+
__name(pipeProcessThroughListr, "pipeProcessThroughListr");
|
|
314
|
+
|
|
315
|
+
// src/utils/logger/pipe/pipe-process-to-logger.ts
|
|
316
|
+
var import_through2 = __toESM(require("through"));
|
|
317
|
+
function pipeProcessToLogger(logger, instance, options) {
|
|
318
|
+
options = {
|
|
319
|
+
start: "INFO" /* INFO */,
|
|
320
|
+
end: "INFO" /* INFO */,
|
|
321
|
+
stdout: "INFO" /* INFO */,
|
|
322
|
+
stderr: "WARN" /* WARN */,
|
|
323
|
+
...options
|
|
324
|
+
};
|
|
325
|
+
if (options.start) {
|
|
326
|
+
logger.run(instance.spawnargs.join(" "), { level: options.start });
|
|
327
|
+
}
|
|
328
|
+
if (instance.stdout) {
|
|
329
|
+
instance.stdout.pipe(
|
|
330
|
+
(0, import_through2.default)((chunk) => {
|
|
331
|
+
logger.log(options.stdout, chunk);
|
|
332
|
+
})
|
|
333
|
+
);
|
|
334
|
+
}
|
|
335
|
+
if (instance.stderr) {
|
|
336
|
+
instance.stderr.pipe(
|
|
337
|
+
(0, import_through2.default)((chunk) => {
|
|
338
|
+
logger.log(options.stderr, chunk);
|
|
339
|
+
})
|
|
340
|
+
);
|
|
341
|
+
}
|
|
342
|
+
void instance.on("exit", (code, signal) => {
|
|
343
|
+
const message = `Process ended with code ${code}${signal ? ` and signal ${signal}` : ""}.`;
|
|
344
|
+
logger.debug(message);
|
|
345
|
+
if (options.end) {
|
|
346
|
+
logger.end(instance.spawnargs.join(" "), { level: options.end });
|
|
347
|
+
}
|
|
348
|
+
if (options?.callback) {
|
|
349
|
+
options.callback();
|
|
350
|
+
}
|
|
351
|
+
});
|
|
352
|
+
void instance.on("error", (error) => {
|
|
353
|
+
logger.fatal(error.message);
|
|
354
|
+
logger.debug(error.stack);
|
|
355
|
+
if (options?.callback) {
|
|
356
|
+
options.callback(error);
|
|
357
|
+
}
|
|
358
|
+
});
|
|
359
|
+
return instance;
|
|
360
|
+
}
|
|
361
|
+
__name(pipeProcessToLogger, "pipeProcessToLogger");
|
|
362
|
+
|
|
329
363
|
// src/lib/parser/json-parser.service.ts
|
|
330
364
|
var _JsonParser = class {
|
|
331
365
|
constructor() {
|
|
@@ -592,6 +626,9 @@ function setCtxAssign(ctx, ...assigns) {
|
|
|
592
626
|
}
|
|
593
627
|
__name(setCtxAssign, "setCtxAssign");
|
|
594
628
|
|
|
629
|
+
// src/utils/index.ts
|
|
630
|
+
var import_core = require("@oclif/core");
|
|
631
|
+
|
|
595
632
|
// src/lib/config/config.service.ts
|
|
596
633
|
var ConfigService = class {
|
|
597
634
|
constructor(oclif, command, config) {
|
|
@@ -938,7 +975,7 @@ function setup() {
|
|
|
938
975
|
__name(setup, "setup");
|
|
939
976
|
|
|
940
977
|
// src/commands/base.command.ts
|
|
941
|
-
var Command = class extends
|
|
978
|
+
var Command = class extends import_core2.Command {
|
|
942
979
|
constructor() {
|
|
943
980
|
super(...arguments);
|
|
944
981
|
this.store = new StoreService();
|
|
@@ -959,7 +996,8 @@ var Command = class extends import_core.Command {
|
|
|
959
996
|
ci: this.flags.ci,
|
|
960
997
|
json: this.flags.json
|
|
961
998
|
});
|
|
962
|
-
|
|
999
|
+
const context = this.cs.command.id ? this.cs.command.id : this.cs.command.name;
|
|
1000
|
+
this.logger = new Logger(context, { level: this.cs.logLevel });
|
|
963
1001
|
this.greet();
|
|
964
1002
|
if (err) {
|
|
965
1003
|
throw err;
|
|
@@ -967,10 +1005,15 @@ var Command = class extends import_core.Command {
|
|
|
967
1005
|
this.parser = new ParserService();
|
|
968
1006
|
this.fs = new FileSystemService();
|
|
969
1007
|
this.validator = new ValidatorService();
|
|
970
|
-
this.tasks = new
|
|
1008
|
+
this.tasks = new import_listr23.Manager({
|
|
971
1009
|
rendererFallback: this.cs.isDebug,
|
|
972
1010
|
rendererSilent: this.cs.isSilent,
|
|
973
|
-
nonTTYRendererOptions: {
|
|
1011
|
+
nonTTYRendererOptions: {
|
|
1012
|
+
logEmptyTitle: false,
|
|
1013
|
+
logTitleChange: false,
|
|
1014
|
+
logger: ListrLogger,
|
|
1015
|
+
options: [context]
|
|
1016
|
+
},
|
|
974
1017
|
ctx: {}
|
|
975
1018
|
});
|
|
976
1019
|
if (this.cs.oclif.windows) {
|
|
@@ -991,15 +1034,8 @@ var Command = class extends import_core.Command {
|
|
|
991
1034
|
}
|
|
992
1035
|
shouldRunAfter(_ctx) {
|
|
993
1036
|
}
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
const ctx = await this.tasks.runAll();
|
|
997
|
-
return ctx;
|
|
998
|
-
} catch (e) {
|
|
999
|
-
this.logger.fatal(e.message);
|
|
1000
|
-
this.logger.debug(e.stack, { context: "crash" });
|
|
1001
|
-
process.exit(126);
|
|
1002
|
-
}
|
|
1037
|
+
run() {
|
|
1038
|
+
return;
|
|
1003
1039
|
}
|
|
1004
1040
|
async finally() {
|
|
1005
1041
|
const ctx = await this.runTasks();
|
|
@@ -1009,11 +1045,19 @@ var Command = class extends import_core.Command {
|
|
|
1009
1045
|
catch(e) {
|
|
1010
1046
|
this.logger.fatal(e.message);
|
|
1011
1047
|
this.logger.debug(e.stack, { context: "crash" });
|
|
1012
|
-
|
|
1048
|
+
this.exit(127);
|
|
1049
|
+
return;
|
|
1050
|
+
}
|
|
1051
|
+
exit(code) {
|
|
1052
|
+
this.logger.trace("Exitting with code: %d", code);
|
|
1053
|
+
this.exit(code ?? 0);
|
|
1054
|
+
}
|
|
1055
|
+
runTasks() {
|
|
1056
|
+
return this.tasks.runAll();
|
|
1013
1057
|
}
|
|
1014
1058
|
prompt(options) {
|
|
1015
1059
|
try {
|
|
1016
|
-
return (0,
|
|
1060
|
+
return (0, import_listr23.createPrompt)(options, {
|
|
1017
1061
|
stdout: process.stdout,
|
|
1018
1062
|
cancelCallback: () => {
|
|
1019
1063
|
throw new Error("Cancelled prompt.");
|
|
@@ -1030,10 +1074,6 @@ var Command = class extends import_core.Command {
|
|
|
1030
1074
|
setCtxAssign(...assigns) {
|
|
1031
1075
|
return setCtxAssign(this.tasks.options.ctx, ...assigns);
|
|
1032
1076
|
}
|
|
1033
|
-
exit(code) {
|
|
1034
|
-
this.logger.trace("Exitting with code: %d", code);
|
|
1035
|
-
process.exit(code ?? 0);
|
|
1036
|
-
}
|
|
1037
1077
|
greet() {
|
|
1038
1078
|
if (this.cs.isSilent || this.cs.json) {
|
|
1039
1079
|
return;
|
|
@@ -1047,7 +1087,7 @@ var Command = class extends import_core.Command {
|
|
|
1047
1087
|
};
|
|
1048
1088
|
__name(Command, "Command");
|
|
1049
1089
|
Command.globalFlags = {
|
|
1050
|
-
["log-level"]:
|
|
1090
|
+
["log-level"]: import_core2.Flags.enum({
|
|
1051
1091
|
default: "INFO" /* INFO */,
|
|
1052
1092
|
env: "LOG_LEVEL",
|
|
1053
1093
|
description: "Set the log level of the application.",
|
|
@@ -1055,7 +1095,7 @@ Command.globalFlags = {
|
|
|
1055
1095
|
helpGroup: "CLI" /* CLI */,
|
|
1056
1096
|
parse: async (input) => input?.toUpperCase()
|
|
1057
1097
|
}),
|
|
1058
|
-
ci:
|
|
1098
|
+
ci: import_core2.Flags.boolean({
|
|
1059
1099
|
default: false,
|
|
1060
1100
|
env: "CI",
|
|
1061
1101
|
description: "Instruct whether this is running the CI/CD configuration.",
|
|
@@ -1072,6 +1112,12 @@ var ConfigCommand = class extends Command {
|
|
|
1072
1112
|
this.locker = setup2.locker;
|
|
1073
1113
|
await this.generate();
|
|
1074
1114
|
}
|
|
1115
|
+
setup() {
|
|
1116
|
+
throw new Error("The command should be setup first!");
|
|
1117
|
+
}
|
|
1118
|
+
table(...options) {
|
|
1119
|
+
import_core.CliUx.ux.table(...options);
|
|
1120
|
+
}
|
|
1075
1121
|
async generate() {
|
|
1076
1122
|
const response = await this.prompt({
|
|
1077
1123
|
type: "Select",
|
|
@@ -1084,12 +1130,12 @@ var ConfigCommand = class extends Command {
|
|
|
1084
1130
|
__name(ConfigCommand, "ConfigCommand");
|
|
1085
1131
|
|
|
1086
1132
|
// src/hooks/not-found.hook.ts
|
|
1087
|
-
var
|
|
1133
|
+
var import_core3 = require("@oclif/core");
|
|
1088
1134
|
var notFoundHook = /* @__PURE__ */ __name(async (opts) => {
|
|
1089
1135
|
const logger = new Logger(opts.config.name);
|
|
1090
1136
|
logger.fatal("Command not found. Take a look at help. You can also use --[h]elp flag for subcommands.", { custom: opts.config.name });
|
|
1091
1137
|
logger.direct("");
|
|
1092
|
-
const help = new
|
|
1138
|
+
const help = new import_core3.Help(opts.config);
|
|
1093
1139
|
await help.showHelp(["--all"]);
|
|
1094
1140
|
process.exit(127);
|
|
1095
1141
|
}, "notFoundHook");
|
|
@@ -1106,14 +1152,10 @@ var storeHook = /* @__PURE__ */ __name((cb) => async (opts) => {
|
|
|
1106
1152
|
}, "storeHook");
|
|
1107
1153
|
|
|
1108
1154
|
// src/interfaces/oclif.interface.ts
|
|
1109
|
-
var
|
|
1110
|
-
|
|
1111
|
-
// src/index.ts
|
|
1112
|
-
var src_default = {
|
|
1113
|
-
ux: import_core4.CliUx.ux
|
|
1114
|
-
};
|
|
1155
|
+
var import_core4 = require("@oclif/core");
|
|
1115
1156
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1116
1157
|
0 && (module.exports = {
|
|
1158
|
+
CliUx,
|
|
1117
1159
|
Command,
|
|
1118
1160
|
ConfigCommand,
|
|
1119
1161
|
ConfigService,
|
|
@@ -1122,6 +1164,7 @@ var src_default = {
|
|
|
1122
1164
|
Flags,
|
|
1123
1165
|
HelpGroups,
|
|
1124
1166
|
JsonParser,
|
|
1167
|
+
ListrLogger,
|
|
1125
1168
|
LockerService,
|
|
1126
1169
|
LogFieldStatus,
|
|
1127
1170
|
LogLevels,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cenk1cenk2/oclif-common",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.2.1",
|
|
4
4
|
"description": "Oclif common package for oclif2 projects.",
|
|
5
5
|
"repository": "https://gitlab.kilic.dev/libraries/oclif-tools",
|
|
6
6
|
"author": {
|
|
@@ -44,7 +44,8 @@
|
|
|
44
44
|
"enquirer": ">= 2",
|
|
45
45
|
"execa": ">= 6",
|
|
46
46
|
"listr2": ">= 4",
|
|
47
|
-
"update-notifier": "^5"
|
|
47
|
+
"update-notifier": "^5",
|
|
48
|
+
"fs-extra": ">= 10"
|
|
48
49
|
},
|
|
49
50
|
"peerDependenciesMeta": {
|
|
50
51
|
"execa": {
|
|
@@ -55,10 +56,8 @@
|
|
|
55
56
|
}
|
|
56
57
|
},
|
|
57
58
|
"dependencies": {
|
|
58
|
-
"@types/fs-extra": "^9.0.13",
|
|
59
59
|
"colorette": "^2.0.19",
|
|
60
60
|
"deepmerge": "^4.2.2",
|
|
61
|
-
"fs-extra": "^10.1.0",
|
|
62
61
|
"object-path-immutable": "^4.1.2",
|
|
63
62
|
"reflect-metadata": "^0.1.13",
|
|
64
63
|
"through": "^2.3.8",
|
|
@@ -67,6 +66,8 @@
|
|
|
67
66
|
"yaml": "^2.1.1"
|
|
68
67
|
},
|
|
69
68
|
"devDependencies": {
|
|
69
|
+
"@types/fs-extra": "^9.0.13",
|
|
70
|
+
"fs-extra": "^10.1.0",
|
|
70
71
|
"@oclif/core": "^1.16.1",
|
|
71
72
|
"@types/through": "^0.0.30",
|
|
72
73
|
"@types/update-notifier": "^5",
|