@oclif/plugin-help 3.0.1 → 3.2.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 CHANGED
@@ -1,3 +1,24 @@
1
+ ## [3.2.2](https://github.com/oclif/plugin-help/compare/v3.2.1...v3.2.2) (2021-02-03)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * avoid recomputing topics in loop ([#189](https://github.com/oclif/plugin-help/issues/189)) ([eccb862](https://github.com/oclif/plugin-help/commit/eccb862e725f28d305de5cccde109c15abbb5f98)), closes [#101](https://github.com/oclif/plugin-help/issues/101)
7
+
8
+ ## [3.2.1](https://github.com/oclif/plugin-help/compare/v3.2.0...v3.2.1) (2020-12-14)
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * move oclif/errors to dependencies ([#179](https://github.com/oclif/plugin-help/issues/179)) ([a5e8320](https://github.com/oclif/plugin-help/commit/a5e8320ce480c55ba7800a8a9f444e681dee7a76))
14
+
15
+ # [3.2.0](https://github.com/oclif/plugin-help/compare/v3.1.0...v3.2.0) (2020-08-03)
16
+
17
+
18
+ ### Features
19
+
20
+ * support src/command/index cmd ([#112](https://github.com/oclif/plugin-help/issues/112)) ([8957336](https://github.com/oclif/plugin-help/commit/8957336f3c35675bb243ac90c49c298fbef23e59))
21
+
1
22
  ## [2.1.4](https://github.com/oclif/plugin-help/compare/v2.1.3...v2.1.4) (2018-11-12)
2
23
 
3
24
 
package/lib/command.js CHANGED
@@ -1,14 +1,14 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const chalk_1 = require("chalk");
3
+ const chalk = require("chalk");
4
4
  const indent = require("indent-string");
5
5
  const stripAnsi = require("strip-ansi");
6
6
  const list_1 = require("./list");
7
7
  const util_1 = require("./util");
8
- const { underline, bold, } = chalk_1.default;
9
- let { dim, } = chalk_1.default;
8
+ const { underline, bold, } = chalk;
9
+ let { dim, } = chalk;
10
10
  if (process.env.ConEmuANSI === 'ON') {
11
- dim = chalk_1.default.gray;
11
+ dim = chalk.gray;
12
12
  }
13
13
  const wrap = require('wrap-ansi');
14
14
  class CommandHelp {
package/lib/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as Config from '@oclif/config';
2
- export { getHelpClass } from './util';
2
+ import { getHelpClass } from './util';
3
3
  export interface HelpOptions {
4
4
  all?: boolean;
5
5
  maxWidth: number;
@@ -43,3 +43,4 @@ export default class Help extends HelpBase {
43
43
  */
44
44
  protected command(command: Config.Command): string;
45
45
  }
46
+ export { Help, getHelpClass, };
package/lib/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const errors_1 = require("@oclif/errors");
4
- const chalk_1 = require("chalk");
4
+ const chalk = require("chalk");
5
5
  const indent = require("indent-string");
6
6
  const stripAnsi = require("strip-ansi");
7
7
  const command_1 = require("./command");
@@ -9,18 +9,19 @@ const list_1 = require("./list");
9
9
  const root_1 = require("./root");
10
10
  const screen_1 = require("./screen");
11
11
  const util_1 = require("./util");
12
- var util_2 = require("./util");
12
+ const util_2 = require("./util");
13
13
  exports.getHelpClass = util_2.getHelpClass;
14
14
  const wrap = require('wrap-ansi');
15
- const { bold, } = chalk_1.default;
15
+ const { bold, } = chalk;
16
+ const ROOT_INDEX_CMD_ID = '';
16
17
  function getHelpSubject(args) {
17
18
  for (const arg of args) {
18
19
  if (arg === '--')
19
20
  return;
20
- if (arg.startsWith('-'))
21
- continue;
22
- if (arg === 'help')
21
+ if (arg === 'help' || arg === '--help' || arg === '-h')
23
22
  continue;
23
+ if (arg.startsWith('-'))
24
+ return;
24
25
  return arg;
25
26
  }
26
27
  }
@@ -43,9 +44,12 @@ class Help extends HelpBase {
43
44
  * and this can be removed.
44
45
  */
45
46
  get _topics() {
46
- return this.config.topics.filter((topic) => {
47
+ // since this.config.topics is a getter that does non-trivial work, cache it outside the filter loop for
48
+ // performance benefits in the presence of large numbers of topics
49
+ const topics = this.config.topics;
50
+ return topics.filter((topic) => {
47
51
  // it is assumed a topic has a child if it has children
48
- const hasChild = this.config.topics.some(subTopic => subTopic.name.includes(`${topic.name}:`));
52
+ const hasChild = topics.some(subTopic => subTopic.name.includes(`${topic.name}:`));
49
53
  return hasChild;
50
54
  });
51
55
  }
@@ -66,6 +70,9 @@ class Help extends HelpBase {
66
70
  showHelp(argv) {
67
71
  const subject = getHelpSubject(argv);
68
72
  if (!subject) {
73
+ const rootCmd = this.config.findCommand(ROOT_INDEX_CMD_ID);
74
+ if (rootCmd)
75
+ this.showCommandHelp(rootCmd);
69
76
  this.showRootHelp();
70
77
  return;
71
78
  }
@@ -114,6 +121,7 @@ class Help extends HelpBase {
114
121
  console.log('');
115
122
  }
116
123
  if (rootCommands.length > 0) {
124
+ rootCommands = rootCommands.filter(c => c.id);
117
125
  console.log(this.formatCommands(rootCommands));
118
126
  console.log('');
119
127
  }
@@ -202,3 +210,4 @@ class Help extends HelpBase {
202
210
  }
203
211
  }
204
212
  exports.default = Help;
213
+ exports.Help = Help;
package/lib/root.js CHANGED
@@ -1,11 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const chalk_1 = require("chalk");
3
+ const chalk = require("chalk");
4
4
  const indent = require("indent-string");
5
5
  const stripAnsi = require("strip-ansi");
6
6
  const util_1 = require("./util");
7
7
  const wrap = require('wrap-ansi');
8
- const { bold, } = chalk_1.default;
8
+ const { bold, } = chalk;
9
9
  class RootHelp {
10
10
  constructor(config, opts) {
11
11
  this.config = config;
@@ -1 +1 @@
1
- {"version":"3.0.1","commands":{"help":{"id":"help","description":"display help for <%= config.bin %>","pluginName":"@oclif/plugin-help","pluginType":"core","aliases":[],"flags":{"all":{"name":"all","type":"boolean","description":"see all commands in CLI","allowNo":false}},"args":[{"name":"command","description":"command to show help for","required":false}]}}}
1
+ {"version":"3.2.2","commands":{"help":{"id":"help","description":"display help for <%= config.bin %>","pluginName":"@oclif/plugin-help","pluginType":"core","aliases":[],"flags":{"all":{"name":"all","type":"boolean","description":"see all commands in CLI","allowNo":false}},"args":[{"name":"command","description":"command to show help for","required":false}]}}}
package/package.json CHANGED
@@ -1,42 +1,42 @@
1
1
  {
2
2
  "name": "@oclif/plugin-help",
3
3
  "description": "standard help for oclif",
4
- "version": "3.0.1",
4
+ "version": "3.2.2",
5
5
  "author": "Jeff Dickey @jdxcode",
6
6
  "bugs": "https://github.com/oclif/plugin-help/issues",
7
7
  "dependencies": {
8
8
  "@oclif/command": "^1.5.20",
9
9
  "@oclif/config": "^1.15.1",
10
- "chalk": "^2.4.1",
10
+ "@oclif/errors": "^1.2.2",
11
+ "chalk": "^4.1.0",
11
12
  "indent-string": "^4.0.0",
12
13
  "lodash.template": "^4.4.0",
13
- "string-width": "^3.0.0",
14
- "strip-ansi": "^5.0.0",
15
- "widest-line": "^2.0.1",
14
+ "string-width": "^4.2.0",
15
+ "strip-ansi": "^6.0.0",
16
+ "widest-line": "^3.1.0",
16
17
  "wrap-ansi": "^4.0.0"
17
18
  },
18
19
  "devDependencies": {
19
20
  "@oclif/dev-cli": "^1.21.0",
20
- "@oclif/errors": "^1.2.2",
21
21
  "@oclif/plugin-legacy": "^1.1.3",
22
22
  "@oclif/plugin-plugins": "^1.7.6",
23
23
  "@oclif/test": "^1.2.2",
24
24
  "@types/chai": "^4.1.7",
25
25
  "@types/lodash.template": "^4.4.4",
26
- "@types/mocha": "^5.2.5",
27
- "@types/node": "^8.10.59",
28
- "@types/strip-ansi": "^3.0.0",
26
+ "@types/mocha": "^8.0.0",
27
+ "@types/node": "^14.0.14",
28
+ "@types/strip-ansi": "^5.2.1",
29
29
  "@types/wrap-ansi": "^3.0.0",
30
30
  "chai": "^4.2.0",
31
- "eslint": "^6.6.0",
31
+ "eslint": "^7.3.1",
32
32
  "eslint-config-oclif": "^3.1.0",
33
- "eslint-config-oclif-typescript": "^0.1.0",
34
- "globby": "^9.0.0",
35
- "mocha": "^5.2.0",
36
- "nock": "^12.0.3",
33
+ "eslint-config-oclif-typescript": "^0.2.0",
34
+ "globby": "^11.0.1",
35
+ "mocha": "^8.2.1",
36
+ "nock": "^13.0.0",
37
37
  "sinon": "^9.0.1",
38
- "ts-node": "^8.8.2",
39
- "typescript": "^3.8.3"
38
+ "ts-node": "^9.1.1",
39
+ "typescript": "3.8.3"
40
40
  },
41
41
  "engines": {
42
42
  "node": ">=8.0.0"
@@ -63,7 +63,7 @@
63
63
  "scripts": {
64
64
  "build": "rm -rf lib && tsc",
65
65
  "lint": "eslint . --ext .ts --config .eslintrc",
66
- "pretest": "tsc -p test --noEmit",
66
+ "pretest": "yarn build --noEmit && tsc -p test --noEmit",
67
67
  "test": "mocha --forbid-only \"test/**/*.test.ts\"",
68
68
  "posttest": "yarn lint",
69
69
  "prepack": "yarn run build && oclif-dev manifest",