@oclif/core 1.6.2 → 1.7.0

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
@@ -2,6 +2,27 @@
2
2
 
3
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
4
 
5
+ ## [1.7.0](https://github.com/oclif/core/compare/v1.6.4...v1.7.0) (2022-04-11)
6
+
7
+
8
+ ### Features
9
+
10
+ * move console.log to single class method ([#400](https://github.com/oclif/core/issues/400)) ([2ccb274](https://github.com/oclif/core/commit/2ccb2740912dba3b81c4d36712fbb20fd6a03c23))
11
+
12
+ ### [1.6.4](https://github.com/oclif/core/compare/v1.6.3...v1.6.4) (2022-03-31)
13
+
14
+
15
+ ### Bug Fixes
16
+
17
+ * dynamic help ([#395](https://github.com/oclif/core/issues/395)) ([8ecc8f4](https://github.com/oclif/core/commit/8ecc8f41ec62ef5b05bdb70a79dce09b5913d14b))
18
+
19
+ ### [1.6.3](https://github.com/oclif/core/compare/v1.6.2...v1.6.3) (2022-03-23)
20
+
21
+
22
+ ### Bug Fixes
23
+
24
+ * use plugin alias if available ([245d841](https://github.com/oclif/core/commit/245d84197a64e55b17524c22cbc17ec025a07c08))
25
+
5
26
  ### [1.6.2](https://github.com/oclif/core/compare/v1.6.1...v1.6.2) (2022-03-23)
6
27
 
7
28
 
@@ -24,7 +24,6 @@ export declare class Help extends HelpBase {
24
24
  protected get sortedTopics(): Interfaces.Topic[];
25
25
  constructor(config: Interfaces.Config, opts?: Partial<Interfaces.HelpOptions>);
26
26
  showHelp(argv: string[]): Promise<void>;
27
- private getDynamicCommand;
28
27
  showCommandHelp(command: Interfaces.Command): Promise<void>;
29
28
  protected showRootHelp(): Promise<void>;
30
29
  protected showTopicHelp(topic: Interfaces.Topic): Promise<void>;
@@ -42,4 +41,5 @@ export declare class Help extends HelpBase {
42
41
  * @return {string} the readme help string for the given command
43
42
  */
44
43
  protected command(command: Interfaces.Command): string;
44
+ protected log(...args: string[]): void;
45
45
  }
package/lib/help/index.js CHANGED
@@ -8,7 +8,6 @@ const root_1 = require("./root");
8
8
  const util_1 = require("../util");
9
9
  const util_2 = require("./util");
10
10
  const formatter_1 = require("./formatter");
11
- const plugin_1 = require("../config/plugin");
12
11
  const config_1 = require("../config/config");
13
12
  var command_2 = require("./command");
14
13
  Object.defineProperty(exports, "CommandHelp", { enumerable: true, get: function () { return command_2.CommandHelp; } });
@@ -87,7 +86,7 @@ class Help extends HelpBase {
87
86
  const command = this.config.findCommand(subject);
88
87
  if (command) {
89
88
  if (command.hasDynamicHelp) {
90
- const dynamicCommand = await (0, config_1.toCached)(await this.getDynamicCommand(command));
89
+ const dynamicCommand = await (0, config_1.toCached)(await command.load());
91
90
  await this.showCommandHelp(dynamicCommand);
92
91
  }
93
92
  else {
@@ -110,15 +109,6 @@ class Help extends HelpBase {
110
109
  }
111
110
  (0, errors_1.error)(`Command ${subject} not found.`);
112
111
  }
113
- async getDynamicCommand(command) {
114
- const plugin = new plugin_1.Plugin({ ignoreManifest: true, root: this.config.root, name: command.pluginName });
115
- await plugin.load();
116
- const cmd = await plugin.findCommand(command.id);
117
- if (!cmd) {
118
- throw new Error(`Command ${command.id} not found.`);
119
- }
120
- return cmd;
121
- }
122
112
  async showCommandHelp(command) {
123
113
  var _a, _b, _c, _d;
124
114
  const name = command.id;
@@ -128,20 +118,20 @@ class Help extends HelpBase {
128
118
  const plugin = this.config.plugins.find(p => p.name === command.pluginName);
129
119
  const state = ((_b = (_a = this.config.pjson) === null || _a === void 0 ? void 0 : _a.oclif) === null || _b === void 0 ? void 0 : _b.state) || ((_d = (_c = plugin === null || plugin === void 0 ? void 0 : plugin.pjson) === null || _c === void 0 ? void 0 : _c.oclif) === null || _d === void 0 ? void 0 : _d.state) || command.state;
130
120
  if (state)
131
- console.log(`This command is in ${state}.\n`);
121
+ this.log(`This command is in ${state}.\n`);
132
122
  const summary = this.summary(command);
133
123
  if (summary) {
134
- console.log(summary + '\n');
124
+ this.log(summary + '\n');
135
125
  }
136
- console.log(this.formatCommand(command));
137
- console.log('');
126
+ this.log(this.formatCommand(command));
127
+ this.log('');
138
128
  if (subTopics.length > 0) {
139
- console.log(this.formatTopics(subTopics));
140
- console.log('');
129
+ this.log(this.formatTopics(subTopics));
130
+ this.log('');
141
131
  }
142
132
  if (subCommands.length > 0) {
143
- console.log(this.formatCommands(subCommands));
144
- console.log('');
133
+ this.log(this.formatCommands(subCommands));
134
+ this.log('');
145
135
  }
146
136
  }
147
137
  async showRootHelp() {
@@ -150,21 +140,21 @@ class Help extends HelpBase {
150
140
  let rootCommands = this.sortedCommands;
151
141
  const state = (_b = (_a = this.config.pjson) === null || _a === void 0 ? void 0 : _a.oclif) === null || _b === void 0 ? void 0 : _b.state;
152
142
  if (state)
153
- console.log(`${this.config.bin} is in ${state}.\n`);
154
- console.log(this.formatRoot());
155
- console.log('');
143
+ this.log(`${this.config.bin} is in ${state}.\n`);
144
+ this.log(this.formatRoot());
145
+ this.log('');
156
146
  if (!this.opts.all) {
157
147
  rootTopics = rootTopics.filter(t => !t.name.includes(':'));
158
148
  rootCommands = rootCommands.filter(c => !c.id.includes(':'));
159
149
  }
160
150
  if (rootTopics.length > 0) {
161
- console.log(this.formatTopics(rootTopics));
162
- console.log('');
151
+ this.log(this.formatTopics(rootTopics));
152
+ this.log('');
163
153
  }
164
154
  if (rootCommands.length > 0) {
165
155
  rootCommands = rootCommands.filter(c => c.id);
166
- console.log(this.formatCommands(rootCommands));
167
- console.log('');
156
+ this.log(this.formatCommands(rootCommands));
157
+ this.log('');
168
158
  }
169
159
  }
170
160
  async showTopicHelp(topic) {
@@ -175,15 +165,15 @@ class Help extends HelpBase {
175
165
  const commands = this.sortedCommands.filter(c => c.id.startsWith(name + ':') && c.id.split(':').length === depth + 1);
176
166
  const state = (_b = (_a = this.config.pjson) === null || _a === void 0 ? void 0 : _a.oclif) === null || _b === void 0 ? void 0 : _b.state;
177
167
  if (state)
178
- console.log(`This topic is in ${state}.\n`);
179
- console.log(this.formatTopic(topic));
168
+ this.log(`This topic is in ${state}.\n`);
169
+ this.log(this.formatTopic(topic));
180
170
  if (subTopics.length > 0) {
181
- console.log(this.formatTopics(subTopics));
182
- console.log('');
171
+ this.log(this.formatTopics(subTopics));
172
+ this.log('');
183
173
  }
184
174
  if (commands.length > 0) {
185
- console.log(this.formatCommands(commands));
186
- console.log('');
175
+ this.log(this.formatCommands(commands));
176
+ this.log('');
187
177
  }
188
178
  }
189
179
  formatRoot() {
@@ -271,5 +261,8 @@ class Help extends HelpBase {
271
261
  command(command) {
272
262
  return this.formatCommand(command);
273
263
  }
264
+ log(...args) {
265
+ console.log(...args);
266
+ }
274
267
  }
275
268
  exports.Help = Help;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@oclif/core",
3
3
  "description": "base library for oclif CLIs",
4
- "version": "1.6.2",
4
+ "version": "1.7.0",
5
5
  "author": "Salesforce",
6
6
  "bugs": "https://github.com/oclif/core/issues",
7
7
  "dependencies": {