@oclif/plugin-commands 1.2.2 → 2.0.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/CHANGELOG.md CHANGED
@@ -1,3 +1,18 @@
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.1](https://github.com/oclif/plugin-commands/compare/v2.0.0...v2.0.1) (2021-12-08)
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
+
1
16
  ## [1.2.2](https://github.com/oclif/plugin-commands/compare/v1.2.1...v1.2.2) (2018-10-13)
2
17
 
3
18
 
package/README.md CHANGED
@@ -6,7 +6,6 @@ plugin to show the list of all the commands
6
6
  [![Version](https://img.shields.io/npm/v/@oclif/plugin-commands.svg)](https://npmjs.org/package/@oclif/plugin-commands)
7
7
  [![CircleCI](https://circleci.com/gh/oclif/plugin-commands/tree/master.svg?style=shield)](https://circleci.com/gh/oclif/plugin-commands/tree/master)
8
8
  [![Appveyor CI](https://ci.appveyor.com/api/projects/status/github/oclif/plugin-commands?branch=master&svg=true)](https://ci.appveyor.com/project/oclif/plugin-commands/branch/master)
9
- [![Codecov](https://codecov.io/gh/oclif/plugin-commands/branch/master/graph/badge.svg)](https://codecov.io/gh/oclif/plugin-commands)
10
9
  [![Downloads/week](https://img.shields.io/npm/dw/@oclif/plugin-commands.svg)](https://npmjs.org/package/@oclif/plugin-commands)
11
10
  [![License](https://img.shields.io/npm/l/@oclif/plugin-commands.svg)](https://github.com/oclif/plugin-commands/blob/master/package.json)
12
11
 
@@ -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 (-v|--version|version)
24
- @oclif/plugin-commands/1.2.2 linux-x64 node-v10.12.0
22
+ $ oclif-example (--version)
23
+ @oclif/plugin-commands/2.0.1 linux-x64 node-v12.22.7
25
24
  $ oclif-example --help [COMMAND]
26
25
  USAGE
27
26
  $ oclif-example COMMAND
@@ -38,13 +37,26 @@ list all the commands
38
37
 
39
38
  ```
40
39
  USAGE
41
- $ oclif-example commands
42
-
43
- OPTIONS
44
- -h, --help show CLI help
45
- -j, --json output in json format
46
- --hidden also show hidden commands
40
+ $ oclif-example commands [-h] [-j] [--hidden] [--columns <value> | -x] [--sort <value>] [--filter <value>]
41
+ [--output csv|json|yaml | | [--csv | --no-truncate]] [--no-header | ]
42
+
43
+ FLAGS
44
+ -h, --help Show CLI help.
45
+ -j, --json display unfiltered api data in json format
46
+ -x, --extended show extra columns
47
+ --columns=<value> only show provided columns (comma-separated)
48
+ --csv output is csv format [alias: --output=csv]
49
+ --filter=<value> filter property by partial string matching, ex: name=foo
50
+ --hidden show hidden commands
51
+ --no-header hide table header from output
52
+ --no-truncate do not truncate output to fit screen
53
+ --output=<option> output in a more machine friendly format
54
+ <options: csv|json|yaml>
55
+ --sort=<value> property to sort by (prepend '-' for descending)
56
+
57
+ DESCRIPTION
58
+ list all the commands
47
59
  ```
48
60
 
49
- _See code: [src/commands/commands.ts](https://github.com/oclif/plugin-commands/blob/v1.2.2/src/commands/commands.ts)_
61
+ _See code: [src/commands/commands.ts](https://github.com/oclif/plugin-commands/blob/v2.0.1/src/commands/commands.ts)_
50
62
  <!-- commandsstop -->
@@ -1,10 +1,8 @@
1
- import { Command } from '@oclif/command';
1
+ import { Command } from '@oclif/core';
2
2
  export default class Commands extends Command {
3
3
  static description: string;
4
- static flags: {
5
- help: import("@oclif/parser/lib/flags").IBooleanFlag<void>;
6
- json: import("@oclif/parser/lib/flags").IBooleanFlag<boolean>;
7
- hidden: import("@oclif/parser/lib/flags").IBooleanFlag<boolean>;
8
- };
4
+ static flags: any;
9
5
  run(): Promise<void>;
6
+ private getCommands;
7
+ private removeCycles;
10
8
  }
@@ -1,30 +1,110 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const command_1 = require("@oclif/command");
3
+ const core_1 = require("@oclif/core");
4
4
  const cli_ux_1 = require("cli-ux");
5
5
  const _ = require("lodash");
6
- class Commands extends command_1.Command {
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.config.commands;
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
- commands = _.sortBy(commands, 'id');
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
+ });
14
23
  if (flags.json) {
15
- cli_ux_1.default.styledJSON(commands);
24
+ cli_ux_1.ux.styledJSON(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
+ })));
16
37
  }
17
38
  else {
18
- for (let c of commands) {
19
- this.log(c.id);
20
- }
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));
21
69
  }
22
70
  }
71
+ getCommands() {
72
+ return this.config.commands;
73
+ }
74
+ removeCycles(object) {
75
+ // Keep track of seen objects.
76
+ const seenObjects = new WeakMap();
77
+ const _removeCycles = (obj) => {
78
+ // Use object prototype to get around type and null checks
79
+ if (Object.prototype.toString.call(obj) === '[object Object]') {
80
+ // We know it is a "Dictionary" because of the conditional
81
+ const dictionary = obj;
82
+ if (seenObjects.has(dictionary)) {
83
+ // Seen, return undefined to remove.
84
+ return undefined;
85
+ }
86
+ seenObjects.set(dictionary, undefined);
87
+ for (const key in dictionary) {
88
+ // Delete the duplicate object if cycle found.
89
+ if (_removeCycles(dictionary[key]) === undefined) {
90
+ delete dictionary[key];
91
+ }
92
+ }
93
+ }
94
+ else if (Array.isArray(obj)) {
95
+ for (const i in obj) {
96
+ if (_removeCycles(obj[i]) === undefined) {
97
+ // We don't want to delete the array, but we can replace the element with null.
98
+ obj[i] = null;
99
+ }
100
+ }
101
+ }
102
+ return obj;
103
+ };
104
+ return _removeCycles(object);
105
+ }
23
106
  }
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
107
  exports.default = Commands;
108
+ Commands.description = 'list all the commands';
109
+ // to-do: update this type when cli-ux is on core
110
+ Commands.flags = Object.assign({ help: core_1.Flags.help({ char: 'h' }), json: core_1.Flags.boolean({ char: 'j', description: 'display unfiltered api data in json format' }), hidden: core_1.Flags.boolean({ description: 'show hidden commands' }) }, cli_ux_1.ux.table.flags());
@@ -1 +1 @@
1
- {"version":"1.2.2","commands":{"commands":{"id":"commands","description":"list all the commands","pluginName":"@oclif/plugin-commands","pluginType":"core","aliases":[],"flags":{"help":{"name":"help","type":"boolean","char":"h","description":"show CLI help","allowNo":false},"json":{"name":"json","type":"boolean","char":"j","description":"output in json format","allowNo":false},"hidden":{"name":"hidden","type":"boolean","description":"also show hidden commands","allowNo":false}},"args":[]}}}
1
+ {"version":"2.0.1","commands":{"commands":{"id":"commands","description":"list all the commands","strict":true,"pluginName":"@oclif/plugin-commands","pluginAlias":"@oclif/plugin-commands","pluginType":"core","aliases":[],"flags":{"help":{"name":"help","type":"boolean","char":"h","description":"Show CLI help.","allowNo":false},"json":{"name":"json","type":"boolean","char":"j","description":"display unfiltered api data in json format","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":[]}}}
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": "1.2.2",
4
+ "version": "2.0.1",
5
5
  "author": "Jeff Dickey @jdxcode",
6
6
  "bugs": "https://github.com/oclif/plugin-commands/issues",
7
7
  "dependencies": {
8
- "@oclif/command": "^1.5.4",
9
- "@oclif/config": "^1.8.7",
10
- "cli-ux": "^4.9.0",
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/dev-cli": "^1.19.1",
16
- "@oclif/plugin-help": "^2.1.2",
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": "^5.2.5",
22
- "@types/node": "^10.11.7",
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
- "globby": "^8",
25
- "mocha": "^5",
26
- "nyc": "^13.0.1",
27
- "ts-node": "^7.0.1",
28
- "tslint": "^5.11.0",
29
- "typescript": "^3.1.3"
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": ">=8.0.0"
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
- "postpack": "rm -f oclif.manifest.json",
54
- "posttest": "tsc -p test --noEmit && tslint -p test -t stylish",
55
- "prepack": "rm -rf lib && tsc && oclif-dev manifest && oclif-dev readme",
56
- "test": "nyc mocha --forbid-only \"test/**/*.test.ts\"",
57
- "version": "oclif-dev readme && git add README.md"
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
  }