@oclif/plugin-commands 4.0.17 → 4.1.1

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/README.md CHANGED
@@ -21,7 +21,7 @@ $ npm install -g @oclif/plugin-commands
21
21
  $ oclif-example COMMAND
22
22
  running command...
23
23
  $ oclif-example (--version)
24
- @oclif/plugin-commands/4.0.17 linux-x64 node-v20.17.0
24
+ @oclif/plugin-commands/4.1.1 linux-x64 node-v20.17.0
25
25
  $ oclif-example --help [COMMAND]
26
26
  USAGE
27
27
  $ oclif-example COMMAND
@@ -61,7 +61,7 @@ DESCRIPTION
61
61
  List all oclif-example commands.
62
62
  ```
63
63
 
64
- _See code: [src/commands/commands.ts](https://github.com/oclif/plugin-commands/blob/v4.0.17/src/commands/commands.ts)_
64
+ _See code: [src/commands/commands.ts](https://github.com/oclif/plugin-commands/blob/v4.1.1/src/commands/commands.ts)_
65
65
  <!-- commandsstop -->
66
66
 
67
67
  # Contributing
@@ -1,8 +1,8 @@
1
1
  import { Command, Flags, toConfiguredId } from '@oclif/core';
2
+ import { printTable } from '@oclif/table';
2
3
  import _ from 'lodash';
3
4
  // @ts-expect-error because object-treeify does not have types: https://github.com/blackflux/object-treeify/issues/1077
4
5
  import treeify from 'object-treeify';
5
- import TtyTable from 'tty-table';
6
6
  const COLUMNS = ['id', 'plugin', 'summary', 'type'];
7
7
  function createTree(commands) {
8
8
  const tree = {};
@@ -16,22 +16,6 @@ function createTree(commands) {
16
16
  }
17
17
  return tree;
18
18
  }
19
- function determineHeaders(columns, extended) {
20
- const columnConfigs = {
21
- id: { align: 'left', value: 'ID', width: '25%' },
22
- plugin: { align: 'left', value: 'Plugin' },
23
- summary: { align: 'left', value: 'Summary', width: '75%' },
24
- type: { align: 'left', value: 'Type' },
25
- };
26
- if (columns) {
27
- return columns.map((column) => columnConfigs[column]);
28
- }
29
- if (extended) {
30
- return [columnConfigs.id, columnConfigs.summary, columnConfigs.plugin, columnConfigs.type];
31
- }
32
- return [columnConfigs.id, columnConfigs.summary];
33
- }
34
- // In order to collect static properties up the inheritance chain, we need to recursively access the prototypes until there's nothing left
35
19
  function mergePrototype(result, command) {
36
20
  const proto = Object.getPrototypeOf(command);
37
21
  const filteredProto = _.pickBy(proto, (v) => v !== undefined);
@@ -84,34 +68,22 @@ export default class Commands extends Command {
84
68
  const tree = createTree(commands);
85
69
  this.log(treeify(tree));
86
70
  }
87
- else {
88
- const headers = determineHeaders(flags.columns, flags.extended);
89
- const extractData = (command) => headers.map((header) => {
90
- switch (header.value) {
91
- case 'ID': {
92
- return toConfiguredId(command.id, config);
93
- }
94
- case 'Plugin': {
95
- return command.pluginName;
96
- }
97
- case 'Type': {
98
- return command.pluginType;
99
- }
100
- case 'Summary': {
101
- return command.summary ?? command.description;
102
- }
103
- default: {
104
- throw new Error('Unknown column');
105
- }
106
- }
107
- });
108
- // eslint-disable-next-line new-cap
109
- const table = TtyTable(headers, commands.map((c) => extractData(c)), {
110
- compact: true,
111
- defaultValue: '',
112
- truncate: flags['no-truncate'] ? undefined : '...',
71
+ else if (!this.jsonEnabled()) {
72
+ printTable({
73
+ borderStyle: 'vertical-with-outline',
74
+ columns: (flags.columns ?? ['id', 'summary', ...(flags.extended ? ['plugin', 'type'] : [])]),
75
+ data: commands.map((c) => ({
76
+ id: toConfiguredId(c.id, config),
77
+ plugin: c.pluginName,
78
+ summary: c.summary ?? c.description,
79
+ type: c.pluginType,
80
+ })),
81
+ headerOptions: {
82
+ formatter: 'capitalCase',
83
+ },
84
+ overflow: flags['no-truncate'] ? 'wrap' : 'truncate',
85
+ sort: { [flags.sort]: 'asc' },
113
86
  });
114
- this.log(table.render());
115
87
  }
116
88
  const json = _.uniqBy(await Promise.all(commands.map(async (cmd) => {
117
89
  let commandClass;
@@ -105,5 +105,5 @@
105
105
  ]
106
106
  }
107
107
  },
108
- "version": "4.0.17"
108
+ "version": "4.1.1"
109
109
  }
package/package.json CHANGED
@@ -1,14 +1,14 @@
1
1
  {
2
2
  "name": "@oclif/plugin-commands",
3
3
  "description": "plugin to show the list of all the commands",
4
- "version": "4.0.17",
4
+ "version": "4.1.1",
5
5
  "author": "Salesforce",
6
6
  "bugs": "https://github.com/oclif/plugin-commands/issues",
7
7
  "dependencies": {
8
8
  "@oclif/core": "^4",
9
+ "@oclif/table": "^0.1.13",
9
10
  "lodash": "^4.17.21",
10
- "object-treeify": "^4.0.1",
11
- "tty-table": "^4.2.3"
11
+ "object-treeify": "^4.0.1"
12
12
  },
13
13
  "devDependencies": {
14
14
  "@commitlint/config-conventional": "^19",