@salesforce/sf-plugins-core 1.7.2 → 1.8.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,25 @@
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.8.1](https://github.com/salesforcecli/sf-plugins-core/compare/v1.8.0...v1.8.1) (2022-03-24)
6
+
7
+ ### Bug Fixes
8
+
9
+ - log errors to stderr ([9958d8e](https://github.com/salesforcecli/sf-plugins-core/commit/9958d8e49cf1fbe514026491d8d095651d1cb88b))
10
+
11
+ ## [1.8.0](https://github.com/salesforcecli/sf-plugins-core/compare/v1.7.2...v1.8.0) (2022-03-17)
12
+
13
+ ### Features
14
+
15
+ - confirms are timed ([9c89ee9](https://github.com/salesforcecli/sf-plugins-core/commit/9c89ee99901c7abefc11a811e8e4dda0c704ed1c))
16
+ - simplified confirm prompts ([ddf1364](https://github.com/salesforcecli/sf-plugins-core/commit/ddf1364a48fb384bd0ad66bc310a35abcef20d68))
17
+
18
+ ### Bug Fixes
19
+
20
+ - better checking of hub ([8c92bfe](https://github.com/salesforcecli/sf-plugins-core/commit/8c92bfed8f0600ff03489abbb253b5b95c95128a))
21
+ - no unused, respects timeout ([c41c43e](https://github.com/salesforcecli/sf-plugins-core/commit/c41c43e5c480dc1dd914a86ec8c97a8af41369a1))
22
+ - use OptionFlag interface so that exactlyOne can be used ([0e65453](https://github.com/salesforcecli/sf-plugins-core/commit/0e65453dacb68a90f4af2387e571edbd4077ba1b))
23
+
5
24
  ### [1.7.2](https://github.com/salesforcecli/sf-plugins-core/compare/v1.7.1...v1.7.2) (2022-03-15)
6
25
 
7
26
  ### Bug Fixes
@@ -1,7 +1,7 @@
1
1
  import { Interfaces } from '@oclif/core';
2
2
  import { Duration } from '@salesforce/kit';
3
3
  declare type DurationUnit = Lowercase<keyof typeof Duration.Unit>;
4
- export interface DurationFlagConfig extends Partial<Interfaces.OptionFlagProps> {
4
+ export interface DurationFlagConfig extends Partial<Interfaces.OptionFlag<Duration>> {
5
5
  unit: Required<DurationUnit>;
6
6
  defaultValue?: number;
7
7
  min?: number;
@@ -31,11 +31,10 @@ const getHubOrThrow = async (aliasOrUsername) => {
31
31
  }
32
32
  }
33
33
  const org = await core_2.Org.create({ aliasOrUsername });
34
- // check the synchronous, cached version and only use "determine" if we didn't get a positive result
35
- if (!org.isDevHubOrg() || !(await org.determineIfDevHubOrg())) {
36
- throw messages.createError('errors.NotADevHub', [aliasOrUsername]);
34
+ if (await org.determineIfDevHubOrg()) {
35
+ return org;
37
36
  }
38
- return org;
37
+ throw messages.createError('errors.NotADevHub', [aliasOrUsername]);
39
38
  };
40
39
  /**
41
40
  * An optional org specified by username or alias
@@ -58,7 +57,7 @@ exports.optionalOrgFlag = core_1.Flags.build({
58
57
  char: 'e',
59
58
  parse: async (input) => await maybeGetOrg(input),
60
59
  default: async () => await maybeGetOrg(),
61
- defaultHelp: async () => { var _a; return (_a = (await maybeGetOrg(undefined))) === null || _a === void 0 ? void 0 : _a.getUsername(); },
60
+ defaultHelp: async () => { var _a; return (_a = (await maybeGetOrg())) === null || _a === void 0 ? void 0 : _a.getUsername(); },
62
61
  });
63
62
  /**
64
63
  * An required org, specified by username or alias
@@ -82,8 +81,8 @@ exports.optionalOrgFlag = core_1.Flags.build({
82
81
  exports.requiredOrgFlag = core_1.Flags.build({
83
82
  char: 'e',
84
83
  parse: async (input) => await getOrgOrThrow(input),
85
- default: async () => await getOrgOrThrow(undefined),
86
- defaultHelp: async () => { var _a; return (_a = (await getOrgOrThrow(undefined))) === null || _a === void 0 ? void 0 : _a.getUsername(); },
84
+ default: async () => await getOrgOrThrow(),
85
+ defaultHelp: async () => { var _a; return (_a = (await getOrgOrThrow())) === null || _a === void 0 ? void 0 : _a.getUsername(); },
87
86
  });
88
87
  /**
89
88
  * An required org that is a devHub
@@ -107,7 +106,7 @@ exports.requiredOrgFlag = core_1.Flags.build({
107
106
  exports.requiredHubFlag = core_1.Flags.build({
108
107
  char: 'v',
109
108
  parse: async (input) => await getHubOrThrow(input),
110
- default: async () => await getHubOrThrow(undefined),
111
- defaultHelp: async () => { var _a; return (_a = (await getHubOrThrow(undefined))) === null || _a === void 0 ? void 0 : _a.getUsername(); },
109
+ default: async () => await getHubOrThrow(),
110
+ defaultHelp: async () => { var _a; return (_a = (await getHubOrThrow())) === null || _a === void 0 ? void 0 : _a.getUsername(); },
112
111
  });
113
112
  //# sourceMappingURL=orgFlags.js.map
@@ -1,5 +1,5 @@
1
1
  import { Interfaces } from '@oclif/core';
2
- export interface IdFlagConfig extends Partial<Interfaces.OptionFlagProps> {
2
+ export interface IdFlagConfig extends Partial<Interfaces.OptionFlag<string>> {
3
3
  /**
4
4
  * Can specify if the version must be 15 or 18 characters long. Leave blank to allow either 15 or 18.
5
5
  */
@@ -80,6 +80,14 @@ export declare abstract class SfCommand<T> extends Command {
80
80
  * }
81
81
  */
82
82
  prompt<R = Prompter.Answers>(questions: Prompter.Questions<R>, initialAnswers?: Partial<R>): Promise<R>;
83
+ /**
84
+ * Simplified prompt for single-question confirmation. Times out and throws after 10s
85
+ *
86
+ * @param message text to display. Do not include a question mark.
87
+ * @param ms milliseconds to wait for user input. Defaults to 10s.
88
+ * @return true if the user confirms, false if they do not.
89
+ */
90
+ confirm(message: string, ms?: number): Promise<boolean>;
83
91
  /**
84
92
  * Prompt user for information with a timeout (in milliseconds). See https://www.npmjs.com/package/inquirer for more.
85
93
  */
package/lib/sfCommand.js CHANGED
@@ -113,6 +113,23 @@ class SfCommand extends core_1.Command {
113
113
  async prompt(questions, initialAnswers) {
114
114
  return this.prompter.prompt(questions, initialAnswers);
115
115
  }
116
+ /**
117
+ * Simplified prompt for single-question confirmation. Times out and throws after 10s
118
+ *
119
+ * @param message text to display. Do not include a question mark.
120
+ * @param ms milliseconds to wait for user input. Defaults to 10s.
121
+ * @return true if the user confirms, false if they do not.
122
+ */
123
+ async confirm(message, ms = 10000) {
124
+ const { confirmed } = await this.timedPrompt([
125
+ {
126
+ name: 'confirmed',
127
+ message,
128
+ type: 'confirm',
129
+ },
130
+ ], ms);
131
+ return confirmed;
132
+ }
116
133
  /**
117
134
  * Prompt user for information with a timeout (in milliseconds). See https://www.npmjs.com/package/inquirer for more.
118
135
  */
@@ -166,10 +183,13 @@ class SfCommand extends core_1.Command {
166
183
  async catch(error) {
167
184
  var _a, _b;
168
185
  process.exitCode = (_b = (_a = process.exitCode) !== null && _a !== void 0 ? _a : error.exitCode) !== null && _b !== void 0 ? _b : 1;
169
- this.log(this.formatError(error));
170
186
  if (this.jsonEnabled()) {
171
187
  core_1.CliUx.ux.styledJSON(this.toErrorJson(error));
172
188
  }
189
+ else {
190
+ // eslint-disable-next-line no-console
191
+ console.error(this.formatError(error));
192
+ }
173
193
  return error;
174
194
  }
175
195
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salesforce/sf-plugins-core",
3
- "version": "1.7.2",
3
+ "version": "1.8.1",
4
4
  "description": "Utils for writing deploy and retrieve plugins",
5
5
  "main": "lib/exported",
6
6
  "types": "lib/exported.d.ts",
@@ -32,7 +32,7 @@
32
32
  "/messages"
33
33
  ],
34
34
  "dependencies": {
35
- "@oclif/core": "^1.5.2",
35
+ "@oclif/core": "^1.6.0",
36
36
  "@salesforce/core": "^3.7.9",
37
37
  "@salesforce/kit": "^1.5.34",
38
38
  "@salesforce/ts-types": "^1.5.20",