@oclif/plugin-commands 2.1.0 → 2.2.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 +5 -4
- package/lib/commands/commands.d.ts +1 -1
- package/lib/commands/commands.js +10 -2
- package/lib/utils/tree.d.ts +4 -0
- package/lib/utils/tree.js +27 -0
- package/oclif.manifest.json +1 -1
- package/package.json +4 -4
- package/yarn.lock +13 -13
- package/CHANGELOG.md +0 -78
package/README.md
CHANGED
|
@@ -20,7 +20,7 @@ $ npm install -g @oclif/plugin-commands
|
|
|
20
20
|
$ oclif-example COMMAND
|
|
21
21
|
running command...
|
|
22
22
|
$ oclif-example (--version)
|
|
23
|
-
@oclif/plugin-commands/2.1
|
|
23
|
+
@oclif/plugin-commands/2.2.1 linux-x64 node-v18.12.0
|
|
24
24
|
$ oclif-example --help [COMMAND]
|
|
25
25
|
USAGE
|
|
26
26
|
$ oclif-example COMMAND
|
|
@@ -37,8 +37,8 @@ list all the commands
|
|
|
37
37
|
|
|
38
38
|
```
|
|
39
39
|
USAGE
|
|
40
|
-
$ oclif-example commands [--json] [-h] [--hidden] [--columns <value> | -x] [--sort <value>]
|
|
41
|
-
<value>] [--output csv|json|yaml | | [--csv | --no-truncate]] [--no-header | ]
|
|
40
|
+
$ oclif-example commands [--json] [-h] [--hidden] [--tree] [--columns <value> | -x] [--sort <value>]
|
|
41
|
+
[--filter <value>] [--output csv|json|yaml | | [--csv | --no-truncate]] [--no-header | ]
|
|
42
42
|
|
|
43
43
|
FLAGS
|
|
44
44
|
-h, --help Show CLI help.
|
|
@@ -52,6 +52,7 @@ FLAGS
|
|
|
52
52
|
--output=<option> output in a more machine friendly format
|
|
53
53
|
<options: csv|json|yaml>
|
|
54
54
|
--sort=<value> property to sort by (prepend '-' for descending)
|
|
55
|
+
--tree show tree of commands
|
|
55
56
|
|
|
56
57
|
GLOBAL FLAGS
|
|
57
58
|
--json Format output as json.
|
|
@@ -60,5 +61,5 @@ DESCRIPTION
|
|
|
60
61
|
list all the commands
|
|
61
62
|
```
|
|
62
63
|
|
|
63
|
-
_See code: [src/commands/commands.ts](https://github.com/oclif/plugin-commands/blob/v2.1
|
|
64
|
+
_See code: [src/commands/commands.ts](https://github.com/oclif/plugin-commands/blob/v2.2.1/src/commands/commands.ts)_
|
|
64
65
|
<!-- commandsstop -->
|
|
@@ -3,7 +3,7 @@ export default class Commands extends Command {
|
|
|
3
3
|
static description: string;
|
|
4
4
|
static enableJsonFlag: boolean;
|
|
5
5
|
static flags: any;
|
|
6
|
-
run(): Promise<unknown[] | undefined>;
|
|
6
|
+
run(): Promise<unknown[] | import("@oclif/core/lib/cli-ux/styled/tree").Tree | undefined>;
|
|
7
7
|
private getCommands;
|
|
8
8
|
private removeCycles;
|
|
9
9
|
}
|
package/lib/commands/commands.js
CHANGED
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
const core_1 = require("@oclif/core");
|
|
4
4
|
const _ = require("lodash");
|
|
5
5
|
const os_1 = require("os");
|
|
6
|
+
const tree_1 = require("../utils/tree");
|
|
6
7
|
class Commands extends core_1.Command {
|
|
7
8
|
async run() {
|
|
8
9
|
const { flags } = await this.parse(Commands);
|
|
@@ -19,7 +20,7 @@ class Commands extends core_1.Command {
|
|
|
19
20
|
command.id = (0, core_1.toConfiguredId)(command.id, this.config);
|
|
20
21
|
return command;
|
|
21
22
|
});
|
|
22
|
-
if (this.jsonEnabled()) {
|
|
23
|
+
if (this.jsonEnabled() && !flags.tree) {
|
|
23
24
|
const formatted = await Promise.all(commands.map(async (cmd) => {
|
|
24
25
|
let commandClass = await cmd.load();
|
|
25
26
|
const obj = Object.assign(Object.assign({}, cmd), commandClass);
|
|
@@ -35,6 +36,13 @@ class Commands extends core_1.Command {
|
|
|
35
36
|
}));
|
|
36
37
|
return formatted;
|
|
37
38
|
}
|
|
39
|
+
if (flags.tree) {
|
|
40
|
+
const tree = (0, tree_1.default)(commands, this.config.topicSeparator);
|
|
41
|
+
if (!this.jsonEnabled()) {
|
|
42
|
+
tree.display();
|
|
43
|
+
}
|
|
44
|
+
return tree;
|
|
45
|
+
}
|
|
38
46
|
core_1.CliUx.ux.table(commands.map(command => {
|
|
39
47
|
// Massage some fields so it looks good in the table
|
|
40
48
|
command.description = (command.description || '').split(os_1.EOL)[0];
|
|
@@ -105,4 +113,4 @@ class Commands extends core_1.Command {
|
|
|
105
113
|
exports.default = Commands;
|
|
106
114
|
Commands.description = 'list all the commands';
|
|
107
115
|
Commands.enableJsonFlag = true;
|
|
108
|
-
Commands.flags = Object.assign({ help: core_1.Flags.help({ char: 'h' }), hidden: core_1.Flags.boolean({ description: 'show hidden commands' }) }, core_1.CliUx.ux.table.flags());
|
|
116
|
+
Commands.flags = Object.assign({ help: core_1.Flags.help({ char: 'h' }), hidden: core_1.Flags.boolean({ description: 'show hidden commands' }), tree: core_1.Flags.boolean({ description: 'show tree of commands' }) }, core_1.CliUx.ux.table.flags());
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const core_1 = require("@oclif/core");
|
|
4
|
+
const addNodes = (tree, commandParts) => {
|
|
5
|
+
const existingNode = tree.search(commandParts[0]);
|
|
6
|
+
// If the node exists and there's another part, add it to the node
|
|
7
|
+
if (existingNode && commandParts[1]) {
|
|
8
|
+
addNodes(existingNode, commandParts.slice(1));
|
|
9
|
+
}
|
|
10
|
+
else {
|
|
11
|
+
// The node doesn't exist, create it
|
|
12
|
+
tree.insert(commandParts[0]);
|
|
13
|
+
// If there are more parts, add them to the node
|
|
14
|
+
if (commandParts.length > 1) {
|
|
15
|
+
addNodes(tree.search(commandParts[0]), commandParts.slice(1));
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
const createCommandTree = (commands, topicSeparator = ':') => {
|
|
20
|
+
const tree = core_1.CliUx.ux.tree();
|
|
21
|
+
commands.forEach(command => {
|
|
22
|
+
const commandParts = command.id.split(topicSeparator);
|
|
23
|
+
addNodes(tree, commandParts);
|
|
24
|
+
});
|
|
25
|
+
return tree;
|
|
26
|
+
};
|
|
27
|
+
exports.default = createCommandTree;
|
package/oclif.manifest.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":"2.1
|
|
1
|
+
{"version":"2.2.1","commands":{"commands":{"id":"commands","description":"list all the commands","strict":true,"pluginName":"@oclif/plugin-commands","pluginAlias":"@oclif/plugin-commands","pluginType":"core","aliases":[],"flags":{"json":{"name":"json","type":"boolean","description":"Format output as json.","helpGroup":"GLOBAL","allowNo":false},"help":{"name":"help","type":"boolean","char":"h","description":"Show CLI help.","allowNo":false},"hidden":{"name":"hidden","type":"boolean","description":"show hidden commands","allowNo":false},"tree":{"name":"tree","type":"boolean","description":"show tree of commands","allowNo":false},"columns":{"name":"columns","type":"option","description":"only show provided columns (comma-separated)","multiple":false,"exclusive":["extended"]},"sort":{"name":"sort","type":"option","description":"property to sort by (prepend '-' for descending)","multiple":false},"filter":{"name":"filter","type":"option","description":"filter property by partial string matching, ex: name=foo","multiple":false},"csv":{"name":"csv","type":"boolean","description":"output is csv format [alias: --output=csv]","allowNo":false,"exclusive":["no-truncate"]},"output":{"name":"output","type":"option","description":"output in a more machine friendly format","multiple":false,"options":["csv","json","yaml"],"exclusive":["no-truncate","csv"]},"extended":{"name":"extended","type":"boolean","char":"x","description":"show extra columns","allowNo":false,"exclusive":["columns"]},"no-truncate":{"name":"no-truncate","type":"boolean","description":"do not truncate output to fit screen","allowNo":false,"exclusive":["csv"]},"no-header":{"name":"no-header","type":"boolean","description":"hide table header from output","allowNo":false,"exclusive":["csv"]}},"args":[],"enableJsonFlag":true}}}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oclif/plugin-commands",
|
|
3
3
|
"description": "plugin to show the list of all the commands",
|
|
4
|
-
"version": "2.1
|
|
4
|
+
"version": "2.2.1",
|
|
5
5
|
"author": "Salesforce",
|
|
6
6
|
"bugs": "https://github.com/oclif/plugin-commands/issues",
|
|
7
7
|
"dependencies": {
|
|
@@ -12,10 +12,10 @@
|
|
|
12
12
|
"@oclif/plugin-help": "^5.1.7",
|
|
13
13
|
"@oclif/test": "^2.0.2",
|
|
14
14
|
"@types/chai": "^4.1.6",
|
|
15
|
-
"@types/lodash": "^4.14.
|
|
15
|
+
"@types/lodash": "^4.14.186",
|
|
16
16
|
"@types/mocha": "^8.0.0",
|
|
17
17
|
"@types/nock": "^11.1.0",
|
|
18
|
-
"@types/node": "^14.
|
|
18
|
+
"@types/node": "^14.18.33",
|
|
19
19
|
"chai": "^4.2.0",
|
|
20
20
|
"eslint": "^7.3.1",
|
|
21
21
|
"eslint-config-oclif": "^3.1.0",
|
|
@@ -61,4 +61,4 @@
|
|
|
61
61
|
"version": "oclif readme && git add README.md",
|
|
62
62
|
"build": "shx rm -rf lib && tsc"
|
|
63
63
|
}
|
|
64
|
-
}
|
|
64
|
+
}
|
package/yarn.lock
CHANGED
|
@@ -663,10 +663,10 @@
|
|
|
663
663
|
resolved "https://registry.yarnpkg.com/@types/json-schema/-/json-schema-7.0.3.tgz#bdfd69d61e464dcc81b25159c270d75a73c1a636"
|
|
664
664
|
integrity sha512-Il2DtDVRGDcqjDtE+rF8iqg1CArehSK84HZJCT7AMITlyXRBpuPhqGLDQMowraqqu1coEaimg4ZOqggt6L6L+A==
|
|
665
665
|
|
|
666
|
-
"@types/lodash@*", "@types/lodash@^4.14.
|
|
667
|
-
version "4.14.
|
|
668
|
-
resolved "https://registry.yarnpkg.com/@types/lodash/-/lodash-4.14.
|
|
669
|
-
integrity sha512-
|
|
666
|
+
"@types/lodash@*", "@types/lodash@^4.14.186":
|
|
667
|
+
version "4.14.186"
|
|
668
|
+
resolved "https://registry.yarnpkg.com/@types/lodash/-/lodash-4.14.186.tgz#862e5514dd7bd66ada6c70ee5fce844b06c8ee97"
|
|
669
|
+
integrity sha512-eHcVlLXP0c2FlMPm56ITode2AgLMSa6aJ05JTTbYbI+7EMkCEE5qk2E41d5g2lCVTqRe0GnnRFurmlCsDODrPw==
|
|
670
670
|
|
|
671
671
|
"@types/minimatch@*", "@types/minimatch@^3.0.3":
|
|
672
672
|
version "3.0.5"
|
|
@@ -685,16 +685,16 @@
|
|
|
685
685
|
dependencies:
|
|
686
686
|
nock "*"
|
|
687
687
|
|
|
688
|
-
"@types/node@*", "@types/node@^
|
|
689
|
-
version "14.14.41"
|
|
690
|
-
resolved "https://registry.yarnpkg.com/@types/node/-/node-14.14.41.tgz#d0b939d94c1d7bd53d04824af45f1139b8c45615"
|
|
691
|
-
integrity sha512-dueRKfaJL4RTtSa7bWeTK1M+VH+Gns73oCgzvYfHZywRCoPSd8EkXBL0mZ9unPTveBn+D9phZBaxuzpwjWkW0g==
|
|
692
|
-
|
|
693
|
-
"@types/node@^15.6.1":
|
|
688
|
+
"@types/node@*", "@types/node@^15.6.1":
|
|
694
689
|
version "15.14.9"
|
|
695
690
|
resolved "https://registry.npmjs.org/@types/node/-/node-15.14.9.tgz#bc43c990c3c9be7281868bbc7b8fdd6e2b57adfa"
|
|
696
691
|
integrity sha512-qjd88DrCxupx/kJD5yQgZdcYKZKSIGBVDIBE1/LTGcNm3d2Np/jxojkdePDdfnBHJc5W7vSMpbJ1aB7p/Py69A==
|
|
697
692
|
|
|
693
|
+
"@types/node@^14.18.33":
|
|
694
|
+
version "14.18.33"
|
|
695
|
+
resolved "https://registry.yarnpkg.com/@types/node/-/node-14.18.33.tgz#8c29a0036771569662e4635790ffa9e057db379b"
|
|
696
|
+
integrity sha512-qelS/Ra6sacc4loe/3MSjXNL1dNQ/GjxNHVzuChwMfmk7HuycRLVQN2qNY3XahK+fZc5E2szqQSKUyAF0E+2bg==
|
|
697
|
+
|
|
698
698
|
"@types/normalize-package-data@^2.4.0":
|
|
699
699
|
version "2.4.1"
|
|
700
700
|
resolved "https://registry.yarnpkg.com/@types/normalize-package-data/-/normalize-package-data-2.4.1.tgz#d3357479a0fdfdd5907fe67e17e0a85c906e1301"
|
|
@@ -3549,9 +3549,9 @@ min-document@^2.19.0:
|
|
|
3549
3549
|
brace-expansion "^1.1.7"
|
|
3550
3550
|
|
|
3551
3551
|
minimist@^1.1.0, minimist@^1.1.3, minimist@^1.2.3, minimist@^1.2.5:
|
|
3552
|
-
version "1.2.
|
|
3553
|
-
resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.
|
|
3554
|
-
integrity sha512-
|
|
3552
|
+
version "1.2.7"
|
|
3553
|
+
resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.7.tgz#daa1c4d91f507390437c6a8bc01078e7000c4d18"
|
|
3554
|
+
integrity sha512-bzfL1YUZsP41gmu/qjrEk0Q6i2ix/cVeAhbCbqH9u3zYutS1cLg00qhrD0M2MVdCcx4Sc0UpP2eBWo9rotpq6g==
|
|
3555
3555
|
|
|
3556
3556
|
minipass-collect@^1.0.2:
|
|
3557
3557
|
version "1.0.2"
|
package/CHANGELOG.md
DELETED
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
# Changelog
|
|
2
|
-
|
|
3
|
-
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
|
4
|
-
|
|
5
|
-
## [2.1.0](https://github.com/oclif/plugin-commands/compare/v2.0.2...v2.1.0) (2022-01-28)
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
### Features
|
|
9
|
-
|
|
10
|
-
* remove cli-ux ([#257](https://github.com/oclif/plugin-commands/issues/257)) ([91d8696](https://github.com/oclif/plugin-commands/commit/91d8696bff375e622092744ab005daabf12c34d2))
|
|
11
|
-
|
|
12
|
-
### [2.0.2](https://github.com/oclif/plugin-commands/compare/v2.0.0...v2.0.2) (2022-01-03)
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
### Bug Fixes
|
|
16
|
-
|
|
17
|
-
* add summary and use configured command ([#217](https://github.com/oclif/plugin-commands/issues/217)) ([d1ce99e](https://github.com/oclif/plugin-commands/commit/d1ce99eb233155e019a585177972188953b0ffaf))
|
|
18
|
-
* build error ([6cc7807](https://github.com/oclif/plugin-commands/commit/6cc780725e5dbb64fbc105206cc580bf45325749))
|
|
19
|
-
* bump deps ([#234](https://github.com/oclif/plugin-commands/issues/234)) ([04c903d](https://github.com/oclif/plugin-commands/commit/04c903d45a51987f6262628c7a401481dc237145))
|
|
20
|
-
* bump deps and fix tests ([#236](https://github.com/oclif/plugin-commands/issues/236)) ([064da3f](https://github.com/oclif/plugin-commands/commit/064da3f22778c9625c640012b883eee8c1528ab1))
|
|
21
|
-
* bump-deps ([#235](https://github.com/oclif/plugin-commands/issues/235)) ([55b3e59](https://github.com/oclif/plugin-commands/commit/55b3e59e0743078d2bf81bfa75a56ebd0b746c4b))
|
|
22
|
-
* use enableJsonFlag to enable json output ([#253](https://github.com/oclif/plugin-commands/issues/253)) ([5c839bc](https://github.com/oclif/plugin-commands/commit/5c839bc3d5b079c3080858ca4bc704283ff9d345))
|
|
23
|
-
|
|
24
|
-
## [1.2.2](https://github.com/oclif/plugin-commands/compare/v1.2.1...v1.2.2) (2018-10-13)
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
### Bug Fixes
|
|
28
|
-
|
|
29
|
-
* remove greenkeeper badge ([2bf582a](https://github.com/oclif/plugin-commands/commit/2bf582a))
|
|
30
|
-
|
|
31
|
-
## [1.2.1](https://github.com/oclif/plugin-commands/compare/v1.2.0...v1.2.1) (2018-09-14)
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
### Bug Fixes
|
|
35
|
-
|
|
36
|
-
* updated deps ([adf0726](https://github.com/oclif/plugin-commands/commit/adf0726))
|
|
37
|
-
|
|
38
|
-
# [1.2.0](https://github.com/oclif/plugin-commands/compare/v1.1.3...v1.2.0) (2018-08-17)
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
### Features
|
|
42
|
-
|
|
43
|
-
* typescript 3 ([8267ff5](https://github.com/oclif/plugin-commands/commit/8267ff5))
|
|
44
|
-
|
|
45
|
-
<a name="1.1.1"></a>
|
|
46
|
-
## [1.1.1](https://github.com/oclif/plugin-commands/compare/v1.1.0...v1.1.1) (2018-06-01)
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
### Bug Fixes
|
|
50
|
-
|
|
51
|
-
* updated deps ([22d6a13](https://github.com/oclif/plugin-commands/commit/22d6a13))
|
|
52
|
-
|
|
53
|
-
<a name="1.1.0"></a>
|
|
54
|
-
# [1.1.0](https://github.com/oclif/plugin-commands/compare/v1.0.0...v1.1.0) (2018-05-31)
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
### Features
|
|
58
|
-
|
|
59
|
-
* add --hidden flag ([e6b9424](https://github.com/oclif/plugin-commands/commit/e6b9424))
|
|
60
|
-
|
|
61
|
-
<a name="1.0.0"></a>
|
|
62
|
-
# 1.0.0 (2018-05-31)
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
### Bug Fixes
|
|
66
|
-
|
|
67
|
-
* updated deps ([ef81977](https://github.com/oclif/plugin-commands/commit/ef81977))
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
### Features
|
|
71
|
-
|
|
72
|
-
* init ([03864cc](https://github.com/oclif/plugin-commands/commit/03864cc))
|
|
73
|
-
* sort commands by id ([9cb157a](https://github.com/oclif/plugin-commands/commit/9cb157a))
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
### BREAKING CHANGES
|
|
77
|
-
|
|
78
|
-
* v1
|