@oclif/core 3.26.4 → 4.0.0-beta.2

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 (78) hide show
  1. package/lib/command.js +6 -6
  2. package/lib/config/config.d.ts +3 -4
  3. package/lib/config/config.js +42 -39
  4. package/lib/config/ts-path.js +5 -5
  5. package/lib/errors/error.js +2 -5
  6. package/lib/errors/errors/cli.js +3 -3
  7. package/lib/errors/exit.d.ts +1 -0
  8. package/lib/errors/exit.js +8 -0
  9. package/lib/errors/index.d.ts +1 -1
  10. package/lib/errors/index.js +5 -8
  11. package/lib/errors/logger.js +5 -2
  12. package/lib/errors/warn.d.ts +13 -2
  13. package/lib/errors/warn.js +15 -11
  14. package/lib/execute.js +1 -1
  15. package/lib/{cli-ux/flush.js → flush.js} +1 -1
  16. package/lib/help/command.js +6 -5
  17. package/lib/help/formatter.js +8 -9
  18. package/lib/help/index.js +6 -9
  19. package/lib/help/root.js +3 -3
  20. package/lib/index.d.ts +2 -3
  21. package/lib/index.js +6 -12
  22. package/lib/interfaces/config.d.ts +1 -0
  23. package/lib/interfaces/pjson.d.ts +1 -1
  24. package/lib/interfaces/theme.d.ts +30 -19
  25. package/lib/interfaces/theme.js +2 -19
  26. package/lib/main.js +2 -2
  27. package/lib/parser/errors.js +5 -5
  28. package/lib/parser/help.js +2 -2
  29. package/lib/util/read-tsconfig.js +1 -1
  30. package/lib/{cli-ux → ux}/action/base.d.ts +5 -7
  31. package/lib/{cli-ux → ux}/action/base.js +0 -3
  32. package/lib/{cli-ux → ux}/action/spinner.d.ts +5 -4
  33. package/lib/{cli-ux → ux}/action/spinner.js +16 -39
  34. package/lib/ux/action/types.d.ts +5 -0
  35. package/lib/ux/colorize-json.d.ts +28 -0
  36. package/lib/ux/colorize-json.js +67 -0
  37. package/lib/ux/index.d.ts +64 -0
  38. package/lib/ux/index.js +76 -0
  39. package/lib/{cli-ux → ux}/list.d.ts +1 -1
  40. package/lib/{cli-ux → ux}/list.js +1 -2
  41. package/lib/ux/theme.d.ts +9 -0
  42. package/lib/ux/theme.js +43 -0
  43. package/lib/ux/write.d.ts +2 -0
  44. package/lib/ux/write.js +22 -0
  45. package/package.json +11 -33
  46. package/lib/cli-ux/action/spinners.d.ts +0 -251
  47. package/lib/cli-ux/action/spinners.js +0 -374
  48. package/lib/cli-ux/action/types.d.ts +0 -5
  49. package/lib/cli-ux/config.d.ts +0 -25
  50. package/lib/cli-ux/config.js +0 -52
  51. package/lib/cli-ux/exit.d.ts +0 -8
  52. package/lib/cli-ux/exit.js +0 -16
  53. package/lib/cli-ux/index.d.ts +0 -133
  54. package/lib/cli-ux/index.js +0 -183
  55. package/lib/cli-ux/prompt.d.ts +0 -32
  56. package/lib/cli-ux/prompt.js +0 -185
  57. package/lib/cli-ux/stream.d.ts +0 -23
  58. package/lib/cli-ux/stream.js +0 -43
  59. package/lib/cli-ux/styled/index.d.ts +0 -4
  60. package/lib/cli-ux/styled/index.js +0 -36
  61. package/lib/cli-ux/styled/object.d.ts +0 -1
  62. package/lib/cli-ux/styled/object.js +0 -39
  63. package/lib/cli-ux/styled/progress.d.ts +0 -2
  64. package/lib/cli-ux/styled/progress.js +0 -8
  65. package/lib/cli-ux/styled/table.d.ts +0 -45
  66. package/lib/cli-ux/styled/table.js +0 -345
  67. package/lib/cli-ux/styled/tree.d.ts +0 -9
  68. package/lib/cli-ux/styled/tree.js +0 -37
  69. package/lib/cli-ux/theme.d.ts +0 -11
  70. package/lib/cli-ux/theme.js +0 -61
  71. package/lib/cli-ux/wait.d.ts +0 -2
  72. package/lib/cli-ux/wait.js +0 -5
  73. package/lib/cli-ux/write.d.ts +0 -8
  74. package/lib/cli-ux/write.js +0 -15
  75. /package/lib/{cli-ux/flush.d.ts → flush.d.ts} +0 -0
  76. /package/lib/{cli-ux → ux}/action/simple.d.ts +0 -0
  77. /package/lib/{cli-ux → ux}/action/simple.js +0 -0
  78. /package/lib/{cli-ux → ux}/action/types.js +0 -0
