@cenk1cenk2/oclif-common 5.0.0 → 5.0.2
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 +6 -7
- package/dist/index.js +42 -42
- package/package.json +5 -6
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 { ListrTaskWrapper, ListrContext, Manager, PromptOptions } from 'listr2';
|
|
4
|
+
import { ListrTaskWrapper, splat, 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';
|
|
@@ -11,7 +11,6 @@ import { InferredFlags } from '@oclif/core/lib/interfaces';
|
|
|
11
11
|
export { Flag, InferredFlags } from '@oclif/core/lib/interfaces';
|
|
12
12
|
import { FlagInput } from '@oclif/core/lib/interfaces/parser';
|
|
13
13
|
export { Arg, ArgInput, FlagInput } from '@oclif/core/lib/interfaces/parser';
|
|
14
|
-
import * as colorette from 'colorette';
|
|
15
14
|
|
|
16
15
|
type ClassType<T> = new (...args: any[]) => T;
|
|
17
16
|
|
|
@@ -69,7 +68,8 @@ type Winston = Logger$1 & Record<keyof typeof LogLevels, LeveledLogMethod>;
|
|
|
69
68
|
declare class Logger {
|
|
70
69
|
private context?;
|
|
71
70
|
private options?;
|
|
72
|
-
static instance
|
|
71
|
+
private static instance;
|
|
72
|
+
private static initiated;
|
|
73
73
|
private logger;
|
|
74
74
|
constructor(context?: string, options?: LoggerOptions);
|
|
75
75
|
log(level: LogLevels, data: string | Buffer, ...args: any): void;
|
|
@@ -84,6 +84,7 @@ declare class Logger {
|
|
|
84
84
|
run(data: string | Buffer, ...args: any): void;
|
|
85
85
|
end(data: string | Buffer, ...args: any): void;
|
|
86
86
|
stage(data: string | Buffer, ...args: any): void;
|
|
87
|
+
splat(...args: Parameters<typeof splat>): ReturnType<typeof splat>;
|
|
87
88
|
private initiateLogger;
|
|
88
89
|
private parseMessage;
|
|
89
90
|
private logColoring;
|
|
@@ -106,8 +107,6 @@ interface ConfigIterator {
|
|
|
106
107
|
extensions?: ConfigIterator[];
|
|
107
108
|
}
|
|
108
109
|
|
|
109
|
-
declare const color: colorette.Colorette;
|
|
110
|
-
|
|
111
110
|
declare function isVerbose(logLevel: LogLevels): boolean;
|
|
112
111
|
declare function isDebug(logLevel: LogLevels): boolean;
|
|
113
112
|
declare function isSilent(logLevel: LogLevels): boolean;
|
|
@@ -360,7 +359,7 @@ declare class ConfigCommand<CommandChoices extends string = string, LockFile = a
|
|
|
360
359
|
run(): Promise<any>;
|
|
361
360
|
setup(): ConfigCommandSetup<CommandChoices, LockFile> | Promise<ConfigCommandSetup<CommandChoices, LockFile>>;
|
|
362
361
|
protected table(...options: Parameters<typeof ux.table>): void;
|
|
363
|
-
protected select(): Promise<
|
|
362
|
+
protected select(): Promise<CommandChoices>;
|
|
364
363
|
}
|
|
365
364
|
|
|
366
365
|
declare enum FileConstants {
|
|
@@ -379,4 +378,4 @@ declare const updateNotifierHook: Hook<'init'>;
|
|
|
379
378
|
|
|
380
379
|
declare const storeHook: <T extends Record<PropertyKey, any> = Record<PropertyKey, any>>(cb: (opts: any, store: StoreService<T>) => void) => Hook<'init'>;
|
|
381
380
|
|
|
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,
|
|
381
|
+
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, isDebug, isSilent, isVerbose, merge, notFoundHook, pipeProcessThroughListr, pipeProcessToLogger, setCtxAssign, setCtxDefaults, setup, storeHook, uniqueFilter, updateNotifierHook };
|
package/dist/index.js
CHANGED
|
@@ -452,12 +452,6 @@ var ParserService = _ParserService;
|
|
|
452
452
|
__name(ParserService, "ParserService");
|
|
453
453
|
__publicField(ParserService, "instance");
|
|
454
454
|
|
|
455
|
-
// src/utils/color.ts
|
|
456
|
-
var _colorette = require('colorette'); var colorette = _interopRequireWildcard(_colorette);
|
|
457
|
-
var color = colorette.createColors({
|
|
458
|
-
useColor: true
|
|
459
|
-
});
|
|
460
|
-
|
|
461
455
|
// src/utils/environment.ts
|
|
462
456
|
function isVerbose(logLevel) {
|
|
463
457
|
return logLevel === LogLevels.VERBOSE;
|
|
@@ -968,21 +962,20 @@ var _Logger = class {
|
|
|
968
962
|
__publicField(this, "logger");
|
|
969
963
|
this.context = context;
|
|
970
964
|
this.options = options;
|
|
971
|
-
if (_Logger.instance) {
|
|
965
|
+
if (_Logger.instance && _Logger.initiated === ConfigService.name) {
|
|
972
966
|
this.logger = _Logger.instance;
|
|
973
|
-
|
|
974
|
-
const level = Object.values(LogLevels).includes(_optionalChain([options, 'optionalAccess', _22 => _22.level])) ? options.level : LogLevels.INFO;
|
|
975
|
-
this.options = {
|
|
976
|
-
useIcons: true,
|
|
977
|
-
...options,
|
|
978
|
-
level
|
|
979
|
-
};
|
|
980
|
-
this.logger = this.initiateLogger();
|
|
981
|
-
this.trace("Logger singleton initiated from context: %s", context);
|
|
982
|
-
_Logger.instance = this.logger;
|
|
983
|
-
} else {
|
|
984
|
-
throw new Error("Logger can only be initiated inside the config service context!");
|
|
967
|
+
return this;
|
|
985
968
|
}
|
|
969
|
+
const level = Object.values(LogLevels).includes(_optionalChain([options, 'optionalAccess', _22 => _22.level])) ? options.level : LogLevels.INFO;
|
|
970
|
+
this.options = {
|
|
971
|
+
useIcons: true,
|
|
972
|
+
...options,
|
|
973
|
+
level
|
|
974
|
+
};
|
|
975
|
+
this.logger = this.initiateLogger();
|
|
976
|
+
this.trace("Logger singleton initiated from context: %s", context);
|
|
977
|
+
_Logger.initiated = context;
|
|
978
|
+
_Logger.instance = this.logger;
|
|
986
979
|
}
|
|
987
980
|
log(level, data, ...args) {
|
|
988
981
|
return this.parseMessage(level, data, args);
|
|
@@ -1027,32 +1020,38 @@ var _Logger = class {
|
|
|
1027
1020
|
status: LogFieldStatus.STAGE
|
|
1028
1021
|
});
|
|
1029
1022
|
}
|
|
1023
|
+
splat(...args) {
|
|
1024
|
+
const message = args.shift();
|
|
1025
|
+
if (typeof message === "undefined") {
|
|
1026
|
+
return "";
|
|
1027
|
+
}
|
|
1028
|
+
if (args.length === 0) {
|
|
1029
|
+
return message;
|
|
1030
|
+
}
|
|
1031
|
+
return _listr2.splat.call(void 0, message, args);
|
|
1032
|
+
}
|
|
1030
1033
|
initiateLogger() {
|
|
1031
1034
|
const logFormat = _winston.format.printf(({ level, message, context, status }) => {
|
|
1032
|
-
|
|
1033
|
-
multiLineMessage = message.split(_os.EOL);
|
|
1034
|
-
multiLineMessage = multiLineMessage.filter((msg) => msg.trim() !== "").filter(Boolean);
|
|
1035
|
-
multiLineMessage = multiLineMessage.map((msg) => {
|
|
1035
|
+
return message.split(_os.EOL).filter((msg) => !msg || msg.trim() !== "").map((msg) => {
|
|
1036
1036
|
return this.logColoring({
|
|
1037
1037
|
level,
|
|
1038
1038
|
message: msg,
|
|
1039
1039
|
context,
|
|
1040
1040
|
status
|
|
1041
1041
|
});
|
|
1042
|
-
});
|
|
1043
|
-
return multiLineMessage.join(_os.EOL);
|
|
1042
|
+
}).join(_os.EOL);
|
|
1044
1043
|
});
|
|
1045
1044
|
const logger = _winston2.default.createLogger({
|
|
1046
1045
|
level: this.options.level,
|
|
1047
1046
|
format: _winston.format.combine(_winston.format.splat(), _winston.format.json({
|
|
1048
1047
|
space: 2
|
|
1049
1048
|
}), _winston.format.prettyPrint(), logFormat),
|
|
1050
|
-
levels: Object.values(LogLevels).
|
|
1051
|
-
return
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
}
|
|
1049
|
+
levels: Object.fromEntries(Object.values(LogLevels).map((level, i) => {
|
|
1050
|
+
return [
|
|
1051
|
+
level,
|
|
1052
|
+
i
|
|
1053
|
+
];
|
|
1054
|
+
})),
|
|
1056
1055
|
silent: this.options.level === LogLevels.SILENT,
|
|
1057
1056
|
transports: [
|
|
1058
1057
|
new _winston.transports.Console({
|
|
@@ -1091,45 +1090,45 @@ var _Logger = class {
|
|
|
1091
1090
|
case LogLevels.DIRECT:
|
|
1092
1091
|
return message;
|
|
1093
1092
|
case LogLevels.FATAL:
|
|
1094
|
-
coloring = /* @__PURE__ */ __name((input) => color.red(input), "coloring");
|
|
1093
|
+
coloring = /* @__PURE__ */ __name((input) => _listr2.color.red(input), "coloring");
|
|
1095
1094
|
if (_optionalChain([this, 'access', _23 => _23.options, 'optionalAccess', _24 => _24.useIcons])) {
|
|
1096
1095
|
icon = _listr2.figures.checkboxOn;
|
|
1097
1096
|
}
|
|
1098
1097
|
break;
|
|
1099
1098
|
case LogLevels.ERROR:
|
|
1100
|
-
coloring = color.red;
|
|
1099
|
+
coloring = _listr2.color.red;
|
|
1101
1100
|
if (_optionalChain([this, 'access', _25 => _25.options, 'optionalAccess', _26 => _26.useIcons])) {
|
|
1102
1101
|
icon = _listr2.figures.cross;
|
|
1103
1102
|
}
|
|
1104
1103
|
break;
|
|
1105
1104
|
case LogLevels.WARN:
|
|
1106
|
-
coloring = color.yellow;
|
|
1105
|
+
coloring = _listr2.color.yellow;
|
|
1107
1106
|
if (_optionalChain([this, 'access', _27 => _27.options, 'optionalAccess', _28 => _28.useIcons])) {
|
|
1108
1107
|
icon = _listr2.figures.warning;
|
|
1109
1108
|
}
|
|
1110
1109
|
break;
|
|
1111
1110
|
case LogLevels.INFO:
|
|
1112
|
-
coloring = color.green;
|
|
1111
|
+
coloring = _listr2.color.green;
|
|
1113
1112
|
if (_optionalChain([this, 'access', _29 => _29.options, 'optionalAccess', _30 => _30.useIcons])) {
|
|
1114
1113
|
icon = _listr2.figures.pointerSmall;
|
|
1115
1114
|
}
|
|
1116
1115
|
break;
|
|
1117
1116
|
case LogLevels.VERBOSE:
|
|
1118
|
-
coloring = color.dim;
|
|
1117
|
+
coloring = _listr2.color.dim;
|
|
1119
1118
|
if (_optionalChain([this, 'access', _31 => _31.options, 'optionalAccess', _32 => _32.useIcons])) {
|
|
1120
1119
|
icon = "\u2607";
|
|
1121
1120
|
}
|
|
1122
1121
|
break;
|
|
1123
1122
|
case LogLevels.DEBUG:
|
|
1124
|
-
coloring = color.cyan;
|
|
1125
|
-
msgColoring = color.dim;
|
|
1123
|
+
coloring = _listr2.color.cyan;
|
|
1124
|
+
msgColoring = _listr2.color.dim;
|
|
1126
1125
|
if (_optionalChain([this, 'access', _33 => _33.options, 'optionalAccess', _34 => _34.useIcons])) {
|
|
1127
1126
|
icon = "\uF188";
|
|
1128
1127
|
}
|
|
1129
1128
|
break;
|
|
1130
1129
|
case LogLevels.TRACE:
|
|
1131
|
-
coloring = color.magenta;
|
|
1132
|
-
msgColoring = color.dim;
|
|
1130
|
+
coloring = _listr2.color.magenta;
|
|
1131
|
+
msgColoring = _listr2.color.dim;
|
|
1133
1132
|
if (_optionalChain([this, 'access', _35 => _35.options, 'optionalAccess', _36 => _36.useIcons])) {
|
|
1134
1133
|
icon = "\u26B1";
|
|
1135
1134
|
}
|
|
@@ -1144,6 +1143,7 @@ var _Logger = class {
|
|
|
1144
1143
|
var Logger = _Logger;
|
|
1145
1144
|
__name(Logger, "Logger");
|
|
1146
1145
|
__publicField(Logger, "instance");
|
|
1146
|
+
__publicField(Logger, "initiated");
|
|
1147
1147
|
|
|
1148
1148
|
// src/constants/global-flags.constants.ts
|
|
1149
1149
|
var CLI_FLAGS = {
|
|
@@ -1211,6 +1211,7 @@ var Command = class extends _core.Command {
|
|
|
1211
1211
|
}
|
|
1212
1212
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
1213
1213
|
async _run() {
|
|
1214
|
+
this.constructor.prototype.baseFlags = {};
|
|
1214
1215
|
let result;
|
|
1215
1216
|
try {
|
|
1216
1217
|
delete process.env[this.config.scopedEnvVarKey("REDIRECTED")];
|
|
@@ -1459,5 +1460,4 @@ var storeHook = /* @__PURE__ */ __name((cb) => async (opts) => {
|
|
|
1459
1460
|
|
|
1460
1461
|
|
|
1461
1462
|
|
|
1462
|
-
|
|
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;
|
|
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.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": "5.0.
|
|
3
|
+
"version": "5.0.2",
|
|
4
4
|
"description": "Oclif common package for oclif2 projects.",
|
|
5
5
|
"repository": "https://gitlab.kilic.dev/libraries/oclif-tools",
|
|
6
6
|
"author": {
|
|
@@ -41,10 +41,10 @@
|
|
|
41
41
|
"class-transformer": ">= 0.5.0",
|
|
42
42
|
"class-validator": ">= 0.14.0",
|
|
43
43
|
"enquirer": ">= 2",
|
|
44
|
-
"execa": ">= 5",
|
|
44
|
+
"execa": ">= 5 < 6",
|
|
45
45
|
"fs-extra": ">= 10",
|
|
46
46
|
"listr2": ">= 6",
|
|
47
|
-
"update-notifier": ">=
|
|
47
|
+
"update-notifier": ">= 5"
|
|
48
48
|
},
|
|
49
49
|
"peerDependenciesMeta": {
|
|
50
50
|
"execa": {
|
|
@@ -55,12 +55,11 @@
|
|
|
55
55
|
}
|
|
56
56
|
},
|
|
57
57
|
"dependencies": {
|
|
58
|
-
"colorette": "^2.0.19",
|
|
59
58
|
"deepmerge": "^4.3.1",
|
|
60
59
|
"object-path-immutable": "^4.1.2",
|
|
61
60
|
"reflect-metadata": "^0.1.13",
|
|
62
61
|
"through": "^2.3.8",
|
|
63
|
-
"update-notifier": "^
|
|
62
|
+
"update-notifier": "^6.0.2",
|
|
64
63
|
"winston": "^3.8.2",
|
|
65
64
|
"yaml": "^2.2.1"
|
|
66
65
|
},
|
|
@@ -74,6 +73,6 @@
|
|
|
74
73
|
"enquirer": "^2.3.6",
|
|
75
74
|
"execa": "^5.1.1",
|
|
76
75
|
"fs-extra": "^11.1.1",
|
|
77
|
-
"listr2": "^6.0.
|
|
76
|
+
"listr2": "^6.0.4"
|
|
78
77
|
}
|
|
79
78
|
}
|