@oclif/core 4.0.0-beta.12 → 4.0.0-beta.14

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/lib/ux/index.d.ts CHANGED
@@ -55,13 +55,13 @@ export declare const ux: {
55
55
  *
56
56
  * See node's util.format() for formatting options.
57
57
  */
58
- stderr: (str: string | string[] | undefined, ...args: string[]) => void;
58
+ stderr: (str?: string | string[] | undefined, ...args: string[]) => void;
59
59
  /**
60
60
  * Log a formatted string to stdout.
61
61
  *
62
62
  * See node's util.format() for formatting options.
63
63
  */
64
- stdout: (str: string | string[] | undefined, ...args: string[]) => void;
64
+ stdout: (str?: string | string[] | undefined, ...args: string[]) => void;
65
65
  /**
66
66
  * Prints a pretty warning message to stderr.
67
67
  */
package/lib/ux/theme.js CHANGED
@@ -5,8 +5,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.parseTheme = exports.colorize = void 0;
7
7
  const ansis_1 = __importDefault(require("ansis"));
8
+ const supports_color_1 = require("supports-color");
8
9
  const theme_1 = require("../interfaces/theme");
9
- function isStandardChalk(color) {
10
+ function isStandardAnsi(color) {
10
11
  return theme_1.STANDARD_ANSI.includes(color);
11
12
  }
12
13
  /**
@@ -18,7 +19,11 @@ function isStandardChalk(color) {
18
19
  function colorize(color, text) {
19
20
  if (!color)
20
21
  return text;
21
- if (isStandardChalk(color))
22
+ if (!supports_color_1.stdout)
23
+ return text;
24
+ if (!supports_color_1.stderr)
25
+ return text;
26
+ if (isStandardAnsi(color))
22
27
  return ansis_1.default[color](text);
23
28
  if (color.startsWith('#'))
24
29
  return ansis_1.default.hex(color)(text);
@@ -39,5 +44,5 @@ function parseTheme(theme) {
39
44
  }
40
45
  exports.parseTheme = parseTheme;
41
46
  function isValid(color) {
42
- return color.startsWith('#') || color.startsWith('rgb') || isStandardChalk(color) ? color : undefined;
47
+ return color.startsWith('#') || color.startsWith('rgb') || isStandardAnsi(color) ? color : undefined;
43
48
  }
package/lib/ux/write.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export declare const stdout: (str: string | string[] | undefined, ...args: string[]) => void;
2
- export declare const stderr: (str: string | string[] | undefined, ...args: string[]) => void;
1
+ export declare const stdout: (str?: string | string[] | undefined, ...args: string[]) => void;
2
+ export declare const stderr: (str?: string | string[] | undefined, ...args: string[]) => void;
package/lib/ux/write.js CHANGED
@@ -3,8 +3,14 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.stderr = exports.stdout = void 0;
4
4
  const node_util_1 = require("node:util");
5
5
  const stdout = (str, ...args) => {
6
- if (typeof str === 'string' || !str) {
7
- process.stdout.write((0, node_util_1.format)(str, ...args) + '\n');
6
+ if (!str && args) {
7
+ process.stdout.write((0, node_util_1.format)(...args) + '\n');
8
+ }
9
+ else if (!str) {
10
+ process.stdout.write('\n');
11
+ }
12
+ else if (typeof str === 'string') {
13
+ process.stdout.write((str && (0, node_util_1.format)(str, ...args)) + '\n');
8
14
  }
9
15
  else {
10
16
  process.stdout.write((0, node_util_1.format)(...str, ...args) + '\n');
@@ -12,8 +18,14 @@ const stdout = (str, ...args) => {
12
18
  };
13
19
  exports.stdout = stdout;
14
20
  const stderr = (str, ...args) => {
15
- if (typeof str === 'string' || !str) {
16
- process.stderr.write((0, node_util_1.format)(str, ...args) + '\n');
21
+ if (!str && args) {
22
+ process.stderr.write((0, node_util_1.format)(...args) + '\n');
23
+ }
24
+ else if (!str) {
25
+ process.stderr.write('\n');
26
+ }
27
+ else if (typeof str === 'string') {
28
+ process.stderr.write((str && (0, node_util_1.format)(str, ...args)) + '\n');
17
29
  }
18
30
  else {
19
31
  process.stderr.write((0, node_util_1.format)(...str, ...args) + '\n');
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@oclif/core",
3
3
  "description": "base library for oclif CLIs",
4
- "version": "4.0.0-beta.12",
4
+ "version": "4.0.0-beta.14",
5
5
  "author": "Salesforce",
6
6
  "bugs": "https://github.com/oclif/core/issues",
7
7
  "dependencies": {
8
8
  "ansi-escapes": "^4.3.2",
9
- "ansis": "^3.0.1",
9
+ "ansis": "^3.1.1",
10
10
  "clean-stack": "^3.0.1",
11
11
  "cli-spinners": "^2.9.2",
12
12
  "cosmiconfig": "^9.0.0",
@@ -18,7 +18,7 @@
18
18
  "is-wsl": "^2.2.0",
19
19
  "minimatch": "^9.0.4",
20
20
  "string-width": "^4.2.3",
21
- "supports-color": "^9.4.0",
21
+ "supports-color": "^8",
22
22
  "widest-line": "^3.1.0",
23
23
  "wordwrap": "^1.0.0",
24
24
  "wrap-ansi": "^7.0.0"
@@ -40,6 +40,7 @@
40
40
  "@types/node": "^18",
41
41
  "@types/pnpapi": "^0.0.5",
42
42
  "@types/sinon": "^17.0.3",
43
+ "@types/supports-color": "^8.1.3",
43
44
  "@types/wordwrap": "^1.0.3",
44
45
  "@types/wrap-ansi": "^3.0.0",
45
46
  "benchmark": "^2.1.4",