@oclif/plugin-commands 1.2.3 → 2.0.2
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/CHANGELOG.md +16 -0
- package/README.md +26 -12
- package/lib/commands/commands.d.ts +6 -7
- package/lib/commands/commands.js +97 -17
- package/oclif.manifest.json +1 -1
- package/package.json +31 -25
- package/yarn.lock +4042 -1163
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,19 @@
|
|
|
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.0.2](https://github.com/oclif/plugin-commands/compare/v2.0.0...v2.0.2) (2022-01-03)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
* add summary and use configured command ([#217](https://github.com/oclif/plugin-commands/issues/217)) ([d1ce99e](https://github.com/oclif/plugin-commands/commit/d1ce99eb233155e019a585177972188953b0ffaf))
|
|
11
|
+
* build error ([6cc7807](https://github.com/oclif/plugin-commands/commit/6cc780725e5dbb64fbc105206cc580bf45325749))
|
|
12
|
+
* bump deps ([#234](https://github.com/oclif/plugin-commands/issues/234)) ([04c903d](https://github.com/oclif/plugin-commands/commit/04c903d45a51987f6262628c7a401481dc237145))
|
|
13
|
+
* bump deps and fix tests ([#236](https://github.com/oclif/plugin-commands/issues/236)) ([064da3f](https://github.com/oclif/plugin-commands/commit/064da3f22778c9625c640012b883eee8c1528ab1))
|
|
14
|
+
* bump-deps ([#235](https://github.com/oclif/plugin-commands/issues/235)) ([55b3e59](https://github.com/oclif/plugin-commands/commit/55b3e59e0743078d2bf81bfa75a56ebd0b746c4b))
|
|
15
|
+
* use enableJsonFlag to enable json output ([#253](https://github.com/oclif/plugin-commands/issues/253)) ([5c839bc](https://github.com/oclif/plugin-commands/commit/5c839bc3d5b079c3080858ca4bc704283ff9d345))
|
|
16
|
+
|
|
1
17
|
## [1.2.2](https://github.com/oclif/plugin-commands/compare/v1.2.1...v1.2.2) (2018-10-13)
|
|
2
18
|
|
|
3
19
|
|
package/README.md
CHANGED
|
@@ -4,11 +4,10 @@
|
|
|
4
4
|
plugin to show the list of all the commands
|
|
5
5
|
|
|
6
6
|
[](https://npmjs.org/package/@oclif/plugin-commands)
|
|
7
|
-
[](https://codecov.io/gh/oclif/plugin-commands)
|
|
7
|
+
[](https://circleci.com/gh/oclif/plugin-commands/tree/main)
|
|
8
|
+
[](https://ci.appveyor.com/project/oclif/plugin-commands/branch/main)
|
|
10
9
|
[](https://npmjs.org/package/@oclif/plugin-commands)
|
|
11
|
-
[](https://github.com/oclif/plugin-commands/blob/
|
|
10
|
+
[](https://github.com/oclif/plugin-commands/blob/main/package.json)
|
|
12
11
|
|
|
13
12
|
<!-- toc -->
|
|
14
13
|
* [Usage](#usage)
|
|
@@ -20,8 +19,8 @@ plugin to show the list of all the commands
|
|
|
20
19
|
$ npm install -g @oclif/plugin-commands
|
|
21
20
|
$ oclif-example COMMAND
|
|
22
21
|
running command...
|
|
23
|
-
$ oclif-example (
|
|
24
|
-
@oclif/plugin-commands/
|
|
22
|
+
$ oclif-example (--version)
|
|
23
|
+
@oclif/plugin-commands/2.0.2 linux-x64 node-v12.22.8
|
|
25
24
|
$ oclif-example --help [COMMAND]
|
|
26
25
|
USAGE
|
|
27
26
|
$ oclif-example COMMAND
|
|
@@ -38,13 +37,28 @@ list all the commands
|
|
|
38
37
|
|
|
39
38
|
```
|
|
40
39
|
USAGE
|
|
41
|
-
$ oclif-example commands
|
|
40
|
+
$ oclif-example commands [--json] [-h] [--hidden] [--columns <value> | -x] [--sort <value>] [--filter
|
|
41
|
+
<value>] [--output csv|json|yaml | | [--csv | --no-truncate]] [--no-header | ]
|
|
42
42
|
|
|
43
|
-
|
|
44
|
-
-h, --help
|
|
45
|
-
-
|
|
46
|
-
--
|
|
43
|
+
FLAGS
|
|
44
|
+
-h, --help Show CLI help.
|
|
45
|
+
-x, --extended show extra columns
|
|
46
|
+
--columns=<value> only show provided columns (comma-separated)
|
|
47
|
+
--csv output is csv format [alias: --output=csv]
|
|
48
|
+
--filter=<value> filter property by partial string matching, ex: name=foo
|
|
49
|
+
--hidden show hidden commands
|
|
50
|
+
--no-header hide table header from output
|
|
51
|
+
--no-truncate do not truncate output to fit screen
|
|
52
|
+
--output=<option> output in a more machine friendly format
|
|
53
|
+
<options: csv|json|yaml>
|
|
54
|
+
--sort=<value> property to sort by (prepend '-' for descending)
|
|
55
|
+
|
|
56
|
+
GLOBAL FLAGS
|
|
57
|
+
--json Format output as json.
|
|
58
|
+
|
|
59
|
+
DESCRIPTION
|
|
60
|
+
list all the commands
|
|
47
61
|
```
|
|
48
62
|
|
|
49
|
-
_See code: [src/commands/commands.ts](https://github.com/oclif/plugin-commands/blob/
|
|
63
|
+
_See code: [src/commands/commands.ts](https://github.com/oclif/plugin-commands/blob/v2.0.2/src/commands/commands.ts)_
|
|
50
64
|
<!-- commandsstop -->
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import { Command } from '@oclif/
|
|
1
|
+
import { Command } from '@oclif/core';
|
|
2
2
|
export default class Commands extends Command {
|
|
3
3
|
static description: string;
|
|
4
|
-
static
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
run(): Promise<void>;
|
|
4
|
+
static enableJsonFlag: boolean;
|
|
5
|
+
static flags: any;
|
|
6
|
+
run(): Promise<unknown[] | undefined>;
|
|
7
|
+
private getCommands;
|
|
8
|
+
private removeCycles;
|
|
10
9
|
}
|
package/lib/commands/commands.js
CHANGED
|
@@ -1,30 +1,110 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const
|
|
3
|
+
const core_1 = require("@oclif/core");
|
|
4
4
|
const cli_ux_1 = require("cli-ux");
|
|
5
5
|
const _ = require("lodash");
|
|
6
|
-
|
|
6
|
+
const os_1 = require("os");
|
|
7
|
+
class Commands extends core_1.Command {
|
|
7
8
|
async run() {
|
|
8
|
-
const { flags } = this.parse(Commands);
|
|
9
|
-
let commands = this.
|
|
9
|
+
const { flags } = await this.parse(Commands);
|
|
10
|
+
let commands = this.getCommands();
|
|
10
11
|
if (!flags.hidden) {
|
|
11
12
|
commands = commands.filter(c => !c.hidden);
|
|
12
13
|
}
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
const config = this.config;
|
|
15
|
+
commands = _.sortBy(commands, 'id').map(command => {
|
|
16
|
+
// Template supported fields.
|
|
17
|
+
command.description = (typeof command.description === 'string' && _.template(command.description)({ command, config })) || undefined;
|
|
18
|
+
command.summary = (typeof command.summary === 'string' && _.template(command.summary)({ command, config })) || undefined;
|
|
19
|
+
command.usage = (typeof command.usage === 'string' && _.template(command.usage)({ command, config })) || undefined;
|
|
20
|
+
command.id = (0, core_1.toConfiguredId)(command.id, this.config);
|
|
21
|
+
return command;
|
|
22
|
+
});
|
|
23
|
+
if (this.jsonEnabled()) {
|
|
24
|
+
const formatted = await Promise.all(commands.map(async (cmd) => {
|
|
25
|
+
let commandClass = await cmd.load();
|
|
26
|
+
const obj = Object.assign(Object.assign({}, cmd), commandClass);
|
|
27
|
+
// Load all properties on all extending classes.
|
|
28
|
+
while (commandClass !== undefined) {
|
|
29
|
+
commandClass = Object.getPrototypeOf(commandClass) || undefined;
|
|
30
|
+
Object.assign(obj, commandClass);
|
|
31
|
+
}
|
|
32
|
+
// The plugin property on the loaded class contains a LOT of information including all the commands again. Remove it.
|
|
33
|
+
delete obj.plugin;
|
|
34
|
+
// If Command classes have circular references, don't break the commands command.
|
|
35
|
+
return this.removeCycles(obj);
|
|
36
|
+
}));
|
|
37
|
+
return formatted;
|
|
16
38
|
}
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
39
|
+
cli_ux_1.ux.table(commands.map(command => {
|
|
40
|
+
// Massage some fields so it looks good in the table
|
|
41
|
+
command.description = (command.description || '').split(os_1.EOL)[0];
|
|
42
|
+
command.summary = (command.summary || (command.description || '').split(os_1.EOL)[0]);
|
|
43
|
+
command.hidden = Boolean(command.hidden);
|
|
44
|
+
command.usage = (command.usage || '');
|
|
45
|
+
return command;
|
|
46
|
+
}), {
|
|
47
|
+
id: {
|
|
48
|
+
header: 'Command',
|
|
49
|
+
},
|
|
50
|
+
summary: {},
|
|
51
|
+
description: {
|
|
52
|
+
extended: true,
|
|
53
|
+
},
|
|
54
|
+
usage: {
|
|
55
|
+
extended: true,
|
|
56
|
+
},
|
|
57
|
+
pluginName: {
|
|
58
|
+
extended: true,
|
|
59
|
+
header: 'Plugin',
|
|
60
|
+
},
|
|
61
|
+
pluginType: {
|
|
62
|
+
extended: true,
|
|
63
|
+
header: 'Type',
|
|
64
|
+
},
|
|
65
|
+
hidden: {
|
|
66
|
+
extended: true,
|
|
67
|
+
},
|
|
68
|
+
}, Object.assign({}, flags));
|
|
69
|
+
}
|
|
70
|
+
getCommands() {
|
|
71
|
+
return this.config.commands;
|
|
72
|
+
}
|
|
73
|
+
removeCycles(object) {
|
|
74
|
+
// Keep track of seen objects.
|
|
75
|
+
const seenObjects = new WeakMap();
|
|
76
|
+
const _removeCycles = (obj) => {
|
|
77
|
+
// Use object prototype to get around type and null checks
|
|
78
|
+
if (Object.prototype.toString.call(obj) === '[object Object]') {
|
|
79
|
+
// We know it is a "Dictionary" because of the conditional
|
|
80
|
+
const dictionary = obj;
|
|
81
|
+
if (seenObjects.has(dictionary)) {
|
|
82
|
+
// Seen, return undefined to remove.
|
|
83
|
+
return undefined;
|
|
84
|
+
}
|
|
85
|
+
seenObjects.set(dictionary, undefined);
|
|
86
|
+
for (const key in dictionary) {
|
|
87
|
+
// Delete the duplicate object if cycle found.
|
|
88
|
+
if (_removeCycles(dictionary[key]) === undefined) {
|
|
89
|
+
delete dictionary[key];
|
|
90
|
+
}
|
|
91
|
+
}
|
|
20
92
|
}
|
|
21
|
-
|
|
93
|
+
else if (Array.isArray(obj)) {
|
|
94
|
+
for (const i in obj) {
|
|
95
|
+
if (_removeCycles(obj[i]) === undefined) {
|
|
96
|
+
// We don't want to delete the array, but we can replace the element with null.
|
|
97
|
+
obj[i] = null;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
return obj;
|
|
102
|
+
};
|
|
103
|
+
return _removeCycles(object);
|
|
22
104
|
}
|
|
23
105
|
}
|
|
24
|
-
Commands.description = 'list all the commands';
|
|
25
|
-
Commands.flags = {
|
|
26
|
-
help: command_1.flags.help({ char: 'h' }),
|
|
27
|
-
json: command_1.flags.boolean({ char: 'j', description: 'output in json format' }),
|
|
28
|
-
hidden: command_1.flags.boolean({ description: 'also show hidden commands' }),
|
|
29
|
-
};
|
|
30
106
|
exports.default = Commands;
|
|
107
|
+
Commands.description = 'list all the commands';
|
|
108
|
+
Commands.enableJsonFlag = true;
|
|
109
|
+
// to-do: update this type when cli-ux is on core
|
|
110
|
+
Commands.flags = Object.assign({ help: core_1.Flags.help({ char: 'h' }), hidden: core_1.Flags.boolean({ description: 'show hidden commands' }) }, cli_ux_1.ux.table.flags());
|
package/oclif.manifest.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":"
|
|
1
|
+
{"version":"2.0.2","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},"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,35 +1,38 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oclif/plugin-commands",
|
|
3
3
|
"description": "plugin to show the list of all the commands",
|
|
4
|
-
"version": "
|
|
5
|
-
"author": "
|
|
4
|
+
"version": "2.0.2",
|
|
5
|
+
"author": "Salesforce",
|
|
6
6
|
"bugs": "https://github.com/oclif/plugin-commands/issues",
|
|
7
7
|
"dependencies": {
|
|
8
|
-
"@oclif/
|
|
9
|
-
"
|
|
10
|
-
"
|
|
11
|
-
"lodash": "^4.17.11",
|
|
12
|
-
"tslib": "^1.9.3"
|
|
8
|
+
"@oclif/core": "^1.0.8",
|
|
9
|
+
"cli-ux": "^6.0.5",
|
|
10
|
+
"lodash": "^4.17.11"
|
|
13
11
|
},
|
|
14
12
|
"devDependencies": {
|
|
15
|
-
"@oclif/
|
|
16
|
-
"@oclif/
|
|
17
|
-
"@oclif/test": "^1.2.1",
|
|
18
|
-
"@oclif/tslint": "^3.1.0",
|
|
13
|
+
"@oclif/plugin-help": "^5.1.7",
|
|
14
|
+
"@oclif/test": "^2.0.2",
|
|
19
15
|
"@types/chai": "^4.1.6",
|
|
20
16
|
"@types/lodash": "^4.14.117",
|
|
21
|
-
"@types/mocha": "^
|
|
22
|
-
"@types/
|
|
17
|
+
"@types/mocha": "^8.0.0",
|
|
18
|
+
"@types/nock": "^11.1.0",
|
|
19
|
+
"@types/node": "^14.0.14",
|
|
23
20
|
"chai": "^4.2.0",
|
|
24
|
-
"
|
|
25
|
-
"
|
|
26
|
-
"
|
|
27
|
-
"
|
|
28
|
-
"
|
|
29
|
-
"
|
|
21
|
+
"eslint": "^7.3.1",
|
|
22
|
+
"eslint-config-oclif": "^3.1.0",
|
|
23
|
+
"eslint-config-oclif-typescript": "^0.2.0",
|
|
24
|
+
"globby": "^11",
|
|
25
|
+
"mocha": "^8",
|
|
26
|
+
"nock": "^13.0.0",
|
|
27
|
+
"nyc": "^15.1.0",
|
|
28
|
+
"oclif": "2.0.0-main.14",
|
|
29
|
+
"shx": "^0.3.3",
|
|
30
|
+
"ts-node": "^9.1.1",
|
|
31
|
+
"tslib": "^2.0.0",
|
|
32
|
+
"typescript": "4.4.3"
|
|
30
33
|
},
|
|
31
34
|
"engines": {
|
|
32
|
-
"node": ">=
|
|
35
|
+
"node": ">=12.0.0"
|
|
33
36
|
},
|
|
34
37
|
"files": [
|
|
35
38
|
"/lib",
|
|
@@ -50,10 +53,13 @@
|
|
|
50
53
|
},
|
|
51
54
|
"repository": "oclif/plugin-commands",
|
|
52
55
|
"scripts": {
|
|
53
|
-
"
|
|
54
|
-
"
|
|
55
|
-
"
|
|
56
|
-
"
|
|
57
|
-
"
|
|
56
|
+
"lint": "eslint . --ext .ts --config .eslintrc",
|
|
57
|
+
"pretest": "yarn build && tsc -p test --noEmit",
|
|
58
|
+
"test": "mocha --forbid-only \"test/**/*.test.ts\"",
|
|
59
|
+
"posttest": "yarn lint",
|
|
60
|
+
"prepack": "shx rm -rf lib && tsc && oclif manifest . && oclif readme",
|
|
61
|
+
"postpack": "shx rm -f oclif.manifest.json",
|
|
62
|
+
"version": "oclif readme && git add README.md",
|
|
63
|
+
"build": "shx rm -rf lib && tsc"
|
|
58
64
|
}
|
|
59
65
|
}
|