Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@oclif/core

Package Overview
Dependencies
Maintainers
7
Versions
406
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@oclif/core - npm Package Compare versions

Comparing version 0.5.39 to 0.5.40

7

CHANGELOG.md

@@ -5,2 +5,9 @@ # Changelog

### [0.5.40](https://github.com/oclif/core/compare/v0.5.39...v0.5.40) (2021-09-27)
### Bug Fixes
* adjust help text to new style guide ([#259](https://github.com/oclif/core/issues/259)) ([28d9d78](https://github.com/oclif/core/commit/28d9d78f5118886632a200e51cb34f7896210304))
### [0.5.39](https://github.com/oclif/core/compare/v0.5.38...v0.5.39) (2021-09-17)

@@ -7,0 +14,0 @@

13

lib/command.d.ts

@@ -0,1 +1,2 @@

import { Config } from './config';
import * as Interfaces from './interfaces';

@@ -9,3 +10,3 @@ import { PrettyPrintableError } from './errors';

argv: string[];
config: Interfaces.Config;
config: Config;
static _base: string;

@@ -73,6 +74,6 @@ /** A command ID, used mostly in error or verbose reporting. */

protected debug: (...args: any[]) => void;
constructor(argv: string[], config: Interfaces.Config);
constructor(argv: string[], config: Config);
get ctor(): typeof Command;
_run<T>(): Promise<T | undefined>;
exit(code?: number): never;
exit(code?: number): void;
warn(input: string | Error): void;

@@ -97,6 +98,6 @@ error(input: string | Error, options: {

}>(options?: Interfaces.Input<F>, argv?: string[]): Promise<Interfaces.ParserOutput<F, A>>;
protected catch(err: any): Promise<any>;
protected catch(err: Record<string, any>): Promise<any>;
protected finally(_: Error | undefined): Promise<any>;
protected toSuccessJson(result: any): any;
protected toErrorJson(err: any): any;
protected toSuccessJson(result: unknown): any;
protected toErrorJson(err: unknown): any;
}

@@ -33,3 +33,3 @@ "use strict";

}
catch (_a) {
catch {
this.debug = () => { };

@@ -80,4 +80,4 @@ }

// tslint:disable-next-line strict-type-predicates
message = typeof message === 'string' ? message : util_1.inspect(message);
process.stdout.write(util_1.format(message, ...args) + '\n');
message = typeof message === 'string' ? message : (0, util_1.inspect)(message);
process.stdout.write((0, util_1.format)(message, ...args) + '\n');
}

@@ -105,3 +105,3 @@ }

options = this.constructor;
const opts = Object.assign({ context: this }, options);
const opts = { context: this, ...options };
// the spread operator doesn't work with getters so we have to manually add it here

@@ -122,6 +122,6 @@ opts.flags = options === null || options === void 0 ? void 0 : options.flags;

const { cli } = require('cli-ux');
const chalk = require('chalk'); // eslint-disable-line node/no-extraneous-require
const chalk = require('chalk');
cli.action.stop(chalk.bold.red('!'));
}
catch (_c) { }
catch { }
throw err;

@@ -169,4 +169,5 @@ }

if (typeof opts === 'string' && opts.startsWith('file://')) {
opts = url_1.fileURLToPath(opts);
opts = (0, url_1.fileURLToPath)(opts);
}
// to-do: update in node-14 to module.main
const config = await config_1.Config.load(opts || (module.parent && module.parent.parent && module.parent.parent.filename) || __dirname);

@@ -173,0 +174,0 @@ const cmd = new this(argv, config);

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.toCached = exports.Config = void 0;
const errors_1 = require("../errors");

@@ -15,3 +16,3 @@ const Lodash = require("lodash");

// eslint-disable-next-line new-cap
const debug = util_2.Debug();
const debug = (0, util_2.Debug)();
const _pjson = require('../../package.json');

@@ -39,3 +40,3 @@ function channelFromVersion(version) {

if (typeof opts === 'string' && opts.startsWith('file://')) {
opts = url_1.fileURLToPath(opts);
opts = (0, url_1.fileURLToPath)(opts);
}

@@ -88,3 +89,19 @@ if (typeof opts === 'string')

s3.host = `https://${s3.bucket}.s3.amazonaws.com`;
s3.templates = Object.assign(Object.assign({}, s3.templates), { target: Object.assign({ baseDir: '<%- bin %>', unversioned: "<%- channel === 'stable' ? '' : 'channels/' + channel + '/' %><%- bin %>-<%- platform %>-<%- arch %><%- ext %>", versioned: "<%- channel === 'stable' ? '' : 'channels/' + channel + '/' %><%- bin %>-v<%- version %>/<%- bin %>-v<%- version %>-<%- platform %>-<%- arch %><%- ext %>", manifest: "<%- channel === 'stable' ? '' : 'channels/' + channel + '/' %><%- platform %>-<%- arch %>" }, s3.templates && s3.templates.target), vanilla: Object.assign({ unversioned: "<%- channel === 'stable' ? '' : 'channels/' + channel + '/' %><%- bin %><%- ext %>", versioned: "<%- channel === 'stable' ? '' : 'channels/' + channel + '/' %><%- bin %>-v<%- version %>/<%- bin %>-v<%- version %><%- ext %>", baseDir: '<%- bin %>', manifest: "<%- channel === 'stable' ? '' : 'channels/' + channel + '/' %>version" }, s3.templates && s3.templates.vanilla) });
s3.templates = {
...s3.templates,
target: {
baseDir: '<%- bin %>',
unversioned: "<%- channel === 'stable' ? '' : 'channels/' + channel + '/' %><%- bin %>-<%- platform %>-<%- arch %><%- ext %>",
versioned: "<%- channel === 'stable' ? '' : 'channels/' + channel + '/' %><%- bin %>-v<%- version %>/<%- bin %>-v<%- version %>-<%- platform %>-<%- arch %><%- ext %>",
manifest: "<%- channel === 'stable' ? '' : 'channels/' + channel + '/' %><%- platform %>-<%- arch %>",
...s3.templates && s3.templates.target,
},
vanilla: {
unversioned: "<%- channel === 'stable' ? '' : 'channels/' + channel + '/' %><%- bin %><%- ext %>",
versioned: "<%- channel === 'stable' ? '' : 'channels/' + channel + '/' %><%- bin %>-v<%- version %>/<%- bin %>-v<%- version %><%- ext %>",
baseDir: '<%- bin %>',
manifest: "<%- channel === 'stable' ? '' : 'channels/' + channel + '/' %>version",
...s3.templates && s3.templates.vanilla,
},
};
await this.loadUserPlugins();

@@ -118,3 +135,3 @@ await this.loadDevPlugins();

debug('reading user plugins pjson %s', userPJSONPath);
const pjson = await util_3.loadJSON(userPJSONPath);
const pjson = await (0, util_3.loadJSON)(userPJSONPath);
this.userPJSON = pjson;

@@ -165,12 +182,12 @@ if (!pjson.oclif)

exit(code = 0) {
errors_1.exit(code);
(0, errors_1.exit)(code);
},
log(message, ...args) {
process.stdout.write(util_1.format(message, ...args) + '\n');
process.stdout.write((0, util_1.format)(message, ...args) + '\n');
},
error(message, options = {}) {
errors_1.error(message, options);
(0, errors_1.error)(message, options);
},
warn(message) {
errors_1.warn(message);
(0, errors_1.warn)(message);
},

@@ -185,4 +202,4 @@ };

