@node-core/utils 7.1.0 → 7.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/components/metadata.js +2 -1
- package/lib/ci/build-types/test_build.js +3 -3
- package/lib/ci/failure_aggregator.js +2 -2
- package/lib/ci/run_ci.js +3 -2
- package/lib/cli.js +6 -6
- package/lib/figures.js +6 -6
- package/lib/prepare_security.js +20 -21
- package/lib/request.js +1 -1
- package/lib/update-v8/backport.js +3 -4
- package/lib/utils.js +4 -2
- package/lib/verbosity.js +2 -4
- package/node_modules/@listr2/{prompt-adapter-enquirer → prompt-adapter-inquirer}/README.md +4 -4
- package/node_modules/@listr2/prompt-adapter-inquirer/dist/index.d.mts +21 -0
- package/node_modules/@listr2/prompt-adapter-inquirer/dist/index.mjs +46 -0
- package/node_modules/@listr2/prompt-adapter-inquirer/node_modules/@inquirer/type/LICENSE +22 -0
- package/node_modules/@listr2/prompt-adapter-inquirer/node_modules/@inquirer/type/dist/index.d.ts +2 -0
- package/node_modules/@listr2/prompt-adapter-inquirer/node_modules/@inquirer/type/dist/index.js +2 -0
- package/node_modules/@listr2/prompt-adapter-inquirer/node_modules/@inquirer/type/dist/inquirer.d.ts +35 -0
- package/node_modules/@listr2/prompt-adapter-inquirer/node_modules/@inquirer/type/dist/inquirer.js +1 -0
- package/node_modules/@listr2/prompt-adapter-inquirer/node_modules/@inquirer/type/dist/utils.d.ts +34 -0
- package/node_modules/@listr2/prompt-adapter-inquirer/node_modules/@inquirer/type/dist/utils.js +2 -0
- package/node_modules/@listr2/prompt-adapter-inquirer/node_modules/@inquirer/type/package.json +88 -0
- package/node_modules/@listr2/{prompt-adapter-enquirer → prompt-adapter-inquirer}/package.json +25 -20
- package/node_modules/{log-update/node_modules/ansi-escapes → ansi-escapes}/base.d.ts +48 -3
- package/node_modules/{log-update/node_modules/ansi-escapes → ansi-escapes}/base.js +58 -19
- package/node_modules/{log-update/node_modules/ansi-escapes → ansi-escapes}/package.json +1 -1
- package/node_modules/{log-update/node_modules/ansi-escapes → ansi-escapes}/readme.md +36 -1
- package/node_modules/ansi-regex/index.js +9 -4
- package/node_modules/ansi-regex/package.json +1 -1
- package/node_modules/ansi-regex/readme.md +6 -0
- package/node_modules/ansi-styles/index.d.ts +12 -12
- package/node_modules/ansi-styles/index.js +3 -3
- package/node_modules/ansi-styles/package.json +4 -4
- package/node_modules/cli-truncate/index.d.ts +3 -3
- package/node_modules/cli-truncate/index.js +40 -14
- package/node_modules/cli-truncate/node_modules/string-width/index.js +133 -15
- package/node_modules/cli-truncate/node_modules/string-width/package.json +4 -4
- package/node_modules/cli-truncate/node_modules/string-width/readme.md +1 -1
- package/node_modules/cli-truncate/package.json +7 -7
- package/node_modules/cli-truncate/readme.md +2 -3
- package/node_modules/ghauth/.github/dependabot.yml +11 -3
- package/node_modules/ghauth/.github/workflows/depsound.yml +33 -0
- package/node_modules/ghauth/.github/workflows/test-and-release.yml +4 -4
- package/node_modules/ghauth/CHANGELOG.md +60 -0
- package/node_modules/ghauth/package.json +30 -6
- package/node_modules/js-yaml/README.md +20 -187
- package/node_modules/js-yaml/dist/browser/js-yaml.esm.min.mjs +1008 -946
- package/node_modules/js-yaml/dist/browser/js-yaml.esm.min.mjs.map +1 -1
- package/node_modules/js-yaml/dist/browser/js-yaml.umd.min.js +29 -23
- package/node_modules/js-yaml/dist/browser/js-yaml.umd.min.js.map +1 -1
- package/node_modules/js-yaml/dist/js-yaml.cjs.js +1043 -583
- package/node_modules/js-yaml/dist/js-yaml.cjs.js.map +1 -1
- package/node_modules/js-yaml/dist/js-yaml.d.ts +877 -133
- package/node_modules/js-yaml/dist/js-yaml.mjs +995 -556
- package/node_modules/js-yaml/dist/js-yaml.mjs.map +1 -1
- package/node_modules/js-yaml/package.json +8 -7
- package/node_modules/listr2/dist/{index.d.cts → index.d.mts} +90 -60
- package/node_modules/listr2/dist/{index.js → index.mjs} +496 -373
- package/node_modules/listr2/node_modules/string-width/index.d.ts +39 -0
- package/node_modules/listr2/node_modules/string-width/index.js +207 -0
- package/node_modules/listr2/node_modules/string-width/package.json +65 -0
- package/node_modules/listr2/node_modules/string-width/readme.md +66 -0
- package/node_modules/listr2/node_modules/wrap-ansi/index.d.ts +1 -1
- package/node_modules/listr2/node_modules/wrap-ansi/index.js +544 -116
- package/node_modules/listr2/node_modules/wrap-ansi/package.json +10 -13
- package/node_modules/listr2/node_modules/wrap-ansi/readme.md +2 -0
- package/node_modules/listr2/package.json +16 -19
- package/node_modules/log-update/index.d.ts +64 -1
- package/node_modules/log-update/index.js +268 -18
- package/node_modules/log-update/node_modules/string-width/index.d.ts +39 -0
- package/node_modules/log-update/node_modules/string-width/index.js +207 -0
- package/node_modules/log-update/node_modules/string-width/package.json +65 -0
- package/node_modules/log-update/node_modules/string-width/readme.md +66 -0
- package/node_modules/log-update/node_modules/wrap-ansi/index.d.ts +1 -1
- package/node_modules/log-update/node_modules/wrap-ansi/index.js +544 -116
- package/node_modules/log-update/node_modules/wrap-ansi/package.json +10 -13
- package/node_modules/log-update/node_modules/wrap-ansi/readme.md +2 -0
- package/node_modules/log-update/package.json +14 -12
- package/node_modules/log-update/readme.md +61 -0
- package/node_modules/slice-ansi/index.d.ts +2 -2
- package/node_modules/slice-ansi/index.js +260 -112
- package/node_modules/slice-ansi/package.json +10 -9
- package/node_modules/slice-ansi/readme.md +3 -2
- package/node_modules/slice-ansi/tokenize-ansi.js +752 -0
- package/node_modules/smol-toml/README.md +205 -191
- package/node_modules/smol-toml/dist/date.d.ts +0 -1
- package/node_modules/smol-toml/dist/date.js +0 -1
- package/node_modules/smol-toml/dist/error.d.ts +0 -1
- package/node_modules/smol-toml/dist/error.js +0 -1
- package/node_modules/smol-toml/dist/extract.js +32 -65
- package/node_modules/smol-toml/dist/index.cjs +302 -288
- package/node_modules/smol-toml/dist/index.d.ts +0 -1
- package/node_modules/smol-toml/dist/index.js +0 -1
- package/node_modules/smol-toml/dist/parse.d.ts +1 -3
- package/node_modules/smol-toml/dist/parse.js +22 -21
- package/node_modules/smol-toml/dist/primitive.js +75 -76
- package/node_modules/smol-toml/dist/stringify.d.ts +0 -1
- package/node_modules/smol-toml/dist/stringify.js +43 -30
- package/node_modules/smol-toml/dist/struct.js +90 -93
- package/node_modules/smol-toml/dist/util.d.ts +1 -1
- package/node_modules/smol-toml/dist/util.js +36 -39
- package/node_modules/smol-toml/package.json +6 -6
- package/node_modules/strip-ansi/index.js +5 -0
- package/node_modules/strip-ansi/package.json +5 -5
- package/package.json +3 -9
- package/node_modules/@listr2/prompt-adapter-enquirer/dist/index.cjs +0 -127
- package/node_modules/@listr2/prompt-adapter-enquirer/dist/index.d.cts +0 -152
- package/node_modules/@listr2/prompt-adapter-enquirer/dist/index.d.ts +0 -152
- package/node_modules/@listr2/prompt-adapter-enquirer/dist/index.js +0 -92
- package/node_modules/chalk/package.json +0 -92
- package/node_modules/chalk/readme.md +0 -331
- package/node_modules/chalk/source/index.d.ts +0 -437
- package/node_modules/chalk/source/index.js +0 -261
- package/node_modules/chalk/source/utilities.js +0 -33
- package/node_modules/chalk/source/vendor/ansi-styles/index.d.ts +0 -299
- package/node_modules/chalk/source/vendor/ansi-styles/index.js +0 -261
- package/node_modules/chalk/source/vendor/supports-color/browser.d.ts +0 -1
- package/node_modules/chalk/source/vendor/supports-color/browser.js +0 -32
- package/node_modules/chalk/source/vendor/supports-color/index.d.ts +0 -55
- package/node_modules/chalk/source/vendor/supports-color/index.js +0 -206
- package/node_modules/colorette/LICENSE.md +0 -7
- package/node_modules/colorette/README.md +0 -134
- package/node_modules/colorette/index.cjs +0 -218
- package/node_modules/colorette/index.d.ts +0 -93
- package/node_modules/colorette/index.js +0 -150
- package/node_modules/colorette/package.json +0 -40
- package/node_modules/eventemitter3/LICENSE +0 -21
- package/node_modules/eventemitter3/README.md +0 -94
- package/node_modules/eventemitter3/dist/eventemitter3.esm.js +0 -347
- package/node_modules/eventemitter3/dist/eventemitter3.esm.min.js +0 -1
- package/node_modules/eventemitter3/dist/eventemitter3.esm.min.js.map +0 -1
- package/node_modules/eventemitter3/dist/eventemitter3.umd.js +0 -355
- package/node_modules/eventemitter3/dist/eventemitter3.umd.min.js +0 -1
- package/node_modules/eventemitter3/dist/eventemitter3.umd.min.js.map +0 -1
- package/node_modules/eventemitter3/index.d.ts +0 -135
- package/node_modules/eventemitter3/index.js +0 -336
- package/node_modules/eventemitter3/index.mjs +0 -4
- package/node_modules/eventemitter3/package.json +0 -67
- package/node_modules/figures/index.d.ts +0 -279
- package/node_modules/figures/index.js +0 -292
- package/node_modules/figures/package.json +0 -49
- package/node_modules/figures/readme.md +0 -337
- package/node_modules/isexe/LICENSE.md +0 -55
- package/node_modules/isexe/README.md +0 -80
- package/node_modules/isexe/dist/commonjs/index.d.ts +0 -14
- package/node_modules/isexe/dist/commonjs/index.d.ts.map +0 -1
- package/node_modules/isexe/dist/commonjs/index.js +0 -56
- package/node_modules/isexe/dist/commonjs/index.js.map +0 -1
- package/node_modules/isexe/dist/commonjs/index.min.js +0 -2
- package/node_modules/isexe/dist/commonjs/index.min.js.map +0 -7
- package/node_modules/isexe/dist/commonjs/options.d.ts +0 -32
- package/node_modules/isexe/dist/commonjs/options.d.ts.map +0 -1
- package/node_modules/isexe/dist/commonjs/options.js +0 -3
- package/node_modules/isexe/dist/commonjs/options.js.map +0 -1
- package/node_modules/isexe/dist/commonjs/package.json +0 -3
- package/node_modules/isexe/dist/commonjs/posix.d.ts +0 -18
- package/node_modules/isexe/dist/commonjs/posix.d.ts.map +0 -1
- package/node_modules/isexe/dist/commonjs/posix.js +0 -67
- package/node_modules/isexe/dist/commonjs/posix.js.map +0 -1
- package/node_modules/isexe/dist/commonjs/win32.d.ts +0 -18
- package/node_modules/isexe/dist/commonjs/win32.d.ts.map +0 -1
- package/node_modules/isexe/dist/commonjs/win32.js +0 -63
- package/node_modules/isexe/dist/commonjs/win32.js.map +0 -1
- package/node_modules/isexe/dist/esm/index.d.ts +0 -14
- package/node_modules/isexe/dist/esm/index.d.ts.map +0 -1
- package/node_modules/isexe/dist/esm/index.js +0 -16
- package/node_modules/isexe/dist/esm/index.js.map +0 -1
- package/node_modules/isexe/dist/esm/index.min.js +0 -2
- package/node_modules/isexe/dist/esm/index.min.js.map +0 -7
- package/node_modules/isexe/dist/esm/options.d.ts +0 -32
- package/node_modules/isexe/dist/esm/options.d.ts.map +0 -1
- package/node_modules/isexe/dist/esm/options.js +0 -2
- package/node_modules/isexe/dist/esm/options.js.map +0 -1
- package/node_modules/isexe/dist/esm/package.json +0 -3
- package/node_modules/isexe/dist/esm/posix.d.ts +0 -18
- package/node_modules/isexe/dist/esm/posix.d.ts.map +0 -1
- package/node_modules/isexe/dist/esm/posix.js +0 -62
- package/node_modules/isexe/dist/esm/posix.js.map +0 -1
- package/node_modules/isexe/dist/esm/win32.d.ts +0 -18
- package/node_modules/isexe/dist/esm/win32.d.ts.map +0 -1
- package/node_modules/isexe/dist/esm/win32.js +0 -58
- package/node_modules/isexe/dist/esm/win32.js.map +0 -1
- package/node_modules/isexe/package.json +0 -78
- package/node_modules/listr2/dist/index.cjs +0 -2189
- package/node_modules/listr2/dist/index.d.ts +0 -1528
- package/node_modules/rfdc/.github/workflows/ci.yml +0 -21
- package/node_modules/rfdc/LICENSE +0 -15
- package/node_modules/rfdc/default.js +0 -3
- package/node_modules/rfdc/index.d.ts +0 -13
- package/node_modules/rfdc/index.js +0 -198
- package/node_modules/rfdc/index.test-d.ts +0 -13
- package/node_modules/rfdc/package.json +0 -73
- package/node_modules/rfdc/readme.md +0 -181
- package/node_modules/rfdc/test/index.js +0 -306
- package/node_modules/smol-toml/dist/date.d.ts.map +0 -1
- package/node_modules/smol-toml/dist/date.js.map +0 -1
- package/node_modules/smol-toml/dist/error.d.ts.map +0 -1
- package/node_modules/smol-toml/dist/error.js.map +0 -1
- package/node_modules/smol-toml/dist/extract.js.map +0 -1
- package/node_modules/smol-toml/dist/index.cjs.map +0 -1
- package/node_modules/smol-toml/dist/index.d.ts.map +0 -1
- package/node_modules/smol-toml/dist/index.js.map +0 -1
- package/node_modules/smol-toml/dist/parse.d.ts.map +0 -1
- package/node_modules/smol-toml/dist/parse.js.map +0 -1
- package/node_modules/smol-toml/dist/primitive.d.ts +0 -29
- package/node_modules/smol-toml/dist/primitive.d.ts.map +0 -1
- package/node_modules/smol-toml/dist/primitive.js.map +0 -1
- package/node_modules/smol-toml/dist/stringify.d.ts.map +0 -1
- package/node_modules/smol-toml/dist/stringify.js.map +0 -1
- package/node_modules/smol-toml/dist/struct.js.map +0 -1
- package/node_modules/smol-toml/dist/util.d.ts.map +0 -1
- package/node_modules/smol-toml/dist/util.js.map +0 -1
- package/node_modules/smol-toml/src/date.ts +0 -152
- package/node_modules/smol-toml/src/error.ts +0 -77
- package/node_modules/smol-toml/src/extract.ts +0 -113
- package/node_modules/smol-toml/src/index.ts +0 -42
- package/node_modules/smol-toml/src/parse.ts +0 -184
- package/node_modules/smol-toml/src/primitive.ts +0 -249
- package/node_modules/smol-toml/src/stringify.ts +0 -191
- package/node_modules/smol-toml/src/struct.ts +0 -202
- package/node_modules/smol-toml/src/util.ts +0 -106
- package/node_modules/which/LICENSE +0 -15
- package/node_modules/which/README.md +0 -51
- package/node_modules/which/bin/which.js +0 -52
- package/node_modules/which/lib/index.js +0 -111
- package/node_modules/which/package.json +0 -52
- /package/node_modules/@listr2/{prompt-adapter-enquirer → prompt-adapter-inquirer}/LICENSE +0 -0
- /package/node_modules/{log-update/node_modules/ansi-escapes → ansi-escapes}/index.d.ts +0 -0
- /package/node_modules/{log-update/node_modules/ansi-escapes → ansi-escapes}/index.js +0 -0
- /package/node_modules/{chalk → ansi-escapes}/license +0 -0
- /package/node_modules/{figures → listr2/node_modules/string-width}/license +0 -0
- /package/node_modules/log-update/node_modules/{ansi-escapes → string-width}/license +0 -0
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import EventEmitter from "
|
|
2
|
-
import {
|
|
1
|
+
import EventEmitter, { setMaxListeners } from "node:events";
|
|
2
|
+
import { inspect, styleText } from "node:util";
|
|
3
3
|
import { format } from "util";
|
|
4
4
|
import { EOL } from "os";
|
|
5
5
|
import { StringDecoder } from "string_decoder";
|
|
6
6
|
import { Writable } from "stream";
|
|
7
|
-
import rfdc from "rfdc";
|
|
8
7
|
import { randomUUID } from "crypto";
|
|
9
8
|
|
|
10
9
|
//#region src/constants/ansi-escape-codes.constants.ts
|
|
@@ -16,8 +15,8 @@ const ANSI_ESCAPE = "\x1B[";
|
|
|
16
15
|
* Generic ANSI escape characters for terminal based operations.
|
|
17
16
|
*/
|
|
18
17
|
const ANSI_ESCAPE_CODES = {
|
|
19
|
-
CURSOR_HIDE:
|
|
20
|
-
CURSOR_SHOW:
|
|
18
|
+
CURSOR_HIDE: "\x1B[?25l",
|
|
19
|
+
CURSOR_SHOW: "\x1B[?25h"
|
|
21
20
|
};
|
|
22
21
|
|
|
23
22
|
//#endregion
|
|
@@ -25,12 +24,12 @@ const ANSI_ESCAPE_CODES = {
|
|
|
25
24
|
/**
|
|
26
25
|
* Environment variables for Listr.
|
|
27
26
|
*/
|
|
28
|
-
let ListrEnvironmentVariables = /* @__PURE__ */ function(ListrEnvironmentVariables
|
|
29
|
-
ListrEnvironmentVariables
|
|
30
|
-
ListrEnvironmentVariables
|
|
31
|
-
ListrEnvironmentVariables
|
|
32
|
-
ListrEnvironmentVariables
|
|
33
|
-
return ListrEnvironmentVariables
|
|
27
|
+
let ListrEnvironmentVariables = /* @__PURE__ */ function(ListrEnvironmentVariables) {
|
|
28
|
+
ListrEnvironmentVariables["FORCE_UNICODE"] = "LISTR_FORCE_UNICODE";
|
|
29
|
+
ListrEnvironmentVariables["FORCE_TTY"] = "LISTR_FORCE_TTY";
|
|
30
|
+
ListrEnvironmentVariables["DISABLE_COLOR"] = "NO_COLOR";
|
|
31
|
+
ListrEnvironmentVariables["FORCE_COLOR"] = "FORCE_COLOR";
|
|
32
|
+
return ListrEnvironmentVariables;
|
|
34
33
|
}({});
|
|
35
34
|
|
|
36
35
|
//#endregion
|
|
@@ -38,18 +37,18 @@ let ListrEnvironmentVariables = /* @__PURE__ */ function(ListrEnvironmentVariabl
|
|
|
38
37
|
/**
|
|
39
38
|
* The actual error type that is collected and to help identify where the error is triggered from.
|
|
40
39
|
*/
|
|
41
|
-
let ListrErrorTypes = /* @__PURE__ */ function(ListrErrorTypes
|
|
40
|
+
let ListrErrorTypes = /* @__PURE__ */ function(ListrErrorTypes) {
|
|
42
41
|
/** Task has failed and will try to retry. */
|
|
43
|
-
ListrErrorTypes
|
|
42
|
+
ListrErrorTypes["WILL_RETRY"] = "WILL_RETRY";
|
|
44
43
|
/** Task has failed and will try to rollback. */
|
|
45
|
-
ListrErrorTypes
|
|
44
|
+
ListrErrorTypes["WILL_ROLLBACK"] = "WILL_ROLLBACK";
|
|
46
45
|
/** Task has failed, ran the rollback action but the rollback action itself has failed. */
|
|
47
|
-
ListrErrorTypes
|
|
46
|
+
ListrErrorTypes["HAS_FAILED_TO_ROLLBACK"] = "HAS_FAILED_TO_ROLLBACK";
|
|
48
47
|
/** Task has failed. */
|
|
49
|
-
ListrErrorTypes
|
|
48
|
+
ListrErrorTypes["HAS_FAILED"] = "HAS_FAILED";
|
|
50
49
|
/** Task has failed, but exitOnError is set to false, so will ignore this error. */
|
|
51
|
-
ListrErrorTypes
|
|
52
|
-
return ListrErrorTypes
|
|
50
|
+
ListrErrorTypes["HAS_FAILED_WITHOUT_ERROR"] = "HAS_FAILED_WITHOUT_ERROR";
|
|
51
|
+
return ListrErrorTypes;
|
|
53
52
|
}({});
|
|
54
53
|
|
|
55
54
|
//#endregion
|
|
@@ -61,19 +60,19 @@ let ListrErrorTypes = /* @__PURE__ */ function(ListrErrorTypes$1) {
|
|
|
61
60
|
*
|
|
62
61
|
* @see {@link https://listr2.kilic.dev/listr/events.html}
|
|
63
62
|
*/
|
|
64
|
-
let ListrEventType = /* @__PURE__ */ function(ListrEventType
|
|
63
|
+
let ListrEventType = /* @__PURE__ */ function(ListrEventType) {
|
|
65
64
|
/** Indicates that underlying renderer should refresh the current render. */
|
|
66
|
-
ListrEventType
|
|
67
|
-
return ListrEventType
|
|
65
|
+
ListrEventType["SHOULD_REFRESH_RENDER"] = "SHOUD_REFRESH_RENDER";
|
|
66
|
+
return ListrEventType;
|
|
68
67
|
}({});
|
|
69
68
|
|
|
70
69
|
//#endregion
|
|
71
70
|
//#region src/constants/listr-renderer.constants.ts
|
|
72
|
-
let ListrRendererSelection = /* @__PURE__ */ function(ListrRendererSelection
|
|
73
|
-
ListrRendererSelection
|
|
74
|
-
ListrRendererSelection
|
|
75
|
-
ListrRendererSelection
|
|
76
|
-
return ListrRendererSelection
|
|
71
|
+
let ListrRendererSelection = /* @__PURE__ */ function(ListrRendererSelection) {
|
|
72
|
+
ListrRendererSelection["PRIMARY"] = "PRIMARY";
|
|
73
|
+
ListrRendererSelection["SECONDARY"] = "SECONDARY";
|
|
74
|
+
ListrRendererSelection["SILENT"] = "SILENT";
|
|
75
|
+
return ListrRendererSelection;
|
|
77
76
|
}({});
|
|
78
77
|
|
|
79
78
|
//#endregion
|
|
@@ -83,32 +82,34 @@ let ListrRendererSelection = /* @__PURE__ */ function(ListrRendererSelection$1)
|
|
|
83
82
|
*
|
|
84
83
|
* @see {@link https://listr2.kilic.dev/task/events.html}
|
|
85
84
|
*/
|
|
86
|
-
let ListrTaskEventType = /* @__PURE__ */ function(ListrTaskEventType
|
|
85
|
+
let ListrTaskEventType = /* @__PURE__ */ function(ListrTaskEventType) {
|
|
87
86
|
/** Title has changed for the current Task. */
|
|
88
|
-
ListrTaskEventType
|
|
87
|
+
ListrTaskEventType["TITLE"] = "TITLE";
|
|
89
88
|
/**
|
|
90
89
|
* State has changed for the current Task.
|
|
91
90
|
*
|
|
92
91
|
* @see {@link module:listr2.ListrTaskState}
|
|
93
92
|
*/
|
|
94
|
-
ListrTaskEventType
|
|
93
|
+
ListrTaskEventType["STATE"] = "STATE";
|
|
95
94
|
/** The current Task has been marked as enabled. */
|
|
96
|
-
ListrTaskEventType
|
|
95
|
+
ListrTaskEventType["ENABLED"] = "ENABLED";
|
|
97
96
|
/** The current Task is currently processing subtasks. */
|
|
98
|
-
ListrTaskEventType
|
|
97
|
+
ListrTaskEventType["SUBTASK"] = "SUBTASK";
|
|
99
98
|
/** The current Task is now processing a prompt. */
|
|
100
|
-
ListrTaskEventType
|
|
99
|
+
ListrTaskEventType["PROMPT"] = "PROMPT";
|
|
101
100
|
/** The current Task is now dumping output. */
|
|
102
|
-
ListrTaskEventType
|
|
101
|
+
ListrTaskEventType["OUTPUT"] = "OUTPUT";
|
|
102
|
+
/** The current Task has reset its streamed output. */
|
|
103
|
+
ListrTaskEventType["OUTPUT_RESET"] = "OUTPUT_RESET";
|
|
103
104
|
/**
|
|
104
105
|
* The current Task is now dumping a message.
|
|
105
106
|
*
|
|
106
107
|
* @see {module:Listr2.ListrTaskMessage}
|
|
107
108
|
*/
|
|
108
|
-
ListrTaskEventType
|
|
109
|
+
ListrTaskEventType["MESSAGE"] = "MESSAGE";
|
|
109
110
|
/** The current Task is closed and no further action in expected. */
|
|
110
|
-
ListrTaskEventType
|
|
111
|
-
return ListrTaskEventType
|
|
111
|
+
ListrTaskEventType["CLOSED"] = "CLOSED";
|
|
112
|
+
return ListrTaskEventType;
|
|
112
113
|
}({});
|
|
113
114
|
|
|
114
115
|
//#endregion
|
|
@@ -118,49 +119,57 @@ let ListrTaskEventType = /* @__PURE__ */ function(ListrTaskEventType$1) {
|
|
|
118
119
|
*
|
|
119
120
|
* Whenever a state change occurs, the task will emit a {@link module:listr2.ListrTaskEventType.STATE} with the appropriate state.
|
|
120
121
|
*/
|
|
121
|
-
let ListrTaskState = /* @__PURE__ */ function(ListrTaskState
|
|
122
|
+
let ListrTaskState = /* @__PURE__ */ function(ListrTaskState) {
|
|
122
123
|
/** Task has not started yet, waiting for pick-up. */
|
|
123
|
-
ListrTaskState
|
|
124
|
+
ListrTaskState["WAITING"] = "WAITING";
|
|
124
125
|
/** Task has started. */
|
|
125
|
-
ListrTaskState
|
|
126
|
+
ListrTaskState["STARTED"] = "STARTED";
|
|
126
127
|
/** Task has been completed. */
|
|
127
|
-
ListrTaskState
|
|
128
|
+
ListrTaskState["COMPLETED"] = "COMPLETED";
|
|
128
129
|
/** Task has failed. */
|
|
129
|
-
ListrTaskState
|
|
130
|
+
ListrTaskState["FAILED"] = "FAILED";
|
|
130
131
|
/** Task has been skipped. */
|
|
131
|
-
ListrTaskState
|
|
132
|
+
ListrTaskState["SKIPPED"] = "SKIPPED";
|
|
132
133
|
/** Task is currently trying to rollback. */
|
|
133
|
-
ListrTaskState
|
|
134
|
+
ListrTaskState["ROLLING_BACK"] = "ROLLING_BACK";
|
|
134
135
|
/** Task has rolledback successfully after failing. */
|
|
135
|
-
ListrTaskState
|
|
136
|
+
ListrTaskState["ROLLED_BACK"] = "ROLLED_BACK";
|
|
136
137
|
/** Task is currently retrying. */
|
|
137
|
-
ListrTaskState
|
|
138
|
+
ListrTaskState["RETRY"] = "RETRY";
|
|
138
139
|
/** Task is currently paused. */
|
|
139
|
-
ListrTaskState
|
|
140
|
+
ListrTaskState["PAUSED"] = "PAUSED";
|
|
140
141
|
/** Task is currently trying to process a prompt. */
|
|
141
|
-
ListrTaskState
|
|
142
|
+
ListrTaskState["PROMPT"] = "PROMPT";
|
|
142
143
|
/** Task has successfully processed the prompt. */
|
|
143
|
-
ListrTaskState
|
|
144
|
+
ListrTaskState["PROMPT_COMPLETED"] = "PROMPT_COMPLETED";
|
|
144
145
|
/** Task has failed to process the prompt. */
|
|
145
|
-
ListrTaskState
|
|
146
|
-
|
|
146
|
+
ListrTaskState["PROMPT_FAILED"] = "PROMPT_FAILED";
|
|
147
|
+
/** Task has been cancelled by an interruption before it could finish. */
|
|
148
|
+
ListrTaskState["CANCELLED"] = "CANCELLED";
|
|
149
|
+
return ListrTaskState;
|
|
147
150
|
}({});
|
|
148
151
|
|
|
149
152
|
//#endregion
|
|
150
153
|
//#region src/lib/event-manager.ts
|
|
151
154
|
var EventManager = class {
|
|
152
155
|
emitter = new EventEmitter();
|
|
156
|
+
constructor() {
|
|
157
|
+
this.emitter.setMaxListeners(0);
|
|
158
|
+
}
|
|
153
159
|
emit(dispatch, args) {
|
|
154
160
|
this.emitter.emit(dispatch, args);
|
|
155
161
|
}
|
|
156
162
|
on(dispatch, handler) {
|
|
163
|
+
if (!handler) return;
|
|
157
164
|
this.emitter.addListener(dispatch, handler);
|
|
158
165
|
}
|
|
159
166
|
once(dispatch, handler) {
|
|
167
|
+
if (!handler) return;
|
|
160
168
|
this.emitter.once(dispatch, handler);
|
|
161
169
|
}
|
|
162
170
|
off(dispatch, handler) {
|
|
163
|
-
this.emitter.off(dispatch, handler);
|
|
171
|
+
if (handler) this.emitter.off(dispatch, handler);
|
|
172
|
+
else this.emitter.removeAllListeners(dispatch);
|
|
164
173
|
}
|
|
165
174
|
complete() {
|
|
166
175
|
this.emitter.removeAllListeners();
|
|
@@ -175,6 +184,45 @@ var EventManager = class {
|
|
|
175
184
|
*/
|
|
176
185
|
var BaseEventMap = class {};
|
|
177
186
|
|
|
187
|
+
//#endregion
|
|
188
|
+
//#region src/interfaces/listr-error.interface.ts
|
|
189
|
+
/**
|
|
190
|
+
* Internal error handling mechanism for Listr collects the errors and details for a failed task.
|
|
191
|
+
*
|
|
192
|
+
* @see {@link https://listr2.kilic.dev/task/error-handling.html}
|
|
193
|
+
*/
|
|
194
|
+
var ListrError = class extends Error {
|
|
195
|
+
error;
|
|
196
|
+
type;
|
|
197
|
+
task;
|
|
198
|
+
path;
|
|
199
|
+
constructor(error, type, task) {
|
|
200
|
+
super(error.message);
|
|
201
|
+
this.error = error;
|
|
202
|
+
this.type = type;
|
|
203
|
+
this.task = task;
|
|
204
|
+
this.name = "ListrError";
|
|
205
|
+
this.path = task.path;
|
|
206
|
+
this.stack = error?.stack;
|
|
207
|
+
}
|
|
208
|
+
};
|
|
209
|
+
|
|
210
|
+
//#endregion
|
|
211
|
+
//#region src/interfaces/listr-renderer-error.interface.ts
|
|
212
|
+
/**
|
|
213
|
+
* Internal error coming from renderer.
|
|
214
|
+
*/
|
|
215
|
+
var ListrRendererError = class extends Error {};
|
|
216
|
+
|
|
217
|
+
//#endregion
|
|
218
|
+
//#region src/interfaces/prompt-error.interface.ts
|
|
219
|
+
/**
|
|
220
|
+
* Internal error handling mechanism for Listr prompts to identify the failing cause is coming from a prompt.
|
|
221
|
+
*
|
|
222
|
+
* @see {@link https://listr2.kilic.dev/task/prompts.html}
|
|
223
|
+
*/
|
|
224
|
+
var PromptError = class extends Error {};
|
|
225
|
+
|
|
178
226
|
//#endregion
|
|
179
227
|
//#region src/utils/environment/is-observable.ts
|
|
180
228
|
/**
|
|
@@ -199,28 +247,25 @@ function isReadable(obj) {
|
|
|
199
247
|
//#region src/utils/environment/is-unicode-supported.ts
|
|
200
248
|
function isUnicodeSupported() {
|
|
201
249
|
/* istanbul ignore next */
|
|
202
|
-
return !!process.env[
|
|
250
|
+
return !!process.env["LISTR_FORCE_UNICODE"] || process.platform !== "win32" || !!process.env.CI || !!process.env.WT_SESSION || process.env.TERM_PROGRAM === "vscode" || process.env.TERM === "xterm-256color" || process.env.TERM === "alacritty";
|
|
203
251
|
}
|
|
204
252
|
|
|
205
253
|
//#endregion
|
|
206
254
|
//#region src/utils/format/cleanse-ansi.constants.ts
|
|
207
255
|
const CLEAR_LINE_REGEX = "(?:\\u001b|\\u009b)\\[[\\=><~/#&.:=?%@~_-]*[0-9]*[\\a-ln-tqyz=><~/#&.:=?%@~_-]+";
|
|
208
|
-
const BELL_REGEX = /\u0007/;
|
|
209
256
|
|
|
210
257
|
//#endregion
|
|
211
258
|
//#region src/utils/format/cleanse-ansi.ts
|
|
212
259
|
function cleanseAnsi(chunk) {
|
|
213
|
-
return String(chunk).replace(new RegExp(CLEAR_LINE_REGEX, "gmi"), "").
|
|
260
|
+
return String(chunk).replace(new RegExp(CLEAR_LINE_REGEX, "gmi"), "").trim();
|
|
214
261
|
}
|
|
215
262
|
|
|
216
263
|
//#endregion
|
|
217
264
|
//#region src/utils/format/color.ts
|
|
218
265
|
/**
|
|
219
|
-
*
|
|
220
|
-
*
|
|
221
|
-
* @see {@link https://www.npmjs.com/package/colorette}
|
|
266
|
+
* Color palette.
|
|
222
267
|
*/
|
|
223
|
-
const color =
|
|
268
|
+
const color = Object.fromEntries(Object.keys(inspect.colors).map((color) => [color, (text) => styleText(color, String(text))]));
|
|
224
269
|
|
|
225
270
|
//#endregion
|
|
226
271
|
//#region src/utils/format/indent.ts
|
|
@@ -232,6 +277,7 @@ function indent(string, count) {
|
|
|
232
277
|
//#region src/utils/format/figures.ts
|
|
233
278
|
const FIGURES_MAIN = {
|
|
234
279
|
warning: "⚠",
|
|
280
|
+
info: "ℹ",
|
|
235
281
|
cross: "✖",
|
|
236
282
|
arrowDown: "↓",
|
|
237
283
|
tick: "✔",
|
|
@@ -240,67 +286,73 @@ const FIGURES_MAIN = {
|
|
|
240
286
|
checkboxOn: "☒",
|
|
241
287
|
arrowLeft: "←",
|
|
242
288
|
squareSmallFilled: "◼",
|
|
243
|
-
pointerSmall: "›"
|
|
289
|
+
pointerSmall: "›",
|
|
290
|
+
circleSlash: "⊘"
|
|
244
291
|
};
|
|
245
292
|
const FIGURES_FALLBACK = {
|
|
246
293
|
...FIGURES_MAIN,
|
|
247
294
|
warning: "‼",
|
|
295
|
+
info: "i",
|
|
248
296
|
cross: "×",
|
|
249
297
|
tick: "√",
|
|
250
298
|
pointer: ">",
|
|
251
299
|
checkboxOn: "[×]",
|
|
252
|
-
squareSmallFilled: "■"
|
|
300
|
+
squareSmallFilled: "■",
|
|
301
|
+
circleSlash: "ø"
|
|
253
302
|
};
|
|
254
303
|
const figures = isUnicodeSupported() ? FIGURES_MAIN : FIGURES_FALLBACK;
|
|
255
304
|
|
|
256
305
|
//#endregion
|
|
257
306
|
//#region src/utils/format/splat.ts
|
|
258
|
-
function splat(message, ...splat
|
|
259
|
-
return format(String(message), ...splat
|
|
307
|
+
function splat(message, ...splat) {
|
|
308
|
+
return format(String(message), ...splat);
|
|
260
309
|
}
|
|
261
310
|
|
|
262
311
|
//#endregion
|
|
263
312
|
//#region src/utils/logger/logger.constants.ts
|
|
264
313
|
/** Default ListrLogLevels for the logger */
|
|
265
|
-
let ListrLogLevels = /* @__PURE__ */ function(ListrLogLevels
|
|
266
|
-
ListrLogLevels
|
|
267
|
-
ListrLogLevels
|
|
268
|
-
ListrLogLevels
|
|
269
|
-
ListrLogLevels
|
|
270
|
-
ListrLogLevels
|
|
271
|
-
ListrLogLevels
|
|
272
|
-
ListrLogLevels
|
|
273
|
-
ListrLogLevels
|
|
274
|
-
ListrLogLevels
|
|
275
|
-
ListrLogLevels
|
|
276
|
-
|
|
314
|
+
let ListrLogLevels = /* @__PURE__ */ function(ListrLogLevels) {
|
|
315
|
+
ListrLogLevels["STARTED"] = "STARTED";
|
|
316
|
+
ListrLogLevels["COMPLETED"] = "COMPLETED";
|
|
317
|
+
ListrLogLevels["FAILED"] = "FAILED";
|
|
318
|
+
ListrLogLevels["SKIPPED"] = "SKIPPED";
|
|
319
|
+
ListrLogLevels["OUTPUT"] = "OUTPUT";
|
|
320
|
+
ListrLogLevels["TITLE"] = "TITLE";
|
|
321
|
+
ListrLogLevels["ROLLBACK"] = "ROLLBACK";
|
|
322
|
+
ListrLogLevels["RETRY"] = "RETRY";
|
|
323
|
+
ListrLogLevels["PROMPT"] = "PROMPT";
|
|
324
|
+
ListrLogLevels["PAUSED"] = "PAUSED";
|
|
325
|
+
ListrLogLevels["CANCELLED"] = "CANCELLED";
|
|
326
|
+
return ListrLogLevels;
|
|
277
327
|
}({});
|
|
278
328
|
const LISTR_LOGGER_STYLE = {
|
|
279
329
|
icon: {
|
|
280
|
-
[
|
|
281
|
-
[
|
|
282
|
-
[
|
|
283
|
-
[
|
|
284
|
-
[
|
|
285
|
-
[
|
|
286
|
-
[
|
|
287
|
-
[
|
|
288
|
-
[
|
|
330
|
+
["STARTED"]: figures.pointer,
|
|
331
|
+
["FAILED"]: figures.cross,
|
|
332
|
+
["SKIPPED"]: figures.arrowDown,
|
|
333
|
+
["COMPLETED"]: figures.tick,
|
|
334
|
+
["OUTPUT"]: figures.pointerSmall,
|
|
335
|
+
["TITLE"]: figures.arrowRight,
|
|
336
|
+
["RETRY"]: figures.warning,
|
|
337
|
+
["ROLLBACK"]: figures.arrowLeft,
|
|
338
|
+
["PAUSED"]: figures.squareSmallFilled,
|
|
339
|
+
["CANCELLED"]: figures.circleSlash
|
|
289
340
|
},
|
|
290
341
|
color: {
|
|
291
|
-
[
|
|
292
|
-
[
|
|
293
|
-
[
|
|
294
|
-
[
|
|
295
|
-
[
|
|
296
|
-
[
|
|
297
|
-
[
|
|
342
|
+
["STARTED"]: color.yellow,
|
|
343
|
+
["FAILED"]: color.red,
|
|
344
|
+
["SKIPPED"]: color.yellow,
|
|
345
|
+
["COMPLETED"]: color.green,
|
|
346
|
+
["RETRY"]: color.yellowBright,
|
|
347
|
+
["ROLLBACK"]: color.redBright,
|
|
348
|
+
["PAUSED"]: color.yellowBright,
|
|
349
|
+
["CANCELLED"]: color.red
|
|
298
350
|
}
|
|
299
351
|
};
|
|
300
352
|
const LISTR_LOGGER_STDERR_LEVELS = [
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
353
|
+
"RETRY",
|
|
354
|
+
"ROLLBACK",
|
|
355
|
+
"FAILED"
|
|
304
356
|
];
|
|
305
357
|
|
|
306
358
|
//#endregion
|
|
@@ -313,6 +365,7 @@ const LISTR_LOGGER_STDERR_LEVELS = [
|
|
|
313
365
|
* @see {@link https://listr2.kilic.dev/renderer/logger.html}
|
|
314
366
|
*/
|
|
315
367
|
var ListrLogger = class {
|
|
368
|
+
options;
|
|
316
369
|
process;
|
|
317
370
|
constructor(options) {
|
|
318
371
|
this.options = options;
|
|
@@ -417,6 +470,7 @@ var ListrLogger = class {
|
|
|
417
470
|
//#endregion
|
|
418
471
|
//#region src/utils/process-output/process-output-buffer.ts
|
|
419
472
|
var ProcessOutputBuffer = class {
|
|
473
|
+
options;
|
|
420
474
|
buffer = [];
|
|
421
475
|
decoder = new StringDecoder();
|
|
422
476
|
constructor(options) {
|
|
@@ -450,6 +504,7 @@ var ProcessOutputBuffer = class {
|
|
|
450
504
|
//#endregion
|
|
451
505
|
//#region src/utils/process-output/process-output-stream.ts
|
|
452
506
|
var ProcessOutputStream = class {
|
|
507
|
+
stream;
|
|
453
508
|
method;
|
|
454
509
|
buffer;
|
|
455
510
|
constructor(stream) {
|
|
@@ -458,7 +513,11 @@ var ProcessOutputStream = class {
|
|
|
458
513
|
this.buffer = new ProcessOutputBuffer({ stream });
|
|
459
514
|
}
|
|
460
515
|
get out() {
|
|
461
|
-
|
|
516
|
+
const self = this;
|
|
517
|
+
return new Proxy(this.stream, { get(target, prop, receiver) {
|
|
518
|
+
if (prop === "write") return self.write.bind(self);
|
|
519
|
+
return Reflect.get(target, prop, receiver);
|
|
520
|
+
} });
|
|
462
521
|
}
|
|
463
522
|
hijack() {
|
|
464
523
|
this.stream.write = this.buffer.write.bind(this.buffer);
|
|
@@ -484,6 +543,7 @@ var ProcessOutputStream = class {
|
|
|
484
543
|
* @see {@link https://listr2.kilic.dev/renderer/process-output.html}
|
|
485
544
|
*/
|
|
486
545
|
var ProcessOutput = class {
|
|
546
|
+
options;
|
|
487
547
|
stream;
|
|
488
548
|
active;
|
|
489
549
|
constructor(stdout, stderr, options) {
|
|
@@ -514,7 +574,7 @@ var ProcessOutput = class {
|
|
|
514
574
|
const output = Object.entries(this.stream).map(([name, stream]) => ({
|
|
515
575
|
name,
|
|
516
576
|
buffer: stream.release()
|
|
517
|
-
})).filter((output
|
|
577
|
+
})).filter((output) => this.options.dump.includes(output.name)).flatMap((output) => output.buffer).sort((a, b) => a.time - b.time).map((message) => {
|
|
518
578
|
return {
|
|
519
579
|
...message,
|
|
520
580
|
entry: cleanseAnsi(message.entry)
|
|
@@ -557,6 +617,8 @@ function createWritable(cb) {
|
|
|
557
617
|
//#region src/utils/prompts/adapter.ts
|
|
558
618
|
/* istanbul ignore next */
|
|
559
619
|
var ListrPromptAdapter = class {
|
|
620
|
+
task;
|
|
621
|
+
wrapper;
|
|
560
622
|
state;
|
|
561
623
|
constructor(task, wrapper) {
|
|
562
624
|
this.task = task;
|
|
@@ -566,14 +628,14 @@ var ListrPromptAdapter = class {
|
|
|
566
628
|
this.state = this.task.state;
|
|
567
629
|
if (this.task.prompt) throw new PromptError("There is already an active prompt attached to this task which may not be cleaned up properly.");
|
|
568
630
|
this.task.prompt = this;
|
|
569
|
-
this.task.state$ =
|
|
631
|
+
this.task.state$ = "PROMPT";
|
|
570
632
|
}
|
|
571
633
|
reportFailed() {
|
|
572
|
-
this.task.state$ =
|
|
634
|
+
this.task.state$ = "PROMPT_FAILED";
|
|
573
635
|
this.restoreState();
|
|
574
636
|
}
|
|
575
637
|
reportCompleted() {
|
|
576
|
-
this.task.state$ =
|
|
638
|
+
this.task.state$ = "PROMPT_COMPLETED";
|
|
577
639
|
this.restoreState();
|
|
578
640
|
}
|
|
579
641
|
restoreState() {
|
|
@@ -622,61 +684,65 @@ var Spinner = class {
|
|
|
622
684
|
}
|
|
623
685
|
stop() {
|
|
624
686
|
clearInterval(this.id);
|
|
687
|
+
this.id = void 0;
|
|
625
688
|
}
|
|
626
689
|
};
|
|
627
690
|
|
|
628
691
|
//#endregion
|
|
629
692
|
//#region src/renderer/default/renderer.constants.ts
|
|
630
|
-
let ListrDefaultRendererLogLevels = /* @__PURE__ */ function(ListrDefaultRendererLogLevels
|
|
631
|
-
ListrDefaultRendererLogLevels
|
|
632
|
-
ListrDefaultRendererLogLevels
|
|
633
|
-
ListrDefaultRendererLogLevels
|
|
634
|
-
ListrDefaultRendererLogLevels
|
|
635
|
-
ListrDefaultRendererLogLevels
|
|
636
|
-
ListrDefaultRendererLogLevels
|
|
637
|
-
ListrDefaultRendererLogLevels
|
|
638
|
-
ListrDefaultRendererLogLevels
|
|
639
|
-
ListrDefaultRendererLogLevels
|
|
640
|
-
ListrDefaultRendererLogLevels
|
|
641
|
-
ListrDefaultRendererLogLevels
|
|
642
|
-
ListrDefaultRendererLogLevels
|
|
643
|
-
ListrDefaultRendererLogLevels
|
|
644
|
-
ListrDefaultRendererLogLevels
|
|
645
|
-
ListrDefaultRendererLogLevels
|
|
646
|
-
|
|
693
|
+
let ListrDefaultRendererLogLevels = /* @__PURE__ */ function(ListrDefaultRendererLogLevels) {
|
|
694
|
+
ListrDefaultRendererLogLevels["SKIPPED_WITH_COLLAPSE"] = "SKIPPED_WITH_COLLAPSE";
|
|
695
|
+
ListrDefaultRendererLogLevels["SKIPPED_WITHOUT_COLLAPSE"] = "SKIPPED_WITHOUT_COLLAPSE";
|
|
696
|
+
ListrDefaultRendererLogLevels["OUTPUT"] = "OUTPUT";
|
|
697
|
+
ListrDefaultRendererLogLevels["OUTPUT_WITH_BOTTOMBAR"] = "OUTPUT_WITH_BOTTOMBAR";
|
|
698
|
+
ListrDefaultRendererLogLevels["PENDING"] = "PENDING";
|
|
699
|
+
ListrDefaultRendererLogLevels["COMPLETED"] = "COMPLETED";
|
|
700
|
+
ListrDefaultRendererLogLevels["COMPLETED_WITH_FAILED_SUBTASKS"] = "COMPLETED_WITH_FAILED_SUBTASKS";
|
|
701
|
+
ListrDefaultRendererLogLevels["COMPLETED_WITH_FAILED_SISTER_TASKS"] = "COMPLETED_WITH_SISTER_TASKS_FAILED";
|
|
702
|
+
ListrDefaultRendererLogLevels["RETRY"] = "RETRY";
|
|
703
|
+
ListrDefaultRendererLogLevels["ROLLING_BACK"] = "ROLLING_BACK";
|
|
704
|
+
ListrDefaultRendererLogLevels["ROLLED_BACK"] = "ROLLED_BACK";
|
|
705
|
+
ListrDefaultRendererLogLevels["FAILED"] = "FAILED";
|
|
706
|
+
ListrDefaultRendererLogLevels["FAILED_WITH_FAILED_SUBTASKS"] = "FAILED_WITH_SUBTASKS";
|
|
707
|
+
ListrDefaultRendererLogLevels["WAITING"] = "WAITING";
|
|
708
|
+
ListrDefaultRendererLogLevels["PAUSED"] = "PAUSED";
|
|
709
|
+
ListrDefaultRendererLogLevels["CANCELLED"] = "CANCELLED";
|
|
710
|
+
return ListrDefaultRendererLogLevels;
|
|
647
711
|
}({});
|
|
648
712
|
const LISTR_DEFAULT_RENDERER_STYLE = {
|
|
649
713
|
icon: {
|
|
650
|
-
[
|
|
651
|
-
[
|
|
652
|
-
[
|
|
653
|
-
[
|
|
654
|
-
[
|
|
655
|
-
[
|
|
656
|
-
[
|
|
657
|
-
[
|
|
658
|
-
[
|
|
659
|
-
[
|
|
660
|
-
[
|
|
661
|
-
[
|
|
662
|
-
[
|
|
663
|
-
[
|
|
664
|
-
[
|
|
714
|
+
["SKIPPED_WITH_COLLAPSE"]: figures.arrowDown,
|
|
715
|
+
["SKIPPED_WITHOUT_COLLAPSE"]: figures.warning,
|
|
716
|
+
["OUTPUT"]: figures.pointerSmall,
|
|
717
|
+
["OUTPUT_WITH_BOTTOMBAR"]: figures.pointerSmall,
|
|
718
|
+
["PENDING"]: figures.pointer,
|
|
719
|
+
["COMPLETED"]: figures.tick,
|
|
720
|
+
["COMPLETED_WITH_FAILED_SUBTASKS"]: figures.warning,
|
|
721
|
+
["COMPLETED_WITH_SISTER_TASKS_FAILED"]: figures.squareSmallFilled,
|
|
722
|
+
["RETRY"]: figures.warning,
|
|
723
|
+
["ROLLING_BACK"]: figures.warning,
|
|
724
|
+
["ROLLED_BACK"]: figures.arrowLeft,
|
|
725
|
+
["FAILED"]: figures.cross,
|
|
726
|
+
["FAILED_WITH_SUBTASKS"]: figures.pointer,
|
|
727
|
+
["WAITING"]: figures.squareSmallFilled,
|
|
728
|
+
["PAUSED"]: figures.squareSmallFilled,
|
|
729
|
+
["CANCELLED"]: figures.circleSlash
|
|
665
730
|
},
|
|
666
731
|
color: {
|
|
667
|
-
[
|
|
668
|
-
[
|
|
669
|
-
[
|
|
670
|
-
[
|
|
671
|
-
[
|
|
672
|
-
[
|
|
673
|
-
[
|
|
674
|
-
[
|
|
675
|
-
[
|
|
676
|
-
[
|
|
677
|
-
[
|
|
678
|
-
[
|
|
679
|
-
[
|
|
732
|
+
["SKIPPED_WITH_COLLAPSE"]: color.yellow,
|
|
733
|
+
["SKIPPED_WITHOUT_COLLAPSE"]: color.yellow,
|
|
734
|
+
["PENDING"]: color.yellow,
|
|
735
|
+
["COMPLETED"]: color.green,
|
|
736
|
+
["COMPLETED_WITH_FAILED_SUBTASKS"]: color.yellow,
|
|
737
|
+
["COMPLETED_WITH_SISTER_TASKS_FAILED"]: color.red,
|
|
738
|
+
["RETRY"]: color.yellowBright,
|
|
739
|
+
["ROLLING_BACK"]: color.redBright,
|
|
740
|
+
["ROLLED_BACK"]: color.redBright,
|
|
741
|
+
["FAILED"]: color.red,
|
|
742
|
+
["FAILED_WITH_SUBTASKS"]: color.red,
|
|
743
|
+
["WAITING"]: color.dim,
|
|
744
|
+
["PAUSED"]: color.yellowBright,
|
|
745
|
+
["CANCELLED"]: color.red
|
|
680
746
|
}
|
|
681
747
|
};
|
|
682
748
|
|
|
@@ -726,6 +792,9 @@ const PRESET_TIMESTAMP = {
|
|
|
726
792
|
//#endregion
|
|
727
793
|
//#region src/renderer/default/renderer.ts
|
|
728
794
|
var DefaultRenderer = class DefaultRenderer {
|
|
795
|
+
tasks;
|
|
796
|
+
options;
|
|
797
|
+
events;
|
|
729
798
|
static nonTTY = false;
|
|
730
799
|
static rendererOptions = {
|
|
731
800
|
indentation: 2,
|
|
@@ -799,15 +868,14 @@ var DefaultRenderer = class DefaultRenderer {
|
|
|
799
868
|
if (!this.options?.lazy) this.spinner.start(() => {
|
|
800
869
|
this.update();
|
|
801
870
|
});
|
|
802
|
-
this.events.on(
|
|
803
|
-
this.update();
|
|
804
|
-
});
|
|
871
|
+
this.events.on("SHOUD_REFRESH_RENDER", this.refresh);
|
|
805
872
|
}
|
|
806
873
|
update() {
|
|
807
874
|
this.updater(this.create());
|
|
808
875
|
}
|
|
809
876
|
end() {
|
|
810
877
|
this.spinner.stop();
|
|
878
|
+
this.events.off("SHOUD_REFRESH_RENDER", this.refresh);
|
|
811
879
|
this.updater.clear();
|
|
812
880
|
this.updater.done();
|
|
813
881
|
if (!this.options.clearOutput) this.logger.process.toStdout(this.create({ prompt: false }));
|
|
@@ -838,32 +906,33 @@ var DefaultRenderer = class DefaultRenderer {
|
|
|
838
906
|
style(task, output = false) {
|
|
839
907
|
const rendererOptions = this.cache.rendererOptions.get(task.id);
|
|
840
908
|
if (task.isSkipped()) {
|
|
841
|
-
if (output || rendererOptions.collapseSkips) return this.logger.icon(
|
|
842
|
-
else if (rendererOptions.collapseSkips === false) return this.logger.icon(
|
|
909
|
+
if (output || rendererOptions.collapseSkips) return this.logger.icon("SKIPPED_WITH_COLLAPSE");
|
|
910
|
+
else if (rendererOptions.collapseSkips === false) return this.logger.icon("SKIPPED_WITHOUT_COLLAPSE");
|
|
843
911
|
}
|
|
844
912
|
if (output) {
|
|
845
|
-
if (this.shouldOutputToBottomBar(task)) return this.logger.icon(
|
|
846
|
-
return this.logger.icon(
|
|
913
|
+
if (this.shouldOutputToBottomBar(task)) return this.logger.icon("OUTPUT_WITH_BOTTOMBAR");
|
|
914
|
+
return this.logger.icon("OUTPUT");
|
|
847
915
|
}
|
|
848
916
|
if (task.hasSubtasks()) {
|
|
849
|
-
if (task.isStarted() || task.isPrompt() && rendererOptions.showSubtasks !== false && !task.subtasks.every((subtask) => !subtask.hasTitle())) return this.logger.icon(
|
|
850
|
-
else if (task.isCompleted() && task.subtasks.some((subtask) => subtask.hasFailed())) return this.logger.icon(
|
|
851
|
-
else if (task.hasFailed()) return this.logger.icon(
|
|
917
|
+
if (task.isStarted() || task.isPrompt() && rendererOptions.showSubtasks !== false && !task.subtasks.every((subtask) => !subtask.hasTitle())) return this.logger.icon("PENDING");
|
|
918
|
+
else if (task.isCompleted() && task.subtasks.some((subtask) => subtask.hasFailed())) return this.logger.icon("COMPLETED_WITH_FAILED_SUBTASKS");
|
|
919
|
+
else if (task.hasFailed()) return this.logger.icon("FAILED_WITH_SUBTASKS");
|
|
852
920
|
}
|
|
853
|
-
if (task.isStarted() || task.isPrompt()) return this.logger.icon(
|
|
854
|
-
else if (task.isCompleted()) return this.logger.icon(
|
|
855
|
-
else if (task.isRetrying()) return this.logger.icon(
|
|
856
|
-
else if (task.isRollingBack()) return this.logger.icon(
|
|
857
|
-
else if (task.hasRolledBack()) return this.logger.icon(
|
|
858
|
-
else if (task.hasFailed()) return this.logger.icon(
|
|
859
|
-
else if (task.
|
|
860
|
-
return this.logger.icon(
|
|
921
|
+
if (task.isStarted() || task.isPrompt()) return this.logger.icon("PENDING", !this.options?.lazy && this.spinner.fetch());
|
|
922
|
+
else if (task.isCompleted()) return this.logger.icon("COMPLETED");
|
|
923
|
+
else if (task.isRetrying()) return this.logger.icon("RETRY", !this.options?.lazy && this.spinner.fetch());
|
|
924
|
+
else if (task.isRollingBack()) return this.logger.icon("ROLLING_BACK", !this.options?.lazy && this.spinner.fetch());
|
|
925
|
+
else if (task.hasRolledBack()) return this.logger.icon("ROLLED_BACK");
|
|
926
|
+
else if (task.hasFailed()) return this.logger.icon("FAILED");
|
|
927
|
+
else if (task.isCancelled()) return this.logger.icon("CANCELLED");
|
|
928
|
+
else if (task.isPaused()) return this.logger.icon("PAUSED");
|
|
929
|
+
return this.logger.icon("WAITING");
|
|
861
930
|
}
|
|
862
931
|
format(message, icon, level) {
|
|
863
932
|
if (message.trim() === "") return [];
|
|
864
933
|
if (icon) message = icon + " " + message;
|
|
865
934
|
let parsed;
|
|
866
|
-
const columns = (process.stdout.columns ?? 80) - level * this.options.indentation - 2;
|
|
935
|
+
const columns = (this.logger.process.stdout.columns ?? 80) - level * this.options.indentation - 2;
|
|
867
936
|
switch (this.options.formatOutput) {
|
|
868
937
|
case "truncate":
|
|
869
938
|
parsed = message.split(EOL).map((s, i) => {
|
|
@@ -889,6 +958,9 @@ var DefaultRenderer = class DefaultRenderer {
|
|
|
889
958
|
const bottomBar = this.cache.rendererTaskOptions.get(task.id).bottomBar;
|
|
890
959
|
return typeof bottomBar === "number" && bottomBar !== 0 || typeof bottomBar === "boolean" && bottomBar !== false || !task.hasTitle();
|
|
891
960
|
}
|
|
961
|
+
refresh = () => {
|
|
962
|
+
this.update();
|
|
963
|
+
};
|
|
892
964
|
renderer(tasks, level = 0) {
|
|
893
965
|
return tasks.flatMap((task) => {
|
|
894
966
|
if (!task.isEnabled()) return [];
|
|
@@ -901,28 +973,28 @@ var DefaultRenderer = class DefaultRenderer {
|
|
|
901
973
|
if (task.isPrompt()) {
|
|
902
974
|
if (this.activePrompt && this.activePrompt !== task.id) throw new ListrRendererError("Only one prompt can be active at the given time, please re-evaluate your task design.");
|
|
903
975
|
else if (!this.activePrompt) {
|
|
904
|
-
task.on(
|
|
976
|
+
task.on("PROMPT", (prompt) => {
|
|
905
977
|
const cleansed = cleanseAnsi(prompt);
|
|
906
978
|
if (cleansed) this.prompt = cleansed;
|
|
907
979
|
});
|
|
908
|
-
task.on(
|
|
909
|
-
if (state ===
|
|
980
|
+
task.on("STATE", (state) => {
|
|
981
|
+
if (state === "PROMPT_COMPLETED" || task.hasFinalized() || task.hasReset()) {
|
|
910
982
|
this.prompt = null;
|
|
911
983
|
this.activePrompt = null;
|
|
912
|
-
task.off(
|
|
984
|
+
task.off("PROMPT");
|
|
913
985
|
}
|
|
914
986
|
});
|
|
915
987
|
this.activePrompt = task.id;
|
|
916
988
|
}
|
|
917
989
|
}
|
|
918
|
-
if (task.hasTitle()) if (!(tasks.some((task
|
|
990
|
+
if (task.hasTitle()) if (!(tasks.some((task) => task.hasFailed()) && !task.hasFailed() && task.options.exitOnError !== false && !(task.isCompleted() || task.isSkipped() || task.isCancelled()))) if (task.hasFailed() && rendererOptions.collapseErrors) output.push(...this.format(!task.hasSubtasks() && task.message.error && rendererOptions.showErrorMessage ? task.message.error : task.title, this.style(task), level));
|
|
919
991
|
else if (task.isSkipped() && rendererOptions.collapseSkips) output.push(...this.format(this.logger.suffix(task.message.skip && rendererOptions.showSkipMessage ? task.message.skip : task.title, {
|
|
920
|
-
field:
|
|
992
|
+
field: "SKIPPED",
|
|
921
993
|
condition: rendererOptions.suffixSkips,
|
|
922
994
|
format: () => color.dim
|
|
923
995
|
}), this.style(task), level));
|
|
924
996
|
else if (task.isRetrying()) output.push(...this.format(this.logger.suffix(task.title, {
|
|
925
|
-
field: `${
|
|
997
|
+
field: `${"RETRY"}:${task.message.retry.count}`,
|
|
926
998
|
format: () => color.yellow,
|
|
927
999
|
condition: rendererOptions.suffixRetries
|
|
928
1000
|
}), this.style(task), level));
|
|
@@ -935,13 +1007,13 @@ var DefaultRenderer = class DefaultRenderer {
|
|
|
935
1007
|
args: [task.message.paused - Date.now()]
|
|
936
1008
|
}), this.style(task), level));
|
|
937
1009
|
else output.push(...this.format(task.title, this.style(task), level));
|
|
938
|
-
else output.push(...this.format(task.title, this.logger.icon(
|
|
1010
|
+
else output.push(...this.format(task.title, this.logger.icon("COMPLETED_WITH_SISTER_TASKS_FAILED"), level));
|
|
939
1011
|
if (!task.hasSubtasks() || !rendererOptions.showSubtasks) {
|
|
940
|
-
if (task.hasFailed() && rendererOptions.collapseErrors === false && (rendererOptions.showErrorMessage || !rendererOptions.showSubtasks)) output.push(...this.dump(task, level,
|
|
941
|
-
else if (task.isSkipped() && rendererOptions.collapseSkips === false && (rendererOptions.showSkipMessage || !rendererOptions.showSubtasks)) output.push(...this.dump(task, level,
|
|
1012
|
+
if (task.hasFailed() && rendererOptions.collapseErrors === false && (rendererOptions.showErrorMessage || !rendererOptions.showSubtasks)) output.push(...this.dump(task, level, "FAILED"));
|
|
1013
|
+
else if (task.isSkipped() && rendererOptions.collapseSkips === false && (rendererOptions.showSkipMessage || !rendererOptions.showSubtasks)) output.push(...this.dump(task, level, "SKIPPED"));
|
|
942
1014
|
}
|
|
943
1015
|
if (task.isPending() || rendererTaskOptions.persistentOutput) output.push(...this.renderOutputBar(task, level));
|
|
944
|
-
if (rendererOptions.showSubtasks !== false && task.hasSubtasks() && (task.isPending() || task.hasFinalized() && !task.hasTitle() || task.isCompleted() && rendererOptions.collapseSubtasks === false && !task.subtasks.some((subtask) => this.cache.rendererOptions.get(subtask.id)?.collapseSubtasks === true) || task.subtasks.some((subtask) => this.cache.rendererOptions.get(subtask.id)?.collapseSubtasks === false) || task.subtasks.some((subtask) => subtask.hasFailed()) || task.subtasks.some((subtask) => subtask.hasRolledBack()))) {
|
|
1016
|
+
if (rendererOptions.showSubtasks !== false && task.hasSubtasks() && (task.isPending() || task.hasFinalized() && !task.hasTitle() || task.isCompleted() && rendererOptions.collapseSubtasks === false && !task.subtasks.some((subtask) => this.cache.rendererOptions.get(subtask.id)?.collapseSubtasks === true) || task.subtasks.some((subtask) => this.cache.rendererOptions.get(subtask.id)?.collapseSubtasks === false) || task.subtasks.some((subtask) => subtask.hasFailed()) || task.subtasks.some((subtask) => subtask.hasRolledBack()) || task.subtasks.some((subtask) => subtask.isCancelled()))) {
|
|
945
1017
|
const subtaskLevel = !task.hasTitle() ? level : level + 1;
|
|
946
1018
|
const subtaskRender = this.renderer(task.subtasks, subtaskLevel);
|
|
947
1019
|
output.push(...subtaskRender);
|
|
@@ -962,7 +1034,7 @@ var DefaultRenderer = class DefaultRenderer {
|
|
|
962
1034
|
renderOutputBar(task, level) {
|
|
963
1035
|
const output = this.buffer.output.get(task.id);
|
|
964
1036
|
if (!output) return [];
|
|
965
|
-
return output.all.flatMap((o) => this.dump(task, level,
|
|
1037
|
+
return output.all.flatMap((o) => this.dump(task, level, "OUTPUT", o.entry));
|
|
966
1038
|
}
|
|
967
1039
|
renderBottomBar() {
|
|
968
1040
|
if (this.buffer.bottom.size === 0) return [];
|
|
@@ -987,31 +1059,30 @@ var DefaultRenderer = class DefaultRenderer {
|
|
|
987
1059
|
}
|
|
988
1060
|
setupBuffer(task) {
|
|
989
1061
|
if (this.buffer.bottom.has(task.id) || this.buffer.output.has(task.id)) return;
|
|
1062
|
+
if (task.hasFinalized()) return;
|
|
990
1063
|
const rendererTaskOptions = this.cache.rendererTaskOptions.get(task.id);
|
|
991
1064
|
if (this.shouldOutputToBottomBar(task) && !this.buffer.bottom.has(task.id)) {
|
|
992
1065
|
this.buffer.bottom.set(task.id, new ProcessOutputBuffer({ limit: typeof rendererTaskOptions.bottomBar === "number" ? rendererTaskOptions.bottomBar : 1 }));
|
|
993
|
-
task.on(
|
|
994
|
-
const data = this.dump(task, -1,
|
|
1066
|
+
task.on("OUTPUT", (output) => {
|
|
1067
|
+
const data = this.dump(task, -1, "OUTPUT", output);
|
|
995
1068
|
this.buffer.bottom.get(task.id).write(data.join(EOL));
|
|
996
1069
|
});
|
|
997
|
-
task.on(
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
}
|
|
1070
|
+
task.on("OUTPUT_RESET", () => {
|
|
1071
|
+
this.buffer.bottom.get(task.id)?.reset();
|
|
1072
|
+
});
|
|
1073
|
+
task.on("STATE", (state) => {
|
|
1074
|
+
if (state === "RETRY" || state === "ROLLING_BACK") this.buffer.bottom.delete(task.id);
|
|
1003
1075
|
});
|
|
1004
1076
|
} else if (this.shouldOutputToOutputBar(task) && !this.buffer.output.has(task.id)) {
|
|
1005
1077
|
this.buffer.output.set(task.id, new ProcessOutputBuffer({ limit: typeof rendererTaskOptions.outputBar === "number" ? rendererTaskOptions.outputBar : 1 }));
|
|
1006
|
-
task.on(
|
|
1078
|
+
task.on("OUTPUT", (output) => {
|
|
1007
1079
|
this.buffer.output.get(task.id).write(output);
|
|
1008
1080
|
});
|
|
1009
|
-
task.on(
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
}
|
|
1081
|
+
task.on("OUTPUT_RESET", () => {
|
|
1082
|
+
this.buffer.output.get(task.id)?.reset();
|
|
1083
|
+
});
|
|
1084
|
+
task.on("STATE", (state) => {
|
|
1085
|
+
if (state === "RETRY" || state === "ROLLING_BACK") this.buffer.output.delete(task.id);
|
|
1015
1086
|
});
|
|
1016
1087
|
}
|
|
1017
1088
|
}
|
|
@@ -1020,20 +1091,20 @@ var DefaultRenderer = class DefaultRenderer {
|
|
|
1020
1091
|
this.cache.rendererTaskOptions.delete(task.id);
|
|
1021
1092
|
this.buffer.output.delete(task.id);
|
|
1022
1093
|
}
|
|
1023
|
-
dump(task, level, source =
|
|
1094
|
+
dump(task, level, source = "OUTPUT", data) {
|
|
1024
1095
|
if (!data) switch (source) {
|
|
1025
|
-
case
|
|
1096
|
+
case "OUTPUT":
|
|
1026
1097
|
data = task.output;
|
|
1027
1098
|
break;
|
|
1028
|
-
case
|
|
1099
|
+
case "SKIPPED":
|
|
1029
1100
|
data = task.message.skip;
|
|
1030
1101
|
break;
|
|
1031
|
-
case
|
|
1102
|
+
case "FAILED":
|
|
1032
1103
|
data = task.message.error;
|
|
1033
1104
|
break;
|
|
1034
1105
|
}
|
|
1035
|
-
if (task.hasTitle() && source ===
|
|
1036
|
-
if (source ===
|
|
1106
|
+
if (task.hasTitle() && source === "FAILED" && data === task.title || typeof data !== "string") return [];
|
|
1107
|
+
if (source === "OUTPUT") data = cleanseAnsi(data);
|
|
1037
1108
|
return this.format(data, this.style(task, true), level + 1);
|
|
1038
1109
|
}
|
|
1039
1110
|
indent(str, i) {
|
|
@@ -1044,6 +1115,8 @@ var DefaultRenderer = class DefaultRenderer {
|
|
|
1044
1115
|
//#endregion
|
|
1045
1116
|
//#region src/renderer/silent/renderer.ts
|
|
1046
1117
|
var SilentRenderer = class {
|
|
1118
|
+
tasks;
|
|
1119
|
+
options;
|
|
1047
1120
|
static nonTTY = true;
|
|
1048
1121
|
static rendererOptions;
|
|
1049
1122
|
static rendererTaskOptions;
|
|
@@ -1058,10 +1131,12 @@ var SilentRenderer = class {
|
|
|
1058
1131
|
//#endregion
|
|
1059
1132
|
//#region src/renderer/simple/renderer.ts
|
|
1060
1133
|
var SimpleRenderer = class SimpleRenderer {
|
|
1134
|
+
tasks;
|
|
1135
|
+
options;
|
|
1061
1136
|
static nonTTY = true;
|
|
1062
1137
|
static rendererOptions = { pausedTimer: {
|
|
1063
1138
|
...PRESET_TIMER,
|
|
1064
|
-
field: (time) => `${
|
|
1139
|
+
field: (time) => `${"PAUSED"}:${time}`,
|
|
1065
1140
|
format: () => color.yellowBright
|
|
1066
1141
|
} };
|
|
1067
1142
|
static rendererTaskOptions = {};
|
|
@@ -1100,57 +1175,57 @@ var SimpleRenderer = class SimpleRenderer {
|
|
|
1100
1175
|
renderer(tasks) {
|
|
1101
1176
|
tasks.forEach((task) => {
|
|
1102
1177
|
this.calculate(task);
|
|
1103
|
-
task.once(
|
|
1178
|
+
task.once("CLOSED", () => {
|
|
1104
1179
|
this.reset(task);
|
|
1105
1180
|
});
|
|
1106
1181
|
const rendererOptions = this.cache.rendererOptions.get(task.id);
|
|
1107
1182
|
const rendererTaskOptions = this.cache.rendererTaskOptions.get(task.id);
|
|
1108
|
-
task.on(
|
|
1183
|
+
task.on("SUBTASK", (subtasks) => {
|
|
1109
1184
|
this.renderer(subtasks);
|
|
1110
1185
|
});
|
|
1111
|
-
task.on(
|
|
1186
|
+
task.on("STATE", (state) => {
|
|
1112
1187
|
if (!task.hasTitle()) return;
|
|
1113
|
-
if (state ===
|
|
1114
|
-
else if (state ===
|
|
1188
|
+
if (state === "STARTED") this.logger.log("STARTED", task.title);
|
|
1189
|
+
else if (state === "COMPLETED") {
|
|
1115
1190
|
const timer = rendererTaskOptions?.timer;
|
|
1116
|
-
this.logger.log(
|
|
1191
|
+
this.logger.log("COMPLETED", task.title, timer && { suffix: {
|
|
1117
1192
|
...timer,
|
|
1118
1193
|
condition: !!task.message?.duration && timer.condition,
|
|
1119
1194
|
args: [task.message.duration]
|
|
1120
1195
|
} });
|
|
1121
|
-
} else if (state ===
|
|
1196
|
+
} else if (state === "PROMPT") {
|
|
1122
1197
|
this.logger.process.hijack();
|
|
1123
|
-
task.on(
|
|
1198
|
+
task.on("PROMPT", (prompt) => {
|
|
1124
1199
|
this.logger.process.toStderr(prompt, false);
|
|
1125
1200
|
});
|
|
1126
|
-
} else if (state ===
|
|
1127
|
-
task.off(
|
|
1201
|
+
} else if (state === "PROMPT_COMPLETED") {
|
|
1202
|
+
task.off("PROMPT");
|
|
1128
1203
|
this.logger.process.release();
|
|
1129
|
-
}
|
|
1204
|
+
} else if (state === "CANCELLED") this.logger.log("CANCELLED", task.title);
|
|
1130
1205
|
});
|
|
1131
|
-
task.on(
|
|
1132
|
-
this.logger.log(
|
|
1206
|
+
task.on("OUTPUT", (output) => {
|
|
1207
|
+
this.logger.log("OUTPUT", output);
|
|
1133
1208
|
});
|
|
1134
|
-
task.on(
|
|
1135
|
-
if (message.error) this.logger.log(
|
|
1136
|
-
field: `${
|
|
1209
|
+
task.on("MESSAGE", (message) => {
|
|
1210
|
+
if (message.error) this.logger.log("FAILED", task.title, { suffix: {
|
|
1211
|
+
field: `${"FAILED"}: ${message.error}`,
|
|
1137
1212
|
format: () => color.red
|
|
1138
1213
|
} });
|
|
1139
|
-
else if (message.skip) this.logger.log(
|
|
1140
|
-
field: `${
|
|
1214
|
+
else if (message.skip) this.logger.log("SKIPPED", task.title, { suffix: {
|
|
1215
|
+
field: `${"SKIPPED"}: ${message.skip}`,
|
|
1141
1216
|
format: () => color.yellow
|
|
1142
1217
|
} });
|
|
1143
|
-
else if (message.rollback) this.logger.log(
|
|
1144
|
-
field: `${
|
|
1218
|
+
else if (message.rollback) this.logger.log("ROLLBACK", task.title, { suffix: {
|
|
1219
|
+
field: `${"ROLLBACK"}: ${message.rollback}`,
|
|
1145
1220
|
format: () => color.red
|
|
1146
1221
|
} });
|
|
1147
|
-
else if (message.retry) this.logger.log(
|
|
1148
|
-
field: `${
|
|
1222
|
+
else if (message.retry) this.logger.log("RETRY", task.title, { suffix: {
|
|
1223
|
+
field: `${"RETRY"}:${message.retry.count}`,
|
|
1149
1224
|
format: () => color.red
|
|
1150
1225
|
} });
|
|
1151
1226
|
else if (message.paused) {
|
|
1152
1227
|
const timer = rendererOptions?.pausedTimer;
|
|
1153
|
-
this.logger.log(
|
|
1228
|
+
this.logger.log("PAUSED", task.title, timer && { suffix: {
|
|
1154
1229
|
...timer,
|
|
1155
1230
|
condition: !!message?.paused && timer.condition,
|
|
1156
1231
|
args: [message.paused - Date.now()]
|
|
@@ -1181,6 +1256,7 @@ var SimpleRenderer = class SimpleRenderer {
|
|
|
1181
1256
|
//#endregion
|
|
1182
1257
|
//#region src/renderer/test/serializer.ts
|
|
1183
1258
|
var TestRendererSerializer = class {
|
|
1259
|
+
options;
|
|
1184
1260
|
constructor(options) {
|
|
1185
1261
|
this.options = options;
|
|
1186
1262
|
}
|
|
@@ -1207,6 +1283,8 @@ var TestRendererSerializer = class {
|
|
|
1207
1283
|
//#endregion
|
|
1208
1284
|
//#region src/renderer/test/renderer.ts
|
|
1209
1285
|
var TestRenderer = class TestRenderer {
|
|
1286
|
+
tasks;
|
|
1287
|
+
options;
|
|
1210
1288
|
static nonTTY = true;
|
|
1211
1289
|
static rendererOptions = {
|
|
1212
1290
|
subtasks: true,
|
|
@@ -1239,7 +1317,7 @@ var TestRenderer = class TestRenderer {
|
|
|
1239
1317
|
"isPrompt",
|
|
1240
1318
|
"isPaused",
|
|
1241
1319
|
"isPending",
|
|
1242
|
-
"
|
|
1320
|
+
"isCancelled",
|
|
1243
1321
|
"isStarted",
|
|
1244
1322
|
"hasFailed",
|
|
1245
1323
|
"isEnabled",
|
|
@@ -1266,27 +1344,27 @@ var TestRenderer = class TestRenderer {
|
|
|
1266
1344
|
end() {}
|
|
1267
1345
|
renderer(tasks) {
|
|
1268
1346
|
tasks.forEach((task) => {
|
|
1269
|
-
if (this.options.subtasks) task.on(
|
|
1347
|
+
if (this.options.subtasks) task.on("SUBTASK", (subtasks) => {
|
|
1270
1348
|
this.renderer(subtasks);
|
|
1271
1349
|
});
|
|
1272
|
-
if (this.options.state) task.on(
|
|
1273
|
-
this.logger.toStdout(this.serializer.serialize(
|
|
1350
|
+
if (this.options.state) task.on("STATE", (state) => {
|
|
1351
|
+
this.logger.toStdout(this.serializer.serialize("STATE", state, task));
|
|
1274
1352
|
});
|
|
1275
|
-
if (this.options.output) task.on(
|
|
1276
|
-
this.logger.toStdout(this.serializer.serialize(
|
|
1353
|
+
if (this.options.output) task.on("OUTPUT", (data) => {
|
|
1354
|
+
this.logger.toStdout(this.serializer.serialize("OUTPUT", data, task));
|
|
1277
1355
|
});
|
|
1278
|
-
if (this.options.prompt) task.on(
|
|
1279
|
-
this.logger.toStdout(this.serializer.serialize(
|
|
1356
|
+
if (this.options.prompt) task.on("PROMPT", (prompt) => {
|
|
1357
|
+
this.logger.toStdout(this.serializer.serialize("PROMPT", prompt, task));
|
|
1280
1358
|
});
|
|
1281
|
-
if (this.options.title) task.on(
|
|
1282
|
-
this.logger.toStdout(this.serializer.serialize(
|
|
1359
|
+
if (this.options.title) task.on("TITLE", (title) => {
|
|
1360
|
+
this.logger.toStdout(this.serializer.serialize("TITLE", title, task));
|
|
1283
1361
|
});
|
|
1284
|
-
task.on(
|
|
1362
|
+
task.on("MESSAGE", (message) => {
|
|
1285
1363
|
const parsed = Object.fromEntries(Object.entries(message).map(([key, value]) => {
|
|
1286
1364
|
if (this.options.messages.includes(key)) return [key, value];
|
|
1287
1365
|
}).filter(Boolean));
|
|
1288
1366
|
if (Object.keys(parsed).length > 0) {
|
|
1289
|
-
const output = this.serializer.serialize(
|
|
1367
|
+
const output = this.serializer.serialize("MESSAGE", parsed, task);
|
|
1290
1368
|
if (this.options.messagesToStderr.some((state) => Object.keys(parsed).includes(state))) this.logger.toStderr(output);
|
|
1291
1369
|
else this.logger.toStdout(output);
|
|
1292
1370
|
}
|
|
@@ -1298,6 +1376,8 @@ var TestRenderer = class TestRenderer {
|
|
|
1298
1376
|
//#endregion
|
|
1299
1377
|
//#region src/renderer/verbose/renderer.ts
|
|
1300
1378
|
var VerboseRenderer = class VerboseRenderer {
|
|
1379
|
+
tasks;
|
|
1380
|
+
options;
|
|
1301
1381
|
static nonTTY = true;
|
|
1302
1382
|
static rendererOptions = {
|
|
1303
1383
|
logTitleChange: false,
|
|
@@ -1342,44 +1422,44 @@ var VerboseRenderer = class VerboseRenderer {
|
|
|
1342
1422
|
renderer(tasks) {
|
|
1343
1423
|
tasks.forEach((task) => {
|
|
1344
1424
|
this.calculate(task);
|
|
1345
|
-
task.once(
|
|
1425
|
+
task.once("CLOSED", () => {
|
|
1346
1426
|
this.reset(task);
|
|
1347
1427
|
});
|
|
1348
1428
|
const rendererOptions = this.cache.rendererOptions.get(task.id);
|
|
1349
1429
|
const rendererTaskOptions = this.cache.rendererTaskOptions.get(task.id);
|
|
1350
|
-
task.on(
|
|
1430
|
+
task.on("SUBTASK", (subtasks) => {
|
|
1351
1431
|
this.renderer(subtasks);
|
|
1352
1432
|
});
|
|
1353
|
-
task.on(
|
|
1433
|
+
task.on("STATE", (state) => {
|
|
1354
1434
|
if (!task.hasTitle()) return;
|
|
1355
|
-
if (state ===
|
|
1356
|
-
else if (state ===
|
|
1435
|
+
if (state === "STARTED") this.logger.log("STARTED", task.title);
|
|
1436
|
+
else if (state === "COMPLETED") {
|
|
1357
1437
|
const timer = rendererTaskOptions.timer;
|
|
1358
|
-
this.logger.log(
|
|
1438
|
+
this.logger.log("COMPLETED", task.title, timer && { suffix: {
|
|
1359
1439
|
...timer,
|
|
1360
1440
|
condition: !!task.message?.duration && timer.condition,
|
|
1361
1441
|
args: [task.message.duration]
|
|
1362
1442
|
} });
|
|
1363
|
-
}
|
|
1443
|
+
} else if (state === "CANCELLED") this.logger.log("CANCELLED", task.title);
|
|
1364
1444
|
});
|
|
1365
|
-
task.on(
|
|
1366
|
-
this.logger.log(
|
|
1445
|
+
task.on("OUTPUT", (data) => {
|
|
1446
|
+
this.logger.log("OUTPUT", data);
|
|
1367
1447
|
});
|
|
1368
|
-
task.on(
|
|
1448
|
+
task.on("PROMPT", (prompt) => {
|
|
1369
1449
|
const cleansed = cleanseAnsi(prompt);
|
|
1370
|
-
if (cleansed) this.logger.log(
|
|
1450
|
+
if (cleansed) this.logger.log("PROMPT", cleansed);
|
|
1371
1451
|
});
|
|
1372
|
-
if (this.options?.logTitleChange !== false) task.on(
|
|
1373
|
-
this.logger.log(
|
|
1452
|
+
if (this.options?.logTitleChange !== false) task.on("TITLE", (title) => {
|
|
1453
|
+
this.logger.log("TITLE", title);
|
|
1374
1454
|
});
|
|
1375
|
-
task.on(
|
|
1376
|
-
if (message?.error) this.logger.log(
|
|
1377
|
-
else if (message?.skip) this.logger.log(
|
|
1378
|
-
else if (message?.rollback) this.logger.log(
|
|
1379
|
-
else if (message?.retry) this.logger.log(
|
|
1455
|
+
task.on("MESSAGE", (message) => {
|
|
1456
|
+
if (message?.error) this.logger.log("FAILED", message.error);
|
|
1457
|
+
else if (message?.skip) this.logger.log("SKIPPED", message.skip);
|
|
1458
|
+
else if (message?.rollback) this.logger.log("ROLLBACK", message.rollback);
|
|
1459
|
+
else if (message?.retry) this.logger.log("RETRY", task.title, { suffix: message.retry.count.toString() });
|
|
1380
1460
|
else if (message?.paused) {
|
|
1381
1461
|
const timer = rendererOptions?.pausedTimer;
|
|
1382
|
-
this.logger.log(
|
|
1462
|
+
this.logger.log("PAUSED", task.title, timer && { suffix: {
|
|
1383
1463
|
...timer,
|
|
1384
1464
|
condition: !!message?.paused && timer.condition,
|
|
1385
1465
|
args: [message.paused - Date.now()]
|
|
@@ -1426,17 +1506,17 @@ function getRendererClass(renderer) {
|
|
|
1426
1506
|
function getRenderer(options) {
|
|
1427
1507
|
if (assertFunctionOrSelf(options?.silentRendererCondition)) return {
|
|
1428
1508
|
renderer: getRendererClass("silent"),
|
|
1429
|
-
selection:
|
|
1509
|
+
selection: "SILENT"
|
|
1430
1510
|
};
|
|
1431
1511
|
const r = {
|
|
1432
1512
|
renderer: getRendererClass(options.renderer),
|
|
1433
1513
|
options: options.rendererOptions,
|
|
1434
|
-
selection:
|
|
1514
|
+
selection: "PRIMARY"
|
|
1435
1515
|
};
|
|
1436
1516
|
if (!isRendererSupported(r.renderer) || assertFunctionOrSelf(options?.fallbackRendererCondition)) return {
|
|
1437
1517
|
renderer: getRendererClass(options.fallbackRenderer),
|
|
1438
1518
|
options: options.fallbackRendererOptions,
|
|
1439
|
-
selection:
|
|
1519
|
+
selection: "SECONDARY"
|
|
1440
1520
|
};
|
|
1441
1521
|
return r;
|
|
1442
1522
|
}
|
|
@@ -1453,16 +1533,6 @@ function assertFunctionOrSelf(functionOrSelf, ...args) {
|
|
|
1453
1533
|
else return functionOrSelf;
|
|
1454
1534
|
}
|
|
1455
1535
|
|
|
1456
|
-
//#endregion
|
|
1457
|
-
//#region src/utils/clone.ts
|
|
1458
|
-
const clone = rfdc({ circles: true });
|
|
1459
|
-
/**
|
|
1460
|
-
* Deep clones a object in the easiest manner.
|
|
1461
|
-
*/
|
|
1462
|
-
function cloneObject(obj) {
|
|
1463
|
-
return clone(obj);
|
|
1464
|
-
}
|
|
1465
|
-
|
|
1466
1536
|
//#endregion
|
|
1467
1537
|
//#region src/utils/concurrency.ts
|
|
1468
1538
|
var Concurrency = class {
|
|
@@ -1510,47 +1580,6 @@ function delay(time) {
|
|
|
1510
1580
|
});
|
|
1511
1581
|
}
|
|
1512
1582
|
|
|
1513
|
-
//#endregion
|
|
1514
|
-
//#region src/interfaces/listr-error.interface.ts
|
|
1515
|
-
/**
|
|
1516
|
-
* Internal error handling mechanism for Listr collects the errors and details for a failed task.
|
|
1517
|
-
*
|
|
1518
|
-
* @see {@link https://listr2.kilic.dev/task/error-handling.html}
|
|
1519
|
-
*/
|
|
1520
|
-
var ListrError = class extends Error {
|
|
1521
|
-
path;
|
|
1522
|
-
ctx;
|
|
1523
|
-
constructor(error, type, task) {
|
|
1524
|
-
super(error.message);
|
|
1525
|
-
this.error = error;
|
|
1526
|
-
this.type = type;
|
|
1527
|
-
this.task = task;
|
|
1528
|
-
this.name = "ListrError";
|
|
1529
|
-
this.path = task.path;
|
|
1530
|
-
if (task?.options.collectErrors === "full") {
|
|
1531
|
-
this.task = cloneObject(task);
|
|
1532
|
-
this.ctx = cloneObject(task.listr.ctx);
|
|
1533
|
-
}
|
|
1534
|
-
this.stack = error?.stack;
|
|
1535
|
-
}
|
|
1536
|
-
};
|
|
1537
|
-
|
|
1538
|
-
//#endregion
|
|
1539
|
-
//#region src/interfaces/listr-renderer-error.interface.ts
|
|
1540
|
-
/**
|
|
1541
|
-
* Internal error coming from renderer.
|
|
1542
|
-
*/
|
|
1543
|
-
var ListrRendererError = class extends Error {};
|
|
1544
|
-
|
|
1545
|
-
//#endregion
|
|
1546
|
-
//#region src/interfaces/prompt-error.interface.ts
|
|
1547
|
-
/**
|
|
1548
|
-
* Internal error handling mechanism for Listr prompts to identify the failing cause is coming from a prompt.
|
|
1549
|
-
*
|
|
1550
|
-
* @see {@link https://listr2.kilic.dev/task/prompts.html}
|
|
1551
|
-
*/
|
|
1552
|
-
var PromptError = class extends Error {};
|
|
1553
|
-
|
|
1554
1583
|
//#endregion
|
|
1555
1584
|
//#region src/lib/task-wrapper.ts
|
|
1556
1585
|
/**
|
|
@@ -1559,6 +1588,7 @@ var PromptError = class extends Error {};
|
|
|
1559
1588
|
* @see {@link https://listr2.kilic.dev/task/task.html}
|
|
1560
1589
|
*/
|
|
1561
1590
|
var TaskWrapper = class {
|
|
1591
|
+
task;
|
|
1562
1592
|
constructor(task) {
|
|
1563
1593
|
this.task = task;
|
|
1564
1594
|
}
|
|
@@ -1586,6 +1616,10 @@ var TaskWrapper = class {
|
|
|
1586
1616
|
* @see {@link https://listr2.kilic.dev/task/output.html}
|
|
1587
1617
|
*/
|
|
1588
1618
|
set output(output) {
|
|
1619
|
+
if (output === null) {
|
|
1620
|
+
this.task.outputReset$ = null;
|
|
1621
|
+
return;
|
|
1622
|
+
}
|
|
1589
1623
|
output = Array.isArray(output) ? output : [output];
|
|
1590
1624
|
this.task.output$ = splat(output.shift(), ...output);
|
|
1591
1625
|
}
|
|
@@ -1595,6 +1629,22 @@ var TaskWrapper = class {
|
|
|
1595
1629
|
this.task.promptOutput$ = output;
|
|
1596
1630
|
}
|
|
1597
1631
|
/**
|
|
1632
|
+
* The `AbortSignal` for the current run, aborted when the run is interrupted (e.g. `SIGINT`).
|
|
1633
|
+
* Wire it into your own async work (`fetch`, child processes, timers) to cancel cooperatively.
|
|
1634
|
+
*
|
|
1635
|
+
* @see {@link https://listr2.kilic.dev/task/rollback.html}
|
|
1636
|
+
*/
|
|
1637
|
+
get signal() {
|
|
1638
|
+
return this.task.listr.signal;
|
|
1639
|
+
}
|
|
1640
|
+
/**
|
|
1641
|
+
* Interrupt the whole run programmatically, as if it received a `SIGINT`.
|
|
1642
|
+
* The other in-flight tasks roll back or are marked as cancelled, then the process exits with `127`.
|
|
1643
|
+
*/
|
|
1644
|
+
cancel() {
|
|
1645
|
+
this.task.listr.cancel();
|
|
1646
|
+
}
|
|
1647
|
+
/**
|
|
1598
1648
|
* Creates a new set of Listr subtasks.
|
|
1599
1649
|
*
|
|
1600
1650
|
* @see {@link https://listr2.kilic.dev/task/subtasks.html}
|
|
@@ -1611,7 +1661,7 @@ var TaskWrapper = class {
|
|
|
1611
1661
|
* @see {@link https://listr2.kilic.dev/task/error-handling.html}
|
|
1612
1662
|
*/
|
|
1613
1663
|
report(error, type) {
|
|
1614
|
-
if (this.task.options.collectErrors
|
|
1664
|
+
if (this.task.options.collectErrors) this.task.listr.errors?.push(new ListrError(error, type, this.task));
|
|
1615
1665
|
this.task.message$ = { error: error.message ?? this.task?.title };
|
|
1616
1666
|
}
|
|
1617
1667
|
/**
|
|
@@ -1620,7 +1670,7 @@ var TaskWrapper = class {
|
|
|
1620
1670
|
* @see {@link https://listr2.kilic.dev/task/skip.html}
|
|
1621
1671
|
*/
|
|
1622
1672
|
skip(message, ...metadata) {
|
|
1623
|
-
this.task.state$ =
|
|
1673
|
+
this.task.state$ = "SKIPPED";
|
|
1624
1674
|
if (message) this.task.message$ = { skip: message ? splat(message, ...metadata) : this.task?.title };
|
|
1625
1675
|
}
|
|
1626
1676
|
/**
|
|
@@ -1653,7 +1703,7 @@ var TaskWrapper = class {
|
|
|
1653
1703
|
stdout(type) {
|
|
1654
1704
|
return createWritable((chunk) => {
|
|
1655
1705
|
switch (type) {
|
|
1656
|
-
case
|
|
1706
|
+
case "PROMPT":
|
|
1657
1707
|
this.promptOutput = chunk;
|
|
1658
1708
|
break;
|
|
1659
1709
|
default: this.output = chunk;
|
|
@@ -1676,10 +1726,15 @@ var ListrTaskEventManager = class extends EventManager {};
|
|
|
1676
1726
|
* Creates and handles a runnable instance of the Task.
|
|
1677
1727
|
*/
|
|
1678
1728
|
var Task = class extends ListrTaskEventManager {
|
|
1729
|
+
listr;
|
|
1730
|
+
task;
|
|
1731
|
+
options;
|
|
1732
|
+
rendererOptions;
|
|
1733
|
+
rendererTaskOptions;
|
|
1679
1734
|
/** Unique id per task, can be used for identifying a Task. */
|
|
1680
1735
|
id = randomUUID();
|
|
1681
1736
|
/** The current state of the task. */
|
|
1682
|
-
state =
|
|
1737
|
+
state = "WAITING";
|
|
1683
1738
|
/** Subtasks of the current task. */
|
|
1684
1739
|
subtasks;
|
|
1685
1740
|
/** Title of the task. */
|
|
@@ -1726,26 +1781,34 @@ var Task = class extends ListrTaskEventManager {
|
|
|
1726
1781
|
*/
|
|
1727
1782
|
set state$(state) {
|
|
1728
1783
|
this.state = state;
|
|
1729
|
-
this.emit(
|
|
1784
|
+
this.emit("STATE", state);
|
|
1730
1785
|
if (this.hasSubtasks() && this.hasFailed()) {
|
|
1731
|
-
for (const subtask of this.subtasks) if (subtask.state ===
|
|
1786
|
+
for (const subtask of this.subtasks) if (subtask.state === "STARTED") subtask.state$ = "FAILED";
|
|
1732
1787
|
}
|
|
1733
|
-
this.listr.events.emit(
|
|
1788
|
+
this.listr.events.emit("SHOUD_REFRESH_RENDER");
|
|
1734
1789
|
}
|
|
1735
1790
|
/**
|
|
1736
1791
|
* Update the current output of the Task and emit the neccassary events.
|
|
1737
1792
|
*/
|
|
1738
1793
|
set output$(data) {
|
|
1739
1794
|
this.output = data;
|
|
1740
|
-
this.emit(
|
|
1741
|
-
this.listr.events.emit(
|
|
1795
|
+
this.emit("OUTPUT", data);
|
|
1796
|
+
this.listr.events.emit("SHOUD_REFRESH_RENDER");
|
|
1797
|
+
}
|
|
1798
|
+
/**
|
|
1799
|
+
* Reset the current output of the Task and emit the neccassary events.
|
|
1800
|
+
*/
|
|
1801
|
+
set outputReset$(data) {
|
|
1802
|
+
this.output = data;
|
|
1803
|
+
this.emit("OUTPUT_RESET");
|
|
1804
|
+
this.listr.events.emit("SHOUD_REFRESH_RENDER");
|
|
1742
1805
|
}
|
|
1743
1806
|
/**
|
|
1744
1807
|
* Update the current prompt output of the Task and emit the neccassary events.
|
|
1745
1808
|
*/
|
|
1746
1809
|
set promptOutput$(data) {
|
|
1747
|
-
this.emit(
|
|
1748
|
-
if (cleanseAnsi(data)) this.listr.events.emit(
|
|
1810
|
+
this.emit("PROMPT", data);
|
|
1811
|
+
if (cleanseAnsi(data)) this.listr.events.emit("SHOUD_REFRESH_RENDER");
|
|
1749
1812
|
}
|
|
1750
1813
|
/**
|
|
1751
1814
|
* Update or extend the current message of the Task and emit the neccassary events.
|
|
@@ -1755,16 +1818,16 @@ var Task = class extends ListrTaskEventManager {
|
|
|
1755
1818
|
...this.message,
|
|
1756
1819
|
...data
|
|
1757
1820
|
};
|
|
1758
|
-
this.emit(
|
|
1759
|
-
this.listr.events.emit(
|
|
1821
|
+
this.emit("MESSAGE", data);
|
|
1822
|
+
this.listr.events.emit("SHOUD_REFRESH_RENDER");
|
|
1760
1823
|
}
|
|
1761
1824
|
/**
|
|
1762
1825
|
* Update the current title of the Task and emit the neccassary events.
|
|
1763
1826
|
*/
|
|
1764
1827
|
set title$(title) {
|
|
1765
1828
|
this.title = title;
|
|
1766
|
-
this.emit(
|
|
1767
|
-
this.listr.events.emit(
|
|
1829
|
+
this.emit("TITLE", title);
|
|
1830
|
+
this.listr.events.emit("SHOUD_REFRESH_RENDER");
|
|
1768
1831
|
}
|
|
1769
1832
|
/**
|
|
1770
1833
|
* Current task path in the hierarchy.
|
|
@@ -1776,10 +1839,10 @@ var Task = class extends ListrTaskEventManager {
|
|
|
1776
1839
|
* Checks whether the current task with the given context should be set as enabled.
|
|
1777
1840
|
*/
|
|
1778
1841
|
async check(ctx) {
|
|
1779
|
-
if (this.state ===
|
|
1842
|
+
if (this.state === "WAITING") {
|
|
1780
1843
|
this.enabled = await assertFunctionOrSelf(this.task?.enabled ?? true, ctx);
|
|
1781
|
-
this.emit(
|
|
1782
|
-
this.listr.events.emit(
|
|
1844
|
+
this.emit("ENABLED", this.enabled);
|
|
1845
|
+
this.listr.events.emit("SHOUD_REFRESH_RENDER");
|
|
1783
1846
|
}
|
|
1784
1847
|
return this.enabled;
|
|
1785
1848
|
}
|
|
@@ -1789,7 +1852,7 @@ var Task = class extends ListrTaskEventManager {
|
|
|
1789
1852
|
}
|
|
1790
1853
|
/** Returns whether this task is finalized in someform. */
|
|
1791
1854
|
hasFinalized() {
|
|
1792
|
-
return this.isCompleted() || this.hasFailed() || this.isSkipped() || this.hasRolledBack();
|
|
1855
|
+
return this.isCompleted() || this.hasFailed() || this.isSkipped() || this.hasRolledBack() || this.isCancelled();
|
|
1793
1856
|
}
|
|
1794
1857
|
/** Returns whether this task is in progress. */
|
|
1795
1858
|
isPending() {
|
|
@@ -1797,35 +1860,39 @@ var Task = class extends ListrTaskEventManager {
|
|
|
1797
1860
|
}
|
|
1798
1861
|
/** Returns whether this task has started. */
|
|
1799
1862
|
isStarted() {
|
|
1800
|
-
return this.state ===
|
|
1863
|
+
return this.state === "STARTED";
|
|
1801
1864
|
}
|
|
1802
1865
|
/** Returns whether this task is skipped. */
|
|
1803
1866
|
isSkipped() {
|
|
1804
|
-
return this.state ===
|
|
1867
|
+
return this.state === "SKIPPED";
|
|
1805
1868
|
}
|
|
1806
1869
|
/** Returns whether this task has been completed. */
|
|
1807
1870
|
isCompleted() {
|
|
1808
|
-
return this.state ===
|
|
1871
|
+
return this.state === "COMPLETED";
|
|
1809
1872
|
}
|
|
1810
1873
|
/** Returns whether this task has been failed. */
|
|
1811
1874
|
hasFailed() {
|
|
1812
|
-
return this.state ===
|
|
1875
|
+
return this.state === "FAILED";
|
|
1876
|
+
}
|
|
1877
|
+
/** Returns whether this task has been cancelled by an interruption. */
|
|
1878
|
+
isCancelled() {
|
|
1879
|
+
return this.state === "CANCELLED";
|
|
1813
1880
|
}
|
|
1814
1881
|
/** Returns whether this task has an active rollback task going on. */
|
|
1815
1882
|
isRollingBack() {
|
|
1816
|
-
return this.state ===
|
|
1883
|
+
return this.state === "ROLLING_BACK";
|
|
1817
1884
|
}
|
|
1818
1885
|
/** Returns whether the rollback action was successful. */
|
|
1819
1886
|
hasRolledBack() {
|
|
1820
|
-
return this.state ===
|
|
1887
|
+
return this.state === "ROLLED_BACK";
|
|
1821
1888
|
}
|
|
1822
1889
|
/** Returns whether this task has an actively retrying task going on. */
|
|
1823
1890
|
isRetrying() {
|
|
1824
|
-
return this.state ===
|
|
1891
|
+
return this.state === "RETRY";
|
|
1825
1892
|
}
|
|
1826
1893
|
/** Returns whether this task has some kind of reset like retry and rollback going on. */
|
|
1827
1894
|
hasReset() {
|
|
1828
|
-
return this.state ===
|
|
1895
|
+
return this.state === "RETRY" || this.state === "ROLLING_BACK";
|
|
1829
1896
|
}
|
|
1830
1897
|
/** Returns whether enabled function resolves to true. */
|
|
1831
1898
|
isEnabled() {
|
|
@@ -1837,11 +1904,11 @@ var Task = class extends ListrTaskEventManager {
|
|
|
1837
1904
|
}
|
|
1838
1905
|
/** Returns whether this task has a prompt inside. */
|
|
1839
1906
|
isPrompt() {
|
|
1840
|
-
return this.state ===
|
|
1907
|
+
return this.state === "PROMPT";
|
|
1841
1908
|
}
|
|
1842
1909
|
/** Returns whether this task is currently paused. */
|
|
1843
1910
|
isPaused() {
|
|
1844
|
-
return this.state ===
|
|
1911
|
+
return this.state === "PAUSED";
|
|
1845
1912
|
}
|
|
1846
1913
|
/** Returns whether this task is closed. */
|
|
1847
1914
|
isClosed() {
|
|
@@ -1850,7 +1917,7 @@ var Task = class extends ListrTaskEventManager {
|
|
|
1850
1917
|
/** Pause the given task for certain time. */
|
|
1851
1918
|
async pause(time) {
|
|
1852
1919
|
const state = this.state;
|
|
1853
|
-
this.state$ =
|
|
1920
|
+
this.state$ = "PAUSED";
|
|
1854
1921
|
this.message$ = { paused: Date.now() + time };
|
|
1855
1922
|
await delay(time);
|
|
1856
1923
|
this.state$ = state;
|
|
@@ -1867,7 +1934,7 @@ var Task = class extends ListrTaskEventManager {
|
|
|
1867
1934
|
result.rendererClass = getRendererClass("silent");
|
|
1868
1935
|
this.subtasks = result.tasks;
|
|
1869
1936
|
result.errors = this.listr.errors;
|
|
1870
|
-
this.emit(
|
|
1937
|
+
this.emit("SUBTASK", this.subtasks);
|
|
1871
1938
|
result = result.run(context);
|
|
1872
1939
|
} else if (result instanceof Promise) result = result.then(handleResult);
|
|
1873
1940
|
else if (isReadable(result)) result = new Promise((resolve, reject) => {
|
|
@@ -1889,22 +1956,23 @@ var Task = class extends ListrTaskEventManager {
|
|
|
1889
1956
|
return result;
|
|
1890
1957
|
};
|
|
1891
1958
|
const startTime = Date.now();
|
|
1892
|
-
this.state$ =
|
|
1959
|
+
this.state$ = "STARTED";
|
|
1893
1960
|
const skipped = await assertFunctionOrSelf(this.task?.skip ?? false, context);
|
|
1894
1961
|
if (skipped) {
|
|
1895
1962
|
if (typeof skipped === "string") this.message$ = { skip: skipped };
|
|
1896
1963
|
else if (this.hasTitle()) this.message$ = { skip: this.title };
|
|
1897
1964
|
else this.message$ = { skip: "Skipped task without a title." };
|
|
1898
|
-
this.state$ =
|
|
1965
|
+
this.state$ = "SKIPPED";
|
|
1899
1966
|
return;
|
|
1900
1967
|
}
|
|
1901
1968
|
try {
|
|
1902
1969
|
const retryCount = typeof this.task?.retry === "number" && this.task.retry > 0 ? this.task.retry + 1 : typeof this.task?.retry === "object" && this.task.retry.tries > 0 ? this.task.retry.tries + 1 : 1;
|
|
1903
1970
|
const retryDelay = typeof this.task.retry === "object" && this.task.retry.delay;
|
|
1904
1971
|
for (let retries = 1; retries <= retryCount; retries++) try {
|
|
1905
|
-
await handleResult(this.taskFn(context, wrapper));
|
|
1972
|
+
await Promise.race([handleResult(this.taskFn(context, wrapper)), this.whenInterrupted()]);
|
|
1906
1973
|
break;
|
|
1907
1974
|
} catch (err) {
|
|
1975
|
+
if (this.listr.signal.aborted) throw err;
|
|
1908
1976
|
if (retries !== retryCount) {
|
|
1909
1977
|
this.retry = {
|
|
1910
1978
|
count: retries,
|
|
@@ -1913,27 +1981,27 @@ var Task = class extends ListrTaskEventManager {
|
|
|
1913
1981
|
this.message$ = { retry: this.retry };
|
|
1914
1982
|
this.title$ = this.initialTitle;
|
|
1915
1983
|
this.output = void 0;
|
|
1916
|
-
wrapper.report(err,
|
|
1917
|
-
this.state$ =
|
|
1984
|
+
wrapper.report(err, "WILL_RETRY");
|
|
1985
|
+
this.state$ = "RETRY";
|
|
1918
1986
|
if (retryDelay) await this.pause(retryDelay);
|
|
1919
1987
|
} else throw err;
|
|
1920
1988
|
}
|
|
1921
1989
|
if (this.isStarted() || this.isRetrying()) {
|
|
1922
1990
|
this.message$ = { duration: Date.now() - startTime };
|
|
1923
|
-
this.state$ =
|
|
1991
|
+
this.state$ = "COMPLETED";
|
|
1924
1992
|
}
|
|
1925
1993
|
} catch (error) {
|
|
1926
1994
|
if (this.prompt instanceof PromptError) error = this.prompt;
|
|
1927
1995
|
if (this.task?.rollback) {
|
|
1928
|
-
wrapper.report(error,
|
|
1996
|
+
wrapper.report(error, "WILL_ROLLBACK");
|
|
1929
1997
|
try {
|
|
1930
|
-
this.state$ =
|
|
1998
|
+
this.state$ = "ROLLING_BACK";
|
|
1931
1999
|
await this.task.rollback(context, wrapper);
|
|
1932
2000
|
this.message$ = { rollback: this.title };
|
|
1933
|
-
this.state$ =
|
|
2001
|
+
this.state$ = "ROLLED_BACK";
|
|
1934
2002
|
} catch (err) {
|
|
1935
|
-
this.state$ =
|
|
1936
|
-
wrapper.report(err,
|
|
2003
|
+
this.state$ = "FAILED";
|
|
2004
|
+
wrapper.report(err, "HAS_FAILED_TO_ROLLBACK");
|
|
1937
2005
|
this.close();
|
|
1938
2006
|
throw err;
|
|
1939
2007
|
}
|
|
@@ -1942,22 +2010,38 @@ var Task = class extends ListrTaskEventManager {
|
|
|
1942
2010
|
throw error;
|
|
1943
2011
|
}
|
|
1944
2012
|
} else {
|
|
1945
|
-
this.
|
|
2013
|
+
if (this.listr.signal.aborted) {
|
|
2014
|
+
this.state$ = "CANCELLED";
|
|
2015
|
+
throw error;
|
|
2016
|
+
}
|
|
2017
|
+
this.state$ = "FAILED";
|
|
1946
2018
|
if (this.listr.options.exitOnError !== false && await assertFunctionOrSelf(this.task?.exitOnError, context) !== false) {
|
|
1947
|
-
wrapper.report(error,
|
|
2019
|
+
wrapper.report(error, "HAS_FAILED");
|
|
1948
2020
|
this.close();
|
|
1949
2021
|
throw error;
|
|
1950
|
-
} else if (!this.hasSubtasks()) wrapper.report(error,
|
|
2022
|
+
} else if (!this.hasSubtasks()) wrapper.report(error, "HAS_FAILED_WITHOUT_ERROR");
|
|
1951
2023
|
}
|
|
1952
2024
|
} finally {
|
|
1953
2025
|
this.close();
|
|
1954
2026
|
}
|
|
1955
2027
|
}
|
|
1956
2028
|
close() {
|
|
1957
|
-
this.emit(
|
|
1958
|
-
this.listr.events.emit(
|
|
2029
|
+
this.emit("CLOSED");
|
|
2030
|
+
this.listr.events.emit("SHOUD_REFRESH_RENDER");
|
|
1959
2031
|
this.complete();
|
|
1960
2032
|
}
|
|
2033
|
+
whenInterrupted() {
|
|
2034
|
+
return new Promise((_, reject) => {
|
|
2035
|
+
const onAbort = () => {
|
|
2036
|
+
if (!this.hasSubtasks()) reject(/* @__PURE__ */ new Error("Interrupted."));
|
|
2037
|
+
};
|
|
2038
|
+
if (this.listr.signal.aborted) {
|
|
2039
|
+
onAbort();
|
|
2040
|
+
return;
|
|
2041
|
+
}
|
|
2042
|
+
this.listr.signal.addEventListener("abort", onAbort, { once: true });
|
|
2043
|
+
});
|
|
2044
|
+
}
|
|
1961
2045
|
};
|
|
1962
2046
|
|
|
1963
2047
|
//#endregion
|
|
@@ -1972,8 +2056,11 @@ var ListrEventManager = class extends EventManager {};
|
|
|
1972
2056
|
* @see {@link https://listr2.kilic.dev/listr/listr.html}
|
|
1973
2057
|
*/
|
|
1974
2058
|
var Listr = class {
|
|
2059
|
+
task;
|
|
2060
|
+
options;
|
|
2061
|
+
parentTask;
|
|
1975
2062
|
tasks = [];
|
|
1976
|
-
errors
|
|
2063
|
+
errors;
|
|
1977
2064
|
ctx;
|
|
1978
2065
|
events;
|
|
1979
2066
|
path = [];
|
|
@@ -1981,8 +2068,11 @@ var Listr = class {
|
|
|
1981
2068
|
rendererClassOptions;
|
|
1982
2069
|
rendererSelection;
|
|
1983
2070
|
boundSignalHandler;
|
|
2071
|
+
signal;
|
|
1984
2072
|
concurrency;
|
|
1985
2073
|
renderer;
|
|
2074
|
+
abortController;
|
|
2075
|
+
startedTasks = [];
|
|
1986
2076
|
constructor(task, options, parentTask) {
|
|
1987
2077
|
this.task = task;
|
|
1988
2078
|
this.options = options;
|
|
@@ -2004,16 +2094,22 @@ var Listr = class {
|
|
|
2004
2094
|
if (parentTask) {
|
|
2005
2095
|
this.path = [...parentTask.listr.path, parentTask.title];
|
|
2006
2096
|
this.errors = parentTask.listr.errors;
|
|
2007
|
-
}
|
|
2097
|
+
} else this.errors = this.options.collectErrors ? [] : null;
|
|
2008
2098
|
if (this.parentTask?.listr.events instanceof ListrEventManager) this.events = this.parentTask.listr.events;
|
|
2009
2099
|
else this.events = new ListrEventManager();
|
|
2100
|
+
if (this.parentTask?.listr.abortController instanceof AbortController) this.abortController = this.parentTask.listr.abortController;
|
|
2101
|
+
else {
|
|
2102
|
+
this.abortController = new AbortController();
|
|
2103
|
+
setMaxListeners(0, this.abortController.signal);
|
|
2104
|
+
}
|
|
2105
|
+
this.signal = this.abortController.signal;
|
|
2010
2106
|
/* istanbul ignore if */
|
|
2011
|
-
if (this.options?.forceTTY || process.env[
|
|
2107
|
+
if (this.options?.forceTTY || process.env["LISTR_FORCE_TTY"]) {
|
|
2012
2108
|
process.stdout.isTTY = true;
|
|
2013
2109
|
process.stderr.isTTY = true;
|
|
2014
2110
|
}
|
|
2015
2111
|
/* istanbul ignore if */
|
|
2016
|
-
if (this.options?.forceUnicode) process.env[
|
|
2112
|
+
if (this.options?.forceUnicode) process.env["LISTR_FORCE_UNICODE"] = "1";
|
|
2017
2113
|
const renderer = getRenderer({
|
|
2018
2114
|
renderer: this.options.renderer,
|
|
2019
2115
|
rendererOptions: this.options.rendererOptions,
|
|
@@ -2028,9 +2124,9 @@ var Listr = class {
|
|
|
2028
2124
|
/* istanbul ignore next */
|
|
2029
2125
|
this.add(task ?? []);
|
|
2030
2126
|
/* istanbul ignore if */
|
|
2031
|
-
if (this.options.registerSignalListeners) {
|
|
2127
|
+
if (this.options.registerSignalListeners && this.isRoot()) {
|
|
2032
2128
|
this.boundSignalHandler = this.signalHandler.bind(this);
|
|
2033
|
-
process.
|
|
2129
|
+
process.on("SIGINT", this.boundSignalHandler).setMaxListeners(0);
|
|
2034
2130
|
}
|
|
2035
2131
|
}
|
|
2036
2132
|
/**
|
|
@@ -2062,46 +2158,73 @@ var Listr = class {
|
|
|
2062
2158
|
if (!this.renderer) this.renderer = new this.rendererClass(this.tasks, this.rendererClassOptions, this.events);
|
|
2063
2159
|
await this.renderer.render();
|
|
2064
2160
|
this.ctx = this.options?.ctx ?? context ?? {};
|
|
2161
|
+
let error;
|
|
2162
|
+
let failed = false;
|
|
2065
2163
|
try {
|
|
2066
2164
|
await Promise.all(this.tasks.map((task) => task.check(this.ctx)));
|
|
2067
2165
|
await Promise.all(this.tasks.map((task) => this.concurrency.add(() => this.runTask(task))));
|
|
2068
|
-
this.renderer.end();
|
|
2069
|
-
this.removeSignalHandler();
|
|
2070
2166
|
} catch (err) {
|
|
2071
|
-
|
|
2072
|
-
|
|
2167
|
+
failed = true;
|
|
2168
|
+
error = err;
|
|
2169
|
+
}
|
|
2170
|
+
if (this.signal.aborted) {
|
|
2171
|
+
await Promise.allSettled(this.startedTasks);
|
|
2172
|
+
if (this.isRoot()) {
|
|
2173
|
+
this.cancelUnfinishedTasks();
|
|
2174
|
+
this.renderer.end();
|
|
2073
2175
|
this.removeSignalHandler();
|
|
2074
|
-
|
|
2176
|
+
process.exit(127);
|
|
2177
|
+
return this.ctx;
|
|
2075
2178
|
}
|
|
2179
|
+
throw error ?? /* @__PURE__ */ new Error("Interrupted.");
|
|
2180
|
+
}
|
|
2181
|
+
if (failed && this.options.exitOnError !== false) {
|
|
2182
|
+
this.renderer.end(error);
|
|
2183
|
+
this.removeSignalHandler();
|
|
2184
|
+
throw error;
|
|
2185
|
+
}
|
|
2186
|
+
if (!failed) {
|
|
2187
|
+
this.renderer.end();
|
|
2188
|
+
this.removeSignalHandler();
|
|
2076
2189
|
}
|
|
2077
2190
|
return this.ctx;
|
|
2078
2191
|
}
|
|
2192
|
+
/**
|
|
2193
|
+
* Interrupt the running task list programmatically, as if it received a `SIGINT`.
|
|
2194
|
+
*
|
|
2195
|
+
* In-flight tasks roll back or are marked as cancelled and the process exits with `127`.
|
|
2196
|
+
*/
|
|
2197
|
+
cancel() {
|
|
2198
|
+
this.abortController.abort();
|
|
2199
|
+
}
|
|
2079
2200
|
generate(tasks) {
|
|
2080
2201
|
tasks = Array.isArray(tasks) ? tasks : [tasks];
|
|
2081
2202
|
return tasks.map((task) => {
|
|
2082
2203
|
let rendererTaskOptions;
|
|
2083
|
-
if (this.rendererSelection ===
|
|
2084
|
-
else if (this.rendererSelection ===
|
|
2204
|
+
if (this.rendererSelection === "PRIMARY") rendererTaskOptions = task.rendererOptions;
|
|
2205
|
+
else if (this.rendererSelection === "SECONDARY") rendererTaskOptions = task.fallbackRendererOptions;
|
|
2085
2206
|
return new Task(this, task, this.options, this.rendererClassOptions, rendererTaskOptions);
|
|
2086
2207
|
});
|
|
2087
2208
|
}
|
|
2088
2209
|
async runTask(task) {
|
|
2089
2210
|
if (!await task.check(this.ctx)) return;
|
|
2090
|
-
|
|
2211
|
+
const promise = new TaskWrapper(task).run(this.ctx);
|
|
2212
|
+
this.startedTasks.push(promise);
|
|
2213
|
+
return promise;
|
|
2091
2214
|
}
|
|
2092
2215
|
signalHandler() {
|
|
2093
|
-
this.
|
|
2094
|
-
if (task.isPending()) task.state$ = ListrTaskState.FAILED;
|
|
2095
|
-
});
|
|
2096
|
-
if (this.isRoot()) {
|
|
2097
|
-
this.renderer?.end(/* @__PURE__ */ new Error("Interrupted."));
|
|
2098
|
-
process.exit(127);
|
|
2099
|
-
}
|
|
2216
|
+
this.abortController.abort();
|
|
2100
2217
|
}
|
|
2101
2218
|
removeSignalHandler() {
|
|
2102
2219
|
if (this.boundSignalHandler) process.removeListener("SIGINT", this.boundSignalHandler);
|
|
2103
2220
|
}
|
|
2221
|
+
cancelUnfinishedTasks(tasks = this.tasks) {
|
|
2222
|
+
for (const task of tasks) {
|
|
2223
|
+
if (task.hasSubtasks()) this.cancelUnfinishedTasks(task.subtasks);
|
|
2224
|
+
if (task.isEnabled() !== false && !task.hasFinalized()) task.state$ = "CANCELLED";
|
|
2225
|
+
}
|
|
2226
|
+
}
|
|
2104
2227
|
};
|
|
2105
2228
|
|
|
2106
2229
|
//#endregion
|
|
2107
|
-
export { ANSI_ESCAPE, ANSI_ESCAPE_CODES, BaseEventMap, Concurrency, DefaultRenderer, EventManager, LISTR_DEFAULT_RENDERER_STYLE, LISTR_LOGGER_STDERR_LEVELS, LISTR_LOGGER_STYLE, Listr, ListrDefaultRendererLogLevels, ListrEnvironmentVariables, ListrError, ListrErrorTypes, ListrEventManager, ListrEventType, ListrLogLevels, ListrLogger, ListrPromptAdapter, ListrRendererError, ListrRendererSelection, ListrTaskEventManager, ListrTaskEventType, ListrTaskState, PRESET_TIMER, PRESET_TIMESTAMP, ProcessOutput, ProcessOutputBuffer, ProcessOutputStream, PromptError, SilentRenderer, SimpleRenderer, Spinner, TestRenderer, TestRendererSerializer, VerboseRenderer, assertFunctionOrSelf, cleanseAnsi,
|
|
2230
|
+
export { ANSI_ESCAPE, ANSI_ESCAPE_CODES, BaseEventMap, Concurrency, DefaultRenderer, EventManager, LISTR_DEFAULT_RENDERER_STYLE, LISTR_LOGGER_STDERR_LEVELS, LISTR_LOGGER_STYLE, Listr, ListrDefaultRendererLogLevels, ListrEnvironmentVariables, ListrError, ListrErrorTypes, ListrEventManager, ListrEventType, ListrLogLevels, ListrLogger, ListrPromptAdapter, ListrRendererError, ListrRendererSelection, ListrTaskEventManager, ListrTaskEventType, ListrTaskState, PRESET_TIMER, PRESET_TIMESTAMP, ProcessOutput, ProcessOutputBuffer, ProcessOutputStream, PromptError, SilentRenderer, SimpleRenderer, Spinner, TestRenderer, TestRendererSerializer, VerboseRenderer, assertFunctionOrSelf, cleanseAnsi, color, createWritable, delay, figures, getRenderer, getRendererClass, indent, isObservable, isReadable, isUnicodeSupported, parseTimer, parseTimestamp, splat };
|