@oclif/core 4.0.0-beta.9 → 4.0.0

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/command.d.ts CHANGED
@@ -15,6 +15,7 @@ export declare abstract class Command {
15
15
  static aliases: string[];
16
16
  /** An order-dependent object of arguments for the command */
17
17
  static args: ArgInput;
18
+ static baseFlags: FlagInput;
18
19
  /**
19
20
  * Emit deprecation warning when a command alias is used
20
21
  */
@@ -108,7 +109,7 @@ export declare abstract class Command {
108
109
  log(message?: string, ...args: any[]): void;
109
110
  protected logJson(json: unknown): void;
110
111
  logToStderr(message?: string, ...args: any[]): void;
111
- protected parse<F extends FlagOutput, A extends ArgOutput>(options?: Input<F, A>, argv?: string[]): Promise<ParserOutput<F, A>>;
112
+ protected parse<F extends FlagOutput, B extends FlagOutput, A extends ArgOutput>(options?: Input<F, B, A>, argv?: string[]): Promise<ParserOutput<F, A>>;
112
113
  protected toErrorJson(err: unknown): any;
113
114
  protected toSuccessJson(result: unknown): any;
114
115
  warn(input: Error | string): Error | string;
package/lib/command.js CHANGED
@@ -61,6 +61,7 @@ class Command {
61
61
  static aliases = [];
62
62
  /** An order-dependent object of arguments for the command */
63
63
  static args = {};
64
+ static baseFlags;
64
65
  /**
65
66
  * Emit deprecation warning when a command alias is used
66
67
  */
@@ -231,7 +232,7 @@ class Command {
231
232
  const opts = {
232
233
  context: this,
233
234
  ...options,
234
- flags: (0, aggregate_flags_1.aggregateFlags)(options.flags, options.enableJsonFlag),
235
+ flags: (0, aggregate_flags_1.aggregateFlags)(options.flags, options.baseFlags, options.enableJsonFlag),
235
236
  };
236
237
  const hookResult = await this.config.runHook('preparse', { argv: [...argv], options: opts });
237
238
  // Since config.runHook will only run the hook for the root plugin, hookResult.successes will always have a length of 0 or 1
@@ -268,7 +269,7 @@ class Command {
268
269
  }
269
270
  }
270
271
  warnIfFlagDeprecated(flags) {
271
- const allFlags = (0, aggregate_flags_1.aggregateFlags)(this.ctor.flags, this.ctor.enableJsonFlag);
272
+ const allFlags = (0, aggregate_flags_1.aggregateFlags)(this.ctor.flags, this.ctor.baseFlags, this.ctor.enableJsonFlag);
272
273
  for (const flag of Object.keys(flags)) {
273
274
  const flagDef = allFlags[flag];
274
275
  const deprecated = flagDef?.deprecated;
@@ -78,6 +78,24 @@ async function loadTSConfig(root) {
78
78
  (0, warn_1.memoizedWarn)(`Could not parse tsconfig.json for ${root}. Falling back to compiled source.`);
79
79
  }
80
80
  }
81
+ async function registerTsx(root, moduleType) {
82
+ if (REGISTERED.has(root))
83
+ return;
84
+ try {
85
+ const apiPath = moduleType === 'module' ? 'tsx/esm/api' : 'tsx/cjs/api';
86
+ const tsxPath = require.resolve(apiPath, { paths: [root] });
87
+ if (!tsxPath)
88
+ return;
89
+ debug('registering tsx at', root);
90
+ debug('tsx path:', tsxPath);
91
+ const { register } = await import(tsxPath);
92
+ register();
93
+ REGISTERED.add(root);
94
+ }
95
+ catch {
96
+ debug(`Could not find tsx. Skipping tsx registration for ${root}.`);
97
+ }
98
+ }
81
99
  async function registerTSNode(root, tsconfig) {
82
100
  if (REGISTERED.has(root))
83
101
  return;
@@ -135,18 +153,20 @@ async function registerTSNode(root, tsconfig) {
135
153
  }
136
154
  /**
137
155
  * Skip ts-node registration for ESM plugins in production.
138
- * The node ecosystem is not mature enough to support auto-transpiling ESM modules at this time.
156
+ * The node/ts-node ecosystem is not mature enough to support auto-transpiling ESM modules at this time.
139
157
  * See the following:
140
158
  * - https://github.com/TypeStrong/ts-node/issues/1791#issuecomment-1149754228
141
159
  * - https://github.com/nodejs/node/issues/49432
142
160
  * - https://github.com/nodejs/node/pull/49407
143
161
  * - https://github.com/nodejs/node/issues/34049
144
162
  *
145
- * We still register ts-node for ESM plugins when NODE_ENV is "test" or "development" and root plugin is also ESM
163
+ * We still register tsx/ts-node for ESM plugins when NODE_ENV is "test" or "development" and root plugin is also ESM
146
164
  * since that allows plugins to be auto-transpiled when developing locally using `bin/dev.js`.
147
165
  */
148
166
  function cannotTranspileEsm(rootPlugin, plugin, isProduction) {
149
- return (isProduction || rootPlugin?.moduleType === 'commonjs') && plugin?.moduleType === 'module';
167
+ return ((isProduction || rootPlugin?.moduleType === 'commonjs') &&
168
+ plugin?.moduleType === 'module' &&
169
+ !plugin?.pjson.devDependencies?.tsx);
150
170
  }
151
171
  /**
152
172
  * If the dev script is run with ts-node for an ESM plugin, skip ts-node registration
@@ -166,15 +186,18 @@ function cannotUseTsNode(root, plugin, isProduction) {
166
186
  /**
167
187
  * Determine the path to the source file from the compiled ./lib files
168
188
  */
169
- async function determinePath(root, orig) {
189
+ async function determinePath(root, orig, plugin) {
170
190
  const tsconfig = await loadTSConfig(root);
171
191
  if (!tsconfig)
172
192
  return orig;
173
193
  debug(`Determining path for ${orig}`);
174
- if (RUN_TIME === 'tsx' || RUN_TIME === 'bun') {
194
+ if (RUN_TIME === 'bun') {
175
195
  debug(`Skipping ts-node registration for ${root} because the runtime is: ${RUN_TIME}`);
176
196
  }
177
197
  else {
198
+ // attempt to register tsx first. If it fails to register, we will fall back to ts-node
199
+ await registerTsx(root, plugin?.moduleType);
200
+ // if tsx registration succeeded, then this will exit early since the path will be in REGISTERED already
178
201
  await registerTSNode(root, tsconfig);
179
202
  }
180
203
  const { baseUrl, outDir, rootDir, rootDirs } = tsconfig.compilerOptions;
@@ -251,7 +274,7 @@ async function tsPath(root, orig, plugin) {
251
274
  return orig;
252
275
  }
253
276
  try {
254
- return await determinePath(root, orig);
277
+ return await determinePath(root, orig, plugin);
255
278
  }
256
279
  catch (error) {
257
280
  debug(error);
@@ -153,12 +153,7 @@ class CommandHelp extends formatter_1.HelpFormatter {
153
153
  label = labels.join(flag.char ? (0, theme_1.colorize)(this.config?.theme?.flagSeparator, ', ') : ' ');
154
154
  }
155
155
  if (flag.type === 'option') {
156
- let value = flag.helpValue || (this.opts.showFlagNameInTitle ? flag.name : '<value>');
157
- if (!flag.helpValue && flag.options) {
158
- value = showOptions || this.opts.showFlagOptionsInTitle ? `${flag.options.join('|')}` : '<option>';
159
- }
160
- if (flag.multiple)
161
- value += '...';
156
+ let value = docopts_1.DocOpts.formatUsageType(flag, this.opts.showFlagNameInTitle ?? false, this.opts.showFlagOptionsInTitle ?? showOptions);
162
157
  if (!value.includes('|'))
163
158
  value = ansis_1.default.underline(value);
164
159
  label += `=${value}`;
@@ -304,7 +299,11 @@ class CommandHelp extends formatter_1.HelpFormatter {
304
299
  const dollarSign = (0, theme_1.colorize)(this.config?.theme?.dollarSign, '$');
305
300
  const bin = (0, theme_1.colorize)(this.config?.theme?.bin, this.config.bin);
306
301
  const command = (0, theme_1.colorize)(this.config?.theme?.command, '<%= command.id %>');
307
- const commandDescription = (0, theme_1.colorize)(this.config?.theme?.sectionDescription, u.replace('<%= command.id %>', '').replace(standardId, '').replace(configuredId, '').trim());
302
+ const commandDescription = (0, theme_1.colorize)(this.config?.theme?.sectionDescription, u
303
+ .replace('<%= command.id %>', '')
304
+ .replace(new RegExp(`^${standardId}`), '')
305
+ .replace(new RegExp(`^${configuredId}`), '')
306
+ .trim());
308
307
  const line = `${dollarSign} ${bin} ${command} ${commandDescription}`.trim();
309
308
  if (line.length > allowedSpacing) {
310
309
  const splitIndex = line.slice(0, Math.max(0, allowedSpacing)).lastIndexOf(' ');
@@ -60,6 +60,7 @@ export declare class DocOpts {
60
60
  private flagList;
61
61
  private flagMap;
62
62
  constructor(cmd: Command.Loadable);
63
+ static formatUsageType(flag: Command.Flag.Any, showFlagName: boolean, showOptions: boolean): string;
63
64
  static generate(cmd: Command.Loadable): string;
64
65
  toString(): string;
65
66
  private combineElementsToFlag;
@@ -73,6 +73,27 @@ class DocOpts {
73
73
  return flag;
74
74
  });
75
75
  }
76
+ static formatUsageType(flag, showFlagName, showOptions) {
77
+ if (flag.type !== 'option')
78
+ return '';
79
+ let helpValues;
80
+ if (flag.helpValue) {
81
+ // if there is a given helpValue, use it
82
+ helpValues = typeof flag.helpValue === 'string' ? [flag.helpValue] : flag.helpValue;
83
+ }
84
+ else if (flag.options) {
85
+ // if there are options, show them if wanted
86
+ helpValues = [showOptions ? flag.options.join('|') : '<option>'];
87
+ }
88
+ else if (showFlagName) {
89
+ helpValues = [flag.name];
90
+ }
91
+ else {
92
+ // default to <value>
93
+ helpValues = ['<value>'];
94
+ }
95
+ return helpValues.map((v) => `${v}${flag.multiple ? '...' : ''}`).join(' ');
96
+ }
76
97
  static generate(cmd) {
77
98
  return new DocOpts(cmd).toString();
78
99
  }
@@ -93,7 +114,7 @@ class DocOpts {
93
114
  const name = flag.char ? `-${flag.char}` : `--${flag.name}`;
94
115
  if (flag.type === 'boolean')
95
116
  return name;
96
- return `${name}=<value>`;
117
+ return `${name}=${DocOpts.formatUsageType(flag, false, true)}`;
97
118
  }));
98
119
  }
99
120
  return opts.join(' ');
@@ -123,7 +144,7 @@ class DocOpts {
123
144
  // not all flags have short names
124
145
  const flagName = flag.char ? `-${flag.char}` : `--${flag.name}`;
125
146
  if (flag.type === 'option') {
126
- type = flag.options ? ` ${flag.options.join('|')}` : ' <value>';
147
+ type = ` ${DocOpts.formatUsageType(flag, false, true)}`;
127
148
  }
128
149
  const element = `${flagName}${type}`;
129
150
  elementMap[flag.name] = element;
@@ -3,7 +3,7 @@ import { FlagInput } from './parser';
3
3
  * Infer the flags that are returned by Command.parse. This is useful for when you want to assign the flags as a class property.
4
4
  *
5
5
  * @example
6
- * export type StatusFlags = Interfaces.InferredFlags<typeof Status.flags>
6
+ * export type StatusFlags = Interfaces.InferredFlags<typeof Status.flags && typeof Status.baseFlags>
7
7
  *
8
8
  * export abstract class BaseCommand extends Command {
9
9
  * static enableJsonFlag = true
@@ -17,7 +17,6 @@ import { FlagInput } from './parser';
17
17
  *
18
18
  * export default class Status extends BaseCommand {
19
19
  * static flags = {
20
- * ...BaseCommand.flags,
21
20
  * force: Flags.boolean({char: 'f', description: 'a flag'}),
22
21
  * }
23
22
  *
@@ -74,7 +74,7 @@ export interface Hooks {
74
74
  preparse: {
75
75
  options: {
76
76
  argv: string[];
77
- options: Input<OutputFlags<any>, OutputFlags<any>>;
77
+ options: Input<OutputFlags<any>, OutputFlags<any>, OutputFlags<any>>;
78
78
  };
79
79
  return: string[];
80
80
  };
@@ -8,7 +8,7 @@ export type { Hook, Hooks } from './hooks';
8
8
  export type { Logger } from './logger';
9
9
  export type { Manifest } from './manifest';
10
10
  export type { Arg, BooleanFlag, CustomOptions, Deprecation, Flag, FlagDefinition, OptionFlag } from './parser';
11
- export type { OclifConfiguration, PJSON, S3, S3Templates, UserPJSON } from './pjson';
11
+ export type { LinkedPlugin, OclifConfiguration, PJSON, S3, S3Templates, UserPJSON, UserPlugin } from './pjson';
12
12
  export type { Options, Plugin, PluginOptions } from './plugin';
13
13
  export type { S3Manifest } from './s3-manifest';
14
14
  export type { Theme } from './theme';
@@ -198,7 +198,7 @@ export type BooleanFlagProps = FlagProps & {
198
198
  };
199
199
  export type OptionFlagProps = FlagProps & {
200
200
  type: 'option';
201
- helpValue?: string;
201
+ helpValue?: string | string[];
202
202
  options?: readonly string[];
203
203
  multiple?: boolean;
204
204
  /**
@@ -426,8 +426,9 @@ export type FlagDefinition<T, P = CustomOptions, R extends ReturnTypeSwitches =
426
426
  }>>;
427
427
  };
428
428
  export type Flag<T> = BooleanFlag<T> | OptionFlag<T>;
429
- export type Input<TFlags extends FlagOutput, AFlags extends ArgOutput> = {
429
+ export type Input<TFlags extends FlagOutput, BFlags extends FlagOutput, AFlags extends ArgOutput> = {
430
430
  flags?: FlagInput<TFlags>;
431
+ baseFlags?: FlagInput<BFlags>;
431
432
  enableJsonFlag?: true | false;
432
433
  args?: ArgInput<AFlags>;
433
434
  strict?: boolean | undefined;
@@ -177,7 +177,7 @@ export type OclifConfiguration = {
177
177
  * Register hooks to run at various points in the CLI lifecycle.
178
178
  */
179
179
  hooks?: {
180
- [name: string]: string | string[] | HookOptions | HookOptions[];
180
+ [name: string]: string | string[] | HookOptions | HookOptions[] | (string | HookOptions)[];
181
181
  };
182
182
  /**
183
183
  * Plugins that can be installed just-in-time.
@@ -279,12 +279,9 @@ export type LinkedPlugin = {
279
279
  root: string;
280
280
  type: 'link';
281
281
  };
282
- export type PluginTypes = {
283
- root: string;
284
- } | UserPlugin | LinkedPlugin;
285
282
  export type UserPJSON = {
286
283
  oclif: {
287
- plugins?: PluginTypes[];
284
+ plugins?: (UserPlugin | LinkedPlugin)[];
288
285
  };
289
286
  private?: boolean;
290
287
  };
@@ -1,3 +1,3 @@
1
1
  import { Input, OutputArgs, OutputFlags, ParserOutput } from '../interfaces/parser';
2
2
  export { flagUsages } from './help';
3
- export declare function parse<TFlags extends OutputFlags<any>, TArgs extends OutputArgs<any>>(argv: string[], options: Input<TFlags, TArgs>): Promise<ParserOutput<TFlags, TArgs>>;
3
+ export declare function parse<TFlags extends OutputFlags<any>, BFlags extends OutputFlags<any>, TArgs extends OutputArgs<any>>(argv: string[], options: Input<TFlags, BFlags, TArgs>): Promise<ParserOutput<TFlags, BFlags, TArgs>>;
@@ -315,9 +315,7 @@ class Parser {
315
315
  .map(async (v) => parseFlagOrThrowError(v, i.inputFlag.flag, this.context, {
316
316
  ...(0, util_1.last)(i.tokens),
317
317
  input: v,
318
- }))))
319
- // eslint-disable-next-line unicorn/no-await-expression-member
320
- .map((v) => validateOptions(i.inputFlag.flag, v)),
318
+ })))).map((v) => validateOptions(i.inputFlag.flag, v)),
321
319
  };
322
320
  }
323
321
  // multiple in the oclif-core style
@@ -1,2 +1,2 @@
1
1
  import { FlagInput, FlagOutput } from '../interfaces/parser';
2
- export declare function aggregateFlags<F extends FlagOutput>(flags: FlagInput<F> | undefined, enableJsonFlag: boolean | undefined): FlagInput<F>;
2
+ export declare function aggregateFlags<F extends FlagOutput, B extends FlagOutput>(flags: FlagInput<F> | undefined, baseFlags: FlagInput<B> | undefined, enableJsonFlag: boolean | undefined): FlagInput<F>;
@@ -6,7 +6,8 @@ const json = (0, flags_1.boolean)({
6
6
  description: 'Format output as json.',
7
7
  helpGroup: 'GLOBAL',
8
8
  });
9
- function aggregateFlags(flags, enableJsonFlag) {
10
- return (enableJsonFlag ? { json, ...flags } : flags);
9
+ function aggregateFlags(flags, baseFlags, enableJsonFlag) {
10
+ const combinedFlags = { ...baseFlags, ...flags };
11
+ return (enableJsonFlag ? { json, ...combinedFlags } : combinedFlags);
11
12
  }
12
13
  exports.aggregateFlags = aggregateFlags;
@@ -6,7 +6,8 @@ const cache_default_value_1 = require("./cache-default-value");
6
6
  const ensure_arg_object_1 = require("./ensure-arg-object");
7
7
  const util_1 = require("./util");
8
8
  // In order to collect static properties up the inheritance chain, we need to recursively
9
- // access the prototypes until there's nothing left.
9
+ // access the prototypes until there's nothing left. This allows us to combine baseFlags
10
+ // and flags as well as add in the json flag if enableJsonFlag is enabled.
10
11
  function mergePrototype(result, cmd) {
11
12
  const proto = Object.getPrototypeOf(cmd);
12
13
  const filteredProto = (0, util_1.pickBy)(proto, (v) => v !== undefined);
@@ -70,10 +71,10 @@ async function cacheCommand(uncachedCmd, plugin, respectNoCacheDefault = false)
70
71
  const cmd = mergePrototype(uncachedCmd, uncachedCmd);
71
72
  // @ts-expect-error because v2 commands have flags stored in _flags
72
73
  const uncachedFlags = cmd.flags ?? cmd._flags;
73
- // @ts-expect-error because v2 commands have base flags stored in `_baseFlags` and v4 commands never have `baseFlags`
74
+ // @ts-expect-error because v2 commands have base flags stored in _baseFlags
74
75
  const uncachedBaseFlags = cmd.baseFlags ?? cmd._baseFlags;
75
76
  const [flags, args] = await Promise.all([
76
- await cacheFlags((0, aggregate_flags_1.aggregateFlags)({ ...uncachedFlags, ...uncachedBaseFlags }, cmd.enableJsonFlag), respectNoCacheDefault),
77
+ await cacheFlags((0, aggregate_flags_1.aggregateFlags)(uncachedFlags, uncachedBaseFlags, cmd.enableJsonFlag), respectNoCacheDefault),
77
78
  await cacheArgs((0, ensure_arg_object_1.ensureArgObject)(cmd.args), respectNoCacheDefault),
78
79
  ]);
79
80
  const stdProperties = {
package/lib/util/fs.js CHANGED
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.existsSync = exports.safeReadJson = exports.readJsonSync = exports.readJson = exports.fileExists = exports.dirExists = void 0;
4
4
  const node_fs_1 = require("node:fs");
5
5
  const promises_1 = require("node:fs/promises");
6
+ const util_1 = require("./util");
6
7
  /**
7
8
  * Parser for Args.directory and Flags.directory. Checks that the provided path
8
9
  * exists and is a directory.
@@ -43,7 +44,15 @@ const fileExists = async (input) => {
43
44
  return input;
44
45
  };
45
46
  exports.fileExists = fileExists;
46
- const cache = new Map();
47
+ class ProdOnlyCache extends Map {
48
+ set(key, value) {
49
+ if ((0, util_1.isProd)() ?? false) {
50
+ super.set(key, value);
51
+ }
52
+ return this;
53
+ }
54
+ }
55
+ const cache = new ProdOnlyCache();
47
56
  async function readJson(path) {
48
57
  if (cache.has(path)) {
49
58
  return JSON.parse(cache.get(path));
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
  */
@@ -0,0 +1 @@
1
+ export declare function supportsColor(): boolean;
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.supportsColor = void 0;
4
+ const supports_color_1 = require("supports-color");
5
+ function supportsColor() {
6
+ return Boolean(supports_color_1.stdout) && Boolean(supports_color_1.stderr);
7
+ }
8
+ exports.supportsColor = supportsColor;
package/lib/ux/theme.js CHANGED
@@ -6,7 +6,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.parseTheme = exports.colorize = void 0;
7
7
  const ansis_1 = __importDefault(require("ansis"));
8
8
  const theme_1 = require("../interfaces/theme");
9
- function isStandardChalk(color) {
9
+ const supports_color_1 = require("./supports-color");
10
+ function isStandardAnsi(color) {
10
11
  return theme_1.STANDARD_ANSI.includes(color);
11
12
  }
12
13
  /**
@@ -18,7 +19,9 @@ function isStandardChalk(color) {
18
19
  function colorize(color, text) {
19
20
  if (!color)
20
21
  return text;
21
- if (isStandardChalk(color))
22
+ if (!(0, supports_color_1.supportsColor)())
23
+ return text;
24
+ if (isStandardAnsi(color))
22
25
  return ansis_1.default[color](text);
23
26
  if (color.startsWith('#'))
24
27
  return ansis_1.default.hex(color)(text);
@@ -39,5 +42,5 @@ function parseTheme(theme) {
39
42
  }
40
43
  exports.parseTheme = parseTheme;
41
44
  function isValid(color) {
42
- return color.startsWith('#') || color.startsWith('rgb') || isStandardChalk(color) ? color : undefined;
45
+ return color.startsWith('#') || color.startsWith('rgb') || isStandardAnsi(color) ? color : undefined;
43
46
  }
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,16 +1,16 @@
1
1
  {
2
2
  "name": "@oclif/core",
3
3
  "description": "base library for oclif CLIs",
4
- "version": "4.0.0-beta.9",
4
+ "version": "4.0.0",
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",
13
- "debug": "^4.3.4",
13
+ "debug": "^4.3.5",
14
14
  "ejs": "^3.1.10",
15
15
  "get-package-type": "^0.1.0",
16
16
  "globby": "^11.1.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,11 +40,12 @@
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",
46
47
  "chai": "^4.4.1",
47
- "chai-as-promised": "^7.1.1",
48
+ "chai-as-promised": "^7.1.2",
48
49
  "commitlint": "^19",
49
50
  "cross-env": "^7.0.3",
50
51
  "eslint": "^8.57.0",