@@ -0,0 +1,76 @@
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
+ exports.methods = void 0;
7
+ const error_1 = require("../errors/error");
8
+ const exit_1 = require("../errors/exit");
9
+ const warn_1 = require("../errors/warn");
10
+ const simple_1 = __importDefault(require("./action/simple"));
11
+ const spinner_1 = __importDefault(require("./action/spinner"));
12
+ const colorize_json_1 = __importDefault(require("./colorize-json"));
13
+ const theme_1 = require("./theme");
14
+ const write_1 = require("./write");
15
+ const ACTION_TYPE = (Boolean(process.stderr.isTTY) &&
16
+ !process.env.CI &&
17
+ !['dumb', 'emacs-color'].includes(process.env.TERM) &&
18
+ 'spinner') ||
19
+ 'simple';
20
+ exports.methods = {
21
+ action: ACTION_TYPE === 'spinner' ? new spinner_1.default() : new simple_1.default(),
22
+ /**
23
+ * Add color to text.
24
+ * @param color color to use. Can be hex code (e.g. `#ff0000`), rgb (e.g. `rgb(255, 255, 255)`) or a standard ansi color (e.g. `red`)
25
+ * @param text string to colorize
26
+ * @returns colorized string
27
+ */
28
+ colorize: theme_1.colorize,
29
+ /**
30
+ * Add color to JSON.
31
+ *
32
+ * options
33
+ * pretty: set to true to pretty print the JSON (defaults to true)
34
+ * theme: theme to use for colorizing. See keys below for available options. All keys are optional and must be valid colors (e.g. hex code, rgb, or standard ansi color).
35
+ *
36
+ * Available theme keys:
37
+ * - brace
38
+ * - bracket
39
+ * - colon
40
+ * - comma
41
+ * - key
42
+ * - string
43
+ * - number
44
+ * - boolean
45
+ * - null
46
+ */
47
+ colorizeJson: colorize_json_1.default,
48
+ /**
49
+ * Throw an error.
50
+ *
51
+ * If `exit` option is `false`, the error will be logged to stderr but not exit the process.
52
+ * If `exit` is set to a number, the process will exit with that code.
53
+ */
54
+ error: error_1.error,
55
+ /**
56
+ * Exit the process with provided exit code (defaults to 0).
57
+ */
58
+ exit: exit_1.exit,
59
+ /**
60
+ * Log a formatted string to stderr.
61
+ *
62
+ * See node's util.format() for formatting options.
63
+ */
64
+ stderr: write_1.stderr,
65
+ /**
66
+ * Log a formatted string to stdout.
67
+ *
68
+ * See node's util.format() for formatting options.
69
+ */
70
+ stdout: write_1.stdout,
71
+ /**
72
+ * Prints a pretty warning message to stderr.
73
+ */
74
+ warn: warn_1.warn,
75
+ };
76
+ exports.default = exports.methods;
@@ -1,3 +1,3 @@
1
1
  export type IListItem = [string, string | undefined];
2
2
  export type IList = IListItem[];
3
- export declare function renderList(items: IListItem[]): string;
3
+ export default function renderList(items: IListItem[]): string;
@@ -1,6 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.renderList = void 0;
4
3
  const screen_1 = require("../screen");
5
4
  const util_1 = require("../util/util");
6
5
  const wordwrap = require('wordwrap');
@@ -26,4 +25,4 @@ function renderList(items) {
26
25
  });
27
26
  return lines.join('\n');
28
27
  }
