@oclif/core 3.0.0-beta.2 → 3.0.0-beta.21

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 (112) hide show
  1. package/README.md +10 -6
  2. package/flush.js +1 -1
  3. package/handle.js +1 -1
  4. package/lib/args.d.ts +1 -1
  5. package/lib/args.js +17 -18
  6. package/lib/cli-ux/action/base.d.ts +3 -5
  7. package/lib/cli-ux/action/base.js +32 -26
  8. package/lib/cli-ux/action/simple.js +13 -18
  9. package/lib/cli-ux/action/spinner.d.ts +4 -2
  10. package/lib/cli-ux/action/spinner.js +27 -19
  11. package/lib/cli-ux/action/spinners.js +1 -1
  12. package/lib/cli-ux/action/types.d.ts +5 -0
  13. package/lib/cli-ux/action/types.js +2 -0
  14. package/lib/cli-ux/config.d.ts +0 -1
  15. package/lib/cli-ux/config.js +17 -21
  16. package/lib/cli-ux/exit.d.ts +1 -1
  17. package/lib/cli-ux/exit.js +4 -1
  18. package/lib/cli-ux/flush.d.ts +1 -0
  19. package/lib/cli-ux/flush.js +28 -0
  20. package/lib/cli-ux/index.d.ts +10 -30
  21. package/lib/cli-ux/index.js +32 -75
  22. package/lib/cli-ux/list.js +3 -3
  23. package/lib/cli-ux/prompt.js +32 -22
  24. package/lib/cli-ux/stream.js +1 -0
  25. package/lib/cli-ux/styled/index.d.ts +5 -6
  26. package/lib/cli-ux/styled/index.js +11 -11
  27. package/lib/cli-ux/styled/json.js +8 -5
  28. package/lib/cli-ux/styled/object.js +7 -9
  29. package/lib/cli-ux/styled/table.d.ts +4 -4
  30. package/lib/cli-ux/styled/table.js +61 -64
  31. package/lib/cli-ux/styled/tree.js +1 -3
  32. package/lib/cli-ux/wait.js +3 -5
  33. package/lib/command.d.ts +15 -19
  34. package/lib/command.js +117 -96
  35. package/lib/config/config.d.ts +16 -23
  36. package/lib/config/config.js +180 -334
  37. package/lib/config/index.d.ts +1 -1
  38. package/lib/config/index.js +1 -2
  39. package/lib/config/plugin-loader.d.ts +30 -0
  40. package/lib/config/plugin-loader.js +145 -0
  41. package/lib/config/plugin.d.ts +6 -11
  42. package/lib/config/plugin.js +112 -78
  43. package/lib/config/ts-node.d.ts +2 -1
  44. package/lib/config/ts-node.js +64 -51
  45. package/lib/config/util.d.ts +1 -11
  46. package/lib/config/util.js +6 -59
  47. package/lib/errors/config.js +1 -1
  48. package/lib/errors/errors/cli.d.ts +1 -1
  49. package/lib/errors/errors/cli.js +18 -14
  50. package/lib/errors/errors/exit.d.ts +0 -3
  51. package/lib/errors/errors/exit.js +1 -1
  52. package/lib/errors/errors/module-load.d.ts +0 -3
  53. package/lib/errors/errors/module-load.js +1 -1
  54. package/lib/errors/errors/pretty-print.js +11 -9
  55. package/lib/errors/handle.d.ts +12 -2
  56. package/lib/errors/handle.js +28 -18
  57. package/lib/errors/index.d.ts +2 -2
  58. package/lib/errors/index.js +20 -19
  59. package/lib/errors/logger.js +9 -8
  60. package/lib/execute.d.ts +49 -0
  61. package/lib/execute.js +63 -0
  62. package/lib/flags.d.ts +102 -31
  63. package/lib/flags.js +81 -46
  64. package/lib/help/command.d.ts +2 -0
  65. package/lib/help/command.js +68 -53
  66. package/lib/help/docopts.js +9 -13
  67. package/lib/help/formatter.d.ts +1 -1
  68. package/lib/help/formatter.js +35 -24
  69. package/lib/help/index.d.ts +7 -3
  70. package/lib/help/index.js +77 -55
  71. package/lib/help/root.js +7 -9
  72. package/lib/help/util.d.ts +1 -7
  73. package/lib/help/util.js +8 -28
  74. package/lib/index.d.ts +19 -18
  75. package/lib/index.js +36 -48
  76. package/lib/interfaces/config.d.ts +30 -30
  77. package/lib/interfaces/errors.d.ts +1 -1
  78. package/lib/interfaces/hooks.d.ts +3 -3
  79. package/lib/interfaces/index.d.ts +14 -14
  80. package/lib/interfaces/parser.d.ts +188 -116
  81. package/lib/interfaces/pjson.d.ts +2 -1
  82. package/lib/interfaces/plugin.d.ts +10 -1
  83. package/lib/main.d.ts +0 -48
  84. package/lib/main.js +11 -66
  85. package/lib/module-loader.d.ts +68 -79
  86. package/lib/module-loader.js +183 -150
  87. package/lib/parser/errors.d.ts +3 -3
  88. package/lib/parser/errors.js +17 -10
  89. package/lib/parser/help.js +5 -5
  90. package/lib/parser/parse.d.ts +3 -0
  91. package/lib/parser/parse.js +114 -115
  92. package/lib/parser/validate.js +45 -25
  93. package/lib/performance.d.ts +5 -1
  94. package/lib/performance.js +40 -19
  95. package/lib/util/aggregate-flags.d.ts +2 -0
  96. package/lib/util/aggregate-flags.js +13 -0
  97. package/lib/util/cache-command.d.ts +3 -0
  98. package/lib/util/cache-command.js +109 -0
  99. package/lib/util/cache-default-value.d.ts +2 -0
  100. package/lib/util/cache-default-value.js +28 -0
  101. package/lib/util/ensure-arg-object.d.ts +12 -0
  102. package/lib/util/ensure-arg-object.js +14 -0
  103. package/lib/util/fs.d.ts +7 -0
  104. package/lib/util/fs.js +54 -0
  105. package/lib/util/os.d.ts +19 -0
  106. package/lib/util/os.js +28 -0
  107. package/lib/{util.d.ts → util/util.d.ts} +6 -15
  108. package/lib/util/util.js +98 -0
  109. package/package.json +32 -34
  110. package/lib/cli-ux/action/pride-spinner.d.ts +0 -4
  111. package/lib/cli-ux/action/pride-spinner.js +0 -30
  112. package/lib/util.js +0 -126
@@ -1,44 +1,19 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.warn = exports.wait = exports.url = exports.tree = exports.trace = exports.Table = exports.table = exports.styledObject = exports.styledJSON = exports.styledHeader = exports.prompt = exports.progress = exports.prideAction = exports.log = exports.info = exports.flush = exports.ExitError = exports.exit = exports.error = exports.done = exports.debug = exports.confirm = exports.Config = exports.config = exports.anykey = exports.annotation = exports.ActionBase = exports.action = exports.ux = void 0;
4
- const Errors = require("../errors");
5
- const util = require("util");
6
- const chalk = require("chalk");
7
- const base_1 = require("./action/base");
8
- Object.defineProperty(exports, "ActionBase", { enumerable: true, get: function () { return base_1.ActionBase; } });
3
+ exports.Config = exports.config = exports.ActionBase = exports.Table = exports.ExitError = exports.warn = exports.wait = exports.url = exports.tree = exports.trace = exports.table = exports.styledObject = exports.styledJSON = exports.styledHeader = exports.prompt = exports.progress = 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;
4
+ const tslib_1 = require("tslib");
5
+ const Errors = tslib_1.__importStar(require("../errors"));
6
+ const styled = tslib_1.__importStar(require("./styled"));
7
+ const uxPrompt = tslib_1.__importStar(require("./prompt"));
9
8
  const config_1 = require("./config");
