@oclif/plugin-commands
Advanced tools
Comparing version 4.0.17 to 4.1.0
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 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
15023
272
+ Added@oclif/table@^0.1.12
+ Added@alcalzone/ansi-tokenize@0.1.3(transitive)
+ Added@oclif/table@0.1.24(transitive)
+ Added@types/prop-types@15.7.14(transitive)
+ Added@types/react@18.3.16(transitive)
+ Addedansi-escapes@7.0.0(transitive)
+ Addedansi-regex@6.1.0(transitive)
+ Addedansi-styles@6.2.1(transitive)
+ Addedauto-bind@5.0.1(transitive)
+ Addedchalk@5.3.0(transitive)
+ Addedchange-case@5.4.4(transitive)
+ Addedcli-boxes@3.0.0(transitive)
+ Addedcli-cursor@4.0.0(transitive)
+ Addedcli-truncate@4.0.0(transitive)
+ Addedcode-excerpt@4.0.0(transitive)
+ Addedconvert-to-spaces@2.0.1(transitive)
+ Addedcsstype@3.1.3(transitive)
+ Addedemoji-regex@10.4.0(transitive)
+ Addedenvironment@1.1.0(transitive)
+ Addedes-toolkit@1.30.1(transitive)
+ Addedescape-string-regexp@2.0.0(transitive)
+ Addedget-east-asian-width@1.3.0(transitive)
+ Addedindent-string@5.0.0(transitive)
+ Addedink@5.1.0(transitive)
+ Addedis-fullwidth-code-point@4.0.05.0.0(transitive)
+ Addedis-in-ci@1.0.0(transitive)
+ Addedjs-tokens@4.0.0(transitive)
+ Addedloose-envify@1.4.0(transitive)
+ Addedmimic-fn@2.1.0(transitive)
+ Addednatural-orderby@3.0.2(transitive)
+ Addedobject-hash@3.0.0(transitive)
+ Addedonetime@5.1.2(transitive)
+ Addedpatch-console@2.0.0(transitive)
+ Addedreact@18.3.1(transitive)
+ Addedreact-reconciler@0.29.2(transitive)
+ Addedrestore-cursor@4.0.0(transitive)
+ Addedscheduler@0.23.2(transitive)
+ Addedsignal-exit@3.0.7(transitive)
+ Addedslice-ansi@5.0.07.1.0(transitive)
+ Addedstack-utils@2.0.6(transitive)
+ Addedstring-width@7.2.0(transitive)
+ Addedstrip-ansi@7.1.0(transitive)
+ Addedtype-fest@4.30.1(transitive)
+ Addedwidest-line@5.0.0(transitive)
+ Addedwrap-ansi@9.0.0(transitive)
+ Addedws@8.18.0(transitive)
+ Addedyoga-wasm-web@0.3.3(transitive)
- Removedtty-table@^4.2.3
- Removedarray-buffer-byte-length@1.0.1(transitive)
- Removedarray.prototype.flat@1.3.2(transitive)
- Removedarraybuffer.prototype.slice@1.0.3(transitive)
- Removedavailable-typed-arrays@1.0.7(transitive)
- Removedbreakword@1.0.6(transitive)
- Removedcall-bind@1.0.8(transitive)
- Removedcall-bind-apply-helpers@1.0.1(transitive)
- Removedcall-bound@1.0.2(transitive)
- Removedcamelcase@5.3.1(transitive)
- Removedcliui@6.0.08.0.1(transitive)
- Removedclone@1.0.4(transitive)
- Removedcsv@5.5.3(transitive)
- Removedcsv-generate@3.4.3(transitive)
- Removedcsv-parse@4.16.3(transitive)
- Removedcsv-stringify@5.6.5(transitive)
- Removeddata-view-buffer@1.0.1(transitive)
- Removeddata-view-byte-length@1.0.1(transitive)
- Removeddata-view-byte-offset@1.0.0(transitive)
- Removeddecamelize@1.2.0(transitive)
- Removeddefaults@1.0.4(transitive)
- Removeddefine-data-property@1.1.4(transitive)
- Removeddefine-properties@1.2.1(transitive)
- Removeddunder-proto@1.0.0(transitive)
- Removedes-abstract@1.23.5(transitive)
- Removedes-define-property@1.0.1(transitive)
- Removedes-errors@1.3.0(transitive)
- Removedes-object-atoms@1.0.0(transitive)
- Removedes-set-tostringtag@2.0.3(transitive)
- Removedes-shim-unscopables@1.0.2(transitive)
- Removedes-to-primitive@1.3.0(transitive)
- Removedescalade@3.2.0(transitive)
- Removedfind-up@4.1.0(transitive)
- Removedfor-each@0.3.3(transitive)
- Removedfunction-bind@1.1.2(transitive)
- Removedfunction.prototype.name@1.1.6(transitive)
- Removedfunctions-have-names@1.2.3(transitive)
- Removedget-caller-file@2.0.5(transitive)
- Removedget-intrinsic@1.2.6(transitive)
- Removedget-symbol-description@1.0.2(transitive)
- Removedglobalthis@1.0.4(transitive)
- Removedgopd@1.2.0(transitive)
- Removedgrapheme-splitter@1.0.4(transitive)
- Removedhas-bigints@1.0.2(transitive)
- Removedhas-property-descriptors@1.0.2(transitive)
- Removedhas-proto@1.2.0(transitive)
- Removedhas-symbols@1.1.0(transitive)
- Removedhas-tostringtag@1.0.2(transitive)
- Removedhasown@2.0.2(transitive)
- Removedinternal-slot@1.1.0(transitive)
- Removedis-array-buffer@3.0.4(transitive)
- Removedis-async-function@2.0.0(transitive)
- Removedis-bigint@1.1.0(transitive)
- Removedis-boolean-object@1.2.1(transitive)
- Removedis-callable@1.2.7(transitive)
- Removedis-data-view@1.0.2(transitive)
- Removedis-date-object@1.1.0(transitive)
- Removedis-finalizationregistry@1.1.0(transitive)
- Removedis-generator-function@1.0.10(transitive)
- Removedis-map@2.0.3(transitive)
- Removedis-negative-zero@2.0.3(transitive)
- Removedis-number-object@1.1.0(transitive)
- Removedis-regex@1.2.1(transitive)
- Removedis-set@2.0.3(transitive)
- Removedis-shared-array-buffer@1.0.3(transitive)
- Removedis-string@1.1.0(transitive)
- Removedis-symbol@1.1.1(transitive)
- Removedis-typed-array@1.1.13(transitive)
- Removedis-weakmap@2.0.2(transitive)
- Removedis-weakref@1.1.0(transitive)
- Removedis-weakset@2.0.3(transitive)
- Removedisarray@2.0.5(transitive)
- Removedkleur@4.1.5(transitive)
- Removedlocate-path@5.0.0(transitive)
- Removedmath-intrinsics@1.0.0(transitive)
- Removedmixme@0.5.10(transitive)
- Removedobject-inspect@1.13.3(transitive)
- Removedobject-keys@1.1.1(transitive)
- Removedobject.assign@4.1.5(transitive)
- Removedp-limit@2.3.0(transitive)
- Removedp-locate@4.1.0(transitive)
- Removedp-try@2.2.0(transitive)
- Removedpath-exists@4.0.0(transitive)
- Removedpossible-typed-array-names@1.0.0(transitive)
- Removedreflect.getprototypeof@1.0.8(transitive)
- Removedregexp.prototype.flags@1.5.3(transitive)
- Removedrequire-directory@2.1.1(transitive)
- Removedrequire-main-filename@2.0.0(transitive)
- Removedsafe-array-concat@1.1.3(transitive)
- Removedsafe-regex-test@1.1.0(transitive)
- Removedset-blocking@2.0.0(transitive)
- Removedset-function-length@1.2.2(transitive)
- Removedset-function-name@2.0.2(transitive)
- Removedside-channel@1.1.0(transitive)
- Removedside-channel-list@1.0.0(transitive)
- Removedside-channel-map@1.0.1(transitive)
- Removedside-channel-weakmap@1.0.2(transitive)
- Removedsmartwrap@2.0.2(transitive)
- Removedstream-transform@2.1.3(transitive)
- Removedstring.prototype.trim@1.2.10(transitive)
- Removedstring.prototype.trimend@1.0.9(transitive)
- Removedstring.prototype.trimstart@1.0.8(transitive)
- Removedtty-table@4.2.3(transitive)
- Removedtyped-array-buffer@1.0.2(transitive)
- Removedtyped-array-byte-length@1.0.1(transitive)
- Removedtyped-array-byte-offset@1.0.3(transitive)
- Removedtyped-array-length@1.0.7(transitive)
- Removedunbox-primitive@1.0.2(transitive)
- Removedwcwidth@1.0.1(transitive)
- Removedwhich-boxed-primitive@1.1.0(transitive)
- Removedwhich-builtin-type@1.2.1(transitive)
- Removedwhich-collection@1.0.2(transitive)
- Removedwhich-module@2.0.1(transitive)
- Removedwhich-typed-array@1.1.16(transitive)
- Removedwrap-ansi@6.2.0(transitive)
- Removedy18n@4.0.35.0.8(transitive)
- Removedyargs@15.4.117.7.2(transitive)
- Removedyargs-parser@18.1.321.1.1(transitive)