const result = timeout ?
await withTimeout(timeout, search(module).call(context, Object.assign(Object.assign({}, opts), { config: this }))) :
await search(module).call(context, Object.assign(Object.assign({}, opts), { config: this }));
await withTimeout(timeout, search(module).call(context, { ...opts, config: this })) :
await search(module).call(context, { ...opts, config: this });
final.successes.push({ plugin: p, result });

@@ -201,2 +218,3 @@ debug('done');

}
// eslint-disable-next-line default-param-last
async runCommand(id, argv = [], cachedCommand) {

@@ -224,4 +242,3 @@ debug('runCommand %s %o', id, argv);

return [this.bin, k]
// eslint-disable-next-line no-useless-escape
.map(p => p.replace(/@/g, '').replace(/[-\/]/g, '_'))
.map(p => p.replace(/@/g, '').replace(/[/-]/g, '_'))
.join('_')

@@ -253,3 +270,3 @@ .toUpperCase();

if (opts.must && commands.length === 0)
errors_1.error(`command ${id} not found`);
(0, errors_1.error)(`command ${id} not found`);
if (commands.length === 1)

@@ -293,3 +310,3 @@ return commands[0];

return this._commands;
this._commands = util_3.flatMap(this.plugins, p => p.commands);
this._commands = (0, util_3.flatMap)(this.plugins, p => p.commands);
return this._commands;

@@ -301,3 +318,3 @@ }

const ids = Lodash.flattenDeep(this.commands.map(c => [c.id, c.aliases]));
this._commandIDs = util_3.uniq(ids);
this._commandIDs = (0, util_3.uniq)(ids);
return this._commandIDs;

@@ -310,3 +327,3 @@ }

for (const plugin of this.plugins) {
for (const topic of util_3.compact(plugin.topics)) {
for (const topic of (0, util_3.compact)(plugin.topics)) {
const existing = topics.find(t => t.name === topic.name);

@@ -324,3 +341,3 @@ if (existing) {

const parts = c.id.split(':');
while (parts.length) {
while (parts.length > 0) {
const name = parts.join(':');

@@ -342,3 +359,3 @@ if (name && !topics.find(t => t.name === name)) {

const _ = require('lodash');
return _.template(this.pjson.oclif.update.s3.templates[options.platform ? 'target' : 'vanilla'][type])(Object.assign(Object.assign({}, this), options));
return _.template(this.pjson.oclif.update.s3.templates[options.platform ? 'target' : 'vanilla'][type])({ ...this, ...options });
}

@@ -393,4 +410,3 @@ s3Url(key) {

}
catch (_a) {
}
catch { }
return 0;

@@ -419,3 +435,2 @@ }

if (parent) {
// eslint-disable-next-line require-atomic-updates
instance.parent = parent;

@@ -443,3 +458,3 @@ if (!parent.children)

modifiedErr.name = `${err.name} Plugin: ${this.name}`;
modifiedErr.detail = util_3.compact([
modifiedErr.detail = (0, util_3.compact)([
err.detail,

@@ -458,3 +473,3 @@ `module: ${this._base}`,

err.name = `${err.name} Plugin: ${this.name}`;
err.detail = util_3.compact([
err.detail = (0, util_3.compact)([
err.detail,

@@ -470,3 +485,3 @@ `module: ${this._base}`,

get isProd() {
return util_4.isProd();
return (0, util_4.isProd)();
}

@@ -510,3 +525,2 @@ }

exclusive: flag.exclusive,
// eslint-disable-next-line no-await-in-loop
default: typeof flag.default === 'function' ? await flag.default({ options: {}, flags: {} }) : flag.default,

@@ -546,7 +560,7 @@ };

const additionalProperties = {};
keysToAdd.forEach(key => {
for (const key of keysToAdd) {
additionalProperties[key] = c[key];
});
return Object.assign(Object.assign({}, stdProperties), additionalProperties);
}
return { ...stdProperties, ...additionalProperties };
}
exports.toCached = toCached;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.tsPath = exports.Plugin = exports.toCached = exports.Config = void 0;
try {

@@ -7,9 +8,9 @@ // eslint-disable-next-line node/no-missing-require

}
catch (_a) { }
catch { }
var config_1 = require("./config");
exports.Config = config_1.Config;
exports.toCached = config_1.toCached;
Object.defineProperty(exports, "Config", { enumerable: true, get: function () { return config_1.Config; } });
Object.defineProperty(exports, "toCached", { enumerable: true, get: function () { return config_1.toCached; } });
var plugin_1 = require("./plugin");
exports.Plugin = plugin_1.Plugin;
Object.defineProperty(exports, "Plugin", { enumerable: true, get: function () { return plugin_1.Plugin; } });
var ts_node_1 = require("./ts-node");
exports.tsPath = ts_node_1.tsPath;
Object.defineProperty(exports, "tsPath", { enumerable: true, get: function () { return ts_node_1.tsPath; } });
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Plugin = void 0;
const errors_1 = require("../errors");

@@ -18,7 +19,7 @@ const path = require("path");

if (Array.isArray(input)) {
return input.concat(util_3.flatMap(input, t => topicsToArray(t.subtopics, `${base}${t.name}`)));
return input.concat((0, util_3.flatMap)(input, t => topicsToArray(t.subtopics, `${base}${t.name}`)));
}
return util_3.flatMap(Object.keys(input), k => {
return (0, util_3.flatMap)(Object.keys(input), k => {
input[k].name = k;
return [Object.assign(Object.assign({}, input[k]), { name: `${base}${k}` })].concat(topicsToArray(input[k].subtopics, `${base}${input[k].name}`));
return [{ ...input[k], name: `${base}${k}` }].concat(topicsToArray(input[k].subtopics, `${base}${input[k].name}`));
});

@@ -48,11 +49,11 @@ }

// eslint-disable-next-line no-await-in-loop
if (await util_3.exists(cur))
if (await (0, util_3.exists)(cur))
return path.dirname(cur);
try {
// eslint-disable-next-line no-await-in-loop
const pkg = await util_3.loadJSON(path.join(next, 'package.json'));
const pkg = await (0, util_3.loadJSON)(path.join(next, 'package.json'));
if (pkg.name === name)
return next;
}
catch (_a) { }
catch { }
}

@@ -62,3 +63,3 @@ else {

// eslint-disable-next-line no-await-in-loop
if (await util_3.exists(cur))
if (await (0, util_3.exists)(cur))
return path.dirname(cur);

@@ -78,3 +79,3 @@ }

// eslint-disable-next-line new-cap
this._debug = util_2.Debug();
this._debug = (0, util_2.Debug)();
this.warned = false;

@@ -88,6 +89,6 @@ }

if (!root)
throw new Error(`could not find package.json with ${util_1.inspect(this.options)}`);
throw new Error(`could not find package.json with ${(0, util_1.inspect)(this.options)}`);
this.root = root;
this._debug('reading %s plugin %s', this.type, root);
this.pjson = await util_3.loadJSON(path.join(root, 'package.json'));
this.pjson = await (0, util_3.loadJSON)(path.join(root, 'package.json'));
this.name = this.pjson.name;

@@ -98,6 +99,6 @@ this.alias = (_a = this.options.name) !== null && _a !== void 0 ? _a : this.pjson.name;

throw new Error(`no name in ${pjsonPath}`);
if (!util_4.isProd() && !this.pjson.files)
if (!(0, util_4.isProd)() && !this.pjson.files)
this.warn(`files attribute must be specified in ${pjsonPath}`);
// eslint-disable-next-line new-cap
this._debug = util_2.Debug(this.name);
this._debug = (0, util_2.Debug)(this.name);
this.version = this.pjson.version;

@@ -110,13 +111,7 @@ if (this.pjson.oclif) {

}
this.hooks = util_3.mapValues(this.pjson.oclif.hooks || {}, i => Array.isArray(i) ? i : [i]);
this.hooks = (0, util_3.mapValues)(this.pjson.oclif.hooks || {}, i => Array.isArray(i) ? i : [i]);
this.manifest = await this._manifest(Boolean(this.options.ignoreManifest), Boolean(this.options.errorOnManifestCreate));
this.commands = Object.entries(this.manifest.commands)
.map(([id, c]) => (Object.assign(Object.assign({}, c), { pluginAlias: this.alias, pluginType: this.type, load: async () => this.findCommand(id, { must: true }) })));
this.commands.sort((a, b) => {
if (a.id < b.id)
return -1;
if (a.id > b.id)
return 1;
return 0;
});
.map(([id, c]) => ({ ...c, pluginAlias: this.alias, pluginType: this.type, load: async () => this.findCommand(id, { must: true }) }));
this.commands.sort((a, b) => a.id.localeCompare(b.id));
}

@@ -127,3 +122,3 @@ get topics() {

get commandsDir() {
return ts_node_1.tsPath(this.root, this.pjson.oclif.commands);
return (0, ts_node_1.tsPath)(this.root, this.pjson.oclif.commands);
}

@@ -189,3 +184,3 @@ get commandIDs() {

if (!cmd && opts.must)
errors_1.error(`command ${id} not found`);
(0, errors_1.error)(`command ${id} not found`);
return cmd;

@@ -197,3 +192,3 @@ }

const p = path.join(this.root, `${dotfile ? '.' : ''}oclif.manifest.json`);
const manifest = await util_3.loadJSON(p);
const manifest = await (0, util_3.loadJSON)(p);
if (!process.env.OCLIF_NEXT_VERSION && manifest.version.split('-')[0] !== this.version.split('-')[0]) {

@@ -224,6 +219,5 @@ process.emitWarning(`Mismatched version in ${this.name} plugin manifest. Expected: ${this.version} Received: ${manifest.version}\nThis usually means you have an oclif.manifest.json file that should be deleted in development. This file should be automatically generated when publishing.`);

version: this.version,
// eslint-disable-next-line array-callback-return
commands: (await Promise.all(this.commandIDs.map(async (id) => {
try {
return [id, await config_1.toCached(await this.findCommand(id, { must: true }), this)];
return [id, await (0, config_1.toCached)(await this.findCommand(id, { must: true }), this)];
}

@@ -254,3 +248,3 @@ catch (error) {

err.name = `${err.name} Plugin: ${this.name}`;
err.detail = util_3.compact([err.detail, `module: ${this._base}`, scope && `task: ${scope}`, `plugin: ${this.name}`, `root: ${this.root}`, 'See more details with DEBUG=*']).join('\n');
err.detail = (0, util_3.compact)([err.detail, `module: ${this._base}`, scope && `task: ${scope}`, `plugin: ${this.name}`, `root: ${this.root}`, 'See more details with DEBUG=*']).join('\n');
return err;

@@ -257,0 +251,0 @@ }

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.tsPath = void 0;
const fs = require("fs");

@@ -9,3 +10,3 @@ const path = require("path");

// eslint-disable-next-line new-cap
const debug = util_2.Debug('ts-node');
const debug = (0, util_2.Debug)('ts-node');
function loadTSConfig(root) {

@@ -17,7 +18,7 @@ const tsconfigPath = path.join(root, 'tsconfig.json');

}
catch (_a) {
catch {
try {
typescript = require(root + '/node_modules/typescript');
}
catch (_b) { }
catch { }
}

@@ -41,3 +42,3 @@ if (fs.existsSync(tsconfigPath) && typescript) {

// the CLI didn't specify ts-node and it is production
(settings_1.settings.tsnodeEnabled === undefined && util_1.isProd());
(settings_1.settings.tsnodeEnabled === undefined && (0, util_1.isProd)());
if (skipTSNode)

@@ -44,0 +45,0 @@ return orig;

export declare function flatMap<T, U>(arr: T[], fn: (i: T) => U[]): U[];
export declare function mapValues<T extends object, TResult>(obj: {
export declare function mapValues<T extends Record<string, any>, TResult>(obj: {
[P in keyof T]: T[P];

@@ -4,0 +4,0 @@ }, fn: (i: T[keyof T], k: keyof T) => TResult): {

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Debug = exports.uniq = exports.compact = exports.loadJSON = exports.exists = exports.mapValues = exports.flatMap = void 0;
const fs = require("fs");

@@ -18,2 +19,3 @@ const debug = require('debug');

function exists(path) {
// eslint-disable-next-line no-promise-executor-return
return new Promise(resolve => resolve(fs.existsSync(path)));

@@ -20,0 +22,0 @@ }

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.config = void 0;
const settings_1 = require("../settings");

@@ -4,0 +5,0 @@ const logger_1 = require("./logger");

"use strict";
// tslint:disable no-implicit-dependencies
Object.defineProperty(exports, "__esModule", { value: true });
exports.CLIError = exports.addOclifExitCode = void 0;
const config_1 = require("../config");

@@ -50,3 +51,3 @@ /**

}
catch (_a) { }
catch { }
return red(process.platform === 'win32' ? '»' : '›');

@@ -67,3 +68,3 @@ }

}
catch (_a) { }
catch { }
return yellow(process.platform === 'win32' ? '»' : '›');

@@ -70,0 +71,0 @@ }

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ExitError = void 0;
const cli_1 = require("./cli");

@@ -4,0 +5,0 @@ class ExitError extends cli_1.CLIError {

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ModuleLoadError = void 0;
const cli_1 = require("./cli");

@@ -4,0 +5,0 @@ class ModuleLoadError extends cli_1.CLIError {

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.applyPrettyPrintOptions = void 0;
const wrap = require("wrap-ansi");

@@ -9,3 +10,3 @@ const indent = require("indent-string");

const prettyErrorKeys = ['message', 'code', 'ref', 'suggestions'];
prettyErrorKeys.forEach(key => {
for (const key of prettyErrorKeys) {
const applyOptionsKey = !(key in error) && options[key];

@@ -15,3 +16,3 @@ if (applyOptionsKey) {

}
});
}
return error;

@@ -18,0 +19,0 @@ }

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.handle = void 0;
/* eslint-disable no-process-exit */

@@ -10,3 +11,3 @@ /* eslint-disable unicorn/no-process-exit */

const cli_1 = require("./errors/cli");
exports.handle = (err) => {
const handle = (err) => {
var _a, _b, _c;

@@ -19,3 +20,3 @@ try {

const shouldPrint = !(err instanceof _1.ExitError);
const pretty = pretty_print_1.default(err);
const pretty = (0, pretty_print_1.default)(err);
const stack = clean(err.stack || '', { pretty: true });

@@ -43,1 +44,2 @@ if (shouldPrint) {

};
exports.handle = handle;
"use strict";
// tslint:disable no-console
Object.defineProperty(exports, "__esModule", { value: true });
exports.warn = exports.error = exports.exit = exports.config = exports.Logger = exports.CLIError = exports.ModuleLoadError = exports.ExitError = exports.handle = void 0;
var handle_1 = require("./handle");
exports.handle = handle_1.handle;
Object.defineProperty(exports, "handle", { enumerable: true, get: function () { return handle_1.handle; } });
var exit_1 = require("./errors/exit");
exports.ExitError = exit_1.ExitError;
Object.defineProperty(exports, "ExitError", { enumerable: true, get: function () { return exit_1.ExitError; } });
var module_load_1 = require("./errors/module-load");
exports.ModuleLoadError = module_load_1.ModuleLoadError;
Object.defineProperty(exports, "ModuleLoadError", { enumerable: true, get: function () { return module_load_1.ModuleLoadError; } });
var cli_1 = require("./errors/cli");
exports.CLIError = cli_1.CLIError;
Object.defineProperty(exports, "CLIError", { enumerable: true, get: function () { return cli_1.CLIError; } });
var logger_1 = require("./logger");
exports.Logger = logger_1.Logger;
Object.defineProperty(exports, "Logger", { enumerable: true, get: function () { return logger_1.Logger; } });
var config_1 = require("./config");
exports.config = config_1.config;
Object.defineProperty(exports, "config", { enumerable: true, get: function () { return config_1.config; } });
const config_2 = require("./config");

@@ -31,3 +32,3 @@ const cli_2 = require("./errors/cli");

else if (input instanceof Error) {
err = cli_2.addOclifExitCode(input, options);
err = (0, cli_2.addOclifExitCode)(input, options);
}

@@ -37,5 +38,5 @@ else {

}
err = pretty_print_1.applyPrettyPrintOptions(err, options);
err = (0, pretty_print_1.applyPrettyPrintOptions)(err, options);
if (options.exit === false) {
const message = pretty_print_1.default(err);
const message = (0, pretty_print_1.default)(err);
console.error(message);

@@ -56,3 +57,3 @@ if (config_2.config.errorLogger)

else if (input instanceof Error) {
err = cli_2.addOclifExitCode(input);
err = (0, cli_2.addOclifExitCode)(input);
}

@@ -62,3 +63,3 @@ else {

}
const message = pretty_print_1.default(err);
const message = (0, pretty_print_1.default)(err);
console.error(message);

@@ -65,0 +66,0 @@ if (config_2.config.errorLogger)

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Logger = void 0;
const path = require("path");

@@ -9,3 +10,3 @@ const timestamp = () => new Date().toISOString();

timer.unref();
timer = setTimeout(() => resolve(), ms);
timer = setTimeout(() => resolve(null), ms);
});

@@ -27,3 +28,3 @@ function chomp(s) {

msg = stripAnsi(chomp(msg));
const lines = msg.split('\n').map(l => `${timestamp()} ${l}`.trimRight());
const lines = msg.split('\n').map(l => `${timestamp()} ${l}`.trimEnd());
this.buffer.push(...lines);

@@ -30,0 +31,0 @@ // tslint:disable-next-line no-console

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.help = exports.version = exports.url = exports.integer = exports.boolean = exports.string = exports.enum = exports.option = exports.build = void 0;
const Parser = require("./parser");

@@ -13,7 +14,11 @@ function build(defaults) {

const _enum = (opts) => {
return build(Object.assign({ async parse(input) {
return build({
async parse(input) {
if (!opts.options.includes(input))
throw new Error(`Expected --${this.name}=${input} to be one of: ${opts.options.join(', ')}`);
return input;
}, helpValue: `(${opts.options.join('|')})` }, opts))();
},
helpValue: `(${opts.options.join('|')})`,
...opts,
})();
};

@@ -24,15 +29,25 @@ exports.enum = _enum;

var parser_1 = require("./parser");
exports.boolean = parser_1.boolean;
exports.integer = parser_1.integer;
exports.url = parser_1.url;
exports.version = (opts = {}) => {
return Parser.flags.boolean(Object.assign(Object.assign({ description: 'show CLI version' }, opts), { parse: async (_, cmd) => {
Object.defineProperty(exports, "boolean", { enumerable: true, get: function () { return parser_1.boolean; } });
Object.defineProperty(exports, "integer", { enumerable: true, get: function () { return parser_1.integer; } });
Object.defineProperty(exports, "url", { enumerable: true, get: function () { return parser_1.url; } });
const version = (opts = {}) => {
return Parser.flags.boolean({
description: 'Show CLI version.',
...opts,
parse: async (_, cmd) => {
cmd.log(cmd.config.userAgent);
cmd.exit(0);
} }));
},
});
};
exports.help = (opts = {}) => {
return Parser.flags.boolean(Object.assign(Object.assign({ description: 'show CLI help' }, opts), { parse: async (_, cmd) => {
exports.version = version;
const help = (opts = {}) => {
return Parser.flags.boolean({
description: 'Show CLI help.',
...opts,
parse: async (_, cmd) => {
cmd._help();
} }));
},
});
};
exports.help = help;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.CommandHelp = void 0;
const Chalk = require("chalk");

@@ -15,2 +16,3 @@ const stripAnsi = require("strip-ansi");

if (process.env.ConEmuANSI === 'ON') {
// eslint-disable-next-line unicorn/consistent-destructuring
dim = Chalk.gray;

@@ -27,3 +29,3 @@ }

const cmd = this.command;
const flags = util_1.sortBy(Object.entries(cmd.flags || {})
const flags = (0, util_1.sortBy)(Object.entries(cmd.flags || {})
.filter(([, v]) => !v.hidden)

@@ -35,3 +37,3 @@ .map(([k, v]) => {

const args = (cmd.args || []).filter(a => !a.hidden);
const output = util_1.compact(this.sections().map(({ header, generate }) => {
const output = (0, util_1.compact)(this.sections().map(({ header, generate }) => {
const body = generate({ cmd, flags, args }, header);

@@ -80,8 +82,8 @@ // Generate can return a list of sections

flagSections.push({ header, body: mainFlagBody });
Object.entries(flagGroups).forEach(([name, flags]) => {
for (const [name, flags] of Object.entries(flagGroups)) {
const body = this.flags(flags);
if (body)
flagSections.push({ header: `${name.toUpperCase()} ${header}`, body });
});
return util_1.compact(flagSections);
}
return (0, util_1.compact)(flagSections);
},

@@ -112,3 +114,3 @@ },

const usage = this.command.usage;
const body = (usage ? util_1.castArray(usage) : [this.defaultUsage()])
const body = (usage ? (0, util_1.castArray)(usage) : [this.defaultUsage()])
.map(u => {

@@ -118,5 +120,5 @@ const allowedSpacing = this.opts.maxWidth - this.indentSpacing;

if (line.length > allowedSpacing) {
const splitIndex = line.substring(0, allowedSpacing).lastIndexOf(' ');
return line.substring(0, splitIndex) + '\n' +
this.indent(this.wrap(line.substring(splitIndex), this.indentSpacing * 2));
const splitIndex = line.slice(0, Math.max(0, allowedSpacing)).lastIndexOf(' ');
return line.slice(0, Math.max(0, splitIndex)) + '\n' +
this.indent(this.wrap(line.slice(Math.max(0, splitIndex)), this.indentSpacing * 2));
}

@@ -133,3 +135,3 @@ return this.wrap(line);

}
return util_1.compact([
return (0, util_1.compact)([
this.command.id,

@@ -154,3 +156,3 @@ this.command.args.filter(a => !a.hidden).map(a => this.arg(a)).join(' '),

// Always separate by two newlines.
return this.wrap(util_1.compact(description).join('\n\n'));
return this.wrap((0, util_1.compact)(description).join('\n\n'));
}

@@ -176,3 +178,3 @@ }

const isCommand = (example) => stripAnsi(formatIfCommand(example)).startsWith(`$ ${this.config.bin}`);
const body = util_1.castArray(examples).map(a => {
const body = (0, util_1.castArray)(examples).map(a => {
let description;

@@ -185,2 +187,3 @@ let commands;

// If the example is <description>\n<command> then format correctly
// eslint-disable-next-line unicorn/no-array-callback-reference
if (lines.length >= 2 && !isCommand(lines[0]) && lines.slice(1).every(isCommand)) {

@@ -199,3 +202,3 @@ description = lines[0];

const multilineSeparator = this.config.platform === 'win32' ?
this.config.shell.includes('powershell') ? '`' : '^' :
(this.config.shell.includes('powershell') ? '`' : '^') :
'\\';

@@ -252,6 +255,3 @@ // The command will be indented in the section, which is also indented

if (!flag.helpValue && flag.options) {
if (showOptions || this.opts.showFlagOptionsInTitle)
value = `${flag.options.join('|')}`;
else
value = '<option>';
value = showOptions || this.opts.showFlagOptionsInTitle ? `${flag.options.join('|')}` : '<option>';
}

@@ -291,8 +291,3 @@ if (flag.multiple)

let flagHelp = this.flagHelpLabel(flag, true);
if (flagHelp.length + summary.length + 2 < this.opts.maxWidth) {
flagHelp += ' ' + summary;
}
else {
flagHelp += '\n\n' + this.indent(this.wrap(summary, this.indentSpacing * 2));
}
flagHelp += flagHelp.length + summary.length + 2 < this.opts.maxWidth ? ' ' + summary : '\n\n' + this.indent(this.wrap(summary, this.indentSpacing * 2));
return `${flagHelp}\n\n${this.indent(this.wrap(flag.description || '', this.indentSpacing * 2))}`;

@@ -299,0 +294,0 @@ }).join('\n\n');

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.DocOpts = void 0;
/**

@@ -78,3 +79,4 @@ * DocOpts - See http://docopt.org/.

if (this.cmd.args) {
opts.push(...(_a = this.cmd.args) === null || _a === void 0 ? void 0 : _a.map(arg => `[${arg.name.toUpperCase()}]`));
const a = ((_a = this.cmd.args) === null || _a === void 0 ? void 0 : _a.map(arg => `[${arg.name.toUpperCase()}]`)) || [];
opts.push(...a);
}

@@ -84,3 +86,3 @@ try {

}
catch (error) {
catch {
// If there is an error, just return no usage so we don't fail command help.

@@ -145,2 +147,3 @@ opts.push(...this.flagList.map(flag => {

}
// eslint-disable-next-line default-param-last
generateElements(elementMap = {}, flagGroups) {

@@ -147,0 +150,0 @@ const elementStrs = [];

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.HelpFormatter = void 0;
const Chalk = require("chalk");

@@ -16,4 +17,4 @@ const indent = require("indent-string");

this.config = config;
this.opts = Object.assign({ maxWidth: screen_1.stdtermwidth }, opts);
this.render = util_1.template(this);
this.opts = { maxWidth: screen_1.stdtermwidth, ...opts };
this.render = (0, util_1.template)(this);
}

@@ -20,0 +21,0 @@ /**

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Help = exports.HelpBase = exports.getHelpFlagAdditions = exports.loadHelpClass = exports.standardizeIDFromArgv = exports.CommandHelp = void 0;
const stripAnsi = require("strip-ansi");

@@ -11,6 +12,6 @@ const errors_1 = require("../errors");

var command_2 = require("./command");
exports.CommandHelp = command_2.CommandHelp;
Object.defineProperty(exports, "CommandHelp", { enumerable: true, get: function () { return command_2.CommandHelp; } });
var util_3 = require("./util");
exports.standardizeIDFromArgv = util_3.standardizeIDFromArgv;
exports.loadHelpClass = util_3.loadHelpClass;
Object.defineProperty(exports, "standardizeIDFromArgv", { enumerable: true, get: function () { return util_3.standardizeIDFromArgv; } });
Object.defineProperty(exports, "loadHelpClass", { enumerable: true, get: function () { return util_3.loadHelpClass; } });
const helpFlags = ['--help'];

@@ -65,4 +66,4 @@ function getHelpFlagAdditions(config) {

commands = commands.filter(c => this.opts.all || !c.hidden);
commands = util_1.sortBy(commands, c => c.id);
commands = util_1.uniqBy(commands, c => c.id);
commands = (0, util_1.sortBy)(commands, c => c.id);
commands = (0, util_1.uniqBy)(commands, c => c.id);
return commands;

@@ -73,4 +74,4 @@ }

topics = topics.filter(t => this.opts.all || !t.hidden);
topics = util_1.sortBy(topics, t => t.name);
topics = util_1.uniqBy(topics, t => t.name);
topics = (0, util_1.sortBy)(topics, t => t.name);
topics = (0, util_1.uniqBy)(topics, t => t.name);
return topics;

@@ -81,3 +82,3 @@ }

if (this.config.topicSeparator !== ':')
argv = util_2.standardizeIDFromArgv(argv, this.config);
argv = (0, util_2.standardizeIDFromArgv)(argv, this.config);
const subject = getHelpSubject(argv, this.config);

@@ -103,3 +104,3 @@ if (!subject) {

}
errors_1.error(`command ${subject} not found`);
(0, errors_1.error)(`Command ${subject} not found.`);
}

@@ -223,3 +224,3 @@ async showCommandHelp(command) {

topicID = topicID.replace(/:/g, this.config.topicSeparator);
let output = util_1.compact([
let output = (0, util_1.compact)([
summary,

@@ -226,0 +227,0 @@ this.section(this.opts.usageHeader || 'USAGE', `$ ${this.config.bin} ${topicID}`),

@@ -16,3 +16,3 @@ "use strict";

description = description.split('\n')[0];
let output = util_1.compact([
let output = (0, util_1.compact)([
description,

@@ -19,0 +19,0 @@ this.version(),

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.standardizeIDFromArgv = exports.toConfiguredId = exports.toStandardizedId = exports.template = exports.loadHelpClass = void 0;
const lodashTemplate = require("lodash.template");

@@ -34,6 +35,6 @@ const _1 = require(".");

return argv;
const ids = config.commandIDs.concat(config.topics.map(t => t.name));
const ids = new Set(config.commandIDs.concat(config.topics.map(t => t.name)));
const findId = (argv) => {
const final = [];
const idPresent = (id) => ids.includes(id);
const idPresent = (id) => ids.has(id);
const isFlag = (s) => s.startsWith('-');

@@ -77,3 +78,4 @@ const isArgWithValue = (s) => s.includes('=');

function toConfiguredId(commandID, config) {
return commandID.replace(new RegExp(':', 'g'), config.topicSeparator);
const defaultTopicSeperator = ':';
return commandID.replace(new RegExp(defaultTopicSeperator, 'g'), config.topicSeparator);
}

@@ -80,0 +82,0 @@ exports.toConfiguredId = toConfiguredId;

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.flush = exports.settings = exports.toConfiguredId = exports.toStandardizedId = exports.tsPath = exports.toCached = exports.run = exports.Plugin = exports.Parser = exports.Interfaces = exports.HelpBase = exports.Help = exports.loadHelpClass = exports.Flags = exports.Errors = exports.Config = exports.CommandHelp = exports.Command = void 0;
const path = require("path");

@@ -8,8 +9,8 @@ const semver = require("semver");

const main_1 = require("./main");
exports.run = main_1.run;
Object.defineProperty(exports, "run", { enumerable: true, get: function () { return main_1.run; } });
const config_1 = require("./config");
exports.Config = config_1.Config;
exports.Plugin = config_1.Plugin;
exports.tsPath = config_1.tsPath;
exports.toCached = config_1.toCached;
Object.defineProperty(exports, "Config", { enumerable: true, get: function () { return config_1.Config; } });
Object.defineProperty(exports, "Plugin", { enumerable: true, get: function () { return config_1.Plugin; } });
Object.defineProperty(exports, "tsPath", { enumerable: true, get: function () { return config_1.tsPath; } });
Object.defineProperty(exports, "toCached", { enumerable: true, get: function () { return config_1.toCached; } });
const Interfaces = require("./interfaces");

@@ -22,13 +23,13 @@ exports.Interfaces = Interfaces;

const help_1 = require("./help");
exports.CommandHelp = help_1.CommandHelp;
exports.HelpBase = help_1.HelpBase;
exports.Help = help_1.Help;
exports.loadHelpClass = help_1.loadHelpClass;
Object.defineProperty(exports, "CommandHelp", { enumerable: true, get: function () { return help_1.CommandHelp; } });
Object.defineProperty(exports, "HelpBase", { enumerable: true, get: function () { return help_1.HelpBase; } });
Object.defineProperty(exports, "Help", { enumerable: true, get: function () { return help_1.Help; } });
Object.defineProperty(exports, "loadHelpClass", { enumerable: true, get: function () { return help_1.loadHelpClass; } });
const util_1 = require("./help/util");
exports.toStandardizedId = util_1.toStandardizedId;
exports.toConfiguredId = util_1.toConfiguredId;
Object.defineProperty(exports, "toStandardizedId", { enumerable: true, get: function () { return util_1.toStandardizedId; } });
Object.defineProperty(exports, "toConfiguredId", { enumerable: true, get: function () { return util_1.toConfiguredId; } });
const Parser = require("./parser");
exports.Parser = Parser;
const settings_1 = require("./settings");
exports.settings = settings_1.settings;
Object.defineProperty(exports, "settings", { enumerable: true, get: function () { return settings_1.settings; } });
const flush = require('../flush');

@@ -35,0 +36,0 @@ exports.flush = flush;

@@ -68,6 +68,6 @@ import { HelpOptions } from './help';

interface Templates {
baseDir: string;
versioned: string;
unversioned: string;
manifest: string;
baseDir?: string;
versioned?: string;
unversioned?: string;
manifest?: string;
}

@@ -74,0 +74,0 @@ }

import * as Interfaces from './interfaces';
import { Config } from './config';
export declare const helpAddition: (argv: string[], config: Interfaces.Config) => boolean;
export declare const versionAddition: (argv: string[], config?: Interfaces.Config | undefined) => boolean;
export declare function run(argv?: string[], options?: Interfaces.LoadOptions): Promise<unknown>;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.run = exports.versionAddition = exports.helpAddition = void 0;
const url_1 = require("url");
const util_1 = require("util");
const url_2 = require("url");
const config_1 = require("./config");

@@ -9,9 +11,9 @@ const help_1 = require("./help");

// tslint:disable-next-line strict-type-predicates
message = typeof message === 'string' ? message : util_1.inspect(message);
process.stdout.write(util_1.format(message, ...args) + '\n');
message = typeof message === 'string' ? message : (0, util_1.inspect)(message);
process.stdout.write((0, util_1.format)(message, ...args) + '\n');
};
exports.helpAddition = (argv, config) => {
const helpAddition = (argv, config) => {
if (argv.length === 0 && !config.pjson.oclif.default)
return true;
const mergedHelpFlags = help_1.getHelpFlagAdditions(config);
const mergedHelpFlags = (0, help_1.getHelpFlagAdditions)(config);
for (const arg of argv) {

@@ -25,6 +27,7 @@ if (mergedHelpFlags.includes(arg))

};
exports.versionAddition = (argv, config) => {
exports.helpAddition = helpAddition;
const versionAddition = (argv, config) => {
var _a;
const additionalVersionFlags = (_a = config === null || config === void 0 ? void 0 : config.pjson.oclif.additionalVersionFlags) !== null && _a !== void 0 ? _a : [];
const mergedVersionFlags = [...new Set([...['--version'], ...additionalVersionFlags]).values()];
const mergedVersionFlags = [...new Set(['--version', ...additionalVersionFlags]).values()];
if (mergedVersionFlags.includes(argv[0]))

@@ -34,7 +37,9 @@ return true;

};
exports.versionAddition = versionAddition;
// eslint-disable-next-line default-param-last
async function run(argv = process.argv.slice(2), options) {
var _a;
// Handle the case when a file URL string or URL is passed in such as 'import.meta.url'; covert to file path.
if ((typeof options === 'string' && options.startsWith('file://')) || options instanceof URL) {
options = url_1.fileURLToPath(options);
if (options && ((typeof options === 'string' && options.startsWith('file://')) || options instanceof url_2.URL)) {
options = (0, url_1.fileURLToPath)(options);
}

@@ -44,3 +49,3 @@ // return Main.run(argv, options)

if (config.topicSeparator !== ':' && !((_a = argv[0]) === null || _a === void 0 ? void 0 : _a.includes(':')))
argv = help_1.standardizeIDFromArgv(argv, config);
argv = (0, help_1.standardizeIDFromArgv)(argv, config);
let [id, ...argvSlice] = argv;

@@ -50,3 +55,3 @@ // run init hook

// display version if applicable
if (exports.versionAddition(argv, config)) {
if ((0, exports.versionAddition)(argv, config)) {
log(config.userAgent);

@@ -56,4 +61,4 @@ return;

// display help version if applicable
if (exports.helpAddition(argv, config)) {
const Help = await help_1.loadHelpClass(config);
if ((0, exports.helpAddition)(argv, config)) {
const Help = await (0, help_1.loadHelpClass)(config);
const help = new Help(config, config.pjson.helpOptions);

@@ -60,0 +65,0 @@ await help.showHelp(argv);

@@ -12,2 +12,3 @@ "use strict";

*/
// eslint-disable-next-line camelcase
const s_EXTENSIONS = ['.js', '.mjs', '.cjs'];

@@ -25,2 +26,3 @@ /**

*/
// eslint-disable-next-line unicorn/no-static-only-class
class ModuleLoader {

@@ -128,6 +130,7 @@ /**

}
catch (error) {
catch {
filePath = Config.tsPath(config.root, modulePath);
// Try all supported extensions.
if (!fs.existsSync(filePath)) {
// eslint-disable-next-line camelcase
for (const extension of s_EXTENSIONS) {

@@ -134,0 +137,0 @@ const testPath = `${filePath}${extension}`;

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.newArg = void 0;
function newArg(arg) {
return Object.assign(Object.assign({ parse: (i) => i }, arg), { required: Boolean(arg.required) });
return {
parse: (i) => i,
...arg,
required: Boolean(arg.required),
};
}
exports.newArg = newArg;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ArgInvalidOptionError = exports.FlagInvalidOptionError = exports.UnexpectedArgsError = exports.RequiredFlagError = exports.RequiredArgsError = exports.InvalidArgsSpecError = exports.CLIParseError = exports.CLIError = void 0;
const errors_1 = require("../errors");
const deps_1 = require("./deps");
var errors_2 = require("../errors");
exports.CLIError = errors_2.CLIError;
Object.defineProperty(exports, "CLIError", { enumerable: true, get: function () { return errors_2.CLIError; } });
// eslint-disable-next-line new-cap
const m = deps_1.default()
const m = (0, deps_1.default)()
// eslint-disable-next-line node/no-missing-require

@@ -10,0 +11,0 @@ .add('help', () => require('./help'))

"use strict";
// tslint:disable interface-over-type-literal
Object.defineProperty(exports, "__esModule", { value: true });
exports.defaultFlags = exports.string = exports.option = exports.url = exports.integer = exports.boolean = exports.build = void 0;
const url_1 = require("url");
function build(defaults) {
return (options = {}) => {
return Object.assign(Object.assign(Object.assign({ parse: async (i, _) => i }, defaults), options), { input: [], multiple: Boolean(options.multiple), type: 'option' });
return {
parse: async (i, _) => i,
...defaults,
...options,
input: [],
multiple: Boolean(options.multiple),
type: 'option',
};
};

@@ -12,3 +20,8 @@ }

function boolean(options = {}) {
return Object.assign(Object.assign({ parse: async (b, _) => b }, options), { allowNo: Boolean(options.allowNo), type: 'boolean' });
return {
parse: async (b, _) => b,
...options,
allowNo: Boolean(options.allowNo),
type: 'boolean',
};
}

@@ -20,3 +33,3 @@ exports.boolean = boolean;

throw new Error(`Expected an integer but received: ${input}`);
return parseInt(input, 10);
return Number.parseInt(input, 10);
},

@@ -33,3 +46,3 @@ });

}
catch (_a) {
catch {
throw new Error(`Expected a valid url but received: ${input}`);

@@ -36,0 +49,0 @@ }

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.flagUsages = exports.flagUsage = void 0;
const deps_1 = require("./deps");
// eslint-disable-next-line new-cap
const m = deps_1.default()
const m = (0, deps_1.default)()
.add('chalk', () => require('chalk'))

@@ -7,0 +8,0 @@ // eslint-disable-next-line node/no-missing-require

"use strict";
// tslint:disable interface-over-type-literal
Object.defineProperty(exports, "__esModule", { value: true });
exports.url = exports.integer = exports.boolean = exports.parse = exports.flagUsages = exports.flags = exports.args = void 0;
const args = require("./args");

@@ -11,5 +12,5 @@ exports.args = args;

var help_1 = require("./help");
exports.flagUsages = help_1.flagUsages;
Object.defineProperty(exports, "flagUsages", { enumerable: true, get: function () { return help_1.flagUsages; } });
// eslint-disable-next-line new-cap
const m = deps_1.default()
const m = (0, deps_1.default)()
// eslint-disable-next-line node/no-missing-require

@@ -23,3 +24,6 @@ .add('validate', () => require('./validate').validate);

'--': options['--'],
flags: Object.assign({ color: flags.defaultFlags.color }, ((options.flags || {}))),
flags: {
color: flags.defaultFlags.color,
...((options.flags || {})),
},
strict: options.strict !== false,

@@ -26,0 +30,0 @@ };

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.renderList = void 0;
const screen_1 = require("../screen");

@@ -15,3 +16,3 @@ const util_1 = require("./util");

}
const maxLength = util_1.maxBy(items, i => i[0].length)[0].length;
const maxLength = (0, util_1.maxBy)(items, i => i[0].length)[0].length;
const lines = items.map(i => {

@@ -18,0 +19,0 @@ let left = i[0];

"use strict";
// tslint:disable interface-over-type-literal
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
exports.Parser = void 0;
const deps_1 = require("./deps");
// eslint-disable-next-line new-cap
const m = deps_1.default()
const m = (0, deps_1.default)()
// eslint-disable-next-line node/no-missing-require

@@ -15,13 +15,8 @@ .add('errors', () => require('./errors'))

// eslint-disable-next-line no-negated-condition
if (process.env.CLI_FLAGS_DEBUG !== '1')
debug = () => { };
else
// eslint-disable-next-line node/no-extraneous-require
debug = require('debug')('../parser');
debug = process.env.CLI_FLAGS_DEBUG !== '1' ? () => { } : require('debug')('../parser');
}
catch (_a) {
catch {
debug = () => { };
}
const readStdin = async () => {
var e_1, _a;
const { stdin } = process;

@@ -33,15 +28,5 @@ let result;

stdin.setEncoding('utf8');
try {
for (var stdin_1 = tslib_1.__asyncValues(stdin), stdin_1_1; stdin_1_1 = await stdin_1.next(), !stdin_1_1.done;) {
const chunk = stdin_1_1.value;
result += chunk;
}
for await (const chunk of stdin) {
result += chunk;
}
catch (e_1_1) { e_1 = { error: e_1_1 }; }
finally {
try {
if (stdin_1_1 && !stdin_1_1.done && (_a = stdin_1.return)) await _a.call(stdin_1);
}
finally { if (e_1) throw e_1.error; }
}
return result;

@@ -55,3 +40,3 @@ };

this.context = input.context || {};
this.argv = input.argv.slice(0);
this.argv = [...input.argv];
this._setNames();

@@ -96,9 +81,3 @@ this.booleanFlags = pickBy(input.flags, f => f.type === 'boolean');

this.currentFlag = flag;
let input;
if (long || arg.length < 3) {
input = this.argv.shift();
}
else {
input = arg.slice(arg[2] === '=' ? 3 : 2);
}
const input = long || arg.length < 3 ? this.argv.shift() : arg.slice(arg[2] === '=' ? 3 : 2);
if (typeof input !== 'string') {

@@ -119,3 +98,3 @@ throw new m.errors.CLIError(`Flag --${name} expects a value`);

let parsingFlags = true;
while (this.argv.length) {
while (this.argv.length > 0) {
const input = this.argv.shift();

@@ -209,3 +188,3 @@ if (parsingFlags && input.startsWith('-') && input !== '-') {

// eslint-disable-next-line no-await-in-loop
const defaultValue = (typeof flag.default === 'function' ? await flag.default(Object.assign({ options: flag, flags }, this.context)) : flag.default);
const defaultValue = (typeof flag.default === 'function' ? await flag.default({ options: flag, flags, ...this.context }) : flag.default);
const parsedValue = flag.type === 'option' && flag.parse ?

@@ -212,0 +191,0 @@ // eslint-disable-next-line no-await-in-loop

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.sortBy = exports.maxBy = exports.pickBy = void 0;
function pickBy(obj, fn) {

@@ -4,0 +5,0 @@ return Object.entries(obj)

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.validate = void 0;
const errors_1 = require("../errors");

@@ -14,3 +15,3 @@ const errors_2 = require("./errors");

let hasOptional = false;
parse.input.args.forEach((arg, index) => {
for (const [index, arg] of parse.input.args.entries()) {
if (!arg.required) {

@@ -24,8 +25,6 @@ hasOptional = true;

}
if (arg.required) {
if (!parse.output.argv[index] && parse.output.argv[index] !== 0) {
missingRequiredArgs.push(arg);
}
if (arg.required && !parse.output.argv[index] && parse.output.argv[index] !== 0) {
missingRequiredArgs.push(arg);
}
});
}
if (missingRequiredArgs.length > 0) {

@@ -32,0 +31,0 @@ throw new errors_2.RequiredArgsError({ parse, args: missingRequiredArgs });

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.errtermwidth = exports.stdtermwidth = void 0;
const settings_1 = require("./settings");

@@ -17,4 +18,4 @@ function termwidth(stream) {

}
const columns = parseInt(process.env.OCLIF_COLUMNS, 10) || settings_1.settings.columns;
const columns = Number.parseInt(process.env.OCLIF_COLUMNS, 10) || settings_1.settings.columns;
exports.stdtermwidth = columns || termwidth(process.stdout);
exports.errtermwidth = columns || termwidth(process.stderr);
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.settings = void 0;
// Set global.oclif to the new object if it wasn't set before

@@ -4,0 +5,0 @@ if (!global.oclif)

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.isProd = exports.castArray = exports.sortBy = exports.uniqBy = exports.compact = void 0;
function compact(a) {

@@ -4,0 +5,0 @@ return a.filter((a) => Boolean(a));

{
"name": "@oclif/core",
"description": "base library for oclif CLIs",
"version": "0.5.39",
"version": "0.5.40",
"author": "Jeff Dickey @jdxcode",

@@ -53,4 +53,4 @@ "bugs": "https://github.com/oclif/core/issues",

"eslint": "^7.3.1",
"eslint-config-oclif": "^3.1.0",
"eslint-config-oclif-typescript": "^0.2.0",
"eslint-config-oclif": "^4.0.0",
"eslint-config-oclif-typescript": "^1.0.2",
"fancy-test": "^1.4.3",

@@ -66,3 +66,3 @@ "globby": "^11.0.1",

"ts-node": "^9.0.0",
"typescript": "3.8.3"
"typescript": "4.4.3"
},

@@ -69,0 +69,0 @@ "engines": {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc