@sorrell/cli-utilities 1.0.26 ā 1.0.28
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/Distribution/Listr.Types.d.ts +4 -0
- package/Distribution/Listr.Types.d.ts.map +1 -0
- package/Distribution/Listr.Types.js +7 -0
- package/Distribution/Listr.Types.js.map +1 -0
- package/Distribution/Listr.d.ts +22 -0
- package/Distribution/Listr.d.ts.map +1 -0
- package/Distribution/Listr.js +57 -0
- package/Distribution/Listr.js.map +1 -0
- package/Distribution/Print/Print.d.ts +4 -2
- package/Distribution/Print/Print.d.ts.map +1 -1
- package/Distribution/Print/Print.js +25 -3
- package/Distribution/Print/Print.js.map +1 -1
- package/package.json +3 -1
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { DefaultRenderer, ListrDefaultRenderer, ListrGetRendererClassFromValue, ListrTask, ListrTaskWrapper } from "listr2";
|
|
2
|
+
export type Wrapper<ContextType> = ListrTaskWrapper<ContextType, ListrDefaultRenderer, ListrDefaultRenderer>;
|
|
3
|
+
export type ListrConstructorTask<ContextType> = ListrTask<ContextType, ListrGetRendererClassFromValue<typeof DefaultRenderer>, ListrGetRendererClassFromValue<typeof DefaultRenderer>> | Array<ListrTask<ContextType, ListrGetRendererClassFromValue<typeof DefaultRenderer>, ListrGetRendererClassFromValue<typeof DefaultRenderer>>>;
|
|
4
|
+
//# sourceMappingURL=Listr.Types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Listr.Types.d.ts","sourceRoot":"","sources":["../Source/Listr.Types.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EACR,eAAe,EACf,oBAAoB,EACpB,8BAA8B,EAC9B,SAAS,EACT,gBAAgB,EAAE,MAAM,QAAQ,CAAC;AAErC,MAAM,MAAM,OAAO,CAAC,WAAW,IAAI,gBAAgB,CAC/C,WAAW,EACX,oBAAoB,EACpB,oBAAoB,CACvB,CAAC;AAEF,MAAM,MAAM,oBAAoB,CAAC,WAAW,IACtC,SAAS,CACP,WAAW,EACX,8BAA8B,CAAC,OAAO,eAAe,CAAC,EACtD,8BAA8B,CAAC,OAAO,eAAe,CAAC,CAAC,GACzD,KAAK,CAAC,SAAS,CACb,WAAW,EACX,8BAA8B,CAAC,OAAO,eAAe,CAAC,EACtD,8BAA8B,CAAC,OAAO,eAAe,CAAC,CAAC,CAC1D,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Listr.Types.js","sourceRoot":"","sources":["../Source/Listr.Types.ts"],"names":[],"mappings":"AAAA;;;;GAIG"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { type DefaultRenderer, type ListrBaseClassOptions, type ListrTaskObject } from "listr2";
|
|
2
|
+
import type { ListrConstructorTask } from "./Listr.Types.js";
|
|
3
|
+
/** A string-only {@link Error} used by {@link Listr} to show nicely-formatted errors. */
|
|
4
|
+
export declare class SimpleError extends Error {
|
|
5
|
+
constructor(Message: string);
|
|
6
|
+
TheMessage: string;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* A wrapper for `new Listr` that handles errors nicely.
|
|
10
|
+
*
|
|
11
|
+
* @typeParam ContextType - The type of the `listr2` context used by the {@link Task}.
|
|
12
|
+
*
|
|
13
|
+
* @param Task - The task(s) to run.
|
|
14
|
+
* @param GenericErrorMessage - The error message that is shown if the {@link Task | task(s)} throw(s)
|
|
15
|
+
* something other than a {@link SimpleError}.
|
|
16
|
+
* @param Options - *(Optional)* The {@link ListrBaseClassOptions} used to customize the
|
|
17
|
+
* {@link Task | task(s)}.
|
|
18
|
+
* @param ParentTask - *(Optional)* The {@link ListrTaskObject | parent task} of which the
|
|
19
|
+
* {@link Task | task(s)} are (a) descendant(s).
|
|
20
|
+
*/
|
|
21
|
+
export declare function RunListr<ContextType = unknown>(Task: ListrConstructorTask<ContextType>, GenericErrorMessage: string, Options?: ListrBaseClassOptions<ContextType, typeof DefaultRenderer, typeof DefaultRenderer>, ParentTask?: ListrTaskObject<unknown, typeof DefaultRenderer, typeof DefaultRenderer>): Promise<void>;
|
|
22
|
+
//# sourceMappingURL=Listr.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Listr.d.ts","sourceRoot":"","sources":["../Source/Listr.ts"],"names":[],"mappings":"AAMA,OAAO,EACH,KAAK,eAAe,EACpB,KAAK,qBAAqB,EAC1B,KAAK,eAAe,EACI,MAAM,QAAQ,CAAC;AAC3C,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAE7D,yFAAyF;AACzF,qBAAa,WAAY,SAAQ,KAAK;gBAEf,OAAO,EAAE,MAAM;IAM3B,UAAU,EAAE,MAAM,CAAC;CAC7B;AA8BD;;;;;;;;;;;;GAYG;AACH,wBAAsB,QAAQ,CAAC,WAAW,GAAG,OAAO,EAChD,IAAI,EAAE,oBAAoB,CAAC,WAAW,CAAC,EACvC,mBAAmB,EAAE,MAAM,EAC3B,OAAO,CAAC,EAAE,qBAAqB,CAAC,WAAW,EAAE,OAAO,eAAe,EAAE,OAAO,eAAe,CAAC,EAC5F,UAAU,CAAC,EAAE,eAAe,CACxB,OAAO,EACP,OAAO,eAAe,EACtB,OAAO,eAAe,CACzB,GACF,OAAO,CAAC,IAAI,CAAC,CAkBf"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/* File: Listr.ts
|
|
2
|
+
* Author: Gage Sorrell <gage@sorrell.sh>
|
|
3
|
+
* Copyright: (c) 2026 Gage Sorrell
|
|
4
|
+
* License: MIT
|
|
5
|
+
*/
|
|
6
|
+
import { Listr as OriginalListr } from "listr2";
|
|
7
|
+
/** A string-only {@link Error} used by {@link Listr} to show nicely-formatted errors. */
|
|
8
|
+
export class SimpleError extends Error {
|
|
9
|
+
constructor(Message) {
|
|
10
|
+
super();
|
|
11
|
+
this.TheMessage = Message;
|
|
12
|
+
}
|
|
13
|
+
TheMessage;
|
|
14
|
+
}
|
|
15
|
+
;
|
|
16
|
+
class Listr extends OriginalListr {
|
|
17
|
+
constructor(Task, Options, ParentTask) {
|
|
18
|
+
if (Options === undefined && ParentTask === undefined) {
|
|
19
|
+
super(Task);
|
|
20
|
+
}
|
|
21
|
+
else if (Options !== undefined && ParentTask === undefined) {
|
|
22
|
+
super(Task, Options);
|
|
23
|
+
}
|
|
24
|
+
else if (Options !== undefined && ParentTask !== undefined) {
|
|
25
|
+
super(Task, Options, ParentTask);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
;
|
|
30
|
+
/**
|
|
31
|
+
* A wrapper for `new Listr` that handles errors nicely.
|
|
32
|
+
*
|
|
33
|
+
* @typeParam ContextType - The type of the `listr2` context used by the {@link Task}.
|
|
34
|
+
*
|
|
35
|
+
* @param Task - The task(s) to run.
|
|
36
|
+
* @param GenericErrorMessage - The error message that is shown if the {@link Task | task(s)} throw(s)
|
|
37
|
+
* something other than a {@link SimpleError}.
|
|
38
|
+
* @param Options - *(Optional)* The {@link ListrBaseClassOptions} used to customize the
|
|
39
|
+
* {@link Task | task(s)}.
|
|
40
|
+
* @param ParentTask - *(Optional)* The {@link ListrTaskObject | parent task} of which the
|
|
41
|
+
* {@link Task | task(s)} are (a) descendant(s).
|
|
42
|
+
*/
|
|
43
|
+
export async function RunListr(Task, GenericErrorMessage, Options, ParentTask) {
|
|
44
|
+
try {
|
|
45
|
+
await new Listr(Task, Options, ParentTask);
|
|
46
|
+
}
|
|
47
|
+
catch (ListrError) {
|
|
48
|
+
if (ListrError instanceof SimpleError) {
|
|
49
|
+
console.error(`šØ ${ListrError.TheMessage}`);
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
console.dir(ListrError);
|
|
53
|
+
console.error(`\nšØ ${GenericErrorMessage}. The error is printed above.`);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
//# sourceMappingURL=Listr.js.map
|
|
@@ -0,0 +1 @@
|
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C,UAAU,CAAC,CAAC;YACxB,OAAO,CAAC,KAAK,CAAC,QAAS,mBAAoB,gCAAgC,CAAC,CAAC;QACjF,CAAC;IACL,CAAC;AACL,CAAC"}
|
|
@@ -31,10 +31,12 @@ export declare function Format(Message: string, Rules: FormatRules): string;
|
|
|
31
31
|
* Creates a function that formats a given `string` with the given {@link Rules}.
|
|
32
32
|
*
|
|
33
33
|
* @param Rules - The {@link FormatRules} used to format messages passed to the
|
|
34
|
-
* returned function.
|
|
34
|
+
* returned function. If multiple are given, then the keys will be pooled. If
|
|
35
|
+
* multiple {@link Rules} share a given key, then the respective formatter functions
|
|
36
|
+
* will be composed in the order of the given {@link Rules} objects.
|
|
35
37
|
*
|
|
36
38
|
* @returns A function that will format the `Message` passed to it according to the
|
|
37
39
|
* {@link Rules} passed to this function.
|
|
38
40
|
*/
|
|
39
|
-
export declare function MakeFormatter(Rules: FormatRules): Formatter;
|
|
41
|
+
export declare function MakeFormatter(...Rules: [FormatRules] | Array<FormatRules>): Formatter;
|
|
40
42
|
//# sourceMappingURL=Print.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Print.d.ts","sourceRoot":"","sources":["../../Source/Print/Print.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Print.d.ts","sourceRoot":"","sources":["../../Source/Print/Print.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAiB/D;;;;;;GAMG;AACH,wBAAgB,IAAI,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAG5C;AAED;;;;;;;;GAQG;AACH,wBAAgB,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAGzC;AAED;;;;;;;;GAQG;AACH,wBAAgB,MAAM,CAClB,OAAO,EAAE,MAAM,EACf,KAAK,EAAE,WAAW,GACnB,MAAM,CAYR;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,aAAa,CAAC,GAAG,KAAK,EAAE,CAAE,WAAW,CAAE,GAAG,KAAK,CAAC,WAAW,CAAC,GAAG,SAAS,CAsCvF"}
|
|
@@ -60,14 +60,36 @@ export function Format(Message, Rules) {
|
|
|
60
60
|
* Creates a function that formats a given `string` with the given {@link Rules}.
|
|
61
61
|
*
|
|
62
62
|
* @param Rules - The {@link FormatRules} used to format messages passed to the
|
|
63
|
-
* returned function.
|
|
63
|
+
* returned function. If multiple are given, then the keys will be pooled. If
|
|
64
|
+
* multiple {@link Rules} share a given key, then the respective formatter functions
|
|
65
|
+
* will be composed in the order of the given {@link Rules} objects.
|
|
64
66
|
*
|
|
65
67
|
* @returns A function that will format the `Message` passed to it according to the
|
|
66
68
|
* {@link Rules} passed to this function.
|
|
67
69
|
*/
|
|
68
|
-
export function MakeFormatter(Rules) {
|
|
70
|
+
export function MakeFormatter(...Rules) {
|
|
71
|
+
/* eslint-disable-next-line jsdoc/require-jsdoc */
|
|
72
|
+
function ComposeRules() {
|
|
73
|
+
if (Rules.length === 1) {
|
|
74
|
+
return Rules[0];
|
|
75
|
+
}
|
|
76
|
+
return Rules.reduce((PreviousValue, CurrentValue) => {
|
|
77
|
+
const NewValue = { ...PreviousValue };
|
|
78
|
+
Object.keys(CurrentValue).forEach((Key) => {
|
|
79
|
+
if (Key in NewValue && PreviousValue[Key] !== undefined && CurrentValue[Key] !== undefined) {
|
|
80
|
+
const OriginalFunction = PreviousValue[Key];
|
|
81
|
+
const CurrentFunction = CurrentValue[Key];
|
|
82
|
+
NewValue[Key] = function (Message) {
|
|
83
|
+
return CurrentFunction(OriginalFunction(Message));
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
return NewValue;
|
|
88
|
+
}, {});
|
|
89
|
+
}
|
|
90
|
+
const OutRules = ComposeRules();
|
|
69
91
|
return function (Message) {
|
|
70
|
-
return Format(Message,
|
|
92
|
+
return Format(Message, OutRules);
|
|
71
93
|
};
|
|
72
94
|
}
|
|
73
95
|
//# sourceMappingURL=Print.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Print.js","sourceRoot":"","sources":["../../Source/Print/Print.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;
|
|
1
|
+
{"version":3,"file":"Print.js","sourceRoot":"","sources":["../../Source/Print/Print.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAEvD;;;;;;GAMG;AACH,SAAS,UAAU,CAAC,OAAe;IAE/B,OAAO,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;AAChC,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,IAAI,CAAC,OAAe;IAEhC,OAAO,UAAU,CAAC,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC;AAC1C,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,IAAI,CAAC,IAAY;IAE7B,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC;AACjC,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,MAAM,CAClB,OAAe,EACf,KAAkB;IAGlB,OAAO,GAAG,UAAU,CAAC,OAAO,CAAC,CAAC;IAE9B,MAAM,WAAW,GAAsB,gBAAgB,CAAC,KAAK,CAAC,CAAC;IAE/D,KAAK,MAAM,CAAE,KAAK,EAAE,SAAS,CAAE,IAAI,WAAW,EAC9C,CAAC;QACG,OAAO,GAAG,OAAO,CAAC,UAAU,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;IACnD,CAAC;IAED,OAAO,OAAO,CAAC;AACnB,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,UAAU,aAAa,CAAC,GAAG,KAA2C;IAExE,kDAAkD;IAClD,SAAS,YAAY;QAEjB,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EACtB,CAAC;YACG,OAAO,KAAK,CAAC,CAAC,CAAC,CAAC;QACpB,CAAC;QAED,OAAO,KAAK,CAAC,MAAM,CAAC,CAAC,aAA0B,EAAE,YAAyB,EAAe,EAAE;YAEvF,MAAM,QAAQ,GAAgB,EAAE,GAAG,aAAa,EAAE,CAAC;YAEnD,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,OAAO,CAAC,CAAC,GAAW,EAAQ,EAAE;gBAEpD,IAAI,GAAG,IAAI,QAAQ,IAAI,aAAa,CAAC,GAAG,CAAC,KAAK,SAAS,IAAI,YAAY,CAAC,GAAG,CAAC,KAAK,SAAS,EAC1F,CAAC;oBACG,MAAM,gBAAgB,GAAc,aAAa,CAAC,GAAG,CAAC,CAAC;oBACvD,MAAM,eAAe,GAAc,YAAY,CAAC,GAAG,CAAC,CAAC;oBAErD,QAAQ,CAAC,GAAG,CAAC,GAAG,UAAS,OAAe;wBAEpC,OAAO,eAAe,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC,CAAC;oBACtD,CAAC,CAAC;gBACN,CAAC;YACL,CAAC,CAAC,CAAC;YAEH,OAAO,QAAQ,CAAC;QACpB,CAAC,EAAE,EAAG,CAAC,CAAC;IACZ,CAAC;IAED,MAAM,QAAQ,GAAgB,YAAY,EAAE,CAAC;IAE7C,OAAO,UAAS,OAAe;QAE3B,OAAO,MAAM,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;IACrC,CAAC,CAAC;AACN,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sorrell/cli-utilities",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.28",
|
|
4
4
|
"description": "Utilities for CLI tools.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cli",
|
|
@@ -44,12 +44,14 @@
|
|
|
44
44
|
"@inquirer/core": "^11.1.7",
|
|
45
45
|
"@inquirer/prompts": "^8.3.2",
|
|
46
46
|
"@inquirer/type": "^4.0.4",
|
|
47
|
+
"@listr2/prompt-adapter-enquirer": "^4.2.1",
|
|
47
48
|
"@sorrell/inquirer-file-selector": "^1.0.4",
|
|
48
49
|
"@sorrell/utilities": "^1.1.11",
|
|
49
50
|
"chalk": "^5.6.2",
|
|
50
51
|
"cli-table3": "^0.6.5",
|
|
51
52
|
"clipboardy": "^5.3.1",
|
|
52
53
|
"commander": "^14.0.3",
|
|
54
|
+
"listr2": "^10.2.1",
|
|
53
55
|
"ora": "^9.3.0"
|
|
54
56
|
}
|
|
55
57
|
}
|