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

cli-engine-command

Package Overview
Dependencies
Maintainers
3
Versions
159
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cli-engine-command - npm Package Compare versions

Comparing version 10.0.1 to 10.0.2

4

lib/command.js

@@ -48,7 +48,7 @@ "use strict";

static buildHelp(config) {
let help = new help_1.default(config);
let help = new help_1.Help(config);
return help.command(this);
}
static buildHelpLine(config) {
let help = new help_1.default(config);
let help = new help_1.Help(config);
return help.commandLine(this);

@@ -55,0 +55,0 @@ }

import { Config, ICommand } from 'cli-engine-config';
import { IArg, IFlag } from 'cli-flags';
export default class Help {
export declare class Help {
config: Config;

@@ -8,5 +8,5 @@ constructor(config: Config);

commandLine(cmd: ICommand): [string, string | undefined];
renderAliases(aliases?: string[]): string;
renderArgs(args: IArg[]): string;
renderFlags(flags: [string, IFlag<any>][]): string;
renderAliases(aliases: string[] | undefined): string;
renderArgs(args: IArg<string>[]): string;
renderFlags(flags: IFlag<any>[]): string;
}
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const screen_1 = require("cli-ux/lib/screen");
const color_1 = require("./color");
function linewrap(length, s) {
const linewrap = require('@heroku/linewrap');
return linewrap(length, screen_1.default.stdtermwidth, {
skipScheme: 'ansi-color',
})(s).trim();
}
function renderList(items) {
const S = require('string');
const max = require('lodash.maxby');
let maxLength = max(items, '[0].length')[0].length;
let lines = items.map(i => {
let left = i[0];
let right = i[1];
if (!right)
return left;
left = `${S(left).padRight(maxLength)}`;
right = linewrap(maxLength + 2, right);
return `${left} ${right}`;
});
return lines.join('\n');
}
const list_1 = require("cli-ux/lib/list");
const cli_flags_1 = require("cli-flags");
const chalk_1 = require("chalk");
function buildUsage(command) {

@@ -31,3 +11,3 @@ if (command.usage)

if (!command.args)
return cmd.trim();
return (cmd || '').trim();
let args = command.args.map(renderArg);

@@ -48,10 +28,15 @@ return `${cmd} ${args.join(' ')}`.trim();

command(cmd) {
let flags = Object.entries(cmd.flags || {}).filter(([, flag]) => !flag.hidden);
let flags = Object.entries(cmd.flags || {})
.filter(([, f]) => !f.hidden)
.map(([k, f]) => {
f.name = k;
return f;
});
let args = (cmd.args || []).filter(a => !a.hidden);
let hasFlags = flags.length ? ` ${color_1.color.blue('[flags]')}` : '';
let usage = `${color_1.color.bold('Usage:')} ${this.config.bin} ${buildUsage(cmd)}${hasFlags}\n`;
let hasFlags = flags.length ? ` ${chalk_1.default.blue('[flags]')}` : '';
let usage = `${chalk_1.default.bold('Usage:')} ${this.config.bin} ${buildUsage(cmd)}${hasFlags}\n`;
return [
usage,
cmd.description ? `\n${color_1.color.bold(cmd.description.trim())}\n` : '',
this.renderAliases(cmd.aliases),
cmd.description ? `\n${chalk_1.default.bold(cmd.description.trim())}\n` : '',
this.renderAliases(this.config.aliases[cmd.id]),
this.renderArgs(args),

@@ -63,3 +48,3 @@ this.renderFlags(flags),

commandLine(cmd) {
return [buildUsage(cmd), cmd.description ? color_1.color.dim(cmd.description) : undefined];
return [buildUsage(cmd), cmd.description ? chalk_1.default.dim(cmd.description) : undefined];
}

@@ -70,3 +55,3 @@ renderAliases(aliases) {

let a = aliases.map(a => ` $ ${this.config.bin} ${a}`).join('\n');
return `\n${color_1.color.blue('Aliases:')}\n${a}\n`;
return `\n${chalk_1.default.blue('Aliases:')}\n${a}\n`;
}

@@ -77,4 +62,4 @@ renderArgs(args) {

return ('\n' +
renderList(args.map(a => {
return [a.name.toUpperCase(), a.description ? color_1.color.dim(a.description) : undefined];
list_1.renderList(args.map(a => {
return [a.name.toUpperCase(), a.description ? chalk_1.default.dim(a.description) : undefined];
})) +

@@ -86,27 +71,5 @@ '\n');

return '';
flags.sort((a, b) => {
if (a[1].char && !b[1].char)
return -1;
if (b[1].char && !a[1].char)
return 1;
if (a[0] < b[0])
return -1;
return b[0] < a[0] ? 1 : 0;
});
return (`\n${color_1.color.blue('Flags:')}\n` +
renderList(flags.map(([name, f]) => {
let label = [];
if (f.char)
label.push(`-${f.char}`);
if (name)
label.push(` --${name}`);
let usage = f.type === 'option' ? ` ${name.toUpperCase()}` : '';
let description = f.description || '';
if (f.required)
description = `(required) ${description}`;
return [` ${label.join(',').trim()}` + usage, description ? color_1.color.dim(description) : undefined];
})) +
'\n');
return `\n${chalk_1.default.blue('Flags:')}\n` + list_1.renderList(cli_flags_1.flagUsages(flags)) + '\n';
}
}
exports.default = Help;
exports.Help = Help;
{
"name": "cli-engine-command",
"description": "base CLI command for cli-engine",
"version": "10.0.1",
"version": "10.0.2",
"author": "Jeff Dickey @jdxcode",

@@ -12,7 +12,7 @@ "bugs": "https://github.com/heroku/cli-engine-command/issues",

"chalk": "2.3.0",
"cli-engine-config": "4.1.0",
"cli-engine-config": "4.2.3",
"cli-flags": "1.0.18",
"cli-ux": "^2.0.5",
"cli-ux": "^2.0.6",
"fs-extra": "^5.0.0",
"http-call": "^4.0.0",
"http-call": "^4.0.4",
"lodash.maxby": "^4.6.0",

@@ -27,4 +27,4 @@ "moment": "^2.19.4",

"@types/jest": "21.1.8",
"@types/nock": "8.2.1",
"@types/node": "8.0.58",
"@types/nock": "9.1.0",
"@types/node": "8.5.1",
"@types/supports-color": "3.1.0",

@@ -31,0 +31,0 @@ "del-cli": "1.1.0",

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