@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
@@ -22,13 +22,10 @@ var __importStar = (this && this.__importStar) || function (mod) {
22
22
  __setModuleDefault(result, mod);
23
23
  return result;
24
24
  };
25
- var __importDefault = (this && this.__importDefault) || function (mod) {
26
- return (mod && mod.__esModule) ? mod : { "default": mod };
27
- };
28
25
  Object.defineProperty(exports, "__esModule", { value: true });
29
26
  exports.error = void 0;
30
- const write_1 = __importDefault(require("../cli-ux/write"));
31
- const config_1 = require("./config");
27
+ const logger_1 = require("../logger");
28
+ const write_1 = require("../ux/write");
32
29
  const cli_1 = require("./errors/cli");
33
30
  const pretty_print_1 = __importStar(require("./errors/pretty-print"));
34
31
  function error(input, options = {}) {
@@ -46,9 +43,9 @@ function error(input, options = {}) {
46
43
  if (options.exit === false) {
47
44
  const message = (0, pretty_print_1.default)(err);
48
45
  if (message)
49
- write_1.default.stderr(message + '\n');
50
- if (config_1.config.errorLogger)
51
- config_1.config.errorLogger.log(err?.stack ?? '');
46
+ (0, write_1.stderr)(message);
47
+ if (err?.stack)
48
+ (0, logger_1.getLogger)().error(err.stack);
52
49
  }
53
50
  else
54
51
  throw err;
@@ -3,15 +3,15 @@ import { OclifError, PrettyPrintableError } from '../../interfaces/errors';
3
3
  * properties specific to internal oclif error handling
4
4
  */
5
5
  export declare function addOclifExitCode(error: Record<string, any>, options?: {
6
- exit?: false | number;
6
+ exit?: false | number | undefined;
7
7
  }): OclifError;
8
8
  export declare class CLIError extends Error implements OclifError {
9
- code?: string;
9
+ code?: string | undefined;
10
10
  oclif: OclifError['oclif'];
11
- skipOclifErrorHandling?: boolean;
12
- suggestions?: string[];
11
+ skipOclifErrorHandling?: boolean | undefined;
12
+ suggestions?: string[] | undefined;
13
13
  constructor(error: Error | string, options?: {
14
- exit?: false | number;
14
+ exit?: false | number | undefined;
15
15
  } & PrettyPrintableError);
16
16
  get bang(): string | undefined;
17
17
  get stack(): string;
@@ -4,13 +4,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.CLIError = exports.addOclifExitCode = void 0;
7
- const chalk_1 = __importDefault(require("chalk"));
7
+ const ansis_1 = __importDefault(require("ansis"));
8
8
  const clean_stack_1 = __importDefault(require("clean-stack"));
9
9
  const indent_string_1 = __importDefault(require("indent-string"));
10
10
  const wrap_ansi_1 = __importDefault(require("wrap-ansi"));
11
11
  const cache_1 = __importDefault(require("../../cache"));
12
12
  const screen_1 = require("../../screen");
13
- const config_1 = require("../config");
13
+ const settings_1 = require("../../settings");
14
14
  /**
15
15
  * properties specific to internal oclif error handling
16
16
  */
@@ -36,7 +36,7 @@ class CLIError extends Error {
36
36
  }
37
37
  get bang() {
38
38
  try {
39
- return chalk_1.default.red(process.platform === 'win32' ? '»' : '›');
39
+ return ansis_1.default.red(process.platform === 'win32' ? '»' : '›');
40
40
  }
41
41
  catch { }
42
42
  }
@@ -48,7 +48,7 @@ class CLIError extends Error {
48
48
  * @return {string} returns a string representing the dispay of the error
49
49
  */
50
50
  render() {
51
- if (config_1.config.debug) {
51
+ if (settings_1.settings.debug) {
52
52
  return this.stack;
53
53
  }
54
54
  let output = `${this.name}: ${this.message}`;
@@ -68,7 +68,7 @@ exports.CLIError = CLIError;
68
68
  }
69
69
  get bang() {
70
70
  try {
71
- return chalk_1.default.yellow(process.platform === 'win32' ? '»' : '›');
71
+ return ansis_1.default.yellow(process.platform === 'win32' ? '»' : '›');
72
72
  }
73
73
  catch { }
74
74
  }
@@ -1,7 +1,7 @@
1
1
  import { PrettyPrintableError } from '../../interfaces/errors';
2
2
  type CLIErrorDisplayOptions = {
3
- bang?: string;
4
- name?: string;
3
+ bang?: string | undefined;
4
+ name?: string | undefined;
5
5
  };
6
6
  export declare function applyPrettyPrintOptions(error: Error, options: PrettyPrintableError): PrettyPrintableError;
7
7
  export default function prettyPrint(error: Error & PrettyPrintableError & CLIErrorDisplayOptions): string | undefined;
@@ -7,7 +7,7 @@ exports.applyPrettyPrintOptions = void 0;
7
7
  const indent_string_1 = __importDefault(require("indent-string"));
8
8
  const wrap_ansi_1 = __importDefault(require("wrap-ansi"));
9
9
  const screen_1 = require("../../screen");
10
- const config_1 = require("../config");
10
+ const settings_1 = require("../../settings");
11
11
  function applyPrettyPrintOptions(error, options) {
12
12
  const prettyErrorKeys = ['message', 'code', 'ref', 'suggestions'];
13
13
  for (const key of prettyErrorKeys) {
@@ -30,7 +30,7 @@ const formatSuggestions = (suggestions) => {
30
30
  return `${label}\n${(0, indent_string_1.default)(multiple, 2)}`;
31
31
  };
32
32
  function prettyPrint(error) {
33
- if (config_1.config.debug) {
33
+ if (settings_1.settings.debug) {
34
34
  return error.stack;
35
35
  }
36
36
  const { bang, code, message, name: errorSuffix, ref, suggestions } = error;
@@ -0,0 +1 @@
1
+ export declare function exit(code?: number): never;
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.exit = void 0;
4
+ const exit_1 = require("./errors/exit");
5
+ function exit(code = 0) {
6
+ throw new exit_1.ExitError(code);
7
+ }
8
+ exports.exit = exit;
@@ -7,7 +7,7 @@ exports.handle = exports.Exit = void 0;
7
7
  const clean_stack_1 = __importDefault(require("clean-stack"));
8
8
  const cache_1 = __importDefault(require("../cache"));
9
9
  const index_1 = require("../help/index");
10
- const config_1 = require("./config");
10
+ const logger_1 = require("../logger");
11
11
  const cli_1 = require("./errors/cli");
12
12
  const exit_1 = require("./errors/exit");
13
13
  const pretty_print_1 = __importDefault(require("./errors/pretty-print"));
@@ -46,17 +46,10 @@ async function handle(err) {
46
46
  }
47
47
  }
48
48
  const exitCode = err.oclif?.exit ?? 1;
49
- if (config_1.config.errorLogger && err.code !== 'EEXIT') {
50
- if (stack) {
51
- config_1.config.errorLogger.log(stack);
52
- }
53
- await config_1.config.errorLogger
54
- .flush()
55
- .then(() => exports.Exit.exit(exitCode))
56
- .catch(console.error);
49
+ if (err.code !== 'EEXIT' && stack) {
50
+ (0, logger_1.getLogger)().error(stack);
57
51
  }
58
- else
59
- exports.Exit.exit(exitCode);
52
+ exports.Exit.exit(exitCode);
60
53
  }
61
54
  catch (error) {
62
55
  console.error(err.stack);
@@ -1,10 +1,8 @@
1
1
  export { PrettyPrintableError } from '../interfaces';
2
- export { config } from './config';
3
2
  export { error } from './error';
4
3
  export { CLIError } from './errors/cli';
5
4
  export { ExitError } from './errors/exit';
6
5
  export { ModuleLoadError } from './errors/module-load';
6
+ export { exit } from './exit';
7
7
  export { handle } from './handle';
8
- export { Logger } from './logger';
9
- export declare function exit(code?: number): never;
10
8
  export { warn } from './warn';
@@ -1,24 +1,17 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.warn = exports.exit = exports.Logger = exports.handle = exports.ModuleLoadError = exports.ExitError = exports.CLIError = exports.error = exports.config = void 0;
4
- const exit_1 = require("./errors/exit");
5
- var config_1 = require("./config");
6
- Object.defineProperty(exports, "config", { enumerable: true, get: function () { return config_1.config; } });
3
+ exports.warn = exports.handle = exports.exit = exports.ModuleLoadError = exports.ExitError = exports.CLIError = exports.error = void 0;
7
4
  var error_1 = require("./error");
8
5
  Object.defineProperty(exports, "error", { enumerable: true, get: function () { return error_1.error; } });
9
6
  var cli_1 = require("./errors/cli");
10
7
  Object.defineProperty(exports, "CLIError", { enumerable: true, get: function () { return cli_1.CLIError; } });
11
- var exit_2 = require("./errors/exit");
12
- Object.defineProperty(exports, "ExitError", { enumerable: true, get: function () { return exit_2.ExitError; } });
8
+ var exit_1 = require("./errors/exit");
9
+ Object.defineProperty(exports, "ExitError", { enumerable: true, get: function () { return exit_1.ExitError; } });
13
10
  var module_load_1 = require("./errors/module-load");
14
11
  Object.defineProperty(exports, "ModuleLoadError", { enumerable: true, get: function () { return module_load_1.ModuleLoadError; } });
12
+ var exit_2 = require("./exit");
13
+ Object.defineProperty(exports, "exit", { enumerable: true, get: function () { return exit_2.exit; } });
15
14
  var handle_1 = require("./handle");
16
15
  Object.defineProperty(exports, "handle", { enumerable: true, get: function () { return handle_1.handle; } });
17
- var logger_1 = require("./logger");
18
- Object.defineProperty(exports, "Logger", { enumerable: true, get: function () { return logger_1.Logger; } });
19
- function exit(code = 0) {
20
- throw new exit_1.ExitError(code);
21
- }
22
- exports.exit = exit;
23
16
  var warn_1 = require("./warn");
24
17
  Object.defineProperty(exports, "warn", { enumerable: true, get: function () { return warn_1.warn; } });
@@ -1,3 +1,8 @@
1
+ /**
2
+ * Prints a pretty warning message to stderr.
3
+ *
4
+ * @param input The error or string to print.
5
+ */
1
6
  export declare function warn(input: Error | string): void;
2
7
  export declare function memoizedWarn(input: Error | string): void;
3
8
  export default warn;
@@ -4,10 +4,15 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.memoizedWarn = exports.warn = void 0;
7
- const write_1 = __importDefault(require("../cli-ux/write"));
8
- const config_1 = require("./config");
7
+ const logger_1 = require("../logger");
8
+ const write_1 = require("../ux/write");
9
9
  const cli_1 = require("./errors/cli");
10
10
  const pretty_print_1 = __importDefault(require("./errors/pretty-print"));
11
+ /**
12
+ * Prints a pretty warning message to stderr.
13
+ *
14
+ * @param input The error or string to print.
15
+ */
11
16
  function warn(input) {
12
17
  let err;
13
18
  if (typeof input === 'string') {
@@ -21,9 +26,9 @@ function warn(input) {
21
26
  }
22
27
  const message = (0, pretty_print_1.default)(err);
23
28
  if (message)
24
- write_1.default.stderr(message + '\n');
25
- if (config_1.config.errorLogger)
26
- config_1.config.errorLogger.log(err?.stack ?? '');
29
+ (0, write_1.stderr)(message);
30
+ if (err?.stack)
31
+ (0, logger_1.getLogger)().error(err.stack);
27
32
  }
28
33
  exports.warn = warn;
29
34
  const WARNINGS = new Set();
package/lib/execute.js CHANGED
@@ -1,9 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.execute = void 0;
4
- const flush_1 = require("./cli-ux/flush");
5
4
  const errors_1 = require("./errors");
6
5
  const handle_1 = require("./errors/handle");
6
+ const flush_1 = require("./flush");
7
7
  const main_1 = require("./main");
8
8
  const settings_1 = require("./settings");
9
9
  /**
package/lib/flags.d.ts CHANGED
@@ -72,8 +72,8 @@ export declare function boolean<T = boolean>(options?: Partial<BooleanFlag<T>>):
72
72
  * - `max` option allows to set a maximum value.
73
73
  */
74
74
  export declare const integer: FlagDefinition<number, {
75
- max?: number | undefined;
76
- min?: number | undefined;
75
+ max?: number;
76
+ min?: number;
77
77
  }, {
78
78
  multiple: false;
79
79
  requiredOrDefaulted: false;
@@ -84,7 +84,7 @@ export declare const integer: FlagDefinition<number, {
84
84
  * - `exists` option allows you to throw an error if the directory does not exist.
85
85
  */
86
86
  export declare const directory: FlagDefinition<string, {
87
- exists?: boolean | undefined;
87
+ exists?: boolean;
88
88
  }, {
89
89
  multiple: false;
90
90
  requiredOrDefaulted: false;
@@ -95,7 +95,7 @@ export declare const directory: FlagDefinition<string, {
95
95
  * - `exists` option allows you to throw an error if the file does not exist.
96
96
  */
97
97
  export declare const file: FlagDefinition<string, {
98
- exists?: boolean | undefined;
98
+ exists?: boolean;
99
99
  }, {
100
100
  multiple: false;
101
101
  requiredOrDefaulted: false;
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.flush = void 0;
4
- const errors_1 = require("../errors");
4
+ const error_1 = require("./errors/error");
5
5
  function timeout(p, ms) {
6
6
  function wait(ms, unref = false) {
7
7
  return new Promise((resolve) => {
@@ -10,7 +10,7 @@ function timeout(p, ms) {
10
10
  t.unref();
11
11
  });
12
12
  }
13
- return Promise.race([p, wait(ms, true).then(() => (0, errors_1.error)('timed out'))]);
13
+ return Promise.race([p, wait(ms, true).then(() => (0, error_1.error)('timed out'))]);
14
14
  }
15
15
  async function _flush() {
16
16
  const p = new Promise((resolve) => {
@@ -4,12 +4,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.CommandHelp = void 0;
7
- const chalk_1 = __importDefault(require("chalk"));
8
- const strip_ansi_1 = __importDefault(require("strip-ansi"));
9
- const theme_1 = require("../cli-ux/theme");
7
+ const ansis_1 = __importDefault(require("ansis"));
10
8
  const ensure_arg_object_1 = require("../util/ensure-arg-object");
11
9
  const ids_1 = require("../util/ids");
12
10
  const util_1 = require("../util/util");
11
+ const theme_1 = require("../ux/theme");
13
12
  const docopts_1 = require("./docopts");
14
13
  const formatter_1 = require("./formatter");
15
14
  // Don't use os.EOL because we need to ensure that a string
@@ -161,7 +160,7 @@ class CommandHelp extends formatter_1.HelpFormatter {
161
160
  if (flag.multiple)
162
161
  value += '...';
163
162
  if (!value.includes('|'))
164
- value = chalk_1.default.underline(value);
163
+ value = ansis_1.default.underline(value);
165
164
  label += `=${value}`;
166
165
  }
167
166
  return (0, theme_1.colorize)(this.config.theme?.flag, label);
@@ -328,7 +327,9 @@ class CommandHelp extends formatter_1.HelpFormatter {
328
327
  return example;
329
328
  }
330
329
  isCommand(example) {
331
- return (0, strip_ansi_1.default)(this.formatIfCommand(example)).startsWith(`${(0, theme_1.colorize)(this.config?.theme?.dollarSign, '$')} ${this.config.bin}`);
330
+ return ansis_1.default
331
+ .strip(this.formatIfCommand(example))
332
+ .startsWith(`${(0, theme_1.colorize)(this.config?.theme?.dollarSign, '$')} ${this.config.bin}`);
332
333
  }
333
334
  }
334
335
  exports.CommandHelp = CommandHelp;
@@ -59,9 +59,9 @@ export declare class HelpFormatter {
59
59
  indent(body: string, spacing?: number): string;
60
60
  renderList(input: (string | undefined)[][], opts: {
61
61
  indentation: number;
62
- multiline?: boolean;
63
- spacer?: string;
64
- stripAnsi?: boolean;
62
+ multiline?: boolean | undefined;
63
+ spacer?: string | undefined;
64
+ stripAnsi?: boolean | undefined;
65
65
  }): string;
66
66
  section(header: string, body: [string, string | undefined][] | HelpSection | HelpSectionKeyValueTable | string): string;
67
67
  /**
@@ -4,14 +4,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.HelpFormatter = void 0;
7
- const chalk_1 = __importDefault(require("chalk"));
7
+ const ansis_1 = __importDefault(require("ansis"));
8
8
  const indent_string_1 = __importDefault(require("indent-string"));
9
9
  const string_width_1 = __importDefault(require("string-width"));
10
- const strip_ansi_1 = __importDefault(require("strip-ansi"));
11
10
  const widest_line_1 = __importDefault(require("widest-line"));
12
11
  const wrap_ansi_1 = __importDefault(require("wrap-ansi"));
13
- const theme_1 = require("../cli-ux/theme");
14
12
  const screen_1 = require("../screen");
13
+ const theme_1 = require("../ux/theme");
15
14
  const util_1 = require("./util");
16
15
  class HelpFormatter {
17
16
  config;
@@ -74,12 +73,12 @@ class HelpFormatter {
74
73
  continue;
75
74
  if (left) {
76
75
  if (opts.stripAnsi)
77
- left = (0, strip_ansi_1.default)(left);
76
+ left = ansis_1.default.strip(left);
78
77
  output += this.wrap(left.trim(), opts.indentation);
79
78
  }
80
79
  if (right) {
81
80
  if (opts.stripAnsi)
82
- right = (0, strip_ansi_1.default)(right);
81
+ right = ansis_1.default.strip(right);
83
82
  output += '\n';
84
83
  output += this.indent(this.wrap(right.trim(), opts.indentation + 2), 4);
85
84
  }
@@ -101,13 +100,13 @@ class HelpFormatter {
101
100
  }
102
101
  cur = left || '';
103
102
  if (opts.stripAnsi)
104
- cur = (0, strip_ansi_1.default)(cur);
103
+ cur = ansis_1.default.strip(cur);
105
104
  if (!right) {
106
105
  cur = cur.trim();
107
106
  continue;
108
107
  }
109
108
  if (opts.stripAnsi)
110
- right = (0, strip_ansi_1.default)(right);
109
+ right = ansis_1.default.strip(right);
111
110
  right = this.wrap(right.trim(), opts.indentation + maxLength + 2);
112
111
  const [first, ...lines] = right.split('\n').map((s) => s.trim());
113
112
  cur += ' '.repeat(maxLength - (0, string_width_1.default)(cur) + 2);
@@ -155,10 +154,10 @@ class HelpFormatter {
155
154
  .map(([left, right]) => [this.render(left), right && this.render(right)]);
156
155
  }
157
156
  const output = [
158
- (0, theme_1.colorize)(this.config?.theme?.sectionHeader, chalk_1.default.bold(header)),
157
+ (0, theme_1.colorize)(this.config?.theme?.sectionHeader, ansis_1.default.bold(header)),
159
158
  (0, theme_1.colorize)(this.config?.theme?.sectionDescription, this.indent(Array.isArray(newBody) ? this.renderList(newBody, { indentation: 2, stripAnsi: this.opts.stripAnsi }) : newBody)),
160
159
  ].join('\n');
161
- return this.opts.stripAnsi ? (0, strip_ansi_1.default)(output) : output;
160
+ return this.opts.stripAnsi ? ansis_1.default.strip(output) : output;
162
161
  }
163
162
  /**
164
163
  * Wrap text according to `opts.maxWidth` which is typically set to the terminal width. All text
@@ -3,6 +3,7 @@ import * as Interfaces from '../interfaces';
3
3
  import { CommandHelp } from './command';
4
4
  import { HelpFormatter } from './formatter';
5
5
  export { CommandHelp } from './command';
6
+ export { HelpFormatter, type HelpSection, type HelpSectionKeyValueTable, type HelpSectionRenderer } from './formatter';
6
7
  export { getHelpFlagAdditions, normalizeArgv, standardizeIDFromArgv } from './util';
7
8
  export declare abstract class HelpBase extends HelpFormatter {
8
9
  constructor(config: Interfaces.Config, opts?: Partial<Interfaces.HelpOptions>);
package/lib/help/index.js CHANGED
@@ -3,11 +3,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.loadHelpClass = exports.Help = exports.HelpBase = exports.standardizeIDFromArgv = exports.normalizeArgv = exports.getHelpFlagAdditions = exports.CommandHelp = void 0;
7
- const node_util_1 = require("node:util");
8
- const strip_ansi_1 = __importDefault(require("strip-ansi"));
9
- const theme_1 = require("../cli-ux/theme");
10
- const write_1 = __importDefault(require("../cli-ux/write"));
6
+ exports.loadHelpClass = exports.Help = exports.HelpBase = exports.standardizeIDFromArgv = exports.normalizeArgv = exports.getHelpFlagAdditions = exports.HelpFormatter = exports.CommandHelp = void 0;
7
+ const ansis_1 = __importDefault(require("ansis"));
11
8
  const ts_path_1 = require("../config/ts-path");
12
9
  const error_1 = require("../errors/error");
13
10
  const module_loader_1 = require("../module-loader");
@@ -15,12 +12,16 @@ const symbols_1 = require("../symbols");
15
12
  const cache_default_value_1 = require("../util/cache-default-value");
16
13
  const ids_1 = require("../util/ids");
17
14
  const util_1 = require("../util/util");
15
+ const ux_1 = require("../ux");
16
+ const theme_1 = require("../ux/theme");
18
17
  const command_1 = require("./command");
19
18
  const formatter_1 = require("./formatter");
20
19
  const root_1 = __importDefault(require("./root"));
21
20
  const util_2 = require("./util");
22
21
  var command_2 = require("./command");
23
22
  Object.defineProperty(exports, "CommandHelp", { enumerable: true, get: function () { return command_2.CommandHelp; } });
23
+ var formatter_2 = require("./formatter");
24
+ Object.defineProperty(exports, "HelpFormatter", { enumerable: true, get: function () { return formatter_2.HelpFormatter; } });
24
25
  var util_3 = require("./util");
25
26
  Object.defineProperty(exports, "getHelpFlagAdditions", { enumerable: true, get: function () { return util_3.getHelpFlagAdditions; } });
26
27
  Object.defineProperty(exports, "normalizeArgv", { enumerable: true, get: function () { return util_3.normalizeArgv; } });
@@ -94,7 +95,7 @@ class Help extends HelpBase {
94
95
  const summary = this.summary(c);
95
96
  return [
96
97
  (0, theme_1.colorize)(this.config?.theme?.command, c.id),
97
- summary && (0, theme_1.colorize)(this.config?.theme?.sectionDescription, (0, strip_ansi_1.default)(summary)),
98
+ summary && (0, theme_1.colorize)(this.config?.theme?.sectionDescription, ansis_1.default.strip(summary)),
98
99
  ];
99
100
  }), {
100
101
  indentation: 2,
@@ -121,7 +122,7 @@ class Help extends HelpBase {
121
122
  this.section('DESCRIPTION', this.wrap((0, theme_1.colorize)(this.config?.theme?.sectionDescription, description))),
122
123
  ]).join('\n\n');
123
124
  if (this.opts.stripAnsi)
124
- output = (0, strip_ansi_1.default)(output);
125
+ output = ansis_1.default.strip(output);
125
126
  return output + '\n';
126
127
  }
127
128
  formatTopics(topics) {
@@ -145,9 +146,7 @@ class Help extends HelpBase {
145
146
  return new this.CommandHelpClass(command, this.config, this.opts);
146
147
  }
147
148
  log(...args) {
148
- this.opts.sendToStderr
149
- ? write_1.default.stderr(node_util_1.format.apply(this, args) + '\n')
150
- : write_1.default.stdout(node_util_1.format.apply(this, args) + '\n');
149
+ this.opts.sendToStderr ? ux_1.ux.stderr(args) : ux_1.ux.stdout(args);
151
150
  }
152
151
  async showCommandHelp(command) {
153
152
  const name = command.id;
@@ -317,17 +316,24 @@ exports.Help = Help;
317
316
  function extractClass(exported) {
318
317
  return exported && exported.default ? exported.default : exported;
319
318
  }
319
+ function determineLocation(helpClass) {
320
+ if (typeof helpClass === 'string')
321
+ return { identifier: 'default', target: helpClass };
322
+ if (!helpClass.identifier)
323
+ return { ...helpClass, identifier: 'default' };
324
+ return helpClass;
325
+ }
320
326
  async function loadHelpClass(config) {
321
- const { pjson } = config;
322
- const configuredClass = pjson.oclif?.helpClass;
323
- if (configuredClass) {
327
+ if (config.pjson.oclif?.helpClass) {
328
+ const { identifier, target } = determineLocation(config.pjson.oclif?.helpClass);
324
329
  try {
325
- const path = (await (0, ts_path_1.tsPath)(config.root, configuredClass)) ?? configuredClass;
326
- const exported = await (0, module_loader_1.load)(config, path);
327
- return extractClass(exported);
330
+ const path = (await (0, ts_path_1.tsPath)(config.root, target)) ?? target;
331
+ const module = await (0, module_loader_1.load)(config, path);
332
+ const helpClass = module[identifier] ?? (identifier === 'default' ? extractClass(module) : undefined);
333
+ return extractClass(helpClass);
328
334
  }
329
335
  catch (error) {
330
- throw new Error(`Unable to load configured help class "${configuredClass}", failed with message:\n${error.message}`);
336
+ throw new Error(`Unable to load configured help class "${target}", failed with message:\n${error.message}`);
331
337
  }
332
338
  }
333
339
  return Help;
package/lib/help/root.js CHANGED
@@ -3,9 +3,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- const strip_ansi_1 = __importDefault(require("strip-ansi"));
7
- const theme_1 = require("../cli-ux/theme");
6
+ const ansis_1 = __importDefault(require("ansis"));
8
7
  const util_1 = require("../util/util");
8
+ const theme_1 = require("../ux/theme");
9
9
  const formatter_1 = require("./formatter");
10
10
  class RootHelp extends formatter_1.HelpFormatter {
11
11
  config;
@@ -34,7 +34,7 @@ class RootHelp extends formatter_1.HelpFormatter {
34
34
  this.description(),
35
35
  ]).join('\n\n');
36
36
  if (this.opts.stripAnsi)
37
- output = (0, strip_ansi_1.default)(output);
37
+ output = ansis_1.default.strip(output);
38
38
  return output;
39
39
  }
40
40
  usage() {
package/lib/index.d.ts CHANGED
@@ -1,20 +1,19 @@
1
1
  export * as Args from './args';
2
- export * as ux from './cli-ux';
3
- export { flush } from './cli-ux/flush';
4
- export { stderr, stdout } from './cli-ux/stream';
5
2
  export { Command } from './command';
6
3
  export { Config, Plugin } from './config';
7
4
  export * as Errors from './errors';
8
5
  export { handle } from './errors/handle';
9
6
  export { execute } from './execute';
10
7
  export * as Flags from './flags';
11
- export { CommandHelp, Help, HelpBase, loadHelpClass } from './help';
12
- export { HelpSection, HelpSectionKeyValueTable, HelpSectionRenderer } from './help/formatter';
8
+ export { flush } from './flush';
9
+ export { CommandHelp, Help, HelpBase, type HelpSection, type HelpSectionKeyValueTable, type HelpSectionRenderer, loadHelpClass, } from './help';
13
10
  export * as Interfaces from './interfaces';
14
- export { Hook } from './interfaces/hooks';
11
+ export { type Hook } from './interfaces/hooks';
12
+ export { getLogger } from './logger';
15
13
  export { run } from './main';
16
14
  export * as ModuleLoader from './module-loader';
17
15
  export * as Parser from './parser';
18
16
  export { Performance } from './performance';
19
- export { Settings, settings } from './settings';
17
+ export { type Settings, settings } from './settings';
20
18
  export { toConfiguredId, toStandardizedId } from './util/ids';
19
+ export { ux } from './ux';
package/lib/index.js CHANGED
@@ -22,30 +22,20 @@ var __importStar = (this && this.__importStar) || function (mod) {
22
22
  __setModuleDefault(result, mod);
23
23
  return result;
24
24
  };
25
- var __importDefault = (this && this.__importDefault) || function (mod) {
26
- return (mod && mod.__esModule) ? mod : { "default": mod };
27
- };
28
25
  Object.defineProperty(exports, "__esModule", { value: true });
29
- exports.toStandardizedId = exports.toConfiguredId = exports.settings = exports.Performance = exports.Parser = exports.ModuleLoader = exports.run = exports.Interfaces = exports.loadHelpClass = exports.HelpBase = exports.Help = exports.CommandHelp = exports.Flags = exports.execute = exports.handle = exports.Errors = exports.Plugin = exports.Config = exports.Command = exports.stdout = exports.stderr = exports.flush = exports.ux = exports.Args = void 0;
30
- const write_1 = __importDefault(require("./cli-ux/write"));
26
+ exports.ux = exports.toStandardizedId = exports.toConfiguredId = exports.settings = exports.Performance = exports.Parser = exports.ModuleLoader = exports.run = exports.getLogger = exports.Interfaces = exports.loadHelpClass = exports.HelpBase = exports.Help = exports.CommandHelp = exports.flush = exports.Flags = exports.execute = exports.handle = exports.Errors = exports.Plugin = exports.Config = exports.Command = exports.Args = void 0;
31
27
  function checkCWD() {
32
28
  try {
33
29
  process.cwd();
34
30
  }
35
31
  catch (error) {
36
32
  if (error.code === 'ENOENT') {
37
- write_1.default.stderr('WARNING: current directory does not exist\n');
33
+ process.stderr.write('WARNING: current directory does not exist\n');
38
34
  }
39
35
  }
40
36
  }
41
37
  checkCWD();
42
38
  exports.Args = __importStar(require("./args"));
43
- exports.ux = __importStar(require("./cli-ux"));
44
- var flush_1 = require("./cli-ux/flush");
45
- Object.defineProperty(exports, "flush", { enumerable: true, get: function () { return flush_1.flush; } });
46
- var stream_1 = require("./cli-ux/stream"); // Remove these in the next major version
47
- Object.defineProperty(exports, "stderr", { enumerable: true, get: function () { return stream_1.stderr; } });
48
- Object.defineProperty(exports, "stdout", { enumerable: true, get: function () { return stream_1.stdout; } });
49
39
  var command_1 = require("./command");
50
40
  Object.defineProperty(exports, "Command", { enumerable: true, get: function () { return command_1.Command; } });
51
41
  var config_1 = require("./config");
@@ -57,12 +47,16 @@ Object.defineProperty(exports, "handle", { enumerable: true, get: function () {
57
47
  var execute_1 = require("./execute");
58
48
  Object.defineProperty(exports, "execute", { enumerable: true, get: function () { return execute_1.execute; } });
59
49
  exports.Flags = __importStar(require("./flags"));
50
+ var flush_1 = require("./flush");
51
+ Object.defineProperty(exports, "flush", { enumerable: true, get: function () { return flush_1.flush; } });
60
52
  var help_1 = require("./help");
61
53
  Object.defineProperty(exports, "CommandHelp", { enumerable: true, get: function () { return help_1.CommandHelp; } });
62
54
  Object.defineProperty(exports, "Help", { enumerable: true, get: function () { return help_1.Help; } });
63
55
  Object.defineProperty(exports, "HelpBase", { enumerable: true, get: function () { return help_1.HelpBase; } });
64
56
  Object.defineProperty(exports, "loadHelpClass", { enumerable: true, get: function () { return help_1.loadHelpClass; } });
65
57
  exports.Interfaces = __importStar(require("./interfaces"));
58
+ var logger_1 = require("./logger");
59
+ Object.defineProperty(exports, "getLogger", { enumerable: true, get: function () { return logger_1.getLogger; } });
66
60
  var main_1 = require("./main");
67
61
  Object.defineProperty(exports, "run", { enumerable: true, get: function () { return main_1.run; } });
68
62
  exports.ModuleLoader = __importStar(require("./module-loader"));
@@ -74,3 +68,5 @@ Object.defineProperty(exports, "settings", { enumerable: true, get: function ()
74
68
  var ids_1 = require("./util/ids");
75
69
  Object.defineProperty(exports, "toConfiguredId", { enumerable: true, get: function () { return ids_1.toConfiguredId; } });
76
70
  Object.defineProperty(exports, "toStandardizedId", { enumerable: true, get: function () { return ids_1.toStandardizedId; } });
71
+ var ux_1 = require("./ux");
72
+ Object.defineProperty(exports, "ux", { enumerable: true, get: function () { return ux_1.ux; } });