@cenk1cenk2/oclif-common 4.0.3 → 5.0.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.
- package/dist/index.d.ts +19 -32
- package/dist/index.js +102 -151
- package/package.json +8 -9
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Command as Command$1, ux, Hook } from '@oclif/core';
|
|
2
2
|
export { Flags, ux } from '@oclif/core';
|
|
3
3
|
import { ExecaChildProcess } from 'execa';
|
|
4
|
-
import {
|
|
4
|
+
import { ListrTaskWrapper, ListrContext, Manager, PromptOptions } from 'listr2';
|
|
5
5
|
import { Logger as Logger$1, LeveledLogMethod } from 'winston';
|
|
6
6
|
import fs from 'fs-extra';
|
|
7
7
|
export { default as fs } from 'fs-extra';
|
|
@@ -15,6 +15,8 @@ import * as colorette from 'colorette';
|
|
|
15
15
|
|
|
16
16
|
type ClassType<T> = new (...args: any[]) => T;
|
|
17
17
|
|
|
18
|
+
declare function pipeProcessThroughListr(task: ListrTaskWrapper<any, any>, instance: ExecaChildProcess): ExecaChildProcess;
|
|
19
|
+
|
|
18
20
|
declare enum LogLevels {
|
|
19
21
|
SILENT = "SILENT",
|
|
20
22
|
DIRECT = "DIRECT",
|
|
@@ -34,6 +36,21 @@ declare enum LogFieldStatus {
|
|
|
34
36
|
TERMINATE = "terminate"
|
|
35
37
|
}
|
|
36
38
|
|
|
39
|
+
interface PipeProcessToLoggerOptions {
|
|
40
|
+
/** Will log the command when the process starts. */
|
|
41
|
+
start?: LogLevels;
|
|
42
|
+
/** Will log the command when the process ends. */
|
|
43
|
+
end?: LogLevels;
|
|
44
|
+
/** enable/disable stdout */
|
|
45
|
+
stdout?: LogLevels;
|
|
46
|
+
/** enable/disable stderrr */
|
|
47
|
+
stderr?: LogLevels;
|
|
48
|
+
/** will callback on error in the instance */
|
|
49
|
+
callback?: (error?: Error) => void;
|
|
50
|
+
/** context for logger */
|
|
51
|
+
context?: string;
|
|
52
|
+
}
|
|
53
|
+
|
|
37
54
|
interface LoggerOptions {
|
|
38
55
|
useIcons?: boolean;
|
|
39
56
|
level?: LogLevels;
|
|
@@ -72,36 +89,6 @@ declare class Logger {
|
|
|
72
89
|
private logColoring;
|
|
73
90
|
}
|
|
74
91
|
|
|
75
|
-
declare class ListrLogger extends Logger$2 {
|
|
76
|
-
logger: Logger;
|
|
77
|
-
constructor(context?: string);
|
|
78
|
-
fail(message: string): void;
|
|
79
|
-
skip(message: string): void;
|
|
80
|
-
success(message: string): void;
|
|
81
|
-
data(message: string): void;
|
|
82
|
-
start(message: string): void;
|
|
83
|
-
title(message: string): void;
|
|
84
|
-
retry(message: string): void;
|
|
85
|
-
rollback(message: string): void;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
declare function pipeProcessThroughListr(task: ListrTaskWrapper<any, any>, instance: ExecaChildProcess): ExecaChildProcess;
|
|
89
|
-
|
|
90
|
-
interface PipeProcessToLoggerOptions {
|
|
91
|
-
/** Will log the command when the process starts. */
|
|
92
|
-
start?: LogLevels;
|
|
93
|
-
/** Will log the command when the process ends. */
|
|
94
|
-
end?: LogLevels;
|
|
95
|
-
/** enable/disable stdout */
|
|
96
|
-
stdout?: LogLevels;
|
|
97
|
-
/** enable/disable stderrr */
|
|
98
|
-
stderr?: LogLevels;
|
|
99
|
-
/** will callback on error in the instance */
|
|
100
|
-
callback?: (error?: Error) => void;
|
|
101
|
-
/** context for logger */
|
|
102
|
-
context?: string;
|
|
103
|
-
}
|
|
104
|
-
|
|
105
92
|
/**
|
|
106
93
|
* Given the instance it will pipe process output through the logger to append prefixes such as the application name.
|
|
107
94
|
*/
|
|
@@ -392,4 +379,4 @@ declare const updateNotifierHook: Hook<'init'>;
|
|
|
392
379
|
|
|
393
380
|
declare const storeHook: <T extends Record<PropertyKey, any> = Record<PropertyKey, any>>(cb: (opts: any, store: StoreService<T>) => void) => Hook<'init'>;
|
|
394
381
|
|
|
395
|
-
export { CLI_FLAGS, ClassType, Command, CommonLockerData, ConfigCommand, ConfigCommandChoices, ConfigCommandSetup, ConfigIterator, ConfigService, DataStore, DeepPartial, EnvironmentVariableParser, FileConstants, FileSystemService, GenericParser, GlobalConfig, HelpGroups, InferArgs, InferFlags, JsonParser,
|
|
382
|
+
export { CLI_FLAGS, ClassType, Command, CommonLockerData, ConfigCommand, ConfigCommandChoices, ConfigCommandSetup, ConfigIterator, ConfigService, DataStore, DeepPartial, EnvironmentVariableParser, FileConstants, FileSystemService, GenericParser, GlobalConfig, HelpGroups, InferArgs, InferFlags, JsonParser, LockData, LockableData, LockerService, LogFieldStatus, LogLevels, Logger, LoggerFormat, LoggerOptions, MergeStrategy, ParserService, PipeProcessToLoggerOptions, SetCtxAssignOptions, SetCtxDefaultsOptions, StoreService, UnlockData, ValidatorService, ValidatorServiceOptions, Winston, YamlParser, color, isDebug, isSilent, isVerbose, merge, notFoundHook, pipeProcessThroughListr, pipeProcessToLogger, setCtxAssign, setCtxDefaults, setup, storeHook, uniqueFilter, updateNotifierHook };
|
package/dist/index.js
CHANGED
|
@@ -34,13 +34,16 @@ var HelpGroups;
|
|
|
34
34
|
// src/interfaces/oclif.interface.ts
|
|
35
35
|
|
|
36
36
|
|
|
37
|
-
// src/utils/logger/listr
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
37
|
+
// src/utils/logger/pipe/pipe-process-to-listr.ts
|
|
38
|
+
function pipeProcessThroughListr(task, instance) {
|
|
39
|
+
instance.stdout.pipe(task.stdout());
|
|
40
|
+
instance.stderr.pipe(task.stdout());
|
|
41
|
+
return instance;
|
|
42
|
+
}
|
|
43
|
+
__name(pipeProcessThroughListr, "pipeProcessThroughListr");
|
|
41
44
|
|
|
42
|
-
|
|
43
|
-
var
|
|
45
|
+
// src/utils/logger/pipe/pipe-process-to-logger.ts
|
|
46
|
+
var _stream = require('stream');
|
|
44
47
|
|
|
45
48
|
// src/utils/logger/logger.constants.ts
|
|
46
49
|
var LogLevels;
|
|
@@ -64,6 +67,76 @@ var LogFieldStatus;
|
|
|
64
67
|
LogFieldStatus2["TERMINATE"] = "terminate";
|
|
65
68
|
})(LogFieldStatus || (LogFieldStatus = exports.LogFieldStatus = {}));
|
|
66
69
|
|
|
70
|
+
// src/utils/logger/pipe/pipe-process-to-logger.ts
|
|
71
|
+
function pipeProcessToLogger(logger, instance, options) {
|
|
72
|
+
options = {
|
|
73
|
+
start: LogLevels.INFO,
|
|
74
|
+
end: LogLevels.INFO,
|
|
75
|
+
stdout: LogLevels.INFO,
|
|
76
|
+
stderr: LogLevels.WARN,
|
|
77
|
+
...options
|
|
78
|
+
};
|
|
79
|
+
if (options.start) {
|
|
80
|
+
logger.run(instance.spawnargs.join(" "), {
|
|
81
|
+
level: options.start,
|
|
82
|
+
context: options.context
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
if (instance.stdout) {
|
|
86
|
+
const writable = new (0, _stream.Writable)();
|
|
87
|
+
writable.write = (chunk) => {
|
|
88
|
+
logger.log(options.stdout, chunk, {
|
|
89
|
+
context: options.context
|
|
90
|
+
});
|
|
91
|
+
return true;
|
|
92
|
+
};
|
|
93
|
+
instance.stdout.pipe(writable);
|
|
94
|
+
}
|
|
95
|
+
if (instance.stderr) {
|
|
96
|
+
const writable = new (0, _stream.Writable)();
|
|
97
|
+
writable.write = (chunk) => {
|
|
98
|
+
logger.log(options.stderr, chunk, {
|
|
99
|
+
context: options.context
|
|
100
|
+
});
|
|
101
|
+
return true;
|
|
102
|
+
};
|
|
103
|
+
instance.stderr.pipe(writable);
|
|
104
|
+
}
|
|
105
|
+
void instance.on("exit", (code, signal) => {
|
|
106
|
+
const message = `Process ended with code ${code}${signal ? ` and signal ${signal}` : ""}.`;
|
|
107
|
+
logger.debug(message, {
|
|
108
|
+
context: options.context
|
|
109
|
+
});
|
|
110
|
+
if (options.end) {
|
|
111
|
+
logger.end(instance.spawnargs.join(" "), {
|
|
112
|
+
level: options.end,
|
|
113
|
+
context: options.context
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
if (_optionalChain([options, 'optionalAccess', _2 => _2.callback])) {
|
|
117
|
+
options.callback();
|
|
118
|
+
}
|
|
119
|
+
});
|
|
120
|
+
void instance.on("error", (error) => {
|
|
121
|
+
logger.fatal(error.message, {
|
|
122
|
+
context: options.context
|
|
123
|
+
});
|
|
124
|
+
logger.debug(error.stack, {
|
|
125
|
+
context: options.context
|
|
126
|
+
});
|
|
127
|
+
if (_optionalChain([options, 'optionalAccess', _3 => _3.callback])) {
|
|
128
|
+
options.callback(error);
|
|
129
|
+
}
|
|
130
|
+
});
|
|
131
|
+
return instance;
|
|
132
|
+
}
|
|
133
|
+
__name(pipeProcessToLogger, "pipeProcessToLogger");
|
|
134
|
+
|
|
135
|
+
// src/utils/logger/logger.ts
|
|
136
|
+
|
|
137
|
+
var _os = require('os');
|
|
138
|
+
var _winston = require('winston'); var _winston2 = _interopRequireDefault(_winston);
|
|
139
|
+
|
|
67
140
|
// src/lib/config/config.service.ts
|
|
68
141
|
var _objectpathimmutable = require('object-path-immutable'); var _objectpathimmutable2 = _interopRequireDefault(_objectpathimmutable);
|
|
69
142
|
var _path = require('path');
|
|
@@ -427,7 +500,7 @@ __name(uniqueFilter, "uniqueFilter");
|
|
|
427
500
|
|
|
428
501
|
// src/utils/defaults.ts
|
|
429
502
|
function setCtxDefaults(ctx, ...defaults) {
|
|
430
|
-
_optionalChain([defaults, 'optionalAccess',
|
|
503
|
+
_optionalChain([defaults, 'optionalAccess', _4 => _4.forEach, 'call', _5 => _5((i) => {
|
|
431
504
|
if (typeof i === "object" && !Array.isArray(i)) {
|
|
432
505
|
Object.assign(ctx, i);
|
|
433
506
|
}
|
|
@@ -436,7 +509,7 @@ function setCtxDefaults(ctx, ...defaults) {
|
|
|
436
509
|
__name(setCtxDefaults, "setCtxDefaults");
|
|
437
510
|
function setCtxAssign(ctx, ...assigns) {
|
|
438
511
|
assigns.forEach((assign) => {
|
|
439
|
-
_optionalChain([assign, 'optionalAccess',
|
|
512
|
+
_optionalChain([assign, 'optionalAccess', _6 => _6.keys, 'access', _7 => _7.forEach, 'call', _8 => _8((i) => {
|
|
440
513
|
if (assign.from[i]) {
|
|
441
514
|
ctx[i] = assign.from[i];
|
|
442
515
|
}
|
|
@@ -667,13 +740,13 @@ var LockerService = class {
|
|
|
667
740
|
async lock(...data) {
|
|
668
741
|
let lock = await _asyncNullishCoalesce(await this.tryRead(), async () => ( {}));
|
|
669
742
|
data.forEach((d) => {
|
|
670
|
-
if (_optionalChain([d, 'optionalAccess',
|
|
743
|
+
if (_optionalChain([d, 'optionalAccess', _9 => _9.enabled]) === false) {
|
|
671
744
|
return;
|
|
672
|
-
} else if (!_optionalChain([d, 'optionalAccess',
|
|
745
|
+
} else if (!_optionalChain([d, 'optionalAccess', _10 => _10.data]) || Array.isArray(_optionalChain([d, 'optionalAccess', _11 => _11.data])) && d.data.length === 0 || typeof _optionalChain([d, 'optionalAccess', _12 => _12.data]) === "object" && Object.keys(d.data).length === 0) {
|
|
673
746
|
return;
|
|
674
747
|
}
|
|
675
748
|
const path = this.buildPath(d);
|
|
676
|
-
if (_optionalChain([d, 'optionalAccess',
|
|
749
|
+
if (_optionalChain([d, 'optionalAccess', _13 => _13.merge])) {
|
|
677
750
|
let parsed;
|
|
678
751
|
if (typeof d.data === "object") {
|
|
679
752
|
parsed = merge(d.merge, _objectpathimmutable2.default.get(lock, path, Array.isArray(d.data) ? [] : {}), d.data);
|
|
@@ -698,7 +771,7 @@ var LockerService = class {
|
|
|
698
771
|
}
|
|
699
772
|
if (data.length > 0) {
|
|
700
773
|
data.forEach((d) => {
|
|
701
|
-
if (_optionalChain([d, 'optionalAccess',
|
|
774
|
+
if (_optionalChain([d, 'optionalAccess', _14 => _14.enabled]) === false) {
|
|
702
775
|
return;
|
|
703
776
|
}
|
|
704
777
|
const path = this.buildPath(d);
|
|
@@ -739,7 +812,7 @@ var LockerService = class {
|
|
|
739
812
|
return this.fs.write(this.file, this.parser.stringify(data));
|
|
740
813
|
}
|
|
741
814
|
buildPath(d) {
|
|
742
|
-
if (_optionalChain([d, 'optionalAccess',
|
|
815
|
+
if (_optionalChain([d, 'optionalAccess', _15 => _15.root]) !== true && _optionalChain([this, 'access', _16 => _16.root, 'optionalAccess', _17 => _17.length])) {
|
|
743
816
|
return [
|
|
744
817
|
...this.root,
|
|
745
818
|
...this.normalizePath(d.path)
|
|
@@ -813,11 +886,11 @@ var _ValidatorService = class {
|
|
|
813
886
|
async validate(classType, object, options) {
|
|
814
887
|
const classObject = _classtransformer.plainToClass.call(void 0, classType, object, {
|
|
815
888
|
...this.options.transformer,
|
|
816
|
-
..._nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
889
|
+
..._nullishCoalesce(_optionalChain([options, 'optionalAccess', _18 => _18.transformer]), () => ( {}))
|
|
817
890
|
});
|
|
818
891
|
const errors = await _classvalidator.validate.call(void 0, classObject, {
|
|
819
892
|
...this.options.validator,
|
|
820
|
-
..._nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
893
|
+
..._nullishCoalesce(_optionalChain([options, 'optionalAccess', _19 => _19.validator]), () => ( {}))
|
|
821
894
|
});
|
|
822
895
|
if (errors.length) {
|
|
823
896
|
errors.forEach((error) => {
|
|
@@ -830,11 +903,11 @@ var _ValidatorService = class {
|
|
|
830
903
|
validateSync(classType, object, options) {
|
|
831
904
|
const classObject = _classtransformer.plainToClass.call(void 0, classType, object, {
|
|
832
905
|
...this.options.transformer,
|
|
833
|
-
..._nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
906
|
+
..._nullishCoalesce(_optionalChain([options, 'optionalAccess', _20 => _20.transformer]), () => ( {}))
|
|
834
907
|
});
|
|
835
908
|
const errors = _classvalidator.validateSync.call(void 0, classObject, {
|
|
836
909
|
...this.options.validator,
|
|
837
|
-
..._nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
910
|
+
..._nullishCoalesce(_optionalChain([options, 'optionalAccess', _21 => _21.validator]), () => ( {}))
|
|
838
911
|
});
|
|
839
912
|
if (errors.length) {
|
|
840
913
|
errors.forEach((error) => {
|
|
@@ -898,7 +971,7 @@ var _Logger = class {
|
|
|
898
971
|
if (_Logger.instance) {
|
|
899
972
|
this.logger = _Logger.instance;
|
|
900
973
|
} else if (context === ConfigService.name) {
|
|
901
|
-
const level = Object.values(LogLevels).includes(_optionalChain([options, 'optionalAccess',
|
|
974
|
+
const level = Object.values(LogLevels).includes(_optionalChain([options, 'optionalAccess', _22 => _22.level])) ? options.level : LogLevels.INFO;
|
|
902
975
|
this.options = {
|
|
903
976
|
useIcons: true,
|
|
904
977
|
...options,
|
|
@@ -1019,45 +1092,45 @@ var _Logger = class {
|
|
|
1019
1092
|
return message;
|
|
1020
1093
|
case LogLevels.FATAL:
|
|
1021
1094
|
coloring = /* @__PURE__ */ __name((input) => color.red(input), "coloring");
|
|
1022
|
-
if (_optionalChain([this, 'access',
|
|
1095
|
+
if (_optionalChain([this, 'access', _23 => _23.options, 'optionalAccess', _24 => _24.useIcons])) {
|
|
1023
1096
|
icon = _listr2.figures.checkboxOn;
|
|
1024
1097
|
}
|
|
1025
1098
|
break;
|
|
1026
1099
|
case LogLevels.ERROR:
|
|
1027
1100
|
coloring = color.red;
|
|
1028
|
-
if (_optionalChain([this, 'access',
|
|
1101
|
+
if (_optionalChain([this, 'access', _25 => _25.options, 'optionalAccess', _26 => _26.useIcons])) {
|
|
1029
1102
|
icon = _listr2.figures.cross;
|
|
1030
1103
|
}
|
|
1031
1104
|
break;
|
|
1032
1105
|
case LogLevels.WARN:
|
|
1033
1106
|
coloring = color.yellow;
|
|
1034
|
-
if (_optionalChain([this, 'access',
|
|
1107
|
+
if (_optionalChain([this, 'access', _27 => _27.options, 'optionalAccess', _28 => _28.useIcons])) {
|
|
1035
1108
|
icon = _listr2.figures.warning;
|
|
1036
1109
|
}
|
|
1037
1110
|
break;
|
|
1038
1111
|
case LogLevels.INFO:
|
|
1039
1112
|
coloring = color.green;
|
|
1040
|
-
if (_optionalChain([this, 'access',
|
|
1113
|
+
if (_optionalChain([this, 'access', _29 => _29.options, 'optionalAccess', _30 => _30.useIcons])) {
|
|
1041
1114
|
icon = _listr2.figures.pointerSmall;
|
|
1042
1115
|
}
|
|
1043
1116
|
break;
|
|
1044
1117
|
case LogLevels.VERBOSE:
|
|
1045
1118
|
coloring = color.dim;
|
|
1046
|
-
if (_optionalChain([this, 'access',
|
|
1119
|
+
if (_optionalChain([this, 'access', _31 => _31.options, 'optionalAccess', _32 => _32.useIcons])) {
|
|
1047
1120
|
icon = "\u2607";
|
|
1048
1121
|
}
|
|
1049
1122
|
break;
|
|
1050
1123
|
case LogLevels.DEBUG:
|
|
1051
1124
|
coloring = color.cyan;
|
|
1052
1125
|
msgColoring = color.dim;
|
|
1053
|
-
if (_optionalChain([this, 'access',
|
|
1126
|
+
if (_optionalChain([this, 'access', _33 => _33.options, 'optionalAccess', _34 => _34.useIcons])) {
|
|
1054
1127
|
icon = "\uF188";
|
|
1055
1128
|
}
|
|
1056
1129
|
break;
|
|
1057
1130
|
case LogLevels.TRACE:
|
|
1058
1131
|
coloring = color.magenta;
|
|
1059
1132
|
msgColoring = color.dim;
|
|
1060
|
-
if (_optionalChain([this, 'access',
|
|
1133
|
+
if (_optionalChain([this, 'access', _35 => _35.options, 'optionalAccess', _36 => _36.useIcons])) {
|
|
1061
1134
|
icon = "\u26B1";
|
|
1062
1135
|
}
|
|
1063
1136
|
break;
|
|
@@ -1072,122 +1145,6 @@ var Logger = _Logger;
|
|
|
1072
1145
|
__name(Logger, "Logger");
|
|
1073
1146
|
__publicField(Logger, "instance");
|
|
1074
1147
|
|
|
1075
|
-
// src/utils/logger/listr-logger.ts
|
|
1076
|
-
var ListrLogger = class extends _listr2.Logger {
|
|
1077
|
-
constructor(context) {
|
|
1078
|
-
super();
|
|
1079
|
-
__publicField(this, "logger");
|
|
1080
|
-
this.logger = new Logger(context);
|
|
1081
|
-
}
|
|
1082
|
-
fail(message) {
|
|
1083
|
-
this.logger.error(message);
|
|
1084
|
-
}
|
|
1085
|
-
skip(message) {
|
|
1086
|
-
this.logger.warn(message, {
|
|
1087
|
-
status: "skip"
|
|
1088
|
-
});
|
|
1089
|
-
}
|
|
1090
|
-
success(message) {
|
|
1091
|
-
this.logger.info(message, {
|
|
1092
|
-
status: "end"
|
|
1093
|
-
});
|
|
1094
|
-
}
|
|
1095
|
-
data(message) {
|
|
1096
|
-
this.logger.info(message);
|
|
1097
|
-
}
|
|
1098
|
-
start(message) {
|
|
1099
|
-
this.logger.info(message, {
|
|
1100
|
-
status: "run"
|
|
1101
|
-
});
|
|
1102
|
-
}
|
|
1103
|
-
title(message) {
|
|
1104
|
-
this.logger.info(message);
|
|
1105
|
-
}
|
|
1106
|
-
retry(message) {
|
|
1107
|
-
this.logger.warn(message, {
|
|
1108
|
-
status: "retry"
|
|
1109
|
-
});
|
|
1110
|
-
}
|
|
1111
|
-
rollback(message) {
|
|
1112
|
-
this.logger.error(message, {
|
|
1113
|
-
status: "rollback"
|
|
1114
|
-
});
|
|
1115
|
-
}
|
|
1116
|
-
};
|
|
1117
|
-
__name(ListrLogger, "ListrLogger");
|
|
1118
|
-
|
|
1119
|
-
// src/utils/logger/pipe/pipe-process-to-listr.ts
|
|
1120
|
-
var _through = require('through'); var _through2 = _interopRequireDefault(_through);
|
|
1121
|
-
function pipeProcessThroughListr(task, instance) {
|
|
1122
|
-
const logOut = _through2.default.call(void 0, (chunk) => {
|
|
1123
|
-
task.output = _optionalChain([chunk, 'optionalAccess', _35 => _35.toString, 'call', _36 => _36("utf-8"), 'access', _37 => _37.trim, 'call', _38 => _38()]);
|
|
1124
|
-
});
|
|
1125
|
-
instance.stdout.pipe(logOut);
|
|
1126
|
-
instance.stderr.pipe(logOut);
|
|
1127
|
-
return instance;
|
|
1128
|
-
}
|
|
1129
|
-
__name(pipeProcessThroughListr, "pipeProcessThroughListr");
|
|
1130
|
-
|
|
1131
|
-
// src/utils/logger/pipe/pipe-process-to-logger.ts
|
|
1132
|
-
|
|
1133
|
-
function pipeProcessToLogger(logger, instance, options) {
|
|
1134
|
-
options = {
|
|
1135
|
-
start: LogLevels.INFO,
|
|
1136
|
-
end: LogLevels.INFO,
|
|
1137
|
-
stdout: LogLevels.INFO,
|
|
1138
|
-
stderr: LogLevels.WARN,
|
|
1139
|
-
...options
|
|
1140
|
-
};
|
|
1141
|
-
if (options.start) {
|
|
1142
|
-
logger.run(instance.spawnargs.join(" "), {
|
|
1143
|
-
level: options.start,
|
|
1144
|
-
context: options.context
|
|
1145
|
-
});
|
|
1146
|
-
}
|
|
1147
|
-
if (instance.stdout) {
|
|
1148
|
-
instance.stdout.pipe(_through2.default.call(void 0, (chunk) => {
|
|
1149
|
-
logger.log(options.stdout, chunk, {
|
|
1150
|
-
context: options.context
|
|
1151
|
-
});
|
|
1152
|
-
}));
|
|
1153
|
-
}
|
|
1154
|
-
if (instance.stderr) {
|
|
1155
|
-
instance.stderr.pipe(_through2.default.call(void 0, (chunk) => {
|
|
1156
|
-
logger.log(options.stderr, chunk, {
|
|
1157
|
-
context: options.context
|
|
1158
|
-
});
|
|
1159
|
-
}));
|
|
1160
|
-
}
|
|
1161
|
-
void instance.on("exit", (code, signal) => {
|
|
1162
|
-
const message = `Process ended with code ${code}${signal ? ` and signal ${signal}` : ""}.`;
|
|
1163
|
-
logger.debug(message, {
|
|
1164
|
-
context: options.context
|
|
1165
|
-
});
|
|
1166
|
-
if (options.end) {
|
|
1167
|
-
logger.end(instance.spawnargs.join(" "), {
|
|
1168
|
-
level: options.end,
|
|
1169
|
-
context: options.context
|
|
1170
|
-
});
|
|
1171
|
-
}
|
|
1172
|
-
if (_optionalChain([options, 'optionalAccess', _39 => _39.callback])) {
|
|
1173
|
-
options.callback();
|
|
1174
|
-
}
|
|
1175
|
-
});
|
|
1176
|
-
void instance.on("error", (error) => {
|
|
1177
|
-
logger.fatal(error.message, {
|
|
1178
|
-
context: options.context
|
|
1179
|
-
});
|
|
1180
|
-
logger.debug(error.stack, {
|
|
1181
|
-
context: options.context
|
|
1182
|
-
});
|
|
1183
|
-
if (_optionalChain([options, 'optionalAccess', _40 => _40.callback])) {
|
|
1184
|
-
options.callback(error);
|
|
1185
|
-
}
|
|
1186
|
-
});
|
|
1187
|
-
return instance;
|
|
1188
|
-
}
|
|
1189
|
-
__name(pipeProcessToLogger, "pipeProcessToLogger");
|
|
1190
|
-
|
|
1191
1148
|
// src/constants/global-flags.constants.ts
|
|
1192
1149
|
var CLI_FLAGS = {
|
|
1193
1150
|
["log-level"]: _core.Flags.string({
|
|
@@ -1196,7 +1153,7 @@ var CLI_FLAGS = {
|
|
|
1196
1153
|
description: "Set the log level of the application.",
|
|
1197
1154
|
options: Object.values(LogLevels).map((level) => level.toLowerCase()),
|
|
1198
1155
|
helpGroup: HelpGroups.CLI,
|
|
1199
|
-
parse: async (input) => _optionalChain([input, 'optionalAccess',
|
|
1156
|
+
parse: async (input) => _optionalChain([input, 'optionalAccess', _37 => _37.toUpperCase, 'call', _38 => _38()])
|
|
1200
1157
|
}),
|
|
1201
1158
|
ci: _core.Flags.boolean({
|
|
1202
1159
|
default: false,
|
|
@@ -1335,13 +1292,8 @@ var Command = class extends _core.Command {
|
|
|
1335
1292
|
this.fs = new FileSystemService();
|
|
1336
1293
|
this.validator = new ValidatorService();
|
|
1337
1294
|
this.tasks = new (0, _listr2.Manager)({
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
nonTTYRendererOptions: {
|
|
1341
|
-
logEmptyTitle: false,
|
|
1342
|
-
logTitleChange: false,
|
|
1343
|
-
logger: ListrLogger
|
|
1344
|
-
},
|
|
1295
|
+
fallbackRendererCondition: this.cs.isDebug,
|
|
1296
|
+
silentRendererCondition: this.cs.isSilent,
|
|
1345
1297
|
ctx: {}
|
|
1346
1298
|
});
|
|
1347
1299
|
if (this.cs.oclif.windows) {
|
|
@@ -1508,5 +1460,4 @@ var storeHook = /* @__PURE__ */ __name((cb) => async (opts) => {
|
|
|
1508
1460
|
|
|
1509
1461
|
|
|
1510
1462
|
|
|
1511
|
-
|
|
1512
|
-
exports.CLI_FLAGS = CLI_FLAGS; exports.Command = Command; exports.ConfigCommand = ConfigCommand; exports.ConfigService = ConfigService; exports.EnvironmentVariableParser = EnvironmentVariableParser; exports.FileConstants = FileConstants; exports.FileSystemService = FileSystemService; exports.Flags = _core.Flags; exports.HelpGroups = HelpGroups; exports.JsonParser = JsonParser; exports.ListrLogger = ListrLogger; exports.LockerService = LockerService; exports.LogFieldStatus = LogFieldStatus; exports.LogLevels = LogLevels; exports.Logger = Logger; exports.MergeStrategy = MergeStrategy; exports.ParserService = ParserService; exports.StoreService = StoreService; exports.ValidatorService = ValidatorService; exports.YamlParser = YamlParser; exports.color = color; exports.fs = _fsextra2.default; exports.isDebug = isDebug; exports.isSilent = isSilent; exports.isVerbose = isVerbose; exports.merge = merge; exports.notFoundHook = notFoundHook; exports.pipeProcessThroughListr = pipeProcessThroughListr; exports.pipeProcessToLogger = pipeProcessToLogger; exports.setCtxAssign = setCtxAssign; exports.setCtxDefaults = setCtxDefaults; exports.setup = setup; exports.storeHook = storeHook; exports.uniqueFilter = uniqueFilter; exports.updateNotifierHook = updateNotifierHook; exports.ux = _core.ux;
|
|
1463
|
+
exports.CLI_FLAGS = CLI_FLAGS; exports.Command = Command; exports.ConfigCommand = ConfigCommand; exports.ConfigService = ConfigService; exports.EnvironmentVariableParser = EnvironmentVariableParser; exports.FileConstants = FileConstants; exports.FileSystemService = FileSystemService; exports.Flags = _core.Flags; exports.HelpGroups = HelpGroups; exports.JsonParser = JsonParser; exports.LockerService = LockerService; exports.LogFieldStatus = LogFieldStatus; exports.LogLevels = LogLevels; exports.Logger = Logger; exports.MergeStrategy = MergeStrategy; exports.ParserService = ParserService; exports.StoreService = StoreService; exports.ValidatorService = ValidatorService; exports.YamlParser = YamlParser; exports.color = color; exports.fs = _fsextra2.default; exports.isDebug = isDebug; exports.isSilent = isSilent; exports.isVerbose = isVerbose; exports.merge = merge; exports.notFoundHook = notFoundHook; exports.pipeProcessThroughListr = pipeProcessThroughListr; exports.pipeProcessToLogger = pipeProcessToLogger; exports.setCtxAssign = setCtxAssign; exports.setCtxDefaults = setCtxDefaults; exports.setup = setup; exports.storeHook = storeHook; exports.uniqueFilter = uniqueFilter; exports.updateNotifierHook = updateNotifierHook; exports.ux = _core.ux;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cenk1cenk2/oclif-common",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "5.0.0",
|
|
4
4
|
"description": "Oclif common package for oclif2 projects.",
|
|
5
5
|
"repository": "https://gitlab.kilic.dev/libraries/oclif-tools",
|
|
6
6
|
"author": {
|
|
@@ -23,9 +23,8 @@
|
|
|
23
23
|
"scripts": {
|
|
24
24
|
"build": "tsup-node",
|
|
25
25
|
"dev:start": "tsup-node --watch",
|
|
26
|
-
"
|
|
27
|
-
"lint
|
|
28
|
-
"docs:toc": "markdown-toc README.md --bullets='-' -i",
|
|
26
|
+
"format": "prettier --write src/ --loglevel warn && eslint --ext .ts,.js,.tsx,.jsx --fix src/",
|
|
27
|
+
"lint": "eslint --ext .ts,.js,.tsx,.jsx src/",
|
|
29
28
|
"docs:api": "typedoc --options .typedoc.json --hideInPageTOC --hideBreadcrumbs"
|
|
30
29
|
},
|
|
31
30
|
"lint-staged": {
|
|
@@ -39,13 +38,13 @@
|
|
|
39
38
|
},
|
|
40
39
|
"peerDependencies": {
|
|
41
40
|
"@oclif/core": ">= 1",
|
|
42
|
-
"class-transformer": "
|
|
43
|
-
"class-validator": "
|
|
41
|
+
"class-transformer": ">= 0.5.0",
|
|
42
|
+
"class-validator": ">= 0.14.0",
|
|
44
43
|
"enquirer": ">= 2",
|
|
45
44
|
"execa": ">= 5",
|
|
46
45
|
"fs-extra": ">= 10",
|
|
47
|
-
"listr2": ">=
|
|
48
|
-
"update-notifier": "^5
|
|
46
|
+
"listr2": ">= 6",
|
|
47
|
+
"update-notifier": ">= ^5"
|
|
49
48
|
},
|
|
50
49
|
"peerDependenciesMeta": {
|
|
51
50
|
"execa": {
|
|
@@ -75,6 +74,6 @@
|
|
|
75
74
|
"enquirer": "^2.3.6",
|
|
76
75
|
"execa": "^5.1.1",
|
|
77
76
|
"fs-extra": "^11.1.1",
|
|
78
|
-
"listr2": "^
|
|
77
|
+
"listr2": "^6.0.1"
|
|
79
78
|
}
|
|
80
79
|
}
|