29
- exports.renderList = renderList;
28
+ exports.default = renderList;
@@ -0,0 +1,9 @@
1
+ import { StandardAnsi, Theme } from '../interfaces/theme';
2
+ /**
3
+ * Add color to text.
4
+ * @param color color to use. Can be hex code (e.g. `#ff0000`), rgb (e.g. `rgb(255, 255, 255)`) or a standard ansi color (e.g. `red`)
5
+ * @param text string to colorize
6
+ * @returns colorized string
7
+ */
8
+ export declare function colorize(color: string | StandardAnsi | undefined, text: string): string;
9
+ export declare function parseTheme(theme: Record<string, string>): Theme;
@@ -0,0 +1,43 @@
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
+ exports.parseTheme = exports.colorize = void 0;
7
+ const ansis_1 = __importDefault(require("ansis"));
8
+ const theme_1 = require("../interfaces/theme");
9
+ function isStandardChalk(color) {
10
+ return theme_1.STANDARD_ANSI.includes(color);
11
+ }
12
+ /**
13
+ * Add color to text.
14
+ * @param color color to use. Can be hex code (e.g. `#ff0000`), rgb (e.g. `rgb(255, 255, 255)`) or a standard ansi color (e.g. `red`)
15
+ * @param text string to colorize
16
+ * @returns colorized string
17
+ */
18
+ function colorize(color, text) {
19
+ if (!color)
20
+ return text;
21
+ if (isStandardChalk(color))
22
+ return ansis_1.default[color](text);
23
+ if (color.startsWith('#'))
24
+ return ansis_1.default.hex(color)(text);
25
+ if (color.startsWith('rgb')) {
26
+ const [red, green, blue] = color
27
+ .slice(4, -1)
28
+ .split(',')
29
+ .map((c) => Number.parseInt(c.trim(), 10));
30
+ return ansis_1.default.rgb(red, green, blue)(text);
31
+ }
32
+ return text;
33
+ }
34
+ exports.colorize = colorize;
35
+ function parseTheme(theme) {
36
+ return Object.fromEntries(Object.entries(theme)
37
+ .map(([key, value]) => [key, typeof value === 'string' ? isValid(value) : parseTheme(value)])
38
+ .filter(([_, value]) => value));
39
+ }
40
+ exports.parseTheme = parseTheme;
41
+ function isValid(color) {
42
+ return color.startsWith('#') || color.startsWith('rgb') || isStandardChalk(color) ? color : undefined;
43
+ }
@@ -0,0 +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;
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.stderr = exports.stdout = void 0;
4
+ const node_util_1 = require("node:util");
5
+ const stdout = (str, ...args) => {
6
+ if (typeof str === 'string' || !str) {
7
+ process.stdout.write((0, node_util_1.format)(str, ...args) + '\n');
8
+ }
9
+ else {
10
+ process.stdout.write((0, node_util_1.format)(...str, ...args) + '\n');
11
+ }
12
+ };
13
+ exports.stdout = stdout;
14
+ const stderr = (str, ...args) => {
15
+ if (typeof str === 'string' || !str) {
16
+ process.stderr.write((0, node_util_1.format)(str, ...args) + '\n');
17
+ }
18
+ else {
19
+ process.stderr.write((0, node_util_1.format)(...str, ...args) + '\n');
20
+ }
21
+ };
22
+ exports.stderr = stderr;
package/package.json CHANGED
@@ -1,83 +1,61 @@
1
1
  {
2
2
  "name": "@oclif/core",
3
3
  "description": "base library for oclif CLIs",
4
- "version": "3.26.4",
4
+ "version": "4.0.0-beta.2",
5
5
  "author": "Salesforce",
6
6
  "bugs": "https://github.com/oclif/core/issues",
7
7
  "dependencies": {
8
- "@types/cli-progress": "^3.11.5",
9
8
  "ansi-escapes": "^4.3.2",
10
- "ansi-styles": "^4.3.0",
11
- "cardinal": "^2.1.1",
12
- "chalk": "^4.1.2",
9
+ "ansis": "^3.0.1",
13
10
  "clean-stack": "^3.0.1",
14
- "cli-progress": "^3.12.0",
15
- "color": "^4.2.3",
11
+ "cli-spinners": "^2.9.2",
16
12
  "debug": "^4.3.4",
17
13
  "ejs": "^3.1.10",
18
14
  "get-package-type": "^0.1.0",
19
15
  "globby": "^11.1.0",
20
- "hyperlinker": "^1.0.0",
21
16
  "indent-string": "^4.0.0",
22
17
  "is-wsl": "^2.2.0",
23
- "js-yaml": "^3.14.1",
24
18
  "minimatch": "^9.0.4",
25
- "natural-orderby": "^2.0.3",
26
- "object-treeify": "^1.1.33",
27
- "password-prompt": "^1.1.3",
28
- "slice-ansi": "^4.0.0",
29
19
  "string-width": "^4.2.3",
30
- "strip-ansi": "^6.0.1",
31
- "supports-color": "^8.1.1",
32
- "supports-hyperlinks": "^2.2.0",
33
20
  "widest-line": "^3.1.0",
34
21
  "wordwrap": "^1.0.0",
35
22
  "wrap-ansi": "^7.0.0"
36
23
  },
37
24
  "devDependencies": {
38
- "@commitlint/config-conventional": "^17.8.1",
25
+ "@commitlint/config-conventional": "^19",
39
26
  "@oclif/plugin-help": "^6",
40
- "@oclif/plugin-plugins": "^4",
27
+ "@oclif/plugin-plugins": "^5",
41
28
  "@oclif/prettier-config": "^0.2.1",
42
- "@oclif/test": "^3.2.9",
43
- "@types/ansi-styles": "^3.2.1",
44
29
  "@types/benchmark": "^2.1.5",
45
30
  "@types/chai": "^4.3.11",
46
31
  "@types/chai-as-promised": "^7.1.8",
47
32
  "@types/clean-stack": "^2.1.1",
48
- "@types/color": "^3.0.6",
49
33
  "@types/debug": "^4.1.10",
50
34
  "@types/ejs": "^3.1.5",
51
35
  "@types/indent-string": "^4.0.1",
52
- "@types/js-yaml": "^3.12.7",
53
36
  "@types/mocha": "^10.0.6",
54
37
  "@types/node": "^18",
55
- "@types/node-notifier": "^8.0.5",
56
38
  "@types/pnpapi": "^0.0.5",
57
- "@types/slice-ansi": "^4.0.0",
58
- "@types/strip-ansi": "^5.2.1",
59
- "@types/supports-color": "^8.1.1",
39
+ "@types/sinon": "^17.0.3",
60
40
  "@types/wordwrap": "^1.0.3",
61
41
  "@types/wrap-ansi": "^3.0.0",
62
42
  "benchmark": "^2.1.4",
63
43
  "chai": "^4.4.1",
64
44
  "chai-as-promised": "^7.1.1",
65
- "commitlint": "^17.8.1",
45
+ "commitlint": "^19",
66
46
  "cross-env": "^7.0.3",
67
47
  "eslint": "^8.57.0",
68
48
  "eslint-config-oclif": "^5.1.1",
69
49
  "eslint-config-oclif-typescript": "^3.1.4",
70
50
  "eslint-config-prettier": "^9.1.0",
71
- "fancy-test": "^3.0.14",
72
- "globby": "^11.1.0",
73
- "husky": "^8",
74
- "lint-staged": "^14.0.1",
51
+ "husky": "^9",
52
+ "lint-staged": "^15",
75
53
  "madge": "^6.1.0",
76
54
  "mocha": "^10.4.0",
77
55
  "nyc": "^15.1.0",
78
56
  "prettier": "^3.2.5",
79
57
  "shx": "^0.3.4",
80
- "sinon": "^16.1.3",
58
+ "sinon": "^17",
81
59
  "ts-node": "^10.9.2",
82
60
  "tsd": "^0.31.0",
83
61
  "typescript": "^5"
@@ -122,7 +100,7 @@
122
100
  "lint": "eslint . --ext .ts",
123
101
  "posttest": "yarn lint && yarn test:circular-deps",
124
102
  "prepack": "yarn run build",
125
- "prepare": "husky install",
103
+ "prepare": "husky",
126
104
  "pretest": "yarn build && tsc -p test --noEmit --skipLibCheck",
127
105
  "test:circular-deps": "madge lib/ -c",
128
106
  "test:debug": "nyc mocha --debug-brk --inspect \"test/**/*.test.ts\"",
@@ -1,251 +0,0 @@
1
- declare const _default: {
2
- arc: {
3
- frames: string[];
4
- interval: number;
5
- };
6
- arrow: {
7
- frames: string[];
8
- interval: number;
9
- };
10
- arrow2: {
11
- frames: string[];
12
- interval: number;
13
- };
14
- arrow3: {
15
- frames: string[];
16
- interval: number;
17
- };
18
- balloon: {
19
- frames: string[];
20
- interval: number;
21
- };
22
- balloon2: {
23
- frames: string[];
24
- interval: number;
25
- };
26
- bounce: {
27
- frames: string[];
28
- interval: number;
29
- };
30
- bouncingBall: {
31
- frames: string[];
32
- interval: number;
33
- };
34
- bouncingBar: {
35
- frames: string[];
36
- interval: number;
37
- };
38
- boxBounce: {
39
- frames: string[];
40
- interval: number;
41
- };
42
- boxBounce2: {
43
- frames: string[];
44
- interval: number;
45
- };
46
- circle: {
47
- frames: string[];
48
- interval: number;
49
- };
50
- circleHalves: {
51
- frames: string[];
52
- interval: number;
53
- };
54
- circleQuarters: {
55
- frames: string[];
56
- interval: number;
57
- };
58
- clock: {
59
- frames: string[];
60
- interval: number;
61
- };
62
- dots: {
63
- frames: string[];
64
- interval: number;
65
- };
66
- dots2: {
67
- frames: string[];
68
- interval: number;
69
- };
70
- dots3: {
71
- frames: string[];
72
- interval: number;
73
- };
74
- dots4: {
75
- frames: string[];
76
- interval: number;
77
- };
78
- dots5: {
79
- frames: string[];
80
- interval: number;
81
- };
82
- dots6: {
83
- frames: string[];
84
- interval: number;
85
- };
86
- dots7: {
87
- frames: string[];
88
- interval: number;
89
- };
90
- dots8: {
91
- frames: string[];
92
- interval: number;
93
- };
94
- dots9: {
95
- frames: string[];
96
- interval: number;
97
- };
98
- dots10: {
99
- frames: string[];
100
- interval: number;
101
- };
102
- dots11: {
103
- frames: string[];
104
- interval: number;
105
- };
106
- earth: {
107
- frames: string[];
108
- interval: number;
109
- };
110
- flip: {
111
- frames: string[];
112
- interval: number;
113
- };
114
- growHorizontal: {
115
- frames: string[];
116
- interval: number;
117
- };
118
- growVertical: {
119
- frames: string[];
120
- interval: number;
121
- };
122
- hamburger: {
123
- frames: string[];
124
- interval: number;
125
- };
126
- hearts: {
127
- frames: string[];
128
- interval: number;
129
- };
130
- hexagon: {
131
- frames: string[];
132
- interval: number;
133
- };
134
- line: {
135
- frames: string[];
136
- interval: number;
137
- };
138
- line2: {
139
- frames: string[];
140
- interval: number;
141
- };
142
- monkey: {
143
- frames: string[];
144
- interval: number;
145
- };
146
- moon: {
147
- frames: string[];
148
- interval: number;
149
- };
150
- noise: {
151
- frames: string[];
152
- interval: number;
153
- };
154
- pipe: {
155
- frames: string[];
156
- interval: number;
157
- };
158
- pong: {
159
- frames: string[];
160
- interval: number;
161
- };
162
- runner: {
163
- frames: string[];
164
- interval: number;
165
- };
166
- simpleDots: {
167
- frames: string[];
168
- interval: number;
169
- };
170
- simpleDotsScrolling: {
171
- frames: string[];
172
- interval: number;
173
- };
174
- smiley: {
175
- frames: string[];
176
- interval: number;
177
- };
178
- squareCorners: {
179
- frames: string[];
180
- interval: number;
181
- };
182
- squish: {
183
- frames: string[];
184
- interval: number;
185
- };
186
- star: {
187
- frames: string[];
188
- interval: number;
189
- };
190
- star2: {
191
- frames: string[];
192
- interval: number;
193
- };
194
- toggle: {
195
- frames: string[];
196
- interval: number;
197
- };
198
- toggle2: {
199
- frames: string[];
200
- interval: number;
201
- };
202
- toggle3: {
203
- frames: string[];
204
- interval: number;
205
- };
206
- toggle4: {
207
- frames: string[];
208
- interval: number;
209
- };
210
- toggle5: {
211
- frames: string[];
212
- interval: number;
213
- };
214
- toggle6: {
215
- frames: string[];
216
- interval: number;
217
- };
218
- toggle7: {
219
- frames: string[];
220
- interval: number;
221
- };
222
- toggle8: {
223
- frames: string[];
224
- interval: number;
225
- };
226
- toggle9: {
227
- frames: string[];
228
- interval: number;
229
- };
230
- toggle10: {
231
- frames: string[];
232
- interval: number;
233
- };
234
- toggle11: {
235
- frames: string[];
236
- interval: number;
237
- };
238
- toggle12: {
239
- frames: string[];
240
- interval: number;
241
- };
242
- toggle13: {
243
- frames: string[];
244
- interval: number;
245
- };
246
- triangle: {
247
- frames: string[];
248
- interval: number;
249
- };
250
- };
251
- export default _default;