@salesforce/sf-plugins-core 1.12.3 → 1.13.2

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,29 @@
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.13.2](https://github.com/salesforcecli/sf-plugins-core/compare/v1.13.1...v1.13.2) (2022-08-09)
6
+
7
+ ### Bug Fixes
8
+
9
+ - add function overloads to custom flags ([12c1178](https://github.com/salesforcecli/sf-plugins-core/commit/12c117837a08bc8cf8eff41832f95a19d3386b18))
10
+ - compile errors ([3782a70](https://github.com/salesforcecli/sf-plugins-core/commit/3782a703b7b0eddbc3d47a7dcbdf33272bdfd6fc))
11
+
12
+ ### [1.13.1](https://github.com/salesforcecli/sf-plugins-core/compare/v1.13.0...v1.13.1) (2022-08-03)
13
+
14
+ ### Bug Fixes
15
+
16
+ - add number to deploy function return type ([ac9457b](https://github.com/salesforcecli/sf-plugins-core/commit/ac9457b78ab1242090fc4322ec266e8d0157cb6f))
17
+
18
+ ## [1.13.0](https://github.com/salesforcecli/sf-plugins-core/compare/v1.12.3...v1.13.0) (2022-06-09)
19
+
20
+ ### Features
21
+
22
+ - catch method supports base and SfError ([2b9a038](https://github.com/salesforcecli/sf-plugins-core/commit/2b9a038713c77e1230e21f5cc6f8ae2a6aaab5be))
23
+
24
+ ### Bug Fixes
25
+
26
+ - error can't be spread ([30930b7](https://github.com/salesforcecli/sf-plugins-core/commit/30930b74ff5e6b59116228d547362a284ad98388))
27
+
5
28
  ### [1.12.3](https://github.com/salesforcecli/sf-plugins-core/compare/v1.12.2...v1.12.3) (2022-05-04)
6
29
 
7
30
  ### Bug Fixes
package/lib/deployer.d.ts CHANGED
@@ -2,6 +2,9 @@
2
2
  import { EventEmitter } from 'events';
3
3
  import { AnyJson, JsonMap } from '@salesforce/ts-types';
4
4
  import { QuestionCollection } from 'inquirer';
5
+ export declare type DeployerResult = {
6
+ exitCode: number;
7
+ };
5
8
  export declare abstract class Deployable {
6
9
  abstract getName(): string;
7
10
  abstract getType(): string;
@@ -51,7 +54,7 @@ export declare abstract class Deployer extends EventEmitter {
51
54
  /**
52
55
  * Deploy the app.
53
56
  */
54
- abstract deploy(): Promise<void>;
57
+ abstract deploy<R extends DeployerResult>(): Promise<void | R>;
55
58
  }
56
59
  export declare namespace Deployer {
57
60
  type Flags = {
package/lib/exported.d.ts CHANGED
@@ -1,25 +1,23 @@
1
1
  /// <reference types="node" />
2
2
  export { toHelpSection } from './util';
3
- export { Deployable, Deployer } from './deployer';
3
+ export { Deployable, Deployer, DeployerResult } from './deployer';
4
4
  export { Deauthorizer } from './deauthorizer';
5
5
  export { Progress, Prompter, generateTableChoices } from './ux';
6
6
  export { SfHook } from './hooks';
7
7
  export * from './types';
8
8
  export { SfCommand, SfCommandInterface, StandardColors } from './sfCommand';
9
+ import { salesforceIdFlag } from './flags/salesforceId';
10
+ import { durationFlag } from './flags/duration';
9
11
  export declare const Flags: {
10
12
  boolean: typeof import("@oclif/core/lib/parser/flags").boolean;
11
- directory: (opts?: ({
12
- exists?: boolean | undefined;
13
- } & Partial<import("@oclif/core/lib/interfaces").OptionFlag<string>>) | undefined) => import("@oclif/core/lib/interfaces").OptionFlag<string | undefined>;
13
+ directory: typeof import("@oclif/core/lib/parser/flags").directory;
14
14
  enum: <T = string>(opts: import("@oclif/core/lib/interfaces").EnumFlagOptions<T>) => import("@oclif/core/lib/interfaces").OptionFlag<T>;
15
- file: (opts?: ({
16
- exists?: boolean | undefined;
17
- } & Partial<import("@oclif/core/lib/interfaces").OptionFlag<string>>) | undefined) => import("@oclif/core/lib/interfaces").OptionFlag<string | undefined>;
18
- integer: import("@oclif/core/lib/interfaces").Definition<number>;
15
+ file: typeof import("@oclif/core/lib/parser/flags").file;
16
+ integer: typeof import("@oclif/core/lib/parser/flags").integer;
19
17
  string: import("@oclif/core/lib/interfaces").Definition<string>;
20
18
  url: import("@oclif/core/lib/interfaces").Definition<import("url").URL>;
21
- duration: (durationConfig: import("./flags/duration").DurationFlagConfig) => import("@oclif/core/lib/interfaces").OptionFlag<import("@salesforce/kit").Duration | undefined>;
22
- salesforceId: (inputs?: import("./flags/salesforceId").IdFlagConfig) => import("@oclif/core/lib/interfaces").OptionFlag<string | undefined>;
19
+ duration: typeof durationFlag;
20
+ salesforceId: typeof salesforceIdFlag;
23
21
  orgApiVersion: import("@oclif/core/lib/interfaces").Definition<string>;
24
22
  requiredOrg: import("@oclif/core/lib/interfaces").Definition<import("@salesforce/core").Org>;
25
23
  requiredHub: import("@oclif/core/lib/interfaces").Definition<import("@salesforce/core").Org>;
@@ -24,6 +24,11 @@ export interface DurationFlagConfig extends Partial<Interfaces.OptionFlag<Durati
24
24
  * }),
25
25
  * }
26
26
  */
27
- export declare const durationFlag: (durationConfig: DurationFlagConfig) => Interfaces.OptionFlag<Duration | undefined>;
27
+ export declare function durationFlag(durationConfig: DurationFlagConfig & ({
28
+ required: true;
29
+ } | {
30
+ default: Interfaces.Default<Duration>;
31
+ })): Interfaces.OptionFlag<Duration>;
32
+ export declare function durationFlag(durationConfig: DurationFlagConfig): Interfaces.OptionFlag<Duration | undefined>;
28
33
  export {};
29
34
  //# sourceMappingURL=duration.d.ts.map
@@ -12,31 +12,14 @@ const core_2 = require("@salesforce/core");
12
12
  const kit_1 = require("@salesforce/kit");
13
13
  core_2.Messages.importMessagesDirectory(__dirname);
14
14
  const messages = core_2.Messages.loadMessages('@salesforce/sf-plugins-core', 'messages');
15
- /**
16
- * Duration flag with built-in default and min/max validation
17
- * You must specify a unit
18
- * Defaults to undefined if you don't specify a default
19
- *
20
- * @example
21
- * import { SfCommand, Flags } from '@salesforce/sf-plugins-core';
22
- * public static flags = {
23
- * 'wait': duration({
24
- * min: 1,
25
- * unit: 'minutes'
26
- * defaultValue: 33,
27
- * char: 'w',
28
- * description: 'Wait time in minutes'
29
- * }),
30
- * }
31
- */
32
- const durationFlag = (durationConfig) => {
15
+ function durationFlag(durationConfig) {
33
16
  const { defaultValue, min, max, unit, ...baseProps } = durationConfig;
34
17
  return core_1.Flags.build({
35
18
  ...baseProps,
36
19
  parse: async (input) => validate(input, { min, max, unit }),
37
20
  default: defaultValue ? async () => toDuration(defaultValue, unit) : undefined,
38
21
  })();
39
- };
22
+ }
40
23
  exports.durationFlag = durationFlag;
41
24
  const validate = (input, config) => {
42
25
  const { min, max, unit } = config || {};
@@ -28,5 +28,10 @@ export interface IdFlagConfig extends Partial<Interfaces.OptionFlag<string>> {
28
28
  * }),
29
29
  * }
30
30
  */
31
- export declare const salesforceIdFlag: (inputs?: IdFlagConfig) => Interfaces.OptionFlag<string | undefined>;
31
+ export declare function salesforceIdFlag(inputs: IdFlagConfig & ({
32
+ required: true;
33
+ } | {
34
+ default: Interfaces.Default<string>;
35
+ })): Interfaces.OptionFlag<string>;
36
+ export declare function salesforceIdFlag(inputs?: IdFlagConfig): Interfaces.OptionFlag<string | undefined>;
32
37
  //# sourceMappingURL=salesforceId.d.ts.map
@@ -11,33 +11,14 @@ const core_1 = require("@oclif/core");
11
11
  const core_2 = require("@salesforce/core");
12
12
  core_2.Messages.importMessagesDirectory(__dirname);
13
13
  const messages = core_2.Messages.loadMessages('@salesforce/sf-plugins-core', 'messages');
14
- /**
15
- * Id flag with built-in validation. Short character is `i`
16
- *
17
- * @example
18
- * import { SfCommand, Flags } from '@salesforce/sf-plugins-core';
19
- * public static flags = {
20
- * // set length or prefix
21
- * 'flag-name': salesforceId({ length: 15, startsWith: '00D' }),
22
- * // add flag properties
23
- * 'flag2': salesforceId({
24
- * required: true,
25
- * description: 'flag2 description',
26
- * }),
27
- * // override the character i
28
- * 'flag3': salesforceId({
29
- * char: 'j',
30
- * }),
31
- * }
32
- */
33
- const salesforceIdFlag = (inputs = {}) => {
14
+ function salesforceIdFlag(inputs = {}) {
34
15
  const { length, startsWith, ...baseProps } = inputs;
35
16
  return core_1.Flags.build({
36
17
  char: 'i',
37
18
  ...baseProps,
38
19
  parse: async (input) => validate(input, { length, startsWith }),
39
20
  })();
40
- };
21
+ }
41
22
  exports.salesforceIdFlag = salesforceIdFlag;
42
23
  const validate = (input, config) => {
43
24
  const { length, startsWith } = config || {};
@@ -1,5 +1,5 @@
1
1
  import { CliUx, Command, Config, HelpSection, Interfaces } from '@oclif/core';
2
- import { SfProject, StructuredMessage } from '@salesforce/core';
2
+ import { SfProject, StructuredMessage, SfError } from '@salesforce/core';
3
3
  import { AnyJson } from '@salesforce/ts-types';
4
4
  import * as chalk from 'chalk';
5
5
  import { Progress, Prompter, Spinner, Ux } from './ux';
@@ -114,9 +114,9 @@ export declare abstract class SfCommand<T> extends Command {
114
114
  /**
115
115
  * Wrap the command error into the standardized JSON structure.
116
116
  */
117
- protected toErrorJson(error: Error): SfCommand.Error;
117
+ protected toErrorJson(error: SfCommand.Error): SfCommand.Error;
118
118
  protected assignProject(): Promise<SfProject>;
119
- protected catch(error: SfCommand.Error): Promise<SfCommand.Error>;
119
+ protected catch(error: Error | SfError | SfCommand.Error): Promise<SfCommand.Error>;
120
120
  /**
121
121
  * Format errors and actions for human consumption. Adds 'Error (<ErrorCode>):',
122
122
  * When there are actions, we add 'Try this:' in blue
@@ -153,6 +153,8 @@ export declare namespace SfCommand {
153
153
  actions?: string[];
154
154
  code?: unknown;
155
155
  exitCode?: number;
156
+ data?: unknown;
157
+ context?: string;
156
158
  }
157
159
  }
158
160
  //# sourceMappingURL=sfCommand.d.ts.map
package/lib/sfCommand.js CHANGED
@@ -178,12 +178,8 @@ class SfCommand extends core_1.Command {
178
178
  * Wrap the command error into the standardized JSON structure.
179
179
  */
180
180
  toErrorJson(error) {
181
- var _a;
182
181
  return {
183
- status: (_a = process.exitCode) !== null && _a !== void 0 ? _a : 1,
184
- stack: error.stack,
185
- name: error.name,
186
- message: error.message,
182
+ ...error,
187
183
  warnings: this.warnings,
188
184
  };
189
185
  }
@@ -200,15 +196,30 @@ class SfCommand extends core_1.Command {
200
196
  }
201
197
  async catch(error) {
202
198
  var _a, _b;
203
- process.exitCode = (_b = (_a = process.exitCode) !== null && _a !== void 0 ? _a : error.exitCode) !== null && _b !== void 0 ? _b : 1;
199
+ // transform an unknown error into one that conforms to the interface
200
+ const codeFromError = error instanceof core_2.SfError ? error.exitCode : 1;
201
+ (_a = process.exitCode) !== null && _a !== void 0 ? _a : (process.exitCode = codeFromError);
202
+ const sfErrorProperties = error instanceof core_2.SfError
203
+ ? { data: error.data, actions: error.actions, code: codeFromError, context: error.context }
204
+ : {};
205
+ const sfCommandError = {
206
+ ...sfErrorProperties,
207
+ ...{
208
+ message: error.message,
209
+ name: (_b = error.name) !== null && _b !== void 0 ? _b : 'Error',
210
+ status: process.exitCode,
211
+ stack: error.stack,
212
+ exitCode: process.exitCode,
213
+ },
214
+ };
204
215
  if (this.jsonEnabled()) {
205
- core_1.CliUx.ux.styledJSON(this.toErrorJson(error));
216
+ core_1.CliUx.ux.styledJSON(this.toErrorJson(sfCommandError));
206
217
  }
207
218
  else {
208
219
  // eslint-disable-next-line no-console
209
- console.error(this.formatError(error));
220
+ console.error(this.formatError(sfCommandError));
210
221
  }
211
- return error;
222
+ return sfCommandError;
212
223
  }
213
224
  /**
214
225
  * Format errors and actions for human consumption. Adds 'Error (<ErrorCode>):',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salesforce/sf-plugins-core",
3
- "version": "1.12.3",
3
+ "version": "1.13.2",
4
4
  "description": "Utils for writing deploy and retrieve plugins",
5
5
  "main": "lib/exported",
6
6
  "types": "lib/exported.d.ts",
@@ -32,9 +32,9 @@
32
32
  "/messages"
33
33
  ],
34
34
  "dependencies": {
35
- "@oclif/core": "^1.7.0",
36
- "@salesforce/core": "^3.15.5",
37
- "@salesforce/kit": "^1.5.41",
35
+ "@oclif/core": "^1.13.9",
36
+ "@salesforce/core": "^3.25.0",
37
+ "@salesforce/kit": "^1.5.44",
38
38
  "@salesforce/ts-types": "^1.5.20",
39
39
  "chalk": "^4",
40
40
  "inquirer": "^8.2.0"
@@ -49,14 +49,14 @@
49
49
  "@typescript-eslint/eslint-plugin": "^4.33.0",
50
50
  "@typescript-eslint/parser": "^4.33.0",
51
51
  "chai": "^4.3.6",
52
- "eslint": "^6.8.0",
52
+ "eslint": "^7.32.0",
53
53
  "eslint-config-prettier": "^6.15.0",
54
54
  "eslint-config-salesforce": "^0.1.6",
55
55
  "eslint-config-salesforce-license": "^0.1.6",
56
56
  "eslint-config-salesforce-typescript": "^0.2.8",
57
57
  "eslint-plugin-header": "^3.1.1",
58
58
  "eslint-plugin-import": "^2.25.4",
59
- "eslint-plugin-jsdoc": "^27.1.2",
59
+ "eslint-plugin-jsdoc": "^35.1.2",
60
60
  "eslint-plugin-prettier": "^3.4.1",
61
61
  "husky": "^7.0.4",
62
62
  "mocha": "^8.4.0",