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

@oclif/plugin-commands

Package Overview
Dependencies
Maintainers
2
Versions
101
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@oclif/plugin-commands - npm Package Compare versions

Comparing version 4.0.17 to 4.1.0

60

lib/commands/commands.js
import { Command, Flags, toConfiguredId } from '@oclif/core';
import { printTable } from '@oclif/table';
import _ from 'lodash';
// @ts-expect-error because object-treeify does not have types: https://github.com/blackflux/object-treeify/issues/1077
import treeify from 'object-treeify';
import TtyTable from 'tty-table';
const COLUMNS = ['id', 'plugin', 'summary', 'type'];

@@ -19,18 +19,2 @@ function createTree(commands) {

}
function determineHeaders(columns, extended) {
const columnConfigs = {
id: { align: 'left', value: 'ID', width: '25%' },
plugin: { align: 'left', value: 'Plugin' },
summary: { align: 'left', value: 'Summary', width: '75%' },
type: { align: 'left', value: 'Type' },
};
if (columns) {
return columns.map((column) => columnConfigs[column]);
}
if (extended) {
return [columnConfigs.id, columnConfigs.summary, columnConfigs.plugin, columnConfigs.type];
}
return [columnConfigs.id, columnConfigs.summary];
}
// In order to collect static properties up the inheritance chain, we need to recursively access the prototypes until there's nothing left
function mergePrototype(result, command) {

@@ -88,30 +72,18 @@ const proto = Object.getPrototypeOf(command);

}
else {
const headers = determineHeaders(flags.columns, flags.extended);
const extractData = (command) => headers.map((header) => {
switch (header.value) {
case 'ID': {
return toConfiguredId(command.id, config);
}
case 'Plugin': {
return command.pluginName;
}
case 'Type': {
return command.pluginType;
}
case 'Summary': {
return command.summary ?? command.description;
}
default: {
throw new Error('Unknown column');
}
}
else if (!this.jsonEnabled()) {
printTable({
borderStyle: 'vertical-with-outline',
columns: (flags.columns ?? ['id', 'summary', ...(flags.extended ? ['plugin', 'type'] : [])]),
data: commands.map((c) => ({
id: toConfiguredId(c.id, config),
plugin: c.pluginName,
summary: c.summary ?? c.description,
type: c.pluginType,
})),
headerOptions: {
formatter: 'capitalCase',
},
overflow: flags['no-truncate'] ? 'wrap' : 'truncate',
sort: { [flags.sort]: 'asc' },
});
// eslint-disable-next-line new-cap
const table = TtyTable(headers, commands.map((c) => extractData(c)), {
compact: true,
defaultValue: '',
truncate: flags['no-truncate'] ? undefined : '...',
});
this.log(table.render());
}

@@ -118,0 +90,0 @@ const json = _.uniqBy(await Promise.all(commands.map(async (cmd) => {

@@ -108,3 +108,3 @@ {

},
"version": "4.0.17"
"version": "4.1.0"
}
{
"name": "@oclif/plugin-commands",
"description": "plugin to show the list of all the commands",
"version": "4.0.17",
"version": "4.1.0",
"author": "Salesforce",

@@ -9,5 +9,5 @@ "bugs": "https://github.com/oclif/plugin-commands/issues",

"@oclif/core": "^4",
"@oclif/table": "^0.1.12",
"lodash": "^4.17.21",
"object-treeify": "^4.0.1",
"tty-table": "^4.2.3"
"object-treeify": "^4.0.1"
},

@@ -14,0 +14,0 @@ "devDependencies": {

@@ -24,3 +24,3 @@ # @oclif/plugin-commands

$ oclif-example (--version)
@oclif/plugin-commands/4.0.17 linux-x64 node-v20.17.0
@oclif/plugin-commands/4.1.0 linux-x64 node-v20.17.0
$ oclif-example --help [COMMAND]

@@ -65,3 +65,3 @@ USAGE

_See code: [src/commands/commands.ts](https://github.com/oclif/plugin-commands/blob/v4.0.17/src/commands/commands.ts)_
_See code: [src/commands/commands.ts](https://github.com/oclif/plugin-commands/blob/v4.1.0/src/commands/commands.ts)_
<!-- commandsstop -->

@@ -68,0 +68,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