@oclif/core 3.26.6 → 4.0.0-beta.10

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.
Files changed (124) hide show
  1. package/lib/args.d.ts +4 -4
  2. package/lib/cache.d.ts +3 -3
  3. package/lib/cache.js +1 -1
  4. package/lib/command.d.ts +18 -18
  5. package/lib/command.js +12 -21
  6. package/lib/config/config.d.ts +14 -40
  7. package/lib/config/config.js +120 -153
  8. package/lib/config/plugin-loader.d.ts +6 -6
  9. package/lib/config/plugin-loader.js +4 -28
  10. package/lib/config/plugin.d.ts +3 -3
  11. package/lib/config/plugin.js +7 -11
  12. package/lib/config/ts-path.d.ts +1 -1
  13. package/lib/config/ts-path.js +1 -2
  14. package/lib/config/util.d.ts +1 -1
  15. package/lib/config/util.js +5 -21
  16. package/lib/errors/error.js +5 -8
  17. package/lib/errors/errors/cli.d.ts +5 -5
  18. package/lib/errors/errors/cli.js +5 -5
  19. package/lib/errors/errors/pretty-print.d.ts +2 -2
  20. package/lib/errors/errors/pretty-print.js +2 -2
  21. package/lib/errors/exit.d.ts +1 -0
  22. package/lib/errors/exit.js +8 -0
  23. package/lib/errors/handle.js +4 -11
  24. package/lib/errors/index.d.ts +1 -3
  25. package/lib/errors/index.js +5 -12
  26. package/lib/errors/warn.d.ts +5 -0
  27. package/lib/errors/warn.js +10 -5
  28. package/lib/execute.js +1 -1
  29. package/lib/flags.d.ts +4 -4
  30. package/lib/{cli-ux/flush.js → flush.js} +2 -2
  31. package/lib/help/command.js +6 -5
  32. package/lib/help/formatter.d.ts +3 -3
  33. package/lib/help/formatter.js +8 -9
  34. package/lib/help/index.d.ts +1 -0
  35. package/lib/help/index.js +23 -17
  36. package/lib/help/root.js +3 -3
  37. package/lib/index.d.ts +6 -7
  38. package/lib/index.js +8 -12
  39. package/lib/interfaces/config.d.ts +9 -20
  40. package/lib/interfaces/errors.d.ts +5 -5
  41. package/lib/interfaces/flags.d.ts +2 -2
  42. package/lib/interfaces/index.d.ts +2 -1
  43. package/lib/interfaces/logger.d.ts +9 -0
  44. package/lib/interfaces/parser.d.ts +6 -6
  45. package/lib/interfaces/pjson.d.ts +217 -151
  46. package/lib/interfaces/plugin.d.ts +26 -24
  47. package/lib/interfaces/theme.d.ts +30 -19
  48. package/lib/interfaces/theme.js +2 -19
  49. package/lib/interfaces/topic.d.ts +2 -2
  50. package/lib/logger.d.ts +14 -0
  51. package/lib/logger.js +90 -0
  52. package/lib/main.js +5 -3
  53. package/lib/parser/errors.d.ts +1 -1
  54. package/lib/parser/errors.js +5 -5
  55. package/lib/parser/help.js +2 -2
  56. package/lib/parser/parse.js +2 -1
  57. package/lib/performance.js +3 -2
  58. package/lib/settings.d.ts +5 -11
  59. package/lib/util/determine-priority.d.ts +21 -0
  60. package/lib/util/determine-priority.js +55 -0
  61. package/lib/util/find-root.d.ts +1 -0
  62. package/lib/util/find-root.js +19 -19
  63. package/lib/util/fs.js +12 -0
  64. package/lib/util/ids.d.ts +1 -1
  65. package/lib/util/read-pjson.d.ts +7 -0
  66. package/lib/util/read-pjson.js +60 -0
  67. package/lib/util/read-tsconfig.js +3 -8
  68. package/lib/{cli-ux → ux}/action/base.d.ts +5 -7
  69. package/lib/{cli-ux → ux}/action/base.js +0 -3
  70. package/lib/{cli-ux → ux}/action/spinner.d.ts +5 -4
  71. package/lib/{cli-ux → ux}/action/spinner.js +16 -39
  72. package/lib/ux/action/types.d.ts +5 -0
  73. package/lib/ux/action/types.js +2 -0
  74. package/lib/ux/colorize-json.d.ts +28 -0
  75. package/lib/ux/colorize-json.js +67 -0
  76. package/lib/ux/index.d.ts +69 -0
  77. package/lib/ux/index.js +88 -0
  78. package/lib/{cli-ux → ux}/list.d.ts +1 -1
  79. package/lib/{cli-ux → ux}/list.js +1 -2
  80. package/lib/ux/theme.d.ts +9 -0
  81. package/lib/ux/theme.js +43 -0
  82. package/lib/ux/write.d.ts +2 -0
  83. package/lib/ux/write.js +22 -0
  84. package/package.json +37 -42
  85. package/flush.d.ts +0 -3
  86. package/flush.js +0 -1
  87. package/handle.js +0 -1
  88. package/lib/cli-ux/action/spinners.d.ts +0 -251
  89. package/lib/cli-ux/action/spinners.js +0 -374
  90. package/lib/cli-ux/action/types.d.ts +0 -5
  91. package/lib/cli-ux/config.d.ts +0 -25
  92. package/lib/cli-ux/config.js +0 -52
  93. package/lib/cli-ux/exit.d.ts +0 -8
  94. package/lib/cli-ux/exit.js +0 -16
  95. package/lib/cli-ux/index.d.ts +0 -133
  96. package/lib/cli-ux/index.js +0 -183
  97. package/lib/cli-ux/prompt.d.ts +0 -32
  98. package/lib/cli-ux/prompt.js +0 -185
  99. package/lib/cli-ux/stream.d.ts +0 -23
  100. package/lib/cli-ux/stream.js +0 -43
  101. package/lib/cli-ux/styled/index.d.ts +0 -4
  102. package/lib/cli-ux/styled/index.js +0 -36
  103. package/lib/cli-ux/styled/object.d.ts +0 -1
  104. package/lib/cli-ux/styled/object.js +0 -39
  105. package/lib/cli-ux/styled/progress.d.ts +0 -2
  106. package/lib/cli-ux/styled/progress.js +0 -8
  107. package/lib/cli-ux/styled/table.d.ts +0 -45
  108. package/lib/cli-ux/styled/table.js +0 -345
  109. package/lib/cli-ux/styled/tree.d.ts +0 -9
  110. package/lib/cli-ux/styled/tree.js +0 -37
  111. package/lib/cli-ux/theme.d.ts +0 -11
  112. package/lib/cli-ux/theme.js +0 -61
  113. package/lib/cli-ux/wait.d.ts +0 -2
  114. package/lib/cli-ux/wait.js +0 -5
  115. package/lib/cli-ux/write.d.ts +0 -8
  116. package/lib/cli-ux/write.js +0 -15
  117. package/lib/errors/config.d.ts +0 -6
  118. package/lib/errors/config.js +0 -38
  119. package/lib/errors/logger.d.ts +0 -8
  120. package/lib/errors/logger.js +0 -45
  121. /package/lib/{cli-ux/flush.d.ts → flush.d.ts} +0 -0
  122. /package/lib/{cli-ux/action/types.js → interfaces/logger.js} +0 -0
  123. /package/lib/{cli-ux → ux}/action/simple.d.ts +0 -0
  124. /package/lib/{cli-ux → ux}/action/simple.js +0 -0
@@ -1,183 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- var __importDefault = (this && this.__importDefault) || function (mod) {
26
- return (mod && mod.__esModule) ? mod : { "default": mod };
27
- };
28
- Object.defineProperty(exports, "__esModule", { value: true });
29
- exports.write = exports.colorize = exports.Table = exports.ExitError = exports.config = exports.Config = exports.ActionBase = exports.warn = exports.wait = exports.url = exports.tree = exports.trace = exports.table = exports.styledObject = exports.styledJSON = exports.styledHeader = exports.prompt = exports.progress = exports.logToStderr = exports.log = exports.info = exports.flush = exports.exit = exports.error = exports.done = exports.debug = exports.confirm = exports.anykey = exports.annotation = exports.action = exports.ux = void 0;
30
- const chalk_1 = __importDefault(require("chalk"));
31
- const node_util_1 = require("node:util");
32
- const Errors = __importStar(require("../errors"));
33
- const config_1 = require("./config");
34
- const flush_1 = require("./flush");
35
- const uxPrompt = __importStar(require("./prompt"));
36
- const styled = __importStar(require("./styled"));
37
- const wait_1 = __importDefault(require("./wait"));
38
- const write_1 = __importDefault(require("./write"));
39
- const hyperlinker = require('hyperlinker');
40
- class ux {
41
- static config = config_1.config;
42
- static get action() {
43
- return config_1.config.action;
44
- }
45
- static annotation(text, annotation) {
46
- const supports = require('supports-hyperlinks');
47
- if (supports.stdout) {
48
- // \u001b]8;;https://google.com\u0007sometext\u001b]8;;\u0007
49
- this.log(`\u001B]1337;AddAnnotation=${text.length}|${annotation}\u0007${text}`);
50
- }
51
- else {
52
- this.log(text);
53
- }
54
- }
55
- /**
56
- * "press anykey to continue"
57
- */
58
- static get anykey() {
59
- return uxPrompt.anykey;
60
- }
61
- static get confirm() {
62
- return uxPrompt.confirm;
63
- }
64
- static debug(format, ...args) {
65
- if (['debug', 'trace'].includes(this.config.outputLevel)) {
66
- this.info((0, node_util_1.format)(format, ...args) + '\n');
67
- }
68
- }
69
- static async done() {
70
- config_1.config.action.stop();
71
- }
72
- static async flush(ms = 10_000) {
73
- await (0, flush_1.flush)(ms);
74
- }
75
- static info(format, ...args) {
76
- write_1.default.stdout((0, node_util_1.format)(format, ...args) + '\n');
77
- }
78
- static log(format, ...args) {
79
- this.info(format || '', ...args);
80
- }
81
- static logToStderr(format, ...args) {
82
- write_1.default.stderr((0, node_util_1.format)(format, ...args) + '\n');
83
- }
84
- static get progress() {
85
- return styled.progress;
86
- }
87
- static get prompt() {
88
- return uxPrompt.prompt;
89
- }
90
- static styledHeader(header) {
91
- this.info(chalk_1.default.dim('=== ') + chalk_1.default.bold(header) + '\n');
92
- }
93
- static styledJSON(obj) {
94
- const json = JSON.stringify(obj, null, 2);
95
- if (!chalk_1.default.level) {
96
- this.info(json);
97
- return;
98
- }
99
- const cardinal = require('cardinal');
100
- const theme = require('cardinal/themes/jq');
101
- this.info(cardinal.highlight(json, { json: true, theme }));
102
- }
103
- static styledObject(obj, keys) {
104
- this.info(styled.styledObject(obj, keys));
105
- }
106
- static get table() {
107
- return styled.Table.table;
108
- }
109
- static trace(format, ...args) {
110
- if (this.config.outputLevel === 'trace') {
111
- this.info((0, node_util_1.format)(format, ...args) + '\n');
112
- }
113
- }
114
- static get tree() {
115
- return styled.tree;
116
- }
117
- static url(text, uri, params = {}) {
118
- const supports = require('supports-hyperlinks');
119
- if (supports.stdout) {
120
- this.log(hyperlinker(text, uri, params));
121
- }
122
- else {
123
- this.log(uri);
124
- }
125
- }
126
- static get wait() {
127
- return wait_1.default;
128
- }
129
- }
130
- exports.ux = ux;
131
- const { action, annotation, anykey, confirm, debug, done, flush, info, log, logToStderr, progress, prompt, styledHeader, styledJSON, styledObject, table, trace, tree, url, wait, } = ux;
132
- exports.action = action;
133
- exports.annotation = annotation;
134
- exports.anykey = anykey;
135
- exports.confirm = confirm;
136
- exports.debug = debug;
137
- exports.done = done;
138
- exports.flush = flush;
139
- exports.info = info;
140
- exports.log = log;
141
- exports.logToStderr = logToStderr;
142
- exports.progress = progress;
143
- exports.prompt = prompt;
144
- exports.styledHeader = styledHeader;
145
- exports.styledJSON = styledJSON;
146
- exports.styledObject = styledObject;
147
- exports.table = table;
148
- exports.trace = trace;
149
- exports.tree = tree;
150
- exports.url = url;
151
- exports.wait = wait;
152
- const { error, exit, warn } = Errors;
153
- exports.error = error;
154
- exports.exit = exit;
155
- exports.warn = warn;
156
- const uxProcessExitHandler = async () => {
157
- try {
158
- await ux.done();
159
- }
160
- catch (error) {
161
- console.error(error);
162
- process.exitCode = 1;
163
- }
164
- };
165
- // to avoid MaxListenersExceededWarning
166
- // only attach named listener once
167
- const uxListener = process.listeners('exit').find((fn) => fn.name === uxProcessExitHandler.name);
168
- if (!uxListener) {
169
- process.once('exit', uxProcessExitHandler);
170
- }
171
- var base_1 = require("./action/base");
172
- Object.defineProperty(exports, "ActionBase", { enumerable: true, get: function () { return base_1.ActionBase; } });
173
- var config_2 = require("./config");
174
- Object.defineProperty(exports, "Config", { enumerable: true, get: function () { return config_2.Config; } });
175
- Object.defineProperty(exports, "config", { enumerable: true, get: function () { return config_2.config; } });
176
- var exit_1 = require("./exit");
177
- Object.defineProperty(exports, "ExitError", { enumerable: true, get: function () { return exit_1.ExitError; } });
178
- var styled_1 = require("./styled");
179
- Object.defineProperty(exports, "Table", { enumerable: true, get: function () { return styled_1.Table; } });
180
- var theme_1 = require("./theme");
181
- Object.defineProperty(exports, "colorize", { enumerable: true, get: function () { return theme_1.colorize; } });
182
- var write_2 = require("./write");
183
- Object.defineProperty(exports, "write", { enumerable: true, get: function () { return __importDefault(write_2).default; } });
@@ -1,32 +0,0 @@
1
- /**
2
- * @deprecated `ux` will be removed in the next major. See https://github.com/oclif/core/discussions/999
3
- */
4
- export interface IPromptOptions {
5
- default?: string;
6
- prompt?: string;
7
- /**
8
- * Requires user input if true, otherwise allows empty input
9
- */
10
- required?: boolean;
11
- timeout?: number;
12
- type?: 'hide' | 'mask' | 'normal' | 'single';
13
- }
14
- /**
15
- * prompt for input
16
- * @param name - prompt text
17
- * @param options - @see IPromptOptions
18
- * @returns Promise<string>
19
- */
20
- export declare function prompt(name: string, options?: IPromptOptions): Promise<string>;
21
- /**
22
- * confirmation prompt (yes/no)
23
- * @param message - confirmation text
24
- * @returns Promise<boolean>
25
- */
26
- export declare function confirm(message: string): Promise<boolean>;
27
- /**
28
- * "press anykey to continue"
29
- * @param message - optional message to display to user
30
- * @returns Promise<string>
31
- */
32
- export declare function anykey(message?: string): Promise<string>;
@@ -1,185 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- var __importDefault = (this && this.__importDefault) || function (mod) {
26
- return (mod && mod.__esModule) ? mod : { "default": mod };
27
- };
28
- Object.defineProperty(exports, "__esModule", { value: true });
29
- exports.anykey = exports.confirm = exports.prompt = void 0;
30
- const chalk_1 = __importDefault(require("chalk"));
31
- const Errors = __importStar(require("../errors"));
32
- const config_1 = require("./config");
33
- function normal(options, retries = 100) {
34
- if (retries < 0)
35
- throw new Error('no input');
36
- return new Promise((resolve, reject) => {
37
- let timer;
38
- if (options.timeout) {
39
- timer = setTimeout(() => {
40
- process.stdin.pause();
41
- reject(new Error('Prompt timeout'));
42
- }, options.timeout);
43
- timer.unref();
44
- }
45
- process.stdin.setEncoding('utf8');
46
- process.stderr.write(options.prompt);
47
- process.stdin.resume();
48
- process.stdin.once('data', (b) => {
49
- if (timer)
50
- clearTimeout(timer);
51
- process.stdin.pause();
52
- const data = (typeof b === 'string' ? b : b.toString()).trim();
53
- if (!options.default && options.required && data === '') {
54
- resolve(normal(options, retries - 1));
55
- }
56
- else {
57
- resolve(data || options.default);
58
- }
59
- });
60
- });
61
- }
62
- function getPrompt(name, type, defaultValue) {
63
- let prompt = '> ';
64
- if (defaultValue && type === 'hide') {
65
- defaultValue = '*'.repeat(defaultValue.length);
66
- }
67
- if (name && defaultValue)
68
- prompt = name + ' ' + chalk_1.default.yellow('[' + defaultValue + ']') + ': ';
69
- else if (name)
70
- prompt = `${name}: `;
71
- return prompt;
72
- }
73
- async function single(options) {
74
- const raw = process.stdin.isRaw;
75
- if (process.stdin.setRawMode)
76
- process.stdin.setRawMode(true);
77
- options.required = options.required ?? false;
78
- const response = await normal(options);
79
- if (process.stdin.setRawMode)
80
- process.stdin.setRawMode(Boolean(raw));
81
- return response;
82
- }
83
- function replacePrompt(prompt) {
84
- const ansiEscapes = require('ansi-escapes');
85
- process.stderr.write(ansiEscapes.cursorHide +
86
- ansiEscapes.cursorUp(1) +
87
- ansiEscapes.cursorLeft +
88
- prompt +
89
- ansiEscapes.cursorDown(1) +
90
- ansiEscapes.cursorLeft +
91
- ansiEscapes.cursorShow);
92
- }
93
- async function _prompt(name, inputOptions = {}) {
94
- const prompt = getPrompt(name, inputOptions.type, inputOptions.default);
95
- const options = {
96
- default: '',
97
- isTTY: Boolean(process.env.TERM !== 'dumb' && process.stdin.isTTY),
98
- name,
99
- prompt,
100
- required: true,
101
- type: 'normal',
102
- ...inputOptions,
103
- };
104
- const passwordPrompt = require('password-prompt');
105
- switch (options.type) {
106
- case 'normal': {
107
- return normal(options);
108
- }
109
- case 'single': {
110
- return single(options);
111
- }
112
- case 'mask': {
113
- return passwordPrompt(options.prompt, {
114
- default: options.default,
115
- method: options.type,
116
- required: options.required,
117
- }).then((value) => {
118
- replacePrompt(getPrompt(name, 'hide', inputOptions.default));
119
- return value;
120
- });
121
- }
122
- case 'hide': {
123
- return passwordPrompt(options.prompt, {
124
- default: options.default,
125
- method: options.type,
126
- required: options.required,
127
- });
128
- }
129
- default: {
130
- throw new Error(`unexpected type ${options.type}`);
131
- }
132
- }
133
- }
134
- /**
135
- * prompt for input
136
- * @param name - prompt text
137
- * @param options - @see IPromptOptions
138
- * @returns Promise<string>
139
- */
140
- async function prompt(name, options = {}) {
141
- return config_1.config.action.pauseAsync(() => _prompt(name, options), chalk_1.default.cyan('?'));
142
- }
143
- exports.prompt = prompt;
144
- /**
145
- * confirmation prompt (yes/no)
146
- * @param message - confirmation text
147
- * @returns Promise<boolean>
148
- */
149
- function confirm(message) {
150
- return config_1.config.action.pauseAsync(async () => {
151
- const confirm = async () => {
152
- const raw = await _prompt(message);
153
- const response = raw.toLowerCase();
154
- if (['n', 'no'].includes(response))
155
- return false;
156
- if (['y', 'yes'].includes(response))
157
- return true;
158
- return confirm();
159
- };
160
- return confirm();
161
- }, chalk_1.default.cyan('?'));
162
- }
163
- exports.confirm = confirm;
164
- /**
165
- * "press anykey to continue"
166
- * @param message - optional message to display to user
167
- * @returns Promise<string>
168
- */
169
- async function anykey(message) {
170
- const tty = Boolean(process.stdin.setRawMode);
171
- if (!message) {
172
- message = tty
173
- ? `Press any key to continue or ${chalk_1.default.yellow('q')} to exit`
174
- : `Press enter to continue or ${chalk_1.default.yellow('q')} to exit`;
175
- }
176
- const char = await prompt(message, { required: false, type: 'single' });
177
- if (tty)
178
- process.stderr.write('\n');
179
- if (char === 'q')
180
- Errors.error('quit');
181
- if (char === '\u0003')
182
- Errors.error('ctrl-c');
183
- return char;
184
- }
185
- exports.anykey = anykey;
@@ -1,23 +0,0 @@
1
- /**
2
- * A wrapper around process.stdout and process.stderr that allows us to mock out the streams for testing.
3
- */
4
- declare class Stream {
5
- channel: 'stderr' | 'stdout';
6
- constructor(channel: 'stderr' | 'stdout');
7
- get isTTY(): boolean;
8
- emit(event: string, ...args: any[]): boolean;
9
- getWindowSize(): number[];
10
- on(event: string, listener: (...args: any[]) => void): Stream;
11
- once(event: string, listener: (...args: any[]) => void): Stream;
12
- read(): boolean;
13
- write(data: string): boolean;
14
- }
15
- /**
16
- * @deprecated Use process.stdout directly. This will be removed in the next major version
17
- */
18
- export declare const stdout: Stream;
19
- /**
20
- * @deprecated Use process.stderr directly. This will be removed in the next major version
21
- */
22
- export declare const stderr: Stream;
23
- export {};
@@ -1,43 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.stderr = exports.stdout = void 0;
4
- /**
5
- * A wrapper around process.stdout and process.stderr that allows us to mock out the streams for testing.
6
- */
7
- class Stream {
8
- channel;
9
- constructor(channel) {
10
- this.channel = channel;
11
- }
12
- get isTTY() {
13
- return process[this.channel].isTTY;
14
- }
15
- emit(event, ...args) {
16
- return process[this.channel].emit(event, ...args);
17
- }
18
- getWindowSize() {
19
- return process[this.channel].getWindowSize();
20
- }
21
- on(event, listener) {
22
- process[this.channel].on(event, listener);
23
- return this;
24
- }
25
- once(event, listener) {
26
- process[this.channel].once(event, listener);
27
- return this;
28
- }
29
- read() {
30
- return process[this.channel].read();
31
- }
32
- write(data) {
33
- return process[this.channel].write(data);
34
- }
35
- }
36
- /**
37
- * @deprecated Use process.stdout directly. This will be removed in the next major version
38
- */
39
- exports.stdout = new Stream('stdout');
40
- /**
41
- * @deprecated Use process.stderr directly. This will be removed in the next major version
42
- */
43
- exports.stderr = new Stream('stderr');
@@ -1,4 +0,0 @@
1
- export { default as styledObject } from './object';
2
- export { default as progress } from './progress';
3
- export * as Table from './table';
4
- export { default as tree } from './tree';
@@ -1,36 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- var __importDefault = (this && this.__importDefault) || function (mod) {
26
- return (mod && mod.__esModule) ? mod : { "default": mod };
27
- };
28
- Object.defineProperty(exports, "__esModule", { value: true });
29
- exports.tree = exports.Table = exports.progress = exports.styledObject = void 0;
30
- var object_1 = require("./object");
31
- Object.defineProperty(exports, "styledObject", { enumerable: true, get: function () { return __importDefault(object_1).default; } });
32
- var progress_1 = require("./progress");
33
- Object.defineProperty(exports, "progress", { enumerable: true, get: function () { return __importDefault(progress_1).default; } });
34
- exports.Table = __importStar(require("./table"));
35
- var tree_1 = require("./tree");
36
- Object.defineProperty(exports, "tree", { enumerable: true, get: function () { return __importDefault(tree_1).default; } });
@@ -1 +0,0 @@
1
- export default function styledObject(obj: any, keys?: string[]): string;
@@ -1,39 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const chalk_1 = __importDefault(require("chalk"));
7
- const node_util_1 = require("node:util");
8
- function styledObject(obj, keys) {
9
- const output = [];
10
- const keyLengths = Object.keys(obj).map((key) => key.toString().length);
11
- const maxKeyLength = Math.max(...keyLengths) + 2;
12
- function pp(obj) {
13
- if (typeof obj === 'string' || typeof obj === 'number')
14
- return obj;
15
- if (typeof obj === 'object') {
16
- return Object.keys(obj)
17
- .map((k) => k + ': ' + (0, node_util_1.inspect)(obj[k]))
18
- .join(', ');
19
- }
20
- return (0, node_util_1.inspect)(obj);
21
- }
22
- const logKeyValue = (key, value) => `${chalk_1.default.blue(key)}:` + ' '.repeat(maxKeyLength - key.length - 1) + pp(value);
23
- for (const key of keys || Object.keys(obj).sort()) {
24
- const value = obj[key];
25
- if (Array.isArray(value)) {
26
- if (value.length > 0) {
27
- output.push(logKeyValue(key, value[0]));
28
- for (const e of value.slice(1)) {
29
- output.push(' '.repeat(maxKeyLength) + pp(e));
30
- }
31
- }
32
- }
33
- else if (value !== null && value !== undefined) {
34
- output.push(logKeyValue(key, value));
35
- }
36
- }
37
- return output.join('\n');
38
- }
39
- exports.default = styledObject;
@@ -1,2 +0,0 @@
1
- import { Options, SingleBar } from 'cli-progress';
2
- export default function progress(options?: Options): SingleBar;
@@ -1,8 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- // 3pp
4
- const cli_progress_1 = require("cli-progress");
5
- function progress(options = {}) {
6
- return new cli_progress_1.SingleBar({ noTTYOutput: Boolean(process.env.TERM === 'dumb' || !process.stdin.isTTY), ...options });
7
- }
8
- exports.default = progress;
@@ -1,45 +0,0 @@
1
- import * as Interfaces from '../../interfaces';
2
- export declare function table<T extends Record<string, unknown>>(data: T[], columns: table.Columns<T>, options?: table.Options): void;
3
- export declare namespace table {
4
- export const Flags: {
5
- columns: Interfaces.OptionFlag<string | undefined>;
6
- csv: Interfaces.BooleanFlag<boolean>;
7
- extended: Interfaces.BooleanFlag<boolean>;
8
- filter: Interfaces.OptionFlag<string | undefined>;
9
- 'no-header': Interfaces.BooleanFlag<boolean>;
10
- 'no-truncate': Interfaces.BooleanFlag<boolean>;
11
- output: Interfaces.OptionFlag<string | undefined>;
12
- sort: Interfaces.OptionFlag<string | undefined>;
13
- };
14
- type IFlags = typeof Flags;
15
- type ExcludeFlags<T, Z> = Pick<T, Exclude<keyof T, Z>>;
16
- type IncludeFlags<T, K extends keyof T> = Pick<T, K>;
17
- export function flags(): IFlags;
18
- export function flags<Z extends keyof IFlags = keyof IFlags>(opts: {
19
- except: Z | Z[];
20
- }): ExcludeFlags<IFlags, Z>;
21
- export function flags<K extends keyof IFlags = keyof IFlags>(opts: {
22
- only: K | K[];
23
- }): IncludeFlags<IFlags, K>;
24
- export interface Column<T extends Record<string, unknown>> {
25
- extended: boolean;
26
- get(row: T): any;
27
- header: string;
28
- minWidth: number;
29
- }
30
- export type Columns<T extends Record<string, unknown>> = {
31
- [key: string]: Partial<Column<T>>;
32
- };
33
- export interface Options {
34
- [key: string]: any;
35
- columns?: string;
36
- extended?: boolean;
37
- filter?: string;
38
- 'no-header'?: boolean;
39
- 'no-truncate'?: boolean;
40
- output?: string;
41
- printLine?(s: any): any;
42
- sort?: string;
43
- }
44
- export {};
45
- }