@oclif/core 0.5.34 → 0.5.38

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,34 @@
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
+ ### [0.5.38](https://github.com/oclif/core/compare/v0.5.37...v0.5.38) (2021-09-15)
6
+
7
+
8
+ ### Features
9
+
10
+ * have --json global flag disabled by default ([#252](https://github.com/oclif/core/issues/252)) ([c2a7799](https://github.com/oclif/core/commit/c2a7799ce036697c77917a830a12bce5db6c68a7))
11
+
12
+ ### [0.5.37](https://github.com/oclif/core/compare/v0.5.36...v0.5.37) (2021-09-15)
13
+
14
+
15
+ ### Bug Fixes
16
+
17
+ * don't warn on hook errors ([#246](https://github.com/oclif/core/issues/246)) ([ba4be4b](https://github.com/oclif/core/commit/ba4be4b010f5f861e44b43ac31f33ce4b749982e))
18
+
19
+ ### [0.5.36](https://github.com/oclif/core/compare/v0.5.35...v0.5.36) (2021-09-14)
20
+
21
+
22
+ ### Bug Fixes
23
+
24
+ * move ctor for command help class to its own function ([#244](https://github.com/oclif/core/issues/244)) ([26f2445](https://github.com/oclif/core/commit/26f24457c71276c38f86821c2b1498ecb8e4e2a4))
25
+
26
+ ### [0.5.35](https://github.com/oclif/core/compare/v0.5.34...v0.5.35) (2021-09-08)
27
+
28
+
29
+ ### Bug Fixes
30
+
31
+ * clear hook timeout ([#243](https://github.com/oclif/core/issues/243)) ([0c32c65](https://github.com/oclif/core/commit/0c32c65c5c30b02bc3ea6e36b0598adfc5b23ec1))
32
+
5
33
  ### [0.5.34](https://github.com/oclif/core/compare/v0.5.33...v0.5.34) (2021-08-30)
6
34
 
7
35
 
package/lib/command.d.ts CHANGED
@@ -54,7 +54,7 @@ export default abstract class Command {
54
54
  */
55
55
  static examples: Interfaces.Example[];
56
56
  static parserOptions: {};
57
- static disableJsonFlag: boolean | undefined;
57
+ static enableJsonFlag: boolean;
58
58
  /**
59
59
  * instantiate and run the command
60
60
  * @param {Interfaces.Command.Class} this Class
package/lib/command.js CHANGED
@@ -38,7 +38,7 @@ class Command {
38
38
  return this._flags;
39
39
  }
40
40
  static set flags(flags) {
41
- this._flags = this.disableJsonFlag || settings_1.settings.disableJsonFlag ? flags : Object.assign({}, Command.globalFlags, flags);
41
+ this._flags = this.enableJsonFlag || settings_1.settings.enableJsonFlag ? Object.assign({}, Command.globalFlags, flags) : flags;
42
42
  }
43
43
  get ctor() {
44
44
  return this.constructor;
@@ -81,7 +81,7 @@ class Command {
81
81
  }
82
82
  }
83
83
  jsonEnabled() {
84
- return !this.ctor.disableJsonFlag && this.argv.includes('--json');
84
+ return this.ctor.enableJsonFlag && this.argv.includes('--json');
85
85
  }
86
86
  async init() {
87
87
  this.debug('init version: %s argv: %o', this.ctor._base, this.argv);
@@ -149,6 +149,7 @@ Command.aliases = [];
149
149
  Command.strict = true;
150
150
  Command.parse = true;
151
151
  Command.parserOptions = {};
152
+ Command.enableJsonFlag = false;
152
153
  // eslint-disable-next-line valid-jsdoc
153
154
  /**
154
155
  * instantiate and run the command
@@ -137,8 +137,16 @@ class Config {
137
137
  return Object.values(m).find((m) => typeof m === 'function');
138
138
  };
139
139
  const withTimeout = async (ms, promise) => {
140
- const timeout = new Promise((_, reject) => setTimeout(() => reject(new Error(`Timed out after ${ms} ms.`)), ms));
141
- return Promise.race([promise, timeout]);
140
+ let id;
141
+ const timeout = new Promise((_, reject) => {
142
+ id = setTimeout(() => {
143
+ reject(new Error(`Timed out after ${ms} ms.`));
144
+ }, ms).unref();
145
+ });
146
+ return Promise.race([promise, timeout]).then(result => {
147
+ clearTimeout(id);
148
+ return result;
149
+ });
142
150
  };
143
151
  const successes = [];
144
152
  const failures = [];
@@ -173,10 +181,9 @@ class Config {
173
181
  debug('done');
174
182
  }
175
183
  catch (error) {
176
- failures.push({ plugin: p, error });
184
+ failures.push({ plugin: p, error: error });
177
185
  if (error && error.oclif && error.oclif.exit !== undefined)
178
186
  throw error;
179
- this.warn(error, `runHook ${event}`);
180
187
  }
181
188
  }
182
189
  }
@@ -30,6 +30,7 @@ export declare class Help extends HelpBase {
30
30
  protected showTopicHelp(topic: Interfaces.Topic): Promise<void>;
31
31
  protected formatRoot(): string;
32
32
  protected formatCommand(command: Interfaces.Command): string;
33
+ protected getCommandHelpClass(command: Interfaces.Command): CommandHelp;
33
34
  protected formatCommands(commands: Interfaces.Command[]): string;
34
35
  protected summary(c: Interfaces.Command): string | undefined;
35
36
  protected description(c: Interfaces.Command): string;
package/lib/help/index.js CHANGED
@@ -73,6 +73,7 @@ class Help extends HelpBase {
73
73
  return topics;
74
74
  }
75
75
  async showHelp(argv) {
76
+ argv = argv.filter(arg => !getHelpFlagAdditions(this.config).includes(arg));
76
77
  if (this.config.topicSeparator !== ':')
77
78
  argv = util_2.standardizeIDFromArgv(argv, this.config);
78
79
  const subject = getHelpSubject(argv, this.config);
@@ -172,9 +173,12 @@ class Help extends HelpBase {
172
173
  command.id = command.id.replace(/:/g, this.config.topicSeparator);
173
174
  command.aliases = command.aliases && command.aliases.map(a => a.replace(/:/g, this.config.topicSeparator));
174
175
  }
175
- const help = new this.CommandHelpClass(command, this.config, this.opts);
176
+ const help = this.getCommandHelpClass(command);
176
177
  return help.generate();
177
178
  }
179
+ getCommandHelpClass(command) {
180
+ return new this.CommandHelpClass(command, this.config, this.opts);
181
+ }
178
182
  formatCommands(commands) {
179
183
  if (commands.length === 0)
180
184
  return '';
@@ -90,7 +90,7 @@ export declare namespace Hook {
90
90
  plugin: Plugin;
91
91
  }>;
92
92
  failures: Array<{
93
- error: typeof Error;
93
+ error: Error;
94
94
  plugin: Plugin;
95
95
  }>;
96
96
  }
package/lib/main.js CHANGED
@@ -49,7 +49,6 @@ async function run(argv = process.argv.slice(2), options) {
49
49
  }
50
50
  // display help version if applicable
51
51
  if (exports.helpAddition(argv, config)) {
52
- argv = argv.filter(arg => !help_1.getHelpFlagAdditions(config).includes(arg));
53
52
  const Help = await help_1.loadHelpClass(config);
54
53
  const help = new Help(config, config.pjson.helpOptions);
55
54
  await help.showHelp(argv);
package/lib/settings.d.ts CHANGED
@@ -31,8 +31,8 @@ export declare type Settings = {
31
31
  */
32
32
  tsnodeEnabled?: boolean;
33
33
  /**
34
- * Disable the --json flag for all commands
34
+ * Enable the --json flag for all commands
35
35
  */
36
- disableJsonFlag?: boolean;
36
+ enableJsonFlag?: boolean;
37
37
  };
38
38
  export declare const settings: Settings;
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": "0.5.34",
4
+ "version": "0.5.38",
5
5
  "author": "Jeff Dickey @jdxcode",
6
6
  "bugs": "https://github.com/oclif/core/issues",
7
7
  "dependencies": {