@salesforce/sf-plugins-core 1.14.0 → 1.15.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/README.md CHANGED
@@ -13,7 +13,7 @@ The SfCommand abstract class extends [@oclif/core's Command class](https://githu
13
13
  - Enable the json flag support by default
14
14
  - Provides functions that help place success messages, warnings and errors into the correct location in JSON results
15
15
  - Enables additional help sections to the standard oclif command help output
16
- - Provides access to the [cli-ux cli actions](https://github.com/oclif/cli-ux#cliaction) via the public property `spinner` in SfCommand. This avoids having to import that interface from cli-ux.
16
+ - Provides access to the [cli-ux cli actions](https://github.com/oclif/cli-ux#cliaction). This avoids having to import that interface from cli-ux and manually handling the `--json` flag.
17
17
 
18
18
  ## Sf Hooks
19
19
 
@@ -1,7 +1,6 @@
1
1
  import { JsonMap } from '@salesforce/ts-types';
2
2
  /**
3
- * The Deauthorizer is an abstract class that is used to implement a concrete implementations
4
- * of deauthorizing an environment.
3
+ * The Deauthorizer is an abstract class that is used to implement a concrete implementation of deauthorizing an environment.
5
4
  */
6
5
  export declare abstract class Deauthorizer<T = JsonMap> {
7
6
  removeAll(): Promise<Deauthorizer.Result>;
@@ -8,8 +8,7 @@
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
9
  exports.Deauthorizer = void 0;
10
10
  /**
11
- * The Deauthorizer is an abstract class that is used to implement a concrete implementations
12
- * of deauthorizing an environment.
11
+ * The Deauthorizer is an abstract class that is used to implement a concrete implementation of deauthorizing an environment.
13
12
  */
14
13
  class Deauthorizer {
15
14
  async removeAll() {
@@ -20,6 +19,8 @@ class Deauthorizer {
20
19
  const environments = await this.find();
21
20
  for (const id of Object.keys(environments)) {
22
21
  try {
22
+ // avoid configFile collision bug
23
+ // eslint-disable-next-line no-await-in-loop
23
24
  await this.remove(id);
24
25
  result.successes.push(id);
25
26
  }
package/lib/deployer.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  /// <reference types="node" />
2
2
  import { EventEmitter } from 'events';
3
3
  import { AnyJson, JsonMap } from '@salesforce/ts-types';
4
- import { QuestionCollection } from 'inquirer';
4
+ import { QuestionCollection, Answers } from 'inquirer';
5
5
  export declare type DeployerResult = {
6
6
  exitCode: number;
7
7
  };
@@ -33,7 +33,7 @@ export declare abstract class Deployer extends EventEmitter {
33
33
  /**
34
34
  * Prompt user for additional information
35
35
  */
36
- prompt<T>(questions: QuestionCollection<T>, initialAnswers?: Partial<T>): Promise<T>;
36
+ prompt<T extends Answers>(questions: QuestionCollection<T>, initialAnswers?: Partial<T>): Promise<T>;
37
37
  /**
38
38
  * Overwrite the deployables property on the class.
39
39
  */
@@ -62,6 +62,9 @@ export declare namespace Deployer {
62
62
  };
63
63
  /**
64
64
  * This interface represents the aggregation of all deployer options, e.g.
65
+ *
66
+ * @example
67
+ * ```
65
68
  * {
66
69
  * 'Salesforce Apps': {
67
70
  * testLevel: 'RunLocalTests',
@@ -69,6 +72,7 @@ export declare namespace Deployer {
69
72
  * },
70
73
  * 'Salesforce Functions': { username: 'user@salesforce.com' },
71
74
  * }
75
+ * ```
72
76
  */
73
77
  type Options<T = AnyJson> = JsonMap & {
74
78
  [key: string]: T;
package/lib/deployer.js CHANGED
@@ -5,6 +5,7 @@
5
5
  * Licensed under the BSD 3-Clause license.
6
6
  * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
7
7
  */
8
+ /* eslint-disable @typescript-eslint/explicit-member-accessibility */
8
9
  Object.defineProperty(exports, "__esModule", { value: true });
9
10
  exports.Deployer = exports.Deployable = void 0;
10
11
  const events_1 = require("events");
@@ -30,11 +31,12 @@ class Deployer extends events_1.EventEmitter {
30
31
  /**
31
32
  * Method for displaying deploy progress to the user
32
33
  */
33
- // eslint-disable-next-line @typescript-eslint/no-unused-vars, @typescript-eslint/no-empty-function
34
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars, @typescript-eslint/no-empty-function, class-methods-use-this
34
35
  progress(current, total, message) { }
35
36
  /**
36
37
  * Log messages to the console
37
38
  */
39
+ // eslint-disable-next-line class-methods-use-this
38
40
  log(msg, ...args) {
39
41
  core_1.CliUx.ux.log(msg, ...args);
40
42
  }
package/lib/exported.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  /// <reference types="node" />
2
2
  import { Flags as OclifFlags } from '@oclif/core';
3
- export { toHelpSection } from './util';
3
+ export { toHelpSection, parseVarArgs } from './util';
4
4
  export { Deployable, Deployer, DeployerResult } from './deployer';
5
5
  export { Deauthorizer } from './deauthorizer';
6
6
  export { Progress, Prompter, generateTableChoices } from './ux';
package/lib/exported.js CHANGED
@@ -20,10 +20,11 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
20
20
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
21
21
  };
22
22
  Object.defineProperty(exports, "__esModule", { value: true });
23
- exports.Flags = exports.StandardColors = exports.SfCommand = exports.SfHook = exports.generateTableChoices = exports.Prompter = exports.Progress = exports.Deauthorizer = exports.Deployer = exports.Deployable = exports.toHelpSection = void 0;
23
+ exports.Flags = exports.StandardColors = exports.SfCommand = exports.SfHook = exports.generateTableChoices = exports.Prompter = exports.Progress = exports.Deauthorizer = exports.Deployer = exports.Deployable = exports.parseVarArgs = exports.toHelpSection = void 0;
24
24
  const core_1 = require("@oclif/core");
25
25
  var util_1 = require("./util");
26
26
  Object.defineProperty(exports, "toHelpSection", { enumerable: true, get: function () { return util_1.toHelpSection; } });
27
+ Object.defineProperty(exports, "parseVarArgs", { enumerable: true, get: function () { return util_1.parseVarArgs; } });
27
28
  var deployer_1 = require("./deployer");
28
29
  Object.defineProperty(exports, "Deployable", { enumerable: true, get: function () { return deployer_1.Deployable; } });
29
30
  Object.defineProperty(exports, "Deployer", { enumerable: true, get: function () { return deployer_1.Deployer; } });
@@ -12,9 +12,11 @@ export declare type DurationFlagConfig = {
12
12
  * Defaults to undefined if you don't specify a default
13
13
  *
14
14
  * @example
15
- * import { SfCommand, Flags } from '@salesforce/sf-plugins-core';
15
+ *
16
+ * ```
17
+ * import { Flags } from '@salesforce/sf-plugins-core';
16
18
  * public static flags = {
17
- * 'wait': duration({
19
+ * wait: Flags.duration({
18
20
  * min: 1,
19
21
  * unit: 'minutes'
20
22
  * defaultValue: 33,
@@ -22,6 +24,7 @@ export declare type DurationFlagConfig = {
22
24
  * description: 'Wait time in minutes'
23
25
  * }),
24
26
  * }
27
+ * ```
25
28
  */
26
29
  export declare const durationFlag: import("@oclif/core/lib/interfaces").Definition<Duration, DurationFlagConfig>;
27
30
  export {};
@@ -18,9 +18,11 @@ const messages = core_2.Messages.loadMessages('@salesforce/sf-plugins-core', 'me
18
18
  * Defaults to undefined if you don't specify a default
19
19
  *
20
20
  * @example
21
- * import { SfCommand, Flags } from '@salesforce/sf-plugins-core';
21
+ *
22
+ * ```
23
+ * import { Flags } from '@salesforce/sf-plugins-core';
22
24
  * public static flags = {
23
- * 'wait': duration({
25
+ * wait: Flags.duration({
24
26
  * min: 1,
25
27
  * unit: 'minutes'
26
28
  * defaultValue: 33,
@@ -28,12 +30,11 @@ const messages = core_2.Messages.loadMessages('@salesforce/sf-plugins-core', 'me
28
30
  * description: 'Wait time in minutes'
29
31
  * }),
30
32
  * }
33
+ * ```
31
34
  */
32
35
  exports.durationFlag = core_1.Flags.custom({
33
36
  parse: async (input, _, opts) => validate(input, opts),
34
- default: async (context) => {
35
- return context.options.defaultValue ? toDuration(context.options.defaultValue, context.options.unit) : undefined;
36
- },
37
+ default: async (context) => context.options.defaultValue ? toDuration(context.options.defaultValue, context.options.unit) : undefined,
37
38
  });
38
39
  const validate = (input, config) => {
39
40
  const { min, max, unit } = config || {};
@@ -55,7 +56,5 @@ const validate = (input, config) => {
55
56
  }
56
57
  return toDuration(parsedInput, unit);
57
58
  };
58
- const toDuration = (parsedInput, unit) => {
59
- return kit_1.Duration[unit](parsedInput);
60
- };
59
+ const toDuration = (parsedInput, unit) => kit_1.Duration[unit](parsedInput);
61
60
  //# sourceMappingURL=duration.js.map
@@ -8,6 +8,18 @@ export declare const maxDeprecatedUrl = "https://help.salesforce.com/s/articleVi
8
8
  *
9
9
  * CAVEAT: unlike the apiversion flag on sfdxCommand, this does not set the version on the org/connection
10
10
  * We leave this up to the plugins to implement
11
+ *
12
+ * @example
13
+ *
14
+ * ```
15
+ * import { Flags } from '@salesforce/sf-plugins-core';
16
+ * public static flags = {
17
+ * 'api-version': Flags.orgApiVersion({
18
+ * char: 'a',
19
+ * description: 'api version for the org'
20
+ * }),
21
+ * }
22
+ * ```
11
23
  */
12
24
  export declare const orgApiVersionFlag: import("@oclif/core/lib/interfaces").Definition<string, Record<string, unknown>>;
13
25
  //# sourceMappingURL=orgApiVersion.d.ts.map
@@ -23,18 +23,29 @@ exports.maxDeprecatedUrl = 'https://help.salesforce.com/s/articleView?id=0003544
23
23
  *
24
24
  * CAVEAT: unlike the apiversion flag on sfdxCommand, this does not set the version on the org/connection
25
25
  * We leave this up to the plugins to implement
26
+ *
27
+ * @example
28
+ *
29
+ * ```
30
+ * import { Flags } from '@salesforce/sf-plugins-core';
31
+ * public static flags = {
32
+ * 'api-version': Flags.orgApiVersion({
33
+ * char: 'a',
34
+ * description: 'api version for the org'
35
+ * }),
36
+ * }
37
+ * ```
26
38
  */
27
39
  exports.orgApiVersionFlag = core_1.Flags.custom({
28
40
  parse: async (input) => validate(input),
29
- default: async () => await getDefaultFromConfig(),
41
+ default: async () => getDefaultFromConfig(),
30
42
  description: messages.getMessage('flags.apiVersion.description'),
31
43
  });
32
44
  const getDefaultFromConfig = async () => {
33
- var _a;
34
45
  // (perf) only import ConfigAggregator if necessary
35
46
  const { ConfigAggregator } = await Promise.resolve().then(() => require('@salesforce/core'));
36
47
  const config = await ConfigAggregator.create();
37
- const apiVersionFromConfig = (_a = config.getInfo(core_2.OrgConfigProperties.ORG_API_VERSION)) === null || _a === void 0 ? void 0 : _a.value;
48
+ const apiVersionFromConfig = config.getInfo(core_2.OrgConfigProperties.ORG_API_VERSION)?.value;
38
49
  if (apiVersionFromConfig) {
39
50
  await core_2.Lifecycle.getInstance().emitWarning(messages.getMessage('flags.apiVersion.overrideWarning', [apiVersionFromConfig]));
40
51
  return validate(apiVersionFromConfig);
@@ -5,7 +5,9 @@ import { Org } from '@salesforce/core';
5
5
  * Will not throw if the specified org and default do not exist
6
6
  *
7
7
  * @example
8
- * import { SfCommand, Flags } from '@salesforce/sf-plugins-core';
8
+ *
9
+ * ```
10
+ * import { Flags } from '@salesforce/sf-plugins-core';
9
11
  * public static flags = {
10
12
  * // setting length or prefix
11
13
  * 'target-org': Flags.optionalOrg(),
@@ -15,6 +17,7 @@ import { Org } from '@salesforce/core';
15
17
  * description: 'flag2 description',
16
18
  * }),
17
19
  * }
20
+ * ```
18
21
  */
19
22
  export declare const optionalOrgFlag: import("@oclif/core/lib/interfaces").Definition<Org | undefined, Record<string, unknown>>;
20
23
  /**
@@ -24,7 +27,9 @@ export declare const optionalOrgFlag: import("@oclif/core/lib/interfaces").Defin
24
27
  * Will throw if no default org exists and none is specified
25
28
  *
26
29
  * @example
27
- * import { SfCommand, Flags } from '@salesforce/sf-plugins-core';
30
+ *
31
+ * ```
32
+ * import { Flags } from '@salesforce/sf-plugins-core';
28
33
  * public static flags = {
29
34
  * // setting length or prefix
30
35
  * 'target-org': Flags.requiredOrg(),
@@ -35,6 +40,7 @@ export declare const optionalOrgFlag: import("@oclif/core/lib/interfaces").Defin
35
40
  * char: 'o'
36
41
  * }),
37
42
  * }
43
+ * ```
38
44
  */
39
45
  export declare const requiredOrgFlag: import("@oclif/core/lib/interfaces").Definition<Org, Record<string, unknown>>;
40
46
  /**
@@ -44,7 +50,9 @@ export declare const requiredOrgFlag: import("@oclif/core/lib/interfaces").Defin
44
50
  * Will throw if no default deb hub exists and none is specified
45
51
  *
46
52
  * @example
47
- * import { SfCommand, Flags } from '@salesforce/sf-plugins-core';
53
+ *
54
+ * ```
55
+ * import { Flags } from '@salesforce/sf-plugins-core';
48
56
  * public static flags = {
49
57
  * // setting length or prefix
50
58
  * 'target-org': requiredHub(),
@@ -55,6 +63,7 @@ export declare const requiredOrgFlag: import("@oclif/core/lib/interfaces").Defin
55
63
  * char: 'h'
56
64
  * }),
57
65
  * }
66
+ * ```
58
67
  */
59
68
  export declare const requiredHubFlag: import("@oclif/core/lib/interfaces").Definition<Org, Record<string, unknown>>;
60
69
  //# sourceMappingURL=orgFlags.d.ts.map
@@ -32,11 +32,10 @@ const getOrgOrThrow = async (input) => {
32
32
  return org;
33
33
  };
34
34
  const getHubOrThrow = async (aliasOrUsername) => {
35
- var _a;
36
35
  if (!aliasOrUsername) {
37
36
  // check config for a default
38
37
  const config = await core_2.ConfigAggregator.create();
39
- aliasOrUsername = (_a = config.getInfo(core_2.OrgConfigProperties.TARGET_DEV_HUB)) === null || _a === void 0 ? void 0 : _a.value;
38
+ aliasOrUsername = config.getInfo(core_2.OrgConfigProperties.TARGET_DEV_HUB)?.value;
40
39
  if (!aliasOrUsername) {
41
40
  throw messages.createError('errors.NoDefaultDevHub');
42
41
  }
@@ -53,7 +52,9 @@ const getHubOrThrow = async (aliasOrUsername) => {
53
52
  * Will not throw if the specified org and default do not exist
54
53
  *
55
54
  * @example
56
- * import { SfCommand, Flags } from '@salesforce/sf-plugins-core';
55
+ *
56
+ * ```
57
+ * import { Flags } from '@salesforce/sf-plugins-core';
57
58
  * public static flags = {
58
59
  * // setting length or prefix
59
60
  * 'target-org': Flags.optionalOrg(),
@@ -63,12 +64,13 @@ const getHubOrThrow = async (aliasOrUsername) => {
63
64
  * description: 'flag2 description',
64
65
  * }),
65
66
  * }
67
+ * ```
66
68
  */
67
69
  exports.optionalOrgFlag = core_1.Flags.custom({
68
70
  char: 'e',
69
- parse: async (input) => await maybeGetOrg(input),
70
- default: async () => await maybeGetOrg(),
71
- defaultHelp: async () => { var _a; return (_a = (await maybeGetOrg())) === null || _a === void 0 ? void 0 : _a.getUsername(); },
71
+ parse: async (input) => maybeGetOrg(input),
72
+ default: async () => maybeGetOrg(),
73
+ defaultHelp: async () => (await maybeGetOrg())?.getUsername(),
72
74
  });
73
75
  /**
74
76
  * A required org, specified by username or alias
@@ -77,7 +79,9 @@ exports.optionalOrgFlag = core_1.Flags.custom({
77
79
  * Will throw if no default org exists and none is specified
78
80
  *
79
81
  * @example
80
- * import { SfCommand, Flags } from '@salesforce/sf-plugins-core';
82
+ *
83
+ * ```
84
+ * import { Flags } from '@salesforce/sf-plugins-core';
81
85
  * public static flags = {
82
86
  * // setting length or prefix
83
87
  * 'target-org': Flags.requiredOrg(),
@@ -88,12 +92,13 @@ exports.optionalOrgFlag = core_1.Flags.custom({
88
92
  * char: 'o'
89
93
  * }),
90
94
  * }
95
+ * ```
91
96
  */
92
97
  exports.requiredOrgFlag = core_1.Flags.custom({
93
98
  char: 'e',
94
- parse: async (input) => await getOrgOrThrow(input),
95
- default: async () => await getOrgOrThrow(),
96
- defaultHelp: async () => { var _a; return (_a = (await getOrgOrThrow())) === null || _a === void 0 ? void 0 : _a.getUsername(); },
99
+ parse: async (input) => getOrgOrThrow(input),
100
+ default: async () => getOrgOrThrow(),
101
+ defaultHelp: async () => (await getOrgOrThrow())?.getUsername(),
97
102
  });
98
103
  /**
99
104
  * A required org that is a devHub
@@ -102,7 +107,9 @@ exports.requiredOrgFlag = core_1.Flags.custom({
102
107
  * Will throw if no default deb hub exists and none is specified
103
108
  *
104
109
  * @example
105
- * import { SfCommand, Flags } from '@salesforce/sf-plugins-core';
110
+ *
111
+ * ```
112
+ * import { Flags } from '@salesforce/sf-plugins-core';
106
113
  * public static flags = {
107
114
  * // setting length or prefix
108
115
  * 'target-org': requiredHub(),
@@ -113,11 +120,12 @@ exports.requiredOrgFlag = core_1.Flags.custom({
113
120
  * char: 'h'
114
121
  * }),
115
122
  * }
123
+ * ```
116
124
  */
117
125
  exports.requiredHubFlag = core_1.Flags.custom({
118
126
  char: 'v',
119
- parse: async (input) => await getHubOrThrow(input),
120
- default: async () => await getHubOrThrow(),
121
- defaultHelp: async () => { var _a; return (_a = (await getHubOrThrow())) === null || _a === void 0 ? void 0 : _a.getUsername(); },
127
+ parse: async (input) => getHubOrThrow(input),
128
+ default: async () => getHubOrThrow(),
129
+ defaultHelp: async () => (await getHubOrThrow())?.getUsername(),
122
130
  });
123
131
  //# sourceMappingURL=orgFlags.js.map
@@ -12,7 +12,9 @@ export declare type IdFlagConfig = {
12
12
  * Id flag with built-in validation. Short character is `i`
13
13
  *
14
14
  * @example
15
- * import { SfCommand, Flags } from '@salesforce/sf-plugins-core';
15
+ *
16
+ * ```
17
+ * import { Flags } from '@salesforce/sf-plugins-core';
16
18
  * public static flags = {
17
19
  * // set length or prefix
18
20
  * 'flag-name': salesforceId({ length: 15, startsWith: '00D' }),
@@ -26,6 +28,7 @@ export declare type IdFlagConfig = {
26
28
  * char: 'j',
27
29
  * }),
28
30
  * }
31
+ * ```
29
32
  */
30
33
  export declare const salesforceIdFlag: import("@oclif/core/lib/interfaces").Definition<string, IdFlagConfig>;
31
34
  //# sourceMappingURL=salesforceId.d.ts.map
@@ -15,7 +15,9 @@ const messages = core_2.Messages.loadMessages('@salesforce/sf-plugins-core', 'me
15
15
  * Id flag with built-in validation. Short character is `i`
16
16
  *
17
17
  * @example
18
- * import { SfCommand, Flags } from '@salesforce/sf-plugins-core';
18
+ *
19
+ * ```
20
+ * import { Flags } from '@salesforce/sf-plugins-core';
19
21
  * public static flags = {
20
22
  * // set length or prefix
21
23
  * 'flag-name': salesforceId({ length: 15, startsWith: '00D' }),
@@ -29,13 +31,14 @@ const messages = core_2.Messages.loadMessages('@salesforce/sf-plugins-core', 'me
29
31
  * char: 'j',
30
32
  * }),
31
33
  * }
34
+ * ```
32
35
  */
33
36
  exports.salesforceIdFlag = core_1.Flags.custom({
34
37
  parse: async (input, _ctx, opts) => validate(input, opts),
35
38
  char: 'i',
36
39
  });
37
40
  const validate = (input, config) => {
38
- const { length, startsWith } = config || {};
41
+ const { length, startsWith } = config ?? {};
39
42
  if (length && input.length !== length) {
40
43
  throw messages.createError('errors.InvalidIdLength', [length]);
41
44
  }
package/lib/hooks.d.ts CHANGED
@@ -15,9 +15,12 @@ interface SfHooks<T = unknown> extends Hooks {
15
15
  }
16
16
  declare type GenericHook<T extends keyof SfHooks, P> = Hook<T, SfHooks<P>>;
17
17
  /**
18
- * Class that provides a static method to run a well known hook.
18
+ * Class that provides a static method to run a pre-defined sf hook. See {@link SfHooks}.
19
19
  */
20
20
  export declare class SfHook {
21
+ /**
22
+ * Executes a well known Unified CLI hook. See {@link SfHooks}.
23
+ */
21
24
  static run<T extends keyof SfHooks>(config: Config, hookName: T, options?: SfHooks[T]['options']): Promise<Hook.Result<SfHooks[T]['return']>>;
22
25
  }
23
26
  export declare namespace SfHook {
package/lib/hooks.js CHANGED
@@ -10,11 +10,14 @@ exports.SfHook = void 0;
10
10
  const kit_1 = require("@salesforce/kit");
11
11
  const core_1 = require("@oclif/core");
12
12
  /**
13
- * Class that provides a static method to run a well known hook.
13
+ * Class that provides a static method to run a pre-defined sf hook. See {@link SfHooks}.
14
14
  */
15
15
  class SfHook {
16
+ /**
17
+ * Executes a well known Unified CLI hook. See {@link SfHooks}.
18
+ */
16
19
  static async run(config, hookName, options = {}) {
17
- const timeout = kit_1.Duration.milliseconds(kit_1.env.getNumber('SF_HOOK_TIMEOUT_MS') || 5000);
20
+ const timeout = kit_1.Duration.milliseconds(kit_1.env.getNumber('SF_HOOK_TIMEOUT_MS') ?? 5000);
18
21
  const results = await config.runHook(hookName, options, timeout.milliseconds);
19
22
  results.failures.forEach((failure) => {
20
23
  core_1.CliUx.ux.debug(`Failed to run ${hookName} hook for ${failure.plugin.name}`);
@@ -15,49 +15,148 @@ export declare const StandardColors: {
15
15
  success: chalk.Chalk;
16
16
  };
17
17
  /**
18
- * A base command that provides convenient access to CLI help
19
- * output formatting. Extend this command and set specific properties
20
- * to add help sections to the command's help output.
18
+ * A base command that provided common functionality for all sf commands.
19
+ * Functionality includes:
20
+ * - JSON support
21
+ * - progress bars
22
+ * - spinners
23
+ * - prompts
24
+ * - stylized output (JSON, url, objects, headers)
25
+ * - lifecycle events
26
+ * - configuration variables help section
27
+ * - environment variables help section
28
+ * - error codes help section
21
29
  *
22
- * @extends @oclif/core/command
23
- * @see https://github.com/oclif/core/blob/main/src/command.ts
30
+ * All implementations of this class need to implement the run() method.
31
+ *
32
+ * Additionally, all implementations of this class need to provide a generic type that describes the JSON output.
33
+ *
34
+ * See {@link https://github.com/salesforcecli/plugin-template-sf/blob/main/src/commands/hello/world.ts example implementation}.
35
+ *
36
+ * @example
37
+ *
38
+ * ```
39
+ * import { SfCommand } from '@salesforce/sf-plugins-core';
40
+ * export type MyJsonOutput = { success: boolean };
41
+ * export default class MyCommand extends SfCommand<MyJsonOutput> {
42
+ * public async run(): Promise<MyJsonOutput> {
43
+ * return { success: true };
44
+ * }
45
+ * }
46
+ * ```
24
47
  */
25
48
  export declare abstract class SfCommand<T> extends Command {
26
49
  static SF_ENV: string;
27
50
  static enableJsonFlag: boolean;
51
+ /**
52
+ * Add a CONFIGURATION VARIABLES section to the help output.
53
+ *
54
+ * @example
55
+ * ```
56
+ * import { SfCommand, toHelpSection } from '@salesforce/sf-plugins-core';
57
+ * import { OrgConfigProperties } from '@salesforce/core';
58
+ * export default class MyCommand extends SfCommand {
59
+ * public static configurationVariablesSection = toHelpSection(
60
+ * 'CONFIGURATION VARIABLES',
61
+ * OrgConfigProperties.TARGET_ORG,
62
+ * OrgConfigProperties.ORG_API_VERSION,
63
+ * );
64
+ * }
65
+ * ```
66
+ */
28
67
  static configurationVariablesSection?: HelpSection;
68
+ /**
69
+ * Add an Environment VARIABLES section to the help output.
70
+ *
71
+ * @example
72
+ * ```
73
+ * import { SfCommand, toHelpSection } from '@salesforce/sf-plugins-core';
74
+ * import { EnvironmentVariable } from '@salesforce/core';
75
+ * export default class MyCommand extends SfCommand {
76
+ * public static envVariablesSection = toHelpSection(
77
+ * 'ENVIRONMENT VARIABLES',
78
+ * EnvironmentVariable.SF_TARGET_ORG,
79
+ * EnvironmentVariable.SF_USE_PROGRESS_BAR,
80
+ * );
81
+ * }
82
+ * ```
83
+ */
29
84
  static envVariablesSection?: HelpSection;
85
+ /**
86
+ * Add an ERROR CODES section to the help output.
87
+ *
88
+ * @example
89
+ * ```
90
+ * import { SfCommand, toHelpSection } from '@salesforce/sf-plugins-core';
91
+ * export default class MyCommand extends SfCommand {
92
+ * public static errorCodes = toHelpSection(
93
+ * 'ERROR CODES',
94
+ * { 0: 'Success', 1: 'Failure' },
95
+ * );
96
+ * }
97
+ * ```
98
+ */
30
99
  static errorCodes?: HelpSection;
100
+ /**
101
+ * Flags that you can use for manipulating tables.
102
+ *
103
+ * @example
104
+ * ```
105
+ * import { SfCommand } from '@salesforce/sf-plugins-core';
106
+ * export default class MyCommand extends SfCommand {
107
+ * public static flags = {
108
+ * ...SfCommand.tableFags,
109
+ * 'my-flags: flags.string({ char: 'm', description: 'my flag' }),
110
+ * }
111
+ * }
112
+ * ```
113
+ */
31
114
  static tableFlags: typeof CliUx.Table.table.flags;
115
+ /**
116
+ * Set to true if the command must be executed inside a Salesforce project directory.
117
+ *
118
+ * If set to true the command will throw an error if the command is executed outside of a Salesforce project directory.
119
+ * Additionally, this.project will be set to the current Salesforce project (SfProject).
120
+ *
121
+ */
32
122
  static requiresProject: boolean;
123
+ /**
124
+ * Add a spinner to the console. {@link Spinner}
125
+ */
33
126
  spinner: Spinner;
127
+ /**
128
+ * Add a progress bar to the console. {@link Progress}
129
+ */
34
130
  progress: Progress;
35
131
  project: SfProject;
36
132
  private warnings;
37
133
  private ux;
38
134
  private prompter;
39
135
  private lifecycle;
40
- protected get statics(): typeof SfCommand;
41
136
  constructor(argv: string[], config: Config);
137
+ protected get statics(): typeof SfCommand;
42
138
  /**
43
- * Log a success message that has the standard success message color applied
139
+ * Log a success message that has the standard success message color applied.
44
140
  *
45
- * @param message
46
- * @param args
141
+ * @param message The message to log.
47
142
  */
48
143
  logSuccess(message: string): void;
49
144
  /**
50
- * Log warning to users. If --json is enabled, then the warning
51
- * will be added to the json output under the warnings property.
145
+ * Log warning to users. If --json is enabled, then the warning will be added to the json output under the warnings property.
146
+ *
147
+ * @param input {@link SfCommand.Warning} The message to log.
52
148
  */
53
149
  warn(input: SfCommand.Warning): SfCommand.Warning;
54
150
  /**
55
151
  * Log info message to users.
152
+ *
153
+ * @param input {@link SfCommand.Info} The message to log.
56
154
  */
57
155
  info(input: SfCommand.Info): void;
58
156
  /**
59
- * Warn user about sensitive information (access tokens, etc...) before
60
- * logging to the console.
157
+ * Warn user about sensitive information (access tokens, etc...) before logging to the console.
158
+ *
159
+ * @param msg The message to log.
61
160
  */
62
161
  logSensitive(msg?: string): void;
63
162
  /**
@@ -66,18 +165,27 @@ export declare abstract class SfCommand<T> extends Command {
66
165
  table<R extends Ux.Table.Data>(data: R[], columns: Ux.Table.Columns<R>, options?: Ux.Table.Options): void;
67
166
  /**
68
167
  * Log a stylized url to the console. Will automatically be suppressed when --json flag is present.
168
+ *
169
+ * @param text The text to display for the url.
170
+ * @param uri The url to display.
69
171
  */
70
172
  url(text: string, uri: string, params?: {}): void;
71
173
  /**
72
174
  * Log stylized JSON to the console. Will automatically be suppressed when --json flag is present.
175
+ *
176
+ * @param obj The JSON to log.
73
177
  */
74
178
  styledJSON(obj: AnyJson): void;
75
179
  /**
76
180
  * Log stylized object to the console. Will automatically be suppressed when --json flag is present.
181
+ *
182
+ * @param obj The object to log.
77
183
  */
78
184
  styledObject(obj: AnyJson): void;
79
185
  /**
80
186
  * Log stylized header to the console. Will automatically be suppressed when --json flag is present.
187
+ *
188
+ * @param text the text to display as a header.
81
189
  */
82
190
  styledHeader(text: string): void;
83
191
  /**
@@ -93,9 +201,9 @@ export declare abstract class SfCommand<T> extends Command {
93
201
  * await this.prompt();
94
202
  * }
95
203
  */
96
- prompt<R = Prompter.Answers>(questions: Prompter.Questions<R>, initialAnswers?: Partial<R>): Promise<R>;
204
+ prompt<R extends Prompter.Answers>(questions: Prompter.Questions<R>, initialAnswers?: Partial<R>): Promise<R>;
97
205
  /**
98
- * Simplified prompt for single-question confirmation. Times out and throws after 10s
206
+ * Simplified prompt for single-question confirmation. Times out and throws after 10s
99
207
  *
100
208
  * @param message text to display. Do not include a question mark.
101
209
  * @param ms milliseconds to wait for user input. Defaults to 10s.
@@ -105,7 +213,7 @@ export declare abstract class SfCommand<T> extends Command {
105
213
  /**
106
214
  * Prompt user for information with a timeout (in milliseconds). See https://www.npmjs.com/package/inquirer for more.
107
215
  */
108
- timedPrompt<R = Prompter.Answers>(questions: Prompter.Questions<R>, ms?: number, initialAnswers?: Partial<R>): Promise<R>;
216
+ timedPrompt<R extends Prompter.Answers>(questions: Prompter.Questions<R>, ms?: number, initialAnswers?: Partial<R>): Promise<R>;
109
217
  _run<R>(): Promise<R | undefined>;
110
218
  /**
111
219
  * Wrap the command result into the standardized JSON structure.
package/lib/sfCommand.js CHANGED
@@ -21,12 +21,35 @@ exports.StandardColors = {
21
21
  success: chalk.bold.green,
22
22
  };
23
23
  /**
24
- * A base command that provides convenient access to CLI help
25
- * output formatting. Extend this command and set specific properties
26
- * to add help sections to the command's help output.
24
+ * A base command that provided common functionality for all sf commands.
25
+ * Functionality includes:
26
+ * - JSON support
27
+ * - progress bars
28
+ * - spinners
29
+ * - prompts
30
+ * - stylized output (JSON, url, objects, headers)
31
+ * - lifecycle events
32
+ * - configuration variables help section
33
+ * - environment variables help section
34
+ * - error codes help section
27
35
  *
28
- * @extends @oclif/core/command
29
- * @see https://github.com/oclif/core/blob/main/src/command.ts
36
+ * All implementations of this class need to implement the run() method.
37
+ *
38
+ * Additionally, all implementations of this class need to provide a generic type that describes the JSON output.
39
+ *
40
+ * See {@link https://github.com/salesforcecli/plugin-template-sf/blob/main/src/commands/hello/world.ts example implementation}.
41
+ *
42
+ * @example
43
+ *
44
+ * ```
45
+ * import { SfCommand } from '@salesforce/sf-plugins-core';
46
+ * export type MyJsonOutput = { success: boolean };
47
+ * export default class MyCommand extends SfCommand<MyJsonOutput> {
48
+ * public async run(): Promise<MyJsonOutput> {
49
+ * return { success: true };
50
+ * }
51
+ * }
52
+ * ```
30
53
  */
31
54
  class SfCommand extends core_1.Command {
32
55
  constructor(argv, config) {
@@ -43,40 +66,43 @@ class SfCommand extends core_1.Command {
43
66
  return this.constructor;
44
67
  }
45
68
  /**
46
- * Log a success message that has the standard success message color applied
69
+ * Log a success message that has the standard success message color applied.
47
70
  *
48
- * @param message
49
- * @param args
71
+ * @param message The message to log.
50
72
  */
51
73
  logSuccess(message) {
52
74
  this.log(exports.StandardColors.success(message));
53
75
  }
54
76
  /**
55
- * Log warning to users. If --json is enabled, then the warning
56
- * will be added to the json output under the warnings property.
77
+ * Log warning to users. If --json is enabled, then the warning will be added to the json output under the warnings property.
78
+ *
79
+ * @param input {@link SfCommand.Warning} The message to log.
57
80
  */
58
81
  warn(input) {
59
82
  const colorizedArgs = [];
60
83
  this.warnings.push(input);
61
84
  const message = typeof input === 'string' ? input : input.message;
62
85
  colorizedArgs.push(`${exports.StandardColors.warning(messages.getMessage('warning.prefix'))} ${message}`);
63
- colorizedArgs.push(...this.formatActions(typeof input === 'string' ? [] : input.actions || [], { actionColor: exports.StandardColors.info }));
86
+ colorizedArgs.push(...this.formatActions(typeof input === 'string' ? [] : input.actions ?? [], { actionColor: exports.StandardColors.info }));
64
87
  this.log(colorizedArgs.join(os.EOL));
65
88
  return input;
66
89
  }
67
90
  /**
68
91
  * Log info message to users.
92
+ *
93
+ * @param input {@link SfCommand.Info} The message to log.
69
94
  */
70
95
  info(input) {
71
96
  const colorizedArgs = [];
72
97
  const message = typeof input === 'string' ? input : input.message;
73
98
  colorizedArgs.push(`${exports.StandardColors.info(message)}`);
74
- colorizedArgs.push(...this.formatActions(typeof input === 'string' ? [] : input.actions || [], { actionColor: exports.StandardColors.info }));
99
+ colorizedArgs.push(...this.formatActions(typeof input === 'string' ? [] : input.actions ?? [], { actionColor: exports.StandardColors.info }));
75
100
  this.log(colorizedArgs.join(os.EOL));
76
101
  }
77
102
  /**
78
- * Warn user about sensitive information (access tokens, etc...) before
79
- * logging to the console.
103
+ * Warn user about sensitive information (access tokens, etc...) before logging to the console.
104
+ *
105
+ * @param msg The message to log.
80
106
  */
81
107
  logSensitive(msg) {
82
108
  this.warn(messages.getMessage('warning.security'));
@@ -90,24 +116,33 @@ class SfCommand extends core_1.Command {
90
116
  }
91
117
  /**
92
118
  * Log a stylized url to the console. Will automatically be suppressed when --json flag is present.
119
+ *
120
+ * @param text The text to display for the url.
121
+ * @param uri The url to display.
93
122
  */
94
123
  url(text, uri, params = {}) {
95
124
  this.ux.url(text, uri, params);
96
125
  }
97
126
  /**
98
127
  * Log stylized JSON to the console. Will automatically be suppressed when --json flag is present.
128
+ *
129
+ * @param obj The JSON to log.
99
130
  */
100
131
  styledJSON(obj) {
101
132
  this.ux.styledJSON(obj);
102
133
  }
103
134
  /**
104
135
  * Log stylized object to the console. Will automatically be suppressed when --json flag is present.
136
+ *
137
+ * @param obj The object to log.
105
138
  */
106
139
  styledObject(obj) {
107
140
  this.ux.styledObject(obj);
108
141
  }
109
142
  /**
110
143
  * Log stylized header to the console. Will automatically be suppressed when --json flag is present.
144
+ *
145
+ * @param text the text to display as a header.
111
146
  */
112
147
  styledHeader(text) {
113
148
  this.ux.styledHeader(text);
@@ -129,7 +164,7 @@ class SfCommand extends core_1.Command {
129
164
  return this.prompter.prompt(questions, initialAnswers);
130
165
  }
131
166
  /**
132
- * Simplified prompt for single-question confirmation. Times out and throws after 10s
167
+ * Simplified prompt for single-question confirmation. Times out and throws after 10s
133
168
  *
134
169
  * @param message text to display. Do not include a question mark.
135
170
  * @param ms milliseconds to wait for user input. Defaults to 10s.
@@ -167,9 +202,8 @@ class SfCommand extends core_1.Command {
167
202
  * Wrap the command result into the standardized JSON structure.
168
203
  */
169
204
  toSuccessJson(result) {
170
- var _a;
171
205
  return {
172
- status: (_a = process.exitCode) !== null && _a !== void 0 ? _a : 0,
206
+ status: process.exitCode ?? 0,
173
207
  result,
174
208
  warnings: this.warnings,
175
209
  };
@@ -183,6 +217,7 @@ class SfCommand extends core_1.Command {
183
217
  warnings: this.warnings,
184
218
  };
185
219
  }
220
+ // eslint-disable-next-line class-methods-use-this
186
221
  async assignProject() {
187
222
  try {
188
223
  return await core_2.SfProject.resolve();
@@ -195,10 +230,9 @@ class SfCommand extends core_1.Command {
195
230
  }
196
231
  }
197
232
  async catch(error) {
198
- var _a, _b;
199
233
  // transform an unknown error into one that conforms to the interface
200
234
  const codeFromError = error instanceof core_2.SfError ? error.exitCode : 1;
201
- (_a = process.exitCode) !== null && _a !== void 0 ? _a : (process.exitCode = codeFromError);
235
+ process.exitCode ?? (process.exitCode = codeFromError);
202
236
  const sfErrorProperties = error instanceof core_2.SfError
203
237
  ? { data: error.data, actions: error.actions, code: codeFromError, context: error.context }
204
238
  : {};
@@ -206,7 +240,7 @@ class SfCommand extends core_1.Command {
206
240
  ...sfErrorProperties,
207
241
  ...{
208
242
  message: error.message,
209
- name: (_b = error.name) !== null && _b !== void 0 ? _b : 'Error',
243
+ name: error.name ?? 'Error',
210
244
  status: process.exitCode,
211
245
  stack: error.stack,
212
246
  exitCode: process.exitCode,
@@ -234,7 +268,7 @@ class SfCommand extends core_1.Command {
234
268
  const errorCode = error.code ? ` (${error.code})` : '';
235
269
  const errorPrefix = `${exports.StandardColors.error(messages.getMessage('error.prefix', [errorCode]))}`;
236
270
  colorizedArgs.push(`${errorPrefix} ${error.message}`);
237
- colorizedArgs.push(...this.formatActions(error.actions || []));
271
+ colorizedArgs.push(...this.formatActions(error.actions ?? []));
238
272
  if (error.stack && core_2.envVars.getString(SfCommand.SF_ENV) === core_2.Mode.DEVELOPMENT) {
239
273
  colorizedArgs.push(exports.StandardColors.info(`\n*** Internal Diagnostic ***\n\n${error.stack}\n******\n`));
240
274
  }
@@ -247,10 +281,11 @@ class SfCommand extends core_1.Command {
247
281
  * @param options
248
282
  * @private
249
283
  */
284
+ // eslint-disable-next-line class-methods-use-this
250
285
  formatActions(actions, options = { actionColor: exports.StandardColors.info }) {
251
286
  const colorizedArgs = [];
252
287
  // Format any actions.
253
- if (actions === null || actions === void 0 ? void 0 : actions.length) {
288
+ if (actions?.length) {
254
289
  colorizedArgs.push(`\n${exports.StandardColors.info(messages.getMessage('actions.tryThis'))}\n`);
255
290
  actions.forEach((action) => {
256
291
  colorizedArgs.push(`${options.actionColor(action)}`);
@@ -262,5 +297,19 @@ class SfCommand extends core_1.Command {
262
297
  exports.SfCommand = SfCommand;
263
298
  SfCommand.SF_ENV = 'SF_ENV';
264
299
  SfCommand.enableJsonFlag = true;
300
+ /**
301
+ * Flags that you can use for manipulating tables.
302
+ *
303
+ * @example
304
+ * ```
305
+ * import { SfCommand } from '@salesforce/sf-plugins-core';
306
+ * export default class MyCommand extends SfCommand {
307
+ * public static flags = {
308
+ * ...SfCommand.tableFags,
309
+ * 'my-flags: flags.string({ char: 'm', description: 'my flag' }),
310
+ * }
311
+ * }
312
+ * ```
313
+ */
265
314
  SfCommand.tableFlags = core_1.CliUx.ux.table.flags;
266
315
  //# sourceMappingURL=sfCommand.js.map
@@ -9,13 +9,18 @@ export declare type JsonObject = {
9
9
  * you can specify how a key should be displayed to the user.
10
10
  *
11
11
  * @example
12
+ *
13
+ * ```
12
14
  * { data: { theURL: 'https://example.com' } }
13
15
  * // Renders as:
14
16
  * Key Value
15
17
  * ------- -------------------
16
18
  * The URL https://example.com
19
+ * ```
17
20
  *
18
21
  * @example
22
+ *
23
+ * ```
19
24
  * {
20
25
  * data: { theURL: 'https://example.com' }
21
26
  * keys: { theURL: 'Url' },
@@ -24,11 +29,13 @@ export declare type JsonObject = {
24
29
  * Key Value
25
30
  * --- -------------------
26
31
  * Url https://example.com
27
- *
32
+ *```
28
33
  * If no environment matches the provided targetEnv, then return null in the data field.
29
34
  *
30
35
  * @example
36
+ * ```
31
37
  * { data: null }
38
+ * ```
32
39
  */
33
40
  export declare namespace EnvDisplay {
34
41
  type Keys<T> = Record<keyof T, string>;
@@ -50,6 +57,8 @@ export declare namespace EnvDisplay {
50
57
  * the `keys` property.
51
58
  *
52
59
  * @example
60
+ *
61
+ * ```
53
62
  * {
54
63
  * title: 'My Envs',
55
64
  * data: [{ username: 'foo', theURL: 'https://example.com' }]
@@ -59,8 +68,11 @@ export declare namespace EnvDisplay {
59
68
  * ================================
60
69
  * | Username | The URL
61
70
  * | foo | https://example.com
71
+ *```
62
72
  *
63
73
  * @example
74
+ *
75
+ * ```
64
76
  * {
65
77
  * data: [{ username: 'foo', theURL: 'https://example.com' }]
66
78
  * keys: { theURL: 'Url', username: 'Name' },
@@ -71,6 +83,8 @@ export declare namespace EnvDisplay {
71
83
  * ============================
72
84
  * | Name | Url
73
85
  * | foo | https://example.com
86
+ *
87
+ *```
74
88
  */
75
89
  export declare namespace EnvList {
76
90
  export enum EnvType {
@@ -14,6 +14,8 @@ exports.EnvList = void 0;
14
14
  * the `keys` property.
15
15
  *
16
16
  * @example
17
+ *
18
+ * ```
17
19
  * {
18
20
  * title: 'My Envs',
19
21
  * data: [{ username: 'foo', theURL: 'https://example.com' }]
@@ -23,8 +25,11 @@ exports.EnvList = void 0;
23
25
  * ================================
24
26
  * | Username | The URL
25
27
  * | foo | https://example.com
28
+ *```
26
29
  *
27
30
  * @example
31
+ *
32
+ * ```
28
33
  * {
29
34
  * data: [{ username: 'foo', theURL: 'https://example.com' }]
30
35
  * keys: { theURL: 'Url', username: 'Name' },
@@ -35,6 +40,8 @@ exports.EnvList = void 0;
35
40
  * ============================
36
41
  * | Name | Url
37
42
  * | foo | https://example.com
43
+ *
44
+ *```
38
45
  */
39
46
  var EnvList;
40
47
  (function (EnvList) {
package/lib/util.d.ts CHANGED
@@ -16,4 +16,5 @@ export declare type HelpSection = {
16
16
  * @param vars
17
17
  */
18
18
  export declare function toHelpSection(header: string, ...vars: Array<OrgConfigProperties | SfdxPropertyKeys | EnvironmentVariable | string | Record<string, string>>): HelpSection;
19
+ export declare function parseVarArgs(args: Record<string, unknown>, argv: string[]): Record<string, unknown>;
19
20
  //# sourceMappingURL=util.d.ts.map
package/lib/util.js CHANGED
@@ -6,8 +6,10 @@
6
6
  * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
7
7
  */
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
- exports.toHelpSection = void 0;
9
+ exports.parseVarArgs = exports.toHelpSection = void 0;
10
10
  const core_1 = require("@salesforce/core");
11
+ core_1.Messages.importMessagesDirectory(__dirname);
12
+ const messages = core_1.Messages.loadMessages('@salesforce/sf-plugins-core', 'messages');
11
13
  /**
12
14
  * Function to build a help section for command help.
13
15
  * Takes a string to be used as section header text and an array of enums
@@ -21,9 +23,7 @@ function toHelpSection(header, ...vars) {
21
23
  const body = vars
22
24
  .flatMap((v) => {
23
25
  if (typeof v === 'string') {
24
- const orgConfig = core_1.ORG_CONFIG_ALLOWED_PROPERTIES.find(({ key }) => {
25
- return key === v;
26
- });
26
+ const orgConfig = core_1.ORG_CONFIG_ALLOWED_PROPERTIES.find(({ key }) => key === v);
27
27
  if (orgConfig) {
28
28
  return { name: orgConfig.key, description: orgConfig.description };
29
29
  }
@@ -46,4 +46,28 @@ function toHelpSection(header, ...vars) {
46
46
  return { header, body };
47
47
  }
48
48
  exports.toHelpSection = toHelpSection;
49
+ function parseVarArgs(args, argv) {
50
+ const final = {};
51
+ const argVals = Object.values(args);
52
+ // Remove arguments from varargs
53
+ const varargs = argv.filter((val) => !argVals.includes(val));
54
+ // Support `config set key value`
55
+ if (varargs.length === 2 && !varargs[0].includes('=')) {
56
+ return { [varargs[0]]: varargs[1] };
57
+ }
58
+ // Ensure that all args are in the right format (e.g. key=value key1=value1)
59
+ varargs.forEach((arg) => {
60
+ const split = arg.split('=');
61
+ if (split.length !== 2) {
62
+ throw messages.createError('error.InvalidArgumentFormat', [arg]);
63
+ }
64
+ const [name, value] = split;
65
+ if (final[name]) {
66
+ throw messages.createError('error.DuplicateArgument', [name]);
67
+ }
68
+ final[name] = value || undefined;
69
+ });
70
+ return final;
71
+ }
72
+ exports.parseVarArgs = parseVarArgs;
49
73
  //# sourceMappingURL=util.js.map
@@ -4,24 +4,27 @@ export declare class Prompter {
4
4
  /**
5
5
  * Prompt user for information. See https://www.npmjs.com/package/inquirer for more.
6
6
  */
7
- prompt<T = Prompter.Answers>(questions: Prompter.Questions<T>, initialAnswers?: Partial<T>): Promise<T>;
7
+ prompt<T extends Prompter.Answers>(questions: Prompter.Questions<T>, initialAnswers?: Partial<T>): Promise<T>;
8
8
  /**
9
9
  * Prompt user for information with a timeout (in milliseconds). See https://www.npmjs.com/package/inquirer for more.
10
10
  */
11
- timedPrompt<T = Prompter.Answers>(questions: Prompter.Questions<T>, ms?: number, initialAnswers?: Partial<T>): Promise<T>;
11
+ timedPrompt<T extends Prompter.Answers>(questions: Prompter.Questions<T>, ms?: number, initialAnswers?: Partial<T>): Promise<T>;
12
12
  }
13
13
  export declare namespace Prompter {
14
14
  type Answers<T = Record<string, unknown>> = T & Record<string, unknown>;
15
- type Questions<T> = QuestionCollection<T>;
15
+ type Questions<T extends Answers> = QuestionCollection<T>;
16
16
  }
17
17
  /**
18
18
  * Generate a formatted table for list and checkbox prompts
19
19
  *
20
20
  * Each option should contain the same keys as specified in columns.
21
- * For example,
21
+ *
22
+ * @example
23
+ * ```
22
24
  * const columns = { name: 'Name', type: 'Type', path: 'Path' };
23
25
  * const options = [{ name: 'foo', type: 'org', path: '/path/to/foo/' }];
24
26
  * generateTableChoices(columns, options);
27
+ * ```
25
28
  */
26
29
  export declare function generateTableChoices<T>(columns: Dictionary<string>, choices: Array<Dictionary<Nullable<string> | T>>, padForCheckbox?: boolean): ChoiceBase[];
27
30
  //# sourceMappingURL=prompter.d.ts.map
@@ -14,6 +14,7 @@ class Prompter {
14
14
  /**
15
15
  * Prompt user for information. See https://www.npmjs.com/package/inquirer for more.
16
16
  */
17
+ // eslint-disable-next-line class-methods-use-this
17
18
  async prompt(questions, initialAnswers) {
18
19
  const answers = await (0, inquirer_1.prompt)(questions, initialAnswers);
19
20
  return answers;
@@ -21,6 +22,7 @@ class Prompter {
21
22
  /**
22
23
  * Prompt user for information with a timeout (in milliseconds). See https://www.npmjs.com/package/inquirer for more.
23
24
  */
25
+ // eslint-disable-next-line class-methods-use-this
24
26
  async timedPrompt(questions, ms = 10000, initialAnswers) {
25
27
  let id;
26
28
  const thePrompt = (0, inquirer_1.prompt)(questions, initialAnswers);
@@ -45,10 +47,13 @@ exports.Prompter = Prompter;
45
47
  * Generate a formatted table for list and checkbox prompts
46
48
  *
47
49
  * Each option should contain the same keys as specified in columns.
48
- * For example,
50
+ *
51
+ * @example
52
+ * ```
49
53
  * const columns = { name: 'Name', type: 'Type', path: 'Path' };
50
54
  * const options = [{ name: 'foo', type: 'org', path: '/path/to/foo/' }];
51
55
  * generateTableChoices(columns, options);
56
+ * ```
52
57
  */
53
58
  function generateTableChoices(columns, choices,
54
59
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
@@ -58,7 +63,7 @@ padForCheckbox = true) {
58
63
  .length)) + 1);
59
64
  const choicesOptions = [
60
65
  new inquirer_1.Separator(`${padForCheckbox ? ' '.repeat(2) : ''}${columnEntries
61
- .map(([, value], index) => value === null || value === void 0 ? void 0 : value.padEnd(columnLengths[index], ' '))
66
+ .map(([, value], index) => value?.padEnd(columnLengths[index], ' '))
62
67
  .join('')}`),
63
68
  ];
64
69
  for (const meta of choices) {
@@ -5,6 +5,14 @@ import { UxBase } from '.';
5
5
  */
6
6
  export declare class Spinner extends UxBase {
7
7
  constructor(outputEnabled: boolean);
8
+ /**
9
+ * Get the status of the current spinner.
10
+ */
11
+ get status(): string | undefined;
12
+ /**
13
+ * Set the status of the current spinner.
14
+ */
15
+ set status(status: string | undefined);
8
16
  /**
9
17
  * Start a spinner on the console.
10
18
  */
@@ -15,14 +23,6 @@ export declare class Spinner extends UxBase {
15
23
  * Stop the spinner on the console.
16
24
  */
17
25
  stop(msg?: string): void;
18
- /**
19
- * Set the status of the current spinner.
20
- */
21
- set status(status: string | undefined);
22
- /**
23
- * Get the status of the current spinner.
24
- */
25
- get status(): string | undefined;
26
26
  /**
27
27
  * Pause the spinner on the console.
28
28
  */
package/lib/ux/spinner.js CHANGED
@@ -18,28 +18,30 @@ class Spinner extends _1.UxBase {
18
18
  super(outputEnabled);
19
19
  }
20
20
  /**
21
- * Start a spinner on the console.
22
- */
23
- start(action, status, opts) {
24
- this.maybeNoop(() => core_1.CliUx.ux.action.start(action, status, opts));
25
- }
26
- /**
27
- * Stop the spinner on the console.
21
+ * Get the status of the current spinner.
28
22
  */
29
- stop(msg) {
30
- this.maybeNoop(() => core_1.CliUx.ux.action.stop(msg));
23
+ // eslint-disable-next-line class-methods-use-this
24
+ get status() {
25
+ return core_1.CliUx.ux.action.status;
31
26
  }
32
27
  /**
33
28
  * Set the status of the current spinner.
34
29
  */
30
+ // eslint-disable-next-line class-methods-use-this
35
31
  set status(status) {
36
32
  core_1.CliUx.ux.action.status = status;
37
33
  }
38
34
  /**
39
- * Get the status of the current spinner.
35
+ * Start a spinner on the console.
40
36
  */
41
- get status() {
42
- return core_1.CliUx.ux.action.status;
37
+ start(action, status, opts) {
38
+ this.maybeNoop(() => core_1.CliUx.ux.action.start(action, status, opts));
39
+ }
40
+ /**
41
+ * Stop the spinner on the console.
42
+ */
43
+ stop(msg) {
44
+ this.maybeNoop(() => core_1.CliUx.ux.action.stop(msg));
43
45
  }
44
46
  /**
45
47
  * Pause the spinner on the console.
@@ -73,3 +73,11 @@ Try this:
73
73
  # warning.CommandInBeta
74
74
 
75
75
  This command is currently in beta. Any aspect of this command can change without advanced notice. Don't use beta commands in your scripts.
76
+
77
+ # error.InvalidArgumentFormat
78
+
79
+ Set varargs with this format: key=value or key="value with spaces".
80
+
81
+ # error.DuplicateArgument
82
+
83
+ Found duplicate argument %s.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salesforce/sf-plugins-core",
3
- "version": "1.14.0",
3
+ "version": "1.15.0",
4
4
  "description": "Utils for writing deploy and retrieve plugins",
5
5
  "main": "lib/exported",
6
6
  "types": "lib/exported.d.ts",
@@ -32,44 +32,43 @@
32
32
  "/messages"
33
33
  ],
34
34
  "dependencies": {
35
- "@oclif/core": "^1.15.0",
36
- "@salesforce/core": "^3.25.0",
35
+ "@oclif/core": "^1.16.4",
36
+ "@salesforce/core": "^3.30.9",
37
37
  "@salesforce/kit": "^1.5.44",
38
38
  "@salesforce/ts-types": "^1.5.20",
39
39
  "chalk": "^4",
40
- "inquirer": "^8.2.0"
40
+ "inquirer": "^8.2.3"
41
41
  },
42
42
  "devDependencies": {
43
43
  "@oclif/test": "^2.1.0",
44
- "@salesforce/dev-config": "^2.1.3",
45
- "@salesforce/dev-scripts": "^1.0.4",
44
+ "@salesforce/dev-config": "^3.0.0",
45
+ "@salesforce/dev-scripts": "^3.1.0",
46
46
  "@salesforce/prettier-config": "^0.0.2",
47
47
  "@salesforce/ts-sinon": "^1.3.21",
48
- "@types/inquirer": "^8.2.0",
49
- "@typescript-eslint/eslint-plugin": "^4.33.0",
50
- "@typescript-eslint/parser": "^4.33.0",
48
+ "@types/inquirer": "^8.2.3",
49
+ "@typescript-eslint/eslint-plugin": "^5.33.0",
50
+ "@typescript-eslint/parser": "^5.33.0",
51
51
  "chai": "^4.3.6",
52
- "eslint": "^7.32.0",
53
- "eslint-config-prettier": "^6.15.0",
54
- "eslint-config-salesforce": "^0.1.6",
52
+ "eslint": "^8.21.0",
53
+ "eslint-config-prettier": "^8.5.0",
54
+ "eslint-config-salesforce": "^1.1.0",
55
55
  "eslint-config-salesforce-license": "^0.1.6",
56
- "eslint-config-salesforce-typescript": "^0.2.8",
56
+ "eslint-config-salesforce-typescript": "^1.1.1",
57
57
  "eslint-plugin-header": "^3.1.1",
58
- "eslint-plugin-import": "^2.25.4",
59
- "eslint-plugin-jsdoc": "^35.1.2",
60
- "eslint-plugin-prettier": "^3.4.1",
58
+ "eslint-plugin-import": "^2.26.0",
59
+ "eslint-plugin-jsdoc": "^39.3.6",
61
60
  "husky": "^7.0.4",
62
- "mocha": "^8.4.0",
61
+ "mocha": "^9.1.3",
63
62
  "nyc": "^15.1.0",
64
- "prettier": "^2.5.1",
63
+ "prettier": "^2.7.1",
65
64
  "pretty-quick": "^3.1.3",
66
65
  "shelljs": "0.8.5",
67
66
  "sinon": "10.0.1",
68
67
  "strip-ansi": "6.0.1",
69
68
  "ts-node": "^10.7.0",
70
- "typescript": "^4.5.5"
69
+ "typescript": "^4.8.4"
71
70
  },
72
71
  "publishConfig": {
73
72
  "access": "public"
74
73
  }
75
- }
74
+ }