@salesforce/sf-plugins-core 1.5.2 → 1.6.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
@@ -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.6.1](https://github.com/salesforcecli/sf-plugins-core/compare/v1.6.0...v1.6.1) (2022-03-09)
6
+
7
+ ### Bug Fixes
8
+
9
+ - erturn error - dont throw ([0ea70bc](https://github.com/salesforcecli/sf-plugins-core/commit/0ea70bc12cecd380a907323eba84ddb9d5a44e08))
10
+
11
+ ## [1.6.0](https://github.com/salesforcecli/sf-plugins-core/compare/v1.5.3...v1.6.0) (2022-03-08)
12
+
13
+ ### Features
14
+
15
+ - add timedPrompt method ([ea9e98c](https://github.com/salesforcecli/sf-plugins-core/commit/ea9e98c5bffdfc1e917d61006a91f4dba1f808f3))
16
+
17
+ ### [1.5.3](https://github.com/salesforcecli/sf-plugins-core/compare/v1.5.2...v1.5.3) (2022-03-08)
18
+
19
+ ### Bug Fixes
20
+
21
+ - expose styledHeader as func in sf command ([fd2dc48](https://github.com/salesforcecli/sf-plugins-core/commit/fd2dc48444be224a884c3b56d5604f4b854f1c0e))
22
+
5
23
  ### [1.5.2](https://github.com/salesforcecli/sf-plugins-core/compare/v1.5.1...v1.5.2) (2022-03-07)
6
24
 
7
25
  ### Bug Fixes
@@ -62,6 +62,10 @@ export declare abstract class SfCommand<T> extends Command {
62
62
  * Log stylized object to the console. Will automatically be suppressed when --json flag is present.
63
63
  */
64
64
  styledObject(obj: AnyJson): void;
65
+ /**
66
+ * Log stylized header to the console. Will automatically be suppressed when --json flag is present.
67
+ */
68
+ styledHeader(text: string): void;
65
69
  /**
66
70
  * Prompt user for information. See https://www.npmjs.com/package/inquirer for more.
67
71
  *
package/lib/sfCommand.js CHANGED
@@ -91,6 +91,12 @@ class SfCommand extends core_1.Command {
91
91
  styledObject(obj) {
92
92
  this.ux.styledObject(obj);
93
93
  }
94
+ /**
95
+ * Log stylized header to the console. Will automatically be suppressed when --json flag is present.
96
+ */
97
+ styledHeader(text) {
98
+ this.ux.styledHeader(text);
99
+ }
94
100
  /**
95
101
  * Prompt user for information. See https://www.npmjs.com/package/inquirer for more.
96
102
  *
@@ -158,7 +164,7 @@ class SfCommand extends core_1.Command {
158
164
  if (this.jsonEnabled()) {
159
165
  core_1.CliUx.ux.styledJSON(this.toErrorJson(error));
160
166
  }
161
- throw error;
167
+ return error;
162
168
  }
163
169
  /**
164
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.2",
3
+ "version": "1.6.1",
4
4
  "description": "Utils for writing deploy and retrieve plugins",
5
5
  "main": "lib/exported",
6
6
  "types": "lib/exported.d.ts",