10
- Object.defineProperty(exports, "config", { enumerable: true, get: function () { return config_1.config; } });
11
- Object.defineProperty(exports, "Config", { enumerable: true, get: function () { return config_1.Config; } });
12
- const exit_1 = require("./exit");
13
- Object.defineProperty(exports, "ExitError", { enumerable: true, get: function () { return exit_1.ExitError; } });
14
- const styled = require("./styled");
15
- const styled_1 = require("./styled");
16
- Object.defineProperty(exports, "Table", { enumerable: true, get: function () { return styled_1.Table; } });
17
- const uxPrompt = require("./prompt");
18
- const wait_1 = require("./wait");
9
+ const flush_1 = require("./flush");
10
+ const chalk_1 = tslib_1.__importDefault(require("chalk"));
19
11
  const stream_1 = require("./stream");
12
+ const node_util_1 = require("node:util");
13
+ const wait_1 = tslib_1.__importDefault(require("./wait"));
20
14
  const hyperlinker = require('hyperlinker');
21
- function timeout(p, ms) {
22
- function wait(ms, unref = false) {
23
- return new Promise(resolve => {
24
- const t = setTimeout(() => resolve(null), ms);
25
- if (unref)
26
- t.unref();
27
- });
28
- }
29
- return Promise.race([p, wait(ms, true).then(() => Errors.error('timed out'))]);
30
- }
31
- async function _flush() {
32
- const p = new Promise(resolve => {
33
- stream_1.stdout.once('drain', () => resolve(null));
34
- });
35
- const flushed = stream_1.stdout.write('');
36
- if (flushed) {
37
- return Promise.resolve();
38
- }
39
- return p;
40
- }
41
15
  class ux {
16
+ static config = config_1.config;
42
17
  static get prompt() {
43
18
  return uxPrompt.prompt;
44
19
  }
@@ -54,15 +29,11 @@ class ux {
54
29
  static get action() {
55
30
  return config_1.config.action;
56
31
  }
57
- static get prideAction() {
58
- return config_1.config.prideAction;
59
- }
60
- // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
61
32
  static styledObject(obj, keys) {
62
33
  this.info(styled.styledObject(obj, keys));
63
34
  }
64
35
  static styledHeader(header) {
65
- this.info(chalk.dim('=== ') + chalk.bold(header) + '\n');
36
+ this.info(chalk_1.default.dim('=== ') + chalk_1.default.bold(header) + '\n');
66
37
  }
67
38
  static get styledJSON() {
68
39
  return styled.styledJSON;
@@ -84,16 +55,16 @@ class ux {
84
55
  }
85
56
  static trace(format, ...args) {
86
57
  if (this.config.outputLevel === 'trace') {
87
- stream_1.stdout.write(util.format(format, ...args) + '\n');
58
+ stream_1.stdout.write((0, node_util_1.format)(format, ...args) + '\n');
88
59
  }
89
60
  }
90
61
  static debug(format, ...args) {
91
62
  if (['trace', 'debug'].includes(this.config.outputLevel)) {
92
- stream_1.stdout.write(util.format(format, ...args) + '\n');
63
+ stream_1.stdout.write((0, node_util_1.format)(format, ...args) + '\n');
93
64
  }
94
65
  }
95
66
  static info(format, ...args) {
96
- stream_1.stdout.write(util.format(format, ...args) + '\n');
67
+ stream_1.stdout.write((0, node_util_1.format)(format, ...args) + '\n');
97
68
  }
98
69
  static log(format, ...args) {
99
70
  this.info(format || '', ...args);
@@ -118,58 +89,35 @@ class ux {
118
89
  }
119
90
  }
120
91
  static async flush(ms = 10000) {
121
- await timeout(_flush(), ms);
92
+ await (0, flush_1.flush)(ms);
122
93
  }
123
94
  }
124
95
  exports.ux = ux;
125
- ux.config = config_1.config;
126
- const action = ux.action;
96
+ const { action, annotation, anykey, confirm, debug, done, flush, info, log, progress, prompt, styledHeader, styledJSON, styledObject, table, trace, tree, url, wait, } = ux;
127
97
  exports.action = action;
128
- const annotation = ux.annotation;
129
98
  exports.annotation = annotation;
130
- const anykey = ux.anykey;
131
99
  exports.anykey = anykey;
132
- const confirm = ux.confirm;
133
100
  exports.confirm = confirm;
134
- const debug = ux.debug;
135
101
  exports.debug = debug;
136
- const done = ux.done;
137
102
  exports.done = done;
138
- const error = Errors.error;
139
- exports.error = error;
140
- const exit = Errors.exit;
141
- exports.exit = exit;
142
- const flush = ux.flush;
143
103
  exports.flush = flush;
144
- const info = ux.info;
145
104
  exports.info = info;
146
- const log = ux.log;
147
105
  exports.log = log;
148
- const prideAction = ux.prideAction;
149
- exports.prideAction = prideAction;
150
- const progress = ux.progress;
151
106
  exports.progress = progress;
152
- const prompt = ux.prompt;
153
107
  exports.prompt = prompt;
154
- const styledHeader = ux.styledHeader;
155
108
  exports.styledHeader = styledHeader;
156
- const styledJSON = ux.styledJSON;
157
109
  exports.styledJSON = styledJSON;
158
- const styledObject = ux.styledObject;
159
110
  exports.styledObject = styledObject;
160
- const table = ux.table;
161
111
  exports.table = table;
162
- const trace = ux.trace;
163
112
  exports.trace = trace;
164
- const tree = ux.tree;
165
113
  exports.tree = tree;
166
- const url = ux.url;
167
114
  exports.url = url;
168
- const wait = ux.wait;
169
115
  exports.wait = wait;
170
- const warn = Errors.warn;
116
+ const { error, exit, warn } = Errors;
117
+ exports.error = error;
118
+ exports.exit = exit;
171
119
  exports.warn = warn;
172
- const cliuxProcessExitHandler = async () => {
120
+ const uxProcessExitHandler = async () => {
173
121
  try {
174
122
  await ux.done();
175
123
  }
@@ -180,7 +128,16 @@ const cliuxProcessExitHandler = async () => {
180
128
  };
181
129
  // to avoid MaxListenersExceededWarning
182
130
  // only attach named listener once
183
- const cliuxListener = process.listeners('exit').find(fn => fn.name === cliuxProcessExitHandler.name);
184
- if (!cliuxListener) {
185
- process.once('exit', cliuxProcessExitHandler);
131
+ const uxListener = process.listeners('exit').find((fn) => fn.name === uxProcessExitHandler.name);
132
+ if (!uxListener) {
133
+ process.once('exit', uxProcessExitHandler);
186
134
  }
135
+ var exit_1 = require("./exit");
136
+ Object.defineProperty(exports, "ExitError", { enumerable: true, get: function () { return exit_1.ExitError; } });
137
+ var styled_1 = require("./styled");
138
+ Object.defineProperty(exports, "Table", { enumerable: true, get: function () { return styled_1.Table; } });
139
+ var base_1 = require("./action/base");
140
+ Object.defineProperty(exports, "ActionBase", { enumerable: true, get: function () { return base_1.ActionBase; } });
141
+ var config_2 = require("./config");
142
+ Object.defineProperty(exports, "config", { enumerable: true, get: function () { return config_2.config; } });
143
+ Object.defineProperty(exports, "Config", { enumerable: true, get: function () { return config_2.Config; } });
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.renderList = void 0;
4
+ const util_1 = require("../util/util");
4
5
  const screen_1 = require("../screen");
5
- const util_1 = require("../util");
6
6
  const wordwrap = require('wordwrap');
7
7
  function linewrap(length, s) {
8
8
  return wordwrap(length, screen_1.stdtermwidth, {
@@ -13,8 +13,8 @@ function renderList(items) {
13
13
  if (items.length === 0) {
14
14
  return '';
15
15
  }
16
- const maxLength = (0, util_1.maxBy)(items, item => item[0].length)?.[0].length ?? 0;
17
- const lines = items.map(i => {
16
+ const maxLength = (0, util_1.maxBy)(items, (item) => item[0].length)?.[0].length ?? 0;
17
+ const lines = items.map((i) => {
18
18
  let left = i[0];
19
19
  let right = i[1];
20
20
  if (!right) {
@@ -1,12 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.anykey = exports.confirm = exports.prompt = void 0;
4
- const Errors = require("../errors");
4
+ const tslib_1 = require("tslib");
5
+ const Errors = tslib_1.__importStar(require("../errors"));
6
+ const chalk_1 = tslib_1.__importDefault(require("chalk"));
5
7
  const config_1 = require("./config");
6
- const chalk = require("chalk");
7
8
  const stream_1 = require("./stream");
8
- const ansiEscapes = require('ansi-escapes');
9
- const passwordPrompt = require('password-prompt');
10
9
  function normal(options, retries = 100) {
11
10
  if (retries < 0)
12
11
  throw new Error('no input');
@@ -22,7 +21,7 @@ function normal(options, retries = 100) {
22
21
  process.stdin.setEncoding('utf8');
23
22
  stream_1.stderr.write(options.prompt);
24
23
  process.stdin.resume();
25
- process.stdin.once('data', b => {
24
+ process.stdin.once('data', (b) => {
26
25
  if (timer)
27
26
  clearTimeout(timer);
28
27
  process.stdin.pause();
@@ -42,7 +41,7 @@ function getPrompt(name, type, defaultValue) {
42
41
  defaultValue = '*'.repeat(defaultValue.length);
43
42
  }
44
43
  if (name && defaultValue)
45
- prompt = name + ' ' + chalk.yellow('[' + defaultValue + ']') + ': ';
44
+ prompt = name + ' ' + chalk_1.default.yellow('[' + defaultValue + ']') + ': ';
46
45
  else if (name)
47
46
  prompt = `${name}: `;
48
47
  return prompt;
@@ -58,8 +57,14 @@ async function single(options) {
58
57
  return response;
59
58
  }
60
59
  function replacePrompt(prompt) {
61
- stream_1.stderr.write(ansiEscapes.cursorHide + ansiEscapes.cursorUp(1) + ansiEscapes.cursorLeft + prompt +
62
- ansiEscapes.cursorDown(1) + ansiEscapes.cursorLeft + ansiEscapes.cursorShow);
60
+ const ansiEscapes = require('ansi-escapes');
61
+ stream_1.stderr.write(ansiEscapes.cursorHide +
62
+ ansiEscapes.cursorUp(1) +
63
+ ansiEscapes.cursorLeft +
64
+ prompt +
65
+ ansiEscapes.cursorDown(1) +
66
+ ansiEscapes.cursorLeft +
67
+ ansiEscapes.cursorShow);
63
68
  }
64
69
  async function _prompt(name, inputOptions = {}) {
65
70
  const prompt = getPrompt(name, inputOptions.type, inputOptions.default);
@@ -72,12 +77,15 @@ async function _prompt(name, inputOptions = {}) {
72
77
  default: '',
73
78
  ...inputOptions,
74
79
  };
80
+ const passwordPrompt = require('password-prompt');
75
81
  switch (options.type) {
76
- case 'normal':
82
+ case 'normal': {
77
83
  return normal(options);
78
- case 'single':
84
+ }
85
+ case 'single': {
79
86
  return single(options);
80
- case 'mask':
87
+ }
88
+ case 'mask': {
81
89
  return passwordPrompt(options.prompt, {
82
90
  method: options.type,
83
91
  required: options.required,
@@ -86,14 +94,17 @@ async function _prompt(name, inputOptions = {}) {
86
94
  replacePrompt(getPrompt(name, 'hide', inputOptions.default));
87
95
  return value;
88
96
  });
89
- case 'hide':
97
+ }
98
+ case 'hide': {
90
99
  return passwordPrompt(options.prompt, {
91
100
  method: options.type,
92
101
  required: options.required,
93
102
  default: options.default,
94
103
  });
95
- default:
104
+ }
105
+ default: {
96
106
  throw new Error(`unexpected type ${options.type}`);
107
+ }
97
108
  }
98
109
  }
99
110
  /**
@@ -103,9 +114,7 @@ async function _prompt(name, inputOptions = {}) {
103
114
  * @returns Promise<string>
104
115
  */
105
116
  async function prompt(name, options = {}) {
106
- return config_1.default.action.pauseAsync(() => {
107
- return _prompt(name, options);
108
- }, chalk.cyan('?'));
117
+ return config_1.config.action.pauseAsync(() => _prompt(name, options), chalk_1.default.cyan('?'));
109
118
  }
110
119
  exports.prompt = prompt;
111
120
  /**
@@ -114,9 +123,10 @@ exports.prompt = prompt;
114
123
  * @returns Promise<boolean>
115
124
  */
116
125
  function confirm(message) {
117
- return config_1.default.action.pauseAsync(async () => {
126
+ return config_1.config.action.pauseAsync(async () => {
118
127
  const confirm = async () => {
119
- const response = (await _prompt(message)).toLowerCase();
128
+ const raw = await _prompt(message);
129
+ const response = raw.toLowerCase();
120
130
  if (['n', 'no'].includes(response))
121
131
  return false;
122
132
  if (['y', 'yes'].includes(response))
@@ -124,7 +134,7 @@ function confirm(message) {
124
134
  return confirm();
125
135
  };
126
136
  return confirm();
127
- }, chalk.cyan('?'));
137
+ }, chalk_1.default.cyan('?'));
128
138
  }
129
139
  exports.confirm = confirm;
130
140
  /**
@@ -135,9 +145,9 @@ exports.confirm = confirm;
135
145
  async function anykey(message) {
136
146
  const tty = Boolean(process.stdin.setRawMode);
137
147
  if (!message) {
138
- message = tty ?
139
- `Press any key to continue or ${chalk.yellow('q')} to exit` :
140
- `Press enter to continue or ${chalk.yellow('q')} to exit`;
148
+ message = tty
149
+ ? `Press any key to continue or ${chalk_1.default.yellow('q')} to exit`
150
+ : `Press enter to continue or ${chalk_1.default.yellow('q')} to exit`;
141
151
  }
142
152
  const char = await prompt(message, { type: 'single', required: false });
143
153
  if (tty)
@@ -5,6 +5,7 @@ exports.stderr = exports.stdout = void 0;
5
5
  * A wrapper around process.stdout and process.stderr that allows us to mock out the streams for testing.
6
6
  */
7
7
  class Stream {
8
+ channel;
8
9
  constructor(channel) {
9
10
  this.channel = channel;
10
11
  }
@@ -1,6 +1,5 @@
1
- import styledJSON from './json';
2
- import styledObject from './object';
3
- import * as Table from './table';
4
- import tree from './tree';
5
- import progress from './progress';
6
- export { styledJSON, styledObject, Table, tree, progress, };
1
+ export * as Table from './table';
2
+ export { default as progress } from './progress';
3
+ export { default as styledJSON } from './json';
4
+ export { default as styledObject } from './object';
5
+ export { default as tree } from './tree';
@@ -1,13 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.progress = exports.tree = exports.Table = exports.styledObject = exports.styledJSON = void 0;
4
- const json_1 = require("./json");
5
- exports.styledJSON = json_1.default;
6
- const object_1 = require("./object");
7
- exports.styledObject = object_1.default;
8
- const Table = require("./table");
9
- exports.Table = Table;
10
- const tree_1 = require("./tree");
11
- exports.tree = tree_1.default;
12
- const progress_1 = require("./progress");
13
- exports.progress = progress_1.default;
3
+ exports.tree = exports.styledObject = exports.styledJSON = exports.progress = exports.Table = void 0;
4
+ const tslib_1 = require("tslib");
5
+ exports.Table = tslib_1.__importStar(require("./table"));
6
+ var progress_1 = require("./progress");
7
+ Object.defineProperty(exports, "progress", { enumerable: true, get: function () { return tslib_1.__importDefault(progress_1).default; } });
8
+ var json_1 = require("./json");
9
+ Object.defineProperty(exports, "styledJSON", { enumerable: true, get: function () { return tslib_1.__importDefault(json_1).default; } });
10
+ var object_1 = require("./object");
11
+ Object.defineProperty(exports, "styledObject", { enumerable: true, get: function () { return tslib_1.__importDefault(object_1).default; } });
12
+ var tree_1 = require("./tree");
13
+ Object.defineProperty(exports, "tree", { enumerable: true, get: function () { return tslib_1.__importDefault(tree_1).default; } });
@@ -1,15 +1,18 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const chalk = require("chalk");
4
- const index_1 = require("../../index");
3
+ const tslib_1 = require("tslib");
4
+ const chalk_1 = tslib_1.__importDefault(require("chalk"));
5
+ const node_util_1 = require("node:util");
6
+ const stream_1 = require("../stream");
7
+ const info = (output) => stream_1.stdout.write((0, node_util_1.format)(output) + '\n');
5
8
  function styledJSON(obj) {
6
9
  const json = JSON.stringify(obj, null, 2);
7
- if (!chalk.level) {
8
- index_1.ux.info(json);
10
+ if (!chalk_1.default.level) {
11
+ info(json);
9
12
  return;
10
13
  }
11
14
  const cardinal = require('cardinal');
12
15
  const theme = require('cardinal/themes/jq');
13
- index_1.ux.info(cardinal.highlight(json, { json: true, theme }));
16
+ info(cardinal.highlight(json, { json: true, theme }));
14
17
  }
15
18
  exports.default = styledJSON;
@@ -1,25 +1,23 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const chalk = require("chalk");
4
- const util = require("util");
5
- // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
3
+ const tslib_1 = require("tslib");
4
+ const chalk_1 = tslib_1.__importDefault(require("chalk"));
5
+ const node_util_1 = require("node:util");
6
6
  function styledObject(obj, keys) {
7
7
  const output = [];
8
- const keyLengths = Object.keys(obj).map(key => key.toString().length);
8
+ const keyLengths = Object.keys(obj).map((key) => key.toString().length);
9
9
  const maxKeyLength = Math.max(...keyLengths) + 2;
10
10
  function pp(obj) {
11
11
  if (typeof obj === 'string' || typeof obj === 'number')
12
12
  return obj;
13
13
  if (typeof obj === 'object') {
14
14
  return Object.keys(obj)
15
- .map(k => k + ': ' + util.inspect(obj[k]))
15
+ .map((k) => k + ': ' + (0, node_util_1.inspect)(obj[k]))
16
16
  .join(', ');
17
17
  }
18
- return util.inspect(obj);
18
+ return (0, node_util_1.inspect)(obj);
19
19
  }
20
- const logKeyValue = (key, value) => {
21
- return `${chalk.blue(key)}:` + ' '.repeat(maxKeyLength - key.length - 1) + pp(value);
22
- };
20
+ const logKeyValue = (key, value) => `${chalk_1.default.blue(key)}:` + ' '.repeat(maxKeyLength - key.length - 1) + pp(value);
23
21
  for (const key of keys || Object.keys(obj).sort()) {
24
22
  const value = obj[key];
25
23
  if (Array.isArray(value)) {
@@ -5,11 +5,11 @@ export declare namespace table {
5
5
  columns: Interfaces.OptionFlag<string | undefined>;
6
6
  sort: Interfaces.OptionFlag<string | undefined>;
7
7
  filter: Interfaces.OptionFlag<string | undefined>;
8
- csv: Interfaces.Flag<boolean>;
8
+ csv: Interfaces.BooleanFlag<boolean>;
9
9
  output: Interfaces.OptionFlag<string | undefined>;
10
- extended: Interfaces.Flag<boolean>;
11
- 'no-truncate': Interfaces.Flag<boolean>;
12
- 'no-header': Interfaces.Flag<boolean>;
10
+ extended: Interfaces.BooleanFlag<boolean>;
11
+ 'no-truncate': Interfaces.BooleanFlag<boolean>;
12
+ 'no-header': Interfaces.BooleanFlag<boolean>;
13
13
  };
14
14
  type IFlags = typeof Flags;
15
15
  type ExcludeFlags<T, Z> = Pick<T, Exclude<keyof T, Z>>;