@salesforce/sf-plugins-core 1.5.3 → 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,24 @@
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/salesforcecli/sf-plugins-core/compare/v1.6.1...v1.7.0) (2022-03-11)
6
+
7
+ ### Features
8
+
9
+ - suppress progress bar output with env vars ([d2e8a84](https://github.com/salesforcecli/sf-plugins-core/commit/d2e8a849d7ca93b3dba538a26ce5f9ab7f858984))
10
+
11
+ ### [1.6.1](https://github.com/salesforcecli/sf-plugins-core/compare/v1.6.0...v1.6.1) (2022-03-09)
12
+
13
+ ### Bug Fixes
14
+
15
+ - erturn error - dont throw ([0ea70bc](https://github.com/salesforcecli/sf-plugins-core/commit/0ea70bc12cecd380a907323eba84ddb9d5a44e08))
16
+
17
+ ## [1.6.0](https://github.com/salesforcecli/sf-plugins-core/compare/v1.5.3...v1.6.0) (2022-03-08)
18
+
19
+ ### Features
20
+
21
+ - add timedPrompt method ([ea9e98c](https://github.com/salesforcecli/sf-plugins-core/commit/ea9e98c5bffdfc1e917d61006a91f4dba1f808f3))
22
+
5
23
  ### [1.5.3](https://github.com/salesforcecli/sf-plugins-core/compare/v1.5.2...v1.5.3) (2022-03-08)
6
24
 
7
25
  ### Bug Fixes
package/lib/sfCommand.js CHANGED
@@ -28,7 +28,7 @@ class SfCommand extends core_1.Command {
28
28
  this.warnings = [];
29
29
  const outputEnabled = !this.jsonEnabled();
30
30
  this.spinner = new ux_1.Spinner(outputEnabled);
31
- this.progress = new ux_1.Progress(outputEnabled);
31
+ this.progress = new ux_1.Progress(outputEnabled && core_2.envVars.getBoolean(core_2.EnvironmentVariable.SF_USE_PROGRESS_BAR, true));
32
32
  this.ux = new ux_1.Ux(outputEnabled);
33
33
  this.prompter = new ux_1.Prompter();
34
34
  this.lifecycle = core_2.Lifecycle.getInstance();
@@ -164,7 +164,7 @@ class SfCommand extends core_1.Command {
164
164
  if (this.jsonEnabled()) {
165
165
  core_1.CliUx.ux.styledJSON(this.toErrorJson(error));
166
166
  }
167
- throw error;
167
+ return error;
168
168
  }
169
169
  /**
170
170
  * Format errors and actions for human consumption. Adds 'Error:',
@@ -5,6 +5,10 @@ export declare class Prompter {
5
5
  * Prompt user for information. See https://www.npmjs.com/package/inquirer for more.
6
6
  */
7
7
  prompt<T = Prompter.Answers>(questions: Prompter.Questions<T>, initialAnswers?: Partial<T>): Promise<T>;
8
+ /**
9
+ * Prompt user for information with a timeout (in milliseconds). See https://www.npmjs.com/package/inquirer for more.
10
+ */
11
+ timedPrompt<T = Prompter.Answers>(questions: Prompter.Questions<T>, ms?: number, initialAnswers?: Partial<T>): Promise<T>;
8
12
  }
9
13
  export declare namespace Prompter {
10
14
  type Answers<T = Record<string, unknown>> = T & Record<string, unknown>;
@@ -9,6 +9,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
9
9
  exports.generateTableChoices = exports.Prompter = void 0;
10
10
  const inquirer_1 = require("inquirer");
11
11
  const ts_types_1 = require("@salesforce/ts-types");
12
+ const core_1 = require("@oclif/core");
12
13
  class Prompter {
13
14
  /**
14
15
  * Prompt user for information. See https://www.npmjs.com/package/inquirer for more.
@@ -17,6 +18,27 @@ class Prompter {
17
18
  const answers = await (0, inquirer_1.prompt)(questions, initialAnswers);
18
19
  return answers;
19
20
  }
21
+ /**
22
+ * Prompt user for information with a timeout (in milliseconds). See https://www.npmjs.com/package/inquirer for more.
23
+ */
24
+ async timedPrompt(questions, ms = 10000, initialAnswers) {
25
+ let id;
26
+ const thePrompt = (0, inquirer_1.prompt)(questions, initialAnswers);
27
+ const timeout = new Promise((_, reject) => {
28
+ id = setTimeout(() => {
29
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
30
+ // @ts-expect-error
31
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-call
32
+ thePrompt.ui['activePrompt'].done();
33
+ core_1.CliUx.ux.log();
34
+ reject(new Error(`Timed out after ${ms} ms.`));
35
+ }, ms).unref();
36
+ });
37
+ return Promise.race([timeout, thePrompt]).then((result) => {
38
+ clearTimeout(id);
39
+ return result;
40
+ });
41
+ }
20
42
  }
21
43
  exports.Prompter = Prompter;
22
44
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salesforce/sf-plugins-core",
3
- "version": "1.5.3",
3
+ "version": "1.7.0",
4
4
  "description": "Utils for writing deploy and retrieve plugins",
5
5
  "main": "lib/exported",
6
6
  "types": "lib/exported.d.ts",