@cenk1cenk2/oclif-common 3.5.3 → 3.7.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/hooks/index.js +11 -13
- package/dist/hooks/not-found.hook.js +5 -5
- package/dist/hooks/store.hook.js +11 -13
- package/dist/index.d.ts +37 -32
- package/dist/index.js +98 -71
- package/package.json +1 -1
package/dist/hooks/index.js
CHANGED
|
@@ -108,13 +108,13 @@ var Logger = class {
|
|
|
108
108
|
return this.parseMessage("TRACE" /* TRACE */, data, args);
|
|
109
109
|
}
|
|
110
110
|
run(data, ...args) {
|
|
111
|
-
return this.parseMessage("INFO" /* INFO */, data, args, { status: "
|
|
111
|
+
return this.parseMessage("INFO" /* INFO */, data, args, { status: "run" /* RUN */ });
|
|
112
112
|
}
|
|
113
113
|
end(data, ...args) {
|
|
114
|
-
return this.parseMessage("INFO" /* INFO */, data, args, { status: "
|
|
114
|
+
return this.parseMessage("INFO" /* INFO */, data, args, { status: "end" /* END */ });
|
|
115
115
|
}
|
|
116
116
|
stage(data, ...args) {
|
|
117
|
-
return this.parseMessage("TRACE" /* TRACE */, data, args, { status: "
|
|
117
|
+
return this.parseMessage("TRACE" /* TRACE */, data, args, { status: "stage" /* STAGE */ });
|
|
118
118
|
}
|
|
119
119
|
initiateLogger() {
|
|
120
120
|
const logFormat = import_winston.format.printf(({ level, message, context, status }) => {
|
|
@@ -191,7 +191,7 @@ var Logger = class {
|
|
|
191
191
|
case "VERBOSE" /* VERBOSE */:
|
|
192
192
|
coloring = color.dim;
|
|
193
193
|
if (this.options?.useIcons) {
|
|
194
|
-
icon =
|
|
194
|
+
icon = "\u2607";
|
|
195
195
|
}
|
|
196
196
|
break;
|
|
197
197
|
case "DEBUG" /* DEBUG */:
|
|
@@ -205,7 +205,7 @@ var Logger = class {
|
|
|
205
205
|
coloring = color.magenta;
|
|
206
206
|
msgColoring = color.dim;
|
|
207
207
|
if (this.options?.useIcons) {
|
|
208
|
-
icon = "\
|
|
208
|
+
icon = "\u26B1";
|
|
209
209
|
}
|
|
210
210
|
break;
|
|
211
211
|
}
|
|
@@ -273,13 +273,12 @@ var CLI_FLAGS = {
|
|
|
273
273
|
// src/lib/parser/json-parser.service.ts
|
|
274
274
|
var _JsonParser = class {
|
|
275
275
|
constructor() {
|
|
276
|
-
this.logger = new Logger(this.constructor.name);
|
|
277
276
|
if (_JsonParser.instance) {
|
|
278
277
|
return _JsonParser.instance;
|
|
279
|
-
} else {
|
|
280
|
-
_JsonParser.instance = this;
|
|
281
|
-
this.logger.trace("Created a new instance.");
|
|
282
278
|
}
|
|
279
|
+
_JsonParser.instance = this;
|
|
280
|
+
this.logger = new Logger(this.constructor.name);
|
|
281
|
+
this.logger.trace("Created a new instance.");
|
|
283
282
|
}
|
|
284
283
|
parse(data) {
|
|
285
284
|
try {
|
|
@@ -301,13 +300,12 @@ JsonParser.extensions = ["json"];
|
|
|
301
300
|
var import_yaml = require("yaml");
|
|
302
301
|
var _YamlParser = class {
|
|
303
302
|
constructor() {
|
|
304
|
-
this.logger = new Logger(this.constructor.name);
|
|
305
303
|
if (_YamlParser.instance) {
|
|
306
304
|
return _YamlParser.instance;
|
|
307
|
-
} else {
|
|
308
|
-
_YamlParser.instance = this;
|
|
309
|
-
this.logger.trace("Created a new instance.");
|
|
310
305
|
}
|
|
306
|
+
_YamlParser.instance = this;
|
|
307
|
+
this.logger = new Logger(this.constructor.name);
|
|
308
|
+
this.logger.trace("Created a new instance.");
|
|
311
309
|
}
|
|
312
310
|
parse(data) {
|
|
313
311
|
try {
|
|
@@ -104,13 +104,13 @@ var Logger = class {
|
|
|
104
104
|
return this.parseMessage("TRACE" /* TRACE */, data, args);
|
|
105
105
|
}
|
|
106
106
|
run(data, ...args) {
|
|
107
|
-
return this.parseMessage("INFO" /* INFO */, data, args, { status: "
|
|
107
|
+
return this.parseMessage("INFO" /* INFO */, data, args, { status: "run" /* RUN */ });
|
|
108
108
|
}
|
|
109
109
|
end(data, ...args) {
|
|
110
|
-
return this.parseMessage("INFO" /* INFO */, data, args, { status: "
|
|
110
|
+
return this.parseMessage("INFO" /* INFO */, data, args, { status: "end" /* END */ });
|
|
111
111
|
}
|
|
112
112
|
stage(data, ...args) {
|
|
113
|
-
return this.parseMessage("TRACE" /* TRACE */, data, args, { status: "
|
|
113
|
+
return this.parseMessage("TRACE" /* TRACE */, data, args, { status: "stage" /* STAGE */ });
|
|
114
114
|
}
|
|
115
115
|
initiateLogger() {
|
|
116
116
|
const logFormat = import_winston.format.printf(({ level, message, context, status }) => {
|
|
@@ -187,7 +187,7 @@ var Logger = class {
|
|
|
187
187
|
case "VERBOSE" /* VERBOSE */:
|
|
188
188
|
coloring = color.dim;
|
|
189
189
|
if (this.options?.useIcons) {
|
|
190
|
-
icon =
|
|
190
|
+
icon = "\u2607";
|
|
191
191
|
}
|
|
192
192
|
break;
|
|
193
193
|
case "DEBUG" /* DEBUG */:
|
|
@@ -201,7 +201,7 @@ var Logger = class {
|
|
|
201
201
|
coloring = color.magenta;
|
|
202
202
|
msgColoring = color.dim;
|
|
203
203
|
if (this.options?.useIcons) {
|
|
204
|
-
icon = "\
|
|
204
|
+
icon = "\u26B1";
|
|
205
205
|
}
|
|
206
206
|
break;
|
|
207
207
|
}
|
package/dist/hooks/store.hook.js
CHANGED
|
@@ -110,13 +110,13 @@ var Logger = class {
|
|
|
110
110
|
return this.parseMessage("TRACE" /* TRACE */, data, args);
|
|
111
111
|
}
|
|
112
112
|
run(data, ...args) {
|
|
113
|
-
return this.parseMessage("INFO" /* INFO */, data, args, { status: "
|
|
113
|
+
return this.parseMessage("INFO" /* INFO */, data, args, { status: "run" /* RUN */ });
|
|
114
114
|
}
|
|
115
115
|
end(data, ...args) {
|
|
116
|
-
return this.parseMessage("INFO" /* INFO */, data, args, { status: "
|
|
116
|
+
return this.parseMessage("INFO" /* INFO */, data, args, { status: "end" /* END */ });
|
|
117
117
|
}
|
|
118
118
|
stage(data, ...args) {
|
|
119
|
-
return this.parseMessage("TRACE" /* TRACE */, data, args, { status: "
|
|
119
|
+
return this.parseMessage("TRACE" /* TRACE */, data, args, { status: "stage" /* STAGE */ });
|
|
120
120
|
}
|
|
121
121
|
initiateLogger() {
|
|
122
122
|
const logFormat = import_winston.format.printf(({ level, message, context, status }) => {
|
|
@@ -193,7 +193,7 @@ var Logger = class {
|
|
|
193
193
|
case "VERBOSE" /* VERBOSE */:
|
|
194
194
|
coloring = color.dim;
|
|
195
195
|
if (this.options?.useIcons) {
|
|
196
|
-
icon =
|
|
196
|
+
icon = "\u2607";
|
|
197
197
|
}
|
|
198
198
|
break;
|
|
199
199
|
case "DEBUG" /* DEBUG */:
|
|
@@ -207,7 +207,7 @@ var Logger = class {
|
|
|
207
207
|
coloring = color.magenta;
|
|
208
208
|
msgColoring = color.dim;
|
|
209
209
|
if (this.options?.useIcons) {
|
|
210
|
-
icon = "\
|
|
210
|
+
icon = "\u26B1";
|
|
211
211
|
}
|
|
212
212
|
break;
|
|
213
213
|
}
|
|
@@ -252,13 +252,12 @@ var CLI_FLAGS = {
|
|
|
252
252
|
// src/lib/parser/json-parser.service.ts
|
|
253
253
|
var _JsonParser = class {
|
|
254
254
|
constructor() {
|
|
255
|
-
this.logger = new Logger(this.constructor.name);
|
|
256
255
|
if (_JsonParser.instance) {
|
|
257
256
|
return _JsonParser.instance;
|
|
258
|
-
} else {
|
|
259
|
-
_JsonParser.instance = this;
|
|
260
|
-
this.logger.trace("Created a new instance.");
|
|
261
257
|
}
|
|
258
|
+
_JsonParser.instance = this;
|
|
259
|
+
this.logger = new Logger(this.constructor.name);
|
|
260
|
+
this.logger.trace("Created a new instance.");
|
|
262
261
|
}
|
|
263
262
|
parse(data) {
|
|
264
263
|
try {
|
|
@@ -280,13 +279,12 @@ JsonParser.extensions = ["json"];
|
|
|
280
279
|
var import_yaml = require("yaml");
|
|
281
280
|
var _YamlParser = class {
|
|
282
281
|
constructor() {
|
|
283
|
-
this.logger = new Logger(this.constructor.name);
|
|
284
282
|
if (_YamlParser.instance) {
|
|
285
283
|
return _YamlParser.instance;
|
|
286
|
-
} else {
|
|
287
|
-
_YamlParser.instance = this;
|
|
288
|
-
this.logger.trace("Created a new instance.");
|
|
289
284
|
}
|
|
285
|
+
_YamlParser.instance = this;
|
|
286
|
+
this.logger = new Logger(this.constructor.name);
|
|
287
|
+
this.logger.trace("Created a new instance.");
|
|
290
288
|
}
|
|
291
289
|
parse(data) {
|
|
292
290
|
try {
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Command as Command$1, CliUx } from '@oclif/core';
|
|
1
|
+
import { Command as Command$1, Config, CliUx } from '@oclif/core';
|
|
2
2
|
export { CliUx, Flags } from '@oclif/core';
|
|
3
3
|
import { Logger as Logger$2, ListrTaskWrapper, ListrContext, Manager, PromptOptions } from 'listr2';
|
|
4
4
|
import { Logger as Logger$1, LeveledLogMethod } from 'winston';
|
|
@@ -36,11 +36,11 @@ declare enum LogLevels {
|
|
|
36
36
|
TRACE = "TRACE"
|
|
37
37
|
}
|
|
38
38
|
declare enum LogFieldStatus {
|
|
39
|
-
RUN = "
|
|
40
|
-
END = "
|
|
41
|
-
STAGE = "
|
|
42
|
-
EXIT = "
|
|
43
|
-
TERMINATE = "
|
|
39
|
+
RUN = "run",
|
|
40
|
+
END = "end",
|
|
41
|
+
STAGE = "stage",
|
|
42
|
+
EXIT = "exit",
|
|
43
|
+
TERMINATE = "terminate"
|
|
44
44
|
}
|
|
45
45
|
|
|
46
46
|
interface LoggerOptions {
|
|
@@ -179,9 +179,9 @@ declare class LockerService<LockFile extends LockableData = LockableData> {
|
|
|
179
179
|
private root?;
|
|
180
180
|
private toLock;
|
|
181
181
|
private toUnlock;
|
|
182
|
-
private
|
|
183
|
-
private
|
|
184
|
-
constructor(file: string, parser: GenericParser, root?: string);
|
|
182
|
+
private logger;
|
|
183
|
+
private fs;
|
|
184
|
+
constructor(file: string, parser: GenericParser, root?: string, context?: string);
|
|
185
185
|
hasLock(): boolean;
|
|
186
186
|
hasUnlock(): boolean;
|
|
187
187
|
addLock<T extends LockableData = LockableData>(...data: LockData<T>[]): void;
|
|
@@ -201,8 +201,8 @@ declare class LockerService<LockFile extends LockableData = LockableData> {
|
|
|
201
201
|
declare class ParserService {
|
|
202
202
|
private static instance;
|
|
203
203
|
parsers: ClassType<GenericParser>[];
|
|
204
|
-
private
|
|
205
|
-
private
|
|
204
|
+
private logger;
|
|
205
|
+
private fs;
|
|
206
206
|
constructor(parsers?: ClassType<GenericParser>[]);
|
|
207
207
|
getParser(file: string): GenericParser;
|
|
208
208
|
setParsers(...parsers: ClassType<GenericParser>[]): void;
|
|
@@ -226,7 +226,7 @@ declare class ConfigService implements GlobalConfig {
|
|
|
226
226
|
isSilent: boolean;
|
|
227
227
|
ci: boolean;
|
|
228
228
|
json: boolean;
|
|
229
|
-
private
|
|
229
|
+
private logger;
|
|
230
230
|
constructor(oclif: Command['config'], command: Command['ctor'], config: Omit<GlobalConfig, 'isVerbose' | 'isDebug' | 'isSilent'>);
|
|
231
231
|
read<T extends LockableData = LockableData>(path: string): Promise<T>;
|
|
232
232
|
extend<T extends LockableData = LockableData>(paths: (string | Partial<T>)[], strategy?: MergeStrategy): Promise<T>;
|
|
@@ -238,7 +238,7 @@ declare class ConfigService implements GlobalConfig {
|
|
|
238
238
|
|
|
239
239
|
declare class FileSystemService {
|
|
240
240
|
private static instance;
|
|
241
|
-
private
|
|
241
|
+
private logger;
|
|
242
242
|
constructor();
|
|
243
243
|
exists(path: string): boolean;
|
|
244
244
|
stats(path: string): fs.Stats;
|
|
@@ -261,7 +261,7 @@ declare class FileSystemService {
|
|
|
261
261
|
declare class YamlParser implements GenericParser {
|
|
262
262
|
static extensions: string[];
|
|
263
263
|
private static instance;
|
|
264
|
-
private
|
|
264
|
+
private logger;
|
|
265
265
|
constructor();
|
|
266
266
|
parse<T = unknown>(data: string | Buffer): T;
|
|
267
267
|
stringify<T = any>(data: T): string;
|
|
@@ -270,7 +270,7 @@ declare class YamlParser implements GenericParser {
|
|
|
270
270
|
declare class JsonParser implements GenericParser {
|
|
271
271
|
static extensions: string[];
|
|
272
272
|
private static instance;
|
|
273
|
-
private
|
|
273
|
+
private logger;
|
|
274
274
|
constructor();
|
|
275
275
|
parse<T = unknown>(data: string | Buffer): T;
|
|
276
276
|
stringify<T = any>(data: T): string;
|
|
@@ -283,10 +283,11 @@ interface ValidatorServiceOptions {
|
|
|
283
283
|
|
|
284
284
|
declare class ValidatorService {
|
|
285
285
|
options?: ValidatorServiceOptions;
|
|
286
|
-
private
|
|
286
|
+
private static instance;
|
|
287
|
+
private logger;
|
|
287
288
|
constructor(options?: ValidatorServiceOptions);
|
|
288
|
-
validate<T extends Record<PropertyKey, any>>(classType: ClassType<T>, object: T): Promise<T>;
|
|
289
|
-
validateSync<T extends Record<PropertyKey, any>>(classType: ClassType<T>, object: T): T;
|
|
289
|
+
validate<T extends Record<PropertyKey, any>>(classType: ClassType<T>, object: T, options?: ValidatorServiceOptions): Promise<T>;
|
|
290
|
+
validateSync<T extends Record<PropertyKey, any>>(classType: ClassType<T>, object: T, options?: ValidatorServiceOptions): T;
|
|
290
291
|
private logValidationError;
|
|
291
292
|
}
|
|
292
293
|
|
|
@@ -309,7 +310,10 @@ declare type DeepPartial<T> = {
|
|
|
309
310
|
};
|
|
310
311
|
|
|
311
312
|
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 {
|
|
312
|
-
|
|
313
|
+
argv: string[];
|
|
314
|
+
config: Config;
|
|
315
|
+
static get globalFlags(): FlagInput;
|
|
316
|
+
static set globalFlags(flags: FlagInput);
|
|
313
317
|
logger: Logger;
|
|
314
318
|
tasks: Manager<Ctx, 'default' | 'verbose' | 'silent' | 'simple'>;
|
|
315
319
|
validator: ValidatorService;
|
|
@@ -319,8 +323,7 @@ declare class Command<Ctx extends ListrContext = ListrContext, Flags extends Rec
|
|
|
319
323
|
store: StoreService<Store>;
|
|
320
324
|
flags: Flags;
|
|
321
325
|
args: Args;
|
|
322
|
-
|
|
323
|
-
init(): Promise<void>;
|
|
326
|
+
constructor(argv: string[], config: Config);
|
|
324
327
|
/**
|
|
325
328
|
* Construct the class if you dont want to extend init or constructor.
|
|
326
329
|
*/
|
|
@@ -329,25 +332,27 @@ declare class Command<Ctx extends ListrContext = ListrContext, Flags extends Rec
|
|
|
329
332
|
* Deconstruct the class if you dont want to extend finally or catch.
|
|
330
333
|
*/
|
|
331
334
|
shouldRunAfter(_ctx?: Ctx): void | Promise<void>;
|
|
332
|
-
run(): Promise<
|
|
333
|
-
|
|
334
|
-
finally<C extends Ctx = Ctx>(): Promise<{
|
|
335
|
-
ctx: C;
|
|
336
|
-
}>;
|
|
337
|
-
/** Catch any error occurred during command. */
|
|
338
|
-
catch(e: Error): Promise<void>;
|
|
335
|
+
run<T = void>(): Promise<T>;
|
|
336
|
+
_run<T>(): Promise<T | undefined>;
|
|
339
337
|
exit(code?: number): void;
|
|
340
338
|
/** Run all tasks from task manager. */
|
|
341
339
|
runTasks<C extends Ctx = Ctx>(): Promise<C>;
|
|
342
340
|
/** Gets prompt from user. */
|
|
343
341
|
prompt<T = any>(options: PromptOptions): Promise<T>;
|
|
344
|
-
setCtxDefaults(...defaults: SetCtxDefaultsOptions<Ctx>[]): void;
|
|
345
|
-
setCtxAssign<K = Record<PropertyKey, any>>(...assigns: SetCtxAssignOptions<K>[]): void;
|
|
342
|
+
protected setCtxDefaults(...defaults: SetCtxDefaultsOptions<Ctx>[]): void;
|
|
343
|
+
protected setCtxAssign<K = Record<PropertyKey, any>>(...assigns: SetCtxAssignOptions<K>[]): void;
|
|
344
|
+
/** Initial functions / constructor */
|
|
345
|
+
protected init(): Promise<void>;
|
|
346
|
+
/** Tasks to run before end of the command. */
|
|
347
|
+
protected finally<C extends Ctx = Ctx>(): Promise<{
|
|
348
|
+
ctx: C;
|
|
349
|
+
}>;
|
|
350
|
+
/** Catch any error occurred during command. */
|
|
351
|
+
protected catch(e: Error): Promise<void>;
|
|
346
352
|
private greet;
|
|
347
353
|
}
|
|
348
354
|
|
|
349
355
|
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> {
|
|
350
|
-
static globalFlags: object;
|
|
351
356
|
choices: ConfigCommandChoices<CommandChoices>;
|
|
352
357
|
locker: LockerService<LockFile>;
|
|
353
358
|
protected ux: {
|
|
@@ -377,7 +382,7 @@ declare class ConfigCommand<CommandChoices extends string = string, LockFile = a
|
|
|
377
382
|
annotation(text: string, annotation: string): void;
|
|
378
383
|
flush(ms?: number): Promise<void>;
|
|
379
384
|
};
|
|
380
|
-
run(): Promise<
|
|
385
|
+
run<T = void>(): Promise<T>;
|
|
381
386
|
setup(): ConfigCommandSetup<CommandChoices, LockFile> | Promise<ConfigCommandSetup<CommandChoices, LockFile>>;
|
|
382
387
|
protected table(...options: Parameters<typeof CliUx.ux.table>): void;
|
|
383
388
|
protected select(): Promise<string>;
|
package/dist/index.js
CHANGED
|
@@ -106,11 +106,11 @@ var LogLevels = /* @__PURE__ */ ((LogLevels2) => {
|
|
|
106
106
|
return LogLevels2;
|
|
107
107
|
})(LogLevels || {});
|
|
108
108
|
var LogFieldStatus = /* @__PURE__ */ ((LogFieldStatus2) => {
|
|
109
|
-
LogFieldStatus2["RUN"] = "
|
|
110
|
-
LogFieldStatus2["END"] = "
|
|
111
|
-
LogFieldStatus2["STAGE"] = "
|
|
112
|
-
LogFieldStatus2["EXIT"] = "
|
|
113
|
-
LogFieldStatus2["TERMINATE"] = "
|
|
109
|
+
LogFieldStatus2["RUN"] = "run";
|
|
110
|
+
LogFieldStatus2["END"] = "end";
|
|
111
|
+
LogFieldStatus2["STAGE"] = "stage";
|
|
112
|
+
LogFieldStatus2["EXIT"] = "exit";
|
|
113
|
+
LogFieldStatus2["TERMINATE"] = "terminate";
|
|
114
114
|
return LogFieldStatus2;
|
|
115
115
|
})(LogFieldStatus || {});
|
|
116
116
|
|
|
@@ -165,13 +165,13 @@ var Logger = class {
|
|
|
165
165
|
return this.parseMessage("TRACE" /* TRACE */, data, args);
|
|
166
166
|
}
|
|
167
167
|
run(data, ...args) {
|
|
168
|
-
return this.parseMessage("INFO" /* INFO */, data, args, { status: "
|
|
168
|
+
return this.parseMessage("INFO" /* INFO */, data, args, { status: "run" /* RUN */ });
|
|
169
169
|
}
|
|
170
170
|
end(data, ...args) {
|
|
171
|
-
return this.parseMessage("INFO" /* INFO */, data, args, { status: "
|
|
171
|
+
return this.parseMessage("INFO" /* INFO */, data, args, { status: "end" /* END */ });
|
|
172
172
|
}
|
|
173
173
|
stage(data, ...args) {
|
|
174
|
-
return this.parseMessage("TRACE" /* TRACE */, data, args, { status: "
|
|
174
|
+
return this.parseMessage("TRACE" /* TRACE */, data, args, { status: "stage" /* STAGE */ });
|
|
175
175
|
}
|
|
176
176
|
initiateLogger() {
|
|
177
177
|
const logFormat = import_winston.format.printf(({ level, message, context, status }) => {
|
|
@@ -248,7 +248,7 @@ var Logger = class {
|
|
|
248
248
|
case "VERBOSE" /* VERBOSE */:
|
|
249
249
|
coloring = color.dim;
|
|
250
250
|
if (this.options?.useIcons) {
|
|
251
|
-
icon =
|
|
251
|
+
icon = "\u2607";
|
|
252
252
|
}
|
|
253
253
|
break;
|
|
254
254
|
case "DEBUG" /* DEBUG */:
|
|
@@ -262,7 +262,7 @@ var Logger = class {
|
|
|
262
262
|
coloring = color.magenta;
|
|
263
263
|
msgColoring = color.dim;
|
|
264
264
|
if (this.options?.useIcons) {
|
|
265
|
-
icon = "\
|
|
265
|
+
icon = "\u26B1";
|
|
266
266
|
}
|
|
267
267
|
break;
|
|
268
268
|
}
|
|
@@ -398,13 +398,12 @@ var import_path2 = require("path");
|
|
|
398
398
|
// src/lib/parser/json-parser.service.ts
|
|
399
399
|
var _JsonParser = class {
|
|
400
400
|
constructor() {
|
|
401
|
-
this.logger = new Logger(this.constructor.name);
|
|
402
401
|
if (_JsonParser.instance) {
|
|
403
402
|
return _JsonParser.instance;
|
|
404
|
-
} else {
|
|
405
|
-
_JsonParser.instance = this;
|
|
406
|
-
this.logger.trace("Created a new instance.");
|
|
407
403
|
}
|
|
404
|
+
_JsonParser.instance = this;
|
|
405
|
+
this.logger = new Logger(this.constructor.name);
|
|
406
|
+
this.logger.trace("Created a new instance.");
|
|
408
407
|
}
|
|
409
408
|
parse(data) {
|
|
410
409
|
try {
|
|
@@ -426,13 +425,12 @@ JsonParser.extensions = ["json"];
|
|
|
426
425
|
var import_yaml = require("yaml");
|
|
427
426
|
var _YamlParser = class {
|
|
428
427
|
constructor() {
|
|
429
|
-
this.logger = new Logger(this.constructor.name);
|
|
430
428
|
if (_YamlParser.instance) {
|
|
431
429
|
return _YamlParser.instance;
|
|
432
|
-
} else {
|
|
433
|
-
_YamlParser.instance = this;
|
|
434
|
-
this.logger.trace("Created a new instance.");
|
|
435
430
|
}
|
|
431
|
+
_YamlParser.instance = this;
|
|
432
|
+
this.logger = new Logger(this.constructor.name);
|
|
433
|
+
this.logger.trace("Created a new instance.");
|
|
436
434
|
}
|
|
437
435
|
parse(data) {
|
|
438
436
|
try {
|
|
@@ -455,11 +453,11 @@ var import_fs_extra = __toESM(require("fs-extra"));
|
|
|
455
453
|
var import_path = require("path");
|
|
456
454
|
var FileSystemService = class {
|
|
457
455
|
constructor() {
|
|
458
|
-
this.logger = new Logger(this.constructor.name);
|
|
459
456
|
if (FileSystemService.instance) {
|
|
460
457
|
return FileSystemService.instance;
|
|
461
458
|
} else {
|
|
462
459
|
FileSystemService.instance = this;
|
|
460
|
+
this.logger = new Logger(this.constructor.name);
|
|
463
461
|
this.logger.trace("Created a new instance.");
|
|
464
462
|
}
|
|
465
463
|
}
|
|
@@ -568,14 +566,14 @@ __name(FileSystemService, "FileSystemService");
|
|
|
568
566
|
var ParserService = class {
|
|
569
567
|
constructor(parsers) {
|
|
570
568
|
this.parsers = [YamlParser, JsonParser];
|
|
571
|
-
this.logger = new Logger(this.constructor.name);
|
|
572
|
-
this.fs = new FileSystemService();
|
|
573
569
|
if (ParserService.instance) {
|
|
574
570
|
return ParserService.instance;
|
|
575
571
|
} else {
|
|
576
572
|
if (parsers) {
|
|
577
573
|
this.parsers = parsers;
|
|
578
574
|
}
|
|
575
|
+
this.logger = new Logger(this.constructor.name);
|
|
576
|
+
this.fs = new FileSystemService();
|
|
579
577
|
ParserService.instance = this;
|
|
580
578
|
this.logger.trace("Created a new instance.");
|
|
581
579
|
}
|
|
@@ -805,13 +803,13 @@ __name(ConfigService, "ConfigService");
|
|
|
805
803
|
// src/lib/locker/locker.service.ts
|
|
806
804
|
var import_object_path_immutable2 = __toESM(require("object-path-immutable"));
|
|
807
805
|
var LockerService = class {
|
|
808
|
-
constructor(file, parser, root) {
|
|
806
|
+
constructor(file, parser, root, context) {
|
|
809
807
|
this.file = file;
|
|
810
808
|
this.parser = parser;
|
|
811
809
|
this.root = root;
|
|
812
810
|
this.toLock = [];
|
|
813
811
|
this.toUnlock = [];
|
|
814
|
-
this.logger = new Logger(this.constructor.name);
|
|
812
|
+
this.logger = new Logger(context ?? this.constructor.name);
|
|
815
813
|
this.fs = new FileSystemService();
|
|
816
814
|
}
|
|
817
815
|
hasLock() {
|
|
@@ -861,10 +859,10 @@ var LockerService = class {
|
|
|
861
859
|
parsed = d.data;
|
|
862
860
|
}
|
|
863
861
|
lock = import_object_path_immutable2.default.set(lock, path, parsed);
|
|
864
|
-
this.logger.verbose("Merge lock: %s", path);
|
|
862
|
+
this.logger.verbose("Merge lock: %s -> %o", path, parsed);
|
|
865
863
|
} else {
|
|
866
864
|
lock = import_object_path_immutable2.default.set(lock, path, d.data);
|
|
867
|
-
this.logger.verbose("Override lock: %s", path);
|
|
865
|
+
this.logger.verbose("Override lock: %s -> %o", path, d.data);
|
|
868
866
|
}
|
|
869
867
|
})
|
|
870
868
|
);
|
|
@@ -884,12 +882,12 @@ var LockerService = class {
|
|
|
884
882
|
}
|
|
885
883
|
const path = this.buildPath(d);
|
|
886
884
|
lock = import_object_path_immutable2.default.del(lock, path);
|
|
887
|
-
this.logger.verbose("Unlocked: %s", path
|
|
885
|
+
this.logger.verbose("Unlocked: %s", path);
|
|
888
886
|
})
|
|
889
887
|
);
|
|
890
888
|
} else {
|
|
891
889
|
lock = import_object_path_immutable2.default.del(lock, this.root);
|
|
892
|
-
this.logger.verbose("Unlocked module: %s", this.root
|
|
890
|
+
this.logger.verbose("Unlocked module: %s", this.root);
|
|
893
891
|
}
|
|
894
892
|
await this.write(lock);
|
|
895
893
|
}
|
|
@@ -952,7 +950,9 @@ var import_class_validator = require("class-validator");
|
|
|
952
950
|
var ValidatorService = class {
|
|
953
951
|
constructor(options) {
|
|
954
952
|
this.options = options;
|
|
955
|
-
|
|
953
|
+
if (ValidatorService.instance) {
|
|
954
|
+
return ValidatorService.instance;
|
|
955
|
+
}
|
|
956
956
|
this.options = {
|
|
957
957
|
validator: {
|
|
958
958
|
skipMissingProperties: true,
|
|
@@ -963,10 +963,13 @@ var ValidatorService = class {
|
|
|
963
963
|
transformer: { enableImplicitConversion: true },
|
|
964
964
|
...options ?? {}
|
|
965
965
|
};
|
|
966
|
+
this.logger = new Logger(this.constructor.name);
|
|
967
|
+
ValidatorService.instance = this;
|
|
968
|
+
this.logger.trace("Created a new instance.");
|
|
966
969
|
}
|
|
967
|
-
async validate(classType, object) {
|
|
968
|
-
const classObject = (0, import_class_transformer.plainToClass)(classType, object, this.options.transformer);
|
|
969
|
-
const errors = await (0, import_class_validator.validate)(classObject, this.options.validator);
|
|
970
|
+
async validate(classType, object, options) {
|
|
971
|
+
const classObject = (0, import_class_transformer.plainToClass)(classType, object, { ...this.options.transformer, ...options.transformer ?? {} });
|
|
972
|
+
const errors = await (0, import_class_validator.validate)(classObject, { ...this.options.validator, ...options.validator ?? {} });
|
|
970
973
|
if (errors.length) {
|
|
971
974
|
errors.forEach((error) => {
|
|
972
975
|
this.logValidationError(error);
|
|
@@ -975,9 +978,9 @@ var ValidatorService = class {
|
|
|
975
978
|
}
|
|
976
979
|
return classObject;
|
|
977
980
|
}
|
|
978
|
-
validateSync(classType, object) {
|
|
979
|
-
const classObject = (0, import_class_transformer.plainToClass)(classType, object, this.options.transformer);
|
|
980
|
-
const errors = (0, import_class_validator.validateSync)(classObject, this.options.validator);
|
|
981
|
+
validateSync(classType, object, options) {
|
|
982
|
+
const classObject = (0, import_class_transformer.plainToClass)(classType, object, { ...this.options.transformer, ...options.transformer ?? {} });
|
|
983
|
+
const errors = (0, import_class_validator.validateSync)(classObject, { ...this.options.validator, ...options.validator ?? {} });
|
|
981
984
|
if (errors.length) {
|
|
982
985
|
errors.forEach((error) => {
|
|
983
986
|
this.logValidationError(error);
|
|
@@ -1029,13 +1032,68 @@ __name(setup, "setup");
|
|
|
1029
1032
|
|
|
1030
1033
|
// src/commands/base.command.ts
|
|
1031
1034
|
var Command = class extends import_core3.Command {
|
|
1032
|
-
constructor() {
|
|
1033
|
-
super(
|
|
1034
|
-
this.
|
|
1035
|
+
constructor(argv, config) {
|
|
1036
|
+
super(argv, config);
|
|
1037
|
+
this.argv = argv;
|
|
1038
|
+
this.config = config;
|
|
1035
1039
|
this.flags = {};
|
|
1036
1040
|
this.args = {};
|
|
1037
1041
|
}
|
|
1042
|
+
static get globalFlags() {
|
|
1043
|
+
return { CLI_FLAGS, ...this._globalFlags };
|
|
1044
|
+
}
|
|
1045
|
+
static set globalFlags(flags) {
|
|
1046
|
+
this._globalFlags = Object.assign({}, this.globalFlags, flags);
|
|
1047
|
+
this.flags = {};
|
|
1048
|
+
}
|
|
1049
|
+
shouldRunBefore() {
|
|
1050
|
+
}
|
|
1051
|
+
shouldRunAfter(_ctx) {
|
|
1052
|
+
}
|
|
1053
|
+
run() {
|
|
1054
|
+
throw new Error("The command should have a run function to do something!");
|
|
1055
|
+
}
|
|
1056
|
+
async _run() {
|
|
1057
|
+
let result;
|
|
1058
|
+
try {
|
|
1059
|
+
delete process.env[this.config.scopedEnvVarKey("REDIRECTED")];
|
|
1060
|
+
await this.init();
|
|
1061
|
+
result = await this.run();
|
|
1062
|
+
} catch (error) {
|
|
1063
|
+
await this.catch(error);
|
|
1064
|
+
} finally {
|
|
1065
|
+
await this.finally();
|
|
1066
|
+
}
|
|
1067
|
+
if (result && this.jsonEnabled()) {
|
|
1068
|
+
import_core2.CliUx.ux.styledJSON(this.toSuccessJson(result));
|
|
1069
|
+
}
|
|
1070
|
+
return result;
|
|
1071
|
+
}
|
|
1072
|
+
exit(code) {
|
|
1073
|
+
this.logger.trace("Code -> %d", code, { status: "exit" /* EXIT */ });
|
|
1074
|
+
process.exit(code ?? 0);
|
|
1075
|
+
}
|
|
1076
|
+
runTasks() {
|
|
1077
|
+
return this.tasks.runAll();
|
|
1078
|
+
}
|
|
1079
|
+
prompt(options) {
|
|
1080
|
+
return (0, import_listr23.createPrompt)(options, {
|
|
1081
|
+
stdout: process.stdout,
|
|
1082
|
+
cancelCallback: () => {
|
|
1083
|
+
throw new Error("Cancelled prompt.");
|
|
1084
|
+
}
|
|
1085
|
+
});
|
|
1086
|
+
}
|
|
1087
|
+
setCtxDefaults(...defaults) {
|
|
1088
|
+
setCtxDefaults(this.tasks.options.ctx, ...defaults);
|
|
1089
|
+
this.logger.trace("updated with defaults: %o", this.tasks.options.ctx, { status: "ctx" });
|
|
1090
|
+
}
|
|
1091
|
+
setCtxAssign(...assigns) {
|
|
1092
|
+
setCtxAssign(this.tasks.options.ctx, ...assigns);
|
|
1093
|
+
this.logger.trace("updated with assign: %o", this.tasks.options.ctx, { status: "ctx" });
|
|
1094
|
+
}
|
|
1038
1095
|
async init() {
|
|
1096
|
+
await super.init();
|
|
1039
1097
|
let err;
|
|
1040
1098
|
try {
|
|
1041
1099
|
const { flags, args } = await this.parse();
|
|
@@ -1051,6 +1109,7 @@ var Command = class extends import_core3.Command {
|
|
|
1051
1109
|
});
|
|
1052
1110
|
const context = this.cs.command.id ? this.cs.command.id : this.cs.command.name;
|
|
1053
1111
|
this.logger = new Logger(context, { level: this.cs.logLevel });
|
|
1112
|
+
this.store = new StoreService();
|
|
1054
1113
|
this.greet();
|
|
1055
1114
|
if (err) {
|
|
1056
1115
|
throw err;
|
|
@@ -1079,20 +1138,13 @@ var Command = class extends import_core3.Command {
|
|
|
1079
1138
|
});
|
|
1080
1139
|
}
|
|
1081
1140
|
process.on("SIGINT", () => {
|
|
1082
|
-
this.logger.fatal("Caught terminate signal.", { status: "
|
|
1141
|
+
this.logger.fatal("Caught terminate signal.", { status: "terminate" /* TERMINATE */ });
|
|
1083
1142
|
process.exit(1);
|
|
1084
1143
|
});
|
|
1085
1144
|
this.logger.stage("Running shouldRunBefore.");
|
|
1086
1145
|
await this.shouldRunBefore();
|
|
1087
1146
|
this.logger.stage("Finished shouldRunBefore.");
|
|
1088
1147
|
}
|
|
1089
|
-
shouldRunBefore() {
|
|
1090
|
-
}
|
|
1091
|
-
shouldRunAfter(_ctx) {
|
|
1092
|
-
}
|
|
1093
|
-
run() {
|
|
1094
|
-
throw new Error("The command should have a run function to do something!");
|
|
1095
|
-
}
|
|
1096
1148
|
async finally() {
|
|
1097
1149
|
this.logger.stage("Running tasks.");
|
|
1098
1150
|
const ctx = await this.runTasks();
|
|
@@ -1108,29 +1160,6 @@ var Command = class extends import_core3.Command {
|
|
|
1108
1160
|
this.exit(127);
|
|
1109
1161
|
return;
|
|
1110
1162
|
}
|
|
1111
|
-
exit(code) {
|
|
1112
|
-
this.logger.trace("Code -> %d", code, { status: "EXIT" /* EXIT */ });
|
|
1113
|
-
process.exit(code ?? 0);
|
|
1114
|
-
}
|
|
1115
|
-
runTasks() {
|
|
1116
|
-
return this.tasks.runAll();
|
|
1117
|
-
}
|
|
1118
|
-
prompt(options) {
|
|
1119
|
-
return (0, import_listr23.createPrompt)(options, {
|
|
1120
|
-
stdout: process.stdout,
|
|
1121
|
-
cancelCallback: () => {
|
|
1122
|
-
throw new Error("Cancelled prompt.");
|
|
1123
|
-
}
|
|
1124
|
-
});
|
|
1125
|
-
}
|
|
1126
|
-
setCtxDefaults(...defaults) {
|
|
1127
|
-
setCtxDefaults(this.tasks.options.ctx, ...defaults);
|
|
1128
|
-
this.logger.trace("updated with defaults: %o", this.tasks.options.ctx, { status: "ctx" });
|
|
1129
|
-
}
|
|
1130
|
-
setCtxAssign(...assigns) {
|
|
1131
|
-
setCtxAssign(this.tasks.options.ctx, ...assigns);
|
|
1132
|
-
this.logger.trace("updated with assign: %o", this.tasks.options.ctx, { status: "ctx" });
|
|
1133
|
-
}
|
|
1134
1163
|
greet() {
|
|
1135
1164
|
if (this.cs.isSilent || this.cs.json) {
|
|
1136
1165
|
return;
|
|
@@ -1143,7 +1172,6 @@ var Command = class extends import_core3.Command {
|
|
|
1143
1172
|
}
|
|
1144
1173
|
};
|
|
1145
1174
|
__name(Command, "Command");
|
|
1146
|
-
Command.globalFlags = CLI_FLAGS;
|
|
1147
1175
|
|
|
1148
1176
|
// src/commands/config.command.ts
|
|
1149
1177
|
var ConfigCommand = class extends Command {
|
|
@@ -1159,7 +1187,7 @@ var ConfigCommand = class extends Command {
|
|
|
1159
1187
|
this.logger.stage("User selection for configuration.");
|
|
1160
1188
|
const response = await this.select();
|
|
1161
1189
|
this.logger.stage("Will run selection: %s", response);
|
|
1162
|
-
return this.choices[response]();
|
|
1190
|
+
return this.choices[response].bind(this)();
|
|
1163
1191
|
}
|
|
1164
1192
|
setup() {
|
|
1165
1193
|
throw new Error("The command should be setup first!");
|
|
@@ -1177,7 +1205,6 @@ var ConfigCommand = class extends Command {
|
|
|
1177
1205
|
}
|
|
1178
1206
|
};
|
|
1179
1207
|
__name(ConfigCommand, "ConfigCommand");
|
|
1180
|
-
ConfigCommand.globalFlags = CLI_FLAGS;
|
|
1181
1208
|
|
|
1182
1209
|
// src/hooks/not-found.hook.ts
|
|
1183
1210
|
var import_core4 = require("@oclif/